private void populateRelationshipPropertyEvents( PrimitiveElement element, TransactionDataImpl result) { for (long relId : element.relationships.keySet()) { CowRelElement relElement = element.relationships.get(relId); RelationshipProxy rel = nodeManager.newRelationshipProxyById(relId); RelationshipImpl relImpl = nodeManager.getRelationshipForProxy(relId); if (relElement.isDeleted()) { if (primitiveElement.createdRelationships.contains(relId)) { continue; } // note: this is done in node populate data // result.deleted( rel ); } if (relElement.propertyAddMap != null && !relElement.isDeleted()) { for (DefinedProperty data : relElement.propertyAddMap.values()) { String key = nodeManager.getKeyForProperty(data); Object oldValue = relImpl.getCommittedPropertyValue(nodeManager, key); Object newValue = data.value(); result.assignedProperty(rel, key, newValue, oldValue); } } if (relElement.propertyRemoveMap != null) { for (DefinedProperty data : relElement.propertyRemoveMap.values()) { String key = nodeManager.getKeyForProperty(data); Object oldValue = data.value(); if (oldValue != null && !relElement.isDeleted()) { relImpl.getCommittedPropertyValue(nodeManager, key); } result.removedProperty(rel, key, oldValue); } } } }
private void populateNodeRelEvent(PrimitiveElement element, TransactionDataImpl result) { for (long nodeId : element.nodes.keySet()) { CowNodeElement nodeElement = element.nodes.get(nodeId); NodeProxy node = nodeManager.newNodeProxyById(nodeId); NodeImpl nodeImpl = nodeManager.getNodeForProxy(nodeId, null); if (nodeElement.isDeleted()) { if (primitiveElement.createdNodes.contains(nodeId)) { continue; } result.deleted(node); } if (nodeElement.relationshipAddMap != null && !nodeElement.isDeleted()) { for (Integer type : nodeElement.relationshipAddMap.keySet()) { RelIdArray createdRels = nodeElement.relationshipAddMap.get(type); populateNodeRelEvent(element, result, nodeId, createdRels); } } if (nodeElement.relationshipRemoveMap != null) { for (Integer type : nodeElement.relationshipRemoveMap.keySet()) { Collection<Long> deletedRels = nodeElement.relationshipRemoveMap.get(type); for (long relId : deletedRels) { if (primitiveElement.createdRelationships.contains(relId)) { continue; } RelationshipProxy rel = nodeManager.newRelationshipProxyById(relId); if (rel.getStartNode().getId() == nodeId) { result.deleted(nodeManager.newRelationshipProxyById(relId)); } } } } if (nodeElement.propertyAddMap != null && !nodeElement.isDeleted()) { for (DefinedProperty data : nodeElement.propertyAddMap.values()) { String key = nodeManager.getKeyForProperty(data); Object oldValue = nodeImpl.getCommittedPropertyValue(nodeManager, key); Object newValue = data.value(); result.assignedProperty(node, key, newValue, oldValue); } } if (nodeElement.propertyRemoveMap != null) { for (DefinedProperty data : nodeElement.propertyRemoveMap.values()) { String key = nodeManager.getKeyForProperty(data); Object oldValue = data.value(); if (oldValue == null && !nodeElement.isDeleted()) { nodeImpl.getCommittedPropertyValue(nodeManager, key); } result.removedProperty(node, key, oldValue); } } } }