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 classRD_API.EnumIfCategoryEnumeration for interface Categories.static classRD_API.EnumPrefixEnumeration for id prefixes.
-
Field Summary
Fields Modifier and Type Field Description static StringID_SEPARATORSeparator used to separate sections within the IDstatic StringRD_FILE_TYPEFile type (ending) used for Resource description Files
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DocumentconvertRDObjToDOM(ResourceDescription rdObj)Converts Resource Description (RD) from Java Objects format to DOM document.StringconvertRDObjToString(ResourceDescription rdObj)Converts Resource Description (RD) from Java Objects format to String.StringcreateDocFromRD_HTML(ResourceDescription rdObj)Creates XHTML formatted documentation out of an RD objectvoidgetCapabilitiesAsBPOntoModelFromRD(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.ClientgetCapabilitiesAsBPOntoModelFromRD(ResourceDescription rdObj)Creates a new Resource Model Ontology.voidgetCapabilitiesAsBPOntoModelFromResource(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 DocumentgetCapabilitiesOntoAsXMLNodeFromOntoClient(fi.tut.mei.capabilityQueryLib.Client capaOntoModel)StringgetUniqueNameOfResource(ResourceCT resourceObj)Gets unique name of a resourceStringmakeTransform(ResourceDescription rdObj, String transformLocation)Executes a XSLT Transformation for ARD objectprotected voidputCapabilitiesOntoToRDModel(fi.tut.mei.capabilityQueryLib.Client capaOntoModel, ResourceDescription toRdObj)Puts the content of a Resource Model (instance) ontology, inside the given Resource Description.voidputCapabilitiesOntoToRDModel(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).ResourceDescriptionreadRDInFromLocation(String fileLocation)Reads in Resource Description file (XML format) and builds the Java binding (JAXB) objects of it.ResourceDescriptionreadRDInFromString(InputStream rdInXML_inputStream)Reads in Resource Description as argument content (InputStream, String as XML format) and builds the Java binding (JAXB) objects.ResourceDescriptionreadRDInFromString(String rdInXML)Reads in Resource Description as argument content(XML format) and builds the Java binding (JAXB) objects.booleansaveRDToLocation(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:
SAXExceptionJAXBExceptionIOExceptionException
-
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:
JAXBExceptionException
-
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:
ExceptionJAXBException
-
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:
JAXBExceptionException
-
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:
JAXBExceptionException
-
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 ExceptionGets 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 ExceptionGets 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 ExceptionPuts 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 ExceptionPuts 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
-
-