Class AbstractPromotion
java.lang.Object
de.hybris.platform.util.BridgeAbstraction
de.hybris.platform.jalo.Item
de.hybris.platform.jalo.ExtensibleItem
de.hybris.platform.jalo.c2l.LocalizableItem
de.hybris.platform.jalo.GenericItem
de.hybris.platform.promotions.jalo.GeneratedAbstractPromotion
de.hybris.platform.promotions.jalo.AbstractPromotion
- All Implemented Interfaces:
Serializable,Comparable
- Direct Known Subclasses:
GeneratedOrderPromotion,GeneratedProductPromotion,GeneratedRuleBasedPromotion
AbstractPromotion. The base class for all promotions.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class de.hybris.platform.jalo.GenericItem
GenericItem.GenericItemImplNested classes/interfaces inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LocalizableItem.LocalizableItemImplNested classes/interfaces inherited from class de.hybris.platform.jalo.ExtensibleItem
ExtensibleItem.ExtensibleItemImplNested classes/interfaces inherited from class de.hybris.platform.jalo.Item
Item.AttributeFilter, Item.AttributeMode, Item.CachedGetter, Item.CachedSetter, Item.ItemAttributeMap, Item.ItemConstraint, Item.ItemImpl, Item.JaloCachedComputationException -
Field Summary
Fields inherited from class de.hybris.platform.promotions.jalo.GeneratedAbstractPromotion
CODE, DEFAULT_INITIAL_ATTRIBUTES, DESCRIPTION, DETAILSURL, ENABLED, ENDDATE, IMMUTABLEKEY, IMMUTABLEKEYHASH, NAME, PRIORITY, PROMOTIONGROUP, PROMOTIONGROUPHANDLER, PROMOTIONTYPE, RESTRICTIONS, STARTDATE, TITLEFields inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
LANGUAGE_FALLBACK_ENABLEDFields inherited from class de.hybris.platform.jalo.Item
_CREATION_TIME_INTERNAL, _MODIFIED_TIME_INTERNAL, accessorLog, CREATION_TIME, DISABLE_ATTRIBUTE_CHECK, DISABLE_ITEMCHECK_BEFORE_REMOVABLE, EVEN, FEATURE_ACCESSMAP_QUALIFIER, HJMPTS, INITIAL_CREATION_FLAG, isJaloOnly, MODIFIED_TIME, NEGATIVE, NOT_FOUND, OWNER, PK, POSITIVE, SAVE_FROM_SERVICE_LAYER, staticTransientObjects, TYPEFields inherited from class de.hybris.platform.util.BridgeAbstraction
impl, tenant -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbuildDataUniqueKey(SessionContext ctx, StringBuilder builder) Build a unique data driven key.protected static final voidbuildDataUniqueKeyForCategories(SessionContext ctx, StringBuilder builder, Collection<Category> categories) protected static final voidbuildDataUniqueKeyForPriceRows(SessionContext ctx, StringBuilder builder, Collection<PromotionPriceRow> priceRows) protected static final voidbuildDataUniqueKeyForProducts(SessionContext ctx, StringBuilder builder, Collection<Product> products) protected static final StringbuildMD5Hash(String message) protected voidbuildPromotionResultDataUnigueKey(SessionContext ctx, PromotionResult promotionResult, StringBuilder builder) Build a unique identifier for a PromotionResult.protected final AbstractPromotioncreateImmutableDeepClone(SessionContext ctx, String immutableKeyHash, String immutableKey) protected ItemcreateItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) Create the item.protected voiddeepCloneAttributes(SessionContext ctx, Map values) Called to deep clone attributes of this instance.protected static final Collection<PromotionPriceRow>deepClonePriceRows(SessionContext ctx, Collection<PromotionPriceRow> priceRows) static voiddeletePromotionPriceRows(SessionContext ctx, Collection<PromotionPriceRow> prices) Helper method to delete promotion price rows from the database.abstract List<PromotionResult>evaluate(SessionContext ctx, PromotionEvaluationContext promoContext) Evaluate whether a promotion can fire or not.protected static final AbstractPromotionfindImmutablePromotionByUniqueKey(JaloSession jaloSession, SessionContext ctx, String immutableKeyHash, String immutableKey) protected final AbstractPromotionFind or create an immutable clone of this promotion.protected static final StringformatMessage(String pattern, Object[] arguments, Locale locale) Format a message pattern using the MessageFormatGet promotionType for all supported languages.protected final StringBuild a unique data driven key.protected final DoublegetPriceForOrder(SessionContext ctx, Collection<PromotionPriceRow> prices, AbstractOrder order, String fieldLabel) Lookup the price for an order.protected final StringgetPromotionResultDataUnigueKey(SessionContext ctx, PromotionResult promotionResult) Generate a string identifier that can be used to establish if 2 PromotionResults are the same.Return the type name for this promotion instance.final CollectionGet the collection ofAbstractPromotionRestrictioninstances.abstract StringgetResultDescription(SessionContext ctx, PromotionResult promotionResult, Locale locale) Get a localized user presentable description for the result of this promotion.voidremove(SessionContext ctx) Remove the item.voidsetPromotionGroup(SessionContext ctx, PromotionGroup promotionGroup) Override the default behaviour to prevent PromotionGroup from being set to null.final voidsetRestrictions(SessionContext ctx, Collection restrictions) Set the collection ofAbstractPromotionRestrictioninstance.toString()Get a simple description of promotion object.Methods inherited from class de.hybris.platform.promotions.jalo.GeneratedAbstractPromotion
getAllName, getAllName, getAllPromotionType, getCode, getCode, getDefaultAttributeModes, getDescription, getDescription, getDetailsURL, getDetailsURL, getEndDate, getEndDate, getImmutableKey, getImmutableKey, getImmutableKeyHash, getImmutableKeyHash, getName, getName, getPriority, getPriority, getPriorityAsPrimitive, getPriorityAsPrimitive, getPromotionGroup, getPromotionGroup, getPromotionType, getRestrictions, getStartDate, getStartDate, getTitle, getTitle, isEnabled, isEnabled, isEnabledAsPrimitive, isEnabledAsPrimitive, setAllName, setAllName, setCode, setCode, setDescription, setDescription, setDetailsURL, setDetailsURL, setEnabled, setEnabled, setEnabled, setEnabled, setEndDate, setEndDate, setImmutableKey, setImmutableKey, setImmutableKeyHash, setImmutableKeyHash, setName, setName, setPriority, setPriority, setPriority, setPriority, setPromotionGroup, setRestrictions, setStartDate, setStartDate, setTitle, setTitleMethods inherited from class de.hybris.platform.jalo.GenericItem
getImplementation, getInitialProperties, getNonInitialAttributes, getRelatedItems, getRelatedItems, setRelatedItemsMethods inherited from class de.hybris.platform.jalo.c2l.LocalizableItem
getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllLocalizedProperties, getAllValuesSessionContext, getLocalizedProperty, getLocalizedProperty, getLocalizedPropertyInternal, getLocalizedPropertyNames, getLocalizedPropertyNames, hasLanguage, isEmptyValue, isFallbackEnabled, removeLocalizedProperty, removeLocalizedProperty, setAllLocalizedProperties, setAllLocalizedProperties, setLocalizedProperty, setLocalizedPropertyMethods inherited from class de.hybris.platform.jalo.ExtensibleItem
createNonClassAccessor, getAllProperties, getAllProperties, getProperty, getProperty, getPropertyNames, getPropertyNames, removeProperty, removeProperty, setAllProperties, setAllProperties, setProperty, setPropertyMethods inherited from class de.hybris.platform.jalo.Item
addLinkedItems, 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, getPartOfRemovedSessionMarker, 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, isMarkModifiedDisabled, isRelationLocalizationFallbackEnabled, newInstance, notifyExtensionsAfterItemCreation, notifyExtensionsBeforeItemCreation, notifyItemRemoval, notifyManagerAboutItemRemoval, readResolve, 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, suppressRelation, useTA, writeReplaceMethods inherited from class de.hybris.platform.util.BridgeAbstraction
setTenant
-
Constructor Details
-
AbstractPromotion
public AbstractPromotion()
-
-
Method Details
-
createItem
protected Item createItem(SessionContext ctx, ComposedType type, Item.ItemAttributeMap allAttributes) throws JaloBusinessException Create the item.- Overrides:
createItemin classGeneratedAbstractPromotion- Parameters:
ctx- the current session context which this item is created withintype- the actual item type ( since subtypes may not provide a own jalo class this may be different from the type which this method was implemented for )- Returns:
- the new item instance
- Throws:
JaloBusinessException- indicates an error during creation - any changes will be rollbacked
-
remove
Remove the item. When the promotion is removed any associated restriction items are also removed.- Overrides:
removein classItem- Parameters:
ctx- A SessionContext object- Throws:
ConsistencyCheckException- if this item could not be removed for some reason
-
toString
Get a simple description of promotion object. -
getPromotionType
Return the type name for this promotion instance.- Specified by:
getPromotionTypein classGeneratedAbstractPromotion- Parameters:
ctx- The hybris context- Returns:
- the type name for this instance.
-
getAllPromotionType
Get promotionType for all supported languages.- Specified by:
getAllPromotionTypein classGeneratedAbstractPromotion- Parameters:
ctx- The hybris context- Returns:
- a map of the type names keyed by language.
-
setPromotionGroup
Override the default behaviour to prevent PromotionGroup from being set to null.- Overrides:
setPromotionGroupin classGeneratedAbstractPromotion- Parameters:
ctx- The hybris contextpromotionGroup- The promotion group to set
-
evaluate
public abstract List<PromotionResult> evaluate(SessionContext ctx, PromotionEvaluationContext promoContext) Evaluate whether a promotion can fire or not.- Parameters:
ctx- The context to run the operation inpromoContext- The evaluation context- Returns:
- the list of promotion results that this promotions creates
-
getResultDescription
public abstract String getResultDescription(SessionContext ctx, PromotionResult promotionResult, Locale locale) Get a localized user presentable description for the result of this promotion.- Parameters:
ctx- The contextpromotionResult- The promotion result to be describedlocale- The locale to use to generate the message- Returns:
- a string description
-
getPriceForOrder
protected final Double getPriceForOrder(SessionContext ctx, Collection<PromotionPriceRow> prices, AbstractOrder order, String fieldLabel) Lookup the price for an order. Lookup the price for the currency specified on the order.- Parameters:
ctx- The hybris contextprices- The collection ofPromotionPriceRowwhich is the set of pricesorder- The order to lookup the price forfieldLabel- A string label to use when generating error messages.- Returns:
- The price for the order's currency or null if not specified
-
formatMessage
Format a message pattern using the MessageFormat- Parameters:
pattern- the message patternarguments- the arguments to pass into the patternlocale- the rendering locale- Returns:
- a formatted string
-
findOrCreateImmutableClone
Find or create an immutable clone of this promotion.- Parameters:
ctx- the hybris context- Returns:
- the immutable version of this promotion
-
buildMD5Hash
-
createImmutableDeepClone
protected final AbstractPromotion createImmutableDeepClone(SessionContext ctx, String immutableKeyHash, String immutableKey) -
findImmutablePromotionByUniqueKey
protected static final AbstractPromotion findImmutablePromotionByUniqueKey(JaloSession jaloSession, SessionContext ctx, String immutableKeyHash, String immutableKey) -
getDataUniqueKey
Build a unique data driven key. Build a unique key that is data driven. This will uniquely identify the rules used in this promotion and will form the immutable key for stored promotions.- Parameters:
ctx- The hybris context- Returns:
- A
StringBuilderused to build up the immutable key
-
buildDataUniqueKey
Build a unique data driven key. Build a unique key that is data driven. This will uniquely identify the rules used in this promotion and will form the immutable key for stored promotions. This method may be overridden in a subclass to customize the identifier.- Parameters:
ctx- The hybris contextbuilder- AStringBuilderused to build up the immutable key
-
deepCloneAttributes
Called to deep clone attributes of this instance. The values map contains all the attributes defined on this instance. The map will be used to initialize a new instance of the Action that is a clone of this instance. This method can remove, replace or add to the Map of attributes.- Parameters:
ctx- The hybris contextvalues- The map to write into
-
deepClonePriceRows
protected static final Collection<PromotionPriceRow> deepClonePriceRows(SessionContext ctx, Collection<PromotionPriceRow> priceRows) -
buildDataUniqueKeyForPriceRows
protected static final void buildDataUniqueKeyForPriceRows(SessionContext ctx, StringBuilder builder, Collection<PromotionPriceRow> priceRows) -
buildDataUniqueKeyForProducts
protected static final void buildDataUniqueKeyForProducts(SessionContext ctx, StringBuilder builder, Collection<Product> products) -
buildDataUniqueKeyForCategories
protected static final void buildDataUniqueKeyForCategories(SessionContext ctx, StringBuilder builder, Collection<Category> categories) -
getRestrictions
Get the collection ofAbstractPromotionRestrictioninstances.- Specified by:
getRestrictionsin classGeneratedAbstractPromotion- Parameters:
ctx- The hybris session context- Returns:
- A collection of
AbstractPromotionRestrictioninstances attached to this promotion.
-
setRestrictions
Set the collection ofAbstractPromotionRestrictioninstance. TheAbstractPromotionRestrictioninstances associated with this promotion are owned (and part of) this promotion. They cannot belong to another instance, therefore when setting the collection anyAbstractPromotionRestrictioninstances previously associated with this promotion, that are no longer associated are deleted from the database.- Specified by:
setRestrictionsin classGeneratedAbstractPromotion- Parameters:
ctx- The hybris session contextrestrictions- the collection of restrictions
-
deletePromotionPriceRows
public static void deletePromotionPriceRows(SessionContext ctx, Collection<PromotionPriceRow> prices) throws ConsistencyCheckException Helper method to delete promotion price rows from the database.- Parameters:
ctx- The hybris contextprices- The prices to delete- Throws:
ConsistencyCheckException
-
getPromotionResultDataUnigueKey
protected final String getPromotionResultDataUnigueKey(SessionContext ctx, PromotionResult promotionResult) Generate a string identifier that can be used to establish if 2 PromotionResults are the same. The identifier should be based on the data for the PromotionResult, e.g. the promotion that created it, the number and type of products consumed, the actions created. This method is final, but calls thebuildPromotionResultDataUnigueKey(de.hybris.platform.jalo.SessionContext, de.hybris.platform.promotions.jalo.PromotionResult, java.lang.StringBuilder)method to allow subclasses to affect the way the identifier is built.- Parameters:
ctx- The hybris contextpromotionResult- The promotion result- Returns:
- a string that identifies this promotion result
-
buildPromotionResultDataUnigueKey
protected void buildPromotionResultDataUnigueKey(SessionContext ctx, PromotionResult promotionResult, StringBuilder builder) Build a unique identifier for a PromotionResult. This method is called fromgetPromotionResultDataUnigueKey(de.hybris.platform.jalo.SessionContext, de.hybris.platform.promotions.jalo.PromotionResult). This method may be overridden by a subclass to customize how the identifier is built.- Parameters:
ctx- The hybris contextpromotionResult- The promotion resultbuilder- A StringBuilder used to build up the identifier
-