Search in sources :

Example 6 with OrganizationType

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

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

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

Example 9 with OrganizationType

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

the class RegistryPackageTypeHelperTest method testGetOrganizationsFromRegistryObjectList.

@Test
public void testGetOrganizationsFromRegistryObjectList() throws Exception {
    RegistryObjectListType registryObjectList = ((RegistryPackageType) registryObject).getRegistryObjectList();
    List<OrganizationType> organizations = rptHelper.getOrganizations(registryObjectList);
    assertOrganizations(organizations);
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) Test(org.junit.Test)

Example 10 with OrganizationType

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

the class RegistryPackageTypeHelperTest method assertOrganizations.

private void assertOrganizations(List<OrganizationType> organizations) {
    // Values from xml file
    int expectedSize = 1;
    int expectedOrganizationsSize = 2;
    String expectedName = "Codice";
    String expectedCity = "Phoenix";
    String expectedCountry = "USA";
    String expectedPostalCode = "85037";
    String expectedState = "AZ";
    String expectedStreet = "1234 Some Street";
    String expectedAreaCode = "555";
    String expectedNumber = "555-5555";
    String expectedExtension = "1234";
    String expectedCountryCode = null;
    String expectedPhoneType = null;
    String expectedEmail = "emailaddress@something.com";
    String expectedParent = "urn:uuid:2014ca7f59ac46f495e32b4a67a51276";
    String expectedPrimaryContact = "somePrimaryContact";
    assertThat(organizations, hasSize(expectedOrganizationsSize));
    OrganizationType organization = organizations.get(0);
    assertThat(organization.isSetName(), is(true));
    assertIst(organization.getName(), expectedName);
    assertThat(organization.isSetAddress(), is(true));
    List<PostalAddressType> addresses = organization.getAddress();
    assertThat(addresses, hasSize(expectedSize));
    assertAddress(addresses.get(0), expectedCity, expectedCountry, expectedPostalCode, expectedState, expectedStreet);
    assertThat(organization.isSetTelephoneNumber(), is(true));
    List<TelephoneNumberType> phoneNumbers = organization.getTelephoneNumber();
    assertThat(phoneNumbers, hasSize(expectedSize));
    assertPhoneNumbers(phoneNumbers.get(0), expectedAreaCode, expectedNumber, expectedExtension, expectedCountryCode, expectedPhoneType);
    assertThat(organization.isSetEmailAddress(), is(true));
    assertThat(organization.getEmailAddress(), hasSize(expectedSize));
    List<EmailAddressType> emailAddresses = organization.getEmailAddress();
    assertThat(emailAddresses.get(0).getAddress(), is(equalTo(expectedEmail)));
    assertThat(organization.isSetParent(), is(true));
    assertThat(organization.getParent(), is(equalTo(expectedParent)));
    assertThat(organization.isSetPrimaryContact(), is(true));
    assertThat(organization.getPrimaryContact(), is(equalTo(expectedPrimaryContact)));
}
Also used : TelephoneNumberType(oasis.names.tc.ebxml_regrep.xsd.rim._3.TelephoneNumberType) EmailAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) PostalAddressType(oasis.names.tc.ebxml_regrep.xsd.rim._3.PostalAddressType)

Aggregations

OrganizationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)9 PersonType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PersonType)5 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)4 ServiceType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)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 Map (java.util.Map)2 EmailAddressType (oasis.names.tc.ebxml_regrep.xsd.rim._3.EmailAddressType)2 PostalAddressType (oasis.names.tc.ebxml_regrep.xsd.rim._3.PostalAddressType)2 TelephoneNumberType (oasis.names.tc.ebxml_regrep.xsd.rim._3.TelephoneNumberType)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 ClassificationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType)1