KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmanage > core > alert > AlertInfo


1 /**
2 * Copyright (c) 2004-2005 jManage.org
3 *
4 * This is a free software; you can redistribute it and/or
5 * modify it under the terms of the license at
6 * http://www.jmanage.org.
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */

14 package org.jmanage.core.alert;
15
16 import org.jmanage.core.management.ObjectNotification;
17 import org.jmanage.core.config.AlertConfig;
18 import org.jmanage.core.config.ApplicationConfig;
19
20 import java.text.SimpleDateFormat JavaDoc;
21
22 /**
23  *
24  * Date: Jul 31, 2005
25  * @author Rakesh Kalra
26  */

27 public class AlertInfo {
28
29     private static final SimpleDateFormat JavaDoc formatter =
30             new SimpleDateFormat JavaDoc("yyyy, MMM dd HH:mm:ss");
31
32     // unique id for the alert
33
private String JavaDoc alertId = null;
34     private String JavaDoc type = null;
35     private long sequenceNumber = 0;
36     private String JavaDoc message = null;
37     private long timeStamp;
38     private Object JavaDoc userData = null;
39     private String JavaDoc objectName = null;
40
41     private String JavaDoc alertConfigId;
42     private String JavaDoc alertName;
43     private String JavaDoc emailAddress;
44
45     private String JavaDoc appId;
46     private String JavaDoc appName;
47
48     public AlertInfo(){}
49
50     public AlertInfo(ObjectNotification notification){
51         // todo: figure out a better way to generate unique alert ids
52
setAlertId(notification.getType() + System.currentTimeMillis());
53         setType(notification.getType());
54         setSequenceNumber(notification.getSequenceNumber());
55         setMessage(notification.getMessage());
56         setTimeStamp(notification.getTimeStamp());
57         setUserData(notification.getUserData());
58     }
59
60     public void setAlertConfig(AlertConfig alertConfig) {
61         this.alertConfigId = alertConfig.getAlertId();
62         this.alertName = alertConfig.getAlertName();
63         this.emailAddress = alertConfig.getEmailAddress();
64         setObjectName(alertConfig.getAlertSourceConfig().getObjectName());
65         ApplicationConfig appConfig =
66                 alertConfig.getAlertSourceConfig().getApplicationConfig();
67         this.setApplicationId(appConfig.getApplicationId());
68         this.setApplicationName(appConfig.getName());
69     }
70
71     public String JavaDoc getAlertId() {
72         return alertId;
73     }
74
75     public void setAlertId(String JavaDoc alertId) {
76         this.alertId = alertId;
77     }
78
79     public String JavaDoc getType() {
80         return type;
81     }
82
83     public void setType(String JavaDoc type) {
84         this.type = type;
85     }
86
87     public long getSequenceNumber() {
88         return sequenceNumber;
89     }
90
91     public void setSequenceNumber(long sequenceNumber) {
92         this.sequenceNumber = sequenceNumber;
93     }
94
95     public String JavaDoc getMessage() {
96         return message;
97     }
98
99     public void setMessage(String JavaDoc message) {
100         this.message = message;
101     }
102
103     public long getTimeStamp() {
104         return timeStamp;
105     }
106
107     public String JavaDoc getFormattedTimeStamp(){
108         return formatter.format(new java.util.Date JavaDoc(timeStamp));
109     }
110
111     public void setTimeStamp(long timeStamp) {
112         this.timeStamp = timeStamp;
113     }
114
115     public Object JavaDoc getUserData() {
116         return userData;
117     }
118
119     public void setUserData(Object JavaDoc userData) {
120         this.userData = userData;
121     }
122
123     public String JavaDoc getObjectName() {
124         return objectName;
125     }
126
127     public void setObjectName(String JavaDoc objectName) {
128         this.objectName = objectName;
129     }
130
131     public String JavaDoc getAlertConfigId() {
132         return alertConfigId;
133     }
134
135     public void setAlertConfigId(String JavaDoc alertConfigId) {
136         this.alertConfigId = alertConfigId;
137     }
138
139     public String JavaDoc getAlertName() {
140         return alertName;
141     }
142
143     public void setAlertName(String JavaDoc alertName) {
144         this.alertName = alertName;
145     }
146
147     public String JavaDoc getEmailAddress() {
148         return emailAddress;
149     }
150
151     public void setEmailAddress(String JavaDoc emailAddress) {
152         this.emailAddress = emailAddress;
153     }
154
155     public String JavaDoc getApplicationId() {
156         return appId;
157     }
158
159     public void setApplicationId(String JavaDoc appId) {
160         this.appId = appId;
161     }
162
163     public String JavaDoc getApplicationName() {
164         return appName;
165     }
166
167     public void setApplicationName(String JavaDoc appName) {
168         this.appName = appName;
169     }
170 }
171
Popular Tags