Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.connector.store.jpa.model.simple
Class SubgraphQuery

    java.lang.Object
      org.modeshape.connector.store.jpa.model.simple.SubgraphQuery

    public class SubgraphQuery

extends Object

Represents a temporary working area for a query that efficiently retrieves the nodes in a subgraph. This class uses the database to build up the content of the subgraph, and therefore requires write privilege on the database. The benefit is that it minimizes the amount of memory required to process the subgraph, plus the set of nodes that make up the subgraph can be produced with database joins.

The use of database joins also produces another benefit: the number of SQL statements necessary to build the set of nodes in a subgraph is equal to the depth of the subgraph, regardless of the number of child nodes at any level.

Constructor Summary
`protected` | `SubgraphQuery(javax.persistence.EntityManager manager, Long workspaceId, SubgraphQueryEntity query, int maxDepth)`

Method Summary
`void` | `close()` Close this query object and clean up all in-database records associated with this query.
`static SubgraphQuery` | `create(javax.persistence.EntityManager entities, Long workspaceId, UUID subgraphRootUuid, int maxDepth)` Create a query that returns a subgraph at and below the node with the supplied path and the supplied UUID.
`void` | `deleteSubgraph(boolean includeRoot)` Delete the nodes in the subgraph.
`javax.persistence.EntityManager` | `getEntityManager()`
`int` | `getMaxDepth()`
`NodeEntity` | `getNode()` Get the `root node` of the subgraph.
`List<NodeEntity>` | `getNodes(boolean includeRoot, boolean includeChildrenOfMaxDepthNodes)` Get the `nodes` in the subgraph.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SubgraphQuery

    protected SubgraphQuery(javax.persistence.EntityManager manager,
                            Long workspaceId,
                            SubgraphQueryEntity query,
                            int maxDepth)

Method Detail

### create

    public static SubgraphQuery create(javax.persistence.EntityManager entities,
                                       Long workspaceId,
                                       UUID subgraphRootUuid,
                                       int maxDepth)

  Create a query that returns a subgraph at and below the node with the supplied path and the supplied UUID.

  Parameters:
    `entities` - the entity manager; may not be null
    `workspaceId` - the ID of the workspace; may not be null
    `subgraphRootUuid` - the UUID (in string form) of the root node in the subgraph
    `maxDepth` - the maximum depth of the subgraph, or 0 if there is no maximum depth
  Returns:
    the object representing the subgraph

### getMaxDepth

    public int getMaxDepth()

  Returns:
    maxDepth

### getEntityManager

    public javax.persistence.EntityManager getEntityManager()

  Returns:
    manager

### getNode

    public NodeEntity getNode()

  Get the `root node` of the subgraph. This must be called before the query is `closed`.

  Returns:
    the subgraph's root nodes

### getNodes

    public List<NodeEntity> getNodes(boolean includeRoot,
                                     boolean includeChildrenOfMaxDepthNodes)

  Get the `nodes` in the subgraph. This must be called before the query is `closed`.

  Parameters:
    `includeRoot` - true if the subgraph's root node is to be included, or false otherwise
    `includeChildrenOfMaxDepthNodes` - true if the method is to include nodes that are children of nodes that are at the maximum depth, or false if only nodes up to the maximum depth are to be included
  Returns:
    the list of nodes, in breadth-first order

### deleteSubgraph

    public void deleteSubgraph(boolean includeRoot)

  Delete the nodes in the subgraph.

  Parameters:
    `includeRoot` - true if the root node should also be deleted

### close

    public void close()

  Close this query object and clean up all in-database records associated with this query. This method must be called when this query is no longer needed, and once it is called, this subgraph query is no longer usable.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2008-2011 JBoss, a division of Red Hat. All Rights Reserved.