Search in sources :

Example 1 with SubmitObjectsRequest

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

the class DirectDocuments method getSubmitObjectsRequest.

/**
     * Get the metadata represented as a SubmitObjectsRequest object.
     */
public SubmitObjectsRequest getSubmitObjectsRequest() {
    RegistryPackageType registryPackageType = submissionSet.generateRegistryPackageType();
    ClassificationType classificationType = submissionSet.generateClassificationType();
    QName qname = null;
    // Generate ExtrinsicObjectType objects for each document
    qname = new QName(SubmitObjectsRequestEnum.EXTRINSIC_OBJECT.getNamespaceUri(), SubmitObjectsRequestEnum.EXTRINSIC_OBJECT.getName());
    List<JAXBElement<ExtrinsicObjectType>> jaxb_extrinsicObjectTypes = new ArrayList<JAXBElement<ExtrinsicObjectType>>();
    for (DirectDocument2 document : documents) {
        ExtrinsicObjectType extrinsicObjectType = document.getMetadata().generateExtrinsicObjectType();
        JAXBElement<ExtrinsicObjectType> jaxb_extrinsicObjectType = new JAXBElement<ExtrinsicObjectType>(qname, ExtrinsicObjectType.class, extrinsicObjectType);
        jaxb_extrinsicObjectTypes.add(jaxb_extrinsicObjectType);
    }
    // Generate the RegistryPakageType (SubmissionSet) for the group of
    // documents
    qname = new QName(SubmitObjectsRequestEnum.REGISTRY_PACKAGE.getNamespaceUri(), SubmitObjectsRequestEnum.REGISTRY_PACKAGE.getName());
    JAXBElement<RegistryPackageType> jaxb_registryPackageType = new JAXBElement<RegistryPackageType>(qname, RegistryPackageType.class, registryPackageType);
    // Generate the ClassificationType object
    qname = new QName(SubmitObjectsRequestEnum.CLASSIFICATION.getNamespaceUri(), SubmitObjectsRequestEnum.CLASSIFICATION.getName());
    JAXBElement<ClassificationType> jaxb_classificationType = new JAXBElement<ClassificationType>(qname, ClassificationType.class, classificationType);
    // Generate AssociationType1 objects for each document
    qname = new QName(SubmitObjectsRequestEnum.ASSOCIATION.getNamespaceUri(), SubmitObjectsRequestEnum.ASSOCIATION.getName());
    List<JAXBElement<AssociationType1>> jaxb_associationType1s = new ArrayList<JAXBElement<AssociationType1>>();
    for (DirectDocument2 document : documents) {
        AssociationType1 associationType = submissionSet.generateAssociationType(document.getMetadata().getId(), document.getMetadata().getSubmissionSetStatus());
        JAXBElement<AssociationType1> jaxb_AssociationType1 = new JAXBElement<AssociationType1>(qname, AssociationType1.class, associationType);
        jaxb_associationType1s.add(jaxb_AssociationType1);
    }
    SubmitObjectsRequest submitObjectsRequest = new SubmitObjectsRequest();
    RegistryObjectListType registryObjectListType = new RegistryObjectListType();
    List<JAXBElement<? extends IdentifiableType>> elements = registryObjectListType.getIdentifiable();
    elements.addAll(jaxb_extrinsicObjectTypes);
    elements.add(jaxb_registryPackageType);
    elements.add(jaxb_classificationType);
    elements.addAll(jaxb_associationType1s);
    submitObjectsRequest.setRegistryObjectList(registryObjectListType);
    return submitObjectsRequest;
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) IdentifiableType(oasis.names.tc.ebxml_regrep.xsd.rim._3.IdentifiableType) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) AssociationType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) JAXBElement(javax.xml.bind.JAXBElement) ClassificationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType) SubmitObjectsRequest(oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest)

Example 2 with SubmitObjectsRequest

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

the class DirectDocuments method setValues.

public void setValues(String submitObjectsRequestXml) throws Exception {
    SubmitObjectsRequest sor = (SubmitObjectsRequest) XmlUtils.unmarshal(new String(submitObjectsRequestXml), oasis.names.tc.ebxml_regrep.xsd.lcm._3.ObjectFactory.class);
    setValues(sor);
}
Also used : SubmitObjectsRequest(oasis.names.tc.ebxml_regrep.xsd.lcm._3.SubmitObjectsRequest)

Example 3 with SubmitObjectsRequest

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

the class DirectDocuments method setValues.

public void setValues(SubmitObjectsRequest submitObjectsRequest) throws MetadataException {
    RegistryObjectListType rol = submitObjectsRequest.getRegistryObjectList();
    List<JAXBElement<? extends IdentifiableType>> elements = rol.getIdentifiable();
    for (JAXBElement<? extends IdentifiableType> element : elements) {
        if (element.getValue() instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) {
            ExtrinsicObjectType eot = (ExtrinsicObjectType) element.getValue();
            DirectDocument2 document = new DirectDocument2();
            DirectDocument2.Metadata metadata = document.getMetadata();
            metadata.setValues(eot);
            documents.add(document);
        } else if (element.getValue() instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) {
            RegistryPackageType rpt = (RegistryPackageType) element.getValue();
            SubmissionSet submissionSet = new SubmissionSet();
            submissionSet.setValues(rpt);
            this.submissionSet = submissionSet;
        } else if (element.getValue() instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType) {
        // Empty in example
        }
    }
    for (JAXBElement<? extends IdentifiableType> element : elements) {
        if (element.getValue() instanceof oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) {
            AssociationType1 at = (AssociationType1) element.getValue();
            for (SlotType1 slot : at.getSlot()) {
                if (SlotType1Enum.SUBMISSION_SET_STATUS.matches(slot.getName())) {
                    if (slotNotEmpty(slot)) {
                        getDocumentById(at.getTargetObject()).getMetadata().setSubmissionSetStatus(slot.getName());
                    }
                }
            }
        }
    }
}
Also used : RegistryObjectListType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryObjectListType) IdentifiableType(oasis.names.tc.ebxml_regrep.xsd.rim._3.IdentifiableType) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) AssociationType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.AssociationType1) ExtrinsicObjectType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ExtrinsicObjectType) JAXBElement(javax.xml.bind.JAXBElement) ClassificationType(oasis.names.tc.ebxml_regrep.xsd.rim._3.ClassificationType) SlotType1(oasis.names.tc.ebxml_regrep.xsd.rim._3.SlotType1)

Example 4 with SubmitObjectsRequest

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

the class DefaultXdmXdsTransformer method transform.

/*
     * (non-Javadoc)
     * 
     * @see org.nhindirect.transform.XdmXdsTransformer#transform(java.io.File)
     */
@Override
public ProvideAndRegisterDocumentSetRequestType transform(File file) throws TransformationException {
    LOGGER.trace("Begin transformation of XDM to XDS (file)");
    String docId = null;
    ZipFile zipFile = null;
    String docName = getDocName(file);
    if (docName != null) {
        XDM_FILENAME_DATA = docName;
    }
    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);
                    docId = getDocId(submitObjectRequest);
                } else // Read data
                if (matchName(zname, subsetDirspec, XDM_FILENAME_DATA)) {
                    ByteArrayOutputStream byteArrayOutputStream = readData(zipFile, zipEntry);
                    DataSource source = new ByteArrayDataSource(byteArrayOutputStream.toByteArray(), MimeType.APPLICATION_XML + "; charset=UTF-8");
                    DataHandler dhnew = new DataHandler(source);
                    Document pdoc = new Document();
                    pdoc.setValue(dhnew);
                    pdoc.setId(docId);
                    List<Document> docs = prsr.getDocument();
                    docs.add(pdoc);
                }
            }
            if (!prsr.getDocument().isEmpty()) {
                ((Document) prsr.getDocument().get(0)).setId(zname);
            }
        }
        zipFile.close();
    } catch (Exception e) {
        if (LOGGER.isErrorEnabled()) {
            LOGGER.error("Unable to complete transformation.", e);
        }
        throw new TransformationException("Unable to complete transformation.", e);
    }
    return prsr;
}
Also used : TransformationException(org.nhindirect.xd.transform.exception.TransformationException) ZipEntry(java.util.zip.ZipEntry) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DataHandler(javax.activation.DataHandler) Document(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType.Document) 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) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) DataSource(javax.activation.DataSource) ZipFile(java.util.zip.ZipFile) List(java.util.List) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) ProvideAndRegisterDocumentSetRequestType(ihe.iti.xds_b._2007.ProvideAndRegisterDocumentSetRequestType)

Example 5 with SubmitObjectsRequest

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

the class DefaultXdmXdsTransformer method getDocId.

/**
     * Get the document ID from a SubmitObjectsRequest object.
     * 
     * @param sor
     *            The SubmitObjectsRequest object from which to retrieve the
     *            document ID.
     * @return a document ID.
     */
protected String getDocId(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")) {
            ret = getDocId((ExtrinsicObjectType) value);
        }
        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