Пример #1
0
 @SuppressWarnings("unchecked")
 public UserCollectionVO getAllUsers() throws Exception {
   logger.debug("inside getAllUsers: in UserDAOImpl");
   UserCollectionVO allUsers = new UserCollectionVO();
   List<UserVO> usersList = null;
   usersList = getHibernateTemplate().find("from UserVO u  order by lastUpdatedDate desc");
   if (usersList != null) {
     allUsers.addAll(usersList);
   }
   return allUsers;
 }
Пример #2
0
 @SuppressWarnings("unchecked")
 public UserCollectionVO getUsersByPartialUserName(String partialUserName) throws Exception {
   logger.debug("inside getUsersByPartialUserName: in UserDAOImpl");
   UserCollectionVO users = new UserCollectionVO();
   List<UserVO> usersList =
       getHibernateTemplate()
           .find("from UserVO u where u.userName like '%" + partialUserName + "%'");
   if (usersList != null) {
     users.addAll(usersList);
   }
   return users;
 }
Пример #3
0
 @SuppressWarnings("unchecked")
 public UserCollectionVO getUsersByUserType(UserType type) throws Exception {
   logger.debug("inside getUsersByType: in UserDAOImpl");
   UserCollectionVO users = new UserCollectionVO();
   List<UserVO> usersList = null;
   usersList =
       getHibernateTemplate()
           .find(
               "from UserVO u where u.userType ="
                   + Integer.parseInt(type.ordinal() + "")
                   + " order by lastUpdatedDate");
   if (usersList != null) {
     users.addAll(usersList);
   }
   return users;
 }
Пример #4
0
 @SuppressWarnings("unchecked")
 public UserCollectionVO searchUsers(UserVO user) throws Exception {
   logger.debug("inside searchUsers: in UserDAOImpl");
   UserCollectionVO searchedUsers = new UserCollectionVO();
   List<UserVO> userList = null;
   Session session = null;
   try {
     session = getSession();
     Criteria criteria = session.createCriteria(UserVO.class, "user");
     if (StringUtils.isNotEmpty(user.getUserName())) {
       logger.debug("userName search");
       criteria.add(Restrictions.eq("userName", user.getUserName()));
     }
     if (StringUtils.isNotEmpty(user.getLastName())) {
       logger.debug("Last Name search");
       criteria.add(Restrictions.eq("lastName", user.getLastName()));
     }
     if (StringUtils.isNotEmpty(user.getFirstName())) {
       logger.debug("First Name search");
       criteria.add(Restrictions.eq("firstName", user.getFirstName()));
     }
     if (user.getUserType() != null) {
       logger.debug("User Type search");
       criteria.add(Restrictions.eq("userType", user.getUserType()));
     }
     if (user.getUserStatus() != null) {
       logger.debug("User Status search");
       criteria.add(Restrictions.eq("userStatus", user.getUserStatus()));
     }
     criteria.addOrder(Order.desc("lastUpdatedDate"));
     userList = criteria.list();
   } catch (Exception e) {
     logger.error(e.getMessage());
     // System.out.println(e.getMessage());
   } finally {
     session.flush();
     session.close();
   }
   if (userList != null) {
     logger.debug("userList.size()=" + userList.size());
     searchedUsers.addAll(userList);
   }
   return searchedUsers;
 }