9. 付録¶
9.1. 独自のビジネスロジックからロジックフローを呼び出す方法¶
9.1.1. Java開発モデル¶
Java開発モデルを利用してロジックフローを呼び出すコード例です。
package org.example.logicdesigner; import java.util.HashMap; import java.util.Map; import jp.co.intra_mart.foundation.logic.LogicRuntime; import jp.co.intra_mart.foundation.logic.LogicServiceProvider; import jp.co.intra_mart.foundation.logic.LogicSession; import jp.co.intra_mart.foundation.logic.exception.ErrorEndEventException; import jp.co.intra_mart.foundation.logic.exception.LogicServiceException; import jp.co.intra_mart.foundation.logic.exception.LogicServiceRuntimeException; public class CallExample { public void call() { // IM-LogicDesignerで利用するサービス群を管理するインスタンスを取得します。 LogicServiceProvider logicServiceProvider = LogicServiceProvider.getInstance(); // ロジックフロー実行用ランタイムを取得します。 LogicRuntime runtime = logicServiceProvider.getLogicRuntime(); try { // ロジックフロー実行用セッションを取得します。 LogicSession session = runtime.createSession("my-flow"); // フローに受け渡すパラメータを作成します。 Map<String, Object> input = new HashMap<>(); // ロジックフローを実行します。 Map<String, Object> output = (Map<String, Object>) session.execute(input); // 実行結果の確認 System.out.println(output); } catch (LogicServiceRuntimeException e) { // リカバリ不能な例外の場合にはLogicServiceRuntimeExceptionが通知されます。 e.printStackTrace(); } catch (ErrorEndEventException e) { // 明示的にエラー終了による終了を行った場合にはErrorEndEventExceptionが通知されます。 e.printStackTrace(); } catch (LogicServiceException e) { // ロジックフロー実行時に何らかの例外が発生した場合にはLogicServiceExceptionが通知されます。 e.printStackTrace(); } } }
9.1.2. スクリプト開発モデル¶
スクリプト開発モデルを利用してロジックフローを呼び出すコード例です。
function call() { // ロジックフローに受け渡すパラメータを作成します。 var input = {}; // ロジックフローを呼び出します。 var result = LogicFlowExecutor.execute('my-flow', input); if (result.error) { // 何らかのエラーが発生しました。 Debug.console(result); } var output = result.data; Debug.console(output); }