com.elasticpath.service.order.impl
Class OrderServiceImpl

java.lang.Object
  extended by com.elasticpath.service.impl.AbstractEpServiceImpl
      extended by com.elasticpath.service.impl.AbstractEpPersistenceServiceImpl
          extended by com.elasticpath.service.order.impl.OrderServiceImpl
All Implemented Interfaces:
EpPersistenceService, EpService, OrderService

public class OrderServiceImpl
extends AbstractEpPersistenceServiceImpl
implements OrderService

Provides storage and access to Order objects.


Constructor Summary
OrderServiceImpl()
           
 
Method Summary
 Order add(Order order)
          Adds the given order.
 Order addOrderReturn(long orderUid, OrderReturn orderReturn)
          Add the given OrderReturn to the order with given uid.
 java.util.List findAllUids()
          Returns all order uids as a list.
 java.util.List findByCreatedDate(java.util.Date date)
          Retrieves list of Order where the created date is later than the specified date.
 java.util.List findByUids(java.util.Collection orderUids)
          Returns a list of Order based on the given uids.
 java.util.List findOrder(java.lang.String propertyName, java.lang.String criteriaValue, boolean isExactMatch)
          Retrieve the list of orders, whose specified property matches the given criteria value.
 java.util.List findOrderAdvanced(AdvancedOrderSearchCriteria orderSearchCriteria, int maxResults)
          Advanced order search function based on the orderSearchCriteria and the max number of results to return.
 java.util.List findOrderByCriteria(OrderSearchCriteria orderSearchCriteria)
          Retrieve the list of orders, whose specified property contain the given criteria value.
 java.util.List findOrderByCriteria(OrderSearchCriteria orderSearchCriteria, int maxResults)
          Retrieve the list of orders, whose specified property contain the given criteria value.
 java.util.List findOrderByCustomerCriteria(java.lang.String propertyName, java.lang.String criteriaValue, boolean isExactMatch)
          Retrieve the list of orders, whose belonged customer's specified property matches the given criteria value.
 java.util.List findOrderByStatus(int orderStatus, int paymentStatus, int shipmentStatus)
          Retrieve the list of orders with the specified statuses.
 java.util.List findUidsByModifiedDate(java.util.Date date)
          Retrieves list of Order uids where the last modified date is later than the specified date.
 Order get(long orderUid)
          Get the order with the given UID.
 java.lang.String getNextOrderNumber()
          Returns the next order number.
 java.lang.Object getObject(long uid)
          Generic get method for all persistable domain models.
 Order getOrderDetail(long uid)
          Return the fully initialized order object.
 java.util.Map getOrderPaymentStatusMap()
          Returns a map of order payment statuses.
 java.util.Map getOrderReturnReasonMap()
          Returns a map of order return reasons.
 java.util.Map getOrderShipmentStatusMap()
          Returns a map of order shipment statuses.
 java.util.Map getOrderSkuReturnQtyMap(long orderUid)
          Get the orderSku uid -> returned quantity map for the order with given uid.
 java.util.Map getOrderStatusMap()
          Returns a map of order statuses.
 java.util.List list()
          List all orders stored in the database.
 OrderReturn recalculateOrderReturn(long orderUid, OrderReturn orderReturn)
          Recalculate the order return taxes, before-tax total and total.
 Order releaseOrderShipment(long orderUid, long orderShipmentUid, java.lang.String trackingCode, boolean captureFund, boolean sendConfEmail)
          Capture the order balance amount and update the OrderShipment status on success.
 void setEmailService(EmailService emailService)
          Set the emailService.
 void setIndexSearchService(IndexSearchService indexSearchService)
          Set the indexSearchService instance.
 void setOrderPaymentStatusFactory(OrderPaymentStatusFactory orderPaymentStatusFactory)
          Sets the OrderPaymentStatusFactory instance.
 void setOrderReturnReasonFactory(OrderReturnReasonFactory orderReturnReasonFactory)
          Sets the OrderReturnReasonFactory instance.
 void setOrderShipmentStatusFactory(OrderShipmentStatusFactory orderShipmentStatusFactory)
          Sets the OrderShipmentStatusFactory instance.
 OrderSku setOrderSkuProduct(OrderSku orderSku)
          Retrieve the Product associated with the given orderSku based on the productUid saved.
 OrderSku setOrderSkuProductSku(OrderSku orderSku)
          Retrieve the Product associated with the given orderSku based on the productUid saved.
 void setOrderStatusFactory(OrderStatusFactory orderStatusFactory)
          Sets the OrderStatusFactory instance.
 void setPaymentTypeFactory(PaymentTypeFactory paymentTypeFactory)
          Set the PaymentTypeFactory singleton.
 void setTaxJurisdictionService(TaxJurisdictionService taxJurisdictionService)
          Set the taxJurisdictionService.
 void setUtility(Utility utility)
          Sets the utility.
 Order update(Order order)
          Updates the given order.
 
Methods inherited from class com.elasticpath.service.impl.AbstractEpPersistenceServiceImpl
getPersistenceEngine, setPersistenceEngine
 
Methods inherited from class com.elasticpath.service.impl.AbstractEpServiceImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.service.EpPersistenceService
getPersistenceEngine, setPersistenceEngine
 
Methods inherited from interface com.elasticpath.service.EpService
getElasticPath, setElasticPath
 

Constructor Detail

OrderServiceImpl

public OrderServiceImpl()
Method Detail

add

public Order add(Order order)
          throws EpServiceException
Adds the given order.

Specified by:
add in interface OrderService
Parameters:
order - the order to add
Returns:
the persisted instance of order
Throws:
EpServiceException - - in case of any errors

addOrderReturn

public Order addOrderReturn(long orderUid,
                            OrderReturn orderReturn)
Add the given OrderReturn to the order with given uid.

Specified by:
addOrderReturn in interface OrderService
Parameters:
orderUid - orderUid the uid of the order.
orderReturn - orderReturn to be added.
Returns:
the updated order.

findAllUids

public java.util.List findAllUids()
Returns all order uids as a list.

Specified by:
findAllUids in interface OrderService
Returns:
all order uids as a list

findByCreatedDate

public java.util.List findByCreatedDate(java.util.Date date)
Retrieves list of Order where the created date is later than the specified date.

Specified by:
findByCreatedDate in interface OrderService
Parameters:
date - date to compare with the created date
Returns:
list of Order whose created date is later than the specified date

findByUids

public java.util.List findByUids(java.util.Collection orderUids)
Returns a list of Order based on the given uids. The returned orders will be populated based on the given load tuner.

Specified by:
findByUids in interface OrderService
Parameters:
orderUids - a collection of order uids
Returns:
a list of Orders

findOrder

public java.util.List findOrder(java.lang.String propertyName,
                                java.lang.String criteriaValue,
                                boolean isExactMatch)
Retrieve the list of orders, whose specified property matches the given criteria value.

Specified by:
findOrder in interface OrderService
Parameters:
propertyName - order property to search on.
criteriaValue - criteria value to be used for searching.
isExactMatch - true for doing an exact match; false for doing a fuzzy match.
Returns:
list of orders matching the given criteria.

findOrderAdvanced

public java.util.List findOrderAdvanced(AdvancedOrderSearchCriteria orderSearchCriteria,
                                        int maxResults)
Advanced order search function based on the orderSearchCriteria and the max number of results to return.

Specified by:
findOrderAdvanced in interface OrderService
Parameters:
orderSearchCriteria - the order search criteria.
maxResults - the max number of orders to return on search.
Returns:
the list of orders matching the given criteria.

findOrderByCriteria

public java.util.List findOrderByCriteria(OrderSearchCriteria orderSearchCriteria)
Retrieve the list of orders, whose specified property contain the given criteria value. Set global maxCmSearchResultCount variable in commerce-config.xml to change max number of results returned.

Specified by:
findOrderByCriteria in interface OrderService
Parameters:
orderSearchCriteria - criteria for order search.
Returns:
list of orders matching the given criteria.

findOrderByCriteria

public java.util.List findOrderByCriteria(OrderSearchCriteria orderSearchCriteria,
                                          int maxResults)
Retrieve the list of orders, whose specified property contain the given criteria value. Set maxResults to -1 where use the global maxCmSearchResultCount setting in commerce-config.xml.

Specified by:
findOrderByCriteria in interface OrderService
Parameters:
orderSearchCriteria - criteria for order search.
maxResults - the max number of orders to return on search.
Returns:
list of orders matching the given criteria.

findOrderByCustomerCriteria

public java.util.List findOrderByCustomerCriteria(java.lang.String propertyName,
                                                  java.lang.String criteriaValue,
                                                  boolean isExactMatch)
Retrieve the list of orders, whose belonged customer's specified property matches the given criteria value.

Specified by:
findOrderByCustomerCriteria in interface OrderService
Parameters:
propertyName - order's belonged customer property to search on.
criteriaValue - criteria value to be used for searching.
isExactMatch - true for doing an exact match; false for doing a fuzzy match.
Returns:
list of orders matching the given criteria.

findOrderByStatus

public java.util.List findOrderByStatus(int orderStatus,
                                        int paymentStatus,
                                        int shipmentStatus)
Retrieve the list of orders with the specified statuses.

Specified by:
findOrderByStatus in interface OrderService
Parameters:
orderStatus - the status of the order
paymentStatus - the status of the payment
shipmentStatus - the status of the shipment
Returns:
the list of orders with the specified statuses

findUidsByModifiedDate

public java.util.List findUidsByModifiedDate(java.util.Date date)
Retrieves list of Order uids where the last modified date is later than the specified date.

Specified by:
findUidsByModifiedDate in interface OrderService
Parameters:
date - date to compare with the last modified date
Returns:
list of Order whose last modified date is later than the specified date

get

public Order get(long orderUid)
          throws EpServiceException
Get the order with the given UID. Return null if no matching record exists.

Specified by:
get in interface OrderService
Parameters:
orderUid - the order UID
Returns:
the order if UID exists, otherwise null
Throws:
EpServiceException - - in case of any errors

getNextOrderNumber

public java.lang.String getNextOrderNumber()
Returns the next order number.
(And increments it)

Specified by:
getNextOrderNumber in interface OrderService
Returns:
the order number as a String

getObject

public java.lang.Object getObject(long uid)
                           throws EpServiceException
Generic get method for all persistable domain models.

Specified by:
getObject in interface EpPersistenceService
Specified by:
getObject in interface OrderService
Parameters:
uid - the persisted instance uid
Returns:
the persisted instance if exists, otherwise null
Throws:
EpServiceException - - in case of any errors

getOrderDetail

public Order getOrderDetail(long uid)
                     throws EpServiceException
Return the fully initialized order object.

Specified by:
getOrderDetail in interface OrderService
Parameters:
uid - the persisted instance uid
Returns:
the persisted instance if exists, otherwise null
Throws:
EpServiceException - - in case of any errors

getOrderPaymentStatusMap

public java.util.Map getOrderPaymentStatusMap()
Returns a map of order payment statuses.

Specified by:
getOrderPaymentStatusMap in interface OrderService
Returns:
a map of order payment statuses

getOrderReturnReasonMap

public java.util.Map getOrderReturnReasonMap()
Returns a map of order return reasons.

Specified by:
getOrderReturnReasonMap in interface OrderService
Returns:
a map of order return reasons.

getOrderShipmentStatusMap

public java.util.Map getOrderShipmentStatusMap()
Returns a map of order shipment statuses.

Specified by:
getOrderShipmentStatusMap in interface OrderService
Returns:
a map of order shipment statuses

getOrderSkuReturnQtyMap

public java.util.Map getOrderSkuReturnQtyMap(long orderUid)
Get the orderSku uid -> returned quantity map for the order with given uid.

Specified by:
getOrderSkuReturnQtyMap in interface OrderService
Parameters:
orderUid - the uid of the order.
Returns:
the orderSku uid -> returned quantity map.

getOrderStatusMap

public java.util.Map getOrderStatusMap()
Returns a map of order statuses.

Specified by:
getOrderStatusMap in interface OrderService
Returns:
a map of order statuses

list

public java.util.List list()
                    throws EpServiceException
List all orders stored in the database.

Specified by:
list in interface OrderService
Returns:
a list of orders
Throws:
EpServiceException - - in case of any errors

recalculateOrderReturn

public OrderReturn recalculateOrderReturn(long orderUid,
                                          OrderReturn orderReturn)
Recalculate the order return taxes, before-tax total and total.

Specified by:
recalculateOrderReturn in interface OrderService
Parameters:
orderUid - the uid of the order.
orderReturn - the orderReturn to be recalculated.
Returns:
the updated orderReturn instance.

releaseOrderShipment

public Order releaseOrderShipment(long orderUid,
                                  long orderShipmentUid,
                                  java.lang.String trackingCode,
                                  boolean captureFund,
                                  boolean sendConfEmail)
Capture the order balance amount and update the OrderShipment status on success.

Specified by:
releaseOrderShipment in interface OrderService
Parameters:
orderUid - the uid of the order.
orderShipmentUid - the uid of the orderShipment to be released.
trackingCode - the trakcingCode for the orderShipment to be released.
captureFund - need to capture fund for this release or not
sendConfEmail - need to send customer a shipment confirmation email or not
Returns:
the updated order.

setEmailService

public void setEmailService(EmailService emailService)
Set the emailService.

Parameters:
emailService - the emailService

setIndexSearchService

public void setIndexSearchService(IndexSearchService indexSearchService)
Set the indexSearchService instance.

Parameters:
indexSearchService - the indexSearchService instance.

setOrderPaymentStatusFactory

public void setOrderPaymentStatusFactory(OrderPaymentStatusFactory orderPaymentStatusFactory)
Sets the OrderPaymentStatusFactory instance.

Specified by:
setOrderPaymentStatusFactory in interface OrderService
Parameters:
orderPaymentStatusFactory - the OrderPaymentStatusFactory instance.

setOrderReturnReasonFactory

public void setOrderReturnReasonFactory(OrderReturnReasonFactory orderReturnReasonFactory)
Sets the OrderReturnReasonFactory instance.

Specified by:
setOrderReturnReasonFactory in interface OrderService
Parameters:
orderReturnReasonFactory - the OrderReturnReasonFactory instance.

setOrderShipmentStatusFactory

public void setOrderShipmentStatusFactory(OrderShipmentStatusFactory orderShipmentStatusFactory)
Sets the OrderShipmentStatusFactory instance.

Specified by:
setOrderShipmentStatusFactory in interface OrderService
Parameters:
orderShipmentStatusFactory - the OrderShipmentStatusFactory instance.

setOrderSkuProduct

public OrderSku setOrderSkuProduct(OrderSku orderSku)
Retrieve the Product associated with the given orderSku based on the productUid saved.

Specified by:
setOrderSkuProduct in interface OrderService
Parameters:
orderSku - the orderSku instatnce
Returns:
the orderSku instance with the product set inside if found.

setOrderSkuProductSku

public OrderSku setOrderSkuProductSku(OrderSku orderSku)
Retrieve the Product associated with the given orderSku based on the productUid saved.

Specified by:
setOrderSkuProductSku in interface OrderService
Parameters:
orderSku - the orderSku instatnce
Returns:
the orderSku instance with the product set inside if found.

setOrderStatusFactory

public void setOrderStatusFactory(OrderStatusFactory orderStatusFactory)
Sets the OrderStatusFactory instance.

Specified by:
setOrderStatusFactory in interface OrderService
Parameters:
orderStatusFactory - the OrderStatusFactory instance.

setPaymentTypeFactory

public void setPaymentTypeFactory(PaymentTypeFactory paymentTypeFactory)
Set the PaymentTypeFactory singleton.

Parameters:
paymentTypeFactory - the paymentTypeFactory singleton.

setTaxJurisdictionService

public void setTaxJurisdictionService(TaxJurisdictionService taxJurisdictionService)
Set the taxJurisdictionService.

Parameters:
taxJurisdictionService - the taxJurisdictionService singleton.

setUtility

public void setUtility(Utility utility)
Sets the utility.

Parameters:
utility - the utility to set

update

public Order update(Order order)
             throws EpServiceException
Updates the given order.

Specified by:
update in interface OrderService
Parameters:
order - the order to update
Returns:
the persisted instance of order
Throws:
EpServiceException - - in case of any errors