blib/lib/MOBY/Adaptor/moby/queryapi.pm untested

filter: Statementstmt 0.0% 0 / 129 Branchbran 0.0% 0 / 24 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 79 Podpod 0.0% 0 / 75 totaltotal 0.0% 0 / 317 CC 13 SCAR 11.7
CC
13
Cov
0%
new
12.0
username
6.0
password
6.0
CRAP 3.2
1 #$Id: queryapi.pm,v 1.3 2008/09/02 13:09:30 kawas Exp $
2 package MOBY::Adaptor::moby::queryapi;
3 use strict;
4 use Carp;
5 use vars qw($AUTOLOAD);
6  
7 use vars qw /$VERSION/;
8 $VERSION = sprintf "%d.%02d", q$Revision: 1.3 $ =~ /: (\d+)\.(\d+)/;
9  
10 =head1 NAME
11  
12 MOBY::Adaptor::moby::queryapi - An interface definition for MOBY Central underlying data-stores
13  
14 =cut
15  
16 =head1 SYNOPSIS
17  
18 use MOBY::Adaptor::moby::queryapi::mysql # implements this interface def
19 my $m = MOBY::Adaptor::moby::queryapi::mysql->new(
20 username => 'user',
21 password => 'pass',
22 dbname => 'mobycentral',
23 port => '3306',
24 sourcetype => 'DBD::mysql');
25 my $objectid = $m->insert_object(
26 {object_type => "MyObject"},
27 {description => "this represents a foo bar"},
28 {authority => "www.example.org"},
29 {contact_email, 'me@example.org'})
30  
31  
32 =cut
33  
34 =head1 DESCRIPTION
35  
36 This is an interface definition. There is NO implementation in this module
37 with the exception that certain calls to required parameters have get/setter
38 functions in this module (that can be overridden)
39  
40 =head1 AUTHORS
41  
42 Mark Wilkinson markw_at_ illuminae dot com
43 Dennis Wang oikisai _at_ hotmail dot com
44 BioMOBY Project: http://www.biomoby.org
45  
46  
47 =cut
48  
49 =head1 METHODS
50  
51  
52 =head2 new
53  
54 Title : new
55 Usage : my $MOBY = MOBY::Client::Central->new(%args)
56 Function : connect to one or more MOBY-Central
57 registries for searching
58 Returns : MOBY::Client::Central object
59 Args :
60 Notes :
61  
62  
63 =cut
64  
65  
66 sub new {
67 my ($caller, %args) = @_;
68 my $caller_is_obj = ref($caller);
69 my $class = $caller_is_obj || $caller;
70  
71 my $self = bless {}, $class;
72  
73 foreach my $attrname ( $self->_standard_keys_a ) {
74 if (exists $args{$attrname} && defined $args{$attrname}) {
75 $self->{$attrname} = $args{$attrname} }
76 elsif ($caller_is_obj) {
77 $self->{$attrname} = $caller->{$attrname} }
78 else {
79 $self->{$attrname} = $self->_default_for($attrname) }
80 }
81 return $self;
82 }
83  
84  
85 # Modified by Dennis
86  
87 {
88 #Encapsulated class data
89
90 #___________________________________________________________
91 #ATTRIBUTES
92 my %_attr_data = # DEFAULT ACCESSIBILITY
93 (
94 username => [undef, 'read/write'],
95 password => [undef, 'read/write'],
96 dbname => [undef, 'read/write'],
97 port => [undef, 'read/write'],
98 proxy => [undef, 'read/write'],
99 url => [undef, 'read/write'],
100 driver => [undef, 'read/write'],
101 );
102  
103 #_____________________________________________________________
104  
105 # METHODS, to operate on encapsulated class data
106  
107 # Is a specified object attribute accessible in a given mode
108 sub _accessible {
109 my ($self, $attr, $mode) = @_;
110 $_attr_data{$attr}[1] =~ /$mode/
111 }
112  
113 # Classwide default value for a specified object attribute
114 sub _default_for {
115 my ($self, $attr) = @_;
116 $_attr_data{$attr}[0];
117 }
118  
119 # List of names of all specified object attributes
120 sub _standard_keys_a {
121 keys %_attr_data;
122 }
123  
124 =head2 username
125  
126 Title : username
127 Usage : my $un = $API->username($arg)
128 Function : get/set username (if required)
129 Returns : String (username)
130 Args : String (username) - optional.
131  
132 =cut
133  
134  
135 sub username {
136 my ($self, $arg) = @_;
137 $self->{username} = $arg if defined $arg;
138 return $self->{username};
139 }
140  
141 =head2 password
142  
143 Title : password
144 Usage : my $un = $API->password($arg)
145 Function : get/set password (if required)
146 Returns : String (password)
147 Args : String (password) - optional.
148  
149 =cut
150  
151 sub password {
152 my ($self, $arg) = @_;
153 $self->{password} = $arg if defined $arg;
154 return $self->{password};
155 }
156  
157 =head2 dbname
158  
159 Title : dbname
160 Usage : my $un = $API->dbname($arg)
161 Function : get/set dbname (if required)
162 Returns : String (dbname)
163 Args : String (dbname) - optional.
164  
165 =cut
166  
167 sub dbname {
168 my ($self, $arg) = @_;
169 $self->{dbname} = $arg if defined $arg;
170 return $self->{dbname};
171 }
172  
173 =head2 port
174  
175 Title : port
176 Usage : my $un = $API->port($arg)
177 Function : get/set port (if required)
178 Returns : String (port)
179 Args : String (port) - optional.
180  
181 =cut
182  
183  
184 sub port {
185 my ($self, $arg) = @_;
186 $self->{port} = $arg if defined $arg;
187 return $self->{port};
188 }
189  
190 =head2 proxy
191  
192 Title : proxy
193 Usage : my $un = $API->proxy($arg)
194 Function : get/set proxy (if required)
195 Returns : String (proxy)
196 Args : String (proxy) - optional.
197  
198 =cut
199  
200 sub proxy {
201 my ($self, $arg) = @_;
202 $self->{proxy} = $arg if defined $arg;
203 return $self->{proxy};
204 }
205  
206  
207 =head2 sourcetype
208  
209 Title : sourcetype
210 Usage : my $un = $API->sourcetype($arg)
211 Function : get/set string name of sourcetype (e.g. mySQL)
212 Returns : String (sourcetype)
213 Args : String (sourcetype) - optional.
214  
215 =cut
216  
217 sub sourcetype {
218 my ($self, $arg) = @_;
219 $self->{sourcetype} = $arg if defined $arg;
220 return $self->{sourcetype};
221 }
222  
223  
224 =head2 driver
225  
226 Title : driver
227 Usage : my $un = $API->driver($arg)
228 Function : get/set string name of DSI driver module (e.g. DBI:mySQL)
229 Returns : String (driver)
230 Args : String (driver) - optional.
231  
232 =cut
233  
234 sub driver {
235 my ($self, $arg) = @_;
236 $self->{driver} = $arg if defined $arg;
237 return $self->{driver};
238 }
239  
240  
241 =head2 url
242  
243 Title : url
244 Usage : my $un = $API->url($arg)
245 Function : get/set url (if required)
246 Returns : String (url)
247 Args : String (url) - optional.
248  
249 =cut
250  
251 sub url {
252 my ($self, $arg) = @_;
253 $self->{url} = $arg if defined $arg;
254 return $self->{url};
255 }
256  
257 sub _implementation {
258 my ($self, $arg) = @_;
259 $self->{'_implementation'} = $arg if defined $arg;
260 return $self->{'_implementation'};
261 }
262  
263 =head2 dbh
264  
265 Title : dbh
266 Usage : my $un = $API->dbh($arg)
267 Function : get/set database handle (if required)
268 Returns : Database handle in whatever object is appropriate for sourcetype
269 Args : Database handle in whatever object is appropriate for sourcetype
270  
271 =cut
272  
273 sub dbh {
274 my ($self, $arg) = @_;
275 $self->{dbh} = $arg if defined $arg;
276 return $self->{dbh};
277 }
278
279 }
280  
281 # this should replace all other delete_*_input
282 # still incomplete
283 sub delete_inputs{
284 die "delete_inputs not implemented in adaptor\n";
285 }
286  
287 #still incomplete
288 sub delete_output { # this should replace all other delete_*_output
289 die "delete_output not implemented in adaptor\n";
290 }
291  
292 #
293 # collection_input table functions
294 #
295  
296 =head2 query_collection_input
297  
298 Title : query_collection_input
299 Usage : my $un = $API->query_collection_input(%arg)
300 Function : get the collection input information for a given service
301 Args : service_lsid => String
302 Returns : listref of hashrefs:
303 [{collection_input_id => Integer
304 article_name => String}, ...]
305 one hashref for each collection that service consumes
306 Notes : the fact that it returns a collection_input_id is bad since this
307 is only useful to an SQL-based API...
308  
309 =cut
310  
311 sub query_collection_input{
312 die "query_collection_input not implemented in adaptor\n";
313 }
314  
315 =head2 insert_collection_input
316  
317 Title : insert_collection_input
318 Usage : my $un = $API->insert_collection_input(%args)
319 Function : Inserts a Collection input into the database
320 Args : article_name => String,
321 service_instance_lsid => String,
322 Returns : Integer insertid
323 Notes : the fact that it returns an insertid is bad since this
324 is only useful to an SQL-based API...
325  
326 =cut
327  
328 sub insert_collection_input {
329 die "insert_collection_input not implemented in adaptor\n";
330 }
331  
332 =head2 delete_collection_input
333  
334 Title : delete_collection_input
335 Usage : my $un = $API->delete_collection_input(%args)
336 Function : Deletes Collection inputs according to the service instance
337 Args : service_instance_lsid => String,
338 Returns : ($err, $errstr)
339 $err = 1 if there was an delete error, 0 if successful
340 $errstr = String error message if there was an error
341  
342  
343 =cut
344  
345 sub delete_collection_input{
346 die "delete_collection_input not implemented in adaptor\n";
347 }
348  
349 #
350 # collection_output table fuctions
351 #
352  
353 =head2 query_collection_output
354  
355 Title : query_collection_output
356 Usage : my $un = $API->query_collection_output(%args)
357 Function : Executes a query for Collection outputs according to the service instance
358 Args : service_instance_lsid => String,
359 Returns : listref of hashrefs:
360 [{collection_output_id => Integer,
361 article_name => String,
362 service_instance_id => Integer}, ...]
363 Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term
364  
365 =cut
366  
367 sub query_collection_output{
368 die "query_collection_output not implemented in adaptor\n";
369 }
370  
371 =head2 insert_collection_output
372  
373 Title : insert_collection_output
374 Usage : my $un = $API->insert_collection_output(%args)
375 Function : Inserts a Collection output into the database
376 Args : article_name => String,
377 service_instance_lsid => String,
378 Returns : Integer insertid
379 Notes : the fact that it returns an insertid is bad since this
380 is only useful to an SQL-based API...
381  
382 =cut
383  
384 sub insert_collection_output {
385 die "insert_collection_output not implemented in adaptor\n";
386 #my ($self, %args) = @_;
387 #my $dbh = $self->dbh;
388 #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){
389 # # this should be dropped down into the mysql.pm module?? probably...
390 # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name}));
391 # my $id=$self->dbh->{mysql_insertid};
392 # return $id;
393 #}
394 }
395  
396 =head2 delete_collection_output
397  
398 Title : delete_collection_output
399 Usage : my $un = $API->delete_collection_output(%args)
400 Function : Deletes Collection outputs according to the service instance
401 Args : service_instance_lsid => String,
402 Returns : ($err, $errstr)
403 $err = 1 if there was an delete error, 0 if successful
404 $errstr = String error message if there was an error
405  
406  
407 =cut
408  
409 sub delete_collection_output{
410 die "delete_collection_output not implemented in adaptor\n";
411 }
412
413 #
414 # simple_output table functions
415 #
416  
417 =head2 query_simple_input
418  
419 Title : query_simple_input
420 Usage : my $un = $API->query_simple_input(%args)
421 Function : Executes a query for Simple inputs according to the service instance or collection output
422 Args : service_instance_lsid => String,
423 collection_input_id => Integer
424 Returns : listref of hashrefs:
425 [{simple_input_id => Integer,
426 object_type_uri => String,
427 namespace_type_uris => String,
428 article_name => String,
429 service_instance_id => Integer,
430 collection_input_id => Integer}, ...]
431 Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term
432  
433 =cut
434  
435 sub query_simple_input{
436 die "query_simple_input not implemented in adaptor\n";
437 }
438  
439 =head2 insert_simple_input
440  
441 Title : insert_simple_input
442 Usage : my $un = $API->insert_simple_input(%args)
443 Function : Inserts a Simple input into the database
444 Args : object_type_uri => String,
445 namespace_type_uris => String,
446 article_name => String,
447 service_instance_lsid => String,
448 collection_input_id => Integer
449 Returns : Integer insertid
450 Notes : the fact that it returns an insertid is bad since this
451 is only useful to an SQL-based API...
452  
453 =cut
454  
455 sub insert_simple_input {
456 die "insert_simple_input not implemented in adaptor\n";
457 }
458  
459 =head2 delete_simple_input
460  
461 Title : delete_simple_input
462 Usage : my $un = $API->delete_simple_input(%args)
463 Function : Deletes Simple inputs according to the service instance, or collection input
464 Args : service_instance_lsid => String,
465 collection_input_id => Integer
466 Returns : ($err, $errstr)
467 $err = 1 if there was an delete error, 0 if successful
468 $errstr = String error message if there was an error
469  
470 =cut
471  
472 sub delete_simple_input{
473 die "delete_simple_input not implemented in adaptor\n";
474 }
475  
476 #
477 # simple_output table functions
478 #
479  
480 =head2 query_simple_output
481  
482 Title : query_simple_output
483 Usage : my $un = $API->query_simple_output(%args)
484 Function : Executes a query for Simple outputs according to the service instance or collection output
485 Args : service_instance_lsid => String,
486 collection_output_id => Integer
487 Returns : listref of hashrefs:
488 [{simple_output_id => Integer,
489 object_type_uri => String,
490 namespace_type_uris => String,
491 article_name => String,
492 service_instance_id => Integer,
493 collection_output_id => Integer}, ...]
494 Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term
495  
496 =cut
497  
498 sub query_simple_output{
499 die "query_simple_output not implemented in adaptor\n";
500 }
501  
502 =head2 insert_simple_output
503  
504 Title : insert_simple_output
505 Usage : my $un = $API->insert_simple_output(%args)
506 Function : Inserts a Simple output into the database
507 Args : object_type_uri => String,
508 namespace_type_uris => String,
509 article_name => String,
510 service_instance_lsid => String,
511 collection_output_id => Integer
512 Returns : Integer insertid
513 Notes : the fact that it returns an insertid is bad since this
514 is only useful to an SQL-based API...
515  
516 =cut
517  
518 sub insert_simple_output {
519 die "insert_simple_output not implemented in adaptor\n";
520 }
521  
522 =head2 delete_simple_output
523  
524 Title : delete_simple_output
525 Usage : my $un = $API->delete_simple_output(%args)
526 Function : Deletes Simple outputs according to the service instance, or collection output
527 Args : service_instance_lsid => String,
528 collection_output_id => Integer
529 Returns : ($err, $errstr)
530 $err = 1 if there was an delete error, 0 if successful
531 $errstr = String error message if there was an error
532  
533 =cut
534  
535 sub delete_simple_output{
536 die "delete_simple_output not implemented in adaptor\n";
537 }
538  
539 # secondary_input table functions
540  
541 =head2 query_secondary_input
542  
543 Title : query_secondary_input
544 Usage : my $un = $API->query_secondary_input(%args)
545 Function : Executes a query for Secondary input articles in the database
546 Args : service_instance_lsid => String
547 Returns : listref of hashrefs:
548 [{secondary_input_id => Integer,
549 default_value => String,
550 maximum_value => Float,
551 minimum_value => Float,
552 enum_value => String,
553 datatype => String,
554 article_name => String,
555 service_instance_id => Integer}, ...]
556 Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term
557  
558 =cut
559  
560 sub query_secondary_input{
561 die "query_secondary_input not implemented in adaptor\n";
562 }
563  
564 =head2 insert_secondary_input
565  
566 Title : insert_secondary_input
567 Usage : my $un = $API->insert_secondar_input(%args)
568 Function : Inserts a Secondary input into the database
569 Args : default_value => String,
570 maximum_value => Float,
571 minimum_value => Float,
572 enum_value => String,
573 datatype => String,
574 article_name => String,
575 service_instance_lsid => String
576 Returns : Integer insertid
577 Notes : the fact that it returns an insertid is bad since this
578 is only useful to an SQL-based API...
579  
580 =cut
581  
582 sub insert_secondary_input{
583 die "insert_secondary_input not implemented in adaptor\n";
584 }
585  
586 =head2 delete_secondary_input
587  
588 Title : delete_secondary_input
589 Usage : my $un = $API->delete_secondary_input(%args)
590 Function : Deletes a Secondary input from the database
591 Args : service_instance_lsid => String
592 Returns : ($err, $errstr)
593 $err = 1 if there was an delete error, 0 if successful
594 $errstr = String error message if there was an error
595  
596 =cut
597  
598 sub delete_secondary_input{
599 die "delete_secondary_input not implemented in adaptor\n";
600 }
601  
602 #
603 # object table functions
604 #
605  
606 =head2 query_object
607  
608 Title : query_object
609 Usage : my $un = $API->query_object(%args)
610 Function : Executes a query for objects in the database
611 Args : type => String - lsid or a term identifying a particular object
612 Returns : listref of hashrefs:
613 [{object_id => Integer,
614 object_lsid => String,
615 object_type => String,
616 description => String,
617 authority => String,
618 contact_email => String}, ...]
619 Notes : Only allows querying by lsid or type term
620  
621 =cut
622  
623 sub query_object{
624 die "query_object not implemented in adaptor\n";
625 }
626  
627 =head2 insert_object
628  
629 Title : insert_object
630 Usage : my $un = $API->insert_object(%args)
631 Function : Inserts an object into the database
632 Args : object_type => String,
633 object_lsid => String,
634 description => String,
635 authority => String,
636 contact_email => String
637 Returns : Integer insertid
638 Notes : the fact that it returns an insertid is bad since this
639 is only useful to an SQL-based API...
640  
641 =cut
642  
643 sub insert_object{
644 die "insert_object not implemented in adaptor\n";
645 }
646  
647 =head2 delete_object
648  
649 Title : delete_object
650 Usage : my $un = $API->delete_object(%args)
651 Function : Deletes an object and any relationships it has from the database
652 Args : type => String - lsid or term identifying a particular object
653 Returns : ($err, $errstr)
654 $err = 1 if there was an delete error, 0 if successful
655 $errstr = String error message if there was an error
656  
657 =cut
658  
659 sub delete_object{
660 die "delete_object not implemented in adaptor\n";
661 }
662  
663 #
664 # object_term2term table functions
665 #
666  
667 =head2 query_object_term2term
668  
669 Title : query_object_term2term
670 Usage : my $un = $API->query_object_term2term(%args)
671 Function : Executes a query for object relationships in the database
672 Args : type => String - lsid or a term identifying a particular object
673 Returns : listref of hashrefs:
674 [{assertion_id => Integer,
675 relationship_type => String,
676 object1_id => String,
677 object2_id => String,
678 object2_articlename => String}, ...]
679 Notes : Only allows querying by lsid or type term
680  
681 =cut
682  
683 sub query_object_term2term{
684 die "query_object_term2term not implemented in adaptor\n";
685 }
686  
687 =head2 insert_object_term2term
688  
689 Title : insert_object_term2term
690 Usage : my $un = $API->insert_object_term2term(%args)
691 Function : Inserts an object relationship into the database
692 Args : relationship_type => String,
693 object1_id => String,
694 object2_id => String,
695 object2_articlename => String
696 Returns : Integer insertid
697 Notes : the fact that it returns an insertid is bad since this
698 is only useful to an SQL-based API...
699  
700 =cut
701  
702 sub insert_object_term2term{
703 die "insert_object_term2term not implemented in adaptor\n";
704 }
705  
706 # private routine in mysql api, should not be documented
707 sub delete_object_term2term{
708 die "delete_object_term2term not implemented in adaptor\n";
709 }
710  
711 #
712 # service_instance table functions
713 #
714  
715 =head2 query_service_instance
716  
717 Title : query_service_instance
718 Usage : my $un = $API->query_service_instance(%args)
719 Function : Executes a query for service instances in the database
720 Args : 0 or more:
721 service_instance_id => Integer
722 category => String
723 servicename => String
724 service_type_uri => String
725 'authority.authority_uri' => String - IMPORTANT notice use of quotes to avoid conflict with perl special operator '.'
726 url => String
727 'service_instance.contact_email' => String - Again IMPORTANT use of quotes
728 authoritative => Integer
729 description => String
730 signatureURL => String
731 lsid => String
732 Returns : listref of hashrefs:
733 [{service_instance_id => Integer,
734 category => String,
735 servicename => String,
736 service_type_uri => String,
737 authority.authority_uri => String,
738 url => String,
739 service_instance.contact_email => String,
740 authoritative => Integer,
741 description => String,
742 signatureURL => String,
743 lsid => String}, ...]
744 Notes : Allows querying by multiple conditions joined by 'and'
745  
746 =cut
747  
748 sub query_service_instance {
749 die "query_service_instance not implemented in adaptor\n";
750 }
751  
752 =head2 query_service_existence
753  
754 Title : query_service_existence
755 Usage : my $un = $API->query_service_existence(%args)
756 Function : Executes a query to check if the service exists in the database
757 Args : servicename => String
758 authority_uri => String
759 Returns : 1 if service exists
760 0 if no such service instance
761 Notes : Only allows querying by URI of the authority and service name
762  
763 =cut
764  
765 sub query_service_existence{
766 die "query_service_existence not implemented in adaptor\n";
767 }
768  
769 # This might be redundant of query_service_instance(), since same function can be
770 # replicated by several of its calls
771 sub match_service_type_uri{
772 die "match_service_type_uri not implemented in adaptor\n";
773 }
774  
775 =head2 insert_service_instance
776  
777 Title : insert_service_instance
778 Usage : my $un = $API->insert_service_instance(%args)
779 Function : Inserts a service instance into the database
780 Args : category => String,
781 servicename => String,
782 service_type_uri => String,
783 authority_uri => String,
784 url => String,
785 contact_email => String,
786 authoritative => Integer,
787 description => String,
788 signatureURL => String,
789 lsid => String
790 Returns : Integer insertid
791 Notes : the fact that it returns an insertid is bad since this
792 is only useful to an SQL-based API...
793  
794 =cut
795  
796 sub insert_service_instance {
797 die "insert_service_instance not implemented in adaptor\n";
798 }
799  
800 =head2 delete_service_instance
801  
802 Title : delete_service_instance
803 Usage : my $un = $API->delete_service_instance(%args)
804 Function : Deletes a service instance from the database
805 Args : service_instance_lsid => String
806 Returns : ($err, $errstr)
807 $err = 1 if there was an delete error, 0 if successful
808 $errstr = String error message if there was an error
809  
810  
811 =cut
812  
813  
814 sub delete_service_intance{
815 die "delete_service_intance not implemented in adaptor\n";
816 }
817
818 #
819 # authority table functions
820 #
821  
822 =head2 query_authority
823  
824 Title : query_authority
825 Usage : my $un = $API->query_authority(%args)
826 Function : Executes a query for authorities in the database
827 Args : authority_uri => String
828 Returns : listref of hashrefs:
829 [{authority_common_name => String,
830 authority_uri => String,
831 contact_email => String}, ...]
832 Notes : Only allows querying by URI of the authority
833  
834 =cut
835  
836 sub query_authority{
837 die "query_authority not implemented in adaptor\n";
838 }
839  
840 =head2 get_all_authorities
841  
842 Title : get_all_authorities
843 Usage : my $un = $API->get_all_authorities()
844 Function : Gets all unique authority URIs from the database
845 Args : no arguments
846 Returns : listref of hashrefs:
847 [{authority_uri => String}]
848  
849  
850 =cut
851  
852  
853 sub get_all_authorities{
854 die "get_all_authorities not implemented in adaptor\n";
855 }
856  
857 =head2 insert_authority
858  
859 Title : insert_authority
860 Usage : my $un = $API->insert_authority(%args)
861 Function : Inserts an authority into the database
862 Args : authority_common_name => String,
863 authority_uri => String,
864 contact_email => String
865 Returns : Integer insertid
866 Notes : the fact that it returns an insertid is bad since this
867 is only useful to an SQL-based API...
868  
869 =cut
870  
871 sub insert_authority{
872 die "insert_authority not implemented in adaptor\n";
873 }
874  
875 # Not implemented in mysql... should we allow deleting the authority?
876 sub delete_authority{
877 die "delete_authority not implemented in adaptor\n";
878 }
879  
880 #
881 # service table fuctions
882 #
883  
884 =head2 query_service
885  
886 Title : query_service
887 Usage : my $un = $API->query_service(%args)
888 Function : Executes a query for service class
889 Args : type => String - either service_type or service_lsid
890 Returns : listref of hashrefs:
891 [{service_id => Integer,
892 service_lsid => String,
893 service_type => String,
894 description => String,
895 authority => String,
896 contact_email => String}, ...]
897 Notes : the fact that it returns an service_id is bad since this
898 is only useful to an SQL-based API...
899  
900 =cut
901  
902 sub query_service{
903 die "query_service not implemented in adaptor\n";
904 }
905  
906 =head2 insert_service
907  
908 Title : insert_service
909 Usage : my $un = $API->insert_service(%args)
910 Function : Inserts a service class into the database
911 Args : service_type => String,
912 service_lsid => String,
913 description => String,
914 authority => String,
915 contact_email => String
916 Returns : Integer insertid
917 Notes : the fact that it returns an insertid is bad since this
918 is only useful to an SQL-based API...
919  
920 =cut
921  
922 sub insert_service{
923 die "insert_service not implemented in adaptor\n";
924 }
925  
926 =head2 delete_service
927  
928 Title : delete_service
929 Usage : my $un = $API->delete_service(%args)
930 Function : Deletes a service from the database
931 Args : service_lsid => String
932 Returns : ($err, $errstr)
933 $err = 1 if there was an delete error, 0 otherwise
934 $errstr = String error message if there was an error
935  
936  
937 =cut
938  
939 sub delete_service{
940 die "delete_service not implemented in adaptor\n";
941 }
942  
943 #
944 # service_term2term table functions
945 #
946  
947 =head2 query_service_term2term
948  
949 Title : query_service_term2term
950 Usage : my $un = $API->query_service_term2term(%args)
951 Function : Executes a query for service relationships
952 Args : type => String - either service_type or service_lsid
953 Returns : listref of hashrefs:
954 [{assertion_id => Integer,
955 relationship_type => String,
956 service1_id => String,
957 service2_id => String}, ...]
958 Notes : the fact that it returns an service ids is bad since this
959 is only useful to an SQL-based API...should return lsids
960  
961 =cut
962  
963 sub query_service_term2term{
964 die "query_service_term2term not implemented in adaptor\n";
965 }
966  
967 =head2 insert_service_term2term
968  
969 Title : insert_service_term2term
970 Usage : my $un = $API->insert_service_term2term(%args)
971 Function : Inserts a service relationship
972 Args : relationship_type => String,
973 service1_type => String,
974 service2_type => String
975 Returns : Integer insertid
976 Notes : the fact that it returns an insertid is bad since this
977 is only useful to an SQL-based API...
978  
979 =cut
980  
981 sub insert_service_term2term{
982 die "insert_service_term2term not implemented in adaptor\n";
983 }
984  
985 # private subroutine in mysql api
986  
987 sub delete_service_term2term{
988 die "delete_service_term2term not implemented in adaptor\n";
989 }
990  
991 #
992 # relationship table functions
993 #
994  
995 =head2 query_relationship
996  
997 Title : query_relationship
998 Usage : my $un = $API->query_relationship(%args)
999 Function : Executes a query for a relationship in an ontology
1000 Args : type => String,
1001 ontology => String
1002 Returns : listref of hashrefs:
1003 [{relationship_id => Integer,
1004 relationship_lsid => String,
1005 relationship_type => String,
1006 container => Integer,
1007 description => String,
1008 authority => String,
1009 contact_email => String,
1010 ontology => String}, ...]
1011 one hashref for each relationship
1012 Notes : the fact that it returns a relationship_id is bad since this
1013 is only useful to an SQL-based API...
1014  
1015 =cut
1016  
1017 sub query_relationship{
1018 die "query_relationship not implemented in adaptor\n";
1019 }
1020  
1021 # probably no need for this in the future and not implemented in mysql api
1022 sub insert_relationship{
1023 die "insert_relationship not implemented in adaptor\n";
1024 }
1025  
1026 # is not implemented in mysql api either... should this be removed?
1027 sub delete_relationship{
1028 die "delete_relationship not implemented in adaptor\n";
1029 }
1030  
1031 #
1032 # namespace table functions
1033 #
1034  
1035 =head2 query_namespace
1036  
1037 Title : query_namespace
1038 Usage : my $un = $API->query_namespace(%args)
1039 Function : Executes a query for namespace instances in the database
1040 Args : type => String - either lsid or term for a particular namespace
1041 Returns : listref of hashrefs:
1042 [{namespace_id => Integer,
1043 namespace_lsid => String,
1044 namespace_type => String,
1045 description => String,
1046 authority => String,
1047 contact_email => String}, ...]
1048  
1049 =cut
1050  
1051 sub query_namespace{
1052 die "query_namespace not implemented in adaptor\n";
1053 }
1054  
1055 =head2 insert_namespace
1056  
1057 Title : insert_namespace
1058 Usage : my $un = $API->insert_namespace(%args)
1059 Function : Deletes a namespace instance from the database
1060 Args : namespace_type => String,
1061 namespace_lsid => String,
1062 description => String,
1063 authority => String,
1064 contact_email => String
1065 Returns : Integer insertid
1066 Notes : the fact that it returns an insertid is bad since this
1067 is only useful to an SQL-based API...
1068  
1069 =cut
1070  
1071 sub insert_namespace{
1072 die "insert_namespace not implemented in adaptor\n";
1073 }
1074  
1075 =head2 delete_namespace
1076  
1077 Title : delete_namespace
1078 Usage : my $un = $API->delete_namespace(%args)
1079 Function : Deletes a namespace instance from the database
1080 Args : type => String - lsid or namespace term identifying a particular namespace
1081 Returns : ($err, $errstr)
1082 $err = 1 if there was an delete error, 0 otherwise
1083 $errstr = String error message if there was an error
1084  
1085 =cut
1086  
1087 sub delete_namespace{
1088 die "delete_namespace not implemented in adaptor\n";
1089 }
1090  
1091 =head2 query_namespace_term2term
1092  
1093 Title : query_namespace_term2term
1094 Usage : my $un = $API->query_namespace_term2term(%args)
1095 Function : Execute a query for namespaces_term2term
1096 Args : type => String - namespace_type you are checking for
1097 Returns : listref of hashrefs:
1098 [{assertion_id => Integer,
1099 relationship_type => String,
1100 namespace1_id => String,
1101 namespace2_id => String}, ...]
1102 Notes : namespace1_id and namespace2_id will be lsids
1103  
1104 =cut
1105  
1106 # namespace_term2term table functions
1107 sub query_namespace_term2term{
1108 die "query_namespace_term2term not implemented in adaptor\n";
1109 }
1110  
1111 # does not exist in mysql api, should this be removed?
1112 sub insert_namespace_term2term{
1113 die "insert_namespace_term2term not implemented in adaptor\n";
1114 }
1115  
1116 # changed to a private subroutine in mysql
1117 # I guess this subroutine should be removed from here?
1118 sub _delete_namespace_term2term{
1119 die "delete_namespace_term2term not implemented in adaptor\n";
1120 }
1121  
1122 =head2 check_object_usage
1123  
1124 Title : check_object_usage
1125 Usage : my $un = $API->check_object_usage(%args)
1126 Function : Execute a custom query for objects that are used by some service
1127 Args : type => String - either namespace_lsid or namespace_term
1128 Returns : a list:
1129 ($err, $errstr)
1130 $err = 1 if namespace is used by a service, 0 otherwise
1131 $errstr = contains the error message
1132  
1133 =cut
1134  
1135 # custom query subroutine for Moby::Central.pm->deregisterObjectClass()
1136 sub check_object_usage{
1137 die "check_object_usage not implemented in adaptor\n";
1138 }
1139  
1140 =head2 check_namespace_usage
1141  
1142 Title : check_namespace_usage
1143 Usage : my $un = $API->check_namespace_usage(%args)
1144 Function : Execute a custom query for namespaces that are used by some service
1145 Args : type => String - either namespace_lsid or namespace_term
1146 Returns : a list:
1147 ($err, $errstr)
1148 $err = 1 if namespace is used by a service, 0 otherwise
1149 $errstr = contains the error message
1150  
1151 =cut
1152  
1153 # custom query routine for Moby::Central.pm -> deregisterNamespace()
1154 sub check_namespace_usage{
1155 die "check_namespace_usage not implemented in adaptor\n";
1156 }
1157  
1158 =head2 check_keywords
1159  
1160 Title : check_keywords
1161 Usage : my $un = $API->check_keywords(%args)
1162 Function : Execute a custom query for services with keywords in its description
1163 Args : keywords => listref (of keywords)
1164 Returns : listref of hashrefs:
1165 [{service_instance_id => Integer,
1166 category => String,
1167 servicename => String,
1168 service_type_uri => String,
1169 authority_id => Integer,
1170 url => String,
1171 contact_email => String,
1172 authoritative => String,
1173 description => String,
1174 signatureURL => String,
1175 lsid => String}, ...]
1176 Each hash represents a service
1177 Notes : the fact that it returns a service_instance_id is bad since this
1178 is only useful to an SQL-based API...
1179 Keywords are assumed to be joined by "OR" for the query
1180  
1181 =cut
1182  
1183 # custom query routine for Moby::Central.pm -> findService()
1184 sub check_keywords{
1185 die "check_keywords not implemented in adaptor\n";
1186 }
1187  
1188 =head2 find_by_simple
1189  
1190 Title : find_by_simple
1191 Usage : my $un = $API->find_by_simple(%args)
1192 Function : Execute a custom query for service ids in simple_input/output
1193 Args : inout => String - to specify if input or output
1194 ancestor_string => String - values that occur in object_type_uri
1195 namespaceURIs => array-ref - reference to an array of namespace URIs
1196 Returns : listref of hashrefs:
1197 [{service_instance_id => Integer,
1198 namespace_type_uris => String}, ...]
1199 Notes : the fact that it returns a service_instance_id is bad since this
1200 is only useful to an SQL-based API...
1201  
1202 =cut
1203  
1204 # custom query subroutine for Moby::Central.pm->_searchForSimple()
1205 sub find_by_simple{
1206 die "find_by_simple not implemented in adaptor\n";
1207 }
1208  
1209 =head2 find_by_collection
1210  
1211 Title : find_by_collection
1212 Usage : my $un = $API->find_by_collection(%args)
1213 Function : Execute a custom query for service ids from collections
1214 Args : inout => String - to specify if input or output
1215 objectURI => String - value that binds to object_type_uri
1216 namespaceURIs => array-ref - reference to an array of namespace URIs
1217 Returns : listref of hashrefs:
1218 [{service_instance_id => Integer,
1219 namespace_type_uris => String}, ...]
1220 Notes : the fact that it returns a service_instance_id is bad since this
1221 is only useful to an SQL-based API...
1222  
1223 =cut
1224  
1225 # custom query subroutine for Moby::Central.pm->_searchForCollection()
1226 sub find_by_collection{
1227 die "find_by_collection not implemented in adaptor\n";
1228 }
1229  
1230 =head2 get_service_names
1231  
1232 Title : get_service_names
1233 Usage : my $un = $API->get_service_names(%args)
1234 Function : Execute a query for all service names
1235 Args : no inputs needed
1236 Returns : listref of hashrefs:
1237 [{authority_uri => String,
1238 servicename => String}, ...]
1239 one hashref for each service
1240  
1241 =cut
1242  
1243 # custom query subroutine for Moby::Central.pm->RetrieveServiceNames
1244 sub get_service_names{
1245 die "get_service_names not implemented in adaptor\n";
1246 }
1247  
1248 =head2 get_parent_terms
1249  
1250 Title : get_parent_terms
1251 Usage : my $un = $API->get_parent_terms(%args)
1252 Function : From a given term, traverse the ontology and get all parent terms
1253 Args : relationship_type_id => Integer - a bind value for relationship_type_id on an underlying SQL-based data source
1254 term => String - bindvalue for OntologyEntry.term
1255 Returns : listref of hashrefs:
1256 [{term => String}, ...]
1257 one hashref for each parent
1258  
1259 =cut
1260  
1261 # custom query for Moby::Central.pm->_flatten
1262 sub get_parent_terms{
1263 die "get_parent_terms not implemented in adaptor\n";
1264 }
1265  
1266 =head2 get_object_relationships
1267  
1268 Title : get_object_relationships
1269 Usage : my $un = $API->get_object_relationships(%args)
1270 Function : Execute a query for objects that have relationships with other objects
1271 Args : type => String - either an object name or LSID
1272 Returns : listref of hashrefs:
1273 [{relationship_type => String,
1274 object_type => String,
1275 object_lsid => String,
1276 description => String,
1277 authority => String,
1278 contact_email => String,
1279 object2_articlename => String}, ...]
1280 one hashref for each relationship between two objects
1281 Notes : relationship_type from object_term2term, object_lsid from object, and object2_articlename from object_term2term
1282  
1283 =cut
1284  
1285 # custom query subroutine for selecting from object_term2term and object tables
1286 # used in Moby::OntologyServer.pm->retrieveObject()
1287 sub get_object_relationships{
1288 die "get_object_relationships not implemented in adaptor\n";
1289 }
1290  
1291 =head2 get_relationship
1292  
1293 Title : get_relationship
1294 Usage : my $un = $API->get_relationship(%args)
1295 Function : Execute a query for a relationship between two ontologies
1296 Args : direction => String - direction in the ontology (eg. 'root')
1297 ontology => String - name of the table ontology
1298 term => String - a bind value for lsid
1299 relationship => String - a bind value for relationship_type
1300 Returns : reference to array containing array-refs representing the result set:
1301 [[String lsid, String relationship_type], ...]
1302 each array-ref represents one row
1303 Notes : Only returns distinct lsids from $ontology and relationship_type from $ontology_term2term
1304  
1305 =cut
1306  
1307 # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery()
1308 # note: returns a reference to an array containing ARRAY references
1309 sub get_relationship{
1310 die "get_relationship not implemented in adaptor\n";
1311 }
1312  
1313 =head2 get_all_relationships
1314  
1315 Title : get_all_relationships
1316 Usage : my $un = $API->get_all_relationships(%args)
1317 Function : Execute a query for all relationships represented in $ontology_term2term
1318 Args : direction => String - direction in the ontology (either 'root' or 'leaves')
1319 ontology => String - name of the table ontology
1320 Returns : reference to hash with the following structure:
1321 $resultHash->{String relationship_type}->{Integer key_entity_id} = <VALUE>
1322 The structure of <VALUE> depends on relationship_type and direction:
1323 HAS/HASA :
1324 <VALUE> = @([Integer value_entity_id, String articleName, Integer assertion_id])
1325 ISA, leaves :
1326 <VALUE> = @(Integer value_entity_id)
1327 ISA, root :
1328 <VALUE> = Integer value_entity_id
1329 Notes : The hash is built 'direction-aware', that is for
1330 - root : key_entity_id = ${ontology}1_id, value_entity_id = ${ontology}2_id
1331 - leaves: key_entity_id = ${ontology}2_id, value_entity_id = ${ontology}1_id
1332 The structure of the result hash is a bit complex because it is specifically
1333 designed for usage by MOBY::OntolgyServer::Relationships
1334 The result hash contains the entire table ${ontology}_term2term in order to
1335 reduce DB interaction in the ontology exploration
1336  
1337 =cut
1338  
1339 # Get all relationships in the queried database in one go. The
1340 # complete table ${ontology}_term2term is transferred into a hash
1341 # whose reference is finally returned. Important: note that the hash
1342 # is built 'direction aware', that is for objects 'object1_id' is used
1343 # as key when direction is 'root' and 'object2_id' as value. Vice
1344 # versa for the 'leaves' direction. Likewise for services.
1345 # Returns a hash reference.
1346 sub get_all_relationships{
1347 die "get_all_relationships not implemented in adaptor\n";
1348 }
1349  
1350 =head2 get_details_for_id_list
1351  
1352 Title : get_deails_for_id_list
1353 Usage : my $un = $API->get_all_relationships($ontology, $field_list, $id_list)
1354 Function : Retrieve details specified in @$field_list from $ontology for ids in @$id_list
1355 Args : $ontology => String - name of the table ontology
1356 $field_list => Reference to array of Strings representing table fields in $ontology
1357 $id_list => Reference to array of Integers representing ${ontology}_ids
1358 Returns : reference to hash with the following structure:
1359 $resultHash->{Integer ${ontology}_id}->{String field_name} = field_value
1360 Notes : This function is generic with respect to which details (fields) are retrieved, but
1361 is restricted to those tables whose name is identical to the ontology name (i.e.
1362 currently 'object', 'service', 'namespace' and 'relationship')
1363 Makes use of the 'select ... from ... where ... in (<LIST>)' statement syntax
1364 in order to reduce the number of DB interactions
1365 Used in MOBY::OntologyServer::Relationships, but maybe useful for other purposes...
1366  
1367 =cut
1368  
1369 # retrieve details for a number of entities from table $ontology
1370 # represented by a list of ${ontology}_id's;
1371 # used in MOBY::OntologyServer::Relationships
1372 sub get_details_for_id_list {
1373 die "get_details_for_id_list not implemented in adaptor\n";
1374 }
1375  
1376  
1377 # Not quite sure what this does...
1378 sub _checkURI {
1379 die "_checkURI not implemented in adaptor\n";
1380 }
1381
1382 sub _dump {
1383 my ($self) = @_;
1384 foreach my $attrname ( $self->_standard_keys ) {
1385 print STDERR "$attrname = ",($self->{$attrname}),"\n";
1386 }
1387 }
1388  
1389 sub DESTROY {}
1390 #
1391 #sub AUTOLOAD {
1392 # no strict "refs";
1393 # my ($self, $newval) = @_;
1394 #
1395 # $AUTOLOAD =~ /.*::(\w+)/;
1396 #
1397 # my $attr=$1;
1398 # if ($self->_accessible($attr,'write')) {
1399 #
1400 # *{$AUTOLOAD} = sub {
1401 # if (defined $_[1]) { $_[0]->{$attr} = $_[1] }
1402 # return $_[0]->{$attr};
1403 # }; ### end of created subroutine
1404 #
1405 #### this is called first time only
1406 # if (defined $newval) {
1407 # $self->{$attr} = $newval
1408 # }
1409 # return $self->{$attr};
1410 #
1411 # } elsif ($self->_accessible($attr,'read')) {
1412 #
1413 # *{$AUTOLOAD} = sub {
1414 # return $_[0]->{$attr} }; ### end of created subroutine
1415 # return $self->{$attr} }
1416 #
1417 #
1418 # # Must have been a mistake then...
1419 # croak "No such method: $AUTOLOAD";
1420 #}
1421 #
1422  
1423 1;