Package com.starflow.wf.engine.model

Examples of com.starflow.wf.engine.model.ProcessInstance


      isStart = false;
    else if(Constants.ACT_ACTIVATE_RULE_LOGIC.equalsIgnoreCase(activityXml.getActivateRuleType())) {
      String beanName = activityXml.getStartStrategybyAppAction();
     
      try {
        ProcessInstance cloneProcessInstance = new ProcessInstance();
        BeanUtils.copyProperties(event.getProcessInstance(), cloneProcessInstance);
        ActivityInst cloneActivityInst = new ActivityInst();
        BeanUtils.copyProperties(activityInst, cloneActivityInst);
        isStart = executeActivateRule(beanName, cloneProcessInstance, cloneActivityInst);
      } catch (Exception e) {
View Full Code Here


*/
public class ProcessFinishListener extends AbstractProcessListener {
  @Override
  public void processEnd(ProcessFinishEvent event) {
    Date date = new Date();
    ProcessInstance processInstance = event.getProcessInstance();
    long processInstId = processInstance.getProcessInstId();
   
    event.getWorkItemRep().updateProcWorkItemStateAndFinalTime(processInstId, StarFlowState.WORKITEM_STOPPED, date);
    event.getActInstRep().updateProcActivityStateAndFinalTime(processInstId, StarFlowState.ACT_INST_STOPPED, date);
    event.getProcInstFacade().updateProcessStateAndEndTime(processInstId, StarFlowState.PROCESS_INST_COMPLETED, date);
   
    //执行流程完成filter
    for(ProcessFilter filter : event.getProcessEngine().getProcessFilters()) {
      filter.processComplete(event);
    }
   
    //流程完成后触发事件
    TriggerProcessEventUtil.afterComplete(event.getProcessEngine(), null, processInstance,
        event.getProcessXml().getEvents());
   
    //当前流程实例是否为子流程
    long actInstId = processInstance.getActivityInstId();
    if(actInstId != 0) {
      ProcessInstance mainProcess = event.getProcInstFacade().findProcessInstance(processInstance.getParentProcInstId());
      ActivityInst activityInst = event.getActInstRep().findActivityInst(actInstId);
      //异步子流程,不再需要发布结束事件
      if(StarFlowState.ACT_INST_RUNING == activityInst.getCurrentState()) {
        ActivityFinishEvent endEvent = new ActivityFinishEvent(event.getProcessEngine());
        endEvent.setProcessInstance(mainProcess);
View Full Code Here

*/
public class ProcessStartListener extends AbstractProcessListener {

  @Override
  public void processStart(ProcessStartEvent event) {
    ProcessInstance processInstance = event.getProcessInstance();
    ProcessEngine processEngine = event.getProcessEngine();
    ProcessElement processXml = event.getProcessXml();
   
    //设置流程实例为运行状态
    event.getProcInstFacade().updateProcessStateAndStartTime(processInstance.getProcessInstId(),
        StarFlowState.PROCESS_INST_RUNNING, new Date());
   
    //执行流程开始filter
    for(ProcessFilter filter : processEngine.getProcessFilters()) {
      filter.processStart(event);
View Full Code Here

public class ProcessTerminalListener extends AbstractProcessListener {
 
  @Override
  public void processTerminal(ProcessTerminalEvent event) {
    ProcessEngine processEngine = event.getProcessEngine();
    ProcessInstance processInstance = event.getProcessInstance();
    long processInstId = processInstance.getProcessInstId();
   
    Date finalTime = new Date();
    event.getWorkItemRep().updateProcWorkItemStateAndFinalTime(processInstId, StarFlowState.WORKITEM_STOPPED, finalTime);
    event.getActInstRep().updateProcActivityStateAndFinalTime(processInstId, StarFlowState.ACT_INST_STOPPED, finalTime);
    event.getProcInstFacade().updateProcessStateAndFinalTime(processInstId, StarFlowState.PROCESS_INST_STOPPED, finalTime);
View Full Code Here

    updateTransCtrlIsUse(event, event.getActivityXml());
    innerFinishAct(event, activityInst);
  }
 
  private static void startSubProcess(AbstractFlowEvent event, String subProcessDefName, String creator, long activityInstId) {
    ProcessInstance subProcInst = event.getProcessEngine().getProcessInstanceService().innerCreateSubProcess(subProcessDefName,
        creator, event.getProcessInstance().getProcessInstId(), activityInstId);
    event.getProcessEngine().getProcessInstanceService().startProcess(subProcInst.getProcessInstId());   
  }
View Full Code Here

   */
  private void innerFinishAct(ActivityStartEvent event, ActivityInst activityInst) {
    String type = activityInst.getActivityType();
    //发布【结束活动】结束事件
    if(Constants.ACT_TYPE_END.equalsIgnoreCase(type)) {
      ProcessInstance processInstance = event.getProcessInstance();
      EventUtil.publishActivityFinishEvent(event, processInstance, activityInst);
     
      //如果是子流程的,且响应父流程的子流程环节是同步执行,需要发布父流程的子流程环节的结束
      if(Constants.FLOW_IS_SUBFLOW.equals(processInstance.getSubFlow())) {
        ActivityInst pActivityInst = event.getActInstRep().findActivityInst(processInstance.getActivityInstId());
        if(pActivityInst.getCurrentState() == StarFlowState.ACT_INST_RUNING) {
          ProcessInstance pProcessInstance = event.getProcInstFacade().findProcessInstance(processInstance.getParentProcInstId());
          EventUtil.publishActivityFinishEvent(event, pProcessInstance, pActivityInst);
        }
      }
    } else if(Constants.ACT_TYPE_TOOLAPP.equalsIgnoreCase(type)) {
      //自动环节结束模式为:toolApp
View Full Code Here

* @version 1.0
*/
public class SingleWorkItemMode extends AbstractWorkItemMode {

  public List<WorkItem> createWorkItem(AbstractFlowEvent event, ActivityElement activityXml) {
    ProcessInstance procInst = ((ActivityCreateEvent)event).getProcessInstance();
    List<WorkItem> workItems = new ArrayList<WorkItem>();
   
    List<Participant> participants = getWIParticipants(event, activityXml);
   
    WorkItem workItem = new WorkItem();
    workItem.setWorkItemName(activityXml.getName());
    workItem.setWorkItemType(Constants.WORKITEM_MAN_TYPE);
    int currentState = this.getCurrentState(participants);
    workItem.setCurrentState(currentState);
    if(StarFlowState.WORKITEM_RUNNING == currentState)
      workItem.setParticipant(participants.get(0).getParticipant());
    workItem.setProcessInstId(procInst.getProcessInstId());
    workItem.setActivityDefId(activityXml.getId());
    workItem.setLimitTime(activityXml.getLimitTime());
    workItem.setStartTime(new Date());
   
    long workItemId = PrimaryKeyUtil.getPrimaryKey(Keys.WORKITEMID);
View Full Code Here

      this.beanName = beanName.trim();
    }

    @Override
    public Object execute(AbstractFlowEvent event, ActivityInst activityInst) {
      ProcessInstance cloneProcessInstance = new ProcessInstance();
      BeanUtils.copyProperties(event.getProcessInstance(), cloneProcessInstance);
      ActivityInst cloneActivityInst = new ActivityInst();
      BeanUtils.copyProperties(activityInst, cloneActivityInst);
     
      try {
View Full Code Here

public class MultiWorkItemMode extends AbstractWorkItemMode {

  public List<WorkItem> createWorkItem(AbstractFlowEvent event, ActivityElement activityXml) {
    String numStrategy = activityXml.getWorkitemNumStrategy();
    List<WorkItem> workItems = new ArrayList<WorkItem>();
    ProcessInstance procInst = ((ActivityCreateEvent)event).getProcessInstance();
    List<Participant> participants = null;
   
    //按参与者设置个数领取工作项
    if(Constants.ACT_WI_NUM_PARTICIPANT.equalsIgnoreCase(numStrategy)) {
      participants = getWIParticipants(event, activityXml);
    //按操作员个数分配工作项
    } else if(Constants.ACT_WI_NUM_OPERATOR.equalsIgnoreCase(numStrategy)){
      participants = getWIParticipantsExt(event, activityXml);
    }
   
    if(participants != null) {
      for(Participant participant : participants) {
        WorkItem workItem = new WorkItem();
        workItem.setWorkItemName(activityXml.getName());
        workItem.setWorkItemType(Constants.WORKITEM_MAN_TYPE);
        //设置工作项状态
        if(Constants.PARTICIPANT_TYPE_PERSON.equalsIgnoreCase(participant.getParticType())) {
          workItem.setCurrentState(StarFlowState.WORKITEM_RUNNING);
        } else {
          workItem.setCurrentState(StarFlowState.WORKITEM_WAITING_RECEIVE);
        }
       
        if(StarFlowState.WORKITEM_RUNNING == workItem.getCurrentState())
          workItem.setParticipant(participants.get(0).getParticipant());
       
        workItem.setProcessInstId(procInst.getProcessInstId());
        workItem.setActivityDefId(activityXml.getId());
        workItem.setLimitTime(activityXml.getLimitTime());
        workItem.setStartTime(new Date());
       
        long workItemId = PrimaryKeyUtil.getPrimaryKey(Keys.WORKITEMID);
View Full Code Here

    return this.getJdbcTemplate().queryForObject(findProcessInstanceSQL, new RowMapper<ProcessInstance>() {

      @Override
      public ProcessInstance mapRow(ResultSet resultSet, int index)
          throws SQLException {
        ProcessInstance processInstance = new ProcessInstance();
        processInstance.setProcessInstId(resultSet.getLong("processInstId"));
        processInstance.setProcessDefId(resultSet.getLong("processDefId"));
        processInstance.setProcessInstName(resultSet.getString("processInstName"));
        processInstance.setCreator(resultSet.getString("creator"));
        processInstance.setCreateTime(resultSet.getDate("createTime"));
        processInstance.setSubFlow(resultSet.getString("subFlow"));
        processInstance.setLimitNum(resultSet.getLong("limitNum"));
        processInstance.setCurrentState(resultSet.getInt("currentState"));
        processInstance.setParentProcInstId(resultSet.getLong("parentProcInstId"));
        processInstance.setActivityInstId(resultSet.getLong("activityInstId"));
        return processInstance;
      }
     
    }, processInstId);
  }
View Full Code Here

TOP

Related Classes of com.starflow.wf.engine.model.ProcessInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.