use of com.webstart.model.Notifications in project FarmCloud by vratsasg.
the class UsersServiceImpl method makeNotificationRead.
public void makeNotificationRead(int notificationid) {
try {
Notifications notification = this.notificationsJpaRepository.getByNotificationid(notificationid);
//
notification.setIsreaded(true);
this.notificationsJpaRepository.save(notification);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.webstart.model.Notifications in project FarmCloud by vratsasg.
the class UsersServiceImpl method createNewNotification.
public void createNewNotification(int userid, String message, int notificationType) {
try {
Notifications notification = new Notifications(userid, message, false, notificationType);
//
notificationsJpaRepository.save(notification);
} catch (Exception e) {
e.printStackTrace();
}
}
use of com.webstart.model.Notifications in project FarmCloud by vratsasg.
the class UserController method getCounterNotifications.
@RequestMapping(value = "notifications", method = RequestMethod.GET)
@ResponseBody
public List<Notifications> getCounterNotifications(HttpServletRequest request) {
List<Notifications> notificationList = null;
Users users = (Users) request.getSession().getAttribute("current_user");
try {
notificationList = usersService.getUserCounterNotifications(users.getUser_id());
} catch (Exception e) {
e.printStackTrace();
return null;
}
return notificationList;
}
use of com.webstart.model.Notifications in project FarmCloud by vratsasg.
the class UsersServiceImpl method getUserCounterNotifications.
public List<Notifications> getUserCounterNotifications(Integer userId) {
List<Notifications> notifications = null;
try {
notifications = this.notificationsJpaRepository.getAllByUseridAndIsreaded(userId, false);
//
List<Featureofinterest> enddevices = this.featureofinterestJpaRepository.getAllByUseridAndFeatureofinteresttypeid(userId, 3L);
int offset = DateTimeZone.getDefault().getOffset(new Instant());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
DateTimeFormatter dtfInput = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
// Convert Datetime created to user timezone
for (Notifications notification : notifications) {
HelperCls.ConvertToDateTime convertable = new HelperCls.ConvertToDateTime();
DateTime dt = convertable.GetUTCDateTime(sdf.format(notification.getDatecreated()), dtfInput, enddevices.get(0).getTimezone(), StatusTimeConverterEnum.TO_TIMEZONE);
Timestamp ts = new Timestamp(dt.getMillis() - offset);
notification.setDatecreated(ts);
//
logger.debug("params: dt={}, ts={}", dt, ts);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return notifications;
}
}
Aggregations