Bläddra i källkod

Subsection writers

Andrew Grant 3 månader sedan
förälder
incheckning
7b023aa60e

+ 1 - 1
docs/Structure.txt

@@ -1,4 +1,4 @@
-TexController -> TexWriter -> PartsWriter -> PeoplePartWriter -> {PeoplePartHeader PersonSectionWriter}
+TexController -> TexWriter -> PartsWriter -> PeoplePartWriter -> (PeoplePartHeader+PersonSectionWriter) -> (PersonPart SubSectionHeading + PersonTimeLineWriter)
 
 
 

+ 1 - 0
src/main/java/scot/carricksoftware/grantswriter/constants/LatexConstants.java

@@ -21,6 +21,7 @@ public class LatexConstants {
 
     public static final String PART_TERM = "\\part{";
     public static final String SECTION_TERM = "\\section{";
+    public static final String SUBSECTION_TERM = "\\subsection{";
     public static final String TERM_END = "}";
 
 }

+ 12 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/LatexSubSectionHeader.java

@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex;
+
+public interface LatexSubSectionHeader {
+
+    @SuppressWarnings({"EmptyMethod", "unused"})
+    void write(String title);
+}

+ 28 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/LatexSubSectionHeaderImpl.java

@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex;
+
+import org.springframework.stereotype.Component;
+import scot.carricksoftware.grantswriter.constants.LatexConstants;
+import scot.carricksoftware.grantswriter.writer.FileWriter;
+
+@Component
+public class LatexSubSectionHeaderImpl implements LatexSubSectionHeader {
+
+    private final FileWriter fileWriter;
+
+    public LatexSubSectionHeaderImpl(FileWriter fileWriter) {
+        this.fileWriter = fileWriter;
+    }
+
+    @Override
+    public void write(String title) {
+        String sb = LatexConstants.SUBSECTION_TERM +
+                title +
+                LatexConstants.TERM_END;
+        fileWriter.writeLine(sb);
+    }
+}

+ 9 - 1
src/main/java/scot/carricksoftware/grantswriter/writer/latex/sections/PersonSectionImpl.java

@@ -13,13 +13,21 @@ import scot.carricksoftware.grantswriter.domains.people.Person;
 public class PersonSectionImpl implements PersonSection {
 
     private final PersonSectionHeader personSectionHeader;
+    private final PersonSubSectionTimeLineWriter personSubSectionTimeLineWriter;
+    private final PersonSubSectionReferencesWriter personSubSectionReferencesWriter;
 
-    public PersonSectionImpl(PersonSectionHeader personSectionHeader) {
+    public PersonSectionImpl(PersonSectionHeader personSectionHeader,
+                             PersonSubSectionTimeLineWriter personSubSectionTimeLineWriter,
+                             PersonSubSectionReferencesWriter personSubSectionReferencesWriter) {
         this.personSectionHeader = personSectionHeader;
+        this.personSubSectionTimeLineWriter = personSubSectionTimeLineWriter;
+        this.personSubSectionReferencesWriter = personSubSectionReferencesWriter;
     }
 
     @Override
     public void write(Person person) {
         personSectionHeader.write(person);
+        personSubSectionTimeLineWriter.write(person);
+        personSubSectionReferencesWriter.write(person);
     }
 }

+ 13 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/sections/PersonSubSectionReferencesWriter.java

@@ -0,0 +1,13 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.sections;
+
+import scot.carricksoftware.grantswriter.domains.people.Person;
+
+public interface PersonSubSectionReferencesWriter {
+
+    void write(Person person);
+}

+ 27 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/sections/PersonSubSectionReferencesWriterImpl.java

@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.sections;
+
+import org.springframework.stereotype.Component;
+import scot.carricksoftware.grantswriter.domains.people.Person;
+import scot.carricksoftware.grantswriter.writer.latex.LatexSubSectionHeader;
+
+@Component
+public class PersonSubSectionReferencesWriterImpl implements PersonSubSectionReferencesWriter {
+
+    private final LatexSubSectionHeader latexSubSectionHeader;
+
+    public PersonSubSectionReferencesWriterImpl(LatexSubSectionHeader latexSubSectionHeader) {
+        this.latexSubSectionHeader = latexSubSectionHeader;
+    }
+
+    @Override
+    public void write(Person person) {
+        latexSubSectionHeader.write("References");
+        // write refs
+    }
+
+}

+ 12 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/sections/PersonSubSectionTimeLineWriter.java

@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.sections;
+
+import scot.carricksoftware.grantswriter.domains.people.Person;
+
+public interface PersonSubSectionTimeLineWriter {
+    void write(Person person);
+}

+ 30 - 0
src/main/java/scot/carricksoftware/grantswriter/writer/latex/sections/PersonSubSectionTimeLineWriterImpl.java

@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.sections;
+
+import org.springframework.stereotype.Component;
+import scot.carricksoftware.grantswriter.domains.people.Person;
+import scot.carricksoftware.grantswriter.writer.latex.LatexSubSectionHeader;
+
+@Component
+public class PersonSubSectionTimeLineWriterImpl implements PersonSubSectionTimeLineWriter {
+
+private final LatexSubSectionHeader latexSubSectionHeader;
+
+    public PersonSubSectionTimeLineWriterImpl(LatexSubSectionHeader latexSubSectionHeader) {
+        this.latexSubSectionHeader = latexSubSectionHeader;
+    }
+
+    @Override
+    public void write(Person person) {
+        // get census record for name
+        latexSubSectionHeader.write("Timeline");
+
+        // write timeline
+        latexSubSectionHeader.write("References");
+        // write refs
+    }
+}

+ 31 - 0
src/test/java/scot/carricksoftware/grantswriter/writer/latex/LatexSubSectionHeaderTest.java

@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import scot.carricksoftware.grantswriter.writer.FileWriter;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+class LatexSubSectionHeaderTest {
+
+    private LatexSubSectionHeader header;
+
+    @Mock
+    private FileWriter fileWriterMock;
+
+    @BeforeEach
+    void setUp() {
+        header = new LatexSubSectionHeaderImpl(fileWriterMock);
+    }
+
+    @Test
+    void constructorTest() {
+        assertNotNull(header);
+    }
+}

+ 7 - 1
src/test/java/scot/carricksoftware/grantswriter/writer/latex/sections/PersonSectionTest.java

@@ -23,12 +23,18 @@ class PersonSectionTest {
     @Mock
     private PersonSectionHeader personSectionHeaderMock;
 
+    @Mock
+    private PersonSubSectionTimeLineWriter personSubSectionTimeLineWriterMock;
+
+    @Mock
+    private PersonSubSectionReferencesWriter personSubSectionReferencesWriterMock;
+
     @Mock
     private Person personMock;
 
     @BeforeEach
     void setUp() {
-        personSection = new PersonSectionImpl(personSectionHeaderMock);
+        personSection = new PersonSectionImpl(personSectionHeaderMock, personSubSectionTimeLineWriterMock, personSubSectionReferencesWriterMock);
     }
 
     @Test

+ 31 - 0
src/test/java/scot/carricksoftware/grantswriter/writer/latex/sections/PersonSubSectionReferencesWriterTest.java

@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.sections;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import scot.carricksoftware.grantswriter.writer.latex.LatexSubSectionHeader;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+class PersonSubSectionReferencesWriterTest {
+
+    private PersonSubSectionReferencesWriter writer;
+
+    @Mock
+    private LatexSubSectionHeader latexSubSectionHeaderMock;
+
+    @BeforeEach
+    void setUp() {
+        writer = new PersonSubSectionReferencesWriterImpl(latexSubSectionHeaderMock);
+    }
+
+    @Test
+    void constructorTest() {
+        assertNotNull(writer);
+    }
+}

+ 31 - 0
src/test/java/scot/carricksoftware/grantswriter/writer/latex/sections/PersonSubSectionTimeLineWriterTest.java

@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.writer.latex.sections;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.Mock;
+import scot.carricksoftware.grantswriter.writer.latex.LatexSubSectionHeader;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+class PersonSubSectionTimeLineWriterTest {
+
+    private PersonSubSectionTimeLineWriter writer;
+
+    @Mock
+    private LatexSubSectionHeader latexSubSectionHeaderMock;
+
+    @BeforeEach
+    void setUp() {
+        writer = new PersonSubSectionTimeLineWriterImpl(latexSubSectionHeaderMock);
+    }
+
+    @Test
+    void constructTest() {
+        assertNotNull(writer);
+    }
+}