@@ -137,16 +137,9 @@ public void showForm(
137
137
138
138
String lang = LocaleUtils .getLanguageOrNull (userLocale );
139
139
140
- List <CategoryDto > categories =
141
- categoryService .findCategoriesWithParents (lang );
142
- List <FirstLevelCategoryDto > groupedCategories =
143
- GroupByParent .transformCategories (categories );
144
- model .addAttribute ("categories" , groupedCategories );
145
-
146
- List <LinkEntityDto > countries = countryService .findAllAsLinkEntities (lang );
147
- model .addAttribute ("countries" , countries );
148
-
149
- model .addAttribute ("years" , YEARS );
140
+ addCategoriesToModel (model , lang );
141
+ addCountriesToModel (model , lang );
142
+ addYearToModel (model );
150
143
151
144
AddSeriesForm addSeriesForm = new AddSeriesForm ();
152
145
addSeriesForm .setPerforated (true );
@@ -222,16 +215,9 @@ public String processInput(
222
215
if (result .hasErrors ()) {
223
216
String lang = LocaleUtils .getLanguageOrNull (userLocale );
224
217
225
- List <CategoryDto > categories =
226
- categoryService .findCategoriesWithParents (lang );
227
- List <FirstLevelCategoryDto > groupedCategories =
228
- GroupByParent .transformCategories (categories );
229
- model .addAttribute ("categories" , groupedCategories );
230
-
231
- List <LinkEntityDto > countries = countryService .findAllAsLinkEntities (lang );
232
- model .addAttribute ("countries" , countries );
233
-
234
- model .addAttribute ("years" , YEARS );
218
+ addCategoriesToModel (model , lang );
219
+ addCountriesToModel (model , lang );
220
+ addYearToModel (model );
235
221
236
222
// don't try to re-display file upload field
237
223
form .setImage (null );
@@ -493,6 +479,24 @@ public String searchSeriesByCatalog(
493
479
return "series/search_result" ;
494
480
}
495
481
482
+ private void addCategoriesToModel (Model model , String lang ) {
483
+ List <CategoryDto > categories = categoryService .findCategoriesWithParents (lang );
484
+
485
+ List <FirstLevelCategoryDto > groupedCategories =
486
+ GroupByParent .transformCategories (categories );
487
+
488
+ model .addAttribute ("categories" , groupedCategories );
489
+ }
490
+
491
+ private void addCountriesToModel (Model model , String lang ) {
492
+ List <LinkEntityDto > countries = countryService .findAllAsLinkEntities (lang );
493
+ model .addAttribute ("countries" , countries );
494
+ }
495
+
496
+ private void addYearToModel (Model model ) {
497
+ model .addAttribute ("years" , YEARS );
498
+ }
499
+
496
500
// CheckStyle: ignore LineLength for next 1 line
497
501
private Map <String , ?> prepareCommonAttrsForSeriesInfo (SeriesDto series , Integer currentUserId ) {
498
502
Map <String , Object > model = new HashMap <>();
0 commit comments