Issue #2459 - Add unscheduled as a slot attribute
Former-commit-id:9501f3dfa8
[formerly1078c7dbec
] [formerly292ef2c068
] [formerly292ef2c068
[formerly0f655c96e3
]] [formerly47069bd7a4
[formerly292ef2c068
[formerly0f655c96e3
] [formerly47069bd7a4
[formerly 4cd670bc12e09f1acc778e8760615e92561e3ce3]]]] Former-commit-id:47069bd7a4
Former-commit-id: 2aa2124082b39824ee258025d814b5699d67daee [formerly 326fbca95107e72aaa00b4cf88c3bd1d1eafe3f5] [formerly7fe25d02f0
[formerlyfe012ebbd1
]] Former-commit-id:7fe25d02f0
Former-commit-id:39e90e653e
This commit is contained in:
parent
640787a768
commit
3f64f96ad0
1 changed files with 20 additions and 8 deletions
|
@ -216,6 +216,7 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
|
||||
@XmlAttribute
|
||||
@DynamicSerializeElement
|
||||
@SlotAttribute
|
||||
private boolean unscheduled;
|
||||
|
||||
@XmlAttribute
|
||||
|
@ -267,6 +268,9 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
@SlotAttribute(Subscription.SUBSCRIPTION_STATE_SLOT)
|
||||
private SubscriptionState subscriptionState;
|
||||
|
||||
/** Flag stating if the object should be updated */
|
||||
private boolean shouldUpdate = false;
|
||||
|
||||
/**
|
||||
* Get subscription name.
|
||||
*
|
||||
|
@ -878,18 +882,18 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine if subscription status is expired.
|
||||
* Determine if subscription status is expired and set subscription to off
|
||||
* if it is expired.
|
||||
*
|
||||
* @return true if status is expired
|
||||
*/
|
||||
private boolean isExpired() {
|
||||
private boolean checkAndSetExpiration() {
|
||||
Calendar cal = TimeUtil.newGmtCalendar();
|
||||
Date today = cal.getTime();
|
||||
boolean expired = false;
|
||||
if (this.getSubscriptionEnd() != null
|
||||
&& today.after(this.getSubscriptionEnd())) {
|
||||
if (subscriptionEnd != null && cal.getTime().after(subscriptionEnd)) {
|
||||
expired = true;
|
||||
this.subscriptionState = SubscriptionState.OFF;
|
||||
this.shouldUpdate = true;
|
||||
}
|
||||
|
||||
return expired;
|
||||
|
@ -904,7 +908,7 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
public SubscriptionStatus getStatus() {
|
||||
if (!isValid()) {
|
||||
return SubscriptionStatus.INVALID;
|
||||
} else if (isExpired()) {
|
||||
} else if (checkAndSetExpiration()) {
|
||||
return SubscriptionStatus.EXPIRED;
|
||||
} else if (subscriptionState == SubscriptionState.OFF) {
|
||||
return SubscriptionStatus.DEACTIVATED;
|
||||
|
@ -931,7 +935,8 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
* @return true if this subscription should be scheduled
|
||||
*/
|
||||
public boolean shouldSchedule() {
|
||||
return subscriptionState == SubscriptionState.ON && !isExpired();
|
||||
return subscriptionState == SubscriptionState.ON
|
||||
&& !checkAndSetExpiration();
|
||||
}
|
||||
|
||||
private boolean inWindow(Date checkDate) {
|
||||
|
@ -1065,7 +1070,7 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
*/
|
||||
@Override
|
||||
public void activate() {
|
||||
if (valid && !isExpired()) {
|
||||
if (valid && !checkAndSetExpiration()) {
|
||||
this.setSubscriptionState(SubscriptionState.ON);
|
||||
}
|
||||
}
|
||||
|
@ -1077,4 +1082,11 @@ public abstract class RecurringSubscription<T extends Time, C extends Coverage>
|
|||
public void deactivate() {
|
||||
this.setSubscriptionState(SubscriptionState.OFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the shouldUpdate
|
||||
*/
|
||||
public boolean shouldUpdate() {
|
||||
return shouldUpdate;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue