/**
   * get object id list object type and contact list id.
   *
   * @param objectType
   * @param contactListID
   * @return
   * @throws ApplicationException
   */
  public synchronized List getObjectIDListByObjectTypeContactListID(
      String objectType, Integer contactListID) throws ApplicationException {
    PreparedStatement preStat = null;
    ResultSet rs = null;
    StringBuffer sqlStat = new StringBuffer();
    List result = new ArrayList();

    synchronized (dbConn) {
      try {
        sqlStat.append(
            "SELECT A.ID, A.CONTACT_LIST_ID, A.OBJECT_TYPE, A.OBJECT_ID, A.RECORD_STATUS, A.UPDATE_COUNT, A.CREATOR_ID, A.CREATE_DATE, A.UPDATER_ID, A.UPDATE_DATE ");
        sqlStat.append("FROM   MTM_CONTACT_LIST_OBJECT_LINK A ");
        sqlStat.append("WHERE  A.RECORD_STATUS = ? ");
        if (!Utility.isEmpty(objectType)) {
          sqlStat.append("AND A.OBJECT_TYPE = ? ");
        }
        if (!Utility.isEmpty(contactListID)) {
          sqlStat.append("AND A.CONTACT_LIST_ID = ? ");
        }
        preStat =
            dbConn.prepareStatement(
                sqlStat.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        this.setPrepareStatement(preStat, 1, GlobalConstant.RECORD_STATUS_ACTIVE);
        int i = 1;
        if (!Utility.isEmpty(objectType)) {
          this.setPrepareStatement(preStat, ++i, objectType);
        }
        if (!Utility.isEmpty(contactListID)) {
          this.setPrepareStatement(preStat, ++i, contactListID);
        }
        rs = preStat.executeQuery();
        while (rs.next()) {
          Integer objectID = getResultSetInteger(rs, "OBJECT_ID");
          result.add(objectID);
        }
        return (result);
      } catch (ApplicationException appEx) {
        throw appEx;
      } catch (SQLException sqle) {
        log.error(sqle, sqle);
        throw new ApplicationException(ErrorConstant.DB_GENERAL_ERROR, sqle, sqle.toString());
      } catch (Exception e) {
        log.error(e, e);
        throw new ApplicationException(ErrorConstant.DB_SELECT_ERROR, e);
      } finally {
        try {
          rs.close();
        } catch (Exception ignore) {
        } finally {
          rs = null;
        }
        try {
          preStat.close();
        } catch (Exception ignore) {
        } finally {
          preStat = null;
        }
      }
    }
  }
  public String[][] getNotifyTaskTypeByStepType(String setpActionType) {
    /*
     * String TRIGGER_TYPE_MAP[][] = { {"workflow.label.notify_task_is_arrived", MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_ARRIVED},
     * {"workflow.label.notify_task_is_pending", MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_PENDING_FOR}, {"workflow.label.notify_task_priority_changed",
     * MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_PRIORITY_CHANGED}, {"workflow.label.notify_task_is_check_out_by_user",
     * MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_CHECK_OUT_BY_USER}, {"workflow.label.notify_task_is_completed_by_user",
     * MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_COMPLETED_BY_USER}, {"workflow.label.notify_task_is_completed",
     * MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_COMPLETED}, {"workflow.label.notify_task_is_stoped",
     * MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_STOPPED}, {"workflow.label.before_task_due_date",
     * MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_BEFORE_DUE_DATE}, {"workflow.label.notify_task_is_overdue",
     * MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_OVER_DUE_DATE} };
     */

    String tiggerType[][] = null;
    int branchCount = 0;
    if (WorkflowStep.ACTION_TYPE_APPROVAL.equals(setpActionType)) {
      tiggerType = new String[11][2];
      setStandNotifyType(tiggerType);

      tiggerType[9][0] = "workflow.label.notify_task_is_approved";
      tiggerType[9][1] = MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_APPROVED;
      tiggerType[10][0] = "workflow.label.notify_task_is_reject";
      tiggerType[10][1] = MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_REJECT;

    } else if (WorkflowStep.ACTION_TYPE_BOOLEAN.equals(setpActionType)) {
      tiggerType = new String[11][2];
      setStandNotifyType(tiggerType);

      tiggerType[9][0] = "workflow.label.notify_task_is_yes";
      tiggerType[9][1] = MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_YES;
      tiggerType[10][0] = "workflow.label.notify_task_is_no";
      tiggerType[10][1] = MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_NO;

    } else if (!Utility.isEmpty(setpActionType) && setpActionType.length() > 1) {
      String[] routeArr = TextUtility.splitString(setpActionType, "|");
      if (Utility.isEmpty(routeArr)) {
        tiggerType = new String[9][2];
        setStandNotifyType(tiggerType);
      } else {
        tiggerType = new String[9 + routeArr.length][2];
        setStandNotifyType(tiggerType);

        for (int i = 0; i < routeArr.length; i++) {
          tiggerType[9 + i][0] = "workflow.label.notify_task_is_decision";
          tiggerType[9 + i][1] = MtmWfStepNotificationRule.NOTIFY_TRIGGER_TYPE_DECISION + i;
        }
      }
      //      tiggerType = new String[branchCount + 9][2];
      //      setStandNotifyType(tiggerType);

    } else {
      tiggerType = new String[9][2];
      setStandNotifyType(tiggerType);
    }

    return tiggerType;
  }
Exemplo n.º 3
0
  /**
   * getLocaleByString
   *
   * <p>Convert a string representation to a locale object.
   *
   * @param str String representation of that Locale
   * @return Locale after translation
   */
  public static java.util.Locale getLocaleByString(String str) {
    if (Utility.isEmpty(str)) {
      return (null);
    }

    String[] ary = TextUtility.splitString(str, "_");

    if (ary.length == 0) {
      return (null);
    } else if (ary.length == 1) {
      return (new java.util.Locale(ary[0]));
    } else if (ary.length == 2) {
      return (new java.util.Locale(ary[0], ary[1]));
    } else if (ary.length == 3) {
      return (new java.util.Locale(ary[0], ary[1], ary[2]));
    } else {
      return (null);
    }

    /*
       if (str != null && "en_US".equals(str.trim())) {
         return(new java.util.Locale("en", "US"));
       } else if (str != null && "zh_HK".equals(str.trim())) {
         return(new java.util.Locale("zh", "HK"));
       } else if (str != null && "zh_CN".equals(str.trim())) {
         return(new java.util.Locale("zh", "CN"));
       } else {
         return(new java.util.Locale("en", "US"));
       }
    */
  }
Exemplo n.º 4
0
 /**
  * @param stringArray A String Array
  * @param logic The value is "AND" or "OR"
  * @return the String /
  */
 public static String genericLogicSql(String[] stringArray, String logic) {
   String returnTo = null;
   if (!Utility.isEmpty(stringArray)) {
     int count = 0;
     for (int i = 0; i < stringArray.length; i++) {
       if (count == 0) {
         returnTo = stringArray[i];
       } else {
         returnTo = returnTo + " " + logic + " " + stringArray[i];
       }
       count = 1;
     }
   }
   return returnTo;
 }
Exemplo n.º 5
0
  /**
   * Call this function to parse the dateString into System Date format
   *
   * @param dateString The date value string
   * @param dateFormat
   * @param min
   * @param sec
   * @param milliSec
   */
  public static java.sql.Timestamp parseDateStringToSystemDate(
      String dateString, String dateFormat) {
    java.sql.Timestamp tmp = null;
    ;
    // Initial system date parameter
    String localeStr = SystemParameterFactory.getSystemParameter(SystemParameterConstant.LOCALE);
    SimpleDateFormat df = new SimpleDateFormat(dateFormat);
    if (!Utility.isEmpty(localeStr)) {
      Locale locale = getLocaleByString(localeStr);
      df = new SimpleDateFormat(dateFormat, locale);
    }

    try {
      Date inDate = df.parse(dateString);
      Calendar calendar = Calendar.getInstance();
      calendar.setTime(inDate);

      tmp = calendarToTimestamp(calendar);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return tmp;
  }
Exemplo n.º 6
0
  public void renameRecord(
      ActionMapping mapping,
      AbstractActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws ApplicationException {
    SessionContainer sessionContainer = this.getSessionContainer(request);
    Connection conn = this.getConnection(request);
    DocumentOperationManager docOperationManager =
        new DocumentOperationManager(sessionContainer, conn);
    DocumentRetrievalManager documentRetrievalManager =
        new DocumentRetrievalManager(sessionContainer, conn);

    MaintDmsRenameForm documentForm = (MaintDmsRenameForm) form;

    // set the docDetailList and userDefinedFieldID
    DmsDocumentDetailDAObject dmsDocumentDetailDAObj =
        new DmsDocumentDetailDAObject(sessionContainer, conn);
    Integer documentID = TextUtility.parseIntegerObj(documentForm.getID());
    /*
     * joan.xiong update code for bug EIP-153 by 2006/09/19
     */
    //  DmsDocument document = documentRetrievalManager.getDocumentByID(documentID);
    DmsDocument document =
        (DmsDocument)
            new com.dcivision.dms.dao.DmsDocumentDAObject(sessionContainer, conn)
                .getDocumentByID(documentID, documentForm.getRecordStatus());
    /*
     * joan.xiong update code end
     */
    // Add By Jim.Zhou
    DmsDocument dmsDocument = documentRetrievalManager.getMyFavoriteObject();
    // Add End
    /*
     * Update Code Start
     * Author	Jim.Zhou
     * Date		2006/03/29
     */
    /*
    if ("My Favorite".equals(document.getDocumentName())){
    	throw new ApplicationException(DmsErrorConstant.DMS_MESSAGE_UNABLE_RENAME_MYFAVORIT,null);
    } else {
    	document.setDocumentName(documentForm.getDocumentName());
    }
     */
    // Add By Jim.Zhou		2006/07/14		Bug #5006
    if (dmsDocument.getID().equals(document.getID())) {
      // this.addError(request,DmsErrorConstant.DMS_MESSAGE_UNABLE_DELETE_MYFAVORITE);
      // continue;
      throw new ApplicationException(DmsErrorConstant.DMS_MESSAGE_UNABLE_RENAME_MYFAVORIT, null);
    }
    // Add End
    /*
     * Update Code End
     */

    document.setDocumentName(documentForm.getDocumentName());

    List docDetailList = dmsDocumentDetailDAObj.getListByDocumentID(documentID);
    if (!Utility.isEmpty(docDetailList)) {
      DmsDocumentDetail tmpDmsDocumentDetail = (DmsDocumentDetail) docDetailList.get(0);
      Integer userDefinedFieldID = tmpDmsDocumentDetail.getUserDefinedFieldID();
      document.setDocumentDetails(docDetailList);
      document.setUserDefinedFieldID(userDefinedFieldID);
    }

    if (Utility.isEmpty(documentForm.getDocumentName())
        || "".equals(documentForm.getDocumentName().trim())) {
      if (DmsDocument.FOLDER_TYPE.equals(documentForm.getDocumentType())) {
        throw new EmptyContentException(DmsErrorConstant.EMPTY_FOLDER_NAME);
      } else {
        throw new EmptyContentException(DmsErrorConstant.EMPTY_DOCUMENT_NAME);
      }
    }
    DmsDocument newDocument = docOperationManager.renameRecord(document);
    documentForm.setFormData(newDocument);

    sessionContainer = null;
    conn = null;
    docOperationManager.release();
  }