org.camunda.bpm.engine.impl.bpmn.helper.BpmnProperties Java Examples

The following examples show how to use org.camunda.bpm.engine.impl.bpmn.helper.BpmnProperties. 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: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
protected void parseMessageEventDefinitionElement(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element messageEventDefinitionElement) {
    if (isServiceTaskLike(messageEventDefinitionElement)) {

        // CAM-436 same behaviour as service task
        ActivityImpl act = parseServiceTaskLike(ActivityTypes.END_EVENT_MESSAGE, messageEventDefinitionElement,
                scope);
        activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_MESSAGE);
        activity.setActivityBehavior(act.getActivityBehavior());
        scope.getActivities().remove(act);
    } else {
        // default to non behavior if no service task
        // properties have been specified
        activity.setActivityBehavior(new IntermediateThrowNoneEventActivityBehavior());
    }
}
 
Example #2
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 6 votes vote down vote up
protected void parseErrorEventDefinition(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element errorEventDefinition) {
    String errorRef = errorEventDefinition.attribute("errorRef");

    if (errorRef == null || "".equals(errorRef)) {
        errorRef = DEFAULT_ERROR_ID;
    }

    org.camunda.bpm.engine.impl.bpmn.parser.Error error = errors.get(errorRef);
    if (error != null && (error.getErrorCode() == null || "".equals(error.getErrorCode()))) {
        error.setErrorCode(DEFAULT_ERROR_CODE);
    }
    if (error != null && (error.getErrorCode() == null || "".equals(error.getErrorCode()))) {
        addError(
                "'errorCode' is mandatory on errors referenced by throwing error event definitions, but the error '"
                        + error.getId() + "' does not define one.",
                errorEventDefinition);
    }
    activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_ERROR);
    if (error != null) {
        activity.setActivityBehavior(new ErrorEndEventActivityBehavior(error.getErrorCode()));
    } else {
        activity.setActivityBehavior(new ErrorEndEventActivityBehavior(errorRef));
    }

}
 
Example #3
Source File: CompensationEventCoverageHandler.java    From camunda-bpm-process-test-coverage with Apache License 2.0 6 votes vote down vote up
private void addCompensationEventCoverage(EventSubscriptionEntity eventSubscription) {
  if (Api.Camunda.supportsCompensationEventCoverage()) {

      final ActivityImpl activity = eventSubscription.getActivity();

      // Get process definition key
      final ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) activity.getProcessDefinition();
      final String processDefinitionKey = processDefinition.getKey();

      // Get compensation boundary event ID
      final ActivityImpl sourceEvent = (ActivityImpl) activity.getProperty(
          BpmnProperties.COMPENSATION_BOUNDARY_EVENT.getName());

      if (sourceEvent != null) {

          final String sourceEventId = sourceEvent.getActivityId();

          // Register covered element
          final CoveredFlowNode compensationBoundaryEvent = new CoveredFlowNode(processDefinitionKey, sourceEventId);
          compensationBoundaryEvent.setEnded(true);
          coverageTestRunState.addCoveredElement(compensationBoundaryEvent);

      }

  }
}
 
Example #4
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
@Test
public void testParseEscalationIntermediateThrowingEvent() {
  ActivityImpl escalationThrowingEvent = findActivityInDeployedProcessDefinition("escalationThrowingEvent");

  assertEquals(ActivityTypes.INTERMEDIATE_EVENT_ESCALATION_THROW, escalationThrowingEvent.getProperties().get(BpmnProperties.TYPE));
  assertEquals(ThrowEscalationEventActivityBehavior.class, escalationThrowingEvent.getActivityBehavior().getClass());
}
 
Example #5
Source File: EventSubscriptionDeclaration.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public static Map<String, EventSubscriptionDeclaration> getDeclarationsForScope(PvmScope scope) {
  if (scope == null) {
    return Collections.emptyMap();
  }

  return scope.getProperties().get(BpmnProperties.EVENT_SUBSCRIPTION_DECLARATIONS);
}
 
Example #6
Source File: DefaultFailedJobParseListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void parseStartEvent(Element startEventElement, ScopeImpl scope, ActivityImpl startEventActivity) {
  String type = startEventActivity.getProperties().get(BpmnProperties.TYPE);
  if (type != null && type.equals(START_TIMER_EVENT) || isAsync(startEventActivity)) {
    this.setFailedJobRetryTimeCycleValue(startEventElement, startEventActivity);
  }
}
 
Example #7
Source File: DefaultFailedJobParseListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void parseBoundaryEvent(Element boundaryEventElement, ScopeImpl scopeElement, ActivityImpl nestedActivity) {
  String type = nestedActivity.getProperties().get(BpmnProperties.TYPE);
  if ((type != null && type.equals(BOUNDARY_TIMER)) || isAsync(nestedActivity)) {
    setFailedJobRetryTimeCycleValue(boundaryEventElement, nestedActivity);
  }
}
 
Example #8
Source File: DefaultFailedJobParseListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void parseIntermediateThrowEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) {
  String type = activity.getProperties().get(BpmnProperties.TYPE);
  if (type != null) {
    this.setFailedJobRetryTimeCycleValue(intermediateEventElement, activity);
  }
}
 
Example #9
Source File: DefaultFailedJobParseListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void parseIntermediateCatchEvent(Element intermediateEventElement, ScopeImpl scope, ActivityImpl activity) {
  String type = activity.getProperties().get(BpmnProperties.TYPE);
  if (type != null && type.equals(INTERMEDIATE_TIMER) || isAsync(activity)) {
    this.setFailedJobRetryTimeCycleValue(intermediateEventElement, activity);
  }
}
 
Example #10
Source File: ErrorDeclarationForProcessInstanceFinder.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(PvmScope scope) {
  List<ErrorEventDefinition> errorEventDefinitions = scope.getProperties().get(BpmnProperties.ERROR_EVENT_DEFINITIONS);
  for (ErrorEventDefinition errorEventDefinition : errorEventDefinitions) {
    PvmActivity activityHandler = scope.getProcessDefinition().findActivity(errorEventDefinition.getHandlerActivityId());
    if ((!isReThrowingErrorEventSubprocess(activityHandler)) && ((exception != null && errorEventDefinition.catchesException(exception))
      || (exception == null && errorEventDefinition.catchesError(errorCode)))) {

      errorHandlerActivity = activityHandler;
      this.errorEventDefinition = errorEventDefinition;
      break;
    }
  }
}
 
Example #11
Source File: SubProcessActivityBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(ActivityExecution execution) throws Exception {
  PvmActivity activity = execution.getActivity();
  PvmActivity initialActivity = activity.getProperties().get(BpmnProperties.INITIAL_ACTIVITY);

  ensureNotNull("No initial activity found for subprocess " + execution.getActivity().getId(), "initialActivity", initialActivity);

  execution.executeActivity(initialActivity);
}
 
Example #12
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
@Test
public void testParseEscalationBoundaryEvent() {
  ActivityImpl escalationBoundaryEvent = findActivityInDeployedProcessDefinition("escalationBoundaryEvent");

  assertEquals(ActivityTypes.BOUNDARY_ESCALATION, escalationBoundaryEvent.getProperties().get(BpmnProperties.TYPE));
  assertEquals(BoundaryEventActivityBehavior.class, escalationBoundaryEvent.getActivityBehavior().getClass());
}
 
Example #13
Source File: TimerDeclarationImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * @return all timers declared in the given scope
 */
public static Map<String, TimerDeclarationImpl> getDeclarationsForScope(PvmScope scope) {
  if (scope == null) {
    return Collections.emptyMap();
  }

  Map<String, TimerDeclarationImpl> result = scope.getProperties().get(BpmnProperties.TIMER_DECLARATIONS);
  if (result != null) {
    return result;
  }
  else {
    return Collections.emptyMap();
  }
}
 
Example #14
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
@Test
public void testParseEscalationEndEvent() {
  ActivityImpl escalationEndEvent = findActivityInDeployedProcessDefinition("escalationEndEvent");

  assertEquals(ActivityTypes.END_EVENT_ESCALATION, escalationEndEvent.getProperties().get(BpmnProperties.TYPE));
  assertEquals(ThrowEscalationEventActivityBehavior.class, escalationEndEvent.getActivityBehavior().getClass());
}
 
Example #15
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
@Test
public void testParseEscalationStartEvent() {
  ActivityImpl escalationStartEvent = findActivityInDeployedProcessDefinition("escalationStartEvent");

  assertEquals(ActivityTypes.START_EVENT_ESCALATION, escalationStartEvent.getProperties().get(BpmnProperties.TYPE));
  assertEquals(EventSubProcessStartEventActivityBehavior.class, escalationStartEvent.getActivityBehavior().getClass());
}
 
Example #16
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
@Test
public void testParseConditionalBoundaryEvent() {
  ActivityImpl conditionalBoundaryEvent = findActivityInDeployedProcessDefinition("conditionalBoundaryEvent");

  assertEquals(ActivityTypes.BOUNDARY_CONDITIONAL, conditionalBoundaryEvent.getProperties().get(BpmnProperties.TYPE));
  assertEquals(BoundaryConditionalEventActivityBehavior.class, conditionalBoundaryEvent.getActivityBehavior().getClass());
}
 
Example #17
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
@Test
public void testParseIntermediateConditionalEvent() {
  ActivityImpl intermediateConditionalEvent = findActivityInDeployedProcessDefinition("intermediateConditionalEvent");

  assertEquals(ActivityTypes.INTERMEDIATE_EVENT_CONDITIONAL, intermediateConditionalEvent.getProperties().get(BpmnProperties.TYPE));
  assertEquals(IntermediateConditionalEventBehavior.class, intermediateConditionalEvent.getActivityBehavior().getClass());
}
 
Example #18
Source File: BpmnParseTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Deployment
@Test
public void testParseEventSubprocessConditionalStartEvent() {
  ActivityImpl conditionalStartEventSubProcess = findActivityInDeployedProcessDefinition("conditionalStartEventSubProcess");

  assertEquals(ActivityTypes.START_EVENT_CONDITIONAL, conditionalStartEventSubProcess.getProperties().get(BpmnProperties.TYPE));
  assertEquals(EventSubProcessStartConditionalEventActivityBehavior.class, conditionalStartEventSubProcess.getActivityBehavior().getClass());

}
 
Example #19
Source File: TimerDeclarationImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * @return all timeout listeners declared in the given scope
 */
public static Map<String, Map<String, TimerDeclarationImpl>> getTimeoutListenerDeclarationsForScope(PvmScope scope) {
  if (scope == null) {
    return Collections.emptyMap();
  }

  Map<String, Map<String, TimerDeclarationImpl>> result = scope.getProperties().get(BpmnProperties.TIMEOUT_LISTENER_DECLARATIONS);
  if (result != null) {
    return result;
  }
  else {
    return Collections.emptyMap();
  }
}
 
Example #20
Source File: DefaultConditionHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected boolean evaluateCondition(ConditionSet conditionSet, ActivityImpl activity) {
  ExecutionEntity temporaryExecution = new ExecutionEntity();
  if (conditionSet.getVariables() != null) {
    temporaryExecution.initializeVariableStore(conditionSet.getVariables());
  }
  temporaryExecution.setProcessDefinition(activity.getProcessDefinition());

  ConditionalEventDefinition conditionalEventDefinition = activity.getProperties().get(BpmnProperties.CONDITIONAL_EVENT_DEFINITION);
  if (conditionalEventDefinition.getVariableName() == null || conditionSet.getVariables().containsKey(conditionalEventDefinition.getVariableName())) {
    return conditionalEventDefinition.tryEvaluate(temporaryExecution);
  } else {
    return false;
  }
}
 
Example #21
Source File: PvmExecutionImpl.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * Delays and stores the given DelayedVariableEvent on the process instance.
 *
 * @param delayedVariableEvent the DelayedVariableEvent which should be store on the process instance
 */
public void delayEvent(DelayedVariableEvent delayedVariableEvent) {

  //if process definition has no conditional events the variable events does not have to be delayed
  Boolean hasConditionalEvents = this.getProcessDefinition().getProperties().get(BpmnProperties.HAS_CONDITIONAL_EVENTS);
  if (hasConditionalEvents == null || !hasConditionalEvents.equals(Boolean.TRUE)) {
    return;
  }

  if (isProcessInstanceExecution()) {
    delayedEvents.add(delayedVariableEvent);
  } else {
    getProcessInstance().delayEvent(delayedVariableEvent);
  }
}
 
Example #22
Source File: CompensationInstanceHandler.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected MigrationInstruction getMigrationInstruction(MigratingInstanceParseContext parseContext, ActivityImpl activity) {
  if (activity.isCompensationHandler()) {
    Properties compensationHandlerProperties = activity.getProperties();
    ActivityImpl eventTrigger = compensationHandlerProperties.get(BpmnProperties.COMPENSATION_BOUNDARY_EVENT);
    if (eventTrigger == null) {
      eventTrigger = compensationHandlerProperties.get(BpmnProperties.INITIAL_ACTIVITY);
    }

    return parseContext.findSingleMigrationInstruction(eventTrigger.getActivityId());
  }
  else {
    return parseContext.findSingleMigrationInstruction(activity.getActivityId());
  }
}
 
Example #23
Source File: SameEventTypeValidator.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void validate(ValidatingMigrationInstruction instruction, ValidatingMigrationInstructions instructions,
    MigrationInstructionValidationReportImpl report) {
  ActivityImpl sourceActivity = instruction.getSourceActivity();
  ActivityImpl targetActivity = instruction.getTargetActivity();

  if (isEvent(sourceActivity) && isEvent(targetActivity)) {
    String sourceType = sourceActivity.getProperties().get(BpmnProperties.TYPE);
    String targetType = targetActivity.getProperties().get(BpmnProperties.TYPE);

    if (!sourceType.equals(targetType)) {
      report.addFailure("Events are not of the same type (" + sourceType + " != " + targetType + ")");
    }
  }
}
 
Example #24
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void parseCancelEventDefinition(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element cancelEventDefinition) {
    if (scope.getProperty(BpmnProperties.TYPE.getName()) == null
            || !scope.getProperty(BpmnProperties.TYPE.getName()).equals("transaction")) {
        addError("end event with cancelEventDefinition only supported inside transaction subprocess",
                cancelEventDefinition);
    } else {
        activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_CANCEL);
        activity.setActivityBehavior(new CancelEndEventActivityBehavior());
        activity.setActivityStartBehavior(ActivityStartBehavior.INTERRUPT_FLOW_SCOPE);
        activity.setProperty(PROPERTYNAME_THROWS_COMPENSATION, true);
        activity.setScope(true);
    }
}
 
Example #25
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void parseCompensateEventDefinitionElement(Element parentElement, ScopeImpl scope,
        Element endEventElement, ActivityImpl activity, Element compensateEventDefinitionElement) {
    activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_COMPENSATION);
    CompensateEventDefinition compensateEventDefinition = parseThrowCompensateEventDefinition(
            compensateEventDefinitionElement, scope);
    activity.setActivityBehavior(new CompensationEventActivityBehavior(compensateEventDefinition));
    activity.setProperty(PROPERTYNAME_THROWS_COMPENSATION, true);
    activity.setScope(true);
}
 
Example #26
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 5 votes vote down vote up
protected void parseEscalationEventDefinition(Element parentElement, ScopeImpl scope, Element endEventElement,
        ActivityImpl activity, Element escalationEventDefinition) {
    activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_ESCALATION);

    Escalation escalation = findEscalationForEscalationEventDefinition(escalationEventDefinition);
    if (escalation != null && escalation.getEscalationCode() == null) {
        addError("escalation end event must have an 'escalationCode'", escalationEventDefinition);
    }
    activity.setActivityBehavior(new ThrowEscalationEventActivityBehavior(escalation));
}
 
Example #27
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
protected void parseEndEvent(Element parentElement, ScopeImpl scope, Element endEventElement) {
    ActivityImpl activity = createActivityOnScope(endEventElement, scope);

    Element errorEventDefinition = endEventElement.element(ERROR_EVENT_DEFINITION);
    Element cancelEventDefinition = endEventElement.element(CANCEL_EVENT_DEFINITION);
    Element terminateEventDefinition = endEventElement.element("terminateEventDefinition");
    Element messageEventDefinitionElement = endEventElement.element(MESSAGE_EVENT_DEFINITION);
    Element signalEventDefinition = endEventElement.element(SIGNAL_EVENT_DEFINITION);
    Element compensateEventDefinitionElement = endEventElement.element(COMPENSATE_EVENT_DEFINITION);
    Element escalationEventDefinition = endEventElement.element(ESCALATION_EVENT_DEFINITION);

    if (errorEventDefinition != null) { // error end event
        parseErrorEventDefinition(parentElement, scope, endEventElement, activity, errorEventDefinition);
    } else if (cancelEventDefinition != null) {
        parseCancelEventDefinition(parentElement, scope, endEventElement, activity, cancelEventDefinition);
    } else if (terminateEventDefinition != null) {
        parseTerminateEventDefinition(parentElement, scope, endEventElement, activity, terminateEventDefinition);
    } else if (messageEventDefinitionElement != null) {
        parseMessageEventDefinitionElement(parentElement, scope, endEventElement, activity,
                messageEventDefinitionElement);
    } else if (signalEventDefinition != null) {
        parseSignalEventDefinition(parentElement, scope, endEventElement, activity, signalEventDefinition);
    } else if (compensateEventDefinitionElement != null) {
        parseCompensateEventDefinitionElement(parentElement, scope, endEventElement, activity,
                compensateEventDefinitionElement);
    } else if (escalationEventDefinition != null) {
        parseEscalationEventDefinition(parentElement, scope, endEventElement, activity, escalationEventDefinition);
    } else { // default: none end event
        activity.getProperties().set(BpmnProperties.TYPE, ActivityTypes.END_EVENT_NONE);
        activity.setActivityBehavior(new NoneEndEventActivityBehavior());
    }

    if (activity != null) {
        parseActivityInputOutput(endEventElement, activity);
    }

    parseAsynchronousContinuationForActivity(endEventElement, activity);

    parseExecutionListenersOnScope(endEventElement, activity);

    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseEndEvent(endEventElement, scope, activity);
    }
}
 
Example #28
Source File: SupportedPassiveEventTriggerActivityValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public boolean isSupportedEventType(ActivityImpl activity) {
  return supportedTypes.contains(activity.getProperties().get(BpmnProperties.TYPE));
}
 
Example #29
Source File: BpmnDeployer.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public void addEventSubscriptions(ProcessDefinitionEntity processDefinition) {
  Map<String, EventSubscriptionDeclaration> eventDefinitions = processDefinition.getProperties().get(BpmnProperties.EVENT_SUBSCRIPTION_DECLARATIONS);
  for (EventSubscriptionDeclaration eventDefinition : eventDefinitions.values()) {
    addEventSubscription(processDefinition, eventDefinition);
  }
}
 
Example #30
Source File: SameEventScopeInstructionValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isUserTaskWithTimeoutListener(ActivityImpl sourceActivity) {
  return ActivityTypes.TASK_USER_TASK.equals(sourceActivity.getProperties().get(BpmnProperties.TYPE)) &&
      sourceActivity.isScope() && sourceActivity.equals(sourceActivity.getEventScope()) &&
      sourceActivity.getProperties().get(BpmnProperties.TIMEOUT_LISTENER_DECLARATIONS) != null &&
      !sourceActivity.getProperties().get(BpmnProperties.TIMEOUT_LISTENER_DECLARATIONS).isEmpty();
}