Search in sources :

Example 6 with ExternalIdentifierType

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()));
        }
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) ByteArrayInputStream(java.io.ByteArrayInputStream) CreateRequest(ddf.catalog.operation.CreateRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) Test(org.junit.Test)

Example 7 with ExternalIdentifierType

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;
}
Also used : ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)

Example 8 with ExternalIdentifierType

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;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) ClassificationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1) Map(java.util.Map) HashMap(java.util.HashMap)

Example 9 with ExternalIdentifierType

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);
}
Also used : DefaultXdmXdsTransformer(org.nhindirect.xd.transform.impl.DefaultXdmXdsTransformer) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)

Example 10 with ExternalIdentifierType

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"));
        }
    }
}
Also used : Metacard(ddf.catalog.data.Metacard) ByteArrayInputStream(java.io.ByteArrayInputStream) CreateRequest(ddf.catalog.operation.CreateRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) CreateRequestImpl(ddf.catalog.operation.impl.CreateRequestImpl) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) RegistryObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType) Test(org.junit.Test)

Aggregations

ExternalIdentifierType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)11 Metacard (ddf.catalog.data.Metacard)3 CreateRequest (ddf.catalog.operation.CreateRequest)3 CreateRequestImpl (ddf.catalog.operation.impl.CreateRequestImpl)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 InputStream (java.io.InputStream)3 RegistryObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectType)3 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)2 DefaultXdmXdsTransformer (org.nhindirect.xd.transform.impl.DefaultXdmXdsTransformer)2 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)1 StopProcessingException (ddf.catalog.plugin.StopProcessingException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JAXBElement (javax.xml.bind.JAXBElement)1 QName (javax.xml.namespace.QName)1 SubmitObjectsRequest (oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest)1 ClassificationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType)1