Browse Source

CensusEntryService

Andrew Grant 3 tháng trước cách đây
mục cha
commit
51df6999d3

+ 3 - 3
src/main/java/scot/carricksoftware/grantswriter/data/TimelineData.java

@@ -5,10 +5,10 @@
 
 package scot.carricksoftware.grantswriter.data;
 
+import org.springframework.util.LinkedMultiValueMap;
 import scot.carricksoftware.grantswriter.domains.census.CensusEntry;
 
 import java.util.List;
-import java.util.SortedMap;
 import java.util.SortedSet;
 
 public interface TimelineData {
@@ -20,10 +20,10 @@ public interface TimelineData {
     void add(List<CensusEntry> censusEntryList);
 
     @SuppressWarnings("unused")
-    SortedMap<String, String> getTimeline();
+    LinkedMultiValueMap<String, String> getTimeline();
 
     @SuppressWarnings("unused")
-    void setTimeline(SortedMap<String, String> timeline);
+    void setTimeline(LinkedMultiValueMap<String, String> timeline);
 
     @SuppressWarnings("unused")
     SortedSet<String> getRefs();

+ 7 - 9
src/main/java/scot/carricksoftware/grantswriter/data/TimelineDataImpl.java

@@ -6,23 +6,22 @@
 package scot.carricksoftware.grantswriter.data;
 
 import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
 import scot.carricksoftware.grantswriter.domains.census.CensusEntry;
 
 import java.util.List;
-import java.util.SortedMap;
 import java.util.SortedSet;
-import java.util.TreeMap;
 import java.util.TreeSet;
 
 @Component
 public class TimelineDataImpl implements TimelineData {
 
-    private SortedMap<String, String> timeline;
+    private LinkedMultiValueMap<String, String> timeline;
 
     private SortedSet<String> refs;
 
     public TimelineDataImpl() {
-        this.timeline = new TreeMap<>();
+        this.timeline = new LinkedMultiValueMap<>();
         this.refs = new TreeSet<>();
     }
 
@@ -35,26 +34,25 @@ public class TimelineDataImpl implements TimelineData {
     @Override
     public void add(List<CensusEntry> censusEntryList) {
         for (CensusEntry censusEntry : censusEntryList) {
-            timeline.put(censusEntry.getCensus().getCensusDate().label,
+            timeline.add(censusEntry.getCensus().getCensusDate().label,
                     "Recorded as being at " +
                             censusEntry.getCensus().getPlace().toString());
             if (censusEntry.getPersonalOccupation() != null && !censusEntry.getPersonalOccupation().isEmpty()) {
-                timeline.put(censusEntry.getCensus().getCensusDate().label,
+                timeline.add(censusEntry.getCensus().getCensusDate().label,
                         "Occupation recorded as " +
                                 censusEntry.getPersonalOccupation());
             }
             refs.add(censusEntry.getCensus().toString());
         }
-
     }
 
     @Override
-    public SortedMap<String, String> getTimeline() {
+    public LinkedMultiValueMap<String, String> getTimeline() {
         return timeline;
     }
 
     @Override
-    public void setTimeline(SortedMap<String, String> timeline) {
+    public void setTimeline(LinkedMultiValueMap<String, String> timeline) {
         this.timeline = timeline;
     }
 

+ 6 - 2
src/main/java/scot/carricksoftware/grantswriter/writer/latex/parts/people/subsections/PersonSubSectionTimeLineWriterImpl.java

@@ -6,6 +6,7 @@
 package scot.carricksoftware.grantswriter.writer.latex.parts.people.subsections;
 
 import org.springframework.stereotype.Component;
+import scot.carricksoftware.grantswriter.data.TimelineData;
 import scot.carricksoftware.grantswriter.domains.census.CensusEntry;
 import scot.carricksoftware.grantswriter.domains.people.Person;
 import scot.carricksoftware.grantswriter.services.censusentry.CensusEntryService;
@@ -18,16 +19,19 @@ public class PersonSubSectionTimeLineWriterImpl implements PersonSubSectionTimeL
 
     private final LatexSubSectionHeader latexSubSectionHeader;
     private final CensusEntryService censusEntryService;
+    private final TimelineData timelineData;
 
-    public PersonSubSectionTimeLineWriterImpl(LatexSubSectionHeader latexSubSectionHeader, CensusEntryService censusEntryService) {
+    public PersonSubSectionTimeLineWriterImpl(LatexSubSectionHeader latexSubSectionHeader, CensusEntryService censusEntryService, TimelineData timelineData) {
         this.latexSubSectionHeader = latexSubSectionHeader;
         this.censusEntryService = censusEntryService;
+        this.timelineData = timelineData;
     }
 
     @Override
     public void write(Person person) {
         // get census record for name
         latexSubSectionHeader.write("Timeline");
-        @SuppressWarnings("unused") List<CensusEntry>  censusEntryList = censusEntryService.findAllByPerson(person);
+        List<CensusEntry>  censusEntryList = censusEntryService.findAllByPerson(person);
+        timelineData.add(censusEntryList);
     }
 }