]> gerrit.simantics Code Review - simantics/platform.git/blob
347a20fb05ce4e3d9fcb2aff7ff73b14e79fb702
[simantics/platform.git] /
1 package org.simantics.document.linking.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 DocumentLink {
12     
13     public final Resource EvaluatorTree;
14     public final Resource EvaluatorTree_AligmentHint;
15     public final Resource EvaluatorTree_And;
16     public final Resource EvaluatorTree_Constant;
17     public final Resource EvaluatorTree_Date;
18     public final Resource EvaluatorTree_HasValue;
19     public final Resource EvaluatorTree_HasValue_Inverse;
20     public final Resource EvaluatorTree_If;
21     public final Resource EvaluatorTree_Lines;
22     public final Resource EvaluatorTree_Node;
23     public final Resource EvaluatorTree_Or;
24     public final Resource EvaluatorTree_Path;
25     public final Resource EvaluatorTree_Root;
26     public final Resource EvaluatorTree_Template;
27     public final Resource EvaluatorTree_TextSizeHint;
28     public final Resource EvaluatorTree_Variable;
29     public final Resource FunctionalSource;
30     public final Resource InstanceSource;
31     public final Resource ModelViewpointActionContext;
32     public final Resource ModelViewpointBrowseContext;
33     public final Resource ModelViewpointBrowseContext2;
34     public final Resource ModelViewpointBrowseContext2_ChildRule;
35     public final Resource ModelViewpointBrowseContext_ChildRule;
36     public final Resource ReportTemplate;
37     public final Resource SearchContribution;
38     public final Resource SearchFunction;
39     public final Resource Source;
40     public final Resource SourceObjectViewpointActionContext;
41     public final Resource SourceObjectViewpointActionContext_Category;
42     public final Resource SourceObjectViewpointBrowseContext;
43     public final Resource SourceObjectViewpointBrowseContext_ChildRule;
44     public final Resource SourcePropertyViewpointActionContext;
45     public final Resource SourcePropertyViewpointActionContext_Category;
46     public final Resource SourcePropertyViewpointActionContext_FixAll;
47     public final Resource SourcePropertyViewpointActionContext_FixAllReferences;
48     public final Resource SourcePropertyViewpointActionContext_Open;
49     public final Resource SourcePropertyViewpointActionContext_OpenWith;
50     public final Resource SourcePropertyViewpointActionContext_Remove;
51     public final Resource SourcePropertyViewpointActionContext_RemoveSource;
52     public final Resource SourcePropertyViewpointActionContext_Replace;
53     public final Resource SourcePropertyViewpointActionContext_ReplaceWithLatest;
54     public final Resource SourcePropertyViewpointActionContext_ShowDocument;
55     public final Resource SourcePropertyViewpointActionContext_ShowDocumentExternal;
56     public final Resource SourcePropertyViewpointActionContext_SourceObjectDropAction;
57     public final Resource SourcePropertyViewpointActionContext_SourceReferenceOldTest;
58     public final Resource SourcePropertyViewpointActionContext_VariableInstanceTest;
59     public final Resource SourcePropertyViewpointBrowseContext;
60     public final Resource SourcePropertyViewpointBrowseContext_ChildRule;
61     public final Resource SourcePropertyViewpointBrowseContext_Variable;
62     public final Resource SourcePropertyViewpointBrowseContext_VariableImageDecorationRule;
63     public final Resource SourcePropertyViewpointBrowseContext_VariableImageRule;
64     public final Resource SourcePropertyViewpointBrowseContext_VariableLabelRule;
65     public final Resource SourcePropertyViewpointBrowseContext_VariableModifierRule;
66     public final Resource consernsRelation;
67     public final Resource hasFunctionalSource;
68     public final Resource hasFunctionalSource_Inverse;
69     public final Resource hasInstanceSource;
70     public final Resource hasInstanceSource_Inverse;
71     public final Resource hasSource;
72     public final Resource hasSourceComment;
73     public final Resource hasSourceComment_Inverse;
74     public final Resource hasSourceReference;
75     public final Resource hasSourceReferenceURI;
76     public final Resource hasSourceReferenceURI_Inverse;
77     public final Resource hasSource_Inverse;
78         
79     public static class URIs {
80         public static final String EvaluatorTree = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree";
81         public static final String EvaluatorTree_AligmentHint = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/AligmentHint";
82         public static final String EvaluatorTree_And = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/And";
83         public static final String EvaluatorTree_Constant = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/Constant";
84         public static final String EvaluatorTree_Date = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/Date";
85         public static final String EvaluatorTree_HasValue = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/HasValue";
86         public static final String EvaluatorTree_HasValue_Inverse = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/HasValue/Inverse";
87         public static final String EvaluatorTree_If = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/If";
88         public static final String EvaluatorTree_Lines = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/Lines";
89         public static final String EvaluatorTree_Node = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/Node";
90         public static final String EvaluatorTree_Or = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/Or";
91         public static final String EvaluatorTree_Path = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/Path";
92         public static final String EvaluatorTree_Root = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/Root";
93         public static final String EvaluatorTree_Template = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/Template";
94         public static final String EvaluatorTree_TextSizeHint = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/TextSizeHint";
95         public static final String EvaluatorTree_Variable = "http://www.simantics.org/DocumentLink-1.0/EvaluatorTree/Variable";
96         public static final String FunctionalSource = "http://www.simantics.org/DocumentLink-1.0/FunctionalSource";
97         public static final String InstanceSource = "http://www.simantics.org/DocumentLink-1.0/InstanceSource";
98         public static final String ModelViewpointActionContext = "http://www.simantics.org/DocumentLink-1.0/ModelViewpointActionContext";
99         public static final String ModelViewpointBrowseContext = "http://www.simantics.org/DocumentLink-1.0/ModelViewpointBrowseContext";
100         public static final String ModelViewpointBrowseContext2 = "http://www.simantics.org/DocumentLink-1.0/ModelViewpointBrowseContext2";
101         public static final String ModelViewpointBrowseContext2_ChildRule = "http://www.simantics.org/DocumentLink-1.0/ModelViewpointBrowseContext2/ChildRule";
102         public static final String ModelViewpointBrowseContext_ChildRule = "http://www.simantics.org/DocumentLink-1.0/ModelViewpointBrowseContext/ChildRule";
103         public static final String ReportTemplate = "http://www.simantics.org/DocumentLink-1.0/ReportTemplate";
104         public static final String SearchContribution = "http://www.simantics.org/DocumentLink-1.0/SearchContribution";
105         public static final String SearchFunction = "http://www.simantics.org/DocumentLink-1.0/SearchFunction";
106         public static final String Source = "http://www.simantics.org/DocumentLink-1.0/Source";
107         public static final String SourceObjectViewpointActionContext = "http://www.simantics.org/DocumentLink-1.0/SourceObjectViewpointActionContext";
108         public static final String SourceObjectViewpointActionContext_Category = "http://www.simantics.org/DocumentLink-1.0/SourceObjectViewpointActionContext/Category";
109         public static final String SourceObjectViewpointBrowseContext = "http://www.simantics.org/DocumentLink-1.0/SourceObjectViewpointBrowseContext";
110         public static final String SourceObjectViewpointBrowseContext_ChildRule = "http://www.simantics.org/DocumentLink-1.0/SourceObjectViewpointBrowseContext/ChildRule";
111         public static final String SourcePropertyViewpointActionContext = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext";
112         public static final String SourcePropertyViewpointActionContext_Category = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/Category";
113         public static final String SourcePropertyViewpointActionContext_FixAll = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/FixAll";
114         public static final String SourcePropertyViewpointActionContext_FixAllReferences = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/FixAllReferences";
115         public static final String SourcePropertyViewpointActionContext_Open = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/Open";
116         public static final String SourcePropertyViewpointActionContext_OpenWith = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/OpenWith";
117         public static final String SourcePropertyViewpointActionContext_Remove = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/Remove";
118         public static final String SourcePropertyViewpointActionContext_RemoveSource = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/RemoveSource";
119         public static final String SourcePropertyViewpointActionContext_Replace = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/Replace";
120         public static final String SourcePropertyViewpointActionContext_ReplaceWithLatest = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/ReplaceWithLatest";
121         public static final String SourcePropertyViewpointActionContext_ShowDocument = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/ShowDocument";
122         public static final String SourcePropertyViewpointActionContext_ShowDocumentExternal = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/ShowDocumentExternal";
123         public static final String SourcePropertyViewpointActionContext_SourceObjectDropAction = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/SourceObjectDropAction";
124         public static final String SourcePropertyViewpointActionContext_SourceReferenceOldTest = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/SourceReferenceOldTest";
125         public static final String SourcePropertyViewpointActionContext_VariableInstanceTest = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointActionContext/VariableInstanceTest";
126         public static final String SourcePropertyViewpointBrowseContext = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointBrowseContext";
127         public static final String SourcePropertyViewpointBrowseContext_ChildRule = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointBrowseContext/ChildRule";
128         public static final String SourcePropertyViewpointBrowseContext_Variable = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointBrowseContext/Variable";
129         public static final String SourcePropertyViewpointBrowseContext_VariableImageDecorationRule = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointBrowseContext/VariableImageDecorationRule";
130         public static final String SourcePropertyViewpointBrowseContext_VariableImageRule = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointBrowseContext/VariableImageRule";
131         public static final String SourcePropertyViewpointBrowseContext_VariableLabelRule = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointBrowseContext/VariableLabelRule";
132         public static final String SourcePropertyViewpointBrowseContext_VariableModifierRule = "http://www.simantics.org/DocumentLink-1.0/SourcePropertyViewpointBrowseContext/VariableModifierRule";
133         public static final String consernsRelation = "http://www.simantics.org/DocumentLink-1.0/consernsRelation";
134         public static final String hasFunctionalSource = "http://www.simantics.org/DocumentLink-1.0/hasFunctionalSource";
135         public static final String hasFunctionalSource_Inverse = "http://www.simantics.org/DocumentLink-1.0/hasFunctionalSource/Inverse";
136         public static final String hasInstanceSource = "http://www.simantics.org/DocumentLink-1.0/hasInstanceSource";
137         public static final String hasInstanceSource_Inverse = "http://www.simantics.org/DocumentLink-1.0/hasInstanceSource/Inverse";
138         public static final String hasSource = "http://www.simantics.org/DocumentLink-1.0/hasSource";
139         public static final String hasSourceComment = "http://www.simantics.org/DocumentLink-1.0/hasSourceComment";
140         public static final String hasSourceComment_Inverse = "http://www.simantics.org/DocumentLink-1.0/hasSourceComment/Inverse";
141         public static final String hasSourceReference = "http://www.simantics.org/DocumentLink-1.0/hasSourceReference";
142         public static final String hasSourceReferenceURI = "http://www.simantics.org/DocumentLink-1.0/hasSourceReferenceURI";
143         public static final String hasSourceReferenceURI_Inverse = "http://www.simantics.org/DocumentLink-1.0/hasSourceReferenceURI/Inverse";
144         public static final String hasSource_Inverse = "http://www.simantics.org/DocumentLink-1.0/hasSource/Inverse";
145     }
146     
147     public static Resource getResourceOrNull(ReadGraph graph, String uri) {
148         try {
149             return graph.getResource(uri);
150         } catch(DatabaseException e) {
151             System.err.println(e.getMessage());
152             return null;
153         }
154     }
155     
156     public DocumentLink(ReadGraph graph) {
157         EvaluatorTree = getResourceOrNull(graph, URIs.EvaluatorTree);
158         EvaluatorTree_AligmentHint = getResourceOrNull(graph, URIs.EvaluatorTree_AligmentHint);
159         EvaluatorTree_And = getResourceOrNull(graph, URIs.EvaluatorTree_And);
160         EvaluatorTree_Constant = getResourceOrNull(graph, URIs.EvaluatorTree_Constant);
161         EvaluatorTree_Date = getResourceOrNull(graph, URIs.EvaluatorTree_Date);
162         EvaluatorTree_HasValue = getResourceOrNull(graph, URIs.EvaluatorTree_HasValue);
163         EvaluatorTree_HasValue_Inverse = getResourceOrNull(graph, URIs.EvaluatorTree_HasValue_Inverse);
164         EvaluatorTree_If = getResourceOrNull(graph, URIs.EvaluatorTree_If);
165         EvaluatorTree_Lines = getResourceOrNull(graph, URIs.EvaluatorTree_Lines);
166         EvaluatorTree_Node = getResourceOrNull(graph, URIs.EvaluatorTree_Node);
167         EvaluatorTree_Or = getResourceOrNull(graph, URIs.EvaluatorTree_Or);
168         EvaluatorTree_Path = getResourceOrNull(graph, URIs.EvaluatorTree_Path);
169         EvaluatorTree_Root = getResourceOrNull(graph, URIs.EvaluatorTree_Root);
170         EvaluatorTree_Template = getResourceOrNull(graph, URIs.EvaluatorTree_Template);
171         EvaluatorTree_TextSizeHint = getResourceOrNull(graph, URIs.EvaluatorTree_TextSizeHint);
172         EvaluatorTree_Variable = getResourceOrNull(graph, URIs.EvaluatorTree_Variable);
173         FunctionalSource = getResourceOrNull(graph, URIs.FunctionalSource);
174         InstanceSource = getResourceOrNull(graph, URIs.InstanceSource);
175         ModelViewpointActionContext = getResourceOrNull(graph, URIs.ModelViewpointActionContext);
176         ModelViewpointBrowseContext = getResourceOrNull(graph, URIs.ModelViewpointBrowseContext);
177         ModelViewpointBrowseContext2 = getResourceOrNull(graph, URIs.ModelViewpointBrowseContext2);
178         ModelViewpointBrowseContext2_ChildRule = getResourceOrNull(graph, URIs.ModelViewpointBrowseContext2_ChildRule);
179         ModelViewpointBrowseContext_ChildRule = getResourceOrNull(graph, URIs.ModelViewpointBrowseContext_ChildRule);
180         ReportTemplate = getResourceOrNull(graph, URIs.ReportTemplate);
181         SearchContribution = getResourceOrNull(graph, URIs.SearchContribution);
182         SearchFunction = getResourceOrNull(graph, URIs.SearchFunction);
183         Source = getResourceOrNull(graph, URIs.Source);
184         SourceObjectViewpointActionContext = getResourceOrNull(graph, URIs.SourceObjectViewpointActionContext);
185         SourceObjectViewpointActionContext_Category = getResourceOrNull(graph, URIs.SourceObjectViewpointActionContext_Category);
186         SourceObjectViewpointBrowseContext = getResourceOrNull(graph, URIs.SourceObjectViewpointBrowseContext);
187         SourceObjectViewpointBrowseContext_ChildRule = getResourceOrNull(graph, URIs.SourceObjectViewpointBrowseContext_ChildRule);
188         SourcePropertyViewpointActionContext = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext);
189         SourcePropertyViewpointActionContext_Category = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_Category);
190         SourcePropertyViewpointActionContext_FixAll = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_FixAll);
191         SourcePropertyViewpointActionContext_FixAllReferences = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_FixAllReferences);
192         SourcePropertyViewpointActionContext_Open = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_Open);
193         SourcePropertyViewpointActionContext_OpenWith = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_OpenWith);
194         SourcePropertyViewpointActionContext_Remove = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_Remove);
195         SourcePropertyViewpointActionContext_RemoveSource = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_RemoveSource);
196         SourcePropertyViewpointActionContext_Replace = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_Replace);
197         SourcePropertyViewpointActionContext_ReplaceWithLatest = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_ReplaceWithLatest);
198         SourcePropertyViewpointActionContext_ShowDocument = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_ShowDocument);
199         SourcePropertyViewpointActionContext_ShowDocumentExternal = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_ShowDocumentExternal);
200         SourcePropertyViewpointActionContext_SourceObjectDropAction = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_SourceObjectDropAction);
201         SourcePropertyViewpointActionContext_SourceReferenceOldTest = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_SourceReferenceOldTest);
202         SourcePropertyViewpointActionContext_VariableInstanceTest = getResourceOrNull(graph, URIs.SourcePropertyViewpointActionContext_VariableInstanceTest);
203         SourcePropertyViewpointBrowseContext = getResourceOrNull(graph, URIs.SourcePropertyViewpointBrowseContext);
204         SourcePropertyViewpointBrowseContext_ChildRule = getResourceOrNull(graph, URIs.SourcePropertyViewpointBrowseContext_ChildRule);
205         SourcePropertyViewpointBrowseContext_Variable = getResourceOrNull(graph, URIs.SourcePropertyViewpointBrowseContext_Variable);
206         SourcePropertyViewpointBrowseContext_VariableImageDecorationRule = getResourceOrNull(graph, URIs.SourcePropertyViewpointBrowseContext_VariableImageDecorationRule);
207         SourcePropertyViewpointBrowseContext_VariableImageRule = getResourceOrNull(graph, URIs.SourcePropertyViewpointBrowseContext_VariableImageRule);
208         SourcePropertyViewpointBrowseContext_VariableLabelRule = getResourceOrNull(graph, URIs.SourcePropertyViewpointBrowseContext_VariableLabelRule);
209         SourcePropertyViewpointBrowseContext_VariableModifierRule = getResourceOrNull(graph, URIs.SourcePropertyViewpointBrowseContext_VariableModifierRule);
210         consernsRelation = getResourceOrNull(graph, URIs.consernsRelation);
211         hasFunctionalSource = getResourceOrNull(graph, URIs.hasFunctionalSource);
212         hasFunctionalSource_Inverse = getResourceOrNull(graph, URIs.hasFunctionalSource_Inverse);
213         hasInstanceSource = getResourceOrNull(graph, URIs.hasInstanceSource);
214         hasInstanceSource_Inverse = getResourceOrNull(graph, URIs.hasInstanceSource_Inverse);
215         hasSource = getResourceOrNull(graph, URIs.hasSource);
216         hasSourceComment = getResourceOrNull(graph, URIs.hasSourceComment);
217         hasSourceComment_Inverse = getResourceOrNull(graph, URIs.hasSourceComment_Inverse);
218         hasSourceReference = getResourceOrNull(graph, URIs.hasSourceReference);
219         hasSourceReferenceURI = getResourceOrNull(graph, URIs.hasSourceReferenceURI);
220         hasSourceReferenceURI_Inverse = getResourceOrNull(graph, URIs.hasSourceReferenceURI_Inverse);
221         hasSource_Inverse = getResourceOrNull(graph, URIs.hasSource_Inverse);
222     }
223     
224     public static DocumentLink getInstance(ReadGraph graph) {
225         Session session = graph.getSession();
226         DocumentLink ret = session.peekService(DocumentLink.class);
227         if(ret == null) {
228             QueryControl qc = graph.getService(QueryControl.class);
229             ret = new DocumentLink(qc.getIndependentGraph(graph));
230             session.registerService(DocumentLink.class, ret);
231         }
232         return ret;
233     }
234     
235     public static DocumentLink getInstance(RequestProcessor session) throws DatabaseException {
236         DocumentLink ret = session.peekService(DocumentLink.class);
237         if(ret == null) {
238             ret = session.syncRequest(new Read<DocumentLink>() {
239                 public DocumentLink perform(ReadGraph graph) throws DatabaseException {
240                     QueryControl qc = graph.getService(QueryControl.class);
241                     return new DocumentLink(qc.getIndependentGraph(graph));
242                 }
243             });
244             session.registerService(DocumentLink.class, ret);
245         }
246         return ret;
247     }
248     
249 }
250