Class Sandbox


  • public class Sandbox
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Sandbox()
      Constructs a new sandbox where changes are isolated from the Atlas graph
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      SandboxEdge addEdge​(com.ensoftcorp.atlas.core.db.graph.Edge edge)  
      SandboxHashSet<SandboxEdge> addEdges​(com.ensoftcorp.atlas.core.db.set.AtlasSet<com.ensoftcorp.atlas.core.db.graph.Edge> edges)
      Adds the current state of the given edges in the Atlas graph to the sandbox
      SandboxGraph addGraph​(com.ensoftcorp.atlas.core.db.graph.Graph graph)
      Adds the current state of the Atlas nodes and edges from the given Atlas graph to the sandbox
      SandboxNode addNode​(com.ensoftcorp.atlas.core.db.graph.Node node)  
      SandboxHashSet<SandboxNode> addNodes​(com.ensoftcorp.atlas.core.db.set.AtlasSet<com.ensoftcorp.atlas.core.db.graph.Node> nodes)
      Adds the current state of the given nodes in the Atlas graph to the sandbox
      SandboxEdge createEdge​(SandboxNode fromNode, SandboxNode toNode)
      Creates a new sandbox edge This edge does not affect the Atlas universe
      SandboxNode createNode()
      Creates a new sandbox node This node does not affect the Atlas universe
      void delete​(SandboxGraphElement graphElement)
      Removes the given sandbox graph element from the sandbox universe
      SandboxHashSet<SandboxEdge> edges​(com.ensoftcorp.atlas.core.db.set.AtlasSet<com.ensoftcorp.atlas.core.db.graph.Edge> edges)
      Returns a sandbox set of edges contained in the sandbox universe referenced in the given set of the Atlas graph edges
      SandboxGraph empty()
      Returns an empty sandbox graph
      SandboxHashSet<SandboxEdge> emptyEdgeSet()
      Returns an empty sandbox edge set
      SandboxHashSet<SandboxNode> emptyNodeSet()
      Returns an empty sandbox node set
      boolean equals​(java.lang.Object obj)
      Sandboxes are equal if they have the same instance id
      com.ensoftcorp.atlas.core.db.graph.Graph flush()
      Flushes the changes made in the sandbox universe to the Atlas graph
      com.ensoftcorp.atlas.core.db.graph.Graph flush​(SandboxGraph graph)
      Flushes the changes made in the sandbox that are restricted to the nodes and edges in the given graph to the Atlas graph This methods does the following: 1) Adds nodes/edges that are not mirrored to the Atlas graph with the current tags/attributes 2) Updates (adds/removes) tags and attributes from the corresponding Atlas graph element's to match the current sandbox tags/attributes for each node/edge in the sandbox.
      int getInstanceID()
      Returns the instance id of this sandbox
      SandboxGraph graph​(com.ensoftcorp.atlas.core.db.graph.Graph graph)
      Returns a sandbox graph contained in the sandbox universe referenced in the given set of the Atlas graph
      int hashCode()
      Sandboxes are equal if they have the same instance id
      SandboxNode node​(com.ensoftcorp.atlas.core.db.graph.Node node)
      Returns a node from the sandbox corresponding to the Atlas node, if it already exists in the sandbox.
      SandboxHashSet<SandboxNode> nodes​(com.ensoftcorp.atlas.core.db.set.AtlasSet<com.ensoftcorp.atlas.core.db.graph.Node> nodes)
      Returns a set of sandbox nodes contained in the sandbox universe corresponding to the given set Atlas graph nodes.
      void setFlushProvider​(FlushProvider flushProvider)
      Sets the flush provider implementation
      SandboxGraph toGraph​(SandboxGraphElement... graphElements)
      Converts the given graph elements into a sandbox graph
      SandboxGraph toGraph​(SandboxHashSet<? extends SandboxGraphElement> graphElements)
      Converts the given graph elements into a sandbox graph
      SandboxGraph toGraph​(SandboxHashSet<SandboxNode> nodes, SandboxHashSet<SandboxEdge> edges)
      Converts the given graph elements into a sandbox graph
      SandboxGraph universe()
      Returns the current sandbox universe graph
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SANDBOX_ADDRESS_PREFIX

        public static final java.lang.String SANDBOX_ADDRESS_PREFIX
        See Also:
        Constant Field Values
    • Constructor Detail

      • Sandbox

        public Sandbox()
        Constructs a new sandbox where changes are isolated from the Atlas graph
    • Method Detail

      • setFlushProvider

        public void setFlushProvider​(FlushProvider flushProvider)
        Sets the flush provider implementation
        Parameters:
        flushProvider -
      • getInstanceID

        public int getInstanceID()
        Returns the instance id of this sandbox
        Returns:
      • empty

        public SandboxGraph empty()
        Returns an empty sandbox graph
        Returns:
      • universe

        public SandboxGraph universe()
        Returns the current sandbox universe graph
        Returns:
      • toGraph

        public SandboxGraph toGraph​(SandboxGraphElement... graphElements)
        Converts the given graph elements into a sandbox graph
        Parameters:
        graphElements -
        Returns:
      • graph

        public SandboxGraph graph​(com.ensoftcorp.atlas.core.db.graph.Graph graph)
        Returns a sandbox graph contained in the sandbox universe referenced in the given set of the Atlas graph
        Parameters:
        nodes -
        Returns:
      • nodes

        public SandboxHashSet<SandboxNode> nodes​(com.ensoftcorp.atlas.core.db.set.AtlasSet<com.ensoftcorp.atlas.core.db.graph.Node> nodes)
        Returns a set of sandbox nodes contained in the sandbox universe corresponding to the given set Atlas graph nodes. Does not instantiate nodes in the sandbox.
        Parameters:
        tags -
        Returns:
        the sandbox nodes
      • node

        public SandboxNode node​(com.ensoftcorp.atlas.core.db.graph.Node node)
        Returns a node from the sandbox corresponding to the Atlas node, if it already exists in the sandbox.
        Parameters:
        node -
        Returns:
        the sandbox node, else null
      • edges

        public SandboxHashSet<SandboxEdge> edges​(com.ensoftcorp.atlas.core.db.set.AtlasSet<com.ensoftcorp.atlas.core.db.graph.Edge> edges)
        Returns a sandbox set of edges contained in the sandbox universe referenced in the given set of the Atlas graph edges
        Parameters:
        edges -
        Returns:
      • addGraph

        public SandboxGraph addGraph​(com.ensoftcorp.atlas.core.db.graph.Graph graph)
        Adds the current state of the Atlas nodes and edges from the given Atlas graph to the sandbox
        Parameters:
        graph -
      • addNodes

        public SandboxHashSet<SandboxNode> addNodes​(com.ensoftcorp.atlas.core.db.set.AtlasSet<com.ensoftcorp.atlas.core.db.graph.Node> nodes)
        Adds the current state of the given nodes in the Atlas graph to the sandbox
        Parameters:
        nodes -
      • addNode

        public SandboxNode addNode​(com.ensoftcorp.atlas.core.db.graph.Node node)
      • addEdges

        public SandboxHashSet<SandboxEdge> addEdges​(com.ensoftcorp.atlas.core.db.set.AtlasSet<com.ensoftcorp.atlas.core.db.graph.Edge> edges)
        Adds the current state of the given edges in the Atlas graph to the sandbox
        Parameters:
        edges -
      • addEdge

        public SandboxEdge addEdge​(com.ensoftcorp.atlas.core.db.graph.Edge edge)
      • createNode

        public SandboxNode createNode()
        Creates a new sandbox node This node does not affect the Atlas universe
        Returns:
      • createEdge

        public SandboxEdge createEdge​(SandboxNode fromNode,
                                      SandboxNode toNode)
        Creates a new sandbox edge This edge does not affect the Atlas universe
        Parameters:
        fromNode -
        toNode -
        Returns:
      • delete

        public void delete​(SandboxGraphElement graphElement)
        Removes the given sandbox graph element from the sandbox universe
        Parameters:
        graphElement -
      • flush

        public com.ensoftcorp.atlas.core.db.graph.Graph flush()
        Flushes the changes made in the sandbox universe to the Atlas graph
        Returns:
        The serialized Atlas graph version of the sandbox
      • flush

        public com.ensoftcorp.atlas.core.db.graph.Graph flush​(SandboxGraph graph)
        Flushes the changes made in the sandbox that are restricted to the nodes and edges in the given graph to the Atlas graph This methods does the following: 1) Adds nodes/edges that are not mirrored to the Atlas graph with the current tags/attributes 2) Updates (adds/removes) tags and attributes from the corresponding Atlas graph element's to match the current sandbox tags/attributes for each node/edge in the sandbox.
        Parameters:
        graph - the graph containing the set of nodes and edges to flush
        Returns:
        The serialized Atlas graph version of the sandbox
      • hashCode

        public int hashCode()
        Sandboxes are equal if they have the same instance id
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Sandboxes are equal if they have the same instance id
        Overrides:
        equals in class java.lang.Object