com.highdeal.pnr.hci
Class StatelessPreRatingContext

java.lang.Object
  extended by com.highdeal.pnr.hci.StatelessPreRatingContext

public abstract class StatelessPreRatingContext
extends java.lang.Object

This class represents the context to be used for stateless pre-rating.

A StatelessPreRatingContext handles possibly several StatelessRatingContext dedicated to different charges. That enables to manage a set of pending pre-ratings that are linked with different charges, even if we need to bind them together.

As an example, one StatelessPreRatingContext can be linked in the integration with one particular end user. Therefore, that enables to achieve post-rate calls related to this user, even if the post-rate caller doesn't know what charge code has been used at pre-rate time.

The rating record history does not take into account the modification of the (related stateless rating) context that could occur during the life of the context. That means that, while rating record history is not empty, values of parameters and translation instances should not be modified, in order to ensure all re-rating implied by a post-rate will use same data. Counters' values should not be modified either (except modification due to a rating), in order not to bend the history of counters' values. Modifications have no impact, so are allowed, when rating record history is empty. If modifications are needed even with not empty history, a specific integration may use workarounds:

This limitation implies also the incompatibility between stateless pre-rating and stateless rating: since a StatelessRatingContext is embedded within a StatelessPreRatingContext in order to use it for stateless pre-rating, it should not be used concurrently for stateless rating. However, if it is needs to rate on a StatelessRatingContext embedded into a StatelessPreRatingContext without having pre-rate behaviour involved (i.e. without the need to post rate later, not recording the event in case of empty history), it's possible to call pre-rate with a 0 or negative value for the argument postrateDeadline of StatelessServiceClient.statelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean).

This abstract class should not be extended by the developer. The only legal way to get one instance of this class is to call newInstance()or newInstance(String) static methods.

See Also:
StatelessRatingContext, StatelessServiceClient.statelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean), StatelessServiceClient.statelessPostRate(long, StatelessPreRatingContext, int, boolean, ChargeableItem)

Constructor Summary
protected StatelessPreRatingContext()
          Protected constructor.
 
Method Summary
abstract  StatelessRatingContext addStatelessRatingContext(StatelessRatingContext ratingContext, java.lang.String chargeCode)
          Adds in this StatelessPreRatingContext a StatelessRatingContext dedicated to the given charge code.
abstract  java.lang.String getChargeCode(long reservationUID)
          Returns the charge code on which a pre-rate has been done with the given reservation uid, or null if the reservation uid is unknown in this StatelessPreRatingContext.
abstract  java.util.List<java.lang.String> getChargeCodes()
          Returns a list containing any charge code for which one StatelessRatingContext is dedicated in this StatelessPreRatingContext.
abstract  java.lang.String getContextID()
          Returns the context ID.
abstract  java.util.List<java.lang.Long> getNotResolvedReservationUID(java.util.Date date)
          Returns the list of all reservationUID not yet resolved, ignoring those expired at given date.
abstract  StatelessRatingContext getStatelessRatingContext(java.lang.String chargeCode)
          Returns the StatelessRatingContext dedicated to the given charge code.
abstract  boolean isChargeRemovable(java.lang.String chargeCode)
          Returns true if and only if the StatelessRatingContext dedicated to the given charge code can be removed from this StatelessPreRatingContext without losing any pending pre-rating (i.e.
abstract  boolean isChargeRemovable(java.lang.String chargeCode, java.util.Date expirationDate)
          Returns true if and only if the StatelessRatingContext dedicated to the given charge code can be removed from this StatelessPreRatingContext without losing any pending pre-rating (i.e.
abstract  boolean isRemovable()
          Returns true if and only if there are no more pending pre-rating related to this StatelessPreRatingContext.
abstract  boolean isRemovable(java.util.Date expirationDate)
          Returns true if and only if there are no more pending pre-rating related to this StatelessPreRatingContext.
static StatelessPreRatingContext newInstance()
          Creates a newly allocated StatelessPreRatingContext object.
static StatelessPreRatingContext newInstance(java.lang.String contextID)
          Creates a newly allocated StatelessPreRatingContext object.
abstract  StatelessRatingContext removeStatelessRatingContext(java.lang.String chargeCode)
          Removes from this StatelessPreRatingContext the StatelessRatingContext dedicated to the given charge code.
abstract  void setContextID(java.lang.String contextID)
          Sets the context ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatelessPreRatingContext

protected StatelessPreRatingContext()
Protected constructor.

Method Detail

newInstance

public static final StatelessPreRatingContext newInstance()
Creates a newly allocated StatelessPreRatingContext object.

Returns:
a newly allocated StatelessPreRatingContext object.

newInstance

public static final StatelessPreRatingContext newInstance(java.lang.String contextID)
Creates a newly allocated StatelessPreRatingContext object.

Parameters:
contextID - the context ID for the created context.
Returns:
a newly allocated StatelessPreRatingContext object.

setContextID

public abstract void setContextID(java.lang.String contextID)
Sets the context ID. This ID is mainly for external use in the integration code.

Parameters:
contextID - the context ID.

getContextID

public abstract java.lang.String getContextID()
Returns the context ID.

Returns:
the context ID.
See Also:
setContextID(String)

addStatelessRatingContext

public abstract StatelessRatingContext addStatelessRatingContext(StatelessRatingContext ratingContext,
                                                                 java.lang.String chargeCode)
Adds in this StatelessPreRatingContext a StatelessRatingContext dedicated to the given charge code. The given StatelessRatingContext will be used, in any further use of this StatelessPreRatingContext in a stateless pre-rate call, on the related charge code.

Parameters:
ratingContext - a StatelessRatingContext
chargeCode - the charge code for which the ratingContext will be dedicated
Returns:
the added StatelessRatingContext
See Also:
StatelessServiceClient.statelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean)

removeStatelessRatingContext

public abstract StatelessRatingContext removeStatelessRatingContext(java.lang.String chargeCode)
Removes from this StatelessPreRatingContext the StatelessRatingContext dedicated to the given charge code.

Parameters:
chargeCode - a charge code.
Returns:
the removed StatelessRatingContext, or null if nothing is removed

getStatelessRatingContext

public abstract StatelessRatingContext getStatelessRatingContext(java.lang.String chargeCode)
Returns the StatelessRatingContext dedicated to the given charge code. Accessing such a StatelssRatingContext enables to read current counters values, parameters and so on.

Parameters:
chargeCode - the charge code
Returns:
the StatelessRatingContext dedicated to the given charge code in this StatelessPreRatingContext

getChargeCode

public abstract java.lang.String getChargeCode(long reservationUID)
Returns the charge code on which a pre-rate has been done with the given reservation uid, or null if the reservation uid is unknown in this StatelessPreRatingContext.

Parameters:
reservationUID -
Returns:
the charge code for the given reservationUID

getNotResolvedReservationUID

public abstract java.util.List<java.lang.Long> getNotResolvedReservationUID(java.util.Date date)
Returns the list of all reservationUID not yet resolved, ignoring those expired at given date. Returns all reservationUID if date is null.

Parameters:
date - the date to compare to expiration
Returns:
a list of Long

getChargeCodes

public abstract java.util.List<java.lang.String> getChargeCodes()
Returns a list containing any charge code for which one StatelessRatingContext is dedicated in this StatelessPreRatingContext.

Returns:
a list of String

isChargeRemovable

public abstract boolean isChargeRemovable(java.lang.String chargeCode,
                                          java.util.Date expirationDate)
Returns true if and only if the StatelessRatingContext dedicated to the given charge code can be removed from this StatelessPreRatingContext without losing any pending pre-rating (i.e. there are no more pending reservation for this charge code). The date is used in order no to take into account pending pre-rating which are expired at the given date. This comparison is ignored if expirationDate is null.

Parameters:
chargeCode - the charge code
expirationDate - the date used to take into account not expired pending pre-rating.
Returns:
true iff we can call without risk removeStatelessRatingContext(String)with the given charge code as argument.

isChargeRemovable

public abstract boolean isChargeRemovable(java.lang.String chargeCode)
Returns true if and only if the StatelessRatingContext dedicated to the given charge code can be removed from this StatelessPreRatingContext without losing any pending pre-rating (i.e. there are no more pending reservation for this charge code). Same as isChargeRemovable(chargeCode, null)

Parameters:
chargeCode - the charge code
Returns:
true iff we can call without risk removeStatelessRatingContext(String)with the given charge code as argument.

isRemovable

public abstract boolean isRemovable(java.util.Date expirationDate)
Returns true if and only if there are no more pending pre-rating related to this StatelessPreRatingContext. The date is used in order no to take into account pending pre-rating which are expired at the given date. This comparison is ignored if expirationDate is null.

Parameters:
expirationDate - the date used to take into account not expired pending pre-rating.
Returns:
true iff no more pending pre-rating exists for this context.

isRemovable

public abstract boolean isRemovable()
Returns true if and only if there are no more pending pre-rating related to this StatelessPreRatingContext. Same as isRemovable(null)

Returns:
true iff no more pending pre-rating exists for this context.

Document Published: October 2015 (SAP CC 4.0 SP10 and Later)