Class EntityMappingImpl

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

public class EntityMappingImpl extends Object implements EntityMapping
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>>
     
    protected final Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    EntityMappingImpl(Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>> g2l)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.jena.sparql.expr.Expr
    applyInverseToExpression(org.apache.jena.sparql.expr.Expr expr)
    Applies this entity mapping to the given filter expression, which is assumed to use the local representation of the entities mentioned in it, and returns the translated expression.
    Applies the inverse of this entity mapping to the given solution mapping, which is assumed to use the local representation of the entities that it binds to its query variables.
    applyMapToSolutionMapping(SolutionMapping solMap, Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>> x2yMap)
     
    org.apache.jena.sparql.expr.Expr
    applyToExpression(org.apache.jena.sparql.expr.Expr expr)
    Applies this entity mapping to the given filter expression, which is assumed to use the global representation of the entities mentioned in it, and returns the translated expression.
    protected org.apache.jena.sparql.expr.Expr
    applyToExpression(org.apache.jena.sparql.expr.Expr expr, boolean useInverse)
     
    Applies this entity mapping to the given solution mapping, which is assumed to use the global representation of the entities that it binds to its query variables.
    Applies this mapping to the given triple pattern and returns the resulting set of triple patterns that is meant to be used as a union.
    protected static Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>>
    createL2G(Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>> g2lMap)
     
    protected List<org.apache.jena.sparql.expr.Expr>
    expandExpression(org.apache.jena.sparql.expr.Expr e, boolean useInverse)
    Expands the given expression according to an entity mapping.
    protected org.apache.jena.sparql.expr.Expr
    rewriteComparison(org.apache.jena.sparql.expr.Expr expr, boolean useInverse)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • g2lMap

      protected final Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>> g2lMap
    • l2gMap

      protected final Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>> l2gMap
  • Constructor Details

    • EntityMappingImpl

      public EntityMappingImpl(Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>> g2l)
  • Method Details

    • createL2G

      protected static Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>> createL2G(Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>> g2lMap)
    • applyToTriplePattern

      public Set<TriplePattern> applyToTriplePattern(TriplePattern tp)
      Description copied from interface: EntityMapping
      Applies this mapping to the given triple pattern and returns the resulting set of triple patterns that is meant to be used as a union. If this mapping is not relevant for any of the entities mentioned in 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 a singleton set that contains the given triple pattern without any changes.
      Specified by:
      applyToTriplePattern in interface EntityMapping
    • applyToExpression

      public org.apache.jena.sparql.expr.Expr applyToExpression(org.apache.jena.sparql.expr.Expr expr)
      Description copied from interface: EntityMapping
      Applies this entity mapping to the given filter expression, which is assumed to use the global representation of the entities mentioned in it, and returns the translated expression. If this entity mapping is not relevant for the given expression (i.e., applying this entity 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 EntityMapping
    • applyInverseToExpression

      public org.apache.jena.sparql.expr.Expr applyInverseToExpression(org.apache.jena.sparql.expr.Expr expr)
      Description copied from interface: EntityMapping
      Applies this entity mapping to the given filter expression, which is assumed to use the local representation of the entities mentioned in it, and returns the translated expression. If this entity mapping is not relevant for the given expression (i.e., applying this entity 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 EntityMapping
    • 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: EntityMapping
      Applies this entity mapping to the given solution mapping, which is assumed to use the global representation of the entities that it binds to its query variables. If this entity mapping is not relevant for any of the entities mentioned in the given solution mapping (i.e., applying this entity 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 EntityMapping
    • applyInverseToSolutionMapping

      public Set<SolutionMapping> applyInverseToSolutionMapping(SolutionMapping sm)
      Description copied from interface: EntityMapping
      Applies the inverse of this entity mapping to the given solution mapping, which is assumed to use the local representation of the entities that it binds to its query variables. If this entity mapping is not relevant for any of the entities mentioned in the given solution mapping (i.e., applying this entity 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 EntityMapping
    • applyMapToSolutionMapping

      public static Set<SolutionMapping> applyMapToSolutionMapping(SolutionMapping solMap, Map<org.apache.jena.graph.Node,Set<org.apache.jena.graph.Node>> x2yMap)
    • rewriteComparison

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

      protected List<org.apache.jena.sparql.expr.Expr> expandExpression(org.apache.jena.sparql.expr.Expr e, boolean useInverse)
      Expands the given expression according to an entity 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