]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/ProjectModels.java
Merge "Documented difference of RuntimeEnvironmentRequest and Runti...quest2" into...
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / request / ProjectModels.java
1 package org.simantics.db.layer0.request;
2
3 import java.util.ArrayList;
4 import java.util.Collection;
5
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.simulation.ontology.SimulationResource;
13
14 /**
15  * Returns a set of active models.
16  * 
17  * @author Tuukka Lehtonen
18  */
19 public class ProjectModels extends ResourceRead<Collection<Resource>> {
20
21     public ProjectModels(Resource project) {
22         super(project);
23     }
24
25     @Override
26     public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
27         Layer0 L0 = Layer0.getInstance(graph);
28         SimulationResource SIMU = SimulationResource.getInstance(graph);
29         ArrayList<Resource> result = new ArrayList<Resource>();
30         for (Resource model : graph.syncRequest(new ObjectsWithType(resource, L0.ConsistsOf, SIMU.Model))) {
31             result.add(model);
32         }
33         return result;
34     }
35
36 }