Skip to content

Commit

Permalink
Register territory (as processed again by the preacher)
Browse files Browse the repository at this point in the history
  • Loading branch information
hydrogen2oxygen committed May 18, 2023
1 parent 18acc83 commit 975e5db
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>pom</packaging>

<properties>
<revision>1.1.3</revision>
<revision>1.1.4</revision>
<version.info>Removed NitriteDB as main database, instead using ObjectMapper and plain JSON (faster and stable)</version.info>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>

<version>1.1.3</version>
<version>1.1.4</version>
<groupId>de.pietro.lusso</groupId>
<artifactId>server</artifactId>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class RegistryEntry implements Serializable {
private Date assignDate;
private Date returnDate;

private Boolean registration = false;

public String getTerritoryNumber() {
return territoryNumber;
}
Expand Down Expand Up @@ -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() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
public class Dashboard {

private String finalApproachVersion = "";
private UUID uuid;
private List<TerritoryInfos> territories = new ArrayList<>();

Expand All @@ -27,4 +28,12 @@ public List<TerritoryInfos> getTerritories() {
public void setTerritories(List<TerritoryInfos> territories) {
this.territories = territories;
}

public String getFinalApproachVersion() {
return finalApproachVersion;
}

public void setFinalApproachVersion(String finalApproachVersion) {
this.finalApproachVersion = finalApproachVersion;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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> 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 {
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class AppComponent {

constructor(
private router: Router,

private route: ActivatedRoute,
private congregationService:CongregationService,
private navigationService:NavigationService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h3 class="text-dark">{{territory.number}} {{territory.name}}</h3>
</tr>
</thead>
<tbody>
<tr *ngFor="let registryEntry of territory.registryEntryList; index as i" class="col-auto">
<tr *ngFor="let registryEntry of territory.registryEntryList; index as i" class="col-auto" [class.registered]="registryEntry.registration">
<td>{{registryEntry.preacher.name}}</td>
<td>{{registryEntry.assignDate | date:'dd-MM-yy'}}</td>
<td>{{registryEntry.returnDate | date:'dd-MM-yy'}}</td>
Expand Down Expand Up @@ -185,6 +185,7 @@ <h3 class="text-dark">{{territory.number}} {{territory.name}}</h3>

</div>
<div class="modal-footer" *ngIf="territory">
<button type="button" class="btn btn-success" style="margin-right: 1rem" (click)="registerTerritory(territory)" data-bs-toggle="modal" data-bs-target="#territoryDetailsModal">REGISTER</button>
<button type="button" class="btn btn-warning" (click)="repairTerritory(territory)" data-bs-toggle="modal" data-bs-target="#territoryDetailsModal">REPAIR</button>
<button type="button" class="btn btn-outline-warning" (click)="territory = null" data-bs-toggle="modal" data-bs-target="#territoryDetailsModal">Cancel</button>
<button type="button" class="btn btn-outline-success" (click)="saveTerritory()" data-bs-toggle="modal" data-bs-target="#territoryDetailsModal">Save</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ button.archivedButton {
margin: 0.1rem;
font-weight: bolder;
}

.registered {
background-color: #d7f5e8 !important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class TerritoriesComponent implements OnInit {
}

showTerritoryDetails(territory: Territory) {
console.log(territory)
this.territory = territory;
this.intoArchive.setValue(territory.archive);
this.noContacts.setValue(territory.noContacts);
Expand Down Expand Up @@ -145,4 +146,10 @@ export class TerritoriesComponent implements OnInit {
this.toastr.success("S-16 was created inside root folder!","PDF PRINT SERVICE")
});
}

registerTerritory(territory: Territory) {
this.congregationService.registerTerritory(territory.number).subscribe( () => {
this.toastr.info('Territory registered!','Territory Service')
});
}
}
2 changes: 2 additions & 0 deletions server/src/main/ui2/src/app/domains/Congregation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export class RegistryEntry {
preacher:Preacher = new Preacher();
assignDate:Date = new Date();
returnDate:Date | null = new Date();

registration:boolean = false;
territory:Territory = new Territory();
}

Expand Down
5 changes: 5 additions & 0 deletions server/src/main/ui2/src/app/services/congregation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export class CongregationService {
return this.http.get<void>(`${CongregationService.url}printPDF`);
}

registerTerritory(territoryNumber?:string):Observable<Message> {

return this.http.post<Message>(`${CongregationService.url}registerTerritory/${territoryNumber}`,null);
}

exportDatabase():Observable<void> {
return this.http.post<void>(`${CongregationService.url}exportDatabase`,null);
}
Expand Down

0 comments on commit 975e5db

Please sign in to comment.