atg.commerce.order
Class CostCenterManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.order.CostCenterManager
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
CostCenterManager

public class CostCenterManager
extends GenericService

This class is the business layer object for managing and manipulating Cost Centers. This class holds all the business logic for manipulating a Cost Center. The various types of methods in this class are used for creating cost centers, adding cost centers to an Order, adding CommerceItems to cost centers.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
protected static CostCenterManager mCostCenterManager
           
protected static java.util.ResourceBundle sResourceBundle
          Resource Bundle
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
CostCenterManager()
          Constructs an CostCenterManager object.
 
Method Summary
 CostCenter addCostCenterToOrder(Order pOrder, CostCenter pCostCenter)
          Adds the given cost center to the given order.
 void addItemAmountToCostCenter(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pCostCenterId, double pAmount)
          Adds the given amount of the CommerceItem with the given id to the CostCenter with the given id.
 void addItemQuantityToCostCenter(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pCostCenterId, long pQuantity)
          Adds the given quantity of the CommerceItem with the given id to the CostCenter with the given id.
 void addOrderAmountToCostCenter(Order pOrder, java.lang.String pCostCenterId, double pAmount)
          Adds the given amount of the Order's cost to the CostCenter with the given id.
 void addRemainingItemAmountToCostCenter(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pCostCenterId)
          Adds any unassigned amount of the CommerceItem with the given id to the CostCenter with the given id.
 void addRemainingItemQuantityToCostCenter(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pCostCenterId)
          Adds any unassigned quantity of the CommerceItem with the given id to the CostCenter with the given id.
 void addRemainingOrderAmountToCostCenter(Order pOrder, java.lang.String pCostCenterId)
          Adds any unassigned amount of the Order's cost to the CostCenter with the given id.
 void addRemainingShippingCostToCostCenter(Order pOrder, java.lang.String pShippingGroupId, java.lang.String pCostCenterId)
          Adds any unassigned amount of the ShippingGroup's cost with the given id to the CostCenter with the given id.
 void addRemainingTaxAmountToCostCenter(Order pOrder, java.lang.String pCostCenterId)
          Adds any unassigned amount of the Order's tax to the CostCenter with the given id.
 void addShippingCostAmountToCostCenter(Order pOrder, java.lang.String pShippingGroupId, java.lang.String pCostCenterId, double pAmount)
          Adds the given amount of the ShippingGroup's cost with the given id to the CostCenter with the given id.
 void addTaxAmountToCostCenter(Order pOrder, java.lang.String pCostCenterId, double pAmount)
          Adds the given amount of the Order's tax to the CostCenter with the given id.
 CostCenter createCostCenter(java.lang.String pIdentifier)
          Creates a new CostCenter object using the default type specified in the OrderTools defaultCostCenterType property.
 CostCenter createCostCenter(java.lang.String pCostCenterType, java.lang.String pIdentifier)
          Creates a new CostCenter object using the class mapped to the given name in pCostCenterType.
protected  Relationship createRelationship(java.lang.String pRelationshipType)
          Creates a new Relationship object using the class type mapped to the type supplied in pShippingGroupType.
 CostCenter getCostCenterByIdentifier(java.util.List pCostCenters, java.lang.String pIdentifier)
          This method will return a CostCenter whose identifier is pIdentifier.
 CostCenterCommerceItemRelationship getCostCenterCommerceItemRelationship(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pCostCenterId)
          Returns the relationship object which exists between the given CommerceItem and CostCenter.
static CostCenterManager getCostCenterManager()
           
 CostCenterOrderRelationship getCostCenterOrderRelationship(Order pOrder, java.lang.String pCostCenterId)
          Returns the relationship object which exists between the given Order and CostCenter.
 CostCenterShippingGroupRelationship getCostCenterShippingGroupRelationship(Order pOrder, java.lang.String pCostCenterId, java.lang.String pShippingGroupId)
          Returns the relationship object which exists between the given ShippingGroup and CostCenter.
 int getOrderCount(java.lang.String pCostCenterId, java.lang.String[] pStates, java.util.Collection<java.lang.String> pSiteIds)
          Returns a count of the orders for a given cost center id
 java.util.List getOrderIdsForCostCenter(java.lang.String pCostCenterId, int pStartIndex, int pNumOrders)
          Returns the order ids for the given cost center with the given constraints.
 java.util.List getOrderIdsForCostCenter(java.lang.String pCostCenterId, int pStartIndex, int pNumOrders, java.lang.String[] pStates, java.lang.String pSortProperty, boolean pAscending, java.util.Collection<java.lang.String> pSiteIds)
          Returns the order ids for the given cost center id with the given constraints and sorting options.
 OrderManager getOrderManager()
          Returns the OrderManager
 java.util.List getOrdersForCostCenter(java.lang.String pCostCenterId, int pStartIndex, int pNumOrders)
          Returns all the orders for the given cost center id with the given constraints.
 java.util.List getOrdersForCostCenter(java.lang.String pCostCenterId, int pStartIndex, int pNumOrders, java.lang.String[] pStates, java.lang.String pSortProperty, boolean pAscending, java.util.Collection<java.lang.String> pSiteIds)
          Returns the orders for the given cost center id with the given constraints and sorting options.
 OrderTools getOrderTools()
          Returns the OrderTools
 double getRemainingAmountForCostCenter(CommerceItem pItem)
          Calculate the "amount remaining" for a given item.
 long getRemainingQuantityForCostCenter(CommerceItem pItem)
          Calculate the "quantity remaining" for a given item.
 double getUnassignedAmountForCommerceItem(CommerceItem pItem)
          This method returns the unassigned amount for a CommerceItem.
 long getUnassignedQuantityForCommerceItem(CommerceItem pItem)
          This method returns the unassigned quantity for a CommerceItem.
 void moveItemToCostCenter(Order pOrder, CommerceItem pCommerceItem, long pQuantity, CostCenter pSrcCostCenter, CostCenter pDestCostCenter)
          This method moves an item from one CostCenter to another.
 void moveItemToCostCenter(Order pOrder, java.lang.String pCatalogRefId, long pQuantity, java.lang.String pSrcCostCenterId, java.lang.String pDestCostCenterId)
          This method moves an item from one CostCenter to another.
 PipelineResult recalculateCostCenterAmounts(Order pOrder)
          Recalculates the amounts for each CostCenter supplied in pCostCenterList.
 void removeAllCostCentersFromOrder(Order pOrder)
          Removes all the CostCenters and their Relationships from an Order.
 void removeAllRelationshipsFromCostCenter(Order pOrder, java.lang.String pCostCenterId)
          Removes all the relationships from the CostCenter with the given id in the given order.
 void removeCostCenterFromOrder(Order pOrder, java.lang.String pCostCenterId)
          Removes the given CostCenter from the given order.
 void removeItemQuantityFromCostCenter(Order pOrder, java.lang.String pCommerceItemId, java.lang.String pCostCenterId, long pQuantity)
          Removes the given quantity of the CommerceItem with the given id from the CostCenter with the given id.
 void setOrderManager(OrderManager pOrderManager)
          Sets the OrderManager
 void setOrderTools(OrderTools pOrderTools)
          Sets the OrderTools
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


sResourceBundle

protected static java.util.ResourceBundle sResourceBundle
Resource Bundle


mCostCenterManager

protected static CostCenterManager mCostCenterManager
Constructor Detail

CostCenterManager

public CostCenterManager()
Constructs an CostCenterManager object.

Method Detail

getCostCenterManager

public static CostCenterManager getCostCenterManager()

getOrderManager

public OrderManager getOrderManager()
Returns the OrderManager


setOrderManager

public void setOrderManager(OrderManager pOrderManager)
Sets the OrderManager


getOrderTools

public OrderTools getOrderTools()
Returns the OrderTools


setOrderTools

public void setOrderTools(OrderTools pOrderTools)
Sets the OrderTools


createCostCenter

public CostCenter createCostCenter(java.lang.String pIdentifier)
                            throws CommerceException
Creates a new CostCenter object using the default type specified in the OrderTools defaultCostCenterType property.

Returns:
the CostCenter object which was created
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
OrderTools.getDefaultCostCenterType()

createCostCenter

public CostCenter createCostCenter(java.lang.String pCostCenterType,
                                   java.lang.String pIdentifier)
                            throws CommerceException
Creates a new CostCenter object using the class mapped to the given name in pCostCenterType.

Parameters:
pCostCenterType - the name that is mapped in the OrderTools.properties file to the class of the desired type to create
pIdentifier - the user-defined name of the CostCenter
Returns:
the CostCenter object which was created
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectCreationException - if the instantiation of an object fails
CommerceException

addCostCenterToOrder

public CostCenter addCostCenterToOrder(Order pOrder,
                                       CostCenter pCostCenter)
                                throws CommerceException
Adds the given cost center to the given order.

Parameters:
pOrder - the Order to add the CommerceItem to
pCostCenter - the CostCenter to add to the Order
Returns:
the CostCenter which contains the cost center just added.
Throws:
InvalidParameterException - thrown if any of the parameters are null
CommerceException

removeCostCenterFromOrder

public void removeCostCenterFromOrder(Order pOrder,
                                      java.lang.String pCostCenterId)
                               throws CommerceException
Removes the given CostCenter from the given order. This method will also remove relationships which reference the CostCenter.

Parameters:
pOrder - the Order to remove the CostCenter from
pCostCenterId - the id of the CostCenter to remove from the Order
Throws:
InvalidParameterException - thrown if any of the parameters are null
CostCenterNotFoundException - if a CostCenter with the given id is not found in the given order
ObjectRemovalException - thrown if the CostCenter contains any relationships
CommerceException

removeAllCostCentersFromOrder

public void removeAllCostCentersFromOrder(Order pOrder)
                                   throws CommerceException
Removes all the CostCenters and their Relationships from an Order.

Parameters:
pOrder - the Order which contains the CostCenters to be removed
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectRemovalException - thrown if a CostCenter cannot be removed
CommerceException

removeAllRelationshipsFromCostCenter

public void removeAllRelationshipsFromCostCenter(Order pOrder,
                                                 java.lang.String pCostCenterId)
                                          throws CommerceException
Removes all the relationships from the CostCenter with the given id in the given order.

Parameters:
pOrder - the Order which contains the CostCenter to remove the relationships from
pCostCenterId - the id of the CostCenter
Throws:
InvalidParameterException - thrown if any of the parameters are null
CostCenterNotFoundException - if a CostCenter with the given id is not found in the given order
ObjectRemovalException - thrown if a relationship cannot be removed
CommerceException

getCostCenterByIdentifier

public CostCenter getCostCenterByIdentifier(java.util.List pCostCenters,
                                            java.lang.String pIdentifier)
                                     throws CommerceException
This method will return a CostCenter whose identifier is pIdentifier.

Parameters:
pCostCenters - a List of CostCenters
pIdentifier - the identifier to search for in the List of CostCenters
Returns:
the CostCenter whose identifier is pIdentifier or null if it is not found
Throws:
InvalidParameterException - if any of the parameters are null
CommerceException

getCostCenterCommerceItemRelationship

public CostCenterCommerceItemRelationship getCostCenterCommerceItemRelationship(Order pOrder,
                                                                                java.lang.String pCommerceItemId,
                                                                                java.lang.String pCostCenterId)
                                                                         throws CommerceException
Returns the relationship object which exists between the given CommerceItem and CostCenter.

Parameters:
pCommerceItemId - the id of the CommerceItem which makes up a half of the relationship
pCostCenterId - the id of the CostCenter which makes up a half of the relationship
Returns:
the CostCenterCommerceItemRelationship object that exists between these two objects
Throws:
InvalidParameterException - thrown if any of the parameters are null
RelationshipNotFoundException - if a relationship is not found
CommerceException

getCostCenterOrderRelationship

public CostCenterOrderRelationship getCostCenterOrderRelationship(Order pOrder,
                                                                  java.lang.String pCostCenterId)
                                                           throws CommerceException
Returns the relationship object which exists between the given Order and CostCenter.

Parameters:
pOrder - the Order which makes up half of the relationship
pCostCenterId - the id of the CostCenter which makes up a half of the relationship
Returns:
the CostCenterOrderRelationship object that exists between these two objects
Throws:
InvalidParameterException - thrown if any of the parameters are null
RelationshipNotFoundException - if a relationship is not found
CommerceException

getCostCenterShippingGroupRelationship

public CostCenterShippingGroupRelationship getCostCenterShippingGroupRelationship(Order pOrder,
                                                                                  java.lang.String pCostCenterId,
                                                                                  java.lang.String pShippingGroupId)
                                                                           throws CommerceException
Returns the relationship object which exists between the given ShippingGroup and CostCenter.

Parameters:
pShippingGroupId - the id of the ShippingGroup which makes up a half of the relationship
pCostCenterId - the id of the CostCenter which makes up a half of the relationship
Returns:
the CostCenterShippingGroupRelationship object that exists between these two objects
Throws:
InvalidParameterException - thrown if any of the parameters are null
RelationshipNotFoundException - if a relationship is not found
CommerceException

moveItemToCostCenter

public void moveItemToCostCenter(Order pOrder,
                                 java.lang.String pCatalogRefId,
                                 long pQuantity,
                                 java.lang.String pSrcCostCenterId,
                                 java.lang.String pDestCostCenterId)
                          throws CommerceException
This method moves an item from one CostCenter to another. If the quantity in the item exceeds the given quantity, then only that quantity is moved.

Parameters:
pOrder - the order which the item exists in
pCatalogRefId - the catalogRefId of the item to move
pQuantity - the quantity to move
pSrcCostCenterId - the id of the costCenter to move the item from
pDestCostCenterId - the id of the costCenter to move the item to
Throws:
CommerceException - thrown if the operation could not be completed. More information can be found within the exception.

moveItemToCostCenter

public void moveItemToCostCenter(Order pOrder,
                                 CommerceItem pCommerceItem,
                                 long pQuantity,
                                 CostCenter pSrcCostCenter,
                                 CostCenter pDestCostCenter)
                          throws CommerceException
This method moves an item from one CostCenter to another. If the quantity in the item exceeds the given quantity, then only that quantity is moved.

Parameters:
pOrder - the order which the item exists in
pCommerceItem - the commerce item to move
pQuantity - the quantity to move
pSrcCostCenter - the costCenter to move the item from
pDestCostCenter - the costCenter to move the item to
Throws:
CommerceException - thrown if the operation could not be completed. More information can be found within the exception.

removeItemQuantityFromCostCenter

public void removeItemQuantityFromCostCenter(Order pOrder,
                                             java.lang.String pCommerceItemId,
                                             java.lang.String pCostCenterId,
                                             long pQuantity)
                                      throws CommerceException
Removes the given quantity of the CommerceItem with the given id from the CostCenter with the given id.

Parameters:
pOrder - the Order which the CommerceItem and CostCenter exist
pCommerceItemId - the id of the CommerceItem to to remove from the CostCenter
pCostCenterId - the id of the CostCenter which the CommerceItem will be removed from
pQuantity - the quantity of the CommerceItem which will be removed
Throws:
InvalidParameterException - thrown if any of the parameters are null
ObjectRemovalException - if the removal of the quantity fails
CommerceException

addItemQuantityToCostCenter

public void addItemQuantityToCostCenter(Order pOrder,
                                        java.lang.String pCommerceItemId,
                                        java.lang.String pCostCenterId,
                                        long pQuantity)
                                 throws CommerceException
Adds the given quantity of the CommerceItem with the given id to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterCommerceItemRelationship with type QUANTITY and sets the CostCenter, CommerceItem, and quantity properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the CommerceItem and CostCenter exist
pCommerceItemId - the id of the CommerceItem to add
pCostCenterId - the id of the CostCenter which the CommerceItem will be added to
pQuantity - the quantity of the CommerceItem which will be added
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterCommerceItemRelationship

addRemainingItemQuantityToCostCenter

public void addRemainingItemQuantityToCostCenter(Order pOrder,
                                                 java.lang.String pCommerceItemId,
                                                 java.lang.String pCostCenterId)
                                          throws CommerceException
Adds any unassigned quantity of the CommerceItem with the given id to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterCommerceItemRelationship with type QUANTITYREMAINING and sets the CostCenter and CommerceItem properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the CommerceItem and CostCenter exist
pCommerceItemId - the id of the CommerceItem to add
pCostCenterId - the id of the CostCenter which the CommerceItem will be added to
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterCommerceItemRelationship

addItemAmountToCostCenter

public void addItemAmountToCostCenter(Order pOrder,
                                      java.lang.String pCommerceItemId,
                                      java.lang.String pCostCenterId,
                                      double pAmount)
                               throws CommerceException
Adds the given amount of the CommerceItem with the given id to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterCommerceItemRelationship with type AMOUNT and sets the CostCenter, CommerceItem, and amount properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the CommerceItem and CostCenter exist
pCommerceItemId - the id of the CommerceItem to add
pCostCenterId - the id of the CostCenter which the CommerceItem will be added to
pAmount - the amount of the CommerceItem which will be added
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterCommerceItemRelationship

addRemainingItemAmountToCostCenter

public void addRemainingItemAmountToCostCenter(Order pOrder,
                                               java.lang.String pCommerceItemId,
                                               java.lang.String pCostCenterId)
                                        throws CommerceException
Adds any unassigned amount of the CommerceItem with the given id to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterCommerceItemRelationship with type AMOUNTREMAINING and sets the CostCenter and CommerceItem properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the CommerceItem and CostCenter exist
pCommerceItemId - the id of the CommerceItem to add
pCostCenterId - the id of the CostCenter which the CommerceItem will be added to
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterCommerceItemRelationship

getUnassignedQuantityForCommerceItem

public long getUnassignedQuantityForCommerceItem(CommerceItem pItem)
This method returns the unassigned quantity for a CommerceItem. If a CommerceItem contains a CostCenterRelationship with type QuantityRemaining, then the unassigned quantity will always be 0. To determine the remaining quantity call getRemainingQuantityForCostCenter(CommerceItem). This method assumes that CostCenterCommerceItemRelationships have been created between the CommerceItem and CostCenter.

Parameters:
pItem - the CommerceItem we are checking
Returns:
the unassigned quantity.
See Also:
getRemainingQuantityForCostCenter(CommerceItem)

getRemainingQuantityForCostCenter

public long getRemainingQuantityForCostCenter(CommerceItem pItem)
Calculate the "quantity remaining" for a given item. Add up all the quantities in relationships of type QUANTITY then subtract from the CommerceItem's quantity. This method assumes that CostCenterCommerceItemRelationships have been created between the CommerceItem and CostCenter.

Parameters:
pItem - The CommerceItem we are checking
Returns:
The quantity remaining.

getUnassignedAmountForCommerceItem

public double getUnassignedAmountForCommerceItem(CommerceItem pItem)
This method returns the unassigned amount for a CommerceItem. If a CommerceItem contains a CostCenterRelationship with type AmountRemaining, then the unassigned amount will always be 0. To determine the remaining amount call getRemainingAmountForCostCenter(CommerceItem). This method assumes that CostCenterCommerceItemRelationships have been created between the CommerceItem and CostCenter.

Parameters:
pItem - the CommerceItem we are checking
Returns:
the unassigned amount.
See Also:
getRemainingAmountForCostCenter(CommerceItem)

getRemainingAmountForCostCenter

public double getRemainingAmountForCostCenter(CommerceItem pItem)
Calculate the "amount remaining" for a given item. Add up all the amounts in relationships of type AMOUNT then subtract from the CommerceItem's amount. This method assumes that CostCenterCommerceItemRelationships have been created between the CommerceItem and CostCenter.

Parameters:
pItem - The CommerceItem we are checking
Returns:
The amount remaining.

addShippingCostAmountToCostCenter

public void addShippingCostAmountToCostCenter(Order pOrder,
                                              java.lang.String pShippingGroupId,
                                              java.lang.String pCostCenterId,
                                              double pAmount)
                                       throws CommerceException
Adds the given amount of the ShippingGroup's cost with the given id to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterShippingGroupRelationship with type CCSHIPPINGAMOUNT and sets the CostCenter, ShippingGroup, and amount properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the CostCenter and ShippingGroup exist
pShippingGroupId - the id of the ShippingGroup's cost to add
pCostCenterId - the id of the CostCenter which the ShippingGroup's cost will be added to
pAmount - the amount that is assigned for payment to the CostCenter
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterShippingGroupRelationship

addRemainingShippingCostToCostCenter

public void addRemainingShippingCostToCostCenter(Order pOrder,
                                                 java.lang.String pShippingGroupId,
                                                 java.lang.String pCostCenterId)
                                          throws CommerceException
Adds any unassigned amount of the ShippingGroup's cost with the given id to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterShippingGroupRelationship with type CCSHIPPINGAMOUNTREMAINING and sets the CostCenter and ShippingGroup properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the CostCenter and ShippingGroup exist
pShippingGroupId - the id of the ShippingGroup's cost to add
pCostCenterId - the id of the CostCenter which the ShippingGroup's cost will be added to
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterShippingGroupRelationship

addTaxAmountToCostCenter

public void addTaxAmountToCostCenter(Order pOrder,
                                     java.lang.String pCostCenterId,
                                     double pAmount)
                              throws CommerceException
Adds the given amount of the Order's tax to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterOrderRelationship with type CCTAXAMOUNT and sets the CostCenter, Order, and amount properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the CostCenter exists
pCostCenterId - the id of the CostCenter which the Order's tax will be added to
pAmount - the amount that is assigned for payment to the CostCenter
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterOrderRelationship

addRemainingTaxAmountToCostCenter

public void addRemainingTaxAmountToCostCenter(Order pOrder,
                                              java.lang.String pCostCenterId)
                                       throws CommerceException
Adds any unassigned amount of the Order's tax to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterOrderRelationship with type CCTAXAMOUNTREMAINING and sets the CostCenter property in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the PaymentGroup exists
pCostCenterId - the id of the CostCenter which the Order's tax will be added to
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterOrderRelationship

addOrderAmountToCostCenter

public void addOrderAmountToCostCenter(Order pOrder,
                                       java.lang.String pCostCenterId,
                                       double pAmount)
                                throws CommerceException
Adds the given amount of the Order's cost to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterOrderRelationship with type CCORDERAMOUNT and sets the CostCenter, Order, and amount properties in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the CostCenter exists
pCostCenterId - the id of the CostCenter which the Order's cost will be added to
pAmount - the amount that is assigned for payment to the CostCenter
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterOrderRelationship

addRemainingOrderAmountToCostCenter

public void addRemainingOrderAmountToCostCenter(Order pOrder,
                                                java.lang.String pCostCenterId)
                                         throws CommerceException
Adds any unassigned amount of the Order's cost to the CostCenter with the given id. Underneath the surface, this method creates a CostCenterOrderRelationship with type CCORDERAMOUNTREMAINING and sets the CostCenter property in that Relationship to those given as parameters in this method. The id parameters are resolved to the actual objects.

Parameters:
pOrder - the Order which the CostCenter exists
pCostCenterId - the id of the CostCenter which the Order's cost will be added to
Throws:
InvalidParameterException - thrown if any of the parameters are null
InvalidTypeException - thrown if more than one REMAINING relationship type is added to a CostCenter or if an invalid type is set to the Relationship
ObjectCreationException - if the instantiation of an object fails
CommerceException
See Also:
CostCenterOrderRelationship

recalculateCostCenterAmounts

public PipelineResult recalculateCostCenterAmounts(Order pOrder)
                                            throws CommerceException
Recalculates the amounts for each CostCenter supplied in pCostCenterList.

Parameters:
pOrder - the Order to recalculate the CostCenters in
Returns:
the PipelineResult object from the execution of the pipeline
Throws:
CommerceException - thrown if an error occurs while recalculating the amounts

getOrdersForCostCenter

public java.util.List getOrdersForCostCenter(java.lang.String pCostCenterId,
                                             int pStartIndex,
                                             int pNumOrders)
                                      throws CommerceException
Returns all the orders for the given cost center id with the given constraints.

Parameters:
pCostCenterId - the CostCenter id
pStartIndex - The index of the first order to return
pNumOrders - The number of orders to return
Returns:
a List of all the orders for the given cost center id
Throws:
InvalidParameterException - thrown if any of the parameters are null or empty string
CommerceException - thrown if an exception occurs while accessing the repository

getOrdersForCostCenter

public java.util.List getOrdersForCostCenter(java.lang.String pCostCenterId,
                                             int pStartIndex,
                                             int pNumOrders,
                                             java.lang.String[] pStates,
                                             java.lang.String pSortProperty,
                                             boolean pAscending,
                                             java.util.Collection<java.lang.String> pSiteIds)
                                      throws CommerceException
Returns the orders for the given cost center id with the given constraints and sorting options.

Parameters:
pCostCenterId - the CostCenter id
pStartIndex - The index of the first order to return
pNumOrders - The number of orders to return
pStates - If provided, results will be filtered by the provided states
pSortProperty - The property to sort the results by
pAscending - Whether to return the results in ascending or decending order
pSiteIds - Results will be filtered by the given site Ids
Returns:
a List of all the orders for the given cost center id with the given constraints and sorting options.
Throws:
InvalidParameterException - thrown if any of the parameters are null or empty string
CommerceException - thrown if an exception occurs while accessing the repository

getOrderIdsForCostCenter

public java.util.List getOrderIdsForCostCenter(java.lang.String pCostCenterId,
                                               int pStartIndex,
                                               int pNumOrders)
                                        throws CommerceException
Returns the order ids for the given cost center with the given constraints.

Parameters:
pCostCenterId - the CostCenter id
pStartIndex - The index of the first order to return
pNumOrders - The number of orders to return
Returns:
a List of all the order ids for the given cost center id
Throws:
InvalidParameterException - thrown if any of the parameters are null or empty string
CommerceException - thrown if an exception occurs while accessing the repository

getOrderIdsForCostCenter

public java.util.List getOrderIdsForCostCenter(java.lang.String pCostCenterId,
                                               int pStartIndex,
                                               int pNumOrders,
                                               java.lang.String[] pStates,
                                               java.lang.String pSortProperty,
                                               boolean pAscending,
                                               java.util.Collection<java.lang.String> pSiteIds)
                                        throws CommerceException
Returns the order ids for the given cost center id with the given constraints and sorting options.

Parameters:
pCostCenterId - the CostCenter id
pStartIndex - The index of the first order to return
pNumOrders - The number of orders to return
pStates - If provided, results will be filtered by the provided states
pSortProperty - The property to sort the results by
pAscending - Whether to return the results in ascending or decending order
pSiteIds - Results will be filtered by the given site Ids
Returns:
a List of all the order ids for the given cost center id
Throws:
InvalidParameterException - thrown if any of the parameters are null or empty string
CommerceException - thrown if an exception occurs while accessing the repository

getOrderCount

public int getOrderCount(java.lang.String pCostCenterId,
                         java.lang.String[] pStates,
                         java.util.Collection<java.lang.String> pSiteIds)
                  throws CommerceException
Returns a count of the orders for a given cost center id

Parameters:
pCostCenterId - The cost center id
pStates - Order states to filter the results by
pSiteIds - SiteIds to filter the results by
Returns:
The number of orders for the given cost center id.
Throws:
CommerceException

createRelationship

protected Relationship createRelationship(java.lang.String pRelationshipType)
                                   throws CommerceException
Creates a new Relationship object using the class type mapped to the type supplied in pShippingGroupType.

Parameters:
pRelationshipType - the type that is mapped in the OrderTools.properties file to the class of the desired type to create
Returns:
the Relationship object which was created
Throws:
ObjectCreationException - if the instantiation of an object fails
InvalidTypeException - if the given type is not valid
InvalidParameterException - thrown if any of the parameters are null
CommerceException