org.activiti.engine.RepositoryService Java Examples

The following examples show how to use org.activiti.engine.RepositoryService. 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: DefaultAutoDeploymentStrategy.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {

    // Create a single deployment for all resources using the name hint as
    // the literal name
    final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentNameHint);

    for (final Resource resource : resources) {
        final String resourceName = determineResourceName(resource);

        try {
            if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) {
                deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
            } else {
                deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
            }
        } catch (IOException e) {
            throw new ActivitiException("couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
        }
    }

    deploymentBuilder.deploy();

}
 
Example #2
Source File: InitProcessEngineBySpringAnnotation.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    AnnotationConfigApplicationContext ctx =
            new AnnotationConfigApplicationContext();
    ctx.register(SpringAnnotationConfiguration.class);
    ctx.refresh();

    assertNotNull(ctx.getBean(ProcessEngine.class));
    assertNotNull(ctx.getBean(RuntimeService.class));
    TaskService bean = ctx.getBean(TaskService.class);
    assertNotNull(bean);
    assertNotNull(ctx.getBean(HistoryService.class));
    assertNotNull(ctx.getBean(RepositoryService.class));
    assertNotNull(ctx.getBean(ManagementService.class));
    assertNotNull(ctx.getBean(FormService.class));
    Task task = bean.newTask();
    task.setName("哈哈");
    bean.saveTask(task);
}
 
Example #3
Source File: AddZipInputStreamTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 存储服务
	RepositoryService repositoryService = engine.getRepositoryService();
	// 新建部署构造器
	DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
	// 新建文件输入流
	FileInputStream fileInputStream = new FileInputStream(new File("resources/datas.zip"));
	// 新建Zip输入流
	ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
	// 将Zip输入流添加到部署构造器中
	deploymentBuilder.addZipInputStream(zipInputStream);
	// 发布部署构造器
	deploymentBuilder.deploy();
	// 关闭流程引擎
	engine.close();
}
 
Example #4
Source File: TextQueryTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
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();
}
 
Example #5
Source File: AddBpmnModelTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 存储服务
	RepositoryService repositoryService = engine.getRepositoryService();
	// 新建部署构造器
	DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
	String resourceName = "My Process";
	BpmnModel bpmnModel = createProcessModel();
	// 发布部署构造器
	deploymentBuilder.addBpmnModel(resourceName, bpmnModel);
	// 发布部署构造器
	deploymentBuilder.deploy();
	// 关闭流程引擎
	engine.close();
}
 
Example #6
Source File: BpmnErrorTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {       
// 新建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 存储服务
RepositoryService repositoryService = engine.getRepositoryService();
// 新建部署构造器
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
// 增加错误的schema文件(包括无效的标签)<test>test</test>
// 报错信息:[Validation set: 'activiti-executable-process' | 
//Problem: 'activiti-start-event-multiple-found'] : 
//Multiple none start events are not supported - 
//[Extra info : processDefinitionId = myProcess | 
// processDefinitionName = My process |  | id = startevent1 |  
//| activityName = Start | ] ( line: 4, column: 47)
deploymentBuilder.addClasspathResource("error/bpmn_error.bpmn");
// 禁用Bpmn验证
deploymentBuilder.disableBpmnValidation();
// 发布部署构造器
deploymentBuilder.deploy();
// 关闭流程引擎
engine.close();
  }
 
Example #7
Source File: SchemaErrorTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {           
// 新建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 存储服务
RepositoryService repositoryService = engine.getRepositoryService();
// 新建部署构造器
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
// 增加错误的schema文件(包括无效的标签)<test>test</test> 
// 校验报错:发现了以元素 'test' 开头的无效内容。
deploymentBuilder.addClasspathResource("error/schema_error.bpmn");
// 禁用Schema验证
deploymentBuilder.disableSchemaValidation();
// 发布部署构造器
deploymentBuilder.deploy();
// 关闭流程引擎
engine.close();
  }
 
Example #8
Source File: AddZipInputStreamTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 存储服务
	RepositoryService repositoryService = engine.getRepositoryService();
	// 新建部署构造器
	DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
	// 新建文件输入流
	FileInputStream fileInputStream = new FileInputStream(new File("resources/datas.zip"));
	// 新建Zip输入流
	ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
	// 将Zip输入流添加到部署构造器中
	deploymentBuilder.addZipInputStream(zipInputStream);
	// 发布部署构造器
	deploymentBuilder.deploy();
	// 关闭流程引擎
	engine.close();
}
 
Example #9
Source File: BpmnQueryTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
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.getProcessModel(def.getId());
      // 读取输入流
      int count = is.available();
      byte[] contents = new byte[count];
      is.read(contents);
      String result = new String(contents);
      //输入输出结果
      System.out.println(result);
// 关闭流程引擎
engine.close();
  }
 
Example #10
Source File: BpmnQueryTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
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.getProcessModel(def.getId());
      // 读取输入流
      int count = is.available();
      byte[] contents = new byte[count];
      is.read(contents);
      String result = new String(contents);
      //输入输出结果
      System.out.println(result);
// 关闭流程引擎
engine.close();
  }
 
Example #11
Source File: SchemaErrorTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) {           
// 新建流程引擎
ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
// 存储服务
RepositoryService repositoryService = engine.getRepositoryService();
// 新建部署构造器
DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
// 增加错误的schema文件(包括无效的标签)<test>test</test> 
// 校验报错:发现了以元素 'test' 开头的无效内容。
deploymentBuilder.addClasspathResource("error/schema_error.bpmn");
// 禁用Schema验证
deploymentBuilder.disableSchemaValidation();
// 发布部署构造器
deploymentBuilder.deploy();
// 关闭流程引擎
engine.close();
  }
 
Example #12
Source File: SingleResourceAutoDeploymentStrategy.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {

  // Create a separate deployment for each resource using the resource
  // name

  for (final Resource resource : resources) {

    final String resourceName = determineResourceName(resource);
    final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(resourceName);

    try {
      if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) {
        deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
      } else {
        deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
      }
    } catch (IOException e) {
      throw new ActivitiException("couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
    }

    deploymentBuilder.deploy();
  }
}
 
Example #13
Source File: ModelerController.java    From lemon with Apache License 2.0 6 votes vote down vote up
@RequestMapping("modeler-open")
public String open(@RequestParam(value = "id", required = false) String id)
        throws Exception {
    RepositoryService repositoryService = processEngine
            .getRepositoryService();
    Model model = null;

    if (!StringUtils.isEmpty(id)) {
        model = repositoryService.getModel(id);
    }

    if (model == null) {
        model = repositoryService.newModel();
        repositoryService.saveModel(model);
        id = model.getId();
    }

    // return "redirect:/cdn/modeler/editor.html?id=" + id;
    return "redirect:/cdn/public/modeler/5.18.0/modeler.html?modelId=" + id;
}
 
Example #14
Source File: IntegrationAutoConfigurationTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testLaunchingGatewayProcessDefinition() throws Exception {
    AnnotationConfigApplicationContext applicationContext = this.context(InboundGatewayConfiguration.class);
    
    RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class);
    RuntimeService runtimeService = applicationContext.getBean(RuntimeService.class);
    ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);

    Assert.assertNotNull("the process engine should not be null", processEngine);
    Assert.assertNotNull("we should have a default repositoryService included", repositoryService);
    String integrationGatewayProcess = "integrationGatewayProcess";
    List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery()
            .processDefinitionKey(integrationGatewayProcess)
            .list();
    ProcessDefinition processDefinition = processDefinitionList.iterator().next();
    Assert.assertEquals(processDefinition.getKey(), integrationGatewayProcess);
    Map<String, Object> vars = new HashMap<String, Object>();
    vars.put("customerId", 232);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(integrationGatewayProcess, vars);
    Assert.assertNotNull("the processInstance should not be null", processInstance);
    org.junit.Assert.assertTrue(
            applicationContext.getBean(InboundGatewayConfiguration.AnalysingService.class)
                    .getStringAtomicReference().get().equals(projectId));
}
 
Example #15
Source File: VerySimpleLeaveProcessTest.java    From activiti-in-action-codes with Apache License 2.0 6 votes vote down vote up
@Test
public void testStartProcess() throws Exception {
    // 创建流程引擎,使用内存数据库
    ProcessEngine processEngine = ProcessEngineConfiguration
            .createStandaloneInMemProcessEngineConfiguration()
            .buildProcessEngine();

    // 部署流程定义文件
    RepositoryService repositoryService = processEngine.getRepositoryService();
    String processFileName = "me/kafeitu/activiti/helloworld/sayhelloleave.bpmn";
    repositoryService.createDeployment().addClasspathResource(processFileName)
            .deploy();

    // 验证已部署流程定义
    ProcessDefinition processDefinition = repositoryService
            .createProcessDefinitionQuery().singleResult();
    assertEquals("leavesayhello", processDefinition.getKey());

    // 启动流程并返回流程实例
    RuntimeService runtimeService = processEngine.getRuntimeService();
    ProcessInstance processInstance = runtimeService
            .startProcessInstanceByKey("leavesayhello");
    assertNotNull(processInstance);
    System.out.println("pid=" + processInstance.getId() + ", pdid="
            + processInstance.getProcessDefinitionId());
}
 
Example #16
Source File: ProcessTestMyProcess.java    From spring-boot-with-activiti-drools-example with MIT License 6 votes vote down vote up
@Test
public void startProcess() throws Exception
{
    RepositoryService repositoryService = activitiRule.getRepositoryService();
    // TODO:Assembel the process deployment with configuration.
    // @see:
    repositoryService.createDeployment().addClasspathResource("diagrams/BusinessRuleLoanProcess.bpmn")
        .addClasspathResource("diagrams/BusinessRuleLoanProcess.png")
        .addClasspathResource("diagrams/LoanRequestRules.drl").enableDuplicateFiltering()
        .name("businessRuleLoanProcessSimple").deploy();
    // repositoryService.createDeployment().addInputStream("BusinessRuleLoanProcess.bpmn",
    // new FileInputStream(filename)).deploy();
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
    variableMap.put("name", "Nadim");
    variableMap.put("amount", 2400L);
    variableMap.put("salary", 10000L);
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
}
 
Example #17
Source File: ModelerController.java    From lemon with Apache License 2.0 6 votes vote down vote up
@RequestMapping("model/{modelId}/save")
@ResponseBody
public String modelSave(@PathVariable("modelId") String modelId,
        @RequestParam("description") String description,
        @RequestParam("json_xml") String jsonXml,
        @RequestParam("name") String name,
        @RequestParam("svg_xml") String svgXml) throws Exception {
    RepositoryService repositoryService = processEngine
            .getRepositoryService();
    Model model = repositoryService.getModel(modelId);
    model.setName(name);
    // model.setMetaInfo(root.toString());
    logger.info("jsonXml : {}", jsonXml);
    repositoryService.saveModel(model);
    repositoryService.addModelEditorSource(model.getId(),
            jsonXml.getBytes("utf-8"));

    return "{}";
}
 
Example #18
Source File: ProcessExecutionIntegrationTest.java    From tutorials with MIT License 6 votes vote down vote up
@Test
public void givenProcessDefinition_whenStartProcessInstance_thenProcessRunning() {
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment()
      .addClasspathResource("org/activiti/test/vacationRequest.bpmn20.xml")
      .deploy();

    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("employeeName", "Kermit");
    variables.put("numberOfDays", new Integer(4));
    variables.put("vacationMotivation", "I'm really tired!");

    RuntimeService runtimeService = processEngine.getRuntimeService();
    ProcessInstance processInstance = runtimeService
      .startProcessInstanceByKey("vacationRequest", variables);

    Long count = runtimeService.createProcessInstanceQuery().count();
    assertTrue(count >= 1);
}
 
Example #19
Source File: ConsoleController.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 显示流程定义的xml.
 */
@RequestMapping("console-viewXml")
public void viewXml(
        @RequestParam("processDefinitionId") String processDefinitionId,
        HttpServletResponse response) throws Exception {
    RepositoryService repositoryService = processEngine
            .getRepositoryService();
    ProcessDefinition processDefinition = repositoryService
            .createProcessDefinitionQuery()
            .processDefinitionId(processDefinitionId).singleResult();
    String resourceName = processDefinition.getResourceName();
    InputStream resourceAsStream = repositoryService.getResourceAsStream(
            processDefinition.getDeploymentId(), resourceName);
    response.setContentType("text/xml;charset=UTF-8");
    IOUtils.copy(resourceAsStream, response.getOutputStream());
}
 
Example #20
Source File: PlaybackProcessStartTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public void demoCheckStatus() {
  final HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().
    finished().
    includeProcessVariables().
    singleResult();
  assertNotNull(historicProcessInstance);
  RepositoryService repositoryService = processEngine.getRepositoryService();
  final ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().
    processDefinitionId(historicProcessInstance.getProcessDefinitionId()).
    singleResult();
  assertEquals(SIMPLEST_PROCESS, processDefinition.getKey());

  assertEquals(1, historicProcessInstance.getProcessVariables().size());
  assertEquals(TEST_VALUE, historicProcessInstance.getProcessVariables().get(TEST_VARIABLE));
  assertEquals(BUSINESS_KEY, historicProcessInstance.getBusinessKey());
}
 
Example #21
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 #22
Source File: ConsoleController.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 发布流程.
 */
@RequestMapping("console-deploy")
public String deploy(@RequestParam("xml") String xml) throws Exception {
    RepositoryService repositoryService = processEngine
            .getRepositoryService();
    ByteArrayInputStream bais = new ByteArrayInputStream(
            xml.getBytes("UTF-8"));
    Deployment deployment = repositoryService.createDeployment()
            .addInputStream("process.bpmn20.xml", bais).deploy();
    List<ProcessDefinition> processDefinitions = repositoryService
            .createProcessDefinitionQuery()
            .deploymentId(deployment.getId()).list();

    for (ProcessDefinition processDefinition : processDefinitions) {
        processEngine.getManagementService().executeCommand(
                new SyncProcessCmd(processDefinition.getId()));
    }

    return "redirect:/bpm/console-listProcessDefinitions.do";
}
 
Example #23
Source File: DefaultAutoDeploymentStrategy.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {

  // Create a single deployment for all resources using the name hint as
  // the
  // literal name
  final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentNameHint);

  for (final Resource resource : resources) {
    final String resourceName = determineResourceName(resource);

    try {
      if (resourceName.endsWith(".bar") || resourceName.endsWith(".zip") || resourceName.endsWith(".jar")) {
        deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
      } else {
        deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
      }
    } catch (IOException e) {
      throw new ActivitiException("couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
    }
  }

  deploymentBuilder.deploy();

}
 
Example #24
Source File: ImportDefinedProcessModels.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void checkAndImportNewModels(RepositoryService repositoryService) throws IOException, XMLStreamException
{
	List<File> newModelFiles = checkNewModelNames(repositoryService);
	for (File modelFile : newModelFiles)
	{
		ModelUtils.importModel(repositoryService, modelFile);
	}
}
 
Example #25
Source File: ImportDefinedProcessModels.java    From openwebflow with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private List<File> checkNewModelNames(RepositoryService repositoryService) throws FileNotFoundException
{
	if (!_modelDir.exists())
		throw new FileNotFoundException(_modelDir.getPath());

	File[] files = _modelDir.listFiles(new FilenameFilter()
	{
		@Override
		public boolean accept(File dir, String name)
		{
			return name.endsWith(".bpmn");
		}
	});

	List<File> newModelFiles = new ArrayList<File>();
	if (files != null)
	{
		for (File file : files)
		{
			if (!exists(repositoryService, file.getName()))
			{
				newModelFiles.add(file);
			}
		}
	}

	return newModelFiles;
}
 
Example #26
Source File: ParseHandlerTestDataGenerator.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void generateTestData(ProcessEngine processEngine) {
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment().addClasspathResource("parseHandlerProcess.bpmn20.xml").deploy();

    RuntimeService runtimeService = processEngine.getRuntimeService();
    runtimeService.startProcessInstanceByKey("parseHandlerTestProcess");
}
 
Example #27
Source File: WorkspaceController.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 流程列表(所有的流程定义即流程模型)
 * 
 * @return
 */
@RequestMapping("workspace-listProcessDefinitions")
public String listProcessDefinitions(Model model) {
    String tenantId = tenantHolder.getTenantId();
    RepositoryService repositoryService = processEngine
            .getRepositoryService();
    List<ProcessDefinition> processDefinitions = repositoryService
            .createProcessDefinitionQuery()
            .processDefinitionTenantId(tenantId).active()
            .orderByProcessDefinitionId().list();
    model.addAttribute("processDefinitions", processDefinitions);

    return "bpm/workspace-listProcessDefinitions";
}
 
Example #28
Source File: ProcessConnectorImpl.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 流程定义.
 */
public Page findProcessDefinitions(String tenantId, Page page) {
    RepositoryService repositoryService = processEngine
            .getRepositoryService();
    long count = repositoryService.createProcessDefinitionQuery()
            .processDefinitionTenantId(tenantId).count();
    List<ProcessDefinition> processDefinitions = repositoryService
            .createProcessDefinitionQuery()
            .processDefinitionTenantId(tenantId)
            .listPage((int) page.getStart(), page.getPageSize());
    page.setResult(processDefinitions);
    page.setTotalCount(count);

    return page;
}
 
Example #29
Source File: SimulationRunContext.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public static RepositoryService getRepositoryService() {
  Stack<ProcessEngine> stack = getStack(processEngineThreadLocal);
  if (stack.isEmpty()) {
    return null;
  }
  return stack.peek().getRepositoryService();
}
 
Example #30
Source File: TestBPMN001.java    From bamboobsc with Apache License 2.0 5 votes vote down vote up
@Test
public void queryFlowImage() throws Exception {
	
	String deploymentId = "10001";
	RepositoryService repositoryService = (RepositoryService) AppContext.getBean("repositoryService");
	List<String> names = repositoryService.getDeploymentResourceNames(deploymentId);
	for (String name : names) {
		System.out.println( name );
		if (name.endsWith(".png") || name.endsWith(".bmp")) {
			InputStream is = repositoryService.getResourceAsStream(deploymentId, name);
			FileUtils.copyInputStreamToFile(is, new File("/tmp/" + name));
		}
	}
	
}