    public List<Badge> checkNewBadge(User user)
    {
        ArrayList<Badge> list= new ArrayList<Badge>();
        List<Integer> oldBadges = user.getBadges();
        List<Integer> newBadges = new ArrayList<Integer>();
        newBadges.addAll(oldBadges);
        List<Drink> myDrinks = DaoFactory.getInstance().getDrinkDao().findDrinksByIdUser(user.getIdUser(), null);
        if(!oldBadges.contains(BadgeEnum.DRINK_NUM_100.getIdBadge())) 
        {
            log.info("verifica numero bevute complessive");
            int countDrinksByUsername = myDrinks.size();
            if (!oldBadges.contains(BadgeEnum.DRINK_NUM_1.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_5.getIdBadge())  && countDrinksByUsername == BadgeEnum.DRINK_NUM_5.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_10.getIdBadge())  && countDrinksByUsername == BadgeEnum.DRINK_NUM_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_10);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_50.getIdBadge())  && countDrinksByUsername == BadgeEnum.DRINK_NUM_50.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_50);
            } else if ( countDrinksByUsername == BadgeEnum.DRINK_NUM_100.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_100);
            }
        }   
         if(!oldBadges.contains(BadgeEnum.DRINKER_PUB_25.getIdBadge()))
         {
             log.info("verifica numero bevute in pub: ");
             int count=0;
             for(Drink d: myDrinks)
             {
                 log.info("-- in pub: "+d.getIdPlace());
                 Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());
                 if(l.getCategories().contains(LocationCategoryDao.ID_PUB))
                 {
                     count++;
                 }
             }
             if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_1.getIdBadge())  && count == BadgeEnum.DRINKER_PUB_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_3.getIdBadge())  && count == BadgeEnum.DRINKER_PUB_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_5.getIdBadge())  && count == BadgeEnum.DRINKER_PUB_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_10.getIdBadge())  && count == BadgeEnum.DRINKER_PUB_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_10);
            } else if (count == BadgeEnum.DRINKER_PUB_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_25);
            }
         }
         if(!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_25.getIdBadge()))
         {
             log.info("verifica numero bevute in pzzeria");
             int count=0;
             for(Drink d: myDrinks)
             {
                 Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());
                 if(l.getCategories().contains(LocationCategoryDao.ID_PIZZA))
                 {
                     count++;
                 }
             }
             if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_1.getIdBadge())  && count == BadgeEnum.DRINKER_PIZZA_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_3.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_5.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_10.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_10);
            } else if (count == BadgeEnum.DRINKER_PIZZA_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_25);
            }
         }
         if(!oldBadges.contains(BadgeEnum.DRINKER_RISTO_25.getIdBadge()))
         {
             log.info("verifica numero bevute in ristorante");
             String name="Restaurant";
             int count=0;
             count = countDrinkWithLocationCategoryNameLike(myDrinks, name);
             if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_1.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_3.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_5.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_10.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_10);
            } else if (count == BadgeEnum.DRINKER_RISTO_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_25);
            }
         }
         if(!oldBadges.contains(BadgeEnum.DRINKER_BAR_25.getIdBadge()))
         {
             log.info("verifica numero bevute in bar");
             String name="Bar";
             int count=0;
             count = countDrinkWithLocationCategoryNameLike(myDrinks, name);
             if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_1.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_3.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_5.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_10.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_10);
            } else if (count == BadgeEnum.DRINKER_BAR_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_25);
            }
         }
          if(!oldBadges.contains(BadgeEnum.DRINKER_HOME_25.getIdBadge()))
         {
             log.info("verifica numero bevute a casa");
             int count=0;
             for(Drink d: myDrinks)
             {
                 Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());
                 if(l.getCategories().contains(LocationCategoryDao.ID_HOME))
                 {
                     count++;
                 }
             }
             if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_1.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_3.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_5.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_10.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_10);
            } else if ( count == BadgeEnum.DRINKER_HOME_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_25);
            }
         }
         if(!oldBadges.contains(BadgeEnum.DRINKER_SPORT_25.getIdBadge()))
         {
             log.info("verifica numero bevute in stadio");
             String name="Stadium";
             int count=0;
             count = countDrinkWithLocationCategoryNameLike(myDrinks, name);
             if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_1.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_3.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_5.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_10.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_10);
            } else if (count == BadgeEnum.DRINKER_SPORT_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_25);
            }
         }
         Calendar now = Calendar.getInstance();
         int h=now.get(Calendar.HOUR_OF_DAY);
         int m=now.get(Calendar.MINUTE);
         if(h>20 || h<6)
         {
             log.info("verifica numero bevute nella notte");
             Date startLimit=null;
             Date endLimit=null;
             if(h>20)
             {
             Calendar today20 = Calendar.getInstance();
             today20.set(Calendar.HOUR_OF_DAY, 20);
             today20.set(Calendar.MINUTE, 0);
             today20.set(Calendar.MILLISECOND, 0);
             Calendar today6 =Calendar.getInstance();
             today6.set(Calendar.HOUR_OF_DAY, 6);
             today6.set(Calendar.MINUTE, 0);
             today6.set(Calendar.MILLISECOND, 0);
             today6.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH)+1);
             startLimit=today20.getTime();
             endLimit=today6.getTime();
             }
             else if(h<6)
             {
             Calendar today20 = Calendar.getInstance();
             today20.set(Calendar.HOUR_OF_DAY, 20);
             today20.set(Calendar.MINUTE, 0);
             today20.set(Calendar.MILLISECOND, 0);
             Calendar today6 =Calendar.getInstance();
             today6.set(Calendar.HOUR_OF_DAY, 6);
             today6.set(Calendar.MINUTE, 0);
             today6.set(Calendar.MILLISECOND, 0);
             today20.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH)-1);
             startLimit=today20.getTime();
             endLimit=today6.getTime();
             }
             else
             {
                 log.error("vicolo cieco PUPPA!!");
             }
             int count=0;
             for(Drink d : myDrinks)
             {
                 if(d.getInsertedOn().after(startLimit) && d.getInsertedOn().before(endLimit))
                 {
                     count++;     
                 }
             }
             log.info("numero bevute di "+user.getUsername()+":"+count);
              if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_2.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_2.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_2);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_3.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_4.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_4.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_4);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_5.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_5);
            } else if (count == BadgeEnum.DRINK_NIGHT_10.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_10);
            }
         }
        user.setBadges(newBadges);
        user.setCounterBadges(newBadges.size());
        DaoFactory.getInstance().getUserDao().updateUser(user);
        return list;
    }

    public List<Badge> checkNewBadge(User user)
    {
        ArrayList<Badge> list= new ArrayList<Badge>();
        List<Integer> oldBadges = user.getBadges();
        List<Integer> newBadges = new ArrayList<Integer>();
        newBadges.addAll(oldBadges);
        List<Drink> myDrinks = DaoFactory.getInstance().getDrinkDao().findDrinksByIdUser(user.getIdUser(), null);
        if(!oldBadges.contains(BadgeEnum.DRINK_NUM_100.getIdBadge())) 
        {
            log.info("verifica numero bevute complessive");
            int countDrinksByUsername = myDrinks.size();
            if (!oldBadges.contains(BadgeEnum.DRINK_NUM_1.getIdBadge()) && countDrinksByUsername == BadgeEnum.DRINK_NUM_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_5.getIdBadge())  && countDrinksByUsername == BadgeEnum.DRINK_NUM_5.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_10.getIdBadge())  && countDrinksByUsername == BadgeEnum.DRINK_NUM_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_10);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NUM_50.getIdBadge())  && countDrinksByUsername == BadgeEnum.DRINK_NUM_50.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_50);
            } else if ( countDrinksByUsername == BadgeEnum.DRINK_NUM_100.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NUM_100);
            }
        }   
         if(!oldBadges.contains(BadgeEnum.DRINKER_PUB_25.getIdBadge()))
         {
             log.info("verifica numero bevute in pub: ");
             int count=0;
             for(Drink d: myDrinks)
             {
                 log.info("-- in pub: "+d.getIdPlace());
                 Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());
                 if(l.getCategories().contains(LocationCategoryDao.ID_PUB))
                 {
                     count++;
                 }
             }
             if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_1.getIdBadge())  && count == BadgeEnum.DRINKER_PUB_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_3.getIdBadge())  && count == BadgeEnum.DRINKER_PUB_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_5.getIdBadge())  && count == BadgeEnum.DRINKER_PUB_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PUB_10.getIdBadge())  && count == BadgeEnum.DRINKER_PUB_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_10);
            } else if (count == BadgeEnum.DRINKER_PUB_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PUB_25);
            }
         }
         if(!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_25.getIdBadge()))
         {
             log.info("verifica numero bevute in pzzeria");
             int count=0;
             for(Drink d: myDrinks)
             {
                 Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());
                 if(l.getCategories().contains(LocationCategoryDao.ID_PIZZA))
                 {
                     count++;
                 }
             }
             if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_1.getIdBadge())  && count == BadgeEnum.DRINKER_PIZZA_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_3.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_5.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_PIZZA_10.getIdBadge()) && count == BadgeEnum.DRINKER_PIZZA_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_10);
            } else if (count == BadgeEnum.DRINKER_PIZZA_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_PIZZA_25);
            }
         }
         if(!oldBadges.contains(BadgeEnum.DRINKER_RISTO_25.getIdBadge()))
         {
             log.info("verifica numero bevute in ristorante");
             String name="Restaurant";
             int count=0;
             count = countDrinkWithLocationCategoryNameLike(myDrinks, name);
             if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_1.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_3.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_5.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_RISTO_10.getIdBadge()) && count == BadgeEnum.DRINKER_RISTO_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_10);
            } else if (count == BadgeEnum.DRINKER_RISTO_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_RISTO_25);
            }
         }
         if(!oldBadges.contains(BadgeEnum.DRINKER_BAR_25.getIdBadge()))
         {
             log.info("verifica numero bevute in bar");
             String name="Bar";
             int count=0;
             count = countDrinkWithLocationCategoryNameLike(myDrinks, name);
             if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_1.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_3.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_5.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_BAR_10.getIdBadge()) && count == BadgeEnum.DRINKER_BAR_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_10);
            } else if (count == BadgeEnum.DRINKER_BAR_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_BAR_25);
            }
         }
          if(!oldBadges.contains(BadgeEnum.DRINKER_HOME_25.getIdBadge()))
         {
             log.info("verifica numero bevute a casa");
             int count=0;
             for(Drink d: myDrinks)
             {
                 Location l=DaoFactory.getInstance().getLocationDao().findByIdLocation(d.getIdPlace());
                 if(l.getCategories().contains(LocationCategoryDao.ID_HOME))
                 {
                     count++;
                 }
             }
             if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_1.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_3.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_5.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_HOME_10.getIdBadge()) && count == BadgeEnum.DRINKER_HOME_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_10);
            } else if ( count == BadgeEnum.DRINKER_HOME_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_HOME_25);
            }
         }
         if(!oldBadges.contains(BadgeEnum.DRINKER_SPORT_25.getIdBadge()))
         {
             log.info("verifica numero bevute in stadio");
             String name="Stadium";
             int count=0;
             count = countDrinkWithLocationCategoryNameLike(myDrinks, name);
             if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_1.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_1.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_1);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_3.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_5.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_5);
            } else if (!oldBadges.contains(BadgeEnum.DRINKER_SPORT_10.getIdBadge()) && count == BadgeEnum.DRINKER_SPORT_10.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_10);
            } else if (count == BadgeEnum.DRINKER_SPORT_25.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINKER_SPORT_25);
            }
         }
         Calendar now = Calendar.getInstance();
         int h=now.get(Calendar.HOUR_OF_DAY);
         int m=now.get(Calendar.MINUTE);
         if(h>20 || h<6)
         {
             log.info("verifica numero bevute nella notte");
             Date startLimit=null;
             Date endLimit=null;
             if(h>20)
             {
             Calendar today20 = Calendar.getInstance();
             today20.set(Calendar.HOUR_OF_DAY, 20);
             today20.set(Calendar.MINUTE, 0);
             today20.set(Calendar.MILLISECOND, 0);
             Calendar today6 =Calendar.getInstance();
             today6.set(Calendar.HOUR_OF_DAY, 6);
             today6.set(Calendar.MINUTE, 0);
             today6.set(Calendar.MILLISECOND, 0);
             today6.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH)+1);
             startLimit=today20.getTime();
             endLimit=today6.getTime();
             }
             else if(h<6)
             {
             Calendar today20 = Calendar.getInstance();
             today20.set(Calendar.HOUR_OF_DAY, 20);
             today20.set(Calendar.MINUTE, 0);
             today20.set(Calendar.MILLISECOND, 0);
             Calendar today6 =Calendar.getInstance();
             today6.set(Calendar.HOUR_OF_DAY, 6);
             today6.set(Calendar.MINUTE, 0);
             today6.set(Calendar.MILLISECOND, 0);
             today20.set(Calendar.DAY_OF_MONTH, now.get(Calendar.DAY_OF_MONTH)-1);
             startLimit=today20.getTime();
             endLimit=today6.getTime();
             }
             else
             {
                 log.error("vicolo cieco PUPPA!!");
             }
             int count=0;
             for(Drink d : myDrinks)
             {
                 if(d.getInsertedOn().after(startLimit) && d.getInsertedOn().before(endLimit))
                 {
                     count++;     
                 }
             }
             log.info("numero bevute di "+user.getUsername()+":"+count);
              if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_2.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_2.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_2);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_3.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_3.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_3);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_4.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_4.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_4);
            } else if (!oldBadges.contains(BadgeEnum.DRINK_NIGHT_5.getIdBadge()) && count == BadgeEnum.DRINK_NIGHT_5.getQuantity()) {
               updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_5);
            } else if (count == BadgeEnum.DRINK_NIGHT_10.getQuantity()) {
                updateListBadgeLocally(list, newBadges,BadgeEnum.DRINK_NIGHT_10);
            }
         }
        user.setBadges(newBadges);
        user.setCounterBadges(newBadges.size());
        DaoFactory.getInstance().getUserDao().updateUser(user);
        return list;
    }
