org.camunda.bpm.model.bpmn.Bpmn.readModelFromFile()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.2k)|赞(0)|评价(0)|浏览(341)

本文整理了Java中org.camunda.bpm.model.bpmn.Bpmn.readModelFromFile()方法的一些代码示例,展示了Bpmn.readModelFromFile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bpmn.readModelFromFile()方法的具体详情如下:
包路径:org.camunda.bpm.model.bpmn.Bpmn
类名称:Bpmn
方法名:readModelFromFile

Bpmn.readModelFromFile介绍

[英]Allows reading a BpmnModelInstance from a File.
[中]允许从文件中读取BpmnModelInstance。

代码示例

代码示例来源:origin: camunda/camunda-bpm-platform

private static List<String> extractProcessDefinitionKeys(List<String> deployableFileNames) {
 ArrayList<String> keys = new ArrayList<String>();
 for (String file : deployableFileNames) {
  if(file.endsWith(".bpmn") || file.endsWith(".bpmn20.xml")) {
   BpmnModelInstance modelInstance = Bpmn.readModelFromFile(new File(file));
   Collection<Process> processes = modelInstance.getModelElementsByType(Process.class);
   for (Process process : processes) {
    if(process.isExecutable()) {
     keys.add(process.getId());
    }
   }
  }
 }
 return keys;
}

代码示例来源:origin: viadee/vPAV

/**
 * Map for getting bpmn reference by process id
 *
 * @param paths
 * @return
 */
private static Map<String, String> createProcessIdToPathMap(final Set<String> paths) {
  final Map<String, String> keyToPathMap = new HashMap<String, String>();
  for (final String path : paths) {
    // read bpmn file
    BpmnModelInstance modelInstance = null;
    try {
      modelInstance = Bpmn.readModelFromFile(new File(ConfigConstants.BASEPATH + path));
    } catch (final BpmnModelException ex) {
      throw new RuntimeException("bpmn model couldn't be read", ex);
    }
    // if bpmn file could read
    if (modelInstance != null) {
      // find process
      final Collection<Process> processes = modelInstance.getModelElementsByType(Process.class);
      if (processes != null) {
        for (final Process process : processes) {
          // save path for each process
          keyToPathMap.put(process.getId(), path);
        }
      }
    }
  }
  return keyToPathMap;
}

代码示例来源:origin: viadee/vPAV

/**
 * Read and transform process definition into data flows
 *
 * @param context
 *            JavaReaderContext
 * @param fileScanner
 *            FileScanner
 * @param calledElementHierarchy
 *            Collection of Element Hierarchy
 * @param callActivityPath
 *            CallActivityPath
 * @param scanner
 *            OuterProcessVariableScanner
 * @return Collection of IGraphs (subgraphs)
 */
private Collection<IGraph> createSubDataFlowsFromCallActivity(final JavaReaderContext context,
    FileScanner fileScanner, final Collection<String> calledElementHierarchy, final String callActivityPath,
    final ProcessVariablesScanner scanner) {
  // read called process
  final BpmnModelInstance submodel = Bpmn.readModelFromFile(new File(callActivityPath));
  // transform process into data flow
  final ElementGraphBuilder graphBuilder = new ElementGraphBuilder(decisionRefToPathMap, processIdToPathMap,
      messageIdToVariables, processIdToVariables, bpmnScanner);
  final Collection<IGraph> subgraphs = graphBuilder.createProcessGraph(context, fileScanner, submodel,
      callActivityPath, calledElementHierarchy, scanner);
  return subgraphs;
}

代码示例来源:origin: viadee/vPAV

final BpmnModelInstance modelInstance = Bpmn.readModelFromFile(processdefinition);

代码示例来源:origin: viadee/vPAV

public static Collection<ProcessVariable> parseProcessVariables(File modelFile, ApplicationContext ctx) {
  RuntimeConfig.getInstance().setApplicationContext(ctx);
  RuntimeConfig.getInstance().setBeanMapping(BeanMappingGenerator.generateBeanMappingFile(ctx));
  RuntimeConfig.getInstance().setClassLoader(ProcessApplicationValidator.class.getClassLoader());
  FileScanner fileScanner = new FileScanner(new HashMap<>(), ConfigConstants.JAVAPATH);
  ProcessVariablesScanner variableScanner = readOuterProcessVariables(fileScanner);
  BpmnScanner bpmnScanner = createScanner(modelFile);
  final BpmnModelInstance modelInstance = Bpmn.readModelFromFile(modelFile);
  // hold bpmn elements
  final Collection<BaseElement> baseElements = modelInstance
      .getModelElementsByType(BaseElement.class);
  final ElementGraphBuilder graphBuilder = new ElementGraphBuilder(fileScanner.getDecisionRefToPathMap(),
      fileScanner.getProcessIdToPathMap(), variableScanner.getMessageIdToVariableMap(),
      variableScanner.getProcessIdToVariableMap(), bpmnScanner);
  final Collection<BpmnElement> bpmnElements =
      BpmnModelDispatcher.getBpmnElements(modelFile, baseElements, graphBuilder);
  return BpmnModelDispatcher.getProcessVariables(bpmnElements);
}

代码示例来源:origin: viadee/vPAV

final BpmnModelInstance modelInstance = Bpmn.readModelFromFile(processdefinition);

相关文章