Search in sources :

Example 1 with Variable

use of org.alfresco.rest.workflow.api.model.Variable in project alfresco-remote-api by Alfresco.

the class ProcessesImpl method getVariables.

@Override
public CollectionWithPagingInfo<Variable> getVariables(String processId, Paging paging) {
    CollectionWithPagingInfo<Variable> result = null;
    // Check if user is allowed to get variables
    List<HistoricVariableInstance> variableInstances = validateIfUserAllowedToWorkWithProcess(processId);
    Map<String, Object> variables = new HashMap<String, Object>();
    for (HistoricVariableInstance variable : variableInstances) {
        variables.put(variable.getVariableName(), variable.getValue());
    }
    ProcessInstance processInstance = activitiProcessEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processId).singleResult();
    String processDefinitionId = null;
    if (processInstance != null) {
        processDefinitionId = processInstance.getProcessDefinitionId();
    } else {
        // Completed process instance
        HistoricProcessInstance historicInstance = activitiProcessEngine.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(processId).singleResult();
        if (historicInstance == null) {
            throw new EntityNotFoundException(processId);
        }
        processDefinitionId = historicInstance.getProcessDefinitionId();
    }
    // Get start-task definition for explicit typing of variables submitted at the start
    String formKey = null;
    StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(processDefinitionId);
    if (startFormData != null) {
        formKey = startFormData.getFormKey();
    }
    TypeDefinition startTaskTypeDefinition = getWorkflowFactory().getTaskFullTypeDefinition(formKey, true);
    // Convert raw variables to Variable objects
    List<Variable> resultingVariables = restVariableHelper.getVariables(variables, startTaskTypeDefinition);
    result = CollectionWithPagingInfo.asPaged(paging, resultingVariables);
    return result;
}
Also used : Variable(org.alfresco.rest.workflow.api.model.Variable) HashMap(java.util.HashMap) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition) StartFormData(org.activiti.engine.form.StartFormData) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance)

Example 2 with Variable

use of org.alfresco.rest.workflow.api.model.Variable in project alfresco-remote-api by Alfresco.

the class ProcessesImpl method getProcesses.

@Override
public CollectionWithPagingInfo<ProcessInfo> getProcesses(Parameters parameters) {
    Paging paging = parameters.getPaging();
    MapBasedQueryWalker propertyWalker = new MapBasedQueryWalker(PROCESS_COLLECTION_EQUALS_QUERY_PROPERTIES, null);
    propertyWalker.setSupportedGreaterThanParameters(PROCESS_COLLECTION_GREATERTHAN_QUERY_PROPERTIES);
    propertyWalker.setSupportedLessThanParameters(PROCESS_COLLECTION_LESSTHAN_QUERY_PROPERTIES);
    propertyWalker.enableVariablesSupport(namespaceService, dictionaryService);
    if (parameters.getQuery() != null) {
        QueryHelper.walk(parameters.getQuery(), propertyWalker);
    }
    String status = propertyWalker.getProperty("status", WhereClauseParser.EQUALS);
    String processDefinitionId = propertyWalker.getProperty("processDefinitionId", WhereClauseParser.EQUALS);
    String businessKey = propertyWalker.getProperty("businessKey", WhereClauseParser.EQUALS);
    String processDefinitionKey = propertyWalker.getProperty("processDefinitionKey", WhereClauseParser.EQUALS);
    String startUserId = propertyWalker.getProperty("startUserId", WhereClauseParser.EQUALS);
    Date startedAtGreaterThan = propertyWalker.getProperty("startedAt", WhereClauseParser.GREATERTHAN, Date.class);
    Date startedAtLessThan = propertyWalker.getProperty("startedAt", WhereClauseParser.LESSTHAN, Date.class);
    Date endedAtGreaterThan = propertyWalker.getProperty("endedAt", WhereClauseParser.GREATERTHAN, Date.class);
    Date endedAtLessThan = propertyWalker.getProperty("endedAt", WhereClauseParser.LESSTHAN, Date.class);
    Boolean includeVariables = propertyWalker.getProperty("includeVariables", WhereClauseParser.EQUALS, Boolean.class);
    if (status != null && PROCESS_STATUS_LIST.contains(status) == false) {
        throw new InvalidArgumentException("Invalid status parameter: " + status);
    }
    List<SortColumn> sortList = parameters.getSorting();
    SortColumn sortColumn = null;
    if (sortList != null && sortList.size() > 0) {
        if (sortList.size() != 1) {
            throw new InvalidArgumentException("Only one order by parameter is supported");
        }
        sortColumn = sortList.get(0);
    }
    final HistoricProcessInstanceQuery query = activitiProcessEngine.getHistoryService().createHistoricProcessInstanceQuery();
    if (processDefinitionId != null)
        query.processDefinitionId(processDefinitionId);
    if (businessKey != null)
        query.processInstanceBusinessKey(businessKey);
    if (processDefinitionKey != null) {
        if (tenantService.isEnabled() && deployWorkflowsInTenant) {
            if (processDefinitionKey.startsWith("@" + TenantUtil.getCurrentDomain() + "@")) {
                query.processDefinitionKey(processDefinitionKey);
            } else {
                query.processDefinitionKey("@" + TenantUtil.getCurrentDomain() + "@" + processDefinitionKey);
            }
        } else {
            query.processDefinitionKey(processDefinitionKey);
        }
    }
    if (startUserId != null)
        query.startedBy(startUserId);
    if (startedAtGreaterThan != null)
        query.startedAfter(startedAtGreaterThan);
    if (startedAtLessThan != null)
        query.startedBefore(startedAtLessThan);
    if (endedAtGreaterThan != null)
        query.finishedAfter(endedAtGreaterThan);
    if (endedAtLessThan != null)
        query.finishedBefore(endedAtLessThan);
    if (status == null || PROCESS_STATUS_ACTIVE.equals(status)) {
        query.unfinished();
    } else if (PROCESS_STATUS_COMPLETED.equals(status)) {
        query.finished();
        query.notDeleted();
    } else if (PROCESS_STATUS_DELETED.equals(status)) {
        query.deleted();
    }
    if (includeVariables != null && includeVariables) {
        query.includeProcessVariables();
    }
    List<QueryVariableHolder> variableProperties = propertyWalker.getVariableProperties();
    if (variableProperties != null) {
        for (QueryVariableHolder queryVariableHolder : variableProperties) {
            if (queryVariableHolder.getOperator() == WhereClauseParser.EQUALS) {
                query.variableValueEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
            } else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHAN) {
                query.variableValueGreaterThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
            } else if (queryVariableHolder.getOperator() == WhereClauseParser.GREATERTHANOREQUALS) {
                query.variableValueGreaterThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
            } else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHAN) {
                query.variableValueLessThan(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
            } else if (queryVariableHolder.getOperator() == WhereClauseParser.LESSTHANOREQUALS) {
                query.variableValueLessThanOrEqual(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
            } else if (queryVariableHolder.getOperator() == WhereClauseParser.MATCHES) {
                if (queryVariableHolder.getPropertyValue() instanceof String == false) {
                    throw new InvalidArgumentException("the matches operator can only be used with a String value for property " + queryVariableHolder.getPropertyName());
                }
                if (((String) queryVariableHolder.getPropertyValue()).startsWith("(?i)")) {
                    query.variableValueLikeIgnoreCase(queryVariableHolder.getPropertyName(), ((String) queryVariableHolder.getPropertyValue()).substring("(?i)".length()).toLowerCase());
                } else {
                    query.variableValueLike(queryVariableHolder.getPropertyName(), (String) queryVariableHolder.getPropertyValue());
                }
            } else if (queryVariableHolder.getOperator() == WhereClauseParser.NEGATION) {
                query.variableValueNotEquals(queryVariableHolder.getPropertyName(), queryVariableHolder.getPropertyValue());
            } else {
                throw new InvalidArgumentException("variable " + queryVariableHolder.getPropertyName() + " can only be used with an =, >, >=, <=, <, not, matches comparison type");
            }
        }
    }
    if (authorityService.isAdminAuthority(AuthenticationUtil.getRunAsUser())) {
        // Admin is allowed to read all processes in the current tenant
        if (tenantService.isEnabled()) {
            query.variableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
        }
    } else {
        // If non-admin user, involvement in the process is required (either owner, assignee or externally involved).
        query.involvedUser(AuthenticationUtil.getRunAsUser());
    }
    if (sortColumn != null) {
        if (PROCESS_COLLECTION_SORT_PROPERTIES.contains(sortColumn.column)) {
            if ("processDefinitionId".equalsIgnoreCase(sortColumn.column)) {
                query.orderByProcessDefinitionId();
            } else if ("id".equalsIgnoreCase(sortColumn.column)) {
                query.orderByProcessInstanceId();
            } else if ("businessKey".equalsIgnoreCase(sortColumn.column)) {
                query.orderByProcessInstanceBusinessKey();
            } else if ("startedAt".equalsIgnoreCase(sortColumn.column)) {
                query.orderByProcessInstanceStartTime();
            } else if ("endedAt".equalsIgnoreCase(sortColumn.column)) {
                query.orderByProcessInstanceEndTime();
            } else if ("durationInMillis".equalsIgnoreCase(sortColumn.column)) {
                query.orderByProcessInstanceDuration();
            }
        } else {
            throw new InvalidArgumentException("sort " + sortColumn.column + " is not supported, supported items are " + Arrays.toString(PROCESS_COLLECTION_SORT_PROPERTIES.toArray()));
        }
        if (sortColumn.asc) {
            query.asc();
        } else {
            query.desc();
        }
    } else {
        query.orderByProcessInstanceStartTime().desc();
    }
    List<HistoricProcessInstance> processInstances = query.listPage(paging.getSkipCount(), paging.getMaxItems());
    int totalCount = (int) query.count();
    List<ProcessInfo> page = new ArrayList<ProcessInfo>(processInstances.size());
    Map<String, TypeDefinition> definitionTypeMap = new HashMap<String, TypeDefinition>();
    for (HistoricProcessInstance processInstance : processInstances) {
        ProcessInfo processInfo = createProcessInfo(processInstance);
        if (includeVariables != null && includeVariables) {
            if (definitionTypeMap.containsKey(processInfo.getProcessDefinitionId()) == false) {
                StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(processInfo.getProcessDefinitionId());
                if (startFormData != null) {
                    String formKey = startFormData.getFormKey();
                    definitionTypeMap.put(processInfo.getProcessDefinitionId(), getWorkflowFactory().getTaskFullTypeDefinition(formKey, true));
                }
            }
            if (definitionTypeMap.containsKey(processInfo.getProcessDefinitionId())) {
                // Convert raw variables to Variable objects
                List<Variable> resultingVariables = restVariableHelper.getVariables(processInstance.getProcessVariables(), definitionTypeMap.get(processInfo.getProcessDefinitionId()));
                processInfo.setProcessVariables(resultingVariables);
            }
        }
        page.add(processInfo);
    }
    return CollectionWithPagingInfo.asPaged(paging, page, (page.size() + paging.getSkipCount()) < totalCount, totalCount);
}
Also used : Variable(org.alfresco.rest.workflow.api.model.Variable) HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HashMap(java.util.HashMap) Paging(org.alfresco.rest.framework.resource.parameters.Paging) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) ArrayList(java.util.ArrayList) QueryVariableHolder(org.alfresco.rest.workflow.api.impl.MapBasedQueryWalker.QueryVariableHolder) ProcessInfo(org.alfresco.rest.workflow.api.model.ProcessInfo) SortColumn(org.alfresco.rest.framework.resource.parameters.SortColumn) Date(java.util.Date) TypeDefinition(org.alfresco.service.cmr.dictionary.TypeDefinition) DataTypeDefinition(org.alfresco.service.cmr.dictionary.DataTypeDefinition) InvalidArgumentException(org.alfresco.rest.framework.core.exceptions.InvalidArgumentException) StartFormData(org.activiti.engine.form.StartFormData)

Example 3 with Variable

use of org.alfresco.rest.workflow.api.model.Variable in project alfresco-remote-api by Alfresco.

the class ProcessesParser method parseEntry.

@SuppressWarnings("unchecked")
@Override
public ProcessInfo parseEntry(JSONObject entry) {
    ProcessInfo processesRest = new ProcessInfo();
    processesRest.setId((String) entry.get("id"));
    processesRest.setProcessDefinitionId((String) entry.get("processDefinitionId"));
    processesRest.setProcessDefinitionKey((String) entry.get("processDefinitionKey"));
    processesRest.setStartedAt(WorkflowApiClient.parseDate(entry, "startedAt"));
    processesRest.setEndedAt(WorkflowApiClient.parseDate(entry, "endedAt"));
    processesRest.setDurationInMs((Long) entry.get("durationInMs"));
    processesRest.setDeleteReason((String) entry.get("deleteReason"));
    processesRest.setBusinessKey((String) entry.get("businessKey"));
    processesRest.setSuperProcessInstanceId((String) entry.get("superProcessInstanceId"));
    processesRest.setStartActivityId((String) entry.get("startActivityId"));
    processesRest.setStartUserId((String) entry.get("startUserId"));
    processesRest.setEndActivityId((String) entry.get("endActivityId"));
    processesRest.setCompleted((Boolean) entry.get("completed"));
    processesRest.setVariables((Map<String, Object>) entry.get("variables"));
    processesRest.setItems((Set<String>) entry.get("item"));
    if (entry.get("processVariables") != null) {
        List<Variable> processVariables = new ArrayList<Variable>();
        JSONArray variables = (JSONArray) entry.get("processVariables");
        for (int i = 0; i < variables.size(); i++) {
            JSONObject variableJSON = (JSONObject) variables.get(i);
            Variable variable = new Variable();
            variable.setName((String) variableJSON.get("name"));
            variable.setType((String) variableJSON.get("type"));
            variable.setValue(variableJSON.get("value"));
            processVariables.add(variable);
        }
        processesRest.setProcessVariables(processVariables);
    }
    return processesRest;
}
Also used : Variable(org.alfresco.rest.workflow.api.model.Variable) JSONObject(org.json.simple.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.json.simple.JSONArray) JSONObject(org.json.simple.JSONObject) ProcessInfo(org.alfresco.rest.workflow.api.model.ProcessInfo)

Example 4 with Variable

use of org.alfresco.rest.workflow.api.model.Variable in project alfresco-remote-api by Alfresco.

the class ProcessWorkflowApiTest method testGetProcessInstances.

@Test
public void testGetProcessInstances() throws Exception {
    final RequestContext requestContext = initApiClientWithTestUser();
    final ProcessInfo process1 = startAdhocProcess(requestContext, null);
    final ProcessInfo process2 = startAdhocProcess(requestContext, null);
    final ProcessInfo process3 = startAdhocProcess(requestContext, null);
    try {
        ProcessesClient processesClient = publicApiClient.processesClient();
        Map<String, String> paramMap = new HashMap<String, String>();
        ListResponse<ProcessInfo> processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(3, processList.getList().size());
        Map<String, ProcessInfo> processMap = new HashMap<String, ProcessInfo>();
        for (ProcessInfo processRest : processList.getList()) {
            processMap.put(processRest.getId(), processRest);
        }
        assertTrue(processMap.containsKey(process1.getId()));
        assertTrue(processMap.containsKey(process2.getId()));
        assertTrue(processMap.containsKey(process3.getId()));
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(3, processList.getList().size());
        assertNull(processList.getList().get(0).getProcessVariables());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc2')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(0, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc')");
        paramMap.put("maxItems", "2");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(2, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc')");
        paramMap.put("maxItems", "3");
        paramMap.put("skipCount", "1");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(2, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc')");
        paramMap.put("maxItems", "5");
        paramMap.put("skipCount", "2");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(1, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc')");
        paramMap.put("maxItems", "5");
        paramMap.put("skipCount", "5");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(0, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(status = 'completed')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(0, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(status = 'any')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(3, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(status = 'active')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(3, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(status = 'active2')");
        try {
            processList = processesClient.getProcesses(paramMap);
            fail();
        } catch (PublicApiException e) {
        // expected exception
        }
        // Test the variable where-clause
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(variables/bpm_priority = 'd_int 1')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(3, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(variables/bpm_priority = 'd:int 1')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(3, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(variables/bpm_priority > 'd:int 1')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(0, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(variables/bpm_priority >= 'd:int 1')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(3, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(variables/bpm_priority < 'd:int 5')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(3, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(variables/bpm_priority <= 'd:int 4')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(3, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(variables/bpm_priority = 'd_int 5')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(0, processList.getList().size());
        // test with date variable
        Calendar dateCal = Calendar.getInstance();
        Map<String, Object> variablesToSet = new HashMap<String, Object>();
        variablesToSet.put("testVarDate", dateCal.getTime());
        activitiProcessEngine.getRuntimeService().setVariables(process1.getId(), variablesToSet);
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(variables/testVarDate = 'd_datetime " + ISO8601DateFormat.format(dateCal.getTime()) + "')");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(1, processList.getList().size());
        // include process variables as well
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(includeVariables=true)");
        paramMap.put("maxItems", "1");
        paramMap.put("skipCount", "0");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(1, processList.getList().size());
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc' AND includeVariables = true)");
        paramMap.put("maxItems", "1");
        paramMap.put("skipCount", "0");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(1, processList.getList().size());
        ProcessInfo processInfo = processList.getList().get(0);
        assertNotNull(processInfo.getProcessVariables());
        boolean foundDescription = false;
        boolean foundAssignee = false;
        for (Variable variable : processInfo.getProcessVariables()) {
            if ("bpm_description".equals(variable.getName())) {
                assertEquals("d:text", variable.getType());
                assertNull(variable.getValue());
                foundDescription = true;
            } else if ("bpm_assignee".equals(variable.getName())) {
                assertEquals("cm:person", variable.getType());
                assertEquals(requestContext.getRunAsUser(), variable.getValue());
                foundAssignee = true;
            }
        }
        assertTrue(foundDescription);
        assertTrue(foundAssignee);
        // include process variables with paging
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc' AND includeVariables = true)");
        paramMap.put("maxItems", "3");
        paramMap.put("skipCount", "1");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(2, processList.getList().size());
        processInfo = processList.getList().get(0);
        assertNotNull(processInfo.getProcessVariables());
        foundDescription = false;
        foundAssignee = false;
        for (Variable variable : processInfo.getProcessVariables()) {
            if ("bpm_description".equals(variable.getName())) {
                assertEquals("d:text", variable.getType());
                assertNull(variable.getValue());
                foundDescription = true;
            } else if ("bpm_assignee".equals(variable.getName())) {
                assertEquals("cm:person", variable.getType());
                assertEquals(requestContext.getRunAsUser(), variable.getValue());
                foundAssignee = true;
            }
        }
        assertTrue(foundDescription);
        assertTrue(foundAssignee);
        // include process variables with paging outside boundaries
        paramMap = new HashMap<String, String>();
        paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc' AND includeVariables = true)");
        paramMap.put("maxItems", "4");
        paramMap.put("skipCount", "5");
        processList = processesClient.getProcesses(paramMap);
        assertNotNull(processList);
        assertEquals(0, processList.getList().size());
    } finally {
        cleanupProcessInstance(process1.getId(), process2.getId(), process3.getId());
    }
}
Also used : ProcessesClient(org.alfresco.rest.workflow.api.tests.WorkflowApiClient.ProcessesClient) Variable(org.alfresco.rest.workflow.api.model.Variable) HashMap(java.util.HashMap) Calendar(java.util.Calendar) ProcessInfo(org.alfresco.rest.workflow.api.model.ProcessInfo) PublicApiException(org.alfresco.rest.api.tests.client.PublicApiException) JSONObject(org.json.simple.JSONObject) RequestContext(org.alfresco.rest.api.tests.client.RequestContext) Test(org.junit.Test)

Example 5 with Variable

use of org.alfresco.rest.workflow.api.model.Variable in project alfresco-remote-api by Alfresco.

the class ProcessesImpl method updateVariables.

@Override
public List<Variable> updateVariables(String processId, List<Variable> variables) {
    validateIfUserAllowedToWorkWithProcess(processId);
    ProcessInstance processInstance = activitiProcessEngine.getRuntimeService().createProcessInstanceQuery().processInstanceId(processId).singleResult();
    if (processInstance == null) {
        throw new EntityNotFoundException(processId);
    }
    List<Variable> updatedVariables = new ArrayList<Variable>();
    if (variables != null) {
        for (Variable variable : variables) {
            updatedVariables.add(updateVariableInProcess(processId, processInstance.getProcessDefinitionId(), variable));
        }
    }
    return updatedVariables;
}
Also used : Variable(org.alfresco.rest.workflow.api.model.Variable) ArrayList(java.util.ArrayList) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) EntityNotFoundException(org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)

Aggregations

Variable (org.alfresco.rest.workflow.api.model.Variable)7 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 StartFormData (org.activiti.engine.form.StartFormData)3 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)3 ProcessInfo (org.alfresco.rest.workflow.api.model.ProcessInfo)3 DataTypeDefinition (org.alfresco.service.cmr.dictionary.DataTypeDefinition)3 TypeDefinition (org.alfresco.service.cmr.dictionary.TypeDefinition)3 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)2 EntityNotFoundException (org.alfresco.rest.framework.core.exceptions.EntityNotFoundException)2 InvalidArgumentException (org.alfresco.rest.framework.core.exceptions.InvalidArgumentException)2 JSONObject (org.json.simple.JSONObject)2 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)1 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)1 ActivitiScriptNode (org.alfresco.repo.workflow.activiti.ActivitiScriptNode)1 PublicApiException (org.alfresco.rest.api.tests.client.PublicApiException)1 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)1 Paging (org.alfresco.rest.framework.resource.parameters.Paging)1