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