/** * Used to retrieve the duplicate entries for the given name string * * @param name the name * @return a list of {@link org.oruko.dictionary.model.DuplicateNameEntry} */ public List<DuplicateNameEntry> loadNameDuplicates(String name) { return duplicateEntryRepository.findByName(name); }
/** * /** * Updates the properties with values from another {@link org.oruko.dictionary.model.NameEntry} * * @param oldEntry the entry to be updated * @param newEntry the entry with the new value * @return the updated entry */ public NameEntry updateName(NameEntry oldEntry, NameEntry newEntry) { String oldEntryName = oldEntry.getName(); // update main entry oldEntry.update(newEntry); List<DuplicateNameEntry> oldDuplicateNames = duplicateEntryRepository.findByName(oldEntryName); // update all duplicate entries oldDuplicateNames.forEach(duplicateNameEntry -> { duplicateNameEntry.setName(newEntry.getName()); duplicateEntryRepository.save(duplicateNameEntry); }); return nameEntryRepository.save(oldEntry); }