diff --git a/eprints1.pl b/eprints1.pl index b03748d318e235a7570823e77c301c68160a7cea..e9d8635cf39792c3cb2e9e51c1fca8e25d5dde1d 100755 --- a/eprints1.pl +++ b/eprints1.pl @@ -112,8 +112,8 @@ my $op_mode= 'unknown'; # ====================================================================== # BEGIN OT2UT: Othes to Utheses -# my $ot2ut_context= 'ot2ut-entw'; # TODO: parametrize -my $ot2ut_context= 'ot2ut-test'; # TODO: parametrize +my $ot2ut_context= 'ot2ut-entw'; # TODO: parametrize +# my $ot2ut_context= 'ot2ut-test'; # TODO: parametrize my $oma_sleep_time= 10; my %map_ot2ut_roles= @@ -169,6 +169,9 @@ my $ignore_errors= 0; if ($0 eq './ot2ut.pl') { $op_mode= 'ot2ut'; $do_upload= 1; $MAX_SYNC= 1; } if ($0 eq './oma.pl') { $op_mode= 'oma'; $do_upload= 1; } +my $flag_add_utheses_policies= 1; +my $flag_add_identifiers= 1; + my %doc_embargo_dates; # END OT2UT: Othes to Utheses # ====================================================================== @@ -394,6 +397,10 @@ elsif ($op_mode eq 'debug_filenames') { debug_filenames(); } +elsif ($op_mode eq 'update-policies') +{ + update_policies(); +} elsif ($op_mode eq 'policies-stats') { policies_stats(); @@ -3427,7 +3434,7 @@ mysql> select count(*), einverstaendnis, sperre, full_text_status { $policies->{abstract_locked}= $policies->{keywords_locked}= 1; -=begin commment +=begin comment mysql> select count(*), abstract_nicht_anzeigen from eprint group by abstract_nicht_anzeigen; +----------+-------------------------+ @@ -3907,7 +3914,7 @@ sub update_policies utheses_upload_result_json_path => $utheses_upload_result_json_path, }; - map { $full_data->{$_}= $row->{$_} } qw(eprint_status einverstaendnis sperre full_text_status); + map { $full_data->{$_}= $row->{$_} } qw(eprint_status einverstaendnis sperre full_text_status urn doi); # $show++ if ($docs->{cnt_embargo} > 0); # $show++ if ($docs->{cnt_public} > 0 && $docs->{cnt_restricted} > 0); @@ -3982,7 +3989,7 @@ sub policies_stats elsif ($context eq 'ot2ut-entw') { $context= 'entw'; } elsif ($context eq 'ot2ut-prod') { $context= 'prod'; } - $synced{$eprint_id}->{$context}= $lastmod; + $synced{$eprint_id}->{$context}= [ $lastmod, $utheses_id ]; } # MAIN PART: analyze othes policies collection @@ -3990,6 +3997,15 @@ sub policies_stats my $cur_utp= $col_utp->find({}); my @columns= qw(eprint_status einverstaendnis sperre hds fts docs pub restr errors); + if ($flag_add_utheses_policies) + { + push (@columns, qw(lrq kwl absl ftl)); + } + if ($flag_add_identifiers) + { + push (@columns, qw(urn doi)); + } + my $cctab= new cctab(columns => \@columns); my $max; #= 1000; @@ -4000,8 +4016,8 @@ sub policies_stats last unless (defined ($row_utp)); # print __LINE__, " row_utp: ", Dumper($row_utp); last; - my ($eprint_id, $eprint_status, $date_sperre, $einverstaendnis, $lastmod, $full_text_status, $sperre, $cnt_errors, $cnt_warnings, $docs)= - map { $row_utp->{$_} } qw(eprint_id eprint_status date_sperre einverstaendnis lastmod full_text_status sperre cnt_errors cnt_warnings docs); + my ($eprint_id, $eprint_status, $date_sperre, $einverstaendnis, $lastmod, $full_text_status, $sperre, $cnt_errors, $cnt_warnings, $docs, $utp, $urn, $doi)= + map { $row_utp->{$_} } qw(eprint_id eprint_status date_sperre einverstaendnis lastmod full_text_status sperre cnt_errors cnt_warnings docs ut_public urn doi); my ($cnt_docs, $cnt_public, $cnt_restricted)= map { $docs->{$_} } qw(cnt_docs cnt_public cnt_restricted); @@ -4014,22 +4030,50 @@ sub policies_stats $has_date_sperre=($date_sperre lt $ts_now) ? 'past' : 'future'; } - my $bucket= $cctab->bucket($eprint_status, $einverstaendnis, $sperre, $has_date_sperre, $full_text_status, $cnt_docs, $cnt_public, $cnt_restricted, $has_errors); + my @bucket_selectors= ($eprint_status, $einverstaendnis, $sperre, $has_date_sperre, $full_text_status, $cnt_docs, $cnt_public, $cnt_restricted, $has_errors); + + my ($utptp, $lrq, $kwl, $absl, $ftl); + my $utpt= $utp->{thesis}; + if (defined ($utpt)) + { + ($utptp, $urn, $doi)= map { $utpt->{$_} } qw(policies urn doi); + } + if (defined ($utptp)) + { + ($lrq, $kwl, $absl, $ftl)= map { $utptp->{$_} } qw(lock_request keywords_locked abstract_locked fulltext_locked); + + } + if ($flag_add_utheses_policies) + { + push (@bucket_selectors, $lrq, $kwl, $absl, $ftl); + } + + if ($flag_add_identifiers) + { + $urn= 'present' if (defined ($urn)); + $doi= 'present' if (defined ($doi)); + + push (@bucket_selectors, $urn, $doi); + } + + my $bucket= $cctab->bucket(@bucket_selectors); $bucket->{othes}++; push (@{$bucket->{othes_ids}} => $eprint_id); - my $found_utheses= 0; - foreach my $context (@contexts) + if (exists ($synced{$eprint_id})) { - if (exists ($synced{$eprint_id}->{$context})) + foreach my $context (@contexts) { - $bucket->{$context}++; - push (@{$bucket->{$context . '_ids'}} => $eprint_id); - $found_utheses++; + if (exists ($synced{$eprint_id}->{$context})) + { + my $x= $synced{$eprint_id}->{$context}; + $bucket->{$context}++; + push (@{$bucket->{$context . '_ids'}} => [ $eprint_id, $x->[1] ]); + } } + delete($synced{$eprint_id}); } - delete($synced{$eprint_id}) if (exists ($synced{$eprint_id})); last if (defined($max) && --$max <= 0); }