Package com.starflow.wf.engine.model

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


    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);
    workItem.setWorkItemId(workItemId);
   
    for(Participant p : participants) {
      long particId = PrimaryKeyUtil.getPrimaryKey(Keys.PARTICIPANTID);
      p.setParticId(particId);
      p.setWorkItemId(workItemId);
    }
   
    workItem.setParticipants(participants);
    workItems.add(workItem);
    return workItems;
  }
View Full Code Here


      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);
        workItem.setWorkItemId(workItemId);
       
 
        long particId = PrimaryKeyUtil.getPrimaryKey(Keys.PARTICIPANTID);
        participant.setParticId(particId);
        participant.setWorkItemId(workItemId);
       
        List<Participant> list = new ArrayList<Participant>();
        list.add(participant);
        workItem.setParticipants(list);
        workItems.add(workItem);
      }
    }
   
    return workItems;
View Full Code Here

  }
 
  private static class WorkItemRowMapper implements RowMapper<WorkItem> {
    @Override
    public WorkItem mapRow(ResultSet resultSet, int index) throws SQLException {
      WorkItem workItem = new WorkItem();
      workItem.setActivityDefId(resultSet.getString("activityDefId"));
      workItem.setActivityInstId(resultSet.getLong("activityInstId"));
      workItem.setCurrentState(resultSet.getInt("currentState"));
      workItem.setEndTime(resultSet.getDate("endTime"));
      workItem.setFinalTime(resultSet.getDate("finalTime"));
      workItem.setLimitTime(resultSet.getLong("limitTime"));
      workItem.setParticipant(resultSet.getString("participant"));
      workItem.setProcessInstId(resultSet.getLong("processInstId"));
      workItem.setStartTime(resultSet.getDate("startTime"));
      workItem.setWorkItemId(resultSet.getLong("workItemId"));
      workItem.setWorkItemName(resultSet.getString("workItemName"));
      workItem.setWorkItemType(resultSet.getString("workItemType"));
      return workItem;
    }
View Full Code Here

 
  /* (non-Javadoc)
   * @see com.starflow.wf.engine.service.IWorkItemService#finishWorkItem(long, java.lang.String)
   */
  public void finishWorkItem(long workItemId, final String userId) {
    final WorkItem workItem = this.workItemRep.findWorkItem(workItemId);
    final ActivityInst activityInst = this.actInstRep.findActivityInst(workItem.getActivityInstId());
   
    //判断环节是否处于运行状态,才可完成该工作项
    if(StarFlowState.ACT_INST_RUNING != activityInst.getCurrentState())
      throw new ProcessEngineException("当前环节(activityInstId="+activityInst.getActivityInstId()+")不处于状态,"+
          "无法完成环节的运行!");
   
    //判断工作项是否处于待接收或运行状态,才可完成该工作项
    if(workItem.getCurrentState() != StarFlowState.WORKITEM_WAITING_RECEIVE &&
        workItem.getCurrentState() != StarFlowState.WORKITEM_RUNNING)
      throw new ProcessEngineException("当前工作项(workitemid="+workItemId+")不处于状态,"+
          "无法完成工作项的运行!");
   
    final ProcessInstance processInstance = this.procInstRep.findProcessInstance(workItem.getProcessInstId());
    final ProcessDefine processDefine = this.procDefRep.findProcessDefine(processInstance.getProcessDefId());
    final ActivityElement activityXml = processDefine.getProcessObject().getActivitys().get(activityInst.getActivityDefId());
   
    transactionTemplate.execute(new TransactionCallbackWithoutResult() {
      @Override
      protected void doInTransactionWithoutResult(TransactionStatus status) {
        workItemRep.updateWorkItemStateAndEndTime(workItem.getWorkItemId(), userId, StarFlowState.WORKITEM_COMPLETED, new Date());
       
        //发布环节结束事件
        ActivityFinishEvent endEvent = new ActivityFinishEvent(processEngine);
        endEvent.setProcessInstance(processInstance);
        endEvent.setActivityInst(activityInst);
View Full Code Here

TOP

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

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.