1 package org.simantics.workbench.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 WorkbenchResource {
13 public final Resource DependenciesSearchContribution;
14 public final Resource DependenciesSearchFunction;
15 public final Resource HasWorkbenchSearchFunction;
16 public final Resource SearchContribution;
17 public final Resource SearchContribution_isEnabledByDefault;
18 public final Resource SearchContribution_isEnabledByDefault_Inverse;
19 public final Resource SearchFunction;
20 public final Resource hasSearchFunction;
22 public static class URIs {
23 public static final String DependenciesSearchContribution = "http://www.simantics.org/Workbench-1.2/DependenciesSearchContribution";
24 public static final String DependenciesSearchFunction = "http://www.simantics.org/Workbench-1.2/DependenciesSearchFunction";
25 public static final String HasWorkbenchSearchFunction = "http://www.simantics.org/Workbench-1.2/HasWorkbenchSearchFunction";
26 public static final String SearchContribution = "http://www.simantics.org/Workbench-1.2/SearchContribution";
27 public static final String SearchContribution_isEnabledByDefault = "http://www.simantics.org/Workbench-1.2/SearchContribution/isEnabledByDefault";
28 public static final String SearchContribution_isEnabledByDefault_Inverse = "http://www.simantics.org/Workbench-1.2/SearchContribution/isEnabledByDefault/Inverse";
29 public static final String SearchFunction = "http://www.simantics.org/Workbench-1.2/SearchFunction";
30 public static final String hasSearchFunction = "http://www.simantics.org/Workbench-1.2/hasSearchFunction";
33 public static Resource getResourceOrNull(ReadGraph graph, String uri) {
35 return graph.getResource(uri);
36 } catch(DatabaseException e) {
37 System.err.println(e.getMessage());
42 public WorkbenchResource(ReadGraph graph) {
43 DependenciesSearchContribution = getResourceOrNull(graph, URIs.DependenciesSearchContribution);
44 DependenciesSearchFunction = getResourceOrNull(graph, URIs.DependenciesSearchFunction);
45 HasWorkbenchSearchFunction = getResourceOrNull(graph, URIs.HasWorkbenchSearchFunction);
46 SearchContribution = getResourceOrNull(graph, URIs.SearchContribution);
47 SearchContribution_isEnabledByDefault = getResourceOrNull(graph, URIs.SearchContribution_isEnabledByDefault);
48 SearchContribution_isEnabledByDefault_Inverse = getResourceOrNull(graph, URIs.SearchContribution_isEnabledByDefault_Inverse);
49 SearchFunction = getResourceOrNull(graph, URIs.SearchFunction);
50 hasSearchFunction = getResourceOrNull(graph, URIs.hasSearchFunction);
53 public static WorkbenchResource getInstance(ReadGraph graph) {
54 Session session = graph.getSession();
55 WorkbenchResource ret = session.peekService(WorkbenchResource.class);
57 QueryControl qc = graph.getService(QueryControl.class);
58 ret = new WorkbenchResource(qc.getIndependentGraph(graph));
59 session.registerService(WorkbenchResource.class, ret);
64 public static WorkbenchResource getInstance(RequestProcessor session) throws DatabaseException {
65 WorkbenchResource ret = session.peekService(WorkbenchResource.class);
67 ret = session.syncRequest(new Read<WorkbenchResource>() {
68 public WorkbenchResource perform(ReadGraph graph) throws DatabaseException {
69 QueryControl qc = graph.getService(QueryControl.class);
70 return new WorkbenchResource(qc.getIndependentGraph(graph));
73 session.registerService(WorkbenchResource.class, ret);