com.thinkaurelius.titan.core

## Interface TitanTransaction

- All Superinterfaces:
    com.tinkerpop.blueprints.Graph, com.tinkerpop.blueprints.KeyIndexableGraph, com.tinkerpop.blueprints.TransactionalGraph
  All Known Implementing Classes:
    StandardTitanTx, TitanBlueprintsTransaction

      public interface TitanTransaction
      extends com.tinkerpop.blueprints.TransactionalGraph, com.tinkerpop.blueprints.KeyIndexableGraph

  TitanTransaction defines a transactional context for a `TitanGraph`. Since TitanGraph is a transactional graph database, all interactions with the graph are mitigated by a TitanTransaction.

  All vertex and edge retrievals are channeled by a graph transaction which bundles all such retrievals, creations and deletions into one transaction. A graph transaction is analogous to a database transaction. The isolation level and ACID support are configured through the storage backend, meaning whatever level of isolation is supported by the storage backend is mirrored by a graph transaction.

  A graph transaction supports:
  - Creating vertices, properties and edges
  - Creating types
  - Index-based retrieval of vertices
  - Querying edges and vertices
  - Aborting and committing transaction
  Author:
    Matthias Bröcheler (http://www.matthiasb.com)

- - ### Nested Class Summary

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

      `com.tinkerpop.blueprints.TransactionalGraph.Conclusion`

  - ### 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.
    `TitanEdge` | `addEdge(TitanVertex outVertex, TitanVertex inVertex, String 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` | `addProperty(TitanVertex vertex, String key, Object value)` Creates a new property for the given vertex and key with the specified value.
    `TitanVertex` | `addVertex()` Creates a new vertex in the graph with the default vertex label.
    `TitanVertex` | `addVertex(Long id, VertexLabel vertexLabel)` 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.
    `EdgeLabel` | `getEdgeLabel(String name)` Returns the edge label with the given name.
    `Iterable<TitanEdge>` | `getEdges(PropertyKey key, Object value)` Retrieves all vertices which have a property of the given key with the specified value.
    `PropertyKey` | `getPropertyKey(String name)` Returns the property key with the given name.
    `RelationType` | `getRelationType(String name)` Returns the type with the given name.
    `TitanVertex` | `getVertex(long id)` Retrieves the vertex for the specified id.
    `VertexLabel` | `getVertexLabel(String name)` Returns the vertex label with the given name.
    `Iterable<TitanVertex>` | `getVertices(PropertyKey key, Object value)` 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.
    `EdgeLabelMaker` | `makeEdgeLabel(String name)` Returns a `EdgeLabelMaker` instance to define a new `EdgeLabel` with the given name.
    `PropertyKeyMaker` | `makePropertyKey(String name)` Returns a `PropertyKeyMaker` instance to define a new `PropertyKey` with the given name.
    `VertexLabelMaker` | `makeVertexLabel(String name)` Returns a `VertexLabelMaker` to define a new vertex label with the given name.
    `TitanMultiVertexQuery<? extends TitanMultiVertexQuery>` | `multiQuery(Collection<TitanVertex> vertices)`
    `TitanMultiVertexQuery<? extends TitanMultiVertexQuery>` | `multiQuery(TitanVertex... vertices)`
    `TitanGraphQuery<? extends TitanGraphQuery>` | `query()`
    `void` | `rollback()` Aborts and closes the transaction.

    - ### Methods inherited from interface com.tinkerpop.blueprints.TransactionalGraph

      `shutdown, stopTransaction`

    - ### Methods inherited from interface com.tinkerpop.blueprints.KeyIndexableGraph

      `createKeyIndex, dropKeyIndex, getIndexedKeys`

    - ### Methods inherited from interface com.tinkerpop.blueprints.Graph

      `addEdge, addVertex, getEdge, getEdges, getEdges, getFeatures, getVertex, getVertices, getVertices, removeEdge, removeVertex`

- - ### Method Detail

    - #### addVertex

          TitanVertex addVertex()

      Creates a new vertex in the graph with the default vertex label.
      Returns:
        New vertex in the graph created in the context of this transaction.

    - #### addVertexWithLabel

          TitanVertex addVertexWithLabel(String vertexLabel)

      Creates a new vertex in the graph with the vertex label named by the argument.
      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

          TitanVertex addVertexWithLabel(VertexLabel vertexLabel)

      Creates a new vertex in the graph with the given vertex label.
      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

    - #### addVertex

          TitanVertex addVertex(Long id,
                              VertexLabel vertexLabel)

      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.
      Parameters:
        `id` - vertex id of the vertex to be created
        `vertexLabel` - vertex label for this vertex - can be null if no vertex label should be set.
      Returns:
        New vertex

    - #### addEdge

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

      Creates a new edge connecting the specified vertices.

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

    - #### addEdge

          TitanEdge addEdge(TitanVertex outVertex,
                          TitanVertex inVertex,
                          String label)

      Creates a new edge connecting the specified vertices.

      Creates and returns a new `TitanEdge` with given label connecting the vertices in the order specified.
      Automatically creates the edge label if it does not exist and automatic creation of types is enabled. Otherwise, this method with throw an `IllegalArgumentException`.
      Parameters:
        `label` - label of the edge to be created
        `outVertex` - outgoing vertex of the edge
        `inVertex` - incoming vertex of the edge
      Returns:
        new edge

    - #### addProperty

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

      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.
      Parameters:
        `key` - key of the property to be created
        `vertex` - vertex for which to create the property
        `value` - value of the property to be created
      Returns:
        new property
      Throws:
        `IllegalArgumentException` - if the value does not match the data type of the given property key.

    - #### addProperty

          TitanProperty addProperty(TitanVertex vertex,
                                  String key,
                                  Object value)

      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.
      Automatically creates the property key if it does not exist and automatic creation of types is enabled. Otherwise, this method with throw an `IllegalArgumentException`.
      Parameters:
        `key` - key of the property to be created
        `vertex` - vertex for which to create the property
        `value` - value of the property to be created
      Returns:
        new property
      Throws:
        `IllegalArgumentException` - if the value does not match the data type of the given property key.

    - #### getVertex

          TitanVertex getVertex(long id)

      Retrieves the vertex for the specified id.
      Parameters:
        `id` - id of the vertex to retrieve
      Returns:
        vertex with the given id if it exists, else null
      See Also:
        `containsVertex(long)`

    - #### containsVertex

          boolean containsVertex(long vertexid)

      Checks whether a vertex with the specified id exists in the graph database.
      Parameters:
        `vertexid` - vertex id
      Returns:
        true, if a vertex with that id exists, else false

    - #### query

          TitanGraphQuery<? extends TitanGraphQuery> query()

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

    - #### indexQuery

          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. The query string is analyzed and answered by the underlying storage backend.

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

    - #### multiQuery

          TitanMultiVertexQuery<? extends TitanMultiVertexQuery> multiQuery(TitanVertex... vertices)

      Returns:
      See Also:
        `TitanGraph.multiQuery(TitanVertex...)`

    - #### multiQuery

          TitanMultiVertexQuery<? extends TitanMultiVertexQuery> multiQuery(Collection<TitanVertex> vertices)

      Returns:
      See Also:
        `TitanGraph.multiQuery(Collection)`

    - #### getVertices

          Iterable<TitanVertex> getVertices(PropertyKey key,
                                          Object value)

      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.
      Parameters:
        `key` - key
        `value` - value value
      Returns:
        All vertices which have a property of the given key with the specified value.
      See Also:
        `TitanManagement.buildIndex(String, Class)`

    - #### getEdges

          Iterable<TitanEdge> getEdges(PropertyKey key,
                                     Object value)

      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.
      Parameters:
        `key` - key
        `value` - value value
      Returns:
        All edges which have a property of the given key with the specified value.
      See Also:
        `TitanManagement.buildIndex(String, Class)`

    - #### containsRelationType

          boolean containsRelationType(String name)

      Checks whether a type with the specified name exists.
      Parameters:
        `name` - name of the type
      Returns:
        true, if a type with the given name exists, else false

    - #### getRelationType

          RelationType getRelationType(String name)

      Returns the type with the given name. Note, that type names must be unique.
      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`

    - #### getPropertyKey

          PropertyKey getPropertyKey(String name)

      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.
      Parameters:
        `name` - name of the property key to return
      Returns:
        the property key with the given name
      Throws:
        `IllegalArgumentException` - if a property key with the given name does not exist or if the type with the given name is not a property key
      See Also:
        `PropertyKey`

    - #### getEdgeLabel

          EdgeLabel getEdgeLabel(String name)

      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.
      Parameters:
        `name` - name of the edge label to return
      Returns:
        the edge label with the given name
      Throws:
        `IllegalArgumentException` - if an edge label with the given name does not exist or if the type with the given name is not an edge label
      See Also:
        `EdgeLabel`

    - #### makePropertyKey

          PropertyKeyMaker makePropertyKey(String name)

      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.
      Returns:
        a `PropertyKeyMaker` linked to this transaction.
      See Also:
        `PropertyKeyMaker`, `PropertyKey`

    - #### makeEdgeLabel

          EdgeLabelMaker makeEdgeLabel(String name)

      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.
      Returns:
        a `EdgeLabelMaker` linked to this transaction.
      See Also:
        `EdgeLabelMaker`, `EdgeLabel`

    - #### containsVertexLabel

          boolean containsVertexLabel(String name)

      Whether a vertex label with the given name exists in the graph.
      Parameters:
        `name` -
      Returns:

    - #### getVertexLabel

          VertexLabel getVertexLabel(String name)

      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.
      Parameters:
        `name` -
      Returns:

    - #### makeVertexLabel

          VertexLabelMaker makeVertexLabel(String name)

      Returns a `VertexLabelMaker` to define a new vertex label with the given name. Note, that the name must be unique.
      Parameters:
        `name` -
      Returns:

    - #### commit

          void commit()

      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 `com.tinkerpop.blueprints.TransactionalGraph`
      Throws:
        `BackendException` - if an error arises during persistence

    - #### rollback

          void rollback()

      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 `com.tinkerpop.blueprints.TransactionalGraph`
      Throws:
        `BackendException` - if an error arises when releasing the transaction handle

    - #### isOpen

          boolean isOpen()

      Checks whether the transaction is still open.
      Returns:
        true, when the transaction is open, else false

    - #### isClosed

          boolean isClosed()

      Checks whether the transaction has been closed.
      Returns:
        true, if the transaction has been closed, else false

    - #### hasModifications

          boolean hasModifications()

      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.
      Returns:
        true, if the transaction contains updates, else false.

Copyright © 2012–2014. All rights reserved.