-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.layer0.utils.queries;\r
-\r
-import org.simantics.db.AsyncReadGraph;\r
-import org.simantics.db.RequestProcessor;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter;\r
-import org.simantics.db.common.request.ReadRequest;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.procedure.AsyncListener;\r
-import org.simantics.db.procedure.AsyncMultiProcedure;\r
-import org.simantics.db.request.AsyncMultiRead;\r
-\r
-@Deprecated\r
-public abstract class QueryExecutor2 extends ReadRequest implements AsyncListener<Object> {\r
-\r
-// Object DUMMY = new Object();\r
-// \r
-// @Override\r
-// public void perform(SyncReadGraph graph,\r
-// SingleQueryProcedure4<Object> procedure) {\r
-// doPerform(graph);\r
-// procedure.execute(graph, DUMMY);\r
-// \r
-// }\r
- \r
-// protected abstract void doPerform(SyncReadGraph g);\r
- \r
- @Override\r
- public void execute(AsyncReadGraph graph, Object result) {\r
- }\r
-\r
- public void execute(WriteGraph graph) throws DatabaseException {\r
- graph.syncRequest(QueryExecutor2.this, QueryExecutor2.this);\r
- }\r
-\r
- public void execute(RequestProcessor processor) throws DatabaseException {\r
- \r
- AsyncMultiRead<Object> request = new AsyncMultiRead<Object>() {\r
-\r
- @Override\r
- public int threadHash() {\r
- return hashCode();\r
- }\r
- \r
- @Override\r
- public void perform(AsyncReadGraph graph,\r
- AsyncMultiProcedure<Object> callback) {\r
- graph.asyncRequest(QueryExecutor2.this, QueryExecutor2.this);\r
- callback.finished(graph);\r
- }\r
- \r
- }; \r
- \r
- AsyncMultiProcedureAdapter<Object> procedure = new AsyncMultiProcedureAdapter<Object>() {\r
-\r
- @Override\r
- public void exception(AsyncReadGraph graph, Throwable t) {\r
- t.printStackTrace();\r
- }\r
- \r
- }; \r
- \r
- if(processor instanceof WriteGraph) processor.syncRequest(request, procedure);\r
- else processor.asyncRequest(request, procedure);\r
- \r
- }\r
-\r
- @Override\r
- public void exception(AsyncReadGraph graph, Throwable t) {\r
- t.printStackTrace();\r
- }\r
- \r
-}\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.layer0.utils.queries;
+
+import org.simantics.db.AsyncReadGraph;
+import org.simantics.db.RequestProcessor;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.procedure.adapter.AsyncMultiProcedureAdapter;
+import org.simantics.db.common.request.ReadRequest;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.procedure.AsyncListener;
+import org.simantics.db.procedure.AsyncMultiProcedure;
+import org.simantics.db.request.AsyncMultiRead;
+
+@Deprecated
+public abstract class QueryExecutor2 extends ReadRequest implements AsyncListener<Object> {
+
+// Object DUMMY = new Object();
+//
+// @Override
+// public void perform(SyncReadGraph graph,
+// SingleQueryProcedure4<Object> procedure) {
+// doPerform(graph);
+// procedure.execute(graph, DUMMY);
+//
+// }
+
+// protected abstract void doPerform(SyncReadGraph g);
+
+ @Override
+ public void execute(AsyncReadGraph graph, Object result) {
+ }
+
+ public void execute(WriteGraph graph) throws DatabaseException {
+ graph.syncRequest(QueryExecutor2.this, QueryExecutor2.this);
+ }
+
+ public void execute(RequestProcessor processor) throws DatabaseException {
+
+ AsyncMultiRead<Object> request = new AsyncMultiRead<Object>() {
+
+ @Override
+ public void perform(AsyncReadGraph graph,
+ AsyncMultiProcedure<Object> callback) {
+ graph.asyncRequest(QueryExecutor2.this, QueryExecutor2.this);
+ callback.finished(graph);
+ }
+
+ };
+
+ AsyncMultiProcedureAdapter<Object> procedure = new AsyncMultiProcedureAdapter<Object>() {
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable t) {
+ t.printStackTrace();
+ }
+
+ };
+
+ if(processor instanceof WriteGraph) processor.syncRequest(request, procedure);
+ else processor.syncRequest(request, procedure);
+
+ }
+
+ @Override
+ public void exception(AsyncReadGraph graph, Throwable t) {
+ t.printStackTrace();
+ }
+
+}