5.2. IM-FormaDesigner¶
IM-BPMから、IM-FormaDesignerとの連携方法を説明します。
IM-BPMから、IM-FormaDesignerと連携する場合、jugglingプロジェクトにてアプリケーションを追加する必要があります。
5.2.1. 前処理、後処理をカスタマイズする¶
IM-FormaDesignerの前処理、後処理をカスタマイズします。
コラム
IM-FormaDesignerの前処理、後処理の詳細は「IM-FormaDesigner 作成者操作ガイド」を参照してください。
IM-BPMのユーザタスクの フォームキーにIM-FormaDesignerのIDを指定することでIM-FormaDesignerと連携できます。
プロセス定義をデプロイし時点で、ユーザタスクに自動でIM-FormaDesignerに対して、前処理、後処理が設定されます。
前処理の主な処理は、プロセスインスタンスとタスクの変数を取得して画面の初期値に設定しています。
後処理の主な処理は、プロセスインスタンスを開始したり、タスクを完了し画面で入力された値を変数に登録しています。
前処理、後処理を変更したい場合は、 jp.co.intra_mart.activiti.extension.forma.ActivitiPreProcessExecutor を継承したクラスを作成し
IM-FormaDesignerの機能に従い、ユーザプログラム一覧から既存のクラスを削除し作成したクラスを追加してください。
5.2.2. 起票・申請タスクに前処理ユーザプログラムを設定する¶
IM-FormaDesignerを起票、または、申請する前の処理を差し込みます。
前処理ユーザプログラムは、決められたインタフェースを実装する必要があります。
package sample; import jp.co.intra_mart.activiti.engine.delegate.DelegateExecution; import jp.co.intra_mart.activiti.engine.delegate.ImFormaDraftPreprocess; import jp.co.intra_mart.foundation.workflow.application.model.param.DraftParam; public class SampleFormaDraftPreprocess implements ImFormaDraftPreprocess { @Override public void execute(DelegateExecution execution, DraftParam param) throws Exception { String matterName = (String) execution.getVariable("matterName"); String matterNumber = (String) execution.getVariable("matterNumber"); if (matterName != null) { param.setMatterName(matterName); } if (matterNumber != null) { param.setMatterNumber(matterNumber); } } }package sample; import java.util.Map; import jp.co.intra_mart.activiti.engine.delegate.DelegateExecution; import jp.co.intra_mart.activiti.engine.delegate.ImFormaApplyParamModel; import jp.co.intra_mart.activiti.engine.delegate.ImFormaApplyPreprocess; import jp.co.intra_mart.foundation.workflow.application.model.param.ApplyParam; import jp.co.intra_mart.foundation.forma.imw.api.type.impl.StandardFormaUserParamKey; public class SampleFormaApplyPreprocess implements ImFormaApplyPreprocess { @Override public void execute(DelegateExecution execution, ImFormaApplyParamModel model) throws Exception { ApplyParam applyParam = model.getApplyParam(); String matterName = (String) execution.getVariable("matterName"); String matterNumber = (String) execution.getVariable("matterNumber"); if (matterName != null) { applyParam.setMatterName(matterName); } if (matterNumber != null) { applyParam.setMatterNumber(matterNumber); } Map<String, Object> itemsMap = model.getFormaUserParam.get(StandardFormaUserParamKey.ITEMS); String param1 = (String) execution.getVariable("param1"); String param2 = (String) execution.getVariable("param2"); itemsMap.put("param1", param1); itemsMap.put("param2", param2); } }