pt.moredata.usernot
Class UserNotification

java.lang.Object
  extended bypt.moredata.usernot.UserNotification

public class UserNotification
extends java.lang.Object

Title: System User Notification

Description: This class implements logic to distribute and store small notifications to system users


 Objectives: - to implement a generic mecanism that allows to warn users of
               events occuring in the system
             - it's main usage will be (for starters) to allow batch programs
               to send info to users

 Usage:
        The simpler way is to invoce the static method notificate(). This
        method will instantiate an UserNotification object and work it out.
        If more than one user is to receive notification then an
        UserNotification object should be instantiated and destination
        users can be added. The word "user" may mean a "group/role" as described
        in the mdmenus data model

 Requisites:
         like the SwingMenu it needs some tables in the database:
              menu_user_role - to decode user name & email
              menu_role_users - to get the list of users in a group
         besides that, it uses it's own table to store the notifications:
              user_notification - the notification data
              user_notification_to - the notification user list & and read control


 create table user_notification (
   notcode serial,
   nottime datetime year to second default current year to second not null,
   whofrom char(20) not null,
   subject char(80) not null,
   body text not null,
   mailer char(30) not null,
   host char(20) not null
 );


 create table user_notification_to (
   notcode serial,
   whoto char(20) not null,
   execution datetime year to second,
   method char(1) check (method in ('M','E','B')),
   emailaddr char(50)
 );

 alter table user_notification_to add constraint primary key (notcode,whoto,emailaddr);

 Bugs:
     - Does not explode group/role into user list
     - If format != TXT should be MIME-aware when composing e-mail
     - DataSimpleMail is too simple and does not allow to compose pretty adresses

 Warning:
     Does not care about transactions. If the connection has transactions, 
     "commit" should be done by the main program
 

Copyright: Copyright (c) 2003

Company: MoreData - Sistemas de Informação, Lda.

Version:
0.1
Author:
ferdez@moredata.pt

Field Summary
static int BROADCAST
          Notification methods: all available methods
static int EMAIL
          Notification methods: E-Mail
static int HIGH
          Notification priorities: high
static int LOW
          Notification priorities: low
static int MENUENTRANCE
          Notification methods: displays on opening the menu
static int NORMAL
          Notification priorities: normal
 
Constructor Summary
UserNotification(java.lang.String user, int method, java.lang.String text, java.lang.String format, java.lang.String mailRelay, java.sql.Connection con)
           
UserNotification(java.lang.String user, int method, java.lang.String subject, java.lang.String text, java.lang.String format, java.lang.String mailRelay, java.sql.Connection con)
           
 
Method Summary
 void addSpecialUser(java.lang.String username, java.lang.String email)
          Adds a special user that is not in the database (e.g. external user)
 void addUser(java.lang.String user)
          Adds user to the notification list
 void flush()
          Go ahead and do it: Send/store the notification
static void main(java.lang.String[] args)
          For tests only
static void notificate(java.lang.String user, int method, java.lang.String subject, java.lang.String text, java.lang.String mailRelay, java.sql.Connection con)
          Static method for fast and simple notification
 void setPriority(int priority)
          Sets the notification priority - not implemented
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMAIL

public static final int EMAIL
Notification methods: E-Mail

See Also:
Constant Field Values

MENUENTRANCE

public static final int MENUENTRANCE
Notification methods: displays on opening the menu

See Also:
Constant Field Values

BROADCAST

public static final int BROADCAST
Notification methods: all available methods

See Also:
Constant Field Values

HIGH

public static final int HIGH
Notification priorities: high

See Also:
Constant Field Values

NORMAL

public static final int NORMAL
Notification priorities: normal

See Also:
Constant Field Values

LOW

public static final int LOW
Notification priorities: low

See Also:
Constant Field Values
Constructor Detail

UserNotification

public UserNotification(java.lang.String user,
                        int method,
                        java.lang.String subject,
                        java.lang.String text,
                        java.lang.String format,
                        java.lang.String mailRelay,
                        java.sql.Connection con)
Parameters:
user -
method -
subject -
text -
format -
mailRelay -
con -

UserNotification

public UserNotification(java.lang.String user,
                        int method,
                        java.lang.String text,
                        java.lang.String format,
                        java.lang.String mailRelay,
                        java.sql.Connection con)
Parameters:
user -
method -
text -
format -
mailRelay -
con -
Method Detail

addUser

public void addUser(java.lang.String user)
Adds user to the notification list

Parameters:
user -

addSpecialUser

public void addSpecialUser(java.lang.String username,
                           java.lang.String email)
Adds a special user that is not in the database (e.g. external user)

Parameters:
username -
email -

setPriority

public void setPriority(int priority)
Sets the notification priority - not implemented

Parameters:
priority -

flush

public void flush()
Go ahead and do it: Send/store the notification


notificate

public static void notificate(java.lang.String user,
                              int method,
                              java.lang.String subject,
                              java.lang.String text,
                              java.lang.String mailRelay,
                              java.sql.Connection con)
Static method for fast and simple notification

Parameters:
user -
method -
subject -
text -
mailRelay -
con -

main

public static void main(java.lang.String[] args)
For tests only

Parameters:
args -