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 31 public abstract class BaseMITList extends BaseObject 32 implements org.apache.fulcrum.intake.Retrievable 33 { 34 35 private static final MITListPeer peer = 36 new MITListPeer(); 37 38 39 40 private Long listId; 41 42 43 private String name; 44 45 46 private boolean active = true; 47 48 49 private boolean modifiable = true; 50 51 52 private Integer userId; 53 54 55 60 public Long getListId() 61 { 62 return listId; 63 } 64 65 66 71 public void setListId(Long v) throws TorqueException 72 { 73 74 if (!ObjectUtils.equals(this.listId, v)) 75 { 76 this.listId = v; 77 setModified(true); 78 } 79 80 81 82 if (collMITListItems != null) 84 { 85 for (int i = 0; i < collMITListItems.size(); i++) 86 { 87 ((MITListItem) collMITListItems.get(i)) 88 .setListId(v); 89 } 90 } 91 92 if (collRModuleUserAttributes != null) 94 { 95 for (int i = 0; i < collRModuleUserAttributes.size(); i++) 96 { 97 ((RModuleUserAttribute) collRModuleUserAttributes.get(i)) 98 .setListId(v); 99 } 100 } 101 102 if (collQuerys != null) 104 { 105 for (int i = 0; i < collQuerys.size(); i++) 106 { 107 ((Query) collQuerys.get(i)) 108 .setListId(v); 109 } 110 } 111 } 112 113 118 public String getName() 119 { 120 return name; 121 } 122 123 124 129 public void setName(String v) 130 { 131 132 if (!ObjectUtils.equals(this.name, v)) 133 { 134 this.name = v; 135 setModified(true); 136 } 137 138 139 } 140 141 146 public boolean getActive() 147 { 148 return active; 149 } 150 151 152 157 public void setActive(boolean v) 158 { 159 160 if (this.active != v) 161 { 162 this.active = v; 163 setModified(true); 164 } 165 166 167 } 168 169 174 public boolean getModifiable() 175 { 176 return modifiable; 177 } 178 179 180 185 public void setModifiable(boolean v) 186 { 187 188 if (this.modifiable != v) 189 { 190 this.modifiable = v; 191 setModified(true); 192 } 193 194 195 } 196 197 202 public Integer getUserId() 203 { 204 return userId; 205 } 206 207 208 213 public void setUserId(Integer v) throws TorqueException 214 { 215 216 if (!ObjectUtils.equals(this.userId, v)) 217 { 218 this.userId = v; 219 setModified(true); 220 } 221 222 223 if (aScarabUser != null && !ObjectUtils.equals(aScarabUser.getUserId(), v)) 224 { 225 aScarabUser = null; 226 } 227 228 } 229 230 231 232 233 private ScarabUser aScarabUser; 234 235 241 public void setScarabUser(ScarabUser v) throws TorqueException 242 { 243 if (v == null) 244 { 245 setUserId((Integer ) null); 246 } 247 else 248 { 249 setUserId(v.getUserId()); 250 } 251 aScarabUser = v; 252 } 253 254 255 261 public ScarabUser getScarabUser() throws TorqueException 262 { 263 if ( !ObjectUtils.equals(getUserId(), null) ) 264 { 265 return ScarabUserManager.getInstance(SimpleKey.keyFor(getUserId())); 266 } 267 return aScarabUser; 268 } 269 270 276 public void setScarabUserKey(ObjectKey key) throws TorqueException 277 { 278 279 setUserId(new Integer (((NumberKey) key).intValue())); 280 } 281 282 283 284 287 protected List collMITListItems; 288 289 294 protected void initMITListItems() 295 { 296 if (collMITListItems == null) 297 { 298 collMITListItems = new ArrayList (); 299 } 300 } 301 302 303 310 public void addMITListItem(MITListItem l) throws TorqueException 311 { 312 getMITListItems().add(l); 313 l.setMITList((MITList)this); 314 } 315 316 319 private Criteria lastMITListItemsCriteria = null; 320 321 328 public List getMITListItems() throws TorqueException 329 { 330 if (collMITListItems == null) 331 { 332 collMITListItems = getMITListItems(new Criteria(10)); 333 } 334 return collMITListItems; 335 } 336 337 348 public List getMITListItems(Criteria criteria) throws TorqueException 349 { 350 if (collMITListItems == null) 351 { 352 if (isNew()) 353 { 354 collMITListItems = new ArrayList (); 355 } 356 else 357 { 358 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 359 collMITListItems = MITListItemPeer.doSelect(criteria); 360 } 361 } 362 else 363 { 364 if (!isNew()) 366 { 367 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 371 if (!lastMITListItemsCriteria.equals(criteria)) 372 { 373 collMITListItems = MITListItemPeer.doSelect(criteria); 374 } 375 } 376 } 377 lastMITListItemsCriteria = criteria; 378 379 return collMITListItems; 380 } 381 382 390 public List getMITListItems(Connection con) throws TorqueException 391 { 392 if (collMITListItems == null) 393 { 394 collMITListItems = getMITListItems(new Criteria(10),con); 395 } 396 return collMITListItems; 397 } 398 399 411 public List getMITListItems(Criteria criteria,Connection con) throws TorqueException 412 { 413 if (collMITListItems == null) 414 { 415 if (isNew()) 416 { 417 collMITListItems = new ArrayList (); 418 } 419 else 420 { 421 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 422 collMITListItems = MITListItemPeer.doSelect(criteria,con); 423 } 424 } 425 else 426 { 427 if (!isNew()) 429 { 430 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 434 if (!lastMITListItemsCriteria.equals(criteria)) 435 { 436 collMITListItems = MITListItemPeer.doSelect(criteria,con); 437 } 438 } 439 } 440 lastMITListItemsCriteria = criteria; 441 442 return collMITListItems; 443 } 444 445 446 447 448 449 450 451 452 453 454 455 466 protected List getMITListItemsJoinMITList(Criteria criteria) 467 throws TorqueException 468 { 469 if (collMITListItems == null) 470 { 471 if (isNew()) 472 { 473 collMITListItems = new ArrayList (); 474 } 475 else 476 { 477 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 478 collMITListItems = MITListItemPeer.doSelectJoinMITList(criteria); 479 } 480 } 481 else 482 { 483 487 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 488 if (!lastMITListItemsCriteria.equals(criteria)) 489 { 490 collMITListItems = MITListItemPeer.doSelectJoinMITList(criteria); 491 } 492 } 493 lastMITListItemsCriteria = criteria; 494 495 return collMITListItems; 496 } 497 498 499 500 501 502 503 504 505 506 517 protected List getMITListItemsJoinScarabModule(Criteria criteria) 518 throws TorqueException 519 { 520 if (collMITListItems == null) 521 { 522 if (isNew()) 523 { 524 collMITListItems = new ArrayList (); 525 } 526 else 527 { 528 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 529 collMITListItems = MITListItemPeer.doSelectJoinScarabModule(criteria); 530 } 531 } 532 else 533 { 534 538 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 539 if (!lastMITListItemsCriteria.equals(criteria)) 540 { 541 collMITListItems = MITListItemPeer.doSelectJoinScarabModule(criteria); 542 } 543 } 544 lastMITListItemsCriteria = criteria; 545 546 return collMITListItems; 547 } 548 549 550 551 552 553 554 555 556 557 568 protected List getMITListItemsJoinIssueType(Criteria criteria) 569 throws TorqueException 570 { 571 if (collMITListItems == null) 572 { 573 if (isNew()) 574 { 575 collMITListItems = new ArrayList (); 576 } 577 else 578 { 579 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 580 collMITListItems = MITListItemPeer.doSelectJoinIssueType(criteria); 581 } 582 } 583 else 584 { 585 589 criteria.add(MITListItemPeer.LIST_ID, getListId() ); 590 if (!lastMITListItemsCriteria.equals(criteria)) 591 { 592 collMITListItems = MITListItemPeer.doSelectJoinIssueType(criteria); 593 } 594 } 595 lastMITListItemsCriteria = criteria; 596 597 return collMITListItems; 598 } 599 600 601 602 603 604 607 protected List collRModuleUserAttributes; 608 609 614 protected void initRModuleUserAttributes() 615 { 616 if (collRModuleUserAttributes == null) 617 { 618 collRModuleUserAttributes = new ArrayList (); 619 } 620 } 621 622 623 630 public void addRModuleUserAttribute(RModuleUserAttribute l) throws TorqueException 631 { 632 getRModuleUserAttributes().add(l); 633 l.setMITList((MITList)this); 634 } 635 636 639 private Criteria lastRModuleUserAttributesCriteria = null; 640 641 648 public List getRModuleUserAttributes() throws TorqueException 649 { 650 if (collRModuleUserAttributes == null) 651 { 652 collRModuleUserAttributes = getRModuleUserAttributes(new Criteria(10)); 653 } 654 return collRModuleUserAttributes; 655 } 656 657 668 public List getRModuleUserAttributes(Criteria criteria) throws TorqueException 669 { 670 if (collRModuleUserAttributes == null) 671 { 672 if (isNew()) 673 { 674 collRModuleUserAttributes = new ArrayList (); 675 } 676 else 677 { 678 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 679 collRModuleUserAttributes = RModuleUserAttributePeer.doSelect(criteria); 680 } 681 } 682 else 683 { 684 if (!isNew()) 686 { 687 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 691 if (!lastRModuleUserAttributesCriteria.equals(criteria)) 692 { 693 collRModuleUserAttributes = RModuleUserAttributePeer.doSelect(criteria); 694 } 695 } 696 } 697 lastRModuleUserAttributesCriteria = criteria; 698 699 return collRModuleUserAttributes; 700 } 701 702 710 public List getRModuleUserAttributes(Connection con) throws TorqueException 711 { 712 if (collRModuleUserAttributes == null) 713 { 714 collRModuleUserAttributes = getRModuleUserAttributes(new Criteria(10),con); 715 } 716 return collRModuleUserAttributes; 717 } 718 719 731 public List getRModuleUserAttributes(Criteria criteria,Connection con) throws TorqueException 732 { 733 if (collRModuleUserAttributes == null) 734 { 735 if (isNew()) 736 { 737 collRModuleUserAttributes = new ArrayList (); 738 } 739 else 740 { 741 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 742 collRModuleUserAttributes = RModuleUserAttributePeer.doSelect(criteria,con); 743 } 744 } 745 else 746 { 747 if (!isNew()) 749 { 750 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 754 if (!lastRModuleUserAttributesCriteria.equals(criteria)) 755 { 756 collRModuleUserAttributes = RModuleUserAttributePeer.doSelect(criteria,con); 757 } 758 } 759 } 760 lastRModuleUserAttributesCriteria = criteria; 761 762 return collRModuleUserAttributes; 763 } 764 765 766 767 768 769 770 771 772 773 774 775 786 protected List getRModuleUserAttributesJoinMITList(Criteria criteria) 787 throws TorqueException 788 { 789 if (collRModuleUserAttributes == null) 790 { 791 if (isNew()) 792 { 793 collRModuleUserAttributes = new ArrayList (); 794 } 795 else 796 { 797 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 798 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinMITList(criteria); 799 } 800 } 801 else 802 { 803 807 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 808 if (!lastRModuleUserAttributesCriteria.equals(criteria)) 809 { 810 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinMITList(criteria); 811 } 812 } 813 lastRModuleUserAttributesCriteria = criteria; 814 815 return collRModuleUserAttributes; 816 } 817 818 819 820 821 822 823 824 825 826 837 protected List getRModuleUserAttributesJoinScarabModule(Criteria criteria) 838 throws TorqueException 839 { 840 if (collRModuleUserAttributes == null) 841 { 842 if (isNew()) 843 { 844 collRModuleUserAttributes = new ArrayList (); 845 } 846 else 847 { 848 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 849 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinScarabModule(criteria); 850 } 851 } 852 else 853 { 854 858 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 859 if (!lastRModuleUserAttributesCriteria.equals(criteria)) 860 { 861 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinScarabModule(criteria); 862 } 863 } 864 lastRModuleUserAttributesCriteria = criteria; 865 866 return collRModuleUserAttributes; 867 } 868 869 870 871 872 873 874 875 876 877 888 protected List getRModuleUserAttributesJoinScarabUserImpl(Criteria criteria) 889 throws TorqueException 890 { 891 if (collRModuleUserAttributes == null) 892 { 893 if (isNew()) 894 { 895 collRModuleUserAttributes = new ArrayList (); 896 } 897 else 898 { 899 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 900 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinScarabUserImpl(criteria); 901 } 902 } 903 else 904 { 905 909 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 910 if (!lastRModuleUserAttributesCriteria.equals(criteria)) 911 { 912 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinScarabUserImpl(criteria); 913 } 914 } 915 lastRModuleUserAttributesCriteria = criteria; 916 917 return collRModuleUserAttributes; 918 } 919 920 921 922 923 924 925 926 927 928 939 protected List getRModuleUserAttributesJoinIssueType(Criteria criteria) 940 throws TorqueException 941 { 942 if (collRModuleUserAttributes == null) 943 { 944 if (isNew()) 945 { 946 collRModuleUserAttributes = new ArrayList (); 947 } 948 else 949 { 950 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 951 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinIssueType(criteria); 952 } 953 } 954 else 955 { 956 960 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 961 if (!lastRModuleUserAttributesCriteria.equals(criteria)) 962 { 963 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinIssueType(criteria); 964 } 965 } 966 lastRModuleUserAttributesCriteria = criteria; 967 968 return collRModuleUserAttributes; 969 } 970 971 972 973 974 975 976 977 978 979 990 protected List getRModuleUserAttributesJoinAttribute(Criteria criteria) 991 throws TorqueException 992 { 993 if (collRModuleUserAttributes == null) 994 { 995 if (isNew()) 996 { 997 collRModuleUserAttributes = new ArrayList (); 998 } 999 else 1000 { 1001 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 1002 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinAttribute(criteria); 1003 } 1004 } 1005 else 1006 { 1007 1011 criteria.add(RModuleUserAttributePeer.LIST_ID, getListId() ); 1012 if (!lastRModuleUserAttributesCriteria.equals(criteria)) 1013 { 1014 collRModuleUserAttributes = RModuleUserAttributePeer.doSelectJoinAttribute(criteria); 1015 } 1016 } 1017 lastRModuleUserAttributesCriteria = criteria; 1018 1019 return collRModuleUserAttributes; 1020 } 1021 1022 1023 1024 1025 1026 1029 protected List collQuerys; 1030 1031 1036 protected void initQuerys() 1037 { 1038 if (collQuerys == null) 1039 { 1040 collQuerys = new ArrayList (); 1041 } 1042 } 1043 1044 1045 1052 public void addQuery(Query l) throws TorqueException 1053 { 1054 getQuerys().add(l); 1055 l.setMITList((MITList)this); 1056 } 1057 1058 1061 private Criteria lastQuerysCriteria = null; 1062 1063 1070 public List getQuerys() throws TorqueException 1071 { 1072 if (collQuerys == null) 1073 { 1074 collQuerys = getQuerys(new Criteria(10)); 1075 } 1076 return collQuerys; 1077 } 1078 1079 1090 public List getQuerys(Criteria criteria) throws TorqueException 1091 { 1092 if (collQuerys == null) 1093 { 1094 if (isNew()) 1095 { 1096 collQuerys = new ArrayList (); 1097 } 1098 else 1099 { 1100 criteria.add(QueryPeer.LIST_ID, getListId() ); 1101 collQuerys = QueryPeer.doSelect(criteria); 1102 } 1103 } 1104 else 1105 { 1106 if (!isNew()) 1108 { 1109 criteria.add(QueryPeer.LIST_ID, getListId() ); 1113 if (!lastQuerysCriteria.equals(criteria)) 1114 { 1115 collQuerys = QueryPeer.doSelect(criteria); 1116 } 1117 } 1118 } 1119 lastQuerysCriteria = criteria; 1120 1121 return collQuerys; 1122 } 1123 1124 1132 public List getQuerys(Connection con) throws TorqueException 1133 { 1134 if (collQuerys == null) 1135 { 1136 collQuerys = getQuerys(new Criteria(10),con); 1137 } 1138 return collQuerys; 1139 } 1140 1141 1153 public List getQuerys(Criteria criteria,Connection con) throws TorqueException 1154 { 1155 if (collQuerys == null) 1156 { 1157 if (isNew()) 1158 { 1159 collQuerys = new ArrayList (); 1160 } 1161 else 1162 { 1163 criteria.add(QueryPeer.LIST_ID, getListId() ); 1164 collQuerys = QueryPeer.doSelect(criteria,con); 1165 } 1166 } 1167 else 1168 { 1169 if (!isNew()) 1171 { 1172 criteria.add(QueryPeer.LIST_ID, getListId() ); 1176 if (!lastQuerysCriteria.equals(criteria)) 1177 { 1178 collQuerys = QueryPeer.doSelect(criteria,con); 1179 } 1180 } 1181 } 1182 lastQuerysCriteria = criteria; 1183 1184 return collQuerys; 1185 } 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1208 protected List getQuerysJoinScarabUserImpl(Criteria criteria) 1209 throws TorqueException 1210 { 1211 if (collQuerys == null) 1212 { 1213 if (isNew()) 1214 { 1215 collQuerys = new ArrayList (); 1216 } 1217 else 1218 { 1219 criteria.add(QueryPeer.LIST_ID, getListId() ); 1220 collQuerys = QueryPeer.doSelectJoinScarabUserImpl(criteria); 1221 } 1222 } 1223 else 1224 { 1225 1229 criteria.add(QueryPeer.LIST_ID, getListId() ); 1230 if (!lastQuerysCriteria.equals(criteria)) 1231 { 1232 collQuerys = QueryPeer.doSelectJoinScarabUserImpl(criteria); 1233 } 1234 } 1235 lastQuerysCriteria = criteria; 1236 1237 return collQuerys; 1238 } 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1259 protected List getQuerysJoinScope(Criteria criteria) 1260 throws TorqueException 1261 { 1262 if (collQuerys == null) 1263 { 1264 if (isNew()) 1265 { 1266 collQuerys = new ArrayList (); 1267 } 1268 else 1269 { 1270 criteria.add(QueryPeer.LIST_ID, getListId() ); 1271 collQuerys = QueryPeer.doSelectJoinScope(criteria); 1272 } 1273 } 1274 else 1275 { 1276 1280 criteria.add(QueryPeer.LIST_ID, getListId() ); 1281 if (!lastQuerysCriteria.equals(criteria)) 1282 { 1283 collQuerys = QueryPeer.doSelectJoinScope(criteria); 1284 } 1285 } 1286 lastQuerysCriteria = criteria; 1287 1288 return collQuerys; 1289 } 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1310 protected List getQuerysJoinScarabModule(Criteria criteria) 1311 throws TorqueException 1312 { 1313 if (collQuerys == null) 1314 { 1315 if (isNew()) 1316 { 1317 collQuerys = new ArrayList (); 1318 } 1319 else 1320 { 1321 criteria.add(QueryPeer.LIST_ID, getListId() ); 1322 collQuerys = QueryPeer.doSelectJoinScarabModule(criteria); 1323 } 1324 } 1325 else 1326 { 1327 1331 criteria.add(QueryPeer.LIST_ID, getListId() ); 1332 if (!lastQuerysCriteria.equals(criteria)) 1333 { 1334 collQuerys = QueryPeer.doSelectJoinScarabModule(criteria); 1335 } 1336 } 1337 lastQuerysCriteria = criteria; 1338 1339 return collQuerys; 1340 } 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1361 protected List getQuerysJoinIssueType(Criteria criteria) 1362 throws TorqueException 1363 { 1364 if (collQuerys == null) 1365 { 1366 if (isNew()) 1367 { 1368 collQuerys = new ArrayList (); 1369 } 1370 else 1371 { 1372 criteria.add(QueryPeer.LIST_ID, getListId() ); 1373 collQuerys = QueryPeer.doSelectJoinIssueType(criteria); 1374 } 1375 } 1376 else 1377 { 1378 1382 criteria.add(QueryPeer.LIST_ID, getListId() ); 1383 if (!lastQuerysCriteria.equals(criteria)) 1384 { 1385 collQuerys = QueryPeer.doSelectJoinIssueType(criteria); 1386 } 1387 } 1388 lastQuerysCriteria = criteria; 1389 1390 return collQuerys; 1391 } 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1412 protected List getQuerysJoinMITList(Criteria criteria) 1413 throws TorqueException 1414 { 1415 if (collQuerys == null) 1416 { 1417 if (isNew()) 1418 { 1419 collQuerys = new ArrayList (); 1420 } 1421 else 1422 { 1423 criteria.add(QueryPeer.LIST_ID, getListId() ); 1424 collQuerys = QueryPeer.doSelectJoinMITList(criteria); 1425 } 1426 } 1427 else 1428 { 1429 1433 criteria.add(QueryPeer.LIST_ID, getListId() ); 1434 if (!lastQuerysCriteria.equals(criteria)) 1435 { 1436 collQuerys = QueryPeer.doSelectJoinMITList(criteria); 1437 } 1438 } 1439 lastQuerysCriteria = criteria; 1440 1441 return collQuerys; 1442 } 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1463 protected List getQuerysJoinFrequency(Criteria criteria) 1464 throws TorqueException 1465 { 1466 if (collQuerys == null) 1467 { 1468 if (isNew()) 1469 { 1470 collQuerys = new ArrayList (); 1471 } 1472 else 1473 { 1474 criteria.add(QueryPeer.LIST_ID, getListId() ); 1475 collQuerys = QueryPeer.doSelectJoinFrequency(criteria); 1476 } 1477 } 1478 else 1479 { 1480 1484 criteria.add(QueryPeer.LIST_ID, getListId() ); 1485 if (!lastQuerysCriteria.equals(criteria)) 1486 { 1487 collQuerys = QueryPeer.doSelectJoinFrequency(criteria); 1488 } 1489 } 1490 lastQuerysCriteria = criteria; 1491 1492 return collQuerys; 1493 } 1494 1495 1496 1497 1498 private static List fieldNames = null; 1499 1500 1505 public static synchronized List getFieldNames() 1506 { 1507 if (fieldNames == null) 1508 { 1509 fieldNames = new ArrayList (); 1510 fieldNames.add("ListId"); 1511 fieldNames.add("Name"); 1512 fieldNames.add("Active"); 1513 fieldNames.add("Modifiable"); 1514 fieldNames.add("UserId"); 1515 fieldNames = Collections.unmodifiableList(fieldNames); 1516 } 1517 return fieldNames; 1518 } 1519 1520 1526 public Object getByName(String name) 1527 { 1528 if (name.equals("ListId")) 1529 { 1530 return getListId(); 1531 } 1532 if (name.equals("Name")) 1533 { 1534 return getName(); 1535 } 1536 if (name.equals("Active")) 1537 { 1538 return Boolean.valueOf(getActive()); 1539 } 1540 if (name.equals("Modifiable")) 1541 { 1542 return Boolean.valueOf(getModifiable()); 1543 } 1544 if (name.equals("UserId")) 1545 { 1546 return getUserId(); 1547 } 1548 return null; 1549 } 1550 1551 1559 public Object getByPeerName(String name) 1560 { 1561 if (name.equals(MITListPeer.LIST_ID)) 1562 { 1563 return getListId(); 1564 } 1565 if (name.equals(MITListPeer.NAME)) 1566 { 1567 return getName(); 1568 } 1569 if (name.equals(MITListPeer.ACTIVE)) 1570 { 1571 return Boolean.valueOf(getActive()); 1572 } 1573 if (name.equals(MITListPeer.MODIFIABLE)) 1574 { 1575 return Boolean.valueOf(getModifiable()); 1576 } 1577 if (name.equals(MITListPeer.USER_ID)) 1578 { 1579 return getUserId(); 1580 } 1581 return null; 1582 } 1583 1584 1591 public Object getByPosition(int pos) 1592 { 1593 if (pos == 0) 1594 { 1595 return getListId(); 1596 } 1597 if (pos == 1) 1598 { 1599 return getName(); 1600 } 1601 if (pos == 2) 1602 { 1603 return Boolean.valueOf(getActive()); 1604 } 1605 if (pos == 3) 1606 { 1607 return Boolean.valueOf(getModifiable()); 1608 } 1609 if (pos == 4) 1610 { 1611 return getUserId(); 1612 } 1613 return null; 1614 } 1615 1616 1622 public void save() throws Exception 1623 { 1624 save(MITListPeer.getMapBuilder() 1625 .getDatabaseMap().getName()); 1626 } 1627 1628 1638 public void save(String dbName) throws TorqueException 1639 { 1640 Connection con = null; 1641 try 1642 { 1643 con = Transaction.begin(dbName); 1644 save(con); 1645 Transaction.commit(con); 1646 } 1647 catch(TorqueException e) 1648 { 1649 Transaction.safeRollback(con); 1650 throw e; 1651 } 1652 } 1653 1654 1656 private boolean alreadyInSave = false; 1657 1667 public void save(Connection con) throws TorqueException 1668 { 1669 if (!alreadyInSave) 1670 { 1671 alreadyInSave = true; 1672 1673 1674 1675 if (isModified()) 1677 { 1678 if (isNew()) 1679 { 1680 MITListPeer.doInsert((MITList)this, con); 1681 setNew(false); 1682 } 1683 else 1684 { 1685 MITListPeer.doUpdate((MITList)this, con); 1686 } 1687 1688 if (isCacheOnSave()) 1689 { 1690 MITListManager.putInstance(this); 1691 } 1692 } 1693 1694 1695 if (collMITListItems != null) 1696 { 1697 for (int i = 0; i < collMITListItems.size(); i++) 1698 { 1699 ((MITListItem)collMITListItems.get(i)).save(con); 1700 } 1701 } 1702 1703 if (collRModuleUserAttributes != null) 1704 { 1705 for (int i = 0; i < collRModuleUserAttributes.size(); i++) 1706 { 1707 ((RModuleUserAttribute)collRModuleUserAttributes.get(i)).save(con); 1708 } 1709 } 1710 1711 if (collQuerys != null) 1712 { 1713 for (int i = 0; i < collQuerys.size(); i++) 1714 { 1715 ((Query)collQuerys.get(i)).save(con); 1716 } 1717 } 1718 alreadyInSave = false; 1719 } 1720 } 1721 1722 1726 protected boolean isCacheOnSave() 1727 { 1728 return true; 1729 } 1730 1731 1732 1737 public void setPrimaryKey(ObjectKey listId) 1738 throws TorqueException { 1739 setListId(new Long (((NumberKey)listId).longValue())); 1740 } 1741 1742 1747 public void setPrimaryKey(String key) throws TorqueException 1748 { 1749 setListId(new Long (key)); 1750 } 1751 1752 1753 1757 public ObjectKey getPrimaryKey() 1758 { 1759 return SimpleKey.keyFor(getListId()); 1760 } 1761 1762 1766 public String getQueryKey() 1767 { 1768 if (getPrimaryKey() == null) 1769 { 1770 return ""; 1771 } 1772 else 1773 { 1774 return getPrimaryKey().toString(); 1775 } 1776 } 1777 1778 1782 public void setQueryKey(String key) 1783 throws TorqueException 1784 { 1785 setPrimaryKey(key); 1786 } 1787 1788 1794 public MITList copy() throws TorqueException 1795 { 1796 MITList copyObj = new MITList(); 1797 copyObj.setListId(listId); 1798 copyObj.setName(name); 1799 copyObj.setActive(active); 1800 copyObj.setModifiable(modifiable); 1801 copyObj.setUserId(userId); 1802 1803 copyObj.setListId((Long )null); 1804 1805 1806 1807 List v = getMITListItems(); 1808 for (int i = 0; i < v.size(); i++) 1809 { 1810 MITListItem obj = (MITListItem) v.get(i); 1811 copyObj.addMITListItem(obj.copy()); 1812 } 1813 1814 1815 v = getRModuleUserAttributes(); 1816 for (int i = 0; i < v.size(); i++) 1817 { 1818 RModuleUserAttribute obj = (RModuleUserAttribute) v.get(i); 1819 copyObj.addRModuleUserAttribute(obj.copy()); 1820 } 1821 1822 1823 v = getQuerys(); 1824 for (int i = 0; i < v.size(); i++) 1825 { 1826 Query obj = (Query) v.get(i); 1827 copyObj.addQuery(obj.copy()); 1828 } 1829 return copyObj; 1830 } 1831 1832 1838 public MITListPeer getPeer() 1839 { 1840 return peer; 1841 } 1842 1843 public String toString() 1844 { 1845 StringBuffer str = new StringBuffer (); 1846 str.append("MITList:\n"); 1847 str.append("ListId = ") 1848 .append(getListId()) 1849 .append("\n"); 1850 str.append("Name = ") 1851 .append(getName()) 1852 .append("\n"); 1853 str.append("Active = ") 1854 .append(getActive()) 1855 .append("\n"); 1856 str.append("Modifiable = ") 1857 .append(getModifiable()) 1858 .append("\n"); 1859 str.append("UserId = ") 1860 .append(getUserId()) 1861 .append("\n"); 1862 return(str.toString()); 1863 } 1864} 1865 | Popular Tags |