Search in sources :

Example 1 with ReceivedNotification

use of org.nhindirect.monitor.dao.entity.ReceivedNotification in project nhin-d by DirectProject.

the class NotificationDuplicationDAOImpl method addNotification.

/**
	 * {@inheritDoc}
	 */
@Override
@Transactional(readOnly = false)
public void addNotification(String messageId, String address) throws NotificationDAOException {
    validateState();
    try {
        final Collection<String> notification = this.getReceivedAddresses(messageId, Arrays.asList(address));
        if (!notification.isEmpty()) {
            if (LOGGER.isDebugEnabled())
                LOGGER.debug("Notification for message id " + messageId + " and address " + address + " already received.  Not adding to received notification store.");
            return;
        }
        final ReceivedNotification notif = new ReceivedNotification();
        notif.setMessageid(messageId);
        notif.setAddress(address);
        notif.setReceivedTime(Calendar.getInstance(Locale.getDefault()));
        entityManager.persist(notif);
        entityManager.flush();
    }///CLOVER:OFF
     catch (Exception e) {
        throw new NotificationDAOException("Failed to add notification to the store.", e);
    }
///CLOVER:ON
}
Also used : ReceivedNotification(org.nhindirect.monitor.dao.entity.ReceivedNotification) NotificationDAOException(org.nhindirect.monitor.dao.NotificationDAOException) NotificationDAOException(org.nhindirect.monitor.dao.NotificationDAOException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

NotificationDAOException (org.nhindirect.monitor.dao.NotificationDAOException)1 ReceivedNotification (org.nhindirect.monitor.dao.entity.ReceivedNotification)1 Transactional (org.springframework.transaction.annotation.Transactional)1