2013-04-24 5 views
0

JBPM에서 실행중인 프로세스 인스턴스의 프로세스 인스턴스 변수를 설정/수정하는 방법은 무엇입니까? process-instance-variables를 설정할 사전 정의 된 명령 클래스가 있습니까?JBPM 5 - 프로세스 인스턴스 변수 변경 명령 ​​

나는 org.drools.command.SetVariableCommandFromLastReturn & & org.drools.command.SetVariableCommandFromCommand

내가이 명령을 사용할 수와 같은 몇 가지 명령을 볼 수 있습니까? 이 명령을 사용하는 방법?

답변

0

현재로서는이 변수를 GenericCommand으로 업데이트 중입니다.

kSession.execute(new GenericCommand<Boolean>() { 
      public Boolean execute(Context context) { 
       //Get session in the command context 
       StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession(); 
       //Get the process instance 
       ProcessInstance processInstance = (ProcessInstance) ksession.getProcessInstance(processInstanceId); 
       //Get variable scoprts 
       VariableScopeInstance variableScope = (VariableScopeInstance) processInstance.getContextInstance(VariableScope.VARIABLE_SCOPE); 
       Iterator<String> piStateItr=piStateVariables.keySet().iterator(); 
       //Modify required variables 
       while(piStateItr.hasNext()){ 
        String variableName=piStateItr.next(); 
        String variableValue=piStateVariables.get(variableName); 
        logger.debug(">>> Setting State - key "+variableName +" , to "+variableValue); 
        variableScope.setVariable(variableName, variableValue); 
       } 
       return true; 
      } 
     }); 
+0

익명의 GenericCommand가 정상적으로 작동합니다. –

+0

안녕하세요, 귀하의 코드 주셔서 감사합니다, 나는 같은 문제에 직면하고있어. 'processInstanceId' 변수를 어떻게 가져 왔습니까? – ocramot

+0

@ocramot, processInstanceId는 주어진 코드를 둘러싸고있는 메소드를 위해 입력된다. –

관련 문제