use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class FunctionEditorDefinition method enrich.
@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<FunctionDefinition> expression) {
expression.ifPresent(function -> {
KindUtilities.setKind(function, FunctionDefinition.Kind.FEEL);
final LiteralExpression le = new LiteralExpression();
function.setExpression(le);
le.setParent(function);
});
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DecisionRulePropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.DecisionRule dmnFromWB(final DecisionRule wb) {
final org.kie.dmn.model.api.DecisionRule result = new org.kie.dmn.model.v1_2.TDecisionRule();
result.setId(wb.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
for (final RuleAnnotationClauseText ruleAnnotationClauseText : wb.getAnnotationEntry()) {
final org.kie.dmn.model.api.RuleAnnotation ruleAnnotation = RuleAnnotationClauseTextConverter.dmnFromWB(ruleAnnotationClauseText);
if (ruleAnnotation != null) {
ruleAnnotation.setParent(result);
}
result.getAnnotationEntry().add(ruleAnnotation);
}
for (final UnaryTests ie : wb.getInputEntry()) {
final org.kie.dmn.model.api.UnaryTests inputEntryConverted = UnaryTestsPropertyConverter.dmnFromWB(ie);
if (inputEntryConverted != null) {
inputEntryConverted.setParent(result);
}
result.getInputEntry().add(inputEntryConverted);
}
for (final LiteralExpression oe : wb.getOutputEntry()) {
final org.kie.dmn.model.api.LiteralExpression outputEntryConverted = LiteralExpressionPropertyConverter.dmnFromWB(oe);
if (outputEntryConverted != null) {
outputEntryConverted.setParent(result);
}
result.getOutputEntry().add(outputEntryConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class DecisionRulePropertyConverter method wbFromDMN.
public static DecisionRule wbFromDMN(final org.kie.dmn.model.api.DecisionRule dmn) {
final Id id = new Id(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final DecisionRule result = new DecisionRule();
result.setId(id);
if (!(dmn instanceof org.kie.dmn.model.v1_1.TDecisionRule)) {
for (final org.kie.dmn.model.api.RuleAnnotation ruleAnnotation : dmn.getAnnotationEntry()) {
final RuleAnnotationClauseText annotationEntryConverted = RuleAnnotationClauseTextConverter.wbFromDMN(ruleAnnotation);
if (annotationEntryConverted != null) {
annotationEntryConverted.setParent(result);
}
result.getAnnotationEntry().add(annotationEntryConverted);
}
}
if (result.getAnnotationEntry().isEmpty()) {
// If it's empty, then there is none RuleAnnotation and the description was not converted yet to RuleAnnotation.
final RuleAnnotationClauseText annotationEntryText = new RuleAnnotationClauseText();
annotationEntryText.getText().setValue(description.getValue());
annotationEntryText.setParent(result);
result.getAnnotationEntry().add(annotationEntryText);
}
for (final org.kie.dmn.model.api.UnaryTests ie : dmn.getInputEntry()) {
final UnaryTests inputEntryConverted = UnaryTestsPropertyConverter.wbFromDMN(ie);
if (inputEntryConverted != null) {
inputEntryConverted.setParent(result);
}
result.getInputEntry().add(inputEntryConverted);
}
for (final org.kie.dmn.model.api.LiteralExpression oe : dmn.getOutputEntry()) {
final LiteralExpression outputEntryConverted = LiteralExpressionPropertyConverter.wbFromDMN(oe);
if (outputEntryConverted != null) {
outputEntryConverted.setParent(result);
}
result.getOutputEntry().add(outputEntryConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverter method convertContextEntryExpression.
private static void convertContextEntryExpression(final ContextEntry contextEntry) {
final Expression expression = contextEntry.getExpression();
if (expression instanceof LiteralExpression) {
final LiteralExpression le = (LiteralExpression) expression;
final String variableName = contextEntry.getVariable().getName().getValue();
if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, variableName)) {
contextEntry.setExpression(convertLiteralExpressionToPMMLDocument(le));
} else if (Objects.equals(LiteralExpressionPMMLDocumentModel.VARIABLE_MODEL, variableName)) {
contextEntry.setExpression(convertLiteralExpressionToPMMLDocumentModel(le));
}
}
}
use of org.kie.workbench.common.dmn.api.definition.model.LiteralExpression in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverter method wbFromDMN.
public static Expression wbFromDMN(final org.kie.dmn.model.api.Expression dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (dmn instanceof org.kie.dmn.model.api.LiteralExpression) {
final LiteralExpression e = LiteralExpressionPropertyConverter.wbFromDMN((org.kie.dmn.model.api.LiteralExpression) dmn);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.Context) {
final Context e = ContextPropertyConverter.wbFromDMN((org.kie.dmn.model.api.Context) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.Relation) {
final Relation e = RelationPropertyConverter.wbFromDMN((org.kie.dmn.model.api.Relation) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.List) {
final List e = ListPropertyConverter.wbFromDMN((org.kie.dmn.model.api.List) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.Invocation) {
final Invocation e = InvocationPropertyConverter.wbFromDMN((org.kie.dmn.model.api.Invocation) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.FunctionDefinition) {
final FunctionDefinition e = FunctionDefinitionPropertyConverter.wbFromDMN((org.kie.dmn.model.api.FunctionDefinition) dmn, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (dmn instanceof org.kie.dmn.model.api.DecisionTable) {
final DecisionTable e = DecisionTablePropertyConverter.wbFromDMN((org.kie.dmn.model.api.DecisionTable) dmn);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
}
return null;
}
Aggregations