1 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 ; 21 22 27 public class AlertInfo { 28 29 private static final SimpleDateFormat formatter = 30 new SimpleDateFormat ("yyyy, MMM dd HH:mm:ss"); 31 32 private String alertId = null; 34 private String type = null; 35 private long sequenceNumber = 0; 36 private String message = null; 37 private long timeStamp; 38 private Object userData = null; 39 private String objectName = null; 40 41 private String alertConfigId; 42 private String alertName; 43 private String emailAddress; 44 45 private String appId; 46 private String appName; 47 48 public AlertInfo(){} 49 50 public AlertInfo(ObjectNotification notification){ 51 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 getAlertId() { 72 return alertId; 73 } 74 75 public void setAlertId(String alertId) { 76 this.alertId = alertId; 77 } 78 79 public String getType() { 80 return type; 81 } 82 83 public void setType(String 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 getMessage() { 96 return message; 97 } 98 99 public void setMessage(String message) { 100 this.message = message; 101 } 102 103 public long getTimeStamp() { 104 return timeStamp; 105 } 106 107 public String getFormattedTimeStamp(){ 108 return formatter.format(new java.util.Date (timeStamp)); 109 } 110 111 public void setTimeStamp(long timeStamp) { 112 this.timeStamp = timeStamp; 113 } 114 115 public Object getUserData() { 116 return userData; 117 } 118 119 public void setUserData(Object userData) { 120 this.userData = userData; 121 } 122 123 public String getObjectName() { 124 return objectName; 125 } 126 127 public void setObjectName(String objectName) { 128 this.objectName = objectName; 129 } 130 131 public String getAlertConfigId() { 132 return alertConfigId; 133 } 134 135 public void setAlertConfigId(String alertConfigId) { 136 this.alertConfigId = alertConfigId; 137 } 138 139 public String getAlertName() { 140 return alertName; 141 } 142 143 public void setAlertName(String alertName) { 144 this.alertName = alertName; 145 } 146 147 public String getEmailAddress() { 148 return emailAddress; 149 } 150 151 public void setEmailAddress(String emailAddress) { 152 this.emailAddress = emailAddress; 153 } 154 155 public String getApplicationId() { 156 return appId; 157 } 158 159 public void setApplicationId(String appId) { 160 this.appId = appId; 161 } 162 163 public String getApplicationName() { 164 return appName; 165 } 166 167 public void setApplicationName(String appName) { 168 this.appName = appName; 169 } 170 } 171 | Popular Tags |