Java 类org.neo4j.graphdb.event.PropertyEntry 实例源码

项目:neo4j-mobile-android    文件:PropertyEntryImpl.java   
static <T extends PropertyContainer> PropertyEntry<T> assigned( T entity,
        String key, Object value, Object valueBeforeTransaction )
{
    if ( value == null )
    {
        throw new IllegalArgumentException( "Null value" );
    }
    return new PropertyEntryImpl<T>( entity, key, value, valueBeforeTransaction );
}
项目:neo4j-timestamp    文件:TimestampTransactionEventHandler.java   
private void updateParentTimestampsFor(Iterable<? extends PropertyEntry<?>> propertyEntries, long currentTime) {
  if (propertyEntries == null) return;
  Set<PropertyContainer> updatedPropertyContainers = null;
  for (PropertyEntry<?> propertyEntry : propertyEntries) {
    if (updatedPropertyContainers == null)
      updatedPropertyContainers = new HashSet<PropertyContainer>();
    updatedPropertyContainers.add(propertyEntry.entity());
  }
  if (updatedPropertyContainers != null)
    updateTimestampsFor(updatedPropertyContainers, currentTime);
}
项目:neo4j-timestamp    文件:TimestampTransactionEventHandler.java   
private void updateRemoveTimestampsFor(Iterable<? extends PropertyEntry<?>> propertyEntries, Iterable<? extends PropertyContainer> deletedPropertyContainers, long currentTime) {
  if (propertyEntries == null) return;
  Set<PropertyContainer> updatedPropertyContainers = null;
  for (PropertyEntry<?> propertyEntry : propertyEntries) {
    Set<?> deletedPropertyContainerSet = propertyContainersToSet(deletedPropertyContainers);
    if (deletedPropertyContainerSet == null || !deletedPropertyContainerSet.contains(propertyEntry.entity())){
      if (updatedPropertyContainers == null)
        updatedPropertyContainers = new HashSet<PropertyContainer>();
      updatedPropertyContainers.add(propertyEntry.entity());
    }
  }
  if (updatedPropertyContainers != null)
    updateTimestampsFor(updatedPropertyContainers, currentTime);
}
项目:neo4j-mobile-android    文件:PropertyEntryImpl.java   
static <T extends PropertyContainer> PropertyEntry<T> removed( T entity,
        String key, Object valueBeforeTransaction )
{
    return new PropertyEntryImpl<T>( entity, key, null, valueBeforeTransaction );
}
项目:neo4j-mobile-android    文件:TransactionDataImpl.java   
public Iterable<PropertyEntry<Node>> assignedNodeProperties()
{
    return this.assignedNodeProperties;
}
项目:neo4j-mobile-android    文件:TransactionDataImpl.java   
public Iterable<PropertyEntry<Relationship>> assignedRelationshipProperties()
{
    return this.assignedRelationshipProperties;
}
项目:neo4j-mobile-android    文件:TransactionDataImpl.java   
public Iterable<PropertyEntry<Node>> removedNodeProperties()
{
    return this.removedNodeProperties;
}
项目:neo4j-mobile-android    文件:TransactionDataImpl.java   
public Iterable<PropertyEntry<Relationship>> removedRelationshipProperties()
{
    return this.removedRelationshipProperties;
}
项目:neo4j-timestamp    文件:TimestampTransactionEventHandler.java   
@Override
public T beforeCommit(TransactionData data) throws Exception {
  long currentTime = System.currentTimeMillis();
  updateParentTimestampsFor(data.assignedRelationshipProperties(), currentTime);
  updateParentTimestampsFor(data.assignedNodeProperties(), currentTime);

  // With removed properties, don't update when node is being deleted
  updateRemoveTimestampsFor(data.removedRelationshipProperties(), data.deletedRelationships(), currentTime);
  updateRemoveTimestampsFor(data.removedNodeProperties(), data.deletedNodes(), currentTime);

  updateTimestampsFor(data.createdNodes(), currentTime);

  if (this.addCreated){
    addCreatedTimestampFor(data.createdNodes(), currentTime);
  }

  // For created relationships, update both start and end node, and relationship itself
  Iterable<Relationship> createdRelationships = data.createdRelationships();
  Set<PropertyContainer> updatedPropertyContainers = null;
  for (Relationship relationship : createdRelationships) {
    if (updatedPropertyContainers == null)
      updatedPropertyContainers = new HashSet<PropertyContainer>();
    updatedPropertyContainers.add(relationship.getEndNode());
    updatedPropertyContainers.add(relationship.getStartNode());
  }
  updateTimestampsFor(updatedPropertyContainers, currentTime);
  updateTimestampsFor(createdRelationships, currentTime);

  if (this.addCreated){
    addCreatedTimestampFor(createdRelationships, currentTime);
  }

  // Process custom relationships
  if (customPropertyHandlers != null && !customPropertyHandlers.isEmpty()){
    for (TimestampCustomPropertyHandler cpr : customPropertyHandlers){
        for (PropertyEntry<Node> assignedProperty : data.assignedNodeProperties()){
            if (cpr.getCustomPropertyName() == assignedProperty.key()){
                // Assigned custom property found, process modifications
                updateCustomRelationshipModifiedTimestampsFor(
                        assignedProperty.entity(),
                        cpr.getModifiedRelationshipTypes(),
                        cpr.getDirection(),
                        currentTime);
            }
        }
        for (PropertyEntry<Node> removedProperty : data.removedNodeProperties()){
            if (cpr.getCustomPropertyName() == removedProperty.key()){
                // Removed custom property found, process modifications to relationships
                updateCustomRelationshipModifiedTimestampsFor(
                        removedProperty.entity(),
                        cpr.getModifiedRelationshipTypes(),
                        cpr.getDirection(),
                        currentTime);
            }               
        }
    }
  }

  return null;
}