public boolean removeSorName(SorPerson sorPerson, Long nameId) { SorName name = sorPerson.findNameByNameId(nameId); if (name == null) return false; // remove name from the set (annotation in set to delete orphans) sorPerson.getNames().remove(name); // save changes this.personRepository.saveSorPerson(sorPerson); return true; }
/** * Copy SorNames to Calculated Person * * @param person * @param sorPersons */ protected void copySorNamesToPerson(final Person person, final List<SorPerson> sorPersons) { person.getNames().clear(); for (final SorPerson sorPerson : sorPersons) { for (final SorName sorName : sorPerson.getNames()) { boolean alreadyAdded = false; for (final Name calculatedName : person.getNames()) { if (calculatedName.sameAs(sorName)) { alreadyAdded = true; break; } } if (!alreadyAdded) { person.addName(sorName); } } } }