1 package org.simantics.tests.modelled.ui.ontology;
\r
3 import org.simantics.db.RequestProcessor;
\r
4 import org.simantics.db.Resource;
\r
5 import org.simantics.db.ReadGraph;
\r
6 import org.simantics.db.request.Read;
\r
7 import org.simantics.db.Session;
\r
8 import org.simantics.db.exception.DatabaseException;
\r
9 import org.simantics.db.service.QueryControl;
\r
11 public class TestsUIResource {
\r
13 public final Resource BrowseContext;
\r
14 public final Resource Contributions;
\r
15 public final Resource Contributions_NewSTSSuite;
\r
16 public final Resource Contributions_NewSTSTest;
\r
17 public final Resource Contributions_STSSuites;
\r
18 public final Resource Contributions_STSTests;
\r
19 public final Resource Contributions_SuiteImage;
\r
20 public final Resource Contributions_TestImage;
\r
21 public final Resource ModelingActionContext;
\r
22 public final Resource ModelingActionContext_Actions;
\r
23 public final Resource ModelingActionContext_Actions_NewSTSSuite;
\r
24 public final Resource ModelingActionContext_Actions_NewSTSTest;
\r
25 public final Resource ModelingActionContext_Actions_RunSTSTest;
\r
26 public final Resource SCLMain;
\r
27 public final Resource testImage;
\r
28 public final Resource testSuiteImage;
\r
30 public static class URIs {
\r
31 public static final String BrowseContext = "http://www.simantics.org/TestsUI-1.0/BrowseContext";
\r
32 public static final String Contributions = "http://www.simantics.org/TestsUI-1.0/Contributions";
\r
33 public static final String Contributions_NewSTSSuite = "http://www.simantics.org/TestsUI-1.0/Contributions/NewSTSSuite";
\r
34 public static final String Contributions_NewSTSTest = "http://www.simantics.org/TestsUI-1.0/Contributions/NewSTSTest";
\r
35 public static final String Contributions_STSSuites = "http://www.simantics.org/TestsUI-1.0/Contributions/STSSuites";
\r
36 public static final String Contributions_STSTests = "http://www.simantics.org/TestsUI-1.0/Contributions/STSTests";
\r
37 public static final String Contributions_SuiteImage = "http://www.simantics.org/TestsUI-1.0/Contributions/SuiteImage";
\r
38 public static final String Contributions_TestImage = "http://www.simantics.org/TestsUI-1.0/Contributions/TestImage";
\r
39 public static final String ModelingActionContext = "http://www.simantics.org/TestsUI-1.0/ModelingActionContext";
\r
40 public static final String ModelingActionContext_Actions = "http://www.simantics.org/TestsUI-1.0/ModelingActionContext/Actions";
\r
41 public static final String ModelingActionContext_Actions_NewSTSSuite = "http://www.simantics.org/TestsUI-1.0/ModelingActionContext/Actions/NewSTSSuite";
\r
42 public static final String ModelingActionContext_Actions_NewSTSTest = "http://www.simantics.org/TestsUI-1.0/ModelingActionContext/Actions/NewSTSTest";
\r
43 public static final String ModelingActionContext_Actions_RunSTSTest = "http://www.simantics.org/TestsUI-1.0/ModelingActionContext/Actions/RunSTSTest";
\r
44 public static final String SCLMain = "http://www.simantics.org/TestsUI-1.0/SCLMain";
\r
45 public static final String testImage = "http://www.simantics.org/TestsUI-1.0/testImage";
\r
46 public static final String testSuiteImage = "http://www.simantics.org/TestsUI-1.0/testSuiteImage";
\r
49 public static Resource getResourceOrNull(ReadGraph graph, String uri) {
\r
51 return graph.getResource(uri);
\r
52 } catch(DatabaseException e) {
\r
53 System.err.println(e.getMessage());
\r
58 public TestsUIResource(ReadGraph graph) {
\r
59 BrowseContext = getResourceOrNull(graph, URIs.BrowseContext);
\r
60 Contributions = getResourceOrNull(graph, URIs.Contributions);
\r
61 Contributions_NewSTSSuite = getResourceOrNull(graph, URIs.Contributions_NewSTSSuite);
\r
62 Contributions_NewSTSTest = getResourceOrNull(graph, URIs.Contributions_NewSTSTest);
\r
63 Contributions_STSSuites = getResourceOrNull(graph, URIs.Contributions_STSSuites);
\r
64 Contributions_STSTests = getResourceOrNull(graph, URIs.Contributions_STSTests);
\r
65 Contributions_SuiteImage = getResourceOrNull(graph, URIs.Contributions_SuiteImage);
\r
66 Contributions_TestImage = getResourceOrNull(graph, URIs.Contributions_TestImage);
\r
67 ModelingActionContext = getResourceOrNull(graph, URIs.ModelingActionContext);
\r
68 ModelingActionContext_Actions = getResourceOrNull(graph, URIs.ModelingActionContext_Actions);
\r
69 ModelingActionContext_Actions_NewSTSSuite = getResourceOrNull(graph, URIs.ModelingActionContext_Actions_NewSTSSuite);
\r
70 ModelingActionContext_Actions_NewSTSTest = getResourceOrNull(graph, URIs.ModelingActionContext_Actions_NewSTSTest);
\r
71 ModelingActionContext_Actions_RunSTSTest = getResourceOrNull(graph, URIs.ModelingActionContext_Actions_RunSTSTest);
\r
72 SCLMain = getResourceOrNull(graph, URIs.SCLMain);
\r
73 testImage = getResourceOrNull(graph, URIs.testImage);
\r
74 testSuiteImage = getResourceOrNull(graph, URIs.testSuiteImage);
\r
77 public static TestsUIResource getInstance(ReadGraph graph) {
\r
78 Session session = graph.getSession();
\r
79 TestsUIResource ret = session.peekService(TestsUIResource.class);
\r
81 QueryControl qc = graph.getService(QueryControl.class);
\r
82 ret = new TestsUIResource(qc.getIndependentGraph(graph));
\r
83 session.registerService(TestsUIResource.class, ret);
\r
88 public static TestsUIResource getInstance(RequestProcessor session) throws DatabaseException {
\r
89 TestsUIResource ret = session.peekService(TestsUIResource.class);
\r
91 ret = session.syncRequest(new Read<TestsUIResource>() {
\r
92 public TestsUIResource perform(ReadGraph graph) throws DatabaseException {
\r
93 QueryControl qc = graph.getService(QueryControl.class);
\r
94 return new TestsUIResource(qc.getIndependentGraph(graph));
\r
97 session.registerService(TestsUIResource.class, ret);
\r