Class OrderListState

  • All Implemented Interfaces:
    java.io.Serializable

    public class OrderListState
    extends java.lang.Object
    implements java.io.Serializable
    Session object for keeping track of the list of orders. The state of the list is preserved here instead of via url parameters, which can get messy. There are three types of state: Order State, Order Type, and pagination position. Also provides convenience methods for retrieving the right set of data for a particular state. TODO: this can be generalized to use a set of State objects, including Pagination. Think about design patterns in Fowler.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected OrderListState()
      Initializes the order list state with default values.
    • Field Detail

      • VIEW_INDEX_PARAM

        public static final java.lang.String VIEW_INDEX_PARAM
        See Also:
        Constant Field Values
      • PARAM_TO_ORDER_STATUS_ID

        protected static final java.util.Map<java.lang.String,​java.lang.String> PARAM_TO_ORDER_STATUS_ID
      • PARAM_TO_ORDER_TYPE_ID

        protected static final java.util.Map<java.lang.String,​java.lang.String> PARAM_TO_ORDER_TYPE_ID
      • PARAM_TO_FILTER_ID

        protected static final java.util.Map<java.lang.String,​java.lang.String> PARAM_TO_FILTER_ID
    • Constructor Detail

      • OrderListState

        protected OrderListState()
        Initializes the order list state with default values. Do not use directly, instead use getInstance().
    • Method Detail

      • getInstance

        public static OrderListState getInstance​(HttpServletRequest request)
        Retrieves the current user's OrderListState from the session or creates a new one with defaults.
      • update

        public void update​(HttpServletRequest request)
        Given a request, decides what state to change. If a parameter changeStatusAndTypeState is present with value "Y", the status and type state will be updated. Otherwise, if the viewIndex and viewSize parameters are present, the pagination changes.
      • getOrderStatusState

        public java.util.Map<java.lang.String,​java.lang.String> getOrderStatusState()
        Gets order status state.
        Returns:
        the order status state
      • getOrderTypeState

        public java.util.Map<java.lang.String,​java.lang.String> getOrderTypeState()
        Gets order type state.
        Returns:
        the order type state
      • getorderFilterState

        public java.util.Map<java.lang.String,​java.lang.String> getorderFilterState()
        Gets filter state.
        Returns:
        the filter state
      • setStatus

        public void setStatus​(java.lang.String param,
                              boolean b)
        Sets status.
        Parameters:
        param - the param
        b - the b
      • setType

        public void setType​(java.lang.String param,
                            boolean b)
        Sets type.
        Parameters:
        param - the param
        b - the b
      • hasStatus

        public boolean hasStatus​(java.lang.String param)
        Has status boolean.
        Parameters:
        param - the param
        Returns:
        the boolean
      • hasType

        public boolean hasType​(java.lang.String param)
        Has type boolean.
        Parameters:
        param - the param
        Returns:
        the boolean
      • hasFilter

        public boolean hasFilter​(java.lang.String param)
        Has filter boolean.
        Parameters:
        param - the param
        Returns:
        the boolean
      • hasAllStatus

        public boolean hasAllStatus()
        Has all status boolean.
        Returns:
        the boolean
      • getViewSize

        public int getViewSize()
        Gets view size.
        Returns:
        the view size
      • getViewIndex

        public int getViewIndex()
        Gets view index.
        Returns:
        the view index
      • getSize

        public int getSize()
        Gets size.
        Returns:
        the size
      • hasPrevious

        public boolean hasPrevious()
        Has previous boolean.
        Returns:
        the boolean
      • hasNext

        public boolean hasNext()
        Has next boolean.
        Returns:
        the boolean
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object