log.audit("**** Migrated " + counter + " publishers. ****");
log.audit("+-----------------------------------------------------------------------------+");
log.audit("+... Update the latest emailed date for all subscribers +");
log.audit("+-----------------------------------------------------------------------------+");
DBQuery query = DBFactory.getInstance().createQuery("update " + Subscriber.class.getName() + " subscriber set subscriber.latestEmailed=:latestDate");
Calendar cal = Calendar.getInstance();
//
// use the day of installing the release,
// and set the time back to midnight instead of
// going back one day, e.g. cal.add(Calendar.DAY_OF_MONTH, -1);
//
// 1) before release day, sending notifications the old way at 02:00:00 a.m.
// 2) at release day, sending notifications the old way at 02:00:00 a.m.
// .. Install the Release -> Upgrader sets latestEmail sent on subscribers to release day at 00:00:00
// 3) day after release, sending notifications the new way at 02:00:00 a.m.
//
// with this procedure only the news are sent twice which were created between 00:00:00 and 02:00:00 of release day.
//
cal.set(Calendar.HOUR_OF_DAY, 0);
cal.set(Calendar.MINUTE, 0);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.MILLISECOND, 0);
query.setTimestamp("latestDate", cal.getTime());
int subCounter = query.executeUpdate(FlushMode.AUTO);
DBFactory.getInstance().intermediateCommit();
log.audit("**** Migrated " + subCounter + " subscribers. ****");
uhd.setBooleanDataValue(TASK_MIGRATE_NOTIFICATIONS, true);