lib/App/SeismicUnixGui/specs/migration/sudatumfd_spec.pm untested

filter: Statementstmt 0.0% 0 / 140 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 13 totaltotal 0.0% 0 / 184 CC 8 SCAR 14.7
CC
8
Cov
0%
get_binding_index_aref
6.0
get_binding_length
6.0
get_file_dialog_type_aref
6.0
CRAP 4.3
1 package App::SeismicUnixGui::specs::migration::sudatumfd_spec;
2 use Moose;
3 our $VERSION = '0.0.1';
4  
5 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
6 use App::SeismicUnixGui::misc::SeismicUnix
7 qw($bin $ps $segy $su $suffix_bin $suffix_ps $suffix_segy $suffix_su $suffix_txt $txt);
8 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
9  
10 my $get = L_SU_global_constants->new();
11 my $Project = Project_config->new();
12  
13 my $var = $get->var();
14  
15 my $empty_string = $var->{_empty_string};
16 my $true = $var->{_true};
17 my $false = $var->{_false};
18 my $file_dialog_type = $get->file_dialog_type_href();
19 my $flow_type = $get->flow_type_href();
20  
21 my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN();
22 my $DATA_SEISMIC_SEGY = $Project->DATA_SEISMIC_SEGY();
23 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); # output data directory
24 my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT(); # output data directory
25 my $PL_SEISMIC = $Project->PL_SEISMIC();
26 my $PS_SEISMIC = $Project->PS_SEISMIC();
27 my $max_index = 13;
28  
29 my $sudatumfd_spec = {
30 _CONFIG => $PL_SEISMIC,
31 _DATA_DIR_IN => $DATA_SEISMIC_BIN,
32 _DATA_DIR_OUT => $DATA_SEISMIC_SU,
33 _binding_index_aref => '',
34 _suffix_type_in => $su,
35 _data_suffix_in => $suffix_su,
36 _suffix_type_out => $su,
37 _data_suffix_out => $suffix_su,
38 _file_dialog_type_aref => '',
39 _flow_type_aref => '',
40 _has_infile => $true,
41 _has_outpar => $false,
42 _has_pipe_in => $true,
43 _has_pipe_out => $true,
44 _has_redirect_in => $true,
45 _has_redirect_out => $true,
46 _has_subin_in => $false,
47 _has_subin_out => $false,
48 _is_data => $false,
49 _is_first_of_2 => $true,
50 _is_first_of_3or_more => $true,
51 _is_first_of_4or_more => $true,
52 _is_last_of_2 => $false,
53 _is_last_of_3or_more => $false,
54 _is_last_of_4or_more => $false,
55 _is_suprog => $true,
56 _is_superflow => $false,
57 _max_index => $max_index,
58 _prefix_aref => '',
59 _suffix_aref => '',
60 };
61  
62 =head2 sub binding_index_aref
63  
64 =cut
65  
66 sub binding_index_aref {
67  
68 my $self = @_;
69  
70 my @index;
71  
72 # first binding index (index=0)
73 # connects to second item (index=1)
74 # in the parameter list
75 $index[0] = 11; # inbound item is bound
76 $index[1] = 12; # inbound item is bound
77  
78 # $index[2] = 8; # outbound item is bound
79  
80 $sudatumfd_spec->{_binding_index_aref} = \@index;
81 return ();
82  
83 }
84  
85 =head2 sub file_dialog_type_aref
86  
87 type of dialog (Data, Flow, SaveAs) is needed by binding
88 one type of dialog for each index
89 =cut
90  
91 sub file_dialog_type_aref {
92  
93 my $self = @_;
94  
95 my @type;
96  
97 my $index_aref = get_binding_index_aref();
98 my @index = @$index_aref;
99  
100 # bound index will look for data
101 # $type[0] = '';
102 $type[ $index[0] ] = $file_dialog_type->{_Data};
103 $type[ $index[1] ] = $file_dialog_type->{_Data};
104  
105 # $type[$index[2]] = $file_dialog_type->{_Data};
106  
107 $sudatumfd_spec->{_file_dialog_type_aref} = \@type;
108 return ();
109  
110 }
111  
112 =head2 sub flow_type_aref
113  
114 =cut
115  
116 sub flow_type_aref {
117  
118 my $self = @_;
119  
120 my @type;
121  
122 $type[0] = $flow_type->{_user_built};
123  
124 $sudatumfd_spec->{_flow_type_aref} = \@type;
125 return ();
126  
127 }
128  
129 =head2 sub get_binding_index_aref
130  
131 =cut
132  
133 sub get_binding_index_aref {
134  
135 my $self = @_;
136 my @index;
137  
138 if ( $sudatumfd_spec->{_binding_index_aref} ) {
139  
140 my $index_aref = $sudatumfd_spec->{_binding_index_aref};
141 return ($index_aref);
142  
143 }
144 else {
145 print(
146 "sudatumfd_spec, get_binding_index_aref, missing binding_index_aref\n"
147 );
148 return ();
149 }
150  
151 my $index_aref = $sudatumfd_spec->{_binding_index_aref};
152 }
153  
154 =head2 sub get_binding_length
155  
156 =cut
157  
158 sub get_binding_length {
159  
160 my $self = @_;
161  
162 if ( $sudatumfd_spec->{_binding_index_aref} ) {
163  
164 my $binding_length = scalar @{ $sudatumfd_spec->{_binding_index_aref} };
165 return ($binding_length);
166  
167 }
168 else {
169 print("sudatumfd_spec, get_binding_length, missing binding_length\n");
170 return ();
171 }
172  
173 return ();
174 }
175  
176 =head2 sub get_file_dialog_type_aref
177  
178 =cut
179  
180 sub get_file_dialog_type_aref {
181  
182 my $self = @_;
183 if ( $sudatumfd_spec->{_file_dialog_type_aref} ) {
184  
185 my $index_aref = $sudatumfd_spec->{_file_dialog_type_aref};
186 return ($index_aref);
187  
188 }
189 else {
190 print(
191 "sudatumfd_spec, get_file_dialog_type_aref, missing get_file_dialog_type_aref\n"
192 );
193 return ();
194 }
195  
196 return ();
197 }
198  
199 =head2 sub get_flow_type_aref
200  
201 =cut
202  
203 sub get_flow_type_aref {
204  
205 my $self = @_;
206  
207 if ( $sudatumfd_spec->{_flow_type_aref} ) {
208  
209 my $index_aref = $sudatumfd_spec->{_flow_type_aref};
210 return ($index_aref);
211  
212 }
213 else {
214 print("sudatumfd_spec, get_flow_type_aref, missing flow_type_aref\n");
215 return ();
216 }
217  
218 }
219  
220 =head2 sub get_incompatibles
221  
222 =cut
223  
224 sub get_incompatibles {
225  
226 my $self = @_;
227 my @needed;
228  
229 my @_need_both;
230  
231 my @_need_only_1;
232  
233 my @_none_needed;
234  
235 my @_all_needed;
236  
237 my $params = {
238  
239 _need_both => \@_need_both,
240 _need_only_1 => \@_need_only_1,
241 _none_needed => \@_none_needed,
242 _all_needed => \@_all_needed,
243  
244 };
245  
246 my @of_two = ( 'xx', 'yy' );
247 push @{ $params->{_need_only_1} }, \@of_two;
248  
249 my $len_1_needed = scalar @{ $params->{_need_only_1} };
250  
251 if ( $len_1_needed >= 1 ) {
252  
253 for ( my $i = 0 ; $i < $len_1_needed ; $i++ ) {
254  
255 print(
256 "sudatumfd, get_incompatibles,need_only_1: @{@{$params->{_need_only_1}}[$i]}\n"
257 );
258  
259 }
260  
261 }
262 else {
263 print("get_incompatibles, no incompatibles\n");
264 }
265  
266 return ($params);
267  
268 }
269  
270 =head2 sub get_prefix_aref
271  
272 =cut
273  
274 sub get_prefix_aref {
275  
276 my $self = @_;
277  
278 if ( $sudatumfd_spec->{_prefix_aref} ) {
279  
280 my $prefix_aref = $sudatumfd_spec->{_prefix_aref};
281 return ($prefix_aref);
282  
283 }
284 else {
285 print("sudatumfd_spec, get_prefix_aref, missing prefix_aref\n");
286 return ();
287 }
288  
289 return ();
290 }
291  
292 =head2 sub get_suffix_aref
293  
294 =cut
295  
296 sub get_suffix_aref {
297  
298 my $self = @_;
299  
300 if ( $sudatumfd_spec->{_suffix_aref} ) {
301  
302 my $suffix_aref = $sudatumfd_spec->{_suffix_aref};
303 return ($suffix_aref);
304  
305 }
306 else {
307 print("$sudatumfd_spec, get_suffix_aref, missing suffix_aref\n");
308 return ();
309 }
310  
311 return ();
312 }
313  
314 =head2 sub prefix_aref
315  
316 Include in the Set up
317 sections of an output Poop flow.
318  
319 prefixes and suffixes to parameter labels
320 are filtered by sunix_pl
321  
322 =cut
323  
324 sub prefix_aref {
325  
326 my $self = @_;
327  
328 my @prefix;
329  
330 for ( my $i = 0 ; $i < $max_index ; $i++ ) {
331  
332 $prefix[$i] = $empty_string;
333  
334 }
335  
336 my $index_aref = get_binding_index_aref();
337 my @index = @$index_aref;
338  
339 # label 2 in GUI is input xx_file and needs a home directory
340 $prefix[ $index[0] ] = '$DATA_SEISMIC_BIN' . ".'/'.";
341  
342 # label 3 in GUI is input yy_file and needs a home directory
343 $prefix[ $index[1] ] = '$DATA_SEISMIC_BIN' . ".'/'.";
344  
345 # label 9 in GUI is input zz_file and needs a home directory
346 # $prefix[ $index[2] ] = '$DATA_SEISMIC_SU' . ".'/'.";
347  
348 $sudatumfd_spec->{_prefix_aref} = \@prefix;
349 return ();
350  
351 }
352  
353 =head2 sub suffix_aref
354  
355 Initialize suffixes as empty
356 values
357  
358 =cut
359  
360 sub suffix_aref {
361  
362 my $self = @_;
363  
364 my @suffix;
365  
366 for ( my $i = 0 ; $i < $max_index ; $i++ ) {
367  
368 $suffix[$i] = $empty_string;
369  
370 }
371  
372 my $index_aref = get_binding_index_aref();
373 my @index = @$index_aref;
374  
375 # label 2 in GUI is input xx_file and needs a home directory
376 $suffix[ $index[0] ] = '' . '' . '$suffix_bin';
377  
378 # label 3 in GUI is input yy_file and needs a home directory
379 $suffix[ $index[1] ] = '' . '' . '$suffix_bin';
380  
381 # label 9 in GUI is output zz_file and needs a home directory
382 # $suffix[ $index[2] ] = ''.'' . '$suffix_su';
383  
384 $sudatumfd_spec->{_suffix_aref} = \@suffix;
385 return ();
386  
387 }
388  
389 =head2 sub variables
390  
391  
392 return a hash array
393 with definitions
394
395 =cut
396  
397 sub variables {
398  
399 my ($self) = @_;
400 my $hash_ref = $sudatumfd_spec;
401 return ($hash_ref);
402 }
403  
404 1;