Explorar el Código

Military attributes preserved
When Born validated

Andrew Grant hace 4 meses
padre
commit
7d82e2f0b9

+ 1 - 0
src/main/java/scot/carricksoftware/grants/constants/ValidationConstants.java

@@ -64,6 +64,7 @@ public class ValidationConstants {
     public static final String USUAL_RESIDENCE_AND_UNTRACKED_USUAL_RESIDENCE = "Only one usual residence and untracked usual residence may be specified.";
     public static final String WHEN_BORN_INCORRECT_FORMAT = "The format should be dd/MM/yyyy hh:mm.";
     public static final String WHEN_BORN_IS_NULL = "When born cannot be null.";
+    public static final String WHEN_DIED_IS_NULL = "When died cannot be null.";
     public static final String WHEN_REGISTERED_DATE_IN_FUTURE = "Date should not be in the future.";
     public static final String WHEN_REGISTERED_DATE_IS_INVALID = "When registered date is invalid.";
     public static final String WHEN_REGISTERED_DATE_IS_NULL = "When registered cannot be null.";

+ 6 - 1
src/main/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandConverterImpl.java

@@ -13,12 +13,18 @@ import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
 @Component
 public class DeathCertificateCommandConverterImpl implements DeathCertificateCommandConverter {
 
+    private final DeathCertificateCommandMilitaryConverter militaryConverter;
 
+    public DeathCertificateCommandConverterImpl(DeathCertificateCommandMilitaryConverter militaryConverter) {
+        this.militaryConverter = militaryConverter;
+    }
 
     @Override
     public DeathCertificate convert(DeathCertificateCommand source) {
 
         DeathCertificate target = new DeathCertificate();
+
+        militaryConverter.convert(source, target);
         target.setAge(source.getAge());
         target.setSex(source.getSex());
         target.setWhereDied(source.getWhereDied());
@@ -55,7 +61,6 @@ public class DeathCertificateCommandConverterImpl implements DeathCertificateCom
         target.setCauseOfDeath(source.getCauseOfDeath());
 
 
-
         return target;
     }
 }

+ 2 - 2
src/main/java/scot/carricksoftware/grants/converters/certificates/deathcertificates/DeathCertificateCommandMilitaryConverterImpl.java

@@ -5,11 +5,11 @@
 
 package scot.carricksoftware.grants.converters.certificates.deathcertificates;
 
-import org.apache.logging.log4j.core.tools.picocli.CommandLine;
+import org.springframework.stereotype.Component;
 import scot.carricksoftware.grants.commands.certificates.deathcertificates.DeathCertificateCommand;
 import scot.carricksoftware.grants.domains.certificates.DeathCertificate;
 
-@CommandLine.Command
+@Component
 public class DeathCertificateCommandMilitaryConverterImpl implements DeathCertificateCommandMilitaryConverter {
 
     @Override

+ 6 - 0
src/main/java/scot/carricksoftware/grants/validators/certificates/deathcertificate/DeathCertificateNullFieldsValidatorImpl.java

@@ -40,6 +40,12 @@ public class DeathCertificateNullFieldsValidatorImpl implements DeathCertificate
         validateInformantQualification(deathCertificateCommand, bindingResult);
         validateCertificateSource(deathCertificateCommand, bindingResult);
         validateRegistrationAuthority(deathCertificateCommand, bindingResult);
+        validateWhenDied(deathCertificateCommand, bindingResult);
+    }
+
+    private void validateWhenDied(DeathCertificateCommand deathCertificateCommand, BindingResult bindingResult) {
+        logger.debug("DeathCertificateNullFieldsValidator::validateWhenDied");
+        validateTypes.validateNullOrEmptyString(deathCertificateCommand.getWhenDied(), "whenDied", ValidationConstants.WHEN_DIED_IS_NULL, bindingResult);
     }
 
     private void validateDeceased(DeathCertificateCommand deathCertificateCommand, BindingResult bindingResult) {

+ 1 - 3
src/main/resources/application.properties

@@ -2,7 +2,5 @@ spring.application.name=grants
 server.port=8086
 server.servlet.context-path=/grants
 spring.mvc.format.date=dd-MM-yyyy
-spring.profiles.active=uat
+spring.profiles.active=dev
 logging.level.scot.carricksoftware=trace
-
-

+ 13 - 0
src/main/resources/db/changelog/2025/07/26-01-changelog.sql

@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+-- liquibase formatted sql
+
+-- changeset apg:1753557049320-1
+ALTER TABLE death_certificate
+    ADD regiment       VARCHAR(255) NULL,
+    ADD service_number VARCHAR(255) NULL,
+    ADD service_rank   VARCHAR(255) NULL;
+

+ 1 - 0
src/main/resources/db/changelog/master.xml

@@ -47,6 +47,7 @@
     <include file="/db/changelog/2025/07/22-04-changelog.sql"/>
     <include file="/db/changelog/2025/07/22-05-changelog.sql"/>
     <include file="/db/changelog/2025/07/24-01-changelog.sql"/>
+    <include file="/db/changelog/2025/07/26-01-changelog.sql"/>
 
 
 

+ 67 - 7
src/main/resources/templates/certificates/deathCertificate/form.html

@@ -338,7 +338,7 @@
                     </div>
                 </td>
             </tr>
-            <tr>
+            <tr style="border-bottom: 5px solid #ccc;">
                 <td style="text-align: right;">
                     <label for="causeOfDeath">Cause of Death :&nbsp;</label>
                 </td>
@@ -387,7 +387,7 @@
                     </div>
                 </td>
             </tr>
-            <tr>
+            <tr style="border-bottom: 5px solid #ccc;">
                 <td style="text-align: right;">
                     <label for="spouseOccupation">Spouse Occupation :&nbsp;</label>
                 </td>
@@ -404,7 +404,7 @@
                 </td>
             </tr>
             <tr>
-                <td style="text-align: right; background-color: #D6EEEE;">
+                <td style="text-align: right;">
                     <label for="father">Father :&nbsp;</label>
                 </td>
                 <td style="text-align: left;">
@@ -421,7 +421,7 @@
                 </td>
             </tr>
             <tr>
-                <td style="text-align: right; background-color: #D6EEEE;">
+                <td style="text-align: right;">
                     <label for="untrackedFather">Father (untracked) :&nbsp;</label>
                 </td>
                 <td style="text-align: left;">
@@ -436,7 +436,7 @@
                     </div>
                 </td>
             </tr>
-            <tr>
+            <tr style="border-bottom: 5px solid #ccc;">
                 <td style="text-align: right;">
                     <label for="fatherOccupation">Father Occupation :&nbsp;</label>
                 </td>
@@ -485,7 +485,7 @@
                     </div>
                 </td>
             </tr>
-            <tr>
+            <tr  style="border-bottom: 5px solid #ccc;">
                 <td style="text-align: right;">
                     <label for="motherOccupation">Mother Occupation :&nbsp;</label>
                 </td>
@@ -584,7 +584,7 @@
                     </div>
                 </td>
             </tr>
-            <tr>
+            <tr style="border-bottom: 5px solid #ccc;">
                 <td style="text-align: right;">
                     <label for="whereRegistered">Where Registered :&nbsp;</label>
                 </td>
@@ -600,6 +600,66 @@
                     </div>
                 </td>
             </tr>
+	                <tr>
+                <td style="text-align: right;">
+                    <label for="regiment">Regiment :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <select id="regiment" style="width: 200px;" name="regiment"
+                                th:field="*{regiment}">
+                            <option th:value="${''}" th:text="${''}"></option>
+                            <option th:each="value : ${T(scot.carricksoftware.grants.enums.certificates.Regiment).values()}"
+                                    th:value="${value}" th:text="${value.label}"></option>
+                        </select>
+                    </div>
+                    <div th:if="${#fields.hasErrors('regiment')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('regiment')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+			</tr>
+
+            <tr>
+                <td style="text-align: right;">
+                    <label for="serviceRank">Service rank :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <select id="serviceRank" style="width: 200px;" name="serviceRank"
+                                th:field="*{serviceRank}">
+                            <option th:value="${''}" th:text="${''}"></option>
+                            <option th:each="value : ${T(scot.carricksoftware.grants.enums.certificates.ServiceRank).values()}"
+                                    th:value="${value}" th:text="${value.label}"></option>
+                        </select>
+                    </div>
+                    <div th:if="${#fields.hasErrors('serviceRank')}">
+                        <ul class="text-danger">
+                            <li th:each="err : ${#fields.errors('serviceRank')}" th:text="${err}"/>
+                        </ul>
+                    </div>
+		    </td>
+            </tr>
+
+	     <tr>
+                <td style="text-align: right;">
+                    <label for="serviceNumber">Service Number :&nbsp;</label>
+                </td>
+                <td style="text-align: left;">
+                    <div>
+                        <input class="serviceNumber" id="serviceNumber"
+                               th:field="*{serviceNumber}" type="text">
+                        <div th:if="${#fields.hasErrors('serviceNumber')}">
+                            <ul class="text-danger">
+                                <li th:each="err : ${#fields.errors('serviceNumb')}" th:text="${err}"/>
+                            </ul>
+                        </div>
+                    </div>
+                </td>
+            </tr>
+	 
+
+
         </table>
         <button type="submit" class="btn btn-primary">Commit</button>
         <a class="btn btn-secondary" th:href="@{/deathCertificates}" th:text="${'List all'}">List all</a>