Class StatelessPreRatingContext
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:
- Counters modification can be done thanks to a dedicated usage CI, in such a way the modification will be included in history if needed.
- Price Plan can be designed in order not to use parameter nor translation table instances (however, Transalation Tables used in the price plan are allowed) but properties of the CI only.
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.
-
Method Summary
Modifier and TypeMethodDescriptionabstract StatelessRatingContextaddStatelessRatingContext(StatelessRatingContext ratingContext, String chargeCode) Adds in this StatelessPreRatingContext a StatelessRatingContext dedicated to the given charge code.abstract StringgetChargeCode(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.Returns a list containing any charge code for which one StatelessRatingContext is dedicated in this StatelessPreRatingContext.abstract StringReturns the context ID.Returns the list of all reservationUID not yet resolved, ignoring those expired at given date.abstract StatelessRatingContextgetStatelessRatingContext(String chargeCode) Returns the StatelessRatingContext dedicated to the given charge code.abstract booleanisChargeRemovable(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 booleanisChargeRemovable(String chargeCode, 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 booleanReturns true if and only if there are no more pending pre-rating related to this StatelessPreRatingContext.abstract booleanisRemovable(Date expirationDate) Returns true if and only if there are no more pending pre-rating related to this StatelessPreRatingContext.static final StatelessPreRatingContextCreates a newly allocated StatelessPreRatingContext object.static final StatelessPreRatingContextnewInstance(String contextID) Creates a newly allocated StatelessPreRatingContext object.abstract StatelessRatingContextremoveStatelessRatingContext(String chargeCode) Removes from this StatelessPreRatingContext the StatelessRatingContext dedicated to the given charge code.abstract voidsetContextID(String contextID) Sets the context ID.
-
Method Details
-
newInstance
Creates a newly allocated StatelessPreRatingContext object.- Returns:
- a newly allocated StatelessPreRatingContext object.
-
newInstance
Creates a newly allocated StatelessPreRatingContext object.- Parameters:
contextID- the context ID for the created context.- Returns:
- a newly allocated StatelessPreRatingContext object.
-
setContextID
Sets the context ID. This ID is mainly for external use in the integration code.- Parameters:
contextID- the context ID.
-
getContextID
Returns the context ID.- Returns:
- the context ID.
- See Also:
-
addStatelessRatingContext
public abstract StatelessRatingContext addStatelessRatingContext(StatelessRatingContext ratingContext, 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 StatelessRatingContextchargeCode- the charge code for which the ratingContext will be dedicated- Returns:
- the added StatelessRatingContext
- See Also:
-
removeStatelessRatingContext
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
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
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
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
Returns a list containing any charge code for which one StatelessRatingContext is dedicated in this StatelessPreRatingContext.- Returns:
- a list of
String
-
isChargeRemovable
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 codeexpirationDate- 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
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 asisChargeRemovable(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
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 asisRemovable(null)- Returns:
- true iff no more pending pre-rating exists for this context.
-