Search in sources :

Example 1 with Exporter

use of org.dcm4chee.arc.exporter.Exporter in project dcm4chee-arc-light by dcm4che.

the class ExportTaskProcessor method process.

@Override
public Outcome process(Task task) throws Exception {
    Outcome outcome;
    ExportContext exportContext = null;
    try {
        ExporterDescriptor exporterDesc = device.getDeviceExtensionNotNull(ArchiveDeviceExtension.class).getExporterDescriptorNotNull(task.getExporterID());
        Attributes attrs = queryService.queryExportTaskInfo(task, device.getApplicationEntity(exporterDesc.getAETitle(), true));
        if (attrs != null) {
            task.setModalities(attrs.getStrings(Tag.ModalitiesInStudy));
            task.setNumberOfInstances(attrs.getInt(Tag.NumberOfStudyRelatedInstances, -1));
            ejb.merge(task);
        } else {
            LOG.info("No Export Task Info found for {}", task);
        }
        Exporter exporter = exporterFactory.getExporter(exporterDesc);
        exportContext = exporter.createExportContext();
        exportContext.setTaskPK(task.getPk());
        exportContext.setBatchID(task.getBatchID());
        exportContext.setStudyInstanceUID(task.getStudyInstanceUID());
        exportContext.setSeriesInstanceUID(StringUtils.nullify(task.getSeriesInstanceUID(), "*"));
        exportContext.setSopInstanceUID(StringUtils.nullify(task.getSOPInstanceUID(), "*"));
        exportContext.setAETitle(exporterDesc.getAETitle());
        exportContext.setHttpServletRequestInfo(HttpServletRequestInfo.valueOf(task.getRequesterUserID(), task.getRequesterHost(), task.getRequestURI()));
        outcome = exporter.export(exportContext);
        exportContext.setOutcome(outcome);
    } catch (Throwable e) {
        if (exportContext != null)
            exportContext.setException(e);
        LOG.warn("Failed to process {}", task, e);
        throw e;
    } finally {
        if (exportContext != null)
            try {
                exportEvent.fire(exportContext);
            } catch (Exception e) {
                LOG.warn("Failed on firing export context {}", task, e);
            }
    }
    return outcome;
}
Also used : ExportContext(org.dcm4chee.arc.exporter.ExportContext) ArchiveDeviceExtension(org.dcm4chee.arc.conf.ArchiveDeviceExtension) Outcome(org.dcm4chee.arc.qmgt.Outcome) Attributes(org.dcm4che3.data.Attributes) Exporter(org.dcm4chee.arc.exporter.Exporter) ExporterDescriptor(org.dcm4chee.arc.conf.ExporterDescriptor)

Aggregations

Attributes (org.dcm4che3.data.Attributes)1 ArchiveDeviceExtension (org.dcm4chee.arc.conf.ArchiveDeviceExtension)1 ExporterDescriptor (org.dcm4chee.arc.conf.ExporterDescriptor)1 ExportContext (org.dcm4chee.arc.exporter.ExportContext)1 Exporter (org.dcm4chee.arc.exporter.Exporter)1 Outcome (org.dcm4chee.arc.qmgt.Outcome)1