Package fi.tut.mei.resdescapi.rdapi
Class RD_API
- java.lang.Object
-
- fi.tut.mei.resdescapi.rdapi.RD_API
-
public class RD_API extends Object
Resource Description (RD) API for processing such resources.- Author:
- Niko Siltala
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RD_API.EnumIfCategory
Enumeration for interface Categories.static class
RD_API.EnumPrefix
Enumeration for id prefixes.
-
Field Summary
Fields Modifier and Type Field Description static String
ID_SEPARATOR
Separator used to separate sections within the IDstatic String
RD_FILE_TYPE
File type (ending) used for Resource description Files
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Document
convertRDObjToDOM(ResourceDescription rdObj)
Converts Resource Description (RD) from Java Objects format to DOM document.String
convertRDObjToString(ResourceDescription rdObj)
Converts Resource Description (RD) from Java Objects format to String.String
createDocFromRD_HTML(ResourceDescription rdObj)
Creates XHTML formatted documentation out of an RD objectvoid
getCapabilitiesAsBPOntoModelFromRD(fi.tut.mei.capabilityQueryLib.Client capaOntoModel, ResourceDescription rdObj)
Gets the capabilities (in ontology format) from the RD and creates/puts them into Resource Model ontology as instances.fi.tut.mei.capabilityQueryLib.Client
getCapabilitiesAsBPOntoModelFromRD(ResourceDescription rdObj)
Creates a new Resource Model Ontology.void
getCapabilitiesAsBPOntoModelFromResource(fi.tut.mei.capabilityQueryLib.Client capaOntoModel, ResourceCT resourceObj)
Gets the capabilities (in ontology format) from the RD's Resource and creates/puts them into Resource Model ontology as instances.protected Document
getCapabilitiesOntoAsXMLNodeFromOntoClient(fi.tut.mei.capabilityQueryLib.Client capaOntoModel)
String
getUniqueNameOfResource(ResourceCT resourceObj)
Gets unique name of a resourceString
makeTransform(ResourceDescription rdObj, String transformLocation)
Executes a XSLT Transformation for ARD objectprotected void
putCapabilitiesOntoToRDModel(fi.tut.mei.capabilityQueryLib.Client capaOntoModel, ResourceDescription toRdObj)
Puts the content of a Resource Model (instance) ontology, inside the given Resource Description.void
putCapabilitiesOntoToRDModel(fi.tut.mei.capabilityQueryLib.model.Blueprint blueprint, ResourceDescription toRdObj)
Puts the content of a Blueprint, which is defined in Resource Model (instance) ontology, inside the given Resource Description (RD).ResourceDescription
readRDInFromLocation(String fileLocation)
Reads in Resource Description file (XML format) and builds the Java binding (JAXB) objects of it.ResourceDescription
readRDInFromString(InputStream rdInXML_inputStream)
Reads in Resource Description as argument content (InputStream, String as XML format) and builds the Java binding (JAXB) objects.ResourceDescription
readRDInFromString(String rdInXML)
Reads in Resource Description as argument content(XML format) and builds the Java binding (JAXB) objects.boolean
saveRDToLocation(ResourceDescription rdObj, String fileLocation)
Saves given RD object data into file.
-
-
-
Field Detail
-
ID_SEPARATOR
public static final String ID_SEPARATOR
Separator used to separate sections within the ID- See Also:
- Constant Field Values
-
RD_FILE_TYPE
public static final String RD_FILE_TYPE
File type (ending) used for Resource description Files- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RD_API
public RD_API()
Default constructor
-
RD_API
public RD_API(String configFileName)
Constructor with explicit configuration file.- Parameters:
configFileName
- path and filename for configuration file for RD_API
-
-
Method Detail
-
readRDInFromLocation
public ResourceDescription readRDInFromLocation(String fileLocation) throws SAXException, JAXBException, IOException, Exception
Reads in Resource Description file (XML format) and builds the Java binding (JAXB) objects of it.- Parameters:
fileLocation
- Location of the file (in local file system, network drive or web location).- Returns:
- ResourceDescription Root object for the read structure
- Throws:
SAXException
JAXBException
IOException
Exception
-
readRDInFromString
public ResourceDescription readRDInFromString(InputStream rdInXML_inputStream) throws JAXBException, Exception
Reads in Resource Description as argument content (InputStream, String as XML format) and builds the Java binding (JAXB) objects.- Parameters:
rdInXML_inputStream
- RD's content as InputStream and content in XML format- Returns:
- ResourceDescription Root object for the read structure
- Throws:
JAXBException
Exception
-
readRDInFromString
public ResourceDescription readRDInFromString(String rdInXML) throws JAXBException, Exception
Reads in Resource Description as argument content(XML format) and builds the Java binding (JAXB) objects. Stores object structure locally.- Parameters:
rdInXML
- RD's content in XML format- Returns:
- ResourceDescription Root object for the read structure
- Throws:
Exception
JAXBException
-
saveRDToLocation
public boolean saveRDToLocation(ResourceDescription rdObj, String fileLocation) throws Exception
Saves given RD object data into file.- Parameters:
rd
- Resource Description as object modelfileLocation
- Location of the file where data is to be stored.- Returns:
- true if saving succeeds
- Throws:
Exception
-
convertRDObjToString
public String convertRDObjToString(ResourceDescription rdObj) throws JAXBException, Exception
Converts Resource Description (RD) from Java Objects format to String.- Parameters:
rdObj
- Resource Description (RD)- Returns:
- RD contents as String
- Throws:
JAXBException
Exception
-
convertRDObjToDOM
public Document convertRDObjToDOM(ResourceDescription rdObj) throws JAXBException, Exception
Converts Resource Description (RD) from Java Objects format to DOM document.- Parameters:
rdObj
- Resource Description (RD)- Returns:
- RD contents as DOM document
- Throws:
JAXBException
Exception
-
makeTransform
public String makeTransform(ResourceDescription rdObj, String transformLocation) throws NullPointerException, IOException, Exception
Executes a XSLT Transformation for ARD object- Parameters:
ardObj
- ARD Object to be processedtransformLocation
- Location of XLST to be used for transformation. Can be URL or file location.- Returns:
- Transformation result
- Throws:
NullPointerException
- null values have been given as argumentsIOException
- Something has failed in IO systemException
- Some generic exception has occurred
-
createDocFromRD_HTML
public String createDocFromRD_HTML(ResourceDescription rdObj) throws NullPointerException, IOException, Exception
Creates XHTML formatted documentation out of an RD object- Parameters:
rdObj
- RD Object to be processed- Returns:
- XHTML formatted documentation
- Throws:
NullPointerException
- null values have been given as argumentsIOException
- Something has failed in IO systemException
- Some generic exception has occurred
-
getCapabilitiesAsBPOntoModelFromRD
public fi.tut.mei.capabilityQueryLib.Client getCapabilitiesAsBPOntoModelFromRD(ResourceDescription rdObj) throws Exception
Creates a new Resource Model Ontology. After this it gets the capabilities (in ontology format) from the RD and creates/puts them into just created Resource Model ontology as instances.- Parameters:
rdObj
-- Returns:
- new Ontology Client containing the resources capabilities
- Throws:
Exception
-
getCapabilitiesAsBPOntoModelFromRD
public void getCapabilitiesAsBPOntoModelFromRD(fi.tut.mei.capabilityQueryLib.Client capaOntoModel, ResourceDescription rdObj) throws Exception
Gets the capabilities (in ontology format) from the RD and creates/puts them into Resource Model ontology as instances. This limits to the first Resource of this RD. A new blueprint is created into the model and it is populated with the capabilities. The name of the Blueprint is at the same time updated to correspond the Resource's unique name. NOTE: Existing ontology content will be cleared when calling this method!- Parameters:
capaOntoModel
- Resource Model Ontology, where the capabilites from RD are read to. NOTE: Existing ontology content will be cleared!rdObj
- RD object, from which its capabilities (in ontology format) are read from- Throws:
Exception
-
getCapabilitiesAsBPOntoModelFromResource
public void getCapabilitiesAsBPOntoModelFromResource(fi.tut.mei.capabilityQueryLib.Client capaOntoModel, ResourceCT resourceObj) throws Exception
Gets the capabilities (in ontology format) from the RD's Resource and creates/puts them into Resource Model ontology as instances. A new blueprint is created into the model and it is populated with the capabilities. The name of the Blueprint is at the same time updated to correspond the Resource's unique name. NOTE: Existing ontology content will be cleared when calling this method!- Parameters:
capaOntoModel
- Resource Model Ontology, where the capabilites from given RD's Resource are read to. NOTE: Existing ontology content will be cleared!resourceObj
- RD's Resource object, from which its capabilities (in ontology format) are read from- Throws:
Exception
-
getUniqueNameOfResource
public String getUniqueNameOfResource(ResourceCT resourceObj)
Gets unique name of a resource- Parameters:
resourceObj
-- Returns:
- unique name
-
putCapabilitiesOntoToRDModel
public void putCapabilitiesOntoToRDModel(fi.tut.mei.capabilityQueryLib.model.Blueprint blueprint, ResourceDescription toRdObj) throws Exception
Puts the content of a Blueprint, which is defined in Resource Model (instance) ontology, inside the given Resource Description (RD). This creates or overwrites the capability content in the ontology format inside the RD.- Parameters:
blueprint
- Blueprint in the ontology format, which is defined in Resource Model (instance) ontology.toRdObj
- Resource Description where the data is placed.- Throws:
Exception
-
putCapabilitiesOntoToRDModel
protected void putCapabilitiesOntoToRDModel(fi.tut.mei.capabilityQueryLib.Client capaOntoModel, ResourceDescription toRdObj) throws Exception
Puts the content of a Resource Model (instance) ontology, inside the given Resource Description. Ontology should contain ONLY data for a single device (Resource instance). Then this data creates or overwrites the capability content in the ontology format in RD.- Parameters:
capaOntoModel
- Resource Model (instance) ontologytoRdObj
- Resource Description where the data is placed.- Throws:
Exception
-
-