]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Use ListIndexRoots in migration 94/494/1
authorAntti Villberg <antti.villberg@semantum.fi>
Sun, 7 May 2017 06:52:03 +0000 (09:52 +0300)
committerAntti Villberg <antti.villberg@semantum.fi>
Sun, 7 May 2017 06:52:03 +0000 (09:52 +0300)
refs #7198

Change-Id: I09c034e1723ec8bc35706d137f5a8c8cba96a44a

bundles/org.simantics.modeling/src/org/simantics/modeling/UserComponentMigration.java

index b4db9c8766b863103ef3e398d9a73ce8b69bc974..be480be4785357e632310940c2d9948d860be4a5 100644 (file)
@@ -11,8 +11,6 @@
  *******************************************************************************/
 package org.simantics.modeling;
 
-import gnu.trove.set.hash.THashSet;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -28,7 +26,6 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;
 import org.simantics.db.WriteGraph;
 import org.simantics.db.common.NamedResource;
-import org.simantics.db.common.request.ObjectsWithType;
 import org.simantics.db.common.request.PossibleIndexRoot;
 import org.simantics.db.common.utils.NameUtils;
 import org.simantics.db.common.utils.VersionMap;
@@ -37,18 +34,20 @@ import org.simantics.db.exception.CancelTransactionException;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.Instances;
 import org.simantics.db.layer0.request.ActiveModels;
+import org.simantics.db.layer0.request.ListIndexRoots;
 import org.simantics.db.layer0.util.Layer0Utils;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.layer0.Layer0;
 import org.simantics.modeling.MigrateModel.MigrationOperation;
 import org.simantics.modeling.migration.UserComponentPostMigrationAction;
-import org.simantics.simulation.ontology.SimulationResource;
 import org.simantics.structural.stubs.StructuralResource2;
 import org.simantics.utils.datastructures.MapList;
 import org.simantics.utils.datastructures.Pair;
 import org.simantics.utils.datastructures.Triple;
 import org.simantics.utils.strings.AlphanumComparator;
 
+import gnu.trove.set.hash.THashSet;
+
 /**
  * @author Antti Villberg
  * @author Tuukka Lehtonen
@@ -239,18 +238,16 @@ public class UserComponentMigration {
     }
 
     private static Collection<NamedResource> getLocations(ReadGraph graph, final Resource project) throws DatabaseException {
-        Layer0 L0 = Layer0.getInstance(graph);
-        SimulationResource SIMU = SimulationResource.getInstance(graph);
         Collection<NamedResource> libraries = new ArrayList<>();
-        for (Resource r : graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, SIMU.Model))) {
-            String name = Versions.getStandardNameString(graph, r);
-            libraries.add(new NamedResource(name, r));
-        }
-        Collection<Resource> ontologies = Simantics.applySCL("Simantics/SharedOntologies", "traverseSharedOntologies", graph, graph.getRootLibrary());
-        for (Resource r : ontologies) {
+        for (Resource r : graph.syncRequest(new ListIndexRoots())) {
             String name = Versions.getStandardNameString(graph, r);
             libraries.add(new NamedResource(name, r));
         }
+//        Collection<Resource> ontologies = Simantics.applySCL("Simantics/SharedOntologies", "traverseSharedOntologies", graph, graph.getRootLibrary());
+//        for (Resource r : ontologies) {
+//            String name = Versions.getStandardNameString(graph, r);
+//            libraries.add(new NamedResource(name, r));
+//        }
         return libraries;
     }