com.ibm.commerce.payment.rules.commands

Class DetermineSortedPaymentsCmdImpl

  • All Implemented Interfaces:
    com.ibm.commerce.command.CacheableECCommand, ECCommand, ECTargetableCommand, TaskCommand, DetermineSortedPaymentsCmd, com.ibm.websphere.cache.Sizeable, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command, com.ibm.websphere.command.CommandCaller, com.ibm.websphere.command.TargetableCommand, java.io.Serializable


    public class DetermineSortedPaymentsCmdImpl
    extends TaskCommandImpl
    implements DetermineSortedPaymentsCmd
    This is the implementation class of the task command DetermineSortedPaymentsCmd. It builds the relationship between releases and payments according to the algorithm described in the business logic. The relationship will be stored in the table "EDPRELHIST". Each relationship associates an order release with a payment recorded in the table "EDPPAYHIST".
    1. Input parameters:

      paymentContainer: All available com.ibm.commerce.payment.rules.AtomicPaymentToBackendLinkObject objects which can be used. Each com.ibm.commerce.payment.rules.AtomicPaymentToBackendLinkObject object corresponds to an available payment object. This parameter is passed in by setPaymentContainer(Collection).

      releasesWithAmount: The LinkedHashMap object containing all releases to process. The key of this LinkedHashMap is ID of the release object with Long type. The value of this LinkedHashMap is the amount with BigDecimal that needs to process of the corresponding release. This parameter should be set to the request properties in the command context with the key "releasesWithAmount".

    2. Business Logic:

      Step 1. This class firstly iterates the releases in input collection. For each release, this class checks all of the payments in the payment container passed in. If the items of this release include the items associated with the payment object, then relationship will be built between this release and the payment. Also those payment objects which are built relationship with release in this step will be put into the resulting payment container. They will be in the beginning position of the resulting payment container. This is to notify the payment rules engine to pick up these payment with the highest priority when it calculates payment actions for the releases.

      Step 2. This class then iterates the releases which have not been built relationship with any payment objects. For each release, this class checks all of the payments which have not been built relationship with any releases. If the total amount of this release equals to the available amount of one payment, the relationship is built between this release and the payment. At once a release is built relationship with any one payment object here, the iteration for this release will exit. That is, one release would be built relationship with at most one payment object here. Also those payment objects which are built relationship with release in this step will be put into resulting container. The position of these payment objects is after the payment objects of step 1 in the payment container. The remaining payments which have not been built relationship with any releases just keep original order. But they will be at the last part of the resulting payment container.

    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        The internal copyright field.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DetermineSortedPaymentsCmdImpl

        public DetermineSortedPaymentsCmdImpl()
    • Method Detail

      • getReleases

        public java.util.LinkedHashMap getReleases()
                                            throws ECException
        This method gets the collection containing numbers of the release in process.
        Returns:
        the LinkedHashMap object in the request properties
        Throws:
        ECException - in case of exceptional situations
      • getPaymentContainer

        public java.util.Collection getPaymentContainer()
        This method gets the payment container passed in.
        Specified by:
        getPaymentContainer in interface DetermineSortedPaymentsCmd
        Returns:
        the payment container passed in
      • setPaymentContainer

        public void setPaymentContainer(java.util.Collection container)
        This method sets the payment container passed in.
        Specified by:
        setPaymentContainer in interface DetermineSortedPaymentsCmd
        Parameters:
        container - the payment container passed in
      • setOrderId

        public void setOrderId(java.lang.Long orderIdentifier)
        This method sets the current order ID.
        Specified by:
        setOrderId in interface DetermineSortedPaymentsCmd
        Parameters:
        orderIdentifier - the current order ID
      • getOrderId

        public java.lang.Long getOrderId()
        This method returns the current order ID.
        Returns:
        the current order ID