org.starhope.appius.user.events
Class Quaestor

java.lang.Object
  extended by java.util.TimerTask
      extended by org.starhope.appius.user.events.Quaestor
All Implemented Interfaces:
Runnable

public class Quaestor
extends TimerTask

WRITEME: Document this type.

Author:
brpocock@star-hope.org

Field Summary
(package private) static Collection<ActionHandlerInterface> actionHandlers
          collection of all action handlers in the system
private  Queue<Action> actionQueue
          WRITEME: Document this brpocock@star-hope.org
private static Quaestor defaultQuaestor
          WRITEME: Document this brpocock@star-hope.org
private static Quaestor localQuaestor
          The local Quaestor instance, in case it's needed
private  WeakHashMap<AbstractUser,Set<ActionHandlerInterface>> weakListeners
          weak listeners stuff
 
Constructor Summary
private Quaestor()
          WRITEME: Document this constructor brpocock@star-hope.org
 
Method Summary
static void action(AbstractUser subject, String verb)
          Deprecated. use action(Action)
static void action(AbstractUser subject, String verb, AbstractUser object)
          Deprecated. use action(Action)
static void action(AbstractUser user, String verb, String string)
          Deprecated. use action(Action)
 void action(Action action)
          WRITEME: Document this method brpocock@star-hope.org
static void action(Room where, AbstractUser subject, String verb)
          Deprecated. use action(Action)
static void action(Room where, AbstractUser subject, String verb, AbstractUser object)
          Deprecated. use action(Action)
static void action(Room where, AbstractUser subject, String verb, AbstractUser object, String indirectObject, Object... trailer)
          Deprecated. use action(Action)
static void action(Room room, AbstractUser user, String verb, String indirectObject)
          Deprecated. use action(Action)
static void action(Room where, String verb, AbstractUser object)
          Deprecated. use action(Action)
static void action(String verb)
          Deprecated. use action(Action)
static void action(String verb, AbstractUser object)
          Deprecated. use action(Action)
static void action(String verb, String indirectObject)
          Deprecated. use action(Action)
private  boolean dispatchAction(Action action)
          WRITEME: Document this method brpocock@star-hope.org
private static void dispatchAction(Room where, AbstractUser subject, String verb, AbstractUser object, String indirectObject, Object... trailer)
          WRITEME: Document this method brpocock@star-hope.org
static Quaestor getDefault()
          WRITEME: Document this method brpocock@star-hope.org
static int getEndedEventCount(AbstractUser user, String moniker)
          Gets a count of all ended events of a specific event type for a given user
static EventRecord getEventByID(int eventID)
           
static int getEventCount(AbstractUser user, String moniker)
          Gets a count of a all occurrences of a specific event for a specified user regardless of finished status
static EventType getEventTypeByID(int eventTypeID)
          Get an event type, given its ID.
private static EventType getEventTypeForMoniker(String moniker)
          WRITEME: Document this method brpocock@star-hope.org
static int getItemGainedEventCount(AbstractUser user, String moniker, int itemID)
          Gets a count of a all occurrences of a specific event for a specified user that adds an item
static Quaestor getLocal()
          Get the local Quaestor, even if a network one is available
static List<Integer> getStartedEventsByType(AbstractUser user, String moniker)
          Gets a list of all events of the given type that were started but not yet ended
static void ignore(ActionHandlerInterface handler)
          WRITEME: Document this method brpocock@star-hope.org
static void listen(ActionHandlerInterface handler)
          WRITEME: Document this method brpocock@star-hope.org
 void run()
           
 void setDefault()
          Set the default Quaestor to be used when getDefault() is called.
static void setDefaultToLocal()
          Set the local quaestor as the default one to be used, normally flagging the death of a network Quaestor for some reason
static org.json.JSONObject startEvent_JSON(AbstractUser user, String moniker)
          Start an event and return the JSON object for the client with event details
static EventRecord startEvent(AbstractUser user, String moniker)
          WRITEME: Document this method brpocock@star-hope.org
static int startEventRaw(AbstractUser user, String moniker)
          WRITEME: Document this method brpocock@star-hope.org
 void tryAction(Action action)
          WRITEME: Document this method brpocock@star-hope.org
 void weakListen(AbstractUser u, ActionHandlerInterface actionHandler)
          Listen for an event, weakly, forgetting about it if the user logs out.
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actionHandlers

static Collection<ActionHandlerInterface> actionHandlers
collection of all action handlers in the system


defaultQuaestor

private static Quaestor defaultQuaestor
WRITEME: Document this brpocock@star-hope.org


localQuaestor

private static final Quaestor localQuaestor
The local Quaestor instance, in case it's needed


actionQueue

private final Queue<Action> actionQueue
WRITEME: Document this brpocock@star-hope.org


weakListeners

private final WeakHashMap<AbstractUser,Set<ActionHandlerInterface>> weakListeners
weak listeners stuff

Constructor Detail

Quaestor

private Quaestor()
WRITEME: Document this constructor brpocock@star-hope.org

Method Detail

action

@Deprecated
public static void action(AbstractUser subject,
                                     String verb)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
subject - WRITEME
verb - WRITEME

action

@Deprecated
public static void action(AbstractUser subject,
                                     String verb,
                                     AbstractUser object)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
subject - WRITEME
verb - WRITEME
object - WRITEME

action

@Deprecated
public static void action(AbstractUser user,
                                     String verb,
                                     String string)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
user - WRITEME
verb - WRITEME
string - WRITEME

action

@Deprecated
public static void action(Room where,
                                     AbstractUser subject,
                                     String verb)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
where - WRITEME
subject - WRITEME
verb - WRITEME

action

@Deprecated
public static void action(Room where,
                                     AbstractUser subject,
                                     String verb,
                                     AbstractUser object)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
where - WRITEME
subject - WRITEME
verb - WRITEME
object - WRITEME

action

@Deprecated
public static void action(Room where,
                                     AbstractUser subject,
                                     String verb,
                                     AbstractUser object,
                                     String indirectObject,
                                     Object... trailer)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
where - WRITEME
subject - WRITEME
verb - WRITEME
object - WRITEME
indirectObject - WRITEME
trailer - WRITEME

action

@Deprecated
public static void action(Room room,
                                     AbstractUser user,
                                     String verb,
                                     String indirectObject)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
room - WRITEME
user - WRITEME
verb - WRITEME
indirectObject - WRITEME

action

@Deprecated
public static void action(Room where,
                                     String verb,
                                     AbstractUser object)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
where - WRITEME
verb - WRITEME
object - WRITEME

action

@Deprecated
public static void action(String verb)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
verb - WRITEME

action

@Deprecated
public static void action(String verb,
                                     AbstractUser object)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
verb - WRITEME
object - WRITEME

action

@Deprecated
public static void action(String verb,
                                     String indirectObject)
Deprecated. use action(Action)

WRITEME: Document this method brpocock@star-hope.org

Parameters:
verb - WRITEME
indirectObject - WRITEME

dispatchAction

private static void dispatchAction(Room where,
                                   AbstractUser subject,
                                   String verb,
                                   AbstractUser object,
                                   String indirectObject,
                                   Object... trailer)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
where - WRITEME
subject - WRITEME WRITEME
verb - WRITEME
object - WRITEME
indirectObject - WRITEME
trailer - WRITEME

getDefault

public static Quaestor getDefault()
WRITEME: Document this method brpocock@star-hope.org

Returns:
WRITEME: Document this method brpocock@star-hope.org

getEndedEventCount

public static int getEndedEventCount(AbstractUser user,
                                     String moniker)
Gets a count of all ended events of a specific event type for a given user

Parameters:
user - User
moniker - Event Type
Returns:
Number of Occurrences

getEventByID

public static EventRecord getEventByID(int eventID)
                                throws NotFoundException
Parameters:
eventID - the ID of the event to be loaded
Returns:
the event record
Throws:
NotFoundException - if the event record does not exist

getEventCount

public static int getEventCount(AbstractUser user,
                                String moniker)
Gets a count of a all occurrences of a specific event for a specified user regardless of finished status

Parameters:
user - User
moniker - Event Type
Returns:
Number of Occurrences

getEventTypeByID

public static EventType getEventTypeByID(int eventTypeID)
                                  throws NotFoundException
Get an event type, given its ID. Just calls Nomenclator.getDataRecord(Class, int) with EventType.class, these days.

Parameters:
eventTypeID - id number
Returns:
EventType object
Throws:
NotFoundException - if not found

getEventTypeForMoniker

private static EventType getEventTypeForMoniker(String moniker)
                                         throws NotFoundException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
moniker - WRITEME
Returns:
WRITEME
Throws:
NotFoundException - not found

getItemGainedEventCount

public static int getItemGainedEventCount(AbstractUser user,
                                          String moniker,
                                          int itemID)
Gets a count of a all occurrences of a specific event for a specified user that adds an item

Parameters:
user - User
moniker - Event Type
itemID - Item ID
Returns:
Number of Occurrences

getLocal

public static Quaestor getLocal()
Get the local Quaestor, even if a network one is available

Returns:
the local Quaestor

getStartedEventsByType

public static List<Integer> getStartedEventsByType(AbstractUser user,
                                                   String moniker)
Gets a list of all events of the given type that were started but not yet ended

Parameters:
moniker - Event Type moniker
user - User
Returns:
A list of event IDs

ignore

public static void ignore(ActionHandlerInterface handler)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
handler - WRITEME

listen

public static void listen(ActionHandlerInterface handler)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
handler - WRITEME

setDefaultToLocal

public static void setDefaultToLocal()
Set the local quaestor as the default one to be used, normally flagging the death of a network Quaestor for some reason


startEvent

public static EventRecord startEvent(AbstractUser user,
                                     String moniker)
                              throws AlreadyExistsException,
                                     NotFoundException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
user - user starting (creating) the event
moniker - WRITEME
Returns:
WRITEME
Throws:
AlreadyExistsException - if the event can't be started again
NotFoundException - if the type isn't found

startEvent_JSON

public static org.json.JSONObject startEvent_JSON(AbstractUser user,
                                                  String moniker)
Start an event and return the JSON object for the client with event details

Parameters:
user - the user starting the event
moniker - the event moniker
Returns:
the JSON data structure containing WRITEME

startEventRaw

public static int startEventRaw(AbstractUser user,
                                String moniker)
                         throws AlreadyExistsException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
user - WRITEME
moniker - WRITEME
Returns:
WRITEME
Throws:
AlreadyExistsException - if the user can't perform this event because of event limits in place on it

action

public void action(Action action)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
action - WRITEME

dispatchAction

private boolean dispatchAction(Action action)
WRITEME: Document this method brpocock@star-hope.org

Parameters:
action - WRITEME
Returns:
true, if any handler were found.

run

public void run()
Specified by:
run in interface Runnable
Specified by:
run in class TimerTask
See Also:
TimerTask.run()

setDefault

public void setDefault()
Set the default Quaestor to be used when getDefault() is called. Most routines will use this one.


tryAction

public void tryAction(Action action)
               throws NotFoundException
WRITEME: Document this method brpocock@star-hope.org

Parameters:
action - WRITEME
Throws:
NotFoundException - if no handler accepts the action

weakListen

public void weakListen(AbstractUser u,
                       ActionHandlerInterface actionHandler)
Listen for an event, weakly, forgetting about it if the user logs out.

Parameters:
u - the user to weakly listen for an event
actionHandler - the handler to use