|
72 | 72 | import java.time.Year; |
73 | 73 | import java.time.ZoneOffset; |
74 | 74 | import java.util.Collections; |
75 | | -import java.util.HashMap; |
76 | 75 | import java.util.LinkedHashMap; |
77 | 76 | import java.util.List; |
78 | 77 | import java.util.Locale; |
@@ -231,10 +230,7 @@ public String showInfo( |
231 | 230 | return null; |
232 | 231 | } |
233 | 232 |
|
234 | | - Map<String, ?> commonAttrs = |
235 | | - prepareCommonAttrsForSeriesInfo(series, currentUserId, authentication, lang); |
236 | | - model.addAllAttributes(commonAttrs); |
237 | | - |
| 233 | + prepareCommonAttrsForSeriesInfo(model, series, currentUserId, authentication, lang); |
238 | 234 | addSeriesSalesFormToModel(authentication, model); |
239 | 235 | addImageFormToModel(model); |
240 | 236 | addStampsToCollectionForm(model, series); |
@@ -404,10 +400,7 @@ public String processImage( |
404 | 400 | model.addAttribute("maxQuantityOfImagesExceeded", maxQuantityOfImagesExceeded); |
405 | 401 |
|
406 | 402 | if (result.hasErrors() || maxQuantityOfImagesExceeded) { |
407 | | - Map<String, ?> commonAttrs = |
408 | | - prepareCommonAttrsForSeriesInfo(series, currentUserId, authentication, lang); |
409 | | - model.addAllAttributes(commonAttrs); |
410 | | - |
| 403 | + prepareCommonAttrsForSeriesInfo(model, series, currentUserId, authentication, lang); |
411 | 404 | addSeriesSalesFormToModel(authentication, model); |
412 | 405 | addStampsToCollectionForm(model, series); |
413 | 406 |
|
@@ -477,9 +470,7 @@ public String addToCollection( |
477 | 470 | return null; |
478 | 471 | } |
479 | 472 |
|
480 | | - Map<String, ?> commonAttrs = prepareCommonAttrsForSeriesInfo(series, currentUserId, authentication, lang); |
481 | | - model.addAllAttributes(commonAttrs); |
482 | | - |
| 473 | + prepareCommonAttrsForSeriesInfo(model, series, currentUserId, authentication, lang); |
483 | 474 | addSeriesSalesFormToModel(authentication, model); |
484 | 475 | addImageFormToModel(model); |
485 | 476 | addStampsToCollectionForm(model, series); |
@@ -570,10 +561,7 @@ public String processAskForm( |
570 | 561 | model.addAttribute("maxQuantityOfImagesExceeded", maxQuantityOfImagesExceeded); |
571 | 562 |
|
572 | 563 | if (result.hasErrors() || maxQuantityOfImagesExceeded) { |
573 | | - Map<String, ?> commonAttrs = |
574 | | - prepareCommonAttrsForSeriesInfo(series, currentUserId, authentication, lang); |
575 | | - model.addAllAttributes(commonAttrs); |
576 | | - |
| 564 | + prepareCommonAttrsForSeriesInfo(model, series, currentUserId, authentication, lang); |
577 | 565 | addSeriesSalesFormToModel(authentication, model); |
578 | 566 | addImageFormToModel(model); |
579 | 567 | addStampsToCollectionForm(model, series); |
@@ -736,62 +724,60 @@ public static void loadErrorsFromDownloadInterceptor( |
736 | 724 | request.removeAttribute(DownloadImageInterceptor.ERROR_CODE_ATTR_NAME); |
737 | 725 | } |
738 | 726 |
|
739 | | - private Map<String, ?> prepareCommonAttrsForSeriesInfo( |
| 727 | + private void prepareCommonAttrsForSeriesInfo( |
| 728 | + Model model, |
740 | 729 | SeriesDto series, |
741 | 730 | Integer currentUserId, |
742 | 731 | Authentication authentication, |
743 | 732 | String lang) { |
744 | 733 |
|
745 | | - Map<String, Object> model = new HashMap<>(); |
746 | 734 | Integer seriesId = series.getId(); |
747 | 735 |
|
748 | | - model.put("series", series); |
| 736 | + model.addAttribute("series", series); |
749 | 737 |
|
750 | 738 | List<SeriesLinkDto> similarSeries = seriesService.findSimilarSeries(seriesId, lang); |
751 | | - model.put("similarSeries", similarSeries); |
| 739 | + model.addAttribute("similarSeries", similarSeries); |
752 | 740 |
|
753 | 741 | String michelNumbers = CatalogUtils.toShortForm(series.getMichel().getNumbers()); |
754 | 742 | String scottNumbers = CatalogUtils.toShortForm(series.getScott().getNumbers()); |
755 | 743 | String yvertNumbers = CatalogUtils.toShortForm(series.getYvert().getNumbers()); |
756 | 744 | String gibbonsNumbers = CatalogUtils.toShortForm(series.getGibbons().getNumbers()); |
757 | 745 | String solovyovNumbers = CatalogUtils.toShortForm(series.getSolovyov().getNumbers()); |
758 | 746 | String zagorskiNumbers = CatalogUtils.toShortForm(series.getZagorski().getNumbers()); |
759 | | - model.put("michelNumbers", michelNumbers); |
760 | | - model.put("scottNumbers", scottNumbers); |
761 | | - model.put("yvertNumbers", yvertNumbers); |
762 | | - model.put("gibbonsNumbers", gibbonsNumbers); |
763 | | - model.put("solovyovNumbers", solovyovNumbers); |
764 | | - model.put("zagorskiNumbers", zagorskiNumbers); |
| 747 | + model.addAttribute("michelNumbers", michelNumbers); |
| 748 | + model.addAttribute("scottNumbers", scottNumbers); |
| 749 | + model.addAttribute("yvertNumbers", yvertNumbers); |
| 750 | + model.addAttribute("gibbonsNumbers", gibbonsNumbers); |
| 751 | + model.addAttribute("solovyovNumbers", solovyovNumbers); |
| 752 | + model.addAttribute("zagorskiNumbers", zagorskiNumbers); |
765 | 753 |
|
766 | 754 | boolean userCanAddImagesToSeries = |
767 | 755 | isUserCanAddImagesToSeries(authentication, currentUserId, series); |
768 | | - model.put("allowAddingImages", userCanAddImagesToSeries); |
| 756 | + model.addAttribute("allowAddingImages", userCanAddImagesToSeries); |
769 | 757 |
|
770 | 758 | // we require DOWNLOAD_IMAGE and ADD_IMAGES_TO_SERIES in order to reduce |
771 | 759 | // a number of the possible cases to maintain |
772 | 760 | boolean userCanReplaceImages = |
773 | 761 | SecurityContextUtils.hasAuthority(authentication, Authority.REPLACE_IMAGE) |
774 | 762 | && SecurityContextUtils.hasAuthority(authentication, Authority.DOWNLOAD_IMAGE) |
775 | 763 | && SecurityContextUtils.hasAuthority(authentication, Authority.ADD_IMAGES_TO_SERIES); |
776 | | - model.put("allowReplacingImages", userCanReplaceImages); |
| 764 | + model.addAttribute("allowReplacingImages", userCanReplaceImages); |
777 | 765 |
|
778 | 766 | if (SecurityContextUtils.hasAuthority(authentication, Authority.UPDATE_COLLECTION)) { |
779 | 767 | Map<Integer, Integer> seriesInstances = |
780 | 768 | collectionService.findSeriesInstances(currentUserId, seriesId); |
781 | | - model.put("seriesInstances", seriesInstances); |
| 769 | + model.addAttribute("seriesInstances", seriesInstances); |
782 | 770 | } |
783 | 771 |
|
784 | 772 | if (SecurityContextUtils.hasAuthority(authentication, Authority.VIEW_SERIES_SALES)) { |
785 | 773 | List<SeriesSaleDto> seriesSales = seriesSalesService.findSales(seriesId); |
786 | | - model.put("seriesSales", seriesSales); |
| 774 | + model.addAttribute("seriesSales", seriesSales); |
787 | 775 | } |
788 | 776 |
|
789 | 777 | if (SecurityContextUtils.hasAuthority(authentication, Authority.IMPORT_SERIES)) { |
790 | 778 | ImportRequestInfo importInfo = seriesImportService.findRequestInfo(seriesId); |
791 | | - model.put("importInfo", importInfo); |
| 779 | + model.addAttribute("importInfo", importInfo); |
792 | 780 | } |
793 | | - |
794 | | - return model; |
795 | 781 | } |
796 | 782 |
|
797 | 783 | private void addSeriesSalesFormToModel(Authentication authentication, Model model) { |
|
0 commit comments