Browse Source

In certificates, registration Authority, volume, number added to form

Andrew Grant 6 months ago
parent
commit
2ae165b7a0

+ 9 - 9
src/main/java/scot/carricksoftware/grants/controllers/certificates/birthcertificates/BirthCertificateFormControllerImpl.java

@@ -25,7 +25,7 @@ import scot.carricksoftware.grants.converters.certificates.birthcertificates.Bir
 import scot.carricksoftware.grants.converters.certificates.birthcertificates.BirthCertificateConverterImpl;
 import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
-import scot.carricksoftware.grants.services.places.places.PlaceService;
+import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
 import scot.carricksoftware.grants.validators.certificates.BirthCertificateCommandValidator;
 
 @SuppressWarnings("LoggingSimilarMessage")
@@ -39,7 +39,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
     private final BirthCertificateConverterImpl birthCertificateConverter;
     private final BirthCertificateCommandValidator birthCertificateCommandValidator;
     private final PersonService personService;
-    private final PlaceService placeService;
+    private final OrganisationService organisationService;
 
 
     public BirthCertificateFormControllerImpl(BirthCertificateService birthCertificateService,
@@ -47,7 +47,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
                                               BirthCertificateConverterImpl birthCertificateConverter,
                                               BirthCertificateCommandValidator birthCertificateCommandValidator,
                                               PersonService personService,
-                                              PlaceService placeService) {
+                                              OrganisationService organisationService) {
         this.birthCertificateService = birthCertificateService;
         this.birthCertificateCommandConverter = birthCertificateCommandConverter;
 
@@ -55,7 +55,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         this.birthCertificateConverter = birthCertificateConverter;
         this.birthCertificateCommandValidator = birthCertificateCommandValidator;
         this.personService = personService;
-        this.placeService = placeService;
+        this.organisationService = organisationService;
     }
 
     @SuppressWarnings("SameReturnValue")
@@ -65,7 +65,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         logger.debug("BirthCertificateFormControllerImpl::getNewBirthCertificate");
         model.addAttribute(AttributeConstants.BIRTH_CERTIFICATE_COMMAND, new BirthCertificateCommandImpl());
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
-        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return ViewConstants.BIRTH_CERTIFICATE_FORM;
     }
 
@@ -76,7 +76,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         logger.debug("BirthCertificateFormControllerImpl::birthCertificateEdit");
         model.addAttribute(AttributeConstants.BIRTH_CERTIFICATE_COMMAND, birthCertificateService.findById(Long.valueOf(id)));
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
-        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return ViewConstants.BIRTH_CERTIFICATE_FORM;
     }
 
@@ -92,14 +92,14 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         if (bindingResult.hasErrors()) {
             bindingResult.getAllErrors().forEach(error -> logger.debug(error.getDefaultMessage()));
             model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
-            model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+            model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
             return ViewConstants.BIRTH_CERTIFICATE_FORM;
         }
 
         BirthCertificateCommand savedCommand = birthCertificateService.saveBirthCertificateCommand(birthCertificateCommand);
         model.addAttribute(AttributeConstants.BIRTH_CERTIFICATE_COMMAND, savedCommand);
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
-        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return MappingConstants.REDIRECT + CertificateMappingConstants.BIRTH_CERTIFICATE_SHOW.replace("{id}", "" + savedCommand.getId());
     }
 
@@ -112,7 +112,7 @@ public class BirthCertificateFormControllerImpl implements BirthCertificateFormC
         BirthCertificateCommand savedCommand = birthCertificateConverter.convert(birthCertificateService.findById(Long.valueOf(id)));
         model.addAttribute(AttributeConstants.BIRTH_CERTIFICATE_COMMAND, savedCommand);
         model.addAttribute(AttributeConstants.PEOPLE, personService.findAll());
-        model.addAttribute(AttributeConstants.PLACES, placeService.findAll());
+        model.addAttribute(AttributeConstants.ORGANISATIONS, organisationService.findAll());
         return ViewConstants.BIRTH_CERTIFICATE_FORM;
     }
 

+ 5 - 0
src/main/java/scot/carricksoftware/grants/domains/places/Organisation.java

@@ -23,4 +23,9 @@ public class Organisation extends BaseEntity {
     public void setName(String name) {
         this.name = name;
     }
+
+    @Override
+    public String toString() {
+        return name;
+    }
 }

+ 74 - 7
src/main/resources/templates/certificates/birthCertificate/form.html

@@ -18,8 +18,6 @@
 
 </head>
 <body>
-<!--/*@thymesVar id="birthCertificateCommand" type="scot.carricksoftware.grants.commands.certificates.birthCertificates.BirthCertificateCommand"*/-->
-<!--/*@thymesVar id="place" type="scot.carricksoftware.grants.domains.places.Place"*/-->
 <div th:insert="~{fragments/layout::banner}"></div>
 
 
@@ -60,10 +58,11 @@
                 </td>
                 <td style="text-align: left;">
                     <div>
-                        <select id="certificateSource" name="place" th:field="*{certificateSource}">
+                        <select id="certificateSource" name="certificateSource" th:field="*{certificateSource}">
                             <option th:value="${''}" th:text="${''}"></option>
-                            <option th:each="place : ${places}"
-                                    th:value="${place.id}" th:text="${place.toString()}"></option>
+                            <!--/*@thymesVar id="organisations" type="scot.carricksoftware.grants.domains.places.Organisation"*/-->
+                            <option th:each="organisation : ${organisations}"
+                                    th:value="${organisation.id}" th:text="${organisation.toString()}"></option>
                         </select>
                         <div th:if="${#fields.hasErrors('certificateSource')}">
                             <ul class="text-danger">
@@ -75,7 +74,7 @@
             </tr>
             <tr>
                 <td style="text-align: right;">
-                    <label for="certificateDate">Issued At (dd/mm/yyyy)&nbsp;</label>
+                    <label for="certificateDate">Certificate Date (dd/mm/yyyy)&nbsp;</label>
                 </td>
                 <td style="text-align: left;">
                     <input class="form-control" id="certificateDate"
@@ -87,7 +86,7 @@
                     </div>
                 </td>
             </tr>
-            <tr>
+            <tr style = "border-bottom: 5px solid #ccc;">
                 <td style="text-align: right;">
                     <label for="certificateType">Certificate Type&nbsp;</label>
                 </td>
@@ -100,8 +99,76 @@
                                     th:value="${value}" th:text="${value.label}"></option>
                         </select>
                     </div>
+                <div th:if="${#fields.hasErrors('certificateType')}">
+                    <ul class="text-danger">
+                        <li th:each="err : ${#fields.errors('certificateType')}" th:text="${err}"/>
+                    </ul>
+                </div>
+            </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="registrationAuthority">Registration Authority&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <select id="registrationAuthority" style="width: 200px;" name="registrationAuthority"
+                                th:field="*{registrationAuthority}">
+                            <option th:value="${''}" th:text="${''}"></option>
+                            <!--/*@thymesVar id="organisations" type="scot.carricksoftware.grants.domains.places.Organisation"*/-->
+                            <option th:each="organisation : ${organisations}"
+                                    th:value="${organisation.id}" th:text="${organisation.name}"></option>
+                        </select>
+                    </div>
+                    <div th:if="${#fields.hasErrors('registrationAuthority')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('registrationAuthority')}" th:text="${err}"/>
+                        </ul>
+                    </div>
                 </td>
             </tr>
+            <tr>
+                <td style="text-align: right;">
+                    <label for="volume">Volume&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <input class="volume" id="volume"
+                                th:field="*{volume}" type="text">
+                        <div th:if="${#fields.hasErrors('volume')}">
+                            <ul class="text-danger">
+                                <li th:each="err : ${#fields.errors('volume')}" th:text="${err}"/>
+                            </ul>
+                        </div>
+
+                    </div>
+                    <div th:if="${#fields.hasErrors('volume')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('volume')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
+            </tr>
+            <tr style = "border-bottom: 5px solid #ccc;">
+                <td style="text-align: right;">
+                    <label for="number">Number&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <input class="number" id="number"
+                               th:field="*{number}" type="text">
+                        <div th:if="${#fields.hasErrors('number')}">
+                            <ul class="text-danger">
+                                <li th:each="err : ${#fields.errors('number')}" th:text="${err}"/>
+                            </ul>
+                        </div>
+
+                    </div>
+                    <div th:if="${#fields.hasErrors('number')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('number')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+                </td>
 
             <tr>
                 <td style="text-align: right;">

+ 3 - 3
src/test/java/scot/carricksoftware/grants/controllers/certificates/birthcertificates/BirthCertificateFormControllerSaveOrUpdateTest.java

@@ -18,7 +18,7 @@ import scot.carricksoftware.grants.converters.certificates.birthcertificates.Bir
 import scot.carricksoftware.grants.converters.certificates.birthcertificates.BirthCertificateConverterImpl;
 import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
-import scot.carricksoftware.grants.services.places.places.PlaceService;
+import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
 import scot.carricksoftware.grants.validators.certificates.BirthCertificateCommandValidator;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -45,7 +45,7 @@ public class BirthCertificateFormControllerSaveOrUpdateTest {
     private PersonService personServiceMock;
 
     @Mock
-    private PlaceService placeServiceMock;
+    private OrganisationService organisationServiceMock;
 
 
 
@@ -68,7 +68,7 @@ public class BirthCertificateFormControllerSaveOrUpdateTest {
                 birthCertificateConverterMock,
                 birthCertificateCommandValidatorMock,
                 personServiceMock,
-                placeServiceMock);
+                organisationServiceMock);
         birthCertificateCommand = new BirthCertificateCommandImpl();
     }
 

+ 3 - 3
src/test/java/scot/carricksoftware/grants/controllers/certificates/birthcertificates/BirthCertificateFormControllerTest.java

@@ -20,7 +20,7 @@ import scot.carricksoftware.grants.converters.certificates.birthcertificates.Bir
 import scot.carricksoftware.grants.domains.certificates.BirthCertificate;
 import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
-import scot.carricksoftware.grants.services.places.places.PlaceService;
+import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
 import scot.carricksoftware.grants.validators.certificates.BirthCertificateCommandValidator;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -50,7 +50,7 @@ public class BirthCertificateFormControllerTest {
     private PersonService personServiceMock;
 
     @Mock
-    private PlaceService placeServiceMock;
+    private OrganisationService organisationServiceMock;
 
     @Mock
     private Model modelMock;
@@ -66,7 +66,7 @@ public class BirthCertificateFormControllerTest {
                 birthCertificateConverterMock,
                 birthCertificateCommandValidatorMock,
                 personServiceMock,
-                placeServiceMock);
+                organisationServiceMock);
     }
 
     @Test

+ 3 - 3
src/test/java/scot/carricksoftware/grants/controllers/certificates/birthcertificates/BirthCertificateFormControllerValidationTest.java

@@ -19,7 +19,7 @@ import scot.carricksoftware.grants.converters.certificates.birthcertificates.Bir
 import scot.carricksoftware.grants.converters.certificates.birthcertificates.BirthCertificateConverterImpl;
 import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
 import scot.carricksoftware.grants.services.people.PersonService;
-import scot.carricksoftware.grants.services.places.places.PlaceService;
+import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
 import scot.carricksoftware.grants.validators.certificates.BirthCertificateCommandValidator;
 
 import static org.mockito.Mockito.verify;
@@ -49,7 +49,7 @@ public class BirthCertificateFormControllerValidationTest {
     private PersonService personServiceMock;
 
     @Mock
-    private PlaceService placeServiceMock;
+    private OrganisationService organisationServiceMock;
 
     @Mock
     private BirthCertificateCommandValidator birthCertificateCommandValidatorMock;
@@ -65,7 +65,7 @@ public class BirthCertificateFormControllerValidationTest {
                 birthCertificateConverterMock,
                 birthCertificateCommandValidatorMock,
                 personServiceMock,
-                placeServiceMock);
+                organisationServiceMock);
     }