Răsfoiți Sursa

CensusMappingConstants

Andrew Grant 7 luni în urmă
părinte
comite
19360c44de

+ 60 - 0
src/main/java/scot/carricksoftware/grants/constants/CensusMappingConstants.java

@@ -0,0 +1,60 @@
+/*
+ * Copyright (c)  08 Feb 2025, Andrew Grant of Carrick Software .
+ * All rights reserved.
+ */
+
+package scot.carricksoftware.grants.constants;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class CensusMappingConstants {
+
+    private CensusMappingConstants() {
+        // to stop checkstyle complaining
+    }
+
+
+    @SuppressWarnings("unused")
+    public static final String CENSUS_LIST = "/censuses";
+    @SuppressWarnings("unused")
+    public static final String CENSUS_NEXT = "/censuses/next";
+    @SuppressWarnings("unused")
+    public static final String CENSUS_PREVIOUS = "/censuses/prev";
+    @SuppressWarnings("unused")
+    public static final String CENSUS_REWIND = "/censuses/rewind";
+    @SuppressWarnings("unused")
+    public static final String CENSUS_FF = "/censuses/ff";
+    @SuppressWarnings("unused")
+    public static final String CENSUS_NEW = "/census/new";
+    @SuppressWarnings("unused")
+    public static final String CENSUS = "/census";
+    @SuppressWarnings("unused")
+    public static final String CENSUS_SHOW = "/census/{id}/show";
+    @SuppressWarnings("unused")
+    public static final String CENSUS_DELETE = "/census/{id}/delete";
+    @SuppressWarnings("unused")
+    public static final String CENSUS_EDIT = "census/{id}/edit";
+
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY_LIST = "/censusEntries";
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY_NEXT = "/censusEntries/next";
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY_PREVIOUS = "/censusEntries/prev";
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY_REWIND = "/censusEntries/rewind";
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY_FF = "/censusEntries/ff";
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY_NEW = "/censusEntry/new";
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY = "/censusEntry";
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY_SHOW = "/censusEntry/{id}/show";
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY_DELETE = "/censusEntry/{id}/delete";
+    @SuppressWarnings({"unused"})
+    public static final String CENSUS_ENTRY_EDIT = "censusEntry/{id}/edit";
+
+}

+ 0 - 42
src/main/java/scot/carricksoftware/grants/constants/MappingConstants.java

@@ -98,48 +98,6 @@ public class MappingConstants {
     @SuppressWarnings("unused")
     public static final String PLACE_EDIT = "place/{id}/edit";
 
-    @SuppressWarnings("unused")
-    public static final String CENSUS_LIST = "/censuses";
-    @SuppressWarnings("unused")
-    public static final String CENSUS_NEXT = "/censuses/next";
-    @SuppressWarnings("unused")
-    public static final String CENSUS_PREVIOUS = "/censuses/prev";
-    @SuppressWarnings("unused")
-    public static final String CENSUS_REWIND = "/censuses/rewind";
-    @SuppressWarnings("unused")
-    public static final String CENSUS_FF = "/censuses/ff";
-    @SuppressWarnings("unused")
-    public static final String CENSUS_NEW = "/census/new";
-    @SuppressWarnings("unused")
-    public static final String CENSUS = "/census";
-    @SuppressWarnings("unused")
-    public static final String CENSUS_SHOW = "/census/{id}/show";
-    @SuppressWarnings("unused")
-    public static final String CENSUS_DELETE = "/census/{id}/delete";
-    @SuppressWarnings("unused")
-    public static final String CENSUS_EDIT = "census/{id}/edit";
-
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY_LIST = "/censusEntries";
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY_NEXT = "/censusEntries/next";
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY_PREVIOUS = "/censusEntries/prev";
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY_REWIND = "/censusEntries/rewind";
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY_FF = "/censusEntries/ff";
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY_NEW = "/censusEntry/new";
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY = "/censusEntry";
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY_SHOW = "/censusEntry/{id}/show";
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY_DELETE = "/censusEntry/{id}/delete";
-    @SuppressWarnings({"unused"})
-    public static final String CENSUS_ENTRY_EDIT = "censusEntry/{id}/edit";
-
     @SuppressWarnings({"unused"})
     public static final String BIRTH_CERTIFICATE_LIST = "/birthCertificates";
     @SuppressWarnings({"unused"})

+ 8 - 11
src/main/java/scot/carricksoftware/grants/controllers/census/census/CensusEntriesListControllerImpl.java

@@ -11,10 +11,7 @@ import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
-import scot.carricksoftware.grants.constants.ApplicationConstants;
-import scot.carricksoftware.grants.constants.AttributeConstants;
-import scot.carricksoftware.grants.constants.MappingConstants;
-import scot.carricksoftware.grants.constants.ViewConstants;
+import scot.carricksoftware.grants.constants.*;
 import scot.carricksoftware.grants.controllers.ControllerHelper;
 import scot.carricksoftware.grants.services.census.census.CensusService;
 
@@ -36,7 +33,7 @@ public class CensusEntriesListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_LIST)
+    @GetMapping(CensusMappingConstants.CENSUS_LIST)
     @Override
     public final String getListPage(final Model model) {
         logger.debug("PersonListControllerImpl::getCensusPage");
@@ -52,7 +49,7 @@ public class CensusEntriesListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_NEXT)
+    @GetMapping(CensusMappingConstants.CENSUS_NEXT)
     @Override
     public final String getNextPage(final Model model) {
         logger.debug("CensusListControllerImpl::getNextPage");
@@ -61,7 +58,7 @@ public class CensusEntriesListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_PREVIOUS)
+    @GetMapping(CensusMappingConstants.CENSUS_PREVIOUS)
     @Override
     public final String getPreviousPage(final Model model) {
         logger.debug("CensusListControllerImpl::getPreviousPage");
@@ -70,7 +67,7 @@ public class CensusEntriesListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_REWIND)
+    @GetMapping(CensusMappingConstants.CENSUS_REWIND)
     public final String getFirstPage(final Model model) {
         logger.debug("CensusListControllerImpl::getFirstPage");
         currentPage = 0;
@@ -78,7 +75,7 @@ public class CensusEntriesListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_FF)
+    @GetMapping(CensusMappingConstants.CENSUS_FF)
     @Override
     public final String getLastPage(final Model model) {
         logger.debug("CensusListControllerImpl::getLastPage");
@@ -89,12 +86,12 @@ public class CensusEntriesListControllerImpl implements CensusListController {
 
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_DELETE)
+    @GetMapping(CensusMappingConstants.CENSUS_DELETE)
     @Override
     public final String censusDelete(@PathVariable final String id) {
         logger.debug("CensusListControllerImpl::censusDelete");
         censusService.deleteById(Long.valueOf(id));
-        return MappingConstants.REDIRECT + MappingConstants.CENSUS_LIST;
+        return MappingConstants.REDIRECT + CensusMappingConstants.CENSUS_LIST;
     }
 
     @Override

+ 6 - 5
src/main/java/scot/carricksoftware/grants/controllers/census/census/CensusFormControllerImpl.java

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import scot.carricksoftware.grants.commands.census.CensusCommand;
 import scot.carricksoftware.grants.commands.census.CensusCommandImpl;
 import scot.carricksoftware.grants.constants.AttributeConstants;
+import scot.carricksoftware.grants.constants.CensusMappingConstants;
 import scot.carricksoftware.grants.constants.MappingConstants;
 import scot.carricksoftware.grants.constants.ViewConstants;
 import scot.carricksoftware.grants.converters.census.CensusConverter;
@@ -46,7 +47,7 @@ public class CensusFormControllerImpl implements CensusFormController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_NEW)
+    @GetMapping(CensusMappingConstants.CENSUS_NEW)
     public final String getNewCensus(final Model model) {
         logger.debug("CensusFormControllerImpl::getNewCensus");
         model.addAttribute(AttributeConstants.CENSUS_COMMAND, new CensusCommandImpl());
@@ -55,7 +56,7 @@ public class CensusFormControllerImpl implements CensusFormController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_EDIT)
+    @GetMapping(CensusMappingConstants.CENSUS_EDIT)
     public final String censusEdit(@Valid @PathVariable final String id, Model model) {
         logger.debug("CensusFormControllerImpl::censusEdit");
         model.addAttribute(AttributeConstants.CENSUS_COMMAND, censusService.findById(Long.valueOf(id)));
@@ -65,7 +66,7 @@ public class CensusFormControllerImpl implements CensusFormController {
 
 
     @Override
-    @PostMapping(MappingConstants.CENSUS)
+    @PostMapping(CensusMappingConstants.CENSUS)
     public String saveOrUpdate(@Valid @ModelAttribute CensusCommand censusCommand, BindingResult bindingResult, Model model) {
         logger.debug("CensusFormControllerImpl::saveOrUpdate");
 
@@ -82,12 +83,12 @@ public class CensusFormControllerImpl implements CensusFormController {
         CensusCommand savedCommand = censusService.saveCensusCommand(censusCommand);
         model.addAttribute(AttributeConstants.CENSUS_COMMAND, savedCommand);
         model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
-        return MappingConstants.REDIRECT + MappingConstants.CENSUS_SHOW.replace("{id}", "" + savedCommand.getId());
+        return MappingConstants.REDIRECT + CensusMappingConstants.CENSUS_SHOW.replace("{id}", "" + savedCommand.getId());
     }
 
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_SHOW)
+    @GetMapping(CensusMappingConstants.CENSUS_SHOW)
     public String showById(@PathVariable String id, Model model) {
         logger.debug("CensusFormControllerImpl::saveOrUpdate");
         CensusCommand savedCommand = censusConverter.convert(censusService.findById(Long.valueOf(id)));

+ 8 - 11
src/main/java/scot/carricksoftware/grants/controllers/census/census/CensusListControllerImpl.java

@@ -11,10 +11,7 @@ import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
-import scot.carricksoftware.grants.constants.ApplicationConstants;
-import scot.carricksoftware.grants.constants.AttributeConstants;
-import scot.carricksoftware.grants.constants.MappingConstants;
-import scot.carricksoftware.grants.constants.ViewConstants;
+import scot.carricksoftware.grants.constants.*;
 import scot.carricksoftware.grants.controllers.ControllerHelper;
 import scot.carricksoftware.grants.services.census.census.CensusService;
 
@@ -37,7 +34,7 @@ public class CensusListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_LIST)
+    @GetMapping(CensusMappingConstants.CENSUS_LIST)
     @Override
     public final String getListPage(final Model model) {
         logger.debug("PersonListControllerImpl::getCensusPage");
@@ -53,7 +50,7 @@ public class CensusListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_NEXT)
+    @GetMapping(CensusMappingConstants.CENSUS_NEXT)
     @Override
     public final String getNextPage(final Model model) {
         logger.debug("CensusListControllerImpl::getNextPage");
@@ -62,7 +59,7 @@ public class CensusListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_PREVIOUS)
+    @GetMapping(CensusMappingConstants.CENSUS_PREVIOUS)
     @Override
     public final String getPreviousPage(final Model model) {
         logger.debug("CensusListControllerImpl::getPreviousPage");
@@ -71,7 +68,7 @@ public class CensusListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_REWIND)
+    @GetMapping(CensusMappingConstants.CENSUS_REWIND)
     public final String getFirstPage(final Model model) {
         logger.debug("CensusListControllerImpl::getFirstPage");
         currentPage = 0;
@@ -79,7 +76,7 @@ public class CensusListControllerImpl implements CensusListController {
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_FF)
+    @GetMapping(CensusMappingConstants.CENSUS_FF)
     @Override
     public final String getLastPage(final Model model) {
         logger.debug("CensusListControllerImpl::getLastPage");
@@ -90,12 +87,12 @@ public class CensusListControllerImpl implements CensusListController {
 
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_DELETE)
+    @GetMapping(CensusMappingConstants.CENSUS_DELETE)
     @Override
     public final String censusDelete(@PathVariable final String id) {
         logger.debug("CensusListControllerImpl::censusDelete");
         censusService.deleteById(Long.valueOf(id));
-        return MappingConstants.REDIRECT + MappingConstants.CENSUS_LIST;
+        return MappingConstants.REDIRECT + CensusMappingConstants.CENSUS_LIST;
     }
 
     @Override

+ 6 - 5
src/main/java/scot/carricksoftware/grants/controllers/census/censusentry/CensusEntryFormControllerImpl.java

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import scot.carricksoftware.grants.commands.census.CensusEntryCommand;
 import scot.carricksoftware.grants.commands.census.CensusEntryCommandImpl;
 import scot.carricksoftware.grants.constants.AttributeConstants;
+import scot.carricksoftware.grants.constants.CensusMappingConstants;
 import scot.carricksoftware.grants.constants.MappingConstants;
 import scot.carricksoftware.grants.constants.ViewConstants;
 import scot.carricksoftware.grants.converters.Capitalisation;
@@ -59,7 +60,7 @@ public class CensusEntryFormControllerImpl implements CensusEntryFormController
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_ENTRY_NEW)
+    @GetMapping(CensusMappingConstants.CENSUS_ENTRY_NEW)
     public final String getNewCensusEntry(final Model model) {
         logger.debug("CensusEntryFormControllerImpl::getNewCensusEntry");
         model.addAttribute(AttributeConstants.CENSUS_ENTRY_COMMAND, new CensusEntryCommandImpl());
@@ -69,7 +70,7 @@ public class CensusEntryFormControllerImpl implements CensusEntryFormController
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_ENTRY_EDIT)
+    @GetMapping(CensusMappingConstants.CENSUS_ENTRY_EDIT)
     public final String censusEntryEdit(@Valid @PathVariable final String id, Model model) {
         logger.debug("CensusEntryFormControllerImpl::censusEntryEdit");
         model.addAttribute(AttributeConstants.CENSUS_ENTRY_COMMAND, censusEntryService.findById(Long.valueOf(id)));
@@ -80,7 +81,7 @@ public class CensusEntryFormControllerImpl implements CensusEntryFormController
 
 
     @Override
-    @PostMapping(MappingConstants.CENSUS_ENTRY)
+    @PostMapping(CensusMappingConstants.CENSUS_ENTRY)
     public String saveOrUpdate(@Valid @ModelAttribute CensusEntryCommand censusEntryCommand, BindingResult bindingResult, Model model) {
         logger.debug("CensusEntryFormControllerImpl::saveOrUpdate");
 
@@ -97,12 +98,12 @@ public class CensusEntryFormControllerImpl implements CensusEntryFormController
         CensusEntryCommand savedCommand = censusEntryService.saveCensusEntryCommand(censusEntryCommand);
         updateRecordedYearOfBirth.updateRecordedYearOfBirth(savedCommand);
         model.addAttribute(AttributeConstants.CENSUS_ENTRY_COMMAND, savedCommand);
-        return MappingConstants.REDIRECT + MappingConstants.CENSUS_ENTRY_SHOW.replace("{id}", "" + savedCommand.getId());
+        return MappingConstants.REDIRECT + CensusMappingConstants.CENSUS_ENTRY_SHOW.replace("{id}", "" + savedCommand.getId());
     }
 
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_ENTRY_SHOW)
+    @GetMapping(CensusMappingConstants.CENSUS_ENTRY_SHOW)
     public String showById(@PathVariable String id, Model model) {
         logger.debug("CensusEntryFormControllerImpl::saveOrUpdate");
         CensusEntryCommand savedCommand = censusEntryConverter.convert(censusEntryService.findById(Long.valueOf(id)));

+ 8 - 11
src/main/java/scot/carricksoftware/grants/controllers/census/censusentry/CensusEntryListControllerImpl.java

@@ -11,10 +11,7 @@ import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PathVariable;
-import scot.carricksoftware.grants.constants.ApplicationConstants;
-import scot.carricksoftware.grants.constants.AttributeConstants;
-import scot.carricksoftware.grants.constants.MappingConstants;
-import scot.carricksoftware.grants.constants.ViewConstants;
+import scot.carricksoftware.grants.constants.*;
 import scot.carricksoftware.grants.controllers.ControllerHelper;
 import scot.carricksoftware.grants.services.census.censusentry.CensusEntryService;
 
@@ -38,7 +35,7 @@ public class CensusEntryListControllerImpl implements CensusEntryListController
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_ENTRY_LIST)
+    @GetMapping(CensusMappingConstants.CENSUS_ENTRY_LIST)
     @Override
     public final String getListPage(final Model model) {
         logger.debug("PersonListControllerImpl::getCensusEntryPage");
@@ -54,7 +51,7 @@ public class CensusEntryListControllerImpl implements CensusEntryListController
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_ENTRY_NEXT)
+    @GetMapping(CensusMappingConstants.CENSUS_ENTRY_NEXT)
     @Override
     public final String getNextPage(final Model model) {
         logger.debug("CensusEntryListControllerImpl::getNextPage");
@@ -63,7 +60,7 @@ public class CensusEntryListControllerImpl implements CensusEntryListController
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_ENTRY_PREVIOUS)
+    @GetMapping(CensusMappingConstants.CENSUS_ENTRY_PREVIOUS)
     @Override
     public final String getPreviousPage(final Model model) {
         logger.debug("CensusEntryListControllerImpl::getPreviousPage");
@@ -72,7 +69,7 @@ public class CensusEntryListControllerImpl implements CensusEntryListController
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_ENTRY_REWIND)
+    @GetMapping(CensusMappingConstants.CENSUS_ENTRY_REWIND)
     public final String getFirstPage(final Model model) {
         logger.debug("CensusEntryListControllerImpl::getFirstPage");
         currentPage = 0;
@@ -80,7 +77,7 @@ public class CensusEntryListControllerImpl implements CensusEntryListController
     }
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_ENTRY_FF)
+    @GetMapping(CensusMappingConstants.CENSUS_ENTRY_FF)
     @Override
     public final String getLastPage(final Model model) {
         logger.debug("CensusEntryListControllerImpl::getLastPage");
@@ -91,12 +88,12 @@ public class CensusEntryListControllerImpl implements CensusEntryListController
 
 
     @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CENSUS_ENTRY_DELETE)
+    @GetMapping(CensusMappingConstants.CENSUS_ENTRY_DELETE)
     @Override
     public final String censusEntryDelete(@PathVariable final String id) {
         logger.debug("CensusEntryListControllerImpl::censusEntryDelete");
         censusEntryService.deleteById(Long.valueOf(id));
-        return MappingConstants.REDIRECT + MappingConstants.CENSUS_ENTRY_LIST;
+        return MappingConstants.REDIRECT + CensusMappingConstants.CENSUS_ENTRY_LIST;
     }
 
     @Override