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 BaseInboxAttachment extends BaseObject 36 implements org.apache.turbine.om.Retrievable 37 { 38 39 private static final InboxAttachmentPeer peer = 40 new InboxAttachmentPeer(); 41 42 43 44 private int inboxAttachmentId; 45 46 47 private int inboxEventId = 1000; 48 49 50 private String contentType; 51 52 53 private String contentDisposition; 54 55 56 private String contentId; 57 58 59 private String fileName; 60 61 62 private String content; 63 64 65 70 public int getInboxAttachmentId() 71 { 72 return inboxAttachmentId; 73 } 74 75 76 81 public void setInboxAttachmentId(int v) 82 { 83 84 if (this.inboxAttachmentId != v) 85 { 86 this.inboxAttachmentId = v; 87 setModified(true); 88 } 89 90 91 } 92 93 98 public int getInboxEventId() 99 { 100 return inboxEventId; 101 } 102 103 104 109 public void setInboxEventId(int v) throws TorqueException 110 { 111 112 if (this.inboxEventId != v) 113 { 114 this.inboxEventId = v; 115 setModified(true); 116 } 117 118 119 if (aInboxEvent != null && !(aInboxEvent.getInboxEventId() == v)) 120 { 121 aInboxEvent = null; 122 } 123 124 } 125 126 131 public String getContentType() 132 { 133 return contentType; 134 } 135 136 137 142 public void setContentType(String v) 143 { 144 145 if (!ObjectUtils.equals(this.contentType, v)) 146 { 147 this.contentType = v; 148 setModified(true); 149 } 150 151 152 } 153 154 159 public String getContentDisposition() 160 { 161 return contentDisposition; 162 } 163 164 165 170 public void setContentDisposition(String v) 171 { 172 173 if (!ObjectUtils.equals(this.contentDisposition, v)) 174 { 175 this.contentDisposition = v; 176 setModified(true); 177 } 178 179 180 } 181 182 187 public String getContentId() 188 { 189 return contentId; 190 } 191 192 193 198 public void setContentId(String v) 199 { 200 201 if (!ObjectUtils.equals(this.contentId, v)) 202 { 203 this.contentId = v; 204 setModified(true); 205 } 206 207 208 } 209 210 215 public String getFileName() 216 { 217 return fileName; 218 } 219 220 221 226 public void setFileName(String v) 227 { 228 229 if (!ObjectUtils.equals(this.fileName, v)) 230 { 231 this.fileName = v; 232 setModified(true); 233 } 234 235 236 } 237 238 243 public String getContent() 244 { 245 return content; 246 } 247 248 249 254 public void setContent(String v) 255 { 256 257 if (!ObjectUtils.equals(this.content, v)) 258 { 259 this.content = v; 260 setModified(true); 261 } 262 263 264 } 265 266 267 268 269 270 private InboxEvent aInboxEvent; 271 272 278 public void setInboxEvent(InboxEvent v) throws TorqueException 279 { 280 if (v == null) 281 { 282 setInboxEventId( 1000); 283 } 284 else 285 { 286 setInboxEventId(v.getInboxEventId()); 287 } 288 aInboxEvent = v; 289 } 290 291 292 298 public InboxEvent getInboxEvent() throws TorqueException 299 { 300 if (aInboxEvent == null && (this.inboxEventId != 0)) 301 { 302 aInboxEvent = InboxEventPeer.retrieveByPK(SimpleKey.keyFor(this.inboxEventId)); 303 304 313 } 314 return aInboxEvent; 315 } 316 317 323 public void setInboxEventKey(ObjectKey key) throws TorqueException 324 { 325 326 setInboxEventId(((NumberKey) key).intValue()); 327 } 328 329 330 private static List fieldNames = null; 331 332 337 public static synchronized List getFieldNames() 338 { 339 if (fieldNames == null) 340 { 341 fieldNames = new ArrayList (); 342 fieldNames.add("InboxAttachmentId"); 343 fieldNames.add("InboxEventId"); 344 fieldNames.add("ContentType"); 345 fieldNames.add("ContentDisposition"); 346 fieldNames.add("ContentId"); 347 fieldNames.add("FileName"); 348 fieldNames.add("Content"); 349 fieldNames = Collections.unmodifiableList(fieldNames); 350 } 351 return fieldNames; 352 } 353 354 360 public Object getByName(String name) 361 { 362 if (name.equals("InboxAttachmentId")) 363 { 364 return new Integer (getInboxAttachmentId()); 365 } 366 if (name.equals("InboxEventId")) 367 { 368 return new Integer (getInboxEventId()); 369 } 370 if (name.equals("ContentType")) 371 { 372 return getContentType(); 373 } 374 if (name.equals("ContentDisposition")) 375 { 376 return getContentDisposition(); 377 } 378 if (name.equals("ContentId")) 379 { 380 return getContentId(); 381 } 382 if (name.equals("FileName")) 383 { 384 return getFileName(); 385 } 386 if (name.equals("Content")) 387 { 388 return getContent(); 389 } 390 return null; 391 } 392 393 401 public Object getByPeerName(String name) 402 { 403 if (name.equals(InboxAttachmentPeer.INBOX_ATTACHMENT_ID)) 404 { 405 return new Integer (getInboxAttachmentId()); 406 } 407 if (name.equals(InboxAttachmentPeer.INBOX_EVENT_ID)) 408 { 409 return new Integer (getInboxEventId()); 410 } 411 if (name.equals(InboxAttachmentPeer.CONTENT_TYPE)) 412 { 413 return getContentType(); 414 } 415 if (name.equals(InboxAttachmentPeer.CONTENT_DISPOSITION)) 416 { 417 return getContentDisposition(); 418 } 419 if (name.equals(InboxAttachmentPeer.CONTENT_ID)) 420 { 421 return getContentId(); 422 } 423 if (name.equals(InboxAttachmentPeer.FILE_NAME)) 424 { 425 return getFileName(); 426 } 427 if (name.equals(InboxAttachmentPeer.CONTENT)) 428 { 429 return getContent(); 430 } 431 return null; 432 } 433 434 441 public Object getByPosition(int pos) 442 { 443 if (pos == 0) 444 { 445 return new Integer (getInboxAttachmentId()); 446 } 447 if (pos == 1) 448 { 449 return new Integer (getInboxEventId()); 450 } 451 if (pos == 2) 452 { 453 return getContentType(); 454 } 455 if (pos == 3) 456 { 457 return getContentDisposition(); 458 } 459 if (pos == 4) 460 { 461 return getContentId(); 462 } 463 if (pos == 5) 464 { 465 return getFileName(); 466 } 467 if (pos == 6) 468 { 469 return getContent(); 470 } 471 return null; 472 } 473 474 480 public void save() throws Exception  481 { 482 save(InboxAttachmentPeer.getMapBuilder() 483 .getDatabaseMap().getName()); 484 } 485 486 496 public void save(String dbName) throws TorqueException 497 { 498 Connection con = null; 499 try 500 { 501 con = Transaction.begin(dbName); 502 save(con); 503 Transaction.commit(con); 504 } 505 catch(TorqueException e) 506 { 507 Transaction.safeRollback(con); 508 throw e; 509 } 510 } 511 512 514 private boolean alreadyInSave = false; 515 525 public void save(Connection con) throws TorqueException 526 { 527 if (!alreadyInSave) 528 { 529 alreadyInSave = true; 530 531 532 533 if (isModified()) 535 { 536 if (isNew()) 537 { 538 InboxAttachmentPeer.doInsert((InboxAttachment) this, con); 539 setNew(false); 540 } 541 else 542 { 543 InboxAttachmentPeer.doUpdate((InboxAttachment) this, con); 544 } 545 } 546 547 alreadyInSave = false; 548 } 549 } 550 551 552 557 public void setPrimaryKey(ObjectKey key) 558 559 { 560 setInboxAttachmentId(((NumberKey) key).intValue()); 561 } 562 563 568 public void setPrimaryKey(String key) 569 { 570 setInboxAttachmentId(Integer.parseInt(key)); 571 } 572 573 574 578 public ObjectKey getPrimaryKey() 579 { 580 return SimpleKey.keyFor(getInboxAttachmentId()); 581 } 582 583 587 public String getQueryKey() 588 { 589 if (getPrimaryKey() == null) 590 { 591 return ""; 592 } 593 else 594 { 595 return getPrimaryKey().toString(); 596 } 597 } 598 599 603 public void setQueryKey(String key) 604 throws TorqueException 605 { 606 setPrimaryKey(key); 607 } 608 609 615 public InboxAttachment copy() throws TorqueException 616 { 617 return copyInto(new InboxAttachment()); 618 } 619 620 protected InboxAttachment copyInto(InboxAttachment copyObj) throws TorqueException 621 { 622 copyObj.setInboxAttachmentId(inboxAttachmentId); 623 copyObj.setInboxEventId(inboxEventId); 624 copyObj.setContentType(contentType); 625 copyObj.setContentDisposition(contentDisposition); 626 copyObj.setContentId(contentId); 627 copyObj.setFileName(fileName); 628 copyObj.setContent(content); 629 630 copyObj.setInboxAttachmentId( 0); 631 632 return copyObj; 633 } 634 635 641 public InboxAttachmentPeer getPeer() 642 { 643 return peer; 644 } 645 646 public String toString() 647 { 648 StringBuffer str = new StringBuffer (); 649 str.append("InboxAttachment:\n"); 650 str.append("InboxAttachmentId = ") 651 .append(getInboxAttachmentId()) 652 .append("\n"); 653 str.append("InboxEventId = ") 654 .append(getInboxEventId()) 655 .append("\n"); 656 str.append("ContentType = ") 657 .append(getContentType()) 658 .append("\n"); 659 str.append("ContentDisposition = ") 660 .append(getContentDisposition()) 661 .append("\n"); 662 str.append("ContentId = ") 663 .append(getContentId()) 664 .append("\n"); 665 str.append("FileName = ") 666 .append(getFileName()) 667 .append("\n"); 668 str.append("Content = ") 669 .append(getContent()) 670 .append("\n"); 671 return(str.toString()); 672 } 673 } 674
| Popular Tags
|