use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem in project kie-wb-common by kiegroup.
the class RelationUIModelMapperHelperTest method testGetSectionRowNumberColumnWhenInformationItemPresent.
@Test
public void testGetSectionRowNumberColumnWhenInformationItemPresent() {
relation.getColumn().add(new InformationItem());
assertEquals(RelationSection.ROW_INDEX, getSection(relation, 0));
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem in project kie-wb-common by kiegroup.
the class RelationPropertyConverter method wbFromDMN.
public static Relation wbFromDMN(final org.kie.dmn.model.v1_1.Relation dmn) {
Id id = new Id(dmn.getId());
Description description = new Description(dmn.getDescription());
QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
List<org.kie.dmn.model.v1_1.InformationItem> column = dmn.getColumn();
List<org.kie.dmn.model.v1_1.List> row = dmn.getRow();
List<InformationItem> convertedColumn = column.stream().map(InformationItemPropertyConverter::wbFromDMN).collect(Collectors.toList());
List<org.kie.workbench.common.dmn.api.definition.v1_1.List> convertedRow = row.stream().map(ListPropertyConverter::wbFromDMN).collect(Collectors.toList());
Relation result = new Relation(id, description, typeRef, convertedColumn, convertedRow);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem in project kie-wb-common by kiegroup.
the class AddRelationColumnCommand method newGraphCommand.
@Override
protected Command<GraphCommandExecutionContext, RuleViolation> newGraphCommand(final AbstractCanvasHandler handler) {
return new AbstractGraphCommand() {
@Override
protected CommandResult<RuleViolation> check(final GraphCommandExecutionContext gce) {
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> execute(final GraphCommandExecutionContext gce) {
final int iiIndex = uiColumnIndex - RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT;
relation.getColumn().add(iiIndex, informationItem);
relation.getRow().forEach(row -> {
final LiteralExpression le = new LiteralExpression();
row.getExpression().add(iiIndex, le);
});
return GraphCommandResultBuilder.SUCCESS;
}
@Override
public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext gce) {
final int columnIndex = relation.getColumn().indexOf(informationItem);
relation.getRow().forEach(row -> row.getExpression().remove(columnIndex));
relation.getColumn().remove(informationItem);
return GraphCommandResultBuilder.SUCCESS;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem in project kie-wb-common by kiegroup.
the class ContextGrid method addContextEntry.
void addContextEntry(final int index) {
expression.ifPresent(c -> {
final ContextEntry ce = new ContextEntry();
ce.setVariable(new InformationItem());
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddContextEntryCommand(c, ce, model, new DMNGridRow(), index, uiModelMapper, this::synchroniseView));
});
}
use of org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem in project kie-wb-common by kiegroup.
the class ContextUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
dmnModel.get().ifPresent(context -> {
final boolean isLastRow = isLastRow(rowIndex);
final ContextUIModelMapperHelper.ContextSection section = ContextUIModelMapperHelper.getSection(columnIndex);
switch(section) {
case ROW_INDEX:
if (!isLastRow) {
uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
} else {
uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new BaseGridCellValue<>((Integer) null)));
}
uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
break;
case NAME:
if (!isLastRow) {
final InformationItem variable = context.getContextEntry().get(rowIndex).getVariable();
uiModel.get().setCell(rowIndex, columnIndex, () -> new InformationItemNameCell(() -> variable, listSelector));
} else {
uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new BaseGridCellValue<>(DEFAULT_ROW_CAPTION)));
}
break;
case EXPRESSION:
final ContextEntry ce = context.getContextEntry().get(rowIndex);
final Optional<Expression> expression = Optional.ofNullable(ce.getExpression());
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(ed -> {
final Optional<BaseExpressionGrid> editor = ed.getEditor(new GridCellTuple(rowIndex, columnIndex, gridWidget), Optional.empty(), ce, expression, Optional.ofNullable(ce.getVariable()), nesting + 1);
if (!isLastRow) {
uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new ExpressionCellValue(editor), listSelector));
} else {
uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new ExpressionCellValue(editor)));
}
});
}
});
}
Aggregations