Search in sources :

Example 1 with UpdateProcessInstancesSuspensionStateBuilder

use of org.camunda.bpm.engine.runtime.UpdateProcessInstancesSuspensionStateBuilder in project camunda-bpm-platform by camunda.

the class ProcessInstanceSuspensionStateDto method updateSuspensionStateAsync.

public Batch updateSuspensionStateAsync(ProcessEngine engine) {
    int params = parameterCount(processInstanceIds, processInstanceQuery, historicProcessInstanceQuery);
    if (params == 0) {
        String message = "Either processInstanceIds, processInstanceQuery or historicProcessInstanceQuery should be set to update the suspension state.";
        throw new InvalidRequestException(Status.BAD_REQUEST, message);
    }
    UpdateProcessInstancesSuspensionStateBuilder updateSuspensionStateBuilder = createUpdateSuspensionStateGroupBuilder(engine);
    if (getSuspended()) {
        return updateSuspensionStateBuilder.suspendAsync();
    } else {
        return updateSuspensionStateBuilder.activateAsync();
    }
}
Also used : UpdateProcessInstancesSuspensionStateBuilder(org.camunda.bpm.engine.runtime.UpdateProcessInstancesSuspensionStateBuilder) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException)

Example 2 with UpdateProcessInstancesSuspensionStateBuilder

use of org.camunda.bpm.engine.runtime.UpdateProcessInstancesSuspensionStateBuilder in project camunda-bpm-platform by camunda.

the class ProcessInstanceSuspensionStateDto method createUpdateSuspensionStateGroupBuilder.

protected UpdateProcessInstancesSuspensionStateBuilder createUpdateSuspensionStateGroupBuilder(ProcessEngine engine) {
    UpdateProcessInstanceSuspensionStateSelectBuilder selectBuilder = engine.getRuntimeService().updateProcessInstanceSuspensionState();
    UpdateProcessInstancesSuspensionStateBuilder groupBuilder = null;
    if (processInstanceIds != null) {
        groupBuilder = selectBuilder.byProcessInstanceIds(processInstanceIds);
    }
    if (processInstanceQuery != null) {
        if (groupBuilder == null) {
            groupBuilder = selectBuilder.byProcessInstanceQuery(processInstanceQuery.toQuery(engine));
        } else {
            groupBuilder.byProcessInstanceQuery(processInstanceQuery.toQuery(engine));
        }
    }
    if (historicProcessInstanceQuery != null) {
        if (groupBuilder == null) {
            groupBuilder = selectBuilder.byHistoricProcessInstanceQuery(historicProcessInstanceQuery.toQuery(engine));
        } else {
            groupBuilder.byHistoricProcessInstanceQuery(historicProcessInstanceQuery.toQuery(engine));
        }
    }
    return groupBuilder;
}
Also used : UpdateProcessInstancesSuspensionStateBuilder(org.camunda.bpm.engine.runtime.UpdateProcessInstancesSuspensionStateBuilder) UpdateProcessInstanceSuspensionStateSelectBuilder(org.camunda.bpm.engine.runtime.UpdateProcessInstanceSuspensionStateSelectBuilder)

Aggregations

UpdateProcessInstancesSuspensionStateBuilder (org.camunda.bpm.engine.runtime.UpdateProcessInstancesSuspensionStateBuilder)2 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 UpdateProcessInstanceSuspensionStateSelectBuilder (org.camunda.bpm.engine.runtime.UpdateProcessInstanceSuspensionStateSelectBuilder)1