use of org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.Expression dmnFromWB(final Expression wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
if (Objects.isNull(wb)) {
return null;
}
final String uuid = wb.getId().getValue();
if (Objects.nonNull(uuid)) {
final ComponentWidths componentWidths = new ComponentWidths();
componentWidths.setDmnElementRef(new QName(uuid));
componentWidths.setWidths(new ArrayList<>(wb.getComponentWidths()));
componentWidthsConsumer.accept(componentWidths);
}
if (wb instanceof IsLiteralExpression) {
return LiteralExpressionPropertyConverter.dmnFromWB((IsLiteralExpression) wb);
} else if (wb instanceof Context) {
return ContextPropertyConverter.dmnFromWB((Context) wb, componentWidthsConsumer);
} else if (wb instanceof Relation) {
return RelationPropertyConverter.dmnFromWB((Relation) wb, componentWidthsConsumer);
} else if (wb instanceof List) {
return ListPropertyConverter.dmnFromWB((List) wb, componentWidthsConsumer);
} else if (wb instanceof Invocation) {
return InvocationPropertyConverter.dmnFromWB((Invocation) wb, componentWidthsConsumer);
} else if (wb instanceof FunctionDefinition) {
return FunctionDefinitionPropertyConverter.dmnFromWB((FunctionDefinition) wb, componentWidthsConsumer);
} else if (wb instanceof DecisionTable) {
return DecisionTablePropertyConverter.dmnFromWB((DecisionTable) wb);
}
return null;
}
use of org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverter method dmnFromWB.
public static JSITExpression dmnFromWB(final Expression wb, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
if (Objects.isNull(wb)) {
return null;
}
final String uuid = wb.getId().getValue();
if (Objects.nonNull(uuid)) {
final JSITComponentWidths componentWidths = new JSITComponentWidths();
componentWidths.setDmnElementRef(uuid);
wb.getComponentWidths().stream().filter(Objects::nonNull).forEach(w -> componentWidths.addWidth(new Float(w)));
componentWidthsConsumer.accept(componentWidths);
}
if (wb instanceof IsLiteralExpression) {
final JSITLiteralExpression unwrappedJSITLiteralExpression = LiteralExpressionPropertyConverter.dmnFromWB((IsLiteralExpression) wb);
final JSITLiteralExpression wrappedJSITLiteralExpression = getWrappedJSITLiteralExpression(unwrappedJSITLiteralExpression, "dmn", "literalExpression");
return wrappedJSITLiteralExpression;
} else if (wb instanceof Context) {
final JSITContext unwrappedJSITContext = ContextPropertyConverter.dmnFromWB((Context) wb, componentWidthsConsumer);
final JSITContext wrappedJSITContext = getWrappedJSITContext(unwrappedJSITContext, "dmn", "context");
return wrappedJSITContext;
} else if (wb instanceof Relation) {
final JSITRelation unwrappedJSITRelation = RelationPropertyConverter.dmnFromWB((Relation) wb, componentWidthsConsumer);
final JSITRelation wrappedJSITRelation = getWrappedJSITRelation(unwrappedJSITRelation, "dmn", "relation");
return wrappedJSITRelation;
} else if (wb instanceof List) {
final JSITList unwrappedJSITList = ListPropertyConverter.dmnFromWB((List) wb, componentWidthsConsumer);
final JSITList wrappedJSITList = getWrappedJSITList(unwrappedJSITList, "dmn", "list");
return wrappedJSITList;
} else if (wb instanceof Invocation) {
final JSITInvocation unwrappedJSITInvocation = InvocationPropertyConverter.dmnFromWB((Invocation) wb, componentWidthsConsumer);
final JSITInvocation wrappedJSITInvocation = getWrappedJSITInvocation(unwrappedJSITInvocation, "dmn", "invocation");
return wrappedJSITInvocation;
} else if (wb instanceof FunctionDefinition) {
final JSITFunctionDefinition unwrappedJSITFunctionDefinition = FunctionDefinitionPropertyConverter.dmnFromWB((FunctionDefinition) wb, componentWidthsConsumer);
final JSITFunctionDefinition wrappedJSITFunctionDefinition = getWrappedJSITFunctionDefinition(unwrappedJSITFunctionDefinition, "dmn", "functionDefinition");
return wrappedJSITFunctionDefinition;
} else if (wb instanceof DecisionTable) {
final JSITDecisionTable unwrappedJSITDecisionTable = DecisionTablePropertyConverter.dmnFromWB((DecisionTable) wb);
final JSITDecisionTable wrappedJSITDecisionTable = getWrappedJSITDecisionTable(unwrappedJSITDecisionTable, "dmn", "decisionTable");
return wrappedJSITDecisionTable;
}
return null;
}
use of org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression in project kie-wb-common by kiegroup.
the class PMMLIncludedModelHandler method destroy.
@Override
public void destroy(final String oldModelName) {
final List<Decision> decisions = getDecisions();
final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels();
final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels);
final Map<FunctionDefinition, Context> contexts = getPMMLContexts(functions);
// The values in the DMN model are stored with quotes
final String quotedOldModelName = StringUtils.createQuotedString(oldModelName);
for (final Map.Entry<FunctionDefinition, Context> entry : contexts.entrySet()) {
final Context context = entry.getValue();
for (final ContextEntry contextEntry : context.getContextEntry()) {
if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, contextEntry.getVariable().getName().getValue())) {
final Expression expression = contextEntry.getExpression();
if (expression instanceof IsLiteralExpression) {
final IsLiteralExpression ile = (IsLiteralExpression) expression;
if (Objects.nonNull(ile.getText())) {
final Text text = ile.getText();
if (Objects.equals(quotedOldModelName, text.getValue())) {
clearContextValues(context);
entry.getKey().getFormalParameter().clear();
}
}
}
}
}
}
// Refresh cached grids from the DMN model
refreshCachedExpressionGrids(decisions, businessKnowledgeModels);
}
use of org.kie.workbench.common.dmn.api.definition.model.IsLiteralExpression in project kie-wb-common by kiegroup.
the class LiteralExpressionPropertyConverter method dmnFromWB.
public static JSITLiteralExpression dmnFromWB(final IsLiteralExpression wb) {
if (Objects.isNull(wb)) {
return null;
}
final JSITLiteralExpression result = LITERAL_EXPRESSION_PROVIDER.make();
result.setId(wb.getId().getValue());
final String description = wb.getDescription().getValue();
if (StringUtils.nonEmpty(description)) {
result.setDescription(description);
}
if (wb instanceof LiteralExpression) {
final String expressionLanguage = ((LiteralExpression) wb).getExpressionLanguage().getValue();
if (StringUtils.nonEmpty(expressionLanguage)) {
result.setExpressionLanguage(expressionLanguage);
}
}
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
result.setText(wb.getText().getValue());
final JSITImportedValues importedValues = ImportedValuesConverter.dmnFromWB(wb.getImportedValues());
if (Objects.nonNull(importedValues)) {
result.setImportedValues(importedValues);
}
return result;
}
Aggregations