[ https://issues.apache.org/jira/browse/OFBIZ-5793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14203338#comment-14203338 ] Jacopo Cappellato commented on OFBIZ-5793: ------------------------------------------ Thank Ivan. I have committed your patch with r. 1637535 with some minor modifications. Misc comments: * I have modified some minor formatting * I have removed the field serviceNameOnExpiry from SubscriptionForms.xml * performance enhancement - add a condition to only select records with null expirationCompletedDate field in the query: {code}subscriptionList = delegator.findList("Subscription", cond, null,null, null, false);{code} and then remove the if block: {code}if (expirationCompletedDate == null) {{code} * performance enhancement - move the code: {code}Calendar currentDate = Calendar.getInstance(); currentDate.setTime(UtilDateTime.nowTimestamp()); {code} out of the for block * instead of: {code}subscriptionResource = EntityQuery.use(delegator).from("SubscriptionResource").where("subscriptionResourceId", subscriptionResourceId).queryOne();{code} you could have used: {code}subscription.getRelatedOne("SubscriptionResource"){code} > modify logic to only run expiry service once when subscription expires > ---------------------------------------------------------------------- > > Key: OFBIZ-5793 > URL: https://issues.apache.org/jira/browse/OFBIZ-5793 > Project: OFBiz > Issue Type: Improvement > Components: product > Affects Versions: Trunk > Environment: not relevant > Reporter: Ivan Cauchi > Assignee: Jacopo Cappellato > Priority: Minor > Labels: subscription > Fix For: Trunk > > Attachments: OFBIZ-5793.patch, OFBIZ-5793.v3.patch > > Original Estimate: 672h > Remaining Estimate: 672h > > Background > --------------- > Recenlty, the trunk version of OFBiz was augmented with a new service called runServiceUponSubscriptionExpiry through JIRA5333. This service is scheduled to run, using the demo data, once a day. Its algorithm looks up all subscriptions which have expired, which is defined as the current time being greater than the sum of the subscription.thruDate + subscription.gracePeriodOnExpiry, and Subscription.automaticExtend is false. For all such subscriptions, the service runs any service named in SubscriptionResource.serviceNameOnExpiry. > This provides users of the OFBiz framework who provide subscriptions to their customers using the framework, to trigger an external deprovisioning action when a subscription expires, implemented as a service whose name is inserted into SubscriptionResource.serviceNameOnExpiry. > Currently, the service mentioned in SubscriptionResource.serviceNameOnExpiry is run every time the master service runServiceUponSubscriptionExpiry goes through its algorithm (once a day in the demo data). Typically, for subscriptions which require a deprovisioning action when the subscription expired, one and only one deprovisioning action would be required. > proposed solution > ----------------------- > To resolve this, it is being proposed to make the following adjustments: > a) augment the OFBiz data model with the following new field: > Subscription.expirationCompletedDate > b) modify the algorithm of runServiceUponSubscriptionExpiry to also check whether the expiry service has already run, by checking that expirationCompletedDate is null. > - if expirationCompletedDate is null (and the other conditions are satisfied), run the service in SubscriptionResource.serviceNameOnExpiry and update the date/time into expirationCompletedDate > - if expirationCompletedDate is not null, skip the expired subscription and move to the next > Testing > --------- > 1. create a new subscription through OFBiz with demo data > 2. modify the subscription's thru date and gracePeriodOnExpiry so the result of their addition is in the past of the system date > 3. verify that Subscription.expirationCompletedDate is empty > 4. either wait for the daily running of runServiceUponSubscriptionExpiry, or trigger the service manually > 5. verify that the log file contains a reference to the subscription having expired, and that Subscription. expirationCompletedDate contains the date/time the service was run > 6. either wait for the daily running of runServiceUponSubscriptionExpiry, or trigger the service manually, for a second time > 7. verify that the log file does not contain a reference to the subscription having expired, and that Subscription.expirationCompletedDate still contains the date/time the service was run -- This message was sent by Atlassian JIRA (v6.3.4#6332) |
Free forum by Nabble | Edit this page |