use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.
the class IdentificationPluginTest method testBothExtIdMissing.
//test ext IDs are not set (origin & local)
@Test
public void testBothExtIdMissing() throws Exception {
//unmarshal metacard.metadata and confirm both origin and local ext id are set to metacard.getId()
String xml = convert("/registry-no-extid.xml");
sampleData.setAttribute(Metacard.METADATA, xml);
CreateRequest result = identificationPlugin.process(new CreateRequestImpl(sampleData));
Metacard testMetacard = result.getMetacards().get(0);
String metadata = testMetacard.getMetadata();
InputStream inputStream = new ByteArrayInputStream(metadata.getBytes(Charsets.UTF_8));
JAXBElement<RegistryObjectType> registryObjectTypeJAXBElement = parser.unmarshal(configurator, JAXBElement.class, inputStream);
RegistryObjectType registryObjectType = registryObjectTypeJAXBElement.getValue();
List<ExternalIdentifierType> extIdList = registryObjectType.getExternalIdentifier();
for (ExternalIdentifierType singleExtId : extIdList) {
if (singleExtId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_LOCAL)) {
assertThat(singleExtId.getValue(), is(testMetacard.getId()));
} else if (singleExtId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN)) {
assertThat(singleExtId.getId(), is(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN));
assertThat(singleExtId.getValue(), is(testMetacard.getId()));
}
}
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.
the class PersonWebConverter method convert.
/**
* This method creates a Map<String, Object> representation of the PersonType provided.
* The following keys will be added to the map (Taken from EbrimConstants):
* <p>
* PERSON_NAME_KEY = "PersonName"
* 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
* PersonNameWebConverter
*
* @param person the PersonType to be converted into a map, null returns empty Map
* @return Map<String, Object> representation of the PersonType provided
*/
public Map<String, Object> convert(PersonType person) {
Map<String, Object> personMap = new HashMap<>();
if (person == null) {
return personMap;
}
webMapHelper.putAllIfNotEmpty(personMap, super.convertRegistryObject(person));
if (person.isSetAddress()) {
List<Map<String, Object>> addresses = new ArrayList<>();
PostalAddressWebConverter addressConverter = new PostalAddressWebConverter();
for (PostalAddressType address : person.getAddress()) {
Map<String, Object> addressMap = addressConverter.convert(address);
if (MapUtils.isNotEmpty(addressMap)) {
addresses.add(addressMap);
}
}
webMapHelper.putIfNotEmpty(personMap, ADDRESS_KEY, addresses);
}
if (person.isSetEmailAddress()) {
List<Map<String, Object>> emailAddresses = new ArrayList<>();
EmailAddressWebConverter emailConverter = new EmailAddressWebConverter();
for (EmailAddressType email : person.getEmailAddress()) {
Map<String, Object> emailMap = emailConverter.convert(email);
if (MapUtils.isNotEmpty(emailMap)) {
emailAddresses.add(emailMap);
}
}
webMapHelper.putIfNotEmpty(personMap, EMAIL_ADDRESS_KEY, emailAddresses);
}
if (person.isSetPersonName()) {
PersonNameWebConverter personNameConverter = new PersonNameWebConverter();
Map<String, Object> personNameMap = personNameConverter.convert(person.getPersonName());
webMapHelper.putIfNotEmpty(personMap, PERSON_NAME_KEY, personNameMap);
}
if (person.isSetTelephoneNumber()) {
List<Map<String, Object>> telephoneNumbers = new ArrayList<>();
TelephoneNumberWebConverter telephoneConverter = new TelephoneNumberWebConverter();
for (TelephoneNumberType telephone : person.getTelephoneNumber()) {
Map<String, Object> telephoneMap = telephoneConverter.convert(telephone);
if (MapUtils.isNotEmpty(telephoneMap)) {
telephoneNumbers.add(telephoneMap);
}
}
webMapHelper.putIfNotEmpty(personMap, TELEPHONE_KEY, telephoneNumbers);
}
return personMap;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType 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;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType in project ddf by codice.
the class RegistryObjectWebConverter method convertRegistryObject.
/**
* This method creates a Map<String, Object> representation of the RegistryObjectType provided.
* The following keys will be added to the map (Taken from EbrimConstants):
* <p>
* CLASSIFICATION_KEY = "Classification";
* EXTERNAL_IDENTIFIER_KEY = "ExternalIdentifier";
* NAME_KEY = "Name";
* DESCRIPTION_KEY = "Description";
* VERSION_INFO_KEY = "VersionInfo";
* SLOT = "Slot";
* ID_KEY = "id";
* HOME_KEY = "home";
* LID_KEY = "Lid";
* STATUS_KEY = "Status";
* OBJECT_TYPE_KEY = "objectType";
* <p>
* Uses:
* ClassificationWebConverter
* ExternalIdentifierWebConverter
* SlotWebConverter
* InternationalStringTypeHelper
*
* @param registryObject the RegistryObjectType to be converted into a map, null returns empty Map
* @return Map<String, Object> representation of the RegistryObjectType provided
*/
public Map<String, Object> convertRegistryObject(RegistryObjectType registryObject) {
Map<String, Object> registryObjectMap = new HashMap<>();
if (registryObject.isSetClassification()) {
List<Map<String, Object>> classifications = new ArrayList<>();
ClassificationWebConverter classificationConverter = new ClassificationWebConverter();
for (ClassificationType classification : registryObject.getClassification()) {
Map<String, Object> classificationMap = classificationConverter.convert(classification);
if (MapUtils.isNotEmpty(classificationMap)) {
classifications.add(classificationMap);
}
}
webMapHelper.putIfNotEmpty(registryObjectMap, CLASSIFICATION_KEY, classifications);
}
webMapHelper.putIfNotEmpty(registryObjectMap, DESCRIPTION_KEY, registryObject.getDescription());
if (registryObject.isSetExternalIdentifier()) {
List<Map<String, Object>> externalIdentifiers = new ArrayList<>();
ExternalIdentifierWebConverter externalIdentifierConverter = new ExternalIdentifierWebConverter();
for (ExternalIdentifierType externalIdentifier : registryObject.getExternalIdentifier()) {
Map<String, Object> externalIdentifierMap = externalIdentifierConverter.convert(externalIdentifier);
if (MapUtils.isNotEmpty(externalIdentifierMap)) {
externalIdentifiers.add(externalIdentifierMap);
}
}
webMapHelper.putIfNotEmpty(registryObjectMap, EXTERNAL_IDENTIFIER_KEY, externalIdentifiers);
}
webMapHelper.putIfNotEmpty(registryObjectMap, HOME_KEY, registryObject.getHome());
webMapHelper.putIfNotEmpty(registryObjectMap, ID_KEY, registryObject.getId());
webMapHelper.putIfNotEmpty(registryObjectMap, LID_KEY, registryObject.getLid());
webMapHelper.putIfNotEmpty(registryObjectMap, NAME_KEY, registryObject.getName());
webMapHelper.putIfNotEmpty(registryObjectMap, OBJECT_TYPE_KEY, registryObject.getObjectType());
if (registryObject.isSetSlot()) {
List<Map<String, Object>> slots = new ArrayList<>();
SlotWebConverter slotConverter = new SlotWebConverter();
for (SlotType1 slot : registryObject.getSlot()) {
Map<String, Object> slotMap = slotConverter.convert(slot);
if (MapUtils.isNotEmpty(slotMap)) {
slots.add(slotMap);
}
}
webMapHelper.putIfNotEmpty(registryObjectMap, SLOT, slots);
}
webMapHelper.putIfNotEmpty(registryObjectMap, STATUS_KEY, registryObject.getStatus());
webMapHelper.putIfNotEmpty(registryObjectMap, VERSION_INFO_KEY, registryObject.getVersionInfo());
return registryObjectMap;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType 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;
}
Aggregations