Search in sources :

Example 6 with PersonType

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

the class RegistryPackageWebConverterTest method getThirdPerson.

private PersonType getThirdPerson() {
    PersonType person = RIM_FACTORY.createPersonType();
    person.setId("urn:contact:id2");
    person.setPersonName(getPersonName("john2", "doe2", null));
    person.getTelephoneNumber().add(getPhoneNumber("111", null, "1234", "111-1111", null));
    person.getEmailAddress().add(getEmailAddress("emailaddress@something.com", null));
    return person;
}
Also used : PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)

Example 7 with PersonType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType 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 8 with PersonType

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

the class RegistryPackageConverter method parseRegistryObjectList.

private static void parseRegistryObjectList(RegistryObjectListType registryObjects, MetacardImpl metacard) throws RegistryConversionException {
    Map<String, Set<String>> associations = new HashMap<>();
    Map<String, RegistryObjectType> registryIds = new HashMap<>();
    List<OrganizationType> orgs = new ArrayList<>();
    List<PersonType> contacts = new ArrayList<>();
    String nodeId = "";
    for (JAXBElement identifiable : registryObjects.getIdentifiable()) {
        RegistryObjectType registryObject = (RegistryObjectType) identifiable.getValue();
        registryIds.put(registryObject.getId(), registryObject);
        if (registryObject instanceof ExtrinsicObjectType && RegistryConstants.REGISTRY_NODE_OBJECT_TYPE.equals(registryObject.getObjectType())) {
            nodeId = registryObject.getId();
            parseNodeExtrinsicObject(registryObject, metacard);
        } else if (registryObject instanceof ServiceType && RegistryConstants.REGISTRY_SERVICE_OBJECT_TYPE.equals(registryObject.getObjectType())) {
            parseRegistryService((ServiceType) registryObject, metacard);
        } else if (registryObject instanceof OrganizationType) {
            orgs.add((OrganizationType) registryObject);
        } else if (registryObject instanceof PersonType) {
            contacts.add((PersonType) registryObject);
        } else if (registryObject instanceof AssociationType1) {
            AssociationType1 association = (AssociationType1) registryObject;
            if (associations.containsKey(association.getSourceObject())) {
                associations.get(association.getSourceObject()).add(association.getTargetObject());
            } else {
                associations.put(association.getSourceObject(), new HashSet<>(Collections.singleton(association.getTargetObject())));
            }
        }
    }
    boolean orgFound = false;
    boolean contactFound = false;
    if (associations.get(nodeId) != null) {
        Set<String> nodeAssociations = associations.get(nodeId);
        RegistryObjectType ro;
        for (String id : nodeAssociations) {
            ro = registryIds.get(id);
            if (!orgFound && ro != null && ro instanceof OrganizationType) {
                parseRegistryOrganization((OrganizationType) ro, metacard);
                orgFound = true;
            } else if (!contactFound && ro != null && ro instanceof PersonType) {
                parseRegistryPerson((PersonType) ro, metacard);
                contactFound = true;
            }
        }
    }
    if (!orgFound && !orgs.isEmpty()) {
        parseRegistryOrganization(orgs.get(0), metacard);
    }
    if (!contactFound && !contacts.isEmpty()) {
        parseRegistryPerson(contacts.get(0), metacard);
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AssociationType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) JAXBElement(javax.xml.bind.JAXBElement) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) ServiceType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 9 with PersonType

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

the class RegistryPackageConverter method getRegistryObjectMetacard.

public static Metacard getRegistryObjectMetacard(RegistryObjectType registryObject, MetacardType metacardType) throws RegistryConversionException {
    MetacardImpl metacard = null;
    if (registryObject == null) {
        return metacard;
    }
    validateIdentifiable(registryObject);
    metacard = new MetacardImpl(metacardType);
    parseTopLevel(registryObject, metacard);
    if (registryObject instanceof RegistryPackageType) {
        parseRegistryPackage((RegistryPackageType) registryObject, metacard);
    } else if (registryObject instanceof ExtrinsicObjectType) {
        parseNodeExtrinsicObject(registryObject, metacard);
    } else if (registryObject instanceof ServiceType) {
        parseRegistryService((ServiceType) registryObject, metacard);
    } else if (registryObject instanceof OrganizationType) {
        parseRegistryOrganization((OrganizationType) registryObject, metacard);
    } else if (registryObject instanceof PersonType) {
        parseRegistryPerson((PersonType) registryObject, metacard);
    } else {
        LOGGER.debug("Unexpected object found: {}", registryObject);
    }
    return metacard;
}
Also used : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) ServiceType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 10 with PersonType

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

the class RegistryPackageTypeHelperTest method testGetObjectsAssociatedToServiceFromRegistryObjectList.

@Test
public void testGetObjectsAssociatedToServiceFromRegistryObjectList() throws Exception {
    String testServiceId = "urn:service:id0";
    RegistryObjectListType registryObjectList = ((RegistryPackageType) registryObject).getRegistryObjectList();
    List<OrganizationType> organizations = rptHelper.getAssociatedObjects(registryObjectList, testServiceId, OrganizationType.class);
    assertThat(organizations, hasSize(1));
    assertThat(organizations.get(0).getId(), is(equalTo("urn:organization:id0")));
    List<PersonType> contacts = rptHelper.getAssociatedObjects(testServiceId, PersonType.class);
    assertThat(contacts, hasSize(1));
    assertThat(contacts.get(0).getId(), is(equalTo("urn:contact:id1")));
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) PersonType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) Test(org.junit.Test)

Aggregations

PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)10 OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)5 ArrayList (java.util.ArrayList)4 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)4 ServiceType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType)4 HashMap (java.util.HashMap)3 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)3 EmailAddressType (oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType)3 RegistryObjectListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType)3 RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)3 TelephoneNumberType (oasis.names.tc.ebxml_regrep.xsd.rim._3.TelephoneNumberType)3 Map (java.util.Map)2 PostalAddressType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PostalAddressType)2 Test (org.junit.Test)2 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 JAXBElement (javax.xml.bind.JAXBElement)1 PersonNameType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonNameType)1