Package org.fireflow.engine

Examples of org.fireflow.engine.IWorkItem


  /* (non-Javadoc)
   * @see org.fireflow.engine.IWorkflowSession#reassignWorkItemTo(java.lang.String, java.lang.String, java.lang.String)
   */
  public IWorkItem reassignWorkItemTo(String workItemId, String actorId,
      String comments) throws EngineException {
    IWorkItem workItem = this.findWorkItemById(workItemId);
    return workItem.reassignTo(actorId, comments);
  }
View Full Code Here


  /* (non-Javadoc)
   * @see org.fireflow.engine.IWorkflowSession#rejectWorkItem(java.lang.String)
   */
  public void rejectWorkItem(String workItemId) throws EngineException,
      KernelException {
    IWorkItem workItem = this.findWorkItemById(workItemId);
    workItem.reject();

  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.fireflow.engine.IWorkflowSession#rejectWorkItem(java.lang.String, java.lang.String)
   */
  public void rejectWorkItem(String workItemId, String comments)
      throws EngineException, KernelException {
    IWorkItem workItem = this.findWorkItemById(workItemId);
    workItem.reject(comments);
  }
View Full Code Here

  /* (non-Javadoc)
   * @see org.fireflow.engine.IWorkflowSession#withdrawWorkItem(java.lang.String)
   */
  public IWorkItem withdrawWorkItem(final String workItemId)
      throws EngineException, KernelException {
    IWorkItem wi = this.findWorkItemById(workItemId);
    return wi.withdraw();
  }
View Full Code Here

            "The current runtime context is null.");       
      }
 
     
        ITaskInstanceManager taskInstanceMgr = rtCtx.getTaskInstanceManager();
        IWorkItem newWorkItem = taskInstanceMgr.claimWorkItem(this.getId(),this.getTaskInstance().getId());
       
        if (newWorkItem!=null){
          this.state = newWorkItem.getState();
          this.claimedTime = newWorkItem.getClaimedTime();
         
          ((IRuntimeContextAware)newWorkItem).setRuntimeContext(rtCtx);
          ((IWorkflowSessionAware)newWorkItem).setCurrentWorkflowSession(this.workflowSession);
        }else{
          this.state = IWorkItem.CANCELED;
View Full Code Here

      String taskInstanceId) throws EngineException, KernelException {
    IPersistenceService persistenceService = rtCtx.getPersistenceService();

    persistenceService.lockTaskInstance(taskInstanceId);

    IWorkItem workItem = persistenceService.findWorkItemById(workItemId);

    if (workItem == null)
      return null;

    if (workItem.getState().intValue() != IWorkItem.INITIALIZED) {
      TaskInstance thisTaskInst = (TaskInstance) workItem
          .getTaskInstance();
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Claim work item failed. The state of the work item is "
              + workItem.getState());
    }
    if (workItem.getTaskInstance().getState().intValue() != ITaskInstance.INITIALIZED
        && workItem.getTaskInstance().getState().intValue() != ITaskInstance.RUNNING) {
      TaskInstance thisTaskInst = (TaskInstance) workItem
          .getTaskInstance();
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Claim work item failed .The state of the correspond task instance is "
              + workItem.getTaskInstance().getState());
    }

    if (workItem.getTaskInstance().isSuspended()) {
      TaskInstance thisTaskInst = (TaskInstance) workItem
          .getTaskInstance();
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Claim work item failed .The  correspond task instance is suspended");
    }

    // 0、首先修改workitem的状态
    ((WorkItem) workItem).setState(IWorkItem.RUNNING);
    ((WorkItem) workItem).setClaimedTime(rtCtx.getCalendarService()
        .getSysDate());
    persistenceService.saveOrUpdateWorkItem(workItem);

    // 1、如果不是会签,则删除其他的workitem
    if (FormTask.ANY.equals(workItem.getTaskInstance()
        .getAssignmentStrategy())) {
      persistenceService.deleteWorkItemsInInitializedState(workItem
          .getTaskInstance().getId());
    }

    // 2、将TaskInstance的canBeWithdrawn字段改称false。即不允许被撤销
    TaskInstance taskInstance = (TaskInstance) workItem.getTaskInstance();
    taskInstance.setCanBeWithdrawn(false);
    persistenceService.saveOrUpdateTaskInstance(taskInstance);

    return workItem;
View Full Code Here

          //如果是循环且LoopStrategy==REDO,则分配个上次完成该工作的操作员
            if (theLastCompletedTaskInstance!=null && (FormTask.REDO.equals(formTask.getLoopStrategy()) || currentSession.isInWithdrawOrRejectOperation())) {
              List<IWorkItem> workItemList = persistenceService.findCompletedWorkItemsForTaskInstance(theLastCompletedTaskInstance.getId());
              ITaskInstanceManager taskInstanceMgr = runtimeContext.getTaskInstanceManager();
                for (int k = 0; k < workItemList.size(); k++) {
                    IWorkItem completedWorkItem = workItemList.get(k);

                    IWorkItem newFromWorkItem = taskInstanceMgr.createWorkItem(currentSession,processInstance,taskInstance, completedWorkItem.getActorId());
                    newFromWorkItem.claim(); //并自动签收
                }
            } else {
                IBeanFactory beanFactory = runtimeContext.getBeanFactory();
                //从spring中获取到对应任务的Performer,创建工单
                IAssignmentHandler assignmentHandler = (IAssignmentHandler) beanFactory.getBean(part.getAssignmentHandler());
View Full Code Here

   */
  public void onTaskInstanceEventFired(TaskInstanceEvent e) throws EngineException {
    IWorkflowSession session = e.getWorkflowSession();
    IProcessInstance proceInst = e.getProcessInstance();
    ITaskInstance taskInst = (ITaskInstance)e.getSource();
    IWorkItem wi = e.getWorkItem();
    if (e.getEventType()==TaskInstanceEvent.BEFORE_TASK_INSTANCE_START){
      beforeTaskInstanceStart(session,proceInst,taskInst);
    }else if (e.getEventType()==TaskInstanceEvent.AFTER_TASK_INSTANCE_COMPLETE){
      afterTaskInstanceCompleted(session,proceInst,taskInst);
    }
View Full Code Here

        //如果不需要签收,这里自动进行签收,(FormTask的strategy="all"或者=any并且工作项数量为1)
        if (!needClaim){
          if (FormTask.ALL.equals(taskInst.getAssignmentStrategy()) ||
              (FormTask.ANY.equals(taskInst.getAssignmentStrategy()) && actorIdsList.size()==1)){
            for (int i=0;i<workItems.size();i++){
              IWorkItem wi = workItems.get(i);
              wi.claim();
            }
          }
        }
         
    }
View Full Code Here

     */
    @Test
    public void testSaveOrUpdateWorkItem() {
        System.out.println("--------saveOrUpdateWorkItem--------");

        IWorkItem workItem1 = (IWorkItem) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                WorkItem wi = new WorkItem();
                wi.setActorId(actorId);
                wi.setComments(comments);
                wi.setCreatedTime(createdTime);
                wi.setEndTime(endTime);
                wi.setClaimedTime(claimedTime);
                wi.setState(state);
                wi.setTaskInstance(taskInstance);

                persistenceService.saveOrUpdateWorkItem(wi);
                return wi;
            }
        });

        System.out.print("The new work item id = " + workItem1.getId());
        workItemId = workItem1.getId();
        IWorkItem workItem2 = persistenceService.findWorkItemById(workItem1.getId());

        assertFalse(workItem1.hashCode() == workItem2.hashCode());
        assertEquals(workItem1.getId(), workItem2.getId());
        assertEquals(workItem1.getTaskInstance().getId(), this.aliveTaskInstanceId);
        assertEquals(workItem2.getTaskInstance().getName(), name);
        assertEquals(workItem2.getTaskInstance().getDisplayName(), displayName);
        assertEquals(workItem2.getTaskInstance().getProcessId(), processId);
        assertEquals(dFormat.format(workItem2.getCreatedTime()), dFormat.format(createdTime));
        assertEquals(dFormat.format(workItem2.getClaimedTime()), dFormat.format(claimedTime));
        assertEquals(dFormat.format(workItem2.getEndTime()), dFormat.format(endTime));
        assertEquals(workItem2.getState(), state);
        assertEquals(workItem2.getActorId(), actorId);
        assertEquals(workItem2.getComments(), comments);
    }
View Full Code Here

TOP

Related Classes of org.fireflow.engine.IWorkItem

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.