# Copyright (c) 2010 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: TimeZoneList.pm,v 1.4 2010/05/26 03:27:31 schellj Exp $ package Bivio::Biz::Model::TimeZoneList; use strict; use Bivio::Base 'Biz.ListModel'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.4 $ =~ /\d+/g); my($_C) = b_use('FacadeComponent.Constant'); my($_R) = b_use('IO.Ref'); my($_TZ) = b_use('Type.TimeZone'); sub display_name_for_enum { my($self, $enum) = @_; $self->load_all unless $self->is_loaded; return $self->find_row_by(enum => $enum) ? $self->get('display_name') : $enum->as_display_name; } sub enum_for_display_name { my($self, $display_name) = @_; return _get_enum_from_model($self, $display_name) || $_TZ->from_any($display_name); } sub internal_initialize { my($self) = @_; return $self->merge_initialize_info($self->SUPER::internal_initialize, { version => 1, can_iterate => 0, $self->field_decl( primary_key => [ [qw(enum TimeZone)], ], other => [ [qw(display_name Line)], ], undef, 'NOT_NULL', ), }); } sub internal_load_rows { my($self) = @_; return $_R->nested_copy( $_C->get_value('Model.TimeZoneList.rows', $self->req)); } sub unsafe_enum_for_display_name { my($self, $display_name) = @_; return _get_enum_from_model($self, $display_name) || $_TZ->unsafe_from_any($display_name); } sub _get_enum_from_model { my($self, $display_name) = @_; $self->load_all unless $self->is_loaded; return $self->find_row_by(display_name => $display_name) ? $self->get('enum') : undef; } 1;