NAME

CohortExplorer::Application - CohortExplorer superclass

VERSION

Version 0.01

SYNOPSIS

The class is inherited from CLI::Framework::Application and overrides the following methods:

usage_text()

This method returns the application usage.

option_spec()

This method returns the application option specifications as expected by Getopt::Long::Descriptive.

( 
  [ 'datasource|d:s' => 'provide datasource'           ],
  [ 'username|u:s'   => 'provide username'             ],
  [ 'password|p:s'   => 'provide password'             ],
  [ 'verbose|v'      => 'print with verbosity'         ],
  [ 'help|h'         => 'print usage message and exit' ] 
)

validate_options( $opts )

This method ensures the user has supplied all mandatory options (i.e., datasource, username and password).

command_map()

This method returns the mapping between command names and command classes

console  => 'CLI::Framework::Command::Console',
help     => 'CohortExplorer::Application::Command::Help',
menu     => 'CohortExplorer::Application::Command::Menu',
describe => 'CohortExplorer::Application::Command::Describe',
history  => 'CohortExplorer::Application::Command::History',
find     => 'CohortExplorer::Application::Command::Find',
search   => 'CohortExplorer::Application::Command::Query::Search',
compare  => 'CohortExplorer::Application::Command::Query::Compare'

command_alias()

This method returns command alias

h    => 'help',
m    => 'menu',
s    => 'search',
c    => 'compare',
d    => 'describe',
hist => 'history',
f    => 'find',
sh   => 'console'

pre_dispatch( $command )

This method ensures the invalid commands do not dispatch and logs the commands dispatched by the users.

noninteractive_commands()

The method returns a list of the valid commands under interactive mode. The commands search, compare and history can be invalid as they are application dependent because they require the user to have access to at least one variable from the datasource and also depend on the datasource type (e.g., compare command is only available to longitudinal datasources).

render( $output )

This method is responsible for the presentation of the command output. All commands except help produce a tabular output.

read_cmd( )

This method attempts to provide the autocompletion of options and arguments wherever applicable.

handle_exception( $e )

This method prints and logs all exceptions.

init( $opts )

This method is responsible for the initialising of the application which includes initialising the logger and the datasource object.

OPERATIONS

This class attempts to perform the following operations:

  1. Initialises the application logger. The logger's configuration is read from the file specified under log_config_file.

  2. Captures the application options and passes them along with the datasource configuration file specified under datasource_config_file to the datasource class for object intialisation.

  3. Stores the resulting datasource object in the cache along with the logger object to be used by the commands.

  4. Creates a menu of available command based on the datasource type. For standard (i.e. non-longitudinal) datasource the command menu includes describe, find, search, history and help where as, the longitudinal datasources have also access to the compare command. The search, compare and history commands require the user to have access to at least one variable from the datasource.

  5. Provides autocompletion of command arguments/options (if applicable) for the user entered command. This feature is only available when the application is running in the console/interactive mode.

  6. Dispatches the command object for command specific processing.

  7. Captures the output returned by a command and displays them as a table.

  8. Logs all exceptions thrown by the commands.

SUBCLASS HOOK

log_config_file()

Returns the full path to the log configuration file (default /etc/CohortExplorer/log-config.properties). The logger is implemented using Log::Log4perl. The logger attempts to log both the error and information messages.

datasource_config_file()

Returns the full path to the datasource configuration file (default /etc/CohortExplorer/datasource-config.properties). To see how the datasources can be configured using the config file see CohortExplorer::Datasource.

ERROR HANDLING

All exceptions thrown within CohortExplorer are treated by the handle_exception( $e ) method. The exceptions are imported from CLI::Framework::Exception.

DEPENDENCIES

CLI::Framework::Application

CLI::Framework::Exceptions

Exception::Class::TryCatch

File::Find

Log::Log4perl

Term::ReadKey

Text::ASCIITable

SEE ALSO

CohortExplorer

CohortExplorer::Command::Describe

CohortExplorer::Command::History

CohortExplorer::Command::Query::Search

CohortExplorer::Command::Query::Compare

LICENSE AND COPYRIGHT

Copyright (c) 2013-2014 Abhishek Dixit (adixit@cpan.org). All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of either:

  • the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version, or

  • the "Artistic Licence".

AUTHOR

Abhishek Dixit