Search in sources :

Example 1 with OrganizationType

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

the class RegistryObjectListWebConverter method convert.

/**
     * This method creates a Map<String, Object> representation of the RegistryObjectListType provided.
     * The following keys will be added to the map (Taken from EbrimConstants):
     * <p>
     * ASSOCIATION_KEY = "Association";
     * EXTRINSIC_OBJECT_KEY = "ExtrinsicObject";
     * ORGANIZATION_KEY = "Organization";
     * PERSON_KEY = "Person";
     * SERVICE_KEY = "Service";
     * <p>
     * <p>
     * Uses:
     * AssociationWebConverter
     * ExtrinsicObjectWebConverter
     * OrganizationWebConverter
     * PersonWebConverter
     * ServiceWebConverter
     *
     * @param registryObjectList the RegistryObjectListType to be converted into a map, null returns empty Map
     * @return Map<String, Object> representation of the RegistryObjectListType provided
     */
public Map<String, Object> convert(RegistryObjectListType registryObjectList) {
    Map<String, Object> registryObjectListMap = new HashMap<>();
    if (registryObjectList == null) {
        return registryObjectListMap;
    }
    List<Map<String, Object>> associations = new ArrayList<>();
    List<Map<String, Object>> extrinsicObjects = new ArrayList<>();
    List<Map<String, Object>> organizations = new ArrayList<>();
    List<Map<String, Object>> people = new ArrayList<>();
    List<Map<String, Object>> services = new ArrayList<>();
    AssociationWebConverter associationConverter = new AssociationWebConverter();
    ExtrinsicObjectWebConverter extrinsicObjectConverter = new ExtrinsicObjectWebConverter();
    OrganizationWebConverter organizationConverter = new OrganizationWebConverter();
    PersonWebConverter personConverter = new PersonWebConverter();
    ServiceWebConverter serviceConverter = new ServiceWebConverter();
    for (JAXBElement<? extends IdentifiableType> identifiable : registryObjectList.getIdentifiable()) {
        RegistryObjectType registryObject = (RegistryObjectType) identifiable.getValue();
        Map<String, Object> identifiableMap;
        if (registryObject instanceof ExtrinsicObjectType) {
            identifiableMap = extrinsicObjectConverter.convert((ExtrinsicObjectType) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                extrinsicObjects.add(identifiableMap);
            }
        } else if (registryObject instanceof ServiceType) {
            identifiableMap = serviceConverter.convert((ServiceType) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                services.add(identifiableMap);
            }
        } else if (registryObject instanceof OrganizationType) {
            identifiableMap = organizationConverter.convert((OrganizationType) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                organizations.add(identifiableMap);
            }
        } else if (registryObject instanceof PersonType) {
            identifiableMap = personConverter.convert((PersonType) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                people.add(identifiableMap);
            }
        } else if (registryObject instanceof AssociationType1) {
            identifiableMap = associationConverter.convert((AssociationType1) registryObject);
            if (MapUtils.isNotEmpty(identifiableMap)) {
                associations.add(identifiableMap);
            }
        }
    }
    webMapHelper.putIfNotEmpty(registryObjectListMap, ASSOCIATION_KEY, associations);
    webMapHelper.putIfNotEmpty(registryObjectListMap, EXTRINSIC_OBJECT_KEY, extrinsicObjects);
    webMapHelper.putIfNotEmpty(registryObjectListMap, ORGANIZATION_KEY, organizations);
    webMapHelper.putIfNotEmpty(registryObjectListMap, PERSON_KEY, people);
    webMapHelper.putIfNotEmpty(registryObjectListMap, SERVICE_KEY, services);
    return registryObjectListMap;
}
Also used : 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) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) ServiceType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType) HashMap(java.util.HashMap) Map(java.util.Map) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 2 with OrganizationType

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

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

the class RegistryPackageTypeHelper method populateLists.

private void populateLists() {
    serviceBindings.clear();
    services.clear();
    extrinsicObjects.clear();
    organizations.clear();
    persons.clear();
    associations.clear();
    if (registryPackageType == null) {
        return;
    }
    if (registryPackageType.isSetRegistryObjectList()) {
        RegistryObjectListType registryObjectList = registryPackageType.getRegistryObjectList();
        for (JAXBElement<? extends IdentifiableType> identifiableType : registryObjectList.getIdentifiable()) {
            RegistryObjectType registryObject = (RegistryObjectType) identifiableType.getValue();
            if (registryObject instanceof ExtrinsicObjectType) {
                extrinsicObjects.add((ExtrinsicObjectType) registryObject);
            } else if (registryObject instanceof ServiceType) {
                ServiceType service = (ServiceType) registryObject;
                services.add(service);
                serviceBindings.addAll(service.getServiceBinding());
            } else if (registryObject instanceof OrganizationType) {
                organizations.add((OrganizationType) registryObject);
            } else if (registryObject instanceof PersonType) {
                persons.add((PersonType) registryObject);
            } else if (registryObject instanceof AssociationType1) {
                associations.add((AssociationType1) registryObject);
            }
        }
    }
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) ServiceType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ServiceType) 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) OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)

Example 4 with OrganizationType

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

the class RegistryPackageWebConverterTest method getFirstOrganization.

private OrganizationType getFirstOrganization() {
    OrganizationType organization = RIM_FACTORY.createOrganizationType();
    organization.setId("urn:organization:id0");
    organization.setParent("urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
    organization.setPrimaryContact("somePrimaryContact");
    organization.setLid("someLid");
    organization.setStatus("someStatus");
    organization.setName(istHelper.create("Codice"));
    organization.getAddress().add(getAddress("Phoenix", "USA", "85037", "AZ", "1234 Some Street", null));
    organization.getTelephoneNumber().add(getPhoneNumber("555", null, "1234", "555-5555", null));
    organization.getEmailAddress().add(getEmailAddress("emailaddress@something.com", null));
    ClassificationType classification = RIM_FACTORY.createClassificationType();
    classification.setId("urn:classification:id0");
    classification.setClassifiedObject("classifiedObjectId");
    classification.setClassificationScheme("classificationScheme");
    classification.setClassificationNode("classificationNode");
    classification.setNodeRepresentation("nodeRepresentation");
    organization.getClassification().add(classification);
    return organization;
}
Also used : OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType) ClassificationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType)

Example 5 with OrganizationType

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

the class RegistryPackageWebConverterTest method getSecondOrganization.

private OrganizationType getSecondOrganization() {
    OrganizationType organization = RIM_FACTORY.createOrganizationType();
    organization.setId("urn:organization:id1");
    organization.setParent("urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
    organization.setName(istHelper.create("MyOrg"));
    organization.getAddress().add(getAddress("Phoenix", "USA", "85037", "AZ", "1234 Some Street", "3914"));
    organization.getTelephoneNumber().add(getPhoneNumber("555", null, "1234", "555-5555", null));
    organization.getEmailAddress().add(getEmailAddress("emailaddress@something.com", "SomeEmailAddressType"));
    return organization;
}
Also used : OrganizationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.OrganizationType)

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