use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverter method convertPMMLFunctionExpression.
private static void convertPMMLFunctionExpression(final FunctionDefinition function) {
final Expression expression = function.getExpression();
if (expression instanceof Context) {
final Context context = (Context) expression;
context.getContextEntry().forEach(FunctionDefinitionPropertyConverter::convertContextEntryExpression);
}
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class ListPropertyConverter method wbFromDMN.
public static List wbFromDMN(final JSITList dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
final java.util.List<HasExpression> expression = new ArrayList<>();
final List result = new List(id, description, typeRef, expression);
final java.util.List<JSITExpression> jsiExpressions = dmn.getExpression();
for (int i = 0; i < jsiExpressions.size(); i++) {
final JSITExpression jsitExpression = Js.uncheckedCast(jsiExpressions.get(i));
final Expression eConverted = ExpressionPropertyConverter.wbFromDMN(jsitExpression, Js.uncheckedCast(dmn), hasComponentWidthsConsumer);
final HasExpression hasExpression = HasExpression.wrap(result, eConverted);
expression.add(hasExpression);
}
for (HasExpression hasExpression : expression) {
final Expression e = hasExpression.getExpression();
if (Objects.nonNull(e)) {
e.setParent(result);
}
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class ListPropertyConverter method dmnFromWB.
public static JSITList dmnFromWB(final List wb, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
final JSITList result = new JSITList();
result.setId(wb.getId().getValue());
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
description.ifPresent(result::setDescription);
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (HasExpression hasExpression : wb.getExpression()) {
final Expression e = hasExpression.getExpression();
final JSITExpression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer);
result.addExpression(eConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class DecisionConverter method nodeFromDMN.
@Override
public Node<View<Decision>, ?> nodeFromDMN(final NodeEntry nodeEntry) {
final JSITDecision dmn = Js.uncheckedCast(nodeEntry.getDmnElement());
@SuppressWarnings("unchecked") final Node<View<Decision>, ?> node = (Node<View<Decision>, ?>) factoryManager.newElement(nodeEntry.getId(), getDefinitionId(Decision.class)).asNode();
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final Name name = new Name(dmn.getName());
final InformationItemPrimary informationItem = InformationItemPrimaryPropertyConverter.wbFromDMN(dmn.getVariable(), dmn);
Expression expression = null;
final JSITExpression jsiWrapped = dmn.getExpression();
if (Objects.nonNull(jsiWrapped)) {
final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), nodeEntry.getComponentWidthsConsumer());
}
final Decision decision = new Decision(id, description, name, new Question(), new AllowedAnswers(), informationItem, expression, new StylingSet(), new GeneralRectangleDimensionsSet());
decision.setDiagramId(nodeEntry.getDiagramId());
decision.setQuestion(QuestionPropertyConverter.wbFromDMN(dmn.getQuestion()));
decision.setAllowedAnswers(AllowedAnswersPropertyConverter.wbFromDMN(dmn.getAllowedAnswers()));
node.getContent().setDefinition(decision);
if (Objects.nonNull(informationItem)) {
informationItem.setParent(decision);
}
if (Objects.nonNull(expression)) {
expression.setParent(decision);
}
DMNExternalLinksToExtensionElements.loadExternalLinksFromExtensionElements(dmn, decision);
return node;
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class DecisionNavigatorNestedItemFactoryTest method testGetUUID.
@Test
public void testGetUUID() {
final Expression expression = mock(Expression.class);
final Id id = mock(Id.class);
final String expectedUUID = "uuid";
when(boxedExpressionHelper.getExpression(node)).thenReturn(expression);
when(expression.getId()).thenReturn(id);
when(id.getValue()).thenReturn(expectedUUID);
final String actualUUID = factory.getUUID(node);
assertEquals(expectedUUID, actualUUID);
}
Aggregations