Bladeren bron

Birth Certificate fixes

Andrew Grant 2 maanden geleden
bovenliggende
commit
90ea05f4f7

+ 2 - 0
src/main/java/scot/carricksoftware/grantswriter/repositories/certificates/birthcertificate/BirthCertificateRepository.java

@@ -19,4 +19,6 @@ public interface BirthCertificateRepository extends ReadOnlyRepository<BirthCert
     Iterable<BirthCertificate> findAllByFather(Person person);
 
     Iterable<BirthCertificate> findAllByMother(Person person);
+
+    Iterable<BirthCertificate> findAllByInformant(Person person);
 }

+ 2 - 0
src/main/java/scot/carricksoftware/grantswriter/services/certificates/birthcertificate/BirthCertificateService.java

@@ -18,4 +18,6 @@ public interface BirthCertificateService {
     List<BirthCertificate> findAllByFather(Person person);
 
     List<BirthCertificate> findAllByMother(Person person);
+
+    List<BirthCertificate> findAllByInformant(Person person);
 }

+ 11 - 0
src/main/java/scot/carricksoftware/grantswriter/services/certificates/birthcertificate/BirthCertificateServiceImpl.java

@@ -58,4 +58,15 @@ public class BirthCertificateServiceImpl implements BirthCertificateService {
         }
         return result;
     }
+
+    @Override
+    public List<BirthCertificate> findAllByInformant(Person person) {
+        logger.debug("PersonServiceImpl::findAllByInformant");
+        List<BirthCertificate> result = new ArrayList<>();
+        Iterable<BirthCertificate> birthCertificatesIterable = birthCertificateRepository.findAllByInformant(person);
+        for (BirthCertificate birthCertificate : birthCertificatesIterable) {
+            result.add(birthCertificate);
+        }
+        return result;
+    }
 }

+ 11 - 2
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/helpers/GatherBirthCertificateTimeLineDataImpl.java

@@ -10,6 +10,7 @@ import scot.carricksoftware.grantswriter.domains.certificates.birthcertificate.B
 import scot.carricksoftware.grantswriter.domains.people.Person;
 import scot.carricksoftware.grantswriter.services.certificates.birthcertificate.BirthCertificateService;
 import scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers.level2.GatherBirthCertificateFatherTimeLineData;
+import scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers.level2.GatherBirthCertificateInformantTimeLineData;
 import scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers.level2.GatherBirthCertificateMotherTimeLineData;
 import scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers.level2.GatherBirthCertificateNewBornTimeLineData;
 
@@ -26,12 +27,18 @@ public class GatherBirthCertificateTimeLineDataImpl implements GatherBirthCertif
 
     private final GatherBirthCertificateMotherTimeLineData gatherBirthCertificateMotherTimeLineData;
 
+    private final GatherBirthCertificateInformantTimeLineData gatherBirthCertificateInformantTimeLineData;
+
     public GatherBirthCertificateTimeLineDataImpl(BirthCertificateService birthCertificateService,
-                                                  GatherBirthCertificateNewBornTimeLineData gatherBirthCertificateNewBornTimeLineData, GatherBirthCertificateFatherTimeLineData gatherBirthCertificateFatherTimeLineData, GatherBirthCertificateMotherTimeLineData gatherBirthCertificateMotherTimeLineData) {
+                                                  GatherBirthCertificateNewBornTimeLineData gatherBirthCertificateNewBornTimeLineData,
+                                                  GatherBirthCertificateFatherTimeLineData gatherBirthCertificateFatherTimeLineData,
+                                                  GatherBirthCertificateMotherTimeLineData gatherBirthCertificateMotherTimeLineData,
+                                                  GatherBirthCertificateInformantTimeLineData gatherBirthCertificateInformantTimeLineData) {
         this.birthCertificateService = birthCertificateService;
         this.gatherBirthCertificateNewBornTimeLineData = gatherBirthCertificateNewBornTimeLineData;
         this.gatherBirthCertificateFatherTimeLineData = gatherBirthCertificateFatherTimeLineData;
         this.gatherBirthCertificateMotherTimeLineData = gatherBirthCertificateMotherTimeLineData;
+        this.gatherBirthCertificateInformantTimeLineData = gatherBirthCertificateInformantTimeLineData;
     }
 
     @Override
@@ -39,6 +46,7 @@ public class GatherBirthCertificateTimeLineDataImpl implements GatherBirthCertif
         gatherNewBorn(person);
         gatherFather(person);
         gatherMother(person);
+        gatherInformant(person);
     }
 
     @SuppressWarnings("unused")
@@ -63,7 +71,8 @@ public class GatherBirthCertificateTimeLineDataImpl implements GatherBirthCertif
 
     @SuppressWarnings("unused")
     private void gatherInformant(@SuppressWarnings("unused") Person person) {
-        throw new UnsupportedOperationException();
+        List<BirthCertificate> birthCertificates = birthCertificateService.findAllByInformant(person);
+        gatherBirthCertificateInformantTimeLineData.gather(birthCertificates);
     }
 
 

+ 3 - 3
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/helpers/level2/GatherBirthCertificateFatherTimeLineDataImpl.java

@@ -47,7 +47,7 @@ public class GatherBirthCertificateFatherTimeLineDataImpl implements GatherBirth
         }
 
         existingValues.add("Occupation registered as " + birthCertificate.getFatherRank());
-        timeLine.put(getDMY(birthCertificate.getWhenBorn()), existingValues);
+        timeLine.put(getDMY(birthCertificate.getWhenRegistered()), existingValues);
 
     }
 
@@ -58,13 +58,13 @@ public class GatherBirthCertificateFatherTimeLineDataImpl implements GatherBirth
     private void addFather(TreeMap<DMY, List<String>> timeLine, BirthCertificate birthCertificate) {
         logger.info("GatherBirthCertificateFatherTimeLineDataImpl::AddFather");
 
-        List<String> existingValues = timeLine.get(getDMY(birthCertificate.getWhenBorn()));
+        List<String> existingValues = timeLine.get(getDMY(birthCertificate.getWhenRegistered()));
         if (existingValues == null) {
             existingValues = new ArrayList<>();
         }
 
         existingValues.add("Registered as the father of " + birthCertificate.getNewBorn());
-        timeLine.put(getDMY(birthCertificate.getWhenBorn()), existingValues);
+        timeLine.put(getDMY(birthCertificate.getWhenRegistered()), existingValues);
     }
 
     private DMY getDMY(String dateKey) {

+ 15 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/helpers/level2/GatherBirthCertificateInformantTimeLineData.java

@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers.level2;
+
+import scot.carricksoftware.grantswriter.domains.certificates.birthcertificate.BirthCertificate;
+
+import java.util.List;
+
+public interface GatherBirthCertificateInformantTimeLineData {
+   void gather(List<BirthCertificate> birthCertificates);
+
+}

+ 62 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/helpers/level2/GatherBirthCertificateInformantTimeLineDataImpl.java

@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers.level2;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.stereotype.Component;
+import scot.carricksoftware.grantswriter.data.DMY;
+import scot.carricksoftware.grantswriter.data.DMYImpl;
+import scot.carricksoftware.grantswriter.data.TimeLineData;
+import scot.carricksoftware.grantswriter.domains.certificates.birthcertificate.BirthCertificate;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.TreeMap;
+
+@Component
+public class GatherBirthCertificateInformantTimeLineDataImpl implements GatherBirthCertificateInformantTimeLineData {
+
+    private final TimeLineData timelineData;
+
+    private static final Logger logger = LogManager.getLogger(GatherBirthCertificateInformantTimeLineDataImpl.class);
+
+    public GatherBirthCertificateInformantTimeLineDataImpl(TimeLineData timelineData) {
+        this.timelineData = timelineData;
+    }
+
+    @Override
+    public void gather(List<BirthCertificate> birthCertificates) {
+        logger.info("GatherBirthCertificateInformantTimeLineDataImpl::Gather");
+        for (BirthCertificate birthCertificate : birthCertificates) {
+            addInformant(timelineData.getTimeLine(), birthCertificate);
+            addRefs(birthCertificate);
+        }
+    }
+
+    private void addInformant(TreeMap<DMY, List<String>> timeLine, BirthCertificate birthCertificate) {
+        logger.info("GatherBirthCertificateInformantTimeLineDataImpl::AddMother");
+
+        List<String> existingValues = timeLine.get(getDMY(birthCertificate.getWhenRegistered()));
+        if (existingValues == null) {
+            existingValues = new ArrayList<>();
+        }
+
+        existingValues.add("Registered the birth of  " + birthCertificate.getNewBorn() + " at " + birthCertificate.getWhereRegistered());
+        timeLine.put(getDMY(birthCertificate.getWhenRegistered()), existingValues);
+
+    }
+
+    private void addRefs(BirthCertificate birthCertificate) {
+        timelineData.getRefs().add("Birth Certificate for : " + birthCertificate.getNewBorn());
+    }
+
+    private DMY getDMY(String dateKey) {
+        DMY dmyKey = new DMYImpl();
+        dmyKey.parse(dateKey);
+        return dmyKey;
+    }
+}