org.starhope.appius.user.notifications
Class Notification

java.lang.Object
  extended by org.starhope.appius.util.SimpleDataRecord<Notification>
      extended by org.starhope.appius.user.notifications.Notification
All Implemented Interfaces:
com.whirlycott.cache.Cacheable, Serializable, Comparable<Notification>, CastsToJSON, CTime, DataRecord, HasSubversionRevision

public class Notification
extends SimpleDataRecord<Notification>
implements CastsToJSON

Notification class. Used to notify users of events asynchronously. Notifications can be generated for offline users as well.

Author:
Tim Heys
See Also:
Serialized Form

Field Summary
private  int id
          The ID of the notification
private  String messageLabel
          The message catalog label for the notification message
private  Map<String,String> messageParams
          set of parameters to be substituted into the message obtained from LibMisc#getText messageLabel for %s parameters
private  long readTime
          Time at which the notification was read/dispatched
private  AbstractUser recipient
          The user to whom this notification was directed
private  AbstractUser sender
          The ID of the User that initiated this notification
private  long sentTime
          time at which the notification was sent
private static long serialVersionUID
          Java Serialisation unique ID
protected  NotificationReplyVerbSet verbs
          verbs that can be used to respond to this notification
 
Fields inherited from class org.starhope.appius.util.SimpleDataRecord
myLoader, timeLastChanged, timeLastSaved
 
Constructor Summary
Notification(AbstractUser newSender, String label, AbstractUser newRecipient)
          Instantiate a new Notification
 
Method Summary
 void addMessageParam(String key, String param)
          add a message parameter to the notification.
 void addMessageParams(Map<String,String> params)
          add a series of message parameters to the notification.
 int getCacheableID()
          Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.
 String getCacheableIdent()
          Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.
 long getID()
           
 String getMessageLabel()
           
 Map<String,String> getMessageParams()
           
 long getReadTime()
           
 AbstractUser getRecipient()
           
 NotificationReplyVerbSet getReplyVerbs()
          get available response verbs, if any.
 AbstractUser getSender()
           
 long getSentTime()
           
 String getSubversionRevision()
           Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.
 boolean isRead()
           
 boolean isSent()
           
 void markAsRead()
          Used when the notification is handled.
 void send()
          Send a notification
 void setMessageLabel(String newLabel)
           
 void setRecipient(AbstractUser newRecipient)
           
 void setSender(AbstractUser newSender)
           
 org.json.JSONObject toJSON()
          return a JSON version of this notification
 String toString()
           
 
Methods inherited from class org.starhope.appius.util.SimpleDataRecord
changed, checkStale, compareTo, equals, finalize, getRecordLoader, getTimeLastChanged, getTimeLastSaved, hashCode, isBeingLoaded, markAsLoaded, markAsSaved, markForReload, onRemove, onRetrieve, onStore, save, setRecordLoader
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Java Serialisation unique ID

See Also:
Constant Field Values

id

private final int id
The ID of the notification

See Also:
Constant Field Values

messageLabel

private String messageLabel
The message catalog label for the notification message


messageParams

private final Map<String,String> messageParams
set of parameters to be substituted into the message obtained from LibMisc#getText messageLabel for %s parameters


readTime

private long readTime
Time at which the notification was read/dispatched


recipient

private AbstractUser recipient
The user to whom this notification was directed


sender

private AbstractUser sender
The ID of the User that initiated this notification


sentTime

private long sentTime
time at which the notification was sent


verbs

protected NotificationReplyVerbSet verbs
verbs that can be used to respond to this notification

Constructor Detail

Notification

public Notification(AbstractUser newSender,
                    String label,
                    AbstractUser newRecipient)
Instantiate a new Notification

Parameters:
newSender - The sender of the notification
label - The verb/label
newRecipient - The recipient
Method Detail

addMessageParam

public void addMessageParam(String key,
                            String param)
add a message parameter to the notification.

Parameters:
key - the parameter ID
param - the new message parameter

addMessageParams

public void addMessageParams(Map<String,String> params)
add a series of message parameters to the notification. Order is significant!

Parameters:
params - the new message parameters

getCacheableID

public int getCacheableID()
                   throws NotFoundException
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Specified by:
getCacheableID in interface DataRecord
Returns:
an unique ID number
Throws:
NotFoundException - if the item doesn't have a distinct numeric ID
See Also:
DataRecord.getCacheableID()

getCacheableIdent

public String getCacheableIdent()
Description copied from interface: DataRecord
Note that all records must have either a numeric ID ( DataRecord.getCacheableID() or a string identifier ( DataRecord.getCacheableIdent() or both.

Specified by:
getCacheableIdent in interface DataRecord
Returns:
an unique identifier string
See Also:
DataRecord.getCacheableIdent()

getID

public long getID()
Returns:
the id

getMessageLabel

public String getMessageLabel()
Returns:
the messageLabel

getMessageParams

public Map<String,String> getMessageParams()
Returns:
the messageParams

getReadTime

public long getReadTime()
Returns:
the readTime

getRecipient

public AbstractUser getRecipient()
Returns:
the recipient

getReplyVerbs

public NotificationReplyVerbSet getReplyVerbs()
get available response verbs, if any. Special case, returns null for zero verbs.

Returns:
a set of verbs or null

getSender

public AbstractUser getSender()
Returns:
the senderID

getSentTime

public long getSentTime()
Returns:
the sentTime

getSubversionRevision

public String getSubversionRevision()
Description copied from interface: HasSubversionRevision

Return the Subversion revision level of this class's source code file, as supplied via the special "$Rev: " sequence.

As an example,the Subversion revision string for this file is "$Rev: 1968 $"

 
 @Override
 public String getSubversionRevision () {
        return "$Rev: ";
 }
 

Specified by:
getSubversionRevision in interface HasSubversionRevision
Returns:
The Subversion revision level for this class's source code file.
See Also:
HasSubversionRevision.getSubversionRevision()

isRead

public boolean isRead()
Returns:
true, if the notification has been read

isSent

public boolean isSent()
Returns:
true, if the notification has been sent

markAsRead

public void markAsRead()
Used when the notification is handled.


send

public void send()
Send a notification


setMessageLabel

public void setMessageLabel(String newLabel)
Parameters:
newLabel - the messageLabel to set

setRecipient

public void setRecipient(AbstractUser newRecipient)
Parameters:
newRecipient - the recipient to set

setSender

public void setSender(AbstractUser newSender)
Parameters:
newSender - the senderID to set

toJSON

public org.json.JSONObject toJSON()
return a JSON version of this notification

Specified by:
toJSON in interface CastsToJSON
Returns:
JSON object describing this notific

toString

public String toString()
Overrides:
toString in class SimpleDataRecord<Notification>
See Also:
Object.toString()