V3.pm

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