Search in sources :

Example 11 with ProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class MigrationRestServiceImpl method createMigrationPlanExecutionBuilder.

protected MigrationPlanExecutionBuilder createMigrationPlanExecutionBuilder(MigrationExecutionDto migrationExecution) {
    MigrationPlan migrationPlan = createMigrationPlan(migrationExecution.getMigrationPlan());
    List<String> processInstanceIds = migrationExecution.getProcessInstanceIds();
    MigrationPlanExecutionBuilder executionBuilder = processEngine.getRuntimeService().newMigration(migrationPlan).processInstanceIds(processInstanceIds);
    ProcessInstanceQueryDto processInstanceQueryDto = migrationExecution.getProcessInstanceQuery();
    if (processInstanceQueryDto != null) {
        ProcessInstanceQuery processInstanceQuery = processInstanceQueryDto.toQuery(getProcessEngine());
        executionBuilder.processInstanceQuery(processInstanceQuery);
    }
    if (migrationExecution.isSkipCustomListeners()) {
        executionBuilder.skipCustomListeners();
    }
    if (migrationExecution.isSkipIoMappings()) {
        executionBuilder.skipIoMappings();
    }
    return executionBuilder;
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) MigrationPlanExecutionBuilder(org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto)

Example 12 with ProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ModificationRestServiceImpl method createModificationBuilder.

private ModificationBuilder createModificationBuilder(ModificationDto dto) {
    ModificationBuilder builder = getProcessEngine().getRuntimeService().createModification(dto.getProcessDefinitionId());
    if (dto.getInstructions() != null && !dto.getInstructions().isEmpty()) {
        dto.applyTo(builder, getProcessEngine(), objectMapper);
    }
    List<String> processInstanceIds = dto.getProcessInstanceIds();
    builder.processInstanceIds(processInstanceIds);
    ProcessInstanceQueryDto processInstanceQueryDto = dto.getProcessInstanceQuery();
    if (processInstanceQueryDto != null) {
        ProcessInstanceQuery processInstanceQuery = processInstanceQueryDto.toQuery(getProcessEngine());
        builder.processInstanceQuery(processInstanceQuery);
    }
    if (dto.isSkipCustomListeners()) {
        builder.skipCustomListeners();
    }
    if (dto.isSkipIoMappings()) {
        builder.skipIoMappings();
    }
    return builder;
}
Also used : ProcessInstanceQuery(org.camunda.bpm.engine.runtime.ProcessInstanceQuery) ModificationBuilder(org.camunda.bpm.engine.runtime.ModificationBuilder) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto)

Example 13 with ProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ModificationRestServiceInteractionTest method executeModificationWithValidProcessInstanceQuerySync.

@Test
public void executeModificationWithValidProcessInstanceQuerySync() {
    when(runtimeServiceMock.createProcessInstanceQuery()).thenReturn(new ProcessInstanceQueryImpl());
    Map<String, Object> json = new HashMap<String, Object>();
    List<Map<String, Object>> instructions = new ArrayList<Map<String, Object>>();
    instructions.add(ModificationInstructionBuilder.startAfter().activityId("activityId").getJson());
    json.put("processDefinitionId", "processDefinitionId");
    ProcessInstanceQueryDto processInstanceQueryDto = new ProcessInstanceQueryDto();
    processInstanceQueryDto.setBusinessKey("foo");
    json.put("processInstanceQuery", processInstanceQueryDto);
    json.put("instructions", instructions);
    given().contentType(ContentType.JSON).body(json).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().post(EXECUTE_MODIFICATION_SYNC_URL);
    verify(runtimeServiceMock, times(1)).createProcessInstanceQuery();
    verify(modificationBuilderMock).startAfterActivity("activityId");
    verify(modificationBuilderMock).processInstanceQuery(processInstanceQueryDto.toQuery(processEngine));
    verify(modificationBuilderMock).execute();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ProcessInstanceQueryImpl(org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl) Matchers.anyString(org.mockito.Matchers.anyString) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 14 with ProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSuspendInstancesMultipleGroupOperations.

@Test
public void testSuspendInstancesMultipleGroupOperations() {
    List<String> ids = Arrays.asList(MockProvider.EXAMPLE_PROCESS_INSTANCE_ID);
    ProcessInstanceQueryDto query = new ProcessInstanceQueryDto();
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put("processInstanceIds", ids);
    messageBodyJson.put("processInstanceQuery", query);
    messageBodyJson.put("suspended", true);
    given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(PROCESS_INSTANCE_SUSPENDED_URL);
    verify(mockUpdateSuspensionStateSelectBuilder).byProcessInstanceIds(ids);
    verify(mockUpdateProcessInstancesSuspensionStateBuilder).byProcessInstanceQuery(query.toQuery(processEngine));
    verify(mockUpdateProcessInstancesSuspensionStateBuilder).suspend();
}
Also used : HashMap(java.util.HashMap) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) Test(org.junit.Test)

Example 15 with ProcessInstanceQueryDto

use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto in project camunda-bpm-platform by camunda.

the class ProcessInstanceRestServiceInteractionTest method testSuspendAsyncWithProcessInstanceQuery.

@Test
public void testSuspendAsyncWithProcessInstanceQuery() {
    ProcessInstanceQueryDto query = new ProcessInstanceQueryDto();
    Map<String, Object> messageBodyJson = new HashMap<String, Object>();
    messageBodyJson.put("processInstanceQuery", query);
    messageBodyJson.put("suspended", true);
    when(mockUpdateProcessInstancesSuspensionStateBuilder.suspendAsync()).thenReturn(new BatchEntity());
    given().contentType(ContentType.JSON).body(messageBodyJson).then().expect().statusCode(Status.OK.getStatusCode()).when().post(PROCESS_INSTANCE_SUSPENDED_ASYNC_URL);
    verify(mockUpdateSuspensionStateSelectBuilder).byProcessInstanceQuery(query.toQuery(processEngine));
    verify(mockUpdateProcessInstancesSuspensionStateBuilder).suspendAsync();
}
Also used : HashMap(java.util.HashMap) BatchEntity(org.camunda.bpm.engine.impl.batch.BatchEntity) ExampleVariableObject(org.camunda.bpm.engine.rest.helper.ExampleVariableObject) ProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto) HistoricProcessInstanceQueryDto(org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto) Test(org.junit.Test)

Aggregations

ProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceQueryDto)19 Test (org.junit.Test)15 HashMap (java.util.HashMap)13 HistoricProcessInstanceQueryDto (org.camunda.bpm.engine.rest.dto.history.HistoricProcessInstanceQueryDto)10 Matchers.anyString (org.mockito.Matchers.anyString)9 ProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl)8 ExampleVariableObject (org.camunda.bpm.engine.rest.helper.ExampleVariableObject)7 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)6 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 HistoricProcessInstanceQuery (org.camunda.bpm.engine.history.HistoricProcessInstanceQuery)4 BatchEntity (org.camunda.bpm.engine.impl.batch.BatchEntity)4 HistoricProcessInstanceQueryImpl (org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl)2 MigrationExecutionDtoBuilder (org.camunda.bpm.engine.rest.util.migration.MigrationExecutionDtoBuilder)2 BadUserRequestException (org.camunda.bpm.engine.BadUserRequestException)1 ExternalTaskService (org.camunda.bpm.engine.ExternalTaskService)1 Batch (org.camunda.bpm.engine.batch.Batch)1 ExternalTaskQuery (org.camunda.bpm.engine.externaltask.ExternalTaskQuery)1 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)1 MigrationPlanExecutionBuilder (org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder)1