예제 #1
0
 @Override
 public void deleteUserMeal(int id, int userId) throws UnexpectedErrorException {
   try {
     userMealDao.delete(id, userId);
   } catch (DAOException e) {
     throw new UnexpectedErrorException();
   }
 }
예제 #2
0
 @Override
 public UserMeal getUserMeal(int id, int userId)
     throws UnexpectedErrorException, NonExistsingUserMealException {
   try {
     UserMeal userMeal = userMealDao.get(id, userId);
     if (userMeal == null) {
       throw new NonExistsingUserMealException();
     }
     return userMeal;
   } catch (DAOException e) {
     throw new UnexpectedErrorException();
   }
 }
예제 #3
0
 @Override
 public UserMeal addUserMeal(String meal, int userId, String eatingTime)
     throws UnexpectedErrorException, InvalidMealException, InvalidDateException {
   try {
     Timestamp eatingTimestamp = this.convertToTimestamp(eatingTime);
     int mealId = Integer.parseInt(meal);
     mealService.getMealById(mealId);
     return userMealDao.add(mealId, userId, eatingTimestamp);
   } catch (NumberFormatException e) {
     throw new InvalidMealException();
   } catch (ParseException e) {
     throw new InvalidDateException();
   } catch (DAOException e) {
     throw new UnexpectedErrorException();
   }
 }