Search in sources :

Example 21 with DmnDecision

use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.

the class DmnExampleVerifier method assertExample.

public static void assertExample(DmnEngine engine) {
    InputStream inputStream = IoUtil.fileAsStream(EXAMPLE_DMN);
    DmnDecision decision = engine.parseDecision("decision", inputStream);
    assertExample(engine, decision);
}
Also used : InputStream(java.io.InputStream) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision)

Example 22 with DmnDecision

use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.

the class DefaultDmnTransform method getRequiredDmnDecisions.

protected List<DmnDecision> getRequiredDmnDecisions(Decision decision, Map<String, DmnDecisionImpl> dmnDecisions) {
    List<DmnDecision> requiredDecisionList = new ArrayList<DmnDecision>();
    for (InformationRequirement informationRequirement : decision.getInformationRequirements()) {
        Decision requiredDecision = informationRequirement.getRequiredDecision();
        if (requiredDecision != null) {
            DmnDecision requiredDmnDecision = dmnDecisions.get(requiredDecision.getId());
            requiredDecisionList.add(requiredDmnDecision);
        }
    }
    return requiredDecisionList;
}
Also used : InformationRequirement(org.camunda.bpm.model.dmn.instance.InformationRequirement) ArrayList(java.util.ArrayList) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Decision(org.camunda.bpm.model.dmn.instance.Decision) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision)

Example 23 with DmnDecision

use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.

the class DefaultDmnTransform method buildDecisionRequirements.

protected void buildDecisionRequirements(Collection<Decision> decisions, Map<String, DmnDecisionImpl> dmnDecisions) {
    for (Decision decision : decisions) {
        List<DmnDecision> requiredDmnDecisions = getRequiredDmnDecisions(decision, dmnDecisions);
        DmnDecisionImpl dmnDecision = dmnDecisions.get(decision.getId());
        if (requiredDmnDecisions.size() > 0) {
            dmnDecision.setRequiredDecision(requiredDmnDecisions);
        }
    }
}
Also used : DmnDecisionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Decision(org.camunda.bpm.model.dmn.instance.Decision) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision)

Example 24 with DmnDecision

use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.

the class DefaultDmnTransform method transformDecision.

protected DmnDecisionImpl transformDecision(Decision decision) {
    DmnElementTransformHandler<Decision, DmnDecisionImpl> handler = handlerRegistry.getHandler(Decision.class);
    DmnDecisionImpl dmnDecision = handler.handleElement(this, decision);
    this.decision = dmnDecision;
    // validate decision id
    if (dmnDecision.getKey() == null) {
        throw LOG.decisionIdIsMissing(dmnDecision);
    }
    Expression expression = decision.getExpression();
    if (expression == null) {
        LOG.decisionWithoutExpression(decision);
        return null;
    }
    if (expression instanceof DecisionTable) {
        DmnDecisionTableImpl dmnDecisionTable = transformDecisionTable((DecisionTable) expression);
        dmnDecision.setDecisionLogic(dmnDecisionTable);
    } else if (expression instanceof LiteralExpression) {
        DmnDecisionLiteralExpressionImpl dmnDecisionLiteralExpression = transformDecisionLiteralExpression(decision, (LiteralExpression) expression);
        dmnDecision.setDecisionLogic(dmnDecisionLiteralExpression);
    } else {
        LOG.decisionTypeNotSupported(expression, decision);
        return null;
    }
    return dmnDecision;
}
Also used : DecisionTable(org.camunda.bpm.model.dmn.instance.DecisionTable) DmnDecisionTableImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl) LiteralExpression(org.camunda.bpm.model.dmn.instance.LiteralExpression) InputExpression(org.camunda.bpm.model.dmn.instance.InputExpression) Expression(org.camunda.bpm.model.dmn.instance.Expression) DmnDecisionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl) LiteralExpression(org.camunda.bpm.model.dmn.instance.LiteralExpression) DmnDecisionLiteralExpressionImpl(org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision) Decision(org.camunda.bpm.model.dmn.instance.Decision)

Example 25 with DmnDecision

use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.

the class DmnEngineTestRule method loadDecision.

protected DmnDecision loadDecision(Description description) {
    DecisionResource decisionResource = description.getAnnotation(DecisionResource.class);
    if (decisionResource != null) {
        String resourcePath = decisionResource.resource();
        resourcePath = expandResourcePath(description, resourcePath);
        InputStream inputStream = IoUtil.fileAsStream(resourcePath);
        String decisionKey = decisionResource.decisionKey();
        if (decisionKey == null || decisionKey.isEmpty()) {
            List<DmnDecision> decisions = dmnEngine.parseDecisions(inputStream);
            if (!decisions.isEmpty()) {
                return decisions.get(0);
            } else {
                return null;
            }
        } else {
            return dmnEngine.parseDecision(decisionKey, inputStream);
        }
    } else {
        return null;
    }
}
Also used : InputStream(java.io.InputStream) DmnDecision(org.camunda.bpm.dmn.engine.DmnDecision)

Aggregations

DmnDecision (org.camunda.bpm.dmn.engine.DmnDecision)27 DmnEngineTest (org.camunda.bpm.dmn.engine.test.DmnEngineTest)9 Test (org.junit.Test)9 InputStream (java.io.InputStream)8 Decision (org.camunda.bpm.model.dmn.instance.Decision)7 ArrayList (java.util.ArrayList)5 DmnModelInstance (org.camunda.bpm.model.dmn.DmnModelInstance)5 DmnDecisionImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionImpl)3 DmnDecisionLiteralExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionLiteralExpressionImpl)2 DmnDecisionTableImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionTableImpl)2 Definitions (org.camunda.bpm.model.dmn.instance.Definitions)2 List (java.util.List)1 DmnDecisionRequirementsGraph (org.camunda.bpm.dmn.engine.DmnDecisionRequirementsGraph)1 DmnDecisionResult (org.camunda.bpm.dmn.engine.DmnDecisionResult)1 DmnEngine (org.camunda.bpm.dmn.engine.DmnEngine)1 DmnDecisionLogicEvaluationEvent (org.camunda.bpm.dmn.engine.delegate.DmnDecisionLogicEvaluationEvent)1 DmnDecisionRequirementsGraphImpl (org.camunda.bpm.dmn.engine.impl.DmnDecisionRequirementsGraphImpl)1 DmnExpressionImpl (org.camunda.bpm.dmn.engine.impl.DmnExpressionImpl)1 DmnVariableImpl (org.camunda.bpm.dmn.engine.impl.DmnVariableImpl)1 DmnDecisionLogicEvaluationHandler (org.camunda.bpm.dmn.engine.impl.evaluation.DmnDecisionLogicEvaluationHandler)1