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;
});
}
+ /**
+ * 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<Resource> 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<Resource> result = new ArrayList<Resource>();
graph.deny(root, L0.PartOf);
graph.claim(root, L0.PartOf, parent);
+
+ activateIfNoActiveModel(graph, root, parent);
CommentMetadata cm = graph.getMetadata(CommentMetadata.class);
graph.addMetadata(cm.add("Imported " + graph.getURI(root) + ", resource " + root));