org.activiti.engine.impl.pvm.PvmActivity Java Examples

The following examples show how to use org.activiti.engine.impl.pvm.PvmActivity. 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: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String getFormKey(PvmActivity act)
{
    if(act instanceof ActivityImpl) 
    {
        ActivityImpl actImpl = (ActivityImpl) act;
        if (actImpl.getActivityBehavior() instanceof UserTaskActivityBehavior)        
        {
            UserTaskActivityBehavior uta = (UserTaskActivityBehavior) actImpl.getActivityBehavior();
            TaskFormHandler handler = uta.getTaskDefinition().getTaskFormHandler();
            if(handler != null && handler instanceof DefaultTaskFormHandler)
            {
                // We cast to DefaultTaskFormHandler since we do not configure our own
                return ((DefaultTaskFormHandler)handler).getFormKey().getExpressionText();
            }
            
        }
    }
    return null;
}
 
Example #2
Source File: ParallelGateway.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    PvmActivity activity = activityExecution.getActivity();

    List<PvmTransition> outgoingTransitions = activityExecution.getActivity().getOutgoingTransitions();

    execution.inactivate();

    List<ActivityExecution> joinedExecutions = activityExecution.findInactiveConcurrentExecutions(activity);

    int nbrOfExecutionsToJoin = activityExecution.getActivity().getIncomingTransitions().size();
    int nbrOfExecutionsJoined = joinedExecutions.size();

    if (nbrOfExecutionsJoined == nbrOfExecutionsToJoin) {
        LOGGER.debug("parallel gateway '{}' activates: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
        activityExecution.takeAll(outgoingTransitions, joinedExecutions);

    } else if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("parallel gateway '{}' does not activate: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
    }
}
 
Example #3
Source File: BpmTaskServiceImpl.java    From hsweb-framework with Apache License 2.0 6 votes vote down vote up
protected void findActivity(
        PvmActivity activity,
        Function<PvmActivity, List<PvmActivity>> function,
        Predicate<PvmActivity> predicate,
        Consumer<PvmActivity> consumer) {

    List<PvmActivity> activities = function.apply(activity);
    for (PvmActivity pvmActivity : activities) {
        consumer.accept(pvmActivity);
        if (predicate.test(pvmActivity)) {
            return;
        }
        //往下查找
        findActivity(pvmActivity, function, predicate, consumer);
    }
}
 
Example #4
Source File: FindPreviousActivitiesCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
public List<PvmActivity> getPreviousActivities(PvmActivity pvmActivity) {
    List<PvmActivity> pvmActivities = new ArrayList<PvmActivity>();

    for (PvmTransition pvmTransition : pvmActivity.getIncomingTransitions()) {
        PvmActivity targetActivity = pvmTransition.getDestination();

        if ("userTask".equals(targetActivity.getProperty("type"))) {
            pvmActivities.add(targetActivity);
        } else {
            pvmActivities
                    .addAll(this.getPreviousActivities(targetActivity));
        }
    }

    return pvmActivities;
}
 
Example #5
Source File: AutoCompleteFirstTaskEventListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 获得第一个节点.
 */
public PvmActivity findFirstActivity(String processDefinitionId) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getProcessDefinitionCache()
            .get(processDefinitionId);

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.debug("first activity is not userTask, just skip");

        return null;
    }

    return targetActivity;
}
 
Example #6
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getFormKey(PvmActivity act, ReadOnlyProcessDefinition processDefinition)
{
    if(act instanceof ActivityImpl) 
    {
        ActivityImpl actImpl = (ActivityImpl) act;
        if (actImpl.getActivityBehavior() instanceof UserTaskActivityBehavior)        
        {
        	UserTaskActivityBehavior uta = (UserTaskActivityBehavior) actImpl.getActivityBehavior();
            return getFormKey(uta.getTaskDefinition());
        }
        else if(actImpl.getActivityBehavior() instanceof MultiInstanceActivityBehavior) 
        {
        	// Get the task-definition from the process-definition
        	if(processDefinition instanceof ProcessDefinitionEntity)
        	{
        		// Task definition id is the same the the activity id
        		TaskDefinition taskDef = ((ProcessDefinitionEntity) processDefinition).getTaskDefinitions().get(act.getId());
        		if(taskDef != null)
        		{
        			return getFormKey(taskDef);
        		}
        	}
        }
    }
    return null;
}
 
Example #7
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @param activity PvmActivity
 * @param key String
 * @param forceIsTaskNode boolean
 * @return WorkflowNode
 */
private WorkflowNode getNode(PvmActivity activity, String key, boolean forceIsTaskNode)
{
    String name = activity.getId();
     String defaultTitle = (String) activity.getProperty(ActivitiConstants.NODE_NAME);
     String defaultDescription = (String) activity.getProperty(ActivitiConstants.NODE_DESCRIPTION);
     String type = (String) activity.getProperty(ActivitiConstants.NODE_TYPE);
     boolean isTaskNode = forceIsTaskNode || ActivitiConstants.USER_TASK_NODE_TYPE.equals(type);
     
     if(defaultTitle == null)
     {
     	defaultTitle = name;
     }
     if(defaultDescription == null)
     {
     	defaultDescription = name;
     }
    WorkflowTransition transition = getDefaultTransition(key, name);
    return factory.createNode(name, key, defaultTitle, defaultDescription, type, isTaskNode, transition);
}
 
Example #8
Source File: ErrorPropagation.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
private static String findLocalErrorEventHandler(ActivityExecution execution, String errorCode) {
    PvmScope scope = execution.getActivity();
    while (scope != null) {

        @SuppressWarnings("unchecked")
        List<ErrorEventDefinition> definitions = (List<ErrorEventDefinition>) scope.getProperty(BpmnParse.PROPERTYNAME_ERROR_EVENT_DEFINITIONS);
        if (definitions != null) {
            // definitions are sorted by precedence, ie. event subprocesses first.
            for (ErrorEventDefinition errorEventDefinition : definitions) {
                if (errorEventDefinition.catches(errorCode)) {
                    return scope.findActivity(errorEventDefinition.getHandlerActivityId()).getId();
                }
            }
        }

        // search for error handlers in parent scopes
        if (scope instanceof PvmActivity) {
            scope = ((PvmActivity) scope).getParent();
        } else {
            scope = null;
        }
    }
    return null;
}
 
Example #9
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public WorkflowPath convert(Execution execution, ProcessInstance instance)
{
    if(execution == null)
        return null;
    
    boolean isActive = !execution.isEnded();
    
    // Convert workflow and collect variables
    Map<String, Object> workflowInstanceVariables = new HashMap<String, Object>();
    WorkflowInstance wfInstance = convertAndSetVariables(instance, workflowInstanceVariables);
    
    WorkflowNode node = null;
    // Get active node on execution
    List<String> nodeIds = runtimeService.getActiveActivityIds(execution.getId());

    if (nodeIds != null && nodeIds.size() >= 1)
    {
        ReadOnlyProcessDefinition procDef = activitiUtil.getDeployedProcessDefinition(instance.getProcessDefinitionId());
        PvmActivity activity = procDef.findActivity(nodeIds.get(0));
        node = convert(activity);
    }

    return factory.createPath(execution.getId(), wfInstance, node, isActive);
}
 
Example #10
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Get the taskDefinition key based on the Activiti task definition id,
 * @param taskDefinitionKey String
 * @param processDefinitionId String
 * @return WorkflowTaskDefinition
 */
public WorkflowTaskDefinition getTaskDefinition(String taskDefinitionKey, String processDefinitionId)
{
	 ProcessDefinitionEntity procDef = (ProcessDefinitionEntity) activitiUtil.getDeployedProcessDefinition(processDefinitionId);
	 Collection<PvmActivity> userTasks = findUserTasks(procDef.getInitial());
	 
	 TaskDefinition taskDefinition = null;
	 for(PvmActivity activity : userTasks)
	 {
		 taskDefinition = procDef.getTaskDefinitions().get(activity.getId());
		 if(taskDefinitionKey.equals(taskDefinition.getKey()))
		 {
			 String formKey = getFormKey(taskDefinition);
			 WorkflowNode node = convert(activity);
			 return factory.createTaskDefinition(formKey, node, formKey, false);
		 }
	 }
	 
	 return null;
}
 
Example #11
Source File: ParallelGatewayActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    // Join
    PvmActivity activity = activityExecution.getActivity();
    List<PvmTransition> outgoingTransitions = activityExecution.getActivity().getOutgoingTransitions();
    execution.inactivate();
    lockConcurrentRoot(activityExecution);

    List<ActivityExecution> joinedExecutions = activityExecution.findInactiveConcurrentExecutions(activity);
    int nbrOfExecutionsToJoin = activityExecution.getActivity().getIncomingTransitions().size();
    int nbrOfExecutionsJoined = joinedExecutions.size();
    Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) execution);
    if (nbrOfExecutionsJoined == nbrOfExecutionsToJoin) {

        // Fork
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("parallel gateway '{}' activates: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
        }
        activityExecution.takeAll(outgoingTransitions, joinedExecutions);

    } else if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("parallel gateway '{}' does not activate: {} of {} joined", activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin);
    }
}
 
Example #12
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Convert a {@link ProcessDefinition} into a {@link WorkflowDefinition}.
 * @param definition ProcessDefinition
 * @return WorkflowDefinition
 */
public WorkflowDefinition convert(ProcessDefinition definition)
{
    if(definition==null)
        return null;
    
    String defId = definition.getId();
    String defName = definition.getKey();
    int version = definition.getVersion();
    String defaultTitle = definition.getName();
    
    String startTaskName = null;
    StartFormData startFormData = getStartFormData(defId, defName);
    if(startFormData != null) 
    {
        startTaskName = startFormData.getFormKey();
    }
    
    ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(defId);
    PvmActivity startEvent = def.getInitial();
    WorkflowTaskDefinition startTask = getTaskDefinition(startEvent, startTaskName, definition.getKey(), true);
    
    return factory.createDefinition(defId,
                defName, version, defaultTitle,
                null, startTask);
}
 
Example #13
Source File: SubProcessActivityBehavior.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    PvmActivity activity = activityExecution.getActivity();
    ActivityImpl initialActivity = (ActivityImpl) activity.getProperty(BpmnParse.PROPERTYNAME_INITIAL);

    if (initialActivity == null) {
        throw new ActivitiException("No initial activity found for subprocess "
                + activityExecution.getActivity().getId());
    }

    // initialize the template-defined data objects as variables
    initializeDataObjects(activityExecution, activity);

    if (initialActivity.getActivityBehavior() != null
            && initialActivity.getActivityBehavior() instanceof NoneStartEventActivityBehavior) { // embedded subprocess: only none start allowed
        ((ExecutionEntity) execution).setActivity(initialActivity);
        Context.getCommandContext().getHistoryManager().recordActivityStart((ExecutionEntity) execution);
    }

    activityExecution.executeActivity(initialActivity);
}
 
Example #14
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private WorkflowTask getTaskForTimer(Job job, ProcessInstance processInstance, Execution jobExecution) 
{
    if (job instanceof TimerEntity) 
    {
        ReadOnlyProcessDefinition def = activitiUtil.getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
        List<String> activeActivityIds = runtimeService.getActiveActivityIds(jobExecution.getId());
        
        if(activeActivityIds.size() == 1)
        {
            PvmActivity targetActivity = def.findActivity(activeActivityIds.get(0));
            if(targetActivity != null)
            {
                // Only get tasks of active activity is a user-task 
                String activityType = (String) targetActivity.getProperty(ActivitiConstants.NODE_TYPE);
                if(ActivitiConstants.USER_TASK_NODE_TYPE.equals(activityType))
                {
                    Task task = taskService.createTaskQuery().executionId(job.getExecutionId()).singleResult();
                    return typeConverter.convert(task);
                }
            }
        }
    }
    return null;
}
 
Example #15
Source File: AutoCompleteFirstTaskListener.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 获得第一个节点.
 */
public PvmActivity findFirstActivity(String processDefinitionId) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getProcessDefinitionCache()
            .get(processDefinitionId);

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.debug("first activity is not userTask, just skip");

        return null;
    }

    return targetActivity;
}
 
Example #16
Source File: ExecutionEntity.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public List<ActivityExecution> findInactiveConcurrentExecutions(PvmActivity activity) {
    List<ActivityExecution> inactiveConcurrentExecutionsInActivity = new ArrayList<>();
    List<ActivityExecution> otherConcurrentExecutions = new ArrayList<>();
    if (isConcurrent()) {
        List<? extends ActivityExecution> concurrentExecutions = getParent().getAllChildExecutions();
        for (ActivityExecution concurrentExecution : concurrentExecutions) {
            if (concurrentExecution.getActivity() != null && concurrentExecution.getActivity().getId().equals(activity.getId())) {
                if (!concurrentExecution.isActive()) {
                    inactiveConcurrentExecutionsInActivity.add(concurrentExecution);
                }
            } else {
                otherConcurrentExecutions.add(concurrentExecution);
            }
        }
    } else {
        if (!isActive()) {
            inactiveConcurrentExecutionsInActivity.add(this);
        } else {
            otherConcurrentExecutions.add(this);
        }
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("inactive concurrent executions in '{}': {}", activity, inactiveConcurrentExecutionsInActivity);
        LOGGER.debug("other concurrent executions: {}", otherConcurrentExecutions);
    }
    return inactiveConcurrentExecutionsInActivity;
}
 
Example #17
Source File: ActivitiInternalProcessConnector.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 获得提交节点
 */
public String findFirstUserTaskActivityId(String processDefinitionId,
        String initiator) {
    GetDeploymentProcessDefinitionCmd getDeploymentProcessDefinitionCmd = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId);
    ProcessDefinitionEntity processDefinitionEntity = processEngine
            .getManagementService().executeCommand(
                    getDeploymentProcessDefinitionCmd);

    ActivityImpl startActivity = processDefinitionEntity.getInitial();

    if (startActivity.getOutgoingTransitions().size() != 1) {
        throw new IllegalStateException(
                "start activity outgoing transitions cannot more than 1, now is : "
                        + startActivity.getOutgoingTransitions().size());
    }

    PvmTransition pvmTransition = startActivity.getOutgoingTransitions()
            .get(0);
    PvmActivity targetActivity = pvmTransition.getDestination();

    if (!"userTask".equals(targetActivity.getProperty("type"))) {
        logger.info("first activity is not userTask, just skip");

        return null;
    }

    return targetActivity.getId();
}
 
Example #18
Source File: ExecutionImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public List<ActivityExecution> findInactiveConcurrentExecutions(PvmActivity activity) {
    List<ActivityExecution> inactiveConcurrentExecutionsInActivity = new ArrayList<>();
    List<ActivityExecution> otherConcurrentExecutions = new ArrayList<>();
    if (isConcurrent()) {
        List<? extends ActivityExecution> concurrentExecutions = getParent().getExecutions();
        for (ActivityExecution concurrentExecution : concurrentExecutions) {
            if (concurrentExecution.getActivity() != null && concurrentExecution.getActivity().getId().equals(activity.getId())) {
                if (concurrentExecution.isActive()) {
                    throw new PvmException("didn't expect active execution in " + activity + ". bug?");
                }
                inactiveConcurrentExecutionsInActivity.add(concurrentExecution);
            } else {
                otherConcurrentExecutions.add(concurrentExecution);
            }
        }
    } else {
        if (!isActive()) {
            inactiveConcurrentExecutionsInActivity.add(this);
        } else {
            otherConcurrentExecutions.add(this);
        }
    }
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("inactive concurrent executions in '{}': {}", activity, inactiveConcurrentExecutionsInActivity);
        LOGGER.debug("other concurrent executions: {}", otherConcurrentExecutions);
    }
    return inactiveConcurrentExecutionsInActivity;
}
 
Example #19
Source File: BpmResource.java    From lemon with Apache License 2.0 5 votes vote down vote up
public List<ActivityDTO> convertActivityDtos(List<PvmActivity> pvmActivities) {
    List<ActivityDTO> activityDtos = new ArrayList<ActivityDTO>();

    for (PvmActivity pvmActivity : pvmActivities) {
        ActivityDTO activityDto = new ActivityDTO();
        activityDto.setId(pvmActivity.getId());
        activityDto.setName((String) pvmActivity.getProperty("name"));
        activityDtos.add(activityDto);
    }

    return activityDtos;
}
 
Example #20
Source File: ProcessDefinitionPersistenceTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void testProcessDefinitionIntrospection() {
    String deploymentId = repositoryService
            .createDeployment()
            .addClasspathResource("org/activiti/engine/test/db/processOne.bpmn20.xml")
            .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE)
            .deploy()
            .getId();

    String procDefId = repositoryService.createProcessDefinitionQuery().singleResult().getId();
    ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawProcessConfiguration();
    ReadOnlyProcessDefinition processDefinition = ((RepositoryServiceImpl) activiti5ProcessEngineConfig.getRepositoryService()).getDeployedProcessDefinition(procDefId);

    assertEquals(procDefId, processDefinition.getId());
    assertEquals("Process One", processDefinition.getName());
    assertEquals("the first process", processDefinition.getProperty("documentation"));

    PvmActivity start = processDefinition.findActivity("start");
    assertNotNull(start);
    assertEquals("start", start.getId());
    assertEquals("S t a r t", start.getProperty("name"));
    assertEquals("the start event", start.getProperty("documentation"));
    assertEquals(Collections.EMPTY_LIST, start.getActivities());
    List<PvmTransition> outgoingTransitions = start.getOutgoingTransitions();
    assertEquals(1, outgoingTransitions.size());
    assertEquals("${a == b}", outgoingTransitions.get(0).getProperty(BpmnParse.PROPERTYNAME_CONDITION_TEXT));

    PvmActivity end = processDefinition.findActivity("end");
    assertNotNull(end);
    assertEquals("end", end.getId());

    PvmTransition transition = outgoingTransitions.get(0);
    assertEquals("flow1", transition.getId());
    assertEquals("Flow One", transition.getProperty("name"));
    assertEquals("The only transitions in the process", transition.getProperty("documentation"));
    assertSame(start, transition.getSource());
    assertSame(end, transition.getDestination());

    repositoryService.deleteDeployment(deploymentId);
}
 
Example #21
Source File: EventScopeCreatingSubprocess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void timerFires(ActivityExecution execution, String signalName, Object signalData) throws Exception {
    PvmActivity timerActivity = execution.getActivity();
    boolean isInterrupting = (Boolean) timerActivity.getProperty("isInterrupting");
    List<ActivityExecution> recyclableExecutions;
    if (isInterrupting) {
        recyclableExecutions = removeAllExecutions(execution);
    } else {
        recyclableExecutions = Collections.EMPTY_LIST;
    }
    execution.takeAll(timerActivity.getOutgoingTransitions(), recyclableExecutions);
}
 
Example #22
Source File: InclusiveGatewayActivityBehavior.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public boolean activeConcurrentExecutionsExist(ActivityExecution execution) {
    PvmActivity activity = execution.getActivity();
    if (execution.isConcurrent()) {
        for (ActivityExecution concurrentExecution : getLeaveExecutions(execution.getParent())) {
            if (concurrentExecution.isActive() && !concurrentExecution.getId().equals(execution.getId())) {
                // TODO: when is transitionBeingTaken cleared? Should we clear it?
                boolean reachable = false;
                PvmTransition pvmTransition = ((ExecutionEntity) concurrentExecution).getTransitionBeingTaken();
                if (pvmTransition != null) {
                    reachable = isReachable(pvmTransition.getDestination(), activity, new HashSet<>());
                } else {
                    reachable = isReachable(concurrentExecution.getActivity(), activity, new HashSet<>());
                }

                if (reachable) {
                    if (LOGGER.isDebugEnabled()) {
                        LOGGER.debug("an active concurrent execution found: '{}'", concurrentExecution.getActivity());
                    }
                    return true;
                }
            }
        }
    } else if (execution.isActive()) { // is this ever true?
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("an active concurrent execution found: '{}'", execution.getActivity());
        }
        return true;
    }

    return false;
}
 
Example #23
Source File: EventScopeCreatingSubprocess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void execute(DelegateExecution execution) {
    ActivityExecution activityExecution = (ActivityExecution) execution;
    List<PvmActivity> startActivities = new ArrayList<PvmActivity>();
    for (PvmActivity activity : activityExecution.getActivity().getActivities()) {
        if (activity.getIncomingTransitions().isEmpty()) {
            startActivities.add(activity);
        }
    }

    for (PvmActivity startActivity : startActivities) {
        activityExecution.executeActivity(startActivity);
    }
}
 
Example #24
Source File: EmbeddedSubProcess.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void timerFires(ActivityExecution execution, String signalName, Object signalData) throws Exception {
    PvmActivity timerActivity = execution.getActivity();
    boolean isInterrupting = (Boolean) timerActivity.getProperty("isInterrupting");
    List<ActivityExecution> recyclableExecutions;
    if (isInterrupting) {
        recyclableExecutions = removeAllExecutions(execution);
    } else {
        recyclableExecutions = Collections.EMPTY_LIST;
    }
    execution.takeAll(timerActivity.getOutgoingTransitions(), recyclableExecutions);
}
 
Example #25
Source File: WaitState.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception {
    PvmActivity activity = execution.getActivity();
    System.out.println("触发活动" + activity.getId());

    PvmTransition transition = activity.getOutgoingTransitions().get(0);
    execution.take(transition);
}
 
Example #26
Source File: FindPreviousActivitiesCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public List<PvmActivity> execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getDeploymentManager()
            .findDeployedProcessDefinitionById(processDefinitionId);

    if (processDefinitionEntity == null) {
        throw new IllegalArgumentException(
                "cannot find processDefinition : " + processDefinitionId);
    }

    ActivityImpl activity = processDefinitionEntity
            .findActivity(activityId);

    return this.getPreviousActivities(activity);
}
 
Example #27
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isReceiveTask(PvmActivity act)
{
    if(act instanceof ActivityImpl) 
    {
        ActivityImpl actImpl = (ActivityImpl) act;
        return (actImpl.getActivityBehavior() instanceof ReceiveTaskActivityBehavior);        
    }
    return false;
}
 
Example #28
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isSubProcess(PvmActivity currentActivity)
{
    String type = (String) currentActivity.getProperty(ActivitiConstants.NODE_TYPE);
    if(type != null && type.equals(ActivitiConstants.SUB_PROCESS_NODE_TYPE))
    {
        return true;
    }
    return false;
}
 
Example #29
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean isUserTask(PvmActivity currentActivity)
{
    // TODO: Validate if this is the best way to find out an activity is a usertask
    String type = (String) currentActivity.getProperty(ActivitiConstants.NODE_TYPE);
    if(type != null && type.equals(ActivitiConstants.USER_TASK_NODE_TYPE))
    {
        return true;
    }
    return false;
}
 
Example #30
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void findUserTasks(PvmActivity currentActivity, Map<String, PvmActivity> userTasks, Set<String> processedActivities)
{
    // Only process activity if not already processed, to prevent endless loops
    if(!processedActivities.contains(currentActivity.getId()))
    {
        processedActivities.add(currentActivity.getId());
        if(isUserTask(currentActivity)) 
        {
            userTasks.put(currentActivity.getId(), currentActivity);
        }
        
        // Process outgoing transitions
        if(currentActivity.getOutgoingTransitions() != null)
        {
            for(PvmTransition transition : currentActivity.getOutgoingTransitions())
            {
                if(transition.getDestination() != null)
                {
                    findUserTasks(transition.getDestination(), userTasks, processedActivities);
                }
            }
        }

        if (isSubProcess(currentActivity))
        {
            Map<String, Object> properties = ((ActivityImpl)currentActivity).getProperties();
            PvmActivity startEvent = (PvmActivity) properties.get(ActivitiConstants.PROP_INITIAL_ACTIVITY);
            findUserTasks(startEvent, userTasks, processedActivities);
        }
    }
}