feat(person): route generation through service write paths (#689)
- fromCanonical writes the imported generation into a new Person row. - mergeCanonical routes existing/canonical generation through the existing preferHuman(Integer, Integer) overload so a human-edited value is never overwritten on re-import (ADR-025). - updatePerson writes generation verbatim from the form DTO so a human can clear it back to null — same shape as birthYear/deathYear. - createPerson(PersonUpdateDTO) writes generation so /persons/new flow doesn't silently drop a selected G value on create. Pinned with five tests covering the four write paths plus the documenting test that captures preferHuman's known limitation (explicit human null is overwritten by a non-null canonical value — same as birthYear/deathYear, deferred to a future helper rework if it ever produces a user-visible bug). Refs #689 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -177,6 +177,7 @@ public class PersonService {
|
||||
.notes(blankToNull(cmd.notes()))
|
||||
.birthYear(cmd.birthYear())
|
||||
.deathYear(cmd.deathYear())
|
||||
.generation(cmd.generation())
|
||||
.familyMember(cmd.familyMember())
|
||||
.personType(cmd.personType() == null ? PersonType.PERSON : cmd.personType())
|
||||
.provisional(cmd.provisional())
|
||||
@@ -200,6 +201,7 @@ public class PersonService {
|
||||
existing.setNotes(preferHuman(existing.getNotes(), cmd.notes()));
|
||||
existing.setBirthYear(preferHuman(existing.getBirthYear(), cmd.birthYear()));
|
||||
existing.setDeathYear(preferHuman(existing.getDeathYear(), cmd.deathYear()));
|
||||
existing.setGeneration(preferHuman(existing.getGeneration(), cmd.generation()));
|
||||
if (cmd.personType() != null && existing.getPersonType() == PersonType.PERSON) {
|
||||
existing.setPersonType(cmd.personType());
|
||||
}
|
||||
@@ -254,6 +256,7 @@ public class PersonService {
|
||||
.notes(dto.getNotes() == null || dto.getNotes().isBlank() ? null : dto.getNotes().trim())
|
||||
.birthYear(dto.getBirthYear())
|
||||
.deathYear(dto.getDeathYear())
|
||||
.generation(dto.getGeneration())
|
||||
.build();
|
||||
return personRepository.save(person);
|
||||
}
|
||||
@@ -286,6 +289,9 @@ public class PersonService {
|
||||
person.setNotes(dto.getNotes() == null || dto.getNotes().isBlank() ? null : dto.getNotes().trim());
|
||||
person.setBirthYear(dto.getBirthYear());
|
||||
person.setDeathYear(dto.getDeathYear());
|
||||
// Form path: a human can clear generation back to null. Unlike the importer
|
||||
// which routes through preferHuman, we write the DTO value verbatim.
|
||||
person.setGeneration(dto.getGeneration());
|
||||
return personRepository.save(person);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user