All Implemented Interfaces:
BackendBusinessObject, BackendBusinessObjectJCo, BackendState, SalesDocumentBackend
Direct Known Subclasses:
BasketERP, OrderBaseERP

public abstract class SalesDocumentERP extends IsaBackendBusinessObjectBaseSalesERP implements SalesDocumentBackend
Common base class for ECO ERP sales documents. See OrderERP, BasketERP
  • Field Details

    • RESOURCE_KEY

      public static final String RESOURCE_KEY
      See Also:
    • STRATEGY_FACTORY_ERP

      public static final String STRATEGY_FACTORY_ERP
      constant naming the key referenced in factory-config.xml where the strategy class is specified
      See Also:
    • ORDER_ITEM_STRUCTURE

      public static final String ORDER_ITEM_STRUCTURE
      UI controller relevant constant for 'OrderItemStructure'
      See Also:
    • ORDER_HEADER_STRUCTURE

      public static final String ORDER_HEADER_STRUCTURE
      UI controller relevant constant for 'OrderHeaderStructure'
      See Also:
    • isUMEDisabledWarningNecessary

      protected boolean isUMEDisabledWarningNecessary
      Warning message in case UME is disabled. Then we only have one session in ERP, and we cannot fully support multiple documents. UME disabling will not be possible in productive environments.
    • getAllStrategy

      protected GetAllStrategy getAllStrategy
      Strategy pattern to support various LO-API versions
    • lrdActionsStrategy

      protected LrdActionsStrategy lrdActionsStrategy
    • setStrategy

      protected SetStrategy setStrategy
    • itemVariantMap

      protected Map<String,String> itemVariantMap
    • showInlineConfig

      protected boolean showInlineConfig
    • headerCondTypeFreight

      protected String headerCondTypeFreight
    • isIncompletionLogRequested

      protected boolean isIncompletionLogRequested
    • deliveryPriority

      protected String deliveryPriority
    • erroneous

      protected boolean erroneous
    • transactionConfiguration

      protected TransactionConfiguration transactionConfiguration
    • createProcess

      protected boolean createProcess
    • additionalPricing

      protected AdditionalPricing additionalPricing
  • Constructor Details

    • SalesDocumentERP

      protected SalesDocumentERP()
  • Method Details

    • getItemBuffer

      public ItemBuffer getItemBuffer()
      Returns:
      the itemBuffer
    • setItemBuffer

      public void setItemBuffer(ItemBuffer itemBuffer)
      Parameters:
      itemBuffer - the itemBuffer to set
    • getGetAllStrategy

      public GetAllStrategy getGetAllStrategy()
      Returns:
      the getAllStrategy
    • setGetAllStrategy

      public void setGetAllStrategy(GetAllStrategy getAllStrategy)
      Parameters:
      getAllStrategy - the getAllStrategy to set
    • getLrdActionsStrategy

      public LrdActionsStrategy getLrdActionsStrategy()
      Returns:
      the lrdActionsStrategy
    • setLrdActionsStrategy

      public void setLrdActionsStrategy(LrdActionsStrategy lrdActionsStrategy)
      Parameters:
      lrdActionsStrategy - the lrdActionsStrategy to set
    • getSetStrategy

      public SetStrategy getSetStrategy()
      Returns:
      the setStrategy
    • setSetStrategy

      public void setSetStrategy(SetStrategy setStrategy)
      Parameters:
      setStrategy - the setStrategy to set
    • isDocumentInitial

      public boolean isDocumentInitial()
      Specified by:
      isDocumentInitial in interface BackendState
      Returns:
      Sales document is initial
    • setSoldToHandle

      public void setSoldToHandle(String soldTo)
      Description copied from interface: BackendState
      Sets handle of soldTo partner
      Specified by:
      setSoldToHandle in interface BackendState
      Parameters:
      soldTo - handle of the soldto partner function
    • setPayerHandle

      public void setPayerHandle(String payer)
      Description copied from interface: BackendState
      Sets handle of payer
      Specified by:
      setPayerHandle in interface BackendState
      Parameters:
      payer - handle of the payer partner function
    • getPayerHandle

      public String getPayerHandle()
      Specified by:
      getPayerHandle in interface BackendState
      Returns:
      handle of the payer
    • getSoldToHandle

      public String getSoldToHandle()
      Specified by:
      getSoldToHandle in interface BackendState
      Returns:
      handle of the soldTo partner
    • setDocumentInitial

      public void setDocumentInitial(boolean isInitial)
      Description copied from interface: BackendState
      Sales document is initial. The first update might need to do specific shipto handling
      Specified by:
      setDocumentInitial in interface BackendState
      Parameters:
      isInitial - true if document is initial
    • createInBackend

      public void createInBackend(SalesDocument salesDocument) throws BackendException
      Create back end representation of the object
      Parameters:
      salesDocument - sales document to be created in back end
      Throws:
      BackendException - case of a back-end error
    • createInBackend

      public void createInBackend(TransactionConfiguration transactionConfiguration, SalesDocument salesDocument) throws BackendException
      Create back end representation of the object without providing information about the user. This may happen in the B2C scenario where the login may be done later.
      Specified by:
      createInBackend in interface SalesDocumentBackend
      Parameters:
      transactionConfiguration - The current shop
      salesDocument - The document to read the data in
      Throws:
      BackendException - in case of a back-end or communication error
    • handleInvalidHeaderAfterUpdate

      protected void handleInvalidHeaderAfterUpdate(SalesDocument salesDocument) throws BackendException
      Document couldn't be created. Now the header needs to be corrected, and the document is again sent to ERP.
      Throws:
      BackendException
    • restoreErroneousHeaderAfterSet

      protected void restoreErroneousHeaderAfterSet(Header header)
      Restoring header: Initializing delivery date.
      Parameters:
      header -
    • fixErroneousHeader

      protected void fixErroneousHeader(SalesDocument document)
      Fixing a header which cannot be digested from ERP. This implementation sets a delivery date because this is the only error which can be corrected by means of attributes available in WCEM
    • deleteItemInBackend

      public void deleteItemInBackend(SalesDocument salesDocument, TechKey itemToDelete) throws BackendException
      Deletes a single item in the backend.
      Specified by:
      deleteItemInBackend in interface SalesDocumentBackend
      Parameters:
      salesDocument - document to delete item from
      itemToDelete - item technical key that is going to be deleted
      Throws:
      BackendException - in case of a back-end or communication error
    • deleteItemsInBackend

      public void deleteItemsInBackend(SalesDocument salesDocument, TechKey[] itemsToDelete, TransactionConfiguration transConf) throws BackendException
      Deletes multiple items in the backend.
      Specified by:
      deleteItemsInBackend in interface SalesDocumentBackend
      Parameters:
      salesDocument - Document to delete item from
      itemsToDelete - Array of item keys that are going to be deleted
      transConf - TransactionConfiguration to delete items dependent on shop settings
      Throws:
      BackendException - in case of a back-end or communication error
    • removeErroneousItems

      public void removeErroneousItems(TechKey[] itemsToDelete)
      Description copied from interface: BackendState
      Remove entries from list of error restore information .
      Specified by:
      removeErroneousItems in interface BackendState
    • emptyInBackend

      public void emptyInBackend(SalesDocument salesDocument) throws BackendException
      Description copied from interface: SalesDocumentBackend
      Empties the representation of the provided object in the underlying storage. This means that all items and the header information are cleared. The provided document itself is not changed, so you are responsible for clearing the data representation on the business object layer on your own.
      Specified by:
      emptyInBackend in interface SalesDocumentBackend
      Parameters:
      salesDocument - the document to remove the representation in the storage
      Throws:
      BackendException - in case of a back-end or communication error
    • getItemVariantMap

      public Map<String,String> getItemVariantMap()
      Returns the map, to store item variant information
      Specified by:
      getItemVariantMap in interface BackendState
      Specified by:
      getItemVariantMap in class IsaBackendBusinessObjectBaseSalesERP
      Returns:
      HashMap, the map to store item varaint information in
    • fixErroneousItem

      protected void fixErroneousItem(Item item)
    • initBackendObject

      public void initBackendObject() throws BackendException
      Initializes this Business Object.
      Specified by:
      initBackendObject in interface BackendBusinessObject
      Overrides:
      initBackendObject in class IsaBackendBusinessObjectBaseSalesERP
      Throws:
      BackendException - BackendException
    • isCreateProcess

      public boolean isCreateProcess()
      Description copied from interface: BackendState
      In case an order has just been created, or just been saved, we do not expect certain data to be present already. For Example DocFlow data. So for performance reasons it makes sense not to request those data.
      Specified by:
      isCreateProcess in interface BackendState
      Returns:
      true, if the salesdocument is just created
    • isErroneous

      public boolean isErroneous()
      Returns:
      true, if error occured
    • isMultipleAddressesSupported

      public boolean isMultipleAddressesSupported()
      Description copied from interface: SalesDocumentBackend
      Checks in the back end whether the multiple addresses are supported.
      Specified by:
      isMultipleAddressesSupported in interface SalesDocumentBackend
      Returns:
      true when the back end supports the multiple addresses
    • readForUpdateFromBackend

      public void readForUpdateFromBackend(SalesDocument salesDocument) throws BackendException
      Read the complete document from backend and reset the dirty flags.
      Specified by:
      readForUpdateFromBackend in interface SalesDocumentBackend
      Parameters:
      salesDocument - Sales Document
      Throws:
      BackendException - in case of a back-end or communication error
    • checkForInitializationError

      protected boolean checkForInitializationError(SalesDocument salesDocument)
    • isInBackend

      protected boolean isInBackend(SalesDocument salesDocument)
    • readFromBackend

      public void readFromBackend(SalesDocument salesDocument, TransactionConfiguration transConf, boolean directRead) throws BackendException
      Description copied from interface: SalesDocumentBackend
      Reads Data from the back end. Every document consists of two parts: the header and the items. This method retrieves the header and the item information. If a soldTo is set in the partner list, ship to information should be read
      Specified by:
      readFromBackend in interface SalesDocumentBackend
      Parameters:
      salesDocument - Sales Document to be read
      transConf - Transaction Configuration object that holds the configuration settings
      directRead - In case other sessions/channels update the sales document in parallel, it is only guaranteed that the most recent data is returned if direct read is set to true, otherwise the data might be returned from a buffer.
      Throws:
      BackendException - in case of a back-end or communication error
    • handleInvalidHeaderAfterRead

      protected void handleInvalidHeaderAfterRead(SalesDocument salesDocument)
      Actions which are needed for the header after a read step. Messages might need to be restored, because the header has been temporarily adjusted before.
    • restoreErroneousHeaderAfterRead

      protected void restoreErroneousHeaderAfterRead(SalesDocument salesDocument)
      Restore invalid header after read step. Restore required delivery date and messages.
    • handleInvalidItemsAfterRead

      protected void handleInvalidItemsAfterRead(SalesDocument salesDocument)
      Restores the sales document items after read and adds the information which needed to be removed before.
      Parameters:
      salesDocument - The cart sales document.
    • restoreErroneousItem

      protected void restoreErroneousItem(Item savedState, Item errItm)
      If an item has been fixed so that LO-API can consume it, we later on need to restore the user inputs, so that the user sees the data he/she has entered which need to be corrected.
      Parameters:
      savedState - The original, saved state of the item
      errItm - State of the erroneous item after LO-API can digest it
    • getErroneousItems

      public Map<TechKey,Item> getErroneousItems()
      Description copied from interface: BackendState
      Returns the previously stored information about erroneous items. Even if the sales document items are technically ok and can be sent via LO-API, this list holds the information which causes the trouble, and which needs to be put to the items after read to persist the user entry
      Specified by:
      getErroneousItems in interface BackendState
      Returns:
      Map for all erroneous items
    • handleInvalidItems

      protected boolean handleInvalidItems(SalesDocument salesDocument) throws BackendException
      Checks for invalid items and initialises them, so that they can be deleted afterwards. This call is done before the LO-API is called for reading item information.
      The items which cannot be digested by LO-API are fixed, the info needed to restore the document are kept in getErroneousItems()
      Parameters:
      salesDocument - Cart sales document
      Returns:
      Could we fix the document.
      Throws:
      BackendException
    • clearErroneousItems

      public void clearErroneousItems()
      Description copied from interface: BackendState
      Clear list of erroneous items
      Specified by:
      clearErroneousItems in interface BackendState
    • addErroneousItem

      public void addErroneousItem(Item item)
      Description copied from interface: BackendState
      Stores an erroneous item to be later able to restore its attrtibutes
      Specified by:
      addErroneousItem in interface BackendState
      Parameters:
      item - The item (including message list, productId which we need to restore
    • recoverFromBackend

      public boolean recoverFromBackend(SalesDocument salesDoc, TechKey basketGuid) throws BackendException
      Description copied from interface: SalesDocumentBackend
      Recovers the whole document for the given TechKey from the back end. Before calling this method, it should be checked if the back end is capable of recovering a document. This can be done by calling checkRecoveryInBackend. So far the recovery feature is only available for the java basket (see SalesDocumentDB), it is used during startup to recover a basket via a cookie (see BasketCookieHandler).
      Specified by:
      recoverFromBackend in interface SalesDocumentBackend
      Parameters:
      salesDoc - The document to load the data in.
      basketGuid - The TechKey of the basket to read
      Returns:
      success true when the recovering is successful
      Throws:
      BackendException - in case of a back-end or communication error
    • setErroneous

      public void setErroneous(boolean bool)
      Description copied from interface: BackendState
      Set the error state read from the backend
      Specified by:
      setErroneous in interface BackendState
      Parameters:
      bool - true if ERRKZ is 'X', otherwise false
    • setGData

      public void setGData(SalesDocument salesDocument, TransactionConfiguration shop) throws BackendException
      Call the ERP_LORD_LOAD for edit.
      Specified by:
      setGData in interface SalesDocumentBackend
      Parameters:
      salesDocument - The salesDoc to set the data to
      shop - Transaction configuration
      Throws:
      BackendException - in case of a back-end or communication error
    • setLoadStateCreate

      public void setLoadStateCreate()
      Description copied from interface: SalesDocumentBackend
      Copies back end data from basket to the order.
      Specified by:
      setLoadStateCreate in interface SalesDocumentBackend
    • updateInBackend

      public void updateInBackend(SalesDocument salesDocument) throws BackendException
      Description copied from interface: SalesDocumentBackend
      Updates object in the back end without supplying extra information about the transactionConfiguration. This method is normally necessary only for the B2C scenario.
      Note: For a correct support of the business event AddToDocument the techkey of the items should be filled from the back end.
      Specified by:
      updateInBackend in interface SalesDocumentBackend
      Parameters:
      salesDocument - the object to update
      Throws:
      BackendException - in case of a back-end or communication error
    • updateInBackend

      public void updateInBackend(SalesDocument salesDocument, TransactionConfiguration shop) throws BackendException
      Update object in the backend by putting the data into the underlying storage.
      Specified by:
      updateInBackend in interface SalesDocumentBackend
      Parameters:
      salesDocument - the document to update
      shop - the current shop
      Throws:
      BackendException - This exception is thrown if an error occurs in the back end
    • afterWriteDocument

      protected void afterWriteDocument(SalesDocument salesDocument, JCoConnection aJCoCon)
      Parameters:
      salesDocument -
      aJCoCon -
    • afterReadFromBackend

      protected void afterReadFromBackend(SalesDocument salesDocument, JCoConnection aJCoCon)
    • handleInvalidHeaderBeforeUpdate

      protected void handleInvalidHeaderBeforeUpdate(SalesDocument salesDocument)
      Actions which are needed before an update call if error situations occur. Implementation re-initializes the required delivery date in case nothing was entered
      Parameters:
      salesDocument - Sales document
    • handleInvalidItemsAfterUpdate

      protected void handleInvalidItemsAfterUpdate(SalesDocument salesDocument)
      Clear session storage of erroneous items for those items which are fine after the set call to SD
      Parameters:
      salesDocument -
    • checkShippingConditions

      protected void checkShippingConditions(SalesDocument salesDocument) throws BackendException
      Check whether shipping conditions have been changed, and trigger a new pricing if necessary.
      Parameters:
      salesDocument -
      Throws:
      BackendException
    • setShippingCondition

      public void setShippingCondition(String currentShippingCondition)
      Description copied from interface: BackendState
      Sets stored shipping condition. We need this to decide whether a pricing update is necessary.
      Specified by:
      setShippingCondition in interface BackendState
      Parameters:
      currentShippingCondition - Shipping condition
    • getShippingCondition

      public String getShippingCondition()
      Description copied from interface: BackendState
      Returns stored shipping condition. We need this to decide whether a pricing update is necessary.
      Specified by:
      getShippingCondition in interface BackendState
      Returns:
      Shipping condition
    • updateInBackend

      public void updateInBackend(SalesDocument salesDocument, TransactionConfiguration transactionConfiguration, List<TechKey> itemsToDelete) throws BackendException
      Description copied from interface: SalesDocumentBackend
      Updates object in the back end by putting the data into the underlying storage.
      Note: For a correct support of the business event AddToDocument the techkey of the items should be filled from the back end.
      Specified by:
      updateInBackend in interface SalesDocumentBackend
      Parameters:
      salesDocument - the document to update
      transactionConfiguration - Transaction Configuration object that holds the configuration settings
      itemsToDelete - List of techkeys of the items to be deleted in the back end
      Throws:
      BackendException - This exception is thrown if an error occurs in the back end
    • clearItemBuffer

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

      public Header getErroneousHeader()
      Description copied from interface: BackendState
      Returns the previously stored information about the erroneous header.
      Specified by:
      getErroneousHeader in interface BackendState
      Returns:
      Sales document header
    • setErroneousHeader

      public void setErroneousHeader(Header header)
      Description copied from interface: BackendState
      Sets erroneous header.
      Specified by:
      setErroneousHeader in interface BackendState
      Parameters:
      header - Sales document header
    • executeAdditionalPricing

      protected void executeAdditionalPricing(SalesDocument salesDocument, TransactionConfiguration shop) throws BackendException
      Execute additional pricing call if document is error free
      Parameters:
      salesDocument - Sales document
      shop - Sales configuration
      Throws:
      BackendException - Exception from backend call
    • isItemBasedAvailability

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

      public ModuleConfigurationAccess getModuleConfigurationAccess()
      Description copied from class: BackendBusinessObjectBase
      Returns the module configuration access.
      Overrides:
      getModuleConfigurationAccess in class BackendBusinessObjectBase
      Returns:
      the moduleConfigurationAccess
    • getAdditionalPricing

      public AdditionalPricing getAdditionalPricing()
      Returns:
      the additionalPricing
    • setAdditionalPricing

      public void setAdditionalPricing(AdditionalPricing additionalPricing)
      Parameters:
      additionalPricing - the additionalPricing to set
    • validate

      public void validate(SalesDocument salesDocument) throws BackendException
      Description copied from interface: SalesDocumentBackend
      Validates a sales document. Validation messages should be attached to salesDocument after validation
      Specified by:
      validate in interface SalesDocumentBackend
      Throws:
      BackendException
    • prepareForValidation

      protected ItemList prepareForValidation(SalesDocument salesDocument)
      Prepares the sales document for the validation call. In this implementation, to be sure to get all warnings related to order quantity: Changes all item quantities
      Parameters:
      salesDocument -
      Returns:
      Item list in its initial state
    • isBackendDown

      public boolean isBackendDown()
      Specified by:
      isBackendDown in interface SalesDocumentBackend
      Returns:
      Is back end in planned downtime?
    • getCloseStrategy

      protected LrdCloseStrategy getCloseStrategy()
      Returns:
      the closeStrategy
    • setCloseStrategy

      public void setCloseStrategy(LrdCloseStrategy closeStrategy)
      Parameters:
      closeStrategy - the closeStrategy to set
    • closeBackendSession

      public void closeBackendSession()
      Description copied from interface: SalesDocumentBackend
      Closes sales document in backend
      Specified by:
      closeBackendSession in interface SalesDocumentBackend
    • getSalesDocumentERPHooks

      public List<SalesDocumentERPHook> getSalesDocumentERPHooks()
      Returns:
      the salesDocumentERPHooks
    • setSalesDocumentERPHooks

      public void setSalesDocumentERPHooks(List<SalesDocumentERPHook> salesDocumentERPHooks)
      Parameters:
      salesDocumentERPHooks - the salesDocumentERPHooks to set