Search in sources :

Example 71 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.

the class ContextEditorDefinition method enrich.

@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<Context> expression) {
    expression.ifPresent(context -> {
        final ContextEntry contextEntry = new ContextEntry();
        final InformationItem informationItem = new InformationItem();
        informationItem.getName().setValue(ContextEntryDefaultValueUtilities.getNewContextEntryName(context));
        contextEntry.setVariable(informationItem);
        context.getContextEntry().add(contextEntry);
        // Add (default) "result" entry
        final ContextEntry resultEntry = new ContextEntry();
        context.getContextEntry().add(resultEntry);
        // Setup parent relationships
        contextEntry.setParent(context);
        informationItem.setParent(contextEntry);
        resultEntry.setParent(context);
    });
}
Also used : InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry)

Example 72 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.

the class ContextGrid method addContextEntry.

void addContextEntry(final int index) {
    getExpression().get().ifPresent(c -> {
        final ContextEntry ce = new ContextEntry();
        final InformationItem informationItem = new InformationItem();
        informationItem.setName(new Name());
        ce.setVariable(informationItem);
        final CommandResult<CanvasViolation> result = sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddContextEntryCommand(c, ce, model, new ExpressionEditorGridRow(), index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING)));
        if (!CommandUtils.isError(result)) {
            selectCell(index, ContextUIModelMapperHelper.NAME_COLUMN_INDEX, false, false);
            startEditingCell(index, ContextUIModelMapperHelper.NAME_COLUMN_INDEX);
        }
    });
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AddContextEntryCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.context.AddContextEntryCommand) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 73 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.

the class BindingPropertyConverter method wbFromDMN.

public static Binding wbFromDMN(final org.kie.dmn.model.api.Binding dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    if (dmn == null) {
        return null;
    }
    final InformationItem convertedParameter = InformationItemPropertyConverter.wbFromDMN(dmn.getParameter());
    final Expression convertedExpression = ExpressionPropertyConverter.wbFromDMN(dmn.getExpression(), hasComponentWidthsConsumer);
    final Binding result = new Binding();
    if (convertedParameter != null) {
        convertedParameter.setParent(result);
    }
    result.setParameter(convertedParameter);
    if (convertedExpression != null) {
        convertedExpression.setParent(result);
    }
    result.setExpression(convertedExpression);
    return result;
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem)

Example 74 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 org.kie.dmn.model.api.Relation dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn);
    final List<org.kie.dmn.model.api.InformationItem> column = dmn.getColumn();
    final List<org.kie.dmn.model.api.List> row = dmn.getRow();
    final List<InformationItem> convertedColumn = column.stream().map(InformationItemPropertyConverter::wbFromDMN).collect(Collectors.toList());
    final List<org.kie.workbench.common.dmn.api.definition.model.List> convertedRow = row.stream().map(r -> ListPropertyConverter.wbFromDMN(r, hasComponentWidthsConsumer)).collect(Collectors.toList());
    final Relation result = new Relation(id, description, typeRef, convertedColumn, convertedRow);
    for (InformationItem c : convertedColumn) {
        if (c != null) {
            c.setParent(result);
        }
    }
    for (org.kie.workbench.common.dmn.api.definition.model.List r : convertedRow) {
        if (r != null) {
            r.setParent(result);
        }
    }
    return result;
}
Also used : Consumer(java.util.function.Consumer) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) HasComponentWidths(org.kie.workbench.common.dmn.api.definition.HasComponentWidths) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) List(java.util.List) ComponentWidths(org.kie.workbench.common.dmn.backend.definition.v1_1.dd.ComponentWidths) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) BiConsumer(java.util.function.BiConsumer) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) Collectors(java.util.stream.Collectors) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) List(java.util.List) Id(org.kie.workbench.common.dmn.api.property.dmn.Id)

Example 75 with InformationItem

use of org.kie.workbench.common.dmn.api.definition.model.InformationItem in project kie-wb-common by kiegroup.

the class InformationItemPropertyConverter method wbFromDMN.

public static InformationItem wbFromDMN(final org.kie.dmn.model.api.InformationItem dmn) {
    if (dmn == null) {
        return null;
    }
    final Id id = new Id(dmn.getId());
    final Description description = DescriptionPropertyConverter.wbFromDMN(dmn.getDescription());
    final Name name = new Name(dmn.getName());
    final QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef(), dmn);
    final InformationItem result = new InformationItem(id, description, name, typeRef);
    return result;
}
Also used : Description(org.kie.workbench.common.dmn.api.property.dmn.Description) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) Id(org.kie.workbench.common.dmn.api.property.dmn.Id) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

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