Class GraphChange
java.lang.Object
org.aksw.jena_sparql_api.collection.observable.GraphChange
- Direct Known Subclasses:
GraphChangeWithBaseGraph
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ObservableGraphExplicitly added triples - does not include the values ofrenamedNodesprotected ObservableGraphExplicitly deleted triplesprotected ObservableGraphprotected ObservableGraphEffective 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.protected PropertyChangeSupportReplacing a triple with null counts as a deletionprotected 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 resourcesprotected 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
ConstructorsConstructorDescriptionGraphChange(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 TypeMethodDescriptionListeners for after changes occurred.static org.apache.jena.graph.GraphcreateEffectiveGraphView(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.TablecreateTableFromEnties(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.UpdateDeleteInsertcreateUpdateRenameComponent(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.Nodestatic <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> booleanisDeleted(org.apache.jena.graph.Triple triple) static <T> voidmakeSetEqual(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>nullableSingleton(T item) 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.UpdateRequestCreates 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
-
Field Details
-
renamedNodes
protected org.aksw.commons.collection.observable.ObservableMap<org.apache.jena.graph.Node,org.apache.jena.graph.Node> renamedNodesA 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> tripleReplacementsMapping 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
-
additionGraph
Explicitly added triples - does not include the values ofrenamedNodes -
deletionGraph
Explicitly deleted triples -
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
-
newNodes
protected org.aksw.commons.collection.observable.ObservableSet<org.apache.jena.graph.Node> newNodesThe set of newly added nodes which should be blank nodes only. These new nodes can participate in triples and can be renamed. -
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
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
-
getEffectiveDeletionGraph
-
isDeleted
public boolean isDeleted(org.apache.jena.graph.Triple triple) -
addPropertyChangeListener
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
-
getDeletionGraph
-
nullableSingleton
-
makeSetEqual
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
-
filterToPattern
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
-
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:- 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
- 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:
-