Java Code Examples for org.camunda.bpm.engine.impl.pvm.process.ScopeImpl#getProperty()

The following examples show how to use org.camunda.bpm.engine.impl.pvm.process.ScopeImpl#getProperty() . 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 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 2
Source File: ExecutionEntity.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void initialize() {
  LOG.initializeExecution(this);

  ScopeImpl scope = getScopeActivity();
  ensureParentInitialized();

  List<VariableDeclaration> variableDeclarations = (List<VariableDeclaration>) scope.getProperty(BpmnParse.PROPERTYNAME_VARIABLE_DECLARATIONS);
  if (variableDeclarations != null) {
    for (VariableDeclaration variableDeclaration : variableDeclarations) {
      variableDeclaration.initialize(this, parent);
    }
  }

  if (isProcessInstanceExecution()) {
    String initiatorVariableName = (String) processDefinition.getProperty(BpmnParse.PROPERTYNAME_INITIATOR_VARIABLE_NAME);
    if (initiatorVariableName != null) {
      String authenticatedUserId = Context.getCommandContext().getAuthenticatedUserId();
      setVariable(initiatorVariableName, authenticatedUserId);
    }
  }

  // create event subscriptions for the current scope
  for (EventSubscriptionDeclaration declaration : EventSubscriptionDeclaration.getDeclarationsForScope(scope).values()) {
    if(!declaration.isStartEvent()) {
      declaration.createSubscriptionForExecution(this);
    }
  }
}
 
Example 3
Source File: GetActivityInstanceCmd.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected ActivityInstanceImpl createActivityInstance(PvmExecutionImpl scopeExecution, ScopeImpl scope,
    String activityInstanceId, String parentActivityInstanceId,
    Map<String, List<Incident>> incidentsByExecution) {
  ActivityInstanceImpl actInst = new ActivityInstanceImpl();

  actInst.setId(activityInstanceId);
  actInst.setParentActivityInstanceId(parentActivityInstanceId);
  actInst.setProcessInstanceId(scopeExecution.getProcessInstanceId());
  actInst.setProcessDefinitionId(scopeExecution.getProcessDefinitionId());
  actInst.setBusinessKey(scopeExecution.getBusinessKey());
  actInst.setActivityId(scope.getId());

  String name = scope.getName();
  if (name == null) {
    name = (String) scope.getProperty("name");
  }
  actInst.setActivityName(name);

  if (scope.getId().equals(scopeExecution.getProcessDefinition().getId())) {
    actInst.setActivityType("processDefinition");
  }
  else {
    actInst.setActivityType((String) scope.getProperty("type"));
  }

  List<String> executionIds = new ArrayList<String>();
  List<String> incidentIds = new ArrayList<>();
  List<Incident> incidents = new ArrayList<>();

  executionIds.add(scopeExecution.getId());

  ActivityImpl executionActivity = scopeExecution.getActivity();

  // do not collect incidents if scopeExecution is a compacted subtree
  // and we currently create the scope activity instance
  if (executionActivity == null || executionActivity == scope) {
    incidentIds.addAll(getIncidentIds(incidentsByExecution, scopeExecution));
    incidents.addAll(getIncidents(incidentsByExecution, scopeExecution));
  }

  for (PvmExecutionImpl childExecution : scopeExecution.getNonEventScopeExecutions()) {
    // add all concurrent children that are not in an activity
    if (childExecution.isConcurrent() && childExecution.getActivityId() == null) {
      executionIds.add(childExecution.getId());
      incidentIds.addAll(getIncidentIds(incidentsByExecution, childExecution));
      incidents.addAll(getIncidents(incidentsByExecution, childExecution));
    }
  }

  actInst.setExecutionIds(executionIds.toArray(new String[executionIds.size()]));
  actInst.setIncidentIds(incidentIds.toArray(new String[incidentIds.size()]));
  actInst.setIncidents(incidents.toArray(new Incident[0]));

  return actInst;
}