org.camunda.bpm.engine.delegate.CaseExecutionListener Java Examples

The following examples show how to use org.camunda.bpm.engine.delegate.CaseExecutionListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StagePlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(stage, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #2
Source File: CaseTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #3
Source File: CaseTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(caseTask, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #4
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #5
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(humanTask, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #6
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #7
Source File: HumanTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(humanTask, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #8
Source File: StagePlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #9
Source File: StagePlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(stage, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #10
Source File: StagePlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #11
Source File: CaseTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(caseTask, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #12
Source File: DecisionTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #13
Source File: DecisionTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(decisionTask, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #14
Source File: DecisionTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #15
Source File: DecisionTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(decisionTask, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #16
Source File: ProcessTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #17
Source File: ProcessTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(processTask, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #18
Source File: ProcessTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #19
Source File: ProcessTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleCustomStandardEventsByDefaultPlanItemControl() {
  // given
  PlanItemControl defaultControl = createElement(processTask, "DefaultControl_1", DefaultControl.class);
  RepetitionRule repetitionRule = createElement(defaultControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  repetitionRule.setCamundaRepeatOnStandardEvent(CaseExecutionListener.DISABLE);

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(1, events.size());
  assertTrue(events.contains(CaseExecutionListener.DISABLE));
}
 
Example #20
Source File: CaseTaskPlanItemHandlerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Test
public void testRepetitionRuleStandardEvents() {
  // given
  ItemControl itemControl = createElement(planItem, "ItemControl_1", ItemControl.class);
  RepetitionRule repetitionRule = createElement(itemControl, "RepititionRule_1", RepetitionRule.class);
  ConditionExpression expression = createElement(repetitionRule, "Expression_1", ConditionExpression.class);
  expression.setText("${true}");

  Cmmn.validateModel(modelInstance);

  // when
  CmmnActivity newActivity = handler.handleElement(planItem, context);

  // then
  List<String> events = newActivity.getProperties().get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);
  assertNotNull(events);
  assertEquals(2, events.size());
  assertTrue(events.contains(CaseExecutionListener.COMPLETE));
  assertTrue(events.contains(CaseExecutionListener.TERMINATE));
}
 
Example #21
Source File: CaseExecutionListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/listener/CaseExecutionListenerTest.testDoesNotImplementCaseExecutionListenerInterfaceByDelegateExpression.cmmn"})
public void testDoesNotImplementCaseExecutionListenerInterfaceByDelegateExpression() {
  // given

  try {
    // when
    caseService
      .withCaseDefinitionByKey("case")
      .setVariable("myListener", new NotCaseExecutionListener())
      .create();
  } catch (Exception e) {
    // then
    String message = e.getMessage();
    assertTextPresent("Delegate expression ${myListener} did not resolve to an implementation of interface "+CaseExecutionListener.class.getName(), message);
  }

}
 
Example #22
Source File: CaseExecutionListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/listener/CaseExecutionListenerTest.testDoesNotImplementCaseExecutionListenerInterfaceByClass.cmmn"})
public void testDoesNotImplementCaseExecutionListenerInterfaceByClass() {
  // given


  try {
    // when
    caseService
      .withCaseDefinitionByKey("case")
      .create();
  } catch (Exception e) {
    // then
    String message = e.getMessage();
    assertTextPresent("ENGINE-05016 Class 'org.camunda.bpm.engine.test.cmmn.listener.NotCaseExecutionListener' doesn't implement '" + CaseExecutionListener.class.getName() + "'", message);
  }

}
 
Example #23
Source File: CaseInstanceListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/listener/CaseInstanceListenerTest.testDoesNotImplementCaseExecutionListenerInterfaceByDelegateExpression.cmmn"})
public void testDoesNotImplementCaseExecutionListenerInterfaceByDelegateExpression() {
  // given

  try {
    // when
    caseService
      .withCaseDefinitionByKey("case")
      .setVariable("myListener", new NotCaseExecutionListener())
      .create();
  } catch (Exception e) {
    // then
    String message = e.getMessage();
    assertTextPresent("Delegate expression ${myListener} did not resolve to an implementation of interface "+CaseExecutionListener.class.getName(), message);
  }

}
 
Example #24
Source File: CaseInstanceListenerTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = {"org/camunda/bpm/engine/test/cmmn/listener/CaseInstanceListenerTest.testDoesNotImplementCaseExecutionListenerInterfaceByClass.cmmn"})
public void testDoesNotImplementCaseExecutionListenerInterfaceByClass() {
  // given


  try {
    // when
    caseService
      .withCaseDefinitionByKey("case")
      .create();
  } catch (Exception e) {
    // then
    String message = e.getMessage();
    assertTextPresent("ENGINE-05016 Class 'org.camunda.bpm.engine.test.cmmn.listener.NotCaseExecutionListener' doesn't implement '"+CaseExecutionListener.class.getName() + "'", message);
  }

}
 
Example #25
Source File: ItemHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void initializeCaseExecutionListeners(CmmnElement element, CmmnActivity activity, CmmnHandlerContext context) {
  PlanItemDefinition definition = getDefinition(element);

  List<CamundaCaseExecutionListener> listeners = queryExtensionElementsByClass(definition, CamundaCaseExecutionListener.class);

  for (CamundaCaseExecutionListener listener : listeners) {
    CaseExecutionListener caseExecutionListener = initializeCaseExecutionListener(element, activity, context, listener);

    String eventName = listener.getCamundaEvent();
    if(eventName != null) {
      activity.addListener(eventName, caseExecutionListener);

    } else {
      for (String event : getStandardEvents(element)) {
        activity.addListener(event, caseExecutionListener);
      }
    }
  }
}
 
Example #26
Source File: DelegateExpressionCaseExecutionListener.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
public void notify(DelegateCaseExecution caseExecution) throws Exception {
  // Note: we can't cache the result of the expression, because the
  // caseExecution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'
  Object delegate = expression.getValue(caseExecution);
  applyFieldDeclaration(fieldDeclarations, delegate);

  if (delegate instanceof CaseExecutionListener) {
    CaseExecutionListener listenerInstance = (CaseExecutionListener) delegate;
    Context
      .getProcessEngineConfiguration()
      .getDelegateInterceptor()
      .handleInvocation(new CaseExecutionListenerInvocation(listenerInstance, caseExecution));
  } else {
    throw new ProcessEngineException("Delegate expression " + expression
            + " did not resolve to an implementation of " + CaseExecutionListener.class);
  }
}
 
Example #27
Source File: DelegateCaseExecutionEvent.java    From camunda-bpm-reactor with Apache License 2.0 5 votes vote down vote up
public static Consumer<DelegateCaseExecutionEvent> consumer(final CaseExecutionListener listener) {
  return event -> {
    try {
      listener.notify(event.getData());
    } catch (Exception e) {
      throw new ProcessEngineException(e);
    }
  };
}
 
Example #28
Source File: CamundaEventBus.java    From camunda-bpm-reactor with Apache License 2.0 5 votes vote down vote up
/**
 * Register listener for the given topic.
 *
 * @param topicBuilder the topic to register on
 * @param listener the listener to register
 */
public void register(final SelectorBuilder topicBuilder, final CaseExecutionListener listener) {
  if (!Context.cmmn.matches(topicBuilder)) {
    throw new IllegalArgumentException("can not register caseExecutionListener to topic: " + topicBuilder.key());
  }
  eventBus.on(topicBuilder.build(), DelegateCaseExecutionEvent.consumer(listener));
  logger.debug("registered {} to '{}'", listener.getClass().getSimpleName(), topicBuilder.key());
}
 
Example #29
Source File: MetricsCmmnTransformListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected void addListeners(CmmnActivity activity) {
  if(activity != null) {
    activity.addBuiltInListener(CaseExecutionListener.START, listener);
    activity.addBuiltInListener(CaseExecutionListener.MANUAL_START, listener);
    activity.addBuiltInListener(CaseExecutionListener.OCCUR, listener);
  }
}
 
Example #30
Source File: ClassDelegateCaseExecutionListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public void notify(DelegateCaseExecution caseExecution) throws Exception {
  CaseExecutionListener listenerInstance = getListenerInstance();

  Context
    .getProcessEngineConfiguration()
    .getDelegateInterceptor()
    .handleInvocation(new CaseExecutionListenerInvocation(listenerInstance, caseExecution));
}