1package Netdot::Model::Closet;
2
3use base 'Netdot::Model';
4use warnings;
5use strict;
6my $logger = Netdot->log->get_logger("Netdot::Model");
7
8# Make sure to return 1
91;
10
11=head1 NAME
12
13Netdot::Module::Closet
14
15=head1 CLASS METHODS
16
17#############################################################################
18
19=head2 insert - Inserts a closet into the DB.
20
21  Arguments:
22    Key value pairs
23  Returns:
24    New Closet object
25  Examples:
26    $newobj = Closet->insert({name=>'A', floor=>'2'});
27
28=cut
29
30sub insert {
31    my ($self, $argv) = @_;
32
33    $self->_validate($argv);
34    return $self->SUPER::insert($argv);
35}
36
37=head1 INSTANCE METHODS
38=cut
39
40#############################################################################
41
42=head2 update - Updates a closet object.
43
44  Arguments:
45    Key value pairs
46  Returns:
47
48  Examples:
49    $closet->update({name=>'A', floor=>'2'});
50
51=cut
52
53sub update {
54    my ($self, $argv) = @_;
55
56    $self->_validate($argv);
57    return $self->SUPER::update($argv);
58}
59
60###########################################################################
61# PRIVATE METHODS
62###########################################################################
63
64###########################################################################
65# _validate - Validate arguments before inserting/updating
66#
67#    Check for required fields
68#    Automatically assign site field according to floor setting
69
70sub _validate {
71    my ($self, $argv) = @_;
72    if ( ref($self) ){
73	$argv->{name}   = $self->name   unless ( defined $argv->{name} );
74	$argv->{room} = $self->room unless ( defined $argv->{room} );
75    }
76
77    $self->throw_user("A Closet name is required")
78	unless ( $argv->{name} );
79    $self->throw_user("A Room/Closet number is required")
80	unless ( $argv->{room} );
81
82    return 1;
83}
84
85=head1 AUTHOR
86
87Carlos Vicente, C<< <cvicente at ns.uoregon.edu> >>
88
89=head1 COPYRIGHT & LICENSE
90
91Copyright 2012 University of Oregon, all rights reserved.
92
93This program is free software; you can redistribute it and/or modify
94it under the terms of the GNU General Public License as published by
95the Free Software Foundation; either version 2 of the License, or
96(at your option) any later version.
97
98This program is distributed in the hope that it will be useful, but
99WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY
100or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
101License for more details.
102
103You should have received a copy of the GNU General Public License
104along with this program; if not, write to the Free Software Foundation,
105Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
106
107=cut
108
1091;
110