NAME

NotificationParser - Class to parse a Notifications events from a Notification-class instance.

SYNOPSIS

use Notification;
use NotificationHandler;

my $parser=NotificationParser->new(nottypes=>\%types,db=>$db);

my $not=Notification->new();
my $state=$parser->parse($not);

my $etype=$parser->lastEventType();
my $mtype=$parser->messageType();

DESCRIPTION

Class to parse a Notification class instance's events.

It will go through all events delivered and parse down until it comes to the current state of the Notification. It can also be invoked multiple times if the wish is to monitor the notification.

CONSTRUCTOR

new()

Instantiates the class.

It takes the following parameters:

The nottypes-structure is to be as follows:

nottypes = (
             NOTTYPENAMEa = {
                               votes: SCALAR
                               subject: SCALAR
                            }  
             .
             .
             NOTTYPENAMEn = { ... }
           )

The NOTTYPENAME is the name to tag the Notification type as. It is just a textual string and can be something like "user.create", "dataset.remove" etc. "votes" is the number of votes it takes to agree to the event in question. Most event will just have 0 here, since they require no voting. "subject" is the subject-heading to use when sending notices to the user (some Notice-classes may not support using it). This structure is defined by the user of the NotificationParser-module.

Returns a class instance upon success.

METHODS

parse()

Parses a Notification and delivers its current state to the caller.

The method these parameters in the following order: "notification" and "state".

The "notification" parameter is the Notification-class instance to parse. The "state" is the notifications current state, if any (can be omitted). The "state"-parameter is a HASH-reference.

Upon success, the method will return the current state of the Notification in the format of a HASH-reference. Undef will be returned upon failure.

lastEvent()

Retrieves the latest event that was parsed by this class.

lastEventType()

Retrieve the latest events type (MESSAGE, ACK, ESCALATION etc.)

Accepts no input.

Returns the scalar event type (as defined by $Notification::MESSAGE, $Notification::Ack and so on).

messageType()

Retrieves the message type of the notification that was parsed the last.

Returns the textual message type as a SCALAR.

state()

Returns the current Notification-state.

Returns a HASH-reference to the state.

id()

Returns the id of the last parsed notification.