View | Details | Raw Unified | Return to bug 10523
Collapse All | Expand All

(-)a/C4/Installer.pm (-57 / +2 lines)
Lines 34-40 C4::Installer Link Here
34
 my $installer = C4::Installer->new();
34
 my $installer = C4::Installer->new();
35
 my $all_languages = getAllLanguages();
35
 my $all_languages = getAllLanguages();
36
 my $error = $installer->load_db_schema();
36
 my $error = $installer->load_db_schema();
37
 my $list = $installer->sql_file_list('en', 'marc21', { optional => 1, mandatory => 1 });
37
 my $list;
38
 #fill $list with list of sql files
38
 my ($fwk_language, $error_list) = $installer->load_sql_in_order($all_languages, @$list);
39
 my ($fwk_language, $error_list) = $installer->load_sql_in_order($all_languages, @$list);
39
 $installer->set_version_syspref();
40
 $installer->set_version_syspref();
40
 $installer->set_marcflavour_syspref('MARC21');
41
 $installer->set_marcflavour_syspref('MARC21');
Lines 77-103 sub new { Link Here
77
    return $self;
78
    return $self;
78
}
79
}
79
80
80
=head2 marcflavour_list
81
82
  my ($marcflavours) = $installer->marcflavour_list($lang);
83
84
Return a arrayref of the MARC flavour sets available for the
85
specified language C<$lang>.  Returns 'undef' if a directory
86
for the language does not exist.
87
88
=cut
89
90
sub marcflavour_list {
91
    my $self = shift;
92
    my $lang = shift;
93
94
    my $dir = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}/$lang/marcflavour";
95
    opendir(MYDIR, $dir) or return;
96
    my @list = grep { !/^\.|CVS/ && -d "$dir/$_" } readdir(MYDIR);
97
    closedir MYDIR;
98
    return \@list;
99
}
100
101
=head2 marc_framework_sql_list
81
=head2 marc_framework_sql_list
102
82
103
  my ($defaulted_to_en, $list) = 
83
  my ($defaulted_to_en, $list) = 
Lines 257-297 sub sample_data_sql_list { Link Here
257
    return ($defaulted_to_en, \@levellist);
237
    return ($defaulted_to_en, \@levellist);
258
}
238
}
259
239
260
=head2 sql_file_list
261
262
  my $list = $installer->sql_file_list($lang, $marcflavour, $subset_wanted);
263
264
Returns an arrayref containing the filepaths of installer SQL scripts
265
available for laod.  The C<$lang> and C<$marcflavour> arguments
266
specify the desired language and MARC flavour. while C<$subset_wanted>
267
is a hashref containing possible named parameters 'mandatory' and 'optional'.
268
269
=cut
270
271
sub sql_file_list {
272
    my $self = shift;
273
    my $lang = shift;
274
    my $marcflavour = shift;
275
    my $subset_wanted = shift;
276
277
    my ($marc_defaulted_to_en, $marc_sql) = $self->marc_framework_sql_list($lang, $marcflavour);
278
    my ($sample_defaulted_to_en, $sample_sql) = $self->sample_data_sql_list($lang);
279
280
    my @sql_list = ();
281
    map {
282
        map {
283
            if ($subset_wanted->{'mandatory'}) {
284
                push @sql_list, $_->{'fwkfile'} if $_->{'mandatory'};
285
            }
286
            if ($subset_wanted->{'optional'}) {
287
                push @sql_list, $_->{'fwkfile'} unless $_->{'mandatory'};
288
            }
289
        } @{ $_->{'frameworks'} }
290
    } (@$marc_sql, @$sample_sql);
291
292
    return \@sql_list
293
}
294
295
=head2 load_db_schema
240
=head2 load_db_schema
296
241
297
  my $error = $installer->load_db_schema();
242
  my $error = $installer->load_db_schema();
(-)a/installer/install.pl (-1 / +1 lines)
Lines 241-247 elsif ( $step && $step == 3 ) { Link Here
241
        $template->param( "frameworksloop" => $fwklist );
241
        $template->param( "frameworksloop" => $fwklist );
242
        $template->param( "marcflavour" => ucfirst($marcflavour));
242
        $template->param( "marcflavour" => ucfirst($marcflavour));
243
243
244
        my ($sample_defaulted_to_en, $levellist) = $installer->sample_data_sql_list($langchoice, $marcflavour);
244
        my ($sample_defaulted_to_en, $levellist) = $installer->sample_data_sql_list($langchoice);
245
        $template->param( "en_sample_data" => $sample_defaulted_to_en);
245
        $template->param( "en_sample_data" => $sample_defaulted_to_en);
246
        $template->param( "levelloop" => $levellist );
246
        $template->param( "levelloop" => $levellist );
247
        $template->param( "$op"       => 1 );
247
        $template->param( "$op"       => 1 );
(-)a/t/db_dependent/lib/KohaTest.pm (-2 / +3 lines)
Lines 716-723 sub create_test_database { Link Here
716
    my $all_languages = getAllLanguages();
716
    my $all_languages = getAllLanguages();
717
    my $error = $installer->load_db_schema();
717
    my $error = $installer->load_db_schema();
718
    die "unable to load_db_schema: $error" if ( $error );
718
    die "unable to load_db_schema: $error" if ( $error );
719
    my $list = $installer->sql_file_list('en', 'marc21', { optional  => 1,
719
    my (undef, $list) = $installer->marc_framework_sql_list('en', 'marc21');
720
                                                           mandatory => 1 } );
720
    my (undef, $list2) = $installer->sample_data_sql_list('en');
721
    push @$list, @$list2;
721
    my ($fwk_language, $installed_list) = $installer->load_sql_in_order($all_languages, @$list);
722
    my ($fwk_language, $installed_list) = $installer->load_sql_in_order($all_languages, @$list);
722
    $installer->set_version_syspref();
723
    $installer->set_version_syspref();
723
    $installer->set_marcflavour_syspref('MARC21');
724
    $installer->set_marcflavour_syspref('MARC21');
(-)a/t/db_dependent/lib/KohaTest/Installer.pm (-2 lines)
Lines 16-25 sub methods : Test( 1 ) { Link Here
16
    my $self = shift;
16
    my $self = shift;
17
    my @methods = qw(
17
    my @methods = qw(
18
                       new 
18
                       new 
19
                       marcflavour_list 
20
                       marc_framework_sql_list 
19
                       marc_framework_sql_list 
21
                       sample_data_sql_list 
20
                       sample_data_sql_list 
22
                       sql_file_list 
23
                       load_db_schema 
21
                       load_db_schema 
24
                       load_sql_in_order 
22
                       load_sql_in_order 
25
                       set_marcflavour_syspref 
23
                       set_marcflavour_syspref 
(-)a/t/db_dependent/lib/KohaTest/Installer/SqlScripts.pm (-3 / +5 lines)
Lines 32-38 sub installer_all_sample_data : Tests { Link Here
32
    
32
    
33
    foreach my $lang_code (@languages) {
33
    foreach my $lang_code (@languages) {
34
        SKIP: {
34
        SKIP: {
35
            my $marc_flavours = $self->{installer}->marcflavour_list($lang_code);
35
            my $marc_flavours = [ glob($dir.'/'.$lang_code.'/marcflavour/*') ];
36
            ok(defined($marc_flavours), "at least one MARC flavour for $lang_code");
36
            ok(defined($marc_flavours), "at least one MARC flavour for $lang_code");
37
            skip "no MARC flavours for $lang_code" unless defined($marc_flavours);
37
            skip "no MARC flavours for $lang_code" unless defined($marc_flavours);
38
38
Lines 43-49 sub installer_all_sample_data : Tests { Link Here
43
                    is($schema_error, "", "no errors during schema load");
43
                    is($schema_error, "", "no errors during schema load");
44
                    skip "error during schema load" if $schema_error ne "";
44
                    skip "error during schema load" if $schema_error ne "";
45
        
45
        
46
                    my $list = $self->{installer}->sql_file_list($lang_code, $flavour, { optional => 1, mandatory => 1 });
46
                    my (undef, $list) = $installer->marc_framework_sql_list($lang_code, $flavour);
47
                    my (undef, $list2) = $installer->sample_data_sql_list($lang_code);
48
                    push @$list, @$list2;
49
47
                    my $sql_count = scalar(@$list);
50
                    my $sql_count = scalar(@$list);
48
                    cmp_ok($sql_count, '>', 0, "at least one SQL init file for $lang_code, $flavour");
51
                    cmp_ok($sql_count, '>', 0, "at least one SQL init file for $lang_code, $flavour");
49
                    skip "no SQL init files defined for $lang_code, $flavour" unless $sql_count > 0;
52
                    skip "no SQL init files defined for $lang_code, $flavour" unless $sql_count > 0;
50
- 

Return to bug 10523