use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType 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.ExternalIdentifierType in project ddf by codice.
the class IdentificationPlugin method createExternalIdentifier.
private ExternalIdentifierType createExternalIdentifier(String id, String objId, String schema, String value) {
ExternalIdentifierType extId = new ExternalIdentifierType();
extId.setId(id);
extId.setRegistryObject(objId);
extId.setIdentificationScheme(schema);
extId.setValue(value);
return extId;
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType 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.ExternalIdentifierType in project nhin-d by DirectProject.
the class DefaultXdmXdsTransformerTest method testGetDocId_ExtrinsicObjectType.
/**
* Test the getDocId(ExtrinsicObjectType) method.
*/
public void testGetDocId_ExtrinsicObjectType() {
DefaultXdmXdsTransformer transformer = new DefaultXdmXdsTransformer();
String output = null;
ExtrinsicObjectType input = null;
ExternalIdentifierType eit = null;
List<ExternalIdentifierType> externalIdentifiers = null;
eit = new ExternalIdentifierType();
eit.setIdentificationScheme("urn:uuid:2e82c1f6-a085-4c72-9da3-8640a32e42ab");
eit.setValue("eitValue");
input = new ExtrinsicObjectType();
externalIdentifiers = input.getExternalIdentifier();
externalIdentifiers.add(eit);
output = transformer.getDocId(input);
assertEquals("Output does not match expected", "eitValue", output);
eit = new ExternalIdentifierType();
eit.setIdentificationScheme("urn:uuid:incorrecd-uuid");
eit.setValue("eitValue");
input = new ExtrinsicObjectType();
externalIdentifiers = input.getExternalIdentifier();
externalIdentifiers.add(eit);
output = transformer.getDocId(input);
assertEquals("Output does not match expected", null, output);
input = new ExtrinsicObjectType();
externalIdentifiers = input.getExternalIdentifier();
output = transformer.getDocId(input);
assertEquals("Output does not match expected", null, output);
}
use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType in project ddf by codice.
the class IdentificationPluginTest method testIdsAlreadySet.
//test both ids are already set
@Test
public void testIdsAlreadySet() throws Exception {
//unmarshal metacard.metadata and confirm only local ext id are set to metacard.getId()
String xml = convert("/registry-both-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("registryPresetOriginValue"));
}
}
}
Aggregations