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