Search in sources :

Example 31 with Deployment

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

the class DeployCmd method execute.

public Deployment execute(CommandContext commandContext) {
    DeploymentEntity deployment = deploymentBuilder.getDeployment();
    deployment.setDeploymentTime(commandContext.getProcessEngineConfiguration().getClock().getCurrentTime());
    if (deploymentBuilder.isDuplicateFilterEnabled()) {
        List<Deployment> existingDeployments = new ArrayList<Deployment>();
        if (deployment.getTenantId() == null || ProcessEngineConfiguration.NO_TENANT_ID.equals(deployment.getTenantId())) {
            DeploymentEntity existingDeployment = commandContext.getDeploymentEntityManager().findLatestDeploymentByName(deployment.getName());
            if (existingDeployment != null) {
                existingDeployments.add(existingDeployment);
            }
        } else {
            List<Deployment> deploymentList = commandContext.getProcessEngineConfiguration().getRepositoryService().createDeploymentQuery().deploymentName(deployment.getName()).deploymentTenantId(deployment.getTenantId()).orderByDeploymentId().desc().list();
            if (!deploymentList.isEmpty()) {
                existingDeployments.addAll(deploymentList);
            }
        }
        DeploymentEntity existingDeployment = null;
        if (!existingDeployments.isEmpty()) {
            existingDeployment = (DeploymentEntity) existingDeployments.get(0);
        }
        if ((existingDeployment != null) && !deploymentsDiffer(deployment, existingDeployment)) {
            return existingDeployment;
        }
    }
    deployment.setNew(true);
    // Save the data
    commandContext.getDeploymentEntityManager().insertDeployment(deployment);
    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, deployment));
    }
    // Deployment settings
    Map<String, Object> deploymentSettings = new HashMap<String, Object>();
    deploymentSettings.put(DeploymentSettings.IS_BPMN20_XSD_VALIDATION_ENABLED, deploymentBuilder.isBpmn20XsdValidationEnabled());
    deploymentSettings.put(DeploymentSettings.IS_PROCESS_VALIDATION_ENABLED, deploymentBuilder.isProcessValidationEnabled());
    // Actually deploy
    commandContext.getProcessEngineConfiguration().getDeploymentManager().deploy(deployment, deploymentSettings);
    if (deploymentBuilder.getProcessDefinitionsActivationDate() != null) {
        scheduleProcessDefinitionActivation(commandContext, deployment);
    }
    if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        commandContext.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, deployment));
    }
    return deployment;
}
Also used : DeploymentEntity(org.activiti.engine.impl.persistence.entity.DeploymentEntity) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Deployment(org.activiti.engine.repository.Deployment)

Example 32 with Deployment

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

the class ProcessDeployer method deployProcess.

/**
   * Deploys a single process
   * 
   * @return the processDefinitionId of the deployed process as returned by
   *         {@link ProcessDefinition#getId()}
   */
public String deployProcess(String resourceName) {
    logger.debug("Start deploying single process.");
    // deploy processes as one deployment
    DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment();
    deploymentBuilder.addClasspathResource(resourceName);
    // deploy the processes
    Deployment deployment = deploymentBuilder.deploy();
    logger.debug("Process deployed");
    // retreive the processDefinitionId for this process
    return processEngine.getRepositoryService().createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult().getId();
}
Also used : Deployment(org.activiti.engine.repository.Deployment) DeploymentBuilder(org.activiti.engine.repository.DeploymentBuilder)

Example 33 with Deployment

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

the class AbstractActivitiTestCase method deployOneTaskTestProcess.

/**
   * Creates and deploys the one task process. See {@link #createOneTaskTestProcess()}.
   * 
   * @return The process definition id (NOT the process definition key) of deployed one task process.
   */
public String deployOneTaskTestProcess() {
    BpmnModel bpmnModel = createOneTaskTestProcess();
    Deployment deployment = repositoryService.createDeployment().addBpmnModel("oneTasktest.bpmn20.xml", bpmnModel).deploy();
    // For auto-cleanup
    deploymentIdsForAutoCleanup.add(deployment.getId());
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult();
    return processDefinition.getId();
}
Also used : Deployment(org.activiti.engine.repository.Deployment) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 34 with Deployment

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

the class SubTaskTest method testSubTaskDeleteOnProcessInstanceDelete.

public void testSubTaskDeleteOnProcessInstanceDelete() {
    Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml").deploy();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
    taskService.setAssignee(task.getId(), "test");
    Task subTask1 = taskService.newTask();
    subTask1.setName("Sub task 1");
    subTask1.setParentTaskId(task.getId());
    subTask1.setAssignee("test");
    taskService.saveTask(subTask1);
    Task subTask2 = taskService.newTask();
    subTask2.setName("Sub task 2");
    subTask2.setParentTaskId(task.getId());
    subTask2.setAssignee("test");
    taskService.saveTask(subTask2);
    List<Task> tasks = taskService.createTaskQuery().taskAssignee("test").list();
    assertEquals(3, tasks.size());
    runtimeService.deleteProcessInstance(processInstance.getId(), "none");
    tasks = taskService.createTaskQuery().taskAssignee("test").list();
    assertEquals(0, tasks.size());
    if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        List<HistoricTaskInstance> historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list();
        assertEquals(3, historicTasks.size());
        historyService.deleteHistoricProcessInstance(processInstance.getId());
        historicTasks = historyService.createHistoricTaskInstanceQuery().taskAssignee("test").list();
        assertEquals(0, historicTasks.size());
    }
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : Task(org.activiti.engine.task.Task) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance)

Example 35 with Deployment

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

the class SubProcessTest method testSimpleSubProcess.

public void testSimpleSubProcess() {
    Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/examples/bpmn/subprocess/SubProcessTest.fixSystemFailureProcess.bpmn20.xml").deploy();
    // After staring the process, both tasks in the subprocess should be active
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("fixSystemFailure");
    List<Task> tasks = taskService.createTaskQuery().processInstanceId(pi.getId()).orderByTaskName().asc().list();
    // Tasks are ordered by name (see query)
    assertEquals(2, tasks.size());
    Task investigateHardwareTask = tasks.get(0);
    Task investigateSoftwareTask = tasks.get(1);
    assertEquals("Investigate hardware", investigateHardwareTask.getName());
    assertEquals("Investigate software", investigateSoftwareTask.getName());
    // Completing both the tasks finishes the subprocess and enables the task after the subprocess
    taskService.complete(investigateHardwareTask.getId());
    taskService.complete(investigateSoftwareTask.getId());
    Task writeReportTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
    assertEquals("Write report", writeReportTask.getName());
    // Clean up
    repositoryService.deleteDeployment(deployment.getId(), true);
}
Also used : Task(org.activiti.engine.task.Task) Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance)

Aggregations

Deployment (org.activiti.engine.repository.Deployment)66 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)12 BpmnModel (org.activiti.bpmn.model.BpmnModel)10 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ActivitiException (org.activiti.engine.ActivitiException)7 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6 HttpGet (org.apache.http.client.methods.HttpGet)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 InputStream (java.io.InputStream)3 HashSet (java.util.HashSet)3 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)3 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)3 ProcessEngine (org.activiti.engine.ProcessEngine)3 RuntimeService (org.activiti.engine.RuntimeService)3 DeploymentBuilder (org.activiti.engine.repository.DeploymentBuilder)3 Task (org.activiti.engine.task.Task)3