org.springframework.core.io.ContextResource#org.activiti.engine.repository.Deployment源码实例Demo

下面列出了org.springframework.core.io.ContextResource#org.activiti.engine.repository.Deployment 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

public static void main(String[] args) throws Exception {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 存储服务
	RepositoryService repositoryService = engine.getRepositoryService();
	// 新建部署构造器
	DeploymentBuilder deploymentBuilder = repositoryService
			.createDeployment();
	deploymentBuilder.addClasspathResource("my_text.txt");
	Deployment deployment = deploymentBuilder.deploy();
	// 数据查询
	InputStream inputStream = repositoryService.getResourceAsStream(
			deployment.getId(), "my_text.txt");
	int count = inputStream.available();
	byte[] contents = new byte[count];
	inputStream.read(contents);
	String result = new String(contents);
	// 输入结果
	System.out.println(result);
	// 关闭流程引擎
	engine.close();
}
 
/**
 * @description 部署流程模板
 * @param name
 * @return
 */
public boolean deploymentProcessDefinition_classpath(String name){
    Deployment deployment = null;//完成部署
    try {
        deployment = repositoryService //与流程定义和部署对象相关的Service
                .createDeployment()//创建一个部署对象
                .name(name)//添加部署的名称
                .addClasspathResource("diagrams/" + name + ".bpmn") //从classpath的资源中加载,一次只能加载一个文件
                //.addClasspathResource("diagrams/" + name + ".png") //从classpath的资源中加载,一次只能加载一个文件
                .deploy();
    } catch (ActivitiIllegalArgumentException e) {
        logger.error("[部署失败] " + e.getMessage());
        return false;
    }
    logger.info("[部署成功] ID:" + deployment.getId() + ", 名称:" + deployment.getName());
    return true;
}
 
源代码3 项目: my_curd   文件: ProcessDeployController.java
/**
 * 下载部署包
 */
@Before(IdRequired.class)
public void downloadZip() {
    String deploymentId = getPara("id");
    Deployment deployment = ActivitiKit.getRepositoryService().createDeploymentQuery()
            .deploymentId(deploymentId)
            .singleResult();
    if (deployment == null) {
        renderFail("部署包不存在");
        return;
    }

    List<String> resourceNames = ActivitiKit.getRepositoryService().getDeploymentResourceNames(deploymentId);
    List<InputStream> resourceDatas = new ArrayList<>();

    for (String resourceName : resourceNames) {
        resourceDatas.add(ActivitiKit.getRepositoryService().getResourceAsStream(deploymentId, resourceName));
    }
    render(ZipRender.me().filenames(resourceNames).dataIn(resourceDatas).fileName("部署包[" + deployment.getId() + "].zip"));
}
 
源代码4 项目: activiti6-boot2   文件: CallActivityTest.java
public void testInstantiateSubprocess() throws Exception {
  BpmnModel mainBpmnModel = loadBPMNModel(MAIN_PROCESS_RESOURCE);
  BpmnModel childBpmnModel = loadBPMNModel(CHILD_PROCESS_RESOURCE);

  Deployment childDeployment = processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();

  Deployment masterDeployment = processEngine.getRepositoryService().createDeployment().name("masterProcessDeployment").addBpmnModel("masterProcess.bpmn20.xml", mainBpmnModel).deploy();

  suspendProcessDefinitions(childDeployment);

  try {
    ProcessInstance masterProcessInstance = runtimeService.startProcessInstanceByKey("masterProcess");
    fail("Exception expected");
  } catch (ActivitiException ae) {
    assertTextPresent("Cannot start process instance. Process definition Child Process", ae.getMessage());
  }

}
 
源代码5 项目: acitviti6.0   文件: ActivitiController.java
@RequestMapping("helloWorld")  
   public void helloWorld() {  
 
       //根据bpmn文件部署流程  
       Deployment deploy = repositoryService.createDeployment()
       									.addClasspathResource("TestProcess.bpmn")
       									.deploy();  
       //获取流程定义  
       ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult();  
       //启动流程定义,返回流程实例  
       ProcessInstance pi = runtimeService.startProcessInstanceById(processDefinition.getId());  
       String processId = pi.getId();  
       System.out.println("流程创建成功,当前流程实例ID:"+processId);  
         
       Task task=taskService.createTaskQuery().processInstanceId(processId).singleResult();  
       System.out.println("执行前,任务名称:"+task.getName());  
       taskService.complete(task.getId());  
 
       task = taskService.createTaskQuery().processInstanceId(processId).singleResult();  
       System.out.println("task为null,任务执行完毕:"+task);  
}
 
源代码6 项目: activiti6-boot2   文件: MuleHttpBasicAuthTest.java
@Test
public void httpWithBasicAuth() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  Deployment deployment = processEngine.getRepositoryService()
      .createDeployment()
      .addClasspathResource("org/activiti5/mule/testHttpBasicAuth.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(10, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");
  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  processEngine.getRepositoryService().deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
源代码7 项目: activiti6-boot2   文件: VariablesTest.java
@org.activiti.engine.test.Deployment
public void testGetVariableAllVariableFetchingDefault() {

  // Testing it the default way, all using getVariable("someVar");

  Map<String, Object> vars = generateVariables();
  vars.put("testVar", "hello");
  String processInstanceId = runtimeService.startProcessInstanceByKey("variablesFetchingTestProcess", vars).getId();

  taskService.complete(taskService.createTaskQuery().taskName("Task A").singleResult().getId());
  taskService.complete(taskService.createTaskQuery().taskName("Task B").singleResult().getId()); // Triggers service task invocation

  vars = runtimeService.getVariables(processInstanceId);
  assertEquals(71, vars.size());

  String varValue = (String) runtimeService.getVariable(processInstanceId, "testVar");
  assertEquals("HELLO world", varValue);
}
 
@Override
public InputStream execute(CommandContext commandContext) {
    if (deploymentId == null) {
        throw new ActivitiIllegalArgumentException("deploymentId is null");
    }
    if (resourceName == null) {
        throw new ActivitiIllegalArgumentException("resourceName is null");
    }

    ResourceEntity resource = commandContext
            .getResourceEntityManager()
            .findResourceByDeploymentIdAndResourceName(deploymentId, resourceName);
    if (resource == null) {
        if (commandContext.getDeploymentEntityManager().findDeploymentById(deploymentId) == null) {
            throw new ActivitiObjectNotFoundException("deployment does not exist: " + deploymentId, Deployment.class);
        } else {
            throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", InputStream.class);
        }
    }
    return new ByteArrayInputStream(resource.getBytes());
}
 
源代码9 项目: activiti6-boot2   文件: MuleHttpTest.java
@Test
public void http() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/mule/testHttp.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(20, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");
  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  processEngine.getRepositoryService().deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
源代码10 项目: activiti6-boot2   文件: MuleHttpBasicAuthTest.java
@Test
public void httpWithBasicAuth() throws Exception {
  Assert.assertTrue(muleContext.isStarted());

  ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
  Deployment deployment = processEngine.getRepositoryService().createDeployment().addClasspathResource("org/activiti/mule/testHttpBasicAuth.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(10, result);
  runtimeService.deleteProcessInstance(processInstance.getId(), "test");
  processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
  processEngine.getRepositoryService().deleteDeployment(deployment.getId());
  assertAndEnsureCleanDb(processEngine);
  ProcessEngines.destroy();
}
 
源代码11 项目: activiti6-boot2   文件: MuleVMTest.java
@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();
}
 
源代码12 项目: activiti6-boot2   文件: DeploymentCacheLimitTest.java
public void testDeploymentCacheLimit() {
  int processDefinitionCacheLimit = 3; // This is set in the configuration
                                       // above

  DefaultDeploymentCache<ProcessDefinitionCacheEntry> processDefinitionCache = (DefaultDeploymentCache<ProcessDefinitionCacheEntry>) processEngineConfiguration.getProcessDefinitionCache();
  assertEquals(0, processDefinitionCache.size());

  String processDefinitionTemplate = DeploymentCacheTestUtil.readTemplateFile("/org/activiti/standalone/deploy/deploymentCacheTest.bpmn20.xml");
  for (int i = 1; i <= 5; i++) {
    repositoryService.createDeployment().addString("Process " + i + ".bpmn20.xml", MessageFormat.format(processDefinitionTemplate, i)).deploy();

    if (i < processDefinitionCacheLimit) {
      assertEquals(i, processDefinitionCache.size());
    } else {
      assertEquals(processDefinitionCacheLimit, processDefinitionCache.size());
    }
  }

  // Cleanup
  for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
    repositoryService.deleteDeployment(deployment.getId(), true);
  }
}
 
源代码13 项目: activiti6-boot2   文件: GetDeploymentResourceCmd.java
public InputStream execute(CommandContext commandContext) {
  if (deploymentId == null) {
    throw new ActivitiIllegalArgumentException("deploymentId is null");
  }
  if (resourceName == null) {
    throw new ActivitiIllegalArgumentException("resourceName is null");
  }

  ResourceEntity resource = commandContext.getResourceEntityManager().findResourceByDeploymentIdAndResourceName(deploymentId, resourceName);
  if (resource == null) {
    if (commandContext.getDeploymentEntityManager().findById(deploymentId) == null) {
      throw new ActivitiObjectNotFoundException("deployment does not exist: " + deploymentId, Deployment.class);
    } else {
      throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName + "' in deployment '" + deploymentId + "'", InputStream.class);
    }
  }
  return new ByteArrayInputStream(resource.getBytes());
}
 
源代码14 项目: activiti6-boot2   文件: Activiti6Test.java
@Test
@org.activiti.engine.test.Deployment
public void testSimpleParallelGateway() {
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("simpleParallelGateway");
  assertNotNull(processInstance);
  assertFalse(processInstance.isEnded());

  List<Task> tasks = taskService.createTaskQuery().processDefinitionKey("simpleParallelGateway").orderByTaskName().asc().list();
  assertEquals(2, tasks.size());
  assertEquals("Task a", tasks.get(0).getName());
  assertEquals("Task b", tasks.get(1).getName());

  for (Task task : tasks) {
    taskService.complete(task.getId());
  }

  assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
 
源代码15 项目: activiti6-boot2   文件: Activiti6Test.java
@Test
@org.activiti.engine.test.Deployment
public void testSimpleNestedParallelGateway() {
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("simpleParallelGateway");
  assertNotNull(processInstance);
  assertFalse(processInstance.isEnded());

  List<Task> tasks = taskService.createTaskQuery().processDefinitionKey("simpleParallelGateway").orderByTaskName().asc().list();
  assertEquals(4, tasks.size());
  assertEquals("Task a", tasks.get(0).getName());
  assertEquals("Task b1", tasks.get(1).getName());
  assertEquals("Task b2", tasks.get(2).getName());
  assertEquals("Task c", tasks.get(3).getName());

  for (Task task : tasks) {
    taskService.complete(task.getId());
  }

  assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
 
源代码16 项目: activiti6-boot2   文件: Activiti6Test.java
@Test
@org.activiti.engine.test.Deployment
public void testLongServiceTaskLoop() {
  int maxCount = 3210; // You can make this as big as you want (as long as
                       // it still fits within transaction timeouts). Go
                       // on, try it!
  Map<String, Object> vars = new HashMap<String, Object>();
  vars.put("counter", new Integer(0));
  vars.put("maxCount", maxCount);
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testLongServiceTaskLoop", vars);
  assertNotNull(processInstance);
  assertTrue(processInstance.isEnded());

  assertEquals(maxCount, CountingServiceTaskTestDelegate.CALL_COUNT.get());
  assertEquals(0, runtimeService.createExecutionQuery().count());

  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) {
    assertEquals(maxCount, historyService.createHistoricActivityInstanceQuery()
        .processInstanceId(processInstance.getId()).activityId("serviceTask").count());
  }
}
 
源代码17 项目: activiti6-boot2   文件: Activiti6Test.java
@Test
@org.activiti.engine.test.Deployment
public void testScriptTask() {
  Map<String, Object> variableMap = new HashMap<String, Object>();
  variableMap.put("a", 1);
  variableMap.put("b", 2);
  ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", variableMap);
  assertNotNull(processInstance);
  assertFalse(processInstance.isEnded());

  Number sumVariable = (Number) runtimeService.getVariable(processInstance.getId(), "sum");
  assertEquals(3, sumVariable.intValue());

  Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()).onlyChildExecutions().singleResult();
  assertNotNull(execution);

  runtimeService.trigger(execution.getId());

  assertNull(runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()).singleResult());
}
 
public void testQueryByCategoryNotEquals() {
  Deployment deployment = repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/repository/processCategoryOne.bpmn20.xml")
      .addClasspathResource("org/activiti/engine/test/api/repository/processCategoryTwo.bpmn20.xml").addClasspathResource("org/activiti/engine/test/api/repository/processCategoryThree.bpmn20.xml")
      .deploy();

  HashSet<String> processDefinitionNames = getProcessDefinitionNames(repositoryService.createProcessDefinitionQuery().processDefinitionCategoryNotEquals("one").list());
  HashSet<String> expectedProcessDefinitionNames = new HashSet<String>();
  expectedProcessDefinitionNames.add("processTwo");
  expectedProcessDefinitionNames.add("processThree");
  assertEquals(expectedProcessDefinitionNames, processDefinitionNames);

  processDefinitionNames = getProcessDefinitionNames(repositoryService.createProcessDefinitionQuery().processDefinitionCategoryNotEquals("two").list());
  expectedProcessDefinitionNames = new HashSet<String>();
  expectedProcessDefinitionNames.add("processOne");
  expectedProcessDefinitionNames.add("processThree");
  assertEquals(expectedProcessDefinitionNames, processDefinitionNames);

  repositoryService.deleteDeployment(deployment.getId());
}
 
public void testQueryByMessageSubscription() {
  Deployment deployment = repositoryService.createDeployment()
    .addClasspathResource("org/activiti5/engine/test/api/repository/processWithNewBookingMessage.bpmn20.xml")
    .addClasspathResource("org/activiti5/engine/test/api/repository/processWithNewInvoiceMessage.bpmn20.xml")
    .deploymentProperty(DeploymentProperties.DEPLOY_AS_ACTIVITI5_PROCESS_DEFINITION, Boolean.TRUE)
    .deploy();
  
  assertEquals(1,repositoryService.createProcessDefinitionQuery()
    .messageEventSubscriptionName("newInvoiceMessage")
    .count());
  
  assertEquals(1,repositoryService.createProcessDefinitionQuery()
    .messageEventSubscriptionName("newBookingMessage")
    .count());
  
  assertEquals(0,repositoryService.createProcessDefinitionQuery()
    .messageEventSubscriptionName("bogus")
    .count());
  
  repositoryService.deleteDeployment(deployment.getId());
}
 
源代码20 项目: activiti6-boot2   文件: VariablesTest.java
@org.activiti.engine.test.Deployment
public void testGetVariableInDelegateMixed3() {

  Map<String, Object> vars = generateVariables();
  vars.put("testVar1", "one");
  vars.put("testVar2", "two");
  vars.put("testVar3", "three");
  String processInstanceId = runtimeService.startProcessInstanceByKey("variablesFetchingTestProcess", vars).getId();

  taskService.complete(taskService.createTaskQuery().taskName("Task A").singleResult().getId());
  taskService.complete(taskService.createTaskQuery().taskName("Task B").singleResult().getId()); // Triggers
                                                                                                 // service
                                                                                                 // task
                                                                                                 // invocation

  assertEquals("one-CHANGED", (String) runtimeService.getVariable(processInstanceId, "testVar1"));
  assertEquals("two-CHANGED", (String) runtimeService.getVariable(processInstanceId, "testVar2"));
  assertNull(runtimeService.getVariable(processInstanceId, "testVar3"));
}
 
源代码21 项目: activiti-in-action-codes   文件: ModelController.java
/**
 * 根据Model部署流程
 */
@RequestMapping(value = "deploy/{modelId}")
public String deploy(@PathVariable("modelId") String modelId, RedirectAttributes redirectAttributes) {
    try {
        Model modelData = repositoryService.getModel(modelId);
        ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
        byte[] bpmnBytes = null;

        BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
        bpmnBytes = new BpmnXMLConverter().convertToXML(model);

        String processName = modelData.getName() + ".bpmn20.xml";
        Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
        redirectAttributes.addFlashAttribute("message", "部署成功,部署ID=" + deployment.getId());
    } catch (Exception e) {
        logger.error("根据模型部署流程失败:modelId={}", modelId, e);
    }
    return "redirect:/chapter20/model/list";
}
 
源代码22 项目: open-cloud   文件: ProcessEngineService.java
/**
 * 根据部署ID查询部署
 *
 * @param deploymentId
 * @return
 */
public Deployment getDeploymentById(String deploymentId) {
    return repositoryService.createDeploymentQuery()
            // 根据部署ID查询
            .deploymentId(deploymentId)
            // 返回唯一结果
            .singleResult();
}
 
源代码23 项目: activiti6-boot2   文件: DeploymentResponse.java
public DeploymentResponse(Deployment deployment, String url) {
  setId(deployment.getId());
  setName(deployment.getName());
  setDeploymentTime(deployment.getDeploymentTime());
  setCategory(deployment.getCategory());
  setTenantId(deployment.getTenantId());
  setUrl(url);
}
 
源代码24 项目: alfresco-repository   文件: ActivitiSmokeTest.java
private Deployment deployDefinition(RepositoryService repoService) throws IOException
{
    ClassPathResource resource = new ClassPathResource("org/alfresco/repo/workflow/activiti/testTransaction.bpmn20.xml");
    Deployment deployment = repoService.createDeployment()
    .addInputStream(resource.getFilename(), resource.getInputStream())
    .deploy();
    return deployment;
}
 
public static void main(String[] args) throws Exception {
	// 创建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 得到流程存储服务对象
	RepositoryService repositoryService = engine.getRepositoryService();
	// 部署一份流程文件与相应的流程图文件
	Deployment dep = repositoryService.createDeployment()
			.addClasspathResource("MyFirstProcess.bpmn").deploy();
	// 查询流程定义
	ProcessDefinition def = repositoryService
			.createProcessDefinitionQuery().deploymentId(dep.getId())
			.singleResult();
	// 查询资源文件
	InputStream is = repositoryService.getProcessDiagram(def.getId());
	// 将输入流转换为图片对象
	BufferedImage image = ImageIO.read(is);
	// 保存为图片文件
	File file = new File("resources/result.png");
	if (!file.exists()) {
		file.createNewFile();
	}
	FileOutputStream fos = new FileOutputStream(file);
	ImageIO.write(image, "png", fos);
	fos.close();
	is.close();
	// 关闭流程引擎
	engine.close();
}
 
源代码26 项目: Shop-for-JavaWeb   文件: ActModelService.java
/**
	 * 根据Model部署流程
	 */
	public String deploy(String id) {
		String message = "";
		try {
			org.activiti.engine.repository.Model modelData = repositoryService.getModel(id);
			BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
			JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
			BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode);
			BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
			byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);
			
			String processName = modelData.getName();
			if (!StringUtils.endsWith(processName, ".bpmn20.xml")){
				processName += ".bpmn20.xml";
			}
//			System.out.println("========="+processName+"============"+modelData.getName());
			ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
			Deployment deployment = repositoryService.createDeployment().name(modelData.getName())
					.addInputStream(processName, in).deploy();
//					.addString(processName, new String(bpmnBytes)).deploy();
			
			// 设置流程分类
			List<ProcessDefinition> list = repositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list();
			for (ProcessDefinition processDefinition : list) {
				repositoryService.setProcessDefinitionCategory(processDefinition.getId(), modelData.getCategory());
				message = "部署成功,流程ID=" + processDefinition.getId();
			}
			if (list.size() == 0){
				message = "部署失败,没有流程。";
			}
		} catch (Exception e) {
			throw new ActivitiException("设计模型图不正确,检查模型正确性,模型ID="+id, e);
		}
		return message;
	}
 
源代码27 项目: activiti6-boot2   文件: TenancyTest.java
public void testCallActivityWithTenant() {
  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
    String tenantId = "apache";

    // deploying both processes. Process 1 will call Process 2
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testCallActivityWithTenant-process01.bpmn20.xml").tenantId(tenantId).deploy();
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/api/tenant/TenancyTest.testCallActivityWithTenant-process02.bpmn20.xml").tenantId(tenantId).deploy();

    // Starting Process 1. Process 1 will be executed successfully but
    // when the call to process 2 is made internally it will throw the
    // exception
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKeyAndTenantId("process1", null, CollectionUtil.singletonMap("sendFor", "test"), tenantId);
    Assert.assertNotNull(processInstance);

    Assert.assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("process2").processInstanceTenantId(tenantId).count());
    Assert.assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionKey("process2").count());

    // following line if executed will give activiti object not found
    // exception as the process1 is linked to a tenant id.
    try {
      processInstance = runtimeService.startProcessInstanceByKey("process1");
      Assert.fail();
    } catch (Exception e) {

    }

    // Cleanup
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
      repositoryService.deleteDeployment(deployment.getId(), true);
    }
  }
}
 
源代码28 项目: herd   文件: JobDefinitionServiceImpl.java
/**
 * Deploys the Activiti XML into Activiti given the specified namespace and job name. If an existing process definition with the specified namespace and job
 * name already exists, a new process definition with an incremented version will be created by Activiti.
 *
 * @param namespace the namespace.
 * @param jobName the job name.
 * @param activitiJobXml the Activiti job XML.
 *
 * @return the newly created process definition.
 */
private ProcessDefinition createProcessDefinition(String namespace, String jobName, String activitiJobXml)
{
    // Deploy Activiti XML using Activiti API.
    String activitiIdString = jobDefinitionHelper.buildActivitiIdString(namespace, jobName);
    Deployment deployment =
        activitiRepositoryService.createDeployment().name(activitiIdString).addString(activitiIdString + ACTIVITI_DEPLOY_XML_SUFFIX, activitiJobXml)
            .deploy();

    // Read the created process definition.
    return activitiRepositoryService.createProcessDefinitionQuery().deploymentId(deployment.getId()).list().get(0);
}
 
源代码29 项目: alfresco-repository   文件: ActivitiSmokeTest.java
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());
        }
    }
 
源代码30 项目: activiti6-boot2   文件: AbstractActivitiTestCase.java
public String deployTwoTasksTestProcess() {
	BpmnModel bpmnModel = createTwoTasksTestProcess();
	Deployment deployment = repositoryService.createDeployment()
			.addBpmnModel("twoTasksTestProcess.bpmn20.xml", bpmnModel).deploy();
	
	deploymentIdsForAutoCleanup.add(deployment.getId()); // For auto-cleanup

	ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
			.deploymentId(deployment.getId()).singleResult();
	return processDefinition.getId(); 
}