use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class CmmnExecution method isSentryPartsSatisfied.
protected boolean isSentryPartsSatisfied(String sentryId, List<? extends CmmnSentryPart> sentryParts) {
// if part will be evaluated in the end
CmmnSentryPart ifPart = null;
if (sentryParts != null && !sentryParts.isEmpty()) {
for (CmmnSentryPart sentryPart : sentryParts) {
if (PLAN_ITEM_ON_PART.equals(sentryPart.getType())) {
if (!sentryPart.isSatisfied()) {
return false;
}
} else if (VARIABLE_ON_PART.equals(sentryPart.getType())) {
if (!sentryPart.isSatisfied()) {
return false;
}
} else {
/* IF_PART.equals(sentryPart.getType) == true */
ifPart = sentryPart;
// once the ifPart has been satisfied the whole sentry is satisfied
if (ifPart.isSatisfied()) {
return true;
}
}
}
}
if (ifPart != null) {
CmmnExecution execution = ifPart.getCaseExecution();
ensureNotNull("Case execution of sentry '" + ifPart.getSentryId() + "': is null", execution);
CmmnActivity activity = ifPart.getCaseExecution().getActivity();
ensureNotNull("Case execution '" + id + "': has no current activity", "activity", activity);
CmmnSentryDeclaration sentryDeclaration = activity.getSentry(sentryId);
ensureNotNull("Case execution '" + id + "': has no declaration for sentry '" + sentryId + "'", "sentryDeclaration", sentryDeclaration);
CmmnIfPartDeclaration ifPartDeclaration = sentryDeclaration.getIfPart();
ensureNotNull("Sentry declaration '" + sentryId + "' has no definied ifPart, but there should be one defined for case execution '" + id + "'.", "ifPartDeclaration", ifPartDeclaration);
Expression condition = ifPartDeclaration.getCondition();
ensureNotNull("A condition was expected for ifPart of Sentry declaration '" + sentryId + "' for case execution '" + id + "'.", "condition", condition);
Object result = condition.getValue(this);
ensureInstanceOf("condition expression returns non-Boolean", "result", result, Boolean.class);
Boolean booleanResult = (Boolean) result;
ifPart.setSatisfied(booleanResult);
return booleanResult;
}
// ifPart then the whole sentry is satisfied.
return true;
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class CmmnExecution method checkAndFireEntryCriteria.
protected void checkAndFireEntryCriteria(List<String> satisfiedSentries) {
if (isAvailable() || isNew()) {
// do that only, when this child case execution
// is available
CmmnActivity activity = getActivity();
ensureNotNull(PvmException.class, "Case execution '" + getId() + "': has no current activity.", "activity", activity);
List<CmmnSentryDeclaration> criteria = activity.getEntryCriteria();
for (CmmnSentryDeclaration sentryDeclaration : criteria) {
if (sentryDeclaration != null && satisfiedSentries.contains(sentryDeclaration.getId())) {
if (isAvailable()) {
fireEntryCriteria();
} else {
entryCriterionSatisfied = true;
}
break;
}
}
}
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class PlanItemDefinitionActivityBehavior method isAtLeastOneEntryCriterionSatisfied.
// sentries //////////////////////////////////////////////////////////////////////////////
protected boolean isAtLeastOneEntryCriterionSatisfied(CmmnActivityExecution execution) {
if (execution.isEntryCriterionSatisfied()) {
return true;
}
CmmnActivity activity = getActivity(execution);
List<CmmnSentryDeclaration> criteria = activity.getEntryCriteria();
return !(criteria != null && !criteria.isEmpty());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method testSentryWithOnPart.
@Test
public void testSentryWithOnPart() {
// given
CmmnActivity casePlanModelActivity = new CasePlanModelHandler().handleElement(casePlanModel, context);
context.setParent(casePlanModelActivity);
CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
CmmnActivity source = taskItemHandler.handleElement(planItem, context);
// when
sentryHandler.initializeOnParts(sentry, context);
// then
assertNotNull(sentryDeclaration);
List<CmmnOnPartDeclaration> onParts = sentryDeclaration.getOnParts();
assertNotNull(onParts);
assertFalse(onParts.isEmpty());
assertEquals(1, onParts.size());
List<CmmnOnPartDeclaration> onPartsAssociatedWithSource = sentryDeclaration.getOnParts(source.getId());
assertNotNull(onPartsAssociatedWithSource);
assertFalse(onPartsAssociatedWithSource.isEmpty());
assertEquals(1, onParts.size());
CmmnOnPartDeclaration onPartDeclaration = onPartsAssociatedWithSource.get(0);
assertNotNull(onPartDeclaration);
// source
assertEquals(source, onPartDeclaration.getSource());
assertEquals(onPart.getSource().getId(), onPartDeclaration.getSource().getId());
// standardEvent
assertEquals(onPart.getStandardEvent().name(), onPartDeclaration.getStandardEvent());
// sentry
assertNull(onPartDeclaration.getSentry());
assertNull(sentryDeclaration.getIfPart());
}
use of org.camunda.bpm.engine.impl.cmmn.model.CmmnSentryDeclaration in project camunda-bpm-platform by camunda.
the class SentryHandlerTest method testSentryWithIfPart.
@Test
public void testSentryWithIfPart() {
// given
IfPart ifPart = createElement(sentry, "abc", IfPart.class);
ConditionExpression conditionExpression = createElement(ifPart, "def", ConditionExpression.class);
Body body = createElement(conditionExpression, null, Body.class);
String expression = "${test}";
body.setTextContent(expression);
// when
CmmnSentryDeclaration sentryDeclaration = sentryHandler.handleElement(sentry, context);
// then
assertNotNull(sentryDeclaration);
CmmnIfPartDeclaration ifPartDeclaration = sentryDeclaration.getIfPart();
assertNotNull(ifPartDeclaration);
Expression condition = ifPartDeclaration.getCondition();
assertNotNull(condition);
assertEquals(expression, condition.getExpressionText());
assertTrue(sentryDeclaration.getOnParts().isEmpty());
}
Aggregations