NAME

ETLp::Audit::Browser::Model::Schedule - Model Class for interacting with Runtime Process Audit Schedules

SYNOPSIS

use ETLp::Audit::Browser::Model::Schedule;

my $model = ETLp::Audit::Browser::Model::Schedule->new();
my $processes = $model->get_schedules(
    page         => 1,
    config_name  => 'ApacheLogs',
    section_name => 'NZServers'
);

METHODS

get_schedules

Returns a resultset on the ep_schedule table, based on the supplied criteria. It will grab 10 rows at a time, and is ordered by date_updated descending

Parameters

* page. Optional, Integer. The page you wish to return. Defaults
  to 1.
* config_name: Optional. The name of the configuration file
* section_name. The name of the fection in the configuration file

Returns

* A DBIx::Class resultset

get_schedule_details

Returns an array ref consisting of the main schedule and associated time componnets

Parameters

* page. Optional, Integer. The page you wish to return. Defaults
  to 1.
* config_name: Optional. The name of the configuration file
* section_name. The name of the fection in the configuration file
* status. Optional. (1 = active, 0 = inactive)

Returns

An array ref of schedule details:

* schedule_id
* minutes (cron format)
* hours (cron format)
* dom - day of month (cron format)
* days - days of the week (cron format)
* month - 1-12
* description - description of the schedule
* comment - any comment provided by the suer who edited the schedule
* status (1 = active, 0 = inactive)
* config_name - name of the configuration tghe schedule is processing
* section - the section inside the configuration file

get_day_names

Get the day names for a schedule

Parameters

* schedule_id. Optional. The schedule's key

Returns

* An array ref of day names, in day-of-week order

get_schedule

Returns the schedule withe the supplied id

Parameters

* schedule_id. Optional.  1

Returns

* A DBIx::Class row object

get_months

Returns all of the ep_months records

Parameters

None

Returns

* An Array of DBIx::Class row objects

get_dows

Gets all of the ep_days_of_month records

Parameters

None

Returns

* An Array of DBIx::Class row objects

get_schedule_month

Gets the month that the job is scheduled to run for

Parameters

* schedule_id. Integer

Returns

* A EtlpScheduleMonth resultset row

get_schedule_dows

Gets all of the days of the week that the job is scheduled to run for

Parameters

* schedule_id. Integer

Returns

* A hashref, where the keys are the dow_ids that are scheduled

get_schedule_cron_dows

Gets all of the days of the week that the job is scheduled to run for. The days are indexed by the cron day ids (0-6 = Sun - Sat) not the scheduled day of week surrogate key

Parameters

* schedule_id. Integer

Returns

* A hashref, where the keys are the dow_ids that are scheduled

get_schedule_doms

Gets all of the days of the month that the job is scheduled to run for

Parameters

* schedule_id. Integer

Returns

* A EtlpScheduleDayOfMonth resultset

get_schedule_minutes

Gets all of the minutes that the job is scheduled to run for

Parameters

* schedule_id. Integer

Returns

* A EtlpScheduleMinute resultset

get_schedule_hours

Gets all of the hours that the job is scheduled to run for

Parameters

* schedule_id. Integer

Returns

* A EtlpScheduleHour resultset

expand_entries

Takes section of cron entries for a given element (e.g. minutes), and expands the into an array ref. If the section contains a range then these are expanded into indvidual entries.

Example

'1-5,16-20,23'

becomes

[1,2,3,4,5,16,17.18.19.20.23]

Parameters

* entries. String

Returns

* An array ref of scheduled times

expand_days_of_week

Similar to expand_entries, Takes section of cron entries for the day of the week. Cron expects entries to run from Sun (0) t0 Sat (6). Our input runs from (1-7) so we simply subtact 1 from each entry

Example

'1-5,16-20,23'

becomes

[1,2,3,4,5,16,17,18,19,20,23]

Parameters

* entries. String

Returns

* A an arrarey of day elements

validate_entries

Takes a list of entries (Comma-separated values), and makes sure that each element is valid. The rules are

* each element must consist of one or two digits
* each element must be greater than the previous one
* no entry can be greater than the limit for the type of entry
  (e.g. minutes cannot be greater than 59, and hours can't
   be greater than 23)

Parameters

An array consisting of the following entries:

* entries. Mandatory. A string of comma-delimited entries
* upper_limit. Mandatory. The maximum value allowed
* zero_allowed. Optional. Whether or not 0 is a valid element for
  this type of entry

Returns

* 1 (valid) or 0 (invalid)

validate_hours

Validates the cron entries for hours

Parameters

* entries. Mandatory. A string of comma-delimited entries

Returns

* 1 (valid) or 0 (invalid)

validate_minutes

Validates the cron entries for minutes

Parameters

* entries. Mandatory. A string of comma-delimited entries

Returns

* 1 (valid) or 0 (invalid)

validate_days_of_week

Validates the cron entries for days of the week

Parameters

* entries. Mandatory. A string of comma-delimited entries

Returns

* 1 (valid) or 0 (invalid)

validate_days_of_month

Validates the cron entries for days of the month

Parameters

* entries. Mandatory. A string of comma-delimited entries

Returns

* 1 (valid) or 0 (invalid)

validate_months

Validates the cron entries for the month entries

Parameters

* entries. Mandatory. A string of comma-delimited entries

Returns

* 1 (valid) or 0 (invalid)

contract_entries

Takes an array ref of cron entries and turns them back into a cron string. Consectutive values are turned into ranges, i.e.

[1,4,5,6,10]

Becomes

'1,4-6,10'

Parameters

* entries. Mandatory. A string of comma-delimited entries

Returns

* 1 (valid) or 0 (invalid)

get_contracted_doms

Returns the days of month cron string for a given schedule.

Parameters

* schedule_id. Integer. Optional. The primary key of the schedule

Returns

* cron entry string

get_contracted_cron_dows

Returns the days of the week cron string for a given schedule.

Parameters

* schedule_id. Integer. Optional. The primary key of the schedule

Returns

* cron entry string

get_contracted_hours

Returns thehours of execution cron string for a given schedule.

Parameters

* schedule_id. Integer. Optional. The primary key of the schedule

Returns

* cron entry string

get_contracted_minutes

Returns the minutes of execution cron string for a given schedule.

Parameters

* schedule_id. Integer. Optional. The primary key of the schedule

Returns

* cron entry string

save

Saves the schedule to the database

Parameters

* params. A hashref of containing the schedule data

Returns

* Void

get_scheduler_status

Sets the scheduler status

Parameters

None

Returns

* An ep_app_config DBIx::Class row

generate_crontab

Generates a crontab from the database schedues

Parameters

* pipeline script. String. Full path to the etl-pipeline script

Returns

* crontab as a string

get_config_files

Get a list of configuration files in the application configuration directory

Parameters

* config_dir. String. Mandatory. The directory that stores the config files

Returns

* An array ref of configuration files

set_scheduler_status

Sets the scheduler status

Parameters

A string

* The scheduler status

Returns

* Void

get_sections

Get all of the sections in a configurations file

Parameters

* configuration file. String. The *full* path to the configuration file

Returns

* An array ref of sections

get_job

Given a schedule (an EPSection record), returns the job (configuration file name, section name)

Parameters

* configuration file. String. The *full* path to the configuration file

Returns

* An array; config name, section name

get_section_options

Given a config file, return the list of sections - each element will apear in HTML option tags

Parameters

* configuration file. String. The configuration file name

Returns

* An HTML string

config_exists

Determines whether a configuration file exists

Parameters

* configuration file. String. The pull path to the configuration
  file name, excluding the .conf extension

Returns

* 1 = true, 0 = false

delete

Deletes a schedule, and dependent records

Parameters

* schedule_id. Integer. The surrogate key for the schedule

Returns

* Void

get_dependencies

Returns the last of dependent jobs as specified by the "next" parameter in the application config.

Parameters

A hashref:

* config_dir. String. The directory where the configuration files
  are found
* config_file. String. The root config file
* section. The section on the config file that we wish to derive
  the dependencies from

Returns

* dependencies as an array