# com.beasys.commerce.ebusiness.order
OrderManagerBean Class

public class OrderManagerBean
extends `Object`
implements `SessionBean`

The OrderManagerBean is a session bean that isolates the JSP type calls from dealing directly with Order Entity Beans in a piece-meal fashion and improves performance by keeping the calls on the EJB sides.
Its main purpose is to create an Order and to retrieve OrderValue's using a variety of criteria, customerPK, a date range, a SKU, a Status.
The returned objects on those finder methods may be either straight collection with all the orderValue objects filled, or a more sophisticated ScrollableModel which caches the PK and a few orderValues only.
Finally, the OrderManagerBean deals with getting and setting an Order's status, and helps the JSP presentation by providing the only possible statuses an Order can move to.

Related Topics

``OrderValue``
``StateMachine``
``ScrollableModel``
``OrderManagerHome``
``OrderManager``

Hierarchy
  `Object`
  `OrderManagerBean`

All Implemented Interfaces
  `EnterpriseBean`, `Serializable`, `SessionBean`

## Constructor Summary

OrderManagerBean() The constructor gets an order state machine for any status associated action.

## Method Summary

`protected static void` | `close`(`Connection` connection, `PreparedStatement` statement, `ResultSet` resultSet) Close database "stuff" quietly and without exceptions.
`public `Handle`` | `createOrder`(`OrderPk` orderPK, `OrderValue` orderValue, `Quote` adjustments) Creates an order using a value object.
`public void` | `ejbActivate`() Empty ejb method implementation
`public void` | `ejbCreate`() Empty ejb method implementation
`public void` | `ejbPassivate`() Empty ejb method implementation
`public void` | `ejbPostCreate`() Empty ejb method implementation
`public void` | `ejbRemove`() Empty ejb method implementation
`public `ScrollableModel`` | `findByCustomer`(`CustomerPk` customerPK, int pageSize) Finds the OrderValues associated with a customer and returns a scrollable model
`public `Collection`` | `findByCustomer`(`CustomerPk` customerPk) Finds the OrderValues associated with a customer and returns a collection
`public `ScrollableModel`` | `findByDates`(`Date` startDate, `Date` endDate, int pageSize) Finds the OrderValues associated with a date range and returns a scrollable model
`public `Collection`` | `findByDates`(`Date` startDate, `Date` endDate) Finds a collection of orders given a range of dates.
`public `OrderValue`` | `findByPK`(`OrderPk` pk) Finds an order value given its primary key.
`public `Collection`` | `findBySKU`(`String` SKU) This method uses a prepared statement and a Jdbc Connection to retrieve Order Values from the WLCS_ORDER_LINE table, based on the SKU of a product item.
`public `ScrollableModel`` | `findBySKU`(`String` sku, int pageSize) This method uses a prepared statement and a Jdbc Connection to retrieve Order Values organized in a ScrollableModel from the WLCS_ORDER_LINE table, based on the SKU of a product item.
`public `ScrollableModel`` | `findByStatus`(`String` status, int pageSize) Finds the OrderValues associated with a status and returns a scrollable model
`public `Collection`` | `findByStatus`(`String` status) Finds the OrderValues associated with a status and returns a collection
`public `String`` | `getOrderStatus`(`OrderPk` pk) Gets the status of an order, given the order's primary key.
`public `String`[]` | `getValidNewStatuses`(`OrderPk` orderPK) Retrieves all the possible statuses an Order can move to based on its primary key.
`public void` | `queryOrderAdjusments`(`OrderPk` orderPk, `OrderValue` orderValue) this call fills an orderValue with the adjustments that are associated with it.
`public void` | `setOrderStatus`(`OrderPk` pk, `String` orderStatus) Sets an order's status to a specified value, given the order's primary key.
`public void` | `setSessionContext`(`SessionContext` context) Set the session context
`public void` | `updateOrderDiscounts`(`OrderPk` orderPk, `OrderValue` orderValue, `Quote` adjustments) updates the discounts associated with an order

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods from interface `javax.ejb.`SessionBean``
`ejbActivate, ejbPassivate, ejbRemove, setSessionContext`

## Constructor Detail

### OrderManagerBean

    public OrderManagerBean()

  The constructor gets an order state machine for any status associated action. Check license first!

## Method Detail

### close(Connection, PreparedStatement, ResultSet) Method

    protected static void close(Connection connection,
                                PreparedStatement statement,
                                ResultSet resultSet)

Close database "stuff" quietly and without exceptions. This convenience method takes a Statement, ResultSet, and Connection. If the argument is null or not one of the recognized types, nothing is done.

### createOrder(OrderPk, OrderValue, Quote) Method

    public Handle createOrder(OrderPk orderPK,
                              OrderValue orderValue,
                              Quote adjustments)
         throws RemoteException

Creates an order using a value object. It also persist the ajustments associated with that order

#### Parameters

orderPK
  the primary key for the order

orderValue
  the value object for the order

adjustments
  the adjustments for the order (and its lines)

#### Returns

a handle over the order

#### Exceptions

``RemoteException``

### ejbActivate() Method

    public void ejbActivate()

Empty ejb method implementation

### ejbCreate() Method

    public void ejbCreate()

Empty ejb method implementation

### ejbPassivate() Method

    public void ejbPassivate()

Empty ejb method implementation

### ejbPostCreate() Method

    public void ejbPostCreate()

Empty ejb method implementation

### ejbRemove() Method

    public void ejbRemove()

Empty ejb method implementation

### findByCustomer(CustomerPk, int) Method

    public ScrollableModel findByCustomer(CustomerPk customerPK,
                                          int pageSize)
         throws RemoteException

Finds the OrderValues associated with a customer and returns a scrollable model

#### Returns

the ScrollableModel that manages the corresponding Order values

#### Exceptions

``RemoteException``

### findByCustomer(CustomerPk) Method

    public Collection findByCustomer(CustomerPk customerPk)
         throws RemoteException

Finds the OrderValues associated with a customer and returns a collection

#### Returns

the Collection that manages the corresponding Order values

#### Exceptions

``RemoteException``

### findByDates(Date, Date, int) Method

    public ScrollableModel findByDates(Date startDate,
                                       Date endDate,
                                       int pageSize)
         throws RemoteException

Finds the OrderValues associated with a date range and returns a scrollable model

#### Parameters

startDate
  of the date range

endDate
  of the date range

pageSize
  the size of a page of cached order values

#### Returns

the ScrollableModel that manages the corresponding Order values

#### Exceptions

``RemoteException``

### findByDates(Date, Date) Method

    public Collection findByDates(Date startDate,
                                  Date endDate)
         throws RemoteException

Finds a collection of orders given a range of dates.

#### Returns

The Collection of order for the date range

#### Exceptions

``RemoteException``

### findByPK(OrderPk) Method

    public OrderValue findByPK(OrderPk pk)
         throws RemoteException

Finds an order value given its primary key.

#### Parameters

pk
  The primary key of the order to be found

#### Returns

The order value

#### Exceptions

``RemoteException``

### findBySKU(String) Method

    public Collection findBySKU(String SKU)
         throws RemoteException

This method uses a prepared statement and a Jdbc Connection to retrieve Order Values from the WLCS_ORDER_LINE table, based on the SKU of a product item. Each OrderValue found appears only once in the Collection, even if there are many OrderLines in a single Order for a single SKU (unlikely, but physically possible).

#### Returns

a Collection (ArrayList) of OrderValue's

#### Exceptions

``RemoteException``

### findBySKU(String, int) Method

    public ScrollableModel findBySKU(String sku,
                                     int pageSize)
         throws RemoteException

This method uses a prepared statement and a Jdbc Connection to retrieve Order Values organized in a ScrollableModel from the WLCS_ORDER_LINE table, based on the SKU of a product item.
Each OrderValue found appears only once in the ScrollableModel, even if there are many OrderLines in a single Order for a single SKU (unlikely, but physically possible).

#### Returns

a ScrollableModel (ArrayList) managing the Order Values

#### Exceptions

``RemoteException``

### findByStatus(String, int) Method

    public ScrollableModel findByStatus(String status,
                                        int pageSize)
         throws RemoteException

Finds the OrderValues associated with a status and returns a scrollable model

#### Parameters

status
  e.g. "Authorized"

pageSize
  the size of a page of cached order values

#### Returns

the ScrollableModel that manages the corresponding Order values

#### Exceptions

``RemoteException``

### findByStatus(String) Method

    public Collection findByStatus(String status)
         throws RemoteException

Finds the OrderValues associated with a status and returns a collection

#### Parameters

status
  e.g. "Authorized"

#### Returns

the collection that manages the corresponding Order values

#### Exceptions

``RemoteException``

### getOrderStatus(OrderPk) Method

    public String getOrderStatus(OrderPk pk)
         throws RemoteException

Gets the status of an order, given the order's primary key.

#### Parameters

pk
  The primary key of the order in question

#### Returns

A string with the order's status

#### Exceptions

``RemoteException``

### getValidNewStatuses(OrderPk) Method

    public String[] getValidNewStatuses(OrderPk orderPK)
         throws RemoteException

Retrieves all the possible statuses an Order can move to based on its primary key. This can then be used by the presentation layer

#### Returns

a String array, one per status the order can be moved to

#### Exceptions

``RemoteException``

### queryOrderAdjusments(OrderPk, OrderValue) Method

    public void queryOrderAdjusments(OrderPk orderPk,
                                     OrderValue orderValue)
         throws RemoteException

this call fills an orderValue with the adjustments that are associated with it.

#### Parameters

orderPk
  the order primary key.

orderValue
  the order value to fill with adjustments

#### Exceptions

``RemoteException``

### setOrderStatus(OrderPk, String) Method

    public void setOrderStatus(OrderPk pk,
                               String orderStatus)
         throws RemoteException

Sets an order's status to a specified value, given the order's primary key.

#### Parameters

pk
  The order's primary key

orderStatus

#### Exceptions

``RemoteException``

### setSessionContext(SessionContext) Method

    public void setSessionContext(SessionContext context)

Set the session context

#### Parameters

context
  the Session context

### updateOrderDiscounts(OrderPk, OrderValue, Quote) Method

    public void updateOrderDiscounts(OrderPk orderPk,
                                     OrderValue orderValue,
                                     Quote adjustments)
         throws RemoteException

updates the discounts associated with an order

#### Parameters

orderPk
  the order primary key.

orderValue
  the order value which contains the creation date and the orderline

adjustments
  a Quote object containing the adjustments

#### Exceptions

``RemoteException``