Package org.fireflow.engine

Examples of org.fireflow.engine.ITaskInstance


  /* (non-Javadoc)
   * @see org.fireflow.engine.IWorkflowSession#restoreTaskInstance(java.lang.String)
   */
  public ITaskInstance restoreTaskInstance(String taskInstanceId)
      throws EngineException {
    ITaskInstance taskInst = this.findTaskInstanceById(taskInstanceId);
    taskInst.restore();
    return taskInst;
  }
View Full Code Here


  /* (non-Javadoc)
   * @see org.fireflow.engine.IWorkflowSession#suspendTaskInstance(java.lang.String)
   */
  public ITaskInstance suspendTaskInstance(String taskInstanceId)
      throws EngineException {
    ITaskInstance taskInst = this.findTaskInstanceById(taskInstanceId);
    taskInst.suspend();
    return taskInst;
  }
View Full Code Here

    /* (non-Javadoc)
     * @see org.fireflow.engine.persistence.IPersistenceService#findAliveTaskInstanceById(java.lang.String)
     */
    public ITaskInstance findAliveTaskInstanceById(final String id) {
        ITaskInstance result = (ITaskInstance) this.getHibernateTemplate().execute(new HibernateCallback() {

            public Object doInHibernate(Session arg0) throws HibernateException, SQLException {
                Criteria criteria = arg0.createCriteria(TaskInstance.class);


View Full Code Here

    int createdTaskInstanceCount = 0;
    for (int i = 0; i < activity.getTasks().size(); i++) {
      Task task = activity.getTasks().get(i);
      // 1、创建Task实例,并设置工作流系统定义的属性
      ITaskInstance taskInstance = this.createTaskInstance(
          workflowSession, processInstance, task, activity);

      if (taskInstance == null) {
        continue;
      }
View Full Code Here

        ProcessInstanceEvent event = new ProcessInstanceEvent();
        event.setEventType(ProcessInstanceEvent.AFTER_PROCESS_INSTANCE_COMPLETE);
        event.setSource(this);
        this.fireProcessInstanceEvent(event);
        if (this.getParentTaskInstanceId() != null && !this.getParentTaskInstanceId().trim().equals("")) {
            ITaskInstance taskInstance = rtCtx.getPersistenceService().findAliveTaskInstanceById(this.getParentTaskInstanceId());
            ((IRuntimeContextAware) taskInstance).setRuntimeContext(rtCtx);
            ((IWorkflowSessionAware) taskInstance).setCurrentWorkflowSession(workflowSession);
            ((TaskInstance) taskInstance).complete(null);
        }
    }
View Full Code Here

        } else {

          IPersistenceService persistenceService = runtimeContext.getPersistenceService();
          //从数据库中查询任务信息
          List<ITaskInstance> taskInstanceList = persistenceService.findTaskInstancesForProcessInstance(taskInstance.getProcessInstanceId(), taskInstance.getActivityId());
          ITaskInstance theLastCompletedTaskInstance = null;

          for (int i=0;taskInstanceList!=null && i<taskInstanceList.size();i++){
            ITaskInstance tmp = taskInstanceList.get(i);
            if (tmp.getId().equals(taskInstance.getId()))continue;
                if (!tmp.getTaskId().equals(taskInstance.getTaskId()))continue;
                if (tmp.getState().intValue()!=ITaskInstance.COMPLETED)continue;
            if ( theLastCompletedTaskInstance==null){
              theLastCompletedTaskInstance = tmp;
            }else{
              if (theLastCompletedTaskInstance.getStepNumber().intValue()<tmp.getStepNumber().intValue()){
                theLastCompletedTaskInstance=tmp;
              }
            }
          }
View Full Code Here

   * @see org.fireflow.engine.event.ITaskInstanceEventListener#onTaskInstanceEventFired(org.fireflow.engine.event.TaskInstanceEvent)
   */
  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

                    taskInstance.getTaskId(),"actorIdsList can not be empty");
        }

        List<IWorkItem> workItems = asignable.assignToActors(actorIdsList);
       
        ITaskInstance taskInst = (ITaskInstance)asignable;
        //如果不需要签收,这里自动进行签收,(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 testSaveOrUpdateTaskInstance() {
        System.out.println("--------saveOrUpdateTaskInstance--------");

        ITaskInstance taskInstance1 = (ITaskInstance) transactionTemplate.execute(new TransactionCallback() {

            public Object doInTransaction(TransactionStatus arg0) {
                TaskInstance taskInstance = new TaskInstance();
                taskInstance.setActivityId(activityId);
                taskInstance.setAssignmentStrategy(assignmentStrategy);
                taskInstance.setCreatedTime(createdTime);
                taskInstance.setDisplayName(displayName);
                taskInstance.setEndTime(endTime);
                taskInstance.setExpiredTime(expiredTime);
                taskInstance.setName(name);
                taskInstance.setProcessId(processId);
                taskInstance.setProcessInstanceId(aliveProcessInstanceId);
                taskInstance.setStartedTime(startedTime);
                taskInstance.setState(state);
                taskInstance.setTargetActivityId(activityId);
                taskInstance.setTaskId(taskId);
                taskInstance.setTaskType(taskType);
                taskInstance.setVersion(version);
//                taskInstance.setTokenId(tokenId);
                persistenceService.saveOrUpdateTaskInstance(taskInstance);
                return taskInstance;
            }
        });

        System.out.println("The new task instance id  = " + taskInstance1.getId());
        aliveTaskInstanceId = taskInstance1.getId();
        ITaskInstance taskInstance2 = persistenceService.findTaskInstanceById(aliveTaskInstanceId);
        taskInstance = taskInstance2;

        assertFalse(taskInstance1.hashCode() == taskInstance2.hashCode());
        assertEquals(taskInstance1.getId(), taskInstance2.getId());
        assertEquals(taskInstance2.getName(), name);
        assertEquals(taskInstance2.getDisplayName(), displayName);
        assertEquals(taskInstance2.getProcessId(), processId);
        assertEquals(dFormat.format(taskInstance2.getCreatedTime()), dFormat.format(createdTime));
        assertEquals(dFormat.format(taskInstance2.getStartedTime()), dFormat.format(startedTime));
        assertEquals(dFormat.format(taskInstance2.getExpiredTime()), dFormat.format(expiredTime));
        assertEquals(dFormat.format(taskInstance2.getEndTime()), dFormat.format(endTime));
        assertEquals(taskInstance2.getState(), state);
        assertEquals(taskInstance2.getVersion(), version);
        assertEquals(taskInstance2.getActivityId(), activityId);
        assertEquals(taskInstance2.getAssignmentStrategy(), assignmentStrategy);
        assertEquals(taskInstance2.getProcessInstanceId(), aliveProcessInstanceId);
        assertEquals(taskInstance2.getTargetActivityId(), activityId);
        assertEquals(taskInstance2.getTaskId(), taskId);
        assertEquals(taskInstance2.getTaskType(), taskType);

    }
View Full Code Here

     * Test of findAliveTaskInstanceById method, of class PersistenceServiceHibernateImpl.
     */
    @Test
    public void testFindAliveTaskInstanceById() {
        System.out.println("--------findAliveTaskInstanceById--------");
        ITaskInstance taskInstance = persistenceService.findAliveTaskInstanceById(aliveTaskInstanceId);
        assertNotNull(taskInstance);
    }
View Full Code Here

TOP

Related Classes of org.fireflow.engine.ITaskInstance

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.