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);
}
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;
}
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);
}
}
}
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;
}
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;
}
}
Aggregations