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;
}
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();
}
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();
}
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);
}
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);
}
Aggregations