]> gerrit.simantics Code Review - simantics/platform.git/blob
f2fb52856b28a103ac50ea953e6ab3ed57560135
[simantics/platform.git] /
1 package org.simantics.annotation.ontology;\r
2 \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
10 \r
11 public class AnnotationResource {\r
12     \r
13     public final Resource Actions;\r
14     public final Resource Actions_AnnotationDropAction;\r
15     public final Resource Actions_NewAnnotation;\r
16     public final Resource Actions_NewAnnotationInstance;\r
17     public final Resource Actions_NewAnnotationType;\r
18     public final Resource Actions_NoActionCategory;\r
19     public final Resource Annotation;\r
20     public final Resource AnnotationAC;\r
21     public final Resource AnnotationBC;\r
22     public final Resource AnnotationBC_AnnotationTypeLabelRule;\r
23     public final Resource AnnotationBC_AnnotationTypeModifierRule;\r
24     public final Resource AnnotationType;\r
25     @Deprecated public final Resource AnnotationTypeLibrary;\r
26     @Deprecated public final Resource AnnotationTypeLibraryUI;\r
27     @Deprecated public final Resource AnnotationTypeUI;\r
28     @Deprecated public final Resource AnnotationUI;\r
29     public final Resource Annotation_HasEntry;\r
30     public final Resource Annotation_HasEntry_Inverse;\r
31     @Deprecated public final Resource BrowseNode;\r
32     public final Resource DefaultAnnotationSource;\r
33     public final Resource Functions;\r
34     public final Resource Functions_availableAnnotations;\r
35     public final Resource Functions_availableSources;\r
36     public final Resource Functions_descriptionText;\r
37     public final Resource Functions_domainChildren;\r
38     public final Resource Functions_explorerInput;\r
39     public final Resource Functions_explorerInput2;\r
40     public final Resource Functions_newAnnotationModifier;\r
41     public final Resource Functions_removeAnnotationModifier;\r
42     public final Resource Functions_saveAnnotationModifier;\r
43     public final Resource Functions_selectedAnnotation;\r
44     public final Resource Functions_selectedAnnotationModifier;\r
45     public final Resource Functions_selectedSource;\r
46     public final Resource Functions_selectedSourceModifier;\r
47     public final Resource HasAnnotationPropertySubrelation;\r
48     @Deprecated public final Resource HasAnnotationTypeRoot;\r
49     public final Resource HasAnnotationTypeRoot_Inverse;\r
50     public final Resource HasAnnotationTypeSupertype;\r
51     public final Resource HasDefaultAnnotationName;\r
52     public final Resource HasDefaultAnnotationType;\r
53     public final Resource Images;\r
54     public final Resource Images_Annotation;\r
55     public final Resource Images_AnnotationType;\r
56     public final Resource Images_General;\r
57     public final Resource SelectionTab;\r
58     public final Resource SelectionTab2;\r
59     public final Resource SelectionTab2_Properties;\r
60     public final Resource SelectionTabContribution;\r
61     public final Resource SelectionTabContribution2;\r
62     public final Resource SelectionTab_Add;\r
63     public final Resource SelectionTab_BC;\r
64     public final Resource SelectionTab_Combo1;\r
65     public final Resource SelectionTab_Combo2;\r
66     public final Resource SelectionTab_Description;\r
67     public final Resource SelectionTab_Properties;\r
68     public final Resource SelectionTab_Remove;\r
69     public final Resource SelectionTab_Save;\r
70         \r
71     public static class URIs {\r
72         public static final String Actions = "http://www.simantics.org/Annotation-1.0/Actions";\r
73         public static final String Actions_AnnotationDropAction = "http://www.simantics.org/Annotation-1.0/Actions/AnnotationDropAction";\r
74         public static final String Actions_NewAnnotation = "http://www.simantics.org/Annotation-1.0/Actions/NewAnnotation";\r
75         public static final String Actions_NewAnnotationInstance = "http://www.simantics.org/Annotation-1.0/Actions/NewAnnotationInstance";\r
76         public static final String Actions_NewAnnotationType = "http://www.simantics.org/Annotation-1.0/Actions/NewAnnotationType";\r
77         public static final String Actions_NoActionCategory = "http://www.simantics.org/Annotation-1.0/Actions/NoActionCategory";\r
78         public static final String Annotation = "http://www.simantics.org/Annotation-1.0/Annotation";\r
79         public static final String AnnotationAC = "http://www.simantics.org/Annotation-1.0/AnnotationAC";\r
80         public static final String AnnotationBC = "http://www.simantics.org/Annotation-1.0/AnnotationBC";\r
81         public static final String AnnotationBC_AnnotationTypeLabelRule = "http://www.simantics.org/Annotation-1.0/AnnotationBC/AnnotationTypeLabelRule";\r
82         public static final String AnnotationBC_AnnotationTypeModifierRule = "http://www.simantics.org/Annotation-1.0/AnnotationBC/AnnotationTypeModifierRule";\r
83         public static final String AnnotationType = "http://www.simantics.org/Annotation-1.0/AnnotationType";\r
84         @Deprecated public static final String AnnotationTypeLibrary = "http://www.simantics.org/Annotation-1.0/AnnotationTypeLibrary";\r
85         @Deprecated public static final String AnnotationTypeLibraryUI = "http://www.simantics.org/Annotation-1.0/AnnotationTypeLibraryUI";\r
86         @Deprecated public static final String AnnotationTypeUI = "http://www.simantics.org/Annotation-1.0/AnnotationTypeUI";\r
87         @Deprecated public static final String AnnotationUI = "http://www.simantics.org/Annotation-1.0/AnnotationUI";\r
88         public static final String Annotation_HasEntry = "http://www.simantics.org/Annotation-1.0/Annotation/HasEntry";\r
89         public static final String Annotation_HasEntry_Inverse = "http://www.simantics.org/Annotation-1.0/Annotation/HasEntry/Inverse";\r
90         @Deprecated public static final String BrowseNode = "http://www.simantics.org/Annotation-1.0/BrowseNode";\r
91         public static final String DefaultAnnotationSource = "http://www.simantics.org/Annotation-1.0/DefaultAnnotationSource";\r
92         public static final String Functions = "http://www.simantics.org/Annotation-1.0/Functions";\r
93         public static final String Functions_availableAnnotations = "http://www.simantics.org/Annotation-1.0/Functions/availableAnnotations";\r
94         public static final String Functions_availableSources = "http://www.simantics.org/Annotation-1.0/Functions/availableSources";\r
95         public static final String Functions_descriptionText = "http://www.simantics.org/Annotation-1.0/Functions/descriptionText";\r
96         public static final String Functions_domainChildren = "http://www.simantics.org/Annotation-1.0/Functions/domainChildren";\r
97         public static final String Functions_explorerInput = "http://www.simantics.org/Annotation-1.0/Functions/explorerInput";\r
98         public static final String Functions_explorerInput2 = "http://www.simantics.org/Annotation-1.0/Functions/explorerInput2";\r
99         public static final String Functions_newAnnotationModifier = "http://www.simantics.org/Annotation-1.0/Functions/newAnnotationModifier";\r
100         public static final String Functions_removeAnnotationModifier = "http://www.simantics.org/Annotation-1.0/Functions/removeAnnotationModifier";\r
101         public static final String Functions_saveAnnotationModifier = "http://www.simantics.org/Annotation-1.0/Functions/saveAnnotationModifier";\r
102         public static final String Functions_selectedAnnotation = "http://www.simantics.org/Annotation-1.0/Functions/selectedAnnotation";\r
103         public static final String Functions_selectedAnnotationModifier = "http://www.simantics.org/Annotation-1.0/Functions/selectedAnnotationModifier";\r
104         public static final String Functions_selectedSource = "http://www.simantics.org/Annotation-1.0/Functions/selectedSource";\r
105         public static final String Functions_selectedSourceModifier = "http://www.simantics.org/Annotation-1.0/Functions/selectedSourceModifier";\r
106         public static final String HasAnnotationPropertySubrelation = "http://www.simantics.org/Annotation-1.0/HasAnnotationPropertySubrelation";\r
107         @Deprecated public static final String HasAnnotationTypeRoot = "http://www.simantics.org/Annotation-1.0/HasAnnotationTypeRoot";\r
108         public static final String HasAnnotationTypeRoot_Inverse = "http://www.simantics.org/Annotation-1.0/HasAnnotationTypeRoot/Inverse";\r
109         public static final String HasAnnotationTypeSupertype = "http://www.simantics.org/Annotation-1.0/HasAnnotationTypeSupertype";\r
110         public static final String HasDefaultAnnotationName = "http://www.simantics.org/Annotation-1.0/HasDefaultAnnotationName";\r
111         public static final String HasDefaultAnnotationType = "http://www.simantics.org/Annotation-1.0/HasDefaultAnnotationType";\r
112         public static final String Images = "http://www.simantics.org/Annotation-1.0/Images";\r
113         public static final String Images_Annotation = "http://www.simantics.org/Annotation-1.0/Images/Annotation";\r
114         public static final String Images_AnnotationType = "http://www.simantics.org/Annotation-1.0/Images/AnnotationType";\r
115         public static final String Images_General = "http://www.simantics.org/Annotation-1.0/Images/General";\r
116         public static final String SelectionTab = "http://www.simantics.org/Annotation-1.0/SelectionTab";\r
117         public static final String SelectionTab2 = "http://www.simantics.org/Annotation-1.0/SelectionTab2";\r
118         public static final String SelectionTab2_Properties = "http://www.simantics.org/Annotation-1.0/SelectionTab2/Properties";\r
119         public static final String SelectionTabContribution = "http://www.simantics.org/Annotation-1.0/SelectionTabContribution";\r
120         public static final String SelectionTabContribution2 = "http://www.simantics.org/Annotation-1.0/SelectionTabContribution2";\r
121         public static final String SelectionTab_Add = "http://www.simantics.org/Annotation-1.0/SelectionTab/Add";\r
122         public static final String SelectionTab_BC = "http://www.simantics.org/Annotation-1.0/SelectionTab/BC";\r
123         public static final String SelectionTab_Combo1 = "http://www.simantics.org/Annotation-1.0/SelectionTab/Combo1";\r
124         public static final String SelectionTab_Combo2 = "http://www.simantics.org/Annotation-1.0/SelectionTab/Combo2";\r
125         public static final String SelectionTab_Description = "http://www.simantics.org/Annotation-1.0/SelectionTab/Description";\r
126         public static final String SelectionTab_Properties = "http://www.simantics.org/Annotation-1.0/SelectionTab/Properties";\r
127         public static final String SelectionTab_Remove = "http://www.simantics.org/Annotation-1.0/SelectionTab/Remove";\r
128         public static final String SelectionTab_Save = "http://www.simantics.org/Annotation-1.0/SelectionTab/Save";\r
129     }\r
130     \r
131     public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
132         try {\r
133             return graph.getResource(uri);\r
134         } catch(DatabaseException e) {\r
135             System.err.println(e.getMessage());\r
136             return null;\r
137         }\r
138     }\r
139     \r
140     public AnnotationResource(ReadGraph graph) {\r
141         Actions = getResourceOrNull(graph, URIs.Actions);\r
142         Actions_AnnotationDropAction = getResourceOrNull(graph, URIs.Actions_AnnotationDropAction);\r
143         Actions_NewAnnotation = getResourceOrNull(graph, URIs.Actions_NewAnnotation);\r
144         Actions_NewAnnotationInstance = getResourceOrNull(graph, URIs.Actions_NewAnnotationInstance);\r
145         Actions_NewAnnotationType = getResourceOrNull(graph, URIs.Actions_NewAnnotationType);\r
146         Actions_NoActionCategory = getResourceOrNull(graph, URIs.Actions_NoActionCategory);\r
147         Annotation = getResourceOrNull(graph, URIs.Annotation);\r
148         AnnotationAC = getResourceOrNull(graph, URIs.AnnotationAC);\r
149         AnnotationBC = getResourceOrNull(graph, URIs.AnnotationBC);\r
150         AnnotationBC_AnnotationTypeLabelRule = getResourceOrNull(graph, URIs.AnnotationBC_AnnotationTypeLabelRule);\r
151         AnnotationBC_AnnotationTypeModifierRule = getResourceOrNull(graph, URIs.AnnotationBC_AnnotationTypeModifierRule);\r
152         AnnotationType = getResourceOrNull(graph, URIs.AnnotationType);\r
153         AnnotationTypeLibrary = getResourceOrNull(graph, URIs.AnnotationTypeLibrary);\r
154         AnnotationTypeLibraryUI = getResourceOrNull(graph, URIs.AnnotationTypeLibraryUI);\r
155         AnnotationTypeUI = getResourceOrNull(graph, URIs.AnnotationTypeUI);\r
156         AnnotationUI = getResourceOrNull(graph, URIs.AnnotationUI);\r
157         Annotation_HasEntry = getResourceOrNull(graph, URIs.Annotation_HasEntry);\r
158         Annotation_HasEntry_Inverse = getResourceOrNull(graph, URIs.Annotation_HasEntry_Inverse);\r
159         BrowseNode = getResourceOrNull(graph, URIs.BrowseNode);\r
160         DefaultAnnotationSource = getResourceOrNull(graph, URIs.DefaultAnnotationSource);\r
161         Functions = getResourceOrNull(graph, URIs.Functions);\r
162         Functions_availableAnnotations = getResourceOrNull(graph, URIs.Functions_availableAnnotations);\r
163         Functions_availableSources = getResourceOrNull(graph, URIs.Functions_availableSources);\r
164         Functions_descriptionText = getResourceOrNull(graph, URIs.Functions_descriptionText);\r
165         Functions_domainChildren = getResourceOrNull(graph, URIs.Functions_domainChildren);\r
166         Functions_explorerInput = getResourceOrNull(graph, URIs.Functions_explorerInput);\r
167         Functions_explorerInput2 = getResourceOrNull(graph, URIs.Functions_explorerInput2);\r
168         Functions_newAnnotationModifier = getResourceOrNull(graph, URIs.Functions_newAnnotationModifier);\r
169         Functions_removeAnnotationModifier = getResourceOrNull(graph, URIs.Functions_removeAnnotationModifier);\r
170         Functions_saveAnnotationModifier = getResourceOrNull(graph, URIs.Functions_saveAnnotationModifier);\r
171         Functions_selectedAnnotation = getResourceOrNull(graph, URIs.Functions_selectedAnnotation);\r
172         Functions_selectedAnnotationModifier = getResourceOrNull(graph, URIs.Functions_selectedAnnotationModifier);\r
173         Functions_selectedSource = getResourceOrNull(graph, URIs.Functions_selectedSource);\r
174         Functions_selectedSourceModifier = getResourceOrNull(graph, URIs.Functions_selectedSourceModifier);\r
175         HasAnnotationPropertySubrelation = getResourceOrNull(graph, URIs.HasAnnotationPropertySubrelation);\r
176         HasAnnotationTypeRoot = getResourceOrNull(graph, URIs.HasAnnotationTypeRoot);\r
177         HasAnnotationTypeRoot_Inverse = getResourceOrNull(graph, URIs.HasAnnotationTypeRoot_Inverse);\r
178         HasAnnotationTypeSupertype = getResourceOrNull(graph, URIs.HasAnnotationTypeSupertype);\r
179         HasDefaultAnnotationName = getResourceOrNull(graph, URIs.HasDefaultAnnotationName);\r
180         HasDefaultAnnotationType = getResourceOrNull(graph, URIs.HasDefaultAnnotationType);\r
181         Images = getResourceOrNull(graph, URIs.Images);\r
182         Images_Annotation = getResourceOrNull(graph, URIs.Images_Annotation);\r
183         Images_AnnotationType = getResourceOrNull(graph, URIs.Images_AnnotationType);\r
184         Images_General = getResourceOrNull(graph, URIs.Images_General);\r
185         SelectionTab = getResourceOrNull(graph, URIs.SelectionTab);\r
186         SelectionTab2 = getResourceOrNull(graph, URIs.SelectionTab2);\r
187         SelectionTab2_Properties = getResourceOrNull(graph, URIs.SelectionTab2_Properties);\r
188         SelectionTabContribution = getResourceOrNull(graph, URIs.SelectionTabContribution);\r
189         SelectionTabContribution2 = getResourceOrNull(graph, URIs.SelectionTabContribution2);\r
190         SelectionTab_Add = getResourceOrNull(graph, URIs.SelectionTab_Add);\r
191         SelectionTab_BC = getResourceOrNull(graph, URIs.SelectionTab_BC);\r
192         SelectionTab_Combo1 = getResourceOrNull(graph, URIs.SelectionTab_Combo1);\r
193         SelectionTab_Combo2 = getResourceOrNull(graph, URIs.SelectionTab_Combo2);\r
194         SelectionTab_Description = getResourceOrNull(graph, URIs.SelectionTab_Description);\r
195         SelectionTab_Properties = getResourceOrNull(graph, URIs.SelectionTab_Properties);\r
196         SelectionTab_Remove = getResourceOrNull(graph, URIs.SelectionTab_Remove);\r
197         SelectionTab_Save = getResourceOrNull(graph, URIs.SelectionTab_Save);\r
198     }\r
199     \r
200     public static AnnotationResource getInstance(ReadGraph graph) {\r
201         Session session = graph.getSession();\r
202         AnnotationResource ret = session.peekService(AnnotationResource.class);\r
203         if(ret == null) {\r
204             QueryControl qc = graph.getService(QueryControl.class);\r
205             ret = new AnnotationResource(qc.getIndependentGraph(graph));\r
206             session.registerService(AnnotationResource.class, ret);\r
207         }\r
208         return ret;\r
209     }\r
210     \r
211     public static AnnotationResource getInstance(RequestProcessor session) throws DatabaseException {\r
212         AnnotationResource ret = session.peekService(AnnotationResource.class);\r
213         if(ret == null) {\r
214             ret = session.syncRequest(new Read<AnnotationResource>() {\r
215                 public AnnotationResource perform(ReadGraph graph) throws DatabaseException {\r
216                     QueryControl qc = graph.getService(QueryControl.class);\r
217                     return new AnnotationResource(qc.getIndependentGraph(graph));\r
218                 }\r
219             });\r
220             session.registerService(AnnotationResource.class, ret);\r
221         }\r
222         return ret;\r
223     }\r
224     \r
225 }\r
226 \r