Andrew Grant 3 месяцев назад
Родитель
Сommit
a961d6a8eb

+ 12 - 0
src/main/java/scot/carricksoftware/grants/controllers/AddAttribute.java

@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grants.controllers;
+
+import org.springframework.ui.Model;
+
+public interface AddAttribute {
+    void AddDeathCertificate(Model model);
+}

+ 34 - 0
src/main/java/scot/carricksoftware/grants/controllers/AddAttributeImpl.java

@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grants.controllers;
+
+import org.springframework.ui.Model;
+import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommandImpl;
+import scot.carricksoftware.grants.constants.AttributeConstants;
+import scot.carricksoftware.grants.services.people.PersonService;
+import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
+import scot.carricksoftware.grants.services.places.places.PlaceService;
+
+public class AddAttributeImpl implements AddAttribute {
+
+    private final PersonService personService;
+    private final PlaceService placeService;
+    private final OrganisationService organisationService;
+
+    public AddAttributeImpl(PersonService personService, PlaceService placeService, OrganisationService organisationService) {
+        this.personService = personService;
+        this.placeService = placeService;
+        this.organisationService = organisationService;
+    }
+
+    @Override
+    public void AddDeathCertificate(Model model) {
+        model.addAttribute(AttributeConstants.DEATH_CERTIFICATE_COMMAND, new DeathCertificateCommandImpl());
+        model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
+        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
+    }
+}

+ 6 - 0
src/main/java/scot/carricksoftware/grants/controllers/certificates/marriagecertificates/MarriageCertificateFormControllerImpl.java

@@ -8,6 +8,7 @@ package scot.carricksoftware.grants.controllers.certificates.marriagecertificate
 import jakarta.validation.Valid;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.validation.BindingResult;
@@ -87,6 +88,11 @@ public class MarriageCertificateFormControllerImpl implements MarriageCertificat
     @Override
     public final String marriageCertificateEdit(@Valid @PathVariable final String id, Model model) {
         logger.debug("MarriageCertificateFormControllerImpl::marriageCertificateEdit");
+        return getString(id, model);
+    }
+
+    @NotNull
+    private String getString(String id, Model model) {
         model.addAttribute(AttributeConstants.MARRIAGE_CERTIFICATE_COMMAND, marriageCertificateService.findById(Long.valueOf(id)));
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
         model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());

+ 15 - 0
src/test/java/scot/carricksoftware/grants/controllers/AddAttributeTest.java

@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grants.controllers;
+
+import org.junit.jupiter.api.BeforeEach;
+
+class AddAttributeTest {
+
+    @BeforeEach
+    void setUp() {
+    }
+}