]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/PossibleActiveModel.java
Merge "Documented difference of RuntimeEnvironmentRequest and Runti...quest2" into...
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / request / PossibleActiveModel.java
1 package org.simantics.db.layer0.request;
2
3 import java.util.Collection;
4
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.Resource;
7 import org.simantics.db.common.request.ResourceRead;
8 import org.simantics.db.exception.DatabaseException;
9
10 /**
11  * Returns the active model or null if no single active model is available.
12  */
13 public class PossibleActiveModel extends ResourceRead<Resource> {
14
15     public PossibleActiveModel(Resource project) {
16         super(project);
17     }
18
19     @Override
20     public Resource perform(ReadGraph graph) throws DatabaseException {
21         Collection<Resource> actives = graph.syncRequest(new ActiveModels(resource));
22         if (actives.size() == 1)
23             return actives.iterator().next();
24         else
25             return null;
26     }
27
28 }