Issue #2398 Fixed scheduling outside of active period/ expired window

Change-Id: I6a07a597e84351d02cb1a0da29f796d86af28107

Former-commit-id: d5e3fdf7bd51177d24312d9daa6af7a2a4920f06
This commit is contained in:
Dave Hladky 2014-01-20 16:48:58 -06:00 committed by Gerrit Code Review
parent dd12515ca2
commit dfc0d6d9f5
2 changed files with 62 additions and 21 deletions

View file

@ -65,6 +65,7 @@ import com.raytheon.uf.common.time.util.TimeUtil;
* Nov 14, 2013 2548 mpduff Add a subscription type slot.
* Jan 08, 2014 2615 bgonzale Implement calculate start and calculate end methods.
* Jan 14, 2014 2459 mpduff Add subscription state.
* Jan 20, 2013 2398 dhladky Fixed rescheduling beyond active period/expired window.
*
* </pre>
*
@ -898,6 +899,19 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
return expired;
}
/**
* Check for expiration on date
* @param date
* @return
*/
private boolean isExpired(Date date) {
boolean expired = false;
if (subscriptionEnd != null && date.after(subscriptionEnd)) {
expired = true;
}
return expired;
}
/**
* Get the current subscription status.
*
@ -936,6 +950,19 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
&& !checkAndSetExpiration();
}
/**
* Should this be scheduled for this time.
* @param checkDate
* @return
*/
public boolean shouldScheduleForTime(Date checkDate) {
if (!isExpired(checkDate) && inWindow(checkDate)) {
return true;
}
return false;
}
private boolean inWindow(Date checkDate) {
if (activePeriodStart == null && activePeriodEnd == null) {
return true;

View file

@ -49,6 +49,7 @@ import com.raytheon.uf.common.datadelivery.registry.DataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.GriddedDataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.PointDataSetMetaData;
import com.raytheon.uf.common.datadelivery.registry.PointTime;
import com.raytheon.uf.common.datadelivery.registry.RecurringSubscription;
import com.raytheon.uf.common.datadelivery.registry.SiteSubscription;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
@ -113,6 +114,7 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
* insert and update events as dataset metadata events.
* Jan 13, 2014 2679 dhladky Small Point data updates.
* Jan 14, 2014 2692 dhladky AdhocSubscription handler
* Jan 20, 2013 2398 dhladky Fixed rescheduling beyond active period/expired window.
*
* </pre>
*
@ -306,17 +308,28 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
for (int day = 1; day <= days; day++) {
next.add(Calendar.DAY_OF_YEAR, 1);
// Since subscriptions are based on cycles in a day, add one day
// TODO Check if we need to set sub to "OFF" state and save to
// registry
if (((RecurringSubscription<T, C>) subscription)
.shouldScheduleForTime(next.getTime())) {
// Since subscriptions are based on cycles in a day, add
// one
// day
// to the
// completed BandwidthSubscription to get the next days
// retrieval.
// Now check if that BandwidthSubscription has already been
// Now check if that BandwidthSubscription has already
// been
// scheduled.
BandwidthSubscription a = bandwidthDao
.getBandwidthSubscription(dao.getRegistryId(), next);
if (a == null) {
// Create the new BandwidthSubscription record with the next
// Create the new BandwidthSubscription record with
// the
// next
// time..
a = bandwidthDao.newBandwidthSubscription(subscription,
next);
@ -332,6 +345,7 @@ public abstract class EdexBandwidthManager<T extends Time, C extends Coverage>
}
}
}
}
/**
* When a Subscription is removed from the Registry, a RemoveRegistryEvent