X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Frequest%2FActiveModels.java;h=d7e0bcc6bfc4512b594cfcc668fd6c0a7ad05ce6;hb=27cae6bcf184f7e27822886f5a7320f771913b71;hp=ffee00df66a0d7f5c57f49d4a387b4667cd8246c;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/ActiveModels.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/ActiveModels.java index ffee00df6..d7e0bcc6b 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/ActiveModels.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/request/ActiveModels.java @@ -1,47 +1,47 @@ -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> { - - public ActiveModels(Resource project) { - super(project); - } - - @Override - public Collection perform(ReadGraph graph) throws DatabaseException { - Layer0 L0 = Layer0.getInstance(graph); - Layer0X L0X = Layer0X.getInstance(graph); - SimulationResource SIMU = SimulationResource.getInstance(graph); - ArrayList result = new ArrayList(); - 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 models = graph.syncRequest(new ActiveModels(project)); - if(models.isEmpty()) - return null; - else - return models.iterator().next(); - } - -} +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> { + + public ActiveModels(Resource project) { + super(project); + } + + @Override + public Collection perform(ReadGraph graph) throws DatabaseException { + Layer0 L0 = Layer0.getInstance(graph); + Layer0X L0X = Layer0X.getInstance(graph); + SimulationResource SIMU = SimulationResource.getInstance(graph); + ArrayList result = new ArrayList(); + 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 models = graph.syncRequest(new ActiveModels(project)); + if(models.isEmpty()) + return null; + else + return models.iterator().next(); + } + +}