NotificationRule

public class NotificationRule

A notification rule persisted in the database. Represents a rule for sending out a single notification after a matching org.motechproject.admin.domain.StatusMessage is registered in the system. The message is matched against its level and the module to which it is tied to. This class also contains information about this notification’s recipient and the ActionType representing a method used for notifying the recipient.

See also: org.motechproject.admin.domain.StatusMessage

Constructors

NotificationRule

public NotificationRule()

NotificationRule

public NotificationRule(String recipient, ActionType actionType, Level level, String moduleName)

Constructor.

Parameters:
  • recipient – the recipient of the notification
  • actionType – the type of action which will be performed
  • level – the minimal level for which the notification will trigger
  • moduleName – the module name for which this rule will trigger, leave null or blank for every module

Methods

getActionType

public ActionType getActionType()
Returns:the action that should be performed for this notification rule

getId

public Long getId()
Returns:the database ID

getLevel

public Level getLevel()
Returns:the minimal level for which the notification will trigger

getModuleName

public String getModuleName()
Returns:the module name for which this rule will trigger, null or blank for every module

getRecipient

public String getRecipient()
Returns:the recipient of the notification

matches

public boolean matches(StatusMessage message)

Checks if the message matches this rule.

Parameters:
  • message – the message which will be checked against this rule
Returns:

true if message matches this notification rule, false otherwise

setActionType

public void setActionType(ActionType actionType)
Parameters:
  • actionType – the action that should be performed for this notification rule

setId

public void setId(Long id)
Parameters:
  • id – the database ID

setLevel

public void setLevel(Level level)
Parameters:
  • level – the minimal level for which the notification will trigger

setModuleName

public void setModuleName(String moduleName)
Parameters:
  • moduleName – the module name for which this rule will trigger, leave null or blank for every module

setRecipient

public void setRecipient(String recipient)
Parameters:
  • recipient – the recipient of the notification