Class MediaImporter
- java.lang.Object
-
- com.pixelmed.dicom.MediaImporter
-
- Direct Known Subclasses:
AddHierarchicalEvidenceSequencetoStructuredReports.OurMediaImporter
,CheckAllUIDReferencesResolve.OurMediaImporter
,CompressDicomFiles
,ConvertSRTCodesToSCT.OurMediaImporter
,CopyOnlyHeadOfMultipleStructuredReportsAndReferences.OurMediaImporter
,DatabaseMediaImporter
,DecompressDicomFiles
,DeidentifyAndRedact.OurMediaImporter
,DicomCleaner.OurMediaImporter
,DoseUtility.OurMediaImporter
,DownloadOrTransmit.OurMediaImporter
,FindAndCopySelectedDicomFiles
,InsertCodeSequence.OurMediaImporter
,InsertRealWorldValueMap.OurMediaImporter
,MergeCompositeContext.OurFirstPassMediaImporter
,MergeCompositeContext.OurSecondPassMediaImporter
,MergeCompositeContextForOneEntitySelectively.OurFirstPassMediaImporter
,MergeCompositeContextForOneEntitySelectively.OurSecondPassMediaImporter
,MergeFunctionalGroups.OurFirstPassMediaImporter
,MergeFunctionalGroups.OurSecondPassMediaImporter
,NetworkMediaImporter
,PseudonymizeAndSequester.OurMediaImporter
,RemapFrameOfReferenceUIDs.OurMediaImporter
,RemapUIDs.OurMediaImporter
,RotateFlipSetOfImages.OurMediaImporter
,SetCharacteristicsFromSummary.OurMediaImporter
,TranslateImagePositionPatient.OurMediaImporter
,UIDMapByMatchingPixelData.OurMediaImporter
public class MediaImporter extends java.lang.Object
This class is designed to support the importation of DICOM files from interchange media (such as CDs and DVDs).
It supports locating a DICOMDIR file and iterating through the list of referenced files.
The actual work (e.g. to import the file into a database or similar) is performed by the implementation of the
doSomethingWithDicomFileOnMedia
method in a sub-class of this class.- See Also:
DatabaseMediaImporter
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MediaImporter.MediaImporterWithFileChooserDialogThread
A class that implementsRunnable
so that it can be invoked byEventQueue.invokeAndWait()
.protected static class
MediaImporter.OurReadTerminationStrategy
-
Field Summary
Fields Modifier and Type Field Description protected MessageLogger
logger
protected java.lang.String
mediaDirectoryPath
protected javax.swing.JProgressBar
progressBar
protected SafeProgressBarUpdaterThread
progressBarUpdater
protected static AttributeList.ReadTerminationStrategy
terminateAfterIdentifyingGroup
-
Constructor Summary
Constructors Constructor Description MediaImporter(MessageLogger logger)
Construct an importer that will looked for files in the system default path.MediaImporter(MessageLogger logger, javax.swing.JProgressBar progressBar)
Construct an importer that will looked for files in the system default path.MediaImporter(java.lang.String mediaDirectoryPath, MessageLogger logger)
Construct an importer that will looked for files in the specified path.MediaImporter(java.lang.String mediaDirectoryPath, MessageLogger logger, javax.swing.JProgressBar progressBar)
Construct an importer that will looked for files in the specified path.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
choosePathAndImportDicomFiles()
Pop up a file chooser dialog that allows the user to specify the location of the DICOMDIR file, or the parent folder (for example, the drive or volume) in which the DICOMDIR file is located, and then import the referenced files.void
choosePathAndImportDicomFiles(java.awt.Component parent)
Pop up a file chooser dialog that allows the user to specify the location of the DICOMDIR file, or the parent folder (for example, the drive or volume) in which the DICOMDIR file is located, and then import the referenced files.protected void
doSomethingWithDicomFileOnMedia(java.lang.String mediaFileName)
Do something with the referenced DICOM file that has been encountered.protected void
doSomethingWithDicomFileOnMedia(java.lang.String mediaFileName, java.lang.String transferSyntaxUID, java.lang.String sopClassUID)
Do something with the referenced DICOM file that has been encountered.protected void
doSomethingWithUnwantedFileOnMedia(java.lang.String mediaFileName, java.lang.String transferSyntaxUID, java.lang.String sopClassUID)
Do something with the unwanted (possibly DICOM file) that has been encountered.java.lang.String
getDirectory()
void
importDicomFiles(java.lang.String pathName)
Read a DICOMDIR file, and then import any DICOM files that it references.protected boolean
isOKToImport(java.lang.String sopClassUID, java.lang.String transferSyntaxUID)
Check for valid information, and that the file is not compressed or not a suitable storage object for import.protected void
logLn(java.lang.String s)
static void
main(java.lang.String[] arg)
Check that DICOM files are present and importable.
-
-
-
Field Detail
-
mediaDirectoryPath
protected java.lang.String mediaDirectoryPath
-
logger
protected MessageLogger logger
-
progressBar
protected javax.swing.JProgressBar progressBar
-
progressBarUpdater
protected SafeProgressBarUpdaterThread progressBarUpdater
-
terminateAfterIdentifyingGroup
protected static final AttributeList.ReadTerminationStrategy terminateAfterIdentifyingGroup
-
-
Constructor Detail
-
MediaImporter
public MediaImporter(MessageLogger logger)
Construct an importer that will looked for files in the system default path.
- Parameters:
logger
- where to send status updates as files are read (may be null for no logging)
-
MediaImporter
public MediaImporter(MessageLogger logger, javax.swing.JProgressBar progressBar)
Construct an importer that will looked for files in the system default path.
- Parameters:
logger
- where to send status updates as files are read (may be null for no logging)progressBar
- where to update progress as files are read (may be null for no progress bar)
-
MediaImporter
public MediaImporter(java.lang.String mediaDirectoryPath, MessageLogger logger)
Construct an importer that will looked for files in the specified path.
- Parameters:
mediaDirectoryPath
- where to begin looking for the DICOMDIR and DICOM fileslogger
- where to send status updates as files are read (may be null for no logging)
-
MediaImporter
public MediaImporter(java.lang.String mediaDirectoryPath, MessageLogger logger, javax.swing.JProgressBar progressBar)
Construct an importer that will looked for files in the specified path.
- Parameters:
mediaDirectoryPath
- where to begin looking for the DICOMDIR and DICOM fileslogger
- where to send status updates as files are read (may be null for no logging)progressBar
- where to update progress as files are read (may be null for no progress bar)
-
-
Method Detail
-
logLn
protected void logLn(java.lang.String s)
- Parameters:
s
- message to log
-
choosePathAndImportDicomFiles
public void choosePathAndImportDicomFiles(java.awt.Component parent) throws java.io.IOException, DicomException
Pop up a file chooser dialog that allows the user to specify the location of the DICOMDIR file, or the parent folder (for example, the drive or volume) in which the DICOMDIR file is located, and then import the referenced files.
Will be positioned relative to the parent component (for example, centered over the component) if specified, else placed in a look-and-feel-dependent position such as the center of the screen if null.
Can only be invoked on the AWT Event Dispatch Thread.
- Parameters:
parent
- the parent component of the dialog; can benull
- Throws:
java.io.IOException
- thrown if the DICOMDIR file (but not any referenced files) cannot be opened or readDicomException
- thrown if the DICOMDIR file cannot be parsed
-
choosePathAndImportDicomFiles
public void choosePathAndImportDicomFiles() throws java.io.IOException, DicomException
Pop up a file chooser dialog that allows the user to specify the location of the DICOMDIR file, or the parent folder (for example, the drive or volume) in which the DICOMDIR file is located, and then import the referenced files.
Will be placed in a look-and-feel-dependent position such as the center of the screen.
Can only be invoked on the AWT Event Dispatch Thread.
- Throws:
java.io.IOException
- thrown if the DICOMDIR file (but not any referenced files) cannot be opened or readDicomException
- thrown if the DICOMDIR file cannot be parsed
-
isOKToImport
protected boolean isOKToImport(java.lang.String sopClassUID, java.lang.String transferSyntaxUID)
Check for valid information, and that the file is not compressed or not a suitable storage object for import.
- Parameters:
sopClassUID
- the SOP Class UID of the filetransferSyntaxUID
- the Transfer Syntax UID of the file- Returns:
- true if is suitable
-
importDicomFiles
public void importDicomFiles(java.lang.String pathName) throws java.io.IOException, DicomException
Read a DICOMDIR file, and then import any DICOM files that it references.
How errors are handled during the importation of the referenced files depends on the implementation of
doSomethingWithDicomFileOnMedia
in the sub-class. Any such errors will not interrupt the execution of this method (i.e., will not prevent the importation of the remaining files).- Parameters:
pathName
- the path name to a DICOMDIR file or folder containing a DICOMDIR file- Throws:
java.io.IOException
- thrown if the DICOMDIR file (but not any referenced files) cannot be opened or readDicomException
- thrown if the DICOMDIR file cannot be parsed
-
doSomethingWithUnwantedFileOnMedia
protected void doSomethingWithUnwantedFileOnMedia(java.lang.String mediaFileName, java.lang.String transferSyntaxUID, java.lang.String sopClassUID)
Do something with the unwanted (possibly DICOM file) that has been encountered.
This method needs to be implemented in a sub-class to do anything useful. The default method does nothing.
"Unwanted" files are those that are not DICOM files or DICOM files for which
isOKToImport(String sopClassUID,String transferSyntaxUID)
returns false.This method does not define any exceptions and hence must handle any errors locally.
- Parameters:
mediaFileName
- the fully qualified path name to a DICOM filetransferSyntaxUID
- the Transfer Syntax of the Data Set if a DICOM file, from the DICOMDIR or Meta Information HeadersopClassUID
- the SOP Class of the Data Set if a DICOM file, from the DICOMDIR or Meta Information Header
-
doSomethingWithDicomFileOnMedia
protected void doSomethingWithDicomFileOnMedia(java.lang.String mediaFileName, java.lang.String transferSyntaxUID, java.lang.String sopClassUID)
Do something with the referenced DICOM file that has been encountered.
This method may be implemented in a sub-class to do something useful that requires knowledge of the Transfer Syntax or SOP Class. The default method calls the simpler method
doSomethingWithDicomFileOnMedia(String mediaFileName)
."Wanted" files are those that are DICOM files for which
isOKToImport(String sopClassUID,String transferSyntaxUID)
returns true.This method does not define any exceptions and hence must handle any errors locally.
- Parameters:
mediaFileName
- the fully qualified path name to a DICOM filetransferSyntaxUID
- the Transfer Syntax of the Data Set in the DICOM file, from the DICOMDIR or Meta Information HeadersopClassUID
- the SOP Class of the Data Set in the DICOM file, from the DICOMDIR or Meta Information Header
-
doSomethingWithDicomFileOnMedia
protected void doSomethingWithDicomFileOnMedia(java.lang.String mediaFileName)
Do something with the referenced DICOM file that has been encountered.
This method needs to be implemented in a sub-class to do anything useful, unless
doSomethingWithDicomFileOnMedia(String mediaFileName,String transferSyntaxUID,String sopClassUID)
has been overridden instead. The default method does nothing."Wanted" files are those that are DICOM files for which
isOKToImport(String sopClassUID,String transferSyntaxUID)
returns true.This method does not define any exceptions and hence must handle any errors locally.
- Parameters:
mediaFileName
- the fully qualified path name to a DICOM file
-
getDirectory
public java.lang.String getDirectory()
- Returns:
- the directory last used to perform an import
-
main
public static void main(java.lang.String[] arg)
Check that DICOM files are present and importable.
- Parameters:
arg
- array of one string - the path to the media or folder containing the files to check are importable (in which case will write messages to stderr), or else will pop up a file chooser dialog (and write messages to a dialog box)
-
-