use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceDto in project camunda-bpm-platform by camunda.
the class ProcessDefinitionResourceImpl method submitForm.
@Override
public ProcessInstanceDto submitForm(UriInfo context, StartProcessInstanceDto parameters) {
FormService formService = engine.getFormService();
ProcessInstance instance = null;
try {
Map<String, Object> variables = VariableValueDto.toMap(parameters.getVariables(), engine, objectMapper);
String businessKey = parameters.getBusinessKey();
if (businessKey != null) {
instance = formService.submitStartForm(processDefinitionId, businessKey, variables);
} else {
instance = formService.submitStartForm(processDefinitionId, variables);
}
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinitionId, e.getMessage());
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
} catch (RestException e) {
String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinitionId, e.getMessage());
throw new InvalidRequestException(e.getStatus(), e, errorMessage);
}
ProcessInstanceDto result = ProcessInstanceDto.fromProcessInstance(instance);
URI uri = context.getBaseUriBuilder().path(rootResourcePath).path(ProcessInstanceRestService.PATH).path(instance.getId()).build();
result.addReflexiveLink(uri, HttpMethod.GET, "self");
return result;
}
use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceDto in project camunda-bpm-platform by camunda.
the class ProcessDefinitionResourceImpl method startProcessInstance.
@Override
public ProcessInstanceDto startProcessInstance(UriInfo context, StartProcessInstanceDto parameters) {
ProcessInstanceWithVariables instance = null;
try {
instance = startProcessInstanceAtActivities(parameters);
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinitionId, e.getMessage());
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
} catch (RestException e) {
String errorMessage = String.format("Cannot instantiate process definition %s: %s", processDefinitionId, e.getMessage());
throw new InvalidRequestException(e.getStatus(), e, errorMessage);
}
ProcessInstanceDto result;
if (parameters.isWithVariablesInReturn()) {
result = ProcessInstanceWithVariablesDto.fromProcessInstance(instance);
} else {
result = ProcessInstanceDto.fromProcessInstance(instance);
}
URI uri = context.getBaseUriBuilder().path(rootResourcePath).path(ProcessInstanceRestService.PATH).path(instance.getId()).build();
result.addReflexiveLink(uri, HttpMethod.GET, "self");
return result;
}
use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceDto in project camunda-bpm-platform by camunda.
the class ProcessInstanceResourceImpl method getProcessInstance.
@Override
public ProcessInstanceDto getProcessInstance() {
RuntimeService runtimeService = engine.getRuntimeService();
ProcessInstance instance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
if (instance == null) {
throw new InvalidRequestException(Status.NOT_FOUND, "Process instance with id " + processInstanceId + " does not exist");
}
ProcessInstanceDto result = ProcessInstanceDto.fromProcessInstance(instance);
return result;
}
use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceDto in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceImpl method queryProcessInstances.
@Override
public List<ProcessInstanceDto> queryProcessInstances(ProcessInstanceQueryDto queryDto, Integer firstResult, Integer maxResults) {
ProcessEngine engine = getProcessEngine();
queryDto.setObjectMapper(getObjectMapper());
ProcessInstanceQuery query = queryDto.toQuery(engine);
List<ProcessInstance> matchingInstances;
if (firstResult != null || maxResults != null) {
matchingInstances = executePaginatedQuery(query, firstResult, maxResults);
} else {
matchingInstances = query.list();
}
List<ProcessInstanceDto> instanceResults = new ArrayList<ProcessInstanceDto>();
for (ProcessInstance instance : matchingInstances) {
ProcessInstanceDto resultInstance = ProcessInstanceDto.fromProcessInstance(instance);
instanceResults.add(resultInstance);
}
return instanceResults;
}
use of org.camunda.bpm.engine.rest.dto.runtime.ProcessInstanceDto in project camunda-bpm-platform by camunda.
the class ConditionRestServiceImpl method evaluateCondition.
@Override
public List<ProcessInstanceDto> evaluateCondition(EvaluationConditionDto conditionDto) {
if (conditionDto.getTenantId() != null && conditionDto.isWithoutTenantId()) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Parameter 'tenantId' cannot be used together with parameter 'withoutTenantId'.");
}
ConditionEvaluationBuilder builder = createConditionEvaluationBuilder(conditionDto);
List<ProcessInstance> processInstances = builder.evaluateStartConditions();
List<ProcessInstanceDto> result = new ArrayList<ProcessInstanceDto>();
for (ProcessInstance processInstance : processInstances) {
result.add(ProcessInstanceDto.fromProcessInstance(processInstance));
}
return result;
}
Aggregations