public class PromotionResult extends GeneratedPromotionResult
PromotionResult is associated with a single
AbstractPromotion and is either fired (getFired()) or potentially could fire (
getCouldFire()).
A result that has fired as met all the requirements of the promotion. A result that potentially could fire has not
met all the requirements of the promotion. When the result could fire the promotion also assigns a certainty (
GeneratedPromotionResult.getCertainty()) value to the result to indicate how close the result is to firing. This is a value in the
range 0 to 1, where 1 indicates that the promotion has fired. This value can be used to rank potential promotion
results.
A promotion result holds a number of PromotionOrderEntryConsumed instances to represent the entries in the
order that have been consumed by the promotion in generating this result. If the promotion has fired then these
consumed entries are not available to other promotions. If the promotion has not fired then these consumed entries
are just an indication of the entries that will be consumed when the promotion can fire.
If the promotion has fired the promotion result also holds a number of AbstractPromotionAction instances to
represent the actions that the promotion takes. These actions are either applied or not (isApplied()). When
the promotions are evaluated by
PromotionsManager.updatePromotions(SessionContext, Collection, de.hybris.platform.jalo.order.AbstractOrder, boolean, de.hybris.platform.promotions.jalo.PromotionsManager.AutoApplyMode, de.hybris.platform.promotions.jalo.PromotionsManager.AutoApplyMode, java.util.Date)
a firing promotion result may be automatically applied depending on the parameters passed to the method. The actions
of a specific promotion result can be applied by calling the apply() method.
The actions of a specific promotion result can be reversed by calling the undo() method.GenericItem.GenericItemImplLocalizableItem.LocalizableItemImplExtensibleItem.ExtensibleItemImplItem.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationExceptionACTIONS, ALLPROMOTIONACTIONS, ALLPROMOTIONACTIONSHANDLER, CERTAINTY, CONSUMEDENTRIES, CUSTOM, DEFAULT_INITIAL_ATTRIBUTES, ORDER, ORDERHANDLER, PROMOTIONLANGUAGE_FALLBACK_ENABLED_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPEimpl, tenant| Constructor and Description |
|---|
PromotionResult() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAction(SessionContext ctx,
AbstractPromotionAction action)
Adds an action to the promotion results.
|
void |
addConsumedEntry(SessionContext ctx,
PromotionOrderEntryConsumed poec)
Adds a consumed entry to the current result.
|
boolean |
apply()
Applies all of the actions that this promotion generated to the order.
|
boolean |
apply(SessionContext ctx)
Applies all of the actions that this promotion generated to the order.
|
protected Collection<AbstractPromotionAction> |
deepCloneAllActions(SessionContext ctx)
Clones all the actions attached to this promotion result.
|
protected Collection<PromotionOrderEntryConsumed> |
deepCloneConsumedEntriesAndAttachToOrder(SessionContext ctx,
Order target)
Clones of the consumed order entries attached to this promotion result and attach them to order entries in the
specified order.
|
protected static PromotionOrderEntryConsumed |
deepCloneConsumedEntryAndAttachToOrder(SessionContext ctx,
PromotionOrderEntryConsumed source,
List<AbstractOrderEntry> allTargetEntries)
Clones a consumed order entry and attach it to an order entry from the list specified.
|
protected static AbstractOrderEntry |
findOrderEntryWithEntryNumber(List<AbstractOrderEntry> allTargetEntries,
int entryNumber)
Finds the order entry with the specified entry number.
|
Collection |
getActions(SessionContext ctx)
Gets the collection of
AbstractPromotionAction instances. |
long |
getConsumedCount(boolean includeCouldFirePromotions)
Gets the total number of items consumed by this promotion.
|
long |
getConsumedCount(SessionContext ctx,
boolean includeCouldFirePromotions)
Gets the total number of items consumed by this promotion.
|
Collection |
getConsumedEntries(SessionContext ctx)
Gets the collection of
PromotionOrderEntryConsumed consumed. |
boolean |
getCouldFire()
Is this a potential result.
|
boolean |
getCouldFire(SessionContext ctx)
Is this a potential result.
|
protected String |
getDataUnigueKey(SessionContext ctx)
Generates a string identifier that can be used to establish if 2 PromotionResults are the same.
|
String |
getDescription()
Gets the description of this promotion result.
|
String |
getDescription(Locale locale)
Gets the description of this promotion result.
|
String |
getDescription(SessionContext ctx,
Locale locale)
Gets the description of this promotion result.
|
boolean |
getFired()
Returns true if the promotion fired and has produced a result.
|
boolean |
getFired(SessionContext ctx)
Returns true if the promotion fired and has produced a result.
|
double |
getTotalDiscount()
Gets the total value of all discounts in this result.
|
double |
getTotalDiscount(SessionContext ctx)
Gets the total value of all discounts in this result.
|
boolean |
isApplied()
Returns true if the promotion fired and all of its actions have been applied to the order.
|
boolean |
isApplied(SessionContext ctx)
Returns true if the promotion fired and all of its actions have been applied to the order.
|
boolean |
isAppliedToOrder(SessionContext ctx)
Returns true if the promotion fired and all of its actions have been applied to the order.
|
protected boolean |
isValid(SessionContext ctx)
Is this promotion result valid.
|
void |
remove(SessionContext ctx)
Removes the item.
|
void |
removeConsumedEntry(SessionContext ctx,
PromotionOrderEntryConsumed poec)
Removes a consumed entry from the current result.
|
void |
setActions(SessionContext ctx,
Collection actions)
Sets the collection of
AbstractPromotionAction instance. |
void |
setConsumedEntries(SessionContext ctx,
Collection promotionOrderEntryConsumeds)
Sets the collection of
PromotionOrderEntryConsumed consumed. |
protected PromotionResult |
transferToOrder(SessionContext ctx,
Order target)
Creates a deep clone of this promotion result and attach it to the specified order.
|
boolean |
undo()
Undoes all of the changes that this promotion made to the order.
|
boolean |
undo(SessionContext ctx)
Undoes all of the changes that this promotion made to the order.
|
addToAllPromotionActions, addToAllPromotionActions, createItem, getActions, getAllPromotionActions, getAllPromotionActions, getCertainty, getCertainty, getCertaintyAsPrimitive, getCertaintyAsPrimitive, getConsumedEntries, getCustom, getCustom, getDefaultAttributeModes, getOrder, getOrder, getPromotion, getPromotion, removeFromAllPromotionActions, removeFromAllPromotionActions, setActions, setAllPromotionActions, setAllPromotionActions, setCertainty, setCertainty, setCertainty, setCertainty, setConsumedEntries, setCustom, setCustom, setOrder, setOrder, setPromotion, setPromotiongetInitialProperties, getNonInitialAttributesgetAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedPropertycreateNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setPropertyaddLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addLinkedItems, addNegativePermission, addPermission, addPositivePermission, assureExtensionsLoaded, changeTypeAfterCreation, checkConstraint, checkItemPermission, checkMandatoryAttribute, checkMandatoryAttribute, checkPermission, checkPermission, checkRemovable, clearPermission, compareTo, ctx, doAfterRemove, doBeforeRemove, equals, getAccessorFor, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributes, getAllAttributesInternal, getAllLinkedItems, getAndCheckCacheBoundItem, getAttribute, getAttribute, getCacheBoundItem, getComposedType, getComposedTypePK, getCreationTime, getCurrentlyRemovingCount, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItems, getLinkedItemsCount, getLinkedItemsCount, getLinkedItemsCount, getModificationTime, getNegativePermissions, getOwner, getPermissionMap, getPermissions, getPersistenceVersion, getPK, getPositivePermissions, getRestrictedPrincipals, getSession, getSyncObject, getTenant, getTransientObject, getTransientObjectMap, hashCode, hasRegisteredClassAccessorFor, internal_registerClassAccessorFor, internal_registerNonClassAccessorFor, invalidateLocalCaches, isAlive, isCacheBound, isCurrentlyRemoving, isCurrentlyRemoving, isEmptyRelationValue, isInCreate, isInstanceOf, isItemCheckBeforeRemoveableDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, readResolve, refreshRemote, registerAccessFor, registerAccessFor, registerJaloInvalidationListeners, remove, removeItemCollection, removeItemCollection, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinkedItems, removeLinks, removePartOfItems, removePartOfItems, setAllAttributes, setAllAttributes, setAllAttributesInternal, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAllLinkedItems, setAttribute, setAttribute, setAttributeFromString, setAttributeFromString, setCacheBound, setComposedType, setCreationTime, setImplementation, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setLinkedItems, setModificationTime, setNonInitialAttributes, setOwner, setPermissionsByMap, setTransientObject, setUseTA, toString, useTA, writeReplacegetImplementation, setTenantpublic void remove(SessionContext ctx) throws ConsistencyCheckException
remove in class Itemctx - A SessionContext objectConsistencyCheckException - if this item could not be removed for some reasonpublic final boolean isApplied()
public boolean isApplied(SessionContext ctx)
ctx - The hybris session contextpublic boolean isAppliedToOrder(SessionContext ctx)
ctx - The hybris session contextpublic final boolean getFired()
public boolean getFired(SessionContext ctx)
ctx - The hybris session contextpublic final boolean getCouldFire()
public boolean getCouldFire(SessionContext ctx)
ctx - The hybris session contextpublic final String getDescription()
getDescription(java.util.Locale)public final String getDescription(Locale locale)
Locale specified is used to format any numbers, dates or currencies for display to the user. It is
important that this locale best represents the formatting options appropriate for display to the user. The default
currency for the locale is ignored. The currency is always explicitly taken from the
GeneratedAbstractOrder.getCurrency(). The currency is then formatted appropriately in
the locale specified. For example, this does mean that values in the EURO currency will be formatted differently
depending on the locale specified as each locale can specify currency specific formatting.
The currency formatting is part of the Java VM configuration to support multiple locales. If the formatting is
incorrect check your VM configuration for the locale and currency combination.locale - The locale to use to format the messages. This locale must support currency formatting, i.e. this should
be a region specific local. e.g de_DE, en_US, en_GBpublic String getDescription(SessionContext ctx, Locale locale)
Locale specified is used to format any numbers, dates or currencies for display to the user. It is
important that this locale best represents the formatting options appropriate for display to the user. The default
currency for the locale is ignored. The currency is always explicitly taken from the
GeneratedAbstractOrder.getCurrency(). The currency is then formatted appropriately in
the locale specified. For example, this does mean that values in the EURO currency will be formatted differently
depending on the locale specified as each locale can specify currency specific formatting.
The currency formatting is part of the Java VM configuration to support multiple locales. If the formatting is
incorrect check your VM configuration for the locale and currency combination.ctx - The hybris session contextlocale - The locale to use to format the messages. This locale must support currency formatting, i.e. this must
be a region specific local. e.g de_DE, en_US, en_GBpublic final boolean apply()
public boolean apply(SessionContext ctx)
ctx - The hybris session contextpublic final boolean undo()
public boolean undo(SessionContext ctx)
ctx - The hybris session contextpublic final long getConsumedCount(boolean includeCouldFirePromotions)
includeCouldFirePromotions - include could fire promotionspublic long getConsumedCount(SessionContext ctx, boolean includeCouldFirePromotions)
ctx - The hybris session contextincludeCouldFirePromotions - include could fire promotionspublic final double getTotalDiscount()
public double getTotalDiscount(SessionContext ctx)
ctx - The session contextprotected boolean isValid(SessionContext ctx)
ctx - The hybris contextpublic void addAction(SessionContext ctx, AbstractPromotionAction action)
ctx - The hybris contextaction - The action to addpublic void addConsumedEntry(SessionContext ctx, PromotionOrderEntryConsumed poec)
ctx - the hybris contextpoec - the entry to addpublic void removeConsumedEntry(SessionContext ctx, PromotionOrderEntryConsumed poec)
ctx - the hybris contextpoec - the entry to removeprotected PromotionResult transferToOrder(SessionContext ctx, Order target)
ctx - The hybris contexttarget - the target order to transfer toprotected Collection<AbstractPromotionAction> deepCloneAllActions(SessionContext ctx)
ctx - the hybris contextprotected Collection<PromotionOrderEntryConsumed> deepCloneConsumedEntriesAndAttachToOrder(SessionContext ctx, Order target)
ctx - the hybris contexttarget - the target order to attach the consumed order entries toprotected static PromotionOrderEntryConsumed deepCloneConsumedEntryAndAttachToOrder(SessionContext ctx, PromotionOrderEntryConsumed source, List<AbstractOrderEntry> allTargetEntries)
ctx - the hybris contextsource - the consumed entry to cloneallTargetEntries - the list of order entries in the target orderprotected static AbstractOrderEntry findOrderEntryWithEntryNumber(List<AbstractOrderEntry> allTargetEntries, int entryNumber)
allTargetEntries - the list of order entriesentryNumber - the entry number to search forpublic Collection getConsumedEntries(SessionContext ctx)
PromotionOrderEntryConsumed consumed.getConsumedEntries in class GeneratedPromotionResultctx - The hybris session contextPromotionOrderEntryConsumed consumed by this result.public void setConsumedEntries(SessionContext ctx, Collection promotionOrderEntryConsumeds)
PromotionOrderEntryConsumed consumed.
The PromotionOrderEntryConsumed instances associated with this promotion result are owned (and part of)
this result. They cannot belong to another instance, therefore when setting the collection any
PromotionOrderEntryConsumed instances previously associated with this result, that are no longer
associated are deleted from the database.setConsumedEntries in class GeneratedPromotionResultctx - The hybris session contextpromotionOrderEntryConsumeds - the collection of consumed entriespublic Collection getActions(SessionContext ctx)
AbstractPromotionAction instances.getActions in class GeneratedPromotionResultctx - The hybris session contextAbstractPromotionAction instances attached to this result.public void setActions(SessionContext ctx, Collection actions)
AbstractPromotionAction instance.
The AbstractPromotionAction instances associated with this promotion result are owned (and part of) this
result. They cannot belong to another instance, therefore when setting the collection any
AbstractPromotionAction instances previously associated with this result, that are no longer associated
are deleted from the database.setActions in class GeneratedPromotionResultctx - The hybris session contextactions - the collection of actionsprotected String getDataUnigueKey(SessionContext ctx)
ctx - The hybris contextCopyright © 2017 SAP SE. All Rights Reserved.