gov.nih.nlm.mms
Class RichMRMetamorphoSysOutputStream

java.lang.Object
  extended bygov.nih.nlm.umls.io.RichMRFilesConceptOutputStream
      extended bygov.nih.nlm.umls.io.RichMRMetathesaurusOutputStream
          extended bygov.nih.nlm.mms.RichMRMetamorphoSysOutputStream
All Implemented Interfaces:
Comparable, ConceptOutputStream, Configurable, GUIConfigurable, MetamorphoSysOutputStream, MetathesaurusOutputStream, ProgressReporter, SubsetListener

public class RichMRMetamorphoSysOutputStream
extends RichMRMetathesaurusOutputStream
implements MetamorphoSysOutputStream

This MetamorphoSysOutputStream obtains data from the MetamorphoSys subset routine and generates a subset of Rich Release MR files.

Author:
Deborah Shapiro

Field Summary
protected  ApplicationConfiguration default_config
           
protected  UserConfiguration user_config
           
protected  String validate_msg
           
 
Fields inherited from class gov.nih.nlm.umls.io.RichMRMetathesaurusOutputStream
ancillary_files, atoms, change_files, config, lui_to_cui_set, sui_to_cui_set
 
Fields inherited from class gov.nih.nlm.umls.io.RichMRFilesConceptOutputStream
add_unicode_bom, file_ext, mr_dir, mr_targets, target_files, target_to_output_stream, versioned_output
 
Constructor Summary
RichMRMetamorphoSysOutputStream()
          Instantiates an empty RichMRMetamorphoSysOutputStream.
 
Method Summary
 void addDataChangeListener(DataChangeListener dcl)
          Adds a DataChangeListener that will be notified every time a fireDataChanged() call is made.
 boolean addUnicodeBom()
          Indicates whether or not the output stream is configured to prepend the UTF-8 BOM character.
 void beginInitializeCuiList()
          Informs SubsetListener that the Initialize Cui List phase is starting.
 void beginSubsetContent()
          Informs SubsetListener that the Subset Content phase is starting.
 boolean calculateMD5s()
          Indicates whether or not the output stream is configured to calculate md5 values for all of the output files.
 void close()
          Closes source files that were opened by this class's openTargets() method.
 int compareTo(Object o)
          Compares this object with the specified object for order.
 void endInitializeCuiList()
          Informs SubsetListener that the Initialize Cui List phase is ending.
 void endSubsetContent()
          Informs SubsetListener that the Subset Content phase is ending.
protected  void fireDataChanged()
          Enables filters to inform listeners of data changed event.
protected  void fireNotUndoableDataChanged()
          Enables filters to indicate that data has changed without notifying the listeners or making this change undoable.
 Color getColor()
          Indicates the Color that should be used to display the name.
 String getConfigurationDetails()
          Returns a message for the log.
 GUIConfigurable getGUIConfigurableForValidationFailure()
          Returns the GUIConfigurable whose tab should next be displayed to allow the user to correct an error or warning.
 JPanel getHelpPanel()
          Returns a JPanel that will be displayed when the user selects the corresponding menu item from the Help menu and will provide the user with detailed instructions on the tab's use.
 String getName()
          Returns the short name for display purposes.
 JPanel getPanel()
          Returns the GUI panel that will be displayed on one of the tabs on the main GUI window.
 Properties getProperties()
          Returns the current state of the output stream as a Properties object.
 String getTabDescription()
          Returns a description of the screen and includes instructions on use.
 String getValidateMessage()
          Returns the message that the user will see if this GUIConfigurable is invalid.
 String[] getValidationErrors()
          Returns the messages indicating why validation failed.
 String[] getValidationWarnings()
          Returns warnings that were indicated during validation.
 boolean hasAdvancedOptions()
          Indicates whether or not an options menu item should be supplied for advanced configuration options.
 boolean hasDataChanged()
          Returns a boolean indicating whether or not the values on this gui have changed.
 void open(String mr_dir)
          Opens all target files in the specified directory.
protected  BufferedWriter openTargetFile(String name)
          Opens the specified file in the directory passed to open(String).
protected  void printLine(String line, String file_name)
          Prints the given line to the file with the given name.
 void removeDataChangeListener(DataChangeListener dcl)
          Removes a DataChangeListener so that it will no longer be notified every time a fireDataChanged() call is made from this gui.
 boolean removeMTHOnlyConcepts()
          Indicates whether or not the output stream is configured to remove concepts with only MTH atoms.
 boolean removeUnicode()
          Indicates whether or not the output stream is configured to remove non-ASCII Unicode lines.
 void resetDataChanged()
          Resets the data_changed flag to indicate that no data has been changed since the last save.
 void resetToDefaults()
          Provides a mechanism for resetting the variables on a tab back to their default values.
 void setConfiguration(ApplicationConfiguration c)
          Sets the ApplicationConfiguration.
 void setConfiguration(UserConfiguration user_config)
          Sets the UserConfiguration.
 void setCuiList(CuiList cui_list)
          Sets the CuiList reference.
 void setDataChanged(boolean b)
          Sets the "has data changed" flag.
 void setPanelSelections()
          Applies the state of the output stream to the GUI.
 void setProperties(Properties p)
          Sets the current state of the output stream from a Properties object.
 void showOptions()
          Presents an advanced options GUI to the user.
 boolean validate()
          Indicates whether or not the GUIConfigurable is valid.
 void writeIndexEntry(IndexEntry ie)
          Writes index entries with the "remove utf8" settings in mind.
protected  void writeMRCONSO(Concept concept)
          Writes MRCONSO.RRF entries for a Concept.
protected  void writeMRCXT(Concept concept)
          Writes MRCXT entries for a Concept.
protected  void writeMRDEF(Concept concept)
          Writes MRDEF entries for a Concept.
protected  void writeMRDOC(ReleaseMetadata release_metadata)
          Write release_info lines to the MRDOC.RRF file, ensuring no duplicates.
protected  void writeMRSAT(Concept concept)
          Writes MRSAT entries for a Concept.
 
Methods inherited from class gov.nih.nlm.umls.io.RichMRMetathesaurusOutputStream
addProgressListener, ambigCheck, fireProgressEvent, getColumnTextFromFileStatistics, getFileTextFromFileStatistics, removeProgressListener, setCandidateAmbiguousStringIdentifiers, setCandidateAmbiguousStringIdentifiers, setCandidateAmbiguousTermIdentifiers, setCandidateAmbiguousTermIdentifiers, writeConcept, writeFileColumnStats, writeMRAUI, writeMRCUI, writeMRRANK, writeMRSAB, writeReleaseMetadata
 
Methods inherited from class gov.nih.nlm.umls.io.RichMRFilesConceptOutputStream
flush, getFilePosition, writeMRCOC, writeMRHIER, writeMRHIST, writeMRMAP, writeMRREL, writeMRSMAP, writeMRSTY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nih.nlm.umls.io.MetathesaurusOutputStream
setCandidateAmbiguousStringIdentifiers, setCandidateAmbiguousStringIdentifiers, setCandidateAmbiguousTermIdentifiers, setCandidateAmbiguousTermIdentifiers, writeReleaseMetadata
 
Methods inherited from interface gov.nih.nlm.umls.io.ConceptOutputStream
writeConcept
 

Field Detail

user_config

protected UserConfiguration user_config

default_config

protected ApplicationConfiguration default_config

validate_msg

protected String validate_msg
Constructor Detail

RichMRMetamorphoSysOutputStream

public RichMRMetamorphoSysOutputStream()
                                throws IOException
Instantiates an empty RichMRMetamorphoSysOutputStream.

Throws:
IOException
Method Detail

getName

public String getName()
Returns the short name for display purposes.

Specified by:
getName in interface GUIConfigurable
Returns:
the short name for display purposes.

setConfiguration

public void setConfiguration(UserConfiguration user_config)
Sets the UserConfiguration.

Specified by:
setConfiguration in interface Configurable
Parameters:
user_config - the UserConfiguration.

setCuiList

public void setCuiList(CuiList cui_list)
Sets the CuiList reference.

Specified by:
setCuiList in interface SubsetListener
Parameters:
cui_list - the CuiList

setConfiguration

public void setConfiguration(ApplicationConfiguration c)
Sets the ApplicationConfiguration.

Specified by:
setConfiguration in interface Configurable
Parameters:
c - the ApplicationConfiguration

getConfigurationDetails

public String getConfigurationDetails()
Returns a message for the log.

Specified by:
getConfigurationDetails in interface Configurable
Returns:
a message for the log

open

public void open(String mr_dir)
          throws IOException
Opens all target files in the specified directory. The set of target files are of the Rich Release Format.

Specified by:
open in interface ConceptOutputStream
Overrides:
open in class RichMRFilesConceptOutputStream
Parameters:
mr_dir - the subset directory
Throws:
IOException - if the files cannot be opened

close

public void close()
           throws IOException
Closes source files that were opened by this class's openTargets() method.

Specified by:
close in interface ConceptOutputStream
Overrides:
close in class RichMRMetathesaurusOutputStream
Throws:
IOException

openTargetFile

protected BufferedWriter openTargetFile(String name)
                                 throws IOException
Opens the specified file in the directory passed to open(String).

Overrides:
openTargetFile in class RichMRMetathesaurusOutputStream
Parameters:
name - the filename
Returns:
a BufferedWriter for the file
Throws:
IOException - if the file could not be opened.

getPanel

public JPanel getPanel()
Returns the GUI panel that will be displayed on one of the tabs on the main GUI window.

Specified by:
getPanel in interface GUIConfigurable
Returns:
JPanel that displays graphical interface for a tab

hasDataChanged

public boolean hasDataChanged()
Returns a boolean indicating whether or not the values on this gui have changed.

Specified by:
hasDataChanged in interface GUIConfigurable
Returns:
boolean true if data has changed false otherwise

setDataChanged

public void setDataChanged(boolean b)
Sets the "has data changed" flag.

Specified by:
setDataChanged in interface GUIConfigurable
Parameters:
b - boolean indicating whether or not data has changed

getProperties

public Properties getProperties()
Returns the current state of the output stream as a Properties object.

Specified by:
getProperties in interface Configurable
Returns:
Properties only those directly related to the gui

setProperties

public void setProperties(Properties p)
Sets the current state of the output stream from a Properties object.

Specified by:
setProperties in interface Configurable
Parameters:
p - Properties only those directly related to the gui

resetDataChanged

public void resetDataChanged()
Resets the data_changed flag to indicate that no data has been changed since the last save.

Specified by:
resetDataChanged in interface GUIConfigurable

addDataChangeListener

public void addDataChangeListener(DataChangeListener dcl)
Adds a DataChangeListener that will be notified every time a fireDataChanged() call is made. Allows main GUI to record all changes to this gui in the undo/redo mechanism.

Specified by:
addDataChangeListener in interface GUIConfigurable
Parameters:
dcl - DataChangeListener

removeDataChangeListener

public void removeDataChangeListener(DataChangeListener dcl)
Removes a DataChangeListener so that it will no longer be notified every time a fireDataChanged() call is made from this gui.

Specified by:
removeDataChangeListener in interface GUIConfigurable
Parameters:
dcl - DataChangeListener

getColor

public Color getColor()
Indicates the Color that should be used to display the name.

Specified by:
getColor in interface GUIConfigurable
Returns:
Color

getTabDescription

public String getTabDescription()
Returns a description of the screen and includes instructions on use.

Specified by:
getTabDescription in interface GUIConfigurable
Returns:
String text of filter instructions

resetToDefaults

public void resetToDefaults()
Provides a mechanism for resetting the variables on a tab back to their default values. This is not used to actually change the gui. setPanelSelections() is always called after this method and will update the gui based on the variable values.

Specified by:
resetToDefaults in interface Configurable

showOptions

public void showOptions()
Presents an advanced options GUI to the user.

Specified by:
showOptions in interface GUIConfigurable

hasAdvancedOptions

public boolean hasAdvancedOptions()
Indicates whether or not an options menu item should be supplied for advanced configuration options.

Specified by:
hasAdvancedOptions in interface GUIConfigurable
Returns:
true if so; false otherwise

getHelpPanel

public JPanel getHelpPanel()
Returns a JPanel that will be displayed when the user selects the corresponding menu item from the Help menu and will provide the user with detailed instructions on the tab's use.

Specified by:
getHelpPanel in interface GUIConfigurable
Returns:
JPanel to be added to the Help menu

setPanelSelections

public void setPanelSelections()
Applies the state of the output stream to the GUI.

Specified by:
setPanelSelections in interface GUIConfigurable

validate

public boolean validate()
Indicates whether or not the GUIConfigurable is valid.

Specified by:
validate in interface GUIConfigurable
Returns:
booleantrue if GUIConfigurable is valid false if GUIConfigurable is invalid

getValidateMessage

public String getValidateMessage()
Returns the message that the user will see if this GUIConfigurable is invalid.

Returns:
String with error message

getValidationErrors

public String[] getValidationErrors()
Returns the messages indicating why validation failed. Should only be called if validate() returns false.

Specified by:
getValidationErrors in interface GUIConfigurable
Returns:
the failure messages

getValidationWarnings

public String[] getValidationWarnings()
Returns warnings that were indicated during validation.

Specified by:
getValidationWarnings in interface GUIConfigurable
Returns:
the warning messages

getGUIConfigurableForValidationFailure

public GUIConfigurable getGUIConfigurableForValidationFailure()
Returns the GUIConfigurable whose tab should next be displayed to allow the user to correct an error or warning.

Specified by:
getGUIConfigurableForValidationFailure in interface GUIConfigurable
Returns:
GUIConfigurable to be displayed

fireDataChanged

protected void fireDataChanged()
Enables filters to inform listeners of data changed event.


fireNotUndoableDataChanged

protected void fireNotUndoableDataChanged()
Enables filters to indicate that data has changed without notifying the listeners or making this change undoable.


writeMRDOC

protected void writeMRDOC(ReleaseMetadata release_metadata)
                   throws IOException
Write release_info lines to the MRDOC.RRF file, ensuring no duplicates.

Overrides:
writeMRDOC in class RichMRMetathesaurusOutputStream
Parameters:
release_metadata - the ReleaseMetadata
Throws:
IOException - if anything goes wrong

writeMRDEF

protected void writeMRDEF(Concept concept)
                   throws IOException
Writes MRDEF entries for a Concept. Truncates long fields and/or removes unicode characters as user specifies.

Overrides:
writeMRDEF in class RichMRFilesConceptOutputStream
Parameters:
concept - the Concept to write
Throws:
IOException - if anything goes wrong

writeMRSAT

protected void writeMRSAT(Concept concept)
                   throws IOException
Writes MRSAT entries for a Concept. Truncates long fields and/or removes unicode characters as user specifies.

Overrides:
writeMRSAT in class RichMRFilesConceptOutputStream
Parameters:
concept - the Concept to write
Throws:
IOException - if anything goes wrong

writeMRCXT

protected void writeMRCXT(Concept concept)
                   throws IOException
Writes MRCXT entries for a Concept. Truncates long fields and/or removes unicode characters as user specifies.

Overrides:
writeMRCXT in class RichMRFilesConceptOutputStream
Parameters:
concept - the Concept to write
Throws:
IOException - if anything goes wrong

writeMRCONSO

protected void writeMRCONSO(Concept concept)
                     throws IOException
Writes MRCONSO.RRF entries for a Concept. Also writes modified MRXNW.ENG file that tallies sui word count as well.

Overrides:
writeMRCONSO in class RichMRFilesConceptOutputStream
Parameters:
concept - the Concept to write
Throws:
IOException - if anything goes wrong

printLine

protected void printLine(String line,
                         String file_name)
                  throws IOException
Prints the given line to the file with the given name.

Overrides:
printLine in class RichMRMetathesaurusOutputStream
Parameters:
line - the line to be printed
file_name - printing destination
Throws:
IOException

writeIndexEntry

public void writeIndexEntry(IndexEntry ie)
                     throws IOException
Writes index entries with the "remove utf8" settings in mind.

Specified by:
writeIndexEntry in interface MetathesaurusOutputStream
Overrides:
writeIndexEntry in class RichMRMetathesaurusOutputStream
Parameters:
ie - IndexEntry to be written
Throws:
IOException - if anything goes wrong

removeUnicode

public boolean removeUnicode()
Indicates whether or not the output stream is configured to remove non-ASCII Unicode lines.

Specified by:
removeUnicode in interface MetamorphoSysOutputStream
Returns:
true if so, false otherwise

addUnicodeBom

public boolean addUnicodeBom()
Indicates whether or not the output stream is configured to prepend the UTF-8 BOM character.

Returns:
true if so, false otherwise

removeMTHOnlyConcepts

public boolean removeMTHOnlyConcepts()
Indicates whether or not the output stream is configured to remove concepts with only MTH atoms.

Specified by:
removeMTHOnlyConcepts in interface MetamorphoSysOutputStream
Returns:
boolean

calculateMD5s

public boolean calculateMD5s()
Indicates whether or not the output stream is configured to calculate md5 values for all of the output files.

Returns:
boolean

beginInitializeCuiList

public void beginInitializeCuiList()
Informs SubsetListener that the Initialize Cui List phase is starting.

Specified by:
beginInitializeCuiList in interface SubsetListener

endInitializeCuiList

public void endInitializeCuiList()
Informs SubsetListener that the Initialize Cui List phase is ending.

Specified by:
endInitializeCuiList in interface SubsetListener

beginSubsetContent

public void beginSubsetContent()
Informs SubsetListener that the Subset Content phase is starting.

Specified by:
beginSubsetContent in interface SubsetListener

endSubsetContent

public void endSubsetContent()
Informs SubsetListener that the Subset Content phase is ending.

Specified by:
endSubsetContent in interface SubsetListener

compareTo

public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Required method for implementing Comparable interface. Indicates the means for comparison between two MetamorphoSysOutputStreams.

Specified by:
compareTo in interface Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Throws:
ClassCastException - if the specified object's type is not GUIConfigurable.


Copyright ©2005