ビジネスプロセス管理

jBPM関連Tips(タスク編)

※以下のTipsは jBPM Ver.6.0.1(コミュニティ版)で調査したものです

永続化

ユーザ関連

あるユーザの所属するグループを取得して表示

private void dispUserGroup(String user) {
 String callBackProp = System.getProperty("jbpm.usergroup.callback.properties");
 System.out.println("callbackProperty=" + callBackProp);

 UserGroupCallback ugrpCallback = new JBossUserGroupCallbackImpl("classpath:/usergroups.properties");

 List<String> grps = ugrpCallback.getGroupsForUser(user, null, null);
 for(String grp : grps) {
   System.out.println(grp);
 }
/* こういうやり方もある
 RuntimeEnvironment env = RuntimeEnvironmentBuilder.Factory.get().newDefaultInMemoryBuilder()
       .addAsset(ResourceFactory.newClassPathResource("sample.bpmn"), ResourceType.BPMN2).get();
 UserGroupCallback ugc = env.getUserGroupCallback();
 grps = ugrpCallback.getGroupsForUser(user, null, null);
 for(String grp : grps) {
        System.out.println(grp);
 }
*/
}

EclipseでjBPMのテストクラスを動かすときのユーザ情報はどこにある?

プロセス関連

プロセス内のノードの一覧を取得

 @SuppressWarnings("restriction")	
 private void dispProcNodes(ProcessInstance processInstance) {	
   System.out.println("---");	
   WorkflowProcessInstanceImpl instance = (WorkflowProcessInstanceImpl) processInstance;	
   for (Node node : instance.getNodeContainer().getNodes()) {	
       //NodeContainer nc = node.getNodeContainer();	
       //Node[] nods = nc.getNodes();	
       System.out.println(">>id=[" + node.getId() + "], node.Name=[" + node.getName() + "]");	
       Map<String,Object> map =node.getMetaData();	
       for (String key : map.keySet()) {	
         System.out.println(key + " = " + map.get(key));	
       }              	
   }	
   System.out.println("---");	
 }	

プロセスインスタンスのステータス

private void dispProcState(ProcessInstance processInstance) {
int st =processInstance.getState();
switch(st){
  case ProcessInstance.STATE_ACTIVE:
    System.out.println("st=STATE_ACTIVE");
    break;
  case ProcessInstance.STATE_COMPLETED:
    System.out.println("st=STATE_COMPLETED");
    break;
  case ProcessInstance.STATE_ABORTED:
    System.out.println("st=STATE_ABORTED");
    break;
  default:
    System.out.println("st=" + st);
    break;
  }
}

プロセス変数設定

プロセス変数の列挙(通常のやり方)

Map<String,Object> vmap = wfpi.getVariables();
for(String s : vmap.keySet()){ 
  System.out.println( s + "=" + vmap.get(s) );
}

VariableScopeを使ってプロセス変数の一覧を取得する

ContextableInstance ci = (ContextableInstance) processInstance;
VariableScopeInstance vsi =  (VariableScopeInstance)ci.getContextInstance(VariableScope.VARIABLE_SCOPE);
VariableScope vs = vsi.getVariableScope();
List<Variable> vars = vs.getVariables();
for(int i = 0 ; i < vars.size(); i++ ){
  System.out.println(vars.get(i).getName() + "=" + vars.get(i).getValue());
}

Context<?>の取得

セッション関連

デフォルト KieSession と 名前つき KieSession についての解説

KieSessionの実装

Eclipseによる開発


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2014-09-11 (木) 22:47:13