public void markAsSeen(IUINotification notification) { if(notification == null) throw new CodingRuntimeException("Notification passed into markAsSeen is null."); DomainFactory factory = getDomainFactory(); NotificationVo notificationVo = NotificationVoAssembler.create((Notifications) factory.getDomainObject(Notifications.class, notification.getINotificationId())); notificationVo.setSeen(Boolean.TRUE); notificationVo.setSeenAt(new DateTime()); notificationVo.validate(); try { factory.save(NotificationVoAssembler.extractNotifications(factory, notificationVo)); } catch (StaleObjectException e) { throw new RuntimeException(e); } }
public void setUserNotified(INotification notification) { if(notification == null) throw new CodingRuntimeException("Notification passed into setUserNotified is null."); DomainFactory factory = getDomainFactory(); NotificationVo notificationVo = NotificationVoAssembler.create((Notifications) factory.getDomainObject(Notifications.class, notification.getINotificationId())); notificationVo.setUserNotified(true); notificationVo.validate(); try { factory.save(NotificationVoAssembler.extractNotifications(factory, notificationVo)); } catch (StaleObjectException e) { throw new RuntimeException(e); } }
@Override protected void onGrdNotificationsSelectionChanged() throws PresentationLogicException { if(form.grdNotifications().getValue() instanceof NotificationVo) { populateDetails(form.grdNotifications().getValue()); //engine.getNotificationsProvider().markAsSeen(form.grdNotifications().getValue()); form.grdNotifications().getSelectedRow().setBold(false); form.grdNotifications().getSelectedRow().setcolImage(getColImage(((INotification)form.grdNotifications().getValue()).getINotificationPriority(), true)); } updateControlsState(); }
public IUINotification createUINotification(IQueuedNotification notification) throws Exception { if(notification == null) throw new CodingRuntimeException("Invalid notification."); if(notification.getINotificationMessage() == null) throw new CodingRuntimeException("Notification message is null."); if(notification.getINotificationPriority() == null) throw new CodingRuntimeException("Notification priority is null."); NotificationVo instance = new NotificationVo(); DomainFactory domainFactory = this.getDomainFactory(); AppUser doUser = (AppUser)domainFactory.getDomainObject(AppUser.class, notification.getINotificationUserId()); if(doUser == null) throw new DomainRuntimeException("Invalid User Id passed into createNotification."); instance.setUser(AppUserNotificationVoAssembler.create(doUser)); instance.setDateTime(new DateTime()); instance.setNotificationPriority(notification.getINotificationPriority().getId()); instance.setMessage(notification.getINotificationMessage()); instance.setSource(notification.getINotificationSource()); instance.setSeen(Boolean.FALSE); if(notification.getINotificationEntityType() != null) { instance.setEntityType(notification.getINotificationEntityType()); instance.setEntityId(notification.getINotificationEntityId()); } String[] errors = instance.validate(); if(errors != null && errors.length > 0) { throw new RuntimeException("Validation errors while creating a user notification."); } try { ims.core.admin.domain.objects.Notifications doNotification = NotificationVoAssembler.extractNotifications(domainFactory, instance); domainFactory.save(doNotification); instance = NotificationVoAssembler.create(doNotification); } catch (StaleObjectException e) { throw new RuntimeException(e); } return instance; }
public PDSBackOfficeItemVo buildBackOfficeItemAndNotification(PDSBackOfficeType type, String errorDescription, PDSBackOfficeWorkPriority priority) throws PdsException { PDSConfigurationVo pdsConfiguration = impl.getPdsConfiguration(); PDSBackOfficeItemVo item = new PDSBackOfficeItemVo(); item.setType(type); if(errorDescription == null) item.setDescription(""); else item.setDescription(errorDescription.length() <= 200 ? errorDescription : errorDescription.substring(0, 199)); item.setSource("PDS"); item.setPriority(priority); item.setCurrentStatus(PDSBackOfficeWorkStatus.CREATED); PDSBackOfficeStatusVo statusHistory = new PDSBackOfficeStatusVo(); statusHistory.setUpdateDate(new DateTime()); statusHistory.setStatus(PDSBackOfficeWorkStatus.CREATED); item.setStatusHistory(new PDSBackOfficeStatusVoCollection()); item.getStatusHistory().add(statusHistory); item.setNHSNumber(nhsNumber); item.setNHSNumberSuperseded(superseededNhsNumber); item.setPatient(patientInContext); if (pdsConfiguration.getCREATE_BO_NOTIFICATIONS() != null && Boolean.TRUE.equals(pdsConfiguration.getCREATE_BO_NOTIFICATIONS())) { if(pdsConfiguration.getPDS_BACKOFFICE_NOTIFICATI() != null) { NotificationVo notification = new NotificationVo(); notification.setUser(impl.getAppUserById(pdsConfiguration.getPDS_BACKOFFICE_NOTIFICATI())); notification.setDateTime(new DateTime()); if(PDSBackOfficeWorkPriority.P1.equals(priority)) notification.setNotificationPriority(1); else if(PDSBackOfficeWorkPriority.P2.equals(priority)) notification.setNotificationPriority(2); else notification.setNotificationPriority(3); notification.setMessage(errorDescription); notification.setSource("PDS"); notification.setSeen(Boolean.FALSE); item.setNotifications(new NotificationVoCollection()); item.getNotifications().add(notification); } else { domain.createSystemLogEntry(SystemLogType.PDS, SystemLogLevel.ERROR, "PDS Back Office Notification User is not set and therefore cannot create back office notifications !"); } } return item; }