#################### main pod documentation begin ################### =head1 NAME Zymonic::Action::DeleteSupersetSource - Zymonic Workflow System Action module =head1 SYNOPSIS Deletes a Superset Source from the Superset Configuration. =head1 DESCRIPTION Deletes a Superset Source from the Superset Configuration. =head1 USAGE It is not expected that this class would be used directly - only called from the ZymonicSuperset.xml integration. The following ClassOption Schema should be used: =head1 BUGS NONE =head1 SUPPORT As in the license, Zymonic is provided without warranty or support unless purchased separately, however... If you email zymonic-support@zednax.com your issue will be noted and may receive a response. For security issues, please contact zymonic-security@zednax.com and someone will respond within 8 working hours. =head1 AUTHOR Alex Masidlover et al. CPAN ID: MODAUTHOR Zednax Limited alex.masidlover@zednax.com http://www.zednax.com =head1 COPYRIGHT This program is free software licensed under the... Zymonic Public License 1.0 The full text of the license can be found in the LICENSE file included with this module. Other licenses may be acceptable if including parts of Zymonic in larger projects, please contact Zednax for details. =head1 SEE ALSO Zymonic perl(1). =cut #################### main pod documentation end ################### package Zymonic::Action::DeleteSupersetSource; use strict; BEGIN { use Exporter (); use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $VERSION = '0.01'; @ISA = qw(Exporter); #Give a hoot don't pollute, do not export more than needed by default @EXPORT = qw(); @EXPORT_OK = qw(); %EXPORT_TAGS = (); } use base "Zymonic::Action"; use Zymonic; use Zymonic::Utils qw(get_array debug xml_escape debug_function_start debug_function_stop); use Zymonic; use Exception::Class ( 'Zymonic::Exception::Action::DeleteSupersetSource' => { isa => 'Zymonic::Exception::Action', fields => [], description => 'Problem with DeleteSupersetSource Action.' }, ); #################### subroutine header begin #################### =head2 init Usage : N/A Purpose : The init method is called by the object constructor to initialise the object fields. Returns : nothing Argument : nothing Throws : Zymonic::Exception::Action Comment : See Also : =cut #################### subroutine header end #################### sub init { my $self = shift; $self->SUPER::init(); } #################### subroutine header begin #################### =head2 filter Usage : $action->filter Purpose : Returns the filter Returns : See purpose Argument : nothing Throws : Comment : nothing =cut #################### subroutine header end #################### sub filter { my $self = shift; unless ( $self->{filter} ) { # Load the filter $self->{filter} = Zymonic::Filter->new( parent => $self, zname => $self->{filter_field_zname}, config => $self->{config}, DB => $self->{DB}, auth => $self->{auth}, ); } return $self->{filter}; } #################### subroutine header begin #################### =head2 do Usage : $action->do Purpose : Performs the action, i.e. sends a HTTP request Returns : nothing Argument : nothing Throws : Comment : nothing =cut #################### subroutine header end #################### sub do { my $self = shift; my $fake = shift || ''; my $no_display_attributes = shift || 0; my $result = $self->SUPER::do( $fake, $no_display_attributes ); $self->{filter_field_zname} = $self->static_or_field_value('Filter'); if ( $self->{success} && $self->{success} eq 'true' ) { $result->{success} = $self->{success} = 'false'; my $table_rec = $self->superset_db->run_query( { string => 'SELECT id FROM tables WHERE table_name = ?', params => [ $self->{filter_field_zname} ] } ); my $table_id = $table_rec->[0]->{id}; $self->superset_db->run_statement( { string => "DELETE FROM tables WHERE id = ?", params => [$table_id] } ); $self->superset_db->run_statement( { string => "DELETE FROM table_columns WHERE table_id = ?", params => [$table_id] } ); $self->{success} = 'true'; } $result->{success} = $self->{success}; return $result; } #################### subroutine header begin #################### =head2 superset_db Usage : $self->superset_db->run_query(...) Purpose : returns a Zymonic DB object connected to the superset sqlite DB Returns : see purpose Argument : nothing Throws : nothing Comment : See Also : =cut #################### subroutine header end #################### sub superset_db { my $self = shift; # get option # TODO permissions on SQLite DB file need to allow for apache access my $sqlitefile = $self->{config}->sys_opt('superset_sqlite'); $self->{superset_db} = Zymonic::DB->new( dbdriver => 'SQLite', driver_string => 'dbi:SQLite:dbname=' . $sqlitefile, ) unless $self->{superset_db}; return $self->{superset_db}; } 1;