com.ibm.commerce.price.utils

Class TradingManager

  • java.lang.Object
    • com.ibm.commerce.price.utils.TradingManager


  • public class TradingManager
    extends java.lang.Object
    TradingManager is used to ensure compatibility for contract entitlement for a single catalog entry. In some cases, it is desirable to pass inputs between price commands, but the next command should not use a particular contract to calculate a price. This class can be used to ensure that the behavior of the next command will work, by giving it contracts in such a way that the expected prices will always be calculated in the correct way. Here are the scenarios handled:
    • Single mode - single mode identifiers not given
    • Single mode - single mode identifiers given
    • Batch mode - single mode identifiers not given, batch mode identifiers not given
    • Batch mode - single mode identifiers given, batch mode identifiers not given
    • Batch mode - single mode identifiers not given, batch mode identifiers given
    • Batch mode - single mode identifiers given, batch mode identifiers given
    The constructors are used to specify the original trading agreement identifiers that are specified in several places. The addID(Long) method is used to iteratively add the identifiers that are still desired. The single mode identifiers are returned by getSingleModeIDs(). The batch mode identifiers are returned by getBatchModeIDs() (these will always be null if the original input is single mode). The newBatch(List) method can be used as a shortcut to create different mangers for each CatEntryPrices object as needed.

    Note that before using either of the output methods, isValid() must be called to determine if the outputs are valid. This manager may be made invalid by adding an identifier that is not entitled, or by adding one that would be impossible to obtain from the original inputs.

    • Constructor Summary

      Constructors 
      Constructor and Description
      TradingManager(java.util.List<java.lang.Long> newEntitled, java.util.List<java.lang.Long> newCurrent, java.util.List<java.lang.Long> newSingleMode)
      Constructor for TradingManager that is used to handle single mode.
      TradingManager(java.util.List<java.lang.Long> newEntitled, java.util.List<java.lang.Long> newCurrent, java.util.List<java.lang.Long> newSingleMode, java.util.List<java.lang.Long> newBatchMode)
      Constructor for TradingManager that is used to handle batch mode.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void addID(java.lang.Long id)
      Adds the given trading agreement identifier to be managed by this.
      MixList<java.lang.Long> getBasePool()
      Returns the trading agreement identifier "pool" which will contain the allowed identifiers.
      MixList<java.lang.Long> getBatchModeIDs()
      Returns the batch mode trading agreement identifiers that will allow all the accumulated identifiers to be processed as expected.
      MixList<java.lang.Long> getSingleModeIDs()
      Returns the single mode trading agreement identifiers that will allow all the accumulated identifiers to be processed as expected.
      boolean isValid()
      Returns whether the accumulated trading agreement identifiers are valid, using the original input to limit which identifiers are valid.
      TradingManager newBatch(java.util.List<java.lang.Long> newBatchMode)
      Creates a new version of a batch trading agreement manager.
      java.lang.String toString()
      Returns the string representation of this, including the entitled, current, single mode, (if applicable) batch mode, and accumulated identifiers.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TradingManager

        public TradingManager(java.util.List<java.lang.Long> newEntitled,
                              java.util.List<java.lang.Long> newCurrent,
                              java.util.List<java.lang.Long> newSingleMode)
        Constructor for TradingManager that is used to handle single mode.
        Parameters:
        newEntitled - The trading agreement identifiers that the user is entitled to use. All contracts added to this must be in this list. Cannot be null or empty.
        newCurrent - The trading agreement identifiers that the user is currently using. These will be used to determine the allowed default trading agreements, and will limit which contracts can be added if defaults are used. Every element in this list must also be in eligibleTradingIDs (although the reverse is not necessarily true). Cannot be null or empty.
        newSingleMode - The trading agreement identifiers that were set by calling GetContractUnitPriceCmd.setTradingIds(Long[]) (or from one of the other price commands) on the original input. May be null or empty.
      • TradingManager

        public TradingManager(java.util.List<java.lang.Long> newEntitled,
                              java.util.List<java.lang.Long> newCurrent,
                              java.util.List<java.lang.Long> newSingleMode,
                              java.util.List<java.lang.Long> newBatchMode)
        Constructor for TradingManager that is used to handle batch mode.
        Parameters:
        newEntitled - The trading agreement identifiers that the user is entitled to use. All contracts added to this must be in this list. Cannot be null or empty.
        newCurrent - The trading agreement identifiers that the user is currently using. These will be used to determine the allowed default trading agreements, and will limit which contracts can be added if defaults are used. Every element in this list must also be in eligibleTradingIDs (although the reverse is not necessarily true). Cannot be null or empty.
        newSingleMode - The trading agreement identifiers that were set by calling GetContractUnitPriceCmd.setTradingIds(Long[]) (or from one of the other price commands) on the original input. May be null or empty.
        newBatchMode - The trading agreement identifiers that were set by calling CatEntryPrices.setTradingIds(Long[]) on the original input. May be null or empty.
    • Method Detail

      • addID

        public void addID(java.lang.Long id)
        Adds the given trading agreement identifier to be managed by this.
        Parameters:
        id - The trading agreement identifier to add. Cannot be null.
      • getBasePool

        public MixList<java.lang.Long> getBasePool()
        Returns the trading agreement identifier "pool" which will contain the allowed identifiers. There are three base pools:
        1. The current trading agreements. This pool will be used if the others are not available.
        2. The single mode trading agreements. This pool will be used if the single mode identifiers are provided.
        3. The batch mode trading agreements. This pool will be used if batch mode identifiers are provided.
        The base pool determines which identifiers can be used. However, the base pool is not necessarily modified. In single mode, the single base pool can be modified. In batch mode, the batch base pool can be modified. If all the accumulated identifiers are the same as the source pool, the target pool will not be modified.
        Returns:
        The base pool which determines which trading agreement identifiers can be used. This value will not be null or empty.
      • getBatchModeIDs

        public MixList<java.lang.Long> getBatchModeIDs()
        Returns the batch mode trading agreement identifiers that will allow all the accumulated identifiers to be processed as expected. This method should only be used when calling CatEntryPrices.setTradingIds(Long[]), and so is only useful in batch mode.
        Returns:
        The batch mode trading agreement identifiers. This value may be null or empty.
      • getSingleModeIDs

        public MixList<java.lang.Long> getSingleModeIDs()
        Returns the single mode trading agreement identifiers that will allow all the accumulated identifiers to be processed as expected. This method should be used when calling GetContractUnitPriceCmd.setTradingIds(Long[]) (or a similar method in the other price commands), but should be used in both single and batch mode, since both modes can be influenced.
        Returns:
        The single mode trading agreement identifiers. This value may be null or empty.
      • isValid

        public boolean isValid()
        Returns whether the accumulated trading agreement identifiers are valid, using the original input to limit which identifiers are valid.
        Returns:
        True if getSingleModeIDs() and getBatchModeIDs() may be called without problems, false otherwise.
      • newBatch

        public TradingManager newBatch(java.util.List<java.lang.Long> newBatchMode)
                                throws java.lang.IllegalStateException
        Creates a new version of a batch trading agreement manager. The entitled, current and single mode trading agreement identifiers will all be copied to the new manager.
        Parameters:
        newBatchMode - The batch mode trading agreement identifiers for a different input catalog entry than this was used for. May be null or empty.
        Returns:
        A new trading agreement manager. This value will not be null.
        Throws:
        java.lang.IllegalStateException - If this is not used to manage batch trading agreement identifiers.
      • toString

        public java.lang.String toString()
        Returns the string representation of this, including the entitled, current, single mode, (if applicable) batch mode, and accumulated identifiers.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string representation of this. This value will not be null or empty.