]> gerrit.simantics Code Review - simantics/district.git/blob
714f808578ff9116403d494689c9792e26a18bb3
[simantics/district.git] /
1 package org.simantics.district.network.ontology;
2
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;
10
11 public class DistrictNetworkResource {
12     
13     public final Resource ActionContext;
14     public final Resource ActionContext_newDiagramContribution;
15     public final Resource Actions;
16     public final Resource Actions_NewDNDiagram;
17     public final Resource AddLayerToDNDiagramTemplate;
18     public final Resource Bidirectional;
19     public final Resource Bidirectional_Inverse;
20     public final Resource BrowseContext;
21     public final Resource Composite;
22     public final Resource Connection;
23     public final Resource Diagram;
24     public final Resource EPSG_4326;
25     public final Resource Edge;
26     public final Resource EdgeDefaultMapping;
27     public final Resource EdgeDefaultMapping_Inverse;
28     public final Resource EdgeMappingParameterType;
29     public final Resource Edge_HasDiameter;
30     public final Resource Edge_HasDiameter_Inverse;
31     public final Resource Functions;
32     public final Resource Functions_compositeInstantiator;
33     public final Resource Functions_convertToValue;
34     public final Resource Functions_defaultEdgeMappingModifier;
35     public final Resource Functions_defaultVertexMappingModifier;
36     public final Resource Functions_enumerationValues;
37     public final Resource Functions_mappingModifier;
38     public final Resource HasEndVertex;
39     public final Resource HasEndVertex_Inverse;
40     public final Resource HasInLayerTag;
41     public final Resource HasInLayerTag_Inverse;
42     public final Resource HasMapping;
43     public final Resource HasMapping_Inverse;
44     public final Resource HasSRID;
45     public final Resource HasSRID_Inverse;
46     public final Resource HasSRTEXT;
47     public final Resource HasSRTEXT_Inverse;
48     public final Resource HasSpatialRefSystem;
49     public final Resource HasSpatialRefSystem_Inverse;
50     public final Resource HasStartVertex;
51     public final Resource HasStartVertex_Inverse;
52     public final Resource Images;
53     public final Resource Images_ConfigurationFolder;
54     public final Resource InLayer;
55     public final Resource Layer;
56     public final Resource Mapping;
57     public final Resource MappingParameterType;
58     public final Resource Mapping_Base;
59     public final Resource Mapping_ComponentType;
60     public final Resource Mapping_ComponentType_Inverse;
61     public final Resource Mapping_Dummy;
62     public final Resource Mapping_EdgeMapping;
63     public final Resource Mapping_EdgeMapping_Bidirectional;
64     public final Resource Mapping_EdgeMapping_Bidirectional_Inverse;
65     public final Resource Mapping_EdgeMapping_DiameterAttribute;
66     public final Resource Mapping_EdgeMapping_DiameterAttribute_Inverse;
67     public final Resource Mapping_EdgeMapping_LengthAttribute;
68     public final Resource Mapping_EdgeMapping_LengthAttribute_Inverse;
69     public final Resource Mapping_InputTerminal;
70     public final Resource Mapping_InputTerminal_Inverse;
71     public final Resource Mapping_OutputTerminal;
72     public final Resource Mapping_OutputTerminal_Inverse;
73     public final Resource Mapping_Terminal;
74     public final Resource Mapping_TerminalPair;
75     public final Resource Mapping_Terminals;
76     public final Resource Mapping_Terminals_Inverse;
77     public final Resource Mapping_VertexMapping;
78     public final Resource Mapping_VertexMapping_ElevationAttribute;
79     public final Resource Mapping_VertexMapping_ElevationAttribute_Inverse;
80     public final Resource SpatialRefSystem;
81     public final Resource Vertex;
82     public final Resource VertexDefaultMapping;
83     public final Resource VertexDefaultMapping_Inverse;
84     public final Resource VertexMappingParameterType;
85         
86     public static class URIs {
87         public static final String ActionContext = "http://www.simantics.org/DistrictNetwork-1.0/ActionContext";
88         public static final String ActionContext_newDiagramContribution = "http://www.simantics.org/DistrictNetwork-1.0/ActionContext/newDiagramContribution";
89         public static final String Actions = "http://www.simantics.org/DistrictNetwork-1.0/Actions";
90         public static final String Actions_NewDNDiagram = "http://www.simantics.org/DistrictNetwork-1.0/Actions/NewDNDiagram";
91         public static final String AddLayerToDNDiagramTemplate = "http://www.simantics.org/DistrictNetwork-1.0/AddLayerToDNDiagramTemplate";
92         public static final String Bidirectional = "http://www.simantics.org/DistrictNetwork-1.0/Bidirectional";
93         public static final String Bidirectional_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Bidirectional/Inverse";
94         public static final String BrowseContext = "http://www.simantics.org/DistrictNetwork-1.0/BrowseContext";
95         public static final String Composite = "http://www.simantics.org/DistrictNetwork-1.0/Composite";
96         public static final String Connection = "http://www.simantics.org/DistrictNetwork-1.0/Connection";
97         public static final String Diagram = "http://www.simantics.org/DistrictNetwork-1.0/Diagram";
98         public static final String EPSG_4326 = "http://www.simantics.org/DistrictNetwork-1.0/EPSG_4326";
99         public static final String Edge = "http://www.simantics.org/DistrictNetwork-1.0/Edge";
100         public static final String EdgeDefaultMapping = "http://www.simantics.org/DistrictNetwork-1.0/EdgeDefaultMapping";
101         public static final String EdgeDefaultMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/EdgeDefaultMapping/Inverse";
102         public static final String EdgeMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/EdgeMappingParameterType";
103         public static final String Edge_HasDiameter = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasDiameter";
104         public static final String Edge_HasDiameter_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Edge/HasDiameter/Inverse";
105         public static final String Functions = "http://www.simantics.org/DistrictNetwork-1.0/Functions";
106         public static final String Functions_compositeInstantiator = "http://www.simantics.org/DistrictNetwork-1.0/Functions/compositeInstantiator";
107         public static final String Functions_convertToValue = "http://www.simantics.org/DistrictNetwork-1.0/Functions/convertToValue";
108         public static final String Functions_defaultEdgeMappingModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/defaultEdgeMappingModifier";
109         public static final String Functions_defaultVertexMappingModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/defaultVertexMappingModifier";
110         public static final String Functions_enumerationValues = "http://www.simantics.org/DistrictNetwork-1.0/Functions/enumerationValues";
111         public static final String Functions_mappingModifier = "http://www.simantics.org/DistrictNetwork-1.0/Functions/mappingModifier";
112         public static final String HasEndVertex = "http://www.simantics.org/DistrictNetwork-1.0/HasEndVertex";
113         public static final String HasEndVertex_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasEndVertex_Inverse";
114         public static final String HasInLayerTag = "http://www.simantics.org/DistrictNetwork-1.0/HasInLayerTag";
115         public static final String HasInLayerTag_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasInLayerTag/Inverse";
116         public static final String HasMapping = "http://www.simantics.org/DistrictNetwork-1.0/HasMapping";
117         public static final String HasMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasMapping/Inverse";
118         public static final String HasSRID = "http://www.simantics.org/DistrictNetwork-1.0/HasSRID";
119         public static final String HasSRID_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasSRID/Inverse";
120         public static final String HasSRTEXT = "http://www.simantics.org/DistrictNetwork-1.0/HasSRTEXT";
121         public static final String HasSRTEXT_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasSRTEXT/Inverse";
122         public static final String HasSpatialRefSystem = "http://www.simantics.org/DistrictNetwork-1.0/HasSpatialRefSystem";
123         public static final String HasSpatialRefSystem_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasSpatialRefSystem/Inverse";
124         public static final String HasStartVertex = "http://www.simantics.org/DistrictNetwork-1.0/HasStartVertex";
125         public static final String HasStartVertex_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/HasStartVertex_Inverse";
126         public static final String Images = "http://www.simantics.org/DistrictNetwork-1.0/Images";
127         public static final String Images_ConfigurationFolder = "http://www.simantics.org/DistrictNetwork-1.0/Images/ConfigurationFolder";
128         public static final String InLayer = "http://www.simantics.org/DistrictNetwork-1.0/InLayer";
129         public static final String Layer = "http://www.simantics.org/DistrictNetwork-1.0/Layer";
130         public static final String Mapping = "http://www.simantics.org/DistrictNetwork-1.0/Mapping";
131         public static final String MappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/MappingParameterType";
132         public static final String Mapping_Base = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Base";
133         public static final String Mapping_ComponentType = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/ComponentType";
134         public static final String Mapping_ComponentType_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/ComponentType/Inverse";
135         public static final String Mapping_Dummy = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Dummy";
136         public static final String Mapping_EdgeMapping = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping";
137         public static final String Mapping_EdgeMapping_Bidirectional = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/Bidirectional";
138         public static final String Mapping_EdgeMapping_Bidirectional_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/Bidirectional/Inverse";
139         public static final String Mapping_EdgeMapping_DiameterAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/DiameterAttribute";
140         public static final String Mapping_EdgeMapping_DiameterAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/DiameterAttribute/Inverse";
141         public static final String Mapping_EdgeMapping_LengthAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/LengthAttribute";
142         public static final String Mapping_EdgeMapping_LengthAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/EdgeMapping/LengthAttribute/Inverse";
143         public static final String Mapping_InputTerminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/InputTerminal";
144         public static final String Mapping_InputTerminal_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/InputTerminal/Inverse";
145         public static final String Mapping_OutputTerminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/OutputTerminal";
146         public static final String Mapping_OutputTerminal_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/OutputTerminal/Inverse";
147         public static final String Mapping_Terminal = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Terminal";
148         public static final String Mapping_TerminalPair = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/TerminalPair";
149         public static final String Mapping_Terminals = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Terminals";
150         public static final String Mapping_Terminals_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/Terminals/Inverse";
151         public static final String Mapping_VertexMapping = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping";
152         public static final String Mapping_VertexMapping_ElevationAttribute = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ElevationAttribute";
153         public static final String Mapping_VertexMapping_ElevationAttribute_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/Mapping/VertexMapping/ElevationAttribute/Inverse";
154         public static final String SpatialRefSystem = "http://www.simantics.org/DistrictNetwork-1.0/SpatialRefSystem";
155         public static final String Vertex = "http://www.simantics.org/DistrictNetwork-1.0/Vertex";
156         public static final String VertexDefaultMapping = "http://www.simantics.org/DistrictNetwork-1.0/VertexDefaultMapping";
157         public static final String VertexDefaultMapping_Inverse = "http://www.simantics.org/DistrictNetwork-1.0/VertexDefaultMapping/Inverse";
158         public static final String VertexMappingParameterType = "http://www.simantics.org/DistrictNetwork-1.0/VertexMappingParameterType";
159     }
160     
161     public static Resource getResourceOrNull(ReadGraph graph, String uri) {
162         try {
163             return graph.getResource(uri);
164         } catch(DatabaseException e) {
165             System.err.println(e.getMessage());
166             return null;
167         }
168     }
169     
170     public DistrictNetworkResource(ReadGraph graph) {
171         ActionContext = getResourceOrNull(graph, URIs.ActionContext);
172         ActionContext_newDiagramContribution = getResourceOrNull(graph, URIs.ActionContext_newDiagramContribution);
173         Actions = getResourceOrNull(graph, URIs.Actions);
174         Actions_NewDNDiagram = getResourceOrNull(graph, URIs.Actions_NewDNDiagram);
175         AddLayerToDNDiagramTemplate = getResourceOrNull(graph, URIs.AddLayerToDNDiagramTemplate);
176         Bidirectional = getResourceOrNull(graph, URIs.Bidirectional);
177         Bidirectional_Inverse = getResourceOrNull(graph, URIs.Bidirectional_Inverse);
178         BrowseContext = getResourceOrNull(graph, URIs.BrowseContext);
179         Composite = getResourceOrNull(graph, URIs.Composite);
180         Connection = getResourceOrNull(graph, URIs.Connection);
181         Diagram = getResourceOrNull(graph, URIs.Diagram);
182         EPSG_4326 = getResourceOrNull(graph, URIs.EPSG_4326);
183         Edge = getResourceOrNull(graph, URIs.Edge);
184         EdgeDefaultMapping = getResourceOrNull(graph, URIs.EdgeDefaultMapping);
185         EdgeDefaultMapping_Inverse = getResourceOrNull(graph, URIs.EdgeDefaultMapping_Inverse);
186         EdgeMappingParameterType = getResourceOrNull(graph, URIs.EdgeMappingParameterType);
187         Edge_HasDiameter = getResourceOrNull(graph, URIs.Edge_HasDiameter);
188         Edge_HasDiameter_Inverse = getResourceOrNull(graph, URIs.Edge_HasDiameter_Inverse);
189         Functions = getResourceOrNull(graph, URIs.Functions);
190         Functions_compositeInstantiator = getResourceOrNull(graph, URIs.Functions_compositeInstantiator);
191         Functions_convertToValue = getResourceOrNull(graph, URIs.Functions_convertToValue);
192         Functions_defaultEdgeMappingModifier = getResourceOrNull(graph, URIs.Functions_defaultEdgeMappingModifier);
193         Functions_defaultVertexMappingModifier = getResourceOrNull(graph, URIs.Functions_defaultVertexMappingModifier);
194         Functions_enumerationValues = getResourceOrNull(graph, URIs.Functions_enumerationValues);
195         Functions_mappingModifier = getResourceOrNull(graph, URIs.Functions_mappingModifier);
196         HasEndVertex = getResourceOrNull(graph, URIs.HasEndVertex);
197         HasEndVertex_Inverse = getResourceOrNull(graph, URIs.HasEndVertex_Inverse);
198         HasInLayerTag = getResourceOrNull(graph, URIs.HasInLayerTag);
199         HasInLayerTag_Inverse = getResourceOrNull(graph, URIs.HasInLayerTag_Inverse);
200         HasMapping = getResourceOrNull(graph, URIs.HasMapping);
201         HasMapping_Inverse = getResourceOrNull(graph, URIs.HasMapping_Inverse);
202         HasSRID = getResourceOrNull(graph, URIs.HasSRID);
203         HasSRID_Inverse = getResourceOrNull(graph, URIs.HasSRID_Inverse);
204         HasSRTEXT = getResourceOrNull(graph, URIs.HasSRTEXT);
205         HasSRTEXT_Inverse = getResourceOrNull(graph, URIs.HasSRTEXT_Inverse);
206         HasSpatialRefSystem = getResourceOrNull(graph, URIs.HasSpatialRefSystem);
207         HasSpatialRefSystem_Inverse = getResourceOrNull(graph, URIs.HasSpatialRefSystem_Inverse);
208         HasStartVertex = getResourceOrNull(graph, URIs.HasStartVertex);
209         HasStartVertex_Inverse = getResourceOrNull(graph, URIs.HasStartVertex_Inverse);
210         Images = getResourceOrNull(graph, URIs.Images);
211         Images_ConfigurationFolder = getResourceOrNull(graph, URIs.Images_ConfigurationFolder);
212         InLayer = getResourceOrNull(graph, URIs.InLayer);
213         Layer = getResourceOrNull(graph, URIs.Layer);
214         Mapping = getResourceOrNull(graph, URIs.Mapping);
215         MappingParameterType = getResourceOrNull(graph, URIs.MappingParameterType);
216         Mapping_Base = getResourceOrNull(graph, URIs.Mapping_Base);
217         Mapping_ComponentType = getResourceOrNull(graph, URIs.Mapping_ComponentType);
218         Mapping_ComponentType_Inverse = getResourceOrNull(graph, URIs.Mapping_ComponentType_Inverse);
219         Mapping_Dummy = getResourceOrNull(graph, URIs.Mapping_Dummy);
220         Mapping_EdgeMapping = getResourceOrNull(graph, URIs.Mapping_EdgeMapping);
221         Mapping_EdgeMapping_Bidirectional = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_Bidirectional);
222         Mapping_EdgeMapping_Bidirectional_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_Bidirectional_Inverse);
223         Mapping_EdgeMapping_DiameterAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_DiameterAttribute);
224         Mapping_EdgeMapping_DiameterAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_DiameterAttribute_Inverse);
225         Mapping_EdgeMapping_LengthAttribute = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_LengthAttribute);
226         Mapping_EdgeMapping_LengthAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_EdgeMapping_LengthAttribute_Inverse);
227         Mapping_InputTerminal = getResourceOrNull(graph, URIs.Mapping_InputTerminal);
228         Mapping_InputTerminal_Inverse = getResourceOrNull(graph, URIs.Mapping_InputTerminal_Inverse);
229         Mapping_OutputTerminal = getResourceOrNull(graph, URIs.Mapping_OutputTerminal);
230         Mapping_OutputTerminal_Inverse = getResourceOrNull(graph, URIs.Mapping_OutputTerminal_Inverse);
231         Mapping_Terminal = getResourceOrNull(graph, URIs.Mapping_Terminal);
232         Mapping_TerminalPair = getResourceOrNull(graph, URIs.Mapping_TerminalPair);
233         Mapping_Terminals = getResourceOrNull(graph, URIs.Mapping_Terminals);
234         Mapping_Terminals_Inverse = getResourceOrNull(graph, URIs.Mapping_Terminals_Inverse);
235         Mapping_VertexMapping = getResourceOrNull(graph, URIs.Mapping_VertexMapping);
236         Mapping_VertexMapping_ElevationAttribute = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ElevationAttribute);
237         Mapping_VertexMapping_ElevationAttribute_Inverse = getResourceOrNull(graph, URIs.Mapping_VertexMapping_ElevationAttribute_Inverse);
238         SpatialRefSystem = getResourceOrNull(graph, URIs.SpatialRefSystem);
239         Vertex = getResourceOrNull(graph, URIs.Vertex);
240         VertexDefaultMapping = getResourceOrNull(graph, URIs.VertexDefaultMapping);
241         VertexDefaultMapping_Inverse = getResourceOrNull(graph, URIs.VertexDefaultMapping_Inverse);
242         VertexMappingParameterType = getResourceOrNull(graph, URIs.VertexMappingParameterType);
243     }
244     
245     public static DistrictNetworkResource getInstance(ReadGraph graph) {
246         Session session = graph.getSession();
247         DistrictNetworkResource ret = session.peekService(DistrictNetworkResource.class);
248         if(ret == null) {
249             QueryControl qc = graph.getService(QueryControl.class);
250             ret = new DistrictNetworkResource(qc.getIndependentGraph(graph));
251             session.registerService(DistrictNetworkResource.class, ret);
252         }
253         return ret;
254     }
255     
256     public static DistrictNetworkResource getInstance(RequestProcessor session) throws DatabaseException {
257         DistrictNetworkResource ret = session.peekService(DistrictNetworkResource.class);
258         if(ret == null) {
259             ret = session.syncRequest(new Read<DistrictNetworkResource>() {
260                 public DistrictNetworkResource perform(ReadGraph graph) throws DatabaseException {
261                     QueryControl qc = graph.getService(QueryControl.class);
262                     return new DistrictNetworkResource(qc.getIndependentGraph(graph));
263                 }
264             });
265             session.registerService(DistrictNetworkResource.class, ret);
266         }
267         return ret;
268     }
269     
270 }
271