com.ibm.commerce.payment.rules

Class RuleReader

  • java.lang.Object
    • com.ibm.commerce.payment.rules.RuleReader


  • public class RuleReader
    extends java.lang.Object
    This class is the rule implementor for rule. CommandAmount indicates the amount to be acted on in that phase. This is true, even if the backend action is "ConsumeAmount" because some updates need to be done anyway in the Atomic Payments. Thus CommandAmount should always be filled (in a non-error case) and should indicate the amount on which action in this phase is to be taken.

    Class Responsibility: It provides a static function that is used to walk through a list actions to be taken against Backend. The action list having been provided by the payment actions rule. With the help of the dataadapter, it prepares and verifies the presence of all the necessary data elements to take the indicated action against Backend. There is another important responsibility of this class (specifically the static function it houses). It's to create new Atomic Payments if the payment actions rule indicate that it is necessary to do so. This class houses static variables and functions only, and thus would not be instantiated.

    • Constructor Summary

      Constructors 
      Constructor and Description
      RuleReader(EDPServices localServices)
      This method creates a new RuleReader object.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void prepareActionListForUnhandledAmount(java.lang.Integer storeId, java.util.Locale locale, java.lang.String orderChannel, CommandContext context, java.lang.Long edpOrderId, java.math.BigDecimal amountToProcess, java.util.HashMap listOfActionLists, int phase, java.util.List releaseIds)
      This method loops through all payment instructions and until the validation amount is completely allocated, performs each of the following steps for each payment instruction:
      It gets list of Atomic Payments associated with the Payment Instruction.
      java.util.List readEditRuleAndProvideActions(java.lang.String editEvent, java.lang.Long pdpPIId, java.lang.Long edpOrderId, java.util.List releaseIds)
      This method reads the edit rules and provides the actions.
      java.util.List readReversalRuleAndProvideActions(java.lang.String ruleType, java.lang.Long edpOrderId, java.lang.Long pdpPIId, java.lang.Long atomicPaymentId)
      This method reads the cancel order rule and picks actions to possibly move from current state of APPROVED to the desired state of DNE .
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
      • EDIT_EVENT_ADD_ORDER_AMOUNT

        public static final java.lang.String EDIT_EVENT_ADD_ORDER_AMOUNT
        edit event to increase order amount
        See Also:
        Constant Field Values
      • EDIT_EVENT_REDUCE_ORDER_AMOUNT

        public static final java.lang.String EDIT_EVENT_REDUCE_ORDER_AMOUNT
        edit event to reduce to order amount
        See Also:
        Constant Field Values
      • EDIT_EVENT_REPLACE_PMT_INSTR

        public static final java.lang.String EDIT_EVENT_REPLACE_PMT_INSTR
        edit event to replace a PI
        See Also:
        Constant Field Values
      • UNHANDLE_AMOUNT_RULES

        public static final int UNHANDLE_AMOUNT_RULES
        phase for use prepareActionListForUnhandledAmount method
        See Also:
        Constant Field Values
      • EDIT_RULES

        public static final int EDIT_RULES
        phase for use readEditRuleAndProvideActions method
        See Also:
        Constant Field Values
      • REVERSAL_RULES

        public static final int REVERSAL_RULES
        phase for use readReversalRuleAndProvideActions method
        See Also:
        Constant Field Values
    • Constructor Detail

      • RuleReader

        public RuleReader(EDPServices localServices)
        This method creates a new RuleReader object.
        Parameters:
        localServices - The EDP services to be used.
    • Method Detail

      • prepareActionListForUnhandledAmount

        public void prepareActionListForUnhandledAmount(java.lang.Integer storeId,
                                                        java.util.Locale locale,
                                                        java.lang.String orderChannel,
                                                        CommandContext context,
                                                        java.lang.Long edpOrderId,
                                                        java.math.BigDecimal amountToProcess,
                                                        java.util.HashMap listOfActionLists,
                                                        int phase,
                                                        java.util.List releaseIds)
                                                 throws EDPException,
                                                        ECException

        This method loops through all payment instructions and until the validation amount is completely allocated, performs each of the following steps for each payment instruction:

        1. It gets list of Atomic Payments associated with the Payment Instruction.
        2. It returns the amount available for validation for the Payment Instruction.
        3. It allocates a portion of initial amount(or full initialAmount if it is less than available amount) to the Payment Instruction.
        4. It obtains the list of actions required to be taken against Backend to satisfy the request to validate the allocated amount. (Create new atomic payments as part of the process, as needed.)

        The method acts through side-effect by populating the listOfActionDetailLists object. This object can be accessed at the successful completion of this method and the Backend actions contained within it can be executed

        Parameters:
        storeId - The current store ID
        locale - The current locale
        orderChannel - The order channel ID
        context - The command context
        edpOrderId - The Payment Rules order data
        amountToProcess - The amount to process
        listOfActionLists - The list that stores all lists of the actions
        phase - The current payment business event phase
        releaseIds - The identifiers of the current releases
        Throws:
        EDPException - For generic errors as when the phase variable is not correct
        ECException - An error should never happen
      • readEditRuleAndProvideActions

        public java.util.List readEditRuleAndProvideActions(java.lang.String editEvent,
                                                            java.lang.Long pdpPIId,
                                                            java.lang.Long edpOrderId,
                                                            java.util.List releaseIds)
                                                     throws InputException,
                                                            J2EEException,
                                                            RuleException
        This method reads the edit rules and provides the actions. Note that the actions provided are all payment service actions.
        Parameters:
        editEvent - The edit event
        pdpPIId - The Payment Rules Payment Instruction data
        edpOrderId - The Payment Rules order data
        releaseIds - The identifier of current releases
        Returns:
        List The list of edit rules
        Throws:
        InputException - In case of input failure
        J2EEException - In case of J2EEException
        RuleException - In case of rule configuration failure
      • readReversalRuleAndProvideActions

        public java.util.List readReversalRuleAndProvideActions(java.lang.String ruleType,
                                                                java.lang.Long edpOrderId,
                                                                java.lang.Long pdpPIId,
                                                                java.lang.Long atomicPaymentId)
                                                         throws InputException,
                                                                J2EEException,
                                                                RuleException

        This method reads the cancel order rule and picks actions to possibly move from current state of APPROVED to the desired state of DNE . However, the rule may often indicates no action required.

        Parameters:
        ruleType - The rule type
        edpOrderId - Value object for EDPOrder
        pdpPIId - Value object for Payment Instruction
        atomicPaymentId - Value object for atomic payment
        Returns:
        Collection of actions that can be immediately executed against the backend
        Throws:
        InputException - In case of any input failure
        J2EEException - In case of any J2EE failure
        RuleException - In case of rule failure