com.thinkaurelius.titan.graphdb.transaction

## Class StandardTitanTx

- java.lang.Object
- - com.thinkaurelius.titan.graphdb.blueprints.TitanBlueprintsTransaction
  - - com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx

- All Implemented Interfaces:
    TitanTransaction, VertexFactory, TypeInspector, TypeSource, com.tinkerpop.blueprints.Graph, com.tinkerpop.blueprints.KeyIndexableGraph, com.tinkerpop.blueprints.TransactionalGraph

      public class StandardTitanTx
      extends TitanBlueprintsTransaction
      implements TypeInspector, TypeSource, VertexFactory

  Author:
    Matthias Broecheler (me@matthiasb.com)

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.tinkerpop.blueprints.TransactionalGraph

      `com.tinkerpop.blueprints.TransactionalGraph.Conclusion`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `QueryExecutor<VertexCentricQuery,TitanRelation,SliceQuery>` | `edgeProcessor`
    `QueryExecutor<VertexCentricQuery,TitanRelation,SliceQuery>` | `edgeProcessorImpl`
    `QueryExecutor<GraphCentricQuery,TitanElement,JointIndexQuery>` | `elementProcessor`
    `QueryExecutor<GraphCentricQuery,TitanElement,JointIndexQuery>` | `elementProcessorImpl`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StandardTitanTx(StandardTitanGraph graph, TransactionConfiguration config)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `TitanEdge` | `addEdge(TitanVertex outVertex, TitanVertex inVertex, EdgeLabel label)` Creates a new edge connecting the specified vertices.
    `TitanProperty` | `addProperty(TitanVertex vertex, PropertyKey key, Object value)` Creates a new property for the given vertex and key with the specified value.
    `TitanProperty` | `addPropertyInternal(TitanVertex vertex, PropertyKey key, Object value)`
    `TitanVertex` | `addVertex()` Creates a new vertex in the graph with the default vertex label.
    `TitanVertex` | `addVertex(Long vertexId, VertexLabel label)` Creates a new vertex in the graph with the given vertex id and the given vertex label.
    `TitanVertex` | `addVertexWithLabel(String vertexLabel)` Creates a new vertex in the graph with the vertex label named by the argument.
    `TitanVertex` | `addVertexWithLabel(VertexLabel vertexLabel)` Creates a new vertex in the graph with the given vertex label.
    `void` | `commit()` Commits and closes the transaction.
    `boolean` | `containsRelationType(String name)` Checks whether a type with the specified name exists.
    `boolean` | `containsVertex(long vertexid)` Checks whether a vertex with the specified id exists in the graph database.
    `boolean` | `containsVertexLabel(String name)` Whether a vertex label with the given name exists in the graph.
    `void` | `executeMultiQuery(Collection<InternalVertex> vertices, SliceQuery sq)`
    `InternalVertex[]` | `getAllRepresentatives(TitanVertex partitionedVertex, boolean restrict2Partitions)`
    `InternalVertex` | `getCanonicalVertex(InternalVertex partitionedVertex)`
    `TransactionConfiguration` | `getConfiguration()`
    `com.google.common.base.Function<Object,? extends TitanElement>` | `getConversionFunction(ElementCategory elementCategory)`
    `EdgeLabel` | `getEdgeLabel(String name)` Returns the edge label with the given name.
    `Iterable<com.tinkerpop.blueprints.Edge>` | `getEdges()`
    `Iterable<TitanEdge>` | `getEdges(PropertyKey key, Object attribute)` Retrieves all vertices which have a property of the given key with the specified value.
    `EdgeSerializer` | `getEdgeSerializer()`
    `RelationType` | `getExistingRelationType(long typeid)`
    `VertexLabel` | `getExistingVertexLabel(long id)`
    `StandardTitanGraph` | `getGraph()` Returns the graph that this transaction is based on
    `IDInspector` | `getIdInspector()`
    `InternalVertex` | `getInternalVertex(long vertexid)`
    `StandardTitanTx` | `getNextTx()`
    `InternalVertex` | `getOtherPartitionVertex(TitanVertex partitionedVertex, long otherPartition)`
    `PropertyKey` | `getPropertyKey(String name)` Returns the property key with the given name.
    `RelationType` | `getRelationType(String name)` Returns the type with the given name.
    `TitanSchemaVertex` | `getSchemaVertex(String schemaName)`
    `BackendTransaction` | `getTxHandle()`
    `TitanVertex` | `getVertex(long vertexid)` Retrieves the vertex for the specified id.
    `VertexLabel` | `getVertexLabel(String name)` Returns the vertex label with the given name.
    `Iterable<com.tinkerpop.blueprints.Vertex>` | `getVertices()`
    `Iterable<TitanVertex>` | `getVertices(PropertyKey key, Object attribute)` Retrieves all vertices which have a property of the given key with the specified value.
    `boolean` | `hasModifications()` Checks whether any changes to the graph database have been made in this transaction.
    `TitanIndexQuery` | `indexQuery(String indexName, String query)` Returns a `TitanIndexQuery` to query for vertices or edges against the specified indexing backend using the given query string.
    `boolean` | `isClosed()` Checks whether the transaction has been closed.
    `boolean` | `isOpen()` Checks whether the transaction is still open.
    `boolean` | `isPartitionedVertex(TitanVertex vertex)`
    `boolean` | `isRemovedRelation(Long relationId)`
    `EdgeLabelMaker` | `makeEdgeLabel(String name)` Returns a `EdgeLabelMaker` instance to define a new `EdgeLabel` with the given name.
    `EdgeLabel` | `makeEdgeLabel(String name, TypeDefinitionMap definition)`
    `PropertyKeyMaker` | `makePropertyKey(String name)` Returns a `PropertyKeyMaker` instance to define a new `PropertyKey` with the given name.
    `PropertyKey` | `makePropertyKey(String name, TypeDefinitionMap definition)`
    `TitanSchemaVertex` | `makeSchemaVertex(TitanSchemaCategory schemaCategory, String name, TypeDefinitionMap definition)`
    `VertexLabelMaker` | `makeVertexLabel(String name)` Returns a `VertexLabelMaker` to define a new vertex label with the given name.
    `TitanMultiVertexQuery` | `multiQuery(Collection<TitanVertex> vertices)`
    `TitanMultiVertexQuery` | `multiQuery(TitanVertex... vertices)`
    `GraphCentricQueryBuilder` | `query()`
    `VertexCentricQueryBuilder` | `query(TitanVertex vertex)`
    `void` | `removeRelation(InternalRelation relation)`
    `void` | `rollback()` Aborts and closes the transaction.
    `void` | `setBackendTransaction(BackendTransaction txHandle)`
    `TitanProperty` | `setProperty(TitanVertex vertex, PropertyKey key, Object value)`
    `void` | `verifyAccess(TitanVertex... vertices)`
    `Object` | `verifyAttribute(PropertyKey key, Object attribute)`

    - ### Methods inherited from class com.thinkaurelius.titan.graphdb.blueprints.TitanBlueprintsTransaction

      `addEdge, addEdge, addProperty, addVertex, createKeyIndex, dropKeyIndex, getEdge, getEdges, getFeatures, getIndexedKeys, getVertex, getVertices, removeEdge, removeVertex, shutdown, stopTransaction, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### edgeProcessor

          public final QueryExecutor<VertexCentricQuery,TitanRelation,SliceQuery> edgeProcessor

    - #### edgeProcessorImpl

          public final QueryExecutor<VertexCentricQuery,TitanRelation,SliceQuery> edgeProcessorImpl

    - #### elementProcessor

          public final QueryExecutor<GraphCentricQuery,TitanElement,JointIndexQuery> elementProcessor

    - #### elementProcessorImpl

          public final QueryExecutor<GraphCentricQuery,TitanElement,JointIndexQuery> elementProcessorImpl

  - ### Constructor Detail

    - #### StandardTitanTx

          public StandardTitanTx(StandardTitanGraph graph,
                         TransactionConfiguration config)

  - ### Method Detail

    - #### setBackendTransaction

          public void setBackendTransaction(BackendTransaction txHandle)

    - #### verifyAccess

          public final void verifyAccess(TitanVertex... vertices)

    - #### getNextTx

          public StandardTitanTx getNextTx()

    - #### getConfiguration

          public TransactionConfiguration getConfiguration()

    - #### getGraph

          public StandardTitanGraph getGraph()

      Description copied from class: `TitanBlueprintsTransaction`
      Returns the graph that this transaction is based on
      Specified by:
        `getGraph` in class `TitanBlueprintsTransaction`
      Returns:

    - #### getTxHandle

          public BackendTransaction getTxHandle()

    - #### getEdgeSerializer

          public EdgeSerializer getEdgeSerializer()

    - #### getIdInspector

          public IDInspector getIdInspector()

    - #### isPartitionedVertex

          public boolean isPartitionedVertex(TitanVertex vertex)

    - #### getCanonicalVertex

          public InternalVertex getCanonicalVertex(InternalVertex partitionedVertex)

    - #### getOtherPartitionVertex

          public InternalVertex getOtherPartitionVertex(TitanVertex partitionedVertex,
                                               long otherPartition)

    - #### getAllRepresentatives

          public InternalVertex[] getAllRepresentatives(TitanVertex partitionedVertex,
                                               boolean restrict2Partitions)

    - #### containsVertex

          public boolean containsVertex(long vertexid)

      Description copied from interface: `TitanTransaction`
      Checks whether a vertex with the specified id exists in the graph database.
      Specified by:
        `containsVertex` in interface `TitanTransaction`
      Parameters:
        `vertexid` - vertex id
      Returns:
        true, if a vertex with that id exists, else false

    - #### getVertex

          public TitanVertex getVertex(long vertexid)

      Description copied from interface: `TitanTransaction`
      Retrieves the vertex for the specified id.
      Specified by:
        `getVertex` in interface `TitanTransaction`
      Parameters:
        `vertexid` - id of the vertex to retrieve
      Returns:
        vertex with the given id if it exists, else null
      See Also:
        `TitanTransaction.containsVertex(long)`

    - #### getInternalVertex

          public InternalVertex getInternalVertex(long vertexid)

      Specified by:
        `getInternalVertex` in interface `VertexFactory`

    - #### addVertex

          public TitanVertex addVertex(Long vertexId,
                              VertexLabel label)

      Description copied from interface: `TitanTransaction`
      Creates a new vertex in the graph with the given vertex id and the given vertex label. Note, that an exception is thrown if the vertex id is not a valid Titan vertex id or if a vertex with the given id already exists.

      Custom id setting must be enabled via the configuration option `GraphDatabaseConfiguration.ALLOW_SETTING_VERTEX_ID`.

      Use `TitanId.toVertexId(long)` to construct a valid Titan vertex id from a user id.
      Specified by:
        `addVertex` in interface `TitanTransaction`
      Parameters:
        `vertexId` - vertex id of the vertex to be created
        `label` - vertex label for this vertex - can be null if no vertex label should be set.
      Returns:
        New vertex

    - #### addVertex

          public TitanVertex addVertex()

      Description copied from interface: `TitanTransaction`
      Creates a new vertex in the graph with the default vertex label.
      Specified by:
        `addVertex` in interface `TitanTransaction`
      Returns:
        New vertex in the graph created in the context of this transaction.

    - #### addVertexWithLabel

          public TitanVertex addVertexWithLabel(String vertexLabel)

      Description copied from interface: `TitanTransaction`
      Creates a new vertex in the graph with the vertex label named by the argument.
      Specified by:
        `addVertexWithLabel` in interface `TitanTransaction`
      Parameters:
        `vertexLabel` - the name of the vertex label to use
      Returns:
        a new vertex in the graph created in the context of this transaction

    - #### addVertexWithLabel

          public TitanVertex addVertexWithLabel(VertexLabel vertexLabel)

      Description copied from interface: `TitanTransaction`
      Creates a new vertex in the graph with the given vertex label.
      Specified by:
        `addVertexWithLabel` in interface `TitanTransaction`
      Parameters:
        `vertexLabel` - the vertex label which will apply to the new vertex
      Returns:
        a new vertex in the graph created in the context of this transaction

    - #### getVertices

          public Iterable<com.tinkerpop.blueprints.Vertex> getVertices()

      Specified by:
        `getVertices` in interface `com.tinkerpop.blueprints.Graph`

    - #### verifyAttribute

          public final Object verifyAttribute(PropertyKey key,
                               Object attribute)

    - #### removeRelation

          public void removeRelation(InternalRelation relation)

    - #### isRemovedRelation

          public boolean isRemovedRelation(Long relationId)

    - #### addEdge

          public TitanEdge addEdge(TitanVertex outVertex,
                          TitanVertex inVertex,
                          EdgeLabel label)

      Description copied from interface: `TitanTransaction`
      Creates a new edge connecting the specified vertices.

      Creates and returns a new `TitanEdge` with given label connecting the vertices in the order specified.
      Specified by:
        `addEdge` in interface `TitanTransaction`
      Parameters:
        `outVertex` - outgoing vertex of the edge
        `inVertex` - incoming vertex of the edge
        `label` - label of the edge to be created
      Returns:
        new edge

    - #### addProperty

          public TitanProperty addProperty(TitanVertex vertex,
                                  PropertyKey key,
                                  Object value)

      Description copied from interface: `TitanTransaction`
      Creates a new property for the given vertex and key with the specified value.

      Creates and returns a new `TitanProperty` with specified property key and the given object being the value.
      Specified by:
        `addProperty` in interface `TitanTransaction`
      Parameters:
        `vertex` - vertex for which to create the property
        `key` - key of the property to be created
        `value` - value of the property to be created
      Returns:
        new property

    - #### addPropertyInternal

          public TitanProperty addPropertyInternal(TitanVertex vertex,
                                          PropertyKey key,
                                          Object value)

    - #### setProperty

          public TitanProperty setProperty(TitanVertex vertex,
                                  PropertyKey key,
                                  Object value)

    - #### getEdges

          public Iterable<com.tinkerpop.blueprints.Edge> getEdges()

      Specified by:
        `getEdges` in interface `com.tinkerpop.blueprints.Graph`

    - #### makeSchemaVertex

          public final TitanSchemaVertex makeSchemaVertex(TitanSchemaCategory schemaCategory,
                                           String name,
                                           TypeDefinitionMap definition)

    - #### makePropertyKey

          public PropertyKey makePropertyKey(String name,
                                    TypeDefinitionMap definition)

    - #### makeEdgeLabel

          public EdgeLabel makeEdgeLabel(String name,
                                TypeDefinitionMap definition)

    - #### containsRelationType

          public boolean containsRelationType(String name)

      Description copied from interface: `TitanTransaction`
      Checks whether a type with the specified name exists.
      Specified by:
        `containsRelationType` in interface `TitanTransaction`
      Specified by:
        `containsRelationType` in interface `TypeInspector`
      Specified by:
        `containsRelationType` in interface `TypeSource`
      Parameters:
        `name` - name of the type
      Returns:
        true, if a type with the given name exists, else false

    - #### getSchemaVertex

          public TitanSchemaVertex getSchemaVertex(String schemaName)

    - #### getRelationType

          public RelationType getRelationType(String name)

      Description copied from interface: `TitanTransaction`
      Returns the type with the given name. Note, that type names must be unique.
      Specified by:
        `getRelationType` in interface `TitanTransaction`
      Specified by:
        `getRelationType` in interface `TypeInspector`
      Specified by:
        `getRelationType` in interface `TypeSource`
      Parameters:
        `name` - name of the type to return
      Returns:
        The type with the given name, or null if such does not exist
      See Also:
        `RelationType`

    - #### getExistingRelationType

          public RelationType getExistingRelationType(long typeid)

      Specified by:
        `getExistingRelationType` in interface `TypeInspector`

    - #### getPropertyKey

          public PropertyKey getPropertyKey(String name)

      Description copied from interface: `TitanTransaction`
      Returns the property key with the given name. If automatic type making is enabled, it will make the property key using the configured default type maker if a key with the given name does not exist.
      Specified by:
        `getPropertyKey` in interface `TitanTransaction`
      Specified by:
        `getPropertyKey` in interface `TypeSource`
      Parameters:
        `name` - name of the property key to return
      Returns:
        the property key with the given name
      See Also:
        `PropertyKey`

    - #### getEdgeLabel

          public EdgeLabel getEdgeLabel(String name)

      Description copied from interface: `TitanTransaction`
      Returns the edge label with the given name. If automatic type making is enabled, it will make the edge label using the configured default type maker if a label with the given name does not exist.
      Specified by:
        `getEdgeLabel` in interface `TitanTransaction`
      Specified by:
        `getEdgeLabel` in interface `TypeSource`
      Parameters:
        `name` - name of the edge label to return
      Returns:
        the edge label with the given name
      See Also:
        `EdgeLabel`

    - #### makePropertyKey

          public PropertyKeyMaker makePropertyKey(String name)

      Description copied from interface: `TitanTransaction`
      Returns a `PropertyKeyMaker` instance to define a new `PropertyKey` with the given name. By defining types explicitly (rather than implicitly through usage) one can control various aspects of the key and associated consistency constraints.

      The key constructed with this maker will be created in the context of this transaction.
      Specified by:
        `makePropertyKey` in interface `TitanTransaction`
      Returns:
        a `PropertyKeyMaker` linked to this transaction.
      See Also:
        `PropertyKeyMaker`, `PropertyKey`

    - #### makeEdgeLabel

          public EdgeLabelMaker makeEdgeLabel(String name)

      Description copied from interface: `TitanTransaction`
      Returns a `EdgeLabelMaker` instance to define a new `EdgeLabel` with the given name. By defining types explicitly (rather than implicitly through usage) one can control various aspects of the label and associated consistency constraints.

      The label constructed with this maker will be created in the context of this transaction.
      Specified by:
        `makeEdgeLabel` in interface `TitanTransaction`
      Returns:
        a `EdgeLabelMaker` linked to this transaction.
      See Also:
        `EdgeLabelMaker`, `EdgeLabel`

    - #### getExistingVertexLabel

          public VertexLabel getExistingVertexLabel(long id)

      Specified by:
        `getExistingVertexLabel` in interface `TypeInspector`

    - #### containsVertexLabel

          public boolean containsVertexLabel(String name)

      Description copied from interface: `TitanTransaction`
      Whether a vertex label with the given name exists in the graph.
      Specified by:
        `containsVertexLabel` in interface `TitanTransaction`
      Returns:

    - #### getVertexLabel

          public VertexLabel getVertexLabel(String name)

      Description copied from interface: `TitanTransaction`
      Returns the vertex label with the given name. If a vertex label with this name does not exist, the label is automatically created through the registered `DefaultSchemaMaker`.

      Attempting to automatically create a vertex label might cause an exception depending on the configuration.
      Specified by:
        `getVertexLabel` in interface `TitanTransaction`
      Returns:

    - #### makeVertexLabel

          public VertexLabelMaker makeVertexLabel(String name)

      Description copied from interface: `TitanTransaction`
      Returns a `VertexLabelMaker` to define a new vertex label with the given name. Note, that the name must be unique.
      Specified by:
        `makeVertexLabel` in interface `TitanTransaction`
      Returns:

    - #### query

          public VertexCentricQueryBuilder query(TitanVertex vertex)

    - #### multiQuery

          public TitanMultiVertexQuery multiQuery(TitanVertex... vertices)

      Specified by:
        `multiQuery` in interface `TitanTransaction`
      Returns:
      See Also:
        `TitanGraph.multiQuery(TitanVertex...)`

    - #### multiQuery

          public TitanMultiVertexQuery multiQuery(Collection<TitanVertex> vertices)

      Specified by:
        `multiQuery` in interface `TitanTransaction`
      Returns:
      See Also:
        `TitanGraph.multiQuery(Collection)`

    - #### executeMultiQuery

          public void executeMultiQuery(Collection<InternalVertex> vertices,
                               SliceQuery sq)

    - #### getConversionFunction

          public com.google.common.base.Function<Object,? extends TitanElement> getConversionFunction(ElementCategory elementCategory)

    - #### query

          public GraphCentricQueryBuilder query()

      Specified by:
        `query` in interface `TitanTransaction`
      Specified by:
        `query` in interface `com.tinkerpop.blueprints.Graph`
      See Also:
        `TitanGraph.query()`

    - #### indexQuery

          public TitanIndexQuery indexQuery(String indexName,
                                   String query)

      Description copied from interface: `TitanTransaction`
      Returns a `TitanIndexQuery` to query for vertices or edges against the specified indexing backend using the given query string. The query string is analyzed and answered by the underlying storage backend.

      Note, that using indexQuery will may ignore modifications in the current transaction.
      Specified by:
        `indexQuery` in interface `TitanTransaction`
      Parameters:
        `indexName` - Name of the indexing backend to query as configured
        `query` - Query string
      Returns:
        TitanIndexQuery object to query the index directly

    - #### getVertices

          public Iterable<TitanVertex> getVertices(PropertyKey key,
                                          Object attribute)

      Description copied from interface: `TitanTransaction`
      Retrieves all vertices which have a property of the given key with the specified value.

      For this operation to be efficient, please ensure that the given property key is indexed. Some storage backends may not support this method without a pre-configured index.
      Specified by:
        `getVertices` in interface `TitanTransaction`
      Parameters:
        `key` - key
        `attribute` - value value
      Returns:
        All vertices which have a property of the given key with the specified value.
      See Also:
        `TitanManagement.buildIndex(String, Class)`

    - #### getEdges

          public Iterable<TitanEdge> getEdges(PropertyKey key,
                                     Object attribute)

      Description copied from interface: `TitanTransaction`
      Retrieves all vertices which have a property of the given key with the specified value.

      For this operation to be efficient, please ensure that the given property key is indexed. Some storage backends may not support this method without a pre-configured index.
      Specified by:
        `getEdges` in interface `TitanTransaction`
      Parameters:
        `key` - key
        `attribute` - value value
      Returns:
        All edges which have a property of the given key with the specified value.
      See Also:
        `TitanManagement.buildIndex(String, Class)`

    - #### commit

          public void commit()

      Description copied from interface: `TitanTransaction`
      Commits and closes the transaction.

      Will attempt to persist all modifications which may result in exceptions in case of persistence failures or lock contention.
      The call releases data structures if possible. All element references (e.g. vertex objects) retrieved through this transaction are stale after the transaction closes and should no longer be used.
      Specified by:
        `commit` in interface `TitanTransaction`
      Specified by:
        `commit` in interface `com.tinkerpop.blueprints.TransactionalGraph`

    - #### rollback

          public void rollback()

      Description copied from interface: `TitanTransaction`
      Aborts and closes the transaction. Will discard all modifications.

      The call releases data structures if possible. All element references (e.g. vertex objects) retrieved through this transaction are stale after the transaction closes and should no longer be used.
      Specified by:
        `rollback` in interface `TitanTransaction`
      Specified by:
        `rollback` in interface `com.tinkerpop.blueprints.TransactionalGraph`

    - #### isOpen

          public boolean isOpen()

      Description copied from interface: `TitanTransaction`
      Checks whether the transaction is still open.
      Specified by:
        `isOpen` in interface `TitanTransaction`
      Returns:
        true, when the transaction is open, else false

    - #### isClosed

          public boolean isClosed()

      Description copied from interface: `TitanTransaction`
      Checks whether the transaction has been closed.
      Specified by:
        `isClosed` in interface `TitanTransaction`
      Returns:
        true, if the transaction has been closed, else false

    - #### hasModifications

          public boolean hasModifications()

      Description copied from interface: `TitanTransaction`
      Checks whether any changes to the graph database have been made in this transaction.

      A modification may be an edge or vertex update, addition, or deletion.
      Specified by:
        `hasModifications` in interface `TitanTransaction`
      Returns:
        true, if the transaction contains updates, else false.

Copyright © 2012–2014. All rights reserved.