com.ning.billing.subscription.alignment
Class PlanAligner

java.lang.Object
  extended by com.ning.billing.subscription.alignment.BaseAligner
      extended by com.ning.billing.subscription.alignment.PlanAligner

public class PlanAligner
extends BaseAligner

PlanAligner offers specific APIs to return the correct TimedPhase when creating, changing Plan or to compute next Phase on current Plan.


Constructor Summary
PlanAligner(CatalogService catalogService)
           
 
Method Summary
 TimedPhase[] getCurrentAndNextTimedPhaseOnCreate(DefaultSubscriptionBase subscription, Plan plan, PhaseType initialPhase, String priceList, org.joda.time.DateTime requestedDate, org.joda.time.DateTime effectiveDate)
          Returns the current and next phase for the subscription in creation
 TimedPhase getCurrentTimedPhaseOnChange(DefaultSubscriptionBase subscription, Plan plan, String priceList, org.joda.time.DateTime requestedDate, org.joda.time.DateTime effectiveDate)
          Returns current Phase for that Plan change
 TimedPhase getNextTimedPhase(DefaultSubscriptionBase subscription, org.joda.time.DateTime requestedDate, org.joda.time.DateTime effectiveDate)
          Returns next Phase for that SubscriptionBase at a point in time
 TimedPhase getNextTimedPhaseOnChange(DefaultSubscriptionBase subscription, Plan plan, String priceList, org.joda.time.DateTime requestedDate, org.joda.time.DateTime effectiveDate)
          Returns next Phase for that Plan change
 
Methods inherited from class com.ning.billing.subscription.alignment.BaseAligner
addDuration, removeDuration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlanAligner

@Inject
public PlanAligner(CatalogService catalogService)
Method Detail

getCurrentAndNextTimedPhaseOnCreate

public TimedPhase[] getCurrentAndNextTimedPhaseOnCreate(DefaultSubscriptionBase subscription,
                                                        Plan plan,
                                                        PhaseType initialPhase,
                                                        String priceList,
                                                        org.joda.time.DateTime requestedDate,
                                                        org.joda.time.DateTime effectiveDate)
                                                 throws CatalogApiException,
                                                        SubscriptionBaseApiException
Returns the current and next phase for the subscription in creation

Parameters:
subscription - the subscription in creation (only the start date and the bundle start date are looked at)
plan - the current Plan
initialPhase - the initialPhase on which we should create that subscription. can be null
priceList - the priceList
requestedDate - the requested date (only used to load the catalog)
effectiveDate - the effective creation date (driven by the catalog policy, i.e. when the creation occurs)
Returns:
the current and next phases
Throws:
CatalogApiException - for catalog errors
SubscriptionBaseApiException - for subscription errors

getCurrentTimedPhaseOnChange

public TimedPhase getCurrentTimedPhaseOnChange(DefaultSubscriptionBase subscription,
                                               Plan plan,
                                               String priceList,
                                               org.joda.time.DateTime requestedDate,
                                               org.joda.time.DateTime effectiveDate)
                                        throws CatalogApiException,
                                               SubscriptionBaseApiException
Returns current Phase for that Plan change

Parameters:
subscription - the subscription in change (only start date, bundle start date, current phase, plan and pricelist are looked at)
plan - the current Plan
priceList - the priceList on which we should change that subscription.
requestedDate - the requested date
effectiveDate - the effective change date (driven by the catalog policy, i.e. when the change occurs)
Returns:
the current phase
Throws:
CatalogApiException - for catalog errors
SubscriptionBaseApiException - for subscription errors

getNextTimedPhaseOnChange

public TimedPhase getNextTimedPhaseOnChange(DefaultSubscriptionBase subscription,
                                            Plan plan,
                                            String priceList,
                                            org.joda.time.DateTime requestedDate,
                                            org.joda.time.DateTime effectiveDate)
                                     throws CatalogApiException,
                                            SubscriptionBaseApiException
Returns next Phase for that Plan change

Parameters:
subscription - the subscription in change (only start date, bundle start date, current phase, plan and pricelist are looked at)
plan - the current Plan
priceList - the priceList on which we should change that subscription.
requestedDate - the requested date
effectiveDate - the effective change date (driven by the catalog policy, i.e. when the change occurs)
Returns:
the next phase
Throws:
CatalogApiException - for catalog errors
SubscriptionBaseApiException - for subscription errors

getNextTimedPhase

public TimedPhase getNextTimedPhase(DefaultSubscriptionBase subscription,
                                    org.joda.time.DateTime requestedDate,
                                    org.joda.time.DateTime effectiveDate)
Returns next Phase for that SubscriptionBase at a point in time

Parameters:
subscription - the subscription for which we need to compute the next Phase event
requestedDate - the requested date
effectiveDate - the date at which we look to compute that event. effective needs to be after last Plan change or initial Plan
Returns:
the next phase


Copyright © 2010-2013. All Rights Reserved.