Search in sources :

Example 11 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.

the class TaskDetailPanel method initProcessLink.

protected void initProcessLink() {
    if (task.getProcessInstanceId() != null) {
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
        Button showProcessInstanceButton = new Button(i18nManager.getMessage(Messages.TASK_PART_OF_PROCESS, getProcessDisplayName(processDefinition)));
        showProcessInstanceButton.addStyleName(Reindeer.BUTTON_LINK);
        showProcessInstanceButton.addListener(new ClickListener() {

            public void buttonClick(ClickEvent event) {
                viewManager.showMyProcessInstancesPage(task.getProcessInstanceId());
            }
        });
        centralLayout.addComponent(showProcessInstanceButton);
        addEmptySpace(centralLayout);
    }
}
Also used : Button(com.vaadin.ui.Button) LayoutClickEvent(com.vaadin.event.LayoutEvents.LayoutClickEvent) ClickEvent(com.vaadin.ui.Button.ClickEvent) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ClickListener(com.vaadin.ui.Button.ClickListener) LayoutClickListener(com.vaadin.event.LayoutEvents.LayoutClickListener) ClaimTaskClickListener(org.activiti.explorer.ui.task.listener.ClaimTaskClickListener)

Example 12 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.

the class AbstractSetProcessDefinitionStateCmd method findProcessDefinition.

protected List<ProcessDefinitionEntity> findProcessDefinition(CommandContext commandContext) {
    // we don't need to do an extra database fetch and we can simply return it, wrapped in a list
    if (processDefinitionEntity != null) {
        return Arrays.asList(processDefinitionEntity);
    }
    // Validation of input parameters
    if (processDefinitionId == null && processDefinitionKey == null) {
        throw new ActivitiIllegalArgumentException("Process definition id or key cannot be null");
    }
    List<ProcessDefinitionEntity> processDefinitionEntities = new ArrayList<ProcessDefinitionEntity>();
    ProcessDefinitionEntityManager processDefinitionManager = commandContext.getProcessDefinitionEntityManager();
    if (processDefinitionId != null) {
        ProcessDefinitionEntity processDefinitionEntity = processDefinitionManager.findProcessDefinitionById(processDefinitionId);
        if (processDefinitionEntity == null) {
            throw new ActivitiObjectNotFoundException("Cannot find process definition for id '" + processDefinitionId + "'", ProcessDefinition.class);
        }
        processDefinitionEntities.add(processDefinitionEntity);
    } else {
        ProcessDefinitionQueryImpl query = new ProcessDefinitionQueryImpl(commandContext).processDefinitionKey(processDefinitionKey);
        if (tenantId == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(tenantId)) {
            query.processDefinitionWithoutTenantId();
        } else {
            query.processDefinitionTenantId(tenantId);
        }
        List<ProcessDefinition> processDefinitions = query.list();
        if (processDefinitions.isEmpty()) {
            throw new ActivitiException("Cannot find process definition for key '" + processDefinitionKey + "'");
        }
        for (ProcessDefinition processDefinition : processDefinitions) {
            processDefinitionEntities.add((ProcessDefinitionEntity) processDefinition);
        }
    }
    return processDefinitionEntities;
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinitionEntityManager(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntityManager) ProcessDefinitionQueryImpl(org.activiti.engine.impl.ProcessDefinitionQueryImpl) ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) ArrayList(java.util.ArrayList) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessDefinitionEntity(org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 13 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.

the class MyProcessInstancesListQuery method getProcessDefinition.

protected ProcessDefinition getProcessDefinition(String id) {
    ProcessDefinition processDefinition = cachedProcessDefinitions.get(id);
    if (processDefinition == null) {
        processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
        cachedProcessDefinitions.put(id, processDefinition);
    }
    return processDefinition;
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 14 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.

the class MyProcessInstancesListQuery method createItem.

protected ProcessInstanceItem createItem(HistoricProcessInstance processInstance) {
    ProcessInstanceItem item = new ProcessInstanceItem();
    item.addItemProperty("id", new ObjectProperty<String>(processInstance.getId(), String.class));
    ProcessDefinition processDefinition = getProcessDefinition(processInstance.getProcessDefinitionId());
    String itemName = getProcessDisplayName(processDefinition) + " (" + processInstance.getId() + ")" + (processInstance.getBusinessKey() != null ? processInstance.getBusinessKey() : "");
    item.addItemProperty("name", new ObjectProperty<String>(itemName, String.class));
    return item;
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 15 with ProcessDefinition

use of org.activiti.engine.repository.ProcessDefinition in project Activiti by Activiti.

the class ProcessInstanceSuspensionTest method testTaskOperationsFailAfterProcessInstanceSuspend.

@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testTaskOperationsFailAfterProcessInstanceSuspend() {
    // Start a new process instance with one task
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
    final Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    assertNotNull(task);
    // Suspend the process instance
    runtimeService.suspendProcessInstanceById(processInstance.getId());
    // Completing the task should fail
    try {
        taskService.complete(task.getId());
        fail("It is not allowed to complete a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Claiming the task should fail
    try {
        taskService.claim(task.getId(), "jos");
        fail("It is not allowed to claim a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Setting variable on the task should fail
    try {
        taskService.setVariable(task.getId(), "someVar", "someValue");
        fail("It is not allowed to set a variable on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Setting variable on the task should fail
    try {
        taskService.setVariableLocal(task.getId(), "someVar", "someValue");
        fail("It is not allowed to set a variable on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Setting variables on the task should fail
    try {
        HashMap<String, String> variables = new HashMap<String, String>();
        variables.put("varOne", "one");
        variables.put("varTwo", "two");
        taskService.setVariables(task.getId(), variables);
        fail("It is not allowed to set variables on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Setting variables on the task should fail
    try {
        HashMap<String, String> variables = new HashMap<String, String>();
        variables.put("varOne", "one");
        variables.put("varTwo", "two");
        taskService.setVariablesLocal(task.getId(), variables);
        fail("It is not allowed to set variables on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Removing variable on the task should fail
    try {
        taskService.removeVariable(task.getId(), "someVar");
        fail("It is not allowed to remove a variable on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Removing variable on the task should fail
    try {
        taskService.removeVariableLocal(task.getId(), "someVar");
        fail("It is not allowed to remove a variable on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Removing variables on the task should fail
    try {
        taskService.removeVariables(task.getId(), Arrays.asList("one", "two"));
        fail("It is not allowed to remove variables on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Removing variables on the task should fail
    try {
        taskService.removeVariablesLocal(task.getId(), Arrays.asList("one", "two"));
        fail("It is not allowed to remove variables on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Adding candidate groups on the task should fail
    try {
        taskService.addCandidateGroup(task.getId(), "blahGroup");
        fail("It is not allowed to add a candidate group on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Adding candidate users on the task should fail
    try {
        taskService.addCandidateUser(task.getId(), "blahUser");
        fail("It is not allowed to add a candidate user on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Adding candidate users on the task should fail
    try {
        taskService.addGroupIdentityLink(task.getId(), "blahGroup", IdentityLinkType.CANDIDATE);
        fail("It is not allowed to add a candidate user on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Adding an identity link on the task should fail
    try {
        taskService.addUserIdentityLink(task.getId(), "blahUser", IdentityLinkType.OWNER);
        fail("It is not allowed to add an identityLink on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Adding a comment on the task should fail
    try {
        taskService.addComment(task.getId(), processInstance.getId(), "test comment");
        fail("It is not allowed to add a comment on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Adding an attachment on the task should fail
    try {
        taskService.createAttachment("text", task.getId(), processInstance.getId(), "testName", "testDescription", "http://test.com");
        fail("It is not allowed to add an attachment on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Set an assignee on the task should fail
    try {
        taskService.setAssignee(task.getId(), "mispiggy");
        fail("It is not allowed to set an assignee on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Set an owner on the task should fail
    try {
        taskService.setOwner(task.getId(), "kermit");
        fail("It is not allowed to set an owner on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
    // Set priority on the task should fail
    try {
        taskService.setPriority(task.getId(), 99);
        fail("It is not allowed to set a priority on a task of a suspended process instance");
    } catch (ActivitiException e) {
    // This is good
    }
}
Also used : Task(org.activiti.engine.task.Task) ActivitiException(org.activiti.engine.ActivitiException) HashMap(java.util.HashMap) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Aggregations

ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)167 Deployment (org.activiti.engine.test.Deployment)82 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)37 ActivitiException (org.activiti.engine.ActivitiException)24 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)19 Task (org.activiti.engine.task.Task)16 ArrayList (java.util.ArrayList)15 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)12 Date (java.util.Date)10 HashMap (java.util.HashMap)9 HttpGet (org.apache.http.client.methods.HttpGet)9 StringEntity (org.apache.http.entity.StringEntity)9 BpmnModel (org.activiti.bpmn.model.BpmnModel)8 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)7 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)7 IdentityLink (org.activiti.engine.task.IdentityLink)7