{"id":26571214,"url":"https://github.com/materna-se/jdec","last_synced_at":"2025-03-22T22:35:32.418Z","repository":{"id":36103582,"uuid":"190413750","full_name":"materna-se/jdec","owner":"materna-se","description":"🤔 Java library that offers a unified interface to DMN and Java decisions","archived":false,"fork":false,"pushed_at":"2024-10-03T17:03:42.000Z","size":242,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-01T12:24:32.469Z","etag":null,"topics":["java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/materna-se.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-06-05T14:47:08.000Z","updated_at":"2024-07-22T08:30:54.000Z","dependencies_parsed_at":"2024-07-22T09:55:44.388Z","dependency_job_id":null,"html_url":"https://github.com/materna-se/jdec","commit_stats":null,"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/materna-se%2Fjdec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/materna-se%2Fjdec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/materna-se%2Fjdec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/materna-se%2Fjdec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/materna-se","download_url":"https://codeload.github.com/materna-se/jdec/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245029801,"owners_count":20549769,"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":["java"],"created_at":"2025-03-22T22:35:31.815Z","updated_at":"2025-03-22T22:35:32.404Z","avatar_url":"https://github.com/materna-se.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jDEC\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/github/license/materna-se/jdec.svg?style=flat-square\"\u003e\n  \u003cimg src=\"https://img.shields.io/circleci/build/github/materna-se/jdec.svg?style=flat-square\"\u003e\n  \u003cimg src=\"https://img.shields.io/maven-central/v/com.github.materna-se/jdec?style=flat-square\"\u003e\n  \u003cimg src=\"https://img.shields.io/nexus/s/com.github.materna-se/jdec?server=https%3A%2F%2Foss.sonatype.org\u0026label=maven-snapshot\u0026style=flat-square\"\u003e\n\u003c/p\u003e\n\njDEC is a Java library designed to provide a unified interface for executing decisions. The decisions can be modeled with [DMN](https://www.omg.org/spec/DMN) (Decision Model and Notation) or with Java.\n\n## Download\n\njDEC is published to the Maven Central Repository. To get the release versions, you can add the following dependency to your your build management tool. In addition, snapshot versions are published at more regular intervals to the Maven Snapshot Repository. All available versions are also tagged and can be seen at https://github.com/materna-se/jdec/releases.\n\n### Maven\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.materna-se\u003c/groupId\u003e\n    \u003cartifactId\u003ejdec\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\nIf you want to download the snapshot versions, the following repository must also be added:\n```xml\n\u003crepository\u003e\n    \u003cid\u003esonatype-snapshot-repository\u003c/id\u003e\n    \u003curl\u003ehttp://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n    \u003creleases\u003e\n        \u003cenabled\u003efalse\u003c/enabled\u003e\n    \u003c/releases\u003e\n    \u003csnapshots\u003e\n        \u003cenabled\u003etrue\u003c/enabled\u003e\n    \u003c/snapshots\u003e\n\u003c/repository\u003e\n```\n\n### Gradle\n```gradle\ncompile group: 'com.github.materna-se', name: 'jdec', version: 'VERSION'\n```\n\n## Documentation\n\nDecisions can be modeled with DMN with applications like the [Trisotech Decision Modeler](https://www.trisotech.com/digital-modeling-suite), the [ACTICO Platform](https://www.actico.com/platform/dmn-decision-model-notation) or the [Red Hat Decision Manager](https://www.redhat.com/de/technologies/jboss-middleware/decision-manager). After the decisions are modeled, they can be exported as XML:\n```xml\n\u003cdefinitions namespace=\"https://github.com/agilepro/dmn-tck\" name=\"0003-input-data-string-allowed-values\" id=\"_0003-input-data-string-allowed-values\" xmlns=\"http://www.omg.org/spec/DMN/20180521/MODEL/\"\u003e\n    \u003citemDefinition name=\"tEmploymentStatus\"\u003e\n        \u003ctypeRef\u003estring\u003c/typeRef\u003e\n        \u003callowedValues\u003e\n            \u003ctext\u003e\"UNEMPLOYED\",\"EMPLOYED\",\"SELF-EMPLOYED\",\"STUDENT\"\u003c/text\u003e\n        \u003c/allowedValues\u003e\n    \u003c/itemDefinition\u003e\n    \u003cdecision name=\"Employment Status Statement\" id=\"d_EmploymentStatusStatement\"\u003e\n        \u003cvariable typeRef=\"string\" name=\"Employment Status Statement\"/\u003e\n        \u003cinformationRequirement id=\"f4a0451b-8db5-401a-b9b4-dc31416b6e7d\"\u003e\n            \u003crequiredInput href=\"#i_EmploymentStatus\"/\u003e\n        \u003c/informationRequirement\u003e\n        \u003cliteralExpression\u003e\n            \u003ctext\u003e\"You are \" + Employment Status\u003c/text\u003e\n        \u003c/literalExpression\u003e\n    \u003c/decision\u003e\n    \u003cinputData name=\"Employment Status\" id=\"i_EmploymentStatus\"\u003e\n        \u003cvariable typeRef=\"tEmploymentStatus\" name=\"Employment Status\"/\u003e\n    \u003c/inputData\u003e\n\u003c/definitions\u003e\n```\n\nIn addition to DMN, the decisions can be modeled with Java by extending the abstract class `DecisionModel`: \n```java\npackage de.materna.jdec.java.test;\n\nimport de.materna.jdec.java.DecisionModel;\nimport de.materna.jdec.model.ComplexInputStructure;\nimport de.materna.jdec.model.ExecutionResult;\nimport de.materna.jdec.model.InputStructure;\n\nimport java.util.Arrays;\nimport java.util.HashMap;\nimport java.util.LinkedHashMap;\nimport java.util.Map;\n\npublic class EmploymentStatusDecision extends DecisionModel {\n\t@Override\n\tpublic ComplexInputStructure getInputStructure() {\n\t\tMap\u003cString, InputStructure\u003e inputs = new LinkedHashMap\u003c\u003e();\n\n\t\tInputStructure inputStructure = new InputStructure(\"string\", Arrays.asList(\"UNEMPLOYED\", \"EMPLOYED\", \"SELF-EMPLOYED\", \"STUDENT\"));\n\t\tinputs.put(\"Employment Status\", inputStructure);\n\n\t\treturn new ComplexInputStructure(\"object\", inputs);\n\t}\n\n\t@Override\n\tpublic Map\u003cString, Object\u003e executeDecision(Map\u003cString, Object\u003e inputs) {\n\t\tMap\u003cString, Object\u003e output = new HashMap\u003c\u003e();\n\t\toutput.put(\"Employment Status Statement\", \"You are \" + inputs.get(\"Employment Status\"));\n\t\treturn output;\n\t}\n}\n```\n\nOnce the decisions are modeled, they can be used with jDEC. For this purpose, a DecisionSession can be created with three different modes to choose from:\n- `DMNDecisionSession`: Accepts only DMN decisions, components to execute Java decisions are not imported.\n- `JavaDecisionSession`: Accepts only Java decisions, components to execute DMN decisions are not imported.\n- `HybridDecisionSession`: Accepts DMN and Java decisions, even referencing a decision of one language in a decision of another language during execution is possible.\n\nIf `DMNDecisionSession` or `HybridDecisionSession` is used, DMN decisions can be imported and executed like this:\n```java\nDecisionSession decisionSession = new DMNDecisionSession();\ndecisionSession.importModel(\"https://github.com/agilepro/dmn-tck\", \"0003-input-data-string-allowed-values\", /* Decision Source */);\n\nMap\u003cString, Object\u003e inputs = new HashMap\u003c\u003e();\ninputs.put(\"Employment Status\", \"UNEMPLOYED\");\n\nMap\u003cString, Object\u003e outputs = decisionSession.executeModel(\"https://github.com/agilepro/dmn-tck\", \"0003-input-data-string-allowed-values\", inputs);\nSystem.out.println(\"executeHashMap(): \" + outputs);\n\nAssertions.assertTrue(outputs.containsKey(\"Employment Status Statement\"));\nAssertions.assertEquals(\"You are UNEMPLOYED\", outputs.get(\"Employment Status Statement\"));\n```\n\nIf `JavaDecisionSession` or `HybridDecisionSession` is used, Java decisions can be imported and executed like this:\n```java\nDecisionSession decisionSession = new JavaDecisionSession();\ndecisionSession.importModel(\"de.materna.jdec.java.test\", \"EmploymentStatusDecision\", /* Decision Source */);\n\nMap\u003cString, Object\u003e inputs = new HashMap\u003c\u003e();\ninputs.put(\"Employment Status\", \"UNEMPLOYED\");\n\nMap\u003cString, Object\u003e outputs = decisionSession.executeModel(\"de.materna.jdec.java.test\", \"EmploymentStatusDecision\", inputs);\nSystem.out.println(\"executeHashMap(): \" + outputs);\n\nAssertions.assertTrue(outputs.containsKey(\"Employment Status Statement\"));\nAssertions.assertEquals(\"You are UNEMPLOYED\", outputs.get(\"Employment Status Statement\"));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaterna-se%2Fjdec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaterna-se%2Fjdec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaterna-se%2Fjdec/lists"}