package Daje::Workflow::GenerateSQL::Activity;
use Mojo::Base 'Daje::Workflow::Common::Activity::Base', -base, -signatures;


# NAME
# ====
##
# Daje::Workflow::GenerateSQL::Activity - It's to generate SQL from a json description
#
# SYNOPSIS
# ========
##
#     use Daje::Workflow::GenerateSQL::Activity;
#
#     my $object = $activity->{activity}->new(
#             context       => $context,
#             db            => $>db,
#             error         => $error,
#             model         => $model,
#             activity_data => $activity_data,
#         );
#
#     $object->process();
#
# DESCRIPTION
# ===========
##
# Daje::Workflow::GenerateSQL::Activity is ...
#
# LICENSE
# =======
#
# Copyright (C) janeskil1525.
#
# This library is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
# AUTHOR
# ======
#
# janeskil1525 E<lt>janeskil1525@gmail.comE<gt>
#



our $VERSION = "0.01";



# use Daje::Generate::Input::Sql::ConfigManager;

use Daje::Workflow::GenerateSQL::Manager::Sql;
# use Daje::Generate::Output::Sql::Table;
use Daje::Tools::Datasections;
use Config::Tiny;

has 'config_manager';

sub process ($self) {

    my $files_list = $self->context->{context}->{changed_files};
    my $length = scalar @{$files_list};
    for (my $i = 0; $i < $length; $i++) {
        if ($self->_process_sql(@{$files_list}[$i])) {
            #$self->config_manager->save_new_hash(@{$files_list}[$i]);
        }
    }

    return;
}

sub _process_sql($self, $file) {
     my $sql = "";
#     try {
#         my $table = $self->_load_table($file);
#         $table->generate_table();
#         $sql = $table->sql();
#     } catch ($e) {
#         die "Create sql failed '$e'";
#     };
#
#     try {
#         Daje::Generate::Output::Sql::SqlManager->new(
#             config => $self->config,
#             file   => $file,
#             sql    => $sql,
#         )->save_file();
#     } catch ($e) {
#         die "Could not create output '$e'";
#     };
#
     return 1;
}

sub _load_table($self, $file) {

    # my $json = $self->config_manager->load_json($file);
    # my $template = $self->_load_templates(
    #     'Daje::Generate::Templates::Sql',
    #     "table,foreign_key,index,section,file"
    # );
    # my $table;
    # try {
    #     $table = Daje::Workflow::GenerateSQL::Manager::Sql::SqlManager->new(
    #         template => $template,
    #         json     => $json,
    #     );
    # } catch ($e) {
    #     die "process_sql failed '$e";
    # };
    #
    # return $table;
}





1;
__END__




#################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################

=head1 NAME


Daje::Workflow::GenerateSQL::Activity - It's to generate SQL from a json description



=head1 SYNOPSIS


    use Daje::Workflow::GenerateSQL::Activity;

    my $object = $activity->{activity}->new(
            context       => $context,
            db            => $>db,
            error         => $error,
            model         => $model,
            activity_data => $activity_data,
        );

    $object->process();



=head1 DESCRIPTION


Daje::Workflow::GenerateSQL::Activity is ...



=head1 REQUIRES

L<Config::Tiny> 

L<Daje::Tools::Datasections> 

L<Daje::Workflow::GenerateSQL::Manager::Sql> 

L<Mojo::Base> 


=head1 METHODS

=head2 process

 process();


=head1 AUTHOR


janeskil1525 E<lt>janeskil1525@gmail.comE<gt>



=head1 LICENSE


Copyright (C) janeskil1525.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.



=cut

