当前位置: 首页>>代码示例>>Java>>正文


Java BpmnXMLConverter.convertToBpmnModel方法代码示例

本文整理汇总了Java中org.activiti.bpmn.converter.BpmnXMLConverter.convertToBpmnModel方法的典型用法代码示例。如果您正苦于以下问题:Java BpmnXMLConverter.convertToBpmnModel方法的具体用法?Java BpmnXMLConverter.convertToBpmnModel怎么用?Java BpmnXMLConverter.convertToBpmnModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.activiti.bpmn.converter.BpmnXMLConverter的用法示例。


在下文中一共展示了BpmnXMLConverter.convertToBpmnModel方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertToModelTest

import org.activiti.bpmn.converter.BpmnXMLConverter; //导入方法依赖的package包/类
@Test
public void convertToModelTest() throws Exception {

	BpmnModel bpmnModel = buildModel();
	BpmnXMLConverter converter = new BpmnXMLConverter();
	String xml = new String(converter.convertToXML(bpmnModel), "UTF-8");

	byte[] bytes = xml.getBytes();
	ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);

	XMLInputFactory xif = XMLInputFactory.newInstance();
	InputStreamReader in = new InputStreamReader(inputStream, "UTF-8");
	XMLStreamReader xtr = xif.createXMLStreamReader(in);

	bpmnModel = converter.convertToBpmnModel(xtr);

	xml = new String(converter.convertToXML(bpmnModel), "UTF-8");
	System.out.println(xml);
}
 
开发者ID:KayuraTeam,项目名称:kayura-activiti,代码行数:20,代码来源:BpmnModelTest.java

示例2: testXmlToBpmnModel

import org.activiti.bpmn.converter.BpmnXMLConverter; //导入方法依赖的package包/类
/**
 * 把XML转换成BpmnModel对象
 * @throws Exception
 */
@Test
@Deployment(resources = "chapter6/dynamic-form/leave.bpmn")
public void testXmlToBpmnModel() throws Exception {

    // 验证是否部署成功
    long count = repositoryService.createProcessDefinitionQuery().count();
    assertEquals(1, count);

    // 根据流程定义获取XML资源文件流对象
    /*ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("leave").singleResult();
    String resourceName = processDefinition.getResourceName();
    InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), resourceName);*/

    // 从classpath中获取
    InputStream inputStream = getClass().getClassLoader().getResourceAsStream("chapter6/dynamic-form/leave.bpmn");

    // 创建转换对象
    BpmnXMLConverter converter = new BpmnXMLConverter();

    // 创建XMLStreamReader读取XML资源
    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLStreamReader reader = factory.createXMLStreamReader(inputStream);

    // 把XML转换成BpmnModel对象
    BpmnModel bpmnModel = converter.convertToBpmnModel(reader);

    // 验证BpmnModel对象不为空
    assertNotNull(bpmnModel);
    Process process = bpmnModel.getMainProcess();
    assertEquals("leave", process.getId());
}
 
开发者ID:barudisshu,项目名称:activiti-in-action-codes,代码行数:36,代码来源:BpmnModelTest.java

示例3: execute

import org.activiti.bpmn.converter.BpmnXMLConverter; //导入方法依赖的package包/类
public BpmnModel execute(CommandContext commandContext) {
  if (processDefinitionId == null) {
    throw new ActivitiIllegalArgumentException("processDefinitionId is null");
  }

  // Find the bpmn 2.0 xml resource name which is stored on the process definition
  ProcessDefinitionEntity processDefinitionEntity = commandContext
          .getProcessDefinitionEntityManager()
          .findProcessDefinitionById(processDefinitionId);
  
  if (processDefinitionEntity == null) {
    throw new ActivitiObjectNotFoundException("Process definition does not exist: " + processDefinitionId, ProcessDefinitionEntity.class);
  }

  // Fetch the resource
  String resourceName = processDefinitionEntity.getResourceName();
  ResourceEntity resource = commandContext.getResourceEntityManager()
          .findResourceByDeploymentIdAndResourceName(processDefinitionEntity.getDeploymentId(), resourceName);
  if (resource == null) {
    if (commandContext.getDeploymentEntityManager().findDeploymentById(processDefinitionEntity.getDeploymentId()) == null) {
      throw new ActivitiObjectNotFoundException("deployment for process definition does not exist: " 
    + processDefinitionEntity.getDeploymentId(), Deployment.class);
    } else {
      throw new ActivitiObjectNotFoundException("no resource found with name '" + resourceName 
              + "' in deployment '" + processDefinitionEntity.getDeploymentId() + "'", InputStream.class);
    }
  }
  
  // Convert the bpmn 2.0 xml to a bpmn model
  BpmnXMLConverter bpmnXMLConverter = new BpmnXMLConverter();
  return bpmnXMLConverter.convertToBpmnModel(new BytesStreamSource(resource.getBytes()), false, false); // no need to validate schema, it was already validated on deploy
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:33,代码来源:GetBpmnModelCmd.java

示例4: execute

import org.activiti.bpmn.converter.BpmnXMLConverter; //导入方法依赖的package包/类
public BpmnParse execute() {
  try {
    BpmnXMLConverter converter = new BpmnXMLConverter();
    
    boolean enableSafeBpmnXml = false;
    String encoding = null;
    if (Context.getProcessEngineConfiguration() != null) {
      enableSafeBpmnXml = Context.getProcessEngineConfiguration().isEnableSafeBpmnXml();
      encoding = Context.getProcessEngineConfiguration().getXmlEncoding();
    }
    
    if (encoding != null) {
      bpmnModel = converter.convertToBpmnModel(streamSource, true, enableSafeBpmnXml, encoding);
    } else {
      bpmnModel = converter.convertToBpmnModel(streamSource, true, enableSafeBpmnXml);
    }
    
    createImports();
    createItemDefinitions();
    createMessages();
    createOperations();
    transformProcessDefinitions();
  } catch (Exception e) {
    if (e instanceof ActivitiException) {
      throw (ActivitiException) e;
    } else {
      throw new ActivitiException("Error parsing XML", e);
    }
  }

  if (bpmnModel.getProblems().size() > 0) {
    StringBuilder problemBuilder = new StringBuilder();
    for (Problem error : bpmnModel.getProblems()) {
      problemBuilder.append(error.toString());
      problemBuilder.append("\n");
    }
    throw new ActivitiException("Errors while parsing:\n" + problemBuilder.toString());
  }

  return this;
}
 
开发者ID:springvelocity,项目名称:xbpm5,代码行数:42,代码来源:BpmnParse.java


注:本文中的org.activiti.bpmn.converter.BpmnXMLConverter.convertToBpmnModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。