All Superinterfaces:
BackendBusinessObject
All Known Subinterfaces:
BasketBackend, OrderBackend, OrderBaseBackend, OrderHistoryBackend
All Known Implementing Classes:
BasketERP, OrderBaseERP, OrderERP, OrderHistoryERP, SalesDocumentERP

public interface SalesDocumentBackend extends BackendBusinessObject
Common interface for the back-end implementation of all sales documents (i.e. Order and Basket). This grouping may not be suitable for all possible back-end/front-end scenarios but saves a lot of implementation effort for the default scenario, where the only back end system is the CRM.

Note - There was a design decision to give all back-end interfaces and their implementors a stateless-like behaviour. This means that the back-end objects are not truly stateless because the connection management of the actual used back-end systems cannot support this at all, but the method signatures are similar to stateless objects. This feature forces you to provide a reference to the object the back-end method should work on as a method parameter. This may seem a little bit complicated, but it allows us to migrate to an EJB-Solution with real stateless session beans very easy.
  • Method Details

    • createInBackend

      void createInBackend(TransactionConfiguration transactionConfiguration, SalesDocument salesDocument) throws BackendException
      Creates a back-end representation of this object in the back end.
      Parameters:
      transactionConfiguration - Transaction Configuration object that holds the configuration settings
      salesDocument - The sales document object contains data to be used for creating sales document in the back-end
      Throws:
      BackendException - in case of a back-end or communication error
    • deleteItemInBackend

      void deleteItemInBackend(SalesDocument salesDocument, TechKey itemToDelete) throws BackendException
      Deletes one item of the document in the underlying storage. The document in the business object layer is not changed at all.
      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

      void deleteItemsInBackend(SalesDocument salesDocument, TechKey[] itemsToDelete, TransactionConfiguration transConf) throws BackendException
      Deletes list of items from the underlying storage. The document in the business object layer is not changed at all.
      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
    • emptyInBackend

      void emptyInBackend(SalesDocument salesDocument) throws BackendException
      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.
      Parameters:
      salesDocument - the document to remove the representation in the storage
      Throws:
      BackendException - in case of a back-end or communication error
    • getSalesDocumentType

      SalesDocumentType getSalesDocumentType()
      Each implementing class has to define the used sales document type. This is e.g. used for finding the right strategies.
      Returns:
      sales document type
    • isMultipleAddressesSupported

      boolean isMultipleAddressesSupported()
      Checks in the back end whether the multiple addresses are supported.
      Returns:
      true when the back end supports the multiple addresses
    • readForUpdateFromBackend

      void readForUpdateFromBackend(SalesDocument salesDocument) throws BackendException
      Reads the sales document from the back end and lock this document, so that it can be modified.
      Parameters:
      salesDocument - Sales Document
      Throws:
      BackendException - in case of a back-end or communication error
    • readFromBackend

      void readFromBackend(SalesDocument salesDocument, TransactionConfiguration transactionConfiguration, boolean directRead) throws BackendException
      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
      Parameters:
      salesDocument - Sales Document to be read
      transactionConfiguration - 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
    • recoverFromBackend

      boolean recoverFromBackend(SalesDocument salesDoc, TechKey basketGuid) throws BackendException
      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).
      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
    • setGData

      void setGData(SalesDocument salesDoc, TransactionConfiguration transactionConfiguration) throws BackendException
      Sets the global data in the back end. Use this action, if you don't know the soldTo of the sales document.
      Parameters:
      salesDoc - The salesDoc to set the data to
      transactionConfiguration - Transaction configuration
      Throws:
      BackendException - in case of a back-end or communication error
    • setLoadStateCreate

      void setLoadStateCreate()
      Copies back end data from basket to the order.
    • updateInBackend

      void updateInBackend(SalesDocument salesDocument) throws BackendException
      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.
      Parameters:
      salesDocument - the object to update
      Throws:
      BackendException - in case of a back-end or communication error
    • updateInBackend

      void updateInBackend(SalesDocument salesDocument, TransactionConfiguration transactionConfiguration) throws BackendException
      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.
      Parameters:
      salesDocument - the document to update
      transactionConfiguration - Transaction Configuration object that holds the configuration settings
      Throws:
      BackendException - This exception is thrown if an error occurs in the back end
    • updateInBackend

      void updateInBackend(SalesDocument salesDocument, TransactionConfiguration transactionConfiguration, List<TechKey> itemsToDelete) throws BackendException
      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.
      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

      void clearItemBuffer()
      Removes all buffered item information
    • isItemBasedAvailability

      boolean isItemBasedAvailability()
      Checks if availability is compiled only based on item information.
      Returns:
      Availability is compiled only based on item information?
    • validate

      void validate(SalesDocument salesDocument) throws BackendException
      Validates a sales document. Validation messages should be attached to salesDocument after validation
      Parameters:
      salesDocument -
      Throws:
      BackendException
    • isBackendDown

      boolean isBackendDown()
      Returns:
      Is back end in planned downtime?
    • closeBackendSession

      void closeBackendSession()
      Closes sales document in backend