agave-notifications/notifications-core/src/main/java/org/iplantc/service/notification/dao/NotificationDao.java
/**
	 * Merges the current instance with the one in the db.
	 * @param notification
	 * @return the merged Notification
	 * @throws NotificationException
	 */
Merges the current instance with the one in the db.
@param notification
@return the merged Notification
@throws NotificationException
Merges the current instance with the one in the db . @param notification @return the merged Notification @throws NotificationException
public boolean update(Notification notification) throws NotificationException
	{
		if (notification == null)
			throw new NotificationException("Notification cannot be null");
		try
		{	
			HibernateUtil.beginTransaction();
			Session session = HibernateUtil.getSession();
			session.clear();
			session.disableFilter("notificationTenantFilter");
			String sql = "UPDATE notifications n "
					+ "SET  n.status = :status, "
					+ "	    n.last_updated = CURRENT_TIMESTAMP, "
					+ "	    n.associated_uuid = :associateduuid, "
					+ "	    n.notification_event = :event, "
					+ "	    n.callback_url = :callbackurl, "
					+ "	    n.is_persistent = :ispersistent, "
					+ "	    n.is_visible = :isvisible, "
					+ "	    n.retry_strategy = :retrystrategy, "
					+ "	    n.retry_limit = :retrylimit, "
					+ "	    n.retry_rate = :retryrate, "
					+ "	    n.retry_delay = :retrydelay, "
					+ "	    n.save_on_failure = :saveonfailure "
					+ "WHERE n.uuid = :uuid ";
			int rowsAffected = session.createSQLQuery(sql)
					.setString("uuid",notification.getUuid())
					.setString("status", notification.getStatus().name())
					.setString("associateduuid",notification.getAssociatedUuid())
					.setString("event",notification.getEvent())
					.setString("callbackurl",notification.getCallbackUrl())
					.setInteger("ispersistent", notification.isPersistent() ? 1: 0)
					.setInteger("isvisible",notification.isVisible() ? 1: 0)
					.setString("retrystrategy",notification.getPolicy().getRetryStrategyType().name())
					.setInteger("retrylimit",notification.getPolicy().getRetryLimit())
					.setInteger("retryrate",notification.getPolicy().getRetryRate())
					.setInteger("retrydelay",notification.getPolicy().getRetryDelay())
					.setInteger("saveonfailure",notification.getPolicy().isSaveOnFailure() ? 1 : 0)
					.executeUpdate();
			session.flush();
			return rowsAffected > 0;
		}
		catch (HibernateException ex)
		{
			try
			{
				if (HibernateUtil.getSession().isOpen()) {
					HibernateUtil.rollbackTransaction();
				}
			}
			catch (Exception ignored) {}
			throw new NotificationException("Failed to merge notification", ex);
		}
		finally {
			try { HibernateUtil.commitTransaction(); } catch (Exception e) {e.printStackTrace();}
		}
	}
public boolean update ( Notification notification ) throws NotificationException { if ( notification == null ) throw new NotificationException ( "Notification cannot be null" ) ; try { HibernateUtil . beginTransaction ( ) ; Session session = HibernateUtil . getSession ( ) ; session . clear ( ) ; session . disableFilter ( "notificationTenantFilter" ) ; String sql = "UPDATE notifications n " + "SET  n.status = :status, " + "	    n.last_updated = CURRENT_TIMESTAMP, " + "	    n.associated_uuid = :associateduuid, " + "	    n.notification_event = :event, " + "	    n.callback_url = :callbackurl, " + "	    n.is_persistent = :ispersistent, " + "	    n.is_visible = :isvisible, " + "	    n.retry_strategy = :retrystrategy, " + "	    n.retry_limit = :retrylimit, " + "	    n.retry_rate = :retryrate, " + "	    n.retry_delay = :retrydelay, " + "	    n.save_on_failure = :saveonfailure " + "WHERE n.uuid = :uuid " ; int rowsAffected = session . createSQLQuery ( sql ) . setString ( "uuid" , notification . getUuid ( ) ) . setString ( "status" , notification . getStatus ( ) . name ( ) ) . setString ( "associateduuid" , notification . getAssociatedUuid ( ) ) . setString ( "event" , notification . getEvent ( ) ) . setString ( "callbackurl" , notification . getCallbackUrl ( ) ) . setInteger ( "ispersistent" , notification . isPersistent ( ) ? 1 : 0 ) . setInteger ( "isvisible" , notification . isVisible ( ) ? 1 : 0 ) . setString ( "retrystrategy" , notification . getPolicy ( ) . getRetryStrategyType ( ) . name ( ) ) . setInteger ( "retrylimit" , notification . getPolicy ( ) . getRetryLimit ( ) ) . setInteger ( "retryrate" , notification . getPolicy ( ) . getRetryRate ( ) ) . setInteger ( "retrydelay" , notification . getPolicy ( ) . getRetryDelay ( ) ) . setInteger ( "saveonfailure" , notification . getPolicy ( ) . isSaveOnFailure ( ) ? 1 : 0 ) . executeUpdate ( ) ; session . flush ( ) ; return rowsAffected > 0 ; } catch ( HibernateException ex ) { try { if ( HibernateUtil . getSession ( ) . isOpen ( ) ) { HibernateUtil . rollbackTransaction ( ) ; } } catch ( Exception ignored ) { } throw new NotificationException ( "Failed to merge notification" , ex ) ; } finally { try { HibernateUtil . commitTransaction ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } }
Merges the current instance with the one in the db.
Merges the current instance with the one in the db .