steffenbrand/dmn-decision-tables 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

steffenbrand/dmn-decision-tables

Composer 安装命令:

composer require steffenbrand/dmn-decision-tables

包简介

PHP library to programmatically create DMN decision tables.

README 文档

README

Build Scrutinizer Code Quality Latest Stable Version Total Downloads License

DMN Decision Tables

PHP library to programmatically create DMN decision tables

Limitations

  • Generated tables have been tested with Camunda BPM platform and Camunda Cloud, but have NOT been tested with any other BPMN engine
  • Only FEEL and JUEL expressions have been tested yet
  • Only one decision table is supported per .dmn-file
  • No DRD features are supported
  • IDs are generated randomly, as you can see from the examples below

How to install

composer require steffenbrand/dmn-decision-tables

How to use

These examples show how to build the Camunda Cloud example table

Build decision table

try {
    $decisionTable = DecisionTableBuilder::getInstance()
        ->setName('Dish')
        ->setDefinitionKey('decision')
        ->setHitPolicy(HitPolicy::UNIQUE_POLICY)
        ->addInput(new Input('Season', 'season', VariableType::STRING_TYPE))
        ->addInput(new Input('How many guests', 'guests', VariableType::INTEGER_TYPE))
        ->addOutput(new Output('Dish', 'dish', VariableType::STRING_TYPE))
        ->addRule(
            [
                new InputEntry('"Fall"', ExpressionLanguage::FEEL_LANGUAGE),
                new InputEntry('<= 8', ExpressionLanguage::FEEL_LANGUAGE)
            ],
            [new OutputEntry('"Spareribs"', ExpressionLanguage::JUEL_LANGUAGE)]
        )
        ->addRule(
            [new InputEntry('"Winter"'), new InputEntry('<= 8')],
            [new OutputEntry('"Roastbeef"')]
        )
        ->addRule(
            [new InputEntry('"Spring"'), new InputEntry('<= 4')],
            [new OutputEntry('"Dry Aged Gourmet Steak"')]
        )
        ->addRule(
            [new InputEntry('"Spring"'), new InputEntry('[5..8]')],
            [new OutputEntry('"Steak"')],
            'Save money'
        )
        ->addRule(
            [new InputEntry('"Fall", "Winter", "Spring"'), new InputEntry('> 8')],
            [new OutputEntry('"Stew"')],
            'Less effort'
        )
        ->addRule(
            [new InputEntry('"Summer"'), new InputEntry(null)],
            [new OutputEntry('"Light Salad and a nice Steak"')],
            'Hey, why not!?'
        )
        ->build();
} catch (DmnValidationException $e) {
    // Build method validates before it creates the DecisionTable.
    // Can be disabled, so feel free to validate yourself.
    // Use the DecisionTableValidator or inject your own validator.
} catch (DmnConversionException $e) {
    // Conversion to XML might fail because of invalid expressions or whatever.
}

Convert to DMN string (XML)

$decisionTable->toDMN();

Save to filesystem

$decisionTable->saveFile('/my/path/and/filename.dmn');

What the result looks like

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn11.xsd" id="definitions" name="definitions" namespace="http://camunda.org/schema/1.0/dmn">
  <decision id="decision" name="Dish">
    <decisionTable id="decisionTable5990364503747" hitPolicy="UNIQUE">
      <input id="input599036450376b" label="Season">
        <inputExpression id="inputExpression5990364503774" typeRef="string">
          <text>season</text>
        </inputExpression>
      </input>
      <input id="input5990364503786" label="How many guests">
        <inputExpression id="inputExpression5990364503790" typeRef="integer">
          <text>guests</text>
        </inputExpression>
      </input>
      <output id="output59903645037c4" label="Dish" name="dish" typeRef="string"/>
      <rule id="rule59903645037de">
        <inputEntry id="inputEntry59903645037fb" expressionLanguage="feel">
          <text><![CDATA["Fall"]]></text>
        </inputEntry>
        <inputEntry id="inputEntry5990364503816" expressionLanguage="feel">
          <text><![CDATA[<= 8]]></text>
        </inputEntry>
        <outputEntry id="outputEntry5990364503833" expressionLanguage="juel">
          <text><![CDATA["Spareribs"]]></text>
        </outputEntry>
      </rule>
      <rule id="rule5990364503847">
        <inputEntry id="inputEntry5990364503880" expressionLanguage="feel">
          <text><![CDATA["Winter"]]></text>
        </inputEntry>
        <inputEntry id="inputEntry59903645038bf" expressionLanguage="feel">
          <text><![CDATA[<= 8]]></text>
        </inputEntry>
        <outputEntry id="outputEntry59903645038ee" expressionLanguage="juel">
          <text><![CDATA["Roastbeef"]]></text>
        </outputEntry>
      </rule>
      <rule id="rule59903645038fc">
        <inputEntry id="inputEntry599036450390a" expressionLanguage="feel">
          <text><![CDATA["Spring"]]></text>
        </inputEntry>
        <inputEntry id="inputEntry5990364503916" expressionLanguage="feel">
          <text><![CDATA[<= 4]]></text>
        </inputEntry>
        <outputEntry id="outputEntry5990364503922" expressionLanguage="juel">
          <text><![CDATA["Dry Aged Gourmet Steak"]]></text>
        </outputEntry>
      </rule>
      <rule id="rule5990364503930">
        <description>Save money</description>
        <inputEntry id="inputEntry599036450393e" expressionLanguage="feel">
          <text><![CDATA["Spring"]]></text>
        </inputEntry>
        <inputEntry id="inputEntry599036450394d" expressionLanguage="feel">
          <text><![CDATA[[5..8]]]></text>
        </inputEntry>
        <outputEntry id="outputEntry5990364503961" expressionLanguage="juel">
          <text><![CDATA["Steak"]]></text>
        </outputEntry>
      </rule>
      <rule id="rule599036450396e">
        <description>Less effort</description>
        <inputEntry id="inputEntry599036450397b" expressionLanguage="feel">
          <text><![CDATA["Fall", "Winter", "Spring"]]></text>
        </inputEntry>
        <inputEntry id="inputEntry5990364503985" expressionLanguage="feel">
          <text><![CDATA[> 8]]></text>
        </inputEntry>
        <outputEntry id="outputEntry5990364503991" expressionLanguage="juel">
          <text><![CDATA["Stew"]]></text>
        </outputEntry>
      </rule>
      <rule id="rule599036450399d">
        <description>Hey, why not!?</description>
        <inputEntry id="inputEntry59903645039ab" expressionLanguage="feel">
          <text><![CDATA["Summer"]]></text>
        </inputEntry>
        <inputEntry id="inputEntry59903645039b4">
          <text/>
        </inputEntry>
        <outputEntry id="outputEntry59903645039c0" expressionLanguage="juel">
          <text><![CDATA["Light Salad and a nice Steak"]]></text>
        </outputEntry>
      </rule>
    </decisionTable>
  </decision>
</definitions>

Try it

Feel free to download generated_with_dmn_decision_tables.dmn and try it in the Camunda Cloud

steffenbrand/dmn-decision-tables 适用场景与选型建议

steffenbrand/dmn-decision-tables 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.06k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2017 年 08 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「camunda」 「bpmn」 「DMN」 「Decision Table」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 steffenbrand/dmn-decision-tables 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 steffenbrand/dmn-decision-tables 我们能提供哪些服务?
定制开发 / 二次开发

基于 steffenbrand/dmn-decision-tables 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 17.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 20
  • 点击次数: 24
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 19
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-13