Java Code Examples for org.camunda.bpm.engine.impl.util.xml.Element#elements()

The following examples show how to use org.camunda.bpm.engine.impl.util.xml.Element#elements() . 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: BpmPlatformXmlParse.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
/**
 * parse a <code>&lt;job-acquisition .../&gt;</code> element and add it to the
 * list of parsed elements
 */
protected void parseJobAcquisition(Element element, List<JobAcquisitionXml> jobAcquisitions) {

  JobAcquisitionXmlImpl jobAcquisition = new JobAcquisitionXmlImpl();

  // set name
  jobAcquisition.setName(element.attribute(NAME));

  Map<String, String> properties = new HashMap<String, String>();

  for (Element childElement : element.elements()) {
    if (JOB_EXECUTOR_CLASS_NAME.equals(childElement.getTagName())) {
      jobAcquisition.setJobExecutorClassName(childElement.getText());

    } else if (PROPERTIES.equals(childElement.getTagName())) {
      parseProperties(childElement, properties);

    }
  }

  // set collected properties
  jobAcquisition.setProperties(properties);
  // add to list
  jobAcquisitions.add(jobAcquisition);

}
 
Example 2
Source File: DeploymentMetadataParse.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * Transform a <code>&lt;plugins ... /&gt;</code> structure.
 */
protected void parseProcessEnginePlugins(Element element, List<ProcessEnginePluginXml> plugins) {
  for (Element chidElement : element.elements()) {
    if(PLUGIN.equals(chidElement.getTagName())) {
      parseProcessEnginePlugin(chidElement, plugins);
    }
  }
}
 
Example 3
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
public void parseEndEvents(Element parentElement, ScopeImpl scope) {
    for (Element endEventElement : parentElement.elements("endEvent")) {
        parseEndEvent(parentElement, scope, endEventElement);
    }
}
 
Example 4
Source File: BpmnParseUtil.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * @throws BpmnParseException if the parameter is invalid
 */
protected static ParameterValueProvider parseParamValueProvider(Element parameterElement) {

  // LIST
  if("list".equals(parameterElement.getTagName())) {
    List<ParameterValueProvider> providerList = new ArrayList<ParameterValueProvider>();
    for (Element element : parameterElement.elements()) {
      // parse nested provider
      providerList.add(parseParamValueProvider(element));
    }
    return new ListValueProvider(providerList);
  }

  // MAP
  if("map".equals(parameterElement.getTagName())) {
    TreeMap<ParameterValueProvider, ParameterValueProvider> providerMap = new TreeMap<ParameterValueProvider, ParameterValueProvider>();
    for (Element entryElement : parameterElement.elements("entry")) {
      // entry must provide key
      String keyAttribute = entryElement.attribute("key");
      if(keyAttribute == null || keyAttribute.isEmpty()) {
        throw new BpmnParseException("Missing attribute 'key' for 'entry' element", entryElement);
      }
      // parse nested provider
      providerMap.put(new ElValueProvider(getExpressionManager().createExpression(keyAttribute)), parseNestedParamValueProvider(entryElement));
    }
    return new MapValueProvider(providerMap);
  }

  // SCRIPT
  if("script".equals(parameterElement.getTagName())) {
    ExecutableScript executableScript = parseCamundaScript(parameterElement);
    if (executableScript != null) {
      return new ScriptValueProvider(executableScript);
    }
    else {
      return new NullValueProvider();
    }
  }

  String textContent = parameterElement.getText().trim();
  if(!textContent.isEmpty()) {
      // EL
      return new ElValueProvider(getExpressionManager().createExpression(textContent));
  } else {
    // NULL value
    return new NullValueProvider();
  }

}
 
Example 5
Source File: DeploymentMetadataParse.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * parse a <code>&lt;process-engine .../&gt;</code> element and add it to the list of parsed elements
 */
protected void parseProcessEngine(Element element, List<ProcessEngineXml> parsedProcessEngines) {

  ProcessEngineXmlImpl processEngine = new ProcessEngineXmlImpl();

  // set name
  processEngine.setName(element.attribute(NAME));

  // set default
  String defaultValue = element.attribute(DEFAULT);
  if(defaultValue == null || defaultValue.isEmpty()) {
    processEngine.setDefault(false);
  } else {
    processEngine.setDefault(Boolean.parseBoolean(defaultValue));
  }

  Map<String, String> properties = new HashMap<String, String>();
  List<ProcessEnginePluginXml> plugins = new ArrayList<ProcessEnginePluginXml>();

  for (Element childElement : element.elements()) {
    if(CONFIGURATION.equals(childElement.getTagName())) {
      processEngine.setConfigurationClass(childElement.getText());

    } else if(DATASOURCE.equals(childElement.getTagName())) {
      processEngine.setDatasource(childElement.getText());

    } else if(JOB_ACQUISITION.equals(childElement.getTagName())) {
      processEngine.setJobAcquisitionName(childElement.getText());

    } else if(PROPERTIES.equals(childElement.getTagName())) {
      parseProperties(childElement, properties);

    } else if(PLUGINS.equals(childElement.getTagName())) {
      parseProcessEnginePlugins(childElement, plugins);

    }
  }

  // set collected properties
  processEngine.setProperties(properties);
  // set plugins
  processEngine.setPlugins(plugins);
  // add the process engine to the list of parsed engines.
  parsedProcessEngines.add(processEngine);

}
 
Example 6
Source File: DeploymentMetadataParse.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * Transform a <code>&lt;plugin ... /&gt;</code> structure.
 */
protected void parseProcessEnginePlugin(Element element, List<ProcessEnginePluginXml> plugins) {

  ProcessEnginePluginXmlImpl plugin = new ProcessEnginePluginXmlImpl();

  Map<String, String> properties = new HashMap<String, String>();

  for (Element childElement : element.elements()) {
    if(PLUGIN_CLASS.equals(childElement.getTagName())) {
      plugin.setPluginClass(childElement.getText());

    } else if(PROPERTIES.equals(childElement.getTagName())) {
      parseProperties(childElement, properties);

    }

  }

  plugin.setProperties(properties);
  plugins.add(plugin);
}
 
Example 7
Source File: BpmPlatformXmlParse.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
/**
 * parse a <code>&lt;job-executor .../&gt;</code> element and add it to the list of parsed elements
 */
protected void parseJobExecutor(Element element, JobExecutorXmlImpl jobExecutorXml) {

  List<JobAcquisitionXml> jobAcquisitions = new ArrayList<JobAcquisitionXml>();
  Map<String, String> properties = new HashMap<String, String>();

  for (Element childElement : element.elements()) {

    if(JOB_ACQUISITION.equals(childElement.getTagName())) {
      parseJobAcquisition(childElement, jobAcquisitions);

    }else if(PROPERTIES.equals(childElement.getTagName())){
      parseProperties(childElement, properties);
    }

  }

  jobExecutorXml.setJobAcquisitions(jobAcquisitions);
  jobExecutorXml.setProperties(properties);

}
 
Example 8
Source File: ProcessesXmlParse.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
/**
 * parse a <code>&lt;process-archive .../&gt;</code> element and add it to the list of parsed elements
 */
protected void parseProcessArchive(Element element, List<ProcessArchiveXml> parsedProcessArchives) {

  ProcessArchiveXmlImpl processArchive = new ProcessArchiveXmlImpl();

  processArchive.setName(element.attribute(NAME));
  processArchive.setTenantId(element.attribute(TENANT_ID));

  List<String> processResourceNames = new ArrayList<String>();

  Map<String, String> properties = new HashMap<String, String>();
  for (Element childElement : element.elements()) {
    if(PROCESS_ENGINE.equals(childElement.getTagName())) {
      processArchive.setProcessEngineName(childElement.getText());

    } else if(PROCESS.equals(childElement.getTagName()) || RESOURCE.equals(childElement.getTagName())) {
      processResourceNames.add(childElement.getText());

    } else if(PROPERTIES.equals(childElement.getTagName())) {
      parseProperties(childElement, properties);

    }
  }

  // set properties
  processArchive.setProperties(properties);

  // add collected resource names.
  processArchive.setProcessResourceNames(processResourceNames);

  // add process archive to list of parsed archives.
  parsedProcessArchives.add(processArchive);

}
 
Example 9
Source File: DeploymentMetadataParse.java    From camunda-bpm-platform with Apache License 2.0 3 votes vote down vote up
/**
 * Transform a
 * <pre>
 * &lt;properties&gt;
 *   &lt;property name="name"&gt;value&lt;/property&gt;
 * &lt;/properties&gt;
 * </pre>
 * structure into a properties {@link Map}
 *
 * Supports resolution of Ant-style placeholders against system properties.
 *
 */
protected void parseProperties(Element element, Map<String, String> properties) {

  for (Element childElement : element.elements()) {
    if(PROPERTY.equals(childElement.getTagName())) {
      String resolved = PropertyHelper.resolveProperty(System.getProperties(), childElement.getText());
      properties.put(childElement.attribute(NAME), resolved);
    }
  }

}