File Coverage

blib/lib/Elive/StandardV2.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::StandardV2;
2 1     1   2717 use warnings; use strict;
  1     1   2  
  1         42  
  1         7  
  1         3  
  1         40  
3              
4 1     1   949 use Mouse;
  1         37359  
  1         7  
5 1     1   415 use Mouse::Util::TypeConstraints;
  1         2  
  1         6  
6              
7 1     1   1331 use Try::Tiny;
  1         1772  
  1         104  
8              
9 1     1   522 use Elive::DAO '0.04';
  0            
  0            
10             extends 'Elive::DAO';
11              
12             use Carp;
13              
14             =head1 NAME
15              
16             Elive::StandardV2 - Perl bindings for the Elluminate Live Standard Bridge (V2) [DEPRECIATED]
17              
18             =head1 VERSION
19              
20             Version 0.02_1
21              
22             =cut
23              
24             our $VERSION = '0.02_1';
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-StandardV2 is a set of Perl bindings and entity definitions for the
33             Elluminate Standard Bridge V2 SOAP services ('standardv2' 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::StandardV2;
45             use Elive::StandardV2::Session;
46             use Elive::Util;
47              
48             my $connection = Elive::StandardV2->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::StandardV2::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 V2 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::StandardV2::Multimedia
94             Elive::StandardV2::Presentation
95             Elive::StandardV2::Recording
96             Elive::StandardV2::SchedulingManager
97             Elive::StandardV2::ServerConfiguration
98             Elive::StandardV2::ServerVersions
99             Elive::StandardV2::Session
100             Elive::StandardV2::SessionAttendance
101             Elive::StandardV2::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::StandardV2;
121             use Elive::StandardV2::Connection;
122              
123             #
124             # Setup the default connection
125             Elive::StandardV2->connect('http://myServer.com/test1', 'user1', 'pass1');
126             my $c1 = Elive::StandardV2->connection;
127             #
128             # Setup a secondary connection
129             my $c2 = Elive::StandardV2::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::StandardV2::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::StandardV2::Connection}
145             catch {die $_};
146              
147             my $connection = Elive::StandardV2::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::StandardV2->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::StandardV2::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::StandardV2::Session->list(filter => {userId => 'bob'});
240              
241             =cut
242              
243             sub list {
244             my ($self, %opt) = @_;
245              
246             my $filter = delete $opt{filter} || {};
247              
248             $filter = $self->_parse_filter($filter)
249             unless Scalar::Util::reftype $filter;
250              
251             $opt{command} ||= 'list'.$self->entity_name;
252              
253             return $self->_fetch( $filter, %opt );
254             }
255              
256             #
257             # rudimentry parse of expressions of the form:
258             # = and =
259             # A bit of a hack, largely for the benefit of elive_query
260             #
261              
262             sub _parse_filter {
263             my ($self, $expr) = @_;
264             my %selection;
265              
266             foreach ( split(qr{ \s+ and \s+}ix, $expr) ) {
267             my ($field, $op, $val) = m{^ \s* (\w+) \s* ([\!=<>]+) \s* (.*?) \s* $}x;
268              
269             unless (defined($val) && length($val) && $op eq '=') {
270             carp "selection expresion '$_' not in format = ";
271             next;
272             }
273              
274             $selection{$field} = $val;
275             } ;
276              
277             return \%selection;
278             }
279              
280             =head2 delete
281              
282             Abstract method to delete entities:
283              
284             $multimedia->delete;
285              
286             =cut
287              
288             sub delete {
289             my ($self, %opt) = @_;
290              
291             my @primary_key = $self->primary_key;
292             my @id = $self->id;
293              
294             die "entity lacks a primary key - can't delete"
295             unless (@primary_key > 0);
296              
297             my @params = map {
298             $_ => shift( @id );
299             } @primary_key;
300              
301             my $command = $opt{command} || 'remove'.$self->entity_name;
302              
303             my $som = $self->connection->call($command, @params);
304              
305             my $results = $self->_get_results(
306             $som,
307             $self->connection,
308             );
309              
310             my $success = @$results && $results->[0];
311              
312             return $self->_deleted(1)
313             if $success;
314              
315             carp "deletion failed(?) with 'false' status";
316             return;
317             }
318              
319              
320             =head1 SEE ALSO
321              
322             L
323             L
324             L
325             L
326             L
327             L
328             L
329             L
330             L
331             L
332              
333             =head1 AUTHOR
334              
335             David Warring, C<< >>
336              
337             =head1 BUGS
338              
339             Please report any bugs or feature requests to C, or through
340             the web interface at L. I will be notified, and then you'll
341             automatically be notified of progress on your bug as I make changes.
342              
343             =head1 SUPPORT
344              
345             You can find documentation for this module with the perldoc command.
346              
347             perldoc Elive::StandardV2
348              
349              
350             You can also look for information at:
351              
352             =over 4
353              
354             =item * RT: CPAN's request tracker
355              
356             L
357              
358             =item * AnnoCPAN: Annotated CPAN documentation
359              
360             L
361              
362             =item * CPAN Ratings
363              
364             L
365              
366             =item * Search CPAN
367              
368             L
369              
370             =back
371              
372             =head1 SEE ALSO
373              
374             I - this contains essential
375             background information and a full description of the available commands.
376              
377             =head1 ACKNOWLEDGEMENTS
378              
379              
380             =head1 LICENSE AND COPYRIGHT
381              
382             Copyright 2011-2012 David Warring.
383              
384             This program is free software; you can redistribute it and/or modify it
385             under the terms of either: the GNU General Public License as published
386             by the Free Software Foundation; or the Artistic License.
387              
388             See http://dev.perl.org/licenses/ for more information.
389              
390              
391             =cut
392              
393             1;