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 29 30 31 35 public abstract class BaseRModuleUserAttribute extends BaseObject 36 implements org.apache.fulcrum.intake.Retrievable 37 { 38 39 private static final RModuleUserAttributePeer peer = 40 new RModuleUserAttributePeer(); 41 42 43 44 private Long rmuaId; 45 46 47 private Long listId; 48 49 50 private Integer moduleId; 51 52 53 private Integer userId; 54 55 56 private Integer issueTypeId; 57 58 59 private Integer attributeId; 60 61 62 private int order = 0; 63 64 65 70 public Long getRmuaId() 71 { 72 return rmuaId; 73 } 74 75 76 81 public void setRmuaId(Long v) 82 { 83 84 if (!ObjectUtils.equals(this.rmuaId, v)) 85 { 86 this.rmuaId = v; 87 setModified(true); 88 } 89 90 91 } 92 93 98 public Long getListId() 99 { 100 return listId; 101 } 102 103 104 109 public void setListId(Long v) throws TorqueException 110 { 111 112 if (!ObjectUtils.equals(this.listId, v)) 113 { 114 this.listId = v; 115 setModified(true); 116 } 117 118 119 if (aMITList != null && !ObjectUtils.equals(aMITList.getListId(), v)) 120 { 121 aMITList = null; 122 } 123 124 } 125 126 131 public Integer getModuleId() 132 { 133 return moduleId; 134 } 135 136 137 142 public void setModuleId(Integer v) throws TorqueException 143 { 144 145 if (!ObjectUtils.equals(this.moduleId, v)) 146 { 147 this.moduleId = v; 148 setModified(true); 149 } 150 151 152 if (aModule != null && !ObjectUtils.equals(aModule.getModuleId(), v)) 153 { 154 aModule = null; 155 } 156 157 } 158 159 164 public Integer getUserId() 165 { 166 return userId; 167 } 168 169 170 175 public void setUserId(Integer v) throws TorqueException 176 { 177 178 if (!ObjectUtils.equals(this.userId, v)) 179 { 180 this.userId = v; 181 setModified(true); 182 } 183 184 185 if (aScarabUser != null && !ObjectUtils.equals(aScarabUser.getUserId(), v)) 186 { 187 aScarabUser = null; 188 } 189 190 } 191 192 197 public Integer getIssueTypeId() 198 { 199 return issueTypeId; 200 } 201 202 203 208 public void setIssueTypeId(Integer v) throws TorqueException 209 { 210 211 if (!ObjectUtils.equals(this.issueTypeId, v)) 212 { 213 this.issueTypeId = v; 214 setModified(true); 215 } 216 217 218 if (aIssueType != null && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v)) 219 { 220 aIssueType = null; 221 } 222 223 } 224 225 230 public Integer getAttributeId() 231 { 232 return attributeId; 233 } 234 235 236 241 public void setAttributeId(Integer v) throws TorqueException 242 { 243 244 if (!ObjectUtils.equals(this.attributeId, v)) 245 { 246 this.attributeId = v; 247 setModified(true); 248 } 249 250 251 if (aAttribute != null && !ObjectUtils.equals(aAttribute.getAttributeId(), v)) 252 { 253 aAttribute = null; 254 } 255 256 } 257 258 263 public int getOrder() 264 { 265 return order; 266 } 267 268 269 274 public void setOrder(int v) 275 { 276 277 if (this.order != v) 278 { 279 this.order = v; 280 setModified(true); 281 } 282 283 284 } 285 286 287 288 289 private MITList aMITList; 290 291 297 public void setMITList(MITList v) throws TorqueException 298 { 299 if (v == null) 300 { 301 setListId((Long ) null); 302 } 303 else 304 { 305 setListId(v.getListId()); 306 } 307 aMITList = v; 308 } 309 310 311 317 public MITList getMITList() throws TorqueException 318 { 319 if ( !ObjectUtils.equals(getListId(), null) ) 320 { 321 return MITListManager.getInstance(SimpleKey.keyFor(getListId())); 322 } 323 return aMITList; 324 } 325 326 332 public void setMITListKey(ObjectKey key) throws TorqueException 333 { 334 335 setListId(new Long (((NumberKey) key).longValue())); 336 } 337 338 339 340 private Module aModule; 341 342 348 public void setModule(Module v) throws TorqueException 349 { 350 if (v == null) 351 { 352 setModuleId((Integer ) null); 353 } 354 else 355 { 356 setModuleId(v.getModuleId()); 357 } 358 aModule = v; 359 } 360 361 362 368 public Module getModule() throws TorqueException 369 { 370 if ( !ObjectUtils.equals(getModuleId(), null) ) 371 { 372 return ModuleManager.getInstance(SimpleKey.keyFor(getModuleId())); 373 } 374 return aModule; 375 } 376 377 383 public void setModuleKey(ObjectKey key) throws TorqueException 384 { 385 386 setModuleId(new Integer (((NumberKey) key).intValue())); 387 } 388 389 390 391 private ScarabUser aScarabUser; 392 393 399 public void setScarabUser(ScarabUser v) throws TorqueException 400 { 401 if (v == null) 402 { 403 setUserId((Integer ) null); 404 } 405 else 406 { 407 setUserId(v.getUserId()); 408 } 409 aScarabUser = v; 410 } 411 412 413 419 public ScarabUser getScarabUser() throws TorqueException 420 { 421 if ( !ObjectUtils.equals(getUserId(), null) ) 422 { 423 return ScarabUserManager.getInstance(SimpleKey.keyFor(getUserId())); 424 } 425 return aScarabUser; 426 } 427 428 434 public void setScarabUserKey(ObjectKey key) throws TorqueException 435 { 436 437 setUserId(new Integer (((NumberKey) key).intValue())); 438 } 439 440 441 442 private IssueType aIssueType; 443 444 450 public void setIssueType(IssueType v) throws TorqueException 451 { 452 if (v == null) 453 { 454 setIssueTypeId((Integer ) null); 455 } 456 else 457 { 458 setIssueTypeId(v.getIssueTypeId()); 459 } 460 aIssueType = v; 461 } 462 463 464 470 public IssueType getIssueType() throws TorqueException 471 { 472 if ( !ObjectUtils.equals(getIssueTypeId(), null) ) 473 { 474 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId())); 475 } 476 return aIssueType; 477 } 478 479 485 public void setIssueTypeKey(ObjectKey key) throws TorqueException 486 { 487 488 setIssueTypeId(new Integer (((NumberKey) key).intValue())); 489 } 490 491 492 493 private Attribute aAttribute; 494 495 501 public void setAttribute(Attribute v) throws TorqueException 502 { 503 if (v == null) 504 { 505 setAttributeId((Integer ) null); 506 } 507 else 508 { 509 setAttributeId(v.getAttributeId()); 510 } 511 aAttribute = v; 512 } 513 514 515 521 public Attribute getAttribute() throws TorqueException 522 { 523 if ( !ObjectUtils.equals(getAttributeId(), null) ) 524 { 525 return AttributeManager.getInstance(SimpleKey.keyFor(getAttributeId())); 526 } 527 return aAttribute; 528 } 529 530 536 public void setAttributeKey(ObjectKey key) throws TorqueException 537 { 538 539 setAttributeId(new Integer (((NumberKey) key).intValue())); 540 } 541 542 543 private static List fieldNames = null; 544 545 550 public static synchronized List getFieldNames() 551 { 552 if (fieldNames == null) 553 { 554 fieldNames = new ArrayList (); 555 fieldNames.add("RmuaId"); 556 fieldNames.add("ListId"); 557 fieldNames.add("ModuleId"); 558 fieldNames.add("UserId"); 559 fieldNames.add("IssueTypeId"); 560 fieldNames.add("AttributeId"); 561 fieldNames.add("Order"); 562 fieldNames = Collections.unmodifiableList(fieldNames); 563 } 564 return fieldNames; 565 } 566 567 573 public Object getByName(String name) 574 { 575 if (name.equals("RmuaId")) 576 { 577 return getRmuaId(); 578 } 579 if (name.equals("ListId")) 580 { 581 return getListId(); 582 } 583 if (name.equals("ModuleId")) 584 { 585 return getModuleId(); 586 } 587 if (name.equals("UserId")) 588 { 589 return getUserId(); 590 } 591 if (name.equals("IssueTypeId")) 592 { 593 return getIssueTypeId(); 594 } 595 if (name.equals("AttributeId")) 596 { 597 return getAttributeId(); 598 } 599 if (name.equals("Order")) 600 { 601 return new Integer (getOrder()); 602 } 603 return null; 604 } 605 606 614 public Object getByPeerName(String name) 615 { 616 if (name.equals(RModuleUserAttributePeer.RMUA_ID)) 617 { 618 return getRmuaId(); 619 } 620 if (name.equals(RModuleUserAttributePeer.LIST_ID)) 621 { 622 return getListId(); 623 } 624 if (name.equals(RModuleUserAttributePeer.MODULE_ID)) 625 { 626 return getModuleId(); 627 } 628 if (name.equals(RModuleUserAttributePeer.USER_ID)) 629 { 630 return getUserId(); 631 } 632 if (name.equals(RModuleUserAttributePeer.ISSUE_TYPE_ID)) 633 { 634 return getIssueTypeId(); 635 } 636 if (name.equals(RModuleUserAttributePeer.ATTRIBUTE_ID)) 637 { 638 return getAttributeId(); 639 } 640 if (name.equals(RModuleUserAttributePeer.PREFERRED_ORDER)) 641 { 642 return new Integer (getOrder()); 643 } 644 return null; 645 } 646 647 654 public Object getByPosition(int pos) 655 { 656 if (pos == 0) 657 { 658 return getRmuaId(); 659 } 660 if (pos == 1) 661 { 662 return getListId(); 663 } 664 if (pos == 2) 665 { 666 return getModuleId(); 667 } 668 if (pos == 3) 669 { 670 return getUserId(); 671 } 672 if (pos == 4) 673 { 674 return getIssueTypeId(); 675 } 676 if (pos == 5) 677 { 678 return getAttributeId(); 679 } 680 if (pos == 6) 681 { 682 return new Integer (getOrder()); 683 } 684 return null; 685 } 686 687 693 public void save() throws Exception 694 { 695 save(RModuleUserAttributePeer.getMapBuilder() 696 .getDatabaseMap().getName()); 697 } 698 699 709 public void save(String dbName) throws TorqueException 710 { 711 Connection con = null; 712 try 713 { 714 con = Transaction.begin(dbName); 715 save(con); 716 Transaction.commit(con); 717 } 718 catch(TorqueException e) 719 { 720 Transaction.safeRollback(con); 721 throw e; 722 } 723 } 724 725 727 private boolean alreadyInSave = false; 728 738 public void save(Connection con) throws TorqueException 739 { 740 if (!alreadyInSave) 741 { 742 alreadyInSave = true; 743 744 745 746 if (isModified()) 748 { 749 if (isNew()) 750 { 751 RModuleUserAttributePeer.doInsert((RModuleUserAttribute)this, con); 752 setNew(false); 753 } 754 else 755 { 756 RModuleUserAttributePeer.doUpdate((RModuleUserAttribute)this, con); 757 } 758 759 if (isCacheOnSave()) 760 { 761 RModuleUserAttributeManager.putInstance(this); 762 } 763 } 764 765 alreadyInSave = false; 766 } 767 } 768 769 773 protected boolean isCacheOnSave() 774 { 775 return true; 776 } 777 778 779 784 public void setPrimaryKey(ObjectKey rmuaId) 785 { 786 setRmuaId(new Long (((NumberKey)rmuaId).longValue())); 787 } 788 789 794 public void setPrimaryKey(String key) 795 { 796 setRmuaId(new Long (key)); 797 } 798 799 800 804 public ObjectKey getPrimaryKey() 805 { 806 return SimpleKey.keyFor(getRmuaId()); 807 } 808 809 813 public String getQueryKey() 814 { 815 if (getPrimaryKey() == null) 816 { 817 return ""; 818 } 819 else 820 { 821 return getPrimaryKey().toString(); 822 } 823 } 824 825 829 public void setQueryKey(String key) 830 throws TorqueException 831 { 832 setPrimaryKey(key); 833 } 834 835 841 public RModuleUserAttribute copy() throws TorqueException 842 { 843 RModuleUserAttribute copyObj = new RModuleUserAttribute(); 844 copyObj.setRmuaId(rmuaId); 845 copyObj.setListId(listId); 846 copyObj.setModuleId(moduleId); 847 copyObj.setUserId(userId); 848 copyObj.setIssueTypeId(issueTypeId); 849 copyObj.setAttributeId(attributeId); 850 copyObj.setOrder(order); 851 852 copyObj.setRmuaId((Long )null); 853 854 return copyObj; 855 } 856 857 863 public RModuleUserAttributePeer getPeer() 864 { 865 return peer; 866 } 867 868 public String toString() 869 { 870 StringBuffer str = new StringBuffer (); 871 str.append("RModuleUserAttribute:\n"); 872 str.append("RmuaId = ") 873 .append(getRmuaId()) 874 .append("\n"); 875 str.append("ListId = ") 876 .append(getListId()) 877 .append("\n"); 878 str.append("ModuleId = ") 879 .append(getModuleId()) 880 .append("\n"); 881 str.append("UserId = ") 882 .append(getUserId()) 883 .append("\n"); 884 str.append("IssueTypeId = ") 885 .append(getIssueTypeId()) 886 .append("\n"); 887 str.append("AttributeId = ") 888 .append(getAttributeId()) 889 .append("\n"); 890 str.append("Order = ") 891 .append(getOrder()) 892 .append("\n"); 893 return(str.toString()); 894 } 895 } 896 | Popular Tags |