如何在JBPM中设置/修改正在运行的流程实例的流程实例变量?是否有预定义的命令类来设置process-instance-variable?
我可以看到一些命令,比如org.drools.command.SetVariableCommandFromLastReturn && org.drools.command.SetVariableCommandFromCommand
我可以使用这些命令吗?如何使用此命令?
发布于 2013-04-25 14:49:26
到目前为止,我正在使用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;
}
});https://stackoverflow.com/questions/16185729
复制相似问题