Search in sources :

Example 1 with ProcessInstanceResponse

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;
}
Also used : HistoricProcessInstanceResponse(org.activiti.rest.service.api.history.HistoricProcessInstanceResponse) ProcessInstanceResponse(org.activiti.rest.service.api.runtime.process.ProcessInstanceResponse)

Example 2 with ProcessInstanceResponse

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;
}
Also used : HistoricProcessInstanceResponse(org.activiti.rest.service.api.history.HistoricProcessInstanceResponse) ProcessInstanceResponse(org.activiti.rest.service.api.runtime.process.ProcessInstanceResponse) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance)

Example 3 with ProcessInstanceResponse

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;
}
Also used : HistoricProcessInstanceResponse(org.activiti.rest.service.api.history.HistoricProcessInstanceResponse) ProcessInstanceResponse(org.activiti.rest.service.api.runtime.process.ProcessInstanceResponse) ArrayList(java.util.ArrayList) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Aggregations

HistoricProcessInstanceResponse (org.activiti.rest.service.api.history.HistoricProcessInstanceResponse)3 ProcessInstanceResponse (org.activiti.rest.service.api.runtime.process.ProcessInstanceResponse)3 ArrayList (java.util.ArrayList)1 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)1 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1