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 BaseRModuleIssueType extends BaseObject 33 implements org.apache.fulcrum.intake.Retrievable 34 { 35 36 private static final RModuleIssueTypePeer peer = 37 new RModuleIssueTypePeer(); 38 39 40 41 private Integer moduleId; 42 43 44 private Integer issueTypeId; 45 46 47 private boolean active = true; 48 49 50 private boolean display = true; 51 52 53 private int order = 0; 54 55 56 private boolean dedupe = true; 57 58 59 private int history = 5; 60 61 62 private int comments = 5; 63 64 65 private String displayName; 66 67 68 private String displayDescription; 69 70 71 76 public Integer getModuleId() 77 { 78 return moduleId; 79 } 80 81 82 87 public void setModuleId(Integer v) throws TorqueException 88 { 89 90 if (!ObjectUtils.equals(this.moduleId, v)) 91 { 92 this.moduleId = v; 93 setModified(true); 94 } 95 96 97 if (aModule != null && !ObjectUtils.equals(aModule.getModuleId(), v)) 98 { 99 aModule = null; 100 } 101 102 103 if (collConditions != null) 105 { 106 for (int i = 0; i < collConditions.size(); i++) 107 { 108 ((Condition) collConditions.get(i)) 109 .setModuleId(v); 110 } 111 } 112 } 113 114 119 public Integer getIssueTypeId() 120 { 121 return issueTypeId; 122 } 123 124 125 130 public void setIssueTypeId(Integer v) throws TorqueException 131 { 132 133 if (!ObjectUtils.equals(this.issueTypeId, v)) 134 { 135 this.issueTypeId = v; 136 setModified(true); 137 } 138 139 140 if (aIssueType != null && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v)) 141 { 142 aIssueType = null; 143 } 144 145 146 if (collConditions != null) 148 { 149 for (int i = 0; i < collConditions.size(); i++) 150 { 151 ((Condition) collConditions.get(i)) 152 .setIssueTypeId(v); 153 } 154 } 155 } 156 157 162 public boolean getActive() 163 { 164 return active; 165 } 166 167 168 173 public void setActive(boolean v) 174 { 175 176 if (this.active != v) 177 { 178 this.active = v; 179 setModified(true); 180 } 181 182 183 } 184 185 190 public boolean getDisplay() 191 { 192 return display; 193 } 194 195 196 201 public void setDisplay(boolean v) 202 { 203 204 if (this.display != v) 205 { 206 this.display = v; 207 setModified(true); 208 } 209 210 211 } 212 213 218 public int getOrder() 219 { 220 return order; 221 } 222 223 224 229 public void setOrder(int v) 230 { 231 232 if (this.order != v) 233 { 234 this.order = v; 235 setModified(true); 236 } 237 238 239 } 240 241 246 public boolean getDedupe() 247 { 248 return dedupe; 249 } 250 251 252 257 public void setDedupe(boolean v) 258 { 259 260 if (this.dedupe != v) 261 { 262 this.dedupe = v; 263 setModified(true); 264 } 265 266 267 } 268 269 274 public int getHistory() 275 { 276 return history; 277 } 278 279 280 285 public void setHistory(int v) 286 { 287 288 if (this.history != v) 289 { 290 this.history = v; 291 setModified(true); 292 } 293 294 295 } 296 297 302 public int getComments() 303 { 304 return comments; 305 } 306 307 308 313 public void setComments(int v) 314 { 315 316 if (this.comments != v) 317 { 318 this.comments = v; 319 setModified(true); 320 } 321 322 323 } 324 325 330 public String getDisplayName() 331 { 332 return displayName; 333 } 334 335 336 341 public void setDisplayName(String v) 342 { 343 344 if (!ObjectUtils.equals(this.displayName, v)) 345 { 346 this.displayName = v; 347 setModified(true); 348 } 349 350 351 } 352 353 358 public String getDisplayDescription() 359 { 360 return displayDescription; 361 } 362 363 364 369 public void setDisplayDescription(String v) 370 { 371 372 if (!ObjectUtils.equals(this.displayDescription, v)) 373 { 374 this.displayDescription = v; 375 setModified(true); 376 } 377 378 379 } 380 381 382 383 384 private Module aModule; 385 386 392 public void setModule(Module v) throws TorqueException 393 { 394 if (v == null) 395 { 396 setModuleId((Integer ) null); 397 } 398 else 399 { 400 setModuleId(v.getModuleId()); 401 } 402 aModule = v; 403 } 404 405 406 412 public Module getModule() throws TorqueException 413 { 414 if ( !ObjectUtils.equals(getModuleId(), null) ) 415 { 416 return ModuleManager.getInstance(SimpleKey.keyFor(getModuleId())); 417 } 418 return aModule; 419 } 420 421 427 public void setModuleKey(ObjectKey key) throws TorqueException 428 { 429 430 setModuleId(new Integer (((NumberKey) key).intValue())); 431 } 432 433 434 435 private IssueType aIssueType; 436 437 443 public void setIssueType(IssueType v) throws TorqueException 444 { 445 if (v == null) 446 { 447 setIssueTypeId((Integer ) null); 448 } 449 else 450 { 451 setIssueTypeId(v.getIssueTypeId()); 452 } 453 aIssueType = v; 454 } 455 456 457 463 public IssueType getIssueType() throws TorqueException 464 { 465 if ( !ObjectUtils.equals(getIssueTypeId(), null) ) 466 { 467 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId())); 468 } 469 return aIssueType; 470 } 471 472 478 public void setIssueTypeKey(ObjectKey key) throws TorqueException 479 { 480 481 setIssueTypeId(new Integer (((NumberKey) key).intValue())); 482 } 483 484 485 486 489 protected List collConditions; 490 491 496 protected void initConditions() 497 { 498 if (collConditions == null) 499 { 500 collConditions = new ArrayList (); 501 } 502 } 503 504 505 512 public void addCondition(Condition l) throws TorqueException 513 { 514 getConditions().add(l); 515 l.setRModuleIssueType((RModuleIssueType)this); 516 } 517 518 521 private Criteria lastConditionsCriteria = null; 522 523 530 public List getConditions() throws TorqueException 531 { 532 if (collConditions == null) 533 { 534 collConditions = getConditions(new Criteria(10)); 535 } 536 return collConditions; 537 } 538 539 550 public List getConditions(Criteria criteria) throws TorqueException 551 { 552 if (collConditions == null) 553 { 554 if (isNew()) 555 { 556 collConditions = new ArrayList (); 557 } 558 else 559 { 560 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 561 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 562 collConditions = ConditionPeer.doSelect(criteria); 563 } 564 } 565 else 566 { 567 if (!isNew()) 569 { 570 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 574 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 575 if (!lastConditionsCriteria.equals(criteria)) 576 { 577 collConditions = ConditionPeer.doSelect(criteria); 578 } 579 } 580 } 581 lastConditionsCriteria = criteria; 582 583 return collConditions; 584 } 585 586 594 public List getConditions(Connection con) throws TorqueException 595 { 596 if (collConditions == null) 597 { 598 collConditions = getConditions(new Criteria(10),con); 599 } 600 return collConditions; 601 } 602 603 615 public List getConditions(Criteria criteria,Connection con) throws TorqueException 616 { 617 if (collConditions == null) 618 { 619 if (isNew()) 620 { 621 collConditions = new ArrayList (); 622 } 623 else 624 { 625 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 626 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 627 collConditions = ConditionPeer.doSelect(criteria,con); 628 } 629 } 630 else 631 { 632 if (!isNew()) 634 { 635 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 639 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 640 if (!lastConditionsCriteria.equals(criteria)) 641 { 642 collConditions = ConditionPeer.doSelect(criteria,con); 643 } 644 } 645 } 646 lastConditionsCriteria = criteria; 647 648 return collConditions; 649 } 650 651 652 653 654 655 656 657 658 659 660 661 672 protected List getConditionsJoinRModuleAttribute(Criteria criteria) 673 throws TorqueException 674 { 675 if (collConditions == null) 676 { 677 if (isNew()) 678 { 679 collConditions = new ArrayList (); 680 } 681 else 682 { 683 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 684 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 685 collConditions = ConditionPeer.doSelectJoinRModuleAttribute(criteria); 686 } 687 } 688 else 689 { 690 694 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 695 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 696 if (!lastConditionsCriteria.equals(criteria)) 697 { 698 collConditions = ConditionPeer.doSelectJoinRModuleAttribute(criteria); 699 } 700 } 701 lastConditionsCriteria = criteria; 702 703 return collConditions; 704 } 705 706 707 708 709 710 711 712 713 714 725 protected List getConditionsJoinTransition(Criteria criteria) 726 throws TorqueException 727 { 728 if (collConditions == null) 729 { 730 if (isNew()) 731 { 732 collConditions = new ArrayList (); 733 } 734 else 735 { 736 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 737 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 738 collConditions = ConditionPeer.doSelectJoinTransition(criteria); 739 } 740 } 741 else 742 { 743 747 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 748 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 749 if (!lastConditionsCriteria.equals(criteria)) 750 { 751 collConditions = ConditionPeer.doSelectJoinTransition(criteria); 752 } 753 } 754 lastConditionsCriteria = criteria; 755 756 return collConditions; 757 } 758 759 760 761 762 763 764 765 766 767 778 protected List getConditionsJoinAttribute(Criteria criteria) 779 throws TorqueException 780 { 781 if (collConditions == null) 782 { 783 if (isNew()) 784 { 785 collConditions = new ArrayList (); 786 } 787 else 788 { 789 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 790 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 791 collConditions = ConditionPeer.doSelectJoinAttribute(criteria); 792 } 793 } 794 else 795 { 796 800 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 801 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 802 if (!lastConditionsCriteria.equals(criteria)) 803 { 804 collConditions = ConditionPeer.doSelectJoinAttribute(criteria); 805 } 806 } 807 lastConditionsCriteria = criteria; 808 809 return collConditions; 810 } 811 812 813 814 815 816 817 818 819 820 831 protected List getConditionsJoinAttributeOption(Criteria criteria) 832 throws TorqueException 833 { 834 if (collConditions == null) 835 { 836 if (isNew()) 837 { 838 collConditions = new ArrayList (); 839 } 840 else 841 { 842 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 843 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 844 collConditions = ConditionPeer.doSelectJoinAttributeOption(criteria); 845 } 846 } 847 else 848 { 849 853 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 854 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 855 if (!lastConditionsCriteria.equals(criteria)) 856 { 857 collConditions = ConditionPeer.doSelectJoinAttributeOption(criteria); 858 } 859 } 860 lastConditionsCriteria = criteria; 861 862 return collConditions; 863 } 864 865 866 867 868 869 870 871 872 873 884 protected List getConditionsJoinRModuleIssueType(Criteria criteria) 885 throws TorqueException 886 { 887 if (collConditions == null) 888 { 889 if (isNew()) 890 { 891 collConditions = new ArrayList (); 892 } 893 else 894 { 895 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 896 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 897 collConditions = ConditionPeer.doSelectJoinRModuleIssueType(criteria); 898 } 899 } 900 else 901 { 902 906 criteria.add(ConditionPeer.MODULE_ID, getModuleId() ); 907 criteria.add(ConditionPeer.ISSUE_TYPE_ID, getIssueTypeId() ); 908 if (!lastConditionsCriteria.equals(criteria)) 909 { 910 collConditions = ConditionPeer.doSelectJoinRModuleIssueType(criteria); 911 } 912 } 913 lastConditionsCriteria = criteria; 914 915 return collConditions; 916 } 917 918 919 920 921 private static List fieldNames = null; 922 923 928 public static synchronized List getFieldNames() 929 { 930 if (fieldNames == null) 931 { 932 fieldNames = new ArrayList (); 933 fieldNames.add("ModuleId"); 934 fieldNames.add("IssueTypeId"); 935 fieldNames.add("Active"); 936 fieldNames.add("Display"); 937 fieldNames.add("Order"); 938 fieldNames.add("Dedupe"); 939 fieldNames.add("History"); 940 fieldNames.add("Comments"); 941 fieldNames.add("DisplayName"); 942 fieldNames.add("DisplayDescription"); 943 fieldNames = Collections.unmodifiableList(fieldNames); 944 } 945 return fieldNames; 946 } 947 948 954 public Object getByName(String name) 955 { 956 if (name.equals("ModuleId")) 957 { 958 return getModuleId(); 959 } 960 if (name.equals("IssueTypeId")) 961 { 962 return getIssueTypeId(); 963 } 964 if (name.equals("Active")) 965 { 966 return Boolean.valueOf(getActive()); 967 } 968 if (name.equals("Display")) 969 { 970 return Boolean.valueOf(getDisplay()); 971 } 972 if (name.equals("Order")) 973 { 974 return new Integer (getOrder()); 975 } 976 if (name.equals("Dedupe")) 977 { 978 return Boolean.valueOf(getDedupe()); 979 } 980 if (name.equals("History")) 981 { 982 return new Integer (getHistory()); 983 } 984 if (name.equals("Comments")) 985 { 986 return new Integer (getComments()); 987 } 988 if (name.equals("DisplayName")) 989 { 990 return getDisplayName(); 991 } 992 if (name.equals("DisplayDescription")) 993 { 994 return getDisplayDescription(); 995 } 996 return null; 997 } 998 999 1007 public Object getByPeerName(String name) 1008 { 1009 if (name.equals(RModuleIssueTypePeer.MODULE_ID)) 1010 { 1011 return getModuleId(); 1012 } 1013 if (name.equals(RModuleIssueTypePeer.ISSUE_TYPE_ID)) 1014 { 1015 return getIssueTypeId(); 1016 } 1017 if (name.equals(RModuleIssueTypePeer.ACTIVE)) 1018 { 1019 return Boolean.valueOf(getActive()); 1020 } 1021 if (name.equals(RModuleIssueTypePeer.DISPLAY)) 1022 { 1023 return Boolean.valueOf(getDisplay()); 1024 } 1025 if (name.equals(RModuleIssueTypePeer.PREFERRED_ORDER)) 1026 { 1027 return new Integer (getOrder()); 1028 } 1029 if (name.equals(RModuleIssueTypePeer.DEDUPE)) 1030 { 1031 return Boolean.valueOf(getDedupe()); 1032 } 1033 if (name.equals(RModuleIssueTypePeer.HISTORY)) 1034 { 1035 return new Integer (getHistory()); 1036 } 1037 if (name.equals(RModuleIssueTypePeer.COMMENTS)) 1038 { 1039 return new Integer (getComments()); 1040 } 1041 if (name.equals(RModuleIssueTypePeer.DISPLAY_NAME)) 1042 { 1043 return getDisplayName(); 1044 } 1045 if (name.equals(RModuleIssueTypePeer.DISPLAY_DESCRIPTION)) 1046 { 1047 return getDisplayDescription(); 1048 } 1049 return null; 1050 } 1051 1052 1059 public Object getByPosition(int pos) 1060 { 1061 if (pos == 0) 1062 { 1063 return getModuleId(); 1064 } 1065 if (pos == 1) 1066 { 1067 return getIssueTypeId(); 1068 } 1069 if (pos == 2) 1070 { 1071 return Boolean.valueOf(getActive()); 1072 } 1073 if (pos == 3) 1074 { 1075 return Boolean.valueOf(getDisplay()); 1076 } 1077 if (pos == 4) 1078 { 1079 return new Integer (getOrder()); 1080 } 1081 if (pos == 5) 1082 { 1083 return Boolean.valueOf(getDedupe()); 1084 } 1085 if (pos == 6) 1086 { 1087 return new Integer (getHistory()); 1088 } 1089 if (pos == 7) 1090 { 1091 return new Integer (getComments()); 1092 } 1093 if (pos == 8) 1094 { 1095 return getDisplayName(); 1096 } 1097 if (pos == 9) 1098 { 1099 return getDisplayDescription(); 1100 } 1101 return null; 1102 } 1103 1104 1110 public void save() throws Exception 1111 { 1112 save(RModuleIssueTypePeer.getMapBuilder() 1113 .getDatabaseMap().getName()); 1114 } 1115 1116 1126 public void save(String dbName) throws TorqueException 1127 { 1128 Connection con = null; 1129 try 1130 { 1131 con = Transaction.begin(dbName); 1132 save(con); 1133 Transaction.commit(con); 1134 } 1135 catch(TorqueException e) 1136 { 1137 Transaction.safeRollback(con); 1138 throw e; 1139 } 1140 } 1141 1142 1144 private boolean alreadyInSave = false; 1145 1155 public void save(Connection con) throws TorqueException 1156 { 1157 if (!alreadyInSave) 1158 { 1159 alreadyInSave = true; 1160 1161 1162 1163 if (isModified()) 1165 { 1166 if (isNew()) 1167 { 1168 RModuleIssueTypePeer.doInsert((RModuleIssueType)this, con); 1169 setNew(false); 1170 } 1171 else 1172 { 1173 RModuleIssueTypePeer.doUpdate((RModuleIssueType)this, con); 1174 } 1175 1176 if (isCacheOnSave()) 1177 { 1178 RModuleIssueTypeManager.putInstance(this); 1179 } 1180 } 1181 1182 1183 if (collConditions != null) 1184 { 1185 for (int i = 0; i < collConditions.size(); i++) 1186 { 1187 ((Condition)collConditions.get(i)).save(con); 1188 } 1189 } 1190 alreadyInSave = false; 1191 } 1192 } 1193 1194 1198 protected boolean isCacheOnSave() 1199 { 1200 return true; 1201 } 1202 1203 1204 1205 private final SimpleKey[] pks = new SimpleKey[2]; 1206 private final ComboKey comboPK = new ComboKey(pks); 1207 1208 1213 public void setPrimaryKey(ObjectKey key) throws TorqueException 1214 { 1215 SimpleKey[] keys = (SimpleKey[]) key.getValue(); 1216 SimpleKey tmpKey = null; 1217 setModuleId(new Integer (((NumberKey)keys[0]).intValue())); 1218 setIssueTypeId(new Integer (((NumberKey)keys[1]).intValue())); 1219 } 1220 1221 1227 public void setPrimaryKey( Integer moduleId, Integer issueTypeId) 1228 throws TorqueException 1229 { 1230 setModuleId(moduleId); 1231 setIssueTypeId(issueTypeId); 1232 } 1233 1234 1237 public void setPrimaryKey(String key) throws TorqueException 1238 { 1239 setPrimaryKey(new ComboKey(key)); 1240 } 1241 1242 1246 public ObjectKey getPrimaryKey() 1247 { 1248 pks[0] = SimpleKey.keyFor(getModuleId()); 1249 pks[1] = SimpleKey.keyFor(getIssueTypeId()); 1250 return comboPK; 1251 } 1252 1253 1257 public String getQueryKey() 1258 { 1259 if (getPrimaryKey() == null) 1260 { 1261 return ""; 1262 } 1263 else 1264 { 1265 return getPrimaryKey().toString(); 1266 } 1267 } 1268 1269 1273 public void setQueryKey(String key) 1274 throws TorqueException 1275 { 1276 setPrimaryKey(key); 1277 } 1278 1279 1285 public RModuleIssueType copy() throws TorqueException 1286 { 1287 RModuleIssueType copyObj = new RModuleIssueType(); 1288 copyObj.setModuleId(moduleId); 1289 copyObj.setIssueTypeId(issueTypeId); 1290 copyObj.setActive(active); 1291 copyObj.setDisplay(display); 1292 copyObj.setOrder(order); 1293 copyObj.setDedupe(dedupe); 1294 copyObj.setHistory(history); 1295 copyObj.setComments(comments); 1296 copyObj.setDisplayName(displayName); 1297 copyObj.setDisplayDescription(displayDescription); 1298 1299 copyObj.setModuleId((Integer )null); 1300 copyObj.setIssueTypeId((Integer )null); 1301 1302 1303 1304 List v = getConditions(); 1305 for (int i = 0; i < v.size(); i++) 1306 { 1307 Condition obj = (Condition) v.get(i); 1308 copyObj.addCondition(obj.copy()); 1309 } 1310 return copyObj; 1311 } 1312 1313 1319 public RModuleIssueTypePeer getPeer() 1320 { 1321 return peer; 1322 } 1323 1324 public String toString() 1325 { 1326 StringBuffer str = new StringBuffer (); 1327 str.append("RModuleIssueType:\n"); 1328 str.append("ModuleId = ") 1329 .append(getModuleId()) 1330 .append("\n"); 1331 str.append("IssueTypeId = ") 1332 .append(getIssueTypeId()) 1333 .append("\n"); 1334 str.append("Active = ") 1335 .append(getActive()) 1336 .append("\n"); 1337 str.append("Display = ") 1338 .append(getDisplay()) 1339 .append("\n"); 1340 str.append("Order = ") 1341 .append(getOrder()) 1342 .append("\n"); 1343 str.append("Dedupe = ") 1344 .append(getDedupe()) 1345 .append("\n"); 1346 str.append("History = ") 1347 .append(getHistory()) 1348 .append("\n"); 1349 str.append("Comments = ") 1350 .append(getComments()) 1351 .append("\n"); 1352 str.append("DisplayName = ") 1353 .append(getDisplayName()) 1354 .append("\n"); 1355 str.append("DisplayDescription = ") 1356 .append(getDisplayDescription()) 1357 .append("\n"); 1358 return(str.toString()); 1359 } 1360} 1361 | Popular Tags |