{"id":16179288,"url":"https://github.com/jonashackt/dmndemo","last_synced_at":"2025-04-07T11:43:32.855Z","repository":{"id":147269562,"uuid":"38606551","full_name":"jonashackt/dmndemo","owner":"jonashackt","description":"DMN-Decision Table example with camunda dmn-engine","archived":false,"fork":false,"pushed_at":"2019-05-24T11:45:14.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-13T14:24:29.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonashackt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-06T08:25:00.000Z","updated_at":"2024-12-11T03:08:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"e77f72b2-d6be-42f3-83b9-d4af3e112e8f","html_url":"https://github.com/jonashackt/dmndemo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fdmndemo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fdmndemo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fdmndemo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonashackt%2Fdmndemo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonashackt","download_url":"https://codeload.github.com/jonashackt/dmndemo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648923,"owners_count":20972942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T05:26:38.265Z","updated_at":"2025-04-07T11:43:32.833Z","avatar_url":"https://github.com/jonashackt.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dmndemo\n[![Build Status](https://travis-ci.org/jonashackt/dmndemo.svg?branch=master)](https://travis-ci.org/jonashackt/dmndemo)\n[![Coverage Status](https://coveralls.io/repos/jonashackt/dmndemo/badge.svg)](https://coveralls.io/r/jonashackt/dmndemo)\n\nSample Project showing Usage of [camunda DMN engine] working with DMN-compliant Decision Tables.\n\nIt uses [SpringBoot](http://projects.spring.io/spring-boot/) as a basis and performs a Test on a predefined decision-Table (for modelling see the [DMN Modeler](https://camunda.org/dmn/tool/) ).\n\n### Howto\n\nJust clone, mvn clean eclipse:eclipse and run the Test - e.g. in your IDE, to see what´s going on.\n\n### Call Java-Method from within DMN-Table to execute more complex logic\n\nIn some cases the build in Expression Language [FEEL](https://camunda.org/dmn/tutorial/#feel) isn´t sufficient to check more complex Logic. In this case, it´s nice to simply call a Java-Method from within your Decision-Table via the Groovy Expression Language, which is supported in camunda´s [DMN Expressions](https://docs.camunda.org/manual/7.4/user-guide/dmn-engine/expressions-and-scripts/).\n\nFor that you need to add Groovy to your Classpath (I omit the version here, because SpringBoot ships Groovy already):\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.codehaus.groovy\u003c/groupId\u003e\n  \u003cartifactId\u003egroovy-all\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\nIn your Decisiontable you need to define a simple column with a name (in this example it´s \"zip\") you´ll use later when calling the DMN-Engine and a appropriate Datatype - e.g. String.\n\nThen add your Custom-Logic within a Java-Class´ static method (that returns a boolean) to the Project,\nimport the Class in Groovy and call the Method - e.g. like that:\n```\nimport de.jonashackt.dmndemo.PostalcodeChecker\nreturn PostalcodeChecker.isValidPostalcode(cellInput);\n```\n\nNote the correct import of your Class and also note the usage of \"cellInput\" - which contains the Value to check, passed into the DMN-Engine along with the other Variables. \n\n**A Note for users of DMN-Modeler**: If you use the camunda [DMN-Modeler](https://camunda.org/dmn/tool/) (which is a good idea :) ): the last stable Version (0.3.x) removed the Script-Call at the moment - this didn´t happen with the current [Nightly-Build](https://camunda.org/release/camunda-modeler/nightly/) any more.\n\nYou need to resist to use the camunda-Modeler feature to insert a \"Script\" into a table column:\n\n![camunda_modeler_expression_script](https://github.com/jonashackt/dmndemo/blob/master/camunda_modeler_expression_script_screenshot.jpg)\n\nThis will execute the script all the time the decisiontable is evaluated.\n\nAs long as this [feature](https://github.com/bpmn-io/dmn-js/issues/20) isn´t shipped, there are 2 Options: \n\n**Option 1:** You have to open the dmn.xml in a texteditor and alter a rule yourself - e.g. like this:\n\n```\n\u003cinputEntry id=\"UnaryTests_0h6fb9j\" expressionLanguage=\"Groovy\"\u003e        \u003ctext\u003e\u003c![CDATA[import de.jonashackt.dmndemo.PostalcodeChecker\nreturn PostalcodeChecker.isValidPostalcode(cellInput);]]\u003e\u003c/text\u003e\n\u003c/inputEntry\u003e\n```\n**Option 2:** You insert the groovy-Script via the camunda-Modeler and open the XML after saving it up, to add the expressionlanguage-Definition to the right rule:\n```\n expressionLanguage=\"Groovy\"\n```\n\nNow if you run a Test, which fill´s the VariableMap correctly, it should evaluate your Rule and call the Java-Method with your Custom logic:\n\n```\n// Should be ok\nVariableMap variables = Variables\n        .putValue(\"state\", \"France\")\n        .putValue(\"product\", \"RedCar\")\n        .putValue(\"zip\", \"99425\");\n\nDmnDecisionTableResult result = dmnEngine.evaluateDecisionTable(states2ship, variables);\nassertNotNull(result.getSingleResult());\nassertEquals(\"notok\", result.getSingleResult().getEntryMap().get(\"result\"));\nassertEquals(\"sorry, no shipment possible\", result.getSingleResult().getEntryMap().get(\"reason\"));\n```\n\nTo see all this in Action, simply run [DmndemoApplicationTests.java](https://github.com/jonashackt/dmndemo/blob/master/src/test/java/de/jonashackt/dmndemo/DmndemoApplicationTests.java).\n\n[camunda DMN engine]:https://github.com/camunda/camunda-engine-dmn","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fdmndemo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonashackt%2Fdmndemo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonashackt%2Fdmndemo/lists"}