HiRISE

HiRISE.HiCat.CleanUp
Class Product_CleanUp

java.lang.Object
  extended by HiRISE.HiCat.CleanUp.Product_CleanUp
All Implemented Interfaces:
CleanUp
Direct Known Subclasses:
EDR_CleanUp, RDR_CleanUp, RDR_Extras_CleanUp

public abstract class Product_CleanUp
extends Object
implements CleanUp

The Product_CleanUp class partially implements the CleanUp interface and provides some convenience methods to allow subclasses to more quickly initialize themselves.

Subclasses need to implement the Clean_Up_Products(Vector), Column_Names(), Find_Products(String, int, int), and Product_Data(String, String, String) methods of the CleanUp interface.

Note: Each instance of this class (or subclass) will instantiate it's own database connection. This allows multiple intances to operate independently of each other at the same time.

Version:
1.12
Author:
Rodney Heyd UA/HiRISE
See Also:
CleanUp

Field Summary
static String DEFAULT_CONFIGURATION_FILE
           
static String ID
           
protected  boolean isCLI
           
 SwingPropertyChangeSupport Property_Changer
           
protected  boolean Verbose
           
 
Fields inherited from interface HiRISE.HiCat.CleanUp.CleanUp
ABSOLUTE_MAXIMUM_ORBIT_NUMBER, ANAGLYPH, DEFAULT_MAXIMUM_ORBIT_NUMBER, DEFAULT_MINIMUM_ORBIT_NUMBER, EDR, EDR_EXTRAS, IDLE_STATUS_MESSAGE, INDEX_TABLE_UPDATE_PROPERTY_NAME, MAXIMUM_UPDATES_BEFORE_COMMIT, OLD_VERSION_ID_ALIAS, PREPARE_STATUS_PROPERTY_NAME, PREPARE_STATUS_ROW_PROPERTY_NAME, RDR, RDR_EXTRAS, RELEASED_VERSION_ID_ALIAS, REMOVAL_STATUS_COUNT_PROPERTY_NAME, REMOVING_PRODUCT_PROPERTY_NAME, SEARCH_STATUS_COMPILING_DATA, SEARCH_STATUS_COMPLETE, SEARCH_STATUS_CONSTRUCT, SEARCH_STATUS_EXECUTE, SEARCH_STATUS_PROPERTY_NAME, SEARCH_STATUS_START, Status_Hash
 
Constructor Summary
Product_CleanUp()
          The default constructor.
Product_CleanUp(Configuration configuration)
          Construct a new Product_CleanUp object with a configuration object, useful for gui wrappers.
Product_CleanUp(String configuration_file)
          Construct a new Product_CleanUp object specifing the configuration file to use as a string.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          As a CleanUp class processes a list of products, property change events are fired to indicate the products currently being processed.
abstract  void Clean_Up_Products(Vector<Product> products)
          Subclasses need to implement this method for the particular type of product that is to be cleaned up.
abstract  Vector<String> Column_Names()
          A convenience function allowing other applications, particularly gui's, easy access to the list of columns retrieved from the database during the Find_Products(String, int, int) method call.
protected  void File_Status_Tests(File test_file)
          A utility method for outputting various file status values to aid in determining file access or deletion problems in the subclassess of this class.
abstract  Vector<Vector<String>> Find_Products(String observation_id, int start_orbit, int end_orbit)
          This method should retrieve a list of products from the database that can be removed from the file system because newer versions of these products have been released.
 String Get_Catalog()
          Get the database catalog specified within the configuration.
 Configuration Get_Configuration()
          Get the configuration object used to initialize the class
 Database Get_Database()
          Get the Database object created upon the construction of an instance of this class
 boolean isCLI()
          Gets the current command line state of the class.
 void isCLI(boolean cli)
          Sets command line mode.
protected static void Print_Progress(double progress, int total_width, boolean finished)
           
abstract  Product Product_Data(String product_id, String version, String type)
          This method should create a Product instance by retrieving the product information from the database.
 HashMap<String,Integer> Search_Status_Hash()
          Returns the list of status values that are fired as property changes during the search process.
 boolean Verbose()
          Returns the current verbosity setting.
 void Verbose(boolean verbose)
          Set verbose to true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface HiRISE.HiCat.CleanUp.CleanUp
Create_Archive_Table, Drop_Archive_Table
 

Field Detail

ID

public static final String ID
See Also:
Constant Field Values

DEFAULT_CONFIGURATION_FILE

public static final String DEFAULT_CONFIGURATION_FILE
See Also:
Constant Field Values

Verbose

protected boolean Verbose

isCLI

protected boolean isCLI

Property_Changer

public SwingPropertyChangeSupport Property_Changer
Constructor Detail

Product_CleanUp

public Product_CleanUp()
                throws Configuration_Exception,
                       Database_Exception
The default constructor. This will initialize the class using the value of the DEFAULT_CONFIGURATION_FILE for the configuration file to use.

Throws:
Configuration_Exception - if a problem with the configuration file is encountered
Database_Exception - if a problem initializing the database connection is encountered

Product_CleanUp

public Product_CleanUp(String configuration_file)
                throws Configuration_Exception,
                       Database_Exception
Construct a new Product_CleanUp object specifing the configuration file to use as a string.

Parameters:
configuration_file - - the configuration to use to configure the database connection
Throws:
Configuration_Exception - if a problem with the configuration file is encountered
Database_Exception - if a problem initializing the database connection is encountered.

Product_CleanUp

public Product_CleanUp(Configuration configuration)
                throws Configuration_Exception,
                       Database_Exception
Construct a new Product_CleanUp object with a configuration object, useful for gui wrappers.

Parameters:
configuration - - the configuration object to use containing database connection parameters
Throws:
Configuration_Exception - if a missing or invalid parameter is found
Database_Exception - if a problem establishing a database connection occurs.
Method Detail

Get_Configuration

public Configuration Get_Configuration()
Get the configuration object used to initialize the class

Returns:
a Configuration object

Get_Catalog

public String Get_Catalog()
Get the database catalog specified within the configuration.

Returns:
a string contianing the database catalog name.

Get_Database

public Database Get_Database()
Get the Database object created upon the construction of an instance of this class

Returns:
a Database object

Search_Status_Hash

public HashMap<String,Integer> Search_Status_Hash()
Returns the list of status values that are fired as property changes during the search process. These are useful for updating status messages associated with gui progress bars.

Returns:
The set of release status values as a hash.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
As a CleanUp class processes a list of products, property change events are fired to indicate the products currently being processed. A GUI application can add itself as a listener for these events to update a status bar.

Parameters:
listener - - A property change listener

Verbose

public void Verbose(boolean verbose)
Set verbose to true. This will have the impact of outputting additional processing or file status information to stdout as files are cleaned up.

Parameters:
verbose - - a boolean value, set to true to turn verbosity on.

Verbose

public boolean Verbose()
Returns the current verbosity setting.

Returns:
true if verbosity is turn on, false otherwise.

isCLI

public void isCLI(boolean cli)
Sets command line mode. If this is set to true, the clean up class should output status information to stdout.

Parameters:
cli - - a boolean indicating if the calling program is a command line application rather than a gui.

isCLI

public boolean isCLI()
Gets the current command line state of the class. If false, the clean up class assumes the calling application is gui driven and status information will not be output to stdout.

Returns:
true if the class has been set to command line mode.

File_Status_Tests

protected void File_Status_Tests(File test_file)
A utility method for outputting various file status values to aid in determining file access or deletion problems in the subclassess of this class. The method report various file status parameters to stdout: existance, read/write permissions, etc.

Parameters:
test_file - - a File object to report status on.

Print_Progress

protected static void Print_Progress(double progress,
                                     int total_width,
                                     boolean finished)

Clean_Up_Products

public abstract void Clean_Up_Products(Vector<Product> products)
                                throws Database_Exception,
                                       IOException
Subclasses need to implement this method for the particular type of product that is to be cleaned up. In general, this method should delete the product file and it's PDS label (if it has a label), and the product's entry in the database should also be removed and optionally archived.

Specified by:
Clean_Up_Products in interface CleanUp
Parameters:
products - - A vector of products to be removed
Throws:
Database_Exception - if a database error occurrs during the deletion or archive process
IOException - if the file can not be accessed.

Column_Names

public abstract Vector<String> Column_Names()
A convenience function allowing other applications, particularly gui's, easy access to the list of columns retrieved from the database during the Find_Products(String, int, int) method call.

Specified by:
Column_Names in interface CleanUp
Returns:
a Vector containing the column names as elements or null if CleanUp.Find_Products(String, int, int) products has not yet been called.

Find_Products

public abstract Vector<Vector<String>> Find_Products(String observation_id,
                                                     int start_orbit,
                                                     int end_orbit)
                                              throws Database_Exception
This method should retrieve a list of products from the database that can be removed from the file system because newer versions of these products have been released. The list should not contain any products that have not been released yet, or that are currently released.

Specified by:
Find_Products in interface CleanUp
Returns:
- A list of products that can be removed from the system, and database records archived.
Throws:
Database_Exception - if a database error occurs during the search

Product_Data

public abstract Product Product_Data(String product_id,
                                     String version,
                                     String type)
                              throws Database_Exception
This method should create a Product instance by retrieving the product information from the database. At a minimum the label file, the data file, and the product type should be specified.

Specified by:
Product_Data in interface CleanUp
Parameters:
product_id - - the product_id to retrieve information for
version - - the version of the product
type - - the type of product
Returns:
A product instance containing product metadata.
Throws:
Database_Exception - - if an error occurs while retrieving product information from the database.

HiRISE

Copyright (C) Arizona Board of Regents on behalf of the Planetary Image Research Laboratory, Lunar and Planetary Laboratory at the University of Arizona