Exemplo n.º 1
0
 public void refreshUser() {
   if (logged) {
     user =
         (User)
             em.createNamedQuery(Constants.USER_LOGIN_QUERY)
                 .setParameter(Constants.USERNAME_PARAMETER, user.getLogin())
                 .setParameter(Constants.PASSWORD_PARAMETER, user.getPasswordHash())
                 .getSingleResult();
     logged = user != null;
   }
 }
 /**
  * Create query to retrieve shelves, that are shared or belongs to user, that perform search
  *
  * @param em - entityManager
  * @param params - map of additional params for this query
  * @param searchQuery - string to search
  * @return List of shelves that are shared or belongs to user, that perform search
  */
 public Query getQuery(EntityManager em, Map<String, Object> params, String searchQuery) {
   Query query =
       em.createQuery(Constants.SEARCH_SHELVES_QUERY + Constants.SEARCH_SHELF_BOTH_ADDON);
   query.setParameter(
       Constants.QUERY_PARAMETER,
       Constants.PERCENT + searchQuery.toLowerCase() + Constants.PERCENT);
   User user = (User) params.get(Constants.USER_PARAMETER);
   if (null == user) {
     return null;
   }
   query.setParameter(Constants.LOGIN_PARAMETER, user.getLogin());
   return query;
 }