atg.commerce.promotion
Class PromotionTools

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.promotion.PromotionTools
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class PromotionTools
extends GenericService


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String COPIED_DURING_LOGIN
           
protected  ComponentName mUserPricingModelHolderPath
           
static java.lang.String REVOKED_DURING_LOGIN
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
PromotionTools()
           
 
Method Summary
 void addAllPromotions(MutableRepositoryItem pProfile, java.util.Collection pPromotions)
          Adds all of the promotions in the collection to the user's activePromotion attribute value.
 void addAllPromotions(MutableRepositoryItem pProfile, java.util.Collection pPromotions, java.lang.String pComment)
          Adds all of the promotions in the collection to the user's activePromotion attribute value.
 boolean addPromotion(MutableRepositoryItem pProfile, RepositoryItem pPromotion)
          Adds the promotion to the user's activePromotion attribute value.
 boolean addPromotion(MutableRepositoryItem pProfile, RepositoryItem pPromotion, java.lang.String pComment)
          Adds the promotion to the user's activePromotion attribute value.
 java.util.Map calculatePromotionsForOrder(Order pOrder)
          This method will return a map containing the count of promotions contained in the given order, and the total value of those promotions
 boolean checkPromotionExpiration(RepositoryItem pPromotion, java.util.Date pNow)
          Return true if the promotion or the promotionStatus has expired and should not be used in pricing.
 boolean consumePromotion(MutableRepositoryItem pProfile, RepositoryItem pPromotion)
          This method moves a promotion from the user's activePromotions list to their usedPromotions list.
 java.util.Collection convertPromoStatusToPromo(java.util.Collection pPromoStatuses)
           
 RepositoryItem createPromotionStatus(RepositoryItem pProfile, RepositoryItem pPromotion, java.lang.Integer pNumUses)
          This method creates a PromotionStatus repository item and returns it.
 void expirePromotion(RepositoryItem pPromotion, RepositoryItem pProfile)
          This method will remove the passed in promotion from the Profile.
 java.lang.String getActivePromotionsProperty()
          Property of the profile to which we add new promotions
 java.lang.String getAddItemEventPipeline()
          The name of the pipeline used to send the ScenarioAddedItemToOrder event Defaults to PipelineConstants.SENDSCENARIOEVENT
 java.lang.String getAllowMultipleProperty()
          Property name of the 'allowMultiple' property in the promotion
 java.lang.String[] getAlternateUserPricingModelHolderPaths()
          Returns property AlternateUserPricingModelHolderPaths
 java.lang.String getBasePromotionItemType()
          Returns property BasePromotionItemType
 GetService getGetService()
          The tool used to convert promotions to xml in getPromotionsAsXML
 java.lang.String getGiveToAnonymousProfilesProperty()
          Property name of the 'giveToAnonymousProfiles' property in the promotion
 void getItemPromotions(CommerceItem pItem, java.util.Collection pPromotions)
          Returns the promotions used in the CommerceItem.
 void getItemPromotions(CommerceItem pItem, java.util.Collection pPromotions, boolean pGetAdjustments)
          Returns the promotions used in the CommerceItem.
 java.lang.String getMappingFileName()
          The name of the mapping file that describes the XML format for getPromotionsAsXML
 void getOrderPromotions(Order pOrder, java.util.Collection pPromotions)
          Returns the promotions used in the order.
 void getOrderPromotions(Order pOrder, java.util.Collection pPromotions, boolean pGetAdjustments)
          Returns the promotions used in the order.
 void getOrderPromotions(Order pOrder, java.util.Collection pOrderPromotions, java.util.Collection pTaxPromotions, java.util.Collection pItemPromotions, java.util.Collection pShippingPromotions)
          This method retrieves all the promotions in an order and adds them to their respective collection.
 void getOrderPromotions(Order pOrder, java.util.Collection pOrderPromotions, java.util.Collection pTaxPromotions, java.util.Collection pItemPromotions, java.util.Collection pShippingPromotions, boolean pGetAdjustments)
          This method retrieves all the promotions in an order and adds them to their respective collection.
 PipelineManager getPipelineManager()
          The PipelineManager is used to run the pipeline process that sends scenario events
 PricingModelProperties getPricingModelProperties()
          Returns a bean that contains properties for a PricingModel
 PricingTools getPricingTools()
          Return the PricingTools component
 RepositoryItem getProfile(java.lang.String pProfileId)
          Gets the profile repository item with the given id
 java.lang.String getProfileItemType()
           
 MutableRepository getProfileRepository()
          Return the editable profile repository
 java.lang.String getPromoStatusDescriptorName()
          Returns the descriptor name for the promoStatus descriptor
 java.lang.String getPromoStatusNumUsesProperty()
          Returns the promoStatus num_uses property name
 java.lang.String getPromoStatusProfileIdProperty()
          Returns the promoStatus profile id property name
 java.lang.String getPromoStatusPromoProperty()
          Returns the promoStatus promo property name
 int getPromotionCount(Order pOrder, RepositoryItem pPromotion)
          Returns the number of times a promotion appears in the order.
 MessageSender getPromotionGrantedMessageSender()
          Gets property MessageSender.
 MessageSender getPromotionRevokedMessageSender()
          Gets property PromotionRevokedMessageSender.
 Repository getPromotions()
          Returns property Promotions
 java.util.Collection getPromotions(java.lang.String pProfileId)
          This method will look up the given profile and return all of the available promotions for that user.
 java.lang.String[] getPromotionsAsXML(java.lang.String pProfileId)
          This method will look up the given profile, and for each available promotion, will return an xml representation of it using the GetService and the mappingFileName.
 void getShippingPromotions(ShippingGroup pGroup, java.util.Collection pPromotions)
          Returns the promotions used in the ShippingGroup.
 void getShippingPromotions(ShippingGroup pGroup, java.util.Collection pPromotions, boolean pGetAdjustments)
          Returns the promotions used in the ShippingGroup.
 void getTaxPromotions(Order pOrder, java.util.Collection pPromotions)
          Returns the promotions used in the tax calculation.
 void getTaxPromotions(Order pOrder, java.util.Collection pPromotions, boolean pGetAdjustments)
          Returns the promotions used in the tax calculation.
 java.lang.String getUsedPromotionsProperty()
          Property of the profile to which we add consumed promotions
 java.lang.String getUserPricingModelHolderPath()
          Returns property UserPricingModelHolderPath
 java.lang.String getUsesProperty()
          Returns the usesProperty
 void grantPromotion(MutableRepositoryItem pProfile, RepositoryItem pPromotion)
          Adds the given promotion to the user's "activePromotions" list.
 void grantPromotion(MutableRepositoryItem pProfile, RepositoryItem pPromotion, java.lang.String pComment)
          Adds the given promotion to the user's "activePromotions" list.
 void grantPromotion(java.lang.String pProfileId, java.lang.String pPromotionId)
          Adds the given promotion to the user's "activePromotions" list.
 void grantPromotion(java.lang.String pProfileId, java.lang.String pPromotionId, java.lang.String pComment)
          Adds the given promotion to the user's "activePromotions" list.
 void initializePricingModels()
          Initialize the set of pricing models/promotions that a user currently holds while having an active session.
 void initializePricingModels(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Initialize the set of pricing models/promotions that a user currently holds while having an active session.
 boolean isFirePromotionGrantedEvent()
          Gets property FirePromotionGrantedEvent
 boolean isFirePromotionRevokedEvent()
          Gets property FirePromotionRevokedEvent
 boolean isSendEventOnAddItem()
          If this is true, then the ScenarioAddedItemToCart event will be sent If this is false, then the ScenarioAddedItemToCart event will not be sent.
 boolean removePromotion(MutableRepositoryItem pProfile, RepositoryItem pPromotion, boolean pRemoveAll)
          Removes the passed in promotion pPromotion from the pProfile's list of active promotions.
 boolean revokePromotion(MutableRepositoryItem pProfile, RepositoryItem pPromotion, boolean pRemoveAll)
          Removes the passed in promotion pPromotion from the pProfile's list of active promotions.
 boolean revokePromotion(java.lang.String pProfileId, java.lang.String pPromotionId, boolean pRemoveAllInstances)
          Removes the passed in promotion pPromotion from the pProfile's list of active promotions.
 boolean scenarioAddedItemToOrder(Order pOrder, CommerceItem pItem, long pQuantity)
          This method is called by the AddItemToOrder scenario action.
 void sendPromotionGrantedEvent(MutableRepositoryItem pProfile, RepositoryItem pPromotion)
          Sends an PromotionGranted Event through the PromotionGrantedMessageSender if FirePromotionGrantedEvent is set to true.
 void sendPromotionGrantedEvent(MutableRepositoryItem pProfile, RepositoryItem pPromotion, java.lang.String pComment)
          Sends an PromotionGranted Event through the PromotionGrantedMessageSender if FirePromotionGrantedEvent is set to true.
 void sendPromotionRevokedEvent(RepositoryItem pProfile, RepositoryItem pPromotion)
          Sends a PromotionRevoked Event through the PromotionRevokedMessageSender if FirePromotionRevokedEvent is set to true.
 void sendPromotionRevokedEvent(RepositoryItem pProfile, RepositoryItem pPromotion, java.lang.String pComment)
          Sends a PromotionRevoked Event through the PromotionRevokedMessageSender if FirePromotionRevokedEvent is set to true.
 void setActivePromotionsProperty(java.lang.String pActivePromotionsProperty)
           
 void setAddItemEventPipeline(java.lang.String pAddItemEventPipeline)
           
 void setAllowMultipleProperty(java.lang.String pAllowMultipleProperty)
           
 void setAlternateUserPricingModelHolderPaths(java.lang.String[] pAlternateUserPricingModelHolderPaths)
          Sets property AlternateUserPricingModelHolderPaths
 void setBasePromotionItemType(java.lang.String pBasePromotionItemType)
          Sets property BasePromotionItemType
 void setFirePromotionGrantedEvent(boolean pFirePromotionGrantedEvent)
          Sets property FirePromotionGrantedEvent
 void setFirePromotionRevokedEvent(boolean pFirePromotionRevokedEvent)
          Sets property FirePromotionRevokedEvent
 void setGetService(GetService pGetService)
           
 void setGiveToAnonymousProfilesProperty(java.lang.String pGiveToAnonymousProfilesProperty)
           
 void setMappingFileName(java.lang.String pMappingFileName)
           
 void setPipelineManager(PipelineManager pPipelineManager)
           
 void setPricingModelProperties(PricingModelProperties pPricingModelProperties)
           
 void setPricingTools(PricingTools pPricingTools)
           
 void setProfileItemType(java.lang.String pProfileItemType)
           
 void setProfileRepository(MutableRepository pProfileRepository)
           
 void setPromoStatusDescriptorName(java.lang.String pPromoStatusDescriptorName)
           
 void setPromoStatusNumUsesProperty(java.lang.String pPromoStatusNumUsesProperty)
           
 void setPromoStatusProfileIdProperty(java.lang.String pPromoStatusProfileIdProperty)
           
 void setPromoStatusPromoProperty(java.lang.String pPromoStatusPromoProperty)
           
 void setPromotionGrantedMessageSender(MessageSender pPromotionGrantedMessageSender)
          Sets property PromotionGrantedMessageSender.
 void setPromotionRevokedMessageSender(MessageSender pPromotionRevokedMessageSender)
          Sets property PromotionRevokedMessageSender.
 void setPromotions(Repository pPromotions)
          Sets property Promotions
 void setSendEventOnAddItem(boolean pSendEventOnAddItem)
           
 void setUsedPromotionsProperty(java.lang.String pUsedPromotionsProperty)
           
 void setUserPricingModelHolderPath(java.lang.String pUserPricingModelHolderPath)
          Sets property UserPricingModelHolderPath
 void setUsesProperty(java.lang.String pUsesProperty)
          Sets the usesProperty
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

COPIED_DURING_LOGIN

public static final java.lang.String COPIED_DURING_LOGIN
See Also:
Constant Field Values

REVOKED_DURING_LOGIN

public static final java.lang.String REVOKED_DURING_LOGIN
See Also:
Constant Field Values

mUserPricingModelHolderPath

protected ComponentName mUserPricingModelHolderPath
Constructor Detail

PromotionTools

public PromotionTools()
Method Detail

setFirePromotionGrantedEvent

public void setFirePromotionGrantedEvent(boolean pFirePromotionGrantedEvent)
Sets property FirePromotionGrantedEvent


isFirePromotionGrantedEvent

public boolean isFirePromotionGrantedEvent()
Gets property FirePromotionGrantedEvent


setFirePromotionRevokedEvent

public void setFirePromotionRevokedEvent(boolean pFirePromotionRevokedEvent)
Sets property FirePromotionRevokedEvent


isFirePromotionRevokedEvent

public boolean isFirePromotionRevokedEvent()
Gets property FirePromotionRevokedEvent


setPromotionGrantedMessageSender

public void setPromotionGrantedMessageSender(MessageSender pPromotionGrantedMessageSender)
Sets property PromotionGrantedMessageSender. The MessageSender is used to send PromotionGranted Events.


getPromotionGrantedMessageSender

public MessageSender getPromotionGrantedMessageSender()
Gets property MessageSender.


setPromotionRevokedMessageSender

public void setPromotionRevokedMessageSender(MessageSender pPromotionRevokedMessageSender)
Sets property PromotionRevokedMessageSender. The MessageSender is used to send PromotionRevoked Events.


getPromotionRevokedMessageSender

public MessageSender getPromotionRevokedMessageSender()
Gets property PromotionRevokedMessageSender.


setPipelineManager

public void setPipelineManager(PipelineManager pPipelineManager)

getPipelineManager

public PipelineManager getPipelineManager()
The PipelineManager is used to run the pipeline process that sends scenario events


setSendEventOnAddItem

public void setSendEventOnAddItem(boolean pSendEventOnAddItem)

isSendEventOnAddItem

public boolean isSendEventOnAddItem()
If this is true, then the ScenarioAddedItemToCart event will be sent If this is false, then the ScenarioAddedItemToCart event will not be sent. The default value is true


setAddItemEventPipeline

public void setAddItemEventPipeline(java.lang.String pAddItemEventPipeline)

getAddItemEventPipeline

public java.lang.String getAddItemEventPipeline()
The name of the pipeline used to send the ScenarioAddedItemToOrder event Defaults to PipelineConstants.SENDSCENARIOEVENT


setPricingModelProperties

public void setPricingModelProperties(PricingModelProperties pPricingModelProperties)

getPricingModelProperties

public PricingModelProperties getPricingModelProperties()
Returns a bean that contains properties for a PricingModel


setActivePromotionsProperty

public void setActivePromotionsProperty(java.lang.String pActivePromotionsProperty)

getActivePromotionsProperty

public java.lang.String getActivePromotionsProperty()
Property of the profile to which we add new promotions


setUsedPromotionsProperty

public void setUsedPromotionsProperty(java.lang.String pUsedPromotionsProperty)

getUsedPromotionsProperty

public java.lang.String getUsedPromotionsProperty()
Property of the profile to which we add consumed promotions


setAllowMultipleProperty

public void setAllowMultipleProperty(java.lang.String pAllowMultipleProperty)

getAllowMultipleProperty

public java.lang.String getAllowMultipleProperty()
Property name of the 'allowMultiple' property in the promotion


setGiveToAnonymousProfilesProperty

public void setGiveToAnonymousProfilesProperty(java.lang.String pGiveToAnonymousProfilesProperty)

getGiveToAnonymousProfilesProperty

public java.lang.String getGiveToAnonymousProfilesProperty()
Property name of the 'giveToAnonymousProfiles' property in the promotion


setUsesProperty

public void setUsesProperty(java.lang.String pUsesProperty)
Sets the usesProperty


getUsesProperty

public java.lang.String getUsesProperty()
Returns the usesProperty


setPromoStatusDescriptorName

public void setPromoStatusDescriptorName(java.lang.String pPromoStatusDescriptorName)

getPromoStatusDescriptorName

public java.lang.String getPromoStatusDescriptorName()
Returns the descriptor name for the promoStatus descriptor


setPromoStatusProfileIdProperty

public void setPromoStatusProfileIdProperty(java.lang.String pPromoStatusProfileIdProperty)

getPromoStatusProfileIdProperty

public java.lang.String getPromoStatusProfileIdProperty()
Returns the promoStatus profile id property name


setPromoStatusNumUsesProperty

public void setPromoStatusNumUsesProperty(java.lang.String pPromoStatusNumUsesProperty)

getPromoStatusNumUsesProperty

public java.lang.String getPromoStatusNumUsesProperty()
Returns the promoStatus num_uses property name


setPromoStatusPromoProperty

public void setPromoStatusPromoProperty(java.lang.String pPromoStatusPromoProperty)

getPromoStatusPromoProperty

public java.lang.String getPromoStatusPromoProperty()
Returns the promoStatus promo property name


setProfileRepository

public void setProfileRepository(MutableRepository pProfileRepository)

getProfileRepository

public MutableRepository getProfileRepository()
Return the editable profile repository


setProfileItemType

public void setProfileItemType(java.lang.String pProfileItemType)

getProfileItemType

public java.lang.String getProfileItemType()

setPricingTools

public void setPricingTools(PricingTools pPricingTools)

getPricingTools

public PricingTools getPricingTools()
Return the PricingTools component


setPromotions

public void setPromotions(Repository pPromotions)
Sets property Promotions


getPromotions

public Repository getPromotions()
Returns property Promotions


setBasePromotionItemType

public void setBasePromotionItemType(java.lang.String pBasePromotionItemType)
Sets property BasePromotionItemType


getBasePromotionItemType

public java.lang.String getBasePromotionItemType()
Returns property BasePromotionItemType


setUserPricingModelHolderPath

public void setUserPricingModelHolderPath(java.lang.String pUserPricingModelHolderPath)
Sets property UserPricingModelHolderPath


getUserPricingModelHolderPath

public java.lang.String getUserPricingModelHolderPath()
Returns property UserPricingModelHolderPath


setAlternateUserPricingModelHolderPaths

public void setAlternateUserPricingModelHolderPaths(java.lang.String[] pAlternateUserPricingModelHolderPaths)
Sets property AlternateUserPricingModelHolderPaths


getAlternateUserPricingModelHolderPaths

public java.lang.String[] getAlternateUserPricingModelHolderPaths()
Returns property AlternateUserPricingModelHolderPaths


setGetService

public void setGetService(GetService pGetService)

getGetService

public GetService getGetService()
The tool used to convert promotions to xml in getPromotionsAsXML


setMappingFileName

public void setMappingFileName(java.lang.String pMappingFileName)

getMappingFileName

public java.lang.String getMappingFileName()
The name of the mapping file that describes the XML format for getPromotionsAsXML


createPromotionStatus

public RepositoryItem createPromotionStatus(RepositoryItem pProfile,
                                            RepositoryItem pPromotion,
                                            java.lang.Integer pNumUses)
                                     throws RepositoryException
This method creates a PromotionStatus repository item and returns it. If the profile is not transient, then it will also add the PromotionStatus to the promotions repository. This method is responsible for setting the expiration date on the promotionStatus if this promotion is a relative expiration promotion.

Parameters:
pProfile - - the profile of the user for whom the promotion status is being created.
pPromotion - - the promotion to be added.
pNumUses - - the number of uses that this promotion can have.
Throws:
RepositoryException

initializePricingModels

public void initializePricingModels()
                             throws javax.servlet.ServletException,
                                    java.io.IOException
Initialize the set of pricing models/promotions that a user currently holds while having an active session.

Throws:
javax.servlet.ServletException
java.io.IOException

initializePricingModels

public void initializePricingModels(DynamoHttpServletRequest pRequest,
                                    DynamoHttpServletResponse pResponse)
                             throws javax.servlet.ServletException,
                                    java.io.IOException
Initialize the set of pricing models/promotions that a user currently holds while having an active session.

Throws:
javax.servlet.ServletException
java.io.IOException

checkPromotionExpiration

public boolean checkPromotionExpiration(RepositoryItem pPromotion,
                                        java.util.Date pNow)
Return true if the promotion or the promotionStatus has expired and should not be used in pricing.

Parameters:
pPromotion - the promotion that should be verified
pNow - the current date
Returns:
true if the promotion has expired, false otherwise

addAllPromotions

public void addAllPromotions(MutableRepositoryItem pProfile,
                             java.util.Collection pPromotions)
Adds all of the promotions in the collection to the user's activePromotion attribute value.


addAllPromotions

public void addAllPromotions(MutableRepositoryItem pProfile,
                             java.util.Collection pPromotions,
                             java.lang.String pComment)
Adds all of the promotions in the collection to the user's activePromotion attribute value.

Parameters:
pProfile - The profile being modified
pPromotion - The promotion being added
pComment - And extra string describe this event.

addPromotion

public boolean addPromotion(MutableRepositoryItem pProfile,
                            RepositoryItem pPromotion)
Adds the promotion to the user's activePromotion attribute value.

Parameters:
pProfile - The profile being modified
pPromotion - The promotion being added
Returns:
true if the promotion was added

addPromotion

public boolean addPromotion(MutableRepositoryItem pProfile,
                            RepositoryItem pPromotion,
                            java.lang.String pComment)
Adds the promotion to the user's activePromotion attribute value.

Parameters:
pProfile - The profile being modified
pPromotion - The promotion being added
pComment - And extra string describe this event.
Returns:
true if the promotion was added

grantPromotion

public void grantPromotion(java.lang.String pProfileId,
                           java.lang.String pPromotionId)
                    throws atg.commerce.promotion.PromotionException
Adds the given promotion to the user's "activePromotions" list.

Parameters:
pProfileId -
pPromotionId -
Throws:
PromotionException - Thrown if the promotion can't be added for some reason (e.g. the promotion is expired, the user already had the promotion)

grantPromotion

public void grantPromotion(java.lang.String pProfileId,
                           java.lang.String pPromotionId,
                           java.lang.String pComment)
                    throws atg.commerce.promotion.PromotionException
Adds the given promotion to the user's "activePromotions" list.

Parameters:
pProfileId - The profile gaining the promotion
pPromotionId - The promotion being added
pComment - And extra string describe this event.
Throws:
PromotionException - Thrown if the promotion can't be added for some reason (e.g. the promotion is expired, the user already had the promotion)

grantPromotion

public void grantPromotion(MutableRepositoryItem pProfile,
                           RepositoryItem pPromotion)
                    throws atg.commerce.promotion.PromotionException
Adds the given promotion to the user's "activePromotions" list.

Parameters:
pProfile -
pPromotion -
Throws:
PromotionException - Thrown if the promotion can't be added for some reason (e.g. the promotion is expired, the user already had the promotion)

grantPromotion

public void grantPromotion(MutableRepositoryItem pProfile,
                           RepositoryItem pPromotion,
                           java.lang.String pComment)
                    throws atg.commerce.promotion.PromotionException
Adds the given promotion to the user's "activePromotions" list.

Parameters:
pProfile - The profile gaining the promotion
pPromotion - The promotion being added
pComment - And extra string describe this event.
Throws:
PromotionException - Thrown if the promotion can't be added for some reason (e.g. the promotion is expired, the user already had the promotion)

sendPromotionGrantedEvent

public void sendPromotionGrantedEvent(MutableRepositoryItem pProfile,
                                      RepositoryItem pPromotion)
Sends an PromotionGranted Event through the PromotionGrantedMessageSender if FirePromotionGrantedEvent is set to true.

Parameters:
pProfile - the user's profile to record with the event
pPromotion - pPromotion the promotion to record with the event

sendPromotionGrantedEvent

public void sendPromotionGrantedEvent(MutableRepositoryItem pProfile,
                                      RepositoryItem pPromotion,
                                      java.lang.String pComment)
Sends an PromotionGranted Event through the PromotionGrantedMessageSender if FirePromotionGrantedEvent is set to true.

Parameters:
pProfile - the user's profile to record with the event
pPromotion - pPromotion the promotion to record with the event
pComment - An extra comment describing the eveng

sendPromotionRevokedEvent

public void sendPromotionRevokedEvent(RepositoryItem pProfile,
                                      RepositoryItem pPromotion)
Sends a PromotionRevoked Event through the PromotionRevokedMessageSender if FirePromotionRevokedEvent is set to true.

Parameters:
pProfile - the user's profile to record with the event
pPromotion - pPromotion the promotion to record with the event

sendPromotionRevokedEvent

public void sendPromotionRevokedEvent(RepositoryItem pProfile,
                                      RepositoryItem pPromotion,
                                      java.lang.String pComment)
Sends a PromotionRevoked Event through the PromotionRevokedMessageSender if FirePromotionRevokedEvent is set to true.

Parameters:
pProfile - the user's profile to record with the event
pPromotion - pPromotion the promotion to record with the event
pComment - An extra comment describing the event

consumePromotion

public boolean consumePromotion(MutableRepositoryItem pProfile,
                                RepositoryItem pPromotion)
This method moves a promotion from the user's activePromotions list to their usedPromotions list. It does this only for promotions marked as "use once".

Parameters:
pProfile - the user's profile
pPromotion - the promotion to consume
Returns:
true if the promotion was moved, false if the promotion is not found.

removePromotion

public boolean removePromotion(MutableRepositoryItem pProfile,
                               RepositoryItem pPromotion,
                               boolean pRemoveAll)
Removes the passed in promotion pPromotion from the pProfile's list of active promotions. If the pRemoveAll flag is set then all instances of this promotion are removed, otherwise the first one of it's kind is removed.

Parameters:
pProfile - - the profile of the user from whom the promotion will be taken out
pPromotion - - the promotion to be removed
pRemoveAll - - true if all instances of this promotion should be removed, false otherwise
Returns:
true if one or more instances of the promotion was removed from the list of active promotions.

revokePromotion

public boolean revokePromotion(java.lang.String pProfileId,
                               java.lang.String pPromotionId,
                               boolean pRemoveAllInstances)
                        throws atg.commerce.promotion.PromotionException
Removes the passed in promotion pPromotion from the pProfile's list of active promotions. If the pRemoveAll flag is set then all instances of this promotion are removed, otherwise the first one of it's kind is removed.

Parameters:
pProfileId - - the profile of the user from whom the promotion will be taken out
pPromotionId - - the promotion to be removed
pRemoveAll - - true if all instances of this promotion should be removed, false otherwise
Returns:
true if the promotion was removed, false if nothing happened
Throws:
PromotionException - if the promotion could not be removed.

revokePromotion

public boolean revokePromotion(MutableRepositoryItem pProfile,
                               RepositoryItem pPromotion,
                               boolean pRemoveAll)
                        throws atg.commerce.promotion.PromotionException
Removes the passed in promotion pPromotion from the pProfile's list of active promotions. If the pRemoveAll flag is set then all instances of this promotion are removed, otherwise the first one of it's kind is removed.

Parameters:
pProfile - - the profile of the user from whom the promotion will be taken out
pPromotion - - the promotion to be removed
pRemoveAll - - true if all instances of this promotion should be removed, false otherwise
Returns:
true if the promotion was removed, false if nothing happened
Throws:
PromotionException - if the promotion could not be removed.

getOrderPromotions

public void getOrderPromotions(Order pOrder,
                               java.util.Collection pPromotions)
Returns the promotions used in the order.

Parameters:
pOrder - the order that the promotions are in
pPromotions - a collection that the promotions are to be added to

getTaxPromotions

public void getTaxPromotions(Order pOrder,
                             java.util.Collection pPromotions)
Returns the promotions used in the tax calculation.

Parameters:
pOrder - the order that the promotions are in
pPromotions - a collection that the promotions are to be added to

getItemPromotions

public void getItemPromotions(CommerceItem pItem,
                              java.util.Collection pPromotions)
Returns the promotions used in the CommerceItem.

Parameters:
pItem - the CommerceItem that the promotions are in
pPromotions - a collection that the promotions are to be added to

getShippingPromotions

public void getShippingPromotions(ShippingGroup pGroup,
                                  java.util.Collection pPromotions)
Returns the promotions used in the ShippingGroup.

Parameters:
pGroup - the ShippingGroup that the promotions are in
pPromotions - a collection that the promotions are to be added to

getOrderPromotions

public void getOrderPromotions(Order pOrder,
                               java.util.Collection pOrderPromotions,
                               java.util.Collection pTaxPromotions,
                               java.util.Collection pItemPromotions,
                               java.util.Collection pShippingPromotions)
This method retrieves all the promotions in an order and adds them to their respective collection.

Parameters:
pOrder - the order to retrieve the promotions from
pOrderPromotions - the collection to add the order level promotions to
pTaxPromotions - the collection to add the tax level promotions to
pItemPromotions - the collection to add the item level promotions to
pShippingPromotions - the collection to add the shipping level promotions to

getOrderPromotions

public void getOrderPromotions(Order pOrder,
                               java.util.Collection pPromotions,
                               boolean pGetAdjustments)
Returns the promotions used in the order. If pGetAdjustments is true then pPromotions is populated with each PricingAdjustment associated with a promotion. If it is false, then pPromotions is populated with the actual pricing model repository items.

Parameters:
pOrder - the order that the promotions are in
pPromotions - a collection that the promotions are to be added to
pGetAdjustments - If true, get the PricingAdjustments, if false get the promotions

getTaxPromotions

public void getTaxPromotions(Order pOrder,
                             java.util.Collection pPromotions,
                             boolean pGetAdjustments)
Returns the promotions used in the tax calculation. If pGetAdjustments is true then pPromotions is populated with each PricingAdjustment associated with a promotion. If it is false, then pPromotions is populated with the actual pricing model repository items.

Parameters:
pOrder - the order that the promotions are in
pPromotions - a collection that the promotions are to be added to
pGetAdjustments - If true, get the PricingAdjustments, if false get the promotions

getItemPromotions

public void getItemPromotions(CommerceItem pItem,
                              java.util.Collection pPromotions,
                              boolean pGetAdjustments)
Returns the promotions used in the CommerceItem. If pGetAdjustments is true then pPromotions is populated with each PricingAdjustment associated with a promotion. If it is false, then pPromotions is populated with the actual pricing model repository items.

Parameters:
pItem - the CommerceItem that the promotions are in
pPromotions - a collection that the promotions are to be added to
pGetAdjustments - If true, get the PricingAdjustments, if false get the promotions

getShippingPromotions

public void getShippingPromotions(ShippingGroup pGroup,
                                  java.util.Collection pPromotions,
                                  boolean pGetAdjustments)
Returns the promotions used in the ShippingGroup. If pGetAdjustments is true then pPromotions is populated with each PricingAdjustment associated with a promotion. If it is false, then pPromotions is populated with the actual pricing model repository items.

Parameters:
pGroup - the ShippingGroup that the promotions are in
pPromotions - a collection that the promotions are to be added to
pGetAdjustments - If true, get the PricingAdjustments, if false get the promotions

getOrderPromotions

public void getOrderPromotions(Order pOrder,
                               java.util.Collection pOrderPromotions,
                               java.util.Collection pTaxPromotions,
                               java.util.Collection pItemPromotions,
                               java.util.Collection pShippingPromotions,
                               boolean pGetAdjustments)
This method retrieves all the promotions in an order and adds them to their respective collection. If pGetAdjustments is true then each promotion collection is populated with each PricingAdjustment associated with a promotion. If it is false, then each promotion collection is populated with the actual pricing model repository items.

Parameters:
pOrder - the order to retrieve the promotions from
pOrderPromotions - the collection to add the order level promotions to
pTaxPromotions - the collection to add the tax level promotions to
pItemPromotions - the collection to add the item level promotions to
pShippingPromotions - the collection to add the shipping level promotions to
pGetAdjustments - If true, get the PricingAdjustments, if false get the promotions

expirePromotion

public void expirePromotion(RepositoryItem pPromotion,
                            RepositoryItem pProfile)
This method will remove the passed in promotion from the Profile.

Parameters:
pPromotion - the promotion which has expired
pProfile - the profile for which a promotion has expired

convertPromoStatusToPromo

public java.util.Collection convertPromoStatusToPromo(java.util.Collection pPromoStatuses)

scenarioAddedItemToOrder

public boolean scenarioAddedItemToOrder(Order pOrder,
                                        CommerceItem pItem,
                                        long pQuantity)
This method is called by the AddItemToOrder scenario action. It will create a ScenarioAddedItemToOrder scenario event and send it. If sendEventOnAddItem is false, then nothing happens and true is returned.

Parameters:
pOrder - The order that was modified
pItem - The item that was added
pQuantity - The quantity of pItem added to pOrder
Returns:
false if there were errors, true otherwise

getProfile

public RepositoryItem getProfile(java.lang.String pProfileId)
                          throws RepositoryException
Gets the profile repository item with the given id

Parameters:
pProfileId - the id of the profile to retrieve
Returns:
the profie repository item
Throws:
RepositoryException - if there was an error while retrieving the profile

getPromotionsAsXML

public java.lang.String[] getPromotionsAsXML(java.lang.String pProfileId)
                                      throws atg.commerce.promotion.PromotionException
This method will look up the given profile, and for each available promotion, will return an xml representation of it using the GetService and the mappingFileName. Both active promotions in the profile and global promotions are returned.

Parameters:
pProfileId - The id of the user whose promotions are returned
Returns:
An XML representation of each active promotion in the profile
Throws:
PromotionException

getPromotions

public java.util.Collection getPromotions(java.lang.String pProfileId)
                                   throws atg.commerce.promotion.PromotionException
This method will look up the given profile and return all of the available promotions for that user. This will include active promotions in the profile, as well as global promotions.

Parameters:
pProfileId - The id of the user whose promotions are returned
Returns:
A collection of promotion items
Throws:
PromotionException

calculatePromotionsForOrder

public java.util.Map calculatePromotionsForOrder(Order pOrder)
This method will return a map containing the count of promotions contained in the given order, and the total value of those promotions

Parameters:
pOrder - the order whose promotions we would like to calculate.

getPromotionCount

public int getPromotionCount(Order pOrder,
                             RepositoryItem pPromotion)
Returns the number of times a promotion appears in the order.

Parameters:
pOrder - the order
pPromotion - the promotion
Returns:
number of occurrences