Java Code Examples for org.activiti.engine.impl.persistence.entity.ExecutionEntity#setVariables()

The following examples show how to use org.activiti.engine.impl.persistence.entity.ExecutionEntity#setVariables() . 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: TriggerCmd.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
protected Object execute(CommandContext commandContext, ExecutionEntity execution) {
  if (Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, execution.getProcessDefinitionId())) {
    Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler();
    activiti5CompatibilityHandler.trigger(executionId, processVariables);
    return null;
  }

  if (processVariables != null) {
    execution.setVariables(processVariables);
  }

  if (transientVariables != null) {
    execution.setTransientVariables(transientVariables);
  }

  Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(
      ActivitiEventBuilder.createSignalEvent(ActivitiEventType.ACTIVITY_SIGNALED, execution.getCurrentActivityId(), null,
          null, execution.getId(), execution.getProcessInstanceId(), execution.getProcessDefinitionId()));

  Context.getAgenda().planTriggerExecutionOperation(execution);
  return null;
}
 
Example 2
Source File: SignalEventHandler.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {
    if (eventSubscription.getExecutionId() != null) {
        super.handleEvent(eventSubscription, payload, commandContext);
    } else if (eventSubscription.getProcessDefinitionId() != null) {
        // Start event
        String processDefinitionId = eventSubscription.getProcessDefinitionId();
        DeploymentManager deploymentCache = Context
                .getProcessEngineConfiguration()
                .getDeploymentManager();

        ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
        if (processDefinition == null) {
            throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
        }

        ActivityImpl startActivity = processDefinition.findActivity(eventSubscription.getActivityId());
        if (startActivity == null) {
            throw new ActivitiException("Could no handle signal: no start activity found with id " + eventSubscription.getActivityId());
        }
        ExecutionEntity processInstance = processDefinition.createProcessInstance(null, startActivity);
        if (processInstance == null) {
            throw new ActivitiException("Could not handle signal: no process instance started");
        }

        if (payload != null) {
            if (payload instanceof Map) {
                Map<String, Object> variables = (Map<String, Object>) payload;
                processInstance.setVariables(variables);
            }
        }

        processInstance.start();
    } else {
        throw new ActivitiException("Invalid signal handling: no execution nor process definition set");
    }
}
 
Example 3
Source File: StartProcessInstanceCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
protected void initializeVariables(ExecutionEntity processInstance) {
    if (variables != null) {
        processInstance.setVariables(variables);
    }
    if (transientVariables != null) {
        processInstance.setTransientVariables(transientVariables);
    }
}
 
Example 4
Source File: SignalCmd.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
protected Object execute(CommandContext commandContext, ExecutionEntity execution) {
    if (processVariables != null) {
        execution.setVariables(processVariables);
    }
    if (transientVariables != null) {
        execution.setTransientVariables(transientVariables);
    }
    execution.signal(signalName, signalData);
    return null;
}
 
Example 5
Source File: CallActivityBehavior.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
protected void initializeVariables(ExecutionEntity subProcessInstance, Map<String,Object> variables) {
  subProcessInstance.setVariables(variables);
}
 
Example 6
Source File: StartProcessInstanceByMessageCmd.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessInstance execute(CommandContext commandContext) {

    if (messageName == null) {
        throw new ActivitiIllegalArgumentException("Cannot start process instance by message: message name is null");
    }

    MessageEventSubscriptionEntity messageEventSubscription = commandContext.getEventSubscriptionEntityManager()
            .findMessageStartEventSubscriptionByName(messageName, tenantId);

    if (messageEventSubscription == null) {
        throw new ActivitiObjectNotFoundException("Cannot start process instance by message: no subscription to message with name '" + messageName + "' found.", MessageEventSubscriptionEntity.class);
    }

    String processDefinitionId = messageEventSubscription.getConfiguration();
    if (processDefinitionId == null) {
        throw new ActivitiException("Cannot start process instance by message: subscription to message with name '" + messageName + "' is not a message start event.");
    }

    DeploymentManager deploymentManager = commandContext
            .getProcessEngineConfiguration()
            .getDeploymentManager();

    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deploymentManager.findDeployedProcessDefinitionById(processDefinitionId);
    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("No process definition found for id '" + processDefinitionId + "'", ProcessDefinition.class);
    }

    // Do not start process a process instance if the process definition is suspended
    if (deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) {
        throw new ActivitiException("Cannot start process instance. Process definition "
                + processDefinition.getName() + " (id = " + processDefinition.getId() + ") is suspended");
    }

    ActivityImpl startActivity = processDefinition.findActivity(messageEventSubscription.getActivityId());
    ExecutionEntity processInstance = processDefinition.createProcessInstance(businessKey, startActivity);

    if (processVariables != null) {
        processInstance.setVariables(processVariables);
    }
    if (transientVariables != null) {
        processInstance.setTransientVariables(transientVariables);
    }

    processInstance.start();

    return processInstance;
}