瀏覽代碼

DataLoadCertificates::loadBirthCertificates

Andrew Grant 6 月之前
父節點
當前提交
e8e757a915
共有 1 個文件被更改,包括 38 次插入0 次删除
  1. 38 0
      src/main/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificates.java

+ 38 - 0
src/main/java/scot/carricksoftware/grants/bootstrap/DataLoadCertificates.java

@@ -9,6 +9,13 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.springframework.context.annotation.Profile;
 import org.springframework.stereotype.Component;
+import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommand;
+import scot.carricksoftware.grants.commands.certificates.birthcertificates.BirthCertificateCommandImpl;
+import scot.carricksoftware.grants.enums.certificates.CertificateType;
+import scot.carricksoftware.grants.enums.general.Sex;
+import scot.carricksoftware.grants.services.certificates.birthcertificates.BirthCertificateService;
+import scot.carricksoftware.grants.services.people.PersonService;
+import scot.carricksoftware.grants.services.places.organisations.OrganisationService;
 
 
 @Component
@@ -16,6 +23,15 @@ import org.springframework.stereotype.Component;
 public class DataLoadCertificates {
 
     private static final Logger logger = LogManager.getLogger(DataLoadCertificates.class);
+    private final OrganisationService organisationService;
+    private final BirthCertificateService birthCertificateService;
+    private final PersonService personService;
+
+    public DataLoadCertificates(OrganisationService organisationService, BirthCertificateService birthCertificateService, PersonService personService) {
+        this.organisationService = organisationService;
+        this.birthCertificateService = birthCertificateService;
+        this.personService = personService;
+    }
 
     public void load() {
         logger.debug("DataLoadCertificates::load");
@@ -25,10 +41,32 @@ public class DataLoadCertificates {
 
     private void loadBirthCertificates() {
         logger.debug("DataLoadCertificates::LoadBirthCertificates");
+        BirthCertificateCommand birthCertificateCommand = new BirthCertificateCommandImpl();
+
+        birthCertificateCommand.setCertificateNumber("999");
+        birthCertificateCommand.setCertificateDate("25/01/1953");
+        birthCertificateCommand.setCertificateType(CertificateType.EXTRACT);
+
+        birthCertificateCommand.setRegistrationAuthority(organisationService.findByName("Registration Authority"));
+        birthCertificateCommand.setVolume("01");
+        birthCertificateCommand.setNumber("02");
+        birthCertificateCommand.setCertificateSource(organisationService.findByName("Certificate Source"));
+
+        birthCertificateCommand.setNewBorn(personService.findById(3L));
+        birthCertificateCommand.setSex(Sex.MALE);
+        birthCertificateCommand.setWhenBorn("25/01/1953 01:01");
+        birthCertificateCommand.setWhereBorn("Edinburgh");
+        birthCertificateCommand.setFather(personService.findById(1L));
+        birthCertificateCommand.setUntrackedFather("Untracked Father");
+
+        birthCertificateCommand.setMother(personService.findById(2L));
+
+        birthCertificateService.saveBirthCertificateCommand(birthCertificateCommand);
     }
 
     private void loadDeathCertificates() {
         logger.debug("DataLoadCertificates::LoadDeathCertificates");
+
     }