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

Add utils functions for dmn check

parent 094f1f4f
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,6 @@ import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnRule;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnValue;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VTypeRef;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang3.Validate;
......@@ -70,12 +69,54 @@ public class VDmnFunctions {
.collect(Collectors.toList());
}
public boolean differentConclusions(List<VDmnRule> ruleIds) {
// TODO
public boolean differentConclusions(List<VDmnRule> rules) {
if (rules.size() == 0) {
return false;
}
VDmnRule refRule = rules.get(0);
for (VDmnRule rule : rules) {
if (differentConclusions(refRule, rule)) {
return true;
}
}
return false;
}
public List<VDmnRule> getRulesWithEqualOutput(VDmnDecisionTable dmnDecisionTable) {
return Collections.emptyList();
public boolean differentConclusions(VDmnRule oneRule, VDmnRule otherRule) {
if (oneRule.getDmnOutputValues().size() != otherRule.getDmnOutputValues().size()) {
return true;
}
for (int i = 0; i < oneRule.getDmnOutputValues().size(); i++) {
if (oneRule
.getDmnOutputValues()
.get(i)
.getText()
.equals(otherRule.getDmnOutputValues().get(0).getText())) {
return true;
}
}
return false;
}
public List<List<VDmnRule>> getRuleClustersWithIdenticalOutput(
VDmnDecisionTable dmnDecisionTable) {
List<List<VDmnRule>> clusters = new ArrayList<>();
List<VDmnRule> remainingRules = new ArrayList<>(dmnDecisionTable.getRules());
for (int i = 0; i < remainingRules.size(); i++) {
List<VDmnRule> newCluster = new ArrayList<>();
newCluster.add(remainingRules.get(i));
remainingRules.set(i, null);
for (int u = i + 1; u < remainingRules.size(); u++) {
if (remainingRules.get(u) != null
&& !differentConclusions(newCluster.get(0), remainingRules.get(u))) {
newCluster.add(remainingRules.get(u));
remainingRules.set(u, null);
}
}
if (newCluster.size() > 1) {
clusters.add(newCluster);
}
}
return clusters;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment