1 package org.simantics.tests.modelled.ontology;
3 import org.simantics.db.RequestProcessor;
4 import org.simantics.db.Resource;
5 import org.simantics.db.ReadGraph;
6 import org.simantics.db.request.Read;
7 import org.simantics.db.Session;
8 import org.simantics.db.exception.DatabaseException;
9 import org.simantics.db.service.QueryControl;
11 public class TestsResource {
13 public final Resource SCLMain;
14 public final Resource STSSuite;
15 public final Resource STSSuite_moduleNameFilter;
16 public final Resource STSSuite_moduleNameFilter_Inverse;
17 public final Resource STSTest;
18 public final Resource STSTest_definition;
19 public final Resource STSTest_definition_Inverse;
20 public final Resource STSTest_executionPriority;
21 public final Resource STSTest_executionPriority_Inverse;
23 public static class URIs {
24 public static final String SCLMain = "http://www.simantics.org/Tests-1.0/SCLMain";
25 public static final String STSSuite = "http://www.simantics.org/Tests-1.0/STSSuite";
26 public static final String STSSuite_moduleNameFilter = "http://www.simantics.org/Tests-1.0/STSSuite/moduleNameFilter";
27 public static final String STSSuite_moduleNameFilter_Inverse = "http://www.simantics.org/Tests-1.0/STSSuite/moduleNameFilter/Inverse";
28 public static final String STSTest = "http://www.simantics.org/Tests-1.0/STSTest";
29 public static final String STSTest_definition = "http://www.simantics.org/Tests-1.0/STSTest/definition";
30 public static final String STSTest_definition_Inverse = "http://www.simantics.org/Tests-1.0/STSTest/definition/Inverse";
31 public static final String STSTest_executionPriority = "http://www.simantics.org/Tests-1.0/STSTest/executionPriority";
32 public static final String STSTest_executionPriority_Inverse = "http://www.simantics.org/Tests-1.0/STSTest/executionPriority/Inverse";
35 public static Resource getResourceOrNull(ReadGraph graph, String uri) {
37 return graph.getResource(uri);
38 } catch(DatabaseException e) {
39 System.err.println(e.getMessage());
44 public TestsResource(ReadGraph graph) {
45 SCLMain = getResourceOrNull(graph, URIs.SCLMain);
46 STSSuite = getResourceOrNull(graph, URIs.STSSuite);
47 STSSuite_moduleNameFilter = getResourceOrNull(graph, URIs.STSSuite_moduleNameFilter);
48 STSSuite_moduleNameFilter_Inverse = getResourceOrNull(graph, URIs.STSSuite_moduleNameFilter_Inverse);
49 STSTest = getResourceOrNull(graph, URIs.STSTest);
50 STSTest_definition = getResourceOrNull(graph, URIs.STSTest_definition);
51 STSTest_definition_Inverse = getResourceOrNull(graph, URIs.STSTest_definition_Inverse);
52 STSTest_executionPriority = getResourceOrNull(graph, URIs.STSTest_executionPriority);
53 STSTest_executionPriority_Inverse = getResourceOrNull(graph, URIs.STSTest_executionPriority_Inverse);
56 public static TestsResource getInstance(ReadGraph graph) {
57 Session session = graph.getSession();
58 TestsResource ret = session.peekService(TestsResource.class);
60 QueryControl qc = graph.getService(QueryControl.class);
61 ret = new TestsResource(qc.getIndependentGraph(graph));
62 session.registerService(TestsResource.class, ret);
67 public static TestsResource getInstance(RequestProcessor session) throws DatabaseException {
68 TestsResource ret = session.peekService(TestsResource.class);
70 ret = session.syncRequest(new Read<TestsResource>() {
71 public TestsResource perform(ReadGraph graph) throws DatabaseException {
72 QueryControl qc = graph.getService(QueryControl.class);
73 return new TestsResource(qc.getIndependentGraph(graph));
76 session.registerService(TestsResource.class, ret);