|
@@ -1,11 +1,10 @@
|
|
|
/*
|
|
/*
|
|
|
- * Copyright (c) Andrew Grant of Carrick Software 21/03/2025, 00:09. All rights reserved.
|
|
|
|
|
|
|
+ * Copyright (c) Andrew Grant of Carrick Software 21/03/2025, 00:07. All rights reserved.
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-package scot.carricksoftware.grants.controllers.census.census;
|
|
|
|
|
|
|
+package scot.carricksoftware.grants.controllers.census.selectedcensus;
|
|
|
|
|
|
|
|
-import jakarta.validation.Valid;
|
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
import org.apache.logging.log4j.Logger;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.stereotype.Controller;
|
|
@@ -14,25 +13,25 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
import scot.carricksoftware.grants.constants.*;
|
|
import scot.carricksoftware.grants.constants.*;
|
|
|
import scot.carricksoftware.grants.controllers.ControllerHelper;
|
|
import scot.carricksoftware.grants.controllers.ControllerHelper;
|
|
|
-import scot.carricksoftware.grants.services.census.census.CensusService;
|
|
|
|
|
|
|
+import scot.carricksoftware.grants.controllers.census.censusentry.CensusEntryListController;
|
|
|
import scot.carricksoftware.grants.services.census.censusentry.CensusEntryService;
|
|
import scot.carricksoftware.grants.services.census.censusentry.CensusEntryService;
|
|
|
|
|
|
|
|
import static java.lang.Integer.max;
|
|
import static java.lang.Integer.max;
|
|
|
|
|
|
|
|
@Controller
|
|
@Controller
|
|
|
-public class SelectedSelectedCensusListControllerImpl implements SelectedCensusListController {
|
|
|
|
|
|
|
+public class SelectedCensusListControllerImpl implements CensusEntryListController {
|
|
|
|
|
+
|
|
|
|
|
+ private static final Logger logger = LogManager.getLogger(SelectedCensusListControllerImpl.class);
|
|
|
|
|
|
|
|
- private static final Logger logger = LogManager.getLogger(SelectedSelectedCensusListControllerImpl.class);
|
|
|
|
|
|
|
|
|
|
private int currentPage = 0;
|
|
private int currentPage = 0;
|
|
|
private final ControllerHelper controllerHelper;
|
|
private final ControllerHelper controllerHelper;
|
|
|
- private final CensusService censusService;
|
|
|
|
|
private final CensusEntryService censusEntryService;
|
|
private final CensusEntryService censusEntryService;
|
|
|
|
|
|
|
|
- public SelectedSelectedCensusListControllerImpl(ControllerHelper controllerHelper,
|
|
|
|
|
- CensusService censusService, CensusEntryService censusEntryService) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public SelectedCensusListControllerImpl(ControllerHelper controllerHelper,
|
|
|
|
|
+ CensusEntryService censusEntryService) {
|
|
|
this.controllerHelper = controllerHelper;
|
|
this.controllerHelper = controllerHelper;
|
|
|
- this.censusService = censusService;
|
|
|
|
|
this.censusEntryService = censusEntryService;
|
|
this.censusEntryService = censusEntryService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -40,35 +39,32 @@ public class SelectedSelectedCensusListControllerImpl implements SelectedCensusL
|
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_LIST)
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_LIST)
|
|
|
@Override
|
|
@Override
|
|
|
public final String getListPage(final Model model) {
|
|
public final String getListPage(final Model model) {
|
|
|
- logger.debug("PersonListControllerImpl::getCensusPage");
|
|
|
|
|
|
|
+ logger.debug("PersonListControllerImpl::getCensusEntryPage");
|
|
|
currentPage = 0;
|
|
currentPage = 0;
|
|
|
return sendAttributesAndReturn(model);
|
|
return sendAttributesAndReturn(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
@SuppressWarnings("SameReturnValue")
|
|
@SuppressWarnings("SameReturnValue")
|
|
|
private String sendAttributesAndReturn(Model model) {
|
|
private String sendAttributesAndReturn(Model model) {
|
|
|
- model.addAttribute(AttributeConstants.CENSUSES, censusService.getPagedCensuses(currentPage));
|
|
|
|
|
|
|
+ model.addAttribute(AttributeConstants.CENSUS_ENTRIES, censusEntryService.getPagedCensusEntries(currentPage));
|
|
|
controllerHelper.addAttributes(model);
|
|
controllerHelper.addAttributes(model);
|
|
|
- return ViewConstants.CENSUS_LIST;
|
|
|
|
|
|
|
+ return ViewConstants.SELECTED_CENSUS_LIST;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("SameReturnValue")
|
|
@SuppressWarnings("SameReturnValue")
|
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_NEXT)
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_NEXT)
|
|
|
@Override
|
|
@Override
|
|
|
public final String getNextPage(final Model model) {
|
|
public final String getNextPage(final Model model) {
|
|
|
- logger.debug("CensusEntriesListControllerImpl::getNextPage");
|
|
|
|
|
|
|
+ logger.debug("CensusEntryListControllerImpl::getNextPage");
|
|
|
currentPage++;
|
|
currentPage++;
|
|
|
return sendAttributesAndReturn(model);
|
|
return sendAttributesAndReturn(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
@SuppressWarnings("SameReturnValue")
|
|
@SuppressWarnings("SameReturnValue")
|
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_PREVIOUS)
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_PREVIOUS)
|
|
|
@Override
|
|
@Override
|
|
|
public final String getPreviousPage(final Model model) {
|
|
public final String getPreviousPage(final Model model) {
|
|
|
- logger.debug("CensusEntriesListControllerImpl::getPreviousPage");
|
|
|
|
|
|
|
+ logger.debug("CensusEntryListControllerImpl::getPreviousPage");
|
|
|
currentPage = max(0, currentPage - 1);
|
|
currentPage = max(0, currentPage - 1);
|
|
|
return sendAttributesAndReturn(model);
|
|
return sendAttributesAndReturn(model);
|
|
|
}
|
|
}
|
|
@@ -76,40 +72,31 @@ public class SelectedSelectedCensusListControllerImpl implements SelectedCensusL
|
|
|
@SuppressWarnings("SameReturnValue")
|
|
@SuppressWarnings("SameReturnValue")
|
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_REWIND)
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_REWIND)
|
|
|
public final String getFirstPage(final Model model) {
|
|
public final String getFirstPage(final Model model) {
|
|
|
- logger.debug("CensusEntriesListControllerImpl::getFirstPage");
|
|
|
|
|
|
|
+ logger.debug("CensusEntryListControllerImpl::getFirstPage");
|
|
|
currentPage = 0;
|
|
currentPage = 0;
|
|
|
return sendAttributesAndReturn(model);
|
|
return sendAttributesAndReturn(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("SameReturnValue")
|
|
@SuppressWarnings("SameReturnValue")
|
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_FF)
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_FF)
|
|
|
|
|
+ @Override
|
|
|
public final String getLastPage(final Model model) {
|
|
public final String getLastPage(final Model model) {
|
|
|
- logger.debug("CensusEntriesListControllerImpl::getLastPage");
|
|
|
|
|
- long censusCount = censusService.count();
|
|
|
|
|
- currentPage = (int) (censusCount / ApplicationConstants.DEFAULT_PAGE_SIZE);
|
|
|
|
|
|
|
+ logger.debug("CensusEntryListControllerImpl::getLastPage");
|
|
|
|
|
+ long censusEntryCount = censusEntryService.count();
|
|
|
|
|
+ currentPage = (int) (censusEntryCount / ApplicationConstants.DEFAULT_PAGE_SIZE);
|
|
|
return sendAttributesAndReturn(model);
|
|
return sendAttributesAndReturn(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
@SuppressWarnings("SameReturnValue")
|
|
@SuppressWarnings("SameReturnValue")
|
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_DELETE)
|
|
@GetMapping(CensusMappingConstants.SELECTED_CENSUS_DELETE)
|
|
|
@Override
|
|
@Override
|
|
|
- public final String censusDelete(@PathVariable final String id) {
|
|
|
|
|
- logger.debug("CensusEntriesListControllerImpl::censusDelete");
|
|
|
|
|
- censusService.deleteById(Long.valueOf(id));
|
|
|
|
|
|
|
+ public final String censusEntryDelete(@PathVariable final String id) {
|
|
|
|
|
+ logger.debug("CensusEntryListControllerImpl::censusEntryDelete");
|
|
|
|
|
+ censusEntryService.deleteById(Long.valueOf(id));
|
|
|
return MappingConstants.REDIRECT + CensusMappingConstants.SELECTED_CENSUS_LIST;
|
|
return MappingConstants.REDIRECT + CensusMappingConstants.SELECTED_CENSUS_LIST;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @SuppressWarnings("SameReturnValue")
|
|
|
|
|
- @GetMapping(CensusMappingConstants.SELECTED_CENSUS_ENTRIES)
|
|
|
|
|
- @Override
|
|
|
|
|
- public String censusEntriesEntries(@Valid @PathVariable final String id, Model model) {
|
|
|
|
|
- logger.debug("CensusEntriesListControllerImpl::censusEntriesEntries");
|
|
|
|
|
- model.addAttribute(AttributeConstants.CENSUS_ENTRIES, censusEntryService.getPagedCensusEntries(currentPage));
|
|
|
|
|
- model.addAttribute(AttributeConstants.CENSUS, censusService.findById(Long.valueOf(id)));
|
|
|
|
|
- return ViewConstants.SELECTED_CENSUS_LIST;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int getPageNumber() {
|
|
public int getPageNumber() {
|
|
|
return currentPage;
|
|
return currentPage;
|