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

Add name and label in vdmn parser

parent 75b3b706
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import de.unikoblenz.fgbks.core.dmn.domain.ids.DecisionTableId;
import de.unikoblenz.fgbks.core.dmn.domain.ids.DefinitionId;
import de.unikoblenz.fgbks.core.dmn.domain.ids.RuleId;
import java.util.List;
import java.util.Optional;
public interface VDmnValue extends VDmnElement {
......@@ -17,7 +18,7 @@ public interface VDmnValue extends VDmnElement {
VDmnColumn getDmnColumn();
default List<String> getPossiblePredefinedValues() {
default Optional<List<String>> getPossiblePredefinedValues() {
return getDmnColumn().getPredefinedValues();
}
......
......@@ -52,6 +52,11 @@ public class VDmnInputColumnImpl extends AbstractVDmnColumnImpl implements VDmnI
return this;
}
public Builder withLabel(String label) {
value.label = label;
return this;
}
public Builder addValue(VDmnInputValue dmnValue) {
value.values.add(Validate.notNull(dmnValue));
return this;
......
......@@ -44,6 +44,11 @@ public class VDmnOutputColumnImpl extends AbstractVDmnColumnImpl implements VDmn
return this;
}
public Builder withLabel(String label) {
value.label = label;
return this;
}
public Builder addValueFromBuilder(VDmnOutputValueImpl.Builder dmnValueBuilder) {
addValue(Validate.notNull(dmnValueBuilder.getUnbuildValue()));
dmnValueBuilder.withDmnOutputColumn(value);
......
......@@ -48,6 +48,10 @@ public class SimpleVDmnParser implements DmnModelInstanceWrapper {
// Create Builder for DmnDecision
VDmnDecisionImpl.Builder decisionBuilder =
VDmnDecisionImpl.getBuilder().withDecisionId(new DecisionId(decision.getId()));
// Add name, if present
if (decision.getName() != null) {
decisionBuilder.withName(decision.getName());
}
// Add DmnDecisionBuilder to definitionBuilder
definitionBuilder.addDmnDecisionFromBuilder(decisionBuilder);
// Get the decisionTable
......@@ -66,11 +70,21 @@ public class SimpleVDmnParser implements DmnModelInstanceWrapper {
new ArrayList<>(decisionTable.getInputs().size());
for (Input inputCol : decisionTable.getInputs()) {
VTypeRef type = VTypeRef.getTypeRefFromName(inputCol.getInputExpression().getTypeRef());
inputColumnBuilders.add(
VDmnInputColumnImpl.Builder builder =
VDmnInputColumnImpl.getBuilder()
.withInputId(new InputId(inputCol.getId()))
.withInputExpressionId(new InputExpressionId(inputCol.getInputExpression().getId()))
.withTypeRef(type));
.withTypeRef(type);
// name
if (inputCol.getInputExpression().getText() != null) {
builder.withName(inputCol.getInputExpression().getText().getTextContent());
}
// label
if (inputCol.getLabel() != null) {
builder.withLabel(inputCol.getLabel());
}
// Add Builder to builder list
inputColumnBuilders.add(builder);
// Add predefined values to model
if (type == VTypeRef.STRING && inputCol.getInputValues() != null) {
inputColumnBuilders
......@@ -92,10 +106,20 @@ public class SimpleVDmnParser implements DmnModelInstanceWrapper {
new ArrayList<>(decisionTable.getOutputs().size());
for (Output outputCol : decisionTable.getOutputs()) {
VTypeRef type = VTypeRef.getTypeRefFromName(outputCol.getTypeRef());
outputColumnBuilders.add(
VDmnOutputColumnImpl.Builder builder =
VDmnOutputColumnImpl.getBuilder()
.withOutputId(new OutputId(outputCol.getId()))
.withTypeRef(VTypeRef.getTypeRefFromName(outputCol.getTypeRef())));
.withTypeRef(VTypeRef.getTypeRefFromName(outputCol.getTypeRef()));
// name
if (outputCol.getName() != null) {
builder.withName(outputCol.getName());
}
// label
if (outputCol.getLabel() != null) {
builder.withLabel(outputCol.getLabel());
}
// Add Builder to builder list
outputColumnBuilders.add(builder);
// Add predefined values to model
if (type == VTypeRef.STRING && outputCol.getOutputValues() != null) {
outputColumnBuilders
......
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