nectec.semantic.web.knowledge.application.framework.representative
Class ApplicationTemplate

java.lang.Object
  extended by nectec.semantic.web.knowledge.application.framework.representative.ApplicationTemplate
Direct Known Subclasses:
Recommender, SemanticSearch

public abstract class ApplicationTemplate
extends Object

Template class which will be inherited by the application classes: Semantic Search and Recommender and contains all the common methods shared among these two sub classes.


Field Summary
static int PROPERTY_CLASSIFICATION_DISPLAY
          Indicator of property type classified by the system, which in this case, display property.
static int PROPERTY_CLASSIFICATION_PROCESSING
          Indicator of property type classified by the system, which in this case, both searchable property and conditional property.
static String TO_DISPLAY
          Display property indicator for internal processing.
static String TO_PROCESS
          Searchable/Conditional property indicator for internal processing.
 
Constructor Summary
ApplicationTemplate()
           
 
Method Summary
 ArrayList<String> getAllInstanceUniqueIDs()
          Get all the IDs of instances of the currently interested class.
 ArrayList<String> getAllInstanceURNs()
          Get all the URNs of instances of the currently interested class.
abstract  ArrayList<String> getAllPropertiesInvolved(String classOfInterest)
          Get all the properties configured to be involved in the current class of interest.
 String getAppRelPath()
          Get the appRelPath path of the application.
 HashMap<String,String> getAvailableDisplayProperties(String classOfInterest)
          Get the available display properties of the given class.
 HashMap<String,String> getConfig()
          Get the configuration.
 String getCurrentClassOfInterest()
          Get current class(path) of interest.
 String getCustomLabel(String classOfInterest, String propertyName)
          Get the label of the given property (Customized label instead of rdfs:label).
 HashMap<String,ArrayList<String>> getInformationOfGivenInstanceURN(String urn)
          Get all related information of class instances of the given urn.
 String getNamespace()
          Get the namespace of the ontology.
 com.hp.hpl.jena.ontology.OntModel getOntologyModel()
          Get the ontology model of knowledge base.
 OntologyProcessing getOntologyProcessingInstance()
          Get the instance of OntologyProcessing Class so that the processing on the ontology can be performed without the instances.
 ArrayList<String> getPaths()
          Get list of classes involved, defined in the configuration.
static ArrayList<String> getPaths(String root)
          Get list of classes involved, defined in the configuration.
 String getPkeyValueGivenURN(String urn)
          Given the urn, retrieve the value of primary-key like property.
 String getRangeOfPropertyWRTcurretClass(String propertyName)
          Get class of the given property comes from (i.e.
 HashMap<String,ArrayList<String>> getRelatedInformationOfGivenClassInstance(String classOfInterest, String instanceIdentificationNumber)
          Get all related information of instances of the given class.
 HashMap<String,String> getStruturalInfoOfURN(String urn)
          Get the information (RDF type, unique ID, ect) of given URN.
 ArrayList<String> getSubclassesOfGivenPropertyRange(String propertyName)
          Get all the subclasses of the class that the given property comes from.
 String getURNofID(String uniqueID)
          Given the uniqueID of resource, get the URN of it.
 ArrayList<String> getValueOfProperty(String instanceIdentificationNumber, String propertyName)
          Get the value of the given property of the instance with given ID.
 boolean hasPropertyValueForInstanceWithGivenID(String instanceIdentificationNumber, String propertyName)
          Check whether the instance with given id has the given property or not.
 void init()
          Initializing the instance.
abstract  boolean isInIncludedProperties(String propertyName, int propertyClassification)
          Check whether the given property is included in the configuration or not.
 boolean isValidResourceInThisNS(String resourceName)
          Check whether the given resource is a valid resource in the ontology or not.
 ArrayList<String> searchInstances(String propertyName, String operator, String literalValue, String referenceValue)
          Search the instance of a given condition.
 ArrayList<String> searchInstancesOfGivenConditions(ArrayList<String> properties, ArrayList<String> operators, ArrayList<String> literalValues, ArrayList<String> resourceValues)
          Query the model for searching the instances which match all the given conditions.
 void setCurrentApplicationPath(String newAppPath)
          Set the current application path (domain) to another.
 void setCurrentClassOfInterest(String newClassOfInterest)
          Set the current class of interest.
 void setOntologyModel(com.hp.hpl.jena.ontology.OntModel ontologyModel)
          Set the main model for knowledge base.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TO_DISPLAY

public static final String TO_DISPLAY
Display property indicator for internal processing.

See Also:
Constant Field Values

TO_PROCESS

public static final String TO_PROCESS
Searchable/Conditional property indicator for internal processing.

See Also:
Constant Field Values

PROPERTY_CLASSIFICATION_DISPLAY

public static final int PROPERTY_CLASSIFICATION_DISPLAY
Indicator of property type classified by the system, which in this case, display property.

See Also:
Constant Field Values

PROPERTY_CLASSIFICATION_PROCESSING

public static final int PROPERTY_CLASSIFICATION_PROCESSING
Indicator of property type classified by the system, which in this case, both searchable property and conditional property.

See Also:
Constant Field Values
Constructor Detail

ApplicationTemplate

public ApplicationTemplate()
Method Detail

init

public void init()
Initializing the instance.


getValueOfProperty

public ArrayList<String> getValueOfProperty(String instanceIdentificationNumber,
                                            String propertyName)
Get the value of the given property of the instance with given ID.

Parameters:
instanceIdentificationNumber - Instance identification number (Unique Id of the instance).
propertyName - Property of interest.
Returns:
Collection of values of that property.

getRelatedInformationOfGivenClassInstance

public HashMap<String,ArrayList<String>> getRelatedInformationOfGivenClassInstance(String classOfInterest,
                                                                                   String instanceIdentificationNumber)
Get all related information of instances of the given class. In other words, get the values of display properties (defined in the config of class that the instance come from) of the instance with given ID. The unique id is served as a selector.

Parameters:
classOfInterest - Class of interest.
instanceIdentificationNumber - Instance identification number.
Returns:
Related information of the instance.

getAvailableDisplayProperties

public HashMap<String,String> getAvailableDisplayProperties(String classOfInterest)
Get the available display properties of the given class.

Parameters:
classOfInterest - Class of interest (if used null, the class of current interest, which was defined when you create the object, is applied).
Returns:
Collection of display properties along with the RESOURCE or LITERAL type description.

getSubclassesOfGivenPropertyRange

public ArrayList<String> getSubclassesOfGivenPropertyRange(String propertyName)
Get all the subclasses of the class that the given property comes from.

Parameters:
propertyName - Property of interest.
Returns:
Collection of subclasses of that class.

getRangeOfPropertyWRTcurretClass

public String getRangeOfPropertyWRTcurretClass(String propertyName)
Get class of the given property comes from (i.e. 'AllValuesFrom' in OWL).

Parameters:
propertyName - Property of interest.
Returns:
Class name of the given property.

getCustomLabel

public String getCustomLabel(String classOfInterest,
                             String propertyName)
Get the label of the given property (Customized label instead of rdfs:label).

Parameters:
classOfInterest - Class of interest.
propertyName - Property of interest.
Returns:
Label of that property.

setCurrentClassOfInterest

public void setCurrentClassOfInterest(String newClassOfInterest)
Set the current class of interest.

Parameters:
newClassOfInterest - New class of interest.

setCurrentApplicationPath

public void setCurrentApplicationPath(String newAppPath)
Set the current application path (domain) to another.

Parameters:
newAppPath - New application path.

getCurrentClassOfInterest

public String getCurrentClassOfInterest()
Get current class(path) of interest.

Returns:
Name of the class of interest.

setOntologyModel

public void setOntologyModel(com.hp.hpl.jena.ontology.OntModel ontologyModel)
Set the main model for knowledge base.

Parameters:
ontologyModel - New model to be set.

getOntologyModel

public com.hp.hpl.jena.ontology.OntModel getOntologyModel()
Get the ontology model of knowledge base.

Returns:
Ontology model.

getNamespace

public String getNamespace()
Get the namespace of the ontology.

Returns:
Namespace.

getConfig

public HashMap<String,String> getConfig()
Get the configuration.

Returns:
Collections of key and value pairs which come from the configuration file.

searchInstances

public ArrayList<String> searchInstances(String propertyName,
                                         String operator,
                                         String literalValue,
                                         String referenceValue)
Search the instance of a given condition. Only single condition is allowed. For multiple conditions, use searchInstancesOfGivenConditions of SemanticSearch class.

Parameters:
propertyName - Name of the property.
operator - Operator for the condition (Possible operators are are , , , , , , , ).
literalValue - Literal value of the property.
referenceValue - Resource value of the property.
Returns:
Collection of the unique IDs of the instances found.

getOntologyProcessingInstance

public OntologyProcessing getOntologyProcessingInstance()
Get the instance of OntologyProcessing Class so that the processing on the ontology can be performed without the instances.

Returns:
Instance of OntologyProcessing Class.

getPaths

public ArrayList<String> getPaths()
Get list of classes involved, defined in the configuration.

Returns:
Collection of classes.

getPaths

public static ArrayList<String> getPaths(String root)
Get list of classes involved, defined in the configuration.

Parameters:
appRelPath - Searching directory path.
Returns:
Collection of classes.

hasPropertyValueForInstanceWithGivenID

public boolean hasPropertyValueForInstanceWithGivenID(String instanceIdentificationNumber,
                                                      String propertyName)
Check whether the instance with given id has the given property or not.

Parameters:
instanceIdentificationNumber - Identification number of the instance.
propertyName - Property of interest.
Returns:
true(The instance has value for that given property) / false(The instance does not have value for that property).

isValidResourceInThisNS

public boolean isValidResourceInThisNS(String resourceName)
Check whether the given resource is a valid resource in the ontology or not.

Parameters:
resourceName - Resource to be tested.
Returns:
true(It is a valid resource) / false(It is not a valid resource).

isInIncludedProperties

public abstract boolean isInIncludedProperties(String propertyName,
                                               int propertyClassification)
Check whether the given property is included in the configuration or not.

Parameters:
propertyName - Property of interest.
propertyClassification - Property type (Types are defined as Constants (Start with the word 'PROPERTY_CLASSIFICATION_') in ApplicationTemplate class and callable.)
Returns:
true(It is included in configuration) / false(It is not included in configuration)

getAllPropertiesInvolved

public abstract ArrayList<String> getAllPropertiesInvolved(String classOfInterest)
Get all the properties configured to be involved in the current class of interest. Including searchable properties, display properties, conditional properties and, if have, recommended properties.

Parameters:
classOfInterest - Class of interest.
Returns:
Collection of those properties.

getAppRelPath

public String getAppRelPath()
Get the appRelPath path of the application.

Returns:

searchInstancesOfGivenConditions

public ArrayList<String> searchInstancesOfGivenConditions(ArrayList<String> properties,
                                                          ArrayList<String> operators,
                                                          ArrayList<String> literalValues,
                                                          ArrayList<String> resourceValues)
Query the model for searching the instances which match all the given conditions. The conditions are in the form of parallel array.

Parameters:
properties - Collection of properties.
operators - Collection of operators (Possible operators are , , , , , , , ).
literalValues - Collection of Literal values.
resourceValues - Collection of reference values.
Returns:
Collection of the unique IDs of the instances found.

getAllInstanceURNs

public ArrayList<String> getAllInstanceURNs()
Get all the URNs of instances of the currently interested class.

Returns:
Collection of those URNs.

getAllInstanceUniqueIDs

public ArrayList<String> getAllInstanceUniqueIDs()
Get all the IDs of instances of the currently interested class.

Returns:
Collection of those values.

getPkeyValueGivenURN

public String getPkeyValueGivenURN(String urn)
Given the urn, retrieve the value of primary-key like property.

Parameters:
urn - URN/IRI of the resource.
Returns:
Value of that type of property.

getInformationOfGivenInstanceURN

public HashMap<String,ArrayList<String>> getInformationOfGivenInstanceURN(String urn)
Get all related information of class instances of the given urn.

Parameters:
urn - URN/IRI of the resource.
Returns:
Related Information of the instance.

getStruturalInfoOfURN

public HashMap<String,String> getStruturalInfoOfURN(String urn)
Get the information (RDF type, unique ID, ect) of given URN.

Parameters:
urn - Input URN.
Returns:
Information about given URN.

getURNofID

public String getURNofID(String uniqueID)
Given the uniqueID of resource, get the URN of it.

Parameters:
uniqueID - Input unique ID of resource.
Returns:
URN of given ID.