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 32 36 public abstract class BaseQuery extends BaseObject 37 implements org.apache.fulcrum.intake.Retrievable 38 { 39 40 private static final QueryPeer peer = 41 new QueryPeer(); 42 43 44 45 private Long queryId; 46 47 48 private Integer userId; 49 50 51 private String name; 52 53 54 private String description; 55 56 57 private String value; 58 59 60 private Integer scopeId; 61 62 63 private Integer issueTypeId; 64 65 66 private Integer moduleId; 67 68 69 private Long listId; 70 71 72 private boolean deleted = false; 73 74 75 private boolean approved = false; 76 77 78 private Date createdDate; 79 80 81 private Integer subscriptionFrequencyId; 82 83 84 private boolean homePage = false; 85 86 87 private int order = 0; 88 89 90 95 public Long getQueryId() 96 { 97 return queryId; 98 } 99 100 101 106 public void setQueryId(Long v) throws TorqueException 107 { 108 109 if (!ObjectUtils.equals(this.queryId, v)) 110 { 111 this.queryId = v; 112 setModified(true); 113 } 114 115 116 117 if (collRQueryUsers != null) 119 { 120 for (int i = 0; i < collRQueryUsers.size(); i++) 121 { 122 ((RQueryUser) collRQueryUsers.get(i)) 123 .setQueryId(v); 124 } 125 } 126 } 127 128 133 public Integer getUserId() 134 { 135 return userId; 136 } 137 138 139 144 public void setUserId(Integer v) throws TorqueException 145 { 146 147 if (!ObjectUtils.equals(this.userId, v)) 148 { 149 this.userId = v; 150 setModified(true); 151 } 152 153 154 if (aScarabUser != null && !ObjectUtils.equals(aScarabUser.getUserId(), v)) 155 { 156 aScarabUser = null; 157 } 158 159 } 160 161 166 public String getName() 167 { 168 return name; 169 } 170 171 172 177 public void setName(String v) 178 { 179 180 if (!ObjectUtils.equals(this.name, v)) 181 { 182 this.name = v; 183 setModified(true); 184 } 185 186 187 } 188 189 194 public String getDescription() 195 { 196 return description; 197 } 198 199 200 205 public void setDescription(String v) 206 { 207 208 if (!ObjectUtils.equals(this.description, v)) 209 { 210 this.description = v; 211 setModified(true); 212 } 213 214 215 } 216 217 222 public String getValue() 223 { 224 return value; 225 } 226 227 228 233 public void setValue(String v) 234 { 235 236 if (!ObjectUtils.equals(this.value, v)) 237 { 238 this.value = v; 239 setModified(true); 240 } 241 242 243 } 244 245 250 public Integer getScopeId() 251 { 252 return scopeId; 253 } 254 255 256 261 public void setScopeId(Integer v) throws TorqueException 262 { 263 264 if (!ObjectUtils.equals(this.scopeId, v)) 265 { 266 this.scopeId = v; 267 setModified(true); 268 } 269 270 271 if (aScope != null && !ObjectUtils.equals(aScope.getScopeId(), v)) 272 { 273 aScope = null; 274 } 275 276 } 277 278 283 public Integer getIssueTypeId() 284 { 285 return issueTypeId; 286 } 287 288 289 294 public void setIssueTypeId(Integer v) throws TorqueException 295 { 296 297 if (!ObjectUtils.equals(this.issueTypeId, v)) 298 { 299 this.issueTypeId = v; 300 setModified(true); 301 } 302 303 304 if (aIssueType != null && !ObjectUtils.equals(aIssueType.getIssueTypeId(), v)) 305 { 306 aIssueType = null; 307 } 308 309 } 310 311 316 public Integer getModuleId() 317 { 318 return moduleId; 319 } 320 321 322 327 public void setModuleId(Integer v) throws TorqueException 328 { 329 330 if (!ObjectUtils.equals(this.moduleId, v)) 331 { 332 this.moduleId = v; 333 setModified(true); 334 } 335 336 337 if (aModule != null && !ObjectUtils.equals(aModule.getModuleId(), v)) 338 { 339 aModule = null; 340 } 341 342 } 343 344 349 public Long getListId() 350 { 351 return listId; 352 } 353 354 355 360 public void setListId(Long v) throws TorqueException 361 { 362 363 if (!ObjectUtils.equals(this.listId, v)) 364 { 365 this.listId = v; 366 setModified(true); 367 } 368 369 370 if (aMITList != null && !ObjectUtils.equals(aMITList.getListId(), v)) 371 { 372 aMITList = null; 373 } 374 375 } 376 377 382 public boolean getDeleted() 383 { 384 return deleted; 385 } 386 387 388 393 public void setDeleted(boolean v) 394 { 395 396 if (this.deleted != v) 397 { 398 this.deleted = v; 399 setModified(true); 400 } 401 402 403 } 404 405 410 public boolean getApproved() 411 { 412 return approved; 413 } 414 415 416 421 public void setApproved(boolean v) 422 { 423 424 if (this.approved != v) 425 { 426 this.approved = v; 427 setModified(true); 428 } 429 430 431 } 432 433 438 public Date getCreatedDate() 439 { 440 return createdDate; 441 } 442 443 444 449 public void setCreatedDate(Date v) 450 { 451 452 if (!ObjectUtils.equals(this.createdDate, v)) 453 { 454 this.createdDate = v; 455 setModified(true); 456 } 457 458 459 } 460 461 466 public Integer getSubscriptionFrequencyId() 467 { 468 return subscriptionFrequencyId; 469 } 470 471 472 477 public void setSubscriptionFrequencyId(Integer v) throws TorqueException 478 { 479 480 if (!ObjectUtils.equals(this.subscriptionFrequencyId, v)) 481 { 482 this.subscriptionFrequencyId = v; 483 setModified(true); 484 } 485 486 487 if (aFrequency != null && !ObjectUtils.equals(aFrequency.getFrequencyId(), v)) 488 { 489 aFrequency = null; 490 } 491 492 } 493 494 499 public boolean getHomePage() 500 { 501 return homePage; 502 } 503 504 505 510 public void setHomePage(boolean v) 511 { 512 513 if (this.homePage != v) 514 { 515 this.homePage = v; 516 setModified(true); 517 } 518 519 520 } 521 522 527 public int getOrder() 528 { 529 return order; 530 } 531 532 533 538 public void setOrder(int v) 539 { 540 541 if (this.order != v) 542 { 543 this.order = v; 544 setModified(true); 545 } 546 547 548 } 549 550 551 552 553 private ScarabUser aScarabUser; 554 555 561 public void setScarabUser(ScarabUser v) throws TorqueException 562 { 563 if (v == null) 564 { 565 setUserId((Integer ) null); 566 } 567 else 568 { 569 setUserId(v.getUserId()); 570 } 571 aScarabUser = v; 572 } 573 574 575 581 public ScarabUser getScarabUser() throws TorqueException 582 { 583 if ( !ObjectUtils.equals(getUserId(), null) ) 584 { 585 return ScarabUserManager.getInstance(SimpleKey.keyFor(getUserId())); 586 } 587 return aScarabUser; 588 } 589 590 596 public void setScarabUserKey(ObjectKey key) throws TorqueException 597 { 598 599 setUserId(new Integer (((NumberKey) key).intValue())); 600 } 601 602 603 604 private Scope aScope; 605 606 612 public void setScope(Scope v) throws TorqueException 613 { 614 if (v == null) 615 { 616 setScopeId((Integer ) null); 617 } 618 else 619 { 620 setScopeId(v.getScopeId()); 621 } 622 aScope = v; 623 } 624 625 626 632 public Scope getScope() throws TorqueException 633 { 634 if ( !ObjectUtils.equals(getScopeId(), null) ) 635 { 636 return ScopeManager.getInstance(SimpleKey.keyFor(getScopeId())); 637 } 638 return aScope; 639 } 640 641 647 public void setScopeKey(ObjectKey key) throws TorqueException 648 { 649 650 setScopeId(new Integer (((NumberKey) key).intValue())); 651 } 652 653 654 655 private Module aModule; 656 657 663 public void setModule(Module v) throws TorqueException 664 { 665 if (v == null) 666 { 667 setModuleId((Integer ) null); 668 } 669 else 670 { 671 setModuleId(v.getModuleId()); 672 } 673 aModule = v; 674 } 675 676 677 683 public Module getModule() throws TorqueException 684 { 685 if ( !ObjectUtils.equals(getModuleId(), null) ) 686 { 687 return ModuleManager.getInstance(SimpleKey.keyFor(getModuleId())); 688 } 689 return aModule; 690 } 691 692 698 public void setModuleKey(ObjectKey key) throws TorqueException 699 { 700 701 setModuleId(new Integer (((NumberKey) key).intValue())); 702 } 703 704 705 706 private IssueType aIssueType; 707 708 714 public void setIssueType(IssueType v) throws TorqueException 715 { 716 if (v == null) 717 { 718 setIssueTypeId((Integer ) null); 719 } 720 else 721 { 722 setIssueTypeId(v.getIssueTypeId()); 723 } 724 aIssueType = v; 725 } 726 727 728 734 public IssueType getIssueType() throws TorqueException 735 { 736 if ( !ObjectUtils.equals(getIssueTypeId(), null) ) 737 { 738 return IssueTypeManager.getInstance(SimpleKey.keyFor(getIssueTypeId())); 739 } 740 return aIssueType; 741 } 742 743 749 public void setIssueTypeKey(ObjectKey key) throws TorqueException 750 { 751 752 setIssueTypeId(new Integer (((NumberKey) key).intValue())); 753 } 754 755 756 757 private MITList aMITList; 758 759 765 public void setMITList(MITList v) throws TorqueException 766 { 767 if (v == null) 768 { 769 setListId((Long ) null); 770 } 771 else 772 { 773 setListId(v.getListId()); 774 } 775 aMITList = v; 776 } 777 778 779 785 public MITList getMITList() throws TorqueException 786 { 787 if ( !ObjectUtils.equals(getListId(), null) ) 788 { 789 return MITListManager.getInstance(SimpleKey.keyFor(getListId())); 790 } 791 return aMITList; 792 } 793 794 800 public void setMITListKey(ObjectKey key) throws TorqueException 801 { 802 803 setListId(new Long (((NumberKey) key).longValue())); 804 } 805 806 807 808 private Frequency aFrequency; 809 810 816 public void setFrequency(Frequency v) throws TorqueException 817 { 818 if (v == null) 819 { 820 setSubscriptionFrequencyId((Integer ) null); 821 } 822 else 823 { 824 setSubscriptionFrequencyId(v.getFrequencyId()); 825 } 826 aFrequency = v; 827 } 828 829 830 836 public Frequency getFrequency() throws TorqueException 837 { 838 if ( !ObjectUtils.equals(getSubscriptionFrequencyId(), null) ) 839 { 840 return FrequencyManager.getInstance(SimpleKey.keyFor(getSubscriptionFrequencyId())); 841 } 842 return aFrequency; 843 } 844 845 851 public void setFrequencyKey(ObjectKey key) throws TorqueException 852 { 853 854 setSubscriptionFrequencyId(new Integer (((NumberKey) key).intValue())); 855 } 856 857 858 859 862 protected List collRQueryUsers; 863 864 869 protected void initRQueryUsers() 870 { 871 if (collRQueryUsers == null) 872 { 873 collRQueryUsers = new ArrayList (); 874 } 875 } 876 877 878 885 public void addRQueryUser(RQueryUser l) throws TorqueException 886 { 887 getRQueryUsers().add(l); 888 l.setQuery((Query)this); 889 } 890 891 894 private Criteria lastRQueryUsersCriteria = null; 895 896 903 public List getRQueryUsers() throws TorqueException 904 { 905 if (collRQueryUsers == null) 906 { 907 collRQueryUsers = getRQueryUsers(new Criteria(10)); 908 } 909 return collRQueryUsers; 910 } 911 912 923 public List getRQueryUsers(Criteria criteria) throws TorqueException 924 { 925 if (collRQueryUsers == null) 926 { 927 if (isNew()) 928 { 929 collRQueryUsers = new ArrayList (); 930 } 931 else 932 { 933 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 934 collRQueryUsers = RQueryUserPeer.doSelect(criteria); 935 } 936 } 937 else 938 { 939 if (!isNew()) 941 { 942 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 946 if (!lastRQueryUsersCriteria.equals(criteria)) 947 { 948 collRQueryUsers = RQueryUserPeer.doSelect(criteria); 949 } 950 } 951 } 952 lastRQueryUsersCriteria = criteria; 953 954 return collRQueryUsers; 955 } 956 957 965 public List getRQueryUsers(Connection con) throws TorqueException 966 { 967 if (collRQueryUsers == null) 968 { 969 collRQueryUsers = getRQueryUsers(new Criteria(10),con); 970 } 971 return collRQueryUsers; 972 } 973 974 986 public List getRQueryUsers(Criteria criteria,Connection con) throws TorqueException 987 { 988 if (collRQueryUsers == null) 989 { 990 if (isNew()) 991 { 992 collRQueryUsers = new ArrayList (); 993 } 994 else 995 { 996 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 997 collRQueryUsers = RQueryUserPeer.doSelect(criteria,con); 998 } 999 } 1000 else 1001 { 1002 if (!isNew()) 1004 { 1005 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 1009 if (!lastRQueryUsersCriteria.equals(criteria)) 1010 { 1011 collRQueryUsers = RQueryUserPeer.doSelect(criteria,con); 1012 } 1013 } 1014 } 1015 lastRQueryUsersCriteria = criteria; 1016 1017 return collRQueryUsers; 1018 } 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1041 protected List getRQueryUsersJoinQuery(Criteria criteria) 1042 throws TorqueException 1043 { 1044 if (collRQueryUsers == null) 1045 { 1046 if (isNew()) 1047 { 1048 collRQueryUsers = new ArrayList (); 1049 } 1050 else 1051 { 1052 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 1053 collRQueryUsers = RQueryUserPeer.doSelectJoinQuery(criteria); 1054 } 1055 } 1056 else 1057 { 1058 1062 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 1063 if (!lastRQueryUsersCriteria.equals(criteria)) 1064 { 1065 collRQueryUsers = RQueryUserPeer.doSelectJoinQuery(criteria); 1066 } 1067 } 1068 lastRQueryUsersCriteria = criteria; 1069 1070 return collRQueryUsers; 1071 } 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1092 protected List getRQueryUsersJoinScarabUserImpl(Criteria criteria) 1093 throws TorqueException 1094 { 1095 if (collRQueryUsers == null) 1096 { 1097 if (isNew()) 1098 { 1099 collRQueryUsers = new ArrayList (); 1100 } 1101 else 1102 { 1103 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 1104 collRQueryUsers = RQueryUserPeer.doSelectJoinScarabUserImpl(criteria); 1105 } 1106 } 1107 else 1108 { 1109 1113 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 1114 if (!lastRQueryUsersCriteria.equals(criteria)) 1115 { 1116 collRQueryUsers = RQueryUserPeer.doSelectJoinScarabUserImpl(criteria); 1117 } 1118 } 1119 lastRQueryUsersCriteria = criteria; 1120 1121 return collRQueryUsers; 1122 } 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1143 protected List getRQueryUsersJoinFrequency(Criteria criteria) 1144 throws TorqueException 1145 { 1146 if (collRQueryUsers == null) 1147 { 1148 if (isNew()) 1149 { 1150 collRQueryUsers = new ArrayList (); 1151 } 1152 else 1153 { 1154 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 1155 collRQueryUsers = RQueryUserPeer.doSelectJoinFrequency(criteria); 1156 } 1157 } 1158 else 1159 { 1160 1164 criteria.add(RQueryUserPeer.QUERY_ID, getQueryId() ); 1165 if (!lastRQueryUsersCriteria.equals(criteria)) 1166 { 1167 collRQueryUsers = RQueryUserPeer.doSelectJoinFrequency(criteria); 1168 } 1169 } 1170 lastRQueryUsersCriteria = criteria; 1171 1172 return collRQueryUsers; 1173 } 1174 1175 1176 1177 1178 private static List fieldNames = null; 1179 1180 1185 public static synchronized List getFieldNames() 1186 { 1187 if (fieldNames == null) 1188 { 1189 fieldNames = new ArrayList (); 1190 fieldNames.add("QueryId"); 1191 fieldNames.add("UserId"); 1192 fieldNames.add("Name"); 1193 fieldNames.add("Description"); 1194 fieldNames.add("Value"); 1195 fieldNames.add("ScopeId"); 1196 fieldNames.add("IssueTypeId"); 1197 fieldNames.add("ModuleId"); 1198 fieldNames.add("ListId"); 1199 fieldNames.add("Deleted"); 1200 fieldNames.add("Approved"); 1201 fieldNames.add("CreatedDate"); 1202 fieldNames.add("SubscriptionFrequencyId"); 1203 fieldNames.add("HomePage"); 1204 fieldNames.add("Order"); 1205 fieldNames = Collections.unmodifiableList(fieldNames); 1206 } 1207 return fieldNames; 1208 } 1209 1210 1216 public Object getByName(String name) 1217 { 1218 if (name.equals("QueryId")) 1219 { 1220 return getQueryId(); 1221 } 1222 if (name.equals("UserId")) 1223 { 1224 return getUserId(); 1225 } 1226 if (name.equals("Name")) 1227 { 1228 return getName(); 1229 } 1230 if (name.equals("Description")) 1231 { 1232 return getDescription(); 1233 } 1234 if (name.equals("Value")) 1235 { 1236 return getValue(); 1237 } 1238 if (name.equals("ScopeId")) 1239 { 1240 return getScopeId(); 1241 } 1242 if (name.equals("IssueTypeId")) 1243 { 1244 return getIssueTypeId(); 1245 } 1246 if (name.equals("ModuleId")) 1247 { 1248 return getModuleId(); 1249 } 1250 if (name.equals("ListId")) 1251 { 1252 return getListId(); 1253 } 1254 if (name.equals("Deleted")) 1255 { 1256 return Boolean.valueOf(getDeleted()); 1257 } 1258 if (name.equals("Approved")) 1259 { 1260 return Boolean.valueOf(getApproved()); 1261 } 1262 if (name.equals("CreatedDate")) 1263 { 1264 return getCreatedDate(); 1265 } 1266 if (name.equals("SubscriptionFrequencyId")) 1267 { 1268 return getSubscriptionFrequencyId(); 1269 } 1270 if (name.equals("HomePage")) 1271 { 1272 return Boolean.valueOf(getHomePage()); 1273 } 1274 if (name.equals("Order")) 1275 { 1276 return new Integer (getOrder()); 1277 } 1278 return null; 1279 } 1280 1281 1289 public Object getByPeerName(String name) 1290 { 1291 if (name.equals(QueryPeer.QUERY_ID)) 1292 { 1293 return getQueryId(); 1294 } 1295 if (name.equals(QueryPeer.USER_ID)) 1296 { 1297 return getUserId(); 1298 } 1299 if (name.equals(QueryPeer.NAME)) 1300 { 1301 return getName(); 1302 } 1303 if (name.equals(QueryPeer.DESCRIPTION)) 1304 { 1305 return getDescription(); 1306 } 1307 if (name.equals(QueryPeer.VALUE)) 1308 { 1309 return getValue(); 1310 } 1311 if (name.equals(QueryPeer.SCOPE_ID)) 1312 { 1313 return getScopeId(); 1314 } 1315 if (name.equals(QueryPeer.ISSUE_TYPE_ID)) 1316 { 1317 return getIssueTypeId(); 1318 } 1319 if (name.equals(QueryPeer.MODULE_ID)) 1320 { 1321 return getModuleId(); 1322 } 1323 if (name.equals(QueryPeer.LIST_ID)) 1324 { 1325 return getListId(); 1326 } 1327 if (name.equals(QueryPeer.DELETED)) 1328 { 1329 return Boolean.valueOf(getDeleted()); 1330 } 1331 if (name.equals(QueryPeer.APPROVED)) 1332 { 1333 return Boolean.valueOf(getApproved()); 1334 } 1335 if (name.equals(QueryPeer.CREATED_DATE)) 1336 { 1337 return getCreatedDate(); 1338 } 1339 if (name.equals(QueryPeer.SUBSCRIPTION_FREQUENCY_ID)) 1340 { 1341 return getSubscriptionFrequencyId(); 1342 } 1343 if (name.equals(QueryPeer.HOME_PAGE)) 1344 { 1345 return Boolean.valueOf(getHomePage()); 1346 } 1347 if (name.equals(QueryPeer.PREFERRED_ORDER)) 1348 { 1349 return new Integer (getOrder()); 1350 } 1351 return null; 1352 } 1353 1354 1361 public Object getByPosition(int pos) 1362 { 1363 if (pos == 0) 1364 { 1365 return getQueryId(); 1366 } 1367 if (pos == 1) 1368 { 1369 return getUserId(); 1370 } 1371 if (pos == 2) 1372 { 1373 return getName(); 1374 } 1375 if (pos == 3) 1376 { 1377 return getDescription(); 1378 } 1379 if (pos == 4) 1380 { 1381 return getValue(); 1382 } 1383 if (pos == 5) 1384 { 1385 return getScopeId(); 1386 } 1387 if (pos == 6) 1388 { 1389 return getIssueTypeId(); 1390 } 1391 if (pos == 7) 1392 { 1393 return getModuleId(); 1394 } 1395 if (pos == 8) 1396 { 1397 return getListId(); 1398 } 1399 if (pos == 9) 1400 { 1401 return Boolean.valueOf(getDeleted()); 1402 } 1403 if (pos == 10) 1404 { 1405 return Boolean.valueOf(getApproved()); 1406 } 1407 if (pos == 11) 1408 { 1409 return getCreatedDate(); 1410 } 1411 if (pos == 12) 1412 { 1413 return getSubscriptionFrequencyId(); 1414 } 1415 if (pos == 13) 1416 { 1417 return Boolean.valueOf(getHomePage()); 1418 } 1419 if (pos == 14) 1420 { 1421 return new Integer (getOrder()); 1422 } 1423 return null; 1424 } 1425 1426 1432 public void save() throws Exception 1433 { 1434 save(QueryPeer.getMapBuilder() 1435 .getDatabaseMap().getName()); 1436 } 1437 1438 1448 public void save(String dbName) throws TorqueException 1449 { 1450 Connection con = null; 1451 try 1452 { 1453 con = Transaction.begin(dbName); 1454 save(con); 1455 Transaction.commit(con); 1456 } 1457 catch(TorqueException e) 1458 { 1459 Transaction.safeRollback(con); 1460 throw e; 1461 } 1462 } 1463 1464 1466 private boolean alreadyInSave = false; 1467 1477 public void save(Connection con) throws TorqueException 1478 { 1479 if (!alreadyInSave) 1480 { 1481 alreadyInSave = true; 1482 1483 1484 1485 if (isModified()) 1487 { 1488 if (isNew()) 1489 { 1490 QueryPeer.doInsert((Query)this, con); 1491 setNew(false); 1492 } 1493 else 1494 { 1495 QueryPeer.doUpdate((Query)this, con); 1496 } 1497 1498 if (isCacheOnSave()) 1499 { 1500 QueryManager.putInstance(this); 1501 } 1502 } 1503 1504 1505 if (collRQueryUsers != null) 1506 { 1507 for (int i = 0; i < collRQueryUsers.size(); i++) 1508 { 1509 ((RQueryUser)collRQueryUsers.get(i)).save(con); 1510 } 1511 } 1512 alreadyInSave = false; 1513 } 1514 } 1515 1516 1520 protected boolean isCacheOnSave() 1521 { 1522 return true; 1523 } 1524 1525 1526 1531 public void setPrimaryKey(ObjectKey queryId) 1532 throws TorqueException { 1533 setQueryId(new Long (((NumberKey)queryId).longValue())); 1534 } 1535 1536 1541 public void setPrimaryKey(String key) throws TorqueException 1542 { 1543 setQueryId(new Long (key)); 1544 } 1545 1546 1547 1551 public ObjectKey getPrimaryKey() 1552 { 1553 return SimpleKey.keyFor(getQueryId()); 1554 } 1555 1556 1560 public String getQueryKey() 1561 { 1562 if (getPrimaryKey() == null) 1563 { 1564 return ""; 1565 } 1566 else 1567 { 1568 return getPrimaryKey().toString(); 1569 } 1570 } 1571 1572 1576 public void setQueryKey(String key) 1577 throws TorqueException 1578 { 1579 setPrimaryKey(key); 1580 } 1581 1582 1588 public Query copy() throws TorqueException 1589 { 1590 Query copyObj = new Query(); 1591 copyObj.setQueryId(queryId); 1592 copyObj.setUserId(userId); 1593 copyObj.setName(name); 1594 copyObj.setDescription(description); 1595 copyObj.setValue(value); 1596 copyObj.setScopeId(scopeId); 1597 copyObj.setIssueTypeId(issueTypeId); 1598 copyObj.setModuleId(moduleId); 1599 copyObj.setListId(listId); 1600 copyObj.setDeleted(deleted); 1601 copyObj.setApproved(approved); 1602 copyObj.setCreatedDate(createdDate); 1603 copyObj.setSubscriptionFrequencyId(subscriptionFrequencyId); 1604 copyObj.setHomePage(homePage); 1605 copyObj.setOrder(order); 1606 1607 copyObj.setQueryId((Long )null); 1608 1609 1610 1611 List v = getRQueryUsers(); 1612 for (int i = 0; i < v.size(); i++) 1613 { 1614 RQueryUser obj = (RQueryUser) v.get(i); 1615 copyObj.addRQueryUser(obj.copy()); 1616 } 1617 return copyObj; 1618 } 1619 1620 1626 public QueryPeer getPeer() 1627 { 1628 return peer; 1629 } 1630 1631 public String toString() 1632 { 1633 StringBuffer str = new StringBuffer (); 1634 str.append("Query:\n"); 1635 str.append("QueryId = ") 1636 .append(getQueryId()) 1637 .append("\n"); 1638 str.append("UserId = ") 1639 .append(getUserId()) 1640 .append("\n"); 1641 str.append("Name = ") 1642 .append(getName()) 1643 .append("\n"); 1644 str.append("Description = ") 1645 .append(getDescription()) 1646 .append("\n"); 1647 str.append("Value = ") 1648 .append(getValue()) 1649 .append("\n"); 1650 str.append("ScopeId = ") 1651 .append(getScopeId()) 1652 .append("\n"); 1653 str.append("IssueTypeId = ") 1654 .append(getIssueTypeId()) 1655 .append("\n"); 1656 str.append("ModuleId = ") 1657 .append(getModuleId()) 1658 .append("\n"); 1659 str.append("ListId = ") 1660 .append(getListId()) 1661 .append("\n"); 1662 str.append("Deleted = ") 1663 .append(getDeleted()) 1664 .append("\n"); 1665 str.append("Approved = ") 1666 .append(getApproved()) 1667 .append("\n"); 1668 str.append("CreatedDate = ") 1669 .append(getCreatedDate()) 1670 .append("\n"); 1671 str.append("SubscriptionFrequencyId = ") 1672 .append(getSubscriptionFrequencyId()) 1673 .append("\n"); 1674 str.append("HomePage = ") 1675 .append(getHomePage()) 1676 .append("\n"); 1677 str.append("Order = ") 1678 .append(getOrder()) 1679 .append("\n"); 1680 return(str.toString()); 1681 } 1682} 1683 | Popular Tags |