1 64 65 70 package com.jcorporate.expresso.services.dbobj; 71 72 import com.jcorporate.expresso.core.db.DBException; 73 import com.jcorporate.expresso.core.dbobj.RequestContext; 74 import com.jcorporate.expresso.core.dbobj.SecuredDBObject; 75 import com.jcorporate.expresso.core.misc.DateTime; 76 77 78 85 public class LogEntry 86 extends SecuredDBObject { 87 90 public LogEntry() 91 throws DBException { 92 super(); 93 } 94 95 96 100 public LogEntry(int uid) 101 throws DBException { 102 super(uid); 103 } 104 105 112 public LogEntry(RequestContext request) 113 throws DBException { 114 super(request); 115 } 116 117 121 public void add() 122 throws DBException { 123 if (getField("LogTime").equals("")) { 124 setTimeStamp(); 125 } 126 if (getField("MessageLevel").equals("")) { 127 setField("MessageLevel", "0"); 128 } 129 if (getField("JobNumber").equals("")) { 130 setField("JobNumber", "none"); 131 } 132 if (getField("ObjectName").equals("")) { 133 setField("ObjectName", "unknown"); 134 } 135 if (getField("ExpUid").equals("")) { 136 setField("ExpUid", SecuredDBObject.SYSTEM_ACCOUNT); 137 } 138 if (getField("MessageText").equals("")) { 139 setField("MessageText", "No Message"); 140 } 141 142 setField("MessageId", 143 ("" + (Math.round(Math.random() * 1000)))); 144 super.add(); 145 } 146 147 148 151 public void setTimeStamp() 152 throws DBException { 153 setField("LogTime", DateTime.getDateTimeForDB(this.getDataContext())); 154 } 155 156 157 162 public void setupFields() 163 throws DBException { 164 setTargetTable("SYSLOG"); 165 setDescription("DBsyslog"); 166 setCharset("ISO-8859-1"); 167 addField("LogTime", "datetime", 0, false, "dateTime"); 168 addField("MessageText", "text", 0, false, "message"); 169 addField("ObjectName", "varchar", 128, false, "object"); 170 addField("MessageId", "int", 0, false, "messageId"); 171 addField("ExpUid", "int", 0, false, "userId"); 172 addField("JobNumber", "varchar", 80, false, "Job"); 173 addField("MessageLevel", "int", 0, false, "Message Level"); 174 addField("MessageColor", "char", 1, true, "Message Color"); 175 addField("LogChannel", "varchar", 80, true, "Logging Channel"); 176 setStringFilter("MessageText", "rawFilter"); 177 setStringFilter("ObjectName", "stripFilter"); 178 setStringFilter("JobNumber", "rawFilter"); 179 setStringFilter("LogChannel", "rawFilter"); 180 addKey("LogTime"); 181 addKey("ObjectName"); 182 addKey("MessageId"); 183 setReadOnly("LogTime"); 184 } 185 186 187 } 188 | Popular Tags |