Class OntologyImpl

java.lang.Object
de.uni_trier.wi2.procake.utils.ontology.OntologyImpl
All Implemented Interfaces:
Ontology

public class OntologyImpl extends Object implements Ontology
  • Constructor Details

    • OntologyImpl

      public OntologyImpl(org.apache.jena.ontology.OntModel ontModel)
  • Method Details

    • 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:
      isIndividual in interface Ontology
      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: Ontology
      Check whether entity is an Individual.
      Specified by:
      isIndividual in interface Ontology
      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.
      Specified by:
      getLCA in interface Ontology
      Parameters:
      queryRes - the first Entity.
      caseRes - the second Entity.
      Returns:
      the entity of the LCA.
    • getLCA

      public URIObject getLCA(URIObject queryRes, URIObject caseRes, Set<String> relations)
      Specified by:
      getLCA in interface Ontology
    • getLCA

      public org.apache.jena.rdf.model.Resource getLCA(String first, String second, String root, Set<String> relations)
      Description copied from interface: Ontology
      Determine the LCA (Least Common Ancestor) of to concepts.
      Specified by:
      getLCA in interface Ontology
      Parameters:
      first - the first Entity.
      second - the second Entity.
      Returns:
      the entity of the LCA.
    • 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:
      calculateDepthOfResource in interface Ontology
      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:
      calculateDepthOfResource in interface Ontology
    • calculateDepthOfResource

      public int calculateDepthOfResource(org.apache.jena.rdf.model.Resource res)
      Specified by:
      calculateDepthOfResource in interface Ontology
    • calculateDepthOfResource

      public int calculateDepthOfResource(org.apache.jena.rdf.model.Resource res, org.apache.jena.rdf.model.Resource root)
      Specified by:
      calculateDepthOfResource in interface Ontology
    • calculateDepthOfResource

      public int calculateDepthOfResource(org.apache.jena.rdf.model.Resource res, String root)
      Specified by:
      calculateDepthOfResource in interface Ontology
    • calculateDepthOfResource

      public int calculateDepthOfResource(org.apache.jena.rdf.model.Resource res, String root, Set<String> relations)
      Specified by:
      calculateDepthOfResource in interface Ontology
    • 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:
      getShortestPathLength in interface Ontology
      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:
      getShortestPathLength in interface Ontology
    • 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: Ontology
      Recursively 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:
      getAncestors in interface Ontology
      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: Ontology
      Check for the existence of the resource in the underlying ontology.
      Specified by:
      contains in interface Ontology
      Parameters:
      resourceURIobject - the resource that will be examined.
      Returns:
      whether the given resource exists in the underlying ontology.
    • contains

      public boolean contains(String resourceURI)
      Description copied from interface: Ontology
      Check for the existence of the resource in the underlying ontology.
      Specified by:
      contains in interface Ontology
      Parameters:
      resourceURI - the resource that will be examined.
      Returns:
      whether the given resource exists in the underlying ontology.
    • getAllPropertiesOfNode

      public Set<org.apache.jena.rdf.model.Statement> getAllPropertiesOfNode(String nodeURI)
      Specified by:
      getAllPropertiesOfNode in interface Ontology
      Parameters:
      nodeURI - node whose properties should be collected
      Returns:
      set of all properties
    • query

      public org.apache.jena.query.ResultSet query(String sparqlQuery)
      Specified by:
      query in interface Ontology
      Parameters:
      sparqlQuery - SPARQL string
      Returns:
      result set
    • query

      public org.apache.jena.query.ResultSet query(String sparqlQuery, String queryVar, String queryUri)
      Specified by:
      query in interface Ontology
      Parameters:
      sparqlQuery - SPARQL string that contains a variable named queryVar.
      queryVar - the name of the variable in sparqlQuery
      queryUri - the URI value to set for queryVar
      Returns:
      result set
    • getAllChildrenForNode

      public Set<String> getAllChildrenForNode(String rootNodeURI, Set<String> relations)
      Description copied from interface: Ontology
      Recursively collects all children for a given node which are connected via the given relation.
      Specified by:
      getAllChildrenForNode in interface Ontology
      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:
      getMaxDepthToLeaf in interface Ontology
    • 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: Ontology
      Examine the given resource for the given property and collect its objects.
      Specified by:
      getObjectsOfProperty in interface Ontology
      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: Ontology
      Examine the given resource for the given property and collect its objects.
      Specified by:
      getObjectsOfProperty in interface Ontology
      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: Ontology
      Examine the given resource for the given property and collect its objects.
      Specified by:
      getObjectsOfProperty in interface Ontology
      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: Ontology
      Check whether the given relation is a rdfs subclass property.
      Specified by:
      isSubClassOfProperty in interface Ontology
    • isTypeProperty

      public boolean isTypeProperty(String relation)
      Description copied from interface: Ontology
      Check whether the given relation is a rdf type property.
      Specified by:
      isTypeProperty in interface Ontology
    • getResource

      public org.apache.jena.rdf.model.Resource getResource(URIObject resourceURIObject)
      Description copied from interface: Ontology
      Fetches the Resource object with the given URI from the underlying Jena ontology model.
      Specified by:
      getResource in interface Ontology
      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: Ontology
      Fetches the Resource object with the given URI from the underlying Jena ontology model.
      Specified by:
      getResource in interface Ontology
      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: Ontology
      Fetches the Property object with the given URI from the underlying Jena ontology model.
      Specified by:
      getProperty in interface Ontology
      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()