@@ -0,0 +1,1660 @@
+package com.orientechnologies.orient.graph.migration;%0A%0Aimport java.util.List;%0A%0Aimport com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;%0Aimport com.orientechnologies.orient.core.db.record.ridbag.ORidBag;%0Aimport com.orientechnologies.orient.core.record.impl.ODocument;%0Aimport com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;%0Aimport com.orientechnologies.orient.core.type.tree.OMVRBTreeRIDSet;%0Aimport com.tinkerpop.blueprints.impls.orient.OrientVertex;%0A%0A/**%0A * In OrientDb 1.7-rc1 was introduced RidBag a new data structure for link management. Since OrientDB 1.7 RidBag is default data%0A * structure for management relationships in graph. Use this class to upgrade graphs created under older versions of OrientDB.%0A * %0A * @author %3Ca href=%22mailto:enisher@gmail.com%22%3EArtem Orobets%3C/a%3E%0A */%0Apublic class ORidBagMigration %7B%0A  private final ODatabaseDocumentTx database;%0A%0A  public ORidBagMigration(ODatabaseDocumentTx database) %7B%0A    this.database = database;%0A  %7D%0A%0A  public void execute() %7B%0A    List%3CODocument%3E vertexes = database.query(new OSQLSynchQuery%3CODocument%3E(%22select from V%22));%0A%0A    for (ODocument vertex : vertexes) %7B%0A      for (String fieldName : vertex.fieldNames()) %7B%0A        if (fieldName.startsWith(OrientVertex.CONNECTION_IN_PREFIX) %7C%7C fieldName.startsWith(OrientVertex.CONNECTION_OUT_PREFIX)) %7B%0A          Object oldValue = vertex.field(fieldName);%0A          if (oldValue instanceof OMVRBTreeRIDSet) %7B%0A            OMVRBTreeRIDSet oldTree = (OMVRBTreeRIDSet) oldValue;%0A            ORidBag bag = new ORidBag();%0A            bag.addAll(oldTree);%0A%0A            vertex.field(fieldName, bag);%0A          %7D%0A        %7D%0A      %7D%0A    %7D%0A  %7D%0A%7D%0A

Create migration from older version of graph