Search in sources :

Example 1 with ExternalIdentifierType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType in project nhin-d by DirectProject.

the class DefaultXdmXdsTransformerTest method testGetDocId_SubmitObjectsRequest.

/**
     * Test the getDocId(SubmitObjectsRequest) method.
     */
public void testGetDocId_SubmitObjectsRequest() {
    DefaultXdmXdsTransformer transformer = new DefaultXdmXdsTransformer();
    QName qname = null;
    String output = null;
    SubmitObjectsRequest input = null;
    ExternalIdentifierType eit = null;
    RegistryObjectListType registryObject = null;
    RegistryPackageType registryPackageType = null;
    ExtrinsicObjectType extrinsicObjectType = null;
    List<ExternalIdentifierType> externalIdentifiers = null;
    JAXBElement<ExtrinsicObjectType> jaxbExtrinsicObject = null;
    JAXBElement<RegistryPackageType> jaxbRegistryPackageTypeObject = null;
    List<JAXBElement<? extends IdentifiableType>> identifiableList = null;
    registryObject = new RegistryObjectListType();
    identifiableList = registryObject.getIdentifiable();
    eit = new ExternalIdentifierType();
    eit.setIdentificationScheme("urn:uuid:2e82c1f6-a085-4c72-9da3-8640a32e42ab");
    eit.setValue("eitValue");
    extrinsicObjectType = new ExtrinsicObjectType();
    externalIdentifiers = extrinsicObjectType.getExternalIdentifier();
    externalIdentifiers.add(eit);
    qname = new QName("urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", "ExtrinsicObject");
    jaxbExtrinsicObject = new JAXBElement<ExtrinsicObjectType>(qname, ExtrinsicObjectType.class, extrinsicObjectType);
    registryPackageType = new RegistryPackageType();
    qname = new QName("urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0", "RegistryPackage");
    jaxbRegistryPackageTypeObject = new JAXBElement<RegistryPackageType>(qname, RegistryPackageType.class, registryPackageType);
    identifiableList.add(jaxbRegistryPackageTypeObject);
    identifiableList.add(jaxbExtrinsicObject);
    input = new SubmitObjectsRequest();
    input.setRegistryObjectList(registryObject);
    output = transformer.getDocId(input);
    assertEquals("Output does not match expected", "eitValue", output);
    registryObject = new RegistryObjectListType();
    input = new SubmitObjectsRequest();
    input.setRegistryObjectList(registryObject);
    output = transformer.getDocId(input);
    assertEquals("Output does not match expected", null, output);
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) IdentifiableType(oasis.names.tc.ebxml_regrep.xsd.rim._3.IdentifiableType) QName(javax.xml.namespace.QName) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) JAXBElement(javax.xml.bind.JAXBElement) SubmitObjectsRequest(oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest) DefaultXdmXdsTransformer(org.nhindirect.xd.transform.impl.DefaultXdmXdsTransformer)

Example 2 with ExternalIdentifierType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType in project ddf by codice.

the class RegistryPackageWebConverterTest method getSecondExternalIdentifier.

private ExternalIdentifierType getSecondExternalIdentifier() {
    ExternalIdentifierType externalIdentifier = RIM_FACTORY.createExternalIdentifierType();
    externalIdentifier.setId(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN);
    externalIdentifier.setRegistryObject("urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
    externalIdentifier.setIdentificationScheme("MetacardId");
    externalIdentifier.setValue("someUUID");
    return externalIdentifier;
}
Also used : ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)

Example 3 with ExternalIdentifierType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType in project ddf by codice.

the class RegistryPackageWebConverterTest method getFirstExternalIdentifier.

private ExternalIdentifierType getFirstExternalIdentifier() {
    ExternalIdentifierType externalIdentifier = RIM_FACTORY.createExternalIdentifierType();
    externalIdentifier.setId(RegistryConstants.REGISTRY_MCARD_ID_LOCAL);
    externalIdentifier.setRegistryObject("urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
    externalIdentifier.setIdentificationScheme("MetacardId");
    externalIdentifier.setValue("someUUID");
    return externalIdentifier;
}
Also used : ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)

Example 4 with ExternalIdentifierType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType in project ddf by codice.

the class RegistryStoreImpl method setMetacardExtID.

private void setMetacardExtID(Metacard metacard, String newId) throws ParserException {
    RegistryPackageType registryPackage = metacardMarshaller.getRegistryPackageFromMetacard(metacard);
    List<ExternalIdentifierType> currentExtIdList = registryPackage.getExternalIdentifier();
    currentExtIdList.stream().filter(extId -> extId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_LOCAL)).findFirst().ifPresent(extId -> extId.setValue(newId));
    metacardMarshaller.setMetacardRegistryPackage(metacard, registryPackage);
}
Also used : RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType)

Example 5 with ExternalIdentifierType

use of oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType in project ddf by codice.

the class IdentificationPlugin method updateIdentifiers.

private void updateIdentifiers(Metacard metacard, boolean create) throws StopProcessingException {
    boolean extOriginFound = false;
    boolean extRegIdFound = false;
    String metacardID = metacard.getId();
    String registryID = RegistryUtility.getRegistryId(metacard);
    String systemRegId = System.getProperty(RegistryConstants.REGISTRY_ID_PROPERTY);
    try {
        RegistryPackageType registryPackage = metacardMarshaller.getRegistryPackageFromMetacard(metacard);
        List<ExternalIdentifierType> extIdList = new ArrayList<>();
        //check if external ids are already present
        if (registryPackage.isSetExternalIdentifier()) {
            List<ExternalIdentifierType> currentExtIdList = registryPackage.getExternalIdentifier();
            for (ExternalIdentifierType extId : currentExtIdList) {
                extId.setRegistryObject(registryID);
                if (extId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_LOCAL)) {
                    if (isInternal(metacard) && create) {
                        metacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_METACARD_ID, extId.getValue()));
                    }
                    extId.setValue(metacardID);
                } else if (extId.getId().equals(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN)) {
                    extOriginFound = true;
                } else if (extId.getId().equals(RegistryConstants.REGISTRY_ID_ORIGIN)) {
                    if (!systemRegId.equals(extId.getValue()) && isInternal(metacard)) {
                        metacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_REGISTRY_ID, extId.getValue()));
                    }
                    extId.setValue(systemRegId);
                    extRegIdFound = true;
                }
                extIdList.add(extId);
            }
            if (!extOriginFound) {
                extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN, registryID, RegistryConstants.REGISTRY_METACARD_ID_CLASS, metacardID));
            }
            if (!extRegIdFound) {
                extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_ID_ORIGIN, registryID, RegistryConstants.REGISTRY_ID_CLASS, systemRegId));
            }
        } else {
            extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_MCARD_ID_LOCAL, registryID, RegistryConstants.REGISTRY_METACARD_ID_CLASS, metacardID));
            extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_MCARD_ID_ORIGIN, registryID, RegistryConstants.REGISTRY_METACARD_ID_CLASS, metacardID));
            extIdList.add(createExternalIdentifier(RegistryConstants.REGISTRY_ID_ORIGIN, registryID, RegistryConstants.REGISTRY_ID_CLASS, systemRegId));
        }
        registryPackage.setExternalIdentifier(extIdList);
        metacardMarshaller.setMetacardRegistryPackage(metacard, registryPackage);
    } catch (ParserException e) {
        throw new StopProcessingException("Unable to access Registry Metadata. Parser exception caught");
    }
}
Also used : ParserException(org.codice.ddf.parser.ParserException) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) ArrayList(java.util.ArrayList) ExternalIdentifierType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExternalIdentifierType) StopProcessingException(ddf.catalog.plugin.StopProcessingException)

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