All Implemented Interfaces:
BackendAware, BusinessObject, MessageListHolder, SalesDocument, SalesDocumentBase<ItemList,Item,Header>, SimpleDocument<ItemList,Item,Header>, Serializable, Cloneable, Iterable<Item>
Direct Known Subclasses:
BasketImpl, OrderImpl

public abstract class SalesDocumentImpl extends SalesDocumentBaseImpl<ItemList,Item,Header> implements SalesDocument
Common superclass for all sales documents.
See Also:
  • Field Details

    • transactionConfiguration

      protected TransactionConfiguration transactionConfiguration
    • backendService

      protected SalesDocumentBackend backendService
    • alreadyInitialized

      protected boolean alreadyInitialized
    • externalToOrder

      protected boolean externalToOrder
    • checkCatalogNecessary

      protected boolean checkCatalogNecessary
    • redemptionValue

      protected String redemptionValue
      redemption value
    • determinationRequired

      protected boolean determinationRequired
    • grossValueAvailable

      protected boolean grossValueAvailable
    • netValueAvailable

      protected boolean netValueAvailable
    • pricesTraced

      protected boolean pricesTraced
    • itemsWithAlternativeProductList

      protected final List<TechKey> itemsWithAlternativeProductList
      This list stores items with alternative products. For these items events should only be fired when a product is selected (see int msg 385863 2010).
  • Constructor Details

    • SalesDocumentImpl

      public SalesDocumentImpl()
  • Method Details

    • isCheckCatalogNecessary

      public boolean isCheckCatalogNecessary()
      Description copied from interface: SalesDocument
      Does the document require that the items are checked against the catalog?
      Specified by:
      isCheckCatalogNecessary in interface SalesDocument
      Returns:
      true if check is required
    • setCheckCatalogNecessary

      public void setCheckCatalogNecessary(boolean checkCatalogNecessary)
      Description copied from interface: SalesDocument
      Indicates whether a check of the items against the catalog is required
      Specified by:
      setCheckCatalogNecessary in interface SalesDocument
      Parameters:
      checkCatalogNecessary - if check is required
    • adaptHeaderDocumentType

      protected void adaptHeaderDocumentType() throws CommunicationException
      Sets the document type on the document header depending on the Java class instance of the Sales Document (evaluated with instanceof ).
      Throws:
      CommunicationException
    • addShipTo

      public void addShipTo(ShipTo shipTo)
      Adds a shipTo to the shipTo list
      Parameters:
      shipTo - shipTo to add
    • clearShipTos

      public void clearShipTos()
      Description copied from interface: SalesDocument
      Clears the list of the shipTo.
      Specified by:
      clearShipTos in interface SalesDocument
    • createBillTo

      public BillTo createBillTo()
      Description copied from interface: SalesDocument
      Creates a new billTo object
      Specified by:
      createBillTo in interface SalesDocument
      Returns:
      Newly created billTo
    • createItem

      public Item createItem()
      Description copied from interface: SalesDocument
      Gets a new Item object
      Specified by:
      createItem in interface SalesDocument
      Specified by:
      createItem in interface SimpleDocument<ItemList,Item,Header>
      Returns:
      new item instance
      See Also:
    • createShipTo

      public ShipTo createShipTo()
      Description copied from interface: SalesDocument
      Creates a new ship object
      Specified by:
      createShipTo in interface SalesDocument
      Returns:
      Newly created shipTo
    • deleteItemInt

      protected void deleteItemInt(TechKey techKey) throws CommunicationException
      Deletes the item with the given Techkey
      Parameters:
      techKey -
      Throws:
      CommunicationException
    • removeItems

      public void removeItems(TechKey[] techKeys) throws CommunicationException
      Description copied from interface: SalesDocument
      Deletes items from the sales document.
      Specified by:
      removeItems in interface SalesDocument
      Parameters:
      techKeys - Technical keys of the items to be canceld
      Throws:
      CommunicationException - in case back-end error
    • destroy

      public void destroy()
      Description copied from class: SalesDocumentBaseImpl
      Method will be called by the BusinessObjectManager when the end of the life cycle is reached, so that all used resources can be released.
      Specified by:
      destroy in interface BusinessObject
      Overrides:
      destroy in class SalesDocumentBaseImpl<ItemList,Item,Header>
    • destroyContent

      public void destroyContent() throws CommunicationException
      Description copied from interface: SalesDocument
      Destroy the data of the document (items and header) in the backend representation. After a call to this method, the object is in an undefined state. You have to call init() before you can use it again.
      This method is normally called before removing the BO-representation of the object using the BOM.
      Specified by:
      destroyContent in interface SalesDocument
      Throws:
      CommunicationException - in case back-end error
    • emptyContent

      public void emptyContent() throws CommunicationException
      Resets the entire document to empty state.
      Throws:
      CommunicationException - in case of aback-end error
    • getBackendService

      protected abstract SalesDocumentBackend getBackendService() throws BackendException
      Method retrieving the backend object for the object. This method is abstract because every concrete subclass of SalesDocument may use its own implementation of a backend object.
      Returns:
      Backend object to be used
      Throws:
      BackendException
    • getDocumentType

      public SalesDocumentType getDocumentType() throws CommunicationException
      Description copied from interface: SalesDocument
      Returns the type of the sales document (e.g. Order, Basket)
      Specified by:
      getDocumentType in interface SalesDocument
      Returns:
      type of sales document
      Throws:
      CommunicationException - in case back-end error
    • getTransactionConfiguration

      public TransactionConfiguration getTransactionConfiguration()
      Description copied from interface: SalesDocument
      Returns the transaction configuration. The transaction configuration provides access to sales-specific settings (e.g. sales organisation)
      Specified by:
      getTransactionConfiguration in interface SalesDocument
      Returns:
      TransactionConfiguration to access the sales-related configuration
    • init

      public void init(PartnerList partnerList, String processType) throws CommunicationException
      Initializes a sales document
      Parameters:
      partnerList - Partner list
      processType - Sales document type
      Throws:
      CommunicationException
    • init

      public void init(PartnerList partnerList) throws CommunicationException
      Description copied from interface: SalesDocument
      Initializes the sales document with the given arguments and creates and instance in back-end application memory.
      Specified by:
      init in interface SalesDocument
      Parameters:
      partnerList - any partners maintained will be added to the sales document in the same partner function
      Throws:
      CommunicationException - in case back-end error
    • init

      public void init(SalesDocument source, String processType) throws BusinessObjectException
      Description copied from interface: SalesDocument
      Initializes an empty instance of this object with the data coming from the provided document. The former state of this document is dropped and lost, the fields of the other document are copied into the fields of this document. To do this the clone() method of the fields is used to get an shallow copy and minimise interference between the new and the old object. The creation date of the old document is not copied to the new one but the original date is left as it is. A back-end representation of the new object is created and filled with the data retrieved by the copy operation.
      Specified by:
      init in interface SalesDocument
      Parameters:
      source - The SalesDocument to retrieve data from
      processType - process type for the new SalesDocument (optional)
      Throws:
      BusinessObjectException - in case back-end error
    • processItems

      protected StringBuilder processItems(SalesDocument source)
      Parameters:
      source -
      Returns:
    • createInBackend

      protected void createInBackend() throws BusinessObjectException
      Throws:
      BusinessObjectException
    • isExistingInBackend

      public boolean isExistingInBackend()
      Description copied from interface: SalesDocument
      Checks if the document exists in the backend storage
      Specified by:
      isExistingInBackend in interface SalesDocument
      Returns:
      does the document exist in backend?
    • isDeterminationRequired

      public boolean isDeterminationRequired()
      Description copied from interface: SalesDocumentBase
      Determines if manual Product-, Campaign-, ... Determination is necessary for at least one top level item.
      Specified by:
      isDeterminationRequired in interface SalesDocumentBase<ItemList,Item,Header>
      Returns:
      boolean true if there is at least on item that needs manual determination for products, camapigns, etc.
    • isExternalToOrder

      public boolean isExternalToOrder()
      Description copied from interface: SalesDocument
      Indicates whether or not the order has to be maintained as an external document to this one. (e.g. java basket is external to crm backend order)
      Specified by:
      isExternalToOrder in interface SalesDocument
      Returns:
      true indicates that the order is maintained external to this document, false indicates that the order lies on the same system.
    • isGrossValueAvailable

      public boolean isGrossValueAvailable()
      Description copied from interface: SalesDocument
      Indicates whether or not the sales document can provide the Gross value.
      Specified by:
      isGrossValueAvailable in interface SalesDocument
      Returns:
      true indicates that the sales document can provide the gross value. false indicates that the sales document can not deliver the gross value.
    • isMultipleAddressesSupported

      public boolean isMultipleAddressesSupported() throws BusinessObjectException
      Description copied from interface: SalesDocument
      Returns if multiple addresses are supported
      Specified by:
      isMultipleAddressesSupported in interface SalesDocument
      Returns:
      multiple addresses supported
      Throws:
      BusinessObjectException - in case back-end error
    • isNetValueAvailable

      public boolean isNetValueAvailable()
      Description copied from interface: SalesDocument
      Indicates whether or not the sales document can provide a net value.
      Specified by:
      isNetValueAvailable in interface SalesDocument
      Returns:
      true indicates that the sales document can provide the net value false indicates that the sales document can not deliver the net value.
    • isUpdateMissing

      public boolean isUpdateMissing()
      Description copied from interface: SalesDocument
      Check whether its required to Update the object
      Specified by:
      isUpdateMissing in interface SalesDocument
      Returns:
      true, only if the object has to be updated
    • mergeIdenticalProducts

      protected boolean mergeIdenticalProducts() throws CommunicationException
      Merges identical products (this is told from the product ID) and states whether changes have been done
      Returns:
      did we do changes?
      Throws:
      CommunicationException
    • mergingItem

      protected void mergingItem(List<Item> mergeItems, Item merged, double sumQty, int discarded)
      Parameters:
      mergeItems -
      merged -
      sumQty -
      discarded -
    • getDublicatesForItems

      protected Map<String,List<Item>> getDublicatesForItems()
    • createItemKey

      protected String createItemKey(Item toCheck)
    • read

      public void read() throws CommunicationException
      Description copied from interface: SalesDocument
      Reads the sales document. The backend call happens only if necessary.
      Specified by:
      read in interface SalesDocument
      Throws:
      CommunicationException - in case back-end error
    • read

      public void read(boolean force) throws CommunicationException
      Description copied from interface: SalesDocument
      Reads the sales document. The backend call happens if considered as necessary or if forced.
      Specified by:
      read in interface SalesDocument
      Parameters:
      force - If true, then read even if not considered as necessary
      Throws:
      CommunicationException - in case back-end error
    • readForUpdate

      public void readForUpdate() throws CommunicationException
      Description copied from interface: SalesDocument
      Reads the sales document for update (tried to get a lock). The backend call happens only if necessary.
      Specified by:
      readForUpdate in interface SalesDocument
      Throws:
      CommunicationException - in case back-end error
    • readForUpdate

      public void readForUpdate(boolean force) throws CommunicationException
      Description copied from interface: SalesDocument
      Reads the sales document for update (tried to get a lock). The backend call happens if considered as necessary or if forced.
      Specified by:
      readForUpdate in interface SalesDocument
      Parameters:
      force - If true, then read even if not considered as necessary
      Throws:
      CommunicationException - in case back-end error
    • removeItem

      public void removeItem(Item item) throws CommunicationException
      Description copied from interface: SalesDocument
      Removes the item.
      Specified by:
      removeItem in interface SalesDocument
      Parameters:
      item - to remove
      Throws:
      CommunicationException - in case back-end error
    • saveAndCommit

      public abstract boolean saveAndCommit() throws CommunicationException
      Abstract Dummy implementation of interface method
      Specified by:
      saveAndCommit in interface SalesDocument
      Returns:
      true if the save and commit was successful
      Throws:
      CommunicationException
    • setDeterminationRequired

      public void setDeterminationRequired(boolean isDeterminationRequired)
      Description copied from interface: SalesDocumentBase
      Sets the isDeterminationRequired flag
      Specified by:
      setDeterminationRequired in interface SalesDocumentBase<ItemList,Item,Header>
      Parameters:
      isDeterminationRequired - true if there are items that need manual determination either for camapigns, substitution products or something similar
    • setExternalToOrder

      public void setExternalToOrder(boolean isExternalToOrder)
      Description copied from interface: SalesDocument
      Sets whether or not the order has to be maintained as an external document to this one. (e.g. a java basket is an external document to crm backend order)
      Specified by:
      setExternalToOrder in interface SalesDocument
      Parameters:
      isExternalToOrder - true indicates that the order is maintained external to this document, false indicates that the order lies on the same system.
    • setGrossValueAvailable

      public void setGrossValueAvailable(boolean isGrossValueAvailable)
      Description copied from interface: SalesDocument
      Sets the property grossValueAvailable
      Specified by:
      setGrossValueAvailable in interface SalesDocument
      Parameters:
      isGrossValueAvailable - true indicates that the sales document can provide the gross value false indicates that the sales document can not provide the gross value.
    • setNetValueAvailable

      public void setNetValueAvailable(boolean isNetValueAvailable)
      Description copied from interface: SalesDocument
      Sets the property netValueAvailable
      Specified by:
      setNetValueAvailable in interface SalesDocument
      Parameters:
      isNetValueAvailable - true indicates that the sales document can deliver the net value false indicates that the sales document can not deliver the net value.
    • setShipToList

      public void setShipToList(List<ShipTo> shipToList)
      Description copied from interface: SalesDocument
      Sets shipTo list
      Specified by:
      setShipToList in interface SalesDocument
      Parameters:
      shipToList - list of ShipTo's
    • setBillToList

      public void setBillToList(List<BillTo> billToList)
      Description copied from interface: SalesDocument
      Sets BillTo list
      Specified by:
      setBillToList in interface SalesDocument
      Parameters:
      billToList - list of BillTo's
    • setTransactionConfiguration

      public void setTransactionConfiguration(TransactionConfiguration transConf)
      Description copied from interface: SalesDocument
      The transaction configuration provides access to sales-specific settings (e.g. sales organisation)
      Specified by:
      setTransactionConfiguration in interface SalesDocument
      Parameters:
      transConf - API to access the configuration and documents
    • setUpdateMissing

      public void setUpdateMissing(boolean updateMissing)
      Description copied from interface: SalesDocument
      Sets 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:
      setUpdateMissing in interface SalesDocument
      Parameters:
      updateMissing - set to true to force an update before next save
    • toString

      public String toString()
      Returns a string representation of the object
      Overrides:
      toString in class SimpleDocumentImpl<ItemList,Item,Header>
      Returns:
      String representation
    • update

      public void update() throws CommunicationException
      Description copied from interface: SalesDocument
      Update the sales document in the backend. The method also checks for changes in the businesspartner list
      Specified by:
      update in interface SalesDocument
      Throws:
      CommunicationException - in case back-end error
    • updateInBackend

      protected void updateInBackend(List<TechKey> itemsToDelete, List<TechKey> configurableItemsToRelease) throws BackendException, CommunicationException, BusinessObjectException
      Parameters:
      itemsToDelete -
      configurableItemsToRelease -
      Throws:
      BackendException
      CommunicationException
      BusinessObjectException
    • determineConfigurableItemsToRelease

      protected List<TechKey> determineConfigurableItemsToRelease()
    • mergeIdenticalProductsIfRequired

      protected boolean mergeIdenticalProductsIfRequired() throws CommunicationException
      Throws:
      CommunicationException
    • prepareItemsWithChangedProducts

      protected void prepareItemsWithChangedProducts()
    • getSoldToGuid

      public TechKey getSoldToGuid()
      Specified by:
      getSoldToGuid in interface SimpleDocument<ItemList,Item,Header>
      Overrides:
      getSoldToGuid in class SimpleDocumentImpl<ItemList,Item,Header>
      Returns:
      techKey GUID of the soldTo
    • setSoldToGuid

      public void setSoldToGuid(TechKey techKeySoldTo)
      Specified by:
      setSoldToGuid in interface SimpleDocument<ItemList,Item,Header>
      Overrides:
      setSoldToGuid in class SimpleDocumentImpl<ItemList,Item,Header>
      Parameters:
      techKeySoldTo - GUID of the soldTo
    • setSoldToGuid

      public void setSoldToGuid(TechKey techKeySoldTo, String soldToId)
      Specified by:
      setSoldToGuid in interface SalesDocument
      Parameters:
      techKeySoldTo - the guid of the soldto
      soldToId - the partner id of the soldto
    • clearItemBuffer

      public void clearItemBuffer()
      Description copied from interface: SalesDocument
      Removes all buffered item information
      Specified by:
      clearItemBuffer in interface SalesDocument
    • hasPredecessorOfSpecificType

      public boolean hasPredecessorOfSpecificType(DocumentType docType)
      Description copied from interface: SalesDocument
      Scans list of predecessors for given document type.
      Specified by:
      hasPredecessorOfSpecificType in interface SalesDocument
      Parameters:
      docType - to be searched for in predecessors
      Returns:
      true if predecessor list contains given doc type
    • setInitialized

      public void setInitialized(boolean b)
      Description copied from interface: SalesDocument
      Indicates whether a sales document could be initialized
      Specified by:
      setInitialized in interface SalesDocument
      Parameters:
      b - true if initialization was not possible
    • isInitialized

      public boolean isInitialized()
      Description copied from interface: SalesDocument
      Does the document carry an initialization error?
      Specified by:
      isInitialized in interface SalesDocument
      Returns:
      true if initialization was not possible
    • isItemBasedAvailability

      public boolean isItemBasedAvailability()
      Description copied from interface: SalesDocument
      Checks if availability is compiled only based on item information.
      Specified by:
      isItemBasedAvailability in interface SalesDocument
      Returns:
      Availability is compiled only based item on information?
    • setConverter

      public void setConverter(Converter converter)
      Specified by:
      setConverter in interface SalesDocument
      Parameters:
      converter - access object for unit related conversions
    • validate

      public void validate() throws CommunicationException
      Description copied from interface: SalesDocument
      Validates as sales document. Afterwards, all messages are available as part of the message list
      Specified by:
      validate in interface SalesDocument
      Throws:
      CommunicationException
    • afterDeleteItemInBackend

      protected void afterDeleteItemInBackend(List<TechKey> itemsToDelete)
      Releases configuration sessions for all items provided
      Parameters:
      itemsToDelete - List of item TechKeys
    • afterUpdateItemInBackend

      protected void afterUpdateItemInBackend(List<TechKey> itemsToDelete)
      Releases configuration sessions for all items provided
      Parameters:
      itemsToDelete - List of item TechKeys
    • afterDeleteItemInBackend

      public void afterDeleteItemInBackend()
      Description copied from interface: SalesDocument
      Releases all configuration sessions attached to this sales document
      Specified by:
      afterDeleteItemInBackend in interface SalesDocument
    • isBackendDown

      public boolean isBackendDown()
      Specified by:
      isBackendDown in interface SalesDocument
      Returns:
      Is back end down for a planned downtime?
    • getSessionService

      public de.hybris.platform.servicelayer.session.SessionService getSessionService()
      Returns:
      the sessionService
    • setSessionService

      public void setSessionService(de.hybris.platform.servicelayer.session.SessionService sessionService)
      Parameters:
      sessionService - the sessionService to set
    • getSalesDocumentHooks

      public List<SalesDocumentHook> getSalesDocumentHooks()
      Returns:
      the salesDocumentHooks
    • setSalesDocumentHooks

      public void setSalesDocumentHooks(List<SalesDocumentHook> salesDocumentHooks)
      Parameters:
      salesDocumentHooks - the salesDocumentHooks to set