# Copyright (c) 2007-2011 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: RowTag.pm,v 1.5 2011/03/03 18:17:46 nagler Exp $ package Bivio::Util::RowTag; use strict; use Bivio::Base 'Bivio.ShellUtil'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.5 $ =~ /\d+/g); my($_RTK) = b_use('Type.RowTagKey'); sub USAGE { return <<'EOF'; usage: b-row-tag [options] command [args..] commands replace_value key [value] -- calls RowTag->replace_value with auth_id list [key...] -- calls RowTag->replace_value with auth_id EOF } sub list { sub LIST {[[ '*key', 'RowTagKey', sub {[sort({$a->get_name cmp $b->get_name} $_RTK->get_non_zero_list)]}, ]]} my($self, $bp) = shift->parameters(\@_); my($rt) = $self->model('RowTag'); my($id) = $self->req('auth_id'); return {map( ($_->get_name, $rt->get_value($id, $_)), @{$bp->{key}}, )}; } sub replace_value { my($self, $key, $value) = shift->name_args([ ['RowTagKey'], [RowTagValue => undef, undef], ], \@_); $self->model('RowTag')->replace_value($self->req('auth_id'), $key, $value); return; } 1;