@Test public void testCreate() { sqlUserNotificationRepository.createNotification("lumifyUser1", "title1", "message1", new ExpirationAge(1, ExpirationAgeUnit.HOUR)); sqlUserNotificationRepository.createNotification("lumifyUser2", "title2", "message2", new ExpirationAge(1, ExpirationAgeUnit.HOUR)); }
@Override public UserNotification createNotification(String userId, String title, String message, String actionEvent, JSONObject actionPayload, ExpirationAge expirationAge) { Date now = new Date(); String id = Long.toString(now.getTime()) + ":" + UUID.randomUUID().toString(); Session session = sessionManager.getSession(); Transaction transaction = null; try { transaction = session.beginTransaction(); SqlUserNotification notification = new SqlUserNotification(); notification.setId(id); notification.setUserId(userId); notification.setTitle(title); notification.setMessage(message); notification.setSentDate(now); notification.setExpirationAge(expirationAge); notification.setMarkedRead(false); if (actionEvent != null) { notification.setActionEvent(actionEvent); } if (actionPayload != null) { notification.setActionPayload(actionPayload); } session.save(notification); transaction.commit(); return notification; } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while creating", e); } }
SqlUserNotificationRepository extends UserNotificationRepository { @Override public UserNotification createNotification(String userId, String title, String message, String actionEvent, JSONObject actionPayload, ExpirationAge expirationAge) { Date now = new Date(); String id = Long.toString(now.getTime()) + ":" + UUID.randomUUID().toString(); Session session = sessionManager.getSession(); Transaction transaction = null; try { transaction = session.beginTransaction(); SqlUserNotification notification = new SqlUserNotification(); notification.setId(id); notification.setUserId(userId); notification.setTitle(title); notification.setMessage(message); notification.setSentDate(now); notification.setExpirationAge(expirationAge); notification.setMarkedRead(false); if (actionEvent != null) { notification.setActionEvent(actionEvent); } if (actionPayload != null) { notification.setActionPayload(actionPayload); } session.save(notification); transaction.commit(); return notification; } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while creating", e); } } }
SqlUserNotificationRepository extends UserNotificationRepository { @Override public UserNotification createNotification(String userId, String title, String message, String actionEvent, JSONObject actionPayload, ExpirationAge expirationAge) { Date now = new Date(); String id = Long.toString(now.getTime()) + ":" + UUID.randomUUID().toString(); Session session = sessionManager.getSession(); Transaction transaction = null; try { transaction = session.beginTransaction(); SqlUserNotification notification = new SqlUserNotification(); notification.setId(id); notification.setUserId(userId); notification.setTitle(title); notification.setMessage(message); notification.setSentDate(now); notification.setExpirationAge(expirationAge); notification.setMarkedRead(false); if (actionEvent != null) { notification.setActionEvent(actionEvent); } if (actionPayload != null) { notification.setActionPayload(actionPayload); } session.save(notification); transaction.commit(); return notification; } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while creating", e); } } @Inject  SqlUserNotificationRepository(HibernateSessionManager sessionManager); }
SqlUserNotificationRepository extends UserNotificationRepository { @Override public UserNotification createNotification(String userId, String title, String message, String actionEvent, JSONObject actionPayload, ExpirationAge expirationAge) { Date now = new Date(); String id = Long.toString(now.getTime()) + ":" + UUID.randomUUID().toString(); Session session = sessionManager.getSession(); Transaction transaction = null; try { transaction = session.beginTransaction(); SqlUserNotification notification = new SqlUserNotification(); notification.setId(id); notification.setUserId(userId); notification.setTitle(title); notification.setMessage(message); notification.setSentDate(now); notification.setExpirationAge(expirationAge); notification.setMarkedRead(false); if (actionEvent != null) { notification.setActionEvent(actionEvent); } if (actionPayload != null) { notification.setActionPayload(actionPayload); } session.save(notification); transaction.commit(); return notification; } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while creating", e); } } @Inject  SqlUserNotificationRepository(HibernateSessionManager sessionManager); @Override UserNotification createNotification(String userId, String title, String message, String actionEvent, JSONObject actionPayload, ExpirationAge expirationAge); @Override UserNotification getNotification(String notificationId, User user); @Override void markRead(String[] notificationIds, User user); @Override List<UserNotification> getActiveNotifications(User user); void markRead(String notificationId, User user); }
SqlUserNotificationRepository extends UserNotificationRepository { @Override public UserNotification createNotification(String userId, String title, String message, String actionEvent, JSONObject actionPayload, ExpirationAge expirationAge) { Date now = new Date(); String id = Long.toString(now.getTime()) + ":" + UUID.randomUUID().toString(); Session session = sessionManager.getSession(); Transaction transaction = null; try { transaction = session.beginTransaction(); SqlUserNotification notification = new SqlUserNotification(); notification.setId(id); notification.setUserId(userId); notification.setTitle(title); notification.setMessage(message); notification.setSentDate(now); notification.setExpirationAge(expirationAge); notification.setMarkedRead(false); if (actionEvent != null) { notification.setActionEvent(actionEvent); } if (actionPayload != null) { notification.setActionPayload(actionPayload); } session.save(notification); transaction.commit(); return notification; } catch (HibernateException e) { if (transaction != null) { transaction.rollback(); } throw new LumifyException("HibernateException while creating", e); } } @Inject  SqlUserNotificationRepository(HibernateSessionManager sessionManager); @Override UserNotification createNotification(String userId, String title, String message, String actionEvent, JSONObject actionPayload, ExpirationAge expirationAge); @Override UserNotification getNotification(String notificationId, User user); @Override void markRead(String[] notificationIds, User user); @Override List<UserNotification> getActiveNotifications(User user); void markRead(String notificationId, User user);  }