Java Code Examples for org.activiti.engine.impl.pvm.process.TransitionImpl#getDestination()

The following examples show how to use org.activiti.engine.impl.pvm.process.TransitionImpl#getDestination() . 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: ActivitiWorkFlowServiceImpl.java    From maven-framework-project with MIT License 6 votes vote down vote up
public String findParallelGatewayId(ActivityImpl activityImpl) {  
    List<PvmTransition> incomingTransitions = activityImpl  
            .getOutgoingTransitions();  
    for (PvmTransition pvmTransition : incomingTransitions) {  
        TransitionImpl transitionImpl = (TransitionImpl) pvmTransition;  
        activityImpl = transitionImpl.getDestination();  
        String type = (String) activityImpl.getProperty("type");  
        if ("parallelGateway".equals(type)) {// 并行路线  
            String gatewayId = activityImpl.getId();  
            String gatewayType = gatewayId.substring(gatewayId  
                    .lastIndexOf("_") + 1);  
            if ("END".equals(gatewayType.toUpperCase())) {  
                return gatewayId.substring(0, gatewayId.lastIndexOf("_"))  
                        + "_start";  
            }  
        }  
    }  
    return null;  
}
 
Example 2
Source File: ProcessCustomService.java    From maven-framework-project with MIT License 6 votes vote down vote up
/** 
 * 根据当前节点,查询输出流向是否为并行终点,如果为并行终点,则拼装对应的并行起点ID 
 *  
 * @param activityImpl 
 *            当前节点 
 * @return 
 */  
private static String findParallelGatewayId(ActivityImpl activityImpl) {  
    List<PvmTransition> incomingTransitions = activityImpl  
            .getOutgoingTransitions();  
    for (PvmTransition pvmTransition : incomingTransitions) {  
        TransitionImpl transitionImpl = (TransitionImpl) pvmTransition;  
        activityImpl = transitionImpl.getDestination();  
        String type = (String) activityImpl.getProperty("type");  
        if ("parallelGateway".equals(type)) {// 并行路线  
            String gatewayId = activityImpl.getId();  
            String gatewayType = gatewayId.substring(gatewayId  
                    .lastIndexOf("_") + 1);  
            if ("END".equals(gatewayType.toUpperCase())) {  
                return gatewayId.substring(0, gatewayId.lastIndexOf("_"))  
                        + "_start";  
            }  
        }  
    }  
    return null;  
}
 
Example 3
Source File: ProcessExtensionServiceImpl.java    From activiti-demo with Apache License 2.0 6 votes vote down vote up
/**
 * 根据当前节点,查询输出流向是否为并行终点,如果为并行终点,则拼装对应的并行起点ID
 * @param activityImpl   当前节点
 * @return
 */
private String findParallelGatewayId(ActivityImpl activityImpl){
    List<PvmTransition> incomingTransitions = activityImpl.getOutgoingTransitions();

    for(PvmTransition pvmTransition : incomingTransitions){
        TransitionImpl transitionImpl = (TransitionImpl)pvmTransition;
        activityImpl = transitionImpl.getDestination();
        String type = (String)activityImpl.getProperty("type");
        if("parallelGateway".equals(type)){ //并行路线
            String gatewayId = activityImpl.getId();
            String gettewayType = gatewayId.substring(gatewayId.lastIndexOf("_")+1);
            if("END".equals(gettewayType.toUpperCase())){
                return gatewayId.substring(0, gatewayId.lastIndexOf("_"))+"_start";
            }
        }
    }

    return null;
}
 
Example 4
Source File: AtomicOperationTransitionDestroyScope.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public void execute(InterpretableExecution execution) {
    InterpretableExecution propagatingExecution = null;

    ActivityImpl activity = (ActivityImpl) execution.getActivity();
    // if this transition is crossing a scope boundary
    if (activity.isScope()) {

        InterpretableExecution parentScopeInstance = null;
        // if this is a concurrent execution crossing a scope boundary
        if (execution.isConcurrent() && !execution.isScope()) {
            // first remove the execution from the current root
            InterpretableExecution concurrentRoot = (InterpretableExecution) execution.getParent();
            parentScopeInstance = (InterpretableExecution) execution.getParent().getParent();

            LOGGER.debug("moving concurrent {} one scope up under {}", execution, parentScopeInstance);
            List<InterpretableExecution> parentScopeInstanceExecutions = (List<InterpretableExecution>) parentScopeInstance.getExecutions();
            List<InterpretableExecution> concurrentRootExecutions = (List<InterpretableExecution>) concurrentRoot.getExecutions();
            // if the parent scope had only one single scope child
            if (parentScopeInstanceExecutions.size() == 1) {
                // it now becomes a concurrent execution
                parentScopeInstanceExecutions.get(0).setConcurrent(true);
            }

            concurrentRootExecutions.remove(execution);
            parentScopeInstanceExecutions.add(execution);
            execution.setParent(parentScopeInstance);
            execution.setActivity(activity);
            propagatingExecution = execution;

            // if there is only a single concurrent execution left
            // in the concurrent root, auto-prune it. meaning, the
            // last concurrent child execution data should be cloned into
            // the concurrent root.
            if (concurrentRootExecutions.size() == 1) {
                InterpretableExecution lastConcurrent = concurrentRootExecutions.get(0);
                if (lastConcurrent.isScope()) {
                    lastConcurrent.setConcurrent(false);

                } else {
                    LOGGER.debug("merging last concurrent {} into concurrent root {}", lastConcurrent, concurrentRoot);

                    // We can't just merge the data of the lastConcurrent into the concurrentRoot.
                    // This is because the concurrent root might be in a takeAll-loop. So the
                    // concurrent execution is the one that will be receiving the take
                    concurrentRoot.setActivity((ActivityImpl) lastConcurrent.getActivity());
                    concurrentRoot.setActive(lastConcurrent.isActive());
                    lastConcurrent.setReplacedBy(concurrentRoot);
                    lastConcurrent.remove();
                }
            }

        } else if (execution.isConcurrent() && execution.isScope()) {
            LOGGER.debug("scoped concurrent {} becomes concurrent and remains under {}", execution, execution.getParent());

            // TODO!
            execution.destroy();
            propagatingExecution = execution;

        } else {
            propagatingExecution = (InterpretableExecution) execution.getParent();
            propagatingExecution.setActivity((ActivityImpl) execution.getActivity());
            propagatingExecution.setTransition(execution.getTransition());
            propagatingExecution.setActive(true);
            LOGGER.debug("destroy scope: scoped {} continues as parent scope {}", execution, propagatingExecution);
            execution.destroy();
            execution.remove();
        }

    } else {
        propagatingExecution = execution;
    }

    // if there is another scope element that is ended
    ScopeImpl nextOuterScopeElement = activity.getParent();
    TransitionImpl transition = propagatingExecution.getTransition();
    ActivityImpl destination = transition.getDestination();
    if (transitionLeavesNextOuterScope(nextOuterScopeElement, destination)) {
        propagatingExecution.setActivity((ActivityImpl) nextOuterScopeElement);
        propagatingExecution.performOperation(TRANSITION_NOTIFY_LISTENER_END);
    } else {
        propagatingExecution.performOperation(TRANSITION_NOTIFY_LISTENER_TAKE);
    }
}