# Copyright (c) 2006 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: TupleList.pm,v 1.4 2006/12/12 05:27:41 aviggio Exp $ package Bivio::Biz::Model::TupleList; use strict; use base 'Bivio::Biz::ListModel'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.4 $ =~ /\d+/g); my($_TSN) = Bivio::Type->get_instance('TupleSlotNum'); sub execute_load_history_list { my($proto, $req) = @_; my($thl) = $proto->new($req, 'TupleHistoryList'); my($q) = $thl->parse_query_from_request; $thl->load_all($q); my($t) = $thl->new_other('Tuple')->load({ thread_root_id => $q->get('parent_id'), }); $proto->new($req)->load_this({ parent_id => $t->get('tuple_def_id'), this => $t->get('tuple_num'), }); return; } sub internal_initialize { my($self) = @_; return $self->merge_initialize_info($self->SUPER::internal_initialize, { version => 1, order_by => [qw( Tuple.tuple_num Tuple.modified_date_time ), @{$_TSN->map_list(sub {'Tuple.' . shift(@_)})}, ], primary_key => [ 'Tuple.tuple_num', ], other => [ 'Tuple.thread_root_id', ], parent_id => 'Tuple.tuple_def_id', auth_id => 'Tuple.realm_id', }); } sub internal_prepare_statement { my($self, undef, $query) = @_; $self->new_other('TupleUseList')->load_this({ this => $query->get('parent_id'), }); $self->new_other('TupleSlotDefList')->unauth_load_all({ map(($_ => $query->get($_)), qw(parent_id auth_id)), }); return shift->SUPER::internal_prepare_statement(@_); } sub parse_query { return shift->SUPER::parse_query(@_)->put(want_only_one_order_by => 1); } sub slot_label { return _slot_row(@_)->get('TupleSlotDef.label'); } sub is_slot_defined { return _slot_row(@_) ? 1 : 0; } sub _slot_row { return shift->get_request->get('Model.TupleSlotDefList') ->find_row_by_num(@_); } 1;