use of org.kie.workbench.common.dmn.api.definition.model.Relation in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.api.Expression dmnFromWB(final Expression wb, final Consumer<ComponentWidths> componentWidthsConsumer) {
if (Objects.isNull(wb)) {
return null;
}
final String uuid = wb.getId().getValue();
if (Objects.nonNull(uuid)) {
final ComponentWidths componentWidths = new ComponentWidths();
componentWidths.setDmnElementRef(new QName(uuid));
componentWidths.setWidths(new ArrayList<>(wb.getComponentWidths()));
componentWidthsConsumer.accept(componentWidths);
}
if (wb instanceof IsLiteralExpression) {
return LiteralExpressionPropertyConverter.dmnFromWB((IsLiteralExpression) wb);
} else if (wb instanceof Context) {
return ContextPropertyConverter.dmnFromWB((Context) wb, componentWidthsConsumer);
} else if (wb instanceof Relation) {
return RelationPropertyConverter.dmnFromWB((Relation) wb, componentWidthsConsumer);
} else if (wb instanceof List) {
return ListPropertyConverter.dmnFromWB((List) wb, componentWidthsConsumer);
} else if (wb instanceof Invocation) {
return InvocationPropertyConverter.dmnFromWB((Invocation) wb, componentWidthsConsumer);
} else if (wb instanceof FunctionDefinition) {
return FunctionDefinitionPropertyConverter.dmnFromWB((FunctionDefinition) wb, componentWidthsConsumer);
} else if (wb instanceof DecisionTable) {
return DecisionTablePropertyConverter.dmnFromWB((DecisionTable) wb);
}
return null;
}
use of org.kie.workbench.common.dmn.api.definition.model.Relation in project kie-wb-common by kiegroup.
the class RelationUIModelMapperTest method setup.
@Before
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiRelationColumn1);
this.uiModel.appendColumn(uiRelationColumn2);
when(uiRowNumberColumn.getIndex()).thenReturn(0);
when(uiRelationColumn1.getIndex()).thenReturn(1);
when(uiRelationColumn2.getIndex()).thenReturn(2);
this.relation = new Relation();
this.relation.getColumn().add(new InformationItem());
this.relation.getColumn().add(new InformationItem());
final List rowList1 = new List();
rowList1.getExpression().add(HasExpression.wrap(rowList1, new LiteralExpression() {
{
getText().setValue("le(1,0)");
}
}));
rowList1.getExpression().add(HasExpression.wrap(rowList1, new LiteralExpression() {
{
getText().setValue("le(2,0)");
}
}));
final List rowList2 = new List();
rowList2.getExpression().add(HasExpression.wrap(rowList2, new LiteralExpression() {
{
getText().setValue("le(1,1)");
}
}));
rowList2.getExpression().add(HasExpression.wrap(rowList2, new LiteralExpression() {
{
getText().setValue("le(2,1)");
}
}));
this.relation.getRow().add(rowList1);
this.relation.getRow().add(rowList2);
this.mapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector, DEFAULT_HEIGHT);
this.cellValueSupplier = Optional::empty;
}
use of org.kie.workbench.common.dmn.api.definition.model.Relation in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverter method dmnFromWB.
public static JSITExpression dmnFromWB(final Expression wb, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
if (Objects.isNull(wb)) {
return null;
}
final String uuid = wb.getId().getValue();
if (Objects.nonNull(uuid)) {
final JSITComponentWidths componentWidths = new JSITComponentWidths();
componentWidths.setDmnElementRef(uuid);
wb.getComponentWidths().stream().filter(Objects::nonNull).forEach(w -> componentWidths.addWidth(new Float(w)));
componentWidthsConsumer.accept(componentWidths);
}
if (wb instanceof IsLiteralExpression) {
final JSITLiteralExpression unwrappedJSITLiteralExpression = LiteralExpressionPropertyConverter.dmnFromWB((IsLiteralExpression) wb);
final JSITLiteralExpression wrappedJSITLiteralExpression = getWrappedJSITLiteralExpression(unwrappedJSITLiteralExpression, "dmn", "literalExpression");
return wrappedJSITLiteralExpression;
} else if (wb instanceof Context) {
final JSITContext unwrappedJSITContext = ContextPropertyConverter.dmnFromWB((Context) wb, componentWidthsConsumer);
final JSITContext wrappedJSITContext = getWrappedJSITContext(unwrappedJSITContext, "dmn", "context");
return wrappedJSITContext;
} else if (wb instanceof Relation) {
final JSITRelation unwrappedJSITRelation = RelationPropertyConverter.dmnFromWB((Relation) wb, componentWidthsConsumer);
final JSITRelation wrappedJSITRelation = getWrappedJSITRelation(unwrappedJSITRelation, "dmn", "relation");
return wrappedJSITRelation;
} else if (wb instanceof List) {
final JSITList unwrappedJSITList = ListPropertyConverter.dmnFromWB((List) wb, componentWidthsConsumer);
final JSITList wrappedJSITList = getWrappedJSITList(unwrappedJSITList, "dmn", "list");
return wrappedJSITList;
} else if (wb instanceof Invocation) {
final JSITInvocation unwrappedJSITInvocation = InvocationPropertyConverter.dmnFromWB((Invocation) wb, componentWidthsConsumer);
final JSITInvocation wrappedJSITInvocation = getWrappedJSITInvocation(unwrappedJSITInvocation, "dmn", "invocation");
return wrappedJSITInvocation;
} else if (wb instanceof FunctionDefinition) {
final JSITFunctionDefinition unwrappedJSITFunctionDefinition = FunctionDefinitionPropertyConverter.dmnFromWB((FunctionDefinition) wb, componentWidthsConsumer);
final JSITFunctionDefinition wrappedJSITFunctionDefinition = getWrappedJSITFunctionDefinition(unwrappedJSITFunctionDefinition, "dmn", "functionDefinition");
return wrappedJSITFunctionDefinition;
} else if (wb instanceof DecisionTable) {
final JSITDecisionTable unwrappedJSITDecisionTable = DecisionTablePropertyConverter.dmnFromWB((DecisionTable) wb);
final JSITDecisionTable wrappedJSITDecisionTable = getWrappedJSITDecisionTable(unwrappedJSITDecisionTable, "dmn", "decisionTable");
return wrappedJSITDecisionTable;
}
return null;
}
use of org.kie.workbench.common.dmn.api.definition.model.Relation in project kie-wb-common by kiegroup.
the class ExpressionPropertyConverter method wbFromDMN.
public static Expression wbFromDMN(final JSITExpression dmn, final JSITExpression parent, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (JSITLiteralExpression.instanceOf(dmn)) {
final JSITLiteralExpression jsiExpression = Js.uncheckedCast(dmn);
final LiteralExpression e = LiteralExpressionPropertyConverter.wbFromDMN(jsiExpression);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (JSITContext.instanceOf(dmn)) {
final JSITContext jsiExpression = Js.uncheckedCast(dmn);
final Context e = ContextPropertyConverter.wbFromDMN(jsiExpression, parent, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (JSITRelation.instanceOf(dmn)) {
final JSITRelation jsiExpression = Js.uncheckedCast(dmn);
final Relation e = RelationPropertyConverter.wbFromDMN(jsiExpression, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (JSITList.instanceOf(dmn)) {
final JSITList jsiExpression = Js.uncheckedCast(dmn);
final List e = ListPropertyConverter.wbFromDMN(jsiExpression, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (JSITInvocation.instanceOf(dmn)) {
final JSITInvocation jsiExpression = Js.uncheckedCast(dmn);
final Invocation e = InvocationPropertyConverter.wbFromDMN(jsiExpression, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (JSITFunctionDefinition.instanceOf(dmn)) {
final JSITFunctionDefinition jsiExpression = Js.uncheckedCast(dmn);
final FunctionDefinition e = FunctionDefinitionPropertyConverter.wbFromDMN(jsiExpression, hasComponentWidthsConsumer);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
} else if (JSITDecisionTable.instanceOf(dmn)) {
final JSITDecisionTable jsiExpression = Js.uncheckedCast(dmn);
final DecisionTable e = DecisionTablePropertyConverter.wbFromDMN(jsiExpression);
hasComponentWidthsConsumer.accept(dmn.getId(), e);
return e;
}
return null;
}
use of org.kie.workbench.common.dmn.api.definition.model.Relation in project kie-wb-common by kiegroup.
the class RelationPropertyConverter method wbFromDMN.
public static Relation wbFromDMN(final JSITRelation 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 List<InformationItem> convertedColumns = new ArrayList<>();
final List<JSITInformationItem> jsiColumns = dmn.getColumn();
for (int i = 0; i < jsiColumns.size(); i++) {
final JSITInformationItem jsiColumn = Js.uncheckedCast(jsiColumns.get(i));
convertedColumns.add(InformationItemPropertyConverter.wbFromDMN(jsiColumn));
}
final List<org.kie.workbench.common.dmn.api.definition.model.List> convertedRows = new ArrayList<>();
final List<JSITList> jsiRows = dmn.getRow();
for (int i = 0; i < jsiRows.size(); i++) {
final JSITList jsiRow = Js.uncheckedCast(jsiRows.get(i));
convertedRows.add(ListPropertyConverter.wbFromDMN(jsiRow, hasComponentWidthsConsumer));
}
final Relation result = new Relation(id, description, typeRef, convertedColumns, convertedRows);
for (InformationItem column : convertedColumns) {
if (Objects.nonNull(column)) {
column.setParent(result);
}
}
for (org.kie.workbench.common.dmn.api.definition.model.List row : convertedRows) {
if (Objects.nonNull(row)) {
row.setParent(result);
}
}
return result;
}
Aggregations