org.marketcetera.ors.history
Class BasicReportHistoryServices

java.lang.Object
  extended by org.marketcetera.ors.history.BasicReportHistoryServices
All Implemented Interfaces:
ReportHistoryServices
Direct Known Subclasses:
AsyncSaveReportHistoryServices

public class BasicReportHistoryServices
extends Object
implements ReportHistoryServices

Provides basic services to save and query reports.

Since:
2.1.0
Version:
$Id: BasicReportHistoryServices.java 16154 2012-07-14 16:34:05Z colin $
Author:
anshul@marketcetera.com

Constructor Summary
BasicReportHistoryServices()
          Creates a new basic report history services provider.
 
Method Summary
protected  void assignID(ReportBase report)
          Sets the ID of the given report.
 Map<PositionKey<Equity>,BigDecimal> getAllEquityPositionsAsOf(SimpleUser inUser, Date inDate)
          Returns the aggregate position of each (equity,account,actor) tuple based on all reports received for each tuple on or before the supplied date, and which are visible to the given user.
 Map<PositionKey<Future>,BigDecimal> getAllFuturePositionsAsOf(SimpleUser inUser, Date inDate)
          Returns the aggregate position of each future (future,account,actor) tuple based on all reports received for each future instrument on or before the supplied date, and which are visible to the given user.
 Map<PositionKey<Option>,BigDecimal> getAllOptionPositionsAsOf(SimpleUser inUser, Date inDate)
          Returns the aggregate position of each option (option,account,actor) tuple based on all reports received for each option instrument on or before the supplied date, and which are visible to the given user.
 BigDecimal getEquityPositionAsOf(SimpleUser inUser, Date inDate, Equity inEquity)
          Returns the position of the equity based on all reports received for it before or on the supplied date, and which are visible to the given user.
 BigDecimal getFuturePositionAsOf(SimpleUser inUser, Date inDate, Future inFuture)
          Gets the current aggregate position for the future instrument based on execution reports received before or on the supplied date, and which are visible to the given user.
protected  JmsManager getJmsManager()
          Returns the receiver's JMS manager.
 BigDecimal getOptionPositionAsOf(SimpleUser inUser, Date inDate, Option inOption)
          Gets the current aggregate position for the option instrument based on execution reports received before or on the supplied date, and which are visible to the given user.
 Map<PositionKey<Option>,BigDecimal> getOptionPositionsAsOf(SimpleUser inUser, Date inDate, String... inSymbols)
          Returns the aggregate position of each option (option,account,actor) tuple based on all reports received for each option instrument on or before the supplied date, and which are visible to the given user.
 Principals getPrincipals(OrderID orderID)
          Returns the principals associated with the report with given order ID.
protected  LongIDFactory getReportIDFactory()
          Returns the receiver's report ID factory.
protected  ReportSavedListener getReportSavedListener()
          Returns the receiver's listener which should be notified after a report has been saved.
 ReportBaseImpl[] getReportsSince(SimpleUser inUser, Date inDate)
          Returns all the reports received after the supplied date-time value, and which are visible to the given user.
 void init(IDFactory idFactory, JmsManager jmsManager, ReportSavedListener reportSavedListener)
          Initializes the receiver with the given system resources.
protected  void invokeListener(ReportBase report, boolean status)
          Invokes the listener which should be notified after the given report has been saved.
 void save(ReportBase report)
          Saves the supplied report to the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicReportHistoryServices

public BasicReportHistoryServices()
Creates a new basic report history services provider.

Method Detail

init

public void init(IDFactory idFactory,
                 JmsManager jmsManager,
                 ReportSavedListener reportSavedListener)
          throws ReportPersistenceException
Description copied from interface: ReportHistoryServices
Initializes the receiver with the given system resources.

Specified by:
init in interface ReportHistoryServices
Parameters:
idFactory - The ID factory to be used for report ID generation.
jmsManager - The JMS manager used for asychronous persistence of reports. Null may be acceptable to certain implementations.
reportSavedListener - The listener notified after a report has been saved (successfully or not). It may be null if no notifications are needed.
Throws:
ReportPersistenceException - Thrown if initialization cannot complete.

getReportsSince

public ReportBaseImpl[] getReportsSince(SimpleUser inUser,
                                        Date inDate)
                                 throws PersistenceException,
                                        ReportPersistenceException
Description copied from interface: ReportHistoryServices
Returns all the reports received after the supplied date-time value, and which are visible to the given user.

Specified by:
getReportsSince in interface ReportHistoryServices
Parameters:
inUser - the user making the query. Cannot be null.
inDate - the date-time value. Cannot be null.
Returns:
the reports that were received after the date-time value, and which are visible to the given user.
Throws:
PersistenceException - if there were persistence errors fetching the reports.
ReportPersistenceException - if the data retrieved had unexpected errors.

getEquityPositionAsOf

public BigDecimal getEquityPositionAsOf(SimpleUser inUser,
                                        Date inDate,
                                        Equity inEquity)
                                 throws PersistenceException
Description copied from interface: ReportHistoryServices
Returns the position of the equity based on all reports received for it before or on the supplied date, and which are visible to the given user.

Specified by:
getEquityPositionAsOf in interface ReportHistoryServices
Parameters:
inUser - the user making the query. Cannot be null.
inDate - the date to compare with all the reports. Only the reports that were received prior to or on this date will be used in this calculation. Cannot be null.
inEquity - the equity whose position is desired. Cannot be null.
Returns:
the equity position.
Throws:
PersistenceException - if there were errors retrieving the equity position

getAllEquityPositionsAsOf

public Map<PositionKey<Equity>,BigDecimal> getAllEquityPositionsAsOf(SimpleUser inUser,
                                                                     Date inDate)
                                                              throws PersistenceException
Description copied from interface: ReportHistoryServices
Returns the aggregate position of each (equity,account,actor) tuple based on all reports received for each tuple on or before the supplied date, and which are visible to the given user.

Specified by:
getAllEquityPositionsAsOf in interface ReportHistoryServices
Parameters:
inUser - the user making the query. Cannot be null.
inDate - the date to compare with all the reports. Only the reports that were received on or prior to this date will be used in this calculation. Cannot be null.
Returns:
the position map.
Throws:
PersistenceException - if there were errors retrieving the position map.

getAllFuturePositionsAsOf

public Map<PositionKey<Future>,BigDecimal> getAllFuturePositionsAsOf(SimpleUser inUser,
                                                                     Date inDate)
                                                              throws PersistenceException
Description copied from interface: ReportHistoryServices
Returns the aggregate position of each future (future,account,actor) tuple based on all reports received for each future instrument on or before the supplied date, and which are visible to the given user.

Buy trades result in positive positions. All other kinds of trades result in negative positions.

Specified by:
getAllFuturePositionsAsOf in interface ReportHistoryServices
Parameters:
inUser - the user making the query. Cannot be null.
inDate - the date to compare with all the reports. Only the reports that were received on or prior to this date will be used in this calculation. Cannot be null.
Returns:
the position map.
Throws:
PersistenceException - if there were errors retrieving the position map.

getFuturePositionAsOf

public BigDecimal getFuturePositionAsOf(SimpleUser inUser,
                                        Date inDate,
                                        Future inFuture)
                                 throws PersistenceException
Description copied from interface: ReportHistoryServices
Gets the current aggregate position for the future instrument based on execution reports received before or on the supplied date, and which are visible to the given user.

Buy trades result in positive positions. All other kinds of trades result in negative positions.

Specified by:
getFuturePositionAsOf in interface ReportHistoryServices
Parameters:
inUser - the user making the query. Cannot be null.
inDate - the time. execution reports with sending time values less than or equal to this time are included in this calculation.
inFuture - The future instrument
Returns:
the aggregate position for the symbol.
Throws:
PersistenceException - if there were errors retrieving the position.

getOptionPositionAsOf

public BigDecimal getOptionPositionAsOf(SimpleUser inUser,
                                        Date inDate,
                                        Option inOption)
                                 throws PersistenceException
Description copied from interface: ReportHistoryServices
Gets the current aggregate position for the option instrument based on execution reports received before or on the supplied date, and which are visible to the given user.

Buy trades result in positive positions. All other kinds of trades result in negative positions.

Specified by:
getOptionPositionAsOf in interface ReportHistoryServices
Parameters:
inUser - the user making the query. Cannot be null.
inDate - the time. execution reports with sending time values less than or equal to this time are included in this calculation.
inOption - The option instrument
Returns:
the aggregate position for the symbol.
Throws:
PersistenceException - if there were errors retrieving the position.

getAllOptionPositionsAsOf

public Map<PositionKey<Option>,BigDecimal> getAllOptionPositionsAsOf(SimpleUser inUser,
                                                                     Date inDate)
                                                              throws PersistenceException
Description copied from interface: ReportHistoryServices
Returns the aggregate position of each option (option,account,actor) tuple based on all reports received for each option instrument on or before the supplied date, and which are visible to the given user.

Buy trades result in positive positions. All other kinds of trades result in negative positions.

Specified by:
getAllOptionPositionsAsOf in interface ReportHistoryServices
Parameters:
inUser - the user making the query. Cannot be null.
inDate - the date to compare with all the reports. Only the reports that were received on or prior to this date will be used in this calculation. Cannot be null.
Returns:
the position map.
Throws:
PersistenceException - if there were errors retrieving the position map.

getOptionPositionsAsOf

public Map<PositionKey<Option>,BigDecimal> getOptionPositionsAsOf(SimpleUser inUser,
                                                                  Date inDate,
                                                                  String... inSymbols)
                                                           throws PersistenceException
Description copied from interface: ReportHistoryServices
Returns the aggregate position of each option (option,account,actor) tuple based on all reports received for each option instrument on or before the supplied date, and which are visible to the given user.

Buy trades result in positive positions. All other kinds of trades result in negative positions.

Specified by:
getOptionPositionsAsOf in interface ReportHistoryServices
Parameters:
inUser - the user making the query. Cannot be null.
inDate - the date to compare with all the reports. Only the reports that were received on or prior to this date will be used in this calculation. Cannot be null.
inSymbols - the list of option roots.
Returns:
the position map.
Throws:
PersistenceException - if there were errors retrieving the position map.

save

public void save(ReportBase report)
          throws PersistenceException
Description copied from interface: ReportHistoryServices
Saves the supplied report to the database. Saving may be immediate or delayed; in either case the report ID is set before this method returns.

Specified by:
save in interface ReportHistoryServices
Parameters:
report - the report to be saved. Cannot be null.
Throws:
PersistenceException - if there were errors saving the report.

getPrincipals

public Principals getPrincipals(OrderID orderID)
                         throws PersistenceException
Description copied from interface: ReportHistoryServices
Returns the principals associated with the report with given order ID.

Specified by:
getPrincipals in interface ReportHistoryServices
Parameters:
orderID - The order ID.
Returns:
The principals. If no report with the given order ID exists, Principals.UNKNOWN is returned, and no exception is thrown.
Throws:
PersistenceException - Thrown if there were errors accessing the report.

getReportIDFactory

protected LongIDFactory getReportIDFactory()
Returns the receiver's report ID factory.

Returns:
The factory.

getJmsManager

protected JmsManager getJmsManager()
Returns the receiver's JMS manager.

Returns:
The manager. It may be null, but only if allowed by the specific subclass.

getReportSavedListener

protected ReportSavedListener getReportSavedListener()
Returns the receiver's listener which should be notified after a report has been saved.

Returns:
The listener. It may be null.

assignID

protected void assignID(ReportBase report)
                 throws PersistenceException
Sets the ID of the given report.

Parameters:
report - The report.
Throws:
PersistenceException - Thrown if there were errors assigning the ID.

invokeListener

protected void invokeListener(ReportBase report,
                              boolean status)
Invokes the listener which should be notified after the given report has been saved. The given flag indicates whether saving completed successfully or not.

Parameters:
report - The report.
status - True if saving completed successfully.


Copyright © 2012. All Rights Reserved.