|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectpt.moredata.usernot.UserNotification
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.
| 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 |
public static final int EMAIL
public static final int MENUENTRANCE
public static final int BROADCAST
public static final int HIGH
public static final int NORMAL
public static final int LOW
| Constructor Detail |
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)
user - method - subject - text - format - mailRelay - con -
public UserNotification(java.lang.String user,
int method,
java.lang.String text,
java.lang.String format,
java.lang.String mailRelay,
java.sql.Connection con)
user - method - text - format - mailRelay - con - | Method Detail |
public void addUser(java.lang.String user)
user -
public void addSpecialUser(java.lang.String username,
java.lang.String email)
username - email - public void setPriority(int priority)
priority - public void flush()
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)
user - method - subject - text - mailRelay - con - public static void main(java.lang.String[] args)
args -
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||