如何使用自定义触发器向camunda属性面板添加动态值到字段注入列表?

时间:2017-03-31 05:36:04

标签: camunda bpmn.io camunda-modeler

我这里有两个问题

  1. 是否可以将动态列表值添加到字段注入列表输入?
  2. 我可以为此创建一个触发器,以便可以从任何其他输入选择启动,例如类选择将填充所有字段
  3. 我只是在调查FieldInjection.js是否可以为同一个

    扩展

    enter image description here

    有人可以为此提供提示或指示吗?

    感谢。

1 个答案:

答案 0 :(得分:0)

对于对答案感兴趣的人,我可以通过更改Java Class选择输入的set函数来实现上述目标

少数进口

var extensionElementsHelper = require('../../../../helper/ExtensionElementsHelper'),
    elementHelper = require('../../../../helper/ElementHelper')

var CAMUNDA_FIELD_EXTENSION_ELEMENT = 'camunda:Field';

function getExtensionFields(bo) {
      return bo && extensionElementsHelper.getExtensionElements(bo, CAMUNDA_FIELD_EXTENSION_ELEMENT) || [];
}

然后更改set函数以创建扩展元素并将字段值推送为:

set: function(element, values, node) {
      var bo = getBusinessObject(element);
      var type = getImplementationType(element);
      var attr = getAttribute(type);
      var prop = {}
      var commands = [];
      prop[attr] = values.delegate || '';
      var extensionElements = getExtensionFields(bo);
      //remove any extension elements existing before
      extensionElements.forEach(function(ele){
        commands.push(extensionElementsHelper.removeEntry(getBusinessObject(element), element, ele));
      });
      if(prop[attr] !== ""){
        var extensionElements = elementHelper.createElement('bpmn:ExtensionElements', { values: [] }, bo, bpmnFactory);
        commands.push(cmdHelper.updateBusinessObject(element, bo, { extensionElements: extensionElements }));
        var arrProperties = ["private org.camunda.bpm.engine.delegate.Expression com.cfe.extensions.SampleJavaDelegate.varOne","private org.camunda.bpm.engine.delegate.Expression com.cfe.extensions.SampleJavaDelegate.varTwo"]

        var newFieldElem = "";
        arrProperties.forEach(function(prop){
          var eachProp = {
            name:"",
            string:"",
            expression:""
          }
          var type = prop.split(" ")[1].split(".").reverse()[0];
          var val = prop.split(" ")[2].split(".").reverse()[0];
          eachProp.name = val;
          if( type == "String"){
            eachProp.string = "${" + val  +" }"
          }else if( type == "Expression"){
            eachProp.expression = "${" + val  +" }"
          }

          newFieldElem = elementHelper.createElement(CAMUNDA_FIELD_EXTENSION_ELEMENT, eachProp, extensionElements, bpmnFactory);
          commands.push(cmdHelper.addElementsTolist(element, extensionElements, 'values', [ newFieldElem ]));
        });
      }
      commands.push(cmdHelper.updateBusinessObject(element, bo, prop));
      return commands;
    }

干杯!