Java Code Examples for org.activiti.engine.RepositoryService#deleteDeployment()

The following examples show how to use org.activiti.engine.RepositoryService#deleteDeployment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MuleVMTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void send() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  RepositoryService repositoryService = processEngine.getRepositoryService();
  Deployment deployment = repositoryService.createDeployment()
      .addClasspathResource("org/activiti5/mule/testVM.bpmn20.xml")
      .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
      .deploy();

  RuntimeService runtimeService = processEngine.getRuntimeService();
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
  Assert.assertFalse(processInstance.isEnded());
  Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
  Assert.assertEquals(30, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");

  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  repositoryService.deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
Example 2
Source File: MuleVMTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void send() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  RepositoryService repositoryService = processEngine.getRepositoryService();
  Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/mule/testVM.bpmn20.xml").deploy();

  RuntimeService runtimeService = processEngine.getRuntimeService();
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
  Assert.assertFalse(processInstance.isEnded());
  Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
  Assert.assertEquals(30, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");

  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  repositoryService.deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
Example 3
Source File: AbstractProcessEngineTest.java    From openwebflow with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * 测试流程模型部署
 */
@Test
public void testModelDeployment() throws Exception
{
	// 取model,该model会自动注册
	RepositoryService repositoryService = _processEngine.getRepositoryService();
	Model model = repositoryService.createModelQuery().modelKey("vacation.bpmn").singleResult();
	//确定已注册
	Assert.assertNotNull(model);
	//由于没有部署,应该拿不到
	Assert.assertEquals(0, repositoryService.createProcessDefinitionQuery().processDefinitionKey("vacationRequest")
			.list().size());

	//部署该model
	Deployment dep = ModelUtils.deployModel(repositoryService, model.getId());
	//现在应该拿得到了
	Assert.assertEquals(1, repositoryService.createProcessDefinitionQuery().processDefinitionKey("vacationRequest")
			.list().size());

	//删除掉
	repositoryService.deleteDeployment(dep.getId(), true);
	//现在再取就拿不到了
	Assert.assertEquals(0, repositoryService.createProcessDefinitionQuery().processDefinitionKey("vacationRequest")
			.list().size());
}
 
Example 4
Source File: CleanTestExecutionListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTestClass(TestContext testContext) throws Exception {
  RepositoryService repositoryService = testContext.getApplicationContext().getBean(RepositoryService.class);
  for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
    repositoryService.deleteDeployment(deployment.getId(), true);
  }
}
 
Example 5
Source File: XmlNamespaceProcessScopeTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@After
public void after() {
  RepositoryService repositoryService = this.processEngine.getRepositoryService();
  for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
    repositoryService.deleteDeployment(deployment.getId(), true);
  }
}
 
Example 6
Source File: CleanTestExecutionListener.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void afterTestClass(TestContext testContext) throws Exception {
  RepositoryService repositoryService = testContext.getApplicationContext().getBean(RepositoryService.class);
  for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
    repositoryService.deleteDeployment(deployment.getId(), true);
  }
}
 
Example 7
Source File: XmlNamespaceProcessScopeTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@After
public void after() {
  RepositoryService repositoryService = this.processEngine.getRepositoryService();
  for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
    repositoryService.deleteDeployment(deployment.getId(), true);
  }
}
 
Example 8
Source File: ActivitiSmokeTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void testDeploy() throws Exception
    {
        ProcessEngine engine = buildProcessEngine();

        RepositoryService repoService = engine.getRepositoryService();

        Deployment deployment = deployDefinition(repoService);

        assertNotNull(deployment);

        RuntimeService runtimeService = engine.getRuntimeService();
        try
        {
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("testTask");
            assertNotNull(instance);
            
            String instanceId = instance.getId();
            ProcessInstance instanceInDb = findProcessInstance(runtimeService, instanceId);
            assertNotNull(instanceInDb);
            runtimeService.deleteProcessInstance(instanceId, "");
        }
        finally
        {
            
//            List<Deployment> deployments = repoService.createDeploymentQuery().list();
//            for (Deployment deployment2 : deployments)
//            {
//                repoService.deleteDeployment(deployment2.getId());
//            }
            
            repoService.deleteDeployment(deployment.getId());
        }
    }
 
Example 9
Source File: ProcessDeployController.java    From my_curd with Apache License 2.0 5 votes vote down vote up
@Before({IdsRequired.class, Tx.class})
public void unDeployAction() {
    boolean cascade = getParaToBoolean("cascade", true);
    RepositoryService service = ActivitiKit.getRepositoryService();
    for (String id : getPara("ids").split(",")) {
        // cascade 如为 false, 如果 流程已经启动,抛出 runtime exception 触发事务
        log.info("{} 部署流程, deploymentId:{}, cascade:{}", WebUtils.getSessionUsername(this), id, cascade);
        service.deleteDeployment(id, cascade);
    }
    renderSuccess("卸载成功");
}
 
Example 10
Source File: ProcessDefinitionCacheTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void testDeployRevisedProcessAfterDeleteOnOtherProcessEngine() {

    // Setup both process engines
    ProcessEngine processEngine1 = new StandaloneProcessEngineConfiguration().setProcessEngineName("reboot-test-schema")
        .setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE).setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000")
        .setAsyncExecutorActivate(false).buildProcessEngine();
    RepositoryService repositoryService1 = processEngine1.getRepositoryService();

    ProcessEngine processEngine2 = new StandaloneProcessEngineConfiguration().setProcessEngineName("reboot-test")
        .setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE).setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000")
        .setAsyncExecutorActivate(false).buildProcessEngine();
    RepositoryService repositoryService2 = processEngine2.getRepositoryService();
    RuntimeService runtimeService2 = processEngine2.getRuntimeService();
    TaskService taskService2 = processEngine2.getTaskService();

    // Deploy first version of process: start->originalTask->end on first
    // process engine
    String deploymentId = repositoryService1.createDeployment().addClasspathResource("org/activiti/engine/test/cache/originalProcess.bpmn20.xml").deploy().getId();

    // Start process instance on second engine
    String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceById(processDefinitionId);
    Task task = taskService2.createTaskQuery().singleResult();
    assertEquals("original task", task.getName());

    // Delete the deployment on second process engine
    repositoryService2.deleteDeployment(deploymentId, true);
    assertEquals(0, repositoryService2.createDeploymentQuery().count());
    assertEquals(0, runtimeService2.createProcessInstanceQuery().count());

    // deploy a revised version of the process: start->revisedTask->end on
    // first process engine
    //
    // Before the bugfix, this would set the cache on the first process
    // engine,
    // but the second process engine still has the original process
    // definition in his cache.
    // Since there is a deployment delete in between, the new generated
    // process definition id is the same
    // as in the original deployment, making the second process engine using
    // the old cached process definition.
    deploymentId = repositoryService1.createDeployment().addClasspathResource("org/activiti/engine/test/cache/revisedProcess.bpmn20.xml").deploy().getId();

    // Start process instance on second process engine -> must use revised
    // process definition
    repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceByKey("oneTaskProcess");
    task = taskService2.createTaskQuery().singleResult();
    assertEquals("revised task", task.getName());

    // cleanup
    repositoryService1.deleteDeployment(deploymentId, true);
    processEngine1.close();
    processEngine2.close();
  }
 
Example 11
Source File: ProcessDefinitionCacheTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public void testDeployRevisedProcessAfterDeleteOnOtherProcessEngine() {
  
  // Setup both process engines
  StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration = new StandaloneProcessEngineConfiguration();
  standaloneProcessEngineConfiguration.setProcessEngineName("reboot-test-schema");
  standaloneProcessEngineConfiguration.setDatabaseSchemaUpdate(org.activiti5.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
  standaloneProcessEngineConfiguration.setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000");
  standaloneProcessEngineConfiguration.setAsyncExecutorActivate(false);
  standaloneProcessEngineConfiguration.setActiviti5CompatibilityEnabled(true);
  ProcessEngine processEngine1 = standaloneProcessEngineConfiguration.buildProcessEngine();
  RepositoryService repositoryService1 = processEngine1.getRepositoryService();
  
  StandaloneProcessEngineConfiguration standaloneProcessEngineConfiguration2 = new StandaloneProcessEngineConfiguration();
  standaloneProcessEngineConfiguration2.setProcessEngineName("reboot-test");
  standaloneProcessEngineConfiguration2.setDatabaseSchemaUpdate(org.activiti5.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE);
  standaloneProcessEngineConfiguration2.setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000");
  standaloneProcessEngineConfiguration2.setAsyncExecutorActivate(false);
  standaloneProcessEngineConfiguration2.setActiviti5CompatibilityEnabled(true);
  ProcessEngine processEngine2  = standaloneProcessEngineConfiguration2.buildProcessEngine();
  RepositoryService repositoryService2 = processEngine2.getRepositoryService();
  RuntimeService runtimeService2 = processEngine2.getRuntimeService();
  TaskService taskService2 = processEngine2.getTaskService();
  
  // Deploy first version of process: start->originalTask->end on first process engine
  String deploymentId = repositoryService1.createDeployment()
    .addClasspathResource("org/activiti5/engine/test/cache/originalProcess.bpmn20.xml")
    .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
    .deploy()
    .getId();
  
  // Start process instance on second engine
  String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
  runtimeService2.startProcessInstanceById(processDefinitionId);
  Task task = taskService2.createTaskQuery().singleResult();
  assertEquals("original task", task.getName());
  
  // Delete the deployment on second process engine
  repositoryService2.deleteDeployment(deploymentId, true);
  assertEquals(0, repositoryService2.createDeploymentQuery().count());
  assertEquals(0, runtimeService2.createProcessInstanceQuery().count());
  
  // deploy a revised version of the process: start->revisedTask->end on first process engine
  //
  // Before the bugfix, this would set the cache on the first process engine,
  // but the second process engine still has the original process definition in his cache.
  // Since there is a deployment delete in between, the new generated process definition id is the same 
  // as in the original deployment, making the second process engine using the old cached process definition.
  deploymentId = repositoryService1.createDeployment()
    .addClasspathResource("org/activiti5/engine/test/cache/revisedProcess.bpmn20.xml")
    .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
    .deploy()
    .getId();
  
  // Start process instance on second process engine -> must use revised process definition
  repositoryService2.createProcessDefinitionQuery().singleResult().getId();
  runtimeService2.startProcessInstanceByKey("oneTaskProcess");
  task = taskService2.createTaskQuery().singleResult();
  assertEquals("revised task", task.getName());
  
  // cleanup
  repositoryService1.deleteDeployment(deploymentId, true);
  processEngine1.close();
  processEngine2.close();
}
 
Example 12
Source File: ConsoleController.java    From lemon with Apache License 2.0 4 votes vote down vote up
/**
 * 删除部署.
 */
@RequestMapping("console-removeDeployment")
public String removeDeployment(
        @RequestParam("deploymentId") String deploymentId) {
    RepositoryService repositoryService = processEngine
            .getRepositoryService();
    List<ProcessDefinition> processDefinitions = repositoryService
            .createProcessDefinitionQuery().deploymentId(deploymentId)
            .list();

    for (ProcessDefinition processDefinition : processDefinitions) {
        String hql = "from BpmConfBase where processDefinitionId=? or (processDefinitionKey=? and processDefinitionVersion=?)";
        List<BpmConfBase> bpmConfBases = bpmConfBaseManager.find(hql,
                processDefinition.getId(), processDefinition.getKey(),
                processDefinition.getVersion());

        for (BpmConfBase bpmConfBase : bpmConfBases) {
            for (BpmConfNode bpmConfNode : bpmConfBase.getBpmConfNodes()) {
                for (BpmConfCountersign bpmConfCountersign : bpmConfNode
                        .getBpmConfCountersigns()) {
                    bpmConfBaseManager.remove(bpmConfCountersign);
                }

                for (BpmConfForm bpmConfForm : bpmConfNode
                        .getBpmConfForms()) {
                    bpmConfBaseManager.remove(bpmConfForm);
                }

                for (BpmConfListener bpmConfListener : bpmConfNode
                        .getBpmConfListeners()) {
                    bpmConfBaseManager.remove(bpmConfListener);
                }

                for (BpmConfNotice bpmConfNotice : bpmConfNode
                        .getBpmConfNotices()) {
                    bpmConfBaseManager.remove(bpmConfNotice);
                }

                for (BpmConfOperation bpmConfOperation : bpmConfNode
                        .getBpmConfOperations()) {
                    bpmConfBaseManager.remove(bpmConfOperation);
                }

                for (BpmConfRule bpmConfRule : bpmConfNode
                        .getBpmConfRules()) {
                    bpmConfBaseManager.remove(bpmConfRule);
                }

                for (BpmConfUser bpmConfUser : bpmConfNode
                        .getBpmConfUsers()) {
                    bpmConfBaseManager.remove(bpmConfUser);
                }

                bpmConfBaseManager.remove(bpmConfNode);
            }

            for (BpmProcess bpmProcess : bpmConfBase.getBpmProcesses()) {
                bpmProcessManager.remove(bpmProcess);
            }

            bpmConfBaseManager.remove(bpmConfBase);
        }
    }

    repositoryService.deleteDeployment(deploymentId, true);

    return "redirect:/bpm/console-listDeployments.do";
}
 
Example 13
Source File: TestBPMN001.java    From bamboobsc with Apache License 2.0 3 votes vote down vote up
@Test
public void deleteProcess() throws Exception {
	
	String deploymentId = "10001";
	
	RepositoryService repositoryService = (RepositoryService) AppContext.getBean("repositoryService");
	repositoryService.deleteDeployment(deploymentId);
	//repositoryService.deleteDeployment(processId, true); no need it
	
}