1 package org.tigris.scarab.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.fulcrum.intake.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 28 32 public abstract class BaseRIssueTypeAttribute extends BaseObject 33 implements org.apache.fulcrum.intake.Retrievable 34 { 35 36 private static final RIssueTypeAttributePeer peer = 37 new RIssueTypeAttributePeer(); 38 39 40 41 private Integer attributeId; 42 43 44 private Integer issueTypeId; 45 46 47 private boolean active = true; 48 49 50 private boolean required = false; 51 52 53 private int order = 0; 54 55 56 private boolean quickSearch = false; 57 58 59 private boolean defaultTextFlag = false; 60 61 62 private boolean locked = false; 63 64 65 70 public Integer getAttributeId() 71 { 72 return attributeId; 73 } 74 75 76 81 public void setAttributeId(Integer v) throws TorqueException 82 { 83 84 if (!ObjectUtils.equals(this.attributeId, v)) 85 { 86 this.attributeId = v; 87 setModified(true); 88 } 89 90 91 if (aAttribute != null && !ObjectUtils.equals(aAttribute.getAttributeId(), v)) 92 { 93 aAttribute = null; 94 } 95 96 } 97 98 103 public Integer getIssueTypeId() 104 { 105 return issueTypeId; 106 } 107 108 109 114 public void setIssueTypeId(Integer v) throws TorqueException 115 { 116 117 if (!ObjectUtils.equals(this.issueTypeId, v)) 118 { 119 this.issueTypeId = v; 120 setModified(true); 121 } 122 123 124 if (aIssueType != null && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v)) 125 { 126 aIssueType = null; 127 } 128 129 } 130 131 136 public boolean getActive() 137 { 138 return active; 139 } 140 141 142 147 public void setActive(boolean v) 148 { 149 150 if (this.active != v) 151 { 152 this.active = v; 153 setModified(true); 154 } 155 156 157 } 158 159 164 public boolean getRequired() 165 { 166 return required; 167 } 168 169 170 175 public void setRequired(boolean v) 176 { 177 178 if (this.required != v) 179 { 180 this.required = v; 181 setModified(true); 182 } 183 184 185 } 186 187 192 public int getOrder() 193 { 194 return order; 195 } 196 197 198 203 public void setOrder(int v) 204 { 205 206 if (this.order != v) 207 { 208 this.order = v; 209 setModified(true); 210 } 211 212 213 } 214 215 220 public boolean getQuickSearch() 221 { 222 return quickSearch; 223 } 224 225 226 231 public void setQuickSearch(boolean v) 232 { 233 234 if (this.quickSearch != v) 235 { 236 this.quickSearch = v; 237 setModified(true); 238 } 239 240 241 } 242 243 248 public boolean getDefaultTextFlag() 249 { 250 return defaultTextFlag; 251 } 252 253 254 259 public void setDefaultTextFlag(boolean v) 260 { 261 262 if (this.defaultTextFlag != v) 263 { 264 this.defaultTextFlag = v; 265 setModified(true); 266 } 267 268 269 } 270 271 276 public boolean getLocked() 277 { 278 return locked; 279 } 280 281 282 287 public void setLocked(boolean v) 288 { 289 290 if (this.locked != v) 291 { 292 this.locked = v; 293 setModified(true); 294 } 295 296 297 } 298 299 300 301 302 private Attribute aAttribute; 303 304 310 public void setAttribute(Attribute v) throws TorqueException 311 { 312 if (v == null) 313 { 314 setAttributeId((Integer ) null); 315 } 316 else 317 { 318 setAttributeId(v.getAttributeId()); 319 } 320 aAttribute = v; 321 } 322 323 324 330 public Attribute getAttribute() throws TorqueException 331 { 332 if ( !ObjectUtils.equals(getAttributeId(), null) ) 333 { 334 return AttributeManager.getInstance(SimpleKey.keyFor(getAttributeId())); 335 } 336 return aAttribute; 337 } 338 339 345 public void setAttributeKey(ObjectKey key) throws TorqueException 346 { 347 348 setAttributeId(new Integer (((NumberKey) key).intValue())); 349 } 350 351 352 353 private IssueType aIssueType; 354 355 361 public void setIssueType(IssueType v) throws TorqueException 362 { 363 if (v == null) 364 { 365 setIssueTypeId((Integer ) null); 366 } 367 else 368 { 369 setIssueTypeId(v.getIssueTypeId()); 370 } 371 aIssueType = v; 372 } 373 374 375 381 public IssueType getIssueType() throws TorqueException 382 { 383 if ( !ObjectUtils.equals(getIssueTypeId(), null) ) 384 { 385 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId())); 386 } 387 return aIssueType; 388 } 389 390 396 public void setIssueTypeKey(ObjectKey key) throws TorqueException 397 { 398 399 setIssueTypeId(new Integer (((NumberKey) key).intValue())); 400 } 401 402 403 private static List fieldNames = null; 404 405 410 public static synchronized List getFieldNames() 411 { 412 if (fieldNames == null) 413 { 414 fieldNames = new ArrayList (); 415 fieldNames.add("AttributeId"); 416 fieldNames.add("IssueTypeId"); 417 fieldNames.add("Active"); 418 fieldNames.add("Required"); 419 fieldNames.add("Order"); 420 fieldNames.add("QuickSearch"); 421 fieldNames.add("DefaultTextFlag"); 422 fieldNames.add("Locked"); 423 fieldNames = Collections.unmodifiableList(fieldNames); 424 } 425 return fieldNames; 426 } 427 428 434 public Object getByName(String name) 435 { 436 if (name.equals("AttributeId")) 437 { 438 return getAttributeId(); 439 } 440 if (name.equals("IssueTypeId")) 441 { 442 return getIssueTypeId(); 443 } 444 if (name.equals("Active")) 445 { 446 return Boolean.valueOf(getActive()); 447 } 448 if (name.equals("Required")) 449 { 450 return Boolean.valueOf(getRequired()); 451 } 452 if (name.equals("Order")) 453 { 454 return new Integer (getOrder()); 455 } 456 if (name.equals("QuickSearch")) 457 { 458 return Boolean.valueOf(getQuickSearch()); 459 } 460 if (name.equals("DefaultTextFlag")) 461 { 462 return Boolean.valueOf(getDefaultTextFlag()); 463 } 464 if (name.equals("Locked")) 465 { 466 return Boolean.valueOf(getLocked()); 467 } 468 return null; 469 } 470 471 479 public Object getByPeerName(String name) 480 { 481 if (name.equals(RIssueTypeAttributePeer.ATTRIBUTE_ID)) 482 { 483 return getAttributeId(); 484 } 485 if (name.equals(RIssueTypeAttributePeer.ISSUE_TYPE_ID)) 486 { 487 return getIssueTypeId(); 488 } 489 if (name.equals(RIssueTypeAttributePeer.ACTIVE)) 490 { 491 return Boolean.valueOf(getActive()); 492 } 493 if (name.equals(RIssueTypeAttributePeer.REQUIRED)) 494 { 495 return Boolean.valueOf(getRequired()); 496 } 497 if (name.equals(RIssueTypeAttributePeer.PREFERRED_ORDER)) 498 { 499 return new Integer (getOrder()); 500 } 501 if (name.equals(RIssueTypeAttributePeer.QUICK_SEARCH)) 502 { 503 return Boolean.valueOf(getQuickSearch()); 504 } 505 if (name.equals(RIssueTypeAttributePeer.DEFAULT_TEXT_FLAG)) 506 { 507 return Boolean.valueOf(getDefaultTextFlag()); 508 } 509 if (name.equals(RIssueTypeAttributePeer.LOCKED)) 510 { 511 return Boolean.valueOf(getLocked()); 512 } 513 return null; 514 } 515 516 523 public Object getByPosition(int pos) 524 { 525 if (pos == 0) 526 { 527 return getAttributeId(); 528 } 529 if (pos == 1) 530 { 531 return getIssueTypeId(); 532 } 533 if (pos == 2) 534 { 535 return Boolean.valueOf(getActive()); 536 } 537 if (pos == 3) 538 { 539 return Boolean.valueOf(getRequired()); 540 } 541 if (pos == 4) 542 { 543 return new Integer (getOrder()); 544 } 545 if (pos == 5) 546 { 547 return Boolean.valueOf(getQuickSearch()); 548 } 549 if (pos == 6) 550 { 551 return Boolean.valueOf(getDefaultTextFlag()); 552 } 553 if (pos == 7) 554 { 555 return Boolean.valueOf(getLocked()); 556 } 557 return null; 558 } 559 560 566 public void save() throws Exception 567 { 568 save(RIssueTypeAttributePeer.getMapBuilder() 569 .getDatabaseMap().getName()); 570 } 571 572 582 public void save(String dbName) throws TorqueException 583 { 584 Connection con = null; 585 try 586 { 587 con = Transaction.begin(dbName); 588 save(con); 589 Transaction.commit(con); 590 } 591 catch(TorqueException e) 592 { 593 Transaction.safeRollback(con); 594 throw e; 595 } 596 } 597 598 600 private boolean alreadyInSave = false; 601 611 public void save(Connection con) throws TorqueException 612 { 613 if (!alreadyInSave) 614 { 615 alreadyInSave = true; 616 617 618 619 if (isModified()) 621 { 622 if (isNew()) 623 { 624 RIssueTypeAttributePeer.doInsert((RIssueTypeAttribute)this, con); 625 setNew(false); 626 } 627 else 628 { 629 RIssueTypeAttributePeer.doUpdate((RIssueTypeAttribute)this, con); 630 } 631 632 if (isCacheOnSave()) 633 { 634 RIssueTypeAttributeManager.putInstance(this); 635 } 636 } 637 638 alreadyInSave = false; 639 } 640 } 641 642 646 protected boolean isCacheOnSave() 647 { 648 return true; 649 } 650 651 652 653 private final SimpleKey[] pks = new SimpleKey[2]; 654 private final ComboKey comboPK = new ComboKey(pks); 655 656 661 public void setPrimaryKey(ObjectKey key) throws TorqueException 662 { 663 SimpleKey[] keys = (SimpleKey[]) key.getValue(); 664 SimpleKey tmpKey = null; 665 setAttributeId(new Integer (((NumberKey)keys[0]).intValue())); 666 setIssueTypeId(new Integer (((NumberKey)keys[1]).intValue())); 667 } 668 669 675 public void setPrimaryKey( Integer attributeId, Integer issueTypeId) 676 throws TorqueException 677 { 678 setAttributeId(attributeId); 679 setIssueTypeId(issueTypeId); 680 } 681 682 685 public void setPrimaryKey(String key) throws TorqueException 686 { 687 setPrimaryKey(new ComboKey(key)); 688 } 689 690 694 public ObjectKey getPrimaryKey() 695 { 696 pks[0] = SimpleKey.keyFor(getAttributeId()); 697 pks[1] = SimpleKey.keyFor(getIssueTypeId()); 698 return comboPK; 699 } 700 701 705 public String getQueryKey() 706 { 707 if (getPrimaryKey() == null) 708 { 709 return ""; 710 } 711 else 712 { 713 return getPrimaryKey().toString(); 714 } 715 } 716 717 721 public void setQueryKey(String key) 722 throws TorqueException 723 { 724 setPrimaryKey(key); 725 } 726 727 733 public RIssueTypeAttribute copy() throws TorqueException 734 { 735 RIssueTypeAttribute copyObj = new RIssueTypeAttribute(); 736 copyObj.setAttributeId(attributeId); 737 copyObj.setIssueTypeId(issueTypeId); 738 copyObj.setActive(active); 739 copyObj.setRequired(required); 740 copyObj.setOrder(order); 741 copyObj.setQuickSearch(quickSearch); 742 copyObj.setDefaultTextFlag(defaultTextFlag); 743 copyObj.setLocked(locked); 744 745 copyObj.setAttributeId((Integer )null); 746 copyObj.setIssueTypeId((Integer )null); 747 748 return copyObj; 749 } 750 751 757 public RIssueTypeAttributePeer getPeer() 758 { 759 return peer; 760 } 761 762 public String toString() 763 { 764 StringBuffer str = new StringBuffer (); 765 str.append("RIssueTypeAttribute:\n"); 766 str.append("AttributeId = ") 767 .append(getAttributeId()) 768 .append("\n"); 769 str.append("IssueTypeId = ") 770 .append(getIssueTypeId()) 771 .append("\n"); 772 str.append("Active = ") 773 .append(getActive()) 774 .append("\n"); 775 str.append("Required = ") 776 .append(getRequired()) 777 .append("\n"); 778 str.append("Order = ") 779 .append(getOrder()) 780 .append("\n"); 781 str.append("QuickSearch = ") 782 .append(getQuickSearch()) 783 .append("\n"); 784 str.append("DefaultTextFlag = ") 785 .append(getDefaultTextFlag()) 786 .append("\n"); 787 str.append("Locked = ") 788 .append(getLocked()) 789 .append("\n"); 790 return(str.toString()); 791 } 792 } 793 | Popular Tags |