From 0073f979f1fb949217d1b19f54162b692d3d3306 Mon Sep 17 00:00:00 2001 From: Gabriele Cardosi Date: Mon, 11 Nov 2024 13:39:49 +0100 Subject: [PATCH] [incubator-kie-issues#1609] Migrate dmn examples to springboot (#2037) * [incubator-kie-issues#1609] Migrated dmn-15-springboot-example * [incubator-kie-issues#1609] Migrated dmn-resource-jar-springboot-example * [incubator-kie-issues#1609] Remove duplicated module declaration --------- Co-authored-by: Gabriele-Cardosi --- .../dmn-15-quarkus-example/README.md | 2 +- .../dmn-15-quarkus-example/pom.xml | 4 +- .../README.md | 19 +- .../pom.xml | 12 +- .../src/main/resources/application.properties | 0 .../example/NativeTrafficViolationIT.java | 0 .../example/TrafficViolationTest.java | 0 .../KogitoScenarioJunitActivatorTest.java | 0 .../resources/TrafficViolationTest.scesim | 0 .../src/test/resources/application.properties | 0 .../pom.xml | 2 +- .../src/main/resources/Traffic Violation.dmn | 0 .../dmn-resource-jar-quarkus-example/pom.xml | 4 +- .../dmn-15-springboot-example/README.md | 452 +++++++++++ .../dmn-15-springboot-example/pom.xml | 177 ++++ .../example/KogitoSpringbootApplication.java | 30 + .../src/main/resources/application.properties | 22 + .../README.md | 105 +++ .../dmn-springboot-consumer-example/pom.xml | 150 ++++ .../example/KogitoSpringbootApplication.java | 30 + .../src/main/resources/application.properties | 22 + .../example/TrafficViolationTest.java | 65 ++ .../KogitoScenarioJunitActivatorTest.java | 28 + .../resources/TrafficViolationTest.scesim | 766 ++++++++++++++++++ .../dmn-springboot-resource-jar/pom.xml | 32 + .../src/main/resources/Traffic Violation.dmn | 230 ++++++ .../pom.xml | 47 ++ .../src/main/resources/application.properties | 1 - kogito-springboot-examples/pom.xml | 4 + 29 files changed, 2182 insertions(+), 22 deletions(-) rename kogito-quarkus-examples/dmn-resource-jar-quarkus-example/{dmn-consumer-example => dmn-quarkus-consumer-example}/pom.xml (94%) rename kogito-quarkus-examples/dmn-resource-jar-quarkus-example/{dmn-consumer-example => dmn-quarkus-consumer-example}/src/main/resources/application.properties (100%) rename kogito-quarkus-examples/dmn-resource-jar-quarkus-example/{dmn-consumer-example => dmn-quarkus-consumer-example}/src/test/java/org/kie/kogito/dmn/consumer/example/NativeTrafficViolationIT.java (100%) rename kogito-quarkus-examples/dmn-resource-jar-quarkus-example/{dmn-consumer-example => dmn-quarkus-consumer-example}/src/test/java/org/kie/kogito/dmn/consumer/example/TrafficViolationTest.java (100%) rename kogito-quarkus-examples/dmn-resource-jar-quarkus-example/{dmn-consumer-example => dmn-quarkus-consumer-example}/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java (100%) rename kogito-quarkus-examples/dmn-resource-jar-quarkus-example/{dmn-consumer-example => dmn-quarkus-consumer-example}/src/test/resources/TrafficViolationTest.scesim (100%) rename kogito-quarkus-examples/dmn-resource-jar-quarkus-example/{dmn-consumer-example => dmn-quarkus-consumer-example}/src/test/resources/application.properties (100%) rename kogito-quarkus-examples/dmn-resource-jar-quarkus-example/{dmn-resource-jar => dmn-quarkus-resource-jar}/pom.xml (94%) rename kogito-quarkus-examples/dmn-resource-jar-quarkus-example/{dmn-resource-jar => dmn-quarkus-resource-jar}/src/main/resources/Traffic Violation.dmn (100%) create mode 100644 kogito-springboot-examples/dmn-15-springboot-example/README.md create mode 100644 kogito-springboot-examples/dmn-15-springboot-example/pom.xml create mode 100644 kogito-springboot-examples/dmn-15-springboot-example/src/main/java/org/kie/kogito/dmn/springboot/example/KogitoSpringbootApplication.java create mode 100644 kogito-springboot-examples/dmn-15-springboot-example/src/main/resources/application.properties create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/README.md create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/pom.xml create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/main/java/org/kie/kogito/dmn/springboot/consumer/example/KogitoSpringbootApplication.java create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/main/resources/application.properties create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/java/org/kie/kogito/dmn/springboot/consumer/example/TrafficViolationTest.java create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/resources/TrafficViolationTest.scesim create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-resource-jar/pom.xml create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-resource-jar/src/main/resources/Traffic Violation.dmn create mode 100644 kogito-springboot-examples/dmn-resource-jar-springboot-example/pom.xml diff --git a/kogito-quarkus-examples/dmn-15-quarkus-example/README.md b/kogito-quarkus-examples/dmn-15-quarkus-example/README.md index bbdc502cc2..3f0a6c9bfc 100644 --- a/kogito-quarkus-examples/dmn-15-quarkus-example/README.md +++ b/kogito-quarkus-examples/dmn-15-quarkus-example/README.md @@ -63,7 +63,7 @@ In this case, the models are contained in the `org.kie:kie-dmn-test-resources` a Extracted models could be found under `target/generated-resources/valid_models.DMNv1_5` directory. -This example also features the `org.kie.dmn.runtime.typecheck` enviropnment variable, to enforce constraint checks +This example also features the `org.kie.dmn.runtime.typecheck` environment variable, to enforce constraint checks ```xml diff --git a/kogito-quarkus-examples/dmn-15-quarkus-example/pom.xml b/kogito-quarkus-examples/dmn-15-quarkus-example/pom.xml index 143d31f7ad..03a1e0ef04 100644 --- a/kogito-quarkus-examples/dmn-15-quarkus-example/pom.xml +++ b/kogito-quarkus-examples/dmn-15-quarkus-example/pom.xml @@ -99,7 +99,7 @@ src/main/resources - + ${project.build.directory}/generated-resources @@ -136,7 +136,7 @@ - + org.apache.maven.plugins maven-dependency-plugin diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md index 8a49a17980..50d9dd5d92 100644 --- a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/README.md @@ -23,24 +23,25 @@ When using native image compilation, you will also need: ### Compile and Run in Local Dev Mode ``` -cd ./dmn-consumer-example -mvn clean compile quarkus:dev +mvn clean install +cd ./dmn-quarkus-consumer-example +mvn quarkus:dev ``` -(This requires a previous installation of `dmn-resource-jar`) +(This requires a previous installation of `dmn-quarkus-resource-jar`) ### Package and Run in JVM mode ``` mvn clean package -java -jar ./dmn-consumer-example/target/quarkus-app/quarkus-run.jar +java -jar ./dmn-quarkus-consumer-example/target/quarkus-app/quarkus-run.jar ``` or on Windows ``` mvn clean package -java -jar .\dmn-consumer-example\target\quarkus-app\quarkus-run.jar +java -jar .\dmn-quarkus-consumer-example\target\quarkus-app\quarkus-run.jar ``` ### Package and Run using Local Native Image @@ -50,10 +51,10 @@ Note that this requires GRAALVM_HOME to point to a valid GraalVM installation mvn clean package -Pnative ``` -To run the generated native executable, generated in `./dmn-consumer-example/target/`, execute +To run the generated native executable, generated in `./dmn-quarkus-consumer-example/target/`, execute ``` -./dmn-consumer-example/target/dmn-consumer-example-runner +./dmn-quarkus-consumer-example/target/dmn-quarkus-consumer-example-runner ``` Note: This does not yet work on Windows, GraalVM and Quarkus should be rolling out support for Windows soon. @@ -74,12 +75,12 @@ Validate the functionality of DMN models before deploying them into a production To define test scenarios you need to create a .scesim file inside your project and link it to the DMN model you want to be tested. Run all Test Scenarios, executing: ```sh -cd ./dmn-consumer-example +cd ./dmn-quarkus-consumer-example mvn clean test ``` See results in surefire test report `target/surefire-reports` -(This requires a previous installation of `dmn-resource-jar`) +(This requires a previous installation of `dmn-quarkus-resource-jar`) ## Example Usage diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/pom.xml b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/pom.xml similarity index 94% rename from kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/pom.xml rename to kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/pom.xml index 11003d1575..7b53ef0882 100644 --- a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/pom.xml +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/pom.xml @@ -9,7 +9,7 @@ 999-SNAPSHOT - dmn-consumer-example + dmn-quarkus-consumer-example 3.8.6 @@ -26,7 +26,7 @@ org.kie.kogito.examples - dmn-resource-jar + dmn-quarkus-resource-jar ${project.version} @@ -48,7 +48,7 @@ org.kie.kogito.examples - dmn-resource-jar + dmn-quarkus-resource-jar org.drools @@ -96,7 +96,7 @@ src/main/resources - + ${project.build.directory}/generated-resources @@ -114,7 +114,7 @@ - + org.apache.maven.plugins maven-dependency-plugin @@ -130,7 +130,7 @@ org.kie.kogito.examples - dmn-resource-jar + dmn-quarkus-resource-jar ${project.version} jar true diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/main/resources/application.properties b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/main/resources/application.properties similarity index 100% rename from kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/main/resources/application.properties rename to kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/main/resources/application.properties diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/NativeTrafficViolationIT.java b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/NativeTrafficViolationIT.java similarity index 100% rename from kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/NativeTrafficViolationIT.java rename to kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/NativeTrafficViolationIT.java diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/TrafficViolationTest.java b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/TrafficViolationTest.java similarity index 100% rename from kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/TrafficViolationTest.java rename to kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/java/org/kie/kogito/dmn/consumer/example/TrafficViolationTest.java diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java similarity index 100% rename from kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java rename to kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/TrafficViolationTest.scesim b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/resources/TrafficViolationTest.scesim similarity index 100% rename from kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/TrafficViolationTest.scesim rename to kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/resources/TrafficViolationTest.scesim diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/application.properties b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/resources/application.properties similarity index 100% rename from kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-consumer-example/src/test/resources/application.properties rename to kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-consumer-example/src/test/resources/application.properties diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/pom.xml b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-resource-jar/pom.xml similarity index 94% rename from kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/pom.xml rename to kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-resource-jar/pom.xml index 5b18fbe235..d7790464c9 100644 --- a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/pom.xml +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-resource-jar/pom.xml @@ -9,7 +9,7 @@ 999-SNAPSHOT - dmn-resource-jar + dmn-quarkus-resource-jar 17 diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/src/main/resources/Traffic Violation.dmn b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-resource-jar/src/main/resources/Traffic Violation.dmn similarity index 100% rename from kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-resource-jar/src/main/resources/Traffic Violation.dmn rename to kogito-quarkus-examples/dmn-resource-jar-quarkus-example/dmn-quarkus-resource-jar/src/main/resources/Traffic Violation.dmn diff --git a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/pom.xml b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/pom.xml index 2d6d5cac92..3ea5f5ab7d 100644 --- a/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/pom.xml +++ b/kogito-quarkus-examples/dmn-resource-jar-quarkus-example/pom.xml @@ -42,7 +42,7 @@ pom - dmn-resource-jar - dmn-consumer-example + dmn-quarkus-resource-jar + dmn-quarkus-consumer-example diff --git a/kogito-springboot-examples/dmn-15-springboot-example/README.md b/kogito-springboot-examples/dmn-15-springboot-example/README.md new file mode 100644 index 0000000000..6db73ac054 --- /dev/null +++ b/kogito-springboot-examples/dmn-15-springboot-example/README.md @@ -0,0 +1,452 @@ + +# DMN 1.5 + Spring Boot example + +## Description + +Multiple DMN services to evaluate new features of the DMN 1.5 version + +Demonstrates DMN on Kogito capabilities, including REST interface code generation. +It also demonstrates the usage models imported through external jar resources. + +In this case, the models are contained in the `org.kie:kie-dmn-test-resources` artifact, and the referenced ones are extracted with the following maven configuration +```xml + + org.apache.maven.plugins + maven-dependency-plugin + ${dependency-plugin.version} + + + unpack + generate-resources + + unpack + + + + + org.kie + kie-dmn-test-resources + ${project.version} + tests + jar + true + ${project.build.directory}/generated-resources + valid_models/DMNv1_5/**/AllowedValuesChecksInsideCollection.dmn, + valid_models/DMNv1_5/**/TypeConstraintsChecks.dmn, + valid_models/DMNv1_5/**/Imported_Model_Unamed.dmn, + valid_models/DMNv1_5/**/Importing_EmptyNamed_Model_With_Href_Namespace.dmn + + + + + + + +``` + +Extracted models could be found under `target/generated-resources/valid_models.DMNv1_5` directory. + +This example also features the `org.kie.dmn.runtime.typecheck` environment variable, to enforce constraint checks + +```xml + + org.codehaus.mojo + properties-maven-plugin + + + + set-system-properties + + + + + org.kie.dmn.runtime.typecheck + ${enable.runtime.typecheck} + + + + + + +``` + +## Installing and Running + +### Prerequisites + +You will need: + - Java 17+ installed + - Environment variable JAVA_HOME set accordingly + - Maven 3.9.6+ installed + +### Compile and Run + +```sh +mvn clean compile spring-boot:run +``` + +### Package and Run + +```sh +mvn clean package +java -jar ./target/dmn-15-springboot-example.jar +``` + +## Example Usage + +Once the service is up and running, multiple services will be available + +The [Swagger](http://localhost:8080/swagger-ui/index.html) page should show all the endpoints. + + +### POST /AllowedValuesChecksInsideCollection + +Demonstrates usage of `allowedValues`constraint (to be used as comparison with the `ConstraintsChecks`) + +Given inputs: + +```json +{ + "p1": { + "Name": "string", + "Interests": [ + "Golf" + ] + } +} +``` + +Curl command (using the JSON object above): + +```sh +curl -X 'POST' \ + 'http://localhost:8080/AllowedValuesChecksInsideCollection' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "p1": { + "Name": "string", + "Interests": [ + "Golf" + ] + } +}' +``` +or on Windows: + +```sh +curl -X 'POST' \ + 'http://localhost:8080/AllowedValuesChecksInsideCollection' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d "{ + \"p1\": { + \"Name\": \"string\", + \"Interests\": [ + \"Golf\" + ] + } +}" +``` + +As response, the interests information is returned. + +Example response: + +```json +{ + "p1": { + "Interests": [ + "Golf" + ], + "Name": "string" + }, + "MyDecision": "The Person string likes 1 thing(s)." +} +``` + + + +### POST /TypeConstraintsChecks + +Demonstrates usage of `typeConstraint` constraint. + +Given inputs: + +```json +{ + "p1": { + "Name": "string", + "Interests": [ + "anything" + ] + } +} +``` + +Curl command (using the JSON object above): + +```sh +curl -X 'POST' \ + 'http://localhost:8080/TypeConstraintsChecks' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "p1": { + "Name": "string", + "Interests": [ + "anything" + ] + } +}' +``` +or on Windows: + +```sh +curl -X 'POST' \ + 'http://localhost:8080/TypeConstraintsChecks' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d "{ + \"p1\": { + \"Name\": \"string\", + \"Interests\": [ + \"anything\" + ] + } +}" +}" +``` + +As response, the interests information is returned. + +Example response: + +```json +{ + "p1": { + "Interests": [ + "anything" + ], + "Name": "string" + }, + "MyDecision": "The Person string likes 1 thing(s)." +} +``` + +The following input, on the other side, would rise an error + +```json +{ + "p1": { + "Name": "string", + "Interests": [ + "string", "strong" + ] + } +} +``` + +Curl command (using the JSON object above): + +```sh +curl -X 'POST' \ + 'http://localhost:8080/TypeConstraintsChecks' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "p1": { + "Name": "string", + "Interests": [ + "string", "strong" + ] + } +}' +``` +or on Windows: + +```sh +curl -X 'POST' \ + 'http://localhost:8080/TypeConstraintsChecks' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d "{ + \"p1\": { + \"Name\": \"string\", + \"Interests\": [ + \"string\", \"strong\" + ] + } +}" +}" +``` + +### POST /Imported Model + +Used to demonstrates usage of `unnamed` import in the `/Importing empty-named Model` service. + +Given inputs: + +```json +{ + "A Person": { + "name": "string", + "age": 0 + }, + "An Imported Person": { + "name": "string", + "age": 0 + } +} +``` + +Curl command (using the JSON object above): + +```sh +curl -X 'POST' \ + 'http://localhost:8080/Imported Model' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "A Person": { + "name": "string", + "age": 0 + }, + "An Imported Person": { + "name": "string", + "age": 0 + } +}' +``` +or on Windows: + +```sh +curl -X 'POST' \ + 'http://localhost:8080/Imported Model' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d "{ + \"A Person\": { + \"name\": \"string\", + \"age\": 0 + }, + \"An Imported Person\": { + \"name\": \"string\", + \"age\": 0 + } +}" +``` + +As response, the greeting is returned. + +Example response: + +```json +{ + "A Person": { + "name": "string", + "age": 0 + }, + "Say Hello": "function Say Hello( Person )", + "Remote Greeting": "Hello string!", + "An Imported Person": { + "name": "string", + "age": 0 + } +} +``` + +### POST /Importing empty-named Model + +Used to demonstrates usage of `unnamed` import (it refers to the dmn model behind the `/Imported Model` service). + +Given inputs: + +```json +{ + "A Person": { + "name": "string", + "age": 0 + }, + "An Imported Person": { + "name": "string", + "age": 0 + } +} +``` + +Curl command (using the JSON object above): + +```sh +curl -X 'POST' \ + 'http://localhost:8080/Importing empty-named Model' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d '{ + "A Person": { + "name": "string", + "age": 0 + }, + "An Imported Person": { + "name": "string", + "age": 0 + } +}' +``` +or on Windows: + +```sh +curl -X 'POST' \ + 'http://localhost:8080/Importing empty-named Model' \ + -H 'accept: application/json' \ + -H 'Content-Type: application/json' \ + -d "{ + \"A Person\": { + \"name\": \"string\", + \"age\": 0 + }, + \"An Imported Person\": { + \"name\": \"string\", + \"age\": 0 + } +}" +``` + +As response, both model-local and imported greetings are returned. + +Example response: + +```json +{ + "Local Hello": "function Local Hello( Person )", + "A Person": { + "name": "string", + "age": 0 + }, + "Say Hello": "function Say Hello( Person )", + "Imported Greeting": "Hello string!", + "Local Greeting": "Local Hello string!", + "An Imported Person": { + "name": "string", + "age": 0 + } +} +``` + diff --git a/kogito-springboot-examples/dmn-15-springboot-example/pom.xml b/kogito-springboot-examples/dmn-15-springboot-example/pom.xml new file mode 100644 index 0000000000..274e46a62d --- /dev/null +++ b/kogito-springboot-examples/dmn-15-springboot-example/pom.xml @@ -0,0 +1,177 @@ + + + + + 4.0.0 + + + org.kie.kogito.examples + kogito-springboot-examples + 999-SNAPSHOT + + dmn-15-springboot-example + Kogito Example :: DMN :: 1.5 Features + + + 999-SNAPSHOT + 999-SNAPSHOT + 3.6.1 + true + + + + + + org.kie + kie-dmn-test-resources + ${project.version} + tests + + + org.kie.kogito + kogito-spring-boot-bom + ${kogito.bom.version} + pom + import + + + + + + + org.kie + kie-dmn-test-resources + tests + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.drools + drools-decisions-spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + test + + + io.rest-assured + rest-assured + test + + + org.kie.kogito + kogito-scenario-simulation + test + + + + + ${project.artifactId} + + + src/main/resources + + + + ${project.build.directory}/generated-resources + + + + + org.codehaus.mojo + properties-maven-plugin + + + + set-system-properties + + + + + org.kie.dmn.runtime.typecheck + ${enable.runtime.typecheck} + + + + + + + + org.kie.kogito + kogito-maven-plugin + ${version.org.kie.kogito} + true + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${dependency-plugin.version} + + + unpack + generate-resources + + unpack + + + + + org.kie + kie-dmn-test-resources + ${project.version} + tests + jar + true + ${project.build.directory}/generated-resources + valid_models/DMNv1_5/**/AllowedValuesChecksInsideCollection.dmn, + valid_models/DMNv1_5/**/TypeConstraintsChecks.dmn, + valid_models/DMNv1_5/**/Imported_Model_Unamed.dmn, + valid_models/DMNv1_5/**/Importing_EmptyNamed_Model_With_Href_Namespace.dmn + + + + + + + + + + + \ No newline at end of file diff --git a/kogito-springboot-examples/dmn-15-springboot-example/src/main/java/org/kie/kogito/dmn/springboot/example/KogitoSpringbootApplication.java b/kogito-springboot-examples/dmn-15-springboot-example/src/main/java/org/kie/kogito/dmn/springboot/example/KogitoSpringbootApplication.java new file mode 100644 index 0000000000..0ae0f6a443 --- /dev/null +++ b/kogito-springboot-examples/dmn-15-springboot-example/src/main/java/org/kie/kogito/dmn/springboot/example/KogitoSpringbootApplication.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.dmn.springboot.example; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication(scanBasePackages = { "org.kie.kogito.dmn.**", "org.kie.kogito.app.**", "http**" }) +public class KogitoSpringbootApplication { + + public static void main(String[] args) { + SpringApplication.run(KogitoSpringbootApplication.class, args); + } +} diff --git a/kogito-springboot-examples/dmn-15-springboot-example/src/main/resources/application.properties b/kogito-springboot-examples/dmn-15-springboot-example/src/main/resources/application.properties new file mode 100644 index 0000000000..fcbf5c6501 --- /dev/null +++ b/kogito-springboot-examples/dmn-15-springboot-example/src/main/resources/application.properties @@ -0,0 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Packaging + +server.address=0.0.0.0 \ No newline at end of file diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/README.md b/kogito-springboot-examples/dmn-resource-jar-springboot-example/README.md new file mode 100644 index 0000000000..e6c24ad700 --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/README.md @@ -0,0 +1,105 @@ +# DMN + Spring Boot example with model included in different jar + +## Description + +A simple DMN service to evaluate a model (traffic violation) that is imported from a different jar. + +Demonstrates DMN on Kogito capabilities, including REST interface code generation. + +## Installing and Running + +### Prerequisites + +You will need: +- Java 17+ installed +- Environment variable JAVA_HOME set accordingly +- Maven 3.9.6+ installed + +### Compile and Run + +```sh +mvn clean install +cd ./dmn-springboot-consumer-example +mvn spring-boot:run +``` + +### Package and Run + +```sh +mvn clean install +cd ./dmn-springboot-consumer-example +java -jar ./target/dmn-springboot-consumer-example.jar +``` + +## Test DMN Model using Maven + +Validate the functionality of DMN models before deploying them into a production environment by defining test scenarios in Test Scenario Editor. + +To define test scenarios you need to create a .scesim file inside your project and link it to the DMN model you want to be tested. Run all Test Scenarios, executing: + +```sh +cd ./dmn-springboot-consumer-example +mvn clean test +``` +See results in surefire test report `target/surefire-reports` + +(This requires a previous installation of `dmn-resource-jar`) + +## Example Usage + +Once the service is up and running, you can use the following example to interact with the service. + +### POST /Traffic Violation + +Returns penalty information from the given inputs -- driver and violation: + +Given inputs: + +```json +{ + "Driver":{"Points":2}, + "Violation":{ + "Type":"speed", + "Actual Speed":120, + "Speed Limit":100 + } +} +``` + +Curl command (using the JSON object above): + +```sh +curl -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -d '{"Driver":{"Points":2},"Violation":{"Type":"speed","Actual Speed":120,"Speed Limit":100}}' http://localhost:8080/Traffic%20Violation +``` +or on Windows: + +```sh +curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d "{\"Driver\":{\"Points\":2},\"Violation\":{\"Type\":\"speed\",\"Actual Speed\":120,\"Speed Limit\":100}}" http://localhost:8080/Traffic%20Violation +``` + +As response, penalty information is returned. + +Example response: + +```json +{ + "Violation":{ + "Type":"speed", + "Speed Limit":100, + "Actual Speed":120 + }, + "Driver":{ + "Points":2 + }, + "Fine":{ + "Points":3, + "Amount":500 + }, + "Should the driver be suspended?":"No" +} +``` + +The difference from the [dmn-springboot-example](../dmn-springboot-example) is that, in the current one, the `Traffic Model.dml` is defined in a different jar. + + + diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/pom.xml b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/pom.xml new file mode 100644 index 0000000000..b44afe69e9 --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/pom.xml @@ -0,0 +1,150 @@ + + + + + 4.0.0 + + + org.kie.kogito.examples + dmn-resource-jar-springboot-example + 999-SNAPSHOT + + + dmn-springboot-consumer-example + + + 999-SNAPSHOT + 999-SNAPSHOT + 3.6.1 + + + + + + org.kie.kogito.examples + dmn-springboot-resource-jar + ${project.version} + + + org.kie.kogito + kogito-spring-boot-bom + ${kogito.bom.version} + pom + import + + + + + + + org.kie.kogito.examples + dmn-springboot-resource-jar + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.drools + drools-decisions-spring-boot-starter + + + org.springframework.boot + spring-boot-starter-test + test + + + io.rest-assured + rest-assured + test + + + org.kie.kogito + kogito-scenario-simulation + test + + + + + ${project.artifactId} + + + src/main/resources + + + + ${project.build.directory}/generated-resources + + + + + org.kie.kogito + kogito-maven-plugin + ${version.org.kie.kogito} + true + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + ${dependency-plugin.version} + + + unpack + generate-resources + + unpack + + + + + org.kie.kogito.examples + dmn-springboot-resource-jar + ${project.version} + jar + true + ${project.build.directory}/generated-resources + **/*.dmn + + + + + + + + + + \ No newline at end of file diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/main/java/org/kie/kogito/dmn/springboot/consumer/example/KogitoSpringbootApplication.java b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/main/java/org/kie/kogito/dmn/springboot/consumer/example/KogitoSpringbootApplication.java new file mode 100644 index 0000000000..49faf5b5ec --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/main/java/org/kie/kogito/dmn/springboot/consumer/example/KogitoSpringbootApplication.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.dmn.springboot.consumer.example; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication(scanBasePackages = { "org.kie.kogito.dmn.**", "org.kie.kogito.app.**", "http**" }) +public class KogitoSpringbootApplication { + + public static void main(String[] args) { + SpringApplication.run(KogitoSpringbootApplication.class, args); + } +} diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/main/resources/application.properties b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/main/resources/application.properties new file mode 100644 index 0000000000..fcbf5c6501 --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/main/resources/application.properties @@ -0,0 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Packaging + +server.address=0.0.0.0 \ No newline at end of file diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/java/org/kie/kogito/dmn/springboot/consumer/example/TrafficViolationTest.java b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/java/org/kie/kogito/dmn/springboot/consumer/example/TrafficViolationTest.java new file mode 100644 index 0000000000..920025c1b3 --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/java/org/kie/kogito/dmn/springboot/consumer/example/TrafficViolationTest.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.kie.kogito.dmn.springboot.consumer.example; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.test.annotation.DirtiesContext; + +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.is; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = KogitoSpringbootApplication.class) +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) +public class TrafficViolationTest { + + @LocalServerPort + private int port; + + @BeforeEach + public void setUp() { + RestAssured.port = port; + } + + @Test + public void testEvaluateTrafficViolation() { + given() + .body("{\n" + + " \"Driver\": {\n" + + " \"Points\": 2\n" + + " },\n" + + " \"Violation\": {\n" + + " \"Type\": \"speed\",\n" + + " \"Actual Speed\": 120,\n" + + " \"Speed Limit\": 100\n" + + " }\n" + + "}") + .contentType(ContentType.JSON) + .when() + .post("/Traffic Violation") + .then() + .statusCode(200) + .body("'Should the driver be suspended?'", is("No")); + } +} diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java new file mode 100644 index 0000000000..7e2f83f2ec --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/java/testscenario/KogitoScenarioJunitActivatorTest.java @@ -0,0 +1,28 @@ +package testscenario;/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * KogitoJunitActivator is a custom JUnit runner that enables the execution of Test Scenario files (*.scesim). + * This activator class, when executed, will load all scesim files available in the project and run them. + * Each row of the scenario will generate a test JUnit result. + */ +@org.junit.runner.RunWith(org.kogito.scenariosimulation.runner.KogitoJunitActivator.class) +public class KogitoScenarioJunitActivatorTest { + +} \ No newline at end of file diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/resources/TrafficViolationTest.scesim b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/resources/TrafficViolationTest.scesim new file mode 100644 index 0000000000..3a9a5d98f5 --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-consumer-example/src/test/resources/TrafficViolationTest.scesim @@ -0,0 +1,766 @@ + + + + + + + + + Index + OTHER + + + # + java.lang.Integer + + java.lang.Integer + # + 70 + NOT_EXPRESSION + + + + + Description + OTHER + + + Scenario description + java.lang.String + + java.lang.String + Scenario description + 300 + NOT_EXPRESSION + + + + + Driver + + + Points + + + + 1|5 + GIVEN + + + Driver + Driver + + number + Driver + Points + + 114 + NOT_EXPRESSION + + + + + Violation + + + Type + + + + 1|8 + GIVEN + + + Violation + Violation + + Type + Violation + Type + + 114 + NOT_EXPRESSION + + + + + Violation + + + Speed Limit + + + + 1|9 + GIVEN + + + Violation + Violation + + number + Violation + Speed Limit + + 114 + NOT_EXPRESSION + + + + + Violation + + + Actual Speed + + + + 1|10 + GIVEN + + + Violation + Violation + + number + Violation + Actual Speed + + 114 + NOT_EXPRESSION + + + + + Fine + + + Amount + + + + 1|11 + EXPECT + + + Fine + Fine + + number + Fine + Amount + + 114 + NOT_EXPRESSION + + + + + Fine + + + Points + + + + 1|12 + EXPECT + + + Fine + Fine + + number + Fine + Points + + 114 + NOT_EXPRESSION + + + + + Should the driver be suspended? + + + + 1|13 + EXPECT + + + Should the driver be suspended? + Should the driver be suspended? + + string + Should the driver be suspended? + value + + 114 + NOT_EXPRESSION + + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + Above speed limit: 10km/h and 30 km/h + + + + Driver + Driver + + + 1|5 + GIVEN + + 10 + + + + Violation + Violation + + + 1|8 + GIVEN + + "speed" + + + + Violation + Violation + + + 1|9 + GIVEN + + 100 + + + + Violation + Violation + + + 1|10 + GIVEN + + 120 + + + + Fine + Fine + + + 1|11 + EXPECT + + 500 + + + + Fine + Fine + + + 1|12 + EXPECT + + 3 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "No" + + + + # + java.lang.Integer + + + Index + OTHER + + 1 + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + Above speed limit: more than 30 km/h + + + + Driver + Driver + + + 1|5 + GIVEN + + 10 + + + + Violation + Violation + + + 1|8 + GIVEN + + "speed" + + + + Violation + Violation + + + 1|9 + GIVEN + + 100 + + + + Violation + Violation + + + 1|10 + GIVEN + + 150 + + + + Fine + Fine + + + 1|11 + EXPECT + + 1000 + + + + Fine + Fine + + + 1|12 + EXPECT + + 7 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "No" + + + + # + java.lang.Integer + + + Index + OTHER + + 2 + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + Parking violation + + + + Driver + Driver + + + 1|5 + GIVEN + + 10 + + + + Violation + Violation + + + 1|8 + GIVEN + + "parking" + + + + Violation + Violation + + + 1|9 + GIVEN + + + + + Violation + Violation + + + 1|10 + GIVEN + + + + + Fine + Fine + + + 1|11 + EXPECT + + 100 + + + + Fine + Fine + + + 1|12 + EXPECT + + 1 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "No" + + + + # + java.lang.Integer + + + Index + OTHER + + 3 + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + DUI violation + + + + Driver + Driver + + + 1|5 + GIVEN + + 10 + + + + Violation + Violation + + + 1|8 + GIVEN + + "driving under the influence" + + + + Violation + Violation + + + 1|9 + GIVEN + + + + + Violation + Violation + + + 1|10 + GIVEN + + + + + Fine + Fine + + + 1|11 + EXPECT + + 1000 + + + + Fine + Fine + + + 1|12 + EXPECT + + 5 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "No" + + + + # + java.lang.Integer + + + Index + OTHER + + 4 + + + + + + + + Scenario description + java.lang.String + + + Description + OTHER + + Driver suspended + + + + Driver + Driver + + + 1|5 + GIVEN + + 15 + + + + Violation + Violation + + + 1|8 + GIVEN + + "speed" + + + + Violation + Violation + + + 1|9 + GIVEN + + 100 + + + + Violation + Violation + + + 1|10 + GIVEN + + 140 + + + + Fine + Fine + + + 1|11 + EXPECT + + 1000 + + + + Fine + Fine + + + 1|12 + EXPECT + + 7 + + + + Should the driver be suspended? + Should the driver be suspended? + + + 1|13 + EXPECT + + "Yes" + + + + # + java.lang.Integer + + + Index + OTHER + + 5 + + + + + + + + + + + + 1|1 + GIVEN + + + Empty + java.lang.Void + + java.lang.Void + INSTANCE 1 + PROPERTY 1 + 114 + NOT_EXPRESSION + + + + + + + + + Empty + java.lang.Void + + + 1|1 + GIVEN + + + + + + + + ../../main/resources/Traffic Violation.dmn + DMN + https://github.com/kiegroup/drools/kie-dmn/_A4BCA8B8-CF08-433F-93B2-A2598F19ECFF + Traffic Violation + false + false + + + + + \ No newline at end of file diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-resource-jar/pom.xml b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-resource-jar/pom.xml new file mode 100644 index 0000000000..f6b89b3224 --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-resource-jar/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + org.kie.kogito.examples + dmn-resource-jar-springboot-example + 999-SNAPSHOT + + + dmn-springboot-resource-jar + + + 17 + 17 + UTF-8 + + + + + maven-compiler-plugin + + + -parameters + + + + + + + \ No newline at end of file diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-resource-jar/src/main/resources/Traffic Violation.dmn b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-resource-jar/src/main/resources/Traffic Violation.dmn new file mode 100644 index 0000000000..109d4689e1 --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/dmn-springboot-resource-jar/src/main/resources/Traffic Violation.dmn @@ -0,0 +1,230 @@ + + + + + + string + + + number + + + string + + + string + + + number + + + + + string + + + date + + + string + + "speed", "parking", "driving under the influence" + + + + number + + + number + + + + + number + + + number + + + + + + + + + + + + + + Violation.Type + + + + + Violation.Actual Speed - Violation.Speed Limit + + + + + + + "speed" + + + [10..30) + + + 500 + + + 3 + + + + + "speed" + + + >= 30 + + + 1000 + + + 7 + + + + + "parking" + + + - + + + 100 + + + 1 + + + + + "driving under the influence" + + + - + + + 1000 + + + 5 + + + + + + + + + Should the driver be suspended due to points on his license? + "Yes", "No" + + + + + + + + + + + + Driver.Points + Fine.Points + + + + + if Total Points >= 20 then "Yes" else "No" + + + + + + + + + + 50.0 + 254.0 + 329.0 + 119.0 + 100.0 + 186.0 + + + 50.0 + 100.0 + 398.0 + + + 398.0 + + + 398.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kogito-springboot-examples/dmn-resource-jar-springboot-example/pom.xml b/kogito-springboot-examples/dmn-resource-jar-springboot-example/pom.xml new file mode 100644 index 0000000000..93f17aa0e1 --- /dev/null +++ b/kogito-springboot-examples/dmn-resource-jar-springboot-example/pom.xml @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + + org.kie.kogito.examples + kogito-springboot-examples + 999-SNAPSHOT + + dmn-resource-jar-springboot-example + Kogito Example :: DMN :: Resource jar providing model + pom + + + 999-SNAPSHOT + 999-SNAPSHOT + + + + dmn-springboot-resource-jar + dmn-springboot-consumer-example + + + \ No newline at end of file diff --git a/kogito-springboot-examples/dmn-springboot-example/src/main/resources/application.properties b/kogito-springboot-examples/dmn-springboot-example/src/main/resources/application.properties index 216ad14477..fcbf5c6501 100644 --- a/kogito-springboot-examples/dmn-springboot-example/src/main/resources/application.properties +++ b/kogito-springboot-examples/dmn-springboot-example/src/main/resources/application.properties @@ -18,6 +18,5 @@ # # Packaging -# quarkus.package.type=fast-jar server.address=0.0.0.0 \ No newline at end of file diff --git a/kogito-springboot-examples/pom.xml b/kogito-springboot-examples/pom.xml index 3becc1edd0..9a82da6b9a 100644 --- a/kogito-springboot-examples/pom.xml +++ b/kogito-springboot-examples/pom.xml @@ -56,10 +56,12 @@ decisiontable-springboot-example + dmn-15-springboot-example dmn-drools-springboot-metrics dmn-event-driven-springboot dmn-listener-springboot dmn-pmml-springboot-example + dmn-resource-jar-springboot-example dmn-springboot-example dmn-tracing-springboot flexible-process-springboot @@ -103,10 +105,12 @@ decisiontable-springboot-example + dmn-15-springboot-example dmn-drools-springboot-metrics dmn-event-driven-springboot dmn-listener-springboot dmn-pmml-springboot-example + dmn-resource-jar-springboot-example dmn-springboot-example dmn-tracing-springboot flexible-process-springboot