当前位置: 首页>>代码示例>>Java>>正文


Java PvmTransition.getSource方法代码示例

本文整理汇总了Java中org.activiti.engine.impl.pvm.PvmTransition.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java PvmTransition.getSource方法的具体用法?Java PvmTransition.getSource怎么用?Java PvmTransition.getSource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.activiti.engine.impl.pvm.PvmTransition的用法示例。


在下文中一共展示了PvmTransition.getSource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getActivityPreTasks

import org.activiti.engine.impl.pvm.PvmTransition; //导入方法依赖的package包/类
private static void getActivityPreTasks(List<PvmTransition> pvmTransitionList, List<String> preTaskList, String myId) {
    for(PvmTransition pvmTransition:pvmTransitionList) {
        PvmActivity pvmActivity = pvmTransition.getSource();
        String actType = (String)pvmActivity.getProperty("type");
        if(actType.endsWith("Task")) {
            //userTask, seriviceTask, ...
            if(!pvmActivity.getId().equals(myId)) {
                preTaskList.add(pvmActivity.getId());
            }
        } else if(actType.endsWith("Gateway")) {
            //gateway
            getActivityPreTasks(pvmActivity.getIncomingTransitions(), preTaskList, myId);
        }
    }
}
 
开发者ID:YuhangGe,项目名称:activiti-spring-hibernate,代码行数:16,代码来源:RhoEventLogger.java

示例2: processNeighbor

import org.activiti.engine.impl.pvm.PvmTransition; //导入方法依赖的package包/类
public void processNeighbor(DelegateTask delegateTask, String value) {
    String processDefinitionId = delegateTask.getProcessDefinitionId();
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getProcessDefinitionCache()
            .get(processDefinitionId);
    ActivityImpl activityImpl = processDefinitionEntity
            .findActivity(delegateTask.getTaskDefinitionKey());
    PvmTransition pvmTransition = activityImpl.getIncomingTransitions()
            .iterator().next();
    PvmActivity pvmActivity = pvmTransition.getSource();

    if (!"userTask".equals(pvmActivity.getProperty("type"))) {
        logger.info("previous {} {} not userTask, just skip",
                pvmActivity.getId(), pvmActivity.getProperty("type"));

        return;
    }

    String targetActivityId = pvmActivity.getId();

    /*
     * JdbcTemplate jdbcTemplate = ApplicationContextHelper .getBean(JdbcTemplate.class); String previousAssignee =
     * jdbcTemplate .queryForObject(
     * "select ASSIGNEE_ from ACT_HI_TASKINST where ACT_ID_=? order by END_TIME_ desc", String.class,
     * targetActivityId);
     */
    List<HistoricTaskInstanceEntity> historicTaskInstanceEntities = Context
            .getCommandContext().getDbSqlSession()
            .findInCache(HistoricTaskInstanceEntity.class);
    logger.info("{}", historicTaskInstanceEntities);

    String previousAssignee = null;

    for (HistoricTaskInstanceEntity historicTaskInstanceEntity : historicTaskInstanceEntities) {
        if (targetActivityId.equals(historicTaskInstanceEntity
                .getTaskDefinitionKey())) {
            previousAssignee = historicTaskInstanceEntity.getAssignee();

            break;
        }
    }

    if (previousAssignee == null) {
        logger.info("cannot previous assignee, skip");

        return;
    }

    logger.info("previousAssignee : {}", previousAssignee);
    logger.info("delegateTask.getAssignee() : {}",
            delegateTask.getAssignee());

    if (previousAssignee.equals(delegateTask.getAssignee())) {
        logger.info("skip");

        new CompleteTaskWithCommentCmd(delegateTask.getId(),
                Collections.<String, Object> emptyMap(), "相邻相同人员自动跳过")
                .execute(Context.getCommandContext());
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:61,代码来源:SkipTaskListener.java

示例3: processNeighbor

import org.activiti.engine.impl.pvm.PvmTransition; //导入方法依赖的package包/类
public void processNeighbor(DelegateTask delegateTask, String value) {
    String processDefinitionId = delegateTask.getProcessDefinitionId();
    ProcessDefinitionEntity processDefinitionEntity = Context
            .getProcessEngineConfiguration().getProcessDefinitionCache()
            .get(processDefinitionId);
    ActivityImpl activityImpl = processDefinitionEntity
            .findActivity(delegateTask.getTaskDefinitionKey());
    PvmTransition pvmTransition = activityImpl.getIncomingTransitions()
            .iterator().next();
    PvmActivity pvmActivity = pvmTransition.getSource();

    if (!"userTask".equals(pvmActivity.getProperty("type"))) {
        logger.info("previous {} {} not userTask, just skip",
                pvmActivity.getId(), pvmActivity.getProperty("type"));

        return;
    }

    String targetActivityId = pvmActivity.getId();

    /*
     * JdbcTemplate jdbcTemplate = ApplicationContextHelper .getBean(JdbcTemplate.class); String previousAssignee =
     * jdbcTemplate .queryForObject(
     * "select ASSIGNEE_ from ACT_HI_TASKINST where ACT_ID_=? order by END_TIME_ desc", String.class,
     * targetActivityId);
     */
    List<HistoricTaskInstanceEntity> historicTaskInstanceEntities = Context
            .getCommandContext().getDbSqlSession()
            .findInCache(HistoricTaskInstanceEntity.class);
    logger.info("{}", historicTaskInstanceEntities);

    String previousAssignee = null;

    for (HistoricTaskInstanceEntity historicTaskInstanceEntity : historicTaskInstanceEntities) {
        if (targetActivityId.equals(historicTaskInstanceEntity
                .getTaskDefinitionKey())) {
            previousAssignee = historicTaskInstanceEntity.getAssignee();

            break;
        }
    }

    if (previousAssignee == null) {
        logger.info("cannot previous assignee, skip");

        return;
    }

    logger.info("previousAssignee : {}", previousAssignee);
    logger.info("delegateTask.getAssignee() : {}",
            delegateTask.getAssignee());

    if (previousAssignee.equals(delegateTask.getAssignee())) {
        logger.info("skip");

        // new CompleteTaskWithCommentCmd(delegateTask.getId(),
        // Collections.<String, Object> emptyMap(), "相邻相同人员自动跳过")
        // .execute(Context.getCommandContext());
        this.doSkip(delegateTask);
    }
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:62,代码来源:SkipEventListener.java

示例4: findPreviousEdge

import org.activiti.engine.impl.pvm.PvmTransition; //导入方法依赖的package包/类
/**
 * 找到这个节点前面的连线.
 */
public Edge findPreviousEdge(Node currentNode, long currentStartTime) {
    String activityId = currentNode.getName();
    ActivityImpl activityImpl = processDefinitionEntity
            .findActivity(activityId);
    HistoricActivityInstance nestestHistoricActivityInstance = null;
    String temporaryPvmTransitionId = null;

    // 遍历进入当前节点的所有连线
    for (PvmTransition pvmTransition : activityImpl
            .getIncomingTransitions()) {
        PvmActivity source = pvmTransition.getSource();

        String previousActivityId = source.getId();

        HistoricActivityInstance visitiedHistoryActivityInstance = this
                .findVisitedHistoricActivityInstance(previousActivityId);

        if (visitiedHistoryActivityInstance == null) {
            continue;
        }

        // 如果上一个节点还未完成,说明不可能是从这个节点过来的,跳过
        if (visitiedHistoryActivityInstance.getEndTime() == null) {
            continue;
        }

        logger.debug("current activity start time : {}", new Date(
                currentStartTime));
        logger.debug("nestest activity end time : {}",
                visitiedHistoryActivityInstance.getEndTime());

        // 如果当前节点的开始时间,比上一个节点的结束时间要早,跳过
        if (currentStartTime < visitiedHistoryActivityInstance.getEndTime()
                .getTime()) {
            continue;
        }

        if (nestestHistoricActivityInstance == null) {
            nestestHistoricActivityInstance = visitiedHistoryActivityInstance;
            temporaryPvmTransitionId = pvmTransition.getId();
        } else if ((currentStartTime - nestestHistoricActivityInstance
                .getEndTime().getTime()) > (currentStartTime - visitiedHistoryActivityInstance
                .getEndTime().getTime())) {
            // 寻找离当前节点最近的上一个节点
            // 比较上一个节点的endTime与当前节点startTime的差
            nestestHistoricActivityInstance = visitiedHistoryActivityInstance;
            temporaryPvmTransitionId = pvmTransition.getId();
        }
    }

    // 没找到上一个节点,就返回null
    if (nestestHistoricActivityInstance == null) {
        return null;
    }

    Node previousNode = nodeMap
            .get(nestestHistoricActivityInstance.getId());

    if (previousNode == null) {
        return null;
    }

    logger.debug("previousNode : {}:{}", previousNode.getName(),
            previousNode.getId());

    Edge edge = new Edge();
    edge.setName(temporaryPvmTransitionId);
    previousNode.getOutgoingEdges().add(edge);
    edge.setSrc(previousNode);
    edge.setDest(currentNode);

    return edge;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:77,代码来源:ActivitiHistoryGraphBuilder.java

示例5: reject

import org.activiti.engine.impl.pvm.PvmTransition; //导入方法依赖的package包/类
@Override
public void reject(String taskId) {
    // 先判定是否存在历史环节
    String oldTaskId = selectVariableLocalByTaskId(taskId, "oldTaskId").toString();
    HistoricTaskInstance taskInstance = historyService.createHistoricTaskInstanceQuery().taskId(oldTaskId).singleResult();
    if (taskInstance == null) {
        throw new NotFoundException("历史任务环节不存在,taskId:" + oldTaskId);
    }

    Task task = selectTaskByTaskId(taskId);

    ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
    if (processInstance == null) {
        throw new NotFoundException("流程已经结束");
    }

    Map<String, Object> variables = processInstance.getProcessVariables();

    ProcessDefinitionEntity definition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(task.getProcessDefinitionId());
    if (definition == null) {
        throw new NotFoundException("流程定义未找到");
    }

    ActivityExecution execution = (ActivityExecution) runtimeService.createExecutionQuery()
            .executionId(task.getExecutionId()).singleResult();
    // 是否并行节点
    if (execution.isConcurrent()) {
        throw new NotFoundException("并行节点不允许驳回,taskId:" + task.getId());
    }

    // 是否存在定时任务
    long num = managementService.createJobQuery().executionId(task.getExecutionId()).count();
    if (num > 0) {
        throw new NotFoundException("当前环节不允许驳回");
    }

    // 驳回


    // 取得上一步活动
    ActivityImpl currActivity = definition.findActivity(task.getTaskDefinitionKey());
    List<PvmTransition> nextTransitionList = currActivity.getIncomingTransitions();
    // 清除当前活动的出口
    List<PvmTransition> oriPvmTransitionList = new ArrayList<>();
    List<PvmTransition> pvmTransitionList = currActivity.getOutgoingTransitions();
    oriPvmTransitionList.addAll(pvmTransitionList);
    pvmTransitionList.clear();

    // 建立新出口
    List<TransitionImpl> newTransitions = new ArrayList<>();
    for (PvmTransition nextTransition : nextTransitionList) {
        PvmActivity nextActivity = nextTransition.getSource();
        ActivityImpl nextActivityImpl = definition.findActivity(nextActivity.getId());
        TransitionImpl newTransition = currActivity.createOutgoingTransition();
        newTransition.setDestination(nextActivityImpl);
        newTransitions.add(newTransition);
    }
    // 完成任务
    List<Task> tasks = taskService.createTaskQuery()
            .processInstanceId(processInstance.getId())
            .taskDefinitionKey(task.getTaskDefinitionKey()).list();
    for (Task t : tasks) {
        taskService.complete(t.getId(), variables);
        historyService.deleteHistoricTaskInstance(t.getId());
    }
    // 恢复方向
    for (TransitionImpl transitionImpl : newTransitions) {
        currActivity.getOutgoingTransitions().remove(transitionImpl);
    }
    pvmTransitionList.addAll(oriPvmTransitionList);

}
 
开发者ID:hs-web,项目名称:hsweb-framework,代码行数:73,代码来源:BpmTaskServiceImp.java

示例6: dealParallelGateway

import org.activiti.engine.impl.pvm.PvmTransition; //导入方法依赖的package包/类
private void dealParallelGateway(ActivityImpl ai) throws Exception {
    List<PvmTransition> incomingTransitions = ai.getIncomingTransitions();
    List<PvmTransition> outgoingTransitions = ai.getOutgoingTransitions();
    /*
     * 不支持多进多出的并发gateway。
     * 如果是多进一出,说明是并发的结束,直接返回。
     * 如果是一进多出,说明是并发的开始,需要处理。
     */
    int is = incomingTransitions.size();
    int os = outgoingTransitions.size();
    if (is <= 0 || os <= 0) {
        return;
    } else if (is > 1 && os > 1) {
        throw new Exception("RhoAutoRunner: do not support such kind of parallel gateway");
    } else if (os == 1) {
        return;
    }

    PvmActivity curAct = incomingTransitions.get(0).getSource();
    String type = (String) curAct.getProperty("type");
    List<String> curTaskList = new ArrayList<>();

    if (type.endsWith("Task")) {
        curTaskList.add((String) curAct.getProperty("name"));
    } else if (type.equals("exclusiveGateway")) {
        List<PvmTransition> ins = curAct.getIncomingTransitions();
        for (PvmTransition pi : ins) {
            PvmActivity pt = pi.getSource();
            String ptype = (String) pt.getProperty("type");
            if (ptype.endsWith("Task")) {
                curTaskList.add((String) pt.getProperty("name"));
            } else {
                throw new Exception("RhoAutoRunner: do not support such kind of parallel gateway");
            }
        }
    } else {
        throw new Exception("RhoAutoRunner: do not support such kind of parallel gateway, with zero pre tasks");
    }
    ParallelE pairList = new ParallelE();
    for (String curTaskName : curTaskList) {
        parallelCache.put(curTaskName, pairList);
    }


    List<PvmActivity> outActList = new ArrayList<>();
    for (PvmTransition outTransition : outgoingTransitions) {
        outActList.add(outTransition.getDestination());
    }

    addOutPair(pairList.list, outActList, 0);

}
 
开发者ID:YuhangGe,项目名称:activiti-spring-hibernate,代码行数:53,代码来源:RhoAutoRunner.java


注:本文中的org.activiti.engine.impl.pvm.PvmTransition.getSource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。