@Override public Void beforeCommit(TransactionData data) throws Exception { if (active) { check(added, "added to", data.assignedLabels()); check(removed, "removed from", data.removedLabels()); } active = false; return null; }
@Override public void afterCommit(TransactionData data, Object state) { for (PropertyEntry<Node> entry : data.removedNodeProperties()) { String key = entry.key(); Object value = entry.previouslyCommitedValue(); nodeProps.put(key, value); } for (PropertyEntry<Relationship> entry : data.removedRelationshipProperties()) { relProps.put(entry.key(), entry.previouslyCommitedValue()); } }
@Override protected void doInitializeChanged() { assignedLabels = new HashMap<>(); removedLabels = new HashMap<>(); deletedNodeLabels = new HashMap<>(); Map<Long, Node> potentiallyChangedNodes = new HashMap<>(); for (LabelEntry labelEntry : transactionData.assignedLabels()) { Node node = labelEntry.node(); if (hasBeenCreated(node)) { continue; } if (!assignedLabels.containsKey(node.getId())) { assignedLabels.put(node.getId(), new HashSet<Label>()); } assignedLabels.get(node.getId()).add(labelEntry.label()); potentiallyChangedNodes.put(node.getId(), node); } for (LabelEntry labelEntry : transactionData.removedLabels()) { Node node = labelEntry.node(); if (hasBeenDeleted(node)) { if (!deletedNodeLabels.containsKey(node.getId())) { deletedNodeLabels.put(node.getId(), new HashSet<Label>()); } deletedNodeLabels.get(node.getId()).add(labelEntry.label()); continue; } if (!removedLabels.containsKey(node.getId())) { removedLabels.put(node.getId(), new HashSet<Label>()); } removedLabels.get(node.getId()).add(labelEntry.label()); potentiallyChangedNodes.put(node.getId(), node); } for (Long nodeId : assignedLabels.keySet()) { registerChange(potentiallyChangedNodes.get(nodeId)); } for (Long nodeId : removedLabels.keySet()) { registerChange(potentiallyChangedNodes.get(nodeId)); } }
@Override protected Iterable<PropertyEntry<Node>> getRemovedPropertiesOnCommit(TransactionData data) { return data.removedNodeProperties(); }
/** {@inheritDoc} */ @Override protected Iterable<PropertyEntry<Node>> removedProperties() { return transactionData.removedNodeProperties(); }
/** {@inheritDoc} */ @Override protected Iterable<Node> deleted() { return transactionData.deletedNodes(); }
/** {@inheritDoc} */ @Override protected Iterable<Node> created() { return transactionData.createdNodes(); }