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 33 public abstract class BaseActivitySet extends BaseObject 34 implements org.apache.fulcrum.intake.Retrievable 35 { 36 37 private static final ActivitySetPeer peer = 38 new ActivitySetPeer(); 39 40 41 42 private Long activitySetId; 43 44 45 private Integer typeId; 46 47 48 private Long attachmentId; 49 50 51 private Integer createdBy; 52 53 54 private Date createdDate; 55 56 57 62 public Long getActivitySetId() 63 { 64 return activitySetId; 65 } 66 67 68 73 public void setActivitySetId(Long v) throws TorqueException 74 { 75 76 if (!ObjectUtils.equals(this.activitySetId, v)) 77 { 78 this.activitySetId = v; 79 setModified(true); 80 } 81 82 83 84 if (collActivitys != null) 86 { 87 for (int i = 0; i < collActivitys.size(); i++) 88 { 89 ((Activity) collActivitys.get(i)) 90 .setTransactionId(v); 91 } 92 } 93 94 if (collIssues != null) 96 { 97 for (int i = 0; i < collIssues.size(); i++) 98 { 99 ((Issue) collIssues.get(i)) 100 .setCreatedTransId(v); 101 } 102 } 103 } 104 105 110 public Integer getTypeId() 111 { 112 return typeId; 113 } 114 115 116 121 public void setTypeId(Integer v) throws TorqueException 122 { 123 124 if (!ObjectUtils.equals(this.typeId, v)) 125 { 126 this.typeId = v; 127 setModified(true); 128 } 129 130 131 if (aActivitySetType != null && !ObjectUtils.equals(aActivitySetType.getTypeId(), v)) 132 { 133 aActivitySetType = null; 134 } 135 136 } 137 138 143 public Long getAttachmentId() 144 { 145 return attachmentId; 146 } 147 148 149 154 public void setAttachmentId(Long v) throws TorqueException 155 { 156 157 if (!ObjectUtils.equals(this.attachmentId, v)) 158 { 159 this.attachmentId = v; 160 setModified(true); 161 } 162 163 164 if (aAttachment != null && !ObjectUtils.equals(aAttachment.getAttachmentId(), v)) 165 { 166 aAttachment = null; 167 } 168 169 } 170 171 176 public Integer getCreatedBy() 177 { 178 return createdBy; 179 } 180 181 182 187 public void setCreatedBy(Integer v) throws TorqueException 188 { 189 190 if (!ObjectUtils.equals(this.createdBy, v)) 191 { 192 this.createdBy = v; 193 setModified(true); 194 } 195 196 197 if (aScarabUser != null && !ObjectUtils.equals(aScarabUser.getUserId(), v)) 198 { 199 aScarabUser = null; 200 } 201 202 } 203 204 209 public Date getCreatedDate() 210 { 211 return createdDate; 212 } 213 214 215 220 public void setCreatedDate(Date v) 221 { 222 223 if (!ObjectUtils.equals(this.createdDate, v)) 224 { 225 this.createdDate = v; 226 setModified(true); 227 } 228 229 230 } 231 232 233 234 235 private ScarabUser aScarabUser; 236 237 243 public void setScarabUser(ScarabUser v) throws TorqueException 244 { 245 if (v == null) 246 { 247 setCreatedBy((Integer ) null); 248 } 249 else 250 { 251 setCreatedBy(v.getUserId()); 252 } 253 aScarabUser = v; 254 } 255 256 257 263 public ScarabUser getScarabUser() throws TorqueException 264 { 265 if ( !ObjectUtils.equals(getCreatedBy(), null) ) 266 { 267 return ScarabUserManager.getInstance(SimpleKey.keyFor(getCreatedBy())); 268 } 269 return aScarabUser; 270 } 271 272 278 public void setScarabUserKey(ObjectKey key) throws TorqueException 279 { 280 281 setCreatedBy(new Integer (((NumberKey) key).intValue())); 282 } 283 284 285 286 private ActivitySetType aActivitySetType; 287 288 294 public void setActivitySetType(ActivitySetType v) throws TorqueException 295 { 296 if (v == null) 297 { 298 setTypeId((Integer ) null); 299 } 300 else 301 { 302 setTypeId(v.getTypeId()); 303 } 304 aActivitySetType = v; 305 } 306 307 308 314 public ActivitySetType getActivitySetType() throws TorqueException 315 { 316 if ( !ObjectUtils.equals(getTypeId(), null) ) 317 { 318 return ActivitySetTypeManager.getInstance(SimpleKey.keyFor(getTypeId())); 319 } 320 return aActivitySetType; 321 } 322 323 329 public void setActivitySetTypeKey(ObjectKey key) throws TorqueException 330 { 331 332 setTypeId(new Integer (((NumberKey) key).intValue())); 333 } 334 335 336 337 private Attachment aAttachment; 338 339 345 public void setAttachment(Attachment v) throws TorqueException 346 { 347 if (v == null) 348 { 349 setAttachmentId((Long ) null); 350 } 351 else 352 { 353 setAttachmentId(v.getAttachmentId()); 354 } 355 aAttachment = v; 356 } 357 358 359 365 public Attachment getAttachment() throws TorqueException 366 { 367 if ( !ObjectUtils.equals(getAttachmentId(), null) ) 368 { 369 return AttachmentManager.getInstance(SimpleKey.keyFor(getAttachmentId())); 370 } 371 return aAttachment; 372 } 373 374 380 public void setAttachmentKey(ObjectKey key) throws TorqueException 381 { 382 383 setAttachmentId(new Long (((NumberKey) key).longValue())); 384 } 385 386 387 388 391 protected List collActivitys; 392 393 398 protected void initActivitys() 399 { 400 if (collActivitys == null) 401 { 402 collActivitys = new ArrayList (); 403 } 404 } 405 406 407 414 public void addActivity(Activity l) throws TorqueException 415 { 416 getActivitys().add(l); 417 l.setActivitySet((ActivitySet)this); 418 } 419 420 423 private Criteria lastActivitysCriteria = null; 424 425 432 public List getActivitys() throws TorqueException 433 { 434 if (collActivitys == null) 435 { 436 collActivitys = getActivitys(new Criteria(10)); 437 } 438 return collActivitys; 439 } 440 441 452 public List getActivitys(Criteria criteria) throws TorqueException 453 { 454 if (collActivitys == null) 455 { 456 if (isNew()) 457 { 458 collActivitys = new ArrayList (); 459 } 460 else 461 { 462 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 463 collActivitys = ActivityPeer.doSelect(criteria); 464 } 465 } 466 else 467 { 468 if (!isNew()) 470 { 471 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 475 if (!lastActivitysCriteria.equals(criteria)) 476 { 477 collActivitys = ActivityPeer.doSelect(criteria); 478 } 479 } 480 } 481 lastActivitysCriteria = criteria; 482 483 return collActivitys; 484 } 485 486 494 public List getActivitys(Connection con) throws TorqueException 495 { 496 if (collActivitys == null) 497 { 498 collActivitys = getActivitys(new Criteria(10),con); 499 } 500 return collActivitys; 501 } 502 503 515 public List getActivitys(Criteria criteria,Connection con) throws TorqueException 516 { 517 if (collActivitys == null) 518 { 519 if (isNew()) 520 { 521 collActivitys = new ArrayList (); 522 } 523 else 524 { 525 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 526 collActivitys = ActivityPeer.doSelect(criteria,con); 527 } 528 } 529 else 530 { 531 if (!isNew()) 533 { 534 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 538 if (!lastActivitysCriteria.equals(criteria)) 539 { 540 collActivitys = ActivityPeer.doSelect(criteria,con); 541 } 542 } 543 } 544 lastActivitysCriteria = criteria; 545 546 return collActivitys; 547 } 548 549 550 551 552 553 554 555 556 557 558 559 570 protected List getActivitysJoinIssue(Criteria criteria) 571 throws TorqueException 572 { 573 if (collActivitys == null) 574 { 575 if (isNew()) 576 { 577 collActivitys = new ArrayList (); 578 } 579 else 580 { 581 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 582 collActivitys = ActivityPeer.doSelectJoinIssue(criteria); 583 } 584 } 585 else 586 { 587 591 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 592 if (!lastActivitysCriteria.equals(criteria)) 593 { 594 collActivitys = ActivityPeer.doSelectJoinIssue(criteria); 595 } 596 } 597 lastActivitysCriteria = criteria; 598 599 return collActivitys; 600 } 601 602 603 604 605 606 607 608 609 610 621 protected List getActivitysJoinAttribute(Criteria criteria) 622 throws TorqueException 623 { 624 if (collActivitys == null) 625 { 626 if (isNew()) 627 { 628 collActivitys = new ArrayList (); 629 } 630 else 631 { 632 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 633 collActivitys = ActivityPeer.doSelectJoinAttribute(criteria); 634 } 635 } 636 else 637 { 638 642 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 643 if (!lastActivitysCriteria.equals(criteria)) 644 { 645 collActivitys = ActivityPeer.doSelectJoinAttribute(criteria); 646 } 647 } 648 lastActivitysCriteria = criteria; 649 650 return collActivitys; 651 } 652 653 654 655 656 657 658 659 660 661 672 protected List getActivitysJoinActivitySet(Criteria criteria) 673 throws TorqueException 674 { 675 if (collActivitys == null) 676 { 677 if (isNew()) 678 { 679 collActivitys = new ArrayList (); 680 } 681 else 682 { 683 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 684 collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria); 685 } 686 } 687 else 688 { 689 693 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 694 if (!lastActivitysCriteria.equals(criteria)) 695 { 696 collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria); 697 } 698 } 699 lastActivitysCriteria = criteria; 700 701 return collActivitys; 702 } 703 704 705 706 707 708 709 710 711 712 723 protected List getActivitysJoinScarabUserImplRelatedByOldUserId(Criteria criteria) 724 throws TorqueException 725 { 726 if (collActivitys == null) 727 { 728 if (isNew()) 729 { 730 collActivitys = new ArrayList (); 731 } 732 else 733 { 734 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 735 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria); 736 } 737 } 738 else 739 { 740 744 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 745 if (!lastActivitysCriteria.equals(criteria)) 746 { 747 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria); 748 } 749 } 750 lastActivitysCriteria = criteria; 751 752 return collActivitys; 753 } 754 755 756 757 758 759 760 761 762 763 774 protected List getActivitysJoinScarabUserImplRelatedByNewUserId(Criteria criteria) 775 throws TorqueException 776 { 777 if (collActivitys == null) 778 { 779 if (isNew()) 780 { 781 collActivitys = new ArrayList (); 782 } 783 else 784 { 785 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 786 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria); 787 } 788 } 789 else 790 { 791 795 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 796 if (!lastActivitysCriteria.equals(criteria)) 797 { 798 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria); 799 } 800 } 801 lastActivitysCriteria = criteria; 802 803 return collActivitys; 804 } 805 806 807 808 809 810 811 812 813 814 825 protected List getActivitysJoinAttributeOptionRelatedByOldOptionId(Criteria criteria) 826 throws TorqueException 827 { 828 if (collActivitys == null) 829 { 830 if (isNew()) 831 { 832 collActivitys = new ArrayList (); 833 } 834 else 835 { 836 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 837 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria); 838 } 839 } 840 else 841 { 842 846 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 847 if (!lastActivitysCriteria.equals(criteria)) 848 { 849 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria); 850 } 851 } 852 lastActivitysCriteria = criteria; 853 854 return collActivitys; 855 } 856 857 858 859 860 861 862 863 864 865 876 protected List getActivitysJoinAttributeOptionRelatedByNewOptionId(Criteria criteria) 877 throws TorqueException 878 { 879 if (collActivitys == null) 880 { 881 if (isNew()) 882 { 883 collActivitys = new ArrayList (); 884 } 885 else 886 { 887 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 888 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria); 889 } 890 } 891 else 892 { 893 897 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 898 if (!lastActivitysCriteria.equals(criteria)) 899 { 900 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria); 901 } 902 } 903 lastActivitysCriteria = criteria; 904 905 return collActivitys; 906 } 907 908 909 910 911 912 913 914 915 916 927 protected List getActivitysJoinAttachment(Criteria criteria) 928 throws TorqueException 929 { 930 if (collActivitys == null) 931 { 932 if (isNew()) 933 { 934 collActivitys = new ArrayList (); 935 } 936 else 937 { 938 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 939 collActivitys = ActivityPeer.doSelectJoinAttachment(criteria); 940 } 941 } 942 else 943 { 944 948 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 949 if (!lastActivitysCriteria.equals(criteria)) 950 { 951 collActivitys = ActivityPeer.doSelectJoinAttachment(criteria); 952 } 953 } 954 lastActivitysCriteria = criteria; 955 956 return collActivitys; 957 } 958 959 960 961 962 963 964 965 966 967 978 protected List getActivitysJoinDepend(Criteria criteria) 979 throws TorqueException 980 { 981 if (collActivitys == null) 982 { 983 if (isNew()) 984 { 985 collActivitys = new ArrayList (); 986 } 987 else 988 { 989 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 990 collActivitys = ActivityPeer.doSelectJoinDepend(criteria); 991 } 992 } 993 else 994 { 995 999 criteria.add(ActivityPeer.TRANSACTION_ID, getActivitySetId() ); 1000 if (!lastActivitysCriteria.equals(criteria)) 1001 { 1002 collActivitys = ActivityPeer.doSelectJoinDepend(criteria); 1003 } 1004 } 1005 lastActivitysCriteria = criteria; 1006 1007 return collActivitys; 1008 } 1009 1010 1011 1012 1013 1014 1017 protected List collIssues; 1018 1019 1024 protected void initIssues() 1025 { 1026 if (collIssues == null) 1027 { 1028 collIssues = new ArrayList (); 1029 } 1030 } 1031 1032 1033 1040 public void addIssue(Issue l) throws TorqueException 1041 { 1042 getIssues().add(l); 1043 l.setActivitySet((ActivitySet)this); 1044 } 1045 1046 1049 private Criteria lastIssuesCriteria = null; 1050 1051 1058 public List getIssues() throws TorqueException 1059 { 1060 if (collIssues == null) 1061 { 1062 collIssues = getIssues(new Criteria(10)); 1063 } 1064 return collIssues; 1065 } 1066 1067 1078 public List getIssues(Criteria criteria) throws TorqueException 1079 { 1080 if (collIssues == null) 1081 { 1082 if (isNew()) 1083 { 1084 collIssues = new ArrayList (); 1085 } 1086 else 1087 { 1088 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1089 collIssues = IssuePeer.doSelect(criteria); 1090 } 1091 } 1092 else 1093 { 1094 if (!isNew()) 1096 { 1097 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1101 if (!lastIssuesCriteria.equals(criteria)) 1102 { 1103 collIssues = IssuePeer.doSelect(criteria); 1104 } 1105 } 1106 } 1107 lastIssuesCriteria = criteria; 1108 1109 return collIssues; 1110 } 1111 1112 1120 public List getIssues(Connection con) throws TorqueException 1121 { 1122 if (collIssues == null) 1123 { 1124 collIssues = getIssues(new Criteria(10),con); 1125 } 1126 return collIssues; 1127 } 1128 1129 1141 public List getIssues(Criteria criteria,Connection con) throws TorqueException 1142 { 1143 if (collIssues == null) 1144 { 1145 if (isNew()) 1146 { 1147 collIssues = new ArrayList (); 1148 } 1149 else 1150 { 1151 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1152 collIssues = IssuePeer.doSelect(criteria,con); 1153 } 1154 } 1155 else 1156 { 1157 if (!isNew()) 1159 { 1160 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1164 if (!lastIssuesCriteria.equals(criteria)) 1165 { 1166 collIssues = IssuePeer.doSelect(criteria,con); 1167 } 1168 } 1169 } 1170 lastIssuesCriteria = criteria; 1171 1172 return collIssues; 1173 } 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1196 protected List getIssuesJoinScarabModule(Criteria criteria) 1197 throws TorqueException 1198 { 1199 if (collIssues == null) 1200 { 1201 if (isNew()) 1202 { 1203 collIssues = new ArrayList (); 1204 } 1205 else 1206 { 1207 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1208 collIssues = IssuePeer.doSelectJoinScarabModule(criteria); 1209 } 1210 } 1211 else 1212 { 1213 1217 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1218 if (!lastIssuesCriteria.equals(criteria)) 1219 { 1220 collIssues = IssuePeer.doSelectJoinScarabModule(criteria); 1221 } 1222 } 1223 lastIssuesCriteria = criteria; 1224 1225 return collIssues; 1226 } 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1247 protected List getIssuesJoinIssueType(Criteria criteria) 1248 throws TorqueException 1249 { 1250 if (collIssues == null) 1251 { 1252 if (isNew()) 1253 { 1254 collIssues = new ArrayList (); 1255 } 1256 else 1257 { 1258 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1259 collIssues = IssuePeer.doSelectJoinIssueType(criteria); 1260 } 1261 } 1262 else 1263 { 1264 1268 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1269 if (!lastIssuesCriteria.equals(criteria)) 1270 { 1271 collIssues = IssuePeer.doSelectJoinIssueType(criteria); 1272 } 1273 } 1274 lastIssuesCriteria = criteria; 1275 1276 return collIssues; 1277 } 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1298 protected List getIssuesJoinActivitySet(Criteria criteria) 1299 throws TorqueException 1300 { 1301 if (collIssues == null) 1302 { 1303 if (isNew()) 1304 { 1305 collIssues = new ArrayList (); 1306 } 1307 else 1308 { 1309 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1310 collIssues = IssuePeer.doSelectJoinActivitySet(criteria); 1311 } 1312 } 1313 else 1314 { 1315 1319 criteria.add(IssuePeer.CREATED_TRANS_ID, getActivitySetId() ); 1320 if (!lastIssuesCriteria.equals(criteria)) 1321 { 1322 collIssues = IssuePeer.doSelectJoinActivitySet(criteria); 1323 } 1324 } 1325 lastIssuesCriteria = criteria; 1326 1327 return collIssues; 1328 } 1329 1330 1331 1332 1333 private static List fieldNames = null; 1334 1335 1340 public static synchronized List getFieldNames() 1341 { 1342 if (fieldNames == null) 1343 { 1344 fieldNames = new ArrayList (); 1345 fieldNames.add("ActivitySetId"); 1346 fieldNames.add("TypeId"); 1347 fieldNames.add("AttachmentId"); 1348 fieldNames.add("CreatedBy"); 1349 fieldNames.add("CreatedDate"); 1350 fieldNames = Collections.unmodifiableList(fieldNames); 1351 } 1352 return fieldNames; 1353 } 1354 1355 1361 public Object getByName(String name) 1362 { 1363 if (name.equals("ActivitySetId")) 1364 { 1365 return getActivitySetId(); 1366 } 1367 if (name.equals("TypeId")) 1368 { 1369 return getTypeId(); 1370 } 1371 if (name.equals("AttachmentId")) 1372 { 1373 return getAttachmentId(); 1374 } 1375 if (name.equals("CreatedBy")) 1376 { 1377 return getCreatedBy(); 1378 } 1379 if (name.equals("CreatedDate")) 1380 { 1381 return getCreatedDate(); 1382 } 1383 return null; 1384 } 1385 1386 1394 public Object getByPeerName(String name) 1395 { 1396 if (name.equals(ActivitySetPeer.TRANSACTION_ID)) 1397 { 1398 return getActivitySetId(); 1399 } 1400 if (name.equals(ActivitySetPeer.TYPE_ID)) 1401 { 1402 return getTypeId(); 1403 } 1404 if (name.equals(ActivitySetPeer.ATTACHMENT_ID)) 1405 { 1406 return getAttachmentId(); 1407 } 1408 if (name.equals(ActivitySetPeer.CREATED_BY)) 1409 { 1410 return getCreatedBy(); 1411 } 1412 if (name.equals(ActivitySetPeer.CREATED_DATE)) 1413 { 1414 return getCreatedDate(); 1415 } 1416 return null; 1417 } 1418 1419 1426 public Object getByPosition(int pos) 1427 { 1428 if (pos == 0) 1429 { 1430 return getActivitySetId(); 1431 } 1432 if (pos == 1) 1433 { 1434 return getTypeId(); 1435 } 1436 if (pos == 2) 1437 { 1438 return getAttachmentId(); 1439 } 1440 if (pos == 3) 1441 { 1442 return getCreatedBy(); 1443 } 1444 if (pos == 4) 1445 { 1446 return getCreatedDate(); 1447 } 1448 return null; 1449 } 1450 1451 1457 public void save() throws Exception 1458 { 1459 save(ActivitySetPeer.getMapBuilder() 1460 .getDatabaseMap().getName()); 1461 } 1462 1463 1473 public void save(String dbName) throws TorqueException 1474 { 1475 Connection con = null; 1476 try 1477 { 1478 con = Transaction.begin(dbName); 1479 save(con); 1480 Transaction.commit(con); 1481 } 1482 catch(TorqueException e) 1483 { 1484 Transaction.safeRollback(con); 1485 throw e; 1486 } 1487 } 1488 1489 1491 private boolean alreadyInSave = false; 1492 1502 public void save(Connection con) throws TorqueException 1503 { 1504 if (!alreadyInSave) 1505 { 1506 alreadyInSave = true; 1507 1508 1509 1510 if (isModified()) 1512 { 1513 if (isNew()) 1514 { 1515 ActivitySetPeer.doInsert((ActivitySet)this, con); 1516 setNew(false); 1517 } 1518 else 1519 { 1520 ActivitySetPeer.doUpdate((ActivitySet)this, con); 1521 } 1522 1523 if (isCacheOnSave()) 1524 { 1525 ActivitySetManager.putInstance(this); 1526 } 1527 } 1528 1529 1530 if (collActivitys != null) 1531 { 1532 for (int i = 0; i < collActivitys.size(); i++) 1533 { 1534 ((Activity)collActivitys.get(i)).save(con); 1535 } 1536 } 1537 1538 if (collIssues != null) 1539 { 1540 for (int i = 0; i < collIssues.size(); i++) 1541 { 1542 ((Issue)collIssues.get(i)).save(con); 1543 } 1544 } 1545 alreadyInSave = false; 1546 } 1547 } 1548 1549 1553 protected boolean isCacheOnSave() 1554 { 1555 return true; 1556 } 1557 1558 1559 1564 public void setPrimaryKey(ObjectKey activitySetId) 1565 throws TorqueException { 1566 setActivitySetId(new Long (((NumberKey)activitySetId).longValue())); 1567 } 1568 1569 1574 public void setPrimaryKey(String key) throws TorqueException 1575 { 1576 setActivitySetId(new Long (key)); 1577 } 1578 1579 1580 1584 public ObjectKey getPrimaryKey() 1585 { 1586 return SimpleKey.keyFor(getActivitySetId()); 1587 } 1588 1589 1593 public String getQueryKey() 1594 { 1595 if (getPrimaryKey() == null) 1596 { 1597 return ""; 1598 } 1599 else 1600 { 1601 return getPrimaryKey().toString(); 1602 } 1603 } 1604 1605 1609 public void setQueryKey(String key) 1610 throws TorqueException 1611 { 1612 setPrimaryKey(key); 1613 } 1614 1615 1621 public ActivitySet copy() throws TorqueException 1622 { 1623 ActivitySet copyObj = new ActivitySet(); 1624 copyObj.setActivitySetId(activitySetId); 1625 copyObj.setTypeId(typeId); 1626 copyObj.setAttachmentId(attachmentId); 1627 copyObj.setCreatedBy(createdBy); 1628 copyObj.setCreatedDate(createdDate); 1629 1630 copyObj.setActivitySetId((Long )null); 1631 1632 1633 1634 List v = getActivitys(); 1635 for (int i = 0; i < v.size(); i++) 1636 { 1637 Activity obj = (Activity) v.get(i); 1638 copyObj.addActivity(obj.copy()); 1639 } 1640 1641 1642 v = getIssues(); 1643 for (int i = 0; i < v.size(); i++) 1644 { 1645 Issue obj = (Issue) v.get(i); 1646 copyObj.addIssue(obj.copy()); 1647 } 1648 return copyObj; 1649 } 1650 1651 1657 public ActivitySetPeer getPeer() 1658 { 1659 return peer; 1660 } 1661 1662 public String toString() 1663 { 1664 StringBuffer str = new StringBuffer (); 1665 str.append("ActivitySet:\n"); 1666 str.append("ActivitySetId = ") 1667 .append(getActivitySetId()) 1668 .append("\n"); 1669 str.append("TypeId = ") 1670 .append(getTypeId()) 1671 .append("\n"); 1672 str.append("AttachmentId = ") 1673 .append(getAttachmentId()) 1674 .append("\n"); 1675 str.append("CreatedBy = ") 1676 .append(getCreatedBy()) 1677 .append("\n"); 1678 str.append("CreatedDate = ") 1679 .append(getCreatedDate()) 1680 .append("\n"); 1681 return(str.toString()); 1682 } 1683} 1684 | Popular Tags |