use of org.activiti.rest.service.api.runtime.process.ProcessInstanceResponse in project Activiti by Activiti.
the class RestResponseFactory method createProcessInstanceResponse.
public ProcessInstanceResponse createProcessInstanceResponse(ProcessInstance processInstance, RestUrlBuilder urlBuilder) {
ProcessInstanceResponse result = new ProcessInstanceResponse();
result.setActivityId(processInstance.getActivityId());
result.setBusinessKey(processInstance.getBusinessKey());
result.setId(processInstance.getId());
result.setName(processInstance.getName());
result.setProcessDefinitionId(processInstance.getProcessDefinitionId());
result.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, processInstance.getProcessDefinitionId()));
result.setProcessDefinitionKey(processInstance.getProcessDefinitionKey());
result.setEnded(processInstance.isEnded());
result.setSuspended(processInstance.isSuspended());
result.setUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE, processInstance.getId()));
result.setTenantId(processInstance.getTenantId());
//Added by Ryan Johnston
if (processInstance.isEnded()) {
//Process complete. Note the same in the result.
result.setCompleted(true);
} else {
//Process not complete. Note the same in the result.
result.setCompleted(false);
}
if (processInstance.getProcessVariables() != null) {
Map<String, Object> variableMap = processInstance.getProcessVariables();
for (String name : variableMap.keySet()) {
result.addVariable(createRestVariable(name, variableMap.get(name), RestVariableScope.LOCAL, processInstance.getId(), VARIABLE_PROCESS, false, urlBuilder));
}
}
return result;
}
use of org.activiti.rest.service.api.runtime.process.ProcessInstanceResponse in project Activiti by Activiti.
the class RestResponseFactory method createProcessInstanceResponse.
public ProcessInstanceResponse createProcessInstanceResponse(ProcessInstance processInstance, boolean returnVariables, Map<String, Object> runtimeVariableMap, List<HistoricVariableInstance> historicVariableList) {
RestUrlBuilder urlBuilder = createUrlBuilder();
ProcessInstanceResponse result = new ProcessInstanceResponse();
result.setActivityId(processInstance.getActivityId());
result.setBusinessKey(processInstance.getBusinessKey());
result.setId(processInstance.getId());
result.setName(processInstance.getName());
result.setProcessDefinitionId(processInstance.getProcessDefinitionId());
result.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, processInstance.getProcessDefinitionId()));
result.setProcessDefinitionKey(processInstance.getProcessDefinitionKey());
result.setEnded(processInstance.isEnded());
result.setSuspended(processInstance.isSuspended());
result.setUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE, processInstance.getId()));
result.setTenantId(processInstance.getTenantId());
//Added by Ryan Johnston
if (processInstance.isEnded()) {
//Process complete. Note the same in the result.
result.setCompleted(true);
} else {
//Process not complete. Note the same in the result.
result.setCompleted(false);
}
if (returnVariables) {
if (processInstance.isEnded()) {
if (historicVariableList != null) {
for (HistoricVariableInstance historicVariable : historicVariableList) {
result.addVariable(createRestVariable(historicVariable.getVariableName(), historicVariable.getValue(), RestVariableScope.LOCAL, processInstance.getId(), VARIABLE_PROCESS, false, urlBuilder));
}
}
} else {
if (runtimeVariableMap != null) {
for (String name : runtimeVariableMap.keySet()) {
result.addVariable(createRestVariable(name, runtimeVariableMap.get(name), RestVariableScope.LOCAL, processInstance.getId(), VARIABLE_PROCESS, false, urlBuilder));
}
}
}
}
return result;
}
use of org.activiti.rest.service.api.runtime.process.ProcessInstanceResponse in project Activiti by Activiti.
the class RestResponseFactory method createProcessInstanceResponseList.
public List<ProcessInstanceResponse> createProcessInstanceResponseList(List<ProcessInstance> processInstances) {
RestUrlBuilder urlBuilder = createUrlBuilder();
List<ProcessInstanceResponse> responseList = new ArrayList<ProcessInstanceResponse>();
for (ProcessInstance instance : processInstances) {
responseList.add(createProcessInstanceResponse(instance, urlBuilder));
}
return responseList;
}
Aggregations