Java Code Examples for org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity#findActivity()

The following examples show how to use org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity#findActivity() . 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: TimerStartEventJobHandler.java    From flowable-engine with Apache License 2.0 7 votes vote down vote up
protected void startProcessInstanceWithInitialActivity(Job job, String configuration, DeploymentManager deploymentManager, CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) deploymentManager.findDeployedProcessDefinitionById(job.getProcessDefinitionId());

    String activityId = getActivityIdFromConfiguration(configuration);
    ActivityImpl startActivity = processDefinition.findActivity(activityId);

    if (!deploymentManager.isProcessDefinitionSuspended(processDefinition.getId())) {
        dispatchTimerFiredEvent(job, commandContext);

        ExecutionEntity processInstance = processDefinition.createProcessInstance(null, startActivity);
        processInstance.start();

    } else {
        LOGGER.debug("Ignoring timer of suspended process definition {}", processDefinition.getId());
    }

}
 
Example 2
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 6 votes vote down vote up
/**
 * 查找回退的目的节点.
 */
public ActivityImpl findTargetActivity(CommandContext commandContext,
        TaskEntity taskEntity) {
    if (activityId == null) {
        String historyTaskId = this.findNearestUserTask(commandContext);
        HistoricTaskInstanceEntity historicTaskInstanceEntity = commandContext
                .getHistoricTaskInstanceEntityManager()
                .findHistoricTaskInstanceById(historyTaskId);
        this.activityId = historicTaskInstanceEntity.getTaskDefinitionKey();
    }

    String processDefinitionId = taskEntity.getProcessDefinitionId();
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId).execute(commandContext);

    return processDefinitionEntity.findActivity(activityId);
}
 
Example 3
Source File: ActivitiKit.java    From my_curd with Apache License 2.0 5 votes vote down vote up
private static List<String> getHighLightedFlows(ProcessDefinitionEntity processDefinitionEntity, List<HistoricActivityInstance> historicActivityInstances) {
    List<String> highFlows = new ArrayList<String>();
    for (int i = 0; i < historicActivityInstances.size() - 1; i++) {
        ActivityImpl activityImpl = processDefinitionEntity.findActivity(historicActivityInstances.get(i).getActivityId());
        List<ActivityImpl> sameStartTimeNodes = new ArrayList<>();
        ActivityImpl sameActivityImpl1 = processDefinitionEntity.findActivity(historicActivityInstances.get(i + 1).getActivityId());
        sameStartTimeNodes.add(sameActivityImpl1);
        for (int j = i + 1; j < historicActivityInstances.size() - 1; j++) {
            HistoricActivityInstance activityImpl1 = historicActivityInstances.get(j);
            HistoricActivityInstance activityImpl2 = historicActivityInstances.get(j + 1);
            if (activityImpl1.getStartTime().equals(activityImpl2.getStartTime())) {
                ActivityImpl sameActivityImpl2 = processDefinitionEntity.findActivity(activityImpl2.getActivityId());
                sameStartTimeNodes.add(sameActivityImpl2);
            } else {
                break;
            }
        }
        List<PvmTransition> pvmTransitions = activityImpl.getOutgoingTransitions();// 取出节点的所有出去的线
        for (PvmTransition pvmTransition : pvmTransitions) {
            ActivityImpl pvmActivityImpl = (ActivityImpl) pvmTransition.getDestination();
            if (sameStartTimeNodes.contains(pvmActivityImpl)) {
                highFlows.add(pvmTransition.getId());
            }
        }
    }
    return highFlows;
}
 
Example 4
Source File: FindNextActivitiesCmd.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.getNextActivities(activity);
}
 
Example 5
Source File: CheckWithdrawTaskCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public ActivityImpl getActivity(
        HistoricActivityInstanceEntity historicActivityInstanceEntity) {
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            historicActivityInstanceEntity.getProcessDefinitionId())
            .execute(Context.getCommandContext());

    return processDefinitionEntity
            .findActivity(historicActivityInstanceEntity.getActivityId());
}
 
Example 6
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 7
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 获得历史节点对应的节点信息.
 */
public ActivityImpl getActivity(
        HistoricActivityInstanceEntity historicActivityInstanceEntity) {
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            historicActivityInstanceEntity.getProcessDefinitionId())
            .execute(Context.getCommandContext());

    return processDefinitionEntity
            .findActivity(historicActivityInstanceEntity.getActivityId());
}
 
Example 8
Source File: WithdrawTaskCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public ActivityImpl getActivity(
        HistoricActivityInstanceEntity historicActivityInstanceEntity) {
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            historicActivityInstanceEntity.getProcessDefinitionId())
            .execute(Context.getCommandContext());

    return processDefinitionEntity
            .findActivity(historicActivityInstanceEntity.getActivityId());
}
 
Example 9
Source File: BpmnParse.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
public void createBPMNShape(String key, GraphicInfo graphicInfo, ProcessDefinitionEntity processDefinition) {
    ActivityImpl activity = processDefinition.findActivity(key);
    if (activity != null) {
        createDIBounds(graphicInfo, activity);

    } else {
        org.activiti.engine.impl.pvm.process.Lane lane = processDefinition.getLaneForId(key);

        if (lane != null) {
            // The shape represents a lane
            createDIBounds(graphicInfo, lane);
        }
    }
}
 
Example 10
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 11
Source File: RollbackCmd.java    From lemon with Apache License 2.0 5 votes vote down vote up
public ActivityImpl getActivity(
        HistoricActivityInstanceEntity historicActivityInstanceEntity) {
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            historicActivityInstanceEntity.getProcessDefinitionId())
            .execute(Context.getCommandContext());

    return processDefinitionEntity
            .findActivity(historicActivityInstanceEntity.getActivityId());
}
 
Example 12
Source File: BpmActivityServiceImpl.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
@Override
public List<ActivityImpl> getActivitiesById(String processDefId, String activityId) {
    ProcessDefinitionEntity pde = getProcessDefinition(processDefId);
    if (activityId == null) {
        return pde.getActivities();
    } else {
        ActivityImpl activity = pde.findActivity(activityId);
        if (null == activity) {
            return new java.util.ArrayList<>();
        }
        return Collections.singletonList(activity);
    }
}
 
Example 13
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;
}
 
Example 14
Source File: ProcessDefinitionUtils.java    From openwebflow with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static ActivityImpl getActivity(ProcessEngine processEngine, String processDefId, String activityId)
{
	ProcessDefinitionEntity pde = getProcessDefinition(processEngine, processDefId);
	return (ActivityImpl) pde.findActivity(activityId);
}
 
Example 15
Source File: SkipEventListener.java    From lemon with Apache License 2.0 4 votes vote down vote up
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);
    }
}
 
Example 16
Source File: CustomProcessDiagramGenerator.java    From lemon with Apache License 2.0 4 votes vote down vote up
public InputStream generateDiagram(String processInstanceId)
        throws IOException {
    HistoricProcessInstance historicProcessInstance = Context
            .getCommandContext().getHistoricProcessInstanceEntityManager()
            .findHistoricProcessInstance(processInstanceId);
    String processDefinitionId = historicProcessInstance
            .getProcessDefinitionId();
    GetBpmnModelCmd getBpmnModelCmd = new GetBpmnModelCmd(
            processDefinitionId);
    BpmnModel bpmnModel = getBpmnModelCmd.execute(Context
            .getCommandContext());

    // Point point = getMinXAndMinY(bpmnModel);
    // this.minX = point.x;
    // this.minY = point.y;
    // this.minX = (this.minX <= 5) ? 5 : this.minX;
    // this.minY = (this.minY <= 5) ? 5 : this.minY;
    // this.minX -= 5;
    // this.minY -= 5;
    ProcessDefinitionEntity definition = new GetDeploymentProcessDefinitionCmd(
            processDefinitionId).execute(Context.getCommandContext());
    String diagramResourceName = definition.getDiagramResourceName();
    String deploymentId = definition.getDeploymentId();
    byte[] bytes = Context
            .getCommandContext()
            .getResourceEntityManager()
            .findResourceByDeploymentIdAndResourceName(deploymentId,
                    diagramResourceName).getBytes();
    InputStream originDiagram = new ByteArrayInputStream(bytes);
    BufferedImage image = ImageIO.read(originDiagram);

    HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl();
    historicActivityInstanceQueryImpl.processInstanceId(processInstanceId)
            .orderByHistoricActivityInstanceStartTime().asc();

    Page page = new Page(0, 100);
    List<HistoricActivityInstance> activityInstances = Context
            .getCommandContext()
            .getHistoricActivityInstanceEntityManager()
            .findHistoricActivityInstancesByQueryCriteria(
                    historicActivityInstanceQueryImpl, page);

    this.drawHistoryFlow(image, processInstanceId);

    for (HistoricActivityInstance historicActivityInstance : activityInstances) {
        String historicActivityId = historicActivityInstance
                .getActivityId();
        ActivityImpl activity = definition.findActivity(historicActivityId);

        if (activity != null) {
            if (historicActivityInstance.getEndTime() == null) {
                // 节点正在运行中
                signRunningNode(image, activity.getX() - this.minX,
                        activity.getY() - this.minY, activity.getWidth(),
                        activity.getHeight(),
                        historicActivityInstance.getActivityType());
            } else {
                String deleteReason = null;

                if (historicActivityInstance.getTaskId() != null) {
                    deleteReason = Context
                            .getCommandContext()
                            .getHistoricTaskInstanceEntityManager()
                            .findHistoricTaskInstanceById(
                                    historicActivityInstance.getTaskId())
                            .getDeleteReason();
                }

                // 节点已经结束
                if ("跳过".equals(deleteReason)) {
                    signSkipNode(image, activity.getX() - this.minX,
                            activity.getY() - this.minY,
                            activity.getWidth(), activity.getHeight(),
                            historicActivityInstance.getActivityType());
                } else {
                    signHistoryNode(image, activity.getX() - this.minX,
                            activity.getY() - this.minY,
                            activity.getWidth(), activity.getHeight(),
                            historicActivityInstance.getActivityType());
                }
            }
        }
    }

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    String formatName = getDiagramExtension(diagramResourceName);
    ImageIO.write(image, formatName, out);

    return new ByteArrayInputStream(out.toByteArray());
}
 
Example 17
Source File: RollbackTaskCmd.java    From lemon with Apache License 2.0 4 votes vote down vote up
/**
 * 删除未完成任务.
 */
public void deleteActiveTask(TaskEntity taskEntity) {
    ProcessDefinitionEntity processDefinitionEntity = new GetDeploymentProcessDefinitionCmd(
            taskEntity.getProcessDefinitionId()).execute(Context
            .getCommandContext());

    ActivityImpl activityImpl = processDefinitionEntity
            .findActivity(taskEntity.getTaskDefinitionKey());

    if (this.isMultiInstance(activityImpl)) {
        logger.info("{} is multiInstance", taskEntity.getId());
        this.multiInstanceExecutionIds.add(taskEntity.getExecution()
                .getParent().getId());
        logger.info("append : {}", taskEntity.getExecution().getParent()
                .getId());
    }

    // TaskEntity taskEntity = Context.getCommandContext()
    // .getTaskEntityManager().findTaskById(this.taskId);
    Context.getCommandContext().getTaskEntityManager()
            .deleteTask(taskEntity, "驳回", false);

    JdbcTemplate jdbcTemplate = ApplicationContextHelper
            .getBean(JdbcTemplate.class);
    List<Map<String, Object>> list = jdbcTemplate
            .queryForList(
                    "SELECT * FROM ACT_HI_ACTINST WHERE TASK_ID_=? AND END_TIME_ IS NULL",
                    taskId);
    Date now = new Date();

    for (Map<String, Object> map : list) {
        Date startTime = (Date) map.get("START_TIME_");
        long duration = now.getTime() - startTime.getTime();
        jdbcTemplate
                .update("UPDATE ACT_HI_ACTINST SET END_TIME_=?,DURATION_=? WHERE ID_=?",
                        now, duration, map.get("ID_"));
    }

    // 处理humanTask
    HumanTaskConnector humanTaskConnector = ApplicationContextHelper
            .getBean(HumanTaskConnector.class);
    HumanTaskDTO humanTaskDto = humanTaskConnector
            .findHumanTaskByTaskId(this.taskId);
    humanTaskDto.setCompleteTime(new Date());
    humanTaskDto.setStatus("rollback");
    humanTaskConnector.saveHumanTask(humanTaskDto);
}
 
Example 18
Source File: BpmTaskServiceImpl.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
@SneakyThrows
public void doJumpTask(Task task, String activityId, Consumer<Task> newTaskConsumer) {

    ProcessDefinitionEntity entity = (ProcessDefinitionEntity)
            ((RepositoryServiceImpl) repositoryService)
                    .getDeployedProcessDefinition(task.getProcessDefinitionId());

    String sourceId = task.getTaskDefinitionKey();

    ActivityImpl targetActivity = entity.findActivity(activityId);
    ActivityImpl sourceActivity = entity.findActivity(sourceId);

    if (logger.isDebugEnabled()) {
        logger.debug("流程[{}({})]跳转[{}]->[{}]",
                entity.getName(),
                entity.getId(),
                sourceActivity.getId(),
                targetActivity.getId());
    }

    //回退的节点
    List<PvmActivity> backActivities = new ArrayList<>();
    //如果目标节点的Outgoing中有源节点,说明是回退需要删除对应的连线
    findActivity(targetActivity,
            activity -> activity
                    .getOutgoingTransitions()
                    .stream()
                    .map(PvmTransition::getDestination)
                    .collect(Collectors.toList()),
            activity -> sourceActivity.getId().equals(activity.getId()),
            backActivities::add);

    //回退
    if (!backActivities.isEmpty()) {
        for (PvmActivity pvmTransition : backActivities) {
            if (logger.isDebugEnabled()) {
                logger.debug("流程[{}({})]回退[{}]->[{}],删除链接线:{}",
                        entity.getName(),
                        entity.getId(),
                        sourceActivity.getId(),
                        targetActivity.getId(),
                        pvmTransition.getId());
            }
            //删除连线
            List<HistoricActivityInstance> instance = historyService
                    .createHistoricActivityInstanceQuery()
                    .processInstanceId(task.getProcessInstanceId())
                    .activityId(pvmTransition.getId())
                    .list();
            for (HistoricActivityInstance historicActivityInstance : instance) {
                sqlExecutor.delete("delete from act_hi_actinst where id_= #{id}", historicActivityInstance);
            }
        }
    }
    //执行回退命令
    TaskServiceImpl taskServiceImpl = (TaskServiceImpl) taskService;
    taskServiceImpl.getCommandExecutor().execute(new JumpTaskCmd(task.getExecutionId(), activityId));
    //设置候选人并回调
    selectNowTask(task.getProcessInstanceId())
            .forEach(t -> {
                //设置候选人
                setCandidate(task.getAssignee(), t);
                newTaskConsumer.accept(t);
            });

}
 
Example 19
Source File: BpmTaskServiceImpl.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
@Override
@SneakyThrows
public void reject(RejectTaskRequest request) {
    request.tryValidate();
    String taskId = request.getTaskId();
    Task curTask = selectTaskByTaskId(taskId);
    if (curTask == null) {
        throw new NotFoundException("任务不存在或未激活");
    }
    ProcessInstance processInstance = runtimeService
            .createProcessInstanceQuery()
            .processInstanceId(curTask.getProcessInstanceId())
            .singleResult();

    ProcessDefinitionEntity entity = (ProcessDefinitionEntity)
            ((RepositoryServiceImpl) repositoryService)
                    .getDeployedProcessDefinition(curTask.getProcessDefinitionId());

    ActivityImpl currActivity = entity.findActivity(curTask.getTaskDefinitionKey());

    List<PvmActivity> transitions = new ArrayList<>();
    //查找上一个环节
    findActivity(currActivity,
            activity ->
                    activity.getIncomingTransitions()
                            .stream()
                            .map(PvmTransition::getSource)
                            .collect(Collectors.toList()),
            activity -> transitions.isEmpty() && "userTask".equals(activity.getProperty("type")),
            transitions::add);

    if (!transitions.isEmpty()) {
        //跳转到上一环节
        PvmActivity transition = transitions.get(transitions.size() - 1);
        doJumpTask(curTask, transition.getId(), newTask -> {
        });
    } else {
        throw new BusinessException("无法获取上一步任务");
    }

    //记录日志
    ProcessHistoryEntity history = ProcessHistoryEntity.builder()
            .businessKey(processInstance.getBusinessKey())
            .type("reject")
            .typeText("驳回")
            .creatorId(request.getRejectUserId())
            .creatorName(request.getRejectUserName())
            .processDefineId(processInstance.getProcessDefinitionId())
            .processInstanceId(processInstance.getProcessInstanceId())
            .taskId(taskId)
            .taskDefineKey(curTask.getTaskDefinitionKey())
            .taskName(curTask.getName())
            .data(request.getData())
            .build();

    processHistoryService.insert(history);
}
 
Example 20
Source File: ActivitiKit.java    From my_curd with Apache License 2.0 2 votes vote down vote up
/**
 * 获得流程定义某节点
 *
 * @param processDefinitionId 流程定义id
 * @param activityId          任务节点id
 * @return
 */
public static ActivityImpl getActivity(String processDefinitionId, String activityId) {
    ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ActivitiKit.getRepositoryService().getProcessDefinition(processDefinitionId);
    return pde.findActivity(activityId);
}