1 package org.simantics.db.layer0.request;
3 import java.util.ArrayList;
4 import java.util.Collection;
6 import org.simantics.db.ReadGraph;
7 import org.simantics.db.Resource;
8 import org.simantics.db.common.request.ObjectsWithType;
9 import org.simantics.db.common.request.ResourceRead;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.layer0.Layer0;
12 import org.simantics.operation.Layer0X;
13 import org.simantics.simulation.ontology.SimulationResource;
16 * Returns a set of active models.
18 * @author Tuukka Lehtonen
20 public class ActiveModels extends ResourceRead<Collection<Resource>> {
22 public ActiveModels(Resource project) {
27 public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
28 Layer0 L0 = Layer0.getInstance(graph);
29 Layer0X L0X = Layer0X.getInstance(graph);
30 SimulationResource SIMU = SimulationResource.getInstance(graph);
31 ArrayList<Resource> result = new ArrayList<Resource>();
32 for (Resource model : graph.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, SIMU.Model))) {
33 if (graph.hasStatement(model, L0X.IsActivatedBy))
39 public static Resource getPossibleActiveModel(ReadGraph graph, Resource project) throws DatabaseException {
40 Collection<Resource> models = graph.syncRequest(new ActiveModels(project));
44 return models.iterator().next();