瀏覽代碼

GatherDeathCertificateTimeLineData

Andrew Grant 2 月之前
父節點
當前提交
4ffc7c6b58

+ 4 - 2
docs/Structure.txt

@@ -7,7 +7,9 @@ personSection::write -> (personSectionHeader::write, clearExistingTimeLineData::
            personSubSectionTimeLineWriter::write, personSubSectionReferencesWriter::write
 
 
-gatherTimeLineData::gather -> (gatherCensusTimeLineData::gather, GatherBirthCertificateTimeLineData::gather)
+gatherTimeLineData::gather -> (gatherCensusTimeLineData::gather, GatherBirthCertificateTimeLineData::gather, GatherDeathCertificateTimeLineDate::gather)
 
 
-GatherBirthCertificateTimeLineData::gather -> (GatherBirthCertificateNewBornTimeLineData::gather,  )
+GatherBirthCertificateTimeLineData::gather -> (GatherBirthCertificateNewBornTimeLineData::gather,  )
+
+GatherDeathCertificateTimeLineData::gather -> (GatherDeathCertificateDeceasedTimeLineData::gather,  )

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

@@ -8,8 +8,12 @@ package scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.springframework.stereotype.Component;
+import scot.carricksoftware.grantswriter.domains.certificates.deathcertificate.DeathCertificate;
 import scot.carricksoftware.grantswriter.domains.people.Person;
 import scot.carricksoftware.grantswriter.services.certificates.deathcertificate.DeathCertificateService;
+import scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers.level2.deathcertificate.GatherDeathCertificateDeceasedTimeLineData;
+
+import java.util.List;
 
 
 @Component
@@ -17,14 +21,20 @@ public class GatherDeathCertificateTimeLineDataImpl implements GatherDeathCertif
     private static final Logger logger = LogManager.getLogger(GatherDeathCertificateTimeLineDataImpl.class);
 
     private final DeathCertificateService deathCertificateService;
+    private final GatherDeathCertificateDeceasedTimeLineData gatherDeathCertificateDeceasedTimeLineData;
 
-    public GatherDeathCertificateTimeLineDataImpl(DeathCertificateService deathCertificateService) {
+    public GatherDeathCertificateTimeLineDataImpl(DeathCertificateService deathCertificateService, GatherDeathCertificateDeceasedTimeLineData gatherDeathCertificateDeceasedTimeLineData) {
         this.deathCertificateService = deathCertificateService;
+        this.gatherDeathCertificateDeceasedTimeLineData = gatherDeathCertificateDeceasedTimeLineData;
     }
 
     @Override
     public void gather(Person person) {
        logger.debug("GatherDeathCertificateTimeLineDataImpl::gather");
+        List<DeathCertificate> deathCertificates = deathCertificateService.findAllByDeceased(person);
+        if (!deathCertificates.isEmpty()) {
+            gatherDeathCertificateDeceasedTimeLineData.gather(deathCertificates);
+        }
     }
 
 }

+ 4 - 1
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/helpers/GatherTimeLineDataImpl.java

@@ -13,16 +13,19 @@ public class GatherTimeLineDataImpl implements GatherTimeLineData {
 
    private final GatherCensusTimeLineData gatherCensusTimeLineData;
     private final GatherBirthCertificateTimeLineData gatherBirthCertificateTimeLineData;
+    private final GatherDeathCertificateTimeLineData gatherDeathCertificateTimeLineData;
 
     public GatherTimeLineDataImpl(
-            GatherCensusTimeLineData gatherCensusTimeLineData, GatherBirthCertificateTimeLineData gatherBirthCertificateTimeLineData) {
+            GatherCensusTimeLineData gatherCensusTimeLineData, GatherBirthCertificateTimeLineData gatherBirthCertificateTimeLineData, GatherDeathCertificateTimeLineData gatherDeathCertificateTimeLineData) {
         this.gatherCensusTimeLineData = gatherCensusTimeLineData;
         this.gatherBirthCertificateTimeLineData = gatherBirthCertificateTimeLineData;
+        this.gatherDeathCertificateTimeLineData = gatherDeathCertificateTimeLineData;
     }
 
     @Override
     public void gather(Person person) {
         gatherCensusTimeLineData.gather(person);
         gatherBirthCertificateTimeLineData.gather(person);
+        gatherDeathCertificateTimeLineData.gather(person);
     }
 }

+ 15 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/helpers/level2/deathcertificate/GatherDeathCertificateDeceasedTimeLineData.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.deathcertificate;
+
+import scot.carricksoftware.grantswriter.domains.certificates.deathcertificate.DeathCertificate;
+
+import java.util.List;
+
+public interface GatherDeathCertificateDeceasedTimeLineData {
+   void gather(List<DeathCertificate> deathCertificates);
+
+}

+ 87 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/helpers/level2/deathcertificate/GatherDeathCertificateDeceasedTimeLineDataImpl.java

@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections.helpers.level2.deathcertificate;
+
+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.deathcertificate.DeathCertificate;
+
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.TreeMap;
+
+@Component
+public class GatherDeathCertificateDeceasedTimeLineDataImpl implements GatherDeathCertificateDeceasedTimeLineData {
+
+    private final TimeLineData timelineData;
+
+    private static final Logger logger = LogManager.getLogger(GatherDeathCertificateDeceasedTimeLineDataImpl.class);
+
+    public GatherDeathCertificateDeceasedTimeLineDataImpl(TimeLineData timelineData) {
+        this.timelineData = timelineData;
+    }
+
+    @Override
+    public void gather(List<DeathCertificate> deathCertificates) {
+        logger.info("GatherDeathCertificateDeceasedTimeLineDataImpl::Gather");
+        for (DeathCertificate deathCertificate : deathCertificates) {
+            addWhenDied(timelineData.getTimeLine(), deathCertificate);
+            addWhenRegistered(timelineData.getTimeLine(), deathCertificate);
+            addRefs(deathCertificate);
+        }
+    }
+
+    private void addRefs(DeathCertificate deathCertificate) {
+        timelineData.getRefs().add("Death Certificate for : " + deathCertificate.getDeceased());
+    }
+
+    private void addWhenDied(TreeMap<DMY, List<String>> timeLine, DeathCertificate deathCertificate) {
+        logger.info("GatherDeathCertificateDeceasedTimeLineDataImpl::AddWhenDied");
+
+        List<String> existingValues = timeLine.get(getDMY(deathCertificate.getWhenDied()));
+        if (existingValues == null) {
+            existingValues = new ArrayList<>();
+        }
+
+        if (deathCertificate.getWhereDied() != null) {
+            existingValues.add("Died at " + deathCertificate.getWhereDied().toString());
+        } else {
+            existingValues.add("Died at " + deathCertificate.getUntrackedWhereDied());
+        }
+        timeLine.put(getDMY(deathCertificate.getWhenDied()), existingValues);
+
+    }
+
+    private void addWhenRegistered(TreeMap<DMY, List<String>> timeLine, DeathCertificate deathCertificate) {
+        logger.info("GatherDeathCertificateDeceasedTimeLineDataImpl::AddWhenRegistered");
+
+        if (deathCertificate.getWhereRegistered() != null  && !deathCertificate.getWhereRegistered().isEmpty()) {
+
+            List<String> existingValues = timeLine.get(getDMY(deathCertificate.getWhenRegistered()));
+            if (existingValues == null) {
+                existingValues = new ArrayList<>();
+            }
+
+            if (deathCertificate.getInformant() != null) {
+                existingValues.add("Death Registered by " + deathCertificate.getInformant().toString() + " at " + deathCertificate.getWhereRegistered());
+            } else {
+                existingValues.add("Death Registered by " + deathCertificate.getUntrackedInformant() + " at " + deathCertificate.getWhereRegistered());
+            }
+            timeLine.put(getDMY(deathCertificate.getWhenRegistered()), existingValues);
+        }
+    }
+
+    private DMY getDMY(String dateKey) {
+        DMY dmyKey = new DMYImpl();
+        dmyKey.parse(dateKey);
+        return dmyKey;
+    }
+}