HiRISE

HiRISE.HiCat.Utilities
Class Database_Loader

java.lang.Object
  extended by HiRISE.HiCat.Utilities.Database_Loader
Direct Known Subclasses:
CRISM_Database_Loader, CTX_Database_Loader, MOC_Database_Loader, THEMIS_IR_Database_Loader, THEMIS_VIS_Database_Loader

public abstract class Database_Loader
extends Object

Database_Loader This Abstract Class defines what is necessary to read in a database.

At the time of writing this class, the only use is for importing geospatial data for a WFS server. So, as a caution, the WFS server expects all values to be in a -180,180 range. More specifically the HiRISE hosted server requires these values to be 'ocentric latitude and east positive longitude.

See this utilities class for more information on converting from 'ographic to 'ocentric values.

Version:
1.1
Author:
Sean Whitsitt - UA/PIRL

Field Summary
protected  int Current_Entry
          The entry that the class has currently read up to.
protected  Loaded_Database database
          The data storage object for the database
static String DEFAULT_CONFIG_FILENAME
          The default configuration file name
static int DEFAULT_MAX_ENTRIES
          The default value for the maxium number of entries
static int ERROR
          Status indicating that an error has occurred
protected  String Error_Message
          Error message when an error occurs
static int FINISHED
          Status indicating the database has been fully read.
static String ID
          The class identification with revision and date
protected  int Max_Entries
          The maximum number of entries that can be stored from the database at one time.
static int OUT_OF_MEMORY
          Status indicating the database has not been fully read but that there are memory issues and the max entries should be reduced.
protected  int Status
          The status of the class
static int UNFINISHED
          Status indicating the database has not been fully read in yet.
 
Constructor Summary
Database_Loader()
           
 
Method Summary
 void Clear_Data()
          This method clears the data from the Loaded_Database
 int Get_Current_Entry()
          This method gets the current entry.
 Vector<Vector<String>> Get_Data()
          This method returns the data from the Loaded_Database of this loader
 String Get_Error_Message()
          This method gets the stored Error Message from this class
 Vector<String> Get_Fields()
          This method gets the list of fields from the database
 int Get_Max_Entries()
          This method gets the maximum number of entries to read at one time
 int Get_Status()
          This method gets the current status of the loader
 void Initialize(Configuration config, String loaded_database_group)
          This method initializes the loader
 void Initialize(Configuration config, String loaded_database_group, int max_entries)
          This method initializes the loader
 void Initialize(String config_filename, String loaded_database_group)
          This method initializes the loader
 void Initialize(String config_filename, String loaded_database_group, int max_entries)
          This method initializes the loader
abstract  void Load_Database()
          This is the method that is supposed to do the work of loading the database
abstract  void Load_Fields()
          This is the method that will be run to load the fields of the database.
 Vector<Vector<String>> Remove_Data()
          This method returns and then removes the data in the Loaded_Database
 void Set_Configuration(Configuration config)
          This method sets the configuration to a new configuration
 void Set_Configuration(String filename)
          This method sets the configuration to a new configuration
 void Set_Current_Entry(int entry)
          This method sets the current entry for the database
 void Set_Max_Entries(int max)
          This method sets the maximum number of entries to read at one time
 boolean Validate()
          This method gets the validation status of the database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

public static final String ID
The class identification with revision and date

See Also:
Constant Field Values

database

protected Loaded_Database database
The data storage object for the database


DEFAULT_CONFIG_FILENAME

public static final String DEFAULT_CONFIG_FILENAME
The default configuration file name

See Also:
Constant Field Values

Max_Entries

protected int Max_Entries
The maximum number of entries that can be stored from the database at one time.


DEFAULT_MAX_ENTRIES

public static final int DEFAULT_MAX_ENTRIES
The default value for the maxium number of entries

See Also:
Constant Field Values

Current_Entry

protected int Current_Entry
The entry that the class has currently read up to.


Status

protected int Status
The status of the class


UNFINISHED

public static final int UNFINISHED
Status indicating the database has not been fully read in yet.

See Also:
Constant Field Values

FINISHED

public static final int FINISHED
Status indicating the database has been fully read.

See Also:
Constant Field Values

OUT_OF_MEMORY

public static final int OUT_OF_MEMORY
Status indicating the database has not been fully read but that there are memory issues and the max entries should be reduced.

See Also:
Constant Field Values

ERROR

public static final int ERROR
Status indicating that an error has occurred

See Also:
Constant Field Values

Error_Message

protected String Error_Message
Error message when an error occurs

Constructor Detail

Database_Loader

public Database_Loader()
Method Detail

Initialize

public void Initialize(String config_filename,
                       String loaded_database_group,
                       int max_entries)
                throws Configuration_Exception
This method initializes the loader

This sets up the Configuration from a file, the database group for this class, and the maximum number of entries to read in at a time. The status is set to UNFINISHED and the Current_Entry is set to 0 and the Error_Message is set to the empty String.

Parameters:
config_filename - The configuration file name
loaded_database_group - The group in the database that contains this class's information
max_entries - The maximum number of entries to read at once
Throws:
Configuration_Exception - Thrown when the creation of the configuration fails.

Initialize

public void Initialize(Configuration config,
                       String loaded_database_group,
                       int max_entries)
This method initializes the loader

This sets up the Configuration from a Configuration object, the database group for this class, and the maximum number of entries to read in at a time. The status is set to UNFINISHED and the Current_Entry is set to 0 and the Error_Message is set to the empty String.

Parameters:
config - The configuration object
loaded_database_group - The group in the database that contains this class's information
max_entries - The maximum number of entries to read at once

Initialize

public void Initialize(String config_filename,
                       String loaded_database_group)
                throws Configuration_Exception
This method initializes the loader

This sets up the configuration from a file, the database group for this class, and sets the maximum number of entries to read in at a time to the default. The status is set to UNFINISHED and the Current_Entry is set to 0 and the Error_Message is set to the empty String.

Parameters:
config_filename - The configuration file name
loaded_database_group - The group in the database that contains this class's information
Throws:
Configuration_Exception - Thrown when the creation of the configuration fails.

Initialize

public void Initialize(Configuration config,
                       String loaded_database_group)
This method initializes the loader

This sets up the configuration from a Configuration object, the database group for this class, and sets the maximum number of entries to read in at a time to the default. The status is set to UNFINISHED and the Current_Entry is set to 0 and the Error_Message is set to the empty String.

Parameters:
config - The configuration object
loaded_database_group - The group in the database that contains this class's information

Set_Configuration

public void Set_Configuration(String filename)
                       throws Configuration_Exception
This method sets the configuration to a new configuration

Parameters:
filename - The filename of the new configuration.
Throws:
Configuration_Exception - Thrown when the creation of the configuration fails.

Set_Configuration

public void Set_Configuration(Configuration config)
This method sets the configuration to a new configuration

Parameters:
config - The new configuration object

Set_Current_Entry

public void Set_Current_Entry(int entry)
This method sets the current entry for the database

Parameters:
entry - The entry number.

Get_Current_Entry

public int Get_Current_Entry()
This method gets the current entry.

Returns:
the current entry of this class

Set_Max_Entries

public void Set_Max_Entries(int max)
This method sets the maximum number of entries to read at one time

Parameters:
max - the maximum number of entries

Get_Max_Entries

public int Get_Max_Entries()
This method gets the maximum number of entries to read at one time

Returns:
the maximum number of entries

Get_Status

public int Get_Status()
This method gets the current status of the loader

Returns:
the current status

Get_Data

public Vector<Vector<String>> Get_Data()
This method returns the data from the Loaded_Database of this loader

Returns:
the data read in by this class so far

Remove_Data

public Vector<Vector<String>> Remove_Data()
This method returns and then removes the data in the Loaded_Database

Returns:
the data read in by this class so far

Clear_Data

public void Clear_Data()
This method clears the data from the Loaded_Database


Get_Fields

public Vector<String> Get_Fields()
This method gets the list of fields from the database

Returns:
the list of fields

Validate

public boolean Validate()
This method gets the validation status of the database

Returns:
true if the data is valid, false if it isn't

Get_Error_Message

public String Get_Error_Message()
This method gets the stored Error Message from this class

Returns:
the Error Message of this class.

Load_Fields

public abstract void Load_Fields()
This is the method that will be run to load the fields of the database.

This method will be run before the Load_Database() method. The fields from the source database should be loaded into the Loaded_Database object with this method.

To remain generic and yet still handle errors, the Error status may be used to report problems with operation. The Error_Message String may be used to store information about the error.

There is a method in the Loaded_Database class that will attempt to read in fields from a PVL parameter file stored at a URL. It may be useful when implementing this method.


Load_Database

public abstract void Load_Database()
This is the method that is supposed to do the work of loading the database

A class extending this abstract class needs to only make sure that it loads its database into the Loaded_Database object of this class correctly. See the Loaded_Database class for more information.

After being loaded into the Loaded_Database object the other methods of this class will be run by whatever program is using it to gather information and verify data integrity as necessary.

This method should add no more than the maximum specified entries to the Loaded_Database object at a time. Once hitting that limit the status should be set accordingly to UNFINISHED. Only when the entire database has been read in (however that may be defined but the extending class) should the status be set to FINISHED. The OUT_OF_MEMORY status should be used to indicate that the maximum specified entries may be set too high.

To remain generic and yet still handle errors, the Error status may be used to report problems with operation. The Error_Message String may be used to store information about the error.


HiRISE

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