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 34 public abstract class BaseAttachment extends BaseObject 35 implements org.apache.fulcrum.intake.Retrievable 36 { 37 38 private static final AttachmentPeer peer = 39 new AttachmentPeer(); 40 41 42 43 private Long attachmentId; 44 45 46 private Long issueId; 47 48 49 private Integer typeId; 50 51 52 private String name; 53 54 55 private String data; 56 57 58 private String fileName; 59 60 61 private String mimeType; 62 63 64 private Integer modifiedBy; 65 66 67 private Integer createdBy; 68 69 70 private Date modifiedDate; 71 72 73 private Date createdDate; 74 75 76 private boolean deleted = false; 77 78 79 84 public Long getAttachmentId() 85 { 86 return attachmentId; 87 } 88 89 90 95 public void setAttachmentId(Long v) throws TorqueException 96 { 97 98 if (!ObjectUtils.equals(this.attachmentId, v)) 99 { 100 this.attachmentId = v; 101 setModified(true); 102 } 103 104 105 106 if (collActivitys != null) 108 { 109 for (int i = 0; i < collActivitys.size(); i++) 110 { 111 ((Activity) collActivitys.get(i)) 112 .setAttachmentId(v); 113 } 114 } 115 116 if (collActivitySets != null) 118 { 119 for (int i = 0; i < collActivitySets.size(); i++) 120 { 121 ((ActivitySet) collActivitySets.get(i)) 122 .setAttachmentId(v); 123 } 124 } 125 } 126 127 132 public Long getIssueId() 133 { 134 return issueId; 135 } 136 137 138 143 public void setIssueId(Long v) throws TorqueException 144 { 145 146 if (!ObjectUtils.equals(this.issueId, v)) 147 { 148 this.issueId = v; 149 setModified(true); 150 } 151 152 153 if (aIssue != null && !ObjectUtils.equals(aIssue.getIssueId(), v)) 154 { 155 aIssue = null; 156 } 157 158 } 159 160 165 public Integer getTypeId() 166 { 167 return typeId; 168 } 169 170 171 176 public void setTypeId(Integer v) throws TorqueException 177 { 178 179 if (!ObjectUtils.equals(this.typeId, v)) 180 { 181 this.typeId = v; 182 setModified(true); 183 } 184 185 186 if (aAttachmentType != null && !ObjectUtils.equals(aAttachmentType.getAttachmentTypeId(), v)) 187 { 188 aAttachmentType = null; 189 } 190 191 } 192 193 198 public String getName() 199 { 200 return name; 201 } 202 203 204 209 public void setName(String v) 210 { 211 212 if (!ObjectUtils.equals(this.name, v)) 213 { 214 this.name = v; 215 setModified(true); 216 } 217 218 219 } 220 221 226 public String getData() 227 { 228 return data; 229 } 230 231 232 237 public void setData(String v) 238 { 239 240 if (!ObjectUtils.equals(this.data, v)) 241 { 242 this.data = v; 243 setModified(true); 244 } 245 246 247 } 248 249 254 public String getFileName() 255 { 256 return fileName; 257 } 258 259 260 265 public void setFileName(String v) 266 { 267 268 if (!ObjectUtils.equals(this.fileName, v)) 269 { 270 this.fileName = v; 271 setModified(true); 272 } 273 274 275 } 276 277 282 public String getMimeType() 283 { 284 return mimeType; 285 } 286 287 288 293 public void setMimeType(String v) 294 { 295 296 if (!ObjectUtils.equals(this.mimeType, v)) 297 { 298 this.mimeType = v; 299 setModified(true); 300 } 301 302 303 } 304 305 310 public Integer getModifiedBy() 311 { 312 return modifiedBy; 313 } 314 315 316 321 public void setModifiedBy(Integer v) throws TorqueException 322 { 323 324 if (!ObjectUtils.equals(this.modifiedBy, v)) 325 { 326 this.modifiedBy = v; 327 setModified(true); 328 } 329 330 331 if (aScarabUserRelatedByModifiedBy != null && !ObjectUtils.equals(aScarabUserRelatedByModifiedBy.getUserId(), v)) 332 { 333 aScarabUserRelatedByModifiedBy = null; 334 } 335 336 } 337 338 343 public Integer getCreatedBy() 344 { 345 return createdBy; 346 } 347 348 349 354 public void setCreatedBy(Integer v) throws TorqueException 355 { 356 357 if (!ObjectUtils.equals(this.createdBy, v)) 358 { 359 this.createdBy = v; 360 setModified(true); 361 } 362 363 364 if (aScarabUserRelatedByCreatedBy != null && !ObjectUtils.equals(aScarabUserRelatedByCreatedBy.getUserId(), v)) 365 { 366 aScarabUserRelatedByCreatedBy = null; 367 } 368 369 } 370 371 376 public Date getModifiedDate() 377 { 378 return modifiedDate; 379 } 380 381 382 387 public void setModifiedDate(Date v) 388 { 389 390 if (!ObjectUtils.equals(this.modifiedDate, v)) 391 { 392 this.modifiedDate = v; 393 setModified(true); 394 } 395 396 397 } 398 399 404 public Date getCreatedDate() 405 { 406 return createdDate; 407 } 408 409 410 415 public void setCreatedDate(Date v) 416 { 417 418 if (!ObjectUtils.equals(this.createdDate, v)) 419 { 420 this.createdDate = v; 421 setModified(true); 422 } 423 424 425 } 426 427 432 public boolean getDeleted() 433 { 434 return deleted; 435 } 436 437 438 443 public void setDeleted(boolean v) 444 { 445 446 if (this.deleted != v) 447 { 448 this.deleted = v; 449 setModified(true); 450 } 451 452 453 } 454 455 456 457 458 private Issue aIssue; 459 460 466 public void setIssue(Issue v) throws TorqueException 467 { 468 if (v == null) 469 { 470 setIssueId((Long ) null); 471 } 472 else 473 { 474 setIssueId(v.getIssueId()); 475 } 476 aIssue = v; 477 } 478 479 480 486 public Issue getIssue() throws TorqueException 487 { 488 if ( !ObjectUtils.equals(getIssueId(), null) ) 489 { 490 return IssueManager.getInstance(SimpleKey.keyFor(getIssueId())); 491 } 492 return aIssue; 493 } 494 495 501 public void setIssueKey(ObjectKey key) throws TorqueException 502 { 503 504 setIssueId(new Long (((NumberKey) key).longValue())); 505 } 506 507 508 509 private AttachmentType aAttachmentType; 510 511 517 public void setAttachmentType(AttachmentType v) throws TorqueException 518 { 519 if (v == null) 520 { 521 setTypeId((Integer ) null); 522 } 523 else 524 { 525 setTypeId(v.getAttachmentTypeId()); 526 } 527 aAttachmentType = v; 528 } 529 530 531 537 public AttachmentType getAttachmentType() throws TorqueException 538 { 539 if ( !ObjectUtils.equals(getTypeId(), null) ) 540 { 541 return AttachmentTypeManager.getInstance(SimpleKey.keyFor(getTypeId())); 542 } 543 return aAttachmentType; 544 } 545 546 552 public void setAttachmentTypeKey(ObjectKey key) throws TorqueException 553 { 554 555 setTypeId(new Integer (((NumberKey) key).intValue())); 556 } 557 558 559 560 private ScarabUser aScarabUserRelatedByCreatedBy; 561 562 568 public void setScarabUserRelatedByCreatedBy(ScarabUser v) throws TorqueException 569 { 570 if (v == null) 571 { 572 setCreatedBy((Integer ) null); 573 } 574 else 575 { 576 setCreatedBy(v.getUserId()); 577 } 578 aScarabUserRelatedByCreatedBy = v; 579 } 580 581 582 588 public ScarabUser getScarabUserRelatedByCreatedBy() throws TorqueException 589 { 590 if ( !ObjectUtils.equals(getCreatedBy(), null) ) 591 { 592 return ScarabUserManager.getInstance(SimpleKey.keyFor(getCreatedBy())); 593 } 594 return aScarabUserRelatedByCreatedBy; 595 } 596 597 603 public void setScarabUserRelatedByCreatedByKey(ObjectKey key) throws TorqueException 604 { 605 606 setCreatedBy(new Integer (((NumberKey) key).intValue())); 607 } 608 609 610 611 private ScarabUser aScarabUserRelatedByModifiedBy; 612 613 619 public void setScarabUserRelatedByModifiedBy(ScarabUser v) throws TorqueException 620 { 621 if (v == null) 622 { 623 setModifiedBy((Integer ) null); 624 } 625 else 626 { 627 setModifiedBy(v.getUserId()); 628 } 629 aScarabUserRelatedByModifiedBy = v; 630 } 631 632 633 639 public ScarabUser getScarabUserRelatedByModifiedBy() throws TorqueException 640 { 641 if ( !ObjectUtils.equals(getModifiedBy(), null) ) 642 { 643 return ScarabUserManager.getInstance(SimpleKey.keyFor(getModifiedBy())); 644 } 645 return aScarabUserRelatedByModifiedBy; 646 } 647 648 654 public void setScarabUserRelatedByModifiedByKey(ObjectKey key) throws TorqueException 655 { 656 657 setModifiedBy(new Integer (((NumberKey) key).intValue())); 658 } 659 660 661 662 665 protected List collActivitys; 666 667 672 protected void initActivitys() 673 { 674 if (collActivitys == null) 675 { 676 collActivitys = new ArrayList (); 677 } 678 } 679 680 681 688 public void addActivity(Activity l) throws TorqueException 689 { 690 getActivitys().add(l); 691 l.setAttachment((Attachment)this); 692 } 693 694 697 private Criteria lastActivitysCriteria = null; 698 699 706 public List getActivitys() throws TorqueException 707 { 708 if (collActivitys == null) 709 { 710 collActivitys = getActivitys(new Criteria(10)); 711 } 712 return collActivitys; 713 } 714 715 726 public List getActivitys(Criteria criteria) throws TorqueException 727 { 728 if (collActivitys == null) 729 { 730 if (isNew()) 731 { 732 collActivitys = new ArrayList (); 733 } 734 else 735 { 736 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 737 collActivitys = ActivityPeer.doSelect(criteria); 738 } 739 } 740 else 741 { 742 if (!isNew()) 744 { 745 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 749 if (!lastActivitysCriteria.equals(criteria)) 750 { 751 collActivitys = ActivityPeer.doSelect(criteria); 752 } 753 } 754 } 755 lastActivitysCriteria = criteria; 756 757 return collActivitys; 758 } 759 760 768 public List getActivitys(Connection con) throws TorqueException 769 { 770 if (collActivitys == null) 771 { 772 collActivitys = getActivitys(new Criteria(10),con); 773 } 774 return collActivitys; 775 } 776 777 789 public List getActivitys(Criteria criteria,Connection con) throws TorqueException 790 { 791 if (collActivitys == null) 792 { 793 if (isNew()) 794 { 795 collActivitys = new ArrayList (); 796 } 797 else 798 { 799 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 800 collActivitys = ActivityPeer.doSelect(criteria,con); 801 } 802 } 803 else 804 { 805 if (!isNew()) 807 { 808 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 812 if (!lastActivitysCriteria.equals(criteria)) 813 { 814 collActivitys = ActivityPeer.doSelect(criteria,con); 815 } 816 } 817 } 818 lastActivitysCriteria = criteria; 819 820 return collActivitys; 821 } 822 823 824 825 826 827 828 829 830 831 832 833 844 protected List getActivitysJoinIssue(Criteria criteria) 845 throws TorqueException 846 { 847 if (collActivitys == null) 848 { 849 if (isNew()) 850 { 851 collActivitys = new ArrayList (); 852 } 853 else 854 { 855 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 856 collActivitys = ActivityPeer.doSelectJoinIssue(criteria); 857 } 858 } 859 else 860 { 861 865 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 866 if (!lastActivitysCriteria.equals(criteria)) 867 { 868 collActivitys = ActivityPeer.doSelectJoinIssue(criteria); 869 } 870 } 871 lastActivitysCriteria = criteria; 872 873 return collActivitys; 874 } 875 876 877 878 879 880 881 882 883 884 895 protected List getActivitysJoinAttribute(Criteria criteria) 896 throws TorqueException 897 { 898 if (collActivitys == null) 899 { 900 if (isNew()) 901 { 902 collActivitys = new ArrayList (); 903 } 904 else 905 { 906 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 907 collActivitys = ActivityPeer.doSelectJoinAttribute(criteria); 908 } 909 } 910 else 911 { 912 916 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 917 if (!lastActivitysCriteria.equals(criteria)) 918 { 919 collActivitys = ActivityPeer.doSelectJoinAttribute(criteria); 920 } 921 } 922 lastActivitysCriteria = criteria; 923 924 return collActivitys; 925 } 926 927 928 929 930 931 932 933 934 935 946 protected List getActivitysJoinActivitySet(Criteria criteria) 947 throws TorqueException 948 { 949 if (collActivitys == null) 950 { 951 if (isNew()) 952 { 953 collActivitys = new ArrayList (); 954 } 955 else 956 { 957 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 958 collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria); 959 } 960 } 961 else 962 { 963 967 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 968 if (!lastActivitysCriteria.equals(criteria)) 969 { 970 collActivitys = ActivityPeer.doSelectJoinActivitySet(criteria); 971 } 972 } 973 lastActivitysCriteria = criteria; 974 975 return collActivitys; 976 } 977 978 979 980 981 982 983 984 985 986 997 protected List getActivitysJoinScarabUserImplRelatedByOldUserId(Criteria criteria) 998 throws TorqueException 999 { 1000 if (collActivitys == null) 1001 { 1002 if (isNew()) 1003 { 1004 collActivitys = new ArrayList (); 1005 } 1006 else 1007 { 1008 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1009 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria); 1010 } 1011 } 1012 else 1013 { 1014 1018 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1019 if (!lastActivitysCriteria.equals(criteria)) 1020 { 1021 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByOldUserId(criteria); 1022 } 1023 } 1024 lastActivitysCriteria = criteria; 1025 1026 return collActivitys; 1027 } 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1048 protected List getActivitysJoinScarabUserImplRelatedByNewUserId(Criteria criteria) 1049 throws TorqueException 1050 { 1051 if (collActivitys == null) 1052 { 1053 if (isNew()) 1054 { 1055 collActivitys = new ArrayList (); 1056 } 1057 else 1058 { 1059 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1060 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria); 1061 } 1062 } 1063 else 1064 { 1065 1069 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1070 if (!lastActivitysCriteria.equals(criteria)) 1071 { 1072 collActivitys = ActivityPeer.doSelectJoinScarabUserImplRelatedByNewUserId(criteria); 1073 } 1074 } 1075 lastActivitysCriteria = criteria; 1076 1077 return collActivitys; 1078 } 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1099 protected List getActivitysJoinAttributeOptionRelatedByOldOptionId(Criteria criteria) 1100 throws TorqueException 1101 { 1102 if (collActivitys == null) 1103 { 1104 if (isNew()) 1105 { 1106 collActivitys = new ArrayList (); 1107 } 1108 else 1109 { 1110 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1111 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria); 1112 } 1113 } 1114 else 1115 { 1116 1120 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1121 if (!lastActivitysCriteria.equals(criteria)) 1122 { 1123 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByOldOptionId(criteria); 1124 } 1125 } 1126 lastActivitysCriteria = criteria; 1127 1128 return collActivitys; 1129 } 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1150 protected List getActivitysJoinAttributeOptionRelatedByNewOptionId(Criteria criteria) 1151 throws TorqueException 1152 { 1153 if (collActivitys == null) 1154 { 1155 if (isNew()) 1156 { 1157 collActivitys = new ArrayList (); 1158 } 1159 else 1160 { 1161 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1162 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria); 1163 } 1164 } 1165 else 1166 { 1167 1171 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1172 if (!lastActivitysCriteria.equals(criteria)) 1173 { 1174 collActivitys = ActivityPeer.doSelectJoinAttributeOptionRelatedByNewOptionId(criteria); 1175 } 1176 } 1177 lastActivitysCriteria = criteria; 1178 1179 return collActivitys; 1180 } 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1201 protected List getActivitysJoinAttachment(Criteria criteria) 1202 throws TorqueException 1203 { 1204 if (collActivitys == null) 1205 { 1206 if (isNew()) 1207 { 1208 collActivitys = new ArrayList (); 1209 } 1210 else 1211 { 1212 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1213 collActivitys = ActivityPeer.doSelectJoinAttachment(criteria); 1214 } 1215 } 1216 else 1217 { 1218 1222 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1223 if (!lastActivitysCriteria.equals(criteria)) 1224 { 1225 collActivitys = ActivityPeer.doSelectJoinAttachment(criteria); 1226 } 1227 } 1228 lastActivitysCriteria = criteria; 1229 1230 return collActivitys; 1231 } 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1252 protected List getActivitysJoinDepend(Criteria criteria) 1253 throws TorqueException 1254 { 1255 if (collActivitys == null) 1256 { 1257 if (isNew()) 1258 { 1259 collActivitys = new ArrayList (); 1260 } 1261 else 1262 { 1263 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1264 collActivitys = ActivityPeer.doSelectJoinDepend(criteria); 1265 } 1266 } 1267 else 1268 { 1269 1273 criteria.add(ActivityPeer.ATTACHMENT_ID, getAttachmentId() ); 1274 if (!lastActivitysCriteria.equals(criteria)) 1275 { 1276 collActivitys = ActivityPeer.doSelectJoinDepend(criteria); 1277 } 1278 } 1279 lastActivitysCriteria = criteria; 1280 1281 return collActivitys; 1282 } 1283 1284 1285 1286 1287 1288 1291 protected List collActivitySets; 1292 1293 1298 protected void initActivitySets() 1299 { 1300 if (collActivitySets == null) 1301 { 1302 collActivitySets = new ArrayList (); 1303 } 1304 } 1305 1306 1307 1314 public void addActivitySet(ActivitySet l) throws TorqueException 1315 { 1316 getActivitySets().add(l); 1317 l.setAttachment((Attachment)this); 1318 } 1319 1320 1323 private Criteria lastActivitySetsCriteria = null; 1324 1325 1332 public List getActivitySets() throws TorqueException 1333 { 1334 if (collActivitySets == null) 1335 { 1336 collActivitySets = getActivitySets(new Criteria(10)); 1337 } 1338 return collActivitySets; 1339 } 1340 1341 1352 public List getActivitySets(Criteria criteria) throws TorqueException 1353 { 1354 if (collActivitySets == null) 1355 { 1356 if (isNew()) 1357 { 1358 collActivitySets = new ArrayList (); 1359 } 1360 else 1361 { 1362 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1363 collActivitySets = ActivitySetPeer.doSelect(criteria); 1364 } 1365 } 1366 else 1367 { 1368 if (!isNew()) 1370 { 1371 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1375 if (!lastActivitySetsCriteria.equals(criteria)) 1376 { 1377 collActivitySets = ActivitySetPeer.doSelect(criteria); 1378 } 1379 } 1380 } 1381 lastActivitySetsCriteria = criteria; 1382 1383 return collActivitySets; 1384 } 1385 1386 1394 public List getActivitySets(Connection con) throws TorqueException 1395 { 1396 if (collActivitySets == null) 1397 { 1398 collActivitySets = getActivitySets(new Criteria(10),con); 1399 } 1400 return collActivitySets; 1401 } 1402 1403 1415 public List getActivitySets(Criteria criteria,Connection con) throws TorqueException 1416 { 1417 if (collActivitySets == null) 1418 { 1419 if (isNew()) 1420 { 1421 collActivitySets = new ArrayList (); 1422 } 1423 else 1424 { 1425 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1426 collActivitySets = ActivitySetPeer.doSelect(criteria,con); 1427 } 1428 } 1429 else 1430 { 1431 if (!isNew()) 1433 { 1434 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1438 if (!lastActivitySetsCriteria.equals(criteria)) 1439 { 1440 collActivitySets = ActivitySetPeer.doSelect(criteria,con); 1441 } 1442 } 1443 } 1444 lastActivitySetsCriteria = criteria; 1445 1446 return collActivitySets; 1447 } 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1470 protected List getActivitySetsJoinScarabUserImpl(Criteria criteria) 1471 throws TorqueException 1472 { 1473 if (collActivitySets == null) 1474 { 1475 if (isNew()) 1476 { 1477 collActivitySets = new ArrayList (); 1478 } 1479 else 1480 { 1481 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1482 collActivitySets = ActivitySetPeer.doSelectJoinScarabUserImpl(criteria); 1483 } 1484 } 1485 else 1486 { 1487 1491 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1492 if (!lastActivitySetsCriteria.equals(criteria)) 1493 { 1494 collActivitySets = ActivitySetPeer.doSelectJoinScarabUserImpl(criteria); 1495 } 1496 } 1497 lastActivitySetsCriteria = criteria; 1498 1499 return collActivitySets; 1500 } 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1521 protected List getActivitySetsJoinActivitySetType(Criteria criteria) 1522 throws TorqueException 1523 { 1524 if (collActivitySets == null) 1525 { 1526 if (isNew()) 1527 { 1528 collActivitySets = new ArrayList (); 1529 } 1530 else 1531 { 1532 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1533 collActivitySets = ActivitySetPeer.doSelectJoinActivitySetType(criteria); 1534 } 1535 } 1536 else 1537 { 1538 1542 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1543 if (!lastActivitySetsCriteria.equals(criteria)) 1544 { 1545 collActivitySets = ActivitySetPeer.doSelectJoinActivitySetType(criteria); 1546 } 1547 } 1548 lastActivitySetsCriteria = criteria; 1549 1550 return collActivitySets; 1551 } 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1572 protected List getActivitySetsJoinAttachment(Criteria criteria) 1573 throws TorqueException 1574 { 1575 if (collActivitySets == null) 1576 { 1577 if (isNew()) 1578 { 1579 collActivitySets = new ArrayList (); 1580 } 1581 else 1582 { 1583 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1584 collActivitySets = ActivitySetPeer.doSelectJoinAttachment(criteria); 1585 } 1586 } 1587 else 1588 { 1589 1593 criteria.add(ActivitySetPeer.ATTACHMENT_ID, getAttachmentId() ); 1594 if (!lastActivitySetsCriteria.equals(criteria)) 1595 { 1596 collActivitySets = ActivitySetPeer.doSelectJoinAttachment(criteria); 1597 } 1598 } 1599 lastActivitySetsCriteria = criteria; 1600 1601 return collActivitySets; 1602 } 1603 1604 1605 1606 1607 private static List fieldNames = null; 1608 1609 1614 public static synchronized List getFieldNames() 1615 { 1616 if (fieldNames == null) 1617 { 1618 fieldNames = new ArrayList (); 1619 fieldNames.add("AttachmentId"); 1620 fieldNames.add("IssueId"); 1621 fieldNames.add("TypeId"); 1622 fieldNames.add("Name"); 1623 fieldNames.add("Data"); 1624 fieldNames.add("FileName"); 1625 fieldNames.add("MimeType"); 1626 fieldNames.add("ModifiedBy"); 1627 fieldNames.add("CreatedBy"); 1628 fieldNames.add("ModifiedDate"); 1629 fieldNames.add("CreatedDate"); 1630 fieldNames.add("Deleted"); 1631 fieldNames = Collections.unmodifiableList(fieldNames); 1632 } 1633 return fieldNames; 1634 } 1635 1636 1642 public Object getByName(String name) 1643 { 1644 if (name.equals("AttachmentId")) 1645 { 1646 return getAttachmentId(); 1647 } 1648 if (name.equals("IssueId")) 1649 { 1650 return getIssueId(); 1651 } 1652 if (name.equals("TypeId")) 1653 { 1654 return getTypeId(); 1655 } 1656 if (name.equals("Name")) 1657 { 1658 return getName(); 1659 } 1660 if (name.equals("Data")) 1661 { 1662 return getData(); 1663 } 1664 if (name.equals("FileName")) 1665 { 1666 return getFileName(); 1667 } 1668 if (name.equals("MimeType")) 1669 { 1670 return getMimeType(); 1671 } 1672 if (name.equals("ModifiedBy")) 1673 { 1674 return getModifiedBy(); 1675 } 1676 if (name.equals("CreatedBy")) 1677 { 1678 return getCreatedBy(); 1679 } 1680 if (name.equals("ModifiedDate")) 1681 { 1682 return getModifiedDate(); 1683 } 1684 if (name.equals("CreatedDate")) 1685 { 1686 return getCreatedDate(); 1687 } 1688 if (name.equals("Deleted")) 1689 { 1690 return Boolean.valueOf(getDeleted()); 1691 } 1692 return null; 1693 } 1694 1695 1703 public Object getByPeerName(String name) 1704 { 1705 if (name.equals(AttachmentPeer.ATTACHMENT_ID)) 1706 { 1707 return getAttachmentId(); 1708 } 1709 if (name.equals(AttachmentPeer.ISSUE_ID)) 1710 { 1711 return getIssueId(); 1712 } 1713 if (name.equals(AttachmentPeer.ATTACHMENT_TYPE_ID)) 1714 { 1715 return getTypeId(); 1716 } 1717 if (name.equals(AttachmentPeer.ATTACHMENT_NAME)) 1718 { 1719 return getName(); 1720 } 1721 if (name.equals(AttachmentPeer.ATTACHMENT_DATA)) 1722 { 1723 return getData(); 1724 } 1725 if (name.equals(AttachmentPeer.ATTACHMENT_FILE_PATH)) 1726 { 1727 return getFileName(); 1728 } 1729 if (name.equals(AttachmentPeer.ATTACHMENT_MIME_TYPE)) 1730 { 1731 return getMimeType(); 1732 } 1733 if (name.equals(AttachmentPeer.MODIFIED_BY)) 1734 { 1735 return getModifiedBy(); 1736 } 1737 if (name.equals(AttachmentPeer.CREATED_BY)) 1738 { 1739 return getCreatedBy(); 1740 } 1741 if (name.equals(AttachmentPeer.MODIFIED_DATE)) 1742 { 1743 return getModifiedDate(); 1744 } 1745 if (name.equals(AttachmentPeer.CREATED_DATE)) 1746 { 1747 return getCreatedDate(); 1748 } 1749 if (name.equals(AttachmentPeer.DELETED)) 1750 { 1751 return Boolean.valueOf(getDeleted()); 1752 } 1753 return null; 1754 } 1755 1756 1763 public Object getByPosition(int pos) 1764 { 1765 if (pos == 0) 1766 { 1767 return getAttachmentId(); 1768 } 1769 if (pos == 1) 1770 { 1771 return getIssueId(); 1772 } 1773 if (pos == 2) 1774 { 1775 return getTypeId(); 1776 } 1777 if (pos == 3) 1778 { 1779 return getName(); 1780 } 1781 if (pos == 4) 1782 { 1783 return getData(); 1784 } 1785 if (pos == 5) 1786 { 1787 return getFileName(); 1788 } 1789 if (pos == 6) 1790 { 1791 return getMimeType(); 1792 } 1793 if (pos == 7) 1794 { 1795 return getModifiedBy(); 1796 } 1797 if (pos == 8) 1798 { 1799 return getCreatedBy(); 1800 } 1801 if (pos == 9) 1802 { 1803 return getModifiedDate(); 1804 } 1805 if (pos == 10) 1806 { 1807 return getCreatedDate(); 1808 } 1809 if (pos == 11) 1810 { 1811 return Boolean.valueOf(getDeleted()); 1812 } 1813 return null; 1814 } 1815 1816 1822 public void save() throws Exception 1823 { 1824 save(AttachmentPeer.getMapBuilder() 1825 .getDatabaseMap().getName()); 1826 } 1827 1828 1838 public void save(String dbName) throws TorqueException 1839 { 1840 Connection con = null; 1841 try 1842 { 1843 con = Transaction.begin(dbName); 1844 save(con); 1845 Transaction.commit(con); 1846 } 1847 catch(TorqueException e) 1848 { 1849 Transaction.safeRollback(con); 1850 throw e; 1851 } 1852 } 1853 1854 1856 private boolean alreadyInSave = false; 1857 1867 public void save(Connection con) throws TorqueException 1868 { 1869 if (!alreadyInSave) 1870 { 1871 alreadyInSave = true; 1872 1873 1874 1875 if (isModified()) 1877 { 1878 if (isNew()) 1879 { 1880 AttachmentPeer.doInsert((Attachment)this, con); 1881 setNew(false); 1882 } 1883 else 1884 { 1885 AttachmentPeer.doUpdate((Attachment)this, con); 1886 } 1887 1888 if (isCacheOnSave()) 1889 { 1890 AttachmentManager.putInstance(this); 1891 } 1892 } 1893 1894 1895 if (collActivitys != null) 1896 { 1897 for (int i = 0; i < collActivitys.size(); i++) 1898 { 1899 ((Activity)collActivitys.get(i)).save(con); 1900 } 1901 } 1902 1903 if (collActivitySets != null) 1904 { 1905 for (int i = 0; i < collActivitySets.size(); i++) 1906 { 1907 ((ActivitySet)collActivitySets.get(i)).save(con); 1908 } 1909 } 1910 alreadyInSave = false; 1911 } 1912 } 1913 1914 1918 protected boolean isCacheOnSave() 1919 { 1920 return true; 1921 } 1922 1923 1924 1929 public void setPrimaryKey(ObjectKey attachmentId) 1930 throws TorqueException { 1931 setAttachmentId(new Long (((NumberKey)attachmentId).longValue())); 1932 } 1933 1934 1939 public void setPrimaryKey(String key) throws TorqueException 1940 { 1941 setAttachmentId(new Long (key)); 1942 } 1943 1944 1945 1949 public ObjectKey getPrimaryKey() 1950 { 1951 return SimpleKey.keyFor(getAttachmentId()); 1952 } 1953 1954 1958 public String getQueryKey() 1959 { 1960 if (getPrimaryKey() == null) 1961 { 1962 return ""; 1963 } 1964 else 1965 { 1966 return getPrimaryKey().toString(); 1967 } 1968 } 1969 1970 1974 public void setQueryKey(String key) 1975 throws TorqueException 1976 { 1977 setPrimaryKey(key); 1978 } 1979 1980 1986 public Attachment copy() throws TorqueException 1987 { 1988 Attachment copyObj = new Attachment(); 1989 copyObj.setAttachmentId(attachmentId); 1990 copyObj.setIssueId(issueId); 1991 copyObj.setTypeId(typeId); 1992 copyObj.setName(name); 1993 copyObj.setData(data); 1994 copyObj.setFileName(fileName); 1995 copyObj.setMimeType(mimeType); 1996 copyObj.setModifiedBy(modifiedBy); 1997 copyObj.setCreatedBy(createdBy); 1998 copyObj.setModifiedDate(modifiedDate); 1999 copyObj.setCreatedDate(createdDate); 2000 copyObj.setDeleted(deleted); 2001 2002 copyObj.setAttachmentId((Long )null); 2003 2004 2005 2006 List v = getActivitys(); 2007 for (int i = 0; i < v.size(); i++) 2008 { 2009 Activity obj = (Activity) v.get(i); 2010 copyObj.addActivity(obj.copy()); 2011 } 2012 2013 2014 v = getActivitySets(); 2015 for (int i = 0; i < v.size(); i++) 2016 { 2017 ActivitySet obj = (ActivitySet) v.get(i); 2018 copyObj.addActivitySet(obj.copy()); 2019 } 2020 return copyObj; 2021 } 2022 2023 2029 public AttachmentPeer getPeer() 2030 { 2031 return peer; 2032 } 2033 2034 public String toString() 2035 { 2036 StringBuffer str = new StringBuffer (); 2037 str.append("Attachment:\n"); 2038 str.append("AttachmentId = ") 2039 .append(getAttachmentId()) 2040 .append("\n"); 2041 str.append("IssueId = ") 2042 .append(getIssueId()) 2043 .append("\n"); 2044 str.append("TypeId = ") 2045 .append(getTypeId()) 2046 .append("\n"); 2047 str.append("Name = ") 2048 .append(getName()) 2049 .append("\n"); 2050 str.append("Data = ") 2051 .append(getData()) 2052 .append("\n"); 2053 str.append("FileName = ") 2054 .append(getFileName()) 2055 .append("\n"); 2056 str.append("MimeType = ") 2057 .append(getMimeType()) 2058 .append("\n"); 2059 str.append("ModifiedBy = ") 2060 .append(getModifiedBy()) 2061 .append("\n"); 2062 str.append("CreatedBy = ") 2063 .append(getCreatedBy()) 2064 .append("\n"); 2065 str.append("ModifiedDate = ") 2066 .append(getModifiedDate()) 2067 .append("\n"); 2068 str.append("CreatedDate = ") 2069 .append(getCreatedDate()) 2070 .append("\n"); 2071 str.append("Deleted = ") 2072 .append(getDeleted()) 2073 .append("\n"); 2074 return(str.toString()); 2075 } 2076} 2077 | Popular Tags |