Search in sources :

Example 21 with Decision

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

the class DMNEditDecisionToolboxActionTest method setup.

@Before
public void setup() throws Exception {
    decisionNode = new NodeImpl<>(E_UUID);
    decision = new Decision();
    final Bounds bounds = new BoundsImpl(new BoundImpl(0d, 0d), new BoundImpl(100d, 150d));
    final View<Decision> nodeContent = new ViewImpl<>(decision, bounds);
    decisionNode.setContent(nodeContent);
    when(canvasHandler.getGraphIndex()).thenReturn(graphIndex);
    when(graphIndex.get(eq(E_UUID))).thenReturn(decisionNode);
    when(sessionManager.getCurrentSession()).thenReturn(session);
    this.tested = new DMNEditDecisionToolboxAction(sessionManager, translationService, editExpressionEvent);
}
Also used : Bounds(org.kie.workbench.common.stunner.core.graph.content.Bounds) BoundImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) BoundsImpl(org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) Before(org.junit.Before)

Example 22 with Decision

use of org.kie.workbench.common.dmn.api.definition.v1_1.Decision 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

Decision (org.kie.workbench.common.dmn.api.definition.v1_1.Decision)16 Edge (org.kie.workbench.common.stunner.core.graph.Edge)7 View (org.kie.workbench.common.stunner.core.graph.content.view.View)7 Before (org.junit.Before)6 InputData (org.kie.workbench.common.dmn.api.definition.v1_1.InputData)6 KnowledgeSource (org.kie.workbench.common.dmn.api.definition.v1_1.KnowledgeSource)6 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)6 List (java.util.List)5 Optional (java.util.Optional)5 Test (org.junit.Test)5 HasName (org.kie.workbench.common.dmn.api.definition.HasName)5 BusinessKnowledgeModel (org.kie.workbench.common.dmn.api.definition.v1_1.BusinessKnowledgeModel)5 Decision (org.kie.dmn.model.v1_1.Decision)4 TextAnnotation (org.kie.workbench.common.dmn.api.definition.v1_1.TextAnnotation)4 DMNShape (org.kie.workbench.common.dmn.backend.definition.v1_1.dd.DMNShape)4 Node (org.kie.workbench.common.stunner.core.graph.Node)4 InputStream (java.io.InputStream)3 Consumer (java.util.function.Consumer)3 DMNMessage (org.kie.dmn.api.core.DMNMessage)3 DMNType (org.kie.dmn.api.core.DMNType)3