File Coverage

blib/lib/Siebel/Srvrmgr/ListParser/Output/ListComp/Comp.pm
Criterion Covered Total %
statement 14 17 82.3
branch 1 4 25.0
condition n/a
subroutine 5 5 100.0
pod 2 2 100.0
total 22 28 78.5


line stmt bran cond sub pod time code
1             package Siebel::Srvrmgr::ListParser::Output::ListComp::Comp;
2              
3             =pod
4              
5             =head1 NAME
6              
7             Siebel::Srvrmgr::ListParser::Output::ListComp::Comp - class that represents a Siebel component
8              
9             =cut
10              
11 44     44   7918274 use Moose 2.0401;
  44         9150654  
  44         407  
12 44     44   384264 use MooseX::FollowPBP 0.05;
  44         493534  
  44         402  
13 44     44   447014 use namespace::autoclean 0.13;
  44         176954  
  44         393  
14              
15             with 'Siebel::Srvrmgr::ListParser::Output::Duration';
16             with 'Siebel::Srvrmgr::ListParser::Output::ToString';
17              
18             our $VERSION = '0.29'; # VERSION
19              
20             =pod
21              
22             =head1 SYNOPSIS
23              
24             use Siebel::Srvrmgr::ListParser::Output::ListComp::Comp;
25             # see Siebel::Srvrmgr::ListParser::Output::ListComp::Server for more details
26             my $comp = Siebel::Srvrmgr::ListParser::Output::ListComp::Comp->new( {
27             alias => $data_ref->{CC_ALIAS},
28             name => $data_ref->{CC_NAME},
29             ct_alias => $data_ref->{CT_ALIAS},
30             cg_alias => $data_ref->{CG_ALIAS},
31             run_mode => $data_ref->{CC_RUNMODE},
32             disp_run_state => $data_ref->{CP_DISP_RUN_STATE},
33             start_mode => $data_ref->{CP_STARTMODE},
34             num_run_tasks => $data_ref->{CP_NUM_RUN_TASKS},
35             max_tasks => $data_ref->{CP_MAX_TASKS},
36             actv_mts_procs => $data_ref->{CP_ACTV_MTS_PROCS},
37             max_mts_procs => $data_ref->{CP_MAX_MTS_PROCS},
38             start_datetime => $data_ref->{CP_START_TIME},
39             end_datetime => $data_ref->{CP_END_TIME},
40             status => $data_ref->{CP_STATUS},
41             incarn_no => $data_ref->{CC_INCARN_NO},
42             time_zone => 'America/Sao_Paulo',
43             desc_text => $data_ref->{CC_DESC_TEXT}
44              
45             } );
46              
47             print 'NAME = ', $comp->get_name(), "\n";
48              
49             =head1 DESCRIPTION
50              
51             This class is meant to be used together with L<Siebel::Srvrmgr::ListParser::Output::Server> since a component is always associated with a Siebel server. This class is intended to make it
52             easier to access and modify components as desired (for example, to export all components from one server to another changing some of their parameters).
53              
54             This class uses the roles L<Siebel::Srvrmgr::ListParser::Output::Duration> and L<Siebel::Srvrmgr::ListParser::Output::ToString>.
55              
56             =head1 ATTRIBUTES
57              
58             Beware that some of the attributes of the component may reflect only the current state when the component data was recovered and are, by nature, dynamic. Some example are
59             the number of running tasks and state of the component.
60              
61             =head2 alias
62              
63             A string of the alias of the component.
64              
65             This is a required attribute during object creation.
66              
67             This attribute is read/write.
68              
69             =cut
70              
71             has alias => ( isa => 'Str', is => 'rw', required => 1 );
72              
73             =pod
74              
75             =head2 name
76              
77             A string of the name of the component.
78              
79             This attribute is read/write.
80              
81             =cut
82              
83             has name => ( isa => 'Str', is => 'rw', required => 1 );
84              
85             =pod
86              
87             =head2 ct_alias
88              
89             A string of the component type alias.
90              
91             This attribute is read/write.
92              
93             =cut
94              
95             has ct_alias => ( isa => 'Str', is => 'rw', required => 1 );
96              
97             =pod
98              
99             =head2 cg_alias
100              
101             A string of the component group alias.
102              
103             This attribute is read/write.
104              
105             =cut
106              
107             has cg_alias => ( isa => 'Str', is => 'rw', required => 1 );
108              
109             =pod
110              
111             =head2 run_mode
112              
113             A string of the component run mode.
114              
115             This attribute is read/write.
116              
117             =cut
118              
119             has run_mode => ( isa => 'Str', is => 'rw', required => 1 );
120              
121             =pod
122              
123             =head2 disp_run_state
124              
125             A string of the component display run state.
126              
127             This attribute is read-only.
128              
129             =cut
130              
131             has disp_run_state => ( isa => 'Str', is => 'ro', required => 1 );
132              
133             =pod
134              
135             =head2 start_mode
136              
137             A string representing the component start mode. Currently the only valid values are:
138              
139             =over
140              
141             =item Manual
142              
143             =item Auto
144              
145             =back
146              
147             This attribute is read-only.
148              
149             =cut
150              
151             has start_mode => ( isa => 'Str', is => 'ro', required => 1 );
152              
153             =pod
154              
155             =head2 num_run_tasks
156              
157             An integer with the number of running tasks of the component.
158              
159             This attribute is read-only.
160              
161             =cut
162              
163             has num_run_tasks => ( isa => 'Int', is => 'ro', required => 1 );
164              
165             =pod
166              
167             =head2 max_tasks
168              
169             An integer with the maximum number of tasks the component will execute before restart itself.
170              
171             This attribute is read/write.
172              
173             =cut
174              
175             has max_tasks => ( isa => 'Int', is => 'rw', required => 1 );
176              
177             =pod
178              
179             =head2 actv_mts_procs
180              
181             An integer wit the active MTS processes running for the component.
182              
183             This attribute is read-only.
184              
185             =cut
186              
187             has actv_mts_procs => ( isa => 'Int', is => 'ro', required => 1 );
188              
189             =pod
190              
191             =head2 max_mts_procs
192              
193             An integer with the maximum number of MTS process that will run for the component.
194              
195             This attribute is read/write.
196              
197             =cut
198              
199             has max_mts_procs => ( isa => 'Int', is => 'rw', required => 1 );
200              
201             =pod
202              
203             =head2 status
204              
205             A string representing the status of the component.
206              
207             This attribute is read-only.
208              
209             =cut
210              
211             has status => ( isa => 'Str', is => 'ro', required => 1 );
212              
213             =pod
214              
215             =head2 incarn_no
216              
217             An integer with representing the component incarnation number.
218              
219             This attribute is read-only.
220              
221             =cut
222              
223             has incarn_no => (
224             isa => 'Int',
225             is => 'ro',
226             required => 1
227             );
228              
229             =pod
230              
231             =head2 desc_text
232              
233             A string representing the description of the component.
234              
235             This attribute is read/write.
236              
237             =cut
238              
239             has desc_text => ( isa => 'Str', is => 'rw', required => 1 );
240              
241             =pod
242              
243             =head1 METHODS
244              
245             All attributes have getter methods from than, following the Perl Best Practices book recomendation, so for component description invoke c<get_desc_text> method and so on.
246              
247             For those attributes that are read/write, their setters follows the same scheme.
248              
249             =head2 BUILD
250              
251             The C<BUILD> method will create all attributes/methods based on the value of the C<data> attribute.
252              
253             Once this operation is finished, the C<data> attribute is set to an empty hash reference.
254              
255             =cut
256              
257             sub BUILD {
258 382     382 1 871 my $self = shift;
259 382         1432 $self->fix_endtime;
260             }
261              
262             =pod
263              
264             =head2 is_auto_start
265              
266             A helper method, it returns true if C<start_mode> attribute is "Auto", false if it is "Manual".
267              
268             =cut
269              
270             sub is_auto_start {
271 2     2 1 8 my $self = shift;
272 2 50       104 if ( $self->get_start_mode eq 'Auto' ) {
273 2         17 return 1;
274             }
275              
276 0 0         if ( $self->get_start_mode eq 'Manual' ) {
277 0           return 0;
278             }
279             else {
280 0           confess 'Invalid object state: the start mode value "'
281             . $self->get_start_mode
282             . ' is not valid';
283             }
284             }
285              
286             =pod
287              
288             =head1 SEE ALSO
289              
290             =over
291              
292             =item *
293              
294             L<Moose>
295              
296             =item *
297              
298             L<namespace::autoclean>
299              
300             =item *
301              
302             L<Siebel::Srvrmgr::ListParser::Output::Duration>
303              
304             =item *
305              
306             L<Siebel::Srvrmgr::ListParser::Output::ToString>
307              
308             =item *
309              
310             L<MooseX::FollowPBP>
311              
312             =back
313              
314             =head1 AUTHOR
315              
316             Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
317              
318             =head1 COPYRIGHT AND LICENSE
319              
320             This software is copyright (c) 2012 of Alceu Rodrigues de Freitas Junior, E<lt>arfreitas@cpan.orgE<gt>.
321              
322             This file is part of Siebel Monitoring Tools.
323              
324             Siebel Monitoring Tools is free software: you can redistribute it and/or modify
325             it under the terms of the GNU General Public License as published by
326             the Free Software Foundation, either version 3 of the License, or
327             (at your option) any later version.
328              
329             Siebel Monitoring Tools is distributed in the hope that it will be useful,
330             but WITHOUT ANY WARRANTY; without even the implied warranty of
331             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
332             GNU General Public License for more details.
333              
334             You should have received a copy of the GNU General Public License
335             along with Siebel Monitoring Tools. If not, see L<http://www.gnu.org/licenses/>.
336              
337             =cut
338              
339             __PACKAGE__->meta->make_immutable;