本文整理汇总了Java中org.jbpm.process.instance.context.variable.VariableScopeInstance类的典型用法代码示例。如果您正苦于以下问题:Java VariableScopeInstance类的具体用法?Java VariableScopeInstance怎么用?Java VariableScopeInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VariableScopeInstance类属于org.jbpm.process.instance.context.variable包,在下文中一共展示了VariableScopeInstance类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setProcessInstanceVariables
import org.jbpm.process.instance.context.variable.VariableScopeInstance; //导入依赖的package包/类
public void setProcessInstanceVariables(long processInstanceId,
Map<String, Object> variables) {
StatefulKnowledgeSession ksession = this.bpmService.createSession();
try {
ProcessInstance processInstance = ksession.getProcessInstance(processInstanceId);
if (processInstance != null) {
VariableScopeInstance variableScope = (VariableScopeInstance)
((org.jbpm.process.instance.ProcessInstance) processInstance)
.getContextInstance(VariableScope.VARIABLE_SCOPE);
if (variableScope == null) {
throw new IllegalArgumentException("Could not find variable scope for process instance " + processInstanceId);
}
for (Map.Entry<String, Object> entry: variables.entrySet()) {
variableScope.setVariable(entry.getKey(), entry.getValue());
}
} else {
throw new IllegalArgumentException("Could not find process instance " + processInstanceId);
}
} finally {
ksession.dispose();
}
}
示例2: executeWorkItem
import org.jbpm.process.instance.context.variable.VariableScopeInstance; //导入依赖的package包/类
public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
Task task = new Task();
task.setCreate(new Date());
task.setWorkItemId(workItem.getId());
task.setStatus(TaskStatus.Created);
StatefulKnowledgeSession session=this.getSession();
task.setSessionId(session.getId());
ProcessInstance pi=session.getProcessInstance(workItem.getProcessInstanceId());
task.setProcessId(pi.getProcessId());
VariableScopeInstance varContextInstance=(VariableScopeInstance)((ProcessInstanceImpl)pi).getContextInstance(VariableScope.VARIABLE_SCOPE);
String businessId=(String)varContextInstance.getVariable(ProcessConstants.BUSINESS_ID);
task.setBusinessId(businessId);
task.setProcessInstanceId(workItem.getProcessInstanceId());
String taskName = (String) workItem.getParameter("TaskName");
if(StringUtils.isEmpty(taskName)){
taskName="Unnamed task";
}
task.setName(taskName);
String comment = (String) workItem.getParameter("Comment");
task.setCmnt(comment);
String priorityString = (String) workItem.getParameter("Priority");
int priority = 0;
if (priorityString != null) {
try {
priority = new Integer(priorityString);
} catch (NumberFormatException e) {}
}
task.setPriority(priority);
task.setSkippable(!"false".equals(workItem.getParameter("Skippable")));
String groupId = (String) workItem.getParameter("GroupId");
String actorId = (String) workItem.getParameter("ActorId");
EntityManager em=taskManager.getEntityManager();
EntityTransaction trans=em.getTransaction();
try{
trans.begin();
if (StringUtils.isNotEmpty(actorId)) {
String[] actorIds = actorId.trim().split(",");
assignmentByActorIds(task,em,actorIds);
} else if (StringUtils.isNotEmpty(groupId)) {
String[] groupIds = groupId.trim().split(",");
assignmentByGroupIds(task,em,groupIds);
} else {
//如果没有指定任务处理人或groupId,那么将采用bdf2提供的动态任务分配类
}
trans.commit();
}catch(Exception ex){
trans.rollback();
throw new RuntimeException(ex);
}
// Object contentObject = workItem.getParameter("Content");
}
示例3: testProcessInstanceSignalEvent
import org.jbpm.process.instance.context.variable.VariableScopeInstance; //导入依赖的package包/类
@Test
public void testProcessInstanceSignalEvent() throws Exception {
String str = "";
str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
str += "<process xmlns=\"http://drools.org/drools-5.0/process\"\n";
str += " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
str += " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n";
str += " type=\"RuleFlow\" name=\"flow\" id=\"org.drools.core.event\" package-name=\"org.drools\" version=\"1\" >\n";
str += "\n";
str += " <header>\n";
str += " <variables>\n";
str += " <variable name=\"MyVar\" >\n";
str += " <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n";
str += " <value>SomeText</value>\n";
str += " </variable>\n";
str += " </variables>\n";
str += " </header>\n";
str += "\n";
str += " <nodes>\n";
str += " <start id=\"1\" name=\"Start\" />\n";
str += " <eventNode id=\"2\" name=\"Event\" variableName=\"MyVar\" >\n";
str += " <eventFilters>\n";
str += " <eventFilter type=\"eventType\" eventType=\"MyEvent\" />\n";
str += " </eventFilters>\n";
str += " </eventNode>\n";
str += " <join id=\"3\" name=\"Join\" type=\"1\" />\n";
str += " <end id=\"4\" name=\"End\" />\n";
str += " </nodes>\n";
str += "\n";
str += " <connections>\n";
str += " <connection from=\"1\" to=\"3\" />\n";
str += " <connection from=\"2\" to=\"3\" />\n";
str += " <connection from=\"3\" to=\"4\" />\n";
str += " </connections>\n";
str += "\n";
str += "</process>";
KieSession ksession = getKieSessionFromResource(ResourceFactory.newByteArrayResource(str.getBytes()).setSourcePath("src/main/resources/rule.rf")
.setResourceType(ResourceType.DRF));
ProcessInstance processInstance = ksession.startProcess("org.drools.core.event");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
String inXml = "";
inXml += "<signal-event process-instance-id= '" + processInstance.getId() + "' event-type='MyEvent'>";
inXml += " <string>MyValue</string>";
inXml += "</signal-event>";
setExec(ksession);
String outXml = template.requestBody("direct:exec", inXml, String.class);
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
assertEquals("MyValue",
((VariableScopeInstance)((org.jbpm.process.instance.ProcessInstance)processInstance).getContextInstance(VariableScope.VARIABLE_SCOPE)).getVariable("MyVar"));
}
示例4: testProcessRuntimeSignalEvent
import org.jbpm.process.instance.context.variable.VariableScopeInstance; //导入依赖的package包/类
@Test
public void testProcessRuntimeSignalEvent() throws Exception {
String str = "";
str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
str += "<process xmlns=\"http://drools.org/drools-5.0/process\"\n";
str += " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
str += " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n";
str += " type=\"RuleFlow\" name=\"flow\" id=\"org.drools.core.event\" package-name=\"org.drools\" version=\"1\" >\n";
str += "\n";
str += " <header>\n";
str += " <variables>\n";
str += " <variable name=\"MyVar\" >\n";
str += " <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n";
str += " <value>SomeText</value>\n";
str += " </variable>\n";
str += " </variables>\n";
str += " </header>\n";
str += "\n";
str += " <nodes>\n";
str += " <start id=\"1\" name=\"Start\" />\n";
str += " <eventNode id=\"2\" name=\"Event\" scope=\"external\" variableName=\"MyVar\" >\n";
str += " <eventFilters>\n";
str += " <eventFilter type=\"eventType\" eventType=\"MyEvent\" />\n";
str += " </eventFilters>\n";
str += " </eventNode>\n";
str += " <join id=\"3\" name=\"Join\" type=\"1\" />\n";
str += " <end id=\"4\" name=\"End\" />\n";
str += " </nodes>\n";
str += "\n";
str += " <connections>\n";
str += " <connection from=\"1\" to=\"3\" />\n";
str += " <connection from=\"2\" to=\"3\" />\n";
str += " <connection from=\"3\" to=\"4\" />\n";
str += " </connections>\n";
str += "\n";
str += "</process>";
KieSession ksession = getKieSessionFromResource(ResourceFactory.newByteArrayResource(str.getBytes()).setSourcePath("src/main/resources/rule.rf")
.setResourceType(ResourceType.DRF));
ProcessInstance processInstance = ksession.startProcess("org.drools.core.event");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
String inXml = "";
inXml += "<signal-event event-type='MyEvent'>";
inXml += " <string>MyValue</string>";
inXml += "</signal-event>";
setExec(ksession);
String outXml = template.requestBody("direct:exec", inXml, String.class);
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
assertEquals("MyValue",
((VariableScopeInstance)((org.jbpm.process.instance.ProcessInstance)processInstance).getContextInstance(VariableScope.VARIABLE_SCOPE)).getVariable("MyVar"));
}
示例5: testProcessInstanceSignalEvent
import org.jbpm.process.instance.context.variable.VariableScopeInstance; //导入依赖的package包/类
@Test
public void testProcessInstanceSignalEvent() throws Exception {
String str = "";
str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
str += "<process xmlns=\"http://drools.org/drools-5.0/process\"\n";
str += " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
str += " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n";
str += " type=\"RuleFlow\" name=\"flow\" id=\"org.drools.core.event\" package-name=\"org.drools\" version=\"1\" >\n";
str += "\n";
str += " <header>\n";
str += " <variables>\n";
str += " <variable name=\"MyVar\" >\n";
str += " <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n";
str += " <value>SomeText</value>\n";
str += " </variable>\n";
str += " </variables>\n";
str += " </header>\n";
str += "\n";
str += " <nodes>\n";
str += " <start id=\"1\" name=\"Start\" />\n";
str += " <eventNode id=\"2\" name=\"Event\" variableName=\"MyVar\" >\n";
str += " <eventFilters>\n";
str += " <eventFilter type=\"eventType\" eventType=\"MyEvent\" />\n";
str += " </eventFilters>\n";
str += " </eventNode>\n";
str += " <join id=\"3\" name=\"Join\" type=\"1\" />\n";
str += " <end id=\"4\" name=\"End\" />\n";
str += " </nodes>\n";
str += "\n";
str += " <connections>\n";
str += " <connection from=\"1\" to=\"3\" />\n";
str += " <connection from=\"2\" to=\"3\" />\n";
str += " <connection from=\"3\" to=\"4\" />\n";
str += " </connections>\n";
str += "\n";
str += "</process>";
KieSession ksession = getKieSessionFromResource(ResourceFactory.newByteArrayResource(str.getBytes()).setSourcePath("src/main/resources/rule.rf")
.setResourceType(ResourceType.DRF));
setExec(ksession);
ProcessInstance processInstance = ksession.startProcess("org.drools.core.event");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
execContent("testProcessInstanceSignalEvent.in.1");
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
assertEquals("MyValue",
((VariableScopeInstance)((org.jbpm.process.instance.ProcessInstance)processInstance).getContextInstance(VariableScope.VARIABLE_SCOPE)).getVariable("MyVar"));
}
示例6: testProcessRuntimeSignalEvent
import org.jbpm.process.instance.context.variable.VariableScopeInstance; //导入依赖的package包/类
@Test
public void testProcessRuntimeSignalEvent() throws Exception {
String str = "";
str += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
str += "<process xmlns=\"http://drools.org/drools-5.0/process\"\n";
str += " xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
str += " xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n";
str += " type=\"RuleFlow\" name=\"flow\" id=\"org.drools.core.event\" package-name=\"org.drools\" version=\"1\" >\n";
str += "\n";
str += " <header>\n";
str += " <variables>\n";
str += " <variable name=\"MyVar\" >\n";
str += " <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n";
str += " <value>SomeText</value>\n";
str += " </variable>\n";
str += " </variables>\n";
str += " </header>\n";
str += "\n";
str += " <nodes>\n";
str += " <start id=\"1\" name=\"Start\" />\n";
str += " <eventNode id=\"2\" name=\"Event\" scope=\"external\" variableName=\"MyVar\" >\n";
str += " <eventFilters>\n";
str += " <eventFilter type=\"eventType\" eventType=\"MyEvent\" />\n";
str += " </eventFilters>\n";
str += " </eventNode>\n";
str += " <join id=\"3\" name=\"Join\" type=\"1\" />\n";
str += " <end id=\"4\" name=\"End\" />\n";
str += " </nodes>\n";
str += "\n";
str += " <connections>\n";
str += " <connection from=\"1\" to=\"3\" />\n";
str += " <connection from=\"2\" to=\"3\" />\n";
str += " <connection from=\"3\" to=\"4\" />\n";
str += " </connections>\n";
str += "\n";
str += "</process>";
KieSession ksession = getKieSessionFromResource(ResourceFactory.newByteArrayResource(str.getBytes()).setSourcePath("src/main/resources/rule.rf")
.setResourceType(ResourceType.DRF));
setExec(ksession);
ProcessInstance processInstance = ksession.startProcess("org.drools.core.event");
assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
execContent("testProcessRuntimeSignalEvent.in.1");
assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
assertEquals("MyValue",
((VariableScopeInstance)((org.jbpm.process.instance.ProcessInstance)processInstance).getContextInstance(VariableScope.VARIABLE_SCOPE)).getVariable("MyVar"));
}
示例7: execute
import org.jbpm.process.instance.context.variable.VariableScopeInstance; //导入依赖的package包/类
/**
* 执行任务分配动作
* @param variableScopeInstance 存储当前流程变量的对象实例
* @param processId 流程模版ID
* @param taskName 任务名称
* @return 返回Assignment对象
*/
public Assignment execute(VariableScopeInstance variableScopeInstance,String processId,String taskName){
return null;
}