App-Dochazka-REST
view release on metacpan or search on metacpan
lib/App/Dochazka/REST/Dispatch.pm view on Meta::CPAN
# *************************************************************************
# ------------------------
# Top-level resources
# ------------------------
package App::Dochazka::REST::Dispatch;
use strict;
use warnings;
use App::CELL qw( $CELL $log $core $meta $site );
use App::Dochazka::Common qw( $today init_timepiece );
use App::Dochazka::REST;
use App::Dochazka::REST::ACL qw(
check_acl_context
acl_check_is_me
acl_check_is_my_report
);
use App::Dochazka::REST::ConnBank qw( $dbix_conn conn_status );
use App::Dochazka::REST::Fillup;
use App::Dochazka::REST::LDAP qw( ldap_exists );
use App::Dochazka::REST::Model::Activity;
use App::Dochazka::REST::Model::Component qw( get_all_components );
use App::Dochazka::REST::Model::Employee qw(
list_employees_by_priv
noof_employees_by_priv
);
use App::Dochazka::REST::Model::Interval qw(
delete_intervals_by_eid_and_tsrange
fetch_intervals_by_eid_and_tsrange
generate_interval_summary
);
use App::Dochazka::REST::Model::Lock qw(
fetch_locks_by_eid_and_tsrange
);
use App::Dochazka::REST::Model::Privhistory qw( get_privhistory );
use App::Dochazka::REST::Model::Schedhistory qw( get_schedhistory );
use App::Dochazka::REST::Model::Schedintvls;
use App::Dochazka::REST::Model::Schedule qw( get_all_schedules );
use App::Dochazka::REST::Model::Shared qw(
canonicalize_date
canonicalize_tsrange
load_multiple
priv_by_eid
schedule_by_eid
select_set_of_single_scalar_rows
split_tsrange
timestamp_delta_plus
);
use App::Dochazka::REST::ResourceDefs;
use App::Dochazka::REST::Shared qw( :ALL ); # all the shared_* functions
use App::Dochazka::REST::Holiday qw(
holidays_and_weekends
holidays_in_daterange
);
use Data::Dumper;
use File::Path qw( mkpath rmtree );
use Module::Runtime qw( use_module );
use Params::Validate qw( :all );
use Try::Tiny;
use Web::MREST::InitRouter qw( $router $resources );
use Web::MREST::Util qw( pod_to_html pod_to_text );
use parent 'App::Dochazka::REST::Auth';
=head1 NAME
App::Dochazka::REST::Dispatch - Implementation of top-level resources
=head1 DESCRIPTION
This module contains the C<init_router> method as well as all the resource
handlers referred to in the resource definitions.
=head1 PACKAGE VARIABLES
This module uses some package variables, which are essentially constants, to do
its work.
=cut
my $fail = $CELL->status_not_ok;
my %iue_dispatch = (
'insert_employee' => \&shared_insert_employee,
'update_employee' => \&shared_update_employee,
);
=head1 FUNCTIONS
=cut
=head2 init
This function is called by C<bin/mrest>.
=cut
sub init {
$log->debug("Entering " . __PACKAGE__. "::init");
App::Dochazka::REST::ConnBank::init_singleton();
my $status = App::Dochazka::REST::reset_mason_dir();
return $status unless $status->ok;
my $comp_root = $status->payload;
# get Mason components from database and write them to filesystem
$status = get_all_components( $dbix_conn );
if ( $status->ok and $status->code eq 'DISPATCH_RECORDS_FOUND' ) {
foreach my $comp ( @{ $status->payload } ) {
$comp->create_file;
( run in 0.811 second using v1.01-cache-2.11-cpan-39bf76dae61 )