-package org.simantics.xml.sax.ontology;\r
-\r
-import org.simantics.db.RequestProcessor;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.service.QueryControl;\r
-\r
-public class XMLResource {\r
- \r
- public final Resource AttributeGroup;\r
- public final Resource ComplexType;\r
- public final Resource Date;\r
- public final Resource DateTime;\r
- public final Resource Element;\r
- public final Resource ElementList;\r
- public final Resource Time;\r
- public final Resource externalReferenceOf;\r
- public final Resource hasAttribute;\r
- public final Resource hasAttribute_Inverse;\r
- public final Resource hasComplexType;\r
- public final Resource hasComplexType_Inverse;\r
- public final Resource hasElement;\r
- public final Resource hasElementList;\r
- public final Resource hasElementList_Inverse;\r
- public final Resource hasElement_Inverse;\r
- public final Resource hasExternalReference;\r
- public final Resource hasID;\r
- public final Resource hasID_Inverse;\r
- public final Resource hasOriginalElementList;\r
- public final Resource hasOriginalElementList_Inverse;\r
- public final Resource hasReference;\r
- \r
- public static class URIs {\r
- public static final String AttributeGroup = "http://www.simantics.org/XML-1.0/AttributeGroup";\r
- public static final String ComplexType = "http://www.simantics.org/XML-1.0/ComplexType";\r
- public static final String Date = "http://www.simantics.org/XML-1.0/Date";\r
- public static final String DateTime = "http://www.simantics.org/XML-1.0/DateTime";\r
- public static final String Element = "http://www.simantics.org/XML-1.0/Element";\r
- public static final String ElementList = "http://www.simantics.org/XML-1.0/ElementList";\r
- public static final String Time = "http://www.simantics.org/XML-1.0/Time";\r
- public static final String externalReferenceOf = "http://www.simantics.org/XML-1.0/externalReferenceOf";\r
- public static final String hasAttribute = "http://www.simantics.org/XML-1.0/hasAttribute";\r
- public static final String hasAttribute_Inverse = "http://www.simantics.org/XML-1.0/hasAttribute/Inverse";\r
- public static final String hasComplexType = "http://www.simantics.org/XML-1.0/hasComplexType";\r
- public static final String hasComplexType_Inverse = "http://www.simantics.org/XML-1.0/hasComplexType/Inverse";\r
- public static final String hasElement = "http://www.simantics.org/XML-1.0/hasElement";\r
- public static final String hasElementList = "http://www.simantics.org/XML-1.0/hasElementList";\r
- public static final String hasElementList_Inverse = "http://www.simantics.org/XML-1.0/hasElementList/Inverse";\r
- public static final String hasElement_Inverse = "http://www.simantics.org/XML-1.0/hasElement/Inverse";\r
- public static final String hasExternalReference = "http://www.simantics.org/XML-1.0/hasExternalReference";\r
- public static final String hasID = "http://www.simantics.org/XML-1.0/hasID";\r
- public static final String hasID_Inverse = "http://www.simantics.org/XML-1.0/hasID/Inverse";\r
- public static final String hasOriginalElementList = "http://www.simantics.org/XML-1.0/hasOriginalElementList";\r
- public static final String hasOriginalElementList_Inverse = "http://www.simantics.org/XML-1.0/hasOriginalElementList/Inverse";\r
- public static final String hasReference = "http://www.simantics.org/XML-1.0/hasReference";\r
- }\r
- \r
- public static Resource getResourceOrNull(ReadGraph graph, String uri) {\r
- try {\r
- return graph.getResource(uri);\r
- } catch(DatabaseException e) {\r
- System.err.println(e.getMessage());\r
- return null;\r
- }\r
- }\r
- \r
- public XMLResource(ReadGraph graph) {\r
- AttributeGroup = getResourceOrNull(graph, URIs.AttributeGroup);\r
- ComplexType = getResourceOrNull(graph, URIs.ComplexType);\r
- Date = getResourceOrNull(graph, URIs.Date);\r
- DateTime = getResourceOrNull(graph, URIs.DateTime);\r
- Element = getResourceOrNull(graph, URIs.Element);\r
- ElementList = getResourceOrNull(graph, URIs.ElementList);\r
- Time = getResourceOrNull(graph, URIs.Time);\r
- externalReferenceOf = getResourceOrNull(graph, URIs.externalReferenceOf);\r
- hasAttribute = getResourceOrNull(graph, URIs.hasAttribute);\r
- hasAttribute_Inverse = getResourceOrNull(graph, URIs.hasAttribute_Inverse);\r
- hasComplexType = getResourceOrNull(graph, URIs.hasComplexType);\r
- hasComplexType_Inverse = getResourceOrNull(graph, URIs.hasComplexType_Inverse);\r
- hasElement = getResourceOrNull(graph, URIs.hasElement);\r
- hasElementList = getResourceOrNull(graph, URIs.hasElementList);\r
- hasElementList_Inverse = getResourceOrNull(graph, URIs.hasElementList_Inverse);\r
- hasElement_Inverse = getResourceOrNull(graph, URIs.hasElement_Inverse);\r
- hasExternalReference = getResourceOrNull(graph, URIs.hasExternalReference);\r
- hasID = getResourceOrNull(graph, URIs.hasID);\r
- hasID_Inverse = getResourceOrNull(graph, URIs.hasID_Inverse);\r
- hasOriginalElementList = getResourceOrNull(graph, URIs.hasOriginalElementList);\r
- hasOriginalElementList_Inverse = getResourceOrNull(graph, URIs.hasOriginalElementList_Inverse);\r
- hasReference = getResourceOrNull(graph, URIs.hasReference);\r
- }\r
- \r
- public static XMLResource getInstance(ReadGraph graph) {\r
- Session session = graph.getSession();\r
- XMLResource ret = session.peekService(XMLResource.class);\r
- if(ret == null) {\r
- QueryControl qc = graph.getService(QueryControl.class);\r
- ret = new XMLResource(qc.getIndependentGraph(graph));\r
- session.registerService(XMLResource.class, ret);\r
- }\r
- return ret;\r
- }\r
- \r
- public static XMLResource getInstance(RequestProcessor session) throws DatabaseException {\r
- XMLResource ret = session.peekService(XMLResource.class);\r
- if(ret == null) {\r
- ret = session.syncRequest(new Read<XMLResource>() {\r
- public XMLResource perform(ReadGraph graph) throws DatabaseException {\r
- QueryControl qc = graph.getService(QueryControl.class);\r
- return new XMLResource(qc.getIndependentGraph(graph));\r
- }\r
- });\r
- session.registerService(XMLResource.class, ret);\r
- }\r
- return ret;\r
- }\r
- \r
-}\r
-\r
+package org.simantics.xml.sax.ontology;
+
+import org.simantics.db.RequestProcessor;
+import org.simantics.db.Resource;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.request.Read;
+import org.simantics.db.Session;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.service.QueryControl;
+
+public class XMLResource {
+
+ public final Resource AttributeGroup;
+ public final Resource ComplexType;
+ public final Resource Date;
+ public final Resource DateTime;
+ public final Resource Element;
+ public final Resource ElementList;
+ public final Resource Entity;
+ public final Resource Time;
+ public final Resource externalReferenceOf;
+ public final Resource hasAttribute;
+ public final Resource hasAttribute_Inverse;
+ public final Resource hasComplexType;
+ public final Resource hasComplexType_Inverse;
+ public final Resource hasElement;
+ public final Resource hasElementList;
+ public final Resource hasElementList_Inverse;
+ public final Resource hasElement_Inverse;
+ public final Resource hasExternalReference;
+ public final Resource hasID;
+ public final Resource hasID_Inverse;
+ public final Resource hasOriginalElementList;
+ public final Resource hasOriginalElementList_Inverse;
+ public final Resource hasReference;
+ public final Resource referredBy;
+
+ public static class URIs {
+ public static final String AttributeGroup = "http://www.simantics.org/XML-1.0/AttributeGroup";
+ public static final String ComplexType = "http://www.simantics.org/XML-1.0/ComplexType";
+ public static final String Date = "http://www.simantics.org/XML-1.0/Date";
+ public static final String DateTime = "http://www.simantics.org/XML-1.0/DateTime";
+ public static final String Element = "http://www.simantics.org/XML-1.0/Element";
+ public static final String ElementList = "http://www.simantics.org/XML-1.0/ElementList";
+ public static final String Entity = "http://www.simantics.org/XML-1.0/Entity";
+ public static final String Time = "http://www.simantics.org/XML-1.0/Time";
+ public static final String externalReferenceOf = "http://www.simantics.org/XML-1.0/externalReferenceOf";
+ public static final String hasAttribute = "http://www.simantics.org/XML-1.0/hasAttribute";
+ public static final String hasAttribute_Inverse = "http://www.simantics.org/XML-1.0/hasAttribute/Inverse";
+ public static final String hasComplexType = "http://www.simantics.org/XML-1.0/hasComplexType";
+ public static final String hasComplexType_Inverse = "http://www.simantics.org/XML-1.0/hasComplexType/Inverse";
+ public static final String hasElement = "http://www.simantics.org/XML-1.0/hasElement";
+ public static final String hasElementList = "http://www.simantics.org/XML-1.0/hasElementList";
+ public static final String hasElementList_Inverse = "http://www.simantics.org/XML-1.0/hasElementList/Inverse";
+ public static final String hasElement_Inverse = "http://www.simantics.org/XML-1.0/hasElement/Inverse";
+ public static final String hasExternalReference = "http://www.simantics.org/XML-1.0/hasExternalReference";
+ public static final String hasID = "http://www.simantics.org/XML-1.0/hasID";
+ public static final String hasID_Inverse = "http://www.simantics.org/XML-1.0/hasID/Inverse";
+ public static final String hasOriginalElementList = "http://www.simantics.org/XML-1.0/hasOriginalElementList";
+ public static final String hasOriginalElementList_Inverse = "http://www.simantics.org/XML-1.0/hasOriginalElementList/Inverse";
+ public static final String hasReference = "http://www.simantics.org/XML-1.0/hasReference";
+ public static final String referredBy = "http://www.simantics.org/XML-1.0/referredBy";
+ }
+
+ public static Resource getResourceOrNull(ReadGraph graph, String uri) {
+ try {
+ return graph.getResource(uri);
+ } catch(DatabaseException e) {
+ System.err.println(e.getMessage());
+ return null;
+ }
+ }
+
+ public XMLResource(ReadGraph graph) {
+ AttributeGroup = getResourceOrNull(graph, URIs.AttributeGroup);
+ ComplexType = getResourceOrNull(graph, URIs.ComplexType);
+ Date = getResourceOrNull(graph, URIs.Date);
+ DateTime = getResourceOrNull(graph, URIs.DateTime);
+ Element = getResourceOrNull(graph, URIs.Element);
+ ElementList = getResourceOrNull(graph, URIs.ElementList);
+ Entity = getResourceOrNull(graph, URIs.Entity);
+ Time = getResourceOrNull(graph, URIs.Time);
+ externalReferenceOf = getResourceOrNull(graph, URIs.externalReferenceOf);
+ hasAttribute = getResourceOrNull(graph, URIs.hasAttribute);
+ hasAttribute_Inverse = getResourceOrNull(graph, URIs.hasAttribute_Inverse);
+ hasComplexType = getResourceOrNull(graph, URIs.hasComplexType);
+ hasComplexType_Inverse = getResourceOrNull(graph, URIs.hasComplexType_Inverse);
+ hasElement = getResourceOrNull(graph, URIs.hasElement);
+ hasElementList = getResourceOrNull(graph, URIs.hasElementList);
+ hasElementList_Inverse = getResourceOrNull(graph, URIs.hasElementList_Inverse);
+ hasElement_Inverse = getResourceOrNull(graph, URIs.hasElement_Inverse);
+ hasExternalReference = getResourceOrNull(graph, URIs.hasExternalReference);
+ hasID = getResourceOrNull(graph, URIs.hasID);
+ hasID_Inverse = getResourceOrNull(graph, URIs.hasID_Inverse);
+ hasOriginalElementList = getResourceOrNull(graph, URIs.hasOriginalElementList);
+ hasOriginalElementList_Inverse = getResourceOrNull(graph, URIs.hasOriginalElementList_Inverse);
+ hasReference = getResourceOrNull(graph, URIs.hasReference);
+ referredBy = getResourceOrNull(graph, URIs.referredBy);
+ }
+
+ public static XMLResource getInstance(ReadGraph graph) {
+ Session session = graph.getSession();
+ XMLResource ret = session.peekService(XMLResource.class);
+ if(ret == null) {
+ QueryControl qc = graph.getService(QueryControl.class);
+ ret = new XMLResource(qc.getIndependentGraph(graph));
+ session.registerService(XMLResource.class, ret);
+ }
+ return ret;
+ }
+
+ public static XMLResource getInstance(RequestProcessor session) throws DatabaseException {
+ XMLResource ret = session.peekService(XMLResource.class);
+ if(ret == null) {
+ ret = session.syncRequest(new Read<XMLResource>() {
+ public XMLResource perform(ReadGraph graph) throws DatabaseException {
+ QueryControl qc = graph.getService(QueryControl.class);
+ return new XMLResource(qc.getIndependentGraph(graph));
+ }
+ });
+ session.registerService(XMLResource.class, ret);
+ }
+ return ret;
+ }
+
+}
+