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
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>${dependency-plugin.version}</version> <executions> <execution> <id>unpack</id> <phase>generate-resources</phase> <goals> <goal>unpack</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>org.kie</groupId> <artifactId>kie-dmn-test-resources</artifactId> <version>${project.version}</version> <classifier>tests</classifier> <type>jar</type> <overWrite>true</overWrite> <outputDirectory>${project.build.directory}/generated-resources</outputDirectory> <includes>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 </includes> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin>
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
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <executions> <execution> <goals> <goal>set-system-properties</goal> </goals> <configuration> <properties> <property> <name>org.kie.dmn.runtime.typecheck</name> <value>${enable.runtime.typecheck}</value> </property> </properties> </configuration> </execution> </executions> </plugin>
You will need:
mvn clean compile spring-boot:run
mvn clean package java -jar ./target/dmn-15-springboot-example.jar
Once the service is up and running, multiple services will be available
The Swagger page should show all the endpoints.
Demonstrates usage of allowedValues
constraint (to be used as comparison with the ConstraintsChecks
)
Given inputs:
{ "p1": { "Name": "string", "Interests": [ "Golf" ] } }
Curl command (using the JSON object above):
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:
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:
{ "p1": { "Interests": [ "Golf" ], "Name": "string" }, "MyDecision": "The Person string likes 1 thing(s)." }
Demonstrates usage of typeConstraint
constraint.
Given inputs:
{ "p1": { "Name": "string", "Interests": [ "anything" ] } }
Curl command (using the JSON object above):
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:
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:
{ "p1": { "Interests": [ "anything" ], "Name": "string" }, "MyDecision": "The Person string likes 1 thing(s)." }
The following input, on the other side, would rise an error
{ "p1": { "Name": "string", "Interests": [ "string", "strong" ] } }
Curl command (using the JSON object above):
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:
curl -X 'POST' \ 'http://localhost:8080/TypeConstraintsChecks' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d "{ \"p1\": { \"Name\": \"string\", \"Interests\": [ \"string\", \"strong\" ] } }" }"
Used to demonstrates usage of unnamed
import in the /Importing empty-named Model
service.
Given inputs:
{ "A Person": { "name": "string", "age": 0 }, "An Imported Person": { "name": "string", "age": 0 } }
Curl command (using the JSON object above):
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:
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:
{ "A Person": { "name": "string", "age": 0 }, "Say Hello": "function Say Hello( Person )", "Remote Greeting": "Hello string!", "An Imported Person": { "name": "string", "age": 0 } }
Used to demonstrates usage of unnamed
import (it refers to the dmn model behind the /Imported Model
service).
Given inputs:
{ "A Person": { "name": "string", "age": 0 }, "An Imported Person": { "name": "string", "age": 0 } }
Curl command (using the JSON object above):
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:
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:
{ "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 } }