Java Code Examples for org.camunda.bpm.engine.impl.pvm.process.ActivityImpl#getActivityBehavior()

The following examples show how to use org.camunda.bpm.engine.impl.pvm.process.ActivityImpl#getActivityBehavior() . 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: DebugSessionImpl.java    From camunda-bpm-workbench with GNU Affero General Public License v3.0 6 votes vote down vote up
public Script getScript(String processDefinitionId, String activityId) {
  ProcessDefinitionEntity processDefinition =
    (ProcessDefinitionEntity) getProcessEngine().getRepositoryService().getProcessDefinition(processDefinitionId);

  ActivityImpl activity = processDefinition.findActivity(activityId);

  ActivityBehavior activityBehavior = activity.getActivityBehavior();

  if (activityBehavior instanceof ScriptTaskActivityBehavior) {
    Script script = new Script();
    ExecutableScript taskScript = ((ScriptTaskActivityBehavior) activityBehavior).getScript();

    if (!(taskScript instanceof SourceExecutableScript)) {
      throw new DebuggerException("Encountered non-source script");
    }

    SourceExecutableScript sourceScript = (SourceExecutableScript) taskScript;

    script.setScript(sourceScript.getScriptSource());
    script.setScriptingLanguage(sourceScript.getLanguage());

    return script;
  } else {
    throw new DebuggerException("Activity " + activityId + " is no script task");
  }
}
 
Example 2
Source File: DebugSessionImpl.java    From camunda-bpm-workbench with GNU Affero General Public License v3.0 6 votes vote down vote up
public void updateScript(String processDefinitionId, String activityId, Script script) {
  ProcessDefinitionEntity processDefinition =
    (ProcessDefinitionEntity) getProcessEngine().getRepositoryService().getProcessDefinition(processDefinitionId);

  ActivityImpl activity = processDefinition.findActivity(activityId);

  ActivityBehavior activityBehavior = activity.getActivityBehavior();

  if (activityBehavior instanceof ScriptTaskActivityBehavior) {
    SourceExecutableScript taskScript = (SourceExecutableScript) ((ScriptTaskActivityBehavior) activityBehavior).getScript();
    taskScript.setScriptSource(script.getScript());
    // TODO set script language here
  } else {
    throw new DebuggerException("Activity " + activityId + " is no script task");
  }
}
 
Example 3
Source File: ConditionalEventHandler.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, Object localPayload, String businessKey, CommandContext commandContext) {
  VariableEvent variableEvent;
  if (payload == null || payload instanceof VariableEvent) {
    variableEvent = (VariableEvent) payload;
  } else {
    throw new ProcessEngineException("Payload have to be " + VariableEvent.class.getName() + ", to evaluate condition.");
  }

  ActivityImpl activity = eventSubscription.getActivity();
  ActivityBehavior activityBehavior = activity.getActivityBehavior();
  if (activityBehavior instanceof ConditionalEventBehavior) {
    ConditionalEventBehavior conditionalBehavior = (ConditionalEventBehavior) activityBehavior;
    conditionalBehavior.leaveOnSatisfiedCondition(eventSubscription, variableEvent);
  } else {
    throw new ProcessEngineException("Conditional Event has not correct behavior: " + activityBehavior);
  }
}
 
Example 4
Source File: LegacyBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static boolean wasNoScope72(ActivityImpl activity) {
  ActivityBehavior activityBehavior = activity.getActivityBehavior();
  ActivityBehavior parentActivityBehavior = (ActivityBehavior) (activity.getFlowScope() != null ? activity.getFlowScope().getActivityBehavior() : null);
  return (activityBehavior instanceof EventSubProcessActivityBehavior)
      || (activityBehavior instanceof SubProcessActivityBehavior
            && parentActivityBehavior instanceof SequentialMultiInstanceActivityBehavior)
      || (activityBehavior instanceof ReceiveTaskActivityBehavior
            && parentActivityBehavior instanceof MultiInstanceActivityBehavior);
}
 
Example 5
Source File: GlobalOSGiEventBridgeActivator.java    From camunda-bpm-platform-osgi with Apache License 2.0 5 votes vote down vote up
@Override
public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
  addStartEventListener(activity);
  addEndEventListener(activity);
  UserTaskActivityBehavior activityBehavior = (UserTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = activityBehavior.getTaskDefinition();
  addTaskCreateListeners(taskDefinition);
  addTaskAssignmentListeners(taskDefinition);
  addTaskCompleteListeners(taskDefinition);
  addTaskDeleteListeners(taskDefinition);
}
 
Example 6
Source File: LegacyBehavior.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected static boolean isActivityWrappedInMultiInstanceBody(ActivityImpl activity) {
  ScopeImpl flowScope = activity.getFlowScope();

  if (flowScope != activity.getProcessDefinition()) {
    ActivityImpl flowScopeActivity = (ActivityImpl) flowScope;

    return flowScopeActivity.getActivityBehavior() instanceof MultiInstanceActivityBehavior;
  } else {
    return false;
  }
}
 
Example 7
Source File: CdiEventSupportBpmnParseListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
  addStartEventListener(activity);
  addEndEventListener(activity);
  UserTaskActivityBehavior activityBehavior = (UserTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = activityBehavior.getTaskDefinition();
  addTaskCreateListeners(taskDefinition);
  addTaskAssignmentListeners(taskDefinition);
  addTaskCompleteListeners(taskDefinition);
  addTaskUpdateListeners(taskDefinition);
  addTaskDeleteListeners(taskDefinition);
}
 
Example 8
Source File: ProcessApplicationEventParseListener.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void parseUserTask(Element userTaskElement, ScopeImpl scope, ActivityImpl activity) {
  addStartEventListener(activity);
  addEndEventListener(activity);
  UserTaskActivityBehavior activityBehavior = (UserTaskActivityBehavior) activity.getActivityBehavior();
  TaskDefinition taskDefinition = activityBehavior.getTaskDefinition();
  addTaskCreateListeners(taskDefinition);
  addTaskAssignmentListeners(taskDefinition);
  addTaskCompleteListeners(taskDefinition);
  addTaskUpdateListeners(taskDefinition);
  addTaskDeleteListeners(taskDefinition);
}
 
Example 9
Source File: ConditionalEventUpdateEventTriggerValidator.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();

  if (sourceActivity.getActivityBehavior() instanceof ConditionalEventBehavior && !instruction.isUpdateEventTrigger()) {
    report.addFailure(MIGRATION_CONDITIONAL_VALIDATION_ERROR_MSG);
  }
}
 
Example 10
Source File: CannotRemoveMultiInstanceInnerActivityValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected ActivityImpl getInnerActivity(ActivityImpl multiInstanceBody) {
  MultiInstanceActivityBehavior activityBehavior = (MultiInstanceActivityBehavior) multiInstanceBody.getActivityBehavior();
  return activityBehavior.getInnerActivity(multiInstanceBody);
}
 
Example 11
Source File: LegacyBehavior.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected static boolean wasNoScope73(ActivityImpl activity, PvmExecutionImpl scopeExecutionCandidate) {
  ActivityBehavior activityBehavior = activity.getActivityBehavior();
  return (activityBehavior instanceof CompensationEventActivityBehavior)
      || (activityBehavior instanceof CancelEndEventActivityBehavior)
      || isMultiInstanceInCompensation(activity, scopeExecutionCandidate);
}
 
Example 12
Source File: LegacyBehavior.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected static boolean isMultiInstanceInCompensation(ActivityImpl activity, PvmExecutionImpl scopeExecutionCandidate) {
  return
      activity.getActivityBehavior() instanceof MultiInstanceActivityBehavior
      && ((scopeExecutionCandidate != null && findCompensationThrowingAncestorExecution(scopeExecutionCandidate) != null)
            || scopeExecutionCandidate == null);
}
 
Example 13
Source File: SupportedPassiveEventTriggerActivityValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public boolean isPassivelyWaitingEvent(ActivityImpl activity) {
  return activity.getActivityBehavior() instanceof BoundaryEventActivityBehavior
      || activity.getActivityBehavior() instanceof EventSubProcessStartEventActivityBehavior;
}
 
Example 14
Source File: SameEventTypeValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isEvent(ActivityImpl activity) {
  ActivityBehavior behavior = activity.getActivityBehavior();
  return behavior instanceof BoundaryEventActivityBehavior
      || behavior instanceof EventSubProcessStartEventActivityBehavior;
}
 
Example 15
Source File: CannotAddMultiInstanceInnerActivityValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected ActivityImpl getInnerActivity(ActivityImpl multiInstanceBody) {
  MultiInstanceActivityBehavior activityBehavior = (MultiInstanceActivityBehavior) multiInstanceBody.getActivityBehavior();
  return activityBehavior.getInnerActivity(multiInstanceBody);
}
 
Example 16
Source File: CustomBpmnParse.java    From wecube-platform with Apache License 2.0 4 votes vote down vote up
public ActivityImpl parseServiceTaskLike(String elementName, Element serviceTaskElement, ScopeImpl scope) {
    logger.debug("parse service task like element,elementName={}", elementName);

    ActivityImpl activity = createActivityOnScope(serviceTaskElement, scope);

    String type = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, TYPE);
    String className = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_CLASS);
    String expression = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, PROPERTYNAME_EXPRESSION);
    String delegateExpression = serviceTaskElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS,
            PROPERTYNAME_DELEGATE_EXPRESSION);
    String resultVariableName = parseResultVariable(serviceTaskElement);

    parseAsynchronousContinuationForActivity(serviceTaskElement, activity);

    parseServiceTaskLikeAttributes(elementName, serviceTaskElement, scope, activity, type, className, expression,
            delegateExpression, resultVariableName);

    parseExecutionListenersOnScope(serviceTaskElement, activity);

    for (BpmnParseListener parseListener : parseListeners) {
        parseListener.parseServiceTask(serviceTaskElement, scope, activity);
    }

    if (activity.getActivityBehavior() == null) {
        String defaultDelegateExpression = "${taskDispatcher}";
        if (resultVariableName != null) {
            addError(PREFIX_ERROR_MSG_VARIABLE_NAME + elementName + " elements using 'delegateExpression'",
                    serviceTaskElement);
        }

        activity.setActivityBehavior(new ServiceTaskDelegateExpressionActivityBehavior(
                expressionManager.createExpression(defaultDelegateExpression),
                parseFieldDeclarations(serviceTaskElement)));
    }

    // activity behavior could be set by a listener (e.g. connector); thus,
    // check is after listener invocation
    if (activity.getActivityBehavior() == null) {
        addError("One of the attributes 'class', 'delegateExpression', 'type', or 'expression' is mandatory on "
                + elementName + ".", serviceTaskElement);
    }

    return activity;
}
 
Example 17
Source File: GatewayMappingValidator.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isWaitStateGateway(ActivityImpl activity) {
  ActivityBehavior behavior = activity.getActivityBehavior();
  return behavior instanceof ParallelGatewayActivityBehavior
      || behavior instanceof InclusiveGatewayActivityBehavior;
}
 
Example 18
Source File: DefaultFailedJobParseListener.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected boolean isMultiInstance(ActivityImpl activity) {
  // #isMultiInstance() don't work since the property is not set yet
  ActivityImpl parent = activity.getParentFlowScopeActivity();
  return parent != null && parent.getActivityBehavior() instanceof MultiInstanceActivityBehavior;
}
 
Example 19
Source File: RegisterAllBpmnParseListener.java    From camunda-bpm-reactor with Apache License 2.0 4 votes vote down vote up
/**
 * @param activity the taskActivity
 * @return taskDefinition for activity
 */
static TaskDefinition taskDefinition(final ActivityImpl activity) {
  final UserTaskActivityBehavior activityBehavior = (UserTaskActivityBehavior) activity.getActivityBehavior();
  return activityBehavior.getTaskDefinition();
}
 
Example 20
Source File: PublishDelegateParseListener.java    From camunda-bpm-platform with Apache License 2.0 2 votes vote down vote up
/**
 * Retrieves task definition.
 *
 * @param activity the taskActivity
 * @return taskDefinition for activity
 */
private TaskDefinition taskDefinition(final ActivityImpl activity) {
  final UserTaskActivityBehavior activityBehavior = (UserTaskActivityBehavior) activity.getActivityBehavior();
  return activityBehavior.getTaskDefinition();
}