refactor(person): share yearOf between relationship services

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-12 19:35:50 +02:00
committed by marcel
parent fe4e2d97d0
commit 3626cd1a6d
2 changed files with 5 additions and 4 deletions

View File

@@ -97,8 +97,8 @@ public class RelationshipInferenceService {
List<RelationToken> path = shortestPaths.get(id); List<RelationToken> path = shortestPaths.get(id);
PersonNodeDTO node = new PersonNodeDTO( PersonNodeDTO node = new PersonNodeDTO(
p.getId(), p.getDisplayName(), p.getId(), p.getDisplayName(),
p.getBirthDate() != null ? p.getBirthDate().getYear() : null, RelationshipService.yearOf(p.getBirthDate()),
p.getDeathDate() != null ? p.getDeathDate().getYear() : null, RelationshipService.yearOf(p.getDeathDate()),
p.getGeneration(), p.isFamilyMember()); p.getGeneration(), p.isFamilyMember());
out.add(new InferredRelationshipWithPersonDTO(node, labelFor(path), path.size())); out.add(new InferredRelationshipWithPersonDTO(node, labelFor(path), path.size()));
} }

View File

@@ -158,8 +158,9 @@ public class RelationshipService {
} }
// Stammbaum DTOs stay year-shaped: derive the year from the LocalDate, null-safe // Stammbaum DTOs stay year-shaped: derive the year from the LocalDate, null-safe
// for persons with no date entered (ADR-039, REQ-PERSON-DATE-01). // for persons with no date entered (ADR-039, REQ-PERSON-DATE-01). Package-private
private static Integer yearOf(LocalDate date) { // so RelationshipInferenceService shares the same derivation.
static Integer yearOf(LocalDate date) {
return date != null ? date.getYear() : null; return date != null ? date.getYear() : null;
} }