Search in sources :

Example 16 with DecisionTable

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

the class DeleteInputClauseCommandTest method setup.

@Before
public void setup() {
    this.dtable = new DecisionTable();
    this.inputClause = new InputClause();
    this.dtable.getInput().add(inputClause);
    this.uiModel = new DMNGridData();
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiInputClauseColumn);
    this.uiModel.appendColumn(uiDescriptionColumn);
    this.uiModelMapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
    this.command = spy(new DeleteInputClauseCommand(dtable, uiModel, DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT, uiModelMapper, canvasOperation));
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
    doReturn(2).when(uiDescriptionColumn).getIndex();
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) DecisionTableUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) InputClause(org.kie.workbench.common.dmn.api.definition.v1_1.InputClause) Before(org.junit.Before)

Example 17 with DecisionTable

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

the class SetBuiltinAggregatorCommandTest method makeCommand.

private void makeCommand(final BuiltinAggregator aggregator) {
    this.dtable = new DecisionTable();
    this.dtable.setAggregation(aggregator);
    this.command = new SetBuiltinAggregatorCommand(dtable, NEW_AGGREGATOR, canvasOperation);
}
Also used : DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable)

Example 18 with DecisionTable

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

the class DecisionTablePropertyConverter method dmnFromWB.

public static org.kie.dmn.model.v1_1.DecisionTable dmnFromWB(final DecisionTable wb) {
    org.kie.dmn.model.v1_1.DecisionTable result = new org.kie.dmn.model.v1_1.DecisionTable();
    result.setId(wb.getId().getValue());
    result.setDescription(DescriptionPropertyConverter.dmnFromWB(wb.getDescription()));
    QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
    for (InputClause input : wb.getInput()) {
        result.getInput().add(InputClausePropertyConverter.dmnFromWB(input));
    }
    for (OutputClause input : wb.getOutput()) {
        result.getOutput().add(OutputClausePropertyConverter.dmnFromWB(input));
    }
    for (DecisionRule dr : wb.getRule()) {
        result.getRule().add(DecisionRulePropertyConverter.dmnFromWB(dr));
    }
    if (wb.getHitPolicy() != null) {
        result.setHitPolicy(org.kie.dmn.model.v1_1.HitPolicy.fromValue(wb.getHitPolicy().value()));
    }
    if (wb.getAggregation() != null) {
        result.setAggregation(org.kie.dmn.model.v1_1.BuiltinAggregator.fromValue(wb.getAggregation().value()));
    }
    if (wb.getPreferredOrientation() != null) {
        result.setPreferredOrientation(org.kie.dmn.model.v1_1.DecisionTableOrientation.fromValue(wb.getPreferredOrientation().value()));
    }
    result.setOutputLabel(wb.getOutputLabel());
    return result;
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable) InputClause(org.kie.workbench.common.dmn.api.definition.v1_1.InputClause) DecisionRule(org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)

Example 19 with DecisionTable

use of org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable in project drools by kiegroup.

the class DMNCompilerImpl method resolveTypeRef.

public DMNType resolveTypeRef(DMNModelImpl dmnModel, DMNNode node, NamedElement model, DMNModelInstrumentedBase localElement, QName typeRef) {
    if (typeRef != null) {
        QName nsAndName = getNamespaceAndName(localElement, dmnModel.getImportAliasesForNS(), typeRef);
        DMNType type = dmnModel.getTypeRegistry().resolveType(nsAndName.getNamespaceURI(), nsAndName.getLocalPart());
        if (type == null && DMNModelInstrumentedBase.URI_FEEL.equals(nsAndName.getNamespaceURI())) {
            if (model instanceof Decision && ((Decision) model).getExpression() instanceof DecisionTable) {
                DecisionTable dt = (DecisionTable) ((Decision) model).getExpression();
                if (dt.getOutput().size() > 1) {
                    // implicitly define a type for the decision table result
                    CompositeTypeImpl compType = new CompositeTypeImpl(dmnModel.getNamespace(), model.getName() + "_Type", model.getId(), dt.getHitPolicy().isMultiHit());
                    for (OutputClause oc : dt.getOutput()) {
                        DMNType fieldType = resolveTypeRef(dmnModel, node, model, oc, oc.getTypeRef());
                        compType.addField(oc.getName(), fieldType);
                    }
                    dmnModel.getTypeRegistry().registerType(compType);
                    return compType;
                } else if (dt.getOutput().size() == 1) {
                    return resolveTypeRef(dmnModel, node, model, dt.getOutput().get(0), dt.getOutput().get(0).getTypeRef());
                }
            }
        } else if (type == null) {
            MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, localElement, dmnModel, null, null, Msg.UNKNOWN_TYPE_REF_ON_NODE, typeRef.toString(), localElement.getParentDRDElement().getIdentifierString());
        }
        return type;
    }
    return dmnModel.getTypeRegistry().resolveType(DMNModelInstrumentedBase.URI_FEEL, BuiltInType.UNKNOWN.getName());
}
Also used : OutputClause(org.kie.dmn.model.v1_1.OutputClause) DecisionTable(org.kie.dmn.model.v1_1.DecisionTable) QName(javax.xml.namespace.QName) Decision(org.kie.dmn.model.v1_1.Decision) CompositeTypeImpl(org.kie.dmn.core.impl.CompositeTypeImpl) DMNType(org.kie.dmn.api.core.DMNType)

Aggregations

DecisionTable (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionTable)17 Before (org.junit.Before)9 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)8 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)7 InputClause (org.kie.workbench.common.dmn.api.definition.v1_1.InputClause)6 OutputClause (org.kie.workbench.common.dmn.api.definition.v1_1.OutputClause)5 DecisionTableUIModelMapper (org.kie.workbench.common.dmn.client.editors.expressions.types.dtable.DecisionTableUIModelMapper)5 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)3 Optional (java.util.Optional)2 QName (javax.xml.namespace.QName)2 Test (org.junit.Test)2 DMNType (org.kie.dmn.api.core.DMNType)2 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)2 UnaryTests (org.kie.workbench.common.dmn.api.definition.v1_1.UnaryTests)2 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)2 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Collectors.toList (java.util.stream.Collectors.toList)1