Exemplo n.º 1
0
  public HashMap getAllUsers(
      Filter filterUserId,
      int userTypeId,
      String parentTypeId,
      String sortBy,
      boolean ascending,
      int startIndex,
      int displayCount) {
    Criteria objCriteria = null;
    Session objSession = null;
    Integer totRecordCount = null;
    List objList = null;
    HashMap hmResult = new HashMap();
    try {
      logger.info("GETING ALL USERS");
      objSession = HibernateUtil.getSession();
      objCriteria = objSession.createCriteria(UsersVO.class);

      if (filterUserId != null) {
        objCriteria.add(
            Restrictions.like(
                filterUserId.getFieldName(),
                filterUserId.getFieldValue(),
                (MatchMode) HibernateUtil.htMatchCase.get(filterUserId.getSpecialFunction())));
      }

      if (userTypeId != 0) {
        objCriteria.add(Restrictions.eq("userTypes.userTypeId", new Integer(userTypeId)));
      }

      if (parentTypeId.length() > 0) {
        objCriteria.add(Restrictions.like("parentUser.userId", parentTypeId, MatchMode.EXACT));
      }

      totRecordCount = new Integer(objCriteria.list().size());
      if (ascending) {
        objCriteria.addOrder(Order.asc(sortBy));
      } else {
        objCriteria.addOrder(Order.desc(sortBy));
      }
      objCriteria.setFirstResult(startIndex);
      objCriteria.setMaxResults(displayCount);
      objList = objCriteria.list();
      hmResult.put("TotalRecordCount", totRecordCount);
      hmResult.put("Records", objList);
      logger.info("GOT ALL USERS");
    } catch (HibernateException e) {
      logger.error("HIBERNATE EXCEPTION DURING GET ALL USERS", e);
      e.printStackTrace();
    } finally {
      if (objSession != null) {
        objSession.close();
      }
    }
    return hmResult;
  }
Exemplo n.º 2
0
 public HashMap getAllRateCodes(
     Filter rateCode,
     Filter filtRateClass,
     int tdspId,
     String sortBy,
     boolean ascending,
     int startIndex,
     int displayCount) {
   /**
    * Requires - Modifies - Effects -
    *
    * @throws -
    */
   Criteria objCriteria = null;
   Session objSession = null;
   Integer totRecordCount = null;
   List objList = null;
   HashMap hmResult = new HashMap();
   try {
     logger.info("GETTING ALL RATE CODES");
     objSession = HibernateUtil.getSession();
     objCriteria = objSession.createCriteria(RateCodesVO.class);
     if (rateCode != null) {
       objCriteria.add(
           Restrictions.like(
               rateCode.getFieldName(),
               rateCode.getFieldValue(),
               (MatchMode) HibernateUtil.htMatchCase.get(rateCode.getSpecialFunction())));
     }
     if (filtRateClass != null) {
       objCriteria.add(
           Restrictions.like(
               filtRateClass.getFieldName(),
               filtRateClass.getFieldValue(),
               (MatchMode) HibernateUtil.htMatchCase.get(filtRateClass.getSpecialFunction())));
     }
     if (tdspId != 0) {
       objCriteria.add(Restrictions.eq("tdsp.tdspIdentifier", new Integer(tdspId)));
     }
     totRecordCount = new Integer(objCriteria.list().size());
     if (ascending) {
       objCriteria.addOrder(Order.asc(sortBy));
     } else {
       objCriteria.addOrder(Order.desc(sortBy));
     }
     objCriteria.setFirstResult(startIndex);
     objCriteria.setMaxResults(displayCount);
     objList = objCriteria.list();
     Iterator itr = objList.iterator();
     List resultList = new ArrayList();
     TDSPRateCodesDetails objTDSPRateCodesDetails = null;
     while (itr.hasNext()) {
       RateCodesVO objRateCodesVO = (RateCodesVO) itr.next();
       objTDSPRateCodesDetails = new TDSPRateCodesDetails();
       objTDSPRateCodesDetails.setRateCode(objRateCodesVO.getRateCode());
       objTDSPRateCodesDetails.setRateClass(objRateCodesVO.getRateClass());
       objTDSPRateCodesDetails.setDescription(objRateCodesVO.getDescription());
       TDSPRateCodesVO objTDSPRateCodesVO =
           (TDSPRateCodesVO)
               objSession.get(
                   TDSPRateCodesVO.class, new Integer(objRateCodesVO.getRateCodeIdentifier()));
       objTDSPRateCodesDetails.setMeterCategory(objTDSPRateCodesVO.getMeterCategory());
       objTDSPRateCodesDetails.setServiceVoltage(objTDSPRateCodesVO.getServiceVoltage());
       objTDSPRateCodesDetails.setScudPercentage(objTDSPRateCodesVO.getScudPercentage());
       resultList.add(objTDSPRateCodesDetails);
     }
     hmResult.put("TotalRecordCount", totRecordCount);
     hmResult.put("Records", resultList);
     logger.info("GOT ALL RATE CODES");
   } catch (HibernateException e) {
     logger.error("HIBERNATE EXCEPTION DURING GET ALL RATE CODES", e);
     e.printStackTrace();
   } finally {
     if (objSession != null) {
       objSession.close();
     }
   }
   return hmResult;
 }