use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class ExpressionContainerUIModelMapperTest method assertEditorType.
private void assertEditorType(final Class<?> clazz) {
final GridCell<?> gridCell = uiModel.getCell(0, 0);
assertThat(gridCell).isNotNull();
assertThat(gridCell).isInstanceOf(ContextGridCell.class);
final GridCellValue<?> gridCellValue = gridCell.getValue();
assertThat(gridCellValue).isNotNull();
assertThat(gridCellValue).isInstanceOf(ExpressionCellValue.class);
final ExpressionCellValue ecv = (ExpressionCellValue) gridCellValue;
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
assertThat(editor.isPresent()).isTrue();
assertThat(editor.get()).isInstanceOf(clazz);
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class BoxedExpressionHelperTest method testGetOptionalExpressionWhenIsNotPresent.
@Test
public void testGetOptionalExpressionWhenIsNotPresent() {
final View content = mock(View.class);
final Decision decision = mock(Decision.class);
when(node.getContent()).thenReturn(content);
when(content.getDefinition()).thenReturn(decision);
when(decision.getExpression()).thenReturn(null);
final Optional<Expression> optionalExpression = helper.getOptionalExpression(node);
assertFalse(optionalExpression.isPresent());
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class InvocationPropertyConverter method wbFromDMN.
public static Invocation wbFromDMN(final JSITInvocation dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (Objects.isNull(dmn)) {
return null;
}
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
final Invocation result = new Invocation();
result.setId(id);
result.setDescription(description);
result.setTypeRef(typeRef);
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), hasComponentWidthsConsumer);
}
result.setExpression(expression);
if (Objects.nonNull(expression)) {
expression.setParent(result);
}
final List<JSITBinding> jsiBindings = dmn.getBinding();
for (int i = 0; i < jsiBindings.size(); i++) {
final JSITBinding jsiBinding = Js.uncheckedCast(jsiBindings.get(i));
final Binding bConverted = BindingPropertyConverter.wbFromDMN(jsiBinding, hasComponentWidthsConsumer);
if (Objects.nonNull(bConverted)) {
bConverted.setParent(result);
}
result.getBinding().add(bConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverter method wbFromDMN.
public static FunctionDefinition wbFromDMN(final JSITFunctionDefinition dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (Objects.isNull(dmn)) {
return null;
}
final Id id = IdPropertyConverter.wbFromDMN(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
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), hasComponentWidthsConsumer);
}
final FunctionDefinition result = new FunctionDefinition(id, description, typeRef, expression);
if (Objects.nonNull(expression)) {
expression.setParent(result);
}
// JSITFunctionKind is a String JSO so convert into the real type
final String sKind = Js.uncheckedCast(dmn.getKind());
final Kind kind = Kind.fromValue(sKind);
switch(kind) {
case FEEL:
result.setKind(Kind.FEEL);
break;
case JAVA:
result.setKind(Kind.JAVA);
break;
case PMML:
result.setKind(Kind.PMML);
convertPMMLFunctionExpression(result, hasComponentWidthsConsumer);
break;
default:
result.setKind(Kind.FEEL);
break;
}
final List<JSITInformationItem> jsiInformationItems = dmn.getFormalParameter();
for (int i = 0; i < jsiInformationItems.size(); i++) {
final JSITInformationItem jsiInformationItem = Js.uncheckedCast(jsiInformationItems.get(i));
final InformationItem iiConverted = InformationItemPropertyConverter.wbFromDMN(jsiInformationItem);
if (Objects.nonNull(iiConverted)) {
iiConverted.setParent(result);
}
result.getFormalParameter().add(iiConverted);
}
return result;
}
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 BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
final Expression expression = function.getExpression();
if (expression instanceof Context) {
final Context context = (Context) expression;
context.getContextEntry().forEach(ce -> convertContextEntryExpression(ce, hasComponentWidthsConsumer));
}
}
Aggregations