« Document/Templates/Tools/Generate/Angular.pm
↑ Summary
Workflow/Activities/Tools/Generate/SQL.pm »
| 1 | package Daje::Database::Helper::TreeList; | ||||||||||||||||||||||
| 2 | 2 | ▶ | use Mojo::Base -base, -signatures, -async_await; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 3 | 2 | ▶ | use v5.42; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 4 | |||||||||||||||||||||||
| 5 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 6 | 2 | ▶ | use Scalar::Util qw{ reftype }; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 7 | |||||||||||||||||||||||
| 8 | 2 | ▶ | use Daje::Database::Model::ToolsProjects; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 9 | 2 | ▶ | use Daje::Database::View::VToolsVersion; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 10 | 2 | ▶ | use Daje::Database::View::VToolsObjects; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | 2 | ▶ | use Daje::Database::Model::ToolsObjectsTables; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 12 | 2 | ▶ | use Daje::Database::Model::ToolsObjectIndex; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 13 | 2 | ▶ | use Daje::Database::Model::ToolsObjectSQL; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 14 | 2 | ▶ | use Daje::Database::Model::ToolsObjectViews; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | 2 | has 'db'; | |||||||||||||||||||||
| 17 | |||||||||||||||||||||||
| 18 | 0 | ▶ | async sub load_treelist($self, $tools_projects_pkey) { | ||||||||||||||||||||
|
Subroutine
load_treelist: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||
| 19 | |||||||||||||||||||||||
| 20 | 0 | my $treelist; | |||||||||||||||||||||
| 21 | 0 | my $objects = $self->_load_objects_from_project($tools_projects_pkey); | |||||||||||||||||||||
| 22 | 0 | my $length = scalar @{$objects->{data}}; | |||||||||||||||||||||
| 23 | 0 | ▶ | for (my $i = 0; $i < $length; $i++) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 24 | my $node = $self->_add_objects( | ||||||||||||||||||||||
| 25 | 0 | @{$objects->{data}}[$i], 'tools_objects' | |||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||
| 27 | |||||||||||||||||||||||
| 28 | 0 | ▶ | if(@{$objects->{data}}[$i]->{tools_object_types_fkey} == 1) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 29 | $node = $self->_add_tools_object_tables( | ||||||||||||||||||||||
| 30 | 0 | $node, @{$objects->{data}}[$i]->{tools_objects_pkey} | |||||||||||||||||||||
| 31 | 0 | ); | |||||||||||||||||||||
| 32 | 0 | } elsif (@{$objects->{data}}[$i]->{tools_object_types_fkey} == 2) { | |||||||||||||||||||||
| 33 | $node = $self->_add_tools_object_indexes( | ||||||||||||||||||||||
| 34 | 0 | $node, @{$objects->{data}}[$i]->{tools_objects_pkey} | |||||||||||||||||||||
| 35 | 0 | ); | |||||||||||||||||||||
| 36 | 0 | } elsif (@{$objects->{data}}[$i]->{tools_object_types_fkey} == 3) { | |||||||||||||||||||||
| 37 | $node = $self->_add_tools_object_sql( | ||||||||||||||||||||||
| 38 | 0 | $node, @{$objects->{data}}[$i]->{tools_objects_pkey} | |||||||||||||||||||||
| 39 | 0 | ); | |||||||||||||||||||||
| 40 | 0 | } elsif (@{$objects->{data}}[$i]->{tools_object_types_fkey} == 4) { | |||||||||||||||||||||
| 41 | $node = $self->_add_tools_object_views( | ||||||||||||||||||||||
| 42 | 0 | $node, @{$objects->{data}}[$i]->{tools_objects_pkey} | |||||||||||||||||||||
| 43 | 0 | ); | |||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||
| 45 | 0 | push (@{$treelist->{data}}, $node); | |||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||
| 47 | |||||||||||||||||||||||
| 48 | 0 | return $treelist; | |||||||||||||||||||||
| 49 | 2 | } | |||||||||||||||||||||
| 50 | |||||||||||||||||||||||
| 51 | 0 | ▶ | sub _add_tools_object_views($self, $node, $tools_objects_fkey) { | ||||||||||||||||||||
|
Subroutine
_add_tools_object_views: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||
| 52 | 0 | my $objects_view = $self->_load_tools_object_view($tools_objects_fkey); | |||||||||||||||||||||
| 53 | |||||||||||||||||||||||
| 54 | 0 | ▶ | if($objects_view->{result} > 0) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 55 | 0 | my $length = scalar @{$objects_view->{data}}; | |||||||||||||||||||||
| 56 | 0 | ▶ | for (my $i = 0; $i < $length; $i++) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 57 | 0 | my $res->{id} = @{$objects_view->{data}}[$i]->{tools_object_view_pkey} . "-tools_object_view"; | |||||||||||||||||||||
| 58 | 0 | $res->{label} = @{$objects_view->{data}}[$i]->{name}; | |||||||||||||||||||||
| 59 | 0 | $res->{data} = @{$objects_view->{data}}[$i]; | |||||||||||||||||||||
| 60 | 0 | $res->{icon} = 'pi pi-fw pi-tablet'; | |||||||||||||||||||||
| 61 | 0 | $res->{children} = []; | |||||||||||||||||||||
| 62 | 0 | push(@{$node->{children}}, $res); | |||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||
| 65 | 0 | return $node; | |||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||
| 67 | |||||||||||||||||||||||
| 68 | 0 | ▶ | sub _add_tools_object_sql($self, $node, $tools_objects_fkey) { | ||||||||||||||||||||
|
Subroutine
_add_tools_object_sql: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||
| 69 | 0 | my $objects_sql = $self->_load_tools_object_sql($tools_objects_fkey); | |||||||||||||||||||||
| 70 | 0 | ▶ | if($objects_sql->{result} > 0) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 71 | 0 | my $length = scalar @{$objects_sql->{data}}; | |||||||||||||||||||||
| 72 | 0 | ▶ | for (my $i = 0; $i < $length; $i++) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 73 | 0 | my $res->{id} = @{$objects_sql->{data}}[$i]->{tools_object_sql_pkey} . "-tools_object_sql"; | |||||||||||||||||||||
| 74 | 0 | $res->{label} = @{$objects_sql->{data}}[$i]->{name}; | |||||||||||||||||||||
| 75 | 0 | $res->{data} = @{$objects_sql->{data}}[$i]; | |||||||||||||||||||||
| 76 | 0 | $res->{icon} = 'pi pi-fw pi-wrench'; | |||||||||||||||||||||
| 77 | 0 | $res->{children} = []; | |||||||||||||||||||||
| 78 | 0 | push(@{$node->{children}}, $res); | |||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||
| 81 | 0 | return $node; | |||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||
| 83 | |||||||||||||||||||||||
| 84 | 0 | ▶ | sub _add_tools_object_indexes($self, $node, $tools_objects_fkey) { | ||||||||||||||||||||
|
Subroutine
_add_tools_object_indexes: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||
| 85 | 0 | my $objects_index = $self->_load_tools_object_indexes($tools_objects_fkey); | |||||||||||||||||||||
| 86 | |||||||||||||||||||||||
| 87 | 0 | ▶ | if($objects_index->{result} > 0) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 88 | 0 | my $length = scalar @{$objects_index->{data}}; | |||||||||||||||||||||
| 89 | 0 | ▶ | for (my $i = 0; $i < $length; $i++) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 90 | 0 | my $res->{id} = @{$objects_index->{data}}[$i]->{tools_object_index_pkey} . "-tools_object_index"; | |||||||||||||||||||||
| 91 | 0 | $res->{label} = @{$objects_index->{data}}[$i]->{table_name}; | |||||||||||||||||||||
| 92 | 0 | $res->{data} = @{$objects_index->{data}}[$i]; | |||||||||||||||||||||
| 93 | 0 | $res->{icon} = 'pi pi-fw pi-forward'; | |||||||||||||||||||||
| 94 | 0 | $res->{children} = []; | |||||||||||||||||||||
| 95 | 0 | push(@{$node->{children}}, $res); | |||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||
| 98 | 0 | return $node; | |||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||
| 100 | |||||||||||||||||||||||
| 101 | 0 | ▶ | sub _add_tools_object_tables($self, $node, $tools_objects_fkey) { | ||||||||||||||||||||
|
Subroutine
_add_tools_object_tables: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||
| 102 | 0 | my $objects_tables = $self->_load_tools_object_tables($tools_objects_fkey); | |||||||||||||||||||||
| 103 | |||||||||||||||||||||||
| 104 | 0 | ▶ | if($objects_tables->{result} > 0) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 105 | 0 | my $length = scalar @{$objects_tables->{data}}; | |||||||||||||||||||||
| 106 | 0 | ▶ | for (my $i = 0; $i < $length; $i++) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 107 | 0 | my $res->{id} = @{$objects_tables->{data}}[$i]->{tools_object_tables_pkey} . "-tools_object_tables"; | |||||||||||||||||||||
| 108 | 0 | $res->{label} = @{$objects_tables->{data}}[$i]->{fieldname}; | |||||||||||||||||||||
| 109 | 0 | $res->{data} = @{$objects_tables->{data}}[$i]; | |||||||||||||||||||||
| 110 | 0 | $res->{icon} = 'pi pi-fw pi-sliders-h'; | |||||||||||||||||||||
| 111 | 0 | $res->{children} = []; | |||||||||||||||||||||
| 112 | 0 | push(@{$node->{children}}, $res); | |||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||
| 115 | 0 | return $node; | |||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||
| 117 | 0 | ▶ | sub _load_tools_object_view($self, $tools_objects_fkey) { | ||||||||||||||||||||
|
Subroutine
_load_tools_object_view: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 118 | 0 | return Daje::Database::Model::ToolsObjectViews->new( | |||||||||||||||||||||
| 119 | db => $self->db | ||||||||||||||||||||||
| 120 | )->load_tools_objects_views_fkey('tools_objects_fkey', $tools_objects_fkey); | ||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||
| 122 | |||||||||||||||||||||||
| 123 | 0 | ▶ | sub _load_tools_object_sql($self, $tools_objects_fkey) { | ||||||||||||||||||||
|
Subroutine
_load_tools_object_sql: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 124 | 0 | return Daje::Database::Model::ToolsObjectSQL->new( | |||||||||||||||||||||
| 125 | db => $self->db | ||||||||||||||||||||||
| 126 | )->load_tools_objects_sql_fkey('tools_objects_fkey', $tools_objects_fkey); | ||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||
| 128 | |||||||||||||||||||||||
| 129 | 0 | ▶ | sub _load_tools_object_indexes($self, $tools_objects_fkey) { | ||||||||||||||||||||
|
Subroutine
_load_tools_object_indexes: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 130 | 0 | return Daje::Database::Model::ToolsObjectIndex->new( | |||||||||||||||||||||
| 131 | db => $self->db | ||||||||||||||||||||||
| 132 | )->load_tools_objects_index_fkey('tools_objects_fkey', $tools_objects_fkey); | ||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||
| 134 | |||||||||||||||||||||||
| 135 | 0 | ▶ | sub _load_tools_object_tables($self, $tools_objects_fkey) { | ||||||||||||||||||||
|
Subroutine
_load_tools_object_tables: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 136 | 0 | return Daje::Database::Model::ToolsObjectsTables->new( | |||||||||||||||||||||
| 137 | db => $self->db | ||||||||||||||||||||||
| 138 | )->load_tools_objects_tables_fkey($tools_objects_fkey); | ||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||
| 140 | |||||||||||||||||||||||
| 141 | 0 | ▶ | sub _load_objects_from_project($self, $tools_projects_pkey) { | ||||||||||||||||||||
|
Subroutine
_load_objects_from_project: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 142 | 0 | return Daje::Database::View::VToolsObjects->new( | |||||||||||||||||||||
| 143 | db => $self->db | ||||||||||||||||||||||
| 144 | )->load_tools_objects_fkey('tools_projects_fkey', $tools_projects_pkey); | ||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||
| 146 | |||||||||||||||||||||||
| 147 | 0 | ▶ | sub _load_objects($self, $tools_versions_pkey) { | ||||||||||||||||||||
|
Subroutine
_load_objects: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 148 | 0 | return Daje::Database::View::VToolsObjects->new( | |||||||||||||||||||||
| 149 | db => $self->db | ||||||||||||||||||||||
| 150 | )->load_tools_objects_fkey('tools_versions_fkey', $tools_versions_pkey); | ||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||
| 152 | |||||||||||||||||||||||
| 153 | 0 | ▶ | sub _add_objects($self, $data, $type ) { | ||||||||||||||||||||
|
Subroutine
_add_objects: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||
| 154 | |||||||||||||||||||||||
| 155 | 0 | my $res->{id} = $data->{tools_objects_pkey} . "-" . $type; | |||||||||||||||||||||
| 156 | 0 | $res->{label} = $data->{name} ; | |||||||||||||||||||||
| 157 | 0 | $res->{data} = $data ; | |||||||||||||||||||||
| 158 | 0 | ▶ | if($data->{tools_object_types_fkey} == 1) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 159 | 0 | $res->{icon} = 'pi pi-fw pi-envelope'; | |||||||||||||||||||||
| 160 | } elsif ($data->{tools_object_types_fkey} == 2) { | ||||||||||||||||||||||
| 161 | 0 | $res->{icon} = 'pi pi-fw pi-arrow-up'; | |||||||||||||||||||||
| 162 | } elsif ($data->{tools_object_types_fkey} == 3) { | ||||||||||||||||||||||
| 163 | 0 | $res->{icon} = 'pi pi-fw pi-sort-alpha-up'; | |||||||||||||||||||||
| 164 | } elsif ($data->{tools_object_types_fkey} == 4) { | ||||||||||||||||||||||
| 165 | 0 | $res->{icon} = 'pi pi-fw pi-tags'; | |||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||
| 167 | 0 | $res->{children} = []; | |||||||||||||||||||||
| 168 | |||||||||||||||||||||||
| 169 | |||||||||||||||||||||||
| 170 | 0 | return $res; | |||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||
| 172 | |||||||||||||||||||||||
| 173 | 0 | ▶ | sub _load_versions($self, $tools_projects_pkey) { | ||||||||||||||||||||
|
Subroutine
_load_versions: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 174 | 0 | return Daje::Database::View::VToolsVersion->new( | |||||||||||||||||||||
| 175 | db => $self->db | ||||||||||||||||||||||
| 176 | )->load_tools_version_fkey($tools_projects_pkey) | ||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||
| 178 | |||||||||||||||||||||||
| 179 | 0 | ▶ | sub _load_project($self, $tools_projects_pkey) { | ||||||||||||||||||||
|
Subroutine
_load_project: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||
| 180 | |||||||||||||||||||||||
| 181 | 0 | return Daje::Database::Model::ToolsProjects->new( | |||||||||||||||||||||
| 182 | db => $self->db | ||||||||||||||||||||||
| 183 | )->load_pkey( | ||||||||||||||||||||||
| 184 | $tools_projects_pkey | ||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||
| 187 | 2 | 1; | |||||||||||||||||||||
| 188 | #################### pod generated by Pod::Autopod - keep this line to make pod updates possible #################### | ||||||||||||||||||||||
| 189 | |||||||||||||||||||||||
| 190 | =head1 NAME | ||||||||||||||||||||||
| 191 | |||||||||||||||||||||||
| 192 | Daje::Database::Helper::TreeList | ||||||||||||||||||||||
| 193 | |||||||||||||||||||||||
| 194 | |||||||||||||||||||||||
| 195 | =head1 REQUIRES | ||||||||||||||||||||||
| 196 | |||||||||||||||||||||||
| 197 | L<Daje::Database::Model::ToolsObjectViews> | ||||||||||||||||||||||
| 198 | |||||||||||||||||||||||
| 199 | L<Daje::Database::Model::ToolsObjectSQL> | ||||||||||||||||||||||
| 200 | |||||||||||||||||||||||
| 201 | L<Daje::Database::Model::ToolsObjectIndex> | ||||||||||||||||||||||
| 202 | |||||||||||||||||||||||
| 203 | L<Daje::Database::Model::ToolsObjectsTables> | ||||||||||||||||||||||
| 204 | |||||||||||||||||||||||
| 205 | L<Daje::Database::View::VToolsObjects> | ||||||||||||||||||||||
| 206 | |||||||||||||||||||||||
| 207 | L<Daje::Database::View::VToolsVersion> | ||||||||||||||||||||||
| 208 | |||||||||||||||||||||||
| 209 | L<Daje::Database::Model::ToolsProjects> | ||||||||||||||||||||||
| 210 | |||||||||||||||||||||||
| 211 | L<Scalar::Util> | ||||||||||||||||||||||
| 212 | |||||||||||||||||||||||
| 213 | L<Data::Dumper> | ||||||||||||||||||||||
| 214 | |||||||||||||||||||||||
| 215 | L<v5.42> | ||||||||||||||||||||||
| 216 | |||||||||||||||||||||||
| 217 | L<Mojo::Base> | ||||||||||||||||||||||
| 218 | |||||||||||||||||||||||
| 219 | |||||||||||||||||||||||
| 220 | =head1 METHODS | ||||||||||||||||||||||
| 221 | |||||||||||||||||||||||
| 222 | |||||||||||||||||||||||
| 223 | =cut | ||||||||||||||||||||||
| 224 | |||||||||||||||||||||||