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
parent ef7d0f2182
commit 2a9ae80f81
2 changed files with 5 additions and 4 deletions

View File

@@ -97,8 +97,8 @@ public class RelationshipInferenceService {
List<RelationToken> path = shortestPaths.get(id);
PersonNodeDTO node = new PersonNodeDTO(
p.getId(), p.getDisplayName(),
p.getBirthDate() != null ? p.getBirthDate().getYear() : null,
p.getDeathDate() != null ? p.getDeathDate().getYear() : null,
RelationshipService.yearOf(p.getBirthDate()),
RelationshipService.yearOf(p.getDeathDate()),
p.getGeneration(), p.isFamilyMember());
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
// for persons with no date entered (ADR-039, REQ-PERSON-DATE-01).
private static Integer yearOf(LocalDate date) {
// for persons with no date entered (ADR-039, REQ-PERSON-DATE-01). Package-private
// so RelationshipInferenceService shares the same derivation.
static Integer yearOf(LocalDate date) {
return date != null ? date.getYear() : null;
}