use of org.kie.workbench.common.dmn.api.definition.model.Context 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;
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class MoveRowsCommandTest method setup.
@Before
public void setup() {
this.context = new Context();
this.uiModel = new DMNGridData();
doReturn(ruleManager).when(handler).getRuleManager();
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiNameColumn).getIndex();
doReturn(2).when(uiExpressionEditorColumn).getIndex();
addContextEntry(II1);
addContextEntry(II2);
addUiModelColumn(uiRowNumberColumn);
addUiModelColumn(uiNameColumn);
addUiModelColumn(uiExpressionEditorColumn);
addUiModelRow(0);
addUiModelRow(1);
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class JavaFunctionEditorDefinitionTest method testModelEnrichment.
@Test
public void testModelEnrichment() {
final Optional<Context> oModel = definition.getModelClass();
definition.enrich(Optional.empty(), hasExpression, oModel);
final Context model = oModel.get();
assertEquals(2, model.getContextEntry().size());
assertEquals(JavaFunctionEditorDefinition.VARIABLE_CLASS, model.getContextEntry().get(0).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(0).getExpression() instanceof LiteralExpression);
assertEquals(model, model.getContextEntry().get(0).getParent());
assertEquals(JavaFunctionEditorDefinition.VARIABLE_METHOD_SIGNATURE, model.getContextEntry().get(1).getVariable().getName().getValue());
assertTrue(model.getContextEntry().get(1).getExpression() instanceof LiteralExpression);
assertEquals(model, model.getContextEntry().get(1).getParent());
}
use of org.kie.workbench.common.dmn.api.definition.model.Context in project kie-wb-common by kiegroup.
the class BaseContextUIModelMapperTest method setup.
@SuppressWarnings("unchecked")
public void setup(final boolean isOnlyVisualChangeAllowedSupplier) {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiNameColumn);
this.uiModel.appendColumn(uiExpressionEditorColumn);
when(uiRowNumberColumn.getIndex()).thenReturn(0);
when(uiNameColumn.getIndex()).thenReturn(1);
when(uiExpressionEditorColumn.getIndex()).thenReturn(2);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
when(literalExpressionEditor.getExpression()).thenReturn(() -> Optional.of(literalExpression));
when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
this.context = new Context();
this.context.getContextEntry().add(new ContextEntry() {
{
setVariable(new InformationItem() {
{
setName(new Name("ii1"));
}
});
}
});
this.context.getContextEntry().add(new ContextEntry() {
{
setExpression(new LiteralExpression());
}
});
this.mapper = getMapper(isOnlyVisualChangeAllowedSupplier);
this.cellValueSupplier = Optional::empty;
}
use of org.kie.workbench.common.dmn.api.definition.model.Context 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