X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.layer0.utils%2Fsrc%2Forg%2Fsimantics%2Flayer0%2Futils%2Fqueries%2FQueryExecutor2.java;h=8608fc4d595559c91cc4c682bc1c62838c5b70d2;hb=0d9b90834ce56b292c00b1a39850ed842c3e4d42;hp=90c23305ccb8b1ef80e3cc3bc1df044aeb149524;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/queries/QueryExecutor2.java b/bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/queries/QueryExecutor2.java index 90c23305c..8608fc4d5 100644 --- a/bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/queries/QueryExecutor2.java +++ b/bundles/org.simantics.layer0.utils/src/org/simantics/layer0/utils/queries/QueryExecutor2.java @@ -1,84 +1,79 @@ -/******************************************************************************* - * 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 DUMMY = new Object(); -// -// @Override -// public void perform(SyncReadGraph graph, -// SingleQueryProcedure4 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 request = new AsyncMultiRead() { - - @Override - public int threadHash() { - return hashCode(); - } - - @Override - public void perform(AsyncReadGraph graph, - AsyncMultiProcedure callback) { - graph.asyncRequest(QueryExecutor2.this, QueryExecutor2.this); - callback.finished(graph); - } - - }; - - AsyncMultiProcedureAdapter procedure = new AsyncMultiProcedureAdapter() { - - @Override - public void exception(AsyncReadGraph graph, Throwable t) { - t.printStackTrace(); - } - - }; - - if(processor instanceof WriteGraph) processor.syncRequest(request, procedure); - else processor.asyncRequest(request, procedure); - - } - - @Override - public void exception(AsyncReadGraph graph, Throwable t) { - t.printStackTrace(); - } - -} +/******************************************************************************* + * 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 DUMMY = new Object(); +// +// @Override +// public void perform(SyncReadGraph graph, +// SingleQueryProcedure4 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 request = new AsyncMultiRead() { + + @Override + public void perform(AsyncReadGraph graph, + AsyncMultiProcedure callback) { + graph.asyncRequest(QueryExecutor2.this, QueryExecutor2.this); + callback.finished(graph); + } + + }; + + AsyncMultiProcedureAdapter procedure = new AsyncMultiProcedureAdapter() { + + @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(); + } + +}