package org.simantics.scenegraph.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 ScenegraphResources { public final Resource Functions; public final Resource Functions_defaultRuntimeResource; public final Resource Functions_defaultRuntimeVariable; public final Resource Functions_liftedProperty; public final Resource Functions_singleVariableSelection; public final Resource LiftedProperty; public final Resource LiftedPropertyRelation; public final Resource LiftedProperty_HasPredicate; public final Resource LiftedProperty_HasPredicate_Inverse; public final Resource Node; public final Resource Node_HasProperty; public final Resource Node_HasProperty_Inverse; public final Resource Node_children; public final Resource Node_children_Inverse; public final Resource Runtime; public final Resource Runtime_HasResource; public final Resource Runtime_HasResource_Inverse; public final Resource Runtime_HasVariable; public final Resource Runtime_HasVariable_Inverse; public final Resource Runtime_resource; public final Resource Runtime_resource_Inverse; public final Resource Runtime_variable; public final Resource Runtime_variable_Inverse; public final Resource lifted; public final Resource userProperty; public final Resource userProperty_Inverse; public static class URIs { public static final String Functions = "http://www.simantics.org/Scenegraph-1.1/Functions"; public static final String Functions_defaultRuntimeResource = "http://www.simantics.org/Scenegraph-1.1/Functions/defaultRuntimeResource"; public static final String Functions_defaultRuntimeVariable = "http://www.simantics.org/Scenegraph-1.1/Functions/defaultRuntimeVariable"; public static final String Functions_liftedProperty = "http://www.simantics.org/Scenegraph-1.1/Functions/liftedProperty"; public static final String Functions_singleVariableSelection = "http://www.simantics.org/Scenegraph-1.1/Functions/singleVariableSelection"; public static final String LiftedProperty = "http://www.simantics.org/Scenegraph-1.1/LiftedProperty"; public static final String LiftedPropertyRelation = "http://www.simantics.org/Scenegraph-1.1/LiftedPropertyRelation"; public static final String LiftedProperty_HasPredicate = "http://www.simantics.org/Scenegraph-1.1/LiftedProperty/HasPredicate"; public static final String LiftedProperty_HasPredicate_Inverse = "http://www.simantics.org/Scenegraph-1.1/LiftedProperty/HasPredicate/Inverse"; public static final String Node = "http://www.simantics.org/Scenegraph-1.1/Node"; public static final String Node_HasProperty = "http://www.simantics.org/Scenegraph-1.1/Node/HasProperty"; public static final String Node_HasProperty_Inverse = "http://www.simantics.org/Scenegraph-1.1/Node/HasProperty/Inverse"; public static final String Node_children = "http://www.simantics.org/Scenegraph-1.1/Node/children"; public static final String Node_children_Inverse = "http://www.simantics.org/Scenegraph-1.1/Node/children/Inverse"; public static final String Runtime = "http://www.simantics.org/Scenegraph-1.1/Runtime"; public static final String Runtime_HasResource = "http://www.simantics.org/Scenegraph-1.1/Runtime/HasResource"; public static final String Runtime_HasResource_Inverse = "http://www.simantics.org/Scenegraph-1.1/Runtime/HasResource/Inverse"; public static final String Runtime_HasVariable = "http://www.simantics.org/Scenegraph-1.1/Runtime/HasVariable"; public static final String Runtime_HasVariable_Inverse = "http://www.simantics.org/Scenegraph-1.1/Runtime/HasVariable/Inverse"; public static final String Runtime_resource = "http://www.simantics.org/Scenegraph-1.1/Runtime/resource"; public static final String Runtime_resource_Inverse = "http://www.simantics.org/Scenegraph-1.1/Runtime/resource/Inverse"; public static final String Runtime_variable = "http://www.simantics.org/Scenegraph-1.1/Runtime/variable"; public static final String Runtime_variable_Inverse = "http://www.simantics.org/Scenegraph-1.1/Runtime/variable/Inverse"; public static final String lifted = "http://www.simantics.org/Scenegraph-1.1/lifted"; public static final String userProperty = "http://www.simantics.org/Scenegraph-1.1/userProperty"; public static final String userProperty_Inverse = "http://www.simantics.org/Scenegraph-1.1/userProperty/Inverse"; } public static Resource getResourceOrNull(ReadGraph graph, String uri) { try { return graph.getResource(uri); } catch(DatabaseException e) { System.err.println(e.getMessage()); return null; } } public ScenegraphResources(ReadGraph graph) { Functions = getResourceOrNull(graph, URIs.Functions); Functions_defaultRuntimeResource = getResourceOrNull(graph, URIs.Functions_defaultRuntimeResource); Functions_defaultRuntimeVariable = getResourceOrNull(graph, URIs.Functions_defaultRuntimeVariable); Functions_liftedProperty = getResourceOrNull(graph, URIs.Functions_liftedProperty); Functions_singleVariableSelection = getResourceOrNull(graph, URIs.Functions_singleVariableSelection); LiftedProperty = getResourceOrNull(graph, URIs.LiftedProperty); LiftedPropertyRelation = getResourceOrNull(graph, URIs.LiftedPropertyRelation); LiftedProperty_HasPredicate = getResourceOrNull(graph, URIs.LiftedProperty_HasPredicate); LiftedProperty_HasPredicate_Inverse = getResourceOrNull(graph, URIs.LiftedProperty_HasPredicate_Inverse); Node = getResourceOrNull(graph, URIs.Node); Node_HasProperty = getResourceOrNull(graph, URIs.Node_HasProperty); Node_HasProperty_Inverse = getResourceOrNull(graph, URIs.Node_HasProperty_Inverse); Node_children = getResourceOrNull(graph, URIs.Node_children); Node_children_Inverse = getResourceOrNull(graph, URIs.Node_children_Inverse); Runtime = getResourceOrNull(graph, URIs.Runtime); Runtime_HasResource = getResourceOrNull(graph, URIs.Runtime_HasResource); Runtime_HasResource_Inverse = getResourceOrNull(graph, URIs.Runtime_HasResource_Inverse); Runtime_HasVariable = getResourceOrNull(graph, URIs.Runtime_HasVariable); Runtime_HasVariable_Inverse = getResourceOrNull(graph, URIs.Runtime_HasVariable_Inverse); Runtime_resource = getResourceOrNull(graph, URIs.Runtime_resource); Runtime_resource_Inverse = getResourceOrNull(graph, URIs.Runtime_resource_Inverse); Runtime_variable = getResourceOrNull(graph, URIs.Runtime_variable); Runtime_variable_Inverse = getResourceOrNull(graph, URIs.Runtime_variable_Inverse); lifted = getResourceOrNull(graph, URIs.lifted); userProperty = getResourceOrNull(graph, URIs.userProperty); userProperty_Inverse = getResourceOrNull(graph, URIs.userProperty_Inverse); } public static ScenegraphResources getInstance(ReadGraph graph) { Session session = graph.getSession(); ScenegraphResources ret = session.peekService(ScenegraphResources.class); if(ret == null) { QueryControl qc = graph.getService(QueryControl.class); ret = new ScenegraphResources(qc.getIndependentGraph(graph)); session.registerService(ScenegraphResources.class, ret); } return ret; } public static ScenegraphResources getInstance(RequestProcessor session) throws DatabaseException { ScenegraphResources ret = session.peekService(ScenegraphResources.class); if(ret == null) { ret = session.syncRequest(new Read() { public ScenegraphResources perform(ReadGraph graph) throws DatabaseException { QueryControl qc = graph.getService(QueryControl.class); return new ScenegraphResources(qc.getIndependentGraph(graph)); } }); session.registerService(ScenegraphResources.class, ret); } return ret; } }