Search in sources :

Example 1 with EmailAddressType

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

the class RegistryPackageWebConverterTest method getEmailAddress.

private EmailAddressType getEmailAddress(String address, String type) {
    EmailAddressType emailAddress = RIM_FACTORY.createEmailAddressType();
    emailAddress.setAddress(address);
    emailAddress.setType(type);
    return emailAddress;
}
Also used : EmailAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType)

Example 2 with EmailAddressType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType 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)

Example 3 with EmailAddressType

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

the class PersonWebConverter method convert.

/**
     * This method creates a Map<String, Object> representation of the PersonType provided.
     * The following keys will be added to the map (Taken from EbrimConstants):
     * <p>
     * PERSON_NAME_KEY = "PersonName"
     * ADDRESS_KEY = "Address";
     * EMAIL_ADDRESS_KEY = "EmailAddress";
     * TELEPHONE_KEY = "TelephoneNumber";
     * <p>
     * This will also try to parse RegistryObjectType values to the map.
     * <p>
     * Uses:
     * PostalAddressWebConverter
     * EmailAddressWebConverter
     * TelephoneNumberWebConverter
     * PersonNameWebConverter
     *
     * @param person the PersonType to be converted into a map, null returns empty Map
     * @return Map<String, Object> representation of the PersonType provided
     */
public Map<String, Object> convert(PersonType person) {
    Map<String, Object> personMap = new HashMap<>();
    if (person == null) {
        return personMap;
    }
    webMapHelper.putAllIfNotEmpty(personMap, super.convertRegistryObject(person));
    if (person.isSetAddress()) {
        List<Map<String, Object>> addresses = new ArrayList<>();
        PostalAddressWebConverter addressConverter = new PostalAddressWebConverter();
        for (PostalAddressType address : person.getAddress()) {
            Map<String, Object> addressMap = addressConverter.convert(address);
            if (MapUtils.isNotEmpty(addressMap)) {
                addresses.add(addressMap);
            }
        }
        webMapHelper.putIfNotEmpty(personMap, ADDRESS_KEY, addresses);
    }
    if (person.isSetEmailAddress()) {
        List<Map<String, Object>> emailAddresses = new ArrayList<>();
        EmailAddressWebConverter emailConverter = new EmailAddressWebConverter();
        for (EmailAddressType email : person.getEmailAddress()) {
            Map<String, Object> emailMap = emailConverter.convert(email);
            if (MapUtils.isNotEmpty(emailMap)) {
                emailAddresses.add(emailMap);
            }
        }
        webMapHelper.putIfNotEmpty(personMap, EMAIL_ADDRESS_KEY, emailAddresses);
    }
    if (person.isSetPersonName()) {
        PersonNameWebConverter personNameConverter = new PersonNameWebConverter();
        Map<String, Object> personNameMap = personNameConverter.convert(person.getPersonName());
        webMapHelper.putIfNotEmpty(personMap, PERSON_NAME_KEY, personNameMap);
    }
    if (person.isSetTelephoneNumber()) {
        List<Map<String, Object>> telephoneNumbers = new ArrayList<>();
        TelephoneNumberWebConverter telephoneConverter = new TelephoneNumberWebConverter();
        for (TelephoneNumberType telephone : person.getTelephoneNumber()) {
            Map<String, Object> telephoneMap = telephoneConverter.convert(telephone);
            if (MapUtils.isNotEmpty(telephoneMap)) {
                telephoneNumbers.add(telephoneMap);
            }
        }
        webMapHelper.putIfNotEmpty(personMap, TELEPHONE_KEY, telephoneNumbers);
    }
    return personMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PostalAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PostalAddressType) TelephoneNumberType(oasis.names.tc.ebxml_regrep.xsd.rim._3.TelephoneNumberType) EmailAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with EmailAddressType

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

the class OrganizationWebConverter method convert.

/**
     * This method creates a Map<String, Object> representation of the OrganizationType provided.
     * The following keys will be added to the map (Taken from EbrimConstants):
     * <p>
     * PARENT = "parent";
     * PRIMARY_CONTACT = "primaryContact";
     * ADDRESS_KEY = "Address";
     * EMAIL_ADDRESS_KEY = "EmailAddress";
     * TELEPHONE_KEY = "TelephoneNumber";
     * <p>
     * This will also try to parse RegistryObjectType values to the map.
     * <p>
     * Uses:
     * PostalAddressWebConverter
     * EmailAddressWebConverter
     * TelephoneNumberWebConverter
     *
     * @param organization the OrganizationType to be converted into a map, null returns empty Map
     * @return Map<String, Object> representation of the OrganizationType provided
     */
public Map<String, Object> convert(OrganizationType organization) {
    Map<String, Object> organizationMap = new HashMap<>();
    if (organization == null) {
        return organizationMap;
    }
    webMapHelper.putAllIfNotEmpty(organizationMap, super.convertRegistryObject(organization));
    if (organization.isSetAddress()) {
        List<Map<String, Object>> addresses = new ArrayList<>();
        PostalAddressWebConverter addressConverter = new PostalAddressWebConverter();
        for (PostalAddressType address : organization.getAddress()) {
            Map<String, Object> addressMap = addressConverter.convert(address);
            if (MapUtils.isNotEmpty(addressMap)) {
                addresses.add(addressMap);
            }
        }
        webMapHelper.putIfNotEmpty(organizationMap, ADDRESS_KEY, addresses);
    }
    if (organization.isSetEmailAddress()) {
        List<Map<String, Object>> emailAddresses = new ArrayList<>();
        EmailAddressWebConverter emailConverter = new EmailAddressWebConverter();
        for (EmailAddressType email : organization.getEmailAddress()) {
            Map<String, Object> emailMap = emailConverter.convert(email);
            if (MapUtils.isNotEmpty(emailMap)) {
                emailAddresses.add(emailMap);
            }
        }
        webMapHelper.putIfNotEmpty(organizationMap, EMAIL_ADDRESS_KEY, emailAddresses);
    }
    webMapHelper.putIfNotEmpty(organizationMap, PARENT, organization.getParent());
    webMapHelper.putIfNotEmpty(organizationMap, PRIMARY_CONTACT, organization.getPrimaryContact());
    if (organization.isSetTelephoneNumber()) {
        List<Map<String, Object>> telephoneNumbers = new ArrayList<>();
        TelephoneNumberWebConverter telephoneConverter = new TelephoneNumberWebConverter();
        for (TelephoneNumberType telephone : organization.getTelephoneNumber()) {
            Map<String, Object> telephoneMap = telephoneConverter.convert(telephone);
            if (MapUtils.isNotEmpty(telephoneMap)) {
                telephoneNumbers.add(telephoneMap);
            }
        }
        webMapHelper.putIfNotEmpty(organizationMap, TELEPHONE_KEY, telephoneNumbers);
    }
    return organizationMap;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PostalAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PostalAddressType) TelephoneNumberType(oasis.names.tc.ebxml_regrep.xsd.rim._3.TelephoneNumberType) EmailAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with EmailAddressType

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

the class RegistryPackageTypeHelperTest method assertPersons.

private void assertPersons(List<PersonType> persons) {
    // Values from xml file
    int expectedPersonsSize = 3;
    int expectedSize = 1;
    String expectedFirstName = "john";
    String expectedMiddleName = "middleName";
    String expectedLastname = "doe";
    String expectedCity = "Phoenix";
    String expectedCountry = "USA";
    String expectedPostalCode = "85037";
    String expectedState = "AZ";
    String expectedStreet = "1234 Some Street";
    String expectedAreaCode = "111";
    String expectedNumber = "111-1111";
    String expectedExtension = "1234";
    String expectedCountryCode = "country";
    String expectedPhoneType = "cell phone";
    String expectedEmail = "emailaddress@something.com";
    assertThat(persons, hasSize(expectedPersonsSize));
    PersonType person = persons.get(0);
    assertThat(person.isSetPersonName(), is(true));
    assertPersonName(person.getPersonName(), expectedFirstName, expectedMiddleName, expectedLastname);
    assertThat(person.isSetAddress(), is(true));
    List<PostalAddressType> addresses = person.getAddress();
    assertThat(addresses, hasSize(expectedSize));
    assertAddress(addresses.get(0), expectedCity, expectedCountry, expectedPostalCode, expectedState, expectedStreet);
    assertThat(person.isSetTelephoneNumber(), is(true));
    List<TelephoneNumberType> phoneNumbers = person.getTelephoneNumber();
    assertThat(phoneNumbers, hasSize(expectedSize));
    assertPhoneNumbers(phoneNumbers.get(0), expectedAreaCode, expectedNumber, expectedExtension, expectedCountryCode, expectedPhoneType);
    assertThat(person.isSetEmailAddress(), is(true));
    assertThat(person.getEmailAddress(), hasSize(expectedSize));
    List<EmailAddressType> emailAddresses = person.getEmailAddress();
    assertThat(emailAddresses.get(0).getAddress(), is(equalTo(expectedEmail)));
}
Also used : TelephoneNumberType(oasis.names.tc.ebxml_regrep.xsd.rim._3.TelephoneNumberType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) EmailAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType) PostalAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PostalAddressType)

Aggregations

EmailAddressType (oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType)6 TelephoneNumberType (oasis.names.tc.ebxml_regrep.xsd.rim._3.TelephoneNumberType)5 PostalAddressType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PostalAddressType)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)1 PersonNameType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonNameType)1 PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)1