Эх сурвалжийг харах

Census Boundary Type added to domain

Andrew Grant 7 сар өмнө
parent
commit
f8ba54b67d

+ 11 - 0
src/main/java/scot/carricksoftware/grants/domains/census/Census.java

@@ -8,6 +8,7 @@ package scot.carricksoftware.grants.domains.census;
 import jakarta.persistence.*;
 import scot.carricksoftware.grants.BaseEntity;
 import scot.carricksoftware.grants.domains.places.Place;
+import scot.carricksoftware.grants.enums.census.CensusBoundaryType;
 
 import java.time.LocalDate;
 import java.util.ArrayList;
@@ -25,6 +26,8 @@ public class Census extends BaseEntity {
     @JoinColumn(name = "census_place_id")
     private Place place;
 
+    private CensusBoundaryType boundaryType;
+
 
     public LocalDate getDate() {
         return date;
@@ -54,4 +57,12 @@ public class Census extends BaseEntity {
     public void setPlace(Place place) {
         this.place = place;
     }
+
+    public CensusBoundaryType getBoundaryType() {
+        return boundaryType;
+    }
+
+    public void setBoundaryType(CensusBoundaryType boundaryType) {
+        this.boundaryType = boundaryType;
+    }
 }

+ 32 - 0
src/main/java/scot/carricksoftware/grants/enums/census/CensusBoundaryType.java

@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grants.enums.census;
+
+public enum CensusBoundaryType {
+
+    CIVIL_PARISH("Civil Parish"),
+    PARISH_WARD("Parish Ward"),
+    ECCLESIASTICAL_PARISH("Ecclesical Parish"),
+    QUOAD_SACRA__PARISH ("Quoad Sacra Parish"),
+    SCHOOL_BOARD_DISTRICT ("School Board District"),
+    PARLIAMENTARY_BURGH  ("Parliamentary Burgh"),
+    PARLIAMENTARY_DIVISION("Parliamentary Division"),
+    ROYAL_BURGH  ("Royal Burgh"),
+    MUNICIPAL_BURGH("Municipal Burgh"),
+    POLICE_BURGH  ("Police Burgh"),
+    BURGH_WARD ("Burgh Ward"),
+    TOWN ("Town"),
+    VILLAGE_OR_HAMLET ("Village or Hamlet"),
+    ISLAND ("Island");
+
+    @SuppressWarnings("unused")
+    public final String label;
+
+    @SuppressWarnings("unused")
+    CensusBoundaryType(String label) {
+        this.label = label;
+    }
+}

+ 1 - 0
src/main/java/scot/carricksoftware/grants/enums/censusentry/CensusEntryCondition.java

@@ -6,6 +6,7 @@
 package scot.carricksoftware.grants.enums.censusentry;
 
 public enum CensusEntryCondition {
+
     @SuppressWarnings("unused") WIDOW("Widow"),
     @SuppressWarnings("unused") WIDOWER("Widower"),
     @SuppressWarnings("unused") MARRIED("Married"),

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

@@ -2,7 +2,7 @@ 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=debug
 
 

+ 12 - 0
src/main/resources/db/changelog/2025/04/17-01-changelog.sql

@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+-- liquibase formatted sql
+
+-- changeset apg:1744877825545-1
+ALTER TABLE census_entry
+    ADD age          VARCHAR(255) NULL,
+    ADD where_born   VARCHAR(255) NULL;
+

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

@@ -7,5 +7,6 @@
     <include file="/db/changelog/2025/04/13-01-changelog.sql"/>
     <include file="/db/changelog/2025/04/14-01-changelog.sql"/>
     <include file="/db/changelog/2025/04/16-01-changelog.sql"/>
+    <include file="/db/changelog/2025/04/17-01-changelog.sql"/>
 
 </databaseChangeLog>

+ 25 - 0
src/test/java/scot/carricksoftware/grants/GenerateCensusRandomEnums.java

@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grants;import org.springframework.stereotype.Component;
+import scot.carricksoftware.grants.enums.census.CensusBoundaryType;
+
+import java.util.Random;
+
+@SuppressWarnings("unused")
+@Component
+public class GenerateCensusRandomEnums {
+
+    public static CensusBoundaryType GetRandomCensusBoundaryType() {
+
+        CensusBoundaryType[] boundaryTypes = CensusBoundaryType.values();
+
+        Random random = new Random();
+        int randomInt = random.nextInt(0, boundaryTypes.length );
+        return boundaryTypes[randomInt];
+    }
+
+
+}

+ 40 - 0
src/test/java/scot/carricksoftware/grants/domains/census/CensusEnumTest.java

@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) Andrew Grant of Carrick Software 20/03/2025, 11:01. All rights reserved.
+ *
+ */
+
+package scot.carricksoftware.grants.domains.census;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import scot.carricksoftware.grants.enums.census.CensusBoundaryType;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static scot.carricksoftware.grants.GenerateCensusRandomEnums.GetRandomCensusBoundaryType;
+
+@ExtendWith(MockitoExtension.class)
+class CensusEnumTest {
+
+    private Census census;
+
+    @BeforeEach
+    void setUp() {
+        census = new Census();
+    }
+
+    @Test
+    void getBoundaryType() {
+        assertNull(census.getBoundaryType());
+    }
+
+    @Test
+    void setBoundaryTypeTest() {
+        CensusBoundaryType boundaryType = GetRandomCensusBoundaryType();
+        census.setBoundaryType(boundaryType);
+        assertEquals(boundaryType, census.getBoundaryType());
+    }
+
+}