use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DefaultDmnTransform method transformDefinitions.
protected DmnDecisionRequirementsGraph transformDefinitions(Definitions definitions) {
DmnElementTransformHandler<Definitions, DmnDecisionRequirementsGraphImpl> handler = handlerRegistry.getHandler(Definitions.class);
DmnDecisionRequirementsGraphImpl dmnDrg = handler.handleElement(this, definitions);
// validate id of drd
if (dmnDrg.getKey() == null) {
throw LOG.drdIdIsMissing(dmnDrg);
}
Collection<Decision> decisions = definitions.getChildElementsByType(Decision.class);
List<DmnDecision> dmnDecisions = transformDecisions(decisions);
for (DmnDecision dmnDecision : dmnDecisions) {
dmnDrg.addDecision(dmnDecision);
}
notifyTransformListeners(definitions, dmnDrg);
return dmnDrg;
}
use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DefaultDmnTransform method transformDecisions.
protected List<DmnDecision> transformDecisions(Collection<Decision> decisions) {
Map<String, DmnDecisionImpl> dmnDecisions = transformIndividualDecisions(decisions);
buildDecisionRequirements(decisions, dmnDecisions);
List<DmnDecision> dmnDecisionList = new ArrayList<DmnDecision>(dmnDecisions.values());
for (Decision decision : decisions) {
DmnDecision dmnDecision = dmnDecisions.get(decision.getId());
notifyTransformListeners(decision, dmnDecision);
}
ensureNoLoopInDecisions(dmnDecisionList);
return dmnDecisionList;
}
use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DefaultDmnTransform method ensureNoLoopInDecision.
protected void ensureNoLoopInDecision(DmnDecision decision, List<String> parentDecisionList, List<String> visitedDecisions) {
if (visitedDecisions.contains(decision.getKey())) {
return;
}
parentDecisionList.add(decision.getKey());
for (DmnDecision requiredDecision : decision.getRequiredDecisions()) {
if (parentDecisionList.contains(requiredDecision.getKey())) {
throw LOG.requiredDecisionLoopDetected(requiredDecision.getKey());
}
ensureNoLoopInDecision(requiredDecision, new ArrayList<String>(parentDecisionList), visitedDecisions);
}
visitedDecisions.add(decision.getKey());
}
use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DefaultDmnTransform method transformDecisions.
@SuppressWarnings("unchecked")
public <T extends DmnDecision> List<T> transformDecisions() {
try {
Definitions definitions = modelInstance.getDefinitions();
Collection<Decision> decisions = definitions.getChildElementsByType(Decision.class);
return (List<T>) transformDecisions(decisions);
} catch (Exception e) {
throw LOG.errorWhileTransformingDecisions(e);
}
}
use of org.camunda.bpm.dmn.engine.DmnDecision in project camunda-engine-dmn by camunda.
the class DmnTransformListenerTest method shouldVerifyTransformedDmnDecision.
@Test
public void shouldVerifyTransformedDmnDecision() {
InputStream inputStream = IoUtil.fileAsStream(DECISION_TRANSFORM_DMN);
DmnModelInstance modelInstance = Dmn.readModelFromStream(inputStream);
dmnEngine.parseDecisionRequirementsGraph(modelInstance);
DmnDecision dmnDecision = listener.getDmnDecision();
Decision decision = listener.getDecision();
assertThat(dmnDecision.getKey()).isEqualTo(decision.getId()).isEqualTo("decision1");
assertThat(dmnDecision.getName()).isEqualTo(decision.getName()).isEqualTo("camunda");
}
Aggregations