Class SchemaMappingImpl

java.lang.Object
se.liu.ida.hefquin.base.data.mappings.impl.SchemaMappingImpl
All Implemented Interfaces:
SchemaMapping

public class SchemaMappingImpl extends Object implements SchemaMapping
  • Field Details

    • g2lMap

      protected final Map<org.apache.jena.graph.Node,Set<TermMapping>> g2lMap
      The keys of this map are global terms, and the value for each such global term is a set of all term mappings that have the global term as their TermMapping.getGlobalTerm(). The union of all the sets that are values in this map is exactly the same set of term mappings as the union of all the sets that are values in l2gMap.
    • l2gMap

      protected final Map<org.apache.jena.graph.Node,Set<TermMapping>> l2gMap
      The keys of this map are local terms, and the value for each such local term is a set of all term mappings that have the local term as an element of their TermMapping.getLocalTerms(). The union of all the sets that are values in this map is exactly the same set of term mappings as the union of all the sets that are values in g2lMap.
    • isEquivalenceOnly

      protected final boolean isEquivalenceOnly
  • Constructor Details

    • SchemaMappingImpl

      public SchemaMappingImpl(Map<org.apache.jena.graph.Node,Set<TermMapping>> g2lMap)
  • Method Details

    • populateL2G

      protected static boolean populateL2G(Map<org.apache.jena.graph.Node,Set<TermMapping>> g2lMap, Map<org.apache.jena.graph.Node,Set<TermMapping>> l2gMap)
      Populates the given l2gMap based on the given g2lMap and returns whether all the TermMappings in g2lMap are equivalence mappings only.
    • isEquivalenceOnly

      public boolean isEquivalenceOnly()
      Description copied from interface: SchemaMapping
      Checks whether the schema mapping only contains equivalence rules, e.g., owl:equivalentClass, owl:equivalentProperty Return true if the schema mapping consists solely of equivalence rules, false otherwise.
      Specified by:
      isEquivalenceOnly in interface SchemaMapping
    • applyToTriplePattern

      public SPARQLGraphPattern applyToTriplePattern(TriplePattern tp)
      Description copied from interface: SchemaMapping
      Applies this mapping to the given triple pattern and returns the resulting graph pattern. If this mapping is not relevant for the the given triple pattern (i.e., applying the mapping to the triple pattern does not have any effect), then the result of this function is simply the given triple pattern itself.
      Specified by:
      applyToTriplePattern in interface SchemaMapping
    • applyToExpression

      public org.apache.jena.sparql.expr.Expr applyToExpression(org.apache.jena.sparql.expr.Expr expr)
      Description copied from interface: SchemaMapping
      Applies this schema mapping to the given filter expression, which is assumed to use the global schema for the vocabulary terms mentioned in it, and returns the translated expression. If this schema mapping is not relevant for the given expression (i.e., applying this schema mapping does not change the expression), then the result of this function is simply the given expression itself.

      It may not be possible to translate every expression; if the given expression cannot be translated, then this method throws an UnsupportedOperationException.

      Specified by:
      applyToExpression in interface SchemaMapping
    • applyInverseToExpression

      public org.apache.jena.sparql.expr.Expr applyInverseToExpression(org.apache.jena.sparql.expr.Expr expr)
      Description copied from interface: SchemaMapping
      Applies this schema mapping to the given filter expression, which is assumed to use the local schema for the vocabulary terms mentioned in it, and returns the translated expression. If this schema mapping is not relevant for the given expression (i.e., applying this schema mapping does not change the expression), then the result of this function is simply the given expression itself.

      It may not be possible to translate every expression; if the given expression cannot be translated, then this method throws an UnsupportedOperationException.

      Specified by:
      applyInverseToExpression in interface SchemaMapping
    • applyToExpression

      protected org.apache.jena.sparql.expr.Expr applyToExpression(org.apache.jena.sparql.expr.Expr expr, boolean useInverse)
    • applyToSolutionMapping

      public Set<SolutionMapping> applyToSolutionMapping(SolutionMapping sm)
      Description copied from interface: SchemaMapping
      Applies this schema mapping to the given solution mapping, which is assumed to use the global schema for the vocabulary terms that it binds to its query variables. If this schema mapping is not relevant for anything mentioned in the given solution mapping (i.e., applying this schema mapping to the solution mapping does not have any effect), then the result of this function is simply a singleton set that contains the given solution mapping without any changes.
      Specified by:
      applyToSolutionMapping in interface SchemaMapping
    • applyInverseToSolutionMapping

      public Set<SolutionMapping> applyInverseToSolutionMapping(SolutionMapping sm)
      Description copied from interface: SchemaMapping
      Applies the inverse of this schema mapping to the given solution mapping, which is assumed to use the local schema for the vocabulary terms that it binds to its query variables. If this schema mapping is not relevant for anything mentioned in the given solution mapping (i.e., applying the inverse of this schema mapping to the solution mapping does not have any effect), then the result of this function is simply a singleton set that contains the given solution mapping without any changes.
      Specified by:
      applyInverseToSolutionMapping in interface SchemaMapping
    • applyToSolutionMapping

      protected Set<SolutionMapping> applyToSolutionMapping(SolutionMapping solMap, boolean useInverse)
    • rewriteComparison

      protected org.apache.jena.sparql.expr.Expr rewriteComparison(org.apache.jena.sparql.expr.Expr expr, boolean useInverse)
    • expandExpression

      public List<org.apache.jena.sparql.expr.Expr> expandExpression(org.apache.jena.sparql.expr.Expr e, boolean useInverse)
      Expands the given expression according to a schema mapping.

      If the expression is a constant URI, it is translated to its corresponding local terms. If multiple local terms exist, a corresponding expression is created for each of them. Expressions that are not constant URIs are returned unchanged as a singleton list. Non-constant expressions are only returned unchanged if they do not contain any mapped global URIs anywhere in their structure.

      Parameters:
      e - the expression to expand
      Returns:
      the translated expressions
    • extractGlobalTermsForLocalTerm

      protected Set<org.apache.jena.graph.Node> extractGlobalTermsForLocalTerm(Set<TermMapping> mappingsForTerm)
    • extractLocalTermsForGlobalTerm

      protected Set<org.apache.jena.graph.Node> extractLocalTermsForGlobalTerm(Set<TermMapping> mappingsForTerm)