Package edu.kit.ipd.ontologyaccess
Class OntologyAccess
- java.lang.Object
-
- edu.kit.ipd.ontologyaccess.OntologyAccess
-
public class OntologyAccess extends Object
- Author:
- Jan Keim
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.jena.ontology.AllValuesFromRestriction
addAllValuesFrom(String uri, org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.Resource cls)
Adds a restriction that all values have to come from a specific classorg.apache.jena.ontology.AllValuesFromRestriction
addAllValuesFrom(org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.Resource cls)
Adds a restriction that all values have to come from a specific classorg.apache.jena.ontology.EnumeratedClass
addAnonymousEnumeratedClass()
org.apache.jena.ontology.CardinalityRestriction
addCardinalityToProperty(org.apache.jena.ontology.OntProperty property, int cardinality)
org.apache.jena.ontology.OntClass
addClass(String className)
Adds a class with the given name to the ontology.void
addComment(org.apache.jena.ontology.OntResource resource, String comment, String lang)
Adds a comment to a resource with the provided language setorg.apache.jena.ontology.DatatypeProperty
addDataProperty(String name)
Adds a DatatypeProperty and sets the range.org.apache.jena.ontology.DatatypeProperty
addDataProperty(String name, org.apache.jena.rdf.model.Resource domain)
Adds a DatatypeProperty with the given range as type.org.apache.jena.ontology.DatatypeProperty
addDataProperty(String name, org.apache.jena.rdf.model.Resource domain, org.apache.jena.rdf.model.Resource range)
Adds a DatatypeProperty with the given range as type.void
addDataPropertyToIndividual(org.apache.jena.ontology.Individual individual, org.apache.jena.ontology.DatatypeProperty property, Object value)
void
addDataPropertyToIndividual(org.apache.jena.ontology.Individual individual, org.apache.jena.ontology.DatatypeProperty property, Object value, org.apache.jena.datatypes.RDFDatatype type)
void
addDomainToProperty(org.apache.jena.ontology.OntProperty property, org.apache.jena.rdf.model.Resource domain)
org.apache.jena.ontology.EnumeratedClass
addEnumeratedClass(String name)
org.apache.jena.ontology.ObjectProperty
addFunctionalObjectProperty(String objectPropertyName, org.apache.jena.ontology.OntClass domain, org.apache.jena.ontology.OntClass range)
org.apache.jena.ontology.FunctionalProperty
addFunctionalToProperty(org.apache.jena.ontology.OntProperty property)
void
addIndividualToEnumeratedClass(org.apache.jena.ontology.EnumeratedClass clazz, org.apache.jena.ontology.Individual individual)
org.apache.jena.ontology.Individual
addInstanceToClass(String name, org.apache.jena.ontology.OntClass clazz)
Adds an Individual to the given classvoid
addLabel(org.apache.jena.ontology.OntResource resource, String label)
void
addLabel(org.apache.jena.ontology.OntResource resource, String label, String language)
org.apache.jena.ontology.MaxCardinalityRestriction
addMaxCardinalityToProperty(org.apache.jena.ontology.OntProperty property, int cardinality)
org.apache.jena.ontology.MinCardinalityRestriction
addMinCardinalityToProperty(org.apache.jena.ontology.OntProperty property, int cardinality)
org.apache.jena.ontology.Individual
addNamedIndividual(String shortUri)
Adds an individual to the ontology by adding it as individual of OWL:Thingorg.apache.jena.ontology.Individual
addNamedIndividual(String className, String shortUri)
Adds an individual and sets its class to the given class name (as String) and the short URI (without prefix).org.apache.jena.ontology.Individual
addNamedIndividual(org.apache.jena.ontology.OntClass cls, String shortUri)
Adds an individual and sets its class to the givenOntClass
and the short URI (without prefix).void
addNsPrefix(String prefix, String uri)
Add a namespace prefixorg.apache.jena.ontology.ObjectProperty
addObjectProperty(String objectPropertyName, org.apache.jena.ontology.OntClass domain, org.apache.jena.ontology.OntClass range)
Optional<org.apache.jena.ontology.ObjectProperty>
addObjectPropertyOfIndividual(String subjectShortUri, String propertyName, String objectShortUri)
void
addObjectPropertyOfIndividual(org.apache.jena.rdf.model.Resource subject, org.apache.jena.ontology.ObjectProperty property, org.apache.jena.rdf.model.RDFNode object)
Adds anObjectProperty
to an individual.void
addRangeToProperty(org.apache.jena.ontology.OntProperty property, org.apache.jena.rdf.model.Resource range)
void
addStatement(org.apache.jena.rdf.model.Resource subject, org.apache.jena.ontology.ObjectProperty property, org.apache.jena.rdf.model.RDFNode object)
Adds a statement provided with a triple (subject, predicate, object)void
addStringDataPropertyToIndividual(org.apache.jena.ontology.Individual individual, org.apache.jena.ontology.DatatypeProperty property, String value)
void
addSubClassing(org.apache.jena.ontology.OntClass subClass, org.apache.jena.rdf.model.Resource superClass)
void
addSubClassingExclusive(org.apache.jena.ontology.OntClass subClass, org.apache.jena.rdf.model.Resource superClass)
org.apache.jena.ontology.OntClass
addSubClassOf(String className, String superClassName)
org.apache.jena.ontology.OntClass
addSubClassOf(String className, org.apache.jena.ontology.OntClass superClass)
void
addSubClassProperty(org.apache.jena.ontology.OntClass subClass, org.apache.jena.ontology.OntClass superClass)
boolean
classIsSubClassOf(org.apache.jena.ontology.OntClass clazz, org.apache.jena.ontology.OntClass superClass)
static boolean
compareNamesSimple(String name1, String name2)
boolean
containsClass(String className)
boolean
containsDataProperty(String name)
boolean
containsObjectProperty(String objectPropertyName)
boolean
containsObjectPropertyForIndividuals(String subjectName, String propertyName, String objectName)
Checks whether there is an existing ObjectProperty that fulfils the given parameters.boolean
containsObjectPropertyForIndividuals(org.apache.jena.rdf.model.Resource subject, org.apache.jena.ontology.ObjectProperty property, org.apache.jena.rdf.model.RDFNode object)
Checks whether there is an existing ObjectProperty that fulfils the given parameters.static OntologyAccess
empty(String defaultNameSpaceUri)
Creates an empty OntologyAccess based on neither an existing file norOntModel
.org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.OntProperty>
getAllNamedProperties()
Optional<org.apache.jena.ontology.OntClass>
getClass(String className)
Returns an Optional holding the class that corresponds to the given name.org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.DatatypeProperty>
getDataPropertiesOfIndividual(String individualName)
org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.DatatypeProperty>
getDataPropertiesOfIndividualbyUri(String individualUri)
Optional<org.apache.jena.ontology.DatatypeProperty>
getDataProperty(String dataPropertyLocalName)
Optional<org.apache.jena.ontology.DatatypeProperty>
getDataPropertyByUri(String dataPropertyUri)
org.eclipse.collections.api.list.MutableList<String>
getDataPropertyValuesForIndividual(String datatypePropertyName, String individualUri)
org.eclipse.collections.api.list.MutableList<String>
getDataPropertyValuesForIndividual(org.apache.jena.rdf.model.Property property, String individualUri)
Optional<org.apache.jena.rdf.model.Resource>
getDatatypeByName(String name)
org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.Individual>
getInferredInstancesOfClass(String className)
org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.Individual>
getInstancesOfClass(String className)
Returns the Individuals that have a class that corresponds to the given class nameOptional<String>
getName(String individualUri)
Optional<org.apache.jena.ontology.Individual>
getNamedIndividual(String individualName)
Optional<org.apache.jena.ontology.Individual>
getNamedIndividualByShortUri(String individualShortUri)
Optional<org.apache.jena.ontology.Individual>
getNamedIndividualByUri(String individualUri)
org.eclipse.collections.api.list.MutableList<org.apache.jena.rdf.model.Property>
getNamedPropertiesWithLocalName(String localName)
org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.ObjectProperty>
getObjectPropertiesOfIndividual(String individualName)
Returns a list ofObjectProperty
for the individual that is provided with its nameorg.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.ObjectProperty>
getObjectPropertiesOfIndividual(org.apache.jena.rdf.model.Resource individual)
Returns a list ofObjectProperty
for the given individualorg.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.ObjectProperty>
getObjectPropertiesOfIndividualWithUri(String individualUri)
Returns a list ofObjectProperty
for individual given by the URIOptional<org.apache.jena.ontology.ObjectProperty>
getObjectProperty(String objectPropertyName)
Optional<org.apache.jena.ontology.ObjectProperty>
getObjectPropertyByUri(String objectPropertyUri)
org.eclipse.collections.api.list.MutableList<org.apache.jena.rdf.model.Resource>
getObjectPropertyValues(org.apache.jena.ontology.Individual individual, org.apache.jena.rdf.model.Property property)
Returns the values of the givenObjectProperty
for the providedIndividual
org.apache.jena.ontology.OntModel
getOntology()
Returns theOntModel
of the ontologyorg.eclipse.collections.api.list.MutableList<org.apache.jena.rdf.model.Property>
getPropertiesOfIndividual(org.apache.jena.rdf.model.Resource individual)
Returns the Properties of an individualOptional<org.apache.jena.ontology.OntTools.Path>
getShortestPathBetween(org.apache.jena.ontology.Individual start, org.apache.jena.ontology.Individual target, Predicate<org.apache.jena.rdf.model.Statement> filter)
Optional<org.apache.jena.ontology.OntTools.Path>
getUndirectedShortestPathBetween(org.apache.jena.ontology.Individual start, org.apache.jena.ontology.Individual target, Predicate<org.apache.jena.rdf.model.Statement> filter)
Returns the shortest path between two individuals while treating every edge as undirected.org.apache.jena.rdf.model.StmtIterator
listStatements(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property predicate, org.apache.jena.rdf.model.RDFNode object)
Find all the statements matching a pattern.boolean
nodeHasClass(org.apache.jena.rdf.model.RDFNode node, org.apache.jena.ontology.OntClass clazz)
Returns whether a node is an instance of the given classstatic OntologyAccess
ofFile(String ontoFile)
Create an OntologyAccess based on a file (that is an ontology and) that will be loaded.static OntologyAccess
ofOntModel(org.apache.jena.ontology.OntModel ontModel)
Creates an OntologyAccess based on a givenOntModel
.void
removeSubClassing(org.apache.jena.ontology.OntClass clazz, org.apache.jena.ontology.OntClass superClass)
boolean
save(String file)
Save the ontology to a given file (path).boolean
save(String file, org.apache.jena.riot.Lang language)
Save the ontology to a given file (path).org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.Individual>
searchIndividual(Predicate<org.apache.jena.ontology.Individual> searchPredicate)
Search for individuals based on the givenPredicate
.void
setDefaultPrefix(String prefix)
Set the default Prefixboolean
validateOntology()
Validates the ontology.
-
-
-
Method Detail
-
ofFile
public static OntologyAccess ofFile(String ontoFile)
Create an OntologyAccess based on a file (that is an ontology and) that will be loaded.- Parameters:
ontoFile
- The file of an ontology- Returns:
- An OntologyAccess object that uses the given file as underlying ontology
-
ofOntModel
public static OntologyAccess ofOntModel(org.apache.jena.ontology.OntModel ontModel)
Creates an OntologyAccess based on a givenOntModel
.- Parameters:
ontModel
- The OntModel the access should be based on- Returns:
- An OntologyAccess object that uses the given OntModel as underlying ontology
-
empty
public static OntologyAccess empty(String defaultNameSpaceUri)
Creates an empty OntologyAccess based on neither an existing file norOntModel
.- Parameters:
defaultNameSpaceUri
- The defaul namespace URI- Returns:
- An OntologyAccess object based on neither an existing file nor
OntModel
-
getOntology
public org.apache.jena.ontology.OntModel getOntology()
Returns theOntModel
of the ontology- Returns:
- the
OntModel
of the ontology
-
validateOntology
public boolean validateOntology()
Validates the ontology. A logger will put out warnings iff there are conflicts.- Returns:
true
if the ontology is valid and has no conflicts,false
if there are conflicts
-
save
public boolean save(String file)
Save the ontology to a given file (path). This method uses the N3 language to save.- Parameters:
file
- String containing the path of the file the ontology should be saved to- Returns:
- true if saving was successful, otherwise false is returned
-
save
public boolean save(String file, org.apache.jena.riot.Lang language)
Save the ontology to a given file (path). This method uses the N3 language to save.- Parameters:
file
- String containing the path of the file the ontology should be saved tolanguage
- The language the file should be written in- Returns:
- true if saving was successful, otherwise false is returned
-
setDefaultPrefix
public void setDefaultPrefix(String prefix)
Set the default Prefix- Parameters:
prefix
- the new default prefix
-
addNsPrefix
public void addNsPrefix(String prefix, String uri)
Add a namespace prefix- Parameters:
prefix
- the new prefix that should be able to useuri
- the URI that the prefix should be resolved to
-
searchIndividual
public org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.Individual> searchIndividual(Predicate<org.apache.jena.ontology.Individual> searchPredicate)
Search for individuals based on the givenPredicate
.- Parameters:
searchPredicate
- The predicate that should be used to look for individuals- Returns:
- A list of individuals that correspond to the given predicate
-
addNamedIndividual
public org.apache.jena.ontology.Individual addNamedIndividual(String shortUri)
Adds an individual to the ontology by adding it as individual of OWL:Thing- Parameters:
shortUri
- ShortUri of the Individual- Returns:
- the created Individual
-
addNamedIndividual
public org.apache.jena.ontology.Individual addNamedIndividual(org.apache.jena.ontology.OntClass cls, String shortUri)
Adds an individual and sets its class to the givenOntClass
and the short URI (without prefix). See alsoaddNamedIndividual(String)
.- Parameters:
cls
- Class the individual should belong toshortUri
- Short URI (without prefix)- Returns:
- the created individual
-
addNamedIndividual
public org.apache.jena.ontology.Individual addNamedIndividual(String className, String shortUri)
Adds an individual and sets its class to the given class name (as String) and the short URI (without prefix). See alsoaddNamedIndividual(OntClass, String)
.- Parameters:
className
- Class the individual should belong toshortUri
- Short URI (without prefix)- Returns:
- the created individual
-
getNamedIndividual
public Optional<org.apache.jena.ontology.Individual> getNamedIndividual(String individualName)
-
getNamedIndividualByShortUri
public Optional<org.apache.jena.ontology.Individual> getNamedIndividualByShortUri(String individualShortUri)
-
getNamedIndividualByUri
public Optional<org.apache.jena.ontology.Individual> getNamedIndividualByUri(String individualUri)
-
getAllNamedProperties
public org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.OntProperty> getAllNamedProperties()
-
getNamedPropertiesWithLocalName
public org.eclipse.collections.api.list.MutableList<org.apache.jena.rdf.model.Property> getNamedPropertiesWithLocalName(String localName)
-
containsDataProperty
public boolean containsDataProperty(String name)
-
addDataProperty
public org.apache.jena.ontology.DatatypeProperty addDataProperty(String name)
Adds a DatatypeProperty and sets the range. Range is xsd:string- Parameters:
name
- Name of the property- Returns:
- the created DatatypeProperty
-
addDataProperty
public org.apache.jena.ontology.DatatypeProperty addDataProperty(String name, org.apache.jena.rdf.model.Resource domain)
Adds a DatatypeProperty with the given range as type.- Parameters:
name
- Name of the propertydomain
- Domain of the DatatypeProperty- Returns:
- the created DatatypeProperty
-
addDataProperty
public org.apache.jena.ontology.DatatypeProperty addDataProperty(String name, org.apache.jena.rdf.model.Resource domain, org.apache.jena.rdf.model.Resource range)
Adds a DatatypeProperty with the given range as type.- Parameters:
name
- Name of the propertydomain
- Domain of the DatatypePropertyrange
- Range of the DatatypeProperty- Returns:
- the created DatatypeProperty
-
addStringDataPropertyToIndividual
public void addStringDataPropertyToIndividual(org.apache.jena.ontology.Individual individual, org.apache.jena.ontology.DatatypeProperty property, String value)
-
addDataPropertyToIndividual
public void addDataPropertyToIndividual(org.apache.jena.ontology.Individual individual, org.apache.jena.ontology.DatatypeProperty property, Object value)
-
addDataPropertyToIndividual
public void addDataPropertyToIndividual(org.apache.jena.ontology.Individual individual, org.apache.jena.ontology.DatatypeProperty property, Object value, org.apache.jena.datatypes.RDFDatatype type)
-
getDataPropertiesOfIndividual
public org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.DatatypeProperty> getDataPropertiesOfIndividual(String individualName)
-
getDataPropertiesOfIndividualbyUri
public org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.DatatypeProperty> getDataPropertiesOfIndividualbyUri(String individualUri)
-
getDataPropertyValuesForIndividual
public org.eclipse.collections.api.list.MutableList<String> getDataPropertyValuesForIndividual(String datatypePropertyName, String individualUri)
-
getDataPropertyValuesForIndividual
public org.eclipse.collections.api.list.MutableList<String> getDataPropertyValuesForIndividual(org.apache.jena.rdf.model.Property property, String individualUri)
-
getDataProperty
public Optional<org.apache.jena.ontology.DatatypeProperty> getDataProperty(String dataPropertyLocalName)
-
getDataPropertyByUri
public Optional<org.apache.jena.ontology.DatatypeProperty> getDataPropertyByUri(String dataPropertyUri)
-
addObjectProperty
public org.apache.jena.ontology.ObjectProperty addObjectProperty(String objectPropertyName, org.apache.jena.ontology.OntClass domain, org.apache.jena.ontology.OntClass range)
-
addFunctionalObjectProperty
public org.apache.jena.ontology.ObjectProperty addFunctionalObjectProperty(String objectPropertyName, org.apache.jena.ontology.OntClass domain, org.apache.jena.ontology.OntClass range)
-
containsObjectProperty
public boolean containsObjectProperty(String objectPropertyName)
-
getObjectProperty
public Optional<org.apache.jena.ontology.ObjectProperty> getObjectProperty(String objectPropertyName)
-
getObjectPropertyByUri
public Optional<org.apache.jena.ontology.ObjectProperty> getObjectPropertyByUri(String objectPropertyUri)
-
addAllValuesFrom
public org.apache.jena.ontology.AllValuesFromRestriction addAllValuesFrom(String uri, org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.Resource cls)
Adds a restriction that all values have to come from a specific class- Parameters:
uri
- Uri of the restriction, or null if anonymousproperty
- Property that should be restrictedcls
- The class to which all value are restricted to- Returns:
- the restriction
-
addAllValuesFrom
public org.apache.jena.ontology.AllValuesFromRestriction addAllValuesFrom(org.apache.jena.rdf.model.Property property, org.apache.jena.rdf.model.Resource cls)
Adds a restriction that all values have to come from a specific class- Parameters:
property
- Property that should be restrictedcls
- The class to which all value are restricted to- Returns:
- the restriction
-
addAnonymousEnumeratedClass
public org.apache.jena.ontology.EnumeratedClass addAnonymousEnumeratedClass()
-
addEnumeratedClass
public org.apache.jena.ontology.EnumeratedClass addEnumeratedClass(String name)
-
addIndividualToEnumeratedClass
public void addIndividualToEnumeratedClass(org.apache.jena.ontology.EnumeratedClass clazz, org.apache.jena.ontology.Individual individual)
-
addStatement
public void addStatement(org.apache.jena.rdf.model.Resource subject, org.apache.jena.ontology.ObjectProperty property, org.apache.jena.rdf.model.RDFNode object)
Adds a statement provided with a triple (subject, predicate, object)- Parameters:
subject
- the subjectproperty
- the predicateobject
- the object
-
addObjectPropertyOfIndividual
public Optional<org.apache.jena.ontology.ObjectProperty> addObjectPropertyOfIndividual(String subjectShortUri, String propertyName, String objectShortUri)
-
addObjectPropertyOfIndividual
public void addObjectPropertyOfIndividual(org.apache.jena.rdf.model.Resource subject, org.apache.jena.ontology.ObjectProperty property, org.apache.jena.rdf.model.RDFNode object)
Adds anObjectProperty
to an individual.- Parameters:
subject
- Subject of the propertyproperty
- the propertyobject
- Object of the property
-
containsObjectPropertyForIndividuals
public boolean containsObjectPropertyForIndividuals(String subjectName, String propertyName, String objectName)
Checks whether there is an existing ObjectProperty that fulfils the given parameters. A parameter that isnull
matches everything.- Parameters:
subjectName
- name of Subject (or null)propertyName
- name of Property (or null)objectName
- name of Object (or null)- Returns:
- whether there is an existing ObjectProperty with the given subject and object
-
containsObjectPropertyForIndividuals
public boolean containsObjectPropertyForIndividuals(org.apache.jena.rdf.model.Resource subject, org.apache.jena.ontology.ObjectProperty property, org.apache.jena.rdf.model.RDFNode object)
Checks whether there is an existing ObjectProperty that fulfils the given parameters. A parameter that isnull
matches everything.- Parameters:
subject
- Subject (or null)property
- Property (or null)object
- Object (or null)- Returns:
- whether there is an existing ObjectProperty with the given subject and object
-
getObjectPropertiesOfIndividual
public org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.ObjectProperty> getObjectPropertiesOfIndividual(String individualName)
Returns a list ofObjectProperty
for the individual that is provided with its name- Parameters:
individualName
- name of an individual- Returns:
- List of object properties of the individual. If the individual cannot be found, returns an empty list
-
getObjectPropertiesOfIndividualWithUri
public org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.ObjectProperty> getObjectPropertiesOfIndividualWithUri(String individualUri)
Returns a list ofObjectProperty
for individual given by the URI- Parameters:
individualUri
- URI of an individual- Returns:
- List of object properties of the individual. If the individual cannot be found, returns an empty list
-
getObjectPropertiesOfIndividual
public org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.ObjectProperty> getObjectPropertiesOfIndividual(org.apache.jena.rdf.model.Resource individual)
Returns a list ofObjectProperty
for the given individual- Parameters:
individual
- individual- Returns:
- List of object properties of the individual
-
getPropertiesOfIndividual
public org.eclipse.collections.api.list.MutableList<org.apache.jena.rdf.model.Property> getPropertiesOfIndividual(org.apache.jena.rdf.model.Resource individual)
Returns the Properties of an individual- Parameters:
individual
- Individual- Returns:
- List of properties of the individual
-
addFunctionalToProperty
public org.apache.jena.ontology.FunctionalProperty addFunctionalToProperty(org.apache.jena.ontology.OntProperty property)
-
addMinCardinalityToProperty
public org.apache.jena.ontology.MinCardinalityRestriction addMinCardinalityToProperty(org.apache.jena.ontology.OntProperty property, int cardinality)
-
addMaxCardinalityToProperty
public org.apache.jena.ontology.MaxCardinalityRestriction addMaxCardinalityToProperty(org.apache.jena.ontology.OntProperty property, int cardinality)
-
addCardinalityToProperty
public org.apache.jena.ontology.CardinalityRestriction addCardinalityToProperty(org.apache.jena.ontology.OntProperty property, int cardinality)
-
addRangeToProperty
public void addRangeToProperty(org.apache.jena.ontology.OntProperty property, org.apache.jena.rdf.model.Resource range)
-
addDomainToProperty
public void addDomainToProperty(org.apache.jena.ontology.OntProperty property, org.apache.jena.rdf.model.Resource domain)
-
getClass
public Optional<org.apache.jena.ontology.OntClass> getClass(String className)
Returns an Optional holding the class that corresponds to the given name. If no such class exists, returns an empty optional.- Parameters:
className
- Name of the class that should be returned- Returns:
- Optional holding the class that corresponds to the given name, or an empty optional if no such exists
-
addClass
public org.apache.jena.ontology.OntClass addClass(String className)
Adds a class with the given name to the ontology. If the class exists already, returns the existing class.- Parameters:
className
- Name of the class that should be created- Returns:
- created class
-
addSubClassing
public void addSubClassing(org.apache.jena.ontology.OntClass subClass, org.apache.jena.rdf.model.Resource superClass)
-
addSubClassingExclusive
public void addSubClassingExclusive(org.apache.jena.ontology.OntClass subClass, org.apache.jena.rdf.model.Resource superClass)
-
addSubClassOf
public org.apache.jena.ontology.OntClass addSubClassOf(String className, String superClassName)
-
addSubClassOf
public org.apache.jena.ontology.OntClass addSubClassOf(String className, org.apache.jena.ontology.OntClass superClass)
-
addSubClassProperty
public void addSubClassProperty(org.apache.jena.ontology.OntClass subClass, org.apache.jena.ontology.OntClass superClass)
-
classIsSubClassOf
public boolean classIsSubClassOf(org.apache.jena.ontology.OntClass clazz, org.apache.jena.ontology.OntClass superClass)
-
removeSubClassing
public void removeSubClassing(org.apache.jena.ontology.OntClass clazz, org.apache.jena.ontology.OntClass superClass)
-
containsClass
public boolean containsClass(String className)
-
getInstancesOfClass
public org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.Individual> getInstancesOfClass(String className)
Returns the Individuals that have a class that corresponds to the given class name- Parameters:
className
- Name of the class- Returns:
- List of Individuals for the given class (name)
-
getInferredInstancesOfClass
public org.eclipse.collections.api.list.MutableList<org.apache.jena.ontology.Individual> getInferredInstancesOfClass(String className)
-
addInstanceToClass
public org.apache.jena.ontology.Individual addInstanceToClass(String name, org.apache.jena.ontology.OntClass clazz)
Adds an Individual to the given class- Parameters:
name
- name of the individual that should be addedclazz
- Class the individual should be added to- Returns:
- the created individual
-
getObjectPropertyValues
public org.eclipse.collections.api.list.MutableList<org.apache.jena.rdf.model.Resource> getObjectPropertyValues(org.apache.jena.ontology.Individual individual, org.apache.jena.rdf.model.Property property)
Returns the values of the givenObjectProperty
for the providedIndividual
- Parameters:
individual
- Individual that should be checkedproperty
- Property that should be evaluated- Returns:
- List of values for the given Individual and ObjectProperty
-
addComment
public void addComment(org.apache.jena.ontology.OntResource resource, String comment, String lang)
Adds a comment to a resource with the provided language set- Parameters:
resource
- Resource that should be annotated with the commentcomment
- comment that should be annotatedlang
- Language that should be set
-
addLabel
public void addLabel(org.apache.jena.ontology.OntResource resource, String label)
-
addLabel
public void addLabel(org.apache.jena.ontology.OntResource resource, String label, String language)
-
listStatements
public org.apache.jena.rdf.model.StmtIterator listStatements(org.apache.jena.rdf.model.Resource subject, org.apache.jena.rdf.model.Property predicate, org.apache.jena.rdf.model.RDFNode object)
Find all the statements matching a pattern. Lists all statements within the ontology with the given pattern of subject-predicate-object- Parameters:
subject
- Subjectpredicate
- Predicateobject
- Object- Returns:
- all the statements matching the pattern
-
nodeHasClass
public boolean nodeHasClass(org.apache.jena.rdf.model.RDFNode node, org.apache.jena.ontology.OntClass clazz)
Returns whether a node is an instance of the given class- Parameters:
node
- Node that should be checkedclazz
- Class that should be checked for- Returns:
- whether a node is an instance of the given class
-
getShortestPathBetween
public Optional<org.apache.jena.ontology.OntTools.Path> getShortestPathBetween(org.apache.jena.ontology.Individual start, org.apache.jena.ontology.Individual target, Predicate<org.apache.jena.rdf.model.Statement> filter)
-
getUndirectedShortestPathBetween
public Optional<org.apache.jena.ontology.OntTools.Path> getUndirectedShortestPathBetween(org.apache.jena.ontology.Individual start, org.apache.jena.ontology.Individual target, Predicate<org.apache.jena.rdf.model.Statement> filter)
Returns the shortest path between two individuals while treating every edge as undirected. The path can only travel to directions the provided filter allows.- Parameters:
start
- Starting individualtarget
- Target individualfilter
- Filter for valid Statements (for the path)- Returns:
- Optional holding the shortest Path from start to target, if one exists
-
-