本文整理汇总了Java中org.camunda.bpm.engine.runtime.ProcessInstance类的典型用法代码示例。如果您正苦于以下问题:Java ProcessInstance类的具体用法?Java ProcessInstance怎么用?Java ProcessInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProcessInstance类属于org.camunda.bpm.engine.runtime包,在下文中一共展示了ProcessInstance类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateNewRandomDue
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
protected Date calculateNewRandomDue(ProcessInstance pi, String id, Date creationTime) {
if (!distributions.containsKey(id)) {
StatisticalDistribution distribution = createDistributionForElement(pi, id);
distributions.put(id, distribution);
}
Calendar cal = Calendar.getInstance();
cal.setTime(creationTime);
double timeToWait = distributions.get(id).nextSample();
if (timeToWait <= 0) {
timeToWait = 1;
}
cal.add(Calendar.SECOND, (int) Math.round(timeToWait));
return cal.getTime();
}
开发者ID:camunda-consulting,项目名称:camunda-util-demo-data-generator,代码行数:17,代码来源:TimeAwareDemoGenerator.java
示例2: create
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
/**
* Creates process instance from process definition.
*
* <p>
* Only parameters corresponding to form attributes defined on Start task will be stored.
* Others will be silently ignored.
* </p>
*
* @param key Specified key of {@link WorkflowDto}
* @param businessKey Specified business key (reference to external resource)
* @param params Initial process variables
* @return New process instance ID
*/
public String create(String key, String businessKey, Map<String, Object> params) {
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery()
.processDefinitionKey(key)
.latestVersion()
.singleResult();
notNull(definition, () -> new MissingObject(ProcessDefinition.class, key));
BpmnModelInstance modelInstance = repositoryService.getBpmnModelInstance(definition.getId());
if(!canStart(modelInstance, unwrap(user))) {
throw new ForbiddenOperation(null);
}
StartFormData formData = formService.getStartFormData(definition.getId());
Map<String, Object> filteredParams = filterDefinedFields(formData, params);
ProcessInstance instance = formService.submitStartForm(
definition.getId(), businessKey, filteredParams
);
return instance.getId();
}
示例3: execute
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
private void execute(MigrationPlanContainer migrationPlanContainer) {
ProcessDefinition sourceDefinition = migrationPlanContainer.getSourceDefinition();
ProcessDefinition targetDefinition = migrationPlanContainer.getTargetDefinition();
MigrationPlanExecutionBuilder migrationPlanExecutionBuilder = migrationPlanContainer.getMigrationPlanExecutionBuilder();
LOG.info("\tMigrating all process instances from SOURCE process definition " + sourceDefinition.getId() + " to TARGET process definition " + targetDefinition.getId());
for (ProcessInstance processInstance : runtimeService.createProcessInstanceQuery().processDefinitionId(sourceDefinition.getId()).list()) {
LOG.info("\tMigrating process instance with id " + processInstance.getId());
}
try {
migrationPlanExecutionBuilder.execute();
// .executeAsync() for asynchronous execution in a batch (useful for large numbers of instances)
} catch (MigratingProcessInstanceValidationException e) {
throw new IllegalMigrationStateException("Validation error occurred during executing the migration from SOURCE process definition " + sourceDefinition.getId() + " to TARGET process definition " + targetDefinition.getId() + ": " + e.getValidationReport().toString(), e);
}
LOG.info("\tSuccessfully migrated all process instances from SOURCE process definition " + sourceDefinition.getId() + " to TARGET process definition " + targetDefinition.getId());
}
示例4: shouldModifyBeforeMigrationIfFileExists
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test
public void shouldModifyBeforeMigrationIfFileExists() throws Exception {
//given
ChangelogVersion changelogVersion = new ChangelogVersion();
changelogVersion.setMigrationFolder("test");
Resource resourceMock = mock(Resource.class);
when(resourceMock.exists()).thenReturn(true);
when(resourcePatternResolver.getResource("classpath:/process/migrationplan/test/modification_before.json")).thenReturn(resourceMock);
ModificationCollection modificationCollectionMock = mock(ModificationCollection.class);
when(objectMapperService.convertModificationCollection(resourceMock)).thenReturn(modificationCollectionMock);
Modification modificationMock = mock(Modification.class);
when(modificationCollectionMock.getModifications()).thenReturn(Collections.singletonList(modificationMock));
ProcessInstance processInstanceMock = mock(ProcessInstance.class);
doReturn(Collections.singletonList(processInstanceMock)).when(modificationService).findProcessInstancesToModify(modificationMock);
ProcessInstanceModification processInstanceModificationMock = mock(ProcessInstanceModification.class);
doReturn(processInstanceModificationMock).when(modificationService).createProcessInstanceModification(processInstanceMock, modificationMock);
doNothing().when(modificationService).validate(modificationMock);
//when
modificationService.modifyBeforeMigration(changelogVersion);
//then
verify(processInstanceModificationMock).execute();
}
示例5: shouldModifyAfterMigrationIfFileExists
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test
public void shouldModifyAfterMigrationIfFileExists() throws Exception {
//given
ChangelogVersion changelogVersion = new ChangelogVersion();
changelogVersion.setMigrationFolder("test");
Resource resourceMock = mock(Resource.class);
when(resourceMock.exists()).thenReturn(true);
when(resourcePatternResolver.getResource("classpath:/process/migrationplan/test/modification_after.json")).thenReturn(resourceMock);
ModificationCollection modificationCollectionMock = mock(ModificationCollection.class);
when(objectMapperService.convertModificationCollection(resourceMock)).thenReturn(modificationCollectionMock);
Modification modificationMock = mock(Modification.class);
when(modificationCollectionMock.getModifications()).thenReturn(Collections.singletonList(modificationMock));
ProcessInstance processInstanceMock = mock(ProcessInstance.class);
doReturn(Collections.singletonList(processInstanceMock)).when(modificationService).findProcessInstancesToModify(modificationMock);
ProcessInstanceModification processInstanceModificationMock = mock(ProcessInstanceModification.class);
doReturn(processInstanceModificationMock).when(modificationService).createProcessInstanceModification(processInstanceMock, modificationMock);
doNothing().when(modificationService).validate(modificationMock);
//when
modificationService.modifyAfterMigration(changelogVersion);
//then
verify(processInstanceModificationMock).execute();
}
示例6: execute
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Override
public void execute(DelegateExecution execution) throws Exception {
String processInstanceId = execution.getProcessInstanceId();
System.out.println("Entering FindOwnProcessTask.execute (processInstanceId="
+ processInstanceId + ")");
ProcessInstanceQuery query = execution.getProcessEngineServices().getRuntimeService()
.createProcessInstanceQuery().processInstanceId(processInstanceId);
ProcessInstance pi = query.singleResult();
if (pi == null) {
System.out
.println("WARN - No process instance with id " + processInstanceId + " found!");
} else {
System.out.println("Hello World!");
}
System.out.println(
"Exiting FindOwnProcessTask.execute (processInstanceId=" + processInstanceId + ")");
}
示例7: execute
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Override
public void execute(DelegateExecution execution) throws Exception {
String processInstanceId = execution.getProcessInstanceId();
System.out.println(
"Entering HelloWorldTask.execute (processInstanceId=" + processInstanceId + ")");
ProcessInstanceQuery query =
runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId);
ProcessInstance pi = query.singleResult();
if (pi == null) {
System.out
.println("WARN - No process instance with id " + processInstanceId + " found!");
} else {
System.out.println("Hello World!");
}
System.out.println(
"Exiting HelloWorldTask.execute (processInstanceId=" + processInstanceId + ")");
}
示例8: runProcess
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test
public void runProcess() {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("demoProcess");
// given the execution ids of all activities
String task11ExecId = getExecutionId("Task 1.1", pi.getId());
String task12ExecId = getExecutionId("Task 1.2", pi.getId());
String task13ExecId = getExecutionId("Task 1.3", pi.getId());
String task14ExecId = getExecutionId("Task 1.4", pi.getId());
String task15ExecId = getExecutionId("Task 1.5", pi.getId());
String task16ExecId = getExecutionId("Task 1.6", pi.getId());
String task21ExecId = getExecutionId("Task 2.1", pi.getId());
String task22ExecId = getExecutionId("Task 2.2", pi.getId());
String task31ExecId = getExecutionId("Task 3.1", pi.getId());
// we expect some activities to have the same execution ID
assertEqualIds(task11ExecId, task12ExecId, task14ExecId, task16ExecId);
// and other to have different execution ids (thus have an own execution scope=
assertDifferentIds(task11ExecId, task13ExecId, task14ExecId, task15ExecId, task21ExecId,
task22ExecId, task31ExecId);
}
示例9: pollMailWithTextBody
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test
@Deployment(resources = "processes/mail-poll.bpmn")
public void pollMailWithTextBody() throws MessagingException {
greenMail.setUser("[email protected]", "bpmn");
GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "subject", "text body");
ProcessInstance processInstance = engineRule.getRuntimeService().startProcessInstanceByKey("poll-mails");
@SuppressWarnings("unchecked")
List<Mail> mails = (List<Mail>) engineRule.getRuntimeService().getVariable(processInstance.getId(), "mails");
assertThat(mails)
.isNotNull()
.hasSize(1);
Mail mail = mails.get(0);
assertThat(mail.getFrom()).isEqualTo("[email protected]");
assertThat(mail.getSubject()).isEqualTo("subject");
assertThat(mail.getText()).isEqualTo("text body");
}
示例10: testStartByStarterMessage1
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test
@Deployment(resources = {"org/camunda/bpm/scenario/test/processes/StartByTest.bpmn"})
public void testStartByStarterMessage1() {
when(scenario.waitsAtReceiveTask("ReceiveTask")).thenReturn(new ReceiveTaskAction() {
@Override
public void execute(EventSubscriptionDelegate message) throws Exception {
message.receive();
}
});
Scenario.run(scenario).startBy(new ProcessStarter() {
@Override
public ProcessInstance start() {
return rule.getRuntimeService().startProcessInstanceByMessage("msg_StartEvent1");
}
}).execute();
verify(scenario, times(1)).hasFinished("StartEvent1");
verify(scenario, times(1)).hasFinished("EndEvent");
}
示例11: testStartByStarterMessage2
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test
@Deployment(resources = {"org/camunda/bpm/scenario/test/processes/StartByTest.bpmn"})
public void testStartByStarterMessage2() {
when(scenario.waitsAtReceiveTask("ReceiveTask")).thenReturn(new ReceiveTaskAction() {
@Override
public void execute(EventSubscriptionDelegate message) throws Exception {
message.receive();
}
});
Scenario.run(scenario).startBy(new ProcessStarter() {
@Override
public ProcessInstance start() {
return rule.getRuntimeService().startProcessInstanceByMessage("msg_StartEvent2");
}
}).execute();
verify(scenario, times(1)).hasFinished("StartEvent2");
verify(scenario, times(1)).hasFinished("EndEvent");
}
示例12: testStartByMessageWithVariables
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test
@Deployment(resources = {"org/camunda/bpm/scenario/test/processes/StartByTest.bpmn"})
public void testStartByMessageWithVariables() {
when(scenario.waitsAtReceiveTask("ReceiveTask")).thenReturn(new ReceiveTaskAction() {
@Override
public void execute(EventSubscriptionDelegate message) throws Exception {
message.receive();
}
});
Scenario run = Scenario.run(scenario).startBy(new ProcessStarter() {
@Override
public ProcessInstance start() {
return rule.getRuntimeService().startProcessInstanceByMessage("msg_StartEvent1", withVariables("variable", true));
}
}).execute();
HistoricVariableInstance variable = historyService().createHistoricVariableInstanceQuery().variableName("variable").singleResult();
assertThat(variable).isNotNull();
assertThat((Boolean) variable.getValue()).isTrue();
verify(scenario, times(1)).hasFinished("StartEvent1");
verify(scenario, times(1)).hasFinished("EndEvent");
}
示例13: testCompleteTask2First_Conventional
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test
@Deployment(resources = {"org/camunda/bpm/scenario/test/escalations/EscalationEventSubProcessTriggeredTwiceTest.bpmn"})
public void testCompleteTask2First_Conventional() {
ProcessInstance pi = rule.getRuntimeService()
.startProcessInstanceByKey("EscalationEventSubProcessTriggeredTwiceTest");
complete(task("UserTask2", pi));
complete(task("UserTask1", pi));
complete(task("UserTask2", pi));
assertThat(pi)
.hasPassed("EndEvent")
.hasPassedInOrder("EndEventEscalated", "EndEventEscalated");
}
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:18,代码来源:EscalationEventSubProcessTriggeredTwiceConventionalTest.java
示例14: testCompleteTask2First_Conventional
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test
@Deployment(resources = {"org/camunda/bpm/scenario/test/escalations/BoundaryEscalationEventTriggeredTwiceTest.bpmn"})
public void testCompleteTask2First_Conventional() {
ProcessInstance pi = rule.getRuntimeService()
.startProcessInstanceByKey("BoundaryEscalationEventTriggeredTwiceTest");
complete(task("UserTask2", pi));
complete(task("UserTask1", pi));
complete(task("UserTask2", pi));
assertThat(pi)
.hasPassed("EndEvent")
.hasPassedInOrder("EndEventEscalated", "EndEventEscalated");
}
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:18,代码来源:BoundaryEscalationEventTriggeredTwiceConventionalTest.java
示例15: testCompleteTask1First_Conventional
import org.camunda.bpm.engine.runtime.ProcessInstance; //导入依赖的package包/类
@Test @Ignore // In my mind should work, but does not work due to a Camunda NullpointerExecption
@Deployment(resources = {"org/camunda/bpm/scenario/test/escalations/EscalationEventSubProcessTriggeredTwiceIntermediateTest.bpmn"})
public void testCompleteTask1First_Conventional() {
ProcessInstance pi = rule.getRuntimeService()
.startProcessInstanceByKey("EscalationEventSubProcessTriggeredTwiceIntermediateTest");
complete(task("UserTask1", pi)); // --> Test Case fails here with a NullPointerException
List<Task> tasks = taskQuery().processInstanceId(pi.getId()).taskDefinitionKey("UserTask2").list();
complete(tasks.get(0)); // necessary as query returns two tasks at this point
complete(task("UserTask2", pi));
complete(task("UserTask3", pi));
assertThat(pi)
.hasPassed("EndEvent")
.hasPassedInOrder("EndEventEscalated", "EndEventEscalated");
}
开发者ID:camunda,项目名称:camunda-bpm-assert-scenario,代码行数:21,代码来源:EscalationEventSubProcessTriggeredTwiceIntermediateConventionalTest.java