Class BasketImpl
- java.lang.Object
-
- de.hybris.platform.sap.core.bol.businessobject.BusinessObjectBase
-
- de.hybris.platform.sap.sapordermgmtbol.transaction.businessobject.impl.SimpleDocumentImpl<L,I,H>
-
- de.hybris.platform.sap.sapordermgmtbol.transaction.businessobject.impl.SalesDocumentBaseImpl<ItemList,Item,Header>
-
- de.hybris.platform.sap.sapordermgmtbol.transaction.salesdocument.businessobject.impl.SalesDocumentImpl
-
- de.hybris.platform.sap.sapordermgmtbol.transaction.basket.businessobject.impl.BasketImpl
-
- All Implemented Interfaces:
BackendAware,BusinessObject,MessageListHolder,Basket,SalesDocument,SalesDocumentBase<ItemList,Item,Header>,SimpleDocument<ItemList,Item,Header>,java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<Item>
public class BasketImpl extends SalesDocumentImpl implements Basket
Shopping basket BO implementation. The well known methaphor of a shopping basket is implemented using this class. The basket consist of several items, and header information.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected BasketOrderConsistencybasketOrderConsistencyEnsures consistency between basket and order-
Fields inherited from class de.hybris.platform.sap.sapordermgmtbol.transaction.salesdocument.businessobject.impl.SalesDocumentImpl
alreadyInitialized, backendService, checkCatalogNecessary, determinationRequired, externalToOrder, grossValueAvailable, itemsWithAlternativeProductList, netValueAvailable, pricesTraced, redemptionValue, transactionConfiguration
-
Fields inherited from class de.hybris.platform.sap.sapordermgmtbol.transaction.businessobject.impl.SalesDocumentBaseImpl
billToList, changeHeaderOnly, persistentInBackend, shipToList
-
Fields inherited from class de.hybris.platform.sap.core.bol.businessobject.BusinessObjectBase
backendObject, backendType, bobMessages, bobState, extensionData, genericFactory, handle, moduleConfigurationAccess, techKey
-
Fields inherited from interface de.hybris.platform.sap.core.common.message.MessageListHolder
INVALID, VALID
-
Fields inherited from interface de.hybris.platform.sap.sapordermgmtbol.transaction.businessobject.interf.SalesDocumentBase
NO_OF_ITEMS_UNKNOWN
-
-
Constructor Summary
Constructors Constructor Description BasketImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.math.BigDecimalcalculateTotalQuantity()java.lang.Objectclone()Makes a copy of the object.voiddestroy()Callback method for theBusinessObjectManagerto tell the object that life is over and that it has to release all ressources.booleanequals(java.lang.Object obj)Compares this object to the specified object.protected SalesDocumentBackendgetBackendService()Method retrieving the backend object for the object.inthashCode()Returns the hash code for this object.booleanisUpdateMissing()Check whether its required to Update the objectprotected booleanmergeIdenticalProductsIfRequired()voidread(boolean force)Overwrites the super implementation.
Checks if basket and order are consistent.voidreadForUpdate(boolean force)Reads the sales document for update (tried to get a lock).voidrelease()Releases cart object.protected voidremoveEmptyItemsFromItemList()Removes empty items (blank product ID) from item listbooleansaveAndCommit()Saves the order in the backend.voidsetBackendService(BasketBackend service)This method can be used to set a fixed back end service (e.g.voidsetBasketOrderConsistency(BasketOrderConsistency basketOrderConsistency)Injects the basketOrderConsisteny into the basketvoidsetUpdateMissing(boolean updateMissing)Sets whether update before save is required.voidupdate()Update the sales document in the backend.-
Methods inherited from class de.hybris.platform.sap.sapordermgmtbol.transaction.salesdocument.businessobject.impl.SalesDocumentImpl
adaptHeaderDocumentType, addShipTo, afterDeleteItemInBackend, afterDeleteItemInBackend, afterUpdateItemInBackend, clearItemBuffer, clearShipTos, createBillTo, createInBackend, createItem, createItemKey, createShipTo, deleteItemInt, destroyContent, determineConfigurableItemsToRelease, emptyContent, getDocumentType, getDublicatesForItems, getSalesDocumentHooks, getSessionService, getSoldToGuid, getTransactionConfiguration, hasPredecessorOfSpecificType, init, init, init, isBackendDown, isCheckCatalogNecessary, isDeterminationRequired, isExistingInBackend, isExternalToOrder, isGrossValueAvailable, isInitialized, isItemBasedAvailability, isMultipleAddressesSupported, isNetValueAvailable, mergeIdenticalProducts, mergingItem, prepareItemsWithChangedProducts, processItems, read, readForUpdate, removeItem, removeItems, setBillToList, setCheckCatalogNecessary, setConverter, setDeterminationRequired, setExternalToOrder, setGrossValueAvailable, setInitialized, setNetValueAvailable, setSalesDocumentHooks, setSessionService, setShipToList, setSoldToGuid, setSoldToGuid, setTransactionConfiguration, toString, updateInBackend, validate
-
Methods inherited from class de.hybris.platform.sap.sapordermgmtbol.transaction.businessobject.impl.SalesDocumentBaseImpl
clear, getAlternativeBillTos, getAlternativeShipTos, isChangeHeaderOnly, isPersistentInBackend, setPersistentInBackend
-
Methods inherited from class de.hybris.platform.sap.sapordermgmtbol.transaction.businessobject.impl.SimpleDocumentImpl
addItem, clearHeader, clearItems, clearMessages, getApplicationId, getChangeDate, getHeader, getItem, getItemList, getTypedExtensionMap, getVersion, isDirty, iterator, setApplicationId, setChangeDate, setDirty, setHeader, setItemList, setTechKey, setVersion
-
Methods inherited from class de.hybris.platform.sap.core.bol.businessobject.BusinessObjectBase
addExtensionData, addMessage, clearMessages, clearOwnMessages, copyMessages, copyMessages, createUniqueHandle, determineBackendObject, getBackendBusinessObject, getBackendBusinessObject, getBackendType, getExtensionData, getExtensionDataValues, getExtensionMap, getHandle, getMessageList, getModuleConfigurationAccess, getOwnMessageList, getSubObjectIterator, getTechKey, hasHandle, hasMessages, hasOwnMessages, init, isValid, logMessage, removeExtensionData, removeExtensionDataValues, setBackendObject, setBackendType, setExtensionMap, setGenericFactory, setHandle, setInvalid, setModuleConfigurationAccess, setValid
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.sap.core.bol.businessobject.BusinessObject
addExtensionData, clearMessages, clearOwnMessages, copyMessages, copyMessages, createUniqueHandle, getExtensionData, getExtensionDataValues, getExtensionMap, getHandle, getOwnMessageList, getSubObjectIterator, getTechKey, hasHandle, hasMessages, hasOwnMessages, init, isValid, logMessage, removeExtensionData, removeExtensionDataValues, setExtensionMap, setHandle, setInvalid, setTechKey, setValid
-
Methods inherited from interface de.hybris.platform.sap.core.common.message.MessageListHolder
addMessage, clearMessages, getMessageList
-
Methods inherited from interface de.hybris.platform.sap.sapordermgmtbol.transaction.businessobject.interf.SalesDocument
afterDeleteItemInBackend, clearItemBuffer, clearShipTos, createBillTo, createItem, createShipTo, destroyContent, getDocumentType, getTransactionConfiguration, hasPredecessorOfSpecificType, init, init, isBackendDown, isCheckCatalogNecessary, isExistingInBackend, isExternalToOrder, isGrossValueAvailable, isInitialized, isItemBasedAvailability, isMultipleAddressesSupported, isNetValueAvailable, read, readForUpdate, removeItem, removeItems, setBillToList, setCheckCatalogNecessary, setConverter, setExternalToOrder, setGrossValueAvailable, setInitialized, setNetValueAvailable, setShipToList, setSoldToGuid, setTransactionConfiguration, validate
-
Methods inherited from interface de.hybris.platform.sap.sapordermgmtbol.transaction.businessobject.interf.SalesDocumentBase
getAlternativeBillTos, getAlternativeShipTos, isChangeHeaderOnly, isDeterminationRequired, isPersistentInBackend, setDeterminationRequired, setPersistentInBackend
-
Methods inherited from interface de.hybris.platform.sap.sapordermgmtbol.transaction.businessobject.interf.SimpleDocument
addItem, clear, clearHeader, clearItems, getApplicationId, getChangeDate, getHeader, getItem, getItemList, getSoldToGuid, getTypedExtensionMap, getVersion, isDirty, setApplicationId, setChangeDate, setDirty, setHeader, setItemList, setSoldToGuid, setVersion
-
-
-
-
Field Detail
-
basketOrderConsistency
protected BasketOrderConsistency basketOrderConsistency
Ensures consistency between basket and order
-
-
Method Detail
-
isUpdateMissing
public boolean isUpdateMissing()
Description copied from interface:SalesDocumentCheck whether its required to Update the object- Specified by:
isUpdateMissingin interfaceSalesDocument- Overrides:
isUpdateMissingin classSalesDocumentImpl- Returns:
true, only if the object has to be updated
-
setUpdateMissing
public void setUpdateMissing(boolean updateMissing)
Description copied from interface:SalesDocumentSets whether update before save is required. Has to be set to true for initial objects to ensure that update is called at least once before save.- Specified by:
setUpdateMissingin interfaceSalesDocument- Overrides:
setUpdateMissingin classSalesDocumentImpl- Parameters:
updateMissing- set totrueto force an update before next save
-
destroy
public void destroy()
Callback method for theBusinessObjectManagerto tell the object that life is over and that it has to release all ressources.- Specified by:
destroyin interfaceBusinessObject- Overrides:
destroyin classSalesDocumentImpl
-
getBackendService
protected SalesDocumentBackend getBackendService() throws BackendException
Method retrieving the backend object for the object.- Specified by:
getBackendServicein classSalesDocumentImpl- Returns:
- Backend object to be used
- Throws:
BackendException
-
saveAndCommit
public boolean saveAndCommit() throws CommunicationExceptionSaves the order in the backend.- Specified by:
saveAndCommitin interfaceSalesDocument- Specified by:
saveAndCommitin classSalesDocumentImpl- Returns:
- true if the save and commit was successful
- Throws:
CommunicationException
-
setBackendService
public void setBackendService(BasketBackend service)
This method can be used to set a fixed back end service (e.g. mock it)- Parameters:
service- back end service to be used by this basket
-
setBasketOrderConsistency
public void setBasketOrderConsistency(BasketOrderConsistency basketOrderConsistency)
Description copied from interface:BasketInjects the basketOrderConsisteny into the basket- Specified by:
setBasketOrderConsistencyin interfaceBasket- Parameters:
basketOrderConsistency- consistency manager
-
read
public void read(boolean force) throws CommunicationExceptionOverwrites the super implementation.
Checks if basket and order are consistent. If the data was not consistent a update is triggered before the read- Specified by:
readin interfaceBasket- Specified by:
readin interfaceSalesDocument- Overrides:
readin classSalesDocumentImpl- Parameters:
force- If true, then read even if not considered as necessary- Throws:
CommunicationException- in case back-end error- See Also:
SalesDocumentImpl.read(boolean)
-
readForUpdate
public void readForUpdate(boolean force) throws CommunicationExceptionDescription copied from interface:SalesDocumentReads the sales document for update (tried to get a lock). The backend call happens if considered as necessary or if forced.- Specified by:
readForUpdatein interfaceSalesDocument- Overrides:
readForUpdatein classSalesDocumentImpl- Parameters:
force- If true, then read even if not considered as necessary- Throws:
CommunicationException- in case back-end error
-
update
public void update() throws CommunicationExceptionDescription copied from interface:SalesDocumentUpdate the sales document in the backend. The method also checks for changes in the businesspartner list- Specified by:
updatein interfaceSalesDocument- Overrides:
updatein classSalesDocumentImpl- Throws:
CommunicationException- in case back-end error
-
removeEmptyItemsFromItemList
protected void removeEmptyItemsFromItemList()
Removes empty items (blank product ID) from item list
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionDescription copied from class:BusinessObjectBaseMakes a copy of the object. The MessageList is copied.- Overrides:
clonein classBusinessObjectBase- Returns:
- a copy of object
- Throws:
java.lang.CloneNotSupportedException-CloneNotSupportedException
-
calculateTotalQuantity
public java.math.BigDecimal calculateTotalQuantity()
- Specified by:
calculateTotalQuantityin interfaceBasket- Returns:
- the total quantity of the products in basket
-
mergeIdenticalProductsIfRequired
protected boolean mergeIdenticalProductsIfRequired() throws CommunicationException- Overrides:
mergeIdenticalProductsIfRequiredin classSalesDocumentImpl- Throws:
CommunicationException
-
release
public void release() throws CommunicationExceptionDescription copied from interface:BasketReleases cart object. Afterwards, cart is fully initialized- Specified by:
releasein interfaceBasket- Throws:
CommunicationException
-
hashCode
public int hashCode()
Description copied from class:BusinessObjectBaseReturns the hash code for this object.- Overrides:
hashCodein classBusinessObjectBase- Returns:
- Hash code
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:BusinessObjectBaseCompares this object to the specified object. The result istrueif and only if the argument is notnulland is of the same class that has the same technical key (TechKey) as this object.- Overrides:
equalsin classBusinessObjectBase- Parameters:
obj- Object to compare with- Returns:
trueif the objects are identical; otherwiesefalse.
-
-