예제 #1
0
 @Override
 public NotificationEntity getFreshNotification(String userId) {
   NotificationEntity notificationEntity =
       notificationRepository.getFreshNotificationForUser(
           userId, NotificationType.FRESH.toString());
   return notificationEntity;
 }
예제 #2
0
  @Override
  public void moveNotification(String userId) {

    NotificationEntity freshNotificationEntity =
        notificationRepository.getFreshNotificationForUser(
            userId, NotificationType.FRESH.toString());
    NotificationEntity pastNotificationEntity =
        notificationRepository.getFreshNotificationForUser(
            userId, NotificationType.PAST.toString());

    pastNotificationEntity.getNotifications().addAll(freshNotificationEntity.getNotifications());

    savenotification(pastNotificationEntity);

    freshNotificationEntity.getNotifications().clear();
    savenotification(freshNotificationEntity);
  }
예제 #3
0
  @Override
  public List<Notification> getNotifications(String userId, String filter) {

    List<Notification> notifications = new ArrayList<Notification>();
    Set<String> notificationsSet = new HashSet<String>();
    if (filter.equalsIgnoreCase("all")) {
      List<NotificationEntity> notificationEntity =
          notificationRepository.getAllNotificationForUser(userId);
      for (NotificationEntity eachNotificationEntity : notificationEntity) {
        notificationsSet.addAll(eachNotificationEntity.getNotifications());
      }
      for (String eachNotification : notificationsSet) {
        try {
          System.out.println("each notification" + eachNotification);
          Notification notificationDeserialised =
              objectMapper.readValue(eachNotification, Notification.class);
          notifications.add(notificationDeserialised);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    } else {
      NotificationEntity notificationEntity =
          notificationRepository.getFreshNotificationForUser(
              userId, NotificationType.FRESH.toString());
      notificationsSet.addAll(notificationEntity.getNotifications());

      for (String eachNotification : notificationsSet) {
        try {
          System.out.println("each notification" + eachNotification);
          Notification notificationDeserialised =
              objectMapper.readValue(eachNotification, Notification.class);
          notifications.add(notificationDeserialised);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    return notifications;
  }