public IQueuedNotification[] queueNotification(int userId, NotificationPriority priority, String message, String source, String entityName, Integer entityId, NotificationDelivery[] delivery) throws Exception { IQueuedNotification[] result = new IQueuedNotification[delivery.length]; DomainFactory factory = getDomainFactory(); for(int x = 0; x < delivery.length; x++) { QueuedNotificationVo valueObject = new QueuedNotificationVo(); valueObject.setDateTime(new DateTime()); valueObject.setUserId(userId); valueObject.setPriority(priority.getId()); valueObject.setMessage(message); valueObject.setSource(source); valueObject.setEntityType(entityName); valueObject.setEntityId(entityId); valueObject.setDeliveryMethod(delivery[x].getId()); String[] errors = valueObject.validate(); if(errors != null && errors.length > 0) throw new Exception("Unable to queue notifications because of validation errors"); QueuedNotification domainObject = QueuedNotificationVoAssembler.extractQueuedNotification(factory, valueObject); factory.save(domainObject); valueObject = QueuedNotificationVoAssembler.create(domainObject); result[x] = valueObject; } return result; }
public IQueuedNotification getQueuedNotification(int queuedNotificationId) { return QueuedNotificationVoAssembler.create((QueuedNotification)getDomainFactory().getDomainObject(QueuedNotification.class, queuedNotificationId)); }