use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class RelationUIModelMapperHelperTest method testGetSectionInformationItemColumnIndexEqualToColumnCount.
@Test(expected = IllegalArgumentException.class)
public void testGetSectionInformationItemColumnIndexEqualToColumnCount() {
relation.getColumn().add(new InformationItem());
assertEquals(RelationSection.INFORMATION_ITEM, getInformationItemIndex(relation, relation.getColumn().size() + 1));
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class ContextEntryPropertyConverter method wbFromDMN.
public static ContextEntry wbFromDMN(final JSITContextEntry dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
final InformationItem variable = InformationItemPropertyConverter.wbFromDMN(dmn.getVariable());
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 ContextEntry result = new ContextEntry();
if (Objects.nonNull(variable)) {
variable.setParent(result);
result.setVariable(variable);
}
if (Objects.nonNull(expression)) {
expression.setParent(result);
result.setExpression(expression);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class FunctionDefinitionPropertyConverter method dmnFromWB.
public static JSITFunctionDefinition dmnFromWB(final FunctionDefinition wb, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
if (Objects.isNull(wb)) {
return null;
}
final JSITFunctionDefinition result = new JSITFunctionDefinition();
result.setId(wb.getId().getValue());
// TODO {gcardosi} add because present in original json
if (Objects.isNull(result.getFormalParameter())) {
result.setFormalParameter(new ArrayList<>());
}
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
description.ifPresent(result::setDescription);
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
result.setExpression(ExpressionPropertyConverter.dmnFromWB(wb.getExpression(), componentWidthsConsumer));
final Kind kind = wb.getKind();
switch(kind) {
case FEEL:
result.setKind(Js.uncheckedCast(JSITFunctionKind.FEEL.value()));
break;
case JAVA:
result.setKind(Js.uncheckedCast(JSITFunctionKind.JAVA.value()));
break;
case PMML:
result.setKind(Js.uncheckedCast(JSITFunctionKind.PMML.value()));
break;
default:
result.setKind(Js.uncheckedCast(JSITFunctionKind.FEEL.value()));
break;
}
for (InformationItem ii : wb.getFormalParameter()) {
final JSITInformationItem iiConverted = InformationItemPropertyConverter.dmnFromWB(ii);
result.addFormalParameter(iiConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.
the class RelationPropertyConverter method dmnFromWB.
public static JSITRelation dmnFromWB(final Relation wb, final Consumer<JSITComponentWidths> componentWidthsConsumer) {
final JSITRelation result = new JSITRelation();
result.setId(wb.getId().getValue());
final Optional<String> description = Optional.ofNullable(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
description.ifPresent(result::setDescription);
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (InformationItem iitem : wb.getColumn()) {
final JSITInformationItem iitemConverted = InformationItemPropertyConverter.dmnFromWB(iitem);
result.addColumn(iitemConverted);
}
for (org.kie.workbench.common.dmn.api.definition.model.List list : wb.getRow()) {
final JSITList listConverted = ListPropertyConverter.dmnFromWB(list, componentWidthsConsumer);
result.addRow(listConverted);
}
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.InformationItem 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