use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class BaseExpressionGridCacheTest method getGrid.
@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
final HasExpression hasExpression = mock(HasExpression.class);
final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
final Optional<HasName> hasName = Optional.of(mock(HasName.class));
return new BaseExpressionGrid(parentCell, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, cacheResult, renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {
@Override
protected BaseUIModelMapper makeUiModelMapper() {
return mapper;
}
@Override
protected void initialiseUiColumns() {
model.appendColumn(uiColumn);
}
@Override
protected void initialiseUiModel() {
model.appendRow(uiRow);
}
@Override
protected boolean isHeaderHidden() {
return false;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method getGrid.
@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
final HasExpression hasExpression = mock(HasExpression.class);
final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
final Optional<HasName> hasName = Optional.of(mock(HasName.class));
return new BaseExpressionGrid(parentCell, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, new GridDataCache.CacheResult(new DMNGridData(), false), renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {
@Override
protected BaseUIModelMapper makeUiModelMapper() {
return mapper;
}
@Override
protected void initialiseUiColumns() {
// Nothing for this test
}
@Override
protected void initialiseUiModel() {
// Nothing for this test
}
@Override
protected boolean isHeaderHidden() {
return false;
}
};
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class ExpressionContainerUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
uiModel = new BaseGridData();
uiModel.appendRow(new DMNGridRow());
uiModel.appendColumn(uiExpressionColumn);
doReturn(0).when(uiExpressionColumn).getIndex();
doReturn(MINIMUM_COLUMN_WIDTH).when(uiExpressionColumn).getMinimumWidth();
parent = new GridCellTuple(0, 0, expressionContainerGrid);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
mapper = new ExpressionContainerUIModelMapper(parent, () -> uiModel, () -> Optional.ofNullable(expression), () -> NODE_UUID, () -> hasExpression, () -> Optional.of(hasName), expressionEditorDefinitionsSupplier, listSelector);
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class ListPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.List dmnFromWB(final List wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
final org.kie.dmn.model.api.List result = new org.kie.dmn.model.v1_2.TList();
result.setId(wb.getId().getValue());
result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (HasExpression hasExpression : wb.getExpression()) {
final Expression e = hasExpression.getExpression();
final org.kie.dmn.model.api.Expression eConverted = ExpressionPropertyConverter.dmnFromWB(e, componentWidthsConsumer);
if (Objects.nonNull(eConverted)) {
eConverted.setParent(result);
}
result.getExpression().add(eConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class ListPropertyConverter method wbFromDMN.
public static List wbFromDMN(final org.kie.dmn.model.api.List dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
final Id id = new Id(dmn.getId());
final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn);
final java.util.List<HasExpression> expression = new ArrayList<>();
final List result = new List(id, description, typeRef, expression);
for (org.kie.dmn.model.api.Expression e : dmn.getExpression()) {
final Expression eConverted = ExpressionPropertyConverter.wbFromDMN(e, 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;
}
Aggregations