1 package org.campware.cream.om; 2 3 4 import java.math.BigDecimal ; 5 import java.sql.Connection ; 6 import java.util.ArrayList ; 7 import java.util.Collections ; 8 import java.util.Date ; 9 import java.util.List ; 10 11 import org.apache.commons.lang.ObjectUtils; 12 import org.apache.turbine.om.Retrievable; 13 import org.apache.torque.TorqueException; 14 import org.apache.torque.om.BaseObject; 15 import org.apache.torque.om.ComboKey; 16 import org.apache.torque.om.DateKey; 17 import org.apache.torque.om.NumberKey; 18 import org.apache.torque.om.ObjectKey; 19 import org.apache.torque.om.SimpleKey; 20 import org.apache.torque.om.StringKey; 21 import org.apache.torque.om.Persistent; 22 import org.apache.torque.util.Criteria; 23 import org.apache.torque.util.Transaction; 24 25 26 27 35 public abstract class BaseNotification extends BaseObject 36 implements org.apache.turbine.om.Retrievable 37 { 38 39 private static final NotificationPeer peer = 40 new NotificationPeer(); 41 42 43 44 private int notificationId; 45 46 47 private int notificationType = 10; 48 49 50 private int languageId = 1000; 51 52 53 private int emailFormat = 10; 54 55 56 private String subject; 57 58 59 private String body; 60 61 62 67 public int getNotificationId() 68 { 69 return notificationId; 70 } 71 72 73 78 public void setNotificationId(int v) 79 { 80 81 if (this.notificationId != v) 82 { 83 this.notificationId = v; 84 setModified(true); 85 } 86 87 88 } 89 90 95 public int getNotificationType() 96 { 97 return notificationType; 98 } 99 100 101 106 public void setNotificationType(int v) 107 { 108 109 if (this.notificationType != v) 110 { 111 this.notificationType = v; 112 setModified(true); 113 } 114 115 116 } 117 118 123 public int getLanguageId() 124 { 125 return languageId; 126 } 127 128 129 134 public void setLanguageId(int v) throws TorqueException 135 { 136 137 if (this.languageId != v) 138 { 139 this.languageId = v; 140 setModified(true); 141 } 142 143 144 if (aLanguage != null && !(aLanguage.getLanguageId() == v)) 145 { 146 aLanguage = null; 147 } 148 149 } 150 151 156 public int getEmailFormat() 157 { 158 return emailFormat; 159 } 160 161 162 167 public void setEmailFormat(int v) 168 { 169 170 if (this.emailFormat != v) 171 { 172 this.emailFormat = v; 173 setModified(true); 174 } 175 176 177 } 178 179 184 public String getSubject() 185 { 186 return subject; 187 } 188 189 190 195 public void setSubject(String v) 196 { 197 198 if (!ObjectUtils.equals(this.subject, v)) 199 { 200 this.subject = v; 201 setModified(true); 202 } 203 204 205 } 206 207 212 public String getBody() 213 { 214 return body; 215 } 216 217 218 223 public void setBody(String v) 224 { 225 226 if (!ObjectUtils.equals(this.body, v)) 227 { 228 this.body = v; 229 setModified(true); 230 } 231 232 233 } 234 235 236 237 238 239 private Language aLanguage; 240 241 247 public void setLanguage(Language v) throws TorqueException 248 { 249 if (v == null) 250 { 251 setLanguageId( 1000); 252 } 253 else 254 { 255 setLanguageId(v.getLanguageId()); 256 } 257 aLanguage = v; 258 } 259 260 261 267 public Language getLanguage() throws TorqueException 268 { 269 if (aLanguage == null && (this.languageId != 0)) 270 { 271 aLanguage = LanguagePeer.retrieveByPK(SimpleKey.keyFor(this.languageId)); 272 273 282 } 283 return aLanguage; 284 } 285 286 292 public void setLanguageKey(ObjectKey key) throws TorqueException 293 { 294 295 setLanguageId(((NumberKey) key).intValue()); 296 } 297 298 299 private static List fieldNames = null; 300 301 306 public static synchronized List getFieldNames() 307 { 308 if (fieldNames == null) 309 { 310 fieldNames = new ArrayList (); 311 fieldNames.add("NotificationId"); 312 fieldNames.add("NotificationType"); 313 fieldNames.add("LanguageId"); 314 fieldNames.add("EmailFormat"); 315 fieldNames.add("Subject"); 316 fieldNames.add("Body"); 317 fieldNames = Collections.unmodifiableList(fieldNames); 318 } 319 return fieldNames; 320 } 321 322 328 public Object getByName(String name) 329 { 330 if (name.equals("NotificationId")) 331 { 332 return new Integer (getNotificationId()); 333 } 334 if (name.equals("NotificationType")) 335 { 336 return new Integer (getNotificationType()); 337 } 338 if (name.equals("LanguageId")) 339 { 340 return new Integer (getLanguageId()); 341 } 342 if (name.equals("EmailFormat")) 343 { 344 return new Integer (getEmailFormat()); 345 } 346 if (name.equals("Subject")) 347 { 348 return getSubject(); 349 } 350 if (name.equals("Body")) 351 { 352 return getBody(); 353 } 354 return null; 355 } 356 357 365 public Object getByPeerName(String name) 366 { 367 if (name.equals(NotificationPeer.NOTIFICATION_ID)) 368 { 369 return new Integer (getNotificationId()); 370 } 371 if (name.equals(NotificationPeer.NOTIFICATION_TYPE)) 372 { 373 return new Integer (getNotificationType()); 374 } 375 if (name.equals(NotificationPeer.LANGUAGE_ID)) 376 { 377 return new Integer (getLanguageId()); 378 } 379 if (name.equals(NotificationPeer.EMAIL_FORMAT)) 380 { 381 return new Integer (getEmailFormat()); 382 } 383 if (name.equals(NotificationPeer.SUBJECT)) 384 { 385 return getSubject(); 386 } 387 if (name.equals(NotificationPeer.BODY)) 388 { 389 return getBody(); 390 } 391 return null; 392 } 393 394 401 public Object getByPosition(int pos) 402 { 403 if (pos == 0) 404 { 405 return new Integer (getNotificationId()); 406 } 407 if (pos == 1) 408 { 409 return new Integer (getNotificationType()); 410 } 411 if (pos == 2) 412 { 413 return new Integer (getLanguageId()); 414 } 415 if (pos == 3) 416 { 417 return new Integer (getEmailFormat()); 418 } 419 if (pos == 4) 420 { 421 return getSubject(); 422 } 423 if (pos == 5) 424 { 425 return getBody(); 426 } 427 return null; 428 } 429 430 436 public void save() throws Exception  437 { 438 save(NotificationPeer.getMapBuilder() 439 .getDatabaseMap().getName()); 440 } 441 442 452 public void save(String dbName) throws TorqueException 453 { 454 Connection con = null; 455 try 456 { 457 con = Transaction.begin(dbName); 458 save(con); 459 Transaction.commit(con); 460 } 461 catch(TorqueException e) 462 { 463 Transaction.safeRollback(con); 464 throw e; 465 } 466 } 467 468 470 private boolean alreadyInSave = false; 471 481 public void save(Connection con) throws TorqueException 482 { 483 if (!alreadyInSave) 484 { 485 alreadyInSave = true; 486 487 488 489 if (isModified()) 491 { 492 if (isNew()) 493 { 494 NotificationPeer.doInsert((Notification) this, con); 495 setNew(false); 496 } 497 else 498 { 499 NotificationPeer.doUpdate((Notification) this, con); 500 } 501 } 502 503 alreadyInSave = false; 504 } 505 } 506 507 508 513 public void setPrimaryKey(ObjectKey key) 514 515 { 516 setNotificationId(((NumberKey) key).intValue()); 517 } 518 519 524 public void setPrimaryKey(String key) 525 { 526 setNotificationId(Integer.parseInt(key)); 527 } 528 529 530 534 public ObjectKey getPrimaryKey() 535 { 536 return SimpleKey.keyFor(getNotificationId()); 537 } 538 539 543 public String getQueryKey() 544 { 545 if (getPrimaryKey() == null) 546 { 547 return ""; 548 } 549 else 550 { 551 return getPrimaryKey().toString(); 552 } 553 } 554 555 559 public void setQueryKey(String key) 560 throws TorqueException 561 { 562 setPrimaryKey(key); 563 } 564 565 571 public Notification copy() throws TorqueException 572 { 573 return copyInto(new Notification()); 574 } 575 576 protected Notification copyInto(Notification copyObj) throws TorqueException 577 { 578 copyObj.setNotificationId(notificationId); 579 copyObj.setNotificationType(notificationType); 580 copyObj.setLanguageId(languageId); 581 copyObj.setEmailFormat(emailFormat); 582 copyObj.setSubject(subject); 583 copyObj.setBody(body); 584 585 copyObj.setNotificationId( 0); 586 587 return copyObj; 588 } 589 590 596 public NotificationPeer getPeer() 597 { 598 return peer; 599 } 600 601 public String toString() 602 { 603 StringBuffer str = new StringBuffer (); 604 str.append("Notification:\n"); 605 str.append("NotificationId = ") 606 .append(getNotificationId()) 607 .append("\n"); 608 str.append("NotificationType = ") 609 .append(getNotificationType()) 610 .append("\n"); 611 str.append("LanguageId = ") 612 .append(getLanguageId()) 613 .append("\n"); 614 str.append("EmailFormat = ") 615 .append(getEmailFormat()) 616 .append("\n"); 617 str.append("Subject = ") 618 .append(getSubject()) 619 .append("\n"); 620 str.append("Body = ") 621 .append(getBody()) 622 .append("\n"); 623 return(str.toString()); 624 } 625 } 626
| Popular Tags
|