-package org.simantics.db.layer0.request;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ObjectsWithType;\r
-import org.simantics.db.common.request.ResourceRead;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.operation.Layer0X;\r
-import org.simantics.simulation.ontology.SimulationResource;\r
-\r
-/**\r
- * Returns a set of active models.\r
- * \r
- * @author Tuukka Lehtonen\r
- */\r
-public class ActiveModels extends ResourceRead<Collection<Resource>> {\r
-\r
- public ActiveModels(Resource project) {\r
- super(project);\r
- }\r
-\r
- @Override\r
- public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- Layer0X L0X = Layer0X.getInstance(graph);\r
- SimulationResource SIMU = SimulationResource.getInstance(graph);\r
- ArrayList<Resource> result = new ArrayList<Resource>();\r
- for (Resource model : graph.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, SIMU.Model))) {\r
- if (graph.hasStatement(model, L0X.IsActivatedBy))\r
- result.add(model);\r
- }\r
- return result;\r
- }\r
- \r
- public static Resource getPossibleActiveModel(ReadGraph graph, Resource project) throws DatabaseException {\r
- Collection<Resource> models = graph.syncRequest(new ActiveModels(project));\r
- if(models.isEmpty())\r
- return null;\r
- else\r
- return models.iterator().next();\r
- }\r
-\r
-}\r
+package org.simantics.db.layer0.request;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.ObjectsWithType;
+import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.layer0.Layer0;
+import org.simantics.operation.Layer0X;
+import org.simantics.simulation.ontology.SimulationResource;
+
+/**
+ * Returns a set of active models.
+ *
+ * @author Tuukka Lehtonen
+ */
+public class ActiveModels extends ResourceRead<Collection<Resource>> {
+
+ public ActiveModels(Resource project) {
+ super(project);
+ }
+
+ @Override
+ public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ Layer0X L0X = Layer0X.getInstance(graph);
+ SimulationResource SIMU = SimulationResource.getInstance(graph);
+ ArrayList<Resource> result = new ArrayList<Resource>();
+ for (Resource model : graph.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, SIMU.Model))) {
+ if (graph.hasStatement(model, L0X.IsActivatedBy))
+ result.add(model);
+ }
+ return result;
+ }
+
+ public static Resource getPossibleActiveModel(ReadGraph graph, Resource project) throws DatabaseException {
+ Collection<Resource> models = graph.syncRequest(new ActiveModels(project));
+ if(models.isEmpty())
+ return null;
+ else
+ return models.iterator().next();
+ }
+
+}