|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfo.sswap.impl.empire.model.ReasoningServiceImpl
public class ReasoningServiceImpl
Implementation of the reasoning service for a Jena model.
Nested Class Summary | |
---|---|
static class |
ReasoningServiceImpl.ExplanationSyntax
|
private class |
ReasoningServiceImpl.IndividualTranslator
Translates an individual into using the vocabulary used by the specified class. |
(package private) static class |
ReasoningServiceImpl.PropertyInformation
An entry for caching information about a property so that we do not have to query the reasoner repeatedly about properties. |
static class |
ReasoningServiceImpl.PropertyType
An enum for storing a type of a property (datatype vs object or undefined) |
private class |
ReasoningServiceImpl.ReasoningTaskBase
|
Field Summary | |
---|---|
private boolean |
automaticTermRetrieval
Controls whether reasoning service should retrieve terms (esp. |
private java.util.Map<SSWAPDocument,com.hp.hpl.jena.rdf.model.Model> |
crossDocumentDependencies
Temporarily added dependent SSWAPDocuments (e.g., if a user used a term from a different document in a query) The keys are the SSWAPDocuments, and the values are Jena Models (with TBox of that SSWAPDocument) that have been temporarily added as submodels to this ontModel. |
private boolean |
crossDocumentTermRetrieval
Controls whether reasoning service should monitor attempts to use terms from a different source model, and try to temporarily retrieve information from that different model to answer the query. |
static ReasoningServiceImpl.ExplanationSyntax |
EXPLANATION_SYNTAX
|
private static org.apache.log4j.Logger |
LOGGER
|
private ModelResolver |
mResolver
Used to resolve externally defined terms |
private com.hp.hpl.jena.ontology.OntModel |
ontModel
The Jena OntModel created from the regular Jena model. |
private java.util.Map<java.lang.String,ReasoningServiceImpl.PropertyInformation> |
propertyInformation
A cache for property information so that we do not have repeatedly query the reasoner while validating values. |
private java.util.List<SourceModel> |
sourceModels
The source models for which this reasoning service operates. |
private static java.util.Set<java.lang.String> |
TRANSLATION_NO_FOLLOW_PROPS
A set of URIs of properties that should not be followed during translation/validation process (essentially an exclusion list) Reasons why the predicates are included: - sswap:providedBy - in a typical RDG/RIG/RRG it points to a provider individual, but that provider individual does not contain (in RDG/RIG/RRG) any of the required properties for SSWAPProvider (e.g., name). |
Constructor Summary | |
---|---|
ReasoningServiceImpl(SourceModel sourceModel)
Creates a reasoning service based on Pellet reasoner. |
Method Summary | ||
---|---|---|
void |
addModel(SSWAPModel model)
Adds another model (as a sub-model) whose contents are to be taken into account when reasoning. |
|
private void |
addSourceModel(SourceModel sourceModel)
|
|
private void |
assertCrossModelTerms(SSWAPModel sswapModel)
Ensures that we know all the terms from another document (source model) of the passed model(i.e., separate closure etc), if it happens to be passed to this reasoning service (can happen for two-parameter methods in reasoning service like isSubTypeOf, where one of the arguments (typically the second one) belongs to a different model). |
|
private void |
assertTermKnown(java.net.URI termURI)
Ensures that we know the definition of the term (i.e., if the term is not known, we try to dereference it) |
|
private boolean |
containsPredicateInformation(SSWAPPredicate predicate,
com.hp.hpl.jena.rdf.model.Property informationProperty,
com.hp.hpl.jena.rdf.model.Resource expectedResource)
Checks whether the ontModel contains a specific information about the predicate. |
|
private boolean |
containsPropertyInformation(SSWAPPredicate predicate)
Checks whether this reasoning service has already cached information about the particular property/predicate |
|
private boolean |
containsSourceModel(SSWAPDocument sourceModel)
|
|
private aterm.ATermAppl |
createClassExpression(org.mindswap.pellet.KnowledgeBase kb,
SSWAPNode node,
boolean assertIndirectValues)
Creates a class expression from an individual based on asserted types and properties. |
|
private aterm.ATermAppl |
createClassExpression(org.mindswap.pellet.Node ind,
boolean assertDirectValue,
boolean assertIndirectValues,
java.util.Set<org.mindswap.pellet.Edge> visitedEdges)
|
|
private ReasoningServiceImpl.PropertyInformation |
createPropertyInformation(SSWAPPredicate predicate)
Creates a PropertyInformation entry for the predicate. |
|
com.hp.hpl.jena.rdf.model.Model |
extractABox()
Extracts the ABox from the current OntModel |
|
static com.hp.hpl.jena.rdf.model.Model |
extractABox(com.hp.hpl.jena.rdf.model.Model model)
|
|
com.hp.hpl.jena.rdf.model.Model |
extractInferredIndividualModel(java.net.URI individualURI)
|
|
com.hp.hpl.jena.rdf.model.Model |
extractInferredModel()
|
|
com.hp.hpl.jena.rdf.model.Model |
extractTBox()
Extracts the TBox from the current OntModel |
|
static com.hp.hpl.jena.rdf.model.Model |
extractTBox(com.hp.hpl.jena.rdf.model.Model model)
|
|
static java.util.List<com.hp.hpl.jena.rdf.model.Statement> |
extractTypeDefinition(com.hp.hpl.jena.rdf.model.Model m,
com.hp.hpl.jena.rdf.model.Resource type)
Extracts all the statements that make up an anonymous type. |
|
SSWAPType |
getDomain(SSWAPPredicate predicate)
|
|
java.util.Collection<SSWAPType> |
getDomains(SSWAPPredicate predicate)
|
|
private java.lang.String |
getEnumType(com.hp.hpl.jena.rdf.model.Resource anonDataRange)
|
|
java.util.Collection<java.lang.String> |
getInferredNamedTypes(SSWAPIndividual individual)
Gets all inferred named types for an individual (anonymous classes are not included). |
|
java.util.Collection<java.lang.String> |
getInferredTypes(SSWAPIndividual individual)
Gets all inferred types for the individual. |
|
com.hp.hpl.jena.ontology.OntModel |
getOntModel()
|
|
org.mindswap.pellet.KnowledgeBase |
getPelletKB()
|
|
private java.util.Collection<java.lang.String> |
getPredicateInformation(SSWAPPredicate predicate,
com.hp.hpl.jena.rdf.model.Property informationProperty)
|
|
private ReasoningServiceImpl.PropertyInformation |
getPropertyInformation(SSWAPPredicate predicate)
Gets information about the property. |
|
java.lang.String |
getRange(SSWAPPredicate predicate)
|
|
java.util.Collection<java.lang.String> |
getRanges(SSWAPPredicate predicate)
|
|
private java.lang.String |
getSinglePredicateInformation(SSWAPPredicate predicate,
com.hp.hpl.jena.rdf.model.Property informationProperty)
Gets information about the predicate. |
|
java.util.Collection<java.lang.String> |
getSuperClasses(java.lang.String uri)
|
|
java.lang.String |
getTypeForEnumRange(SSWAPPredicate predicate)
|
|
private void |
handleInconsistentOntologyException(org.mindswap.pellet.exceptions.InconsistentOntologyException e)
|
|
static boolean |
isABoxStatement(com.hp.hpl.jena.rdf.model.Statement s)
Checks whether a triple belongs to ABox. |
|
boolean |
isAnnotationPredicate(SSWAPPredicate predicate)
|
|
private static boolean |
isAnonymousTypeAssertionTriple(com.hp.hpl.jena.rdf.model.Statement s)
Checks whether the given triple asserts that an individual belongs to an anonymous class (i.e., x rdf:type [ ]) |
|
private static boolean |
isAsserted(org.mindswap.pellet.DependencySet ds)
|
|
boolean |
isAutomaticTermRetrieval()
|
|
private static boolean |
isBlacklistedForExtraction(com.hp.hpl.jena.rdf.model.Statement s)
Check whether the statement is not meant to be extracted. |
|
private static boolean |
isBuiltInVocabulary(java.lang.String uri)
Check whether the given URI is a built-in vocabulary (i.e., the vocabulary in owl:, rdf: or rdfs: namespaces |
|
boolean |
isCrossDocumentTermRetrieval()
|
|
boolean |
isDatatypePredicate(SSWAPPredicate predicate)
|
|
boolean |
isDifferentFrom(SSWAPIndividual ind1,
SSWAPIndividual ind2)
|
|
boolean |
isIntersection(java.lang.String type)
|
|
|
isMappingValid(T protocolIndividual,
ProtocolImpl.MappingValidator.MappingType type,
T rdgIndividual)
|
|
boolean |
isObjectPredicate(SSWAPPredicate predicate)
|
|
boolean |
isSameAs(SSWAPIndividual ind1,
SSWAPIndividual ind2)
|
|
private static boolean |
isSSWAPTerm(aterm.ATermAppl term)
|
|
boolean |
isStrictSubPredicateOf(SSWAPPredicate sub,
SSWAPPredicate sup)
Checks whether one predicate is a strict sub predicate of another. |
|
boolean |
isStrictSubTypeOf(SSWAPType sub,
SSWAPType sup)
|
|
boolean |
isSubPredicateOf(SSWAPPredicate sub,
SSWAPPredicate sup)
|
|
boolean |
isSubTypeOf(SSWAPType sub,
SSWAPType sup)
|
|
private static boolean |
isTBoxStatement(com.hp.hpl.jena.rdf.model.Statement s)
Checks whether a triple belongs to a TBox |
|
private boolean |
isTermKnown(java.net.URI termURI)
Checks whether we know anything about the given term (i.e., whether it is used anywhere in the ontModel). |
|
private void |
releaseCrossModelTerms(SSWAPModel... sswapModels)
Releases all the terms that were temporarily imported by assertCrossModelTerms() for each model. |
|
void |
removeModel(SSWAPModel model)
Removes a previously added submodel (via addModel(Model)). |
|
private void |
removeSourceModel(SourceModel sourceModel)
|
|
private java.lang.String |
renderInconsistencyExplanation()
|
|
void |
resetKB()
|
|
private com.hp.hpl.jena.rdf.model.Model |
retrieveAdditionalTerm(java.net.URI termURI)
Retrieves additional term (by dereferencing it). |
|
void |
setAutoDetectChanges(boolean autodetect)
|
|
void |
setAutomaticTermRetrieval(boolean automaticTermRetrieval)
|
|
void |
setCrossDocumentTermRetrieval(boolean crossDocumentTermRetrieval)
|
|
SourceModel |
translate(SSWAPType type,
SSWAPElement individual)
Translates the individual into statements that are required and used by the specified class. |
|
void |
validateConsistency()
Verifies the consistency of the underlying ontologies (together). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final org.apache.log4j.Logger LOGGER
public static ReasoningServiceImpl.ExplanationSyntax EXPLANATION_SYNTAX
private static final java.util.Set<java.lang.String> TRANSLATION_NO_FOLLOW_PROPS
private boolean automaticTermRetrieval
private boolean crossDocumentTermRetrieval
private final com.hp.hpl.jena.ontology.OntModel ontModel
private final java.util.List<SourceModel> sourceModels
private java.util.Map<SSWAPDocument,com.hp.hpl.jena.rdf.model.Model> crossDocumentDependencies
private java.util.Map<java.lang.String,ReasoningServiceImpl.PropertyInformation> propertyInformation
private final ModelResolver mResolver
Constructor Detail |
---|
public ReasoningServiceImpl(SourceModel sourceModel)
sourceModel
- the Jena model to be reasoned overMethod Detail |
---|
public void setAutoDetectChanges(boolean autodetect)
private boolean containsSourceModel(SSWAPDocument sourceModel)
private void addSourceModel(SourceModel sourceModel)
private void removeSourceModel(SourceModel sourceModel)
public void setAutomaticTermRetrieval(boolean automaticTermRetrieval)
public boolean isAutomaticTermRetrieval()
public void setCrossDocumentTermRetrieval(boolean crossDocumentTermRetrieval)
public boolean isCrossDocumentTermRetrieval()
public void validateConsistency() throws ValidationException
ValidationException
- if the ontologies are not consistentprivate void handleInconsistentOntologyException(org.mindswap.pellet.exceptions.InconsistentOntologyException e) throws org.mindswap.pellet.exceptions.InconsistentOntologyException
org.mindswap.pellet.exceptions.InconsistentOntologyException
private java.lang.String renderInconsistencyExplanation()
private com.hp.hpl.jena.rdf.model.Model retrieveAdditionalTerm(java.net.URI termURI)
termURI
- the URI of the term to be retrieved.
private boolean isTermKnown(java.net.URI termURI)
termURI
- the URI of the term that should be checked
private void assertTermKnown(java.net.URI termURI)
termURI
- the URI of the termprivate void assertCrossModelTerms(SSWAPModel sswapModel)
sswapModel
- the term passed to a method where cross-document query is possible. If the document of this model is different
than the document for this reasoning service, this method will add the document to crossDocumentDependencies (remember to use
releaseCrossModelTerms later!)private void releaseCrossModelTerms(SSWAPModel... sswapModels)
sswapModels
- variable list (array) of SSWAPModels from which to remove TBox modelspublic boolean isSameAs(SSWAPIndividual ind1, SSWAPIndividual ind2)
public boolean isDifferentFrom(SSWAPIndividual ind1, SSWAPIndividual ind2)
public boolean isStrictSubTypeOf(SSWAPType sub, SSWAPType sup)
public boolean isSubTypeOf(SSWAPType sub, SSWAPType sup)
public boolean isSubPredicateOf(SSWAPPredicate sub, SSWAPPredicate sup)
public boolean isStrictSubPredicateOf(SSWAPPredicate sub, SSWAPPredicate sup)
sub
- the candidate for the sub predicatesup
- the candidate for the super predicate
public boolean isIntersection(java.lang.String type)
public SSWAPType getDomain(SSWAPPredicate predicate)
public java.util.Collection<SSWAPType> getDomains(SSWAPPredicate predicate)
public java.lang.String getRange(SSWAPPredicate predicate)
public java.util.Collection<java.lang.String> getRanges(SSWAPPredicate predicate)
private java.lang.String getEnumType(com.hp.hpl.jena.rdf.model.Resource anonDataRange)
public java.lang.String getTypeForEnumRange(SSWAPPredicate predicate)
public boolean isObjectPredicate(SSWAPPredicate predicate)
public boolean isDatatypePredicate(SSWAPPredicate predicate)
public boolean isAnnotationPredicate(SSWAPPredicate predicate)
private ReasoningServiceImpl.PropertyInformation getPropertyInformation(SSWAPPredicate predicate)
predicate
- the predicate describing the information requested
private boolean containsPropertyInformation(SSWAPPredicate predicate)
predicate
- the predicate that should be checked
private ReasoningServiceImpl.PropertyInformation createPropertyInformation(SSWAPPredicate predicate)
predicate
- the predicate for which the entry is being created.
public java.util.Collection<java.lang.String> getInferredNamedTypes(SSWAPIndividual individual)
individual
- the individual
public java.util.Collection<java.lang.String> getInferredTypes(SSWAPIndividual individual)
individual
- the individual
public java.util.Collection<java.lang.String> getSuperClasses(java.lang.String uri)
private java.lang.String getSinglePredicateInformation(SSWAPPredicate predicate, com.hp.hpl.jena.rdf.model.Property informationProperty)
predicate
- the SSWAPPredicate to be queried aboutinformationProperty
- the Jena property (e.g., rdfs:domain) that describes the SSWAPPredicate
private java.util.Collection<java.lang.String> getPredicateInformation(SSWAPPredicate predicate, com.hp.hpl.jena.rdf.model.Property informationProperty)
private boolean containsPredicateInformation(SSWAPPredicate predicate, com.hp.hpl.jena.rdf.model.Property informationProperty, com.hp.hpl.jena.rdf.model.Resource expectedResource)
predicate
- the SSWAPPredicate to be queried aboutinformationProperty
- the Jena property (e.g., rdf:type) that describes the SSWAPPredicateexpectedResource
- the expected object (e.g., owl:ObjectProperty)
public void addModel(SSWAPModel model)
ReasoningService
addModel
in interface ReasoningService
model
- dereferenced modelpublic void removeModel(SSWAPModel model)
ReasoningService
removeModel
in interface ReasoningService
model
- dereferenced modelpublic SourceModel translate(SSWAPType type, SSWAPElement individual) throws ValidationException
type
- the URI of the classindividual
- the URI of the individual
ValidationException
- if the individual is not of the specified classpublic com.hp.hpl.jena.rdf.model.Model extractTBox()
public static com.hp.hpl.jena.rdf.model.Model extractTBox(com.hp.hpl.jena.rdf.model.Model model)
public com.hp.hpl.jena.rdf.model.Model extractInferredIndividualModel(java.net.URI individualURI)
private static boolean isBuiltInVocabulary(java.lang.String uri)
uri
- the URI to be checked
private static boolean isBlacklistedForExtraction(com.hp.hpl.jena.rdf.model.Statement s)
s
-
private static boolean isTBoxStatement(com.hp.hpl.jena.rdf.model.Statement s)
s
- Jena statement (triple)
public static boolean isABoxStatement(com.hp.hpl.jena.rdf.model.Statement s)
s
- the triple to be classified as belong to ABox
private static boolean isAnonymousTypeAssertionTriple(com.hp.hpl.jena.rdf.model.Statement s)
s
- statement to be checked
public static java.util.List<com.hp.hpl.jena.rdf.model.Statement> extractTypeDefinition(com.hp.hpl.jena.rdf.model.Model m, com.hp.hpl.jena.rdf.model.Resource type)
m
- the model containing the statementstype
- the resource that represents the anonymous type
public com.hp.hpl.jena.rdf.model.Model extractABox()
public static com.hp.hpl.jena.rdf.model.Model extractABox(com.hp.hpl.jena.rdf.model.Model model)
public com.hp.hpl.jena.rdf.model.Model extractInferredModel()
public void resetKB()
public org.mindswap.pellet.KnowledgeBase getPelletKB()
public com.hp.hpl.jena.ontology.OntModel getOntModel()
public <T extends SSWAPNode> boolean isMappingValid(T protocolIndividual, ProtocolImpl.MappingValidator.MappingType type, T rdgIndividual)
private aterm.ATermAppl createClassExpression(org.mindswap.pellet.KnowledgeBase kb, SSWAPNode node, boolean assertIndirectValues)
private aterm.ATermAppl createClassExpression(org.mindswap.pellet.Node ind, boolean assertDirectValue, boolean assertIndirectValues, java.util.Set<org.mindswap.pellet.Edge> visitedEdges)
private static boolean isAsserted(org.mindswap.pellet.DependencySet ds)
private static boolean isSSWAPTerm(aterm.ATermAppl term)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |