Class OrientVertex

java.lang.Object
com.tinkerpop.blueprints.impls.orient.OrientElement
com.tinkerpop.blueprints.impls.orient.OrientVertex
All Implemented Interfaces:
OIdentifiable, OSerializableStream, com.tinkerpop.blueprints.Element, OrientExtendedVertex, com.tinkerpop.blueprints.Vertex, Externalizable, Serializable, Comparable<OIdentifiable>, Comparator<OIdentifiable>

public class OrientVertex extends OrientElement implements OrientExtendedVertex
OrientDB Vertex implementation of TinkerPop Blueprints standard.
Author:
Luca Garulli (l.garulli--(at)--orientdb.com) (http://orientdb.com)
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getConnectionFieldName

      public static String getConnectionFieldName(com.tinkerpop.blueprints.Direction iDirection, String iClassName, boolean useVertexFieldsForEdgeLabels)
      (Internal only) Returns the field name used for the relationship.
      Parameters:
      iDirection - Direction between IN, OUT or BOTH
      iClassName - Class name if any
      useVertexFieldsForEdgeLabels - Graph setting about using the edge label as vertex's field
    • createLink

      public static Object createLink(OrientBaseGraph iGraph, ODocument iFromVertex, OIdentifiable iTo, String iFieldName)
      (Internal only) Creates a link between a vertices and a Graph Element.
    • getConnectionDirection

      public static com.tinkerpop.blueprints.Direction getConnectionDirection(String iConnectionField, boolean useVertexFieldsForEdgeLabels)
    • getInverseConnectionFieldName

      public static String getInverseConnectionFieldName(String iFieldName, boolean useVertexFieldsForEdgeLabels)
      (Internal only)
    • replaceLinks

      public static void replaceLinks(ODocument iVertex, String iFieldName, OIdentifiable iVertexToRemove, OIdentifiable iNewVertex)
      (Internal only)
    • getEdge

      protected static OrientEdge getEdge(OrientBaseGraph graph, ODocument doc, String fieldName, OPair<com.tinkerpop.blueprints.Direction,String> connection, Object fieldValue, OIdentifiable iTargetVertex, String[] iLabels)
      (Internal only)
    • copy

      public OrientVertex copy()
      Specified by:
      copy in interface OrientExtendedVertex
    • getVertexInstance

      public OrientVertex getVertexInstance()
      Specified by:
      getVertexInstance in interface OrientExtendedVertex
    • execute

      public Object execute(OCommandPredicate iPredicate)
      (Blueprints Extension) Executes the command predicate against current vertex. Use OSQLPredicate to execute SQL. Example: Iterable friendsOfFriends = (Iterable) luca.execute(new OSQLPredicate("out().out('Friend').out('Friend')"));
      Parameters:
      iPredicate - Predicate to evaluate. Use OSQLPredicate to use SQL
    • getPropertyKeys

      public Set<String> getPropertyKeys()
      Returns all the Property names as Set of String. out, in and label are not returned as properties even if are part of the underlying document because are considered internal properties.
      Specified by:
      getPropertyKeys in interface com.tinkerpop.blueprints.Element
    • getProperties

      public Map<String,Object> getProperties()
      Description copied from class: OrientElement
      (Blueprints Extension) Gets all the properties from a Vertex or Edge in one shot.
      Specified by:
      getProperties in class OrientElement
      Returns:
      a map containing all the properties of the Vertex/Edge.
    • getVertices

      public Iterable<com.tinkerpop.blueprints.Vertex> getVertices(com.tinkerpop.blueprints.Direction iDirection, String... iLabels)
      Returns a lazy iterable instance against vertices.
      Specified by:
      getVertices in interface com.tinkerpop.blueprints.Vertex
      Parameters:
      iDirection - The direction between OUT, IN or BOTH
      iLabels - Optional varargs of Strings representing edge label to consider
    • query

      public OrientVertexQuery query()
      Executes a query against the current vertex. The returning type is a OrientVertexQuery.
      Specified by:
      query in interface com.tinkerpop.blueprints.Vertex
    • traverse

      public OTraverse traverse()
      Returns a OTraverse object to start traversing from the current vertex.
    • remove

      public void remove()
      Removes the current Vertex from the Graph. all the incoming and outgoing edges are automatically removed too.
      Specified by:
      remove in interface com.tinkerpop.blueprints.Element
    • moveToClass

      public ORID moveToClass(String iClassName)
      Moves current vertex to another class. All edges are updated automatically.
      Parameters:
      iClassName - New class name to assign
      Returns:
      New vertex's identity
      See Also:
    • moveToCluster

      public ORID moveToCluster(String iClusterName)
      Moves current vertex to another cluster. All edges are updated automatically.
      Parameters:
      iClusterName - Cluster name where to save the new vertex
      Returns:
      New vertex's identity
      See Also:
    • moveTo

      public ORID moveTo(String iClassName, String iClusterName)
      Moves current vertex to another class/cluster. All edges are updated automatically.
      Parameters:
      iClassName - New class name to assign
      iClusterName - Cluster name where to save the new vertex
      Returns:
      New vertex's identity
      See Also:
    • addEdge

      public com.tinkerpop.blueprints.Edge addEdge(String label, com.tinkerpop.blueprints.Vertex inVertex)
      Creates an edge between current Vertex and a target Vertex setting label as Edge's label.
      Specified by:
      addEdge in interface com.tinkerpop.blueprints.Vertex
      Parameters:
      label - Edge's label or class
      inVertex - Outgoing target vertex
      Returns:
      The new Edge created
    • addEdge

      public OrientEdge addEdge(String label, OrientVertex inVertex, String iClassName)
      Creates an edge between current Vertex and a target Vertex setting label as Edge's label. iClassName is the Edge's class used if different by label.
      Parameters:
      label - Edge's label or class
      inVertex - Outgoing target vertex
      iClassName - Edge's class name
      Returns:
      The new Edge created
    • addEdge

      public OrientEdge addEdge(String label, OrientVertex inVertex, Object[] fields)
      Creates an edge between current Vertex and a target Vertex setting label as Edge's label. The fields parameter is an Array of fields to set on Edge upon creation. Fields must be a odd pairs of key/value or a single object as Map containing entries as key/value pairs.
      Parameters:
      label - Edge's label or class
      inVertex - Outgoing target vertex
      fields - Fields must be a odd pairs of key/value or a single object as Map containing entries as key/value pairs
      Returns:
      The new Edge created
    • addEdge

      public OrientEdge addEdge(String label, OrientVertex inVertex, String iClassName, String iClusterName, Object... fields)
      Creates an edge between current Vertex and a target Vertex setting label as Edge's label. The fields parameter is an Array of fields to set on Edge upon creation. Fields must be a odd pairs of key/value or a single object as Map containing entries as key/value pairs. iClusterName is the name of the cluster where to store the new Edge.
      Parameters:
      label - Edge's label or class
      inVertex - Outgoing target vertex
      fields - Fields must be a odd pairs of key/value or a single object as Map containing entries as key/value pairs
      iClassName - Edge's class name
      iClusterName - The cluster name where to store the edge record
      Returns:
      The new Edge created
    • countEdges

      public long countEdges(com.tinkerpop.blueprints.Direction iDirection, String... iLabels)
      (Blueprints Extension) Returns the number of edges connected to the current Vertex.
      Parameters:
      iDirection - The direction between OUT, IN or BOTH
      iLabels - Optional labels as Strings to consider
      Returns:
      A long with the total edges found
    • getEdges

      public Iterable<com.tinkerpop.blueprints.Edge> getEdges(com.tinkerpop.blueprints.Direction iDirection, String... iLabels)
      Returns the edges connected to the current Vertex. If you are interested on just counting the edges use @countEdges that it's more efficient for this use case.
      Specified by:
      getEdges in interface com.tinkerpop.blueprints.Vertex
      Parameters:
      iDirection - The direction between OUT, IN or BOTH
      iLabels - Optional labels as Strings to consider
      Returns:
    • getEdges

      public Iterable<com.tinkerpop.blueprints.Edge> getEdges(OrientVertex iDestination, com.tinkerpop.blueprints.Direction iDirection, String... iLabels)
      (Blueprints Extension) Returns all the edges from the current Vertex to another one.
      Parameters:
      iDestination - The target vertex
      iDirection - The direction between OUT, IN or BOTH
      iLabels - Optional labels as Strings to consider
      Returns:
    • getLabel

      public String getLabel()
      (Blueprints Extension) Returns the Vertex's label. By default OrientDB binds the Blueprints Label concept to Vertex Class. To disable this feature execute this at database level alter database custom useClassForVertexLabel=false
      Specified by:
      getLabel in class OrientElement
    • getBaseClassName

      public String getBaseClassName()
      (Blueprints Extension) Returns "V" as base class name all the vertex sub-classes extend.
      Specified by:
      getBaseClassName in class OrientElement
    • getElementType

      public String getElementType()
      (Blueprints Extension) Returns "Vertex".
      Specified by:
      getElementType in class OrientElement
    • getType

      public OrientVertexType getType()
      (Blueprints Extension) Returns the Vertex type as OrientVertexType object.
      Specified by:
      getType in interface OrientExtendedVertex
    • toString

      public String toString()
      Returns a string representation of the vertex.
      Overrides:
      toString in class Object
    • getConnectionClass

      public String getConnectionClass(com.tinkerpop.blueprints.Direction iDirection, String iFieldName)
      Used to extract the class name from the vertex's field.
      Parameters:
      iDirection - Direction of connection
      iFieldName - Full field name
      Returns:
      Class of the connection if any
    • getConnection

      protected OPair<com.tinkerpop.blueprints.Direction,String> getConnection(com.tinkerpop.blueprints.Direction iDirection, String iFieldName, String... iClassNames)
      Determines if a field is a connections or not.
      Parameters:
      iDirection - Direction to check
      iFieldName - Field name
      iClassNames - Optional array of class names
      Returns:
      The found direction if any
    • addSingleEdge

      protected void addSingleEdge(ODocument doc, OMultiCollectionIterator<com.tinkerpop.blueprints.Edge> iterable, String fieldName, OPair<com.tinkerpop.blueprints.Direction,String> connection, Object fieldValue, OIdentifiable iTargetVertex, String[] iLabels)