java.lang.Object
org.aksw.jena_sparql_api.collection.observable.GraphChange
Direct Known Subclasses:
GraphChangeWithBaseGraph

public class GraphChange extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected ObservableGraph
    Explicitly added triples - does not include the values of renamedNodes
    protected ObservableGraph
    Explicitly deleted triples
    protected ObservableGraph
     
    protected ObservableGraph
    Effective deletions: The set of triples w.r.t.
    protected org.aksw.commons.collection.observable.ObservableSet<org.apache.jena.graph.Node>
    The set of newly added nodes which should be blank nodes only.
    Replacing a triple with null counts as a deletion
    protected org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Node,org.apache.jena.graph.Node>
    A set of blank that were newly created and must thus not clash with existing resources
    protected com.google.common.collect.Multimap<org.apache.jena.graph.Node,RdfField>
     
    protected org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Triple,org.apache.jena.graph.Triple>
    Mapping of original triples to their edited versions.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    GraphChange(org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Node,org.apache.jena.graph.Node> renamedNodes, org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Triple,org.apache.jena.graph.Triple> tripleReplacements)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Listeners for after changes occurred.
    static org.apache.jena.graph.Graph
    createEffectiveGraphView(org.apache.jena.graph.Graph baseGraph, GraphChange graphChange)
    A graph view of the final state: - Nodes that were renamed are no longer visible.
    org.aksw.commons.collection.observable.ObservableValue<org.apache.jena.graph.Node>
    createFieldForExistingTriple(org.apache.jena.graph.Triple baseTriple, int componentIdx)
    Create a reference to a specific triple such that one of its components can be modified.
    createSetField(org.apache.jena.graph.Node sourceNode, org.apache.jena.graph.Node predicate, boolean isForward)
    Create a field over a set of triples with a certain source and predicate.
    static org.apache.jena.sparql.algebra.Table
    createTableFromEnties(org.apache.jena.sparql.core.Var keyVar, org.apache.jena.sparql.core.Var valueVar, Collection<? extends Map.Entry<? extends org.apache.jena.graph.Node,? extends org.apache.jena.graph.Node>> entrySet)
     
    static org.apache.jena.sparql.modify.request.UpdateDeleteInsert
    createUpdateRenameComponent(int componentIdx, Collection<? extends Map.Entry<? extends org.apache.jena.graph.Node,? extends org.apache.jena.graph.Node>> renamedNodes)
     
    static <T> Collection<T>
    defaultToSingletonIfEmpty(Collection<T> items, T defaultItem)
     
    static Stream<org.apache.jena.graph.Triple>
    expand(org.apache.jena.graph.Triple concrete, org.apache.jena.graph.Triple pattern, Function<org.apache.jena.graph.Node,Collection<org.apache.jena.graph.Node>> clusterToMembers)
    Create all possible triples by substituting each node in the triple with all possible nodes w.r.t.
    static <T> Collection<T>
    filterToPattern(Collection<T> collection, T pattern)
    Filter a collection based on a pattern with the following rules: If pattern is null returned the collection unchanged.
    static Collection<org.apache.jena.graph.Node>
    filterToPattern(Function<org.apache.jena.graph.Node,Collection<org.apache.jena.graph.Node>> fn, org.apache.jena.graph.Node node, org.apache.jena.graph.Node pattern)
     
    org.apache.jena.graph.Node
     
    static <T> Collection<T>
    get(com.google.common.collect.Multimap<T,T> multimap, T key, boolean reflexive)
     
     
     
     
     
    org.aksw.commons.collection.observable.ObservableSet<org.apache.jena.graph.Node>
     
    static <K, V> V
    getOrDefault(Function<? super K,? extends V> fn, K key, V defaultValue)
     
    org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Node,org.apache.jena.graph.Node>
     
    org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Triple,org.apache.jena.graph.Triple>
     
    boolean
    isDeleted(org.apache.jena.graph.Triple triple)
     
    static <T> void
    makeSetEqual(Set<T> target, Set<T> reference)
    Make the set of items contained in target equal to those contained in reference thereby calling .add() and .remove() only on items that differ.
    static <T> Collection<T>
     
    putRename(org.apache.jena.graph.Node before, org.apache.jena.graph.Node after)
    Puts an entry into the rename map with the following extra rule: If both arguments are equal (a rename of a node to itself) then the rename entry is removed.
    org.apache.jena.update.UpdateRequest
    Creates a SPARQL update request from the state of this object as follows: Pre-rename deletes: Delete the concrete triples (without renaming) Resource renaming: Rename subjects/predicate/objects Post-rename updates: Apply the triple replacements after renaming; unchanged components are subject to renaming / those that differ not Add the concrete triples

    Methods inherited from class java.lang.Object

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

    • renamedNodes

      protected org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Node,org.apache.jena.graph.Node> renamedNodes
      A set of blank that were newly created and must thus not clash with existing resources
    • tripleReplacements

      protected org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Triple,org.apache.jena.graph.Triple> tripleReplacements
      Mapping of original triples to their edited versions. The nodes of the target triple are subject to renaming: If some source node in a triple gets specifically set to another node, and that other node is mapped to a new target node then it seems reasonable to rename the source node to the target one.
    • sourceNodeToField

      protected com.google.common.collect.Multimap<org.apache.jena.graph.Node,RdfField> sourceNodeToField
    • additionGraph

      protected ObservableGraph additionGraph
      Explicitly added triples - does not include the values of renamedNodes
    • deletionGraph

      protected ObservableGraph deletionGraph
      Explicitly deleted triples
    • effectiveDeletionGraph

      protected ObservableGraph effectiveDeletionGraph
      Effective deletions: The set of triples w.r.t. the base graph that are known to be deleted. This set is the union of the triples that occur in - the base graph that are intensionally deleted by fields - the deletion graph - the key set of the renamed triples
    • effectiveAdditionGraph

      protected ObservableGraph effectiveAdditionGraph
    • newNodes

      protected org.aksw.commons.collection.observable.ObservableSet<org.apache.jena.graph.Node> newNodes
      The set of newly added nodes which should be blank nodes only. These new nodes can participate in triples and can be renamed.
    • pce

      protected PropertyChangeSupport pce
      Replacing a triple with null counts as a deletion
  • Constructor Details

    • GraphChange

      public GraphChange()
    • GraphChange

      public GraphChange(org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Node,org.apache.jena.graph.Node> renamedNodes, org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Triple,org.apache.jena.graph.Triple> tripleReplacements)
  • Method Details

    • getNewNodes

      public org.aksw.commons.collection.observable.ObservableSet<org.apache.jena.graph.Node> getNewNodes()
    • freshNode

      public org.apache.jena.graph.Node freshNode()
    • putRename

      public GraphChange putRename(org.apache.jena.graph.Node before, org.apache.jena.graph.Node after)
      Puts an entry into the rename map with the following extra rule: If both arguments are equal (a rename of a node to itself) then the rename entry is removed.
      Parameters:
      before -
      after -
      Returns:
    • getEffectiveAdditionGraph

      public ObservableGraph getEffectiveAdditionGraph()
    • getEffectiveDeletionGraph

      public ObservableGraph getEffectiveDeletionGraph()
    • isDeleted

      public boolean isDeleted(org.apache.jena.graph.Triple triple)
    • addPropertyChangeListener

      public Runnable addPropertyChangeListener(PropertyChangeListener listener)
      Listeners for after changes occurred. This allows listeners to update their state
    • createFieldForExistingTriple

      public org.aksw.commons.collection.observable.ObservableValue<org.apache.jena.graph.Node> createFieldForExistingTriple(org.apache.jena.graph.Triple baseTriple, int componentIdx)
      Create a reference to a specific triple such that one of its components can be modified. Note that node remapping is applied after the triple remapping. - Fields that delete the original triple are NOT in conflict. - Fields that delete the target triple AFTER node remapping ARE in conflict I.e. the result of editing must not result in a newly added triple being immediately deleted again
      Parameters:
      baseTriple -
      componentIdx -
      Returns:
    • createSetField

      public RdfField createSetField(org.apache.jena.graph.Node sourceNode, org.apache.jena.graph.Node predicate, boolean isForward)
      Create a field over a set of triples with a certain source and predicate. Setting a value corresponds to a replacement of the intensional set of triples with a specific new one.
    • getTripleReplacements

      public org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Triple,org.apache.jena.graph.Triple> getTripleReplacements()
    • getRenamedNodes

      public org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Node,org.apache.jena.graph.Node> getRenamedNodes()
    • getAdditionGraph

      public ObservableGraph getAdditionGraph()
    • getDeletionGraph

      public ObservableGraph getDeletionGraph()
    • nullableSingleton

      public static <T> Collection<T> nullableSingleton(T item)
    • makeSetEqual

      public static <T> void makeSetEqual(Set<T> target, Set<T> reference)
      Make the set of items contained in target equal to those contained in reference thereby calling .add() and .remove() only on items that differ. I.e. this method does NOT perform target.clear() followed by target.addAll(reference)
    • defaultToSingletonIfEmpty

      public static <T> Collection<T> defaultToSingletonIfEmpty(Collection<T> items, T defaultItem)
    • filterToPattern

      public static <T> Collection<T> filterToPattern(Collection<T> collection, T pattern)
      Filter a collection based on a pattern with the following rules: If pattern is null returned the collection unchanged. Otherwise, if the pattern is contained in the collection return a collection with only that item otherwise return an empty collection.
      Type Parameters:
      T -
      Parameters:
      collection -
      pattern -
      Returns:
    • filterToPattern

      public static Collection<org.apache.jena.graph.Node> filterToPattern(Function<org.apache.jena.graph.Node,Collection<org.apache.jena.graph.Node>> fn, org.apache.jena.graph.Node node, org.apache.jena.graph.Node pattern)
    • get

      public static <T> Collection<T> get(com.google.common.collect.Multimap<T,T> multimap, T key, boolean reflexive)
    • getOrDefault

      public static <K, V> V getOrDefault(Function<? super K,? extends V> fn, K key, V defaultValue)
    • expand

      public static Stream<org.apache.jena.graph.Triple> expand(org.apache.jena.graph.Triple concrete, org.apache.jena.graph.Triple pattern, Function<org.apache.jena.graph.Node,Collection<org.apache.jena.graph.Node>> clusterToMembers)
      Create all possible triples by substituting each node in the triple with all possible nodes w.r.t. the reverse mapping. If a node is not mapped it remains itself.
      Parameters:
      concrete -
      reverseMap -
      Returns:
    • createTableFromEnties

      public static org.apache.jena.sparql.algebra.Table createTableFromEnties(org.apache.jena.sparql.core.Var keyVar, org.apache.jena.sparql.core.Var valueVar, Collection<? extends Map.Entry<? extends org.apache.jena.graph.Node,? extends org.apache.jena.graph.Node>> entrySet)
    • createUpdateRenameComponent

      public static org.apache.jena.sparql.modify.request.UpdateDeleteInsert createUpdateRenameComponent(int componentIdx, Collection<? extends Map.Entry<? extends org.apache.jena.graph.Node,? extends org.apache.jena.graph.Node>> renamedNodes)
    • toUpdateRequest

      public org.apache.jena.update.UpdateRequest toUpdateRequest()
      Creates a SPARQL update request from the state of this object as follows:
      1. Pre-rename deletes: Delete the concrete triples (without renaming)
      2. Resource renaming: Rename subjects/predicate/objects
      3. Post-rename updates: Apply the triple replacements after renaming; unchanged components are subject to renaming / those that differ not
      4. Add the concrete triples
      Returns:
    • createEffectiveGraphView

      public static org.apache.jena.graph.Graph createEffectiveGraphView(org.apache.jena.graph.Graph baseGraph, GraphChange graphChange)
      A graph view of the final state: - Nodes that were renamed are no longer visible.
      Returns: