1 19 package org.openharmonise.rm.logging; 20 21 22 import java.util.Date ; 23 import java.util.logging.*; 24 import java.util.logging.Level ; 25 26 import org.openharmonise.rm.*; 27 import org.openharmonise.rm.publishing.*; 28 import org.openharmonise.rm.resources.AbstractObject; 29 import org.openharmonise.rm.resources.users.*; 30 import org.openharmonise.rm.sessions.*; 31 32 33 42 public class LogEvent { 43 44 47 protected Session m_session = null; 48 49 52 53 protected User m_user = null; 54 57 58 protected State m_state = null; 59 60 63 protected Object m_eventObj = null; 64 65 68 protected String m_sCommand = null; 69 70 73 protected Date m_timestamp = null; 74 75 78 protected String m_sAdditional = null; 79 80 83 private static final Logger m_logger = Logger.getLogger(LogEvent.class.getName()); 84 85 88 public LogEvent() { 89 super(); 90 m_timestamp = new Date (); 91 } 92 93 98 public Session getSession() { 99 return m_session; 100 } 101 102 107 public State getState() { 108 return m_state; 109 } 110 111 116 public void setSession(Session session) { 117 m_session = session; 118 try { 119 m_user = session.getUser(); 120 } catch (DataAccessException e) { 121 m_logger.log(Level.WARNING, e.getLocalizedMessage(), e); 122 } 123 } 124 125 130 public void setState(State state) throws PopulateException { 131 m_state = state; 132 try { 133 m_session = state.getSession(); 134 } catch (DataAccessException e) { 135 throw new PopulateException("Error getting session",e); 136 } 137 m_user = state.getLoggedInUser(); 138 139 } 140 141 147 public String getLabel() { 148 return m_sCommand; 149 } 150 151 156 public int getObjectId() { 157 int nObjId = -1; 158 159 if(m_eventObj != null && m_eventObj instanceof AbstractObject) { 160 nObjId = ((AbstractObject)m_eventObj).getId(); 161 } 162 163 164 return nObjId; 165 } 166 167 172 public Object getObject() { 173 return m_eventObj; 174 } 175 176 181 public void setLabel(String string) { 182 m_sCommand = string; 183 } 184 185 190 public void setEventObject(Object obj) { 191 m_eventObj = obj; 192 } 193 194 199 public void setUser(User usr) { 200 m_user = usr; 201 } 202 203 208 public User getUser() { 209 return m_user; 210 } 211 212 217 public Date getTimestamp() { 218 return m_timestamp; 219 } 220 221 226 public void addAdditionalInfo(String sAdditional) { 227 m_sAdditional = sAdditional; 228 } 229 230 235 public String getAdditionalInfo() { 236 return m_sAdditional; 237 } 238 } 239 | Popular Tags |