use of nl.knaw.huygens.timbuctoo.model.PersonNames in project timbuctoo by HuygensING.
the class PersonNamesDefaultNamePropertyParserTest method parseForSortReturnsAStringThatConsistsOfSortNameVariantOfTheDefaultName.
@Test
public void parseForSortReturnsAStringThatConsistsOfSortNameVariantOfTheDefaultName() throws JsonProcessingException {
PersonNames names = new PersonNames();
PersonName name1 = PersonName.newInstance("forename", "surname");
names.list.add(name1);
PersonName name2 = PersonName.newInstance("forename2", "surname2");
names.list.add(name2);
String input = new ObjectMapper().writeValueAsString(names);
Object value = instance.parseForSort(input);
assertThat(value, is(names.defaultName().getSortName()));
}
use of nl.knaw.huygens.timbuctoo.model.PersonNames in project timbuctoo by HuygensING.
the class PersonNamesTripleProcessor method processAssertion.
@Override
protected void processAssertion(String vreName, String subject, String predicate, String lexicalValue, String typeUri) {
LOG.debug("Process PersonNames triple for subject '{}' with value '{}'", subject, lexicalValue);
Entity entity = database.findOrCreateEntity(vreName, subject);
String propertyName = getLocalName(predicate);
Optional<String> propertyValue = entity.getPropertyValue(propertyName);
try {
PersonName personName = objectMapper.readValue(lexicalValue, PersonName.class);
PersonNames personNames = getPersonNames(objectMapper, propertyValue);
personNames.list.add(personName);
String names = objectMapper.writeValueAsString(personNames);
// Because the person names is wrapped in a person names type, the type changes
entity.addProperty(propertyName, names, NAMES_TYPE_ID);
} catch (IOException e) {
LOG.error("Could not convert '{}' to PersonName", lexicalValue);
}
}
Aggregations