Class CypherContext

java.lang.Object
org.neo4j.ogm.cypher.compiler.CypherContext
All Implemented Interfaces:
CompileContext

public class CypherContext extends Object implements CompileContext
Maintains contextual information throughout the process of compiling Cypher statements to persist a graph of objects.
Author:
Mark Angrish, Vince Bickers, Luanne Misquitta, Andreas Berger, Michael J. Simons
  • Constructor Details

  • Method Details

    • visited

      public boolean visited(Object entity, int horizon)
      Specified by:
      visited in interface CompileContext
    • visit

      public void visit(Object entity, NodeBuilder nodeBuilder, int horizon)
      Description copied from interface: CompileContext
      Stores nodeBuilder for given entity with horizon if the nodeBuilder for the entity is already present it will be overwritten (or the horizon will change) the caller should ensure it doesn't happen
      Specified by:
      visit in interface CompileContext
    • registerRelationship

      public void registerRelationship(Mappable mappedRelationship)
      Specified by:
      registerRelationship in interface CompileContext
    • removeRegisteredRelationship

      public boolean removeRegisteredRelationship(Mappable mappedRelationship)
      Specified by:
      removeRegisteredRelationship in interface CompileContext
    • visitedNode

      public NodeBuilder visitedNode(Object entity)
      Specified by:
      visitedNode in interface CompileContext
    • registerNewObject

      public void registerNewObject(Long reference, Object entity)
      Specified by:
      registerNewObject in interface CompileContext
    • getNewObject

      public Object getNewObject(Long id)
      Specified by:
      getNewObject in interface CompileContext
    • register

      public void register(Object object)
      Specified by:
      register in interface CompileContext
    • registerTransientRelationship

      public void registerTransientRelationship(org.neo4j.ogm.compiler.SrcTargetKey key, Object object)
      Specified by:
      registerTransientRelationship in interface CompileContext
    • registry

      public Collection<Object> registry()
      Specified by:
      registry in interface CompileContext
    • deregisterOutgoingRelationships

      public boolean deregisterOutgoingRelationships(Long src, String relationshipType, Class endNodeType)
      Invoked when the mapper wishes to mark a set of outgoing relationships to a specific type like (a)-[:T]->(*) as deleted, prior to possibly re-establishing them individually as it traverses the entity graph. There are two reasons why a set of relationships might not be be able to be marked deleted: 1) the request to mark them as deleted has already been made 2) the relationship is not persisted in the graph (i.e. its a new relationship) Only case 1) is considered to be a failed request, because this context is only concerned about pre-existing relationships in the graph. In order to distinguish between the two cases, we also maintain a list of successfully deleted relationships, so that if we try to delete an already-deleted set of relationships we can signal the error and undelete it.
      Specified by:
      deregisterOutgoingRelationships in interface CompileContext
      Parameters:
      src - the identity of the node at the start of the relationship
      relationshipType - the type of the relationship
      endNodeType - the class type of the entity at the end of the relationship
      Returns:
      true if the relationship was deleted or doesn't exist in the graph, false otherwise
    • deregisterIncomingRelationships

      public boolean deregisterIncomingRelationships(Long tgt, String relationshipType, Class endNodeType, boolean relationshipEntity)
      Invoked when the mapper wishes to mark a set of incoming relationships to a specific type like (a)<-[:T]-(*) as deleted, prior to possibly re-establishing them individually as it traverses the entity graph. There are two reasons why a set of relationships might not be be able to be marked deleted: 1) the request to mark them as deleted has already been made 2) the relationship is not persisted in the graph (i.e. its a new relationship) Only case 1) is considered to be a failed request, because this context is only concerned about pre-existing relationships in the graph. In order to distinguish between the two cases, we also maintain a list of successfully deleted relationships, so that ff we try to delete an already-deleted set of relationships we can signal the error and undelete it.
      Specified by:
      deregisterIncomingRelationships in interface CompileContext
      Parameters:
      tgt - the identity of the node at the pointy end of the relationship
      relationshipType - the type of the relationship
      endNodeType - the class type of the entity at the other end of the relationship
      Returns:
      true if the relationship was deleted or doesn't exist in the graph, false otherwise
    • visitRelationshipEntity

      public void visitRelationshipEntity(Long relationshipEntity)
      Specified by:
      visitRelationshipEntity in interface CompileContext
    • visitedRelationshipEntity

      public boolean visitedRelationshipEntity(Long relationshipEntity)
      Specified by:
      visitedRelationshipEntity in interface CompileContext
    • getCompiler

      public Compiler getCompiler()
      Specified by:
      getCompiler in interface CompileContext
    • getId

      public Long getId(Long reference)
      Specified by:
      getId in interface CompileContext
    • registerNewId

      public void registerNewId(Long reference, Long id)
      Specified by:
      registerNewId in interface CompileContext
    • deregister

      public void deregister(NodeBuilder nodeBuilder)
      Specified by:
      deregister in interface CompileContext
    • getDeletedRelationships

      public Collection<Mappable> getDeletedRelationships()
      Specified by:
      getDeletedRelationships in interface CompileContext
    • getVisitedObject

      public Object getVisitedObject(Long reference)
      Specified by:
      getVisitedObject in interface CompileContext
    • getTransientRelationships

      public Collection<Object> getTransientRelationships(org.neo4j.ogm.compiler.SrcTargetKey srcTargetKey)
      Specified by:
      getTransientRelationships in interface CompileContext