org.dspace.event
Class Event

java.lang.Object
  extended by org.dspace.event.Event
All Implemented Interfaces:
Serializable

public class Event
extends Object
implements Serializable

An Event object represents a single action that changed one object in the DSpace data model. An "atomic" action at the application or business-logic API level may spawn many of these events.

This class includes tools to help set and use the contents of the event. Note that it describes DSpace data object types in two ways: by the type identifiers in the Constants class, and also by an Event-specific bitmask (used by its internal filters). All public API calls use the Constants version of the data model types.

Note that the type of the event itself is actually descriptive of the action it performs: ADD, MODIFY, etc. The most significant elements of the event are:


- (Action) Type
- Subject -- DSpace object to which the action applies, e.g. the Collection to which an ADD adds a member.
- Object -- optional, when present it is the other object effected by an action, e.g. the Item ADDed to a Collection by an ADD.
- detail -- a textual summary of what changed, content and its significance varies by the combination of action and subject type.
- timestamp -- exact millisecond timestamp at which event was logged.

Version:
$Revision: 3762 $
See Also:
Serialized Form

Field Summary
static int ADD
           
static int CREATE
          Event (Action) types
static int DELETE
           
static int EVENT_MASK
           
static int MODIFY
           
static int MODIFY_METADATA
           
static int REMOVE
           
static int SUBJECT_MASK
          Index of filter parts in their array:
 
Constructor Summary
Event(int eventType, int subjectType, int subjectID, int objectType, int objectID, String detail)
          Constructor.
Event(int eventType, int subjectType, int subjectID, String detail)
          Constructor.
 
Method Summary
 boolean equals(Event other)
          Compare two events.
 BitSet getBitSet()
           
 int getCurrentUser()
           
 String getDetail()
           
 int getDispatcher()
           
 int getEventType()
           
 String getEventTypeAsString()
          Get the text name of event (action) type.
 String getExtraLogInfo()
           
 DSpaceObject getObject(Context context)
          Get the DSpace object which is the "object" of an event.
 int getObjectID()
           
 int getObjectType()
           
 String getObjectTypeAsString()
           
 DSpaceObject getSubject(Context context)
          Syntactic sugar to get the DSpace object which is the "subject" of an event.
 int getSubjectID()
           
 int getSubjectType()
           
 String getSubjectTypeAsString()
           
 long getTimeStamp()
           
 String getTransactionID()
           
static int parseEventType(String s)
          Interpret named event type.
static int parseObjectType(String s)
          Translate a textual DSpace Object type name into an event subject-type mask.
 boolean pass(List filters)
           
 void setBitSet(String consumerName)
          Keeps track of which consumers the event has been consumed by.
 void setCurrentUser(int uid)
           
 void setDispatcher(int id)
          Set the identifier of the dispatcher that first processed this event.
 void setExtraLogInfo(String info)
           
 void setTransactionID(String tid)
          Sets value of transactionID element of the event.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CREATE

public static final int CREATE
Event (Action) types

See Also:
Constant Field Values

MODIFY

public static final int MODIFY
See Also:
Constant Field Values

MODIFY_METADATA

public static final int MODIFY_METADATA
See Also:
Constant Field Values

ADD

public static final int ADD
See Also:
Constant Field Values

REMOVE

public static final int REMOVE
See Also:
Constant Field Values

DELETE

public static final int DELETE
See Also:
Constant Field Values

SUBJECT_MASK

public static final int SUBJECT_MASK
Index of filter parts in their array:

See Also:
Constant Field Values

EVENT_MASK

public static final int EVENT_MASK
See Also:
Constant Field Values
Constructor Detail

Event

public Event(int eventType,
             int subjectType,
             int subjectID,
             String detail)
Constructor.

Parameters:
eventType - action type, e.g. Event.ADD
subjectType - DSpace Object Type of subject e.g. Constants.ITEM.
subjectID - database ID of subject instance.
detail - detail information that depends on context.

Event

public Event(int eventType,
             int subjectType,
             int subjectID,
             int objectType,
             int objectID,
             String detail)
Constructor.

Parameters:
eventType - action type, e.g. Event.ADD
subjectType - DSpace Object Type of subject e.g. Constants.ITEM.
subjectID - database ID of subject instance.
objectType - DSpace Object Type of object e.g. Constants.BUNDLE.
objectID - database ID of object instance.
detail - detail information that depends on context.
-
Method Detail

equals

public boolean equals(Event other)
Compare two events. Ignore any difference in the timestamps. Also ignore transactionID since that is not always set initially.

Parameters:
other - the event to compare this one to

setDispatcher

public void setDispatcher(int id)
Set the identifier of the dispatcher that first processed this event.

Parameters:
id - the unique (hash code) value characteristic of the dispatcher.

getObject

public DSpaceObject getObject(Context context)
                       throws SQLException
Get the DSpace object which is the "object" of an event.

Throws:
SQLException

getSubject

public DSpaceObject getSubject(Context context)
                        throws SQLException
Syntactic sugar to get the DSpace object which is the "subject" of an event.

Throws:
SQLException

getSubjectID

public int getSubjectID()

getObjectID

public int getObjectID()

getSubjectType

public int getSubjectType()

getObjectType

public int getObjectType()

getSubjectTypeAsString

public String getSubjectTypeAsString()

getObjectTypeAsString

public String getObjectTypeAsString()

parseObjectType

public static int parseObjectType(String s)
Translate a textual DSpace Object type name into an event subject-type mask. NOTE: This returns a BIT-MASK, not a numeric type value; the mask is only used within the event system.

Parameters:
s - text name of object type.

getEventType

public int getEventType()

getEventTypeAsString

public String getEventTypeAsString()
Get the text name of event (action) type.


parseEventType

public static int parseEventType(String s)
Interpret named event type.

Parameters:
text - name of event type.

getTimeStamp

public long getTimeStamp()

getDispatcher

public int getDispatcher()

getDetail

public String getDetail()

getTransactionID

public String getTransactionID()

setTransactionID

public void setTransactionID(String tid)
Sets value of transactionID element of the event.

Parameters:
tid - new value of transactionID.

setCurrentUser

public void setCurrentUser(int uid)

getCurrentUser

public int getCurrentUser()

setExtraLogInfo

public void setExtraLogInfo(String info)

getExtraLogInfo

public String getExtraLogInfo()

pass

public boolean pass(List filters)
Parameters:
filters - list of filter masks; each one is an Array of two ints.

setBitSet

public void setBitSet(String consumerName)
Keeps track of which consumers the event has been consumed by. Should be called by a dispatcher when calling consume(Context ctx, String name, Event event) on an event.

Parameters:
consumerName -

getBitSet

public BitSet getBitSet()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010 DuraSpace. All Rights Reserved.