1 package org.simantics.xml.sax.ontology;
\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 XMLResource {
\r
13 public final Resource AttributeGroup;
\r
14 public final Resource ComplexType;
\r
15 public final Resource Date;
\r
16 public final Resource DateTime;
\r
17 public final Resource Element;
\r
18 public final Resource ElementList;
\r
19 public final Resource Entity;
\r
20 public final Resource Time;
\r
21 public final Resource externalReferenceOf;
\r
22 public final Resource hasAttribute;
\r
23 public final Resource hasAttribute_Inverse;
\r
24 public final Resource hasComplexType;
\r
25 public final Resource hasComplexType_Inverse;
\r
26 public final Resource hasElement;
\r
27 public final Resource hasElementList;
\r
28 public final Resource hasElementList_Inverse;
\r
29 public final Resource hasElement_Inverse;
\r
30 public final Resource hasExternalReference;
\r
31 public final Resource hasID;
\r
32 public final Resource hasID_Inverse;
\r
33 public final Resource hasOriginalElementList;
\r
34 public final Resource hasOriginalElementList_Inverse;
\r
35 public final Resource hasReference;
\r
37 public static class URIs {
\r
38 public static final String AttributeGroup = "http://www.simantics.org/XML-1.0/AttributeGroup";
\r
39 public static final String ComplexType = "http://www.simantics.org/XML-1.0/ComplexType";
\r
40 public static final String Date = "http://www.simantics.org/XML-1.0/Date";
\r
41 public static final String DateTime = "http://www.simantics.org/XML-1.0/DateTime";
\r
42 public static final String Element = "http://www.simantics.org/XML-1.0/Element";
\r
43 public static final String ElementList = "http://www.simantics.org/XML-1.0/ElementList";
\r
44 public static final String Entity = "http://www.simantics.org/XML-1.0/Entity";
\r
45 public static final String Time = "http://www.simantics.org/XML-1.0/Time";
\r
46 public static final String externalReferenceOf = "http://www.simantics.org/XML-1.0/externalReferenceOf";
\r
47 public static final String hasAttribute = "http://www.simantics.org/XML-1.0/hasAttribute";
\r
48 public static final String hasAttribute_Inverse = "http://www.simantics.org/XML-1.0/hasAttribute/Inverse";
\r
49 public static final String hasComplexType = "http://www.simantics.org/XML-1.0/hasComplexType";
\r
50 public static final String hasComplexType_Inverse = "http://www.simantics.org/XML-1.0/hasComplexType/Inverse";
\r
51 public static final String hasElement = "http://www.simantics.org/XML-1.0/hasElement";
\r
52 public static final String hasElementList = "http://www.simantics.org/XML-1.0/hasElementList";
\r
53 public static final String hasElementList_Inverse = "http://www.simantics.org/XML-1.0/hasElementList/Inverse";
\r
54 public static final String hasElement_Inverse = "http://www.simantics.org/XML-1.0/hasElement/Inverse";
\r
55 public static final String hasExternalReference = "http://www.simantics.org/XML-1.0/hasExternalReference";
\r
56 public static final String hasID = "http://www.simantics.org/XML-1.0/hasID";
\r
57 public static final String hasID_Inverse = "http://www.simantics.org/XML-1.0/hasID/Inverse";
\r
58 public static final String hasOriginalElementList = "http://www.simantics.org/XML-1.0/hasOriginalElementList";
\r
59 public static final String hasOriginalElementList_Inverse = "http://www.simantics.org/XML-1.0/hasOriginalElementList/Inverse";
\r
60 public static final String hasReference = "http://www.simantics.org/XML-1.0/hasReference";
\r
63 public static Resource getResourceOrNull(ReadGraph graph, String uri) {
\r
65 return graph.getResource(uri);
\r
66 } catch(DatabaseException e) {
\r
67 System.err.println(e.getMessage());
\r
72 public XMLResource(ReadGraph graph) {
\r
73 AttributeGroup = getResourceOrNull(graph, URIs.AttributeGroup);
\r
74 ComplexType = getResourceOrNull(graph, URIs.ComplexType);
\r
75 Date = getResourceOrNull(graph, URIs.Date);
\r
76 DateTime = getResourceOrNull(graph, URIs.DateTime);
\r
77 Element = getResourceOrNull(graph, URIs.Element);
\r
78 ElementList = getResourceOrNull(graph, URIs.ElementList);
\r
79 Entity = getResourceOrNull(graph, URIs.Entity);
\r
80 Time = getResourceOrNull(graph, URIs.Time);
\r
81 externalReferenceOf = getResourceOrNull(graph, URIs.externalReferenceOf);
\r
82 hasAttribute = getResourceOrNull(graph, URIs.hasAttribute);
\r
83 hasAttribute_Inverse = getResourceOrNull(graph, URIs.hasAttribute_Inverse);
\r
84 hasComplexType = getResourceOrNull(graph, URIs.hasComplexType);
\r
85 hasComplexType_Inverse = getResourceOrNull(graph, URIs.hasComplexType_Inverse);
\r
86 hasElement = getResourceOrNull(graph, URIs.hasElement);
\r
87 hasElementList = getResourceOrNull(graph, URIs.hasElementList);
\r
88 hasElementList_Inverse = getResourceOrNull(graph, URIs.hasElementList_Inverse);
\r
89 hasElement_Inverse = getResourceOrNull(graph, URIs.hasElement_Inverse);
\r
90 hasExternalReference = getResourceOrNull(graph, URIs.hasExternalReference);
\r
91 hasID = getResourceOrNull(graph, URIs.hasID);
\r
92 hasID_Inverse = getResourceOrNull(graph, URIs.hasID_Inverse);
\r
93 hasOriginalElementList = getResourceOrNull(graph, URIs.hasOriginalElementList);
\r
94 hasOriginalElementList_Inverse = getResourceOrNull(graph, URIs.hasOriginalElementList_Inverse);
\r
95 hasReference = getResourceOrNull(graph, URIs.hasReference);
\r
98 public static XMLResource getInstance(ReadGraph graph) {
\r
99 Session session = graph.getSession();
\r
100 XMLResource ret = session.peekService(XMLResource.class);
\r
102 QueryControl qc = graph.getService(QueryControl.class);
\r
103 ret = new XMLResource(qc.getIndependentGraph(graph));
\r
104 session.registerService(XMLResource.class, ret);
\r
109 public static XMLResource getInstance(RequestProcessor session) throws DatabaseException {
\r
110 XMLResource ret = session.peekService(XMLResource.class);
\r
112 ret = session.syncRequest(new Read<XMLResource>() {
\r
113 public XMLResource perform(ReadGraph graph) throws DatabaseException {
\r
114 QueryControl qc = graph.getService(QueryControl.class);
\r
115 return new XMLResource(qc.getIndependentGraph(graph));
\r
118 session.registerService(XMLResource.class, ret);
\r