use of nl.knaw.huygens.timbuctoo.model.PersonNameComponent in project timbuctoo by HuygensING.
the class UriBearingPersonNames method insertNameComponentAtNaturalPosition.
private void insertNameComponentAtNaturalPosition(PersonNameComponent.Type nameType, String value, PersonName currentPersonName) {
final List<PersonNameComponent> currentPersonNameComponents = currentPersonName.getComponents();
int currentIndex = getNaturalComponentPos(nameType, currentPersonNameComponents);
final PersonNameComponent newNameComponent = new PersonNameComponent(nameType, value);
currentPersonNameComponents.add(currentIndex, newNameComponent);
}
use of nl.knaw.huygens.timbuctoo.model.PersonNameComponent in project timbuctoo by HuygensING.
the class PersonNameBuilderTest method testTwoComponentsReversed.
@Test
public void testTwoComponentsReversed() {
PersonNameBuilder builder = new PersonNameBuilder();
builder.addComponent(new PersonNameComponent(Type.SURNAME, "Huygens"));
builder.addComponent(new PersonNameComponent(Type.FORENAME, "Christiaan"));
assertThat(builder.getName(), equalTo("Huygens, Christiaan"));
}
use of nl.knaw.huygens.timbuctoo.model.PersonNameComponent in project timbuctoo by HuygensING.
the class PersonNameBuilderTest method testOneComponent.
@Test
public void testOneComponent() {
PersonNameBuilder builder = new PersonNameBuilder();
builder.addComponent(new PersonNameComponent(Type.FORENAME, "Christiaan"));
assertThat(builder.getName(), equalTo("Christiaan"));
}
use of nl.knaw.huygens.timbuctoo.model.PersonNameComponent in project timbuctoo by HuygensING.
the class PersonNameBuilderTest method testTwoComponents.
@Test
public void testTwoComponents() {
PersonNameBuilder builder = new PersonNameBuilder();
builder.addComponent(new PersonNameComponent(Type.FORENAME, "Christiaan"));
builder.addComponent(new PersonNameComponent(Type.SURNAME, "Huygens"));
assertThat(builder.getName(), equalTo("Christiaan Huygens"));
}
use of nl.knaw.huygens.timbuctoo.model.PersonNameComponent in project timbuctoo by HuygensING.
the class UriBearingPersonNames method removeComponent.
public void removeComponent(String nameUri, PersonNameComponent.Type nameType, String value) {
if (!nameUris.containsKey(nameUri)) {
LoggerFactory.getLogger(UriBearingPersonNames.class).error("Uri '{}' not known", nameUri);
return;
}
PersonName personName = list.get(nameUris.get(nameUri));
personName.getComponents().remove(new PersonNameComponent(nameType, value));
if (personName.getComponents().isEmpty()) {
list.remove(personName);
Integer indexOfRemoved = nameUris.remove(nameUri);
// reindex the name uri's, because the list will do this automatically.
Map<String, Integer> newNameUris = Maps.newHashMap();
nameUris.forEach((key, val) -> {
if (val > indexOfRemoved) {
val--;
}
newNameUris.put(key, val);
});
nameUris = newNameUris;
}
}
Aggregations