edu.uci.isr.yancees.server.service.persistency
Class PersistencyService

java.lang.Object
  extended byedu.uci.isr.yancees.server.service.AbstractService
      extended byedu.uci.isr.yancees.server.service.persistency.PersistencyService
All Implemented Interfaces:
ServiceInterface

public class PersistencyService
extends AbstractService

This persistency service stores the events in main memory. Future extensions will store them in a secondary memory device.


Constructor Summary
PersistencyService()
          constructor
 
Method Summary
 void clearAllEvents()
          Removes all the events from all the accounts of the database
 EventInterface[] getAndRemoveEvents(SubscriberInterface si)
          Gets all the events from a subscriber
 EventInterface[] getAndRemoveEventsAfter(java.util.Date date, SubscriberInterface si)
          Get the events after a given date and remove them from the database
 EventInterface[] getAndRemoveEventsBefore(java.util.Date date, SubscriberInterface si)
          Gets all the events before a given date for the especified account
 EventInterface[] getEvents(SubscriberInterface si)
          Gets all the events stored for a subscriber
 EventInterface[] getEventsAfter(java.util.Date date, SubscriberInterface si)
          Gets all the events after a given date, for a given subscriber
 EventInterface[] getEventsBefore(java.util.Date date, SubscriberInterface si)
          Gets all the events before a given date
 void removeEvents(SubscriberInterface si)
          Removes all the events, stored in the database, that are associated to the provided subscriber
 void removeEvents(SubscriberInterface si, EventInterface[] eventList)
          Removes specific events form a subscriber account
 void storeEvent(SubscriberInterface si, EventInterface event)
          Stores the event in the database in the si account.
 
Methods inherited from class edu.uci.isr.yancees.server.service.AbstractService
getName, isActive, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistencyService

public PersistencyService()
constructor

Method Detail

storeEvent

public void storeEvent(SubscriberInterface si,
                       EventInterface event)
Stores the event in the database in the si account.

Parameters:
si - is the account to store the event
event - is the event to be stored

getEvents

public EventInterface[] getEvents(SubscriberInterface si)
Gets all the events stored for a subscriber

Parameters:
si - is the subscriber account identifier
Returns:
a list of events or an empty list if no events found

getAndRemoveEvents

public EventInterface[] getAndRemoveEvents(SubscriberInterface si)
Gets all the events from a subscriber

Parameters:
si - is the accoutn where the events are stored
Returns:
a list of events or an empty list if no event is found

getEventsAfter

public EventInterface[] getEventsAfter(java.util.Date date,
                                       SubscriberInterface si)
Gets all the events after a given date, for a given subscriber

Parameters:
date - is the date to be used as reference
si - is the subscriber account identifier
Returns:
a list of events stored in the database or an empty list if no event matched the query.

getEventsBefore

public EventInterface[] getEventsBefore(java.util.Date date,
                                        SubscriberInterface si)
Gets all the events before a given date

Parameters:
date - is the reference date to be considered
si - is the subscriber interface (account) to query
Returns:
a list of events before a referecne date or an empty list if no events matching the query are found

getAndRemoveEventsAfter

public EventInterface[] getAndRemoveEventsAfter(java.util.Date date,
                                                SubscriberInterface si)
Get the events after a given date and remove them from the database

Parameters:
date - is the reference date
si - is the account to be considered
Returns:
the list of events removed from the database or an empty list if no event was found

getAndRemoveEventsBefore

public EventInterface[] getAndRemoveEventsBefore(java.util.Date date,
                                                 SubscriberInterface si)
Gets all the events before a given date for the especified account

Parameters:
date - is the reference date considered
si - is the subscriber account to be queried
Returns:
the list of the events removed or an empty list if no event is found

removeEvents

public void removeEvents(SubscriberInterface si)
Removes all the events, stored in the database, that are associated to the provided subscriber

Parameters:
si - is the subscriber account to be removed

removeEvents

public void removeEvents(SubscriberInterface si,
                         EventInterface[] eventList)
Removes specific events form a subscriber account

Parameters:
si - is the subscriber interface (account) to be considered
eventList - is the list of events to be removed

clearAllEvents

public void clearAllEvents()
Removes all the events from all the accounts of the database