Bugzilla – Attachment 129854 Details for
Bug 20517
Use the "sort bin" field in SIP2 Checkin Response
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20517: Add support for specifying comparitor
Bug-20517-Add-support-for-specifying-comparitor.patch (text/plain), 3.97 KB, created by
Martin Renvoize (ashimema)
on 2022-01-27 10:02:53 UTC
(
hide
)
Description:
Bug 20517: Add support for specifying comparitor
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-01-27 10:02:53 UTC
Size:
3.97 KB
patch
obsolete
>From 65c079f5c1b85f87bb239b93b272a565ecd93b20 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 27 Jan 2022 09:50:33 +0000 >Subject: [PATCH] Bug 20517: Add support for specifying comparitor > >This patch adds support for specifying the comparison operator used in >the sort bin method. It allows for more complex cases where one may wish >to sort on groups of callnumbers for example. >--- > C4/SIP/ILS/Transaction/Checkin.pm | 49 ++++++++++++++++++++++++------- > 1 file changed, 38 insertions(+), 11 deletions(-) > >diff --git a/C4/SIP/ILS/Transaction/Checkin.pm b/C4/SIP/ILS/Transaction/Checkin.pm >index c2120929af..ee5da78004 100644 >--- a/C4/SIP/ILS/Transaction/Checkin.pm >+++ b/C4/SIP/ILS/Transaction/Checkin.pm >@@ -170,7 +170,7 @@ sub do_checkin { > > # Set sort bin based on info in the item associated with the issue, and the > # mapping from SIP2SortBinMapping >- $self->sort_bin( _get_sort_bin( $self->{item} ) ); >+ $self->sort_bin( _get_sort_bin( $item, $branch ) ); > > $self->ok($return); > >@@ -197,19 +197,20 @@ sub patron_id { > > =head1 _get_sort_bin > >-Takes an item represented as a hashref as argument. >+Takes a Koha::Item object and the return branch branchcode as arguments. > > Uses the contents of the SIP2SortBinMapping syspref to determine the sort_bin > value that should be returned for an item checked in via SIP2. > > The mapping should be: > >- <branchcode>:<item field>:<item field value>:<sort bin number> >+ <branchcode>:<item field>:<comparitor>:<item field value>:<sort bin number> > > For example: > >- CPL:itype:BOOK:1 >- CPL:location:OFFICE:2 >+ CPL:itype:eq:BOOK:1 >+ CPL:location:eq:OFFICE:2 >+ CPL:classmark:<:339.6:3 > > This will give: > >@@ -219,6 +220,8 @@ This will give: > > =item * sort_bin = "2" for items at the CPL branch with a location of OFFICE > >+=item * sort_bin = "3" for items at the CPL branch with a classmark less than 339.6 >+ > =back > > Returns the ID of the appropriate sort_bin, if there is one, or undef. >@@ -228,7 +231,7 @@ Returns the ID of the appropriate sort_bin, if there is one, or undef. > sub _get_sort_bin { > > # We should get an item represented as a hashref here >- my ( $item ) = @_; >+ my ( $item, $branch ) = @_; > return undef unless $item; > > # Get the mapping and split on newlines >@@ -237,18 +240,42 @@ sub _get_sort_bin { > my @lines = split /\r\n/, $raw_map; > > # Iterate over the mapping. The first hit wins. >- foreach my $line ( @lines ) { >+ my $rule = 0; >+ foreach my $line (@lines) { >+ warn "Rule: " . $rule++ . " - " . $line . "\n"; >+ > # Split the line into fields >- my ( $branchcode, $item_property, $value, $sort_bin ) = split /:/, $line; >+ my ( $branchcode, $item_property, $comparitor, $value, $sort_bin ) = >+ split /:/, $line; >+ if ( $value =~ s/^\$// ) { >+ $value = $item->$value; >+ } > # Check the fields against values in the item >- if ( ( $item->{homebranch} eq $branchcode ) && ( $item->{$item_property} eq $value ) ) { >- return $sort_bin; >+ if ( $branch eq $branchcode ) { >+ my $property = $item->$item_property; >+ if ( ( $comparitor eq 'eq' || $comparitor eq '=' ) && ( $property eq $value ) ) { >+ return $sort_bin; >+ } >+ if ( ( $comparitor eq 'ne' || $comparitor eq '!=' ) && ( $property ne $value ) ) { >+ return $sort_bin; >+ } >+ if ( ( $comparitor eq '<' ) && ( $property < $value ) ) { >+ return $sort_bin; >+ } >+ if ( ( $comparitor eq '>' ) && ( $property > $value ) ) { >+ return $sort_bin; >+ } >+ if ( ( $comparitor eq '<=' ) && ( $property <= $value ) ) { >+ return $sort_bin; >+ } >+ if ( ( $comparitor eq '>=' ) && ( $property >= $value ) ) { >+ return $sort_bin; >+ } > } > } > > # Return undef if no hits were found > return undef; >- > } > > 1; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20517
:
75126
|
75369
|
103689
|
106291
|
129846
|
129847
|
129848
|
129849
|
129850
|
129851
|
129852
|
129853
|
129854
|
129855
|
132555
|
132556
|
132557
|
132558
|
132559
|
132591
|
132592
|
132593
|
132594
|
132595
|
132596