本文整理汇总了Java中org.kie.api.runtime.process.ProcessInstance.getId方法的典型用法代码示例。如果您正苦于以下问题:Java ProcessInstance.getId方法的具体用法?Java ProcessInstance.getId怎么用?Java ProcessInstance.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.kie.api.runtime.process.ProcessInstance
的用法示例。
在下文中一共展示了ProcessInstance.getId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doTest
import org.kie.api.runtime.process.ProcessInstance; //导入方法依赖的package包/类
@Test
public void doTest() throws Exception {
TaskService service = engine.getTaskService();
ProcessInstance pi = engine.getKieSession().startProcess(PROCESS_ID);
List<TaskSummary> tasks = service.getTasksAssignedAsPotentialOwner(USR, "en-UK");
System.out.println("Process created: " + pi.getId());
System.out.println("Number of tasks: " + tasks.size());
long taskId = 0l;
for (TaskSummary taskSummary : tasks) {
if (taskSummary.getProcessInstanceId() == pi.getId()) {
taskId = taskSummary.getId();
}
}
if (taskId != 0l) {
System.out.println("Found task: " + taskId);
service.claim(taskId, USR);
service.start(taskId, USR);
service.complete(taskId, USR, getParameters());
}
}
示例2: startProcess
import org.kie.api.runtime.process.ProcessInstance; //导入方法依赖的package包/类
/**
* Starts up a new ProcessInstance with the given deploymentId and
* ProcessId. The parameters Map is set into the context of the workflow.
*
* @param deploymentId
* the deployment id
* @param processId
* the process id
* @param parameters
* the parameters
* @return the long
* @throws Exception
* the exception
*/
public long startProcess(String deploymentId, String processId, Map<String, Object> parameters)
throws Exception {
long processInstanceId = -1;
try {
KieSrampUtil kieSrampUtil = new KieSrampUtil();
RuntimeManager runtimeManager = kieSrampUtil.getRuntimeManager(processEngineService, deploymentId);
RuntimeEngine runtime = runtimeManager.getRuntimeEngine(EmptyContext.get());
KieSession ksession = runtime.getKieSession();
// start a new process instance
ProcessInstance processInstance = ksession.startProcess(processId,
parameters);
processInstanceId = processInstance.getId();
logger.info(Messages.i18n.format("ProcessBean.Started", processInstanceId)); //$NON-NLS-1$
} catch (Exception e) {
e.printStackTrace();
throw e;
}
return processInstanceId;
}
示例3: startProcess
import org.kie.api.runtime.process.ProcessInstance; //导入方法依赖的package包/类
private long startProcess(KieSession ksession, TaskService taskService) {
// start a new process instance
ProcessInstance processInstance = ksession.startProcess("com.awizen.gangehi.simple_approval");
long processInstanceId = processInstance.getId();
String processId = processInstance.getProcessId();
System.out.println("Process started ... processInstance:" + processInstanceId + " processId:" + processId );
List<Long> tasksByProcessInstanceId = taskService.getTasksByProcessInstanceId(processInstanceId);
assertEquals(1, tasksByProcessInstanceId.size());
Long taskId = tasksByProcessInstanceId.get(0);
List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
potentialOwners.add(new UserImpl("userA"));
taskService.nominate(taskId, "Administrator", potentialOwners );
taskService.start(taskId, "userA");
return processInstanceId;
}
示例4: testProcessInstanceSignalEvent
import org.kie.api.runtime.process.ProcessInstance; //导入方法依赖的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"));
}