1 106 package com.ivata.groupware.business.library.struts; 107 108 import java.util.HashMap ; 109 import java.util.List ; 110 import java.util.Map ; 111 import java.util.Set ; 112 import java.util.Vector ; 113 114 import javax.servlet.http.HttpServletRequest ; 115 import javax.servlet.http.HttpSession ; 116 117 import org.apache.struts.action.ActionMapping; 118 119 import com.ivata.groupware.admin.security.server.SecuritySession; 120 import com.ivata.groupware.business.library.Library; 121 import com.ivata.groupware.business.library.item.LibraryItemDO; 122 import com.ivata.mask.Mask; 123 import com.ivata.mask.MaskFactory; 124 import com.ivata.mask.util.StringHandling; 125 import com.ivata.mask.validation.ValidationError; 126 import com.ivata.mask.validation.ValidationErrors; 127 128 129 138 public class ItemForm extends LibraryForm { 139 142 private String comment; 143 144 147 private String deleteFileButton; 148 149 153 private String displayIncludePage; 154 158 private int displayPage; 159 160 164 private List fileList = new Vector (); 165 166 170 private LibraryItemDO item; 171 172 private Library library; 173 174 178 private String linkPage; 179 180 185 private String newPage; 186 187 199 private String [] newPoint; 200 201 206 private String nextPageLink; 207 208 212 private String pageLinks; 213 214 219 private String previousPageLink; 220 221 225 private Map selectedAttachedFilesIds; 226 227 230 private String [] selectedNewFilesIds; 231 232 236 private String submitIncludePage; 237 238 242 private String summaryPromptKey; 243 244 247 private String summaryThemeName; 248 249 253 private String summaryTitleKey; 254 255 258 private String themeName; 259 260 264 private Map topicCaptions; 265 266 270 private Set topicIds; 271 272 276 private Map topicImages; 277 278 282 private List uploadingFileList; 283 private Mask mask; 284 292 public ItemForm(final Library library, final MaskFactory maskFactory) { 293 this.library = library; 294 mask = maskFactory.getMask(LibraryItemDO.class); 295 } 296 297 302 protected void clear() { 303 comment = null; 304 deleteFileButton = null; 305 displayIncludePage = null; 306 displayPage = -1; 307 fileList = new Vector (); 309 item = null; 310 linkPage = null; 311 newPage = null; 312 newPoint = new String []{ }; 313 nextPageLink = ""; 314 pageLinks = ""; 315 previousPageLink = ""; 316 selectedAttachedFilesIds = null; 317 selectedNewFilesIds = null; 318 submitIncludePage = null; 319 summaryPromptKey = null; 320 summaryThemeName = null; 321 summaryTitleKey = null; 322 themeName = null; 323 topicCaptions = null; 324 topicIds = null; 325 topicImages = null; 326 uploadingFileList = null; 327 } 328 329 334 public final String getComment() { 335 return comment; 336 } 337 338 343 public final String getDeleteFileButton() { 344 return this.deleteFileButton; 345 } 346 347 353 public final String getDisplayIncludePage() { 354 return displayIncludePage; 355 } 356 357 363 public final int getDisplayPage() { 364 return displayPage; 365 } 366 367 373 public List getFileList() { 374 return this.fileList; 375 } 376 377 383 public final LibraryItemDO getItem() { 384 return item; 385 } 386 387 393 public final String getLinkPage() { 394 return linkPage; 395 } 396 397 403 public final String getNewPage() { 404 return newPage; 405 } 406 407 420 public final String getNewPoint(final int index) { 421 return this.newPoint[0]; 424 } 425 426 433 public final String getNextPageLink() { 434 return nextPageLink; 435 } 436 437 443 public final String getPageLinks() { 444 return pageLinks; 445 } 446 447 454 public final String getPreviousPageLink() { 455 return previousPageLink; 456 } 457 458 463 public final Object getSelectedAttachedFilesIds(final String key) { 464 return this.selectedAttachedFilesIds.get(key); 465 } 466 467 472 public final String [] getSelectedNewFilesIds() { 473 return this.selectedNewFilesIds; 474 } 475 476 482 public final String getSubmitIncludePage() { 483 return submitIncludePage; 484 } 485 486 492 public final String getSummaryPromptKey() { 493 return summaryPromptKey; 494 } 495 496 501 public final String getSummaryThemeName() { 502 return summaryThemeName; 503 } 504 505 511 public final String getSummaryTitleKey() { 512 return summaryTitleKey; 513 } 514 515 520 public final String getThemeName() { 521 return themeName; 522 } 523 524 530 public final Map getTopicCaptions() { 531 return topicCaptions; 532 } 533 534 540 public final Set getTopicIds() { 541 return topicIds; 542 } 543 544 550 public final Map getTopicImages() { 551 return topicImages; 552 } 553 554 560 public List getUploadingFileList() { 561 return this.uploadingFileList; 562 } 563 564 573 public void reset(final ActionMapping mapping, 574 final HttpServletRequest request) { 575 super.reset(mapping, request); 576 setEdit(null); 577 newPage = null; 578 comment = null; 579 580 newPoint = new String [1]; 582 583 if (this.selectedAttachedFilesIds == null) { 584 this.selectedAttachedFilesIds = new HashMap (); 585 } else { 586 this.selectedAttachedFilesIds.clear(); 587 } 588 589 this.selectedNewFilesIds = new String [0]; 590 591 605 } 606 607 612 public final void setComment(final String comment) { 613 this.comment = comment; 614 } 615 616 621 public final void setDeleteFileButton(final String deleteFileButton) { 622 this.deleteFileButton = deleteFileButton; 623 } 624 625 631 public final void setDisplayIncludePage(final String displayIncludePage) { 632 this.displayIncludePage = displayIncludePage; 633 } 634 635 641 public final void setDisplayPage(final int displayPage) { 642 this.displayPage = displayPage; 643 } 644 645 651 public final void setFileList(final List fileList) { 652 this.fileList = fileList; 653 } 654 655 661 public final void setItem(final LibraryItemDO item) { 662 this.item = item; 663 } 664 665 671 public final void setLinkPage(final String linkPage) { 672 this.linkPage = linkPage; 673 } 674 675 681 public final void setNewPage(final String newPage) { 682 this.newPage = newPage; 683 } 684 685 699 public final void setNewPoint(final int index, 700 final String value) { 701 this.newPoint[0] = String.valueOf(index); 702 } 703 704 711 public final void setNextPageLink(final String nextPageLink) { 712 this.nextPageLink = nextPageLink; 713 } 714 715 721 public final void setPageLinks(final String pageLinks) { 722 this.pageLinks = pageLinks; 723 } 724 725 732 public final void setPreviousPageLink(final String previousPageLink) { 733 this.previousPageLink = previousPageLink; 734 } 735 736 742 public final void setSelectedAttachedFilesIds(final String key, 743 final Object value) { 744 this.selectedAttachedFilesIds.put(key, value); 745 } 746 747 752 public final void setSelectedNewFilesIds(final String [] selectedNewFilesIds) { 753 this.selectedNewFilesIds = selectedNewFilesIds; 754 } 755 756 762 public final void setSubmitIncludePage(final String submitIncludePage) { 763 this.submitIncludePage = submitIncludePage; 764 } 765 766 772 public final void setSummaryPromptKey(final String summaryPromptKey) { 773 this.summaryPromptKey = summaryPromptKey; 774 } 775 776 781 public final void setSummaryThemeName(final String summaryThemeName) { 782 this.summaryThemeName = summaryThemeName; 783 } 784 785 791 public final void setSummaryTitleKey(final String summaryTitleKey) { 792 this.summaryTitleKey = summaryTitleKey; 793 } 794 795 800 public final void setThemeName(final String themeName) { 801 this.themeName = themeName; 802 } 803 804 810 public final void setTopicCaptions(final Map topicCaptions) { 811 this.topicCaptions = topicCaptions; 812 } 813 814 820 public final void setTopicIds(final Set topicIds) { 821 this.topicIds = topicIds; 822 } 823 824 830 public final void setTopicImages(final Map topicImages) { 831 this.topicImages = topicImages; 832 } 833 834 840 public final void setUploadingFileList(final List uploadingFileList) { 841 this.uploadingFileList = uploadingFileList; 842 } 843 844 861 public ValidationErrors validate(final HttpServletRequest request, 862 final HttpSession session) { 863 ValidationErrors errors = new ValidationErrors(); 864 865 if ((item == null) || !StringHandling.isNullOrEmpty(getClear())) { 867 return null; 868 } 869 870 if ((item.getTopic() == null) 872 || (item.getTopic().getId().equals(new Integer (-1)))) { 873 errors.add(new ValidationError( 874 "submit", 875 Library.BUNDLE_PATH, 876 mask.getField("topicId"), 877 "errors.library.item.submit.noTopic")); 878 } 879 880 if (StringHandling.isNullOrEmpty(getOk())) { 882 return errors; 883 } 884 885 SecuritySession securitySession = (SecuritySession) session.getAttribute("securitySession"); 887 ValidationErrors libraryErrors = library.validate(securitySession, item); 888 if (libraryErrors != null) { 889 errors.addAll(libraryErrors); 890 } 891 892 return errors; 893 } 894 } 895 | Popular Tags |