예제 #1
0
 public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
   UserRole tmpUserRole = (UserRole) baseObj;
   this.setID(TextUtility.formatIntegerObj(tmpUserRole.getID()));
   this.setRoleName(tmpUserRole.getRoleName());
   this.setRoleDesc(tmpUserRole.getRoleDesc());
   this.setRoleType(tmpUserRole.getRoleType());
   this.setRecordStatus(tmpUserRole.getRecordStatus());
   this.setUpdateCount(TextUtility.formatIntegerObj(tmpUserRole.getUpdateCount()));
   this.setCreatorID(TextUtility.formatIntegerObj(tmpUserRole.getCreatorID()));
   this.setCreateDate(formatTimestamp(tmpUserRole.getCreateDate()));
   this.setUpdaterID(TextUtility.formatIntegerObj(tmpUserRole.getUpdaterID()));
   this.setUpdateDate(formatTimestamp(tmpUserRole.getUpdateDate()));
 }
예제 #2
0
 public AbstractBaseObject getFormData() throws ApplicationException {
   UserRole tmpUserRole = new UserRole();
   tmpUserRole.setID(TextUtility.parseIntegerObj(this.getID()));
   tmpUserRole.setRoleName(this.getRoleName());
   tmpUserRole.setRoleDesc(this.getRoleDesc());
   tmpUserRole.setRoleType(this.getRoleType());
   tmpUserRole.setRecordStatus(this.getRecordStatus());
   tmpUserRole.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
   tmpUserRole.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
   tmpUserRole.setCreateDate(parseTimestamp(this.getCreateDate()));
   tmpUserRole.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
   tmpUserRole.setUpdateDate(parseTimestamp(this.getUpdateDate()));
   return tmpUserRole;
 }
예제 #3
0
  private boolean withinSubnet(String hostIP) {
    String[] keyArry = null;
    String[] hostArry = null;
    boolean flag = true;

    keyArry = com.dcivision.framework.TextUtility.splitString(Info.getIp(), ".");
    hostArry = com.dcivision.framework.TextUtility.splitString(hostIP, ".");

    for (int i = 0; i < 4; i++) {
      if (!(keyArry[i].equals(hostArry[i]) || keyArry[i].equals("*"))) {
        flag = false;
        break;
      }
    }

    return flag;
  }
  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;
  }
예제 #5
0
 public String getFunctionNameByLocale(java.util.Locale loc) {
   try {
     Class cls = this.getClass();
     String suffix = loc.toString().toLowerCase();
     String[] locStrAry = TextUtility.splitString(suffix, "_");
     suffix = "";
     for (int i = 0; i < locStrAry.length; i++) {
       suffix += Character.toUpperCase(locStrAry[i].charAt(0)) + locStrAry[i].substring(1);
     }
     Method mtd = cls.getMethod("getFunctionName" + suffix, null);
     String functionName = (String) mtd.invoke(this, null);
     return (functionName);
   } catch (Exception e) {
     return this.functionName;
   }
 }
  protected synchronized List getList(AbstractSearchForm searchForm) throws ApplicationException {
    PreparedStatement preStat = null;
    PreparedStatement preStatCnt = null;
    ResultSet rs = null;
    ResultSet rsCnt = null;
    StringBuffer sqlStat = new StringBuffer();
    StringBuffer sqlStatCnt = new StringBuffer();
    List result = new ArrayList();
    int totalNumOfRecord = 0;
    int rowLoopCnt = 0;
    int startOffset = TextUtility.parseInteger(searchForm.getCurStartRowNo());
    int pageSize = TextUtility.parseInteger(searchForm.getPageOffset());

    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 = ? ");

        // Form the WHERE clause for filtering.
        if (searchForm.isSearchable()) {
          String searchField = getSearchColumn(searchForm.getBasicSearchField());
          sqlStat.append("AND  " + searchField + " " + searchForm.getBasicSearchType() + " ? ");
        }

        // format the sql for any 'LIKE' statement contained
        sqlStat = this.getFormattedSQL(sqlStat.toString());

        // Form the ORDER clause for sorting.
        if (searchForm.isSortable()) {
          String sortAttribute = searchForm.getSortAttribute();
          if (sortAttribute.indexOf(".") < 0) {
            sortAttribute = "A." + sortAttribute;
          }
          sqlStat.append("ORDER BY " + sortAttribute + " " + searchForm.getSortOrder());
        }

        // Get total number of record return.
        sqlStatCnt = this.getSelectCountSQL(sqlStat);
        preStatCnt =
            dbConn.prepareStatement(
                sqlStatCnt.toString(),
                ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);
        this.setPrepareStatement(preStatCnt, 1, GlobalConstant.RECORD_STATUS_ACTIVE);
        if (searchForm.isSearchable()) {
          String searchKeyword =
              this.getFormattedKeyword(
                  searchForm.getBasicSearchKeyword(), searchForm.getBasicSearchType());
          this.setPrepareStatement(preStatCnt, 2, searchKeyword);
        }
        rsCnt = preStatCnt.executeQuery();
        if (rsCnt.next()) {
          totalNumOfRecord = rsCnt.getInt(1);
        }
        try {
          rsCnt.close();
        } catch (Exception ignore) {
        } finally {
          rsCnt = null;
        }
        try {
          preStatCnt.close();
        } catch (Exception ignore) {
        } finally {
          preStatCnt = null;
        }

        // Retrieve the result in row basis.
        sqlStat = this.getSelectListSQL(sqlStat, startOffset, pageSize);
        preStat =
            dbConn.prepareStatement(
                sqlStat.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
        this.setPrepareStatement(preStat, 1, GlobalConstant.RECORD_STATUS_ACTIVE);
        if (searchForm.isSearchable()) {
          String searchKeyword =
              this.getFormattedKeyword(
                  searchForm.getBasicSearchKeyword(), searchForm.getBasicSearchType());
          this.setPrepareStatement(preStat, 2, searchKeyword);
        }
        rs = preStat.executeQuery();

        this.positionCursor(rs, startOffset, pageSize);

        while (rs.next() && rowLoopCnt < pageSize) {
          MtmContactListObjectLink tmpMtmContactListObjectLink = new MtmContactListObjectLink();
          tmpMtmContactListObjectLink.setID(getResultSetInteger(rs, "ID"));
          tmpMtmContactListObjectLink.setContactListID(getResultSetInteger(rs, "CONTACT_LIST_ID"));
          tmpMtmContactListObjectLink.setObjectType(getResultSetString(rs, "OBJECT_TYPE"));
          tmpMtmContactListObjectLink.setObjectID(getResultSetInteger(rs, "OBJECT_ID"));
          tmpMtmContactListObjectLink.setRecordStatus(getResultSetString(rs, "RECORD_STATUS"));
          tmpMtmContactListObjectLink.setUpdateCount(getResultSetInteger(rs, "UPDATE_COUNT"));
          tmpMtmContactListObjectLink.setCreatorID(getResultSetInteger(rs, "CREATOR_ID"));
          tmpMtmContactListObjectLink.setCreateDate(getResultSetTimestamp(rs, "CREATE_DATE"));
          tmpMtmContactListObjectLink.setUpdaterID(getResultSetInteger(rs, "UPDATER_ID"));
          tmpMtmContactListObjectLink.setUpdateDate(getResultSetTimestamp(rs, "UPDATE_DATE"));
          tmpMtmContactListObjectLink.setCreatorName(
              UserInfoFactory.getUserFullName(tmpMtmContactListObjectLink.getCreatorID()));
          tmpMtmContactListObjectLink.setUpdaterName(
              UserInfoFactory.getUserFullName(tmpMtmContactListObjectLink.getUpdaterID()));
          tmpMtmContactListObjectLink.setRecordCount(totalNumOfRecord);
          tmpMtmContactListObjectLink.setRowNum(startOffset++);
          ++rowLoopCnt;
          result.add(tmpMtmContactListObjectLink);
        }
        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;
        }
        try {
          rsCnt.close();
        } catch (Exception ignore) {
        } finally {
          rsCnt = null;
        }
        try {
          preStatCnt.close();
        } catch (Exception ignore) {
        } finally {
          preStatCnt = null;
        }
      }
    }
  }
예제 #7
0
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws ServletException {
    MaintDmsRenameForm actionForm = (MaintDmsRenameForm) form;
    // DmsDocument document = (DmsDocument) actionForm.getFormData();
    SessionContainer sessionContainer = this.getSessionContainer(request);
    Connection conn = this.getConnection(request);

    DocumentRetrievalManager docRetrievalManager =
        new DocumentRetrievalManager(sessionContainer, conn);

    String opMode = actionForm.getOpMode();
    /*
     * joan.xiong update code for bug EIP-153 by 2006/09/19
     */
    //  DmsDocument document =
    // docRetrievalManager.getDocumentByID(TextUtility.parseIntegerObj(actionForm.getID()));
    DmsDocument document =
        (DmsDocument)
            new com.dcivision.dms.dao.DmsDocumentDAObject(sessionContainer, conn)
                .getDocumentByID(
                    TextUtility.parseIntegerObj(actionForm.getID()), actionForm.getRecordStatus());
    /*
     * joan.xiong update code end
     */
    String path =
        docRetrievalManager.getLocationPath(TextUtility.parseIntegerObj(actionForm.getParentID()));
    request.setAttribute("location", path);

    // Add By Jim Zhou       2007/0110       EIP-1292
    if (!"E".equals(document.getRecordStatus())) {
      MaintDmsDocumentForm documentForm = (MaintDmsDocumentForm) form;
      // Integer documentID = TextUtility.parseIntegerObj(documentForm.getID());
      // DmsDocument document = docRetrievalManager.getDocument(documentID);
      DocumentValidateManager docValidateManager =
          new DocumentValidateManager(sessionContainer, conn);
      StringBuffer message = new StringBuffer();

      DmsValidation validation = docValidateManager.validateOperateAction(document, false, "N");
      List lstIdMisRight = validation.getLstIdReject();
      List lstIdBeLocked = validation.getLstIdlocked();
      List lstIdBeDeleted = validation.getLstIdDeleted();
      List lstIdBeArchived = validation.getLstIdArchived();
      List lstIdRelationship = validation.getLstIdHaveRelationship();
      if (!lstIdMisRight.isEmpty()
          || !lstIdBeLocked.isEmpty()
          || !lstIdBeDeleted.isEmpty()
          || !lstIdBeArchived.isEmpty()) {
        for (int i = 0; i < lstIdMisRight.size(); i++) {
          // request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.no_permission",docRetrievalManager.getLocationPath((Integer)lstIdMisRight.get(i))));
          // addMessage(request,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.no_permission",docRetrievalManager.getLocationPath((Integer)lstIdMisRight.get(i))));
          message.append(
              MessageResourcesFactory.getMessage(
                      sessionContainer.getSessionLocale(),
                      "errors.dms.no_permission",
                      docRetrievalManager.getLocationPath((Integer) lstIdMisRight.get(i)))
                  + "\n");
        }
        for (int i = 0; i < lstIdBeLocked.size(); i++) {
          // request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_checkout",docRetrievalManager.getLocationPath((Integer)lstIdBeLocked.get(i))));
          // addMessage(request,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_checkout",docRetrievalManager.getLocationPath((Integer)lstIdBeLocked.get(i))));
          message.append(
              MessageResourcesFactory.getMessage(
                      sessionContainer.getSessionLocale(),
                      "errors.dms.been_checkout",
                      docRetrievalManager.getLocationPath((Integer) lstIdBeLocked.get(i)))
                  + "\n");
        }
        for (int i = 0; i < lstIdBeDeleted.size(); i++) {
          // request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_deleted",docRetrievalManager.getLocationPath((Integer)lstIdBeDeleted.get(i))));
          // addMessage(request,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_deleted",docRetrievalManager.getLocationPath((Integer)lstIdBeDeleted.get(i))));
          message.append(
              MessageResourcesFactory.getMessage(
                      sessionContainer.getSessionLocale(),
                      "errors.dms.been_deleted",
                      docRetrievalManager.getLocationPath((Integer) lstIdBeDeleted.get(i)))
                  + "\n");
        }
        for (int i = 0; i < lstIdBeArchived.size(); i++) {
          // request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_archived",docRetrievalManager.getLocationPath((Integer)lstIdBeArchived.get(i))));
          // addMessage(request,MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"errors.dms.been_archived",docRetrievalManager.getLocationPath((Integer)lstIdBeArchived.get(i))));
          message.append(
              MessageResourcesFactory.getMessage(
                      sessionContainer.getSessionLocale(),
                      "errors.dms.been_archived",
                      docRetrievalManager.getLocationPath((Integer) lstIdBeArchived.get(i)))
                  + "\n");
        }
        actionForm.setRefreshTag("1");
        addMessage(request, message.toString());
        actionForm.setDocumentName("");
        request.getSession().setAttribute(org.apache.struts.Globals.ERROR_KEY, message.toString());
        return mapping.findForward(GlobalConstant.NAV_MODE_EDIT);
      }
    }
    // Add End

    try {
      if (DmsOperationConstant.RENAME_OPERATION.equals(opMode)) {
        // Insert operation.
        log.debug("enter rename");

        if (!actionForm.getDocumentName().equals(document.getDocumentName())) {
          this.renameRecord(mapping, actionForm, request, response);
          this.commit(request);
          actionForm.setRefreshTag("1");
          addMessage(request, MESSAGE_RECORD_RENAME);
          actionForm.setDocumentName("");
          //
          // request.getSession().setAttribute(MESSAGE_RECORD_RENAME,MESSAGE_RECORD_RENAME);//joan.xiong add code for bug EIP-172 by 2006/10/12
          request
              .getSession()
              .setAttribute(org.apache.struts.Globals.MESSAGE_KEY, MESSAGE_RECORD_RENAME);
        }
      }
    } catch (ApplicationException appEx) {
      this.rollback(request);
      handleApplicationException(request, appEx);
      //      throw new ApplicationException(ErrorConstant.DB_UPDATE_ERROR);
    }
    return mapping.findForward(GlobalConstant.NAV_MODE_EDIT);
  }
예제 #8
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();
  }