File Coverage

blib/lib/Elive/StandardV3.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             package Elive::StandardV3;
2 1     1   2240 use warnings; use strict;
  1     1   3  
  1         37  
  1         6  
  1         5  
  1         41  
3              
4 1     1   841 use Mouse;
  1         30764  
  1         6  
5 1     1   395 use Mouse::Util::TypeConstraints;
  1         2  
  1         6  
6              
7 1     1   1127 use Try::Tiny;
  1         1422  
  1         54  
8              
9 1     1   412 use Elive::DAO '0.06';
  0            
  0            
10             extends 'Elive::DAO';
11              
12             use Carp;
13              
14             =head1 NAME
15              
16             Elive::StandardV3 - Perl bindings for the Elluminate Live Standard Bridge (V3)
17              
18             =head1 VERSION
19              
20             Version 0.01_4
21              
22             =cut
23              
24             our $VERSION = '0.01_4';
25              
26             =head1 DESCRIPTION
27              
28             Elluminate Live! (c) is software for virtual online classrooms. It is
29             suitable for meetings, demonstrations web conferences, seminars and
30             general training and support.
31              
32             Elive-StandardV3 is a set of Perl bindings and entity definitions for the
33             Elluminate Standard Bridge V3 SOAP services ('standardv3' adapter).
34              
35             This is an alternative to the Command Toolkit, as supported by the
36             Elive::Entity classess ('default' adapter).
37              
38             =cut
39              
40             use 5.008003;
41              
42             =head1 EXAMPLE
43              
44             use Elive::StandardV3;
45             use Elive::StandardV3::Session;
46             use Elive::Util;
47              
48             my $connection = Elive::StandardV3->connect(
49             'http://myserver/mysite',
50             'some_user' => 'some_pass' );
51              
52             # Sessions must start and end on the quarter hour.
53              
54             my $session_start = Elive::Util::next_quarter_hour();
55             my $session_end = Elive::Util::next_quarter_hour( $session_start );
56              
57             my %session_data = (
58             sessionName => 'My Demo Session',
59             creatorId => $connection->user,
60             startTime => $session_start . '000',
61             endTime => $session_end . '000',
62             openChair => 1,
63             mustBeSupervised => 0,
64             permissionsOn => 1,
65             nonChairList => [qw(alice bob)],
66             groupingList => [qw(mechanics sewing)],
67             );
68              
69             my $session = Elive::StandardV3::Session->insert(\%session_data);
70              
71             my $url = $session->session_url( userId => 'bob', displayName => 'Robert');
72             print "bob's session link is: $url\n";
73              
74             =head1 DESCRIPTION
75              
76             Implements Elluminate I Standard Bridge V3 API bindings
77              
78             ** DEVELOPER RELEASE - UNDER CONSTRUCTION **
79              
80             =cut
81              
82             =head1 METHODS
83              
84             =head2 data_classes
85              
86             returns a list of all implemented entity classes
87              
88             =cut
89              
90             sub data_classes {
91             my $class = shift;
92             return qw(
93             Elive::StandardV3::Multimedia
94             Elive::StandardV3::Presentation
95             Elive::StandardV3::Recording
96             Elive::StandardV3::SchedulingManager
97             Elive::StandardV3::ServerConfiguration
98             Elive::StandardV3::ServerVersion
99             Elive::StandardV3::Session
100             Elive::StandardV3::SessionAttendance
101             Elive::StandardV3::SessionTelephony
102             );
103             }
104              
105             sub _get_results {
106             my $class = shift;
107             my $som = shift;
108             my $connection = shift;
109              
110             $connection->_check_for_errors($som);
111              
112             my @result = ($som->result, $som->paramsout);
113              
114             return \@result;
115              
116             }
117              
118             =head2 connect
119              
120             use Elive::StandardV3;
121             use Elive::StandardV3::Connection;
122              
123             #
124             # Setup the default connection
125             Elive::StandardV3->connect('http://myServer.com/test1', 'user1', 'pass1');
126             my $c1 = Elive::StandardV3->connection;
127             #
128             # Setup a secondary connection
129             my $c2 = Elive::StandardV3::Connection->connect('http://user2:pass2@myServer.com/test2');
130              
131             Connects to an Elluminate server instance. Dies if the connection could not
132             be established. If, for example, the SOAP connection or authentication failed.
133              
134             See also Elive::StandardV3::Connection.
135              
136             =cut
137              
138             sub connect {
139             my ($class, $url, $login_name, $pass, %opts) = @_;
140              
141             die "usage: ${class}->connect(url, [login_name], [pass])"
142             unless ($class && $url);
143              
144             try {require Elive::StandardV3::Connection}
145             catch {die $_};
146              
147             my $connection = Elive::StandardV3::Connection->connect(
148             $url,
149             $login_name,
150             $pass,
151             debug => $class->debug,
152             %opts,
153             );
154              
155             $class->connection($connection);
156              
157             return $connection;
158             }
159              
160             =head2 connection
161              
162             $e1 = Elive::StandardV3->connection
163             or warn 'no elive connection active';
164              
165             Returns the default Elive connection handle.
166              
167             =cut
168              
169             =head2 update
170              
171             Abstract method to commit outstanding object updates to the server.
172              
173             $obj->{foo} = 'Foo'; # change foo attribute directly
174             $foo->update; # save
175              
176             $obj->bar('Bar'); # change bar via its accessor
177             $obj->update; # save
178              
179             Updates may also be passed as parameters.
180              
181             # change and save foo and bar. All in one go.
182             $obj->update({foo => 'Foo', bar => 'Bar'});
183              
184             =cut
185              
186             sub update {
187             my ($class, $data, %opt) = @_;
188              
189             $opt{command} ||= 'Set'.$class->entity_name;
190              
191             return $class->SUPER::update($data, %opt);
192             }
193              
194             sub _fetch {
195             my ($class, $key, %opt) = @_;
196              
197             #
198             # Let the connection resolve which command to use
199             #
200              
201             $opt{command} ||=
202             ['Get'.$class->entity_name,
203             'List'.$class->entity_name];
204              
205             return $class->SUPER::_fetch($key, %opt);
206             }
207              
208             =head2 insert
209              
210             Abstract method to create new entity instances on the server:
211              
212             my $multimedia = Elive::StandardV3::Multimedia->insert(
213             {
214             filename => 'demo.wav',
215             creatorId => 'bob',
216             content => $content,
217             },
218             );
219              
220             =cut
221              
222             sub insert {
223             my ($class, $data, %opt) = @_;
224              
225             $opt{command} ||= 'Set'.$class->entity_name;
226             #
227             # allow for recurring sessions
228             #
229             my @sessions = $class->SUPER::insert($data, %opt);
230              
231             return wantarray? @sessions : $sessions[0];
232             }
233              
234             =head2 list
235              
236             Abstract selection method. Most commands allow a ranging expression to narrow
237             the selection. This is passed in using the C option. For example:
238              
239             my $bobs_sessions = Elive::StandardV3::Session->list({userId => 'bob'});
240              
241             =cut
242              
243             sub list {
244             my $self = shift;
245              
246             unshift @_, 'filter' if @_ % 2;
247             my %opt = @_;
248              
249             my $filter = delete $opt{filter};
250              
251             $filter = $self->_parse_filter($filter)
252             unless Scalar::Util::reftype $filter;
253              
254             $opt{command} ||= 'List'.$self->entity_name;
255              
256             return $self->_fetch( $filter, %opt );
257             }
258              
259             #
260             # rudimentry parse of expressions of the form:
261             # = and =
262             # A bit of a hack, largely for the benefit of elive_query
263             #
264              
265             sub _parse_filter {
266             my ($self, $expr) = @_;
267             my %selection;
268              
269             return unless defined $expr;
270              
271             foreach ( split(qr{ \s+ and \s+}ix, $expr) ) {
272             my ($field, $op, $val) = m{^ \s* (\w+) \s* ([\!=<>]+) \s* (.*?) \s* $}x;
273              
274             unless (defined($val) && length($val) && $op eq '=') {
275             carp "selection expresion '$_' not in format = ";
276             next;
277             }
278              
279             $selection{$field} = $val;
280             } ;
281              
282             return \%selection;
283             }
284              
285             =head2 delete
286              
287             Abstract method to delete entities:
288              
289             $multimedia->delete;
290              
291             =cut
292              
293             sub delete {
294             my ($self, %opt) = @_;
295              
296             my @primary_key = $self->primary_key;
297             my @id = $self->id;
298              
299             die "entity lacks a primary key - can't delete"
300             unless (@primary_key > 0);
301              
302             my @params = map {
303             $_ => shift( @id );
304             } @primary_key;
305              
306             my $command = $opt{command} || 'Remove'.$self->entity_name;
307              
308             my $som = $self->connection->call($command, @params);
309              
310             my $results = $self->_get_results(
311             $som,
312             $self->connection,
313             );
314              
315             my $success = @$results && $results->[0];
316              
317             return $self->_deleted(1)
318             if $success;
319              
320             carp "deletion failed(?) with 'false' status";
321             return;
322             }
323              
324              
325             =head1 SEE ALSO
326              
327             L
328             L
329             L
330             L
331             L
332             L
333             L
334             L
335             L
336             L
337              
338             =head1 AUTHOR
339              
340             David Warring, C<< >>
341              
342             =head1 BUGS
343              
344             Please report any bugs or feature requests to C, or through
345             the web interface at L. I will be notified, and then you'll
346             automatically be notified of progress on your bug as I make changes.
347              
348             =head1 SUPPORT
349              
350             You can find documentation for this module with the perldoc command.
351              
352             perldoc Elive::StandardV3
353              
354              
355             You can also look for information at:
356              
357             =over 4
358              
359             =item * RT: CPAN's request tracker
360              
361             L
362              
363             =item * AnnoCPAN: Annotated CPAN documentation
364              
365             L
366              
367             =item * CPAN Ratings
368              
369             L
370              
371             =item * Search CPAN
372              
373             L
374              
375             =back
376              
377             =head1 SEE ALSO
378              
379             I - this contains essential
380             background information and a full description of the available commands.
381              
382             =head1 ACKNOWLEDGEMENTS
383              
384              
385             =head1 LICENSE AND COPYRIGHT
386              
387             Copyright 2012 David Warring.
388              
389             This program is free software; you can redistribute it and/or modify it
390             under the terms of either: the GNU General Public License as published
391             by the Free Software Foundation; or the Artistic License.
392              
393             See http://dev.perl.org/licenses/ for more information.
394              
395              
396             =cut
397              
398             1;