atg.commerce.invoice
Class InvoiceManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.invoice.InvoiceManager
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:
InvoiceManager

public class InvoiceManager
extends GenericService

InvoiceManager manages creation, loading, saving, and removing items in the InvoiceRepository. Invoice creation, load, save, and remove operations trigger the execution of optional pipeline chains whose names are specified as part of the InvoiceManager configuration.

In all cases, pipeline chains executed by the InvoiceManager will be passed an InvoicePipelineArgs object as the pipeline processor argument. InvoicePipelineArgs provides convenience functions for obtaining the Invoice repository item being operated upon and the InvoiceManager that is performance the operation.

InvoiceManager subclasses can replace the InvoicePipelineArgs with subclasses that provide additional API's by overriding the createPipelineArgs method on InvoiceManager.


Field Summary
static java.lang.String CLASS_VERSION
           
protected static java.util.ResourceBundle sDefaultResources
           
 
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
InvoiceManager()
           
 
Method Summary
 RepositoryItem addInvoice(MutableRepositoryItem pInvoice)
          Add the invoice represented by pInvoice to the invoice repository, and execute the pipeline chain whose name is specified by addInvoiceChainName
 MutableRepositoryItem createInvoice()
          Create a new invoice repository item whose invoice number is generated automatically and execute the pipeline chain whose name is specified by the property createInvoiceChainName.
 RepositoryItem createInvoice(InvoiceRequestInfo pInfo)
          Create a new invoice repository item whose invoice number is generated automatically, initialize it from the supplied invoice request info, and add it to the repository.
 MutableRepositoryItem createInvoice(java.lang.String pInvoiceNumber)
          Create a new invoice repository item and execute the pipeline chain whose name is specified by the property createInvoiceChainName.
 RepositoryItem createInvoice(java.lang.String pInvoiceNumber, InvoiceRequestInfo pInfo)
          Create a new invoice repository item, initialize it from the supplied invoice request info, and add it to the repository.
protected  InvoicePipelineArgs createPipelineArgs(RepositoryItem pItem)
          Create an instance of InvoicePipelineArgs containing a reference to this pipeline manager and to the specified repository item.
protected  InvoicePipelineArgs createPipelineArgs(RepositoryItem pItem, InvoiceRequestInfo pInfo)
          Create an instance of InvoicePipelineArgs containing a reference to this pipeline manager, to a specified repository item, and to a specified InvoiceRequestInfo that should be used to initialize the repository item.
 java.lang.String getAddInvoiceChainName()
          Return the name of the pipeline chain to run when a new invoice is added to the repository.
 java.lang.String getCreateInvoiceChainName()
          Return the name of the pipeline chain to run when an invoice is created.
 IdGenerator getIdGenerator()
          Return the id generated used to generate unique invoice numbers.
 java.lang.String getInitializeInvoiceChainName()
          Return the name of the pipeline chain to run when initializing an invoice repository item from an InvoiceRequestInfo object.
 java.lang.String getInvoiceNumberIdSpace()
          Return the id generator namespace used to generate unique invoice numbers.
 RepositoryItem[] getInvoicesForInvoiceNumber(java.lang.String pInvoiceNumber)
          Return all of the invoices having the given invoice number.
 InvoiceTools getInvoiceTools()
          Get the invoice tools component this InvoiceManager uses to access the invoice repository.
 java.lang.String getLoadInvoiceChainName()
          Return the name of the pipeline chain to run when an invoice is loaded from the repository.
 java.lang.String getNextInvoiceNumber()
          Return a unique invoice number.
 PipelineManager getPipelineManager()
          Return the pipeline manager this InvoiceManager uses to run pipeline chains.
 java.lang.String getRemoveInvoiceChainName()
          Return the name of the pipeline chain to run when an invoice is removed from the repository.
 javax.transaction.TransactionManager getTransactionManager()
          Return the transaction manager used by this InvoiceManager.
 java.lang.String getUpdateInvoiceChainName()
          Return the name of the pipeline chain to run when an invoice is saved to the repository.
 RepositoryItem loadInvoice(java.lang.String pRepositoryId)
          Load the invoice identified by the given repository id and execute the pipeline chain whose name is specified by loadInvoiceChainName.
 MutableRepositoryItem loadInvoiceForUpdate(java.lang.String pRepositoryId)
          Load a mutable version of the invoice identified by the given repository id and execute the pipeline chain whose name is specified by loadInvoiceChainName.
 void removeInvoice(RepositoryItem pInvoice)
          Remove the specified invoice repository item and execute a pipeline chain.
 void removeInvoice(java.lang.String pRepositoryId)
          Remove the specified invoice repository item and execute a pipeline chain.
protected  PipelineResult runPipelineChain(java.lang.String pChainName, RepositoryItem pItem)
          Run the named pipeline chain, passing this invoice manager and the specified repository item to each pipeline processor.
protected  PipelineResult runPipelineChain(java.lang.String pChainName, RepositoryItem pItem, InvoiceRequestInfo pInfo)
          Run the named pipeline chain, passing this invoice manager, the specified repository item, and the specified invoice request info object (which may be omitted) to each pipeline processor.
 void setAddInvoiceChainName(java.lang.String pAddInvoiceChainName)
          Set the name of the pipeline chain to run when a new invoice is added to the repository.
 void setCreateInvoiceChainName(java.lang.String pCreateInvoiceChainName)
          Set the name of the pipeline chain to run when an invoice is created.
 void setIdGenerator(IdGenerator pIdGenerator)
          Set the id generated used to generate unique invoice numbers.
 void setInitializeInvoiceChainName(java.lang.String pInitializeInvoiceChainName)
          Set the name of the pipeline chain to run when initializing an invoice repository item from an InvoiceRequestInfo object.
 void setInvoiceNumberIdSpace(java.lang.String pInvoiceNumberIdSpace)
          Set the id generator namespace used to generate unique invoice numbers.
 void setInvoiceTools(InvoiceTools pInvoiceTools)
          Set the invoice tools component this InvoiceManager uses to access the invoice repository.
 void setLoadInvoiceChainName(java.lang.String pLoadInvoiceChainName)
          Set the name of the pipeline chain to run when an invoice is loaded from the repository.
 void setPipelineManager(PipelineManager pPipelineManager)
          Set the pipeline manager this InvoiceManager uses to run pipeline chains.
 void setRemoveInvoiceChainName(java.lang.String pRemoveInvoiceChainName)
          Set the name of the pipeline chain to run when an invoice is removed from the repository.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Set the transaction manager used by this InvoiceManager.
 void setUpdateInvoiceChainName(java.lang.String pUpdateInvoiceChainName)
          Set the name of the pipeline chain to run when an invoice is saved to the repository.
protected  void throwPipelineException(java.lang.String pChainName, PipelineResult pResult)
          Throw an InvoicePipelineException with an appropriate error message for the given pipeline chain and pipeline result object.
 void updateInvoice(MutableRepositoryItem pInvoice)
          Update invoice properties in the invoice repository, setting the repository item's last-modified-time to the current time and date, then execute the pipeline chain specified by updateInvoiceChainName.
 
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

sDefaultResources

protected static java.util.ResourceBundle sDefaultResources
Constructor Detail

InvoiceManager

public InvoiceManager()
Method Detail

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Set the transaction manager used by this InvoiceManager.


getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Return the transaction manager used by this InvoiceManager.


setPipelineManager

public void setPipelineManager(PipelineManager pPipelineManager)
Set the pipeline manager this InvoiceManager uses to run pipeline chains.


getPipelineManager

public PipelineManager getPipelineManager()
Return the pipeline manager this InvoiceManager uses to run pipeline chains.


setCreateInvoiceChainName

public void setCreateInvoiceChainName(java.lang.String pCreateInvoiceChainName)
Set the name of the pipeline chain to run when an invoice is created.


getCreateInvoiceChainName

public java.lang.String getCreateInvoiceChainName()
Return the name of the pipeline chain to run when an invoice is created.


setInitializeInvoiceChainName

public void setInitializeInvoiceChainName(java.lang.String pInitializeInvoiceChainName)
Set the name of the pipeline chain to run when initializing an invoice repository item from an InvoiceRequestInfo object.


getInitializeInvoiceChainName

public java.lang.String getInitializeInvoiceChainName()
Return the name of the pipeline chain to run when initializing an invoice repository item from an InvoiceRequestInfo object.


setAddInvoiceChainName

public void setAddInvoiceChainName(java.lang.String pAddInvoiceChainName)
Set the name of the pipeline chain to run when a new invoice is added to the repository.


getAddInvoiceChainName

public java.lang.String getAddInvoiceChainName()
Return the name of the pipeline chain to run when a new invoice is added to the repository.


setLoadInvoiceChainName

public void setLoadInvoiceChainName(java.lang.String pLoadInvoiceChainName)
Set the name of the pipeline chain to run when an invoice is loaded from the repository.


getLoadInvoiceChainName

public java.lang.String getLoadInvoiceChainName()
Return the name of the pipeline chain to run when an invoice is loaded from the repository.


setUpdateInvoiceChainName

public void setUpdateInvoiceChainName(java.lang.String pUpdateInvoiceChainName)
Set the name of the pipeline chain to run when an invoice is saved to the repository.


getUpdateInvoiceChainName

public java.lang.String getUpdateInvoiceChainName()
Return the name of the pipeline chain to run when an invoice is saved to the repository.


setRemoveInvoiceChainName

public void setRemoveInvoiceChainName(java.lang.String pRemoveInvoiceChainName)
Set the name of the pipeline chain to run when an invoice is removed from the repository.


getRemoveInvoiceChainName

public java.lang.String getRemoveInvoiceChainName()
Return the name of the pipeline chain to run when an invoice is removed from the repository.


setInvoiceTools

public void setInvoiceTools(InvoiceTools pInvoiceTools)
Set the invoice tools component this InvoiceManager uses to access the invoice repository.


getInvoiceTools

public InvoiceTools getInvoiceTools()
Get the invoice tools component this InvoiceManager uses to access the invoice repository.


setIdGenerator

public void setIdGenerator(IdGenerator pIdGenerator)
Set the id generated used to generate unique invoice numbers.


getIdGenerator

public IdGenerator getIdGenerator()
Return the id generated used to generate unique invoice numbers.


setInvoiceNumberIdSpace

public void setInvoiceNumberIdSpace(java.lang.String pInvoiceNumberIdSpace)
Set the id generator namespace used to generate unique invoice numbers.


getInvoiceNumberIdSpace

public java.lang.String getInvoiceNumberIdSpace()
Return the id generator namespace used to generate unique invoice numbers.


getNextInvoiceNumber

public java.lang.String getNextInvoiceNumber()
                                      throws InvoiceException
Return a unique invoice number. The value is guaranteed to be unique across all Dynamo servers in a cluster.

Throws:
InvoiceException

createInvoice

public MutableRepositoryItem createInvoice(java.lang.String pInvoiceNumber)
                                    throws InvoiceException,
                                           InvoicePipelineException
Create a new invoice repository item and execute the pipeline chain whose name is specified by the property createInvoiceChainName. The new repository item is transient; to make it persistent, call addInvoice after setting its property values.

Parameters:
pInvoiceNumber - The invoice number for the new invoice.
Returns:
a mutable item ready for calls to setPropertyValue and addInvoice.
Throws:
InvoiceException - if any repository error occurs while creating the new item. The sourceException property of the invoice exception provides access to the original RepositoryException.
InvoicePipelineException

createInvoice

public MutableRepositoryItem createInvoice()
                                    throws InvoiceException,
                                           InvoicePipelineException
Create a new invoice repository item whose invoice number is generated automatically and execute the pipeline chain whose name is specified by the property createInvoiceChainName. The new repository item is transient; to make it persistent, call addInvoice after setting its property values.

Returns:
a mutable item ready for calls to setPropertyValue and addInvoice.
Throws:
InvoiceException - if any repository error occurs while creating the new item. The sourceException property of the invoice exception provides access to the original RepositoryException.
InvoicePipelineException

createInvoice

public RepositoryItem createInvoice(java.lang.String pInvoiceNumber,
                                    InvoiceRequestInfo pInfo)
                             throws InvoiceException,
                                    InvoicePipelineException
Create a new invoice repository item, initialize it from the supplied invoice request info, and add it to the repository.

After the repository item is created, this method executes the pipeline chain whose name is specified by createInvoiceChainName. The invoice repository item is still transient at this point.

The item properties are populated by executing the pipeline chain whose name is specified by initializeInvoiceChainName, after which the item is made persistent and added to the invoice repository.

After the item properties are populated and the item is added to the invoice repository, the method executes the pipeline chain whose name is specified by addInvoiceChainName.

Parameters:
pInvoiceNumber - The invoice number for the new invoice.
pInfo - An InvoiceRequestInfo object used to populate the invoice item's properties.
Returns:
A (non-mutable) repository item that has already been initialized and added to the invoice repository.
Throws:
InvoiceException - if any repository error occurs while creating the new item. The sourceException property of the invoice exception provides access to the original RepositoryException.
InvoicePipelineException

createInvoice

public RepositoryItem createInvoice(InvoiceRequestInfo pInfo)
                             throws InvoiceException,
                                    InvoicePipelineException
Create a new invoice repository item whose invoice number is generated automatically, initialize it from the supplied invoice request info, and add it to the repository.

After the repository item is created, this method executes the pipeline chain whose name is specified by createInvoiceChainName. The invoice repository item is still transient at this point.

The item properties are populated by executing the pipeline chain whose name is specified by initializeInvoiceChainName, after which the item is made persistent and added to the invoice repository.

After the item properties are populated and the item is added to the invoice repository, the method executes the pipeline chain whose name is specified by addInvoiceChainName.

Parameters:
pInfo - An InvoiceRequestInfo object used to populate the invoice item's properties.
Returns:
A (non-mutable) repository item that has already been initialized and added to the invoice repository.
Throws:
InvoiceException - if any repository error occurs while creating the new item. The sourceException property of the invoice exception provides access to the original RepositoryException.
InvoicePipelineException

addInvoice

public RepositoryItem addInvoice(MutableRepositoryItem pInvoice)
                          throws InvoiceException,
                                 InvoicePipelineException
Add the invoice represented by pInvoice to the invoice repository, and execute the pipeline chain whose name is specified by addInvoiceChainName

Parameters:
pInvoice - The transient invoice item that should be added to the repository.
Returns:
A (non-mutable) repository item representing a persistent version of the information in pInvoice. The item may or may not be the same object as pInvoice.
Throws:
InvoiceException - if any repository error occurs while adding the new item. The sourceException property of the invoice exception provides access to the original RepositoryException.
InvoicePipelineException

loadInvoice

public RepositoryItem loadInvoice(java.lang.String pRepositoryId)
                           throws InvoiceException,
                                  InvoicePipelineException
Load the invoice identified by the given repository id and execute the pipeline chain whose name is specified by loadInvoiceChainName.

Throws:
InvoiceException
InvoicePipelineException

loadInvoiceForUpdate

public MutableRepositoryItem loadInvoiceForUpdate(java.lang.String pRepositoryId)
                                           throws InvoiceException,
                                                  InvoicePipelineException
Load a mutable version of the invoice identified by the given repository id and execute the pipeline chain whose name is specified by loadInvoiceChainName.

Throws:
InvoiceException
InvoicePipelineException

removeInvoice

public void removeInvoice(RepositoryItem pInvoice)
                   throws InvoiceException,
                          InvoicePipelineException
Remove the specified invoice repository item and execute a pipeline chain.

Throws:
InvoiceException
InvoicePipelineException

removeInvoice

public void removeInvoice(java.lang.String pRepositoryId)
                   throws InvoiceException,
                          InvoicePipelineException
Remove the specified invoice repository item and execute a pipeline chain.

Throws:
InvoiceException
InvoicePipelineException

updateInvoice

public void updateInvoice(MutableRepositoryItem pInvoice)
                   throws InvoiceException,
                          InvoicePipelineException
Update invoice properties in the invoice repository, setting the repository item's last-modified-time to the current time and date, then execute the pipeline chain specified by updateInvoiceChainName.

Parameters:
pInvoice - The invoice being saved to the repository.
Throws:
InvoiceException - if any repository error occurs while updating the item. The sourceException property of the invoice exception provides access to the original RepositoryException.
InvoicePipelineException

getInvoicesForInvoiceNumber

public RepositoryItem[] getInvoicesForInvoiceNumber(java.lang.String pInvoiceNumber)
                                             throws InvoiceException,
                                                    InvoicePipelineException
Return all of the invoices having the given invoice number.

It may be possible to have several invoices with the same invoice number but different repository id's, e.g., if a new invoice is generated to reflect partial payment of an order and a reduction in the balance due. In most cases, however, this method will return an array containing a single invoice. This method will execute the "loadInvoice" pipeline chain once for each invoice returned.

Throws:
InvoiceException
InvoicePipelineException

runPipelineChain

protected PipelineResult runPipelineChain(java.lang.String pChainName,
                                          RepositoryItem pItem)
                                   throws InvoiceException,
                                          InvoicePipelineException
Run the named pipeline chain, passing this invoice manager and the specified repository item to each pipeline processor.

Throws:
InvoiceException
InvoicePipelineException

runPipelineChain

protected PipelineResult runPipelineChain(java.lang.String pChainName,
                                          RepositoryItem pItem,
                                          InvoiceRequestInfo pInfo)
                                   throws InvoiceException,
                                          InvoicePipelineException
Run the named pipeline chain, passing this invoice manager, the specified repository item, and the specified invoice request info object (which may be omitted) to each pipeline processor.

Throws:
InvoiceException
InvoicePipelineException

createPipelineArgs

protected InvoicePipelineArgs createPipelineArgs(RepositoryItem pItem)
Create an instance of InvoicePipelineArgs containing a reference to this pipeline manager and to the specified repository item.

Invoice manager subclasses that wish to provide additional information to the invoice pipeline can do so by overriding this method to add additional key/value pairs to the InvoicePipelineArgs, and/or to return a different application-specific subclass to use for the argument passed to the pipeline chain.


createPipelineArgs

protected InvoicePipelineArgs createPipelineArgs(RepositoryItem pItem,
                                                 InvoiceRequestInfo pInfo)
Create an instance of InvoicePipelineArgs containing a reference to this pipeline manager, to a specified repository item, and to a specified InvoiceRequestInfo that should be used to initialize the repository item.

Invoice manager subclasses that wish to provide additional information to the invoice pipeline can do so by overriding this method to add additional key/value pairs to the InvoicePipelineArgs, and/or to return a different application-specific subclass to use for the argument passed to the pipeline chain.


throwPipelineException

protected void throwPipelineException(java.lang.String pChainName,
                                      PipelineResult pResult)
                               throws InvoicePipelineException
Throw an InvoicePipelineException with an appropriate error message for the given pipeline chain and pipeline result object.

Throws:
InvoicePipelineException