HiRISE

HiRISE.HiCat.Utilities
Class TopPriorityNotifier

java.lang.Object
  extended by HiRISE.HiCat.Utilities.TopPriorityNotifier

public class TopPriorityNotifier
extends Object

TopPriorityNotifier is a class which searches for the top priority suggestions in each science theme and will send a notification email containing an html formated table of the suggestions that were found, ordered by the science theme. In addition, specific cycles, science themes, and email address can be specified. The suggestions retrieved from the database will conform to the following criteria:

Configuration Parameters

The configuration file for this class is a PVL style configuration file. The file should contain a NOTIFY parameter holding a list of one or more email addresses that should receive the email notification. In addition, the configuration should contain the parameters needed to initiate a database connection. Finally, the configuration file should contain a TopPriorityNotifier group that contains information about the minimum priorities to use for any science themes that will not use the default value.

Here is an example of what the TopPriorityNotifier group should look like:

 Group = TopPriorityNotifier
        Group = Science_Theme_Priorities
                DEFAULT_PRIORITY = 9
                GEOLOGIC_CONTACTS_STRATIGRAPHY = 7
        End_Group
End_Group
 
Note that if the science theme contains spaces or slashes in the database listing, these are replaced by underscores here. Science themes that do not have a minimum priority listed here will use the setting of the DEFAULT_PRIORITY parameter, and therefore this parameter is required.

Since:
2014/09/10 19:46:33
Version:
1.10
Author:
Rodney Heyd UA/HiRISE

Nested Class Summary
static class TopPriorityNotifier.ExitCode
          Exit status
 
Field Summary
static String DEBUG_CYCLE_PROPERTY
          Setting any of the debugging system properties to true will cause additional debugging information to be output during the program execution that relates to operations named by the property.
static String DEBUG_MAIN_PROPERTY
          Setting any of the debugging system properties to true will cause additional debugging information to be output during the program execution that relates to operations named by the property.
static String DEBUG_SEARCH_QUERY_PROPERTY
          Setting any of the debugging system properties to true will cause additional debugging information to be output during the program execution that relates to operations named by the property.
static String DEFAULT_CONFIGURATION_FILENAME
           
static String ID
          Class identifier
 
Constructor Summary
TopPriorityNotifier()
          Construct the object using the default configuration file.
TopPriorityNotifier(String configuration_filename)
          Construct the object using the input string as filename containing configuration information.
 
Method Summary
 void addEmailAddress(String email_address)
          Add a single email address to the list of emails to notify.
 void addEmailAddress(Vector<String> email_list)
          Any emails added in this list will be sent the notification email in addition to any emails that may have been found in the configuration file.
 int getCycle()
          Retrieve the current MRO Cycle ID setting
 boolean getVerbose()
          Return the current verbosity setting
static void main(String[] arguments)
          Retrieve a list of the top priority suggestions and send them via email.
 boolean NOOP()
          Retrieve the current Noop setting.
 void NOOP(boolean noop)
          No operation.
 void resetNotifiers()
          Reset the list of email addresses that will receive the notification email.
 void sendNotification()
          Send a notification with the default minimum priority.
 void sendNotification(int minimum_priority)
          Search for the top priority suggestions and send an email listing the set of top priority suggestions.
 void setCycle(int cycle)
          Set the MRO Planning cycle ID for this run
 boolean setScienceTheme(String theme)
          Set the list of science themes to the input science theme.
 void setVerbose(boolean verbose)
          When set to true additional status information will be sent to stdout
static void Usage(org.apache.commons.cli.Options options)
          Prints the command line usage syntax.
 
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
Class identifier

See Also:
Constant Field Values

DEFAULT_CONFIGURATION_FILENAME

public static final String DEFAULT_CONFIGURATION_FILENAME
See Also:
Constant Field Values

DEBUG_MAIN_PROPERTY

public static final String DEBUG_MAIN_PROPERTY
Setting any of the debugging system properties to true will cause additional debugging information to be output during the program execution that relates to operations named by the property. In addition, full stack traces will be output to stdout for any exceptions that are thrown during the execution of the program if any of these properties are set prior to the initialization of the class.

See Also:
Constant Field Values

DEBUG_SEARCH_QUERY_PROPERTY

public static final String DEBUG_SEARCH_QUERY_PROPERTY
Setting any of the debugging system properties to true will cause additional debugging information to be output during the program execution that relates to operations named by the property. In addition, full stack traces will be output to stdout for any exceptions that are thrown during the execution of the program if any of these properties are set prior to the initialization of the class.

See Also:
Constant Field Values

DEBUG_CYCLE_PROPERTY

public static final String DEBUG_CYCLE_PROPERTY
Setting any of the debugging system properties to true will cause additional debugging information to be output during the program execution that relates to operations named by the property. In addition, full stack traces will be output to stdout for any exceptions that are thrown during the execution of the program if any of these properties are set prior to the initialization of the class.

See Also:
Constant Field Values
Constructor Detail

TopPriorityNotifier

public TopPriorityNotifier()
                    throws Configuration_Exception,
                           Database_Exception
Construct the object using the default configuration file.

Throws:
Configuration_Exception
Database_Exception
See Also:
TopPriorityNotifier(String)

TopPriorityNotifier

public TopPriorityNotifier(String configuration_filename)
                    throws Configuration_Exception,
                           Database_Exception
Construct the object using the input string as filename containing configuration information. The constructor will initialize the database connection, use the current date to determine the MRO planning cycle status of the current week, and initialize the list of science themes.

Parameters:
configuration_filename - - the file name to use holding configuration information required for the operation of the class
Throws:
Configuration_Exception - if configuration cannot be read or required parameters cannot be found
Database_Exception - if the database connection cannot be initialized
Method Detail

sendNotification

public void sendNotification()
                      throws Database_Exception,
                             MessagingException
Send a notification with the default minimum priority.

Throws:
Database_Exception
MessagingException
See Also:
sendNotification(int)

sendNotification

public void sendNotification(int minimum_priority)
                      throws Database_Exception,
                             MessagingException
Search for the top priority suggestions and send an email listing the set of top priority suggestions.

Parameters:
minimum_priority - - the minimum priority a suggestion must have to be included in the list. Note: This priority will not override any priority settings defined in the configuration file.
Throws:
Database_Exception - if a database error occurs while searching for target suggestions in the database.
MessagingException - if an error occurs while sending the notification email
See Also:
NOOP(boolean), setCycle(int), setScienceTheme(String), resetNotifiers(), addEmailAddress(String)

NOOP

public boolean NOOP()
Retrieve the current Noop setting.

See Also:
NOOP(boolean)

NOOP

public void NOOP(boolean noop)
No operation. When set to true, the class will perform all database operations but will not send any email. The text (including the html) of the email notification message will be sent to stdout when this parameter is set to true.

Parameters:
noop - - set to true to prevent the notification email from being sent

getVerbose

public boolean getVerbose()
Return the current verbosity setting

Returns:
true, if verbose is turned on, false otherwise
See Also:
setVerbose(boolean)

setVerbose

public void setVerbose(boolean verbose)
When set to true additional status information will be sent to stdout

Parameters:
verbose - - set to true to output additionals status information, defaults to false

setCycle

public void setCycle(int cycle)
              throws Database_Exception
Set the MRO Planning cycle ID for this run

Parameters:
cycle - - an Integer MRO Cycle ID
Throws:
Database_Exception - if a database error occurs while retrieving the cycle information from the database, or if the cycle cannot be found.

getCycle

public int getCycle()
Retrieve the current MRO Cycle ID setting

Returns:
an Integer MRO Cycle ID number
See Also:
setCycle(int)

resetNotifiers

public void resetNotifiers()
Reset the list of email addresses that will receive the notification email. Calling this method will empty the current list of emails.

See Also:
addEmailAddress(String), addEmailAddress(Vector)

addEmailAddress

public void addEmailAddress(String email_address)
Add a single email address to the list of emails to notify.

Parameters:
email_address -
See Also:
resetNotifiers()

addEmailAddress

public void addEmailAddress(Vector<String> email_list)
Any emails added in this list will be sent the notification email in addition to any emails that may have been found in the configuration file.

Parameters:
email_list -
See Also:
resetNotifiers()

setScienceTheme

public boolean setScienceTheme(String theme)
Set the list of science themes to the input science theme. Only suggestions from the given science theme will be returned. This method will return true if the science theme was successfully reset. In this case, this means that the input science theme matches one of the science themes found in the database. If a matching science theme cannot be found, this method will return false and the list of science themes will remain unchanged.

Parameters:
theme - - the science theme to retrieve suggestions for
Returns:
true if the science theme was successfully reset, false otherwise.

main

public static void main(String[] arguments)
Retrieve a list of the top priority suggestions and send them via email.

Command line syntax is describe in the Usage(Options) method.

Exit Status Values:

0 - Success 1 - Configuration Error 2 - Database Error 3 - Invalid Command Line Syntax 4 - Email Address Error

Parameters:
arguments -
See Also:
Usage(Options)

Usage

public static void Usage(org.apache.commons.cli.Options options)
Prints the command line usage syntax.

Usage: TopPriorityNotifier <Options>
  Options -
    [-Configuration <filename>]
    [-Email <user@host.domain>]
    [-Force_Cycle <cycle_number>]
    [-Help]
    [-Noop]
    [-Theme <Science_Theme>]
    [-Verbose]


HiRISE

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