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);
}
}
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;
}
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")));
}
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);
}
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)));
}
Aggregations