From: Lebbeous Fogle-Weekley Date: Tue, 18 Sep 2012 21:28:02 +0000 (-0400) Subject: EDI: The get_li_attr_jedi() helper for A/T templates now takes a limit arg X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fcollab%2Fsenator%2Fedi-limits;p=working%2FEvergreen.git EDI: The get_li_attr_jedi() helper for A/T templates now takes a limit arg Some vendors seem to use EDI software that doesn't accept long values in segments. This allows you to call the get_li_attr_jedi() helper in your A/T templates with an argument that limits the (pre-jsonification) length of the returned string. Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm index a56a2cd9fe..f7e3b8ee79 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm @@ -22,16 +22,27 @@ sub NOOP_False { return 0 } # here, we can't really reuse it within that structure. sub get_li_attr { my $name = shift or return; # the first arg is always the name - my ($type, $attr) = (scalar(@_) == 1) ? (undef, $_[0]) : @_; + my ($type, $attr, $limit); + if (scalar(@_) == 1) { + ($type, $attr, $limit) = (undef, @_); + } else { + ($type, $attr, $limit) = @_; + } + # if the next is the last, it's the attributes, otherwise type # use Data::Dumper; $logger->warn("get_li_attr: " . Dumper($attr)); ($name and @$attr) or return; + my $length; $name =~ s/^(\D+)_(\d+)$/$1/ and $length = $2; foreach (@$attr) { $_->attr_name eq $name or next; next if $length and $length != length($_->attr_value); - return $_->attr_value if (! $type) or $type eq $_->attr_type; + + my $value = $_->attr_value; + $value = substr($value, 0, $limit) if $limit; + + return $value if (! $type) or $type eq $_->attr_type; } return; }