1 14 package org.compiere.process; 15 16 import java.io.Serializable ; 17 import java.util.*; 18 import java.sql.Timestamp ; 19 import java.math.BigDecimal ; 20 21 import java.text.SimpleDateFormat ; 22 23 import org.compiere.util.DisplayType; 24 import org.compiere.util.Msg; 25 import org.compiere.util.Env; 26 27 33 public class ProcessInfo implements Serializable 34 { 35 41 public ProcessInfo (String Title, int AD_Process_ID, int Record_ID) 42 { 43 setTitle (Title); 44 setAD_Process_ID(AD_Process_ID); 45 setRecord_ID (Record_ID); 46 } 48 49 private String m_Title; 50 51 private int m_AD_Process_ID; 52 53 private int m_Record_ID; 54 55 private Integer m_AD_User_ID; 56 57 private Integer m_AD_Client_ID; 58 59 60 private String m_ClassName; 61 62 63 65 66 private int m_AD_PInstance_ID = 0; 67 68 69 private String m_Summary = ""; 70 71 private boolean m_Error = false; 72 73 74 75 private Serializable m_SerializableObject = null; 76 77 private transient Object m_TransientObject = null; 78 79 private int m_EstSeconds = 5; 80 81 82 private ArrayList m_logs = null; 83 84 85 private ProcessInfoParameter[] m_parameter = null; 86 87 88 92 public String toString() 93 { 94 StringBuffer sb = new StringBuffer ("ProcessInfo["); 95 sb.append(m_Title) 96 .append(",Process_ID=").append(m_AD_Process_ID); 97 if (m_AD_PInstance_ID != 0) 98 sb.append(",AD_PInstance_ID=").append(m_AD_PInstance_ID); 99 if (m_Record_ID != 0) 100 sb.append(",Record_ID=").append(m_Record_ID); 101 sb.append(",Error=").append(isError()); 102 if (m_TransientObject != null) 103 sb.append(",Transient=").append(m_TransientObject); 104 sb.append(",Summary=").append(getSummary()) 105 .append(",Log=").append(m_logs == null ? 0 : m_logs.size()); 106 sb.append("]"); 108 return sb.toString(); 109 } 111 112 113 117 public void setSummary (String translatedSummary) 118 { 119 m_Summary = translatedSummary; 120 } public String getSummary () 122 { 123 return m_Summary; 124 } 126 public void setSummary (String translatedSummary, boolean error) 127 { 128 setSummary (translatedSummary); 129 setError(error); 130 } public void addSummary (String additionalSummary) 132 { 133 m_Summary += additionalSummary; 134 } 136 public void setError (boolean error) 137 { 138 m_Error = error; 139 } public boolean isError () 141 { 142 return m_Error; 143 } 145 155 public String getLogInfo (boolean html) 156 { 157 if (m_logs == null) 158 return ""; 159 StringBuffer sb = new StringBuffer (); 161 SimpleDateFormat dateFormat = DisplayType.getDateFormat(DisplayType.DateTime); 162 if (html) 163 sb.append("<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\">"); 164 for (int i = 0; i < m_logs.size(); i++) 166 { 167 if (html) 168 sb.append("<tr>"); 169 else if (i > 0) 170 sb.append("\n"); 171 ProcessInfoLog log = (ProcessInfoLog)m_logs.get(i); 173 178 if (log.getP_Date() != null) 180 sb.append(html ? "<td>" : "") 181 .append(dateFormat.format(log.getP_Date())) 182 .append(html ? "</td>" : " \t"); 183 if (log.getP_Number() != null) 185 sb.append(html ? "<td>" : "") 186 .append(log.getP_Number()) 187 .append(html ? "</td>" : " \t"); 188 if (log.getP_Msg() != null) 190 sb.append(html ? "<td>" : "") 191 .append(Msg.parseTranslation(Env.getCtx(), log.getP_Msg())) 192 .append(html ? "</td>" : ""); 193 if (html) 195 sb.append("</tr>"); 196 } 197 if (html) 198 sb.append("</table>"); 199 return sb.toString(); 200 } 202 206 public String getLogInfo () 207 { 208 return getLogInfo(false); 209 } 211 public int getAD_PInstance_ID() 212 { 213 return m_AD_PInstance_ID; 214 } 215 public void setAD_PInstance_ID(int AD_PInstance_ID) 216 { 217 m_AD_PInstance_ID = AD_PInstance_ID; 218 } 219 220 public int getAD_Process_ID() 221 { 222 return m_AD_Process_ID; 223 } 224 public void setAD_Process_ID(int AD_Process_ID) 225 { 226 m_AD_Process_ID = AD_Process_ID; 227 } 228 229 public String getClassName() 230 { 231 return m_ClassName; 232 } 233 public void setClassName(String ClassName) 234 { 235 m_ClassName = ClassName; 236 } 237 238 public Object getTransientObject() 239 { 240 return m_TransientObject; 241 } 242 public void setTransientObject (Object TransientObject) 243 { 244 m_TransientObject = TransientObject; 245 } 246 247 public Serializable getSerializableObject() 248 { 249 return m_SerializableObject; 250 } 251 public void setSerializableObject (Serializable SerializableObject) 252 { 253 m_SerializableObject = SerializableObject; 254 } 255 256 public int getEstSeconds() 257 { 258 return m_EstSeconds; 259 } 260 public void setEstSeconds (int EstSeconds) 261 { 262 m_EstSeconds = EstSeconds; 263 } 264 265 public int getRecord_ID() 266 { 267 return m_Record_ID; 268 } 269 public void setRecord_ID(int Record_ID) 270 { 271 m_Record_ID = Record_ID; 272 } 273 274 public String getTitle() 275 { 276 return m_Title; 277 } 278 public void setTitle (String Title) 279 { 280 m_Title = Title; 281 } 283 284 public void setAD_Client_ID (int AD_Client_ID) 285 { 286 m_AD_Client_ID = new Integer (AD_Client_ID); 287 } 288 public Integer getAD_Client_ID() 289 { 290 return m_AD_Client_ID; 291 } 292 293 public void setAD_User_ID (int AD_User_ID) 294 { 295 m_AD_User_ID = new Integer (AD_User_ID); 296 } 297 public Integer getAD_User_ID() 298 { 299 return m_AD_User_ID; 300 } 301 302 303 304 308 public ProcessInfoParameter[] getParameter() 309 { 310 return m_parameter; 311 } 313 317 public void setParameter (ProcessInfoParameter[] parameter) 318 { 319 m_parameter = parameter; 320 } 322 323 324 332 public void addLog (int Log_ID, int P_ID, Timestamp P_Date, BigDecimal P_Number, String P_Msg) 333 { 334 addLog (new ProcessInfoLog (Log_ID, P_ID, P_Date, P_Number, P_Msg)); 335 } 337 344 public void addLog (int P_ID, Timestamp P_Date, BigDecimal P_Number, String P_Msg) 345 { 346 addLog (new ProcessInfoLog (P_ID, P_Date, P_Number, P_Msg)); 347 } 349 353 public void addLog (ProcessInfoLog logEntry) 354 { 355 if (logEntry == null) 356 return; 357 if (m_logs == null) 358 m_logs = new ArrayList(); 359 m_logs.add (logEntry); 360 } 362 363 public ProcessInfoLog[] getLogs() 364 { 365 if (m_logs == null) 366 return null; 367 ProcessInfoLog[] logs = new ProcessInfoLog[m_logs.size()]; 368 m_logs.toArray (logs); 369 return logs; 370 } 372 public int[] getIDs() 373 { 374 if (m_logs == null) 375 return null; 376 int[] ids = new int[m_logs.size()]; 377 for (int i = 0; i < m_logs.size(); i++) 378 ids[i] = ((ProcessInfoLog)m_logs.get(i)).getP_ID(); 379 return ids; 380 } 382 protected ArrayList getLogList() 383 { 384 return m_logs; 385 } 386 protected void setLogList (ArrayList logs) 387 { 388 m_logs = logs; 389 } 390 391 } | Popular Tags |