--- /dev/null
+package org.simantics.district.selection;
+
+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 ElementSelectionResource {
+
+ public final Resource AggregateCondition;
+ public final Resource Condition;
+ public final Resource Condition_IsInverse;
+ public final Resource Condition_IsInverse_Inverse;
+ public final Resource Conjunction;
+ public final Resource Disjunction;
+ public final Resource ElementaryCondition;
+ public final Resource Generator;
+ public final Resource Generator_Diagram;
+ public final Resource Generator_Explicit;
+ public final Resource Generator_HasDiagram;
+ public final Resource Generator_HasDiagram_Inverse;
+ public final Resource Generator_HasSelectedElement;
+ public final Resource Generator_HasSelectedElement_Inverse;
+ public final Resource Generator_Model;
+ public final Resource HasSubcondition;
+ public final Resource HasSubcondition_Inverse;
+ public final Resource Negation;
+ public final Resource PropertyCondition;
+ public final Resource PropertyCondition_HasLowerLimit;
+ public final Resource PropertyCondition_HasLowerLimit_Inverse;
+ public final Resource PropertyCondition_HasPropertyName;
+ public final Resource PropertyCondition_HasPropertyName_Inverse;
+ public final Resource PropertyCondition_HasUpperLimit;
+ public final Resource PropertyCondition_HasUpperLimit_Inverse;
+ public final Resource PropertySelector;
+ public final Resource PropertySelector_HasResultCount;
+ public final Resource PropertySelector_HasResultCount_Inverse;
+ public final Resource PropertySelector_HasSelectionPropertyName;
+ public final Resource PropertySelector_HasSelectionPropertyName_Inverse;
+ public final Resource RegionCondition;
+ public final Resource RegionCondition_HasRegion;
+ public final Resource RegionCondition_HasRegion_Inverse;
+ public final Resource RouteCondition;
+ public final Resource RouteCondition_HasRoute;
+ public final Resource RouteCondition_HasRoute_Inverse;
+ public final Resource Selection;
+ public final Resource Selection_HasCondition;
+ public final Resource Selection_HasCondition_Inverse;
+ public final Resource Selection_HasGenerator;
+ public final Resource Selection_HasGenerator_Inverse;
+ public final Resource Selection_HasSelector;
+ public final Resource Selection_HasSelector_Inverse;
+ public final Resource Selector;
+ public final Resource Selector_All;
+ public final Resource Selector_NHighest;
+ public final Resource Selector_NLowest;
+
+ public static class URIs {
+ public static final String AggregateCondition = "http://www.simantics.org/ElementSelection-1.0/AggregateCondition";
+ public static final String Condition = "http://www.simantics.org/ElementSelection-1.0/Condition";
+ public static final String Condition_IsInverse = "http://www.simantics.org/ElementSelection-1.0/Condition/IsInverse";
+ public static final String Condition_IsInverse_Inverse = "http://www.simantics.org/ElementSelection-1.0/Condition/IsInverse/Inverse";
+ public static final String Conjunction = "http://www.simantics.org/ElementSelection-1.0/Conjunction";
+ public static final String Disjunction = "http://www.simantics.org/ElementSelection-1.0/Disjunction";
+ public static final String ElementaryCondition = "http://www.simantics.org/ElementSelection-1.0/ElementaryCondition";
+ public static final String Generator = "http://www.simantics.org/ElementSelection-1.0/Generator";
+ public static final String Generator_Diagram = "http://www.simantics.org/ElementSelection-1.0/Generator/Diagram";
+ public static final String Generator_Explicit = "http://www.simantics.org/ElementSelection-1.0/Generator/Explicit";
+ public static final String Generator_HasDiagram = "http://www.simantics.org/ElementSelection-1.0/Generator/HasDiagram";
+ public static final String Generator_HasDiagram_Inverse = "http://www.simantics.org/ElementSelection-1.0/Generator/HasDiagram/Inverse";
+ public static final String Generator_HasSelectedElement = "http://www.simantics.org/ElementSelection-1.0/Generator/HasSelectedElement";
+ public static final String Generator_HasSelectedElement_Inverse = "http://www.simantics.org/ElementSelection-1.0/Generator/HasSelectedElement/Inverse";
+ public static final String Generator_Model = "http://www.simantics.org/ElementSelection-1.0/Generator/Model";
+ public static final String HasSubcondition = "http://www.simantics.org/ElementSelection-1.0/HasSubcondition";
+ public static final String HasSubcondition_Inverse = "http://www.simantics.org/ElementSelection-1.0/HasSubcondition/Inverse";
+ public static final String Negation = "http://www.simantics.org/ElementSelection-1.0/Negation";
+ public static final String PropertyCondition = "http://www.simantics.org/ElementSelection-1.0/PropertyCondition";
+ public static final String PropertyCondition_HasLowerLimit = "http://www.simantics.org/ElementSelection-1.0/PropertyCondition/HasLowerLimit";
+ public static final String PropertyCondition_HasLowerLimit_Inverse = "http://www.simantics.org/ElementSelection-1.0/PropertyCondition/HasLowerLimit/Inverse";
+ public static final String PropertyCondition_HasPropertyName = "http://www.simantics.org/ElementSelection-1.0/PropertyCondition/HasPropertyName";
+ public static final String PropertyCondition_HasPropertyName_Inverse = "http://www.simantics.org/ElementSelection-1.0/PropertyCondition/HasPropertyName/Inverse";
+ public static final String PropertyCondition_HasUpperLimit = "http://www.simantics.org/ElementSelection-1.0/PropertyCondition/HasUpperLimit";
+ public static final String PropertyCondition_HasUpperLimit_Inverse = "http://www.simantics.org/ElementSelection-1.0/PropertyCondition/HasUpperLimit/Inverse";
+ public static final String PropertySelector = "http://www.simantics.org/ElementSelection-1.0/PropertySelector";
+ public static final String PropertySelector_HasResultCount = "http://www.simantics.org/ElementSelection-1.0/PropertySelector/HasResultCount";
+ public static final String PropertySelector_HasResultCount_Inverse = "http://www.simantics.org/ElementSelection-1.0/PropertySelector/HasResultCount/Inverse";
+ public static final String PropertySelector_HasSelectionPropertyName = "http://www.simantics.org/ElementSelection-1.0/PropertySelector/HasSelectionPropertyName";
+ public static final String PropertySelector_HasSelectionPropertyName_Inverse = "http://www.simantics.org/ElementSelection-1.0/PropertySelector/HasSelectionPropertyName/Inverse";
+ public static final String RegionCondition = "http://www.simantics.org/ElementSelection-1.0/RegionCondition";
+ public static final String RegionCondition_HasRegion = "http://www.simantics.org/ElementSelection-1.0/RegionCondition/HasRegion";
+ public static final String RegionCondition_HasRegion_Inverse = "http://www.simantics.org/ElementSelection-1.0/RegionCondition/HasRegion/Inverse";
+ public static final String RouteCondition = "http://www.simantics.org/ElementSelection-1.0/RouteCondition";
+ public static final String RouteCondition_HasRoute = "http://www.simantics.org/ElementSelection-1.0/RouteCondition/HasRoute";
+ public static final String RouteCondition_HasRoute_Inverse = "http://www.simantics.org/ElementSelection-1.0/RouteCondition/HasRoute/Inverse";
+ public static final String Selection = "http://www.simantics.org/ElementSelection-1.0/Selection";
+ public static final String Selection_HasCondition = "http://www.simantics.org/ElementSelection-1.0/Selection/HasCondition";
+ public static final String Selection_HasCondition_Inverse = "http://www.simantics.org/ElementSelection-1.0/Selection/HasCondition/Inverse";
+ public static final String Selection_HasGenerator = "http://www.simantics.org/ElementSelection-1.0/Selection/HasGenerator";
+ public static final String Selection_HasGenerator_Inverse = "http://www.simantics.org/ElementSelection-1.0/Selection/HasGenerator/Inverse";
+ public static final String Selection_HasSelector = "http://www.simantics.org/ElementSelection-1.0/Selection/HasSelector";
+ public static final String Selection_HasSelector_Inverse = "http://www.simantics.org/ElementSelection-1.0/Selection/HasSelector/Inverse";
+ public static final String Selector = "http://www.simantics.org/ElementSelection-1.0/Selector";
+ public static final String Selector_All = "http://www.simantics.org/ElementSelection-1.0/Selector/All";
+ public static final String Selector_NHighest = "http://www.simantics.org/ElementSelection-1.0/Selector/NHighest";
+ public static final String Selector_NLowest = "http://www.simantics.org/ElementSelection-1.0/Selector/NLowest";
+ }
+
+ public static Resource getResourceOrNull(ReadGraph graph, String uri) {
+ try {
+ return graph.getResource(uri);
+ } catch(DatabaseException e) {
+ System.err.println(e.getMessage());
+ return null;
+ }
+ }
+
+ public ElementSelectionResource(ReadGraph graph) {
+ AggregateCondition = getResourceOrNull(graph, URIs.AggregateCondition);
+ Condition = getResourceOrNull(graph, URIs.Condition);
+ Condition_IsInverse = getResourceOrNull(graph, URIs.Condition_IsInverse);
+ Condition_IsInverse_Inverse = getResourceOrNull(graph, URIs.Condition_IsInverse_Inverse);
+ Conjunction = getResourceOrNull(graph, URIs.Conjunction);
+ Disjunction = getResourceOrNull(graph, URIs.Disjunction);
+ ElementaryCondition = getResourceOrNull(graph, URIs.ElementaryCondition);
+ Generator = getResourceOrNull(graph, URIs.Generator);
+ Generator_Diagram = getResourceOrNull(graph, URIs.Generator_Diagram);
+ Generator_Explicit = getResourceOrNull(graph, URIs.Generator_Explicit);
+ Generator_HasDiagram = getResourceOrNull(graph, URIs.Generator_HasDiagram);
+ Generator_HasDiagram_Inverse = getResourceOrNull(graph, URIs.Generator_HasDiagram_Inverse);
+ Generator_HasSelectedElement = getResourceOrNull(graph, URIs.Generator_HasSelectedElement);
+ Generator_HasSelectedElement_Inverse = getResourceOrNull(graph, URIs.Generator_HasSelectedElement_Inverse);
+ Generator_Model = getResourceOrNull(graph, URIs.Generator_Model);
+ HasSubcondition = getResourceOrNull(graph, URIs.HasSubcondition);
+ HasSubcondition_Inverse = getResourceOrNull(graph, URIs.HasSubcondition_Inverse);
+ Negation = getResourceOrNull(graph, URIs.Negation);
+ PropertyCondition = getResourceOrNull(graph, URIs.PropertyCondition);
+ PropertyCondition_HasLowerLimit = getResourceOrNull(graph, URIs.PropertyCondition_HasLowerLimit);
+ PropertyCondition_HasLowerLimit_Inverse = getResourceOrNull(graph, URIs.PropertyCondition_HasLowerLimit_Inverse);
+ PropertyCondition_HasPropertyName = getResourceOrNull(graph, URIs.PropertyCondition_HasPropertyName);
+ PropertyCondition_HasPropertyName_Inverse = getResourceOrNull(graph, URIs.PropertyCondition_HasPropertyName_Inverse);
+ PropertyCondition_HasUpperLimit = getResourceOrNull(graph, URIs.PropertyCondition_HasUpperLimit);
+ PropertyCondition_HasUpperLimit_Inverse = getResourceOrNull(graph, URIs.PropertyCondition_HasUpperLimit_Inverse);
+ PropertySelector = getResourceOrNull(graph, URIs.PropertySelector);
+ PropertySelector_HasResultCount = getResourceOrNull(graph, URIs.PropertySelector_HasResultCount);
+ PropertySelector_HasResultCount_Inverse = getResourceOrNull(graph, URIs.PropertySelector_HasResultCount_Inverse);
+ PropertySelector_HasSelectionPropertyName = getResourceOrNull(graph, URIs.PropertySelector_HasSelectionPropertyName);
+ PropertySelector_HasSelectionPropertyName_Inverse = getResourceOrNull(graph, URIs.PropertySelector_HasSelectionPropertyName_Inverse);
+ RegionCondition = getResourceOrNull(graph, URIs.RegionCondition);
+ RegionCondition_HasRegion = getResourceOrNull(graph, URIs.RegionCondition_HasRegion);
+ RegionCondition_HasRegion_Inverse = getResourceOrNull(graph, URIs.RegionCondition_HasRegion_Inverse);
+ RouteCondition = getResourceOrNull(graph, URIs.RouteCondition);
+ RouteCondition_HasRoute = getResourceOrNull(graph, URIs.RouteCondition_HasRoute);
+ RouteCondition_HasRoute_Inverse = getResourceOrNull(graph, URIs.RouteCondition_HasRoute_Inverse);
+ Selection = getResourceOrNull(graph, URIs.Selection);
+ Selection_HasCondition = getResourceOrNull(graph, URIs.Selection_HasCondition);
+ Selection_HasCondition_Inverse = getResourceOrNull(graph, URIs.Selection_HasCondition_Inverse);
+ Selection_HasGenerator = getResourceOrNull(graph, URIs.Selection_HasGenerator);
+ Selection_HasGenerator_Inverse = getResourceOrNull(graph, URIs.Selection_HasGenerator_Inverse);
+ Selection_HasSelector = getResourceOrNull(graph, URIs.Selection_HasSelector);
+ Selection_HasSelector_Inverse = getResourceOrNull(graph, URIs.Selection_HasSelector_Inverse);
+ Selector = getResourceOrNull(graph, URIs.Selector);
+ Selector_All = getResourceOrNull(graph, URIs.Selector_All);
+ Selector_NHighest = getResourceOrNull(graph, URIs.Selector_NHighest);
+ Selector_NLowest = getResourceOrNull(graph, URIs.Selector_NLowest);
+ }
+
+ public static ElementSelectionResource getInstance(ReadGraph graph) {
+ Session session = graph.getSession();
+ ElementSelectionResource ret = session.peekService(ElementSelectionResource.class);
+ if(ret == null) {
+ QueryControl qc = graph.getService(QueryControl.class);
+ ret = new ElementSelectionResource(qc.getIndependentGraph(graph));
+ session.registerService(ElementSelectionResource.class, ret);
+ }
+ return ret;
+ }
+
+ public static ElementSelectionResource getInstance(RequestProcessor session) throws DatabaseException {
+ ElementSelectionResource ret = session.peekService(ElementSelectionResource.class);
+ if(ret == null) {
+ ret = session.syncRequest(new Read<ElementSelectionResource>() {
+ public ElementSelectionResource perform(ReadGraph graph) throws DatabaseException {
+ QueryControl qc = graph.getService(QueryControl.class);
+ return new ElementSelectionResource(qc.getIndependentGraph(graph));
+ }
+ });
+ session.registerService(ElementSelectionResource.class, ret);
+ }
+ return ret;
+ }
+
+}
+