Class OntologyImpl
- java.lang.Object
-
- de.uni_trier.wi2.procake.utils.ontology.OntologyImpl
-
-
Constructor Summary
Constructors Constructor Description OntologyImpl(org.apache.jena.ontology.OntModel ontModel)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcalculateDepthOfResource(URIObject res)Calculate the depth of an entity from the root.intcalculateDepthOfResource(URIObject res, String root, Set<String> relations)intcalculateDepthOfResource(org.apache.jena.rdf.model.Resource res)intcalculateDepthOfResource(org.apache.jena.rdf.model.Resource res, String root)intcalculateDepthOfResource(org.apache.jena.rdf.model.Resource res, String root, Set<String> relations)intcalculateDepthOfResource(org.apache.jena.rdf.model.Resource res, org.apache.jena.rdf.model.Resource root)intcalculateDepthOfResource(org.apache.jena.rdf.model.Resource target, org.apache.jena.rdf.model.Resource root, Set<org.apache.jena.rdf.model.Property> relations)booleancontains(URIObject resourceURIobject)Check for the existence of the resource in the underlying ontology.booleancontains(String resourceURI)Check for the existence of the resource in the underlying ontology.Set<String>getAllChildrenForNode(String rootNodeURI, Set<String> relations)Recursively collects all children for a given node which are connected via the given relation.Set<org.apache.jena.rdf.model.Resource>getAllChildrenForNode(org.apache.jena.rdf.model.Resource root, Set<org.apache.jena.rdf.model.Property> relations)Set<org.apache.jena.rdf.model.Statement>getAllPropertiesOfNode(String nodeURI)Set<String>getAncestors(URIObject res, Set<String> relations, Predicate<String> isValidTreeValuePredicate)Recursively collects all parents of the given node connected by minimally one relation in the given set of relations.Set<org.apache.jena.rdf.model.Resource>getAncestors(org.apache.jena.rdf.model.Resource node, Set<String> relations)Set<org.apache.jena.rdf.model.Resource>getAncestors(org.apache.jena.rdf.model.Resource node, Set<String> relations, Predicate<String> isValidTreeValuePredicate)Set<org.apache.jena.rdf.model.Resource>getClassRoots(org.apache.jena.rdf.model.Resource node)URIObjectgetLCA(URIObject queryRes, URIObject caseRes)Determine the LCA(Least Common Ancestor) of two concepts.URIObjectgetLCA(URIObject queryRes, URIObject caseRes, Set<String> relations)org.apache.jena.rdf.model.ResourcegetLCA(String first, String second, String root, Set<String> relations)Determine the LCA (Least Common Ancestor) of to concepts.org.apache.jena.rdf.model.ResourcegetLCA(org.apache.jena.rdf.model.Resource queryRes, org.apache.jena.rdf.model.Resource caseRes)org.apache.jena.rdf.model.ResourcegetLCA(org.apache.jena.rdf.model.Resource first, org.apache.jena.rdf.model.Resource second, org.apache.jena.rdf.model.Resource root, Set<org.apache.jena.rdf.model.Property> relations)intgetMaxDepthToLeaf(String root, Set<String> relations)intgetMaxDepthToLeaf(org.apache.jena.rdf.model.Resource root, Set<org.apache.jena.rdf.model.Property> relations)org.apache.jena.rdf.model.ModelgetModel()List<org.apache.jena.rdf.model.RDFNode>getObjectsOfProperty(URIObject resourceURIObject, String property)Examine the given resource for the given property and collect its objects.List<org.apache.jena.rdf.model.RDFNode>getObjectsOfProperty(String resourceURI, String property)Examine the given resource for the given property and collect its objects.List<org.apache.jena.rdf.model.RDFNode>getObjectsOfProperty(org.apache.jena.rdf.model.Resource resource, String property)Examine the given resource for the given property and collect its objects.org.apache.jena.ontology.OntModelgetOntModel()org.apache.jena.rdf.model.PropertygetProperty(String propertyURI)Fetches the Property object with the given URI from the underlying Jena ontology model.org.apache.jena.rdf.model.ResourcegetResource(URIObject resourceURIObject)Fetches the Resource object with the given URI from the underlying Jena ontology model.org.apache.jena.rdf.model.ResourcegetResource(String resourceURI)Fetches the Resource object with the given URI from the underlying Jena ontology model.intgetShortestPathLength(URIObject source, URIObject destination, String propName)Calculate the shortest path from on entity to another over a specific relation and return its length.intgetShortestPathLength(URIObject source, URIObject destination, Set<String> relations)intgetShortestPathLength(org.apache.jena.rdf.model.Resource source, org.apache.jena.rdf.model.Resource destination, String propName)intgetShortestPathLength(org.apache.jena.rdf.model.Resource source, org.apache.jena.rdf.model.Resource destination, Set<String> props)org.apache.jena.rdf.model.ResourcegetUniqueLCA(HashSet<org.apache.jena.rdf.model.Resource> tempResources, org.apache.jena.rdf.model.Resource resA, org.apache.jena.rdf.model.Resource resB)Determine the Unique LCA.voidinit(org.apache.jena.ontology.OntModel ontModel)booleanisIndividual(URIObject res)Check if entity is an Individual.booleanisIndividual(org.apache.jena.rdf.model.Resource res)Check whether entity is an Individual.booleanisSubClassOfProperty(String relation)Check whether the given relation is a rdfs subclass property.booleanisTypeProperty(String relation)Check whether the given relation is a rdf type property.org.apache.jena.query.ResultSetquery(String sparqlQuery)org.apache.jena.query.ResultSetquery(String sparqlQuery, String queryVar, String queryUri)voidregisterPredicate(InstanceOntologyOrderPredicate predicate)
-
-
-
Method Detail
-
init
public void init(org.apache.jena.ontology.OntModel ontModel)
-
registerPredicate
public void registerPredicate(InstanceOntologyOrderPredicate predicate)
-
isIndividual
public boolean isIndividual(URIObject res)
Check if entity is an Individual.- Specified by:
isIndividualin interfaceOntology- Parameters:
res- the entity.- Returns:
- if it is an Individual.
-
isIndividual
public boolean isIndividual(org.apache.jena.rdf.model.Resource res)
Description copied from interface:OntologyCheck whether entity is an Individual.- Specified by:
isIndividualin interfaceOntology- Parameters:
res- the entity.- Returns:
- whether it is an Individual.
-
getLCA
public URIObject getLCA(URIObject queryRes, URIObject caseRes)
Determine the LCA(Least Common Ancestor) of two concepts.
-
getLCA
public org.apache.jena.rdf.model.Resource getLCA(String first, String second, String root, Set<String> relations)
Description copied from interface:OntologyDetermine the LCA (Least Common Ancestor) of to concepts.
-
getLCA
public org.apache.jena.rdf.model.Resource getLCA(org.apache.jena.rdf.model.Resource queryRes, org.apache.jena.rdf.model.Resource caseRes)
-
getLCA
public org.apache.jena.rdf.model.Resource getLCA(org.apache.jena.rdf.model.Resource first, org.apache.jena.rdf.model.Resource second, org.apache.jena.rdf.model.Resource root, Set<org.apache.jena.rdf.model.Property> relations)
-
getUniqueLCA
public org.apache.jena.rdf.model.Resource getUniqueLCA(HashSet<org.apache.jena.rdf.model.Resource> tempResources, org.apache.jena.rdf.model.Resource resA, org.apache.jena.rdf.model.Resource resB)
Determine the Unique LCA. It is either the most specific or the one with the smallest distance to the entities.- Parameters:
tempResources- the possible LCAs.resA- the first entity.resB- the second entity- Returns:
- the unique LCA.
-
calculateDepthOfResource
public int calculateDepthOfResource(URIObject res)
Calculate the depth of an entity from the root.- Specified by:
calculateDepthOfResourcein interfaceOntology- Parameters:
res- the entity.- Returns:
- the depth of the entity from the root.
-
calculateDepthOfResource
public int calculateDepthOfResource(URIObject res, String root, Set<String> relations)
- Specified by:
calculateDepthOfResourcein interfaceOntology
-
calculateDepthOfResource
public int calculateDepthOfResource(org.apache.jena.rdf.model.Resource res)
- Specified by:
calculateDepthOfResourcein interfaceOntology
-
calculateDepthOfResource
public int calculateDepthOfResource(org.apache.jena.rdf.model.Resource res, org.apache.jena.rdf.model.Resource root)- Specified by:
calculateDepthOfResourcein interfaceOntology
-
calculateDepthOfResource
public int calculateDepthOfResource(org.apache.jena.rdf.model.Resource res, String root)- Specified by:
calculateDepthOfResourcein interfaceOntology
-
calculateDepthOfResource
public int calculateDepthOfResource(org.apache.jena.rdf.model.Resource res, String root, Set<String> relations)- Specified by:
calculateDepthOfResourcein interfaceOntology
-
calculateDepthOfResource
public int calculateDepthOfResource(org.apache.jena.rdf.model.Resource target, org.apache.jena.rdf.model.Resource root, Set<org.apache.jena.rdf.model.Property> relations)
-
getShortestPathLength
public int getShortestPathLength(URIObject source, URIObject destination, String propName)
Calculate the shortest path from on entity to another over a specific relation and return its length.- Specified by:
getShortestPathLengthin interfaceOntology- Parameters:
source- the first entity.destination- the second entity.propName- the specific relation.- Returns:
- the length of the shortest path.
-
getShortestPathLength
public int getShortestPathLength(URIObject source, URIObject destination, Set<String> relations)
- Specified by:
getShortestPathLengthin interfaceOntology
-
getShortestPathLength
public int getShortestPathLength(org.apache.jena.rdf.model.Resource source, org.apache.jena.rdf.model.Resource destination, String propName)
-
getShortestPathLength
public int getShortestPathLength(org.apache.jena.rdf.model.Resource source, org.apache.jena.rdf.model.Resource destination, Set<String> props)
-
getAncestors
public Set<String> getAncestors(URIObject res, Set<String> relations, Predicate<String> isValidTreeValuePredicate)
Description copied from interface:OntologyRecursively collects all parents of the given node connected by minimally one relation in the given set of relations. Is the given node an individual, the classes of the individuals are determined and their parents are collected- Specified by:
getAncestorsin interfaceOntology- Returns:
-
getAncestors
public Set<org.apache.jena.rdf.model.Resource> getAncestors(org.apache.jena.rdf.model.Resource node, Set<String> relations)
-
getAncestors
public Set<org.apache.jena.rdf.model.Resource> getAncestors(org.apache.jena.rdf.model.Resource node, Set<String> relations, Predicate<String> isValidTreeValuePredicate)
-
contains
public boolean contains(URIObject resourceURIobject)
Description copied from interface:OntologyCheck for the existence of the resource in the underlying ontology.
-
contains
public boolean contains(String resourceURI)
Description copied from interface:OntologyCheck for the existence of the resource in the underlying ontology.
-
getAllPropertiesOfNode
public Set<org.apache.jena.rdf.model.Statement> getAllPropertiesOfNode(String nodeURI)
- Specified by:
getAllPropertiesOfNodein interfaceOntology- Parameters:
nodeURI- node whose properties should be collected- Returns:
- set of all properties
-
query
public org.apache.jena.query.ResultSet query(String sparqlQuery)
-
query
public org.apache.jena.query.ResultSet query(String sparqlQuery, String queryVar, String queryUri)
-
getAllChildrenForNode
public Set<String> getAllChildrenForNode(String rootNodeURI, Set<String> relations)
Description copied from interface:OntologyRecursively collects all children for a given node which are connected via the given relation.- Specified by:
getAllChildrenForNodein interfaceOntology- Parameters:
rootNodeURI- the node whose children should be collected.relations- the relation that is considered during the search.- Returns:
- a set of all children.
-
getAllChildrenForNode
public Set<org.apache.jena.rdf.model.Resource> getAllChildrenForNode(org.apache.jena.rdf.model.Resource root, Set<org.apache.jena.rdf.model.Property> relations)
-
getClassRoots
public Set<org.apache.jena.rdf.model.Resource> getClassRoots(org.apache.jena.rdf.model.Resource node)
-
getMaxDepthToLeaf
public int getMaxDepthToLeaf(String root, Set<String> relations)
- Specified by:
getMaxDepthToLeafin interfaceOntology
-
getMaxDepthToLeaf
public int getMaxDepthToLeaf(org.apache.jena.rdf.model.Resource root, Set<org.apache.jena.rdf.model.Property> relations)
-
getObjectsOfProperty
public List<org.apache.jena.rdf.model.RDFNode> getObjectsOfProperty(org.apache.jena.rdf.model.Resource resource, String property)
Description copied from interface:OntologyExamine the given resource for the given property and collect its objects.- Specified by:
getObjectsOfPropertyin interfaceOntology- Parameters:
resource- the resource that will be examined.property- the property that will be looked for.- Returns:
- a list of all nodes representing the object of the predicate that is represented by the given property.
-
getObjectsOfProperty
public List<org.apache.jena.rdf.model.RDFNode> getObjectsOfProperty(String resourceURI, String property)
Description copied from interface:OntologyExamine the given resource for the given property and collect its objects.- Specified by:
getObjectsOfPropertyin interfaceOntology- Parameters:
resourceURI- the resource that will be examined.property- the property that will be looked for.- Returns:
- a list of all nodes representing the object of the predicate that is represented by the given property.
-
getObjectsOfProperty
public List<org.apache.jena.rdf.model.RDFNode> getObjectsOfProperty(URIObject resourceURIObject, String property)
Description copied from interface:OntologyExamine the given resource for the given property and collect its objects.- Specified by:
getObjectsOfPropertyin interfaceOntology- Parameters:
resourceURIObject- the resource that will be examined.property- the property that will be looked for.- Returns:
- a list of all nodes representing the object of the predicate that is represented by the given property.
-
isSubClassOfProperty
public boolean isSubClassOfProperty(String relation)
Description copied from interface:OntologyCheck whether the given relation is a rdfs subclass property.- Specified by:
isSubClassOfPropertyin interfaceOntology
-
isTypeProperty
public boolean isTypeProperty(String relation)
Description copied from interface:OntologyCheck whether the given relation is a rdf type property.- Specified by:
isTypePropertyin interfaceOntology
-
getResource
public org.apache.jena.rdf.model.Resource getResource(URIObject resourceURIObject)
Description copied from interface:OntologyFetches the Resource object with the given URI from the underlying Jena ontology model.- Specified by:
getResourcein interfaceOntology- Parameters:
resourceURIObject- the URI for which the Resource object should be fetched.- Returns:
- the desired Resource object.
-
getResource
public org.apache.jena.rdf.model.Resource getResource(String resourceURI)
Description copied from interface:OntologyFetches the Resource object with the given URI from the underlying Jena ontology model.- Specified by:
getResourcein interfaceOntology- Parameters:
resourceURI- the URI for which the Resource object should be fetched.- Returns:
- the desired Resource object.
-
getProperty
public org.apache.jena.rdf.model.Property getProperty(String propertyURI)
Description copied from interface:OntologyFetches the Property object with the given URI from the underlying Jena ontology model.- Specified by:
getPropertyin interfaceOntology- Parameters:
propertyURI- the URI for which the Property object should be fetched.- Returns:
- the desired Property object.
-
getModel
public org.apache.jena.rdf.model.Model getModel()
-
getOntModel
public org.apache.jena.ontology.OntModel getOntModel()
-
-