예제 #1
0
  @Override
  public void processStart(ProcessStartEvent event) {
    ProcessInstance processInstance = event.getProcessInstance();
    ProcessEngine processEngine = event.getProcessEngine();
    ProcessElement processElement = event.getProcessElement();

    // 设置流程实例为运行状态
    event
        .getProcInstFacade()
        .updateProcessStateAndStartTime(
            processInstance.getProcessInstId(), StarFlowState.PROCESS_INST_RUNNING, new Date());

    // 执行流程开始filter
    for (ProcessFilter filter : processEngine.getProcessFilters()) {
      filter.processStart(event);
    }

    // 流程启动后触发事件
    TriggerProcessEventUtil.afterStart(
        processEngine, null, processInstance, processElement.getEvents());

    StartActivityType type =
        (StartActivityType) ActivityTypeFactory.buildActivityType(Constants.ACT_TYPE_START);
    ActivityElement activityXml = processElement.getActivitys().get(StarFlowNames.ACT_START_ID);
    ActivityInst activityInst = type.createActivity(event, activityXml);

    EventUtil.publishActivityStartEvent(event, activityInst, activityXml);
  }
  @Override
  public void activityRestart(ActivityRestartEvent event) {
    // 环节实例状态更新为待激活状态。
    event
        .getActInstRep()
        .updateActivityStateToRunning(
            event.getActivityInst().getActivityInstId(),
            StarFlowState.ACT_INST_WAITING,
            new Date());

    if (!ActivityStartRuleUtil.isStartActivity(event, event.getActivityInst())) return;

    String type = event.getActivityXml().getType();
    if (Constants.ACT_TYPE_MANUL.equals(type)) setManualActParticipants(event);

    EventUtil.publishActivityStartEvent(
        event.getProcessEngine(),
        event.getProcessInstance(),
        event.getActivityInst(),
        event.getActivityXml());
  }