public void removeQueuedNotification(IQueuedNotification notification) throws Exception { DomainFactory factory = getDomainFactory(); QueuedNotification domainObject = (QueuedNotification) factory.getDomainObject(QueuedNotification.class, notification.getINotificationId()); if (domainObject != null) { factory.delete(domainObject); } }
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; }