info.sswap.impl.empire.model
Class ReasoningServiceImpl.IndividualTranslator

java.lang.Object
  extended by info.sswap.impl.empire.model.ReasoningServiceImpl.ReasoningTaskBase
      extended by info.sswap.impl.empire.model.ReasoningServiceImpl.IndividualTranslator
Enclosing class:
ReasoningServiceImpl

private class ReasoningServiceImpl.IndividualTranslator
extends ReasoningServiceImpl.ReasoningTaskBase

Translates an individual into using the vocabulary used by the specified class. (The individual must belong to that class.) This kind of translation is performed when the individual belongs to a more specific class, which could have created its own vocabulary (e.g., by creating subProperties or by using subclasses for values of properties), and we want to express that individual using the concepts/classes of a more generic class. An example of a use case when such a situation happens is when a client sends an RIG to the provider, and that RIG can use concepts different than the original RDG. This class will validate and translate all properties for that individual back into using the RDG terminology.

Author:
Blazej Bulka

Nested Class Summary
private  class ReasoningServiceImpl.IndividualTranslator.TranslationCache
          Contains cache of translation results.
 
Nested classes/interfaces inherited from class info.sswap.impl.empire.model.ReasoningServiceImpl.ReasoningTaskBase
ReasoningServiceImpl.ReasoningTaskBase.ClassIndividualMapping
 
Field Summary
private  ReasoningServiceImpl.IndividualTranslator.TranslationCache cache
          A cache for already translated concepts.
private  java.util.Stack<java.lang.String> classExplanationStack
          Stack of named classes that represents the dependencies between named classes being translated.
private  com.hp.hpl.jena.rdf.model.Model model
          The model where the translated concepts will be stored.
 
Constructor Summary
private ReasoningServiceImpl.IndividualTranslator()
           
 
Method Summary
private  void assertContainsTriple(java.lang.String subject, java.lang.String predicate, java.lang.String object)
          Asserts that the underlying ont model contains the specified triple.
private  boolean containsTriple(java.lang.String subject, java.lang.String predicate, java.lang.String object)
          Checks whether the underlying ontModel contains the specified triple
private  com.hp.hpl.jena.rdf.model.Statement createTriple(java.lang.String subject, java.lang.String predicate, java.lang.String object)
          Creates a triple.
 com.hp.hpl.jena.rdf.model.Model getTranslatedModel(aterm.ATermAppl clazz, aterm.ATermAppl individual)
          Creates a Jena model with translated information for the individual
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translate(aterm.ATermAppl clazz, aterm.ATermAppl individual)
          Translates the individual into the vocabulary used by the specified class
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateAllValues(aterm.ATermAppl allValues, aterm.ATermAppl individual)
          Translates an owl:allValuesFrom restriction and the property referenced in it.
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateCard(aterm.ATermAppl card, aterm.ATermAppl individual)
          Translates an owl:cardinality restriction for the individual, and the property referenced in it
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateCardinality(aterm.ATermAppl individual, aterm.ATermAppl property, int n, aterm.ATermAppl rangeRestriction, boolean enforceRange)
          Translates a minimum cardinality constraint, and the property referenced in it
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateComplementOf(aterm.ATermAppl complement, aterm.ATermAppl individual)
          Translates an owl:complementOf
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateDomain(aterm.ATermAppl role, aterm.ATermAppl individual)
           
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateIntersectionOf(aterm.ATermAppl intersection, aterm.ATermAppl individual)
          Translates an owl:intersectionOf
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateMax(aterm.ATermAppl max, aterm.ATermAppl individual)
          Translates owl:maxCardinality restriction for the individual and the property referenced in it
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateMin(aterm.ATermAppl min, aterm.ATermAppl individual)
          Translates an owl:minCardinality restriction and the property referenced in it
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateNamedClass(aterm.ATermAppl namedClass, aterm.ATermAppl individual)
          Translates a named class expression (this includes both named classes and intersections/unions/complements that got assigned a special bnode URI).
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateSelf(aterm.ATermAppl self, aterm.ATermAppl individual)
          Translates owl:hasSelf restriction for the individual and the property referenced in it
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateSomeValues(aterm.ATermAppl someValues, aterm.ATermAppl individual)
          Translates an owl:someValuesFrom restriction and the property referenced in it.
private  java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateUnionOf(aterm.ATermAppl union, aterm.ATermAppl individual)
          Translates an owl:unionOf
private  void validateNone(aterm.ATermAppl individual, aterm.ATermAppl property)
          Validate that there are no values for the property and individual.
 
Methods inherited from class info.sswap.impl.empire.model.ReasoningServiceImpl.ReasoningTaskBase
getDomains, getEquivalentClasses, getRanges, getSuperClasses, getTBoxAxioms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

private com.hp.hpl.jena.rdf.model.Model model
The model where the translated concepts will be stored.


cache

private ReasoningServiceImpl.IndividualTranslator.TranslationCache cache
A cache for already translated concepts. The cache not only includes efficiency (e.g., when the subclass relationships do not form a tree, and a super class can be visited multiple times for an individual), but also prevents infinite loops (e.g., when two classes list each other as equivalent).


classExplanationStack

private java.util.Stack<java.lang.String> classExplanationStack
Stack of named classes that represents the dependencies between named classes being translated. When a class C is being translated, it is pushed on the stack, when its superclass B is translated (as a part of C's translation), it is then pushed on the stack, and popped when its translation is finished. Similar push/pop will also occur for every equivalent class of the currently validated class. The purpose of this stack is to provide more meaningful explanations in ValidationExceptions. If we are to generate an exception at any place (due to restriction violation), the name on the top of the stack (if there is any) identifies the class where the violated restriction was defined (either directly in this class or in one of its anonymous super-/equivalent- classes).

Constructor Detail

ReasoningServiceImpl.IndividualTranslator

private ReasoningServiceImpl.IndividualTranslator()
Method Detail

getTranslatedModel

public com.hp.hpl.jena.rdf.model.Model getTranslatedModel(aterm.ATermAppl clazz,
                                                          aterm.ATermAppl individual)
                                                   throws ValidationException
Creates a Jena model with translated information for the individual

Parameters:
clazz - the class to which the individual should belong (and whose terms should be used)
individual - the individual whose information should be translated.
Returns:
the model with the translated information
Throws:
ValidationException - if the individual does not conform to the restrictions defined in the specified class

translate

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translate(aterm.ATermAppl clazz,
                                                                            aterm.ATermAppl individual)
                                                                     throws ValidationException
Translates the individual into the vocabulary used by the specified class

Parameters:
clazz - the class to which the individual should belong
individual - the individual to be translated
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not belong to the class (e.g., it violates a restriction on a property)

translateNamedClass

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateNamedClass(aterm.ATermAppl namedClass,
                                                                                      aterm.ATermAppl individual)
                                                                               throws ValidationException
Translates a named class expression (this includes both named classes and intersections/unions/complements that got assigned a special bnode URI).

Parameters:
namedClass - the named class expression
individual - the individual that should belong that class expression
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not belong to this class

translateIntersectionOf

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateIntersectionOf(aterm.ATermAppl intersection,
                                                                                          aterm.ATermAppl individual)
                                                                                   throws ValidationException
Translates an owl:intersectionOf

Parameters:
intersection - the intersection of class expressions
individual - the individual that should satisfy all expressions in the intersection
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not satisfy one or more class expressions

translateUnionOf

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateUnionOf(aterm.ATermAppl union,
                                                                                   aterm.ATermAppl individual)
                                                                            throws ValidationException
Translates an owl:unionOf

Parameters:
union - the union of class expressions
individual - the individual that should satisfy all expressions in the intersection
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not satisfy one or more class expressions

translateComplementOf

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateComplementOf(aterm.ATermAppl complement,
                                                                                        aterm.ATermAppl individual)
                                                                                 throws ValidationException
Translates an owl:complementOf

Parameters:
complement - the complement
individual - the individual that should belong to the complement
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not belong to the complement

translateSomeValues

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateSomeValues(aterm.ATermAppl someValues,
                                                                                      aterm.ATermAppl individual)
                                                                               throws ValidationException
Translates an owl:someValuesFrom restriction and the property referenced in it.

Parameters:
someValues - the ATerm describing the restriction
individual - the individual that should satisfy the restriction
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not satisfy the restriction

translateAllValues

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateAllValues(aterm.ATermAppl allValues,
                                                                                     aterm.ATermAppl individual)
                                                                              throws ValidationException
Translates an owl:allValuesFrom restriction and the property referenced in it.

Parameters:
allValues - the ATerm describing the restriction
individual - the individual that should satisfy the restriction
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not satisfy the restriction

translateMin

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateMin(aterm.ATermAppl min,
                                                                               aterm.ATermAppl individual)
                                                                        throws ValidationException
Translates an owl:minCardinality restriction and the property referenced in it

Parameters:
min - the ATerm describing the restriction
individual - the individual that should satisfy the restriction
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not satisfy the restriction

translateMax

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateMax(aterm.ATermAppl max,
                                                                               aterm.ATermAppl individual)
                                                                        throws ValidationException
Translates owl:maxCardinality restriction for the individual and the property referenced in it

Parameters:
max - the ATerm describing the restriction
individual - the individual that should satisfy the restriction
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not satisfy the restriction

translateCard

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateCard(aterm.ATermAppl card,
                                                                                aterm.ATermAppl individual)
                                                                         throws ValidationException
Translates an owl:cardinality restriction for the individual, and the property referenced in it

Parameters:
card - the ATerm describing the restriction
individual - the individual that should satisfy the restriction
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not satisfy the restriction

translateSelf

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateSelf(aterm.ATermAppl self,
                                                                                aterm.ATermAppl individual)
                                                                         throws ValidationException
Translates owl:hasSelf restriction for the individual and the property referenced in it

Parameters:
self - the ATerm describing the restriction
individual - the individual that should satisfy the restriction
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not satisfy the restriction

translateDomain

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateDomain(aterm.ATermAppl role,
                                                                                  aterm.ATermAppl individual)
                                                                           throws ValidationException
Throws:
ValidationException

translateCardinality

private java.util.Collection<com.hp.hpl.jena.rdf.model.Statement> translateCardinality(aterm.ATermAppl individual,
                                                                                       aterm.ATermAppl property,
                                                                                       int n,
                                                                                       aterm.ATermAppl rangeRestriction,
                                                                                       boolean enforceRange)
                                                                                throws ValidationException
Translates a minimum cardinality constraint, and the property referenced in it

Parameters:
individual - the individual for which the cardinality is verified
property - the property on which the cardinality restriction is placed
n - the minimum cardinality
rangeRestriction - the range of the property
enforceRange - if true, throw Validation exception whenever there is any value that does not match the range, otherwise only throw exception whenever the count of valid values (matching the range) violates the cardinality restriction
Returns:
a collection of statements that are the result of translation
Throws:
ValidationException - if the individual does not satisfy the restriction

validateNone

private void validateNone(aterm.ATermAppl individual,
                          aterm.ATermAppl property)
                   throws ValidationException
Validate that there are no values for the property and individual.

Parameters:
individual - the individual
property - the property
Throws:
ValidationException - if there are values for that property and individual

assertContainsTriple

private void assertContainsTriple(java.lang.String subject,
                                  java.lang.String predicate,
                                  java.lang.String object)
                           throws ValidationException
Asserts that the underlying ont model contains the specified triple.

Parameters:
subject - the subject of the triple
predicate - the predicate of the triple
object - the object of the triple
Throws:
ValidationException - if there is no such a triple in the ont model.

containsTriple

private boolean containsTriple(java.lang.String subject,
                               java.lang.String predicate,
                               java.lang.String object)
Checks whether the underlying ontModel contains the specified triple

Parameters:
subject - the subject of the triple
predicate - the predicate of the triple
object - the object of the triple
Returns:
true if the ont model contains the triple, false if it does not

createTriple

private com.hp.hpl.jena.rdf.model.Statement createTriple(java.lang.String subject,
                                                         java.lang.String predicate,
                                                         java.lang.String object)
Creates a triple.

Parameters:
subject - subject URI
predicate - predicate URI
object - object URI
Returns:
a new Jena Statement from the subject, predicate, and object


Copyright (c) 2011, iPlant Collaborative, University of Arizona, Cold Spring Harbor Laboratories, University of Texas at Austin.