Search in sources :

Example 66 with InformationItem

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

the class DecisionTableEditorDefinitionEnricher method getOutputClauseName.

private Optional<String> getOutputClauseName(final HasVariable hasVariable) {
    final IsInformationItem variable = hasVariable.getVariable();
    if (variable instanceof InformationItem) {
        return Optional.ofNullable((variable).getName().getValue());
    }
    final DMNModelInstrumentedBase base = hasVariable.asDMNModelInstrumentedBase().getParent();
    final DMNModelInstrumentedBase parent = base.getParent();
    if (parent instanceof HasName) {
        return Optional.ofNullable(((HasName) parent).getName().getValue());
    }
    if (parent instanceof HasVariable) {
        return getOutputClauseName((HasVariable) parent);
    }
    return Optional.empty();
}
Also used : HasName(org.kie.workbench.common.dmn.api.definition.HasName) HasVariable(org.kie.workbench.common.dmn.api.definition.HasVariable) DMNModelInstrumentedBase(org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase) IsInformationItem(org.kie.workbench.common.dmn.api.definition.model.IsInformationItem) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) IsInformationItem(org.kie.workbench.common.dmn.api.definition.model.IsInformationItem)

Example 67 with InformationItem

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

the class ContextUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    dmnModel.get().ifPresent(context -> {
        final boolean isLastRow = isLastRow(rowIndex);
        final ContextUIModelMapperHelper.ContextSection section = ContextUIModelMapperHelper.getSection(columnIndex);
        switch(section) {
            case ROW_INDEX:
                if (!isLastRow) {
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
                } else {
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new BaseGridCellValue<>((Integer) null)));
                }
                uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
                break;
            case NAME:
                final InformationItem variable = context.getContextEntry().get(rowIndex).getVariable();
                uiModel.get().setCell(rowIndex, columnIndex, () -> new InformationItemCell(() -> InformationItemCell.HasNameAndDataTypeCell.wrap(variable, DEFAULT_ROW_CAPTION), listSelector));
                break;
            case EXPRESSION:
                final ContextEntry ce = context.getContextEntry().get(rowIndex);
                final Optional<Expression> expression = Optional.ofNullable(ce.getExpression());
                final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get();
                final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
                expressionEditorDefinition.ifPresent(ed -> {
                    final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ed.getEditor(new GridCellTuple(rowIndex, columnIndex, gridWidget), Optional.empty(), ce, Optional.ofNullable(ce.getVariable()), isOnlyVisualChangeAllowed, nesting + 1);
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new ExpressionCellValue(editor), listSelector));
                });
        }
    });
}
Also used : ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Example 68 with InformationItem

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

the class InvocationEditorDefinition method enrich.

@Override
public void enrich(final Optional<String> nodeUUID, final HasExpression hasExpression, final Optional<Invocation> expression) {
    expression.ifPresent(invocation -> {
        final LiteralExpression literalExpression = new LiteralExpression();
        invocation.setExpression(literalExpression);
        final InformationItem parameter = new InformationItem();
        parameter.getName().setValue(InvocationDefaultValueUtilities.getNewParameterName(invocation));
        final Binding binding = new Binding();
        binding.setParameter(parameter);
        invocation.getBinding().add(binding);
        // Setup parent relationships
        literalExpression.setParent(invocation);
        binding.setParent(invocation);
        parameter.setParent(binding);
    });
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem)

Example 69 with InformationItem

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

the class InvocationGrid method addParameterBinding.

void addParameterBinding(final int index) {
    getExpression().get().ifPresent(invocation -> {
        final Binding binding = new Binding();
        final InformationItem parameter = new InformationItem();
        parameter.setName(new Name());
        binding.setParameter(parameter);
        final CommandResult<CanvasViolation> result = sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddParameterBindingCommand(invocation, binding, model, new ExpressionEditorGridRow(), index, uiModelMapper, () -> resize(BaseExpressionGrid.RESIZE_EXISTING)));
        if (!CommandUtils.isError(result)) {
            selectCell(index, InvocationUIModelMapper.BINDING_PARAMETER_COLUMN_INDEX, false, false);
            startEditingCell(index, InvocationUIModelMapper.BINDING_PARAMETER_COLUMN_INDEX);
        }
    });
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AddParameterBindingCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.invocation.AddParameterBindingCommand) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ExpressionEditorGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.ExpressionEditorGridRow) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name)

Example 70 with InformationItem

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

the class FunctionGrid method addParameter.

@Override
public void addParameter(final Command onSuccess) {
    getExpression().get().ifPresent(e -> {
        final InformationItem parameter = new InformationItem();
        parameter.setName(new Name());
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddParameterCommand(e, parameter, () -> {
            gridLayer.batch();
            onSuccess.execute();
        }));
    });
}
Also used : AddParameterCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.function.AddParameterCommand) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) HasName(org.kie.workbench.common.dmn.api.definition.HasName) 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