Search in sources :

Example 1 with PersonNameType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonNameType in project ddf by codice.

the class PersonNameTypeConverterTest method testConvertFullName.

@Test
public void testConvertFullName() throws Exception {
    PersonNameTypeConverter pntConverter = new PersonNameTypeConverter();
    Optional<PersonNameType> optionalPersonName = pntConverter.convert(personMap);
    assertThat(optionalPersonName, notNullValue());
    assertThat(optionalPersonName.isPresent(), is(true));
    PersonNameType personName = optionalPersonName.get();
    assertThat(personName, notNullValue());
    assertThat(personName.getFirstName(), is(equalTo(FIRST_NAME)));
    assertThat(personName.getMiddleName(), is(equalTo(MIDDLE_NAME)));
    assertThat(personName.getLastName(), is(equalTo(LAST_NAME)));
}
Also used : PersonNameTypeConverter(org.codice.ddf.registry.schemabindings.converter.type.PersonNameTypeConverter) PersonNameType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonNameType) Test(org.junit.Test)

Example 2 with PersonNameType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonNameType in project ddf by codice.

the class RegistryPackageWebConverterTest method getPersonName.

private PersonNameType getPersonName(String firstName, String lastname, String middleName) {
    PersonNameType personName = RIM_FACTORY.createPersonNameType();
    personName.setFirstName(firstName);
    personName.setLastName(lastname);
    personName.setMiddleName(middleName);
    return personName;
}
Also used : PersonNameType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonNameType)

Example 3 with PersonNameType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonNameType in project ddf by codice.

the class RegistryPackageConverter method parseRegistryPerson.

private static void parseRegistryPerson(PersonType person, MetacardImpl metacard) throws RegistryConversionException {
    validateIdentifiable(person);
    String name = "no name";
    String phone = "no telephone number";
    String email = "no email address";
    if (person.isSetPersonName()) {
        PersonNameType personName = person.getPersonName();
        List<String> nameParts = new ArrayList<>();
        if (StringUtils.isNotBlank(personName.getFirstName())) {
            nameParts.add(personName.getFirstName());
        }
        if (StringUtils.isNotBlank(personName.getLastName())) {
            nameParts.add(personName.getLastName());
        }
        if (CollectionUtils.isNotEmpty(nameParts)) {
            name = String.join(" ", nameParts);
        }
    }
    if (person.isSetTelephoneNumber()) {
        List<TelephoneNumberType> phoneNumbers = person.getTelephoneNumber();
        if (CollectionUtils.isNotEmpty(phoneNumbers)) {
            phone = getPhoneNumber(phoneNumbers.get(0));
        }
    }
    if (person.isSetEmailAddress()) {
        List<EmailAddressType> emailAddresses = person.getEmailAddress();
        if (CollectionUtils.isNotEmpty(emailAddresses)) {
            EmailAddressType emailAddress = emailAddresses.get(0);
            if (StringUtils.isNotBlank(emailAddress.getAddress())) {
                email = emailAddress.getAddress();
            }
        }
    }
    String metacardPoc = String.format("%s, %s, %s", name, phone, email);
    metacard.setAttribute(Metacard.POINT_OF_CONTACT, metacardPoc);
}
Also used : TelephoneNumberType(oasis.names.tc.ebxml_regrep.xsd.rim._3.TelephoneNumberType) ArrayList(java.util.ArrayList) EmailAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType) PersonNameType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonNameType)

Aggregations

PersonNameType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonNameType)3 ArrayList (java.util.ArrayList)1 EmailAddressType (oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType)1 TelephoneNumberType (oasis.names.tc.ebxml_regrep.xsd.rim._3.TelephoneNumberType)1 PersonNameTypeConverter (org.codice.ddf.registry.schemabindings.converter.type.PersonNameTypeConverter)1 Test (org.junit.Test)1