Package org.huihoo.workflow.xpdl

Examples of org.huihoo.workflow.xpdl.WorkflowActivity


    log.debug(
      "[dispatch_subflow] workitem: " + workflowWork.getInfo() + " | transition: " + workflowTransition.getInfo());

    WorkflowCase workflowCase = workflowWork.getWorkflowCase();
    WorkflowPackage workflowPackage = workflowProcess.getWorkflowPackage();
    WorkflowActivity toActivity = workflowTransition.getToWorkflowActivity();

    //1) create org.huihoo.workflow work for subflow task node
    String parentDispWorkId = null;
    if (workflowWork instanceof WorkflowSubWork)
    {
      //performer is null
      WorkflowSubWork subWork = (WorkflowSubWork) workflowWork;
      parentDispWorkId =
        caseDatabase.createWorkflowSubWork(
          workflowProcess,
          operator,
          userTransaction,
          workflowCase,
          toActivity,
          subWork.getParentWorkflowWork(),
          null,
          subWork.getDispatchTime());
    }
    else
    {
      //performer is null
      parentDispWorkId =
        caseDatabase.createWorkflowWork(
          workflowProcess,
          operator,
          userTransaction,
          workflowCase,
          toActivity,
          null,
          workflowWork.getDispatchTime());
    }

    WorkflowWork parentDispWork =
      caseDatabase.findWorkflowWork(workflowProcess, operator, userTransaction, workflowCase, parentDispWorkId);
    caseDatabase.createWorkflowPath(
      workflowProcess,
      operator,
      userTransaction,
      workflowCase,
      workflowWork,
      parentDispWork,
      pathDispBatch,
      WorkflowActivityEvent.WORK_DISPATCH);

    //only accept ,not dispatch
    DispatchController.accept_core(
      workflowService,
      workflowProcess,
      operator,
      caseDatabase,
      userTransaction,
      parentDispWork);

    //2) create org.huihoo.workflow work for subflow process first task node
    SubFlowImplementation impl = (SubFlowImplementation) toActivity.getImplementation();
    String suPprocessId = impl.getProcessID();
    WorkflowProcess subProcess = workflowPackage.findWorkflowProcess(suPprocessId);
    WorkflowTransition firstTransition =
      (WorkflowTransition) subProcess.getBeginActivity().getOutgoingTransitions().get(0);
    WorkflowActivity firstActivity = firstTransition.getToWorkflowActivity();
    String childDispWorkId =
      caseDatabase.createWorkflowSubWork(
        workflowProcess,
        operator,
        userTransaction,
View Full Code Here


  {
    log.debug(
      "[dispatch_automation] workitem: " + workflowWork.getInfo() + " | transition: " + workflowTransition.getInfo());

    WorkflowCase workflowCase = workflowWork.getWorkflowCase();
    WorkflowActivity toActivity = workflowTransition.getToWorkflowActivity();
    String autoDispWorkId = null;
    if (workflowWork instanceof WorkflowSubWork)
    {
      //performer is null
      WorkflowSubWork subWork = (WorkflowSubWork) workflowWork;
View Full Code Here

    throws WorkflowException
  {
    log.debug(
      "[dispatch_manual] workitem: " + workflowWork.getInfo() + " | transition: " + workflowTransition.getInfo());

    WorkflowActivity workflowActivity = workflowTransition.getToWorkflowActivity();
    PerformerType performerType = workflowActivity.getPerformerType();
    WorkflowCase workflowCase = workflowWork.getWorkflowCase();
    WorkflowCaseContext caseContext = workflowCase.getCaseContext();

    UserDatabase userDatabase = workflowService.getUserDatabase();
View Full Code Here

    WorkflowWork workflowWork)
    throws WorkflowException
  {
    log.debug("[accept_core] workitem: " + workflowWork.getInfo());

    WorkflowActivity activity = workflowWork.getWorkflowActivity();
    WorkflowActivityEvent event = new WorkflowActivityEvent(workflowWork, WorkflowActivityEvent.WORK_ACCEPT);
    WorkflowActivityListener[] listeners = activity.getWorkflowActivityListeners();
    for (int i = 0; i < listeners.length; ++i)
    {
      listeners[i].beforeAccepted(event);
    }
    workflowWork.setAcceptTime(new java.util.Date());
    caseDatabase.updateWorkflowWork(workflowProcess, operator, userTransaction, workflowWork);
    Implementation impl = activity.getImplementation();

    WorkflowServiceBase context=(WorkflowServiceBase)workflowService;
    ClassLoader loader=context.getLoader().getClassLoader();
   
    impl.execute(workflowWork,loader);
View Full Code Here

    WorkflowWork workflowWork)
    throws WorkflowException, ScriptException
  {
    log.debug("[dispatch_core] workitem: " + workflowWork.getInfo());

    WorkflowActivity workflowActivity = workflowWork.getWorkflowActivity();
    WorkflowActivityEvent event = new WorkflowActivityEvent(workflowWork, WorkflowActivityEvent.WORK_DISPATCH);
    WorkflowActivityListener[] listeners = workflowActivity.getWorkflowActivityListeners();
    for (int i = 0; i < listeners.length; ++i)
    {
      listeners[i].beforeDispatched(event);
    }

    WorkflowCase workflowCase = workflowWork.getWorkflowCase();
    WorkflowPackage workflowPackage = workflowProcess.getWorkflowPackage();

    workflowWork.setDispatchTime(new java.util.Date());
    caseDatabase.updateWorkflowWork(workflowProcess, operator, userTransaction, workflowWork);

    //------------------------------------------------------------------------------------
    //------------------------------------------------------------------------------------
    WorkflowTransition customizedTransition = dispatch_revert(workflowService,workflowProcess,operator,caseDatabase,userTransaction,workflowWork);

    List filterTrans = null;

    if (customizedTransition == null)
    {
      filterTrans =
        OutTransitionFilter.filterOutTransition(workflowService,
          operator,
          caseDatabase,
          userTransaction,
          workflowWork);
    }
    else
    {
      filterTrans = new ArrayList();
      filterTrans.add(customizedTransition);
    }

    int sizeTrans = filterTrans.size();

    if (sizeTrans > 0)
    {
      WorkflowTransition transition = null;

      //-------------------------------------------------------------
      //   �������ɷ������Ĺ�����ʹ����ͬ���ɷ��Ǻ�
      //--------------------------------------------------------------
      String pathDispBatch = null;
      pathDispBatch =
        caseDatabase.getCaseIdGenerator().genWorkflowPathBatch(
          workflowPackage.getUUID(),
          workflowProcess.getUUID(),
          workflowActivity.getUUID(),
          workflowCase.getUUID());
     
      ParallelThread pThreads[] =new ParallelThread[sizeTrans];
      for (int i = 0; i < sizeTrans; ++i)
      {
        transition = (WorkflowTransition) filterTrans.get(i);

//        dispatch_control(workflowService,
//          workflowProcess,
//          operator,
//          caseDatabase,
//          userTransaction,
//          workflowWork,
//          transition,
//          pathDispBatch);

        pThreads[i]=new ParallelThread(workflowService,
          workflowProcess,
          operator,
          caseDatabase,
          userTransaction,
          workflowWork,
          transition,
          pathDispBatch);  
         
        pThreads[i].start();    
      }
     
      WorkflowException dispatch_exception = null;
      for (int i = 0; i < sizeTrans; ++i)
      {
        try
        {
          pThreads[i].join();
         
          if(pThreads[i].getException() != null)
          {
            dispatch_exception = pThreads[i].getException();
          }
        }
        catch(InterruptedException ex)
        {
          dispatch_exception = new WorkflowException("another thread has interrupted the ParallelThread");
        }
      }
     
      if(dispatch_exception != null)
      {
        throw dispatch_exception;
      }
    }
    else
    {
      // how I can do? just log it
      WorkflowContext context = workflowService.getWorkflowContext();
      String message =
        "---------BEGIN-------------Damn It ,Fatal Error----------------------\n"
          + "no available outgoing transition found. shXt, willow is powered by zosatapo (dertyang@hotmail.com) . \n"
          + "\t\t PackageID  = "
          + workflowPackage.getUUID()
          + "\n"
          + "\t\t ProcessID  = "
          + workflowProcess.getUUID()
          + "\n"
          + "\t\t ActivityID = "
          + workflowActivity.getUUID()
          + "\n"
          + "---------END-------------Damn It ,Fatal Error----------------------\n";
      context.log(message);
    }
View Full Code Here

    WorkflowWork workflowWork)
    throws WorkflowException
  {
    log.debug("[revert_core] workitem: " + workflowWork.getInfo());

    WorkflowActivity activity = workflowWork.getWorkflowActivity();
    WorkflowActivityEvent event = new WorkflowActivityEvent(workflowWork, WorkflowActivityEvent.WORK_REVERT);
    WorkflowActivityListener[] listeners = activity.getWorkflowActivityListeners();
    for (int i = 0; i < listeners.length; ++i)
    {
      listeners[i].beforeReverted(event);
    }

    if (!JoinType.JOIN_NA.equals(activity.getJoinType()))
    {
      throw new WorkflowException("WorkflowActivity JoinType not supported");
    }

    String strSQL =
      "SELECT vc_from,vc_batchNo FROM "
        + caseDatabase.getSchemaContext().getTableName(SchemaContext.SCHEMA_PATH)
        + "  "
        + "WHERE  vc_packageid=? "
        + "AND    vc_processid=? "
        + "AND    vc_caseid=?  "
        + "AND    vc_to=? ";

    Connection conn = (Connection) userTransaction.getStoreConnection().get();
    PreparedStatement pstmt = null;

    WorkflowCase workflowCase = workflowWork.getWorkflowCase();
    WorkflowPackage workflowPackage = workflowProcess.getWorkflowPackage();

    String fromWorkID = null;
    String batchNo = null;
    try
    {
      pstmt = conn.prepareStatement(strSQL);
      pstmt.setString(1, workflowPackage.getUUID());
      pstmt.setString(2, workflowProcess.getUUID());
      pstmt.setString(3, workflowCase.getUUID());
      pstmt.setString(4, workflowWork.getUUID());

      ResultSet rs = pstmt.executeQuery();
      if (rs.next())
      {
        fromWorkID = rs.getString("vc_from");
        batchNo = rs.getString("vc_batchNo");

        rs.close();
        pstmt.close();

        strSQL =
          "SELECT count(*) FROM "
            + caseDatabase.getSchemaContext().getTableName(SchemaContext.SCHEMA_PATH)
            + "  "
            + "WHERE  vc_packageid=? "
            + "AND    vc_processid=? "
            + "AND    vc_caseid=?  "
            + "AND    vc_from=? "
            + "AND    vc_batchNo=? ";
        pstmt = conn.prepareStatement(strSQL);
        pstmt.setString(1, workflowPackage.getUUID());
        pstmt.setString(2, workflowProcess.getUUID());
        pstmt.setString(3, workflowCase.getUUID());
        pstmt.setString(4, fromWorkID);
        pstmt.setString(5, batchNo);

        rs = pstmt.executeQuery();
        if (rs.next())
        {
          int count = rs.getInt(1);

          if (count > 1)
          {
            //ǰ�̻�ַ���Ψһ,���ܽ��л���
            throw new WorkflowException("WorkflowWork broadcast dispatch");
          }
        }
        else
        {
          //never to reach here
          throw new WorkflowException("WorkflowPath not found");
        }
      }
      else
      {
        throw new WorkflowException("WorkflowPath not found ");
      }
    }
    catch (SQLException ex)
    {
      throw new WorkflowException(ex);
    }
    finally
    {
      ConnUtils.cleanupNoThrow(pstmt);
    }

    WorkflowWork fromWork =
      caseDatabase.findWorkflowWork(
        workflowProcess,
        operator,
        userTransaction,
        workflowCase,
        fromWorkID);
    WorkflowParticipant participant = fromWork.getPerformer();

    String dispWorkId =
      caseDatabase.createWorkflowWork(
        workflowProcess,
        operator,
        userTransaction,
        workflowCase,
        activity,
        participant,
        workflowWork.getDispatchTime());
    String pathDispBatch =
      caseDatabase.getCaseIdGenerator().genWorkflowPathBatch(
        workflowPackage.getUUID(),
        workflowProcess.getUUID(),
        activity.getUUID(),
        workflowCase.getUUID());

    WorkflowWork dispWork =
      caseDatabase.findWorkflowWork(workflowProcess, operator, workflowCase, dispWorkId);
    caseDatabase.createWorkflowPath(
View Full Code Here

    WorkflowWork workflowWork)
    throws WorkflowException
  {
    log.debug("[fetch_core] workitem: " + workflowWork.getInfo());

    WorkflowActivity activity = workflowWork.getWorkflowActivity();
    WorkflowActivityEvent event = new WorkflowActivityEvent(workflowWork, WorkflowActivityEvent.WORK_FETCH);
    WorkflowActivityListener[] listeners = activity.getWorkflowActivityListeners();
    for (int i = 0; i < listeners.length; ++i)
    {
      listeners[i].beforeFetched(event);
    }
View Full Code Here

    SpiCaseDatabase caseDatabase,
    UserTransaction userTransaction,
    WorkflowWork workflowWork)
    throws WorkflowException
  {
    WorkflowActivity workflowActivity = workflowWork.getWorkflowActivity();
    WorkflowCase workflowCase = workflowWork.getWorkflowCase();
    WorkflowPackage workflowPackage = workflowProcess.getWorkflowPackage();

    WorkflowTransition rever_transition = null;
View Full Code Here

    throws WorkflowException, ScriptException
  {
    log.debug(
      "[dispatch_control] workitem: " + workflowWork.getInfo() + " | transition: " + workflowTransition.getInfo());
   
    WorkflowActivity fromActivity=workflowWork.getWorkflowActivity();   
    WorkflowActivity toActivity = workflowTransition.getToWorkflowActivity();
   
    Implementation impl = toActivity.getImplementation();
    if (impl instanceof SubFlowImplementation)
    {
      //-----------------------------------------------------------
      // ���������̴����߼�
      //-----------------------------------------------------------
      return DefaultActivityController.dispatch_subflow(workflowService,
        workflowProcess,
        operator,
        caseDatabase,
        userTransaction,
        workflowWork,
        workflowTransition,
        pathDispBatch);
    }

    WorkflowActivity ownerActivity = workflowWork.getWorkflowActivity();
    WorkflowProcess ownerProcess = ownerActivity.getWorkflowProcess();
    WorkflowActivity endActivity = ownerProcess.getEndActivity();
    if (endActivity.getUUID().equals(toActivity.getUUID()))
    {
      if (workflowWork instanceof WorkflowSubWork)
      {
        return DefaultActivityController.dispatch_r2p(workflowService,
          workflowProcess,
View Full Code Here

    WorkflowWork workflowWork)
    throws WorkflowException, ScriptException
  {
    log.debug("[execute_dispatchIfNecessary] workitem: " + workflowWork.getInfo());

    WorkflowActivity workActivity = workflowWork.getWorkflowActivity();
    Implementation impl = workActivity.getImplementation();
    if (impl instanceof SubFlowImplementation)
    {
      return accept_core(workflowService,workflowProcess, operator, caseDatabase, userTransaction, workflowWork)
        && dispatch_core(workflowService,workflowProcess, operator, caseDatabase, userTransaction, workflowWork);
    }

    PerformerType performerType = workActivity.getPerformerType();
    if (PerformerType.PERFORMER_AUTOMATION.equals(performerType))
    {
      return accept_core(workflowService,workflowProcess, operator, caseDatabase, userTransaction, workflowWork)
        && dispatch_core(workflowService,workflowProcess, operator, caseDatabase, userTransaction, workflowWork);
    }
View Full Code Here

TOP

Related Classes of org.huihoo.workflow.xpdl.WorkflowActivity

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.