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