Search in sources :

Example 26 with InformationItem

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));
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Test(org.junit.Test)

Example 27 with InformationItem

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;
}
Also used : JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) WrapperUtils.getWrappedJSITLiteralExpression(org.kie.workbench.common.dmn.client.marshaller.common.WrapperUtils.getWrappedJSITLiteralExpression) JSITLiteralExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITLiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) JSITExpression(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITExpression) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) JSITContextEntry(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITContextEntry)

Example 28 with InformationItem

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;
}
Also used : JSITFunctionDefinition(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITFunctionDefinition) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) JSITFunctionKind(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITFunctionKind) Kind(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition.Kind) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem)

Example 29 with InformationItem

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;
}
Also used : JSITRelation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRelation) JSITList(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITList) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem)

Example 30 with InformationItem

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;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) JSITList(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITList) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) ArrayList(java.util.ArrayList) JSITInformationItem(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) JSITRelation(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITRelation) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) ArrayList(java.util.ArrayList) List(java.util.List) JSITList(org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITList) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Aggregations

InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)110 Test (org.junit.Test)61 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)24 ContextEntry (org.kie.workbench.common.dmn.api.definition.model.ContextEntry)22 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)22 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)20 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)19 Binding (org.kie.workbench.common.dmn.api.definition.model.Binding)13 Context (org.kie.workbench.common.dmn.api.definition.model.Context)11 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)11 Before (org.junit.Before)10 List (org.kie.workbench.common.dmn.api.definition.model.List)10 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)10 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)10 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)9 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)9 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)9 HasName (org.kie.workbench.common.dmn.api.definition.HasName)7 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)7 JSITInformationItem (org.kie.workbench.common.dmn.webapp.kogito.marshaller.js.model.dmn12.JSITInformationItem)7