Skip to content

Commit

Permalink
Block component parts from broadcast
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaraisa committed Oct 7, 2021
1 parent ea4ad09 commit 53e106f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 19 deletions.
4 changes: 3 additions & 1 deletion Koha/Plugin/Fi/KohaSuomi/BroadcastBiblios.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use Koha::Plugin::Fi::KohaSuomi::BroadcastBiblios::Modules::Broadcast;
use Koha::Plugin::Fi::KohaSuomi::BroadcastBiblios::Modules::ActiveRecords;

## Here we set our plugin version
our $VERSION = "1.2.2";
our $VERSION = "1.2.3";

## Here is our metadata, some keys are required, some are optional
our $metadata = {
Expand Down Expand Up @@ -59,6 +59,7 @@ sub new {
$self->{verbose} = $args->{verbose};
$self->{start_time} = $args->{start_time};
$self->{blocked_encoding_level} = $args->{blocked_encoding_level};
$self->{block_component_parts} = $args->{block_component_parts};

}

Expand Down Expand Up @@ -117,6 +118,7 @@ sub run {
log_table => $self->{logTable},
start_time => $self->{start_time},
blocked_encoding_level => $self->{blocked_encoding_level},
block_component_parts => $self->{block_component_parts},
});

my $params = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,13 @@ sub checkEncodingLevel {
return $encoding_level;
}

sub checkComponentPart {
my ($self, $biblio) = @_;

my $record = MARC::Record::new_from_xml($biblio->{metadata}, 'UTF-8');
return 1 if $record->subfield('773', "w");
return 0;
}


1;
13 changes: 13 additions & 0 deletions Koha/Plugin/Fi/KohaSuomi/BroadcastBiblios/Modules/Broadcast.pm
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ sub blockByEncodingLevel {
return 0;
}

sub blockComponentParts {
my ($self, $biblio) = @_;

my $block = shift->{_params}->{block_component_parts};

if ($block) {
return $self->activeRecords()->checkComponentPart($biblio);
}

return 0;
}


sub broadcastBiblios {
my ($self, $params) = @_;
Expand All @@ -164,6 +176,7 @@ sub broadcastBiblios {
my @pusharray;
my ($error, $response);
foreach my $biblio (@{$biblios}) {
next if $self->blockComponentParts($biblio);
next if $self->blockByEncodingLevel($biblio);
my $requestparams = $self->getEndpointParameters($biblio);
if ($self->getEndpointType eq 'identifier_activation') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ BEGIN
my $inactivity_timeout = 30;
my $start_time;
my $encoding_level;
my $block_component_parts = 0;

GetOptions(
'h|help' => \$help,
Expand All @@ -84,30 +85,32 @@ BEGIN
'inactivity_timeout:i' => \$inactivity_timeout,
'start_time:i' => \$start_time,
'blocked_encoding_level:s' => \$encoding_level,
'block_component_parts' => \$block_component_parts,

);

my $usage = <<USAGE;
Broadcast biblios to REST endpoint
-h, --help This message.
-v, --verbose Verbose.
-c, --chunks Process biblios in chunks, default is 200.
-a, --active Send active biblios.
--all Send all biblios, default sends biblios from today.
-b, --biblionumber Start sending from defined biblionumber.
-l, --limit Limiting the results of biblios.
-i, --interface Interface name: with active add your system interface and with staged add remote.
-s, --staged Export staged records to interface.
--batchdate Import batch date, used with 'staged' parameter. Default is today.
-t, --type Stage type, used with 'staged' parameter. Add or update, default is add.
-f, --field Find target id from marcxml, used with 'staged' parameter and update type.
--check Check that field contains some spesific identifier.
--lastrecord Automatically check which is lastly activated record.
--identifier Push to active records with identifier.
--inactivity_timeout Can be used to increase response waiting time, default is 30.
--start_time Define hour when to start broadcast.
--blocked_encoding_level Block encoding level from broadcast. Add multiple values with pipe eg. "5|7|8"
-h, --help This message.
-v, --verbose Verbose.
-c, --chunks Process biblios in chunks, default is 200.
-a, --active Send active biblios.
--all Send all biblios, default sends biblios from today.
-b, --biblionumber Start sending from defined biblionumber.
-l, --limit Limiting the results of biblios.
-i, --interface Interface name: with active add your system interface and with staged add remote.
-s, --staged Export staged records to interface.
--batchdate Import batch date, used with 'staged' parameter. Default is today.
-t, --type Stage type, used with 'staged' parameter. Add or update, default is add.
-f, --field Find target id from marcxml, used with 'staged' parameter and update type.
--check Check that field contains some spesific identifier.
--lastrecord Automatically check which is lastly activated record.
--identifier Push to active records with identifier.
--inactivity_timeout Can be used to increase response waiting time, default is 30.
--start_time Define hour when to start broadcast.
--blocked_encoding_level Block encoding level from broadcast. Add multiple values with pipe eg. "5|7|8"
--block_component_parts Block component parts from broadcast.
USAGE

Expand Down Expand Up @@ -170,6 +173,7 @@ BEGIN
verbose => $verbose,
start_time => $start_time,
blocked_encoding_level => $encoding_level,
block_component_parts => $block_component_parts,
});

$plugin->run();

0 comments on commit 53e106f

Please sign in to comment.