Search in sources :

Example 6 with SubmitObjectsRequest

use of oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest 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 7 with SubmitObjectsRequest

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

the class DefaultXdmXdsTransformer method getDocName.

public String getDocName(File file) throws TransformationException {
    LOGGER.trace("Begin transformation of XDM to XDS (file)");
    ZipFile zipFile = null;
    String objectId = null;
    ProvideAndRegisterDocumentSetRequestType prsr = new ProvideAndRegisterDocumentSetRequestType();
    try {
        zipFile = new ZipFile(file, ZipFile.OPEN_READ);
        Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
        ZipEntry zipEntry = null;
        // load the ZIP archive into memory
        while (zipEntries.hasMoreElements()) {
            zipEntry = zipEntries.nextElement();
            String zname = zipEntry.getName();
            LOGGER.trace("Processing a ZipEntry " + zname);
            if (!zipEntry.isDirectory()) {
                String subsetDirspec = getSubmissionSetDirspec(zipEntry.getName());
                // Read metadata
                if (matchName(zname, subsetDirspec, XDM_FILENAME_METADATA)) {
                    ByteArrayOutputStream byteArrayOutputStream = readData(zipFile, zipEntry);
                    SubmitObjectsRequest submitObjectRequest = (SubmitObjectsRequest) XmlUtils.unmarshal(byteArrayOutputStream.toString(), oasis.names.tc.ebxml_regrep.xsd.lcm._3.ObjectFactory.class);
                    prsr.setSubmitObjectsRequest(submitObjectRequest);
                    objectId = getDocName(submitObjectRequest);
                }
            // Read data
            }
        }
        zipFile.close();
    } catch (Exception e) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error("Unable to complete getObjectId.", e);
        }
        throw new TransformationException("Unable to complete getObjectId.", e);
    }
    return objectId;
}
Also used : TransformationException(org.nhindirect.xd.transform.exception.TransformationException) ZipEntry(java.util.zip.ZipEntry) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SubmitObjectsRequest(oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest) TransformationException(org.nhindirect.xd.transform.exception.TransformationException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ZipFile(java.util.zip.ZipFile) ProvideAndRegisterDocumentSetRequestType(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)

Example 8 with SubmitObjectsRequest

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

the class DefaultXdmXdsTransformer method getDocName.

protected String getDocName(SubmitObjectsRequest submitObjectRequest) {
    if (submitObjectRequest == null) {
        throw new IllegalArgumentException("SubmitObjectRequest must not be null.");
    }
    String ret = null;
    RegistryObjectListType rol = submitObjectRequest.getRegistryObjectList();
    List<JAXBElement<? extends IdentifiableType>> extensible = rol.getIdentifiable();
    for (JAXBElement<? extends IdentifiableType> elem : extensible) {
        String type = elem.getDeclaredType().getName();
        Object value = elem.getValue();
        if (StringUtils.equals(type, "oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType")) {
            String obId = ((ExtrinsicObjectType) value).getId();
            String mimeType = ((ExtrinsicObjectType) value).getMimeType();
            String suffix = "xml";
            if (mimeType.indexOf("xml") >= 0) {
                suffix = "xml";
            } else if (mimeType.indexOf("pdf") >= 0) {
                suffix = "pdf";
            }
            ret = obId + "." + suffix;
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace(type + " " + value.toString());
            }
        }
    }
    return ret;
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) IdentifiableType(oasis.names.tc.ebxml_regrep.xsd.rim._3.IdentifiableType) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) JAXBElement(javax.xml.bind.JAXBElement)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)5 SubmitObjectsRequest (oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest)5 ExtrinsicObjectType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType)5 IdentifiableType (oasis.names.tc.ebxml_regrep.xsd.rim._3.IdentifiableType)5 RegistryObjectListType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType)5 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)3 ProvideAndRegisterDocumentSetRequestType (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 ZipEntry (java.util.zip.ZipEntry)2 ZipFile (java.util.zip.ZipFile)2 QName (javax.xml.namespace.QName)2 AssociationType1 (oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1)2 ClassificationType (oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType)2 TransformationException (org.nhindirect.xd.transform.exception.TransformationException)2 Document (ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType.Document)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DataHandler (javax.activation.DataHandler)1