1 /*******************************************************************************
2 * Copyright (c) 2007, 2018 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.procedure;
14 import org.simantics.db.AsyncReadGraph;
15 import org.simantics.db.ReadGraph;
16 import org.simantics.db.exception.DatabaseException;
19 * @author Antti Villberg
21 * First execute is called k times. After this finished or exception is called exactly once.
23 * @param <Result> the result object type accepted by the procedure
25 public interface SyncContextMultiProcedure<Context, Result> {
28 * Invoked once for each separate result of the request with potentially
29 * multiple results. It shall be guaranteed that all <code>execute</code>
30 * invocations have been completed when either
31 * {@link #finished(AsyncReadGraph)} or
32 * {@link #exception(AsyncReadGraph, Throwable)} are called and that no
33 * <code>execute</code> invocations will follow afterwards.
35 * @param graph asynchronous graph access
36 * @param result a single result of the multiresult procedure
38 void execute(ReadGraph graph, Context context, Result result) throws DatabaseException;
41 * Invoked after all {@link #execute(AsyncReadGraph, Object)} calls have
42 * been finished successfully. This method will not be invoked if case of
43 * errors in {@link #execute(AsyncReadGraph, Object)} or the performed
44 * request that provides the results to this procedure.
46 * @param graph asynchronous graph access
48 void finished(ReadGraph graph, Context context) throws DatabaseException;
51 * If an error occurs in the processing of the database request that
52 * produces the results for this procedure.
54 * @param graph asynchronous graph access
55 * @param throwable the exception that occurred
57 void exception(ReadGraph graph, Throwable throwable) throws DatabaseException;