From: Jason Stephenson Date: Thu, 26 Sep 2013 00:34:17 +0000 (-0400) Subject: Teach Marque.pm to use the from_bare_hash Fieldmapper method. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3ab4dfde721757b9224d2ed48dfceb3d6f3f0d4a;p=working%2FEvergreen.git Teach Marque.pm to use the from_bare_hash Fieldmapper method. Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/src/support-scripts/Marque.pm.in b/Open-ILS/src/support-scripts/Marque.pm.in index 50fc8c923e..89be63207d 100644 --- a/Open-ILS/src/support-scripts/Marque.pm.in +++ b/Open-ILS/src/support-scripts/Marque.pm.in @@ -357,7 +357,7 @@ sub build_query { # Now we build the query in pieces: # We always select the bre fields: - my $select = 'select ' . join(',', @breFields); + my $select = 'select distinct ' . join(',', @breFields); # We always use the bre table. my $from = "from $breTable"; @@ -415,9 +415,9 @@ sub next { my $self = shift; my $output; - my @data = $self->{sth}->fetchrow_array; - if (@data) { - my $bre = $self->{breClass}->new(\@data); + my $data = $self->{sth}->fetchrow_hashref; + if ($data) { + my $bre = $self->{breClass}->from_bare_hash($data); if ($Marque::config->option_value('format') eq 'BRE') { $output = OpenSRF::Utils::JSON->perl2JSON($bre); } else { @@ -472,7 +472,7 @@ sub next { ($location ? ('a' => $location) : ()), b => $acp->call_number()->owning_lib()->shortname(), b => $acp->circ_lib()->shortname(), - c => $acp->copy_location()->name(), + c => $acp->location()->name(), j => $acp->call_number()->label(), ($acp->circ_modifier() ? (g => $acp->circ_modifier()) : ()), p => $acp->barcode(), @@ -509,8 +509,8 @@ sub orgs { $query .= "\nfrom $classTable"; my $sth = $self->{handle}->prepare($query); if ($sth->execute()) { - my $result = $sth->fetchall_arrayref(); - my @orgs = map {$fmClass->new($_)} @{$result}; + my $result = $sth->fetchall_arrayref({}); + my @orgs = map {$fmClass->from_bare_hash($_)} @{$result}; $self->{orgs} = \@orgs; } else { $self->{orgs} = []; @@ -529,8 +529,8 @@ sub shelves { my $classTable = $fmClass->Table(); my $query = 'select ' . join(',', @classFields); $query .= "\nfrom $classTable"; - my $result = $self->{handle}->selectall_arrayref($query); - my @shelves = map {$fmClass->new($_)} @{$result}; + my $result = $self->{handle}->selectall_arrayref($query, {Slice=>{}}); + my @shelves = map {$fmClass->from_bare_hash($_)} @{$result}; $self->{shelves} = \@shelves; } @@ -555,8 +555,8 @@ sub acns_for_bre { } if ($self->{acnHandle}->execute($bre)) { - my $result = $self->{acnHandle}->fetchall_arrayref(); - return map {$self->{acnClass}->new($_)} @{$result}; + my $result = $self->{acnHandle}->fetchall_arrayref({}); + return map {$self->{acnClass}->from_bare_hash($_)} @{$result}; } # If for some reason, we don't find anything. @@ -579,13 +579,13 @@ sub acps_for_bre { $query .= "\nwhere deleted = 'f' and call_number in ("; $query .= join(',', map {$_->id()} @acns); $query .= ")"; - my $result = $self->{handle}->selectall_arrayref($query); + my $result = $self->{handle}->selectall_arrayref($query, {Slice=>{}}); if ($result && @{$result}) { - my @acps = map {$self->{acpClass}->new($_)} @{$result}; - return map { + my @acps = map {$self->{acpClass}->from_bare_hash($_)} @{$result}; + foreach (@acps) { my $cn = $_->call_number(); my $clib = $_->circ_lib(); - my $loc = $_->copy_loaction(); + my $loc = $_->location(); my ($org) = grep {$_->id() == $clib} @orgs; my ($acn) = grep {$_->id() == $cn} @acns; my ($location) = grep {$_->id() == $loc} @locations; @@ -594,8 +594,9 @@ sub acps_for_bre { $acn->owning_lib($owner); $_->call_number($acn); $_->circ_lib($org); - $_->copy_location($location); - } @acps; + $_->location($location); + } + return @acps; } } @@ -656,11 +657,11 @@ sub execute_query { sub next { my $self = shift; my $output; - my @data = $self->{sth}->fetchrow_array; + my $data = $self->{sth}->fetchrow_hashref; - if (@data) { + if ($data) { my $format = $Marque::config->option_value('format'); - my $are = $self->{fmClass}->new(\@data); + my $are = $self->{fmClass}->from_bare_hash($data); if ($format eq 'ARE') { $output = OpenSRF::Utils::JSON->perl2JSON($are); } else {