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

First try, not finished yet

parent ce2b6c9e
No related branches found
No related tags found
No related merge requests found
......@@ -6,14 +6,25 @@ import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.getRu
import static de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions.templateDecision;
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix.SHOW_RULES;
import de.unikoblenz.fgbks.base.domain.Name;
import de.unikoblenz.fgbks.core.dmn.domain.common.RowNumber;
import de.unikoblenz.fgbks.core.dmn.domain.ids.InputEntryId;
import de.unikoblenz.fgbks.core.dmn.domain.ids.RuleId;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecision;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnDecisionTable;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnInputColumn;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnInputValue;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.VDmnRule;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.impl.VDmnInputValueImpl;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.impl.VDmnRuleChangeableImpl;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.impl.VDmnRuleImpl;
import de.unikoblenz.fgbks.core.dmn.domain.vdmn.utils.VDmnFunctions;
import de.unikoblenz.fgbks.core.dmn.verification.result.VerificationResultEntry.VerificationClassification;
import de.unikoblenz.fgbks.core.dmn.verification.result.VerificationResultEntryElement;
import de.unikoblenz.fgbks.core.dmn.verification.result.actions.Action;
import de.unikoblenz.fgbks.core.dmn.verification.result.actions.ActionScope;
import de.unikoblenz.fgbks.core.dmn.verification.result.actions.ActionType;
import de.unikoblenz.fgbks.core.dmn.verification.result.actions.VerificationFix;
import de.unikoblenz.fgbks.core.dmn.verification.verifier.AbstractVerifier;
import de.unikoblenz.fgbks.core.dmn.verification.verifier.DmnVerifier;
import de.unikoblenz.fgbks.core.dmn.verification.verifier.types.PartialReductionVerification;
......@@ -41,6 +52,7 @@ public class PartialReductionVerifier extends AbstractVerifier {
List<VDmnInputColumn> inColumns, int i, List<VDmnRule> clusterRules, boolean hasCombination) {
if (i == inColumns.size()) {
if (hasCombination) {
createCombinedRule(inColumns, clusterRules);
clusterRules.forEach(
rule -> vreFactory.addElement(VerificationResultEntryElement.create(rule)));
vreFactory.addVerificationFix(SHOW_RULES);
......@@ -48,6 +60,7 @@ public class PartialReductionVerifier extends AbstractVerifier {
VerificationClassification.INFO,
templateDecision(inColumns.get(0).getDmnDecision()) + "Rules %s can be combined.",
getRulesRowsStrings(clusterRules));
}
} else {
List<VDmnInputValue> rules =
......@@ -97,4 +110,44 @@ public class PartialReductionVerifier extends AbstractVerifier {
}
}
}
private void createCombinedRule(List<VDmnInputColumn> inColumns, List<VDmnRule> clusterRules) {
// Combined Rule:
VDmnRuleChangeableImpl r =
new VDmnRuleChangeableImpl(
VDmnRuleImpl.getBuilder()
.withRuleId(new RuleId("TODO"))
.addInputValue(clusterRules.get(1).getDmnInputValues().get(0))
.withDmnDecisionTable(inColumns.get(0).getDmnDecisionTable())
.withRowNumber(new RowNumber(999L))
.build());
for (int x = 0; x < inColumns.size(); x++) {
r.setInputValue(
x,
VDmnInputValueImpl.getBuilder()
.withInputEntryId(new InputEntryId("TODO"))
.withText("")
.withBoundary(
clusterRules
.get(0)
.getDmnInputValues()
.get(x)
.getBoundary()
.createBi(
COMBINE, clusterRules.get(1).getDmnInputValues().get(x).getBoundary())
.get())
.withDmnInputColumn(inColumns.get(x))
.withDmnRule(r)
.build());
}
vreFactory.addVerificationFix(VerificationFix.getBuilder()
.withFixName(new Name("Combine"))
.addAction(Action.getBuilder()
.withActionScope(ActionScope.RULE)
.withActionType(ActionType.CREATE)
.addValue("value", r.toString()) // TODO
.build())
.build()
);
}
}
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