--- /dev/null
+/*******************************************************************************\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.db.procedure;\r
+\r
+import java.util.List;\r
+\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.Statement;\r
+\r
+/**\r
+ * @author Antti Villberg\r
+ * \r
+ * First execute is called k times. After this finished or exception is called exactly once.\r
+ *\r
+ * @param <Result> the result object type accepted by the procedure\r
+ */\r
+public interface StatementProcedure extends List<Statement> {\r
+\r
+ /**\r
+ * Invoked once for each separate result of the request with potentially\r
+ * multiple results. It shall be guaranteed that all <code>execute</code>\r
+ * invocations have been completed when either\r
+ * {@link #finished(AsyncReadGraph)} or\r
+ * {@link #exception(AsyncReadGraph, Throwable)} are called and that no\r
+ * <code>execute</code> invocations will follow afterwards.\r
+ * \r
+ * @param graph asynchronous graph access\r
+ * @param result a single result of the multiresult procedure\r
+ */\r
+ void execute(AsyncReadGraph graph, int s, int p, int o);\r
+\r
+ /**\r
+ * Invoked after all {@link #execute(AsyncReadGraph, Object)} calls have\r
+ * been finished successfully. This method will not be invoked if case of\r
+ * errors in {@link #execute(AsyncReadGraph, Object)} or the performed\r
+ * request that provides the results to this procedure.\r
+ * \r
+ * @param graph asynchronous graph access\r
+ */\r
+ void finished(AsyncReadGraph graph);\r
+\r
+ /**\r
+ * If an error occurs in the processing of the database request that\r
+ * produces the results for this procedure.\r
+ * \r
+ * @param graph asynchronous graph access\r
+ * @param throwable the exception that occurred\r
+ */\r
+ void exception(AsyncReadGraph graph, Throwable throwable);\r
+\r
+}\r