1 package org.simantics.layer0;
\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 SoftwareConfigurationResources {
\r
13 public final Resource HasVersion;
\r
14 public final Resource HasVersion_Inverse;
\r
15 public final Resource IsCompatibleWith;
\r
16 public final Resource Product;
\r
17 public final Resource Update;
\r
18 public final Resource Update_From;
\r
19 public final Resource Update_HasMigrationAction;
\r
20 public final Resource Update_To;
\r
21 public final Resource Version;
\r
22 public final Resource Version_HasUpdate;
\r
23 public final Resource Version_Of;
\r
25 public static class URIs {
\r
26 public static final String HasVersion = "http://www.simantics.org/SoftwareConfiguration-1.1/HasVersion";
\r
27 public static final String HasVersion_Inverse = "http://www.simantics.org/SoftwareConfiguration-1.1/HasVersion/Inverse";
\r
28 public static final String IsCompatibleWith = "http://www.simantics.org/SoftwareConfiguration-1.1/IsCompatibleWith";
\r
29 public static final String Product = "http://www.simantics.org/SoftwareConfiguration-1.1/Product";
\r
30 public static final String Update = "http://www.simantics.org/SoftwareConfiguration-1.1/Update";
\r
31 public static final String Update_From = "http://www.simantics.org/SoftwareConfiguration-1.1/Update/From";
\r
32 public static final String Update_HasMigrationAction = "http://www.simantics.org/SoftwareConfiguration-1.1/Update/HasMigrationAction";
\r
33 public static final String Update_To = "http://www.simantics.org/SoftwareConfiguration-1.1/Update/To";
\r
34 public static final String Version = "http://www.simantics.org/SoftwareConfiguration-1.1/Version";
\r
35 public static final String Version_HasUpdate = "http://www.simantics.org/SoftwareConfiguration-1.1/Version/HasUpdate";
\r
36 public static final String Version_Of = "http://www.simantics.org/SoftwareConfiguration-1.1/Version/Of";
\r
39 public static Resource getResourceOrNull(ReadGraph graph, String uri) {
\r
41 return graph.getResource(uri);
\r
42 } catch(DatabaseException e) {
\r
43 System.err.println(e.getMessage());
\r
48 public SoftwareConfigurationResources(ReadGraph graph) {
\r
49 HasVersion = getResourceOrNull(graph, URIs.HasVersion);
\r
50 HasVersion_Inverse = getResourceOrNull(graph, URIs.HasVersion_Inverse);
\r
51 IsCompatibleWith = getResourceOrNull(graph, URIs.IsCompatibleWith);
\r
52 Product = getResourceOrNull(graph, URIs.Product);
\r
53 Update = getResourceOrNull(graph, URIs.Update);
\r
54 Update_From = getResourceOrNull(graph, URIs.Update_From);
\r
55 Update_HasMigrationAction = getResourceOrNull(graph, URIs.Update_HasMigrationAction);
\r
56 Update_To = getResourceOrNull(graph, URIs.Update_To);
\r
57 Version = getResourceOrNull(graph, URIs.Version);
\r
58 Version_HasUpdate = getResourceOrNull(graph, URIs.Version_HasUpdate);
\r
59 Version_Of = getResourceOrNull(graph, URIs.Version_Of);
\r
62 public static SoftwareConfigurationResources getInstance(ReadGraph graph) {
\r
63 Session session = graph.getSession();
\r
64 SoftwareConfigurationResources ret = session.peekService(SoftwareConfigurationResources.class);
\r
66 QueryControl qc = graph.getService(QueryControl.class);
\r
67 ret = new SoftwareConfigurationResources(qc.getIndependentGraph(graph));
\r
68 session.registerService(SoftwareConfigurationResources.class, ret);
\r
73 public static SoftwareConfigurationResources getInstance(RequestProcessor session) throws DatabaseException {
\r
74 SoftwareConfigurationResources ret = session.peekService(SoftwareConfigurationResources.class);
\r
76 ret = session.syncRequest(new Read<SoftwareConfigurationResources>() {
\r
77 public SoftwareConfigurationResources perform(ReadGraph graph) throws DatabaseException {
\r
78 QueryControl qc = graph.getService(QueryControl.class);
\r
79 return new SoftwareConfigurationResources(qc.getIndependentGraph(graph));
\r
82 session.registerService(SoftwareConfigurationResources.class, ret);
\r