graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientVertex.java
public ORID moveTo(final String iClassName, final String iClusterName) {
    final OrientBaseGraph graph = getGraph();

    if (checkDeletedInTx())
      graph.throwRecordNotFoundException(getIdentity(), "The vertex " + getIdentity() + " has been deleted");

    final ORID oldIdentity = getIdentity().copy();

    final ORecord oldRecord = oldIdentity.getRecord();
    if (oldRecord == null)
      graph.throwRecordNotFoundException(getIdentity(), "The vertex " + getIdentity() + " has been deleted");

    final ODocument doc = ((ODocument) rawElement.getRecord()).copy();

    final Iterable<Edge> outEdges = getEdges(Direction.OUT);
    final Iterable<Edge> inEdges = getEdges(Direction.IN);

    // DELETE THE OLD RECORD FIRST TO AVOID ISSUES WITH UNIQUE CONSTRAINTS
    copyRidBags(oldRecord, doc);
    removeEdgeLinks(oldRecord);
    oldRecord.delete();

    if (iClassName != null)
      // OVERWRITE CLASS
      doc.setClassName(iClassName);

    // SAVE THE NEW VERTEX
    doc.setDirty();

    // RESET IDENTITY
    ORecordInternal.setIdentity(doc, new ORecordId());

    if (iClusterName != null)
      doc.save(iClusterName);
    else
      doc.save();

    final ORID newIdentity = doc.getIdentity();

    // CONVERT OUT EDGES
    for (Edge e : outEdges) {
      final OrientEdge oe = (OrientEdge) e;
      if (oe.isLightweight()) {
        // REPLACE ALL REFS IN inVertex
        final OrientVertex inV = oe.getVertex(Direction.IN);

        final String inFieldName = OrientVertex
            .getConnectionFieldName(Direction.IN, oe.getLabel(), graph.isUseVertexFieldsForEdgeLabels());

        replaceLinks(inV.getRecord(), inFieldName, oldIdentity, newIdentity);
      } else {
        // REPLACE WITH NEW VERTEX
        oe.vOut = newIdentity;
        oe.getRecord().field(OrientBaseGraph.CONNECTION_OUT, newIdentity);
        oe.save();
      }
    }

    for (Edge e : inEdges) {
      final OrientEdge oe = (OrientEdge) e;
      if (oe.isLightweight()) {
        // REPLACE ALL REFS IN outVertex
        final OrientVertex outV = oe.getVertex(Direction.OUT);

        final String outFieldName = OrientVertex
            .getConnectionFieldName(Direction.OUT, oe.getLabel(), graph.isUseVertexFieldsForEdgeLabels());

        replaceLinks(outV.getRecord(), outFieldName, oldIdentity, newIdentity);
      } else {
        // REPLACE WITH NEW VERTEX
        oe.vIn = newIdentity;
        oe.getRecord().field(OrientBaseGraph.CONNECTION_IN, newIdentity);
        oe.save();
      }
    }

    // FINAL SAVE
    doc.save();

    return newIdentity;
  }
public ORID moveTo(final String iClassName, final String iClusterName) {
    final OrientBaseGraph graph = getGraph();

    if (checkDeletedInTx())
      graph.throwRecordNotFoundException(getIdentity(), "The vertex " + getIdentity() + " has been deleted");

    final ORID oldIdentity = getIdentity().copy();

    final ORecord oldRecord = oldIdentity.getRecord();
    if (oldRecord == null)
      graph.throwRecordNotFoundException(getIdentity(), "The vertex " + getIdentity() + " has been deleted");

    final ODocument doc = ((ODocument) rawElement.getRecord()).copy();

    final Iterable<Edge> outEdges = getEdges(Direction.OUT);
    final Iterable<Edge> inEdges = getEdges(Direction.IN);

    // DELETE THE OLD RECORD FIRST TO AVOID ISSUES WITH UNIQUE CONSTRAINTS
    copyRidBags(oldRecord, doc);
    removeEdgeLinks(oldRecord);
    oldRecord.delete();

    if (iClassName != null)
      // OVERWRITE CLASS
      doc.setClassName(iClassName);

    // SAVE THE NEW VERTEX
    doc.setDirty();

    // RESET IDENTITY
    ORecordInternal.setIdentity(doc, new ORecordId());

    if (iClusterName != null)
      doc.save(iClusterName);
    else
      doc.save();

    final ORID newIdentity = doc.getIdentity();

    // CONVERT OUT EDGES
    for (Edge e : outEdges) {
      final OrientEdge oe = (OrientEdge) e;
      if (oe.isLightweight()) {
        // REPLACE ALL REFS IN inVertex
        final OrientVertex inV = oe.getVertex(Direction.IN);

        final String inFieldName = OrientVertex
            .getConnectionFieldName(Direction.IN, oe.getLabel(), graph.isUseVertexFieldsForEdgeLabels());

        replaceLinks(inV.getRecord(), inFieldName, oldIdentity, newIdentity);
      } else {
        // REPLACE WITH NEW VERTEX
        oe.vOut = newIdentity;
        oe.getRecord().field(OrientBaseGraph.CONNECTION_OUT, newIdentity);
        oe.save();
      }
    }

    for (Edge e : inEdges) {
      final OrientEdge oe = (OrientEdge) e;
      if (oe.isLightweight()) {
        // REPLACE ALL REFS IN outVertex
        final OrientVertex outV = oe.getVertex(Direction.OUT);

        final String outFieldName = OrientVertex
            .getConnectionFieldName(Direction.OUT, oe.getLabel(), graph.isUseVertexFieldsForEdgeLabels());

        replaceLinks(outV.getRecord(), outFieldName, oldIdentity, newIdentity);
      } else {
        // REPLACE WITH NEW VERTEX
        oe.vIn = newIdentity;
        oe.getRecord().field(OrientBaseGraph.CONNECTION_IN, newIdentity);
        oe.save();
      }
    }

    // FINAL SAVE
    doc.save();

    return newIdentity;
  }
public ORID moveTo ( final String iClassName , final String iClusterName ) { final OrientBaseGraph graph = getGraph ( ) ; if ( checkDeletedInTx ( ) ) graph . throwRecordNotFoundException ( getIdentity ( ) , "The vertex " + getIdentity ( ) + " has been deleted" ) ; final ORID oldIdentity = getIdentity ( ) . copy ( ) ; final ORecord oldRecord = oldIdentity . getRecord ( ) ; if ( oldRecord == null ) graph . throwRecordNotFoundException ( getIdentity ( ) , "The vertex " + getIdentity ( ) + " has been deleted" ) ; final ODocument doc = ( ( ODocument ) rawElement . getRecord ( ) ) . copy ( ) ; final Iterable < Edge > outEdges = getEdges ( Direction . OUT ) ; final Iterable < Edge > inEdges = getEdges ( Direction . IN ) ; // DELETE THE OLD RECORD FIRST TO AVOID ISSUES WITH UNIQUE CONSTRAINTS copyRidBags ( oldRecord , doc ) ; removeEdgeLinks ( oldRecord ) ; oldRecord . delete ( ) ; if ( iClassName != null ) // OVERWRITE CLASS doc . setClassName ( iClassName ) ; // SAVE THE NEW VERTEX doc . setDirty ( ) ; // RESET IDENTITY ORecordInternal . setIdentity ( doc , new ORecordId ( ) ) ; if ( iClusterName != null ) doc . save ( iClusterName ) ; else doc . save ( ) ; final ORID newIdentity = doc . getIdentity ( ) ; // CONVERT OUT EDGES for ( Edge e : outEdges ) { final OrientEdge oe = ( OrientEdge ) e ; if ( oe . isLightweight ( ) ) { // REPLACE ALL REFS IN inVertex final OrientVertex inV = oe . getVertex ( Direction . IN ) ; final String inFieldName = OrientVertex . getConnectionFieldName ( Direction . IN , oe . getLabel ( ) , graph . isUseVertexFieldsForEdgeLabels ( ) ) ; replaceLinks ( inV . getRecord ( ) , inFieldName , oldIdentity , newIdentity ) ; } else { // REPLACE WITH NEW VERTEX oe . vOut = newIdentity ; oe . getRecord ( ) . field ( OrientBaseGraph . CONNECTION_OUT , newIdentity ) ; oe . save ( ) ; } } for ( Edge e : inEdges ) { final OrientEdge oe = ( OrientEdge ) e ; if ( oe . isLightweight ( ) ) { // REPLACE ALL REFS IN outVertex final OrientVertex outV = oe . getVertex ( Direction . OUT ) ; final String outFieldName = OrientVertex . getConnectionFieldName ( Direction . OUT , oe . getLabel ( ) , graph . isUseVertexFieldsForEdgeLabels ( ) ) ; replaceLinks ( outV . getRecord ( ) , outFieldName , oldIdentity , newIdentity ) ; } else { // REPLACE WITH NEW VERTEX oe . vIn = newIdentity ; oe . getRecord ( ) . field ( OrientBaseGraph . CONNECTION_IN , newIdentity ) ; oe . save ( ) ; } } // FINAL SAVE doc . save ( ) ; return newIdentity ; }
Moves current vertex to another class/cluster. All edges are updated automatically.

@param iClassName   New class name to assign
@param iClusterName Cluster name where to save the new vertex

@return New vertex's identity

@see #moveToClass(String)
@see #moveToCluster(String)
Moves current vertex to another class / cluster . All edges are updated automatically .