Package org.huihoo.workflow

Examples of org.huihoo.workflow.WorkflowException


      return;
    }

    if (trueTransitions.size() == 0)
    {
      throw new WorkflowException("signalOrJoinActivity trueTransitions.size()==0 ");
    }

    log.debug(
      "\n"
        + "dispActivity==>"
        + dispActivity
        + "\ntrueTransitions==>"
        + trueTransitions
        + "\nfalseTransitions==>"
        + falseTransitions
        + "\n\n");

    WorkflowProcess workflowProcess = dispWork.getWorkflowCase().getWorkflowProcess();

    WorkflowActivity trueJoinActivity = null;
    WorkflowActivity falseJoinActivity = null;
    WorkflowActivity orJoinActivity = null;

    List swap_trueTransitions = null;
    List swap_falseTransitions = null;

    //-------------------------------------------------------------------
    //  1.���� TRUE ·��ѡ�񷽰� ����TRUE TOKEN ����·��
    //-------------------------------------------------------------------

    trueJoinActivity = ((WorkflowTransition) trueTransitions.get(0)).getToWorkflowActivity();
    swap_trueTransitions = trueTransitions;

    boolean forceLoopTrueJoinActivity = false;
    boolean forceLoopFalseJoinActivity = false;

    LoopTrueJoinActivity : while (
      forceLoopTrueJoinActivity
        || (trueJoinActivity != null && !JoinType.JOIN_OR.equals(trueJoinActivity.getJoinType())))
    {
      forceLoopTrueJoinActivity = false;
      orJoinActivity = null;
     
      //---------------------------------------------------------------------------
      //  1.1 ���� TRUE ·��ѡ�񷽰�, ����next Activity û�� ׷�ݵ�OR Join Activity
      //  [����XPDL End Activity]
      //---------------------------------------------------------------------------
      swap_trueTransitions = trueJoinActivity.getOutgoingTransitions();
      if (swap_trueTransitions == null || swap_trueTransitions.size() == 0)
      {
        throw new WorkflowException("signalOrJoinActivity : outgoingTransitions.size()==0," + trueJoinActivity);
      }

      //---------------------------------------------------------------------------
      //  1.2 ���� TRUE ·��ѡ�񷽰�, ����next Activity û�� ׷�ݵ�OR Join Activity
      //  [��������XPDL �߼�����]
      //---------------------------------------------------------------------------
      trueJoinActivity = nextPossibleActivityFinder(trueJoinActivity, swap_trueTransitions);
      if (trueJoinActivity == null)
      {
        throw new WorkflowException("nextPossibleActivityFinder : nextOrJoinActivity is null");
      }

      //---------------------------------------------------------------------------
      //  1.3 ���� TRUE ·��ѡ�񷽰�, ѡ���next Acitivity ���� OR Join Activity
      //---------------------------------------------------------------------------
      if (!JoinType.JOIN_OR.equals(trueJoinActivity.getJoinType()))
      {
        //find next possible trueJoinActivity
        continue LoopTrueJoinActivity;
      }

      //---------------------------------------------------------------------------
      //  1.4 ���� TRUE ·��ѡ�񷽰�, ������ OR Join Activity
      //---------------------------------------------------------------------------
      log.debug("FOUND TRUE OR-JOIN-ACTIVITY : " +  trueJoinActivity.getInfo());

      //-------------------------------------------------------------------
      //  2.���� FALSE ·��ѡ�񷽰� ����FALSE TOKEN ����·��
      //------------------------------------------------------------------- 
      //---------------------------------------------------------------------------
      //  2.1 ���� FALSE ·��ѡ�񷽰�, �ַ�Activity next ·��ȫ����ѡ��
      //---------------------------------------------------------------------------
      swap_falseTransitions = falseTransitions;
      if (swap_falseTransitions == null || swap_falseTransitions.size() == 0)
      {
        //----------------------------------------
        // [����]  �������Ϸ��� OR Join Activity
        //----------------------------------------
        //or-split's all outTransitions are selected to process
        orJoinActivity = trueJoinActivity;
        break LoopTrueJoinActivity;
      }

      falseJoinActivity = ((WorkflowTransition) swap_falseTransitions.get(0)).getToWorkflowActivity();
      if(JoinType.JOIN_OR.equals(falseJoinActivity.getJoinType()))
      {
        //һ��OR Split  Activity ֱ�Ӻ�� Activity �� JoinType ��Ӧ��Ϊ OR
        throw new WorkflowException("Bad Format XPDL Data : OR Split Activity's next direct Activity's JoinType should not be 'OR'  ");
      }
     
      LoopFalseJoinActivity : while (
        forceLoopFalseJoinActivity
          || (falseJoinActivity != null && !JoinType.JOIN_OR.equals(falseJoinActivity.getJoinType())))
      {
        forceLoopFalseJoinActivity =false;
       
        swap_falseTransitions = falseJoinActivity.getOutgoingTransitions();
        //---------------------------------------------------------------------------
        //  2.2 ���� FLASE ·��ѡ�񷽰�, ���� next Activity û�� ׷�ݵ� OR Join Activity
        //      [����XPDL End Activity]
        //---------------------------------------------------------------------------
        if (swap_falseTransitions == null || swap_falseTransitions.size() == 0)
        {
          break LoopFalseJoinActivity;
        }

        falseJoinActivity = nextPossibleActivityFinder(falseJoinActivity, swap_falseTransitions);

        //---------------------------------------------------------------------------
        //  2.3 ���� FLASE ·��ѡ�񷽰�, ����next Activity û�� ׷�ݵ� OR Join Activity
        //      [��������XPDL �߼�����]
        //---------------------------------------------------------------------------
        if (falseJoinActivity == null)
        {
          break LoopFalseJoinActivity;
        }
        //---------------------------------------------------------------------------
        //  2.4 ���� FALSE ·��ѡ�񷽰�, ѡ���next Acitivity ���� OR Join Activity
        //      [����]  �ƶ� FALSE TOKEN ��ѡ����һ�� OR Join Activity ���в���
        //---------------------------------------------------------------------------
        if (!JoinType.JOIN_OR.equals(falseJoinActivity.getJoinType()))
        {
          //find next possible falseJoinActivity
          continue LoopFalseJoinActivity;
        }

        //---------------------------------------------------------------------------
        //  2.5 ���� FALSE ·��ѡ�񷽰�, ������ OR Join Activity
        //---------------------------------------------------------------------------
        log.debug("FOUND FALSE OR-JOIN-ACTIVITY : " + falseJoinActivity.getInfo());


        if (falseJoinActivity.getUUID().equals(trueJoinActivity.getUUID()))
        {
          //---------------------------------------------------------------------------
          //  2.6.1 ���� TRUE/FALSE ·��ѡ�񷽰�, ������ �Ϸ��� OR Join Activity
          //         [����]  �������Ϸ��� OR Join Activity
          //---------------------------------------------------------------------------
         
          //OR-JOIN Activity found
          orJoinActivity = falseJoinActivity;
          break LoopTrueJoinActivity;
        }
        else
        {
          //---------------------------------------------------------------------------
          //  2.6.2 ���� TRUE/FALSE ·��ѡ�񷽰�, û�м����� �Ϸ��� OR Join Activity
          //         [����]  �ƶ� FALSE TOKEN ��ѡ����һ�� OR Join Activity ���в���
          //---------------------------------------------------------------------------
          forceLoopFalseJoinActivity=true;
          continue LoopFalseJoinActivity;
        }

      } //~end while (falseJoinActivity != null && !JoinType.JOIN_OR.equals(falseJoinActivity.getJoinType()))

      //---------------------------------------------------------------------------
      //  1.5 ���� TRUE/FALSE ·��ѡ�񷽰�, û�м����� OR Join Activity
      //      [����] �ƶ� TRUE TOKEN ��ѡ����һ�� OR Join Activity ���в���
      //---------------------------------------------------------------------------               
      //find next possible orJoinActivity
      forceLoopTrueJoinActivity = true;
      continue LoopTrueJoinActivity;

      //------------------------------------------------------------------------------       
    } //~end while (trueJoinActivity != null && !JoinType.JOIN_OR.equals(trueJoinActivity.getJoinType()))

    if (orJoinActivity == null)
    {
      throw new WorkflowException("signalOrJoinActivity : orJoinActivity not found");
    }

    log.debug("orJoinActivity : " + orJoinActivity.getInfo());

    Connection conn = (Connection) userTransaction.getStoreConnection().get();
View Full Code Here


          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)
      {
View Full Code Here

      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);
    }
View Full Code Here

        String toWorkID = rs.getString("vc_to");

        if (rs.next())
        {
          //��·�ַ���֧��ȡ�ز���
          throw new WorkflowException("WorkflowWork broadcast dispatch");
        }

        WorkflowWork toWork =
          caseDatabase.findWorkflowWork(
            workflowProcess,
            operator,
            userTransaction,
            workflowCase,
            rs.getString("vc_to"));
        caseDatabase.deleteWorkflowWork(workflowProcess, operator, userTransaction, toWork);

        workflowWork.setDispatchTime(null);
        caseDatabase.updateWorkflowWork(workflowProcess, operator, userTransaction, workflowWork);

      }
      else
      {
        //never to reach here
        throw new WorkflowException("WorkflowPath not found ");
      }
    }
    catch (SQLException ex)
    {
      throw new WorkflowException(ex);
    }
    finally
    {
      ConnUtils.cleanupNoThrow(pstmt);
    }
View Full Code Here

        // ���Ի��˴���Ĺ�����ǰ�̹��������Ψһ��
        // ͬʱǰ�̹������ֻ��Ψһ�ĺ�̹����� (�߼��ϵ�����,���ݽṹ)
        //----------------------------------------------------------------------------       
        if (rs.next())
        {
          throw new WorkflowException("Fatal WorkflowService Engine Error");
        }

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

        String vc_owner_processid = rs.getString("vc_owner_processid");
        if (vc_owner_processid != null && !"".equals(vc_owner_processid))
        {
          String vc_transitionid = rs.getString("vc_transitionid");
          WorkflowProcess owner_processid = workflowPackage.findWorkflowProcess(vc_owner_processid);
          rever_transition = owner_processid.findWorkflowTransition(vc_transitionid);
        }
        else
        {
          rever_transition =
            workflowProcess.findWorkflowTransition(
              workflowWork.getWorkflowActivity(),
              fromWork.getWorkflowActivity());
        }

        //�����ߴ����߼��������ڲ����ݽṹ�����й�ϵ
        workflowCase.getCaseContext().setPerformersByTransition(
          rever_transition,
          new WorkflowParticipant[] { fromWork.getPerformer()});
      }
    }
    catch (SQLException ex)
    {
      throw new WorkflowException(ex);
    }
    finally
    {
      ConnUtils.cleanupNoThrow(pstmt);
    }
View Full Code Here

    MonitorEventResult eventResult = monitorEvent.getResult();

    if (eventResult.getException() != null)
    {
      eventResult.getException().printStackTrace();
      throw new WorkflowException(eventResult.getException());
    }

    Connection conn = (Connection) userTransaction.getStoreConnection().get();
    PreparedStatement pstmt = null;
    String strSQL = null;
    WorkflowCase workflowCase = workflowWork.getWorkflowCase();
    WorkflowActivity dispActivity = workflowTransition.getFromWorkflowActivity();
    String disp_owner_process_id = dispActivity.getWorkflowProcess().getUUID();
    String disp_activity_id = dispActivity.getUUID();

    String packageId = workflowProcess.getWorkflowPackage().getUUID();
    String processId = workflowProcess.getUUID();
    String caseId = workflowCase.getUUID();

    log.debug("\norJoin monitorEvent == > "+monitorEvent);
   
    try
    {
      if (eventResult.getBatchNo() == 0)
      {
        strSQL =
          "INSERT INTO  "
            + caseDatabase.getSchemaContext().getTableName(SchemaContext.SCHEMA_ACTIVITY_DISPATCH)
            + "(vc_packageid,vc_processid,vc_caseid,vc_owner_processid,vc_activityid,int_batchNo) "
            + " VALUES(?,?,?,?,?,?)";
        pstmt = conn.prepareStatement(strSQL);
        pstmt.setString(1, packageId);
        pstmt.setString(2, processId);
        pstmt.setString(3, caseId);
        pstmt.setString(4, disp_owner_process_id);
        pstmt.setString(5, disp_activity_id);
        pstmt.setInt(6, eventResult.getBatchNo() + 1);
        pstmt.execute();

        ConnUtils.cleanupNoThrow(pstmt);
        pstmt = null;
      }
      else
      {
        strSQL =
          "UPDATE "
            + caseDatabase.getSchemaContext().getTableName(SchemaContext.SCHEMA_ACTIVITY_DISPATCH)
            + " "
            + "SET    int_batchNo=?,vc_disp_flag=?   "
            + "WHERE  vc_packageid=? "
            + "AND    vc_processid=? "
            + "AND    vc_caseid=?  "
            + "AND    vc_owner_processid=? "
            + "AND    vc_activityid=? ";
        pstmt = conn.prepareStatement(strSQL);
        pstmt.setInt(1, eventResult.getBatchNo() + 1);
        pstmt.setString(2, "TRUE");
        pstmt.setString(3, packageId);
        pstmt.setString(4, processId);
        pstmt.setString(5, caseId);
        pstmt.setString(6, disp_owner_process_id);
        pstmt.setString(7, disp_activity_id);
        ConnUtils.cleanupNoThrow(pstmt);
        pstmt = null;
      }
    }
    catch (SQLException ex)
    {
      throw new WorkflowException(ex);
    }
    finally
    {
      ConnUtils.cleanupNoThrow(pstmt);
      pstmt = null;
View Full Code Here

    MonitorEventResult eventResult = monitorEvent.getResult();

    if (eventResult.getException() != null)
    {
      throw new WorkflowException(eventResult.getException());
    }

    Connection conn = (Connection) userTransaction.getStoreConnection().get();
    PreparedStatement pstmt = null;
    String strSQL = null;
    WorkflowCase workflowCase = workflowWork.getWorkflowCase();
    WorkflowActivity dispActivity = workflowTransition.getFromWorkflowActivity();
    String disp_owner_process_id = dispActivity.getWorkflowProcess().getUUID();
    String disp_activity_id = dispActivity.getUUID();

    String packageId = workflowProcess.getWorkflowPackage().getUUID();
    String processId = workflowProcess.getUUID();
    String caseId = workflowCase.getUUID();
   
    log.debug("\ninstanceAndJoin monitorEvent == > "+monitorEvent);
   
    try
    {
      if (eventResult.getBatchNo() == 0)
      {
        strSQL =
          "INSERT INTO  "
            + caseDatabase.getSchemaContext().getTableName(SchemaContext.SCHEMA_ACTIVITY_DISPATCH)
            + "(vc_packageid,vc_processid,vc_caseid,vc_owner_processid,vc_activityid,int_batchNo) "
            + " VALUES(?,?,?,?,?,?)";
        pstmt = conn.prepareStatement(strSQL);
        pstmt.setString(1, packageId);
        pstmt.setString(2, processId);
        pstmt.setString(3, caseId);
        pstmt.setString(4, disp_owner_process_id);
        pstmt.setString(5, disp_activity_id);
        pstmt.setInt(6, eventResult.getBatchNo() + 1);
        pstmt.execute();

        ConnUtils.cleanupNoThrow(pstmt);
        pstmt = null;
      }
      else
      {
        strSQL =
          "UPDATE "
            + caseDatabase.getSchemaContext().getTableName(SchemaContext.SCHEMA_ACTIVITY_DISPATCH)
            + " "
            + "SET    int_batchNo=?,vc_disp_flag=?   "
            + "WHERE  vc_packageid=? "
            + "AND    vc_processid=? "
            + "AND    vc_caseid=?  "
            + "AND    vc_owner_processid=? "
            + "AND    vc_activityid=? ";
        pstmt = conn.prepareStatement(strSQL);
        pstmt.setInt(1, eventResult.getBatchNo() + 1);
        pstmt.setString(2, "TRUE");
        pstmt.setString(3, packageId);
        pstmt.setString(4, processId);
        pstmt.setString(5, caseId);
        pstmt.setString(6, disp_owner_process_id);
        pstmt.setString(7, disp_activity_id);
        ConnUtils.cleanupNoThrow(pstmt);
        pstmt = null;
      }
    }
    catch (SQLException ex)
    {
      throw new WorkflowException(ex);
    }
    finally
    {
      ConnUtils.cleanupNoThrow(pstmt);
      pstmt = null;
View Full Code Here

    MonitorEventResult eventResult = monitorEvent.getResult();

    if (eventResult.getException() != null)
    {
      throw new WorkflowException(eventResult.getException());
    }

    WorkflowCase workflowCase = workflowWork.getWorkflowCase();
    WorkflowActivity dispActivity = workflowTransition.getFromWorkflowActivity();
    String disp_owner_process_id = dispActivity.getWorkflowProcess().getUUID();
View Full Code Here

      {
        String processId = attribute.getValue();
        if (processId == null || processId.length() == 0)
        {
          errorList.add(
            new WorkflowException(
              "package attribute '"
                + XPDLGlobals.ID_PROCESS_MAIN
                + "' must be set.{packageID="
                + workflowPackage.getUUID()
                + "}"));
        }
      }
      else
      {
        errorList.add(
          new WorkflowException(
            "package attribute '"
              + XPDLGlobals.ID_PROCESS_MAIN
              + "' must be set.{packageID="
              + workflowPackage.getUUID()
              + "}"));
      }
    }

    //  ---------------------------------------------------------------
    //   2. validate workflowapplication qualified class name
    //  --------------------------------------------------------------- 
    List appList = workflowPackage.getWorkflowApplications();
    int app_size = appList.size();
    for (int i = 0; i < app_size; ++i)
    {
      WorkflowApplication app = (WorkflowApplication) appList.get(i);
      ExtendedAttribute attribute = app.findExtendedAttribute(XPDLGlobals.APPLICATION_QUALIFIED_CLASS_NAME);
      if (attribute != null)
      {
        String className = (String) attribute.getValue();
        if (className == null || className.length() == 0)
        {
          errorList.add(
            new WorkflowException(
              "application attribute '"
                + XPDLGlobals.APPLICATION_QUALIFIED_CLASS_NAME
                + "' must be set.{packageID="
                + workflowPackage.getUUID()
                + ",applicationID="
                + app.getUUID()
                + "}"));
        }
      }
      else
      {
        errorList.add(
          new WorkflowException(
            "application attribute '"
              + XPDLGlobals.APPLICATION_QUALIFIED_CLASS_NAME
              + "' must be set.{packageID="
              + workflowPackage.getUUID()
              + ",applicationID="
              + app.getUUID()
              + "}"));
      }
    }

    //  ---------------------------------------------------------------
    //   3. validate workflowprocess beginActivity and endActivity
    //  --------------------------------------------------------------- 
    for (int i = 0; i < process_size; ++i)
    {
      WorkflowProcess workflowProcess = (WorkflowProcess) processList.get(i);
      ExtendedAttribute attribute = workflowProcess.findExtendedAttribute(XPDLGlobals.ID_ACTIVITY_BEGIN);
      String activityId = null;

      if (attribute != null)
      {
        activityId = (String) attribute.getValue();
        if (activityId == null || activityId.length() == 0)
        {
          errorList.add(
            new WorkflowException(
              "process attribute '"
                + XPDLGlobals.ID_ACTIVITY_BEGIN
                + "' must be set.{packageID="
                + workflowPackage.getUUID()
                + ",processID="
                + workflowProcess.getUUID()
                + "}"));
        }
      }
      else
      {
        errorList.add(
          new WorkflowException(
            "process attribute '"
              + XPDLGlobals.ID_ACTIVITY_BEGIN
              + "' must be set.{packageID="
              + workflowPackage.getUUID()
              + ",processID="
              + workflowProcess.getUUID()
              + "}"));
      }

      attribute = (ExtendedAttribute) workflowProcess.findExtendedAttribute(XPDLGlobals.ID_ACTIVITY_END);
      if (attribute != null)
      {
        activityId = (String) attribute.getValue();
        if (activityId == null || activityId.length() == 0)
        {
          errorList.add(
            new WorkflowException(
              "process attribute '"
                + XPDLGlobals.ID_ACTIVITY_END
                + "' must be set.{packageID="
                + workflowPackage.getUUID()
                + ",processID="
                + workflowProcess.getUUID()
                + "}"));
        }
      }
      else
      {
        errorList.add(
          new WorkflowException(
            "process attribute '"
              + XPDLGlobals.ID_ACTIVITY_END
              + "' must be set.{packageID="
              + workflowPackage.getUUID()
              + ",processID="
              + workflowProcess.getUUID()
              + "}"));
      }
    }

    //  ---------------------------------------------------------------
    //   4. validate workflowActivity activity type
    //  --------------------------------------------------------------- 
    for (int i = 0; i < process_size; ++i)
    {
      WorkflowProcess workflowProcess = (WorkflowProcess) processList.get(i);
      List activies = workflowProcess.getWorkflowActivities();
      int activitySize = activies.size();

      for (int j = 0; j < activitySize; ++j)
      {
        WorkflowActivity activity = (WorkflowActivity) activies.get(j);
        ExtendedAttribute attribute = activity.findExtendedAttribute(XPDLGlobals.ACTIVITY_TYPE);
        if (attribute != null)
        {
          String activity_type = (String) attribute.getValue();
          if (activity_type == null || activity_type.length() == 0)
          {
            errorList.add(
              new WorkflowException(
                "activity attribute '"
                  + XPDLGlobals.ACTIVITY_TYPE
                  + "' must be set.{packageID="
                  + workflowPackage.getUUID()
                  + ",processID="
                  + workflowProcess.getUUID()
                  + ",activityID="
                  + activity.getUUID()
                  + "}"));
          }
        }
        else
        {
          errorList.add(
            new WorkflowException(
              "activity attribute '"
                + XPDLGlobals.ACTIVITY_TYPE
                + "' must be set.{packageID="
                + workflowPackage.getUUID()
                + ",processID="
                + workflowProcess.getUUID()
                + ",activityID="
                + activity.getUUID()
                + "}"));
        }
      }
    }

    //  ---------------------------------------------------------------
    //   5. validate workflowActivity performer type
    //  --------------------------------------------------------------- 
    for (int i = 0; i < process_size; ++i)
    {
      WorkflowProcess workflowProcess = (WorkflowProcess) processList.get(i);
      List activies = workflowProcess.getWorkflowActivities();
      int activitySize = activies.size();
      for (int j = 0; j < activitySize; ++j)
      {
        WorkflowActivity activity = (WorkflowActivity) activies.get(j);
        ExtendedAttribute attribute = activity.findExtendedAttribute(XPDLGlobals.ACTIVITY_TYPE);
        if (attribute != null)
        {
          if (!ActivityType.parse((String) attribute.getValue()).equals(ActivityType.ACTIVITY_BUSINESS))
          {
            continue;
          }
        }
        attribute = (ExtendedAttribute) activity.findExtendedAttribute(XPDLGlobals.PERFORMER_TYPE);
        if (attribute != null)
        {
          String performer_type = (String) attribute.getValue();
          if (performer_type == null || performer_type.length() == 0)
          {
            errorList.add(
              new WorkflowException(
                "activity attribute '"
                  + XPDLGlobals.PERFORMER_TYPE
                  + "' must be set.{packageID="
                  + workflowPackage.getUUID()
                  + ",processID="
                  + workflowProcess.getUUID()
                  + ",activityID="
                  + activity.getUUID()
                  + "}"));
          }
        }
        else
        {
          errorList.add(
            new WorkflowException(
              "activity attribute '"
                + XPDLGlobals.PERFORMER_TYPE
                + "' must be set.{packageID="
                + workflowPackage.getUUID()
                + ",processID="
                + workflowProcess.getUUID()
                + ",activityID="
                + activity.getUUID()
                + "}"));
        }
      }
    }

    //  ---------------------------------------------------------------
    //   6. validate workflowActivity Implementation referrence
    //  ---------------------------------------------------------------     
    for (int i = 0; i < process_size; ++i)
    {
      WorkflowProcess workflowProcess = (WorkflowProcess) processList.get(i);
      List activies = workflowProcess.getWorkflowActivities();
      int activitySize = activies.size();

      WorkflowActivity activity = null;
      Implementation impl = null;
      ToolImplementation toolImpl = null;
      ToolSet toolSet = null;
      SubFlowImplementation subFlowImpl = null;

      for (int j = 0; j < activitySize; ++j)
      {
        activity = (WorkflowActivity) activies.get(j);
        impl = activity.getImplementation();

        if (impl == null)
        {
          continue;
        }

        if ((impl instanceof ToolImplementation) && ActivityType.ACTIVITY_BUSINESS.equals(activity.getActivityType()))
        {
          toolImpl = (ToolImplementation) impl;
          String appId = toolImpl.getApplicationID();
          if ((appId == null) || (workflowPackage.findWorkflowApplication(appId) == null))
          {
            errorList.add(
              new WorkflowException(
                "Tool attribute 'Id' must be set.{packageID="
                  + workflowPackage.getUUID()
                  + ",processID="
                  + workflowProcess.getUUID()
                  + ",activityID="
                  + activity.getUUID()
                  + "}"));
          }
        }

        if ((impl instanceof ToolSet) && ActivityType.ACTIVITY_BUSINESS.equals(activity.getActivityType()))
        {
          toolSet = (ToolSet) impl;
          List toolImpls = toolSet.getToolKits();
          int toolImpls_size = toolImpls.size();

          for (int k = 0; k < toolImpls_size; ++k)
          {
            toolImpl = (ToolImplementation) toolImpls.get(k);
            String appId = toolImpl.getApplicationID();
            if ((appId == null) || (workflowPackage.findWorkflowApplication(appId) == null))
            {
              errorList.add(
                new WorkflowException(
                  "Tool attribute 'Id' must be set.{packageID="
                    + workflowPackage.getUUID()
                    + ",processID="
                    + workflowProcess.getUUID()
                    + ",activityID="
                    + activity.getUUID()
                    + "}"));
            }
          }
        }

        if ((impl instanceof SubFlowImplementation)
          && ActivityType.ACTIVITY_SUBFLOW.equals(activity.getActivityType()))
        {
          subFlowImpl = (SubFlowImplementation) impl;
          String processId = subFlowImpl.getProcessID();
          if ((processId == null) || (workflowPackage.findWorkflowProcess(processId) == null))
          {
            errorList.add(
              new WorkflowException(
                "SubFlow attribute 'Id' must be set.{packageID="
                  + workflowPackage.getUUID()
                  + ",processID="
                  + workflowProcess.getUUID()
                  + ",activityID="
                  + activity.getUUID()
                  + "}"));
          }
        }
      }
    }

    //  ---------------------------------------------------------------
    //   7. validate WorkflowTransition formActivity & toActivity
    //  ---------------------------------------------------------------     
    for (int i = 0; i < process_size; ++i)
    {
      WorkflowProcess workflowProcess = (WorkflowProcess) processList.get(i);
      List trans = workflowProcess.getWorkflowTransitions();
      int trans_size = trans.size();

      WorkflowTransition tran = null;

      for (int j = 0; j < trans_size; ++j)
      {
        tran = (WorkflowTransition) trans.get(j);
        if (tran.getFromWorkflowActivity() == null)
        {
          errorList.add(
            new WorkflowException(
              "Transition attribute 'From' must be set.{packageID="
                + workflowPackage.getUUID()
                + ",processID="
                + workflowProcess.getUUID()
                + ",transitionID="
                + tran.getUUID()
                + "}"));
        }

        if (tran.getToWorkflowActivity() == null)
        {
          errorList.add(
            new WorkflowException(
              "Transition attribute 'To' must be set.{packageID="
                + workflowPackage.getUUID()
                + ",processID="
                + workflowProcess.getUUID()
                + ",transitionID="
                + tran.getUUID()
                + "}"));
        }
      }
    }

    //  ---------------------------------------------------------------
    //   8. validate workflowActivity activity type match performer Type
    //  --------------------------------------------------------------- 
    for (int i = 0; i < process_size; ++i)
    {
      WorkflowProcess workflowProcess = (WorkflowProcess) processList.get(i);
      List activies = workflowProcess.getWorkflowActivities();
      int activitySize = activies.size();

      for (int j = 0; j < activitySize; ++j)
      {
        WorkflowActivity activity = (WorkflowActivity) activies.get(j);
        ExtendedAttribute attribute = activity.findExtendedAttribute(XPDLGlobals.ACTIVITY_TYPE);
        if (attribute != null)
        {
          if (ActivityType.parse((String) attribute.getValue()).equals(ActivityType.ACTIVITY_BUSINESS))
          {
            continue;
          }

          attribute = (ExtendedAttribute) activity.findExtendedAttribute(XPDLGlobals.PERFORMER_TYPE);
          if (attribute != null
            && !(PerformerType.parse(attribute.getValue()).equals(PerformerType.PERFORMER_AUTOMATION)))
          {
            errorList.add(
              new WorkflowException(
                "activity attribute '"
                  + XPDLGlobals.PERFORMER_TYPE
                  + "' and attribute '"
                  + XPDLGlobals.ACTIVITY_TYPE
                  + "' mismatched.{packageID="
View Full Code Here

        if (ActivityType.ACTIVITY_BUSINESS.equals(activity.getActivityType()))
        {
          if (impl != null && (impl instanceof SubFlowImplementation))
          {
            errorList.add(
              new WorkflowException(
                "ActivityType 'ACTIVITY_BUSINESS' Implementation can not be 'SubFlow'.{packageID="
                  + workflowPackage.getUUID()
                  + ",processID="
                  + workflowProcess.getUUID()
                  + ",activityID="
                  + activity.getUUID()
                  + "}"));
          }
        }

        if (ActivityType.ACTIVITY_SUBFLOW.equals(activity.getActivityType()))
        {
          if (impl != null && !(impl instanceof SubFlowImplementation))
          {
            errorList.add(
              new WorkflowException(
                "ActivityType 'ACTIVITY_SUBFLOW' Implementation must be 'SubFlow'.{packageID="
                  + workflowPackage.getUUID()
                  + ",processID="
                  + workflowProcess.getUUID()
                  + ",activityID="
                  + activity.getUUID()
                  + "}"));
          }
        }

        if (ActivityType.ACTIVITY_ROUTE.equals(activity.getActivityType()))
        {
          if (impl != null && !(impl instanceof NoImplementation))
          {
            errorList.add(
              new WorkflowException(
                "ActivityType 'ACTIVITY_ROUTE' Implementation must be 'No'.{packageID="
                  + workflowPackage.getUUID()
                  + ",processID="
                  + workflowProcess.getUUID()
                  + ",activityID="
View Full Code Here

TOP

Related Classes of org.huihoo.workflow.WorkflowException

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.