Workflow/Activities/Tools/Generate/Base.pm untested

filter: Statementstmt 0.0% 0 / 96 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 126 CC 3 SCAR 10.4
CC
3
Cov
0%
process_table
6.0
load_active_table_fields
6.0
build_documents
2.0
CRAP 2.8
1 package Daje::Workflow::Activities::Tools::Generate::Base;
2 use Mojo::Base 'Daje::Workflow::Common::Activity::Base', -base, -signatures;
3 use v5.42;
4  
5 # NAME
6 # ====
7 #
8 # Daje::Workflow::Activities::Tools::Generate::Base - Base class fro generate activities
9 #
10 # SYNOPSIS
11 # ========
12 #
13 # use Daje::Workflow::Activities::Tools::Generate::Base
14 #
15 # DESCRIPTION
16 # ===========
17 #
18 # Daje::Workflow::Activities::Tools::Generate::Base is a base class holding common methods
19 #
20 # LICENSE
21 # =======
22 #
23 # Copyright (C) janeskil1525.
24 #
25 # This library is free software; you can redistribute it and/or modify
26 # it under the same terms as Perl itself.
27 #
28 # AUTHOR
29 # ======
30 #
31 # janeskil1525 E<lt>janeskil1525@gmail.comE<gt>
32 #
33  
34 use Daje::Database::View::VToolsParameterValues;
35 use Daje::Database::Helper::LoadParameters;
36 use Daje::Document::Builder;
37 use Daje::Database::Model::ToolsProjects;
38 use Daje::Database::View::VToolsObjectsActive;
39 use Daje::Database::View::VToolsObjectsTablesActive;;
40  
41 has 'versions';
42 has 'tables';
43 has 'parameters';
44  
45  
46 sub build_documents ($self, $source, $data_sections) {
47  
48 my $builder = Daje::Document::Builder->new(
49 source => $source,
50 data_sections => $data_sections,
51 data => $self->versions(),
52 error => $self->error()
53 );
54  
55 $builder->process();
56  
57 return $builder->output();
58 }
59  
60 sub get_parameter($self, $group, $parameter, $tools_projects_pkey) {
61 my $param = Daje::Database::Helper::LoadParameters->new(
62 db => $self->db
63 );
64 my $result = $param->load_parameter(
65 $group, $parameter, $tools_projects_pkey
66 );
67  
68 return $param->parameters->{value};
69 }
70  
71 sub load_project_name($self,$tools_projects_pkey) {
72 return Daje::Database::Model::ToolsProjects->new(
73 db => $self->db
74 )->load_pkey(
75 $tools_projects_pkey
76 )->{data}->{name};
77 }
78  
79 sub process_table($self, $table, $tools_version) {
80 my $fields = Daje::Database::View::VToolsObjectsTables->new(
81 db => $self->db
82 )->load_objects_tables(
83 $table->{tools_objects_pkey}, $tools_version->{tools_version_pkey}
84 );
85 my $arr = [];
86 my $fieldarray = $fields->{data};
87 my $test = ref($fieldarray);
88 if(ref($fieldarray) ne 'ARRAY') {
89 $fieldarray->each(sub($e, $num) {
90 push @{$arr}, $e;
91 });
92 }
93  
94 $table->{fields} = $arr;
95 return $table;
96 }
97  
98 sub load_active_table_fields($self, $tools_objects_pkey) {
99 my $fields = Daje::Database::View::VToolsObjectsTablesActive->new(
100 db => $self->db
101 )->load_objects_tables_active(
102 $tools_objects_pkey
103 );
104 my $arr = [];
105 my $fieldarray = $fields->{data};
106 my $test = ref($fieldarray);
107 if(ref($fieldarray) ne 'ARRAY') {
108 $fieldarray->each(sub($e, $num) {
109 push @{$arr}, $e;
110 });
111 }
112 return $arr;
113 }
114  
115 sub load_active_tables($self, $tools_projects_pkey) {
116 my $objects = Daje::Database::View::VToolsObjectsActive->new(
117 db => $self->db
118 )->load_tools_objects_active(
119 $tools_projects_pkey
120 );
121  
122 my $tables = $objects->{data};
123 my $length = scalar @{$tables};
124 for(my $i = 0; $i < $length; $i++) {
125 @{$tables}[$i]->{table_name} = @{$tables}[$i]->{name};
126 delete @{$tables}[$i]->{name};
127 }
128 $self->tables($tables);
129 return $objects->{result};
130 }
131  
132 sub load_tables($self, $tools_projects_pkey, $tools_version_pkey) {
133 my $objects = $self->load_objects_from_type(1, $tools_projects_pkey,$tools_version_pkey);
134  
135 my $tables = $objects->{data};
136 my $length = scalar @{$tables};
137 for(my $i = 0; $i < $length; $i++) {
138 @{$tables}[$i]->{table_name} = @{$tables}[$i]->{name};
139 delete @{$tables}[$i]->{name};
140 }
141 $self->tables($tables);
142 return $objects->{result};
143 }
144  
145 sub load_versions($self, $tools_projects_pkey) {
146 my $versions = Daje::Database::View::VToolsVersion->new(
147 db => $self->db
148 )->load_tools_version_fkey(
149 $tools_projects_pkey
150 );
151 $self->versions($versions->{data});
152 return $versions->{result};
153 }
154  
155  
156 sub load_objects_from_type($self, $type, $tools_projects_pkey, $tools_version_pkey) {
157 my $objects = Daje::Database::View::VToolsObjectsTypes->new(
158 db => $self->db
159 )->load_objects_type(
160 $type,$tools_projects_pkey,$tools_version_pkey
161 );
162  
163 return $objects;
164 }
165 1;
166 #################### pod generated by Pod::Autopod - keep this line to make pod updates possible ####################
167  
168 =head1 NAME
169  
170  
171 Daje::Workflow::Activities::Tools::Generate::Base - Base class fro generate activities
172  
173  
174  
175 =head1 SYNOPSIS
176  
177  
178 use Daje::Workflow::Activities::Tools::Generate::Base
179  
180  
181  
182 =head1 DESCRIPTION
183  
184  
185 Daje::Workflow::Activities::Tools::Generate::Base is a base class holding common methods
186  
187  
188  
189 =head1 REQUIRES
190  
191 L<Daje::Database::Helper::LoadParameters>
192  
193 L<Daje::Database::View::VToolsObjectsTables>
194  
195 L<Daje::Database::View::VToolsObjectsTypes>
196  
197 L<Daje::Database::View::VToolsVersion>
198  
199 L<Daje::Database::Model::ToolsProjects>
200  
201 L<Daje::Database::View::VToolsParameterValues>
202  
203 L<v5.42>
204  
205 L<Mojo::Base>
206  
207  
208 =head1 METHODS
209  
210 =head2 get_parameter($self,
211  
212 get_parameter($self,();
213  
214 =head2 load_generate_data($self,
215  
216 load_generate_data($self,();
217  
218 =head2 load_project_name($self,$tools_projects_pkey)
219  
220 load_project_name($self,$tools_projects_pkey)();
221  
222 =head2 load_tables($self,
223  
224 load_tables($self,();
225  
226 =head2 load_versions($self,
227  
228 load_versions($self,();
229  
230 =head2 process_table($self,
231  
232 process_table($self,();
233  
234  
235 =head1 AUTHOR
236  
237  
238 janeskil1525 E<lt>janeskil1525@gmail.comE<gt>
239  
240  
241  
242 =head1 LICENSE
243  
244  
245 Copyright (C) janeskil1525.
246  
247 This library is free software; you can redistribute it and/or modify
248 it under the same terms as Perl itself.
249  
250  
251  
252 =cut
253