1 package org.simantics.export.ui.util;
3 import java.util.ArrayList;
4 import java.util.Collection;
7 import org.simantics.db.ReadGraph;
8 import org.simantics.db.Resource;
9 import org.simantics.db.common.request.ObjectsWithType;
10 import org.simantics.db.common.request.ResourceRead;
11 import org.simantics.db.common.request.UniqueRead;
12 import org.simantics.db.exception.AssumptionException;
13 import org.simantics.db.exception.DatabaseException;
14 import org.simantics.db.exception.ServiceException;
15 import org.simantics.db.exception.ValidationException;
16 import org.simantics.db.layer0.request.ActiveModels;
17 import org.simantics.db.request.Read;
18 import org.simantics.layer0.Layer0;
19 import org.simantics.simulation.ontology.SimulationResource;
21 public class ExportUIQueries {
25 * Get a query that returns active models
27 * @return a query that returns active models
29 public static ResourceRead<Collection<Resource>> activeModels(Resource project) {
30 return new ActiveModels(project);
34 public static Read<List<String>> models(final String project) {
35 return new UniqueRead<List<String>>() {
37 public List<String> perform(ReadGraph graph) throws DatabaseException {
38 Layer0 L0 = Layer0.getInstance(graph);
39 SimulationResource SIMU = SimulationResource.getInstance(graph);
40 ArrayList<String> result = new ArrayList<String>();
41 Resource projectRes = graph.getResource(project);
42 for (Resource model : graph.syncRequest(new ObjectsWithType(projectRes, L0.ConsistsOf, SIMU.Model))) {
44 String uri = graph.getURI(model);
45 if ( uri!=null ) result.add( uri );
46 } catch (AssumptionException e) {
48 } catch (ValidationException e) {
50 } catch (ServiceException e) {