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

Merge branch 'feature/actionshasic' into documentation/verifier

parents 75daa648 e9e7d0f7
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,8 @@ import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.ActionSco
import static de.unikoblenz.fgbks.core.dmn.verification.result.actions.ActionType.SHOW;
import de.unikoblenz.fgbks.base.builder.DefaultBuilder;
import de.unikoblenz.fgbks.core.dmn.domain.ids.AbstractId;
import de.unikoblenz.fgbks.core.dmn.domain.ids.JsonIdentifier;
import de.unikoblenz.fgbks.core.dmn.verification.result.AbstractResultObject;
import java.util.HashMap;
import javax.json.bind.annotation.JsonbProperty;
......@@ -83,6 +85,16 @@ public class Action extends AbstractResultObject {
return this;
}
public Builder addIdValue(AbstractId id) {
try {
String keyValue = id.getClass().getAnnotation(JsonIdentifier.class).value();
this.value.values.put(Validate.notNull(keyValue), Validate.notNull(id.getValue()));
} catch (Exception e) {
// nothing
}
return this;
}
@Override
protected void validate() {
super.validate();
......
......@@ -77,6 +77,7 @@ public class MissingInputColumnVerifier extends AbstractVerifier {
.withFixName(new Name("Delete Input Data"))
.addAction(
Action.getBuilder()
.addIdValue(inputDataNode.getId())
.withActionType(ActionType.DELETE)
.withActionScope(ActionScope.INPUT_DATA)
.build())
......@@ -92,7 +93,7 @@ public class MissingInputColumnVerifier extends AbstractVerifier {
Action.getBuilder()
.withActionType(ActionType.CREATE)
.withActionScope(ActionScope.INPUT_COLUMN)
.addValue("decisionId", decision.getDecisionId().getValue())
.addIdValue(decision.getDecisionId())
.addValue("name", inputDataNode.getName().get().getValue())
.addValue("typeRef", "string")
.build())
......@@ -109,7 +110,7 @@ public class MissingInputColumnVerifier extends AbstractVerifier {
Action.getBuilder()
.withActionType(ActionType.CREATE)
.withActionScope(ActionScope.INPUT_COLUMN)
.addValue("decisionId", decision.getDecisionId().getValue())
.addIdValue(decision.getDecisionId())
.addValue("name", outputColumn.getName().get().getValue())
.addValue("typeRef", outputColumn.getTypeRef().getName())
.build())
......
......@@ -71,6 +71,7 @@ public class MissingInputDataVerifier extends AbstractVerifier {
.withFixName(new Name("Add Data Input"))
.addAction(
Action.getBuilder()
.addIdValue(inputColumn.getVDmnDecision().getDecisionId())
.withActionType(ActionType.CREATE)
.withActionScope(ActionScope.INPUT_DATA)
.addValue("name", inputColumn.getName().get().getValue())
......@@ -83,6 +84,8 @@ public class MissingInputDataVerifier extends AbstractVerifier {
.withFixName(new Name("Delete Column"))
.addAction(
Action.getBuilder()
.addIdValue(inputColumn.getVDmnDecision().getDecisionId())
.addIdValue(inputColumn.getInputId())
.withActionType(ActionType.DELETE)
.withActionScope(ActionScope.INPUT_COLUMN)
.build())
......
......@@ -65,7 +65,10 @@ public class MissingRuleVerifier extends AbstractVerifier {
.collect(Collectors.joining(" / ")));
sb.append(" }");
Action.Builder fixActionBuilder =
Action.getBuilder().withActionScope(ActionScope.RULE).withActionType(ActionType.CREATE);
Action.getBuilder()
.withActionScope(ActionScope.RULE)
.withActionType(ActionType.CREATE)
.addIdValue(missingRule.getVDmnDecision().getDecisionId());
for (VDmnInputValue v : missingRule.getVDmnInputValues()) {
fixActionBuilder.addValue(
v.getVDmnInputColumn().getInputId().getValue(), v.getBoundary().getParsedText());
......@@ -99,14 +102,14 @@ public class MissingRuleVerifier extends AbstractVerifier {
private VDmnRuleChangeableImpl constructPseudoMissingRule(List<VDmnInputColumn> inputs) {
Builder b =
VDmnRuleImpl.getBuilder()
.withRuleId(new RuleId("TODO")) // TODO
.withRuleId(new RuleId("TODO"))
.withVDmnDecisionTable(inputs.get(0).getVDmnDecisionTable())
.withRowNumber(new RowNumber(INITIAL_ROW_NUMER));
for (VDmnInputColumn col : inputs) {
b.addVDmnInputValue(
VDmnInputValueImpl.getBuilder()
.withInputEntryId(new InputEntryId("TODO")) // TODO
.withInputEntryId(new InputEntryId("TODO"))
.withText("")
.withVDmnInputColumn(col)
.withVDmnRuleFromBuilder(b)
......
......@@ -157,7 +157,10 @@ public class PartialReductionVerifier extends AbstractVerifier {
.get());
}
Action.Builder fixActionBuilder =
Action.getBuilder().withActionScope(ActionScope.RULE).withActionType(ActionType.CREATE);
Action.getBuilder()
.withActionScope(ActionScope.RULE)
.withActionType(ActionType.CREATE)
.addIdValue(inColumns.get(0).getVDmnDecision().getDecisionId());
for (int i = 0; i < inColumns.size(); i++) {
fixActionBuilder.addValue(
inColumns.get(i).getInputId().getValue(), boundaries.get(i).getParsedText());
......@@ -168,22 +171,25 @@ public class PartialReductionVerifier extends AbstractVerifier {
outputValues.get(i).getVDmnOutputColumn().getOutputId().getValue(),
outputValues.get(i).getText().getValue());
}
Action.Builder fixActionBuilder2 =
Action.getBuilder().withActionScope(ActionScope.RULE).withActionType(ActionType.DELETE);
fixActionBuilder2.addValue(
"decisionId", clusterRules.get(0).getVDmnDecision().getDecisionId().getValue());
fixActionBuilder2.addValue("ruleId", clusterRules.get(0).getRuleId().getValue());
Action.Builder fixActionBuilder3 =
Action.getBuilder().withActionScope(ActionScope.RULE).withActionType(ActionType.DELETE);
fixActionBuilder3.addValue(
"decisionId", clusterRules.get(1).getVDmnDecision().getDecisionId().getValue());
fixActionBuilder3.addValue("ruleId", clusterRules.get(1).getRuleId().getValue());
vreFactory.addVerificationFix(
VerificationFix.getBuilder()
.withFixName(new Name("Combine"))
.addAction(fixActionBuilder.build())
.addAction(fixActionBuilder2.build())
.addAction(fixActionBuilder3.build())
.addAction(
Action.getBuilder()
.withActionScope(ActionScope.RULE)
.withActionType(ActionType.DELETE)
.addIdValue(clusterRules.get(0).getVDmnDecision().getDecisionId())
.addIdValue(clusterRules.get(0).getRuleId())
.build())
.addAction(
Action.getBuilder()
.withActionScope(ActionScope.RULE)
.withActionType(ActionType.DELETE)
.addIdValue(clusterRules.get(1).getVDmnDecision().getDecisionId())
.addIdValue(clusterRules.get(1).getRuleId())
.build())
.build());
}
}
......@@ -13,6 +13,30 @@ function getSheetElementWithId(id) {
return getCurrentModeler()._sheet._elementRegistry.get(id);
}
/**
*
* @param sourceX
* @param sourceY
* @param w
* @param offsetX
* @param offsetY
* @returns {{x: *, y: *}}
*/
function getRandomNewPointInCycle(sourceX, sourceY, w, offsetX, offsetY) {
let dx = Math.floor(Math.random() * Math.floor(2 * w)) - w;
let dy = Math.sqrt(w * w - dx * dx);
if (offsetX) {
dx += offsetX;
}
if (offsetY) {
dy += offsetY;
}
if (Math.random() > 0.5) {
dy *= -1;
}
return {x: sourceX + dx, y: sourceY + dy};
}
/**
*
* @param {VerificationEntry} verificationEntry
......@@ -35,7 +59,7 @@ function performVerificationFix(verificationEntry, fix, id, $callerButton) {
break;
case 'CREATE':
performVerificationFixCREATE(verificationEntry, fix.actions[i]);
$callerButton.css('display', 'none');
//$callerButton.css('display', 'none');
break;
case 'DELETE':
performVerificationFixDELETE(verificationEntry, fix.actions[i]);
......@@ -190,7 +214,7 @@ function performVerificationFixCREATE(verificationEntry, fixAction) {
* @param {Action} fixAction
*/
function createRule(verificationEntry, fixAction) {
openViewWithId(verificationEntry.elements[0].identifier['decisionId']);
openViewWithId(fixAction.actionValues['decisionId']);
const modeler = getCurrentModeler();
const rule = modeler.addRow({type: "dmn:DecisionRule"});
const {cells} = rule;
......@@ -208,17 +232,17 @@ function createRule(verificationEntry, fixAction) {
* @param {Action} fixAction
*/
function createInputData(verificationEntry, fixAction) {
// getCurrentModeler().createShape(getCurrentModeler()._elementFactory.createDrdElement('shape', {type:'dmn:InputData'}), {x:0,y:0}, dmnModeler._definitions)
openViewWithId(verificationEntry.elements[0].identifier['definitionId']);
let decision = getShapeWithId(
verificationEntry.elements[0].identifier['decisionId']);
let decision = getShapeWithId(fixAction.actionValues['decisionId']);
const modeler = getCurrentModeler();
const shape = modeler._elementFactory.createDrdElement('shape',
{type: 'dmn:InputData'});
let inputData = modeler.appendShape(decision, shape,
{x: decision.x - 150, y: decision.y + 40},
getRandomNewPointInCycle(decision.x, decision.y, 250, decision.width / 2,
decision.height / 2),
getShapeWithId(verificationEntry.elements[0].identifier['definitionId']),
{attach: false, connection: {type: "dmn:InformationRequirement"}});
{attach: false, connection: {type: "dmn:InformationRequirement"}}
);
inputData.businessObject.name = fixAction.actionValues['name'];
openViewWithId(verificationEntry.elements[0].identifier['definitionId']);
}
......@@ -229,7 +253,6 @@ function createInputData(verificationEntry, fixAction) {
* @param {Action} fixAction
*/
function createInputColumn(verificationEntry, fixAction) {
// getCurrentModeler().createShape(getCurrentModeler()._elementFactory.createDrdElement('shape', {type:'dmn:InputData'}), {x:0,y:0}, dmnModeler._definitions)
openViewWithId(fixAction.actionValues['decisionId']);
const modeler = getCurrentModeler();
let col = modeler.addCol({type: 'dmn:InputClause'});
......@@ -273,12 +296,12 @@ function performVerificationFixDELETE(verificationEntry, fixAction) {
* @param {Action} fixAction
*/
function deleteRule(verificationEntry, fixAction) {
openViewWithId(verificationEntry.elements[0].identifier['decisionId']);
openViewWithId(fixAction.actionValues['decisionId']);
const modeler = getCurrentModeler();
for (const [key, value] of Object.entries(fixAction.actionValues)) {
if (key === 'ruleId') {
modeler.removeRow(modeler._sheet._elementRegistry.get(value));
}
const row = modeler._sheet._elementRegistry.get(
fixAction.actionValues['ruleId']);
if (row) {
modeler.removeRow(row);
}
}
......@@ -289,14 +312,12 @@ function deleteRule(verificationEntry, fixAction) {
* @param {String} columnIdName
*/
function deleteColumn(verificationEntry, fixAction, columnIdName) {
openViewWithId(verificationEntry.elements[0].identifier['decisionId']);
openViewWithId(fixAction.actionValues['decisionId']);
const modeler = getCurrentModeler();
verificationEntry.elements.forEach(function (el) {
let col = getSheetElementWithId(el.identifier[columnIdName]);
if (col) {
modeler.removeCol(col);
}
});
const col = getSheetElementWithId(fixAction.actionValues[columnIdName]);
if (col) {
modeler.removeCol(col);
}
}
/**
......@@ -307,12 +328,10 @@ function deleteColumn(verificationEntry, fixAction, columnIdName) {
function deleteInputData(verificationEntry, fixAction) {
openViewWithId(verificationEntry.elements[0].identifier['definitionId']);
const modeler = getCurrentModeler();
verificationEntry.elements.forEach(function (el) {
let inputData = getShapeWithId(el.identifier['inputDataId']);
if (inputData) {
modeler.removeShape(inputData);
}
});
let inputData = getShapeWithId(fixAction.actionValues['inputDataId']);
if (inputData) {
modeler.removeShape(inputData);
}
}
// get a rule:
......
......@@ -109,6 +109,10 @@ function toggleFullscreen() {
}
}
/**
*
* @param id
*/
function openViewWithId(id) {
var views = dmnModeler.getViews();
views.forEach(function (view) {
......@@ -135,12 +139,20 @@ function cleanHighlightFunction() {
renderHighlightFunction = [];
}
/**
*
* @param {Array<VerificationEntryElement>} elements
*/
function highlightMultipleDecisions(elements) {
elements.forEach(function (el) {
highlightSingleDecision(el.identifier['decisionId']);
});
}
/**
*
* @param decisionId
*/
function highlightSingleDecision(decisionId) {
// node
let $decisionNode = $(
......@@ -150,12 +162,20 @@ function highlightSingleDecision(decisionId) {
$('#tab-dec-' + decisionId).addClass('highlight');
}
/**
*
* @param {Array<VerificationEntryElement>} elements
*/
function cleanMultipleDecisions(elements) {
elements.forEach(function (el) {
cleanSingleDecision(el.identifier['decisionId']);
});
}
/**
*
* @param decisionId
*/
function cleanSingleDecision(decisionId) {
// node
let $decisionNode = $(
......
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