Skip to content
Snippets Groups Projects
Commit 33864bc7 authored by Jonas Blatt's avatar Jonas Blatt :ant:
Browse files

Merge branch 'develop' into feature-missingRuleWithStrings

parents b34770ce d7adf02b
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<properties> <properties>
<build.name>ROOT</build.name> <build.name>ROOT</build.name>
<version.camunda>7.10.0</version.camunda> <version.camunda>7.11.0</version.camunda>
</properties> </properties>
<repositories> <repositories>
......
...@@ -87,6 +87,10 @@ public class DmnRuleMap { ...@@ -87,6 +87,10 @@ public class DmnRuleMap {
dmnRuleMap.inputColumns.add(it); dmnRuleMap.inputColumns.add(it);
dmnRuleMap.inputs.put(it, new ArrayList<>()); dmnRuleMap.inputs.put(it, new ArrayList<>());
List<Value> inList = dmnRuleMap.inputs.get(it); List<Value> inList = dmnRuleMap.inputs.get(it);
if (DataType.BOOLEAN == it.dataType) {
it.addPredefinedValues("true");
it.addPredefinedValues("false");
}
int r = 0; int r = 0;
for (DmnDecisionTableRuleImpl rule : table.getRules()) { for (DmnDecisionTableRuleImpl rule : table.getRules()) {
DmnExpressionImpl condition = rule.getConditions().get(i); DmnExpressionImpl condition = rule.getConditions().get(i);
...@@ -96,6 +100,12 @@ public class DmnRuleMap { ...@@ -96,6 +100,12 @@ public class DmnRuleMap {
dmnRuleMap.ruleInputValues.getOrDefault(value.getRuleIdentifier(), new ArrayList<>()); dmnRuleMap.ruleInputValues.getOrDefault(value.getRuleIdentifier(), new ArrayList<>());
rules.add(value); rules.add(value);
dmnRuleMap.ruleInputValues.put(value.getRuleIdentifier(), rules); dmnRuleMap.ruleInputValues.put(value.getRuleIdentifier(), rules);
// If string, add to possible values
if (DataType.STRING == it.dataType && value.getOrgExpression() != null) {
it.addPredefinedValues(
value.getOrgExpression()); // TODO: add predifined Values from org "Predefined
// Values"
}
} }
i++; i++;
} }
...@@ -106,6 +116,10 @@ public class DmnRuleMap { ...@@ -106,6 +116,10 @@ public class DmnRuleMap {
dmnRuleMap.outputColumns.add(ot); dmnRuleMap.outputColumns.add(ot);
dmnRuleMap.outputs.put(ot, new ArrayList<>()); dmnRuleMap.outputs.put(ot, new ArrayList<>());
List<Value> outList = dmnRuleMap.outputs.get(ot); List<Value> outList = dmnRuleMap.outputs.get(ot);
if (DataType.BOOLEAN == ot.dataType) {
ot.addPredefinedValues("true");
ot.addPredefinedValues("false");
}
int r = 0; int r = 0;
for (DmnDecisionTableRuleImpl rule : table.getRules()) { for (DmnDecisionTableRuleImpl rule : table.getRules()) {
DmnExpressionImpl conclusion = rule.getConclusions().get(i); DmnExpressionImpl conclusion = rule.getConclusions().get(i);
...@@ -116,6 +130,10 @@ public class DmnRuleMap { ...@@ -116,6 +130,10 @@ public class DmnRuleMap {
value.getRuleIdentifier(), new ArrayList<>()); value.getRuleIdentifier(), new ArrayList<>());
rules.add(value); rules.add(value);
dmnRuleMap.ruleOutputValues.put(value.getRuleIdentifier(), rules); dmnRuleMap.ruleOutputValues.put(value.getRuleIdentifier(), rules);
// If string, add to possible values
if (DataType.STRING == ot.dataType && value.getOrgExpression() != null) {
ot.addPredefinedValues(value.getOrgExpression());
}
} }
i++; i++;
} }
...@@ -163,12 +181,16 @@ public class DmnRuleMap { ...@@ -163,12 +181,16 @@ public class DmnRuleMap {
inputColumns.stream() inputColumns.stream()
.filter(i -> i.getDecisionKey().equals(ot.getDecisionKey())) .filter(i -> i.getDecisionKey().equals(ot.getDecisionKey()))
.collect(Collectors.toList())) { .collect(Collectors.toList())) {
// only, if the label didnt exists in prev created cols // only, if the label didn't exists in previously created input
if (newInputTypes.stream() Optional<InputType> existingInputType =
newInputTypes.stream()
.filter(i -> i.label.equals(inputType.label) && i.dataType == inputType.dataType) .filter(i -> i.label.equals(inputType.label) && i.dataType == inputType.dataType)
.limit(1) .findFirst();
.count() if (existingInputType.isPresent()) {
< 1) { inputType
.getPredefinedValues()
.forEach(p -> existingInputType.get().addPredefinedValues(p));
} else {
InputType newInputType = new InputType(inputType); InputType newInputType = new InputType(inputType);
newInputType.setOverwrittenDecisionKey(newDmnKey); newInputType.setOverwrittenDecisionKey(newDmnKey);
newInputTypes.add(newInputType); newInputTypes.add(newInputType);
......
package de.unikoblenz.fgbks.dmn.core.dmnhelper; package de.unikoblenz.fgbks.dmn.core.dmnhelper;
import de.unikoblenz.fgbks.dmn.core.models.RuleIdentifier; import de.unikoblenz.fgbks.dmn.core.models.RuleIdentifier;
import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import org.camunda.bpm.dmn.engine.DmnDecision; import org.camunda.bpm.dmn.engine.DmnDecision;
import org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl; import org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl;
...@@ -12,6 +14,7 @@ public abstract class Type { ...@@ -12,6 +14,7 @@ public abstract class Type {
protected final DataType dataType; protected final DataType dataType;
protected final String label; protected final String label;
protected String overwrittenDecisionKey; protected String overwrittenDecisionKey;
protected Set<String> predefinedValues;
public String getDecisionKey() { public String getDecisionKey() {
if (overwrittenDecisionKey != null) { if (overwrittenDecisionKey != null) {
...@@ -40,12 +43,21 @@ public abstract class Type { ...@@ -40,12 +43,21 @@ public abstract class Type {
this.overwrittenDecisionKey = overwrittenDecisionKey; this.overwrittenDecisionKey = overwrittenDecisionKey;
} }
public Set<String> getPredefinedValues() {
return new HashSet<>(predefinedValues);
}
public void addPredefinedValues(String predefinedValue) {
predefinedValues.add(predefinedValue);
}
protected Type(DmnDecision decision, String id, DataType dataType, String label) { protected Type(DmnDecision decision, String id, DataType dataType, String label) {
this.decision = decision; this.decision = decision;
this.id = id; this.id = id;
this.dataType = dataType; this.dataType = dataType;
this.label = label; this.label = label;
this.overwrittenDecisionKey = null; this.overwrittenDecisionKey = null;
this.predefinedValues = new HashSet<>();
} }
public Type(Type type) { public Type(Type type) {
...@@ -54,6 +66,7 @@ public abstract class Type { ...@@ -54,6 +66,7 @@ public abstract class Type {
this.dataType = type.dataType; this.dataType = type.dataType;
this.label = type.label; this.label = type.label;
this.overwrittenDecisionKey = type.overwrittenDecisionKey; this.overwrittenDecisionKey = type.overwrittenDecisionKey;
this.predefinedValues = new HashSet<>(type.predefinedValues);
} }
public boolean isMergedType() { public boolean isMergedType() {
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
<inputExpression id="LiteralExpression_16k88l6" typeRef="string"> <inputExpression id="LiteralExpression_16k88l6" typeRef="string">
<text>testString</text> <text>testString</text>
</inputExpression> </inputExpression>
<inputValues id="UnaryTests_1dqtimh">
<text>"Hello","World","Nicole"</text>
</inputValues>
</input> </input>
<output id="output_1" typeRef="string" /> <output id="output_1" typeRef="string" />
<rule id="DecisionRule_1cwar6s"> <rule id="DecisionRule_1cwar6s">
...@@ -21,7 +24,7 @@ ...@@ -21,7 +24,7 @@
<text>=10</text> <text>=10</text>
</inputEntry> </inputEntry>
<inputEntry id="UnaryTests_1wdwt7k"> <inputEntry id="UnaryTests_1wdwt7k">
<text>"Hallo"</text> <text>"Hello"</text>
</inputEntry> </inputEntry>
<outputEntry id="LiteralExpression_0q4dj07"> <outputEntry id="LiteralExpression_0q4dj07">
<text></text> <text></text>
...@@ -43,7 +46,7 @@ ...@@ -43,7 +46,7 @@
<text>=10</text> <text>=10</text>
</inputEntry> </inputEntry>
<inputEntry id="UnaryTests_04ee59d"> <inputEntry id="UnaryTests_04ee59d">
<text>"Hallo"</text> <text>"Hello"</text>
</inputEntry> </inputEntry>
<outputEntry id="LiteralExpression_1vwq9kg"> <outputEntry id="LiteralExpression_1vwq9kg">
<text></text> <text></text>
...@@ -455,54 +458,54 @@ ...@@ -455,54 +458,54 @@
</rule> </rule>
</decisionTable> </decisionTable>
</decision> </decision>
<decision id="Decision_13hi6aw" name="Missing 2"> <decision id="Decision_13hi6aw" name="Missing 2">
<extensionElements> <extensionElements>
<biodi:bounds x="859" y="215" width="180" height="80" /> <biodi:bounds x="859" y="215" width="180" height="80" />
</extensionElements> </extensionElements>
<decisionTable id="DecisionTable_00f0o2m"> <decisionTable id="DecisionTable_00f0o2m">
<input id="InputClause_13up6c7" label="x"> <input id="InputClause_13up6c7" label="x">
<inputExpression id="LiteralExpression_1dn7njr" typeRef="integer" /> <inputExpression id="LiteralExpression_1dn7njr" typeRef="integer" />
</input> </input>
<input id="InputClause_0847npz" label="y"> <input id="InputClause_0847npz" label="y">
<inputExpression id="LiteralExpression_0obosay" typeRef="integer"> <inputExpression id="LiteralExpression_0obosay" typeRef="integer">
<text></text> <text></text>
</inputExpression> </inputExpression>
</input> </input>
<output id="OutputClause_18obzop" typeRef="string" /> <output id="OutputClause_18obzop" typeRef="string" />
<rule id="DecisionRule_0oyfmhy"> <rule id="DecisionRule_0oyfmhy">
<inputEntry id="UnaryTests_0xy4bmj"> <inputEntry id="UnaryTests_0xy4bmj">
<text>[2..4]</text> <text>[2..4]</text>
</inputEntry> </inputEntry>
<inputEntry id="UnaryTests_10fhwew"> <inputEntry id="UnaryTests_10fhwew">
<text>[3..5]</text> <text>[3..5]</text>
</inputEntry> </inputEntry>
<outputEntry id="LiteralExpression_0dwkyvr"> <outputEntry id="LiteralExpression_0dwkyvr">
<text></text> <text></text>
</outputEntry> </outputEntry>
</rule> </rule>
<rule id="DecisionRule_0vgwssx"> <rule id="DecisionRule_0vgwssx">
<inputEntry id="UnaryTests_1lqrnuq"> <inputEntry id="UnaryTests_1lqrnuq">
<text>[6..7]</text> <text>[6..7]</text>
</inputEntry> </inputEntry>
<inputEntry id="UnaryTests_13svgy5"> <inputEntry id="UnaryTests_13svgy5">
<text>[2..7]</text> <text>[2..7]</text>
</inputEntry> </inputEntry>
<outputEntry id="LiteralExpression_01uesqf"> <outputEntry id="LiteralExpression_01uesqf">
<text></text> <text></text>
</outputEntry> </outputEntry>
</rule> </rule>
<rule id="DecisionRule_1nc162p"> <rule id="DecisionRule_1nc162p">
<inputEntry id="UnaryTests_04orlte"> <inputEntry id="UnaryTests_04orlte">
<text>[3..5]</text> <text>[3..5]</text>
</inputEntry> </inputEntry>
<inputEntry id="UnaryTests_1au3mbz"> <inputEntry id="UnaryTests_1au3mbz">
<text>[6..8]</text> <text>[6..8]</text>
</inputEntry> </inputEntry>
<outputEntry id="LiteralExpression_1xsp0mf"> <outputEntry id="LiteralExpression_1xsp0mf">
<text></text> <text></text>
</outputEntry> </outputEntry>
</rule> </rule>
</decisionTable> </decisionTable>
</decision> </decision>
<decision id="Decision_0m4xor4" name="Partial Reduction"> <decision id="Decision_0m4xor4" name="Partial Reduction">
<extensionElements> <extensionElements>
......
...@@ -7,26 +7,33 @@ import java.io.InputStream; ...@@ -7,26 +7,33 @@ import java.io.InputStream;
import java.util.List; import java.util.List;
import org.camunda.bpm.dmn.engine.DmnDecision; import org.camunda.bpm.dmn.engine.DmnDecision;
import org.camunda.bpm.dmn.engine.DmnEngineConfiguration; import org.camunda.bpm.dmn.engine.DmnEngineConfiguration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
class DmnRuleMapTest { class DmnRuleMapTest {
private List<DmnDecision> dmnDecisions;
@BeforeEach @Test
void init() throws FileNotFoundException { void testMultiTable() throws FileNotFoundException {
File f = new File("."); File f = new File(".");
InputStream inputStream = InputStream inputStream =
new FileInputStream( new FileInputStream(
new File(getClass().getClassLoader().getResource("dmnMultiTable1.dmn").getFile())); new File(getClass().getClassLoader().getResource("dmnMultiTable1.dmn").getFile()));
this.dmnDecisions = List<DmnDecision> dmnDecisions =
DmnEngineConfiguration.createDefaultDmnEngineConfiguration() DmnEngineConfiguration.createDefaultDmnEngineConfiguration()
.buildEngine() .buildEngine()
.parseDecisions(inputStream); .parseDecisions(inputStream);
DmnRuleMap rm = DmnRuleMap.createMapFromDmn(dmnDecisions);
} }
@Test @Test
void testCreation() { void testPredefinedValues() throws FileNotFoundException {
File f = new File(".");
InputStream inputStream =
new FileInputStream(
new File(getClass().getClassLoader().getResource("dmnPredefinedValues.dmn").getFile()));
List<DmnDecision> dmnDecisions =
DmnEngineConfiguration.createDefaultDmnEngineConfiguration()
.buildEngine()
.parseDecisions(inputStream);
DmnRuleMap rm = DmnRuleMap.createMapFromDmn(dmnDecisions); DmnRuleMap rm = DmnRuleMap.createMapFromDmn(dmnDecisions);
} }
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" id="Definitions_1kjh9a2" name="DRD" namespace="http://camunda.org/schema/1.0/dmn"> <definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" id="Definitions_1kjh9a2" name="DRD" namespace="http://camunda.org/schema/1.0/dmn">
<decision id="Decision_13nychf" name="Identical test"> <decision id="Decision_13nychf" name="Identical">
<extensionElements> <extensionElements>
<biodi:bounds x="120" y="145" width="180" height="80" /> <biodi:bounds x="87" y="130" width="180" height="80" />
</extensionElements> </extensionElements>
<decisionTable id="decisionTable_1"> <decisionTable id="decisionTable_1">
<input id="input_1"> <input id="input_1">
<inputExpression id="inputExpression_1" typeRef="integer"> <inputExpression id="inputExpression_1" typeRef="integer">
<text>Testnumber</text> <text>testNumber</text>
</inputExpression> </inputExpression>
</input> </input>
<input id="InputClause_0rrhtk1"> <input id="InputClause_0rrhtk1">
<inputExpression id="LiteralExpression_16k88l6" typeRef="string"> <inputExpression id="LiteralExpression_16k88l6" typeRef="string">
<text></text> <text>testString</text>
</inputExpression> </inputExpression>
<inputValues id="UnaryTests_1dqtimh">
<text>"Hello","World","Nicole"</text>
</inputValues>
</input> </input>
<output id="output_1" typeRef="string" /> <output id="output_1" typeRef="string" />
<rule id="DecisionRule_1cwar6s"> <rule id="DecisionRule_1cwar6s">
...@@ -21,7 +24,7 @@ ...@@ -21,7 +24,7 @@
<text>=10</text> <text>=10</text>
</inputEntry> </inputEntry>
<inputEntry id="UnaryTests_1wdwt7k"> <inputEntry id="UnaryTests_1wdwt7k">
<text>"Hallo"</text> <text>"Hello"</text>
</inputEntry> </inputEntry>
<outputEntry id="LiteralExpression_0q4dj07"> <outputEntry id="LiteralExpression_0q4dj07">
<text></text> <text></text>
...@@ -32,7 +35,7 @@ ...@@ -32,7 +35,7 @@
<text>=10</text> <text>=10</text>
</inputEntry> </inputEntry>
<inputEntry id="UnaryTests_01s94by"> <inputEntry id="UnaryTests_01s94by">
<text>"Anna"</text> <text>"Nicole"</text>
</inputEntry> </inputEntry>
<outputEntry id="LiteralExpression_06akk3i"> <outputEntry id="LiteralExpression_06akk3i">
<text></text> <text></text>
...@@ -43,7 +46,7 @@ ...@@ -43,7 +46,7 @@
<text>=10</text> <text>=10</text>
</inputEntry> </inputEntry>
<inputEntry id="UnaryTests_04ee59d"> <inputEntry id="UnaryTests_04ee59d">
<text>"Hallo"</text> <text>"Hello"</text>
</inputEntry> </inputEntry>
<outputEntry id="LiteralExpression_1vwq9kg"> <outputEntry id="LiteralExpression_1vwq9kg">
<text></text> <text></text>
...@@ -73,129 +76,4 @@ ...@@ -73,129 +76,4 @@
</rule> </rule>
</decisionTable> </decisionTable>
</decision> </decision>
<decision id="Decision_1vo386g" name="Subsumption test 1">
<extensionElements>
<biodi:bounds x="344" y="74" width="180" height="80" />
</extensionElements>
<decisionTable id="DecisionTable_0tq1rr0">
<input id="InputClause_0f5fjmn">
<inputExpression id="LiteralExpression_0flv94t" typeRef="integer" />
</input>
<output id="OutputClause_0c6vpaw" typeRef="string" />
<rule id="DecisionRule_15aojnz">
<inputEntry id="UnaryTests_0wp6h38">
<text>[0..10]</text>
</inputEntry>
<outputEntry id="LiteralExpression_0m0psw2">
<text>"Hello"</text>
</outputEntry>
</rule>
<rule id="DecisionRule_0al9vbu">
<inputEntry id="UnaryTests_0rynlvv">
<text>[0..5]</text>
</inputEntry>
<outputEntry id="LiteralExpression_0f6oge7">
<text>"World"</text>
</outputEntry>
</rule>
<rule id="DecisionRule_0p54cry">
<inputEntry id="UnaryTests_0ntn86o">
<text>[7..9]</text>
</inputEntry>
<outputEntry id="LiteralExpression_1atols8">
<text>"Hello"</text>
</outputEntry>
</rule>
<rule id="DecisionRule_0h2fkl8">
<inputEntry id="UnaryTests_11ajd7x">
<text>[7..15]</text>
</inputEntry>
<outputEntry id="LiteralExpression_0drd4qx">
<text>"FuBa"</text>
</outputEntry>
</rule>
</decisionTable>
</decision>
<decision id="Decision_19xi89b" name="Subsumption test 2">
<extensionElements>
<biodi:bounds x="343" y="178" width="180" height="80" />
</extensionElements>
<decisionTable id="DecisionTable_0p3gy3p">
<input id="InputClause_095mouf">
<inputExpression id="LiteralExpression_0by8u52" typeRef="integer" />
</input>
<input id="InputClause_1noqtoh">
<inputExpression id="LiteralExpression_1w9f5gq" typeRef="string">
<text></text>
</inputExpression>
</input>
<output id="OutputClause_0xupopk" typeRef="string" />
<rule id="DecisionRule_0kkfntw">
<inputEntry id="UnaryTests_12wi462">
<text>[10..20]</text>
</inputEntry>
<inputEntry id="UnaryTests_0kardbu">
<text>"a"</text>
</inputEntry>
<outputEntry id="LiteralExpression_09o0uoj">
<text></text>
</outputEntry>
</rule>
<rule id="DecisionRule_02ugnup">
<inputEntry id="UnaryTests_10mg943">
<text>[11..19]</text>
</inputEntry>
<inputEntry id="UnaryTests_16v2m5l">
<text>"a"</text>
</inputEntry>
<outputEntry id="LiteralExpression_1n8yp0s">
<text></text>
</outputEntry>
</rule>
<rule id="DecisionRule_1l9le35">
<inputEntry id="UnaryTests_1nyire8">
<text>[12..18]</text>
</inputEntry>
<inputEntry id="UnaryTests_1lbqwex">
<text>"b"</text>
</inputEntry>
<outputEntry id="LiteralExpression_0h5ubao">
<text></text>
</outputEntry>
</rule>
<rule id="DecisionRule_0ok83ek">
<inputEntry id="UnaryTests_04p4mkt">
<text>[12..18]</text>
</inputEntry>
<inputEntry id="UnaryTests_1w75h2z">
<text>"a"</text>
</inputEntry>
<outputEntry id="LiteralExpression_1s6eocn">
<text></text>
</outputEntry>
</rule>
<rule id="DecisionRule_1fy5k22">
<inputEntry id="UnaryTests_09z2anu">
<text>[13..17]</text>
</inputEntry>
<inputEntry id="UnaryTests_1yd8iel">
<text></text>
</inputEntry>
<outputEntry id="LiteralExpression_0c4gtb4">
<text></text>
</outputEntry>
</rule>
<rule id="DecisionRule_18921uy">
<inputEntry id="UnaryTests_1cbt1dj">
<text>[0..21]</text>
</inputEntry>
<inputEntry id="UnaryTests_1515ccv">
<text></text>
</inputEntry>
<outputEntry id="LiteralExpression_1u5cl6z">
<text></text>
</outputEntry>
</rule>
</decisionTable>
</decision>
</definitions> </definitions>
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" id="Definitions_1kjh9a2" name="DRD" namespace="http://camunda.org/schema/1.0/dmn">
<decision id="Decision_13nychf" name="Decision 1">
<extensionElements>
<biodi:bounds x="120" y="145" width="180" height="80" />
</extensionElements>
<decisionTable id="decisionTable_1">
<input id="input_1">
<inputExpression id="inputExpression_1" typeRef="string">
<text></text>
</inputExpression>
</input>
<output id="output_1" typeRef="string" />
</decisionTable>
</decision>
</definitions>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment