X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fmigration%2FMigrationUtils.java;h=58197619a7a25f8c002ac6460e166ff299b1919d;hp=5f20036a54e1ea75638fba8699a1f7044e8cb26c;hb=e92bb21b41012eb2795d15d1b9609dabb189cb40;hpb=9acebe9584f8f2a78f0322b6e0e24438e7ceb984 diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationUtils.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationUtils.java index 5f20036a5..58197619a 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationUtils.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/migration/MigrationUtils.java @@ -63,6 +63,8 @@ import org.simantics.graph.representation.Root; import org.simantics.graph.representation.TransferableGraph1; import org.simantics.graph.representation.TransferableGraphUtils; import org.simantics.layer0.Layer0; +import org.simantics.operation.Layer0X; +import org.simantics.simulation.ontology.SimulationResource; import org.simantics.utils.datastructures.Pair; import org.simantics.utils.datastructures.collections.CollectionUtils; @@ -100,6 +102,16 @@ public class MigrationUtils { }); } + /** + * Activate the imported resource, if there are no other active models and the resource is a Model. + */ + private static void activateIfNoActiveModel(WriteGraph graph, Resource root, Resource parent) throws DatabaseException { + Layer0X L0X = Layer0X.getInstance(graph); + SimulationResource SIMU = SimulationResource.getInstance(graph); + if(!graph.hasStatement(parent, L0X.Activates) && graph.isInstanceOf(root, SIMU.Model)) + graph.claim(parent, L0X.Activates, root); + } + public static Collection importTo(IProgressMonitor monitor, Session session, MigrationState state, final Resource parent, final IImportAdvisor advisor) throws DatabaseException, TransferableGraphException { final Resource resource = getResource(monitor, session, state); final ArrayList result = new ArrayList(); @@ -130,6 +142,10 @@ public class MigrationUtils { graph.deny(root, L0.PartOf); graph.claim(root, L0.PartOf, parent); + + // FIXME : Model activation must be done in "activations" virtual graph. + // FIXME : This step should be optional, not all the products use active models. + //activateIfNoActiveModel(graph, root, parent); CommentMetadata cm = graph.getMetadata(CommentMetadata.class); graph.addMetadata(cm.add("Imported " + graph.getURI(root) + ", resource " + root));