Class Sandbox
- java.lang.Object
-
- com.ensoftcorp.open.commons.sandbox.Sandbox
-
public class Sandbox extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
SANDBOX_ADDRESS_PREFIX
SandboxGraph
U
The sandbox universe graph
-
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 sandboxSandboxGraph
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 sandboxSandboxNode
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 sandboxSandboxEdge
createEdge(SandboxNode fromNode, SandboxNode toNode)
Creates a new sandbox edge This edge does not affect the Atlas universeSandboxNode
createNode()
Creates a new sandbox node This node does not affect the Atlas universevoid
delete(SandboxGraphElement graphElement)
Removes the given sandbox graph element from the sandbox universeSandboxHashSet<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 edgesSandboxGraph
empty()
Returns an empty sandbox graphSandboxHashSet<SandboxEdge>
emptyEdgeSet()
Returns an empty sandbox edge setSandboxHashSet<SandboxNode>
emptyNodeSet()
Returns an empty sandbox node setboolean
equals(java.lang.Object obj)
Sandboxes are equal if they have the same instance idcom.ensoftcorp.atlas.core.db.graph.Graph
flush()
Flushes the changes made in the sandbox universe to the Atlas graphcom.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 sandboxSandboxGraph
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 graphint
hashCode()
Sandboxes are equal if they have the same instance idSandboxNode
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 implementationSandboxGraph
toGraph(SandboxGraphElement... graphElements)
Converts the given graph elements into a sandbox graphSandboxGraph
toGraph(SandboxHashSet<? extends SandboxGraphElement> graphElements)
Converts the given graph elements into a sandbox graphSandboxGraph
toGraph(SandboxHashSet<SandboxNode> nodes, SandboxHashSet<SandboxEdge> edges)
Converts the given graph elements into a sandbox graphSandboxGraph
universe()
Returns the current sandbox universe graph
-
-
-
Field Detail
-
SANDBOX_ADDRESS_PREFIX
public static final java.lang.String SANDBOX_ADDRESS_PREFIX
- See Also:
- Constant Field Values
-
U
public SandboxGraph U
The sandbox universe 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:
-
emptyNodeSet
public SandboxHashSet<SandboxNode> emptyNodeSet()
Returns an empty sandbox node set- Returns:
-
emptyEdgeSet
public SandboxHashSet<SandboxEdge> emptyEdgeSet()
Returns an empty sandbox edge set- Returns:
-
universe
public SandboxGraph universe()
Returns the current sandbox universe graph- Returns:
-
toGraph
public SandboxGraph toGraph(SandboxHashSet<SandboxNode> nodes, SandboxHashSet<SandboxEdge> edges)
Converts the given graph elements into a sandbox graph- Parameters:
graphElements
-- Returns:
-
toGraph
public SandboxGraph toGraph(SandboxHashSet<? extends SandboxGraphElement> graphElements)
Converts the given graph elements into a sandbox graph- Parameters:
graphElements
-- 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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Sandboxes are equal if they have the same instance id- Overrides:
equals
in classjava.lang.Object
-
-