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