diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 9990ecc..a9a71a4 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -21,11 +21,11 @@ jobs: - name: Upload Artifact - Make Directory run: | mkdir -p finalApproach; - cp server/target/server-1.1.3.jar finalApproach/server.jar; - cp updater/target/updater-1.1.3-jar-with-dependencies.jar finalApproach/launcher.jar; - cp updater/target/updater-1.1.3-jar-with-dependencies.jar finalApproach/newlauncher.jar; + cp server/target/server-1.1.4.jar finalApproach/server.jar; + cp updater/target/updater-1.1.4-jar-with-dependencies.jar finalApproach/launcher.jar; + cp updater/target/updater-1.1.4-jar-with-dependencies.jar finalApproach/newlauncher.jar; cp scripts/start.bat finalApproach/; - uses: actions/upload-artifact@v3 with: - name: final-approach-1.1.3 + name: final-approach-1.1.4 path: finalApproach diff --git a/pom.xml b/pom.xml index 201a1ed..1a4aa06 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ pom - 1.1.3 + 1.1.4 Removed NitriteDB as main database, instead using ObjectMapper and plain JSON (faster and stable) diff --git a/server/pom.xml b/server/pom.xml index 9ff4e42..1c0c05b 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -12,7 +12,7 @@ - 1.1.3 + 1.1.4 de.pietro.lusso server diff --git a/server/src/main/java/de/pietro/lusso/territory/adapter/CongregationAdapter.java b/server/src/main/java/de/pietro/lusso/territory/adapter/CongregationAdapter.java index 45cccc0..a168b0b 100644 --- a/server/src/main/java/de/pietro/lusso/territory/adapter/CongregationAdapter.java +++ b/server/src/main/java/de/pietro/lusso/territory/adapter/CongregationAdapter.java @@ -74,6 +74,14 @@ public void getTerritoryImageAsByteArray(@PathVariable String number, HttpServle ImageIO.write(image, "PNG", response.getOutputStream()); } + @PostMapping("registerTerritory/{number}") + public Message registerTerritory(@PathVariable String number) throws Exception { + databaseService.registerTerritory(number); + Message msg = new Message(); + msg.setMsg("Territory " + number + " registered!"); + return msg; + } + @PostMapping("exportDatabase") public void exportDatabase() { databaseService.exportDatabase(); diff --git a/server/src/main/java/de/pietro/lusso/territory/domain/RegistryEntry.java b/server/src/main/java/de/pietro/lusso/territory/domain/RegistryEntry.java index 00c6bfa..7460e85 100644 --- a/server/src/main/java/de/pietro/lusso/territory/domain/RegistryEntry.java +++ b/server/src/main/java/de/pietro/lusso/territory/domain/RegistryEntry.java @@ -11,6 +11,8 @@ public class RegistryEntry implements Serializable { private Date assignDate; private Date returnDate; + private Boolean registration = false; + public String getTerritoryNumber() { return territoryNumber; } @@ -43,6 +45,14 @@ public void setReturnDate(Date returnDate) { this.returnDate = returnDate; } + public Boolean getRegistration() { + return registration; + } + + public void setRegistration(Boolean registration) { + this.registration = registration; + } + @Override public String toString() { diff --git a/server/src/main/java/de/pietro/lusso/territory/domain/dashboard/Dashboard.java b/server/src/main/java/de/pietro/lusso/territory/domain/dashboard/Dashboard.java index a706024..bc03428 100644 --- a/server/src/main/java/de/pietro/lusso/territory/domain/dashboard/Dashboard.java +++ b/server/src/main/java/de/pietro/lusso/territory/domain/dashboard/Dashboard.java @@ -9,6 +9,7 @@ */ public class Dashboard { + private String finalApproachVersion = ""; private UUID uuid; private List territories = new ArrayList<>(); @@ -27,4 +28,12 @@ public List getTerritories() { public void setTerritories(List territories) { this.territories = territories; } + + public String getFinalApproachVersion() { + return finalApproachVersion; + } + + public void setFinalApproachVersion(String finalApproachVersion) { + this.finalApproachVersion = finalApproachVersion; + } } diff --git a/server/src/main/java/de/pietro/lusso/territory/services/DatabaseService.java b/server/src/main/java/de/pietro/lusso/territory/services/DatabaseService.java index fc05bce..b447d02 100644 --- a/server/src/main/java/de/pietro/lusso/territory/services/DatabaseService.java +++ b/server/src/main/java/de/pietro/lusso/territory/services/DatabaseService.java @@ -35,6 +35,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; @@ -242,13 +243,13 @@ private void splitTerritories(Congregation congregation) { continue; } - if (territory.getRegistryEntryList().get(registrySize - 1).getAssignDate().before(old8Cal.getTime())) { + if (territory.getDate().before(old8Cal.getTime())) { congregation.getTerritoriesOlder8Months().add(territory); toBeRemoved.add(territory); continue; } - if (territory.getRegistryEntryList().get(registrySize - 1).getAssignDate().before(old4Cal.getTime())) { + if (territory.getDate().before(old4Cal.getTime())) { congregation.getTerritoriesOlder4Months().add(territory); toBeRemoved.add(territory); continue; @@ -290,8 +291,16 @@ public int compare(Territory o1, Territory o2) { private void setLastAssignedDate(final Territory territory) { int registrySize = territory.getRegistryEntryList().size(); if (registrySize == 0) return; - Date date = territory.getRegistryEntryList().get(registrySize - 1).getAssignDate(); - territory.setDate(date); + + // set the last assignment, but not the last registration + AtomicReference date = new AtomicReference<>(); + territory.getRegistryEntryList().forEach(registryEntry -> { + if (!registryEntry.getRegistration()) { + date.set(registryEntry.getAssignDate()); + } + }); + //territory.getRegistryEntryList().get(registrySize - 1).getAssignDate(); + territory.setDate(date.get()); } private Congregation enhanceCongregationData(Congregation congregation) throws IOException { @@ -434,6 +443,7 @@ public int compare(Preacher o1, Preacher o2) { try { Preacher preacher = loadPreacher(congregation, preacherName); Dashboard dashboard = new Dashboard(); + dashboard.setFinalApproachVersion(readVersionInfos().getRevision()); dashboard.setUuid(preacher.getUuid()); for (String territoryNumber : preacher.getTerritoryListNumbers()) { @@ -1194,4 +1204,17 @@ public Congregation returnTerritory(String number) throws IOException { return saveCongregation(congregation); } + + public void registerTerritory(String number) throws IOException { + Congregation congregation = loadCongregation(); + Territory territory = getTerritoryByNumber(congregation, number); + RegistryEntry registryEntry = territory.getRegistryEntryList().get(territory.getRegistryEntryList().size() -1); + RegistryEntry registration = new RegistryEntry(); + registration.setAssignDate(Calendar.getInstance().getTime()); + registration.setPreacher(getPreacherByName(registryEntry.getPreacher().getName())); + registration.setTerritoryNumber(registryEntry.getTerritoryNumber()); + registration.setRegistration(true); // this is the difference! + territory.getRegistryEntryList().add(registration); + saveCongregation(congregation); + } } diff --git a/server/src/main/java/de/pietro/lusso/territory/services/PrintService.java b/server/src/main/java/de/pietro/lusso/territory/services/PrintService.java index a20b208..221f85d 100644 --- a/server/src/main/java/de/pietro/lusso/territory/services/PrintService.java +++ b/server/src/main/java/de/pietro/lusso/territory/services/PrintService.java @@ -401,6 +401,10 @@ public int compare(RegistryEntry o1, RegistryEntry o2) { ZoneId.systemDefault()); } + if (entry.getTerritoryNumber() == null) { + continue; + } + String territoryName = entry.getTerritoryNumber() + " " + territoryMap.get(entry.getTerritoryNumber()); if (entry.getReturnDate() != null || entry.getPreacher().getName().toLowerCase().trim().equals(Congregation.CONGREGATION.toLowerCase())) { diff --git a/server/src/main/ui2/src/app/components/app/app.component.ts b/server/src/main/ui2/src/app/components/app/app.component.ts index 2f1ae9e..53c001e 100644 --- a/server/src/main/ui2/src/app/components/app/app.component.ts +++ b/server/src/main/ui2/src/app/components/app/app.component.ts @@ -19,6 +19,7 @@ export class AppComponent { constructor( private router: Router, + private route: ActivatedRoute, private congregationService:CongregationService, private navigationService:NavigationService, diff --git a/server/src/main/ui2/src/app/components/territories/territories.component.html b/server/src/main/ui2/src/app/components/territories/territories.component.html index 7be513e..679ee24 100644 --- a/server/src/main/ui2/src/app/components/territories/territories.component.html +++ b/server/src/main/ui2/src/app/components/territories/territories.component.html @@ -127,7 +127,7 @@ {{territory.number}} {{territory.name}} - + {{registryEntry.preacher.name}} {{registryEntry.assignDate | date:'dd-MM-yy'}} {{registryEntry.returnDate | date:'dd-MM-yy'}} @@ -185,6 +185,7 @@ {{territory.number}} {{territory.name}}