From kawas at pub.open-bio.org Sat Jul 2 10:12:50 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Sat Jul 2 11:03:04 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507021412.j62ECol4022638@pub.open-bio.org> kawas Sat Jul 2 10:12:49 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory pub.open-bio.org:/tmp/cvs-serv22613/org/biomoby/client Modified Files: CentralImpl.java Log Message: Changed the default endpoint to point to the new mobycentral registry. Eddie moby-live/Java/src/main/org/biomoby/client CentralImpl.java,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2005/04/07 16:37:02 1.20 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2005/07/02 14:12:49 1.21 @@ -88,10 +88,10 @@ /** Default location (endpoint) of a Moby registry. */ // public static final String DEFAULT_ENDPOINT = "http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY-Central.pl"; - public static final String DEFAULT_ENDPOINT = "http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY05/mobycentral.pl"; + public static final String DEFAULT_ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; /** Default namespace used by the contacted Moby registry. */ - public static final String DEFAULT_NAMESPACE = "http://mobycentral.cbr.nrc.ca/MOBY/Central"; + public static final String DEFAULT_NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; /************************************************************************* * Default constructor. It connects to a default Moby registry From mwilkinson at pub.open-bio.org Mon Jul 4 13:52:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 4 14:41:26 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041752.j64HqIIr006715@pub.open-bio.org> mwilkinson Mon Jul 4 13:52:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv6677/Perl/MOBY Modified Files: Central.pm Log Message: preparing for an interim release while we wait for the lsid resolution code to be fixed by IBM moby-live/Perl/MOBY Central.pm,1.153,1.154 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.153 retrieving revision 1.154 diff -u -r1.153 -r1.154 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/05/31 15:09:25 1.153 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/04 17:52:18 1.154 @@ -1419,7 +1419,8 @@ #service_instance => $service_instance ); # my $RDF_XML = $RDF_MODEL->serialize; my $LSID = $service_instance->LSID; - my $RDF = _getServiceInstanceRDF($LSID); + # my $RDF = _getServiceInstanceRDF($LSID); +my $RDF=""; unless ($RDF){return &_success("Registration successful but LSID resolution error",$SVC->service_instance_id,"" )} unless ($RDF =~ /RDF/){ return &_success("Registration successful but LSID resolution error $RDF",$SVC->service_instance_id,"") @@ -1435,10 +1436,10 @@ my $RDF_XML = ""; my $lsid_error = ""; my $lsid_good = 1; - use LS::ID; - use LS::Authority::WSDL::Constants; - use LS::Client::BasicResolver; - use LS::Locator; + #use LS::ID; + #use LS::Authority::WSDL::Constants; + #use LS::Client::BasicResolver; + #use LS::Locator; my $resolver = LS::Client::BasicResolver->new(); my $authority = $resolver->resolve( lsid => $lsid ); From mwilkinson at pub.open-bio.org Mon Jul 4 13:52:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 4 14:41:27 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041752.j64HqIv2006696@pub.open-bio.org> mwilkinson Mon Jul 4 13:52:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl In directory pub.open-bio.org:/tmp/cvs-serv6677/Perl Modified Files: Makefile.PL Log Message: preparing for an interim release while we wait for the lsid resolution code to be fixed by IBM moby-live/Perl Makefile.PL,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/Makefile.PL,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/Makefile.PL 2005/05/31 00:06:48 1.8 +++ /home/repository/moby/moby-live/Perl/Makefile.PL 2005/07/04 17:52:18 1.9 @@ -80,7 +80,7 @@ 'Text::Shellwords' => 1.00, 'SOAP::MIME' => 0.55, 'XML::XPath' => 1.12, - 'LS::ID' => 1.1.1, + # 'LS::ID' => 1.1.1, }, # e.g., Module::Name => 1.1 #'PM_FILTER' => "", ($] >= 5.005 ? ## Add these new keywords supported since 5.005 From mwilkinson at pub.open-bio.org Mon Jul 4 13:52:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 4 14:41:28 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041752.j64HqI48006735@pub.open-bio.org> mwilkinson Mon Jul 4 13:52:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv6677/Perl/t Modified Files: Client-Central.t Log Message: preparing for an interim release while we wait for the lsid resolution code to be fixed by IBM moby-live/Perl/t Client-Central.t,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2004/08/18 23:06:03 1.6 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/04 17:52:18 1.7 @@ -13,8 +13,8 @@ # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl', - URI => 'http://mobycentral.cbr.nrc.ca:8080/MOBY/Central'} + mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} } ); From mwilkinson at pub.open-bio.org Mon Jul 4 14:11:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 4 15:00:39 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041811.j64IBb6n006842@pub.open-bio.org> mwilkinson Mon Jul 4 14:11:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv6823/MOBY/Client Modified Files: OntologyServer.pm Log Message: point to new MOBY Central moby-live/Perl/MOBY/Client OntologyServer.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2004/12/14 20:47:04 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2005/07/04 18:11:37 1.11 @@ -84,7 +84,7 @@ my %_attr_data = # DEFAULT ACCESSIBILITY ( host => [ - "http://mobycentral.cbr.nrc.ca/cgi-bin/OntologyServer.cgi", + "http://mobycentral.capture.ubc.ca/cgi-bin/OntologyServer.cgi", 'read/write' ], proxy => [ undef, 'read/write' ], From mwilkinson at pub.open-bio.org Wed Jul 6 11:23:08 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 6 12:12:06 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507061523.j66FN8Fv015701@pub.open-bio.org> mwilkinson Wed Jul 6 11:23:08 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv15682/MOBY/Client Modified Files: OntologyServer.pm Log Message: Doh... typo in my new domain name moby-live/Perl/MOBY/Client OntologyServer.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2005/07/04 18:11:37 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2005/07/06 15:23:07 1.12 @@ -84,7 +84,7 @@ my %_attr_data = # DEFAULT ACCESSIBILITY ( host => [ - "http://mobycentral.capture.ubc.ca/cgi-bin/OntologyServer.cgi", + "http://mobycentral.icapture.ubc.ca/cgi-bin/OntologyServer.cgi", 'read/write' ], proxy => [ undef, 'read/write' ], From mwilkinson at pub.open-bio.org Wed Jul 6 11:32:53 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 6 12:21:44 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507061532.j66FWr7K015751@pub.open-bio.org> mwilkinson Wed Jul 6 11:32:53 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv15732 Modified Files: Central.pm Log Message: documentation for registration of secondary parameters was incorrect. It is an enum of String, Integer, Float, DateTime... not STRING, INT, FLOAT moby-live/Perl/MOBY Central.pm,1.155,1.156 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.155 retrieving revision 1.156 diff -u -r1.155 -r1.156 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/06 14:42:02 1.155 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/06 15:32:52 1.156 @@ -1201,7 +1201,7 @@ - INT|FLOAT|STRING + Integer|Float|String|DateTime ... ... ... From mwilkinson at pub.open-bio.org Wed Jul 6 12:46:41 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 6 13:35:33 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507061646.j66GkfAQ015996@pub.open-bio.org> mwilkinson Wed Jul 6 12:46:41 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv15977 Modified Files: Config.pm Log Message: adding secondary datatypes to the config module moby-live/Perl/MOBY Config.pm,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Config.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/Config.pm 2004/11/18 17:41:14 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/Config.pm 2005/07/06 16:46:41 1.7 @@ -22,6 +22,8 @@ mobynamespace => [ undef, 'read/write' ], mobyservice => [ undef, 'read/write' ], mobyrelationship => [ undef, 'read/write' ], + valid_secondary_datatypes => [["String", "Integer", "DateTime", "Float"], 'read'], + ); #_____________________________________________________________ From mwilkinson at pub.open-bio.org Fri Jul 8 14:41:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 8 15:29:50 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081841.j68IfAcx024586@pub.open-bio.org> mwilkinson Fri Jul 8 14:41:09 EDT 2005 Update of /home/repository/moby/moby-live/Perl/scripts In directory pub.open-bio.org:/tmp/cvs-serv24567/Perl/scripts Modified Files: testMOBYClientCentral_v05.pl Log Message: test script points to new, unfortunately production, registry moby-live/Perl/scripts testMOBYClientCentral_v05.pl,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/scripts/testMOBYClientCentral_v05.pl,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/scripts/testMOBYClientCentral_v05.pl 2004/08/11 16:30:57 1.24 +++ /home/repository/moby/moby-live/Perl/scripts/testMOBYClientCentral_v05.pl 2005/07/08 18:41:09 1.25 @@ -24,8 +24,8 @@ } } -my $URL = $ENV{MOBY_SERVER}?$ENV{MOBY_SERVER}:'http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl'; -my $URI = $ENV{MOBY_URI}?$ENV{MOBY_URI}:'http://mobycentral.cbr.nrc.ca:8080/MOBY/Central'; +my $URL = $ENV{MOBY_SERVER}?$ENV{MOBY_SERVER}:'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl'; +my $URI = $ENV{MOBY_URI}?$ENV{MOBY_URI}:'http://mobycentral.icapture.ubc.ca/MOBY/Central'; my $PROXY = $ENV{MOBY_PROXY}?$ENV{MOBY_PROXY}:'No Proxy Server'; my $C = MOBY::Client::Central->new( From kawas at pub.open-bio.org Fri Jul 8 14:57:00 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Fri Jul 8 15:45:38 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081857.j68Iv0SB024748@pub.open-bio.org> kawas Fri Jul 8 14:57:00 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv24723 Modified Files: Central.pm Log Message: Implemented the check for valid secondary input types. moby-live/Perl/MOBY Central.pm,1.156,1.157 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.156 retrieving revision 1.157 diff -u -r1.156 -r1.157 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/06 15:32:52 1.156 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/08 18:57:00 1.157 @@ -185,6 +185,7 @@ + =head1 METHODS @@ -1409,33 +1410,40 @@ ); } - use MOBY::Client::Central; - my $services = MOBY::Client::Central::_parseServices( '', '', $si ); - my $service_instance = shift @{$services}; - # my $storage = new RDF::Core::Storage::Memory; - # my $model = new RDF::Core::Model( Storage => $storage ); - # my $RDF_MODEL = MOBY::RDF::ServiceInstanceRDF->new( - #model => $model, - #service_instance => $service_instance ); - # my $RDF_XML = $RDF_MODEL->serialize; - my $LSID = $service_instance->LSID; + use MOBY::Client::Central; + my $services = MOBY::Client::Central::_parseServices( '', '', $si ); + my $service_instance = shift @{$services}; + + # my $storage = new RDF::Core::Storage::Memory; + # my $model = new RDF::Core::Model( Storage => $storage ); + # my $RDF_MODEL = MOBY::RDF::ServiceInstanceRDF->new( + #model => $model, + #service_instance => $service_instance ); + # my $RDF_XML = $RDF_MODEL->serialize; + my $LSID = $service_instance->LSID; + # my $RDF = _getServiceInstanceRDF($LSID); -my $RDF=""; - unless ($RDF){return &_success("Registration successful but LSID resolution error",$SVC->service_instance_id,"" )} - unless ($RDF =~ /RDF/){ - return &_success("Registration successful but LSID resolution error $RDF",$SVC->service_instance_id,"") + my $RDF = ""; + unless ($RDF) { + return &_success( "Registration successful but LSID resolution error", + $SVC->service_instance_id, "" ); + } + unless ( $RDF =~ /RDF/ ) { + return &_success( + "Registration successful but LSID resolution error $RDF", + $SVC->service_instance_id, "" ); } - return &_success( "Registration successful", - $SVC->service_instance_id, $RDF ); + return &_success( "Registration successful", $SVC->service_instance_id, + $RDF ); } - sub _getServiceInstanceRDF { - my ($self, $LSID) = @_; + my ( $self, $LSID ) = @_; my $lsid = LS::ID->new($LSID); my $RDF_XML = ""; my $lsid_error = ""; - my $lsid_good = 1; + my $lsid_good = 1; + #use LS::ID; #use LS::Authority::WSDL::Constants; #use LS::Client::BasicResolver; @@ -1451,13 +1459,14 @@ $authority->clean_cache(); my $resource = $authority->getResource($lsid); - unless ($resource) { - $lsid_error .= $authority->error_string. " " ; - return $lsid_error + unless ($resource) { + $lsid_error .= $authority->error_string . " "; + return $lsid_error; } - + my $response = $resource->get_metadata; unless ( ref($response) =~ /LS::Service::Response/ ) { + #TODO raise an error $lsid_error .= "Metadata response didn't come back"; return $lsid_error; @@ -1471,7 +1480,7 @@ } while (<$rsp>) { $RDF_XML .= $_; - } + } return $RDF_XML } @@ -1614,6 +1623,19 @@ ( $_->nodeType == TEXT_NODE ) && ( $datatype .= $_->nodeValue ); } } + + #ensure that thet type is correct (Integer | String | Float | DateTime) + $datatype =~ s/\s//g; + my $secondaries = $CONFIG->{valid_secondary_datatypes}; + my $valid; + map { $valid = 1 if $datatype eq $_ } @{$secondaries}; + unless ($valid) { + $SVC->DELETE_THYSELF; + return ( -1, +"Registration failed. $datatype must be one of type Integer, String, DateTime, or Float." + ); + } + my $defs = $parameter->getElementsByTagName('default'); if ( $defs->get_node(1) ) { foreach ( $defs->get_node(1)->childNodes ) @@ -2998,20 +3020,26 @@ =cut sub DUMP_MySQL { - my ( $pkg ) = @_; - my $config = MOBY::Config->new(); - my @dbsections = ('mobycentral', 'mobyobject', 'mobyservice', 'mobynamespace', 'mobyrelationship'); + my ($pkg) = @_; + my $config = MOBY::Config->new(); + my @dbsections = ( + 'mobycentral', 'mobyobject', + 'mobyservice', 'mobynamespace', + 'mobyrelationship' + ); my @response; - foreach my $dbsection (@dbsections) { - my $dbname = ${${$config}{$dbsection}}{'dbname'}; - my $username = ${${$config}{$dbsection}}{'username'}; - my $password = ${${$config}{$dbsection}}{'password'}; - my $host = ${${$config}{$dbsection}}{'url'}; - my $port = ${${$config}{$dbsection}}{'port'}; - open( IN, "mysqldump -h $host -P $port -u $username --password=$password $dbname|" ) - || die "can't open $dbname for dumping"; + foreach my $dbsection (@dbsections) { + my $dbname = ${ ${$config}{$dbsection} }{'dbname'}; + my $username = ${ ${$config}{$dbsection} }{'username'}; + my $password = ${ ${$config}{$dbsection} }{'password'}; + my $host = ${ ${$config}{$dbsection} }{'url'}; + my $port = ${ ${$config}{$dbsection} }{'port'}; + open( IN, +"mysqldump -h $host -P $port -u $username --password=$password $dbname|" + ) + || die "can't open $dbname for dumping"; my @dbdump; - while ( ) { + while () { push @dbdump, $_; } my $dbdump = ( join "", @dbdump ); @@ -3067,6 +3095,7 @@ + =head1 Internal Object Methods From mwilkinson at pub.open-bio.org Fri Jul 8 15:03:17 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 8 15:51:59 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081903.j68J3Hs2024881@pub.open-bio.org> mwilkinson Fri Jul 8 15:03:17 EDT 2005 Update of /home/repository/moby/moby-live/Database In directory pub.open-bio.org:/tmp/cvs-serv24842 Modified Files: mobycentral.mysql mobynamespace.mysql mobyobject.mysql mobyrelationship.mysql mobyservice.mysql reset Added Files: README mobyobject.data mobyservice.data Log Message: all files needed to create a new bootstrapped MOBY Central database moby-live/Database README,NONE,1.1 mobyobject.data,NONE,1.1 mobyservice.data,NONE,1.1 mobycentral.mysql,1.4,1.5 mobynamespace.mysql,1.5,1.6 mobyobject.mysql,1.8,1.9 mobyrelationship.mysql,1.4,1.5 mobyservice.mysql,1.6,1.7 reset,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobycentral.mysql,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Database/mobycentral.mysql 2004/09/14 21:32:35 1.4 +++ /home/repository/moby/moby-live/Database/mobycentral.mysql 2005/07/08 19:03:17 1.5 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobycentral --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'authority' +-- Table structure for table `authority` -- CREATE TABLE authority ( @@ -14,16 +14,10 @@ contact_email varchar(255) NOT NULL default '', authority_id int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (authority_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'authority' --- - - - --- --- Table structure for table 'collection_input' +-- Table structure for table `collection_input` -- CREATE TABLE collection_input ( @@ -31,16 +25,10 @@ article_name varchar(255) default NULL, service_instance_id int(10) unsigned NOT NULL default '0', PRIMARY KEY (collection_input_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'collection_input' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Table structure for table 'collection_output' +-- Table structure for table `collection_output` -- CREATE TABLE collection_output ( @@ -48,42 +36,30 @@ article_name varchar(255) default NULL, service_instance_id int(10) unsigned NOT NULL default '0', PRIMARY KEY (collection_output_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'collection_output' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Table structure for table 'secondary_input' +-- Table structure for table `secondary_input` -- CREATE TABLE secondary_input ( secondary_input_id int(10) unsigned NOT NULL auto_increment, default_value text, - maximum_value decimal(10,0) default NULL, - minimum_value decimal(10,0) default NULL, + maximum_value float default NULL, + minimum_value float default NULL, enum_value text, - datatype enum('INT','FLOAT','STRING') NOT NULL default 'INT', + datatype enum('String','Integer','DateTime','Float') default NULL, article_name varchar(255) default NULL, service_instance_id int(10) unsigned NOT NULL default '0', PRIMARY KEY (secondary_input_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'secondary_input' --- - - - --- --- Table structure for table 'service_instance' +-- Table structure for table `service_instance` -- CREATE TABLE service_instance ( - category enum('moby','cgi','soap') NOT NULL default 'moby', + category enum('moby','soap','wsdl','cgi') default NULL, servicename varchar(255) NOT NULL default '', service_type_uri varchar(255) NOT NULL default '', authority_id int(10) unsigned NOT NULL default '0', @@ -92,19 +68,25 @@ authoritative enum('1','0') NOT NULL default '0', description text NOT NULL, service_instance_id int(10) unsigned NOT NULL auto_increment, - signatureURL varchar(255), + signatureURL varchar(255) default NULL, + lsid varchar(255) NOT NULL default '', PRIMARY KEY (service_instance_id), UNIQUE KEY servicename (servicename,authority_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'service_instance' +-- Table structure for table `service_validation` -- - +CREATE TABLE service_validation ( + signatureURL varchar(255) NOT NULL default '', + error_code int(4) NOT NULL default '0', + counter int(1) NOT NULL default '0', + PRIMARY KEY (signatureURL) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Table structure for table 'simple_input' +-- Table structure for table `simple_input` -- CREATE TABLE simple_input ( @@ -115,16 +97,10 @@ service_instance_id int(10) unsigned default NULL, collection_input_id int(10) unsigned default NULL, PRIMARY KEY (simple_input_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'simple_input' --- - - - --- --- Table structure for table 'simple_output' +-- Table structure for table `simple_output` -- CREATE TABLE simple_output ( @@ -135,11 +111,5 @@ service_instance_id int(10) unsigned default NULL, collection_output_id int(10) unsigned default NULL, PRIMARY KEY (simple_output_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'simple_output' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobynamespace.mysql,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Database/mobynamespace.mysql 2003/05/24 20:22:15 1.5 +++ /home/repository/moby/moby-live/Database/mobynamespace.mysql 2005/07/08 19:03:17 1.6 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobynamespace --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'namespace' +-- Table structure for table `namespace` -- CREATE TABLE namespace ( @@ -15,18 +15,20 @@ description text NOT NULL, authority varchar(255) NOT NULL default '', contact_email varchar(255) NOT NULL default '', + object text, + generic_url tinytext, + synonym text, + url_syntax text, + url_example text, + shorthand_name varchar(255) default NULL, + example_id varchar(255) default NULL, + note mediumtext, PRIMARY KEY (namespace_id), UNIQUE KEY namespace_type (namespace_type) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'namespace' --- - - - --- --- Table structure for table 'namespace_term2term' +-- Table structure for table `namespace_term2term` -- CREATE TABLE namespace_term2term ( @@ -35,11 +37,5 @@ namespace1_id int(11) NOT NULL default '0', namespace2_id int(11) NOT NULL default '0', PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'namespace_term2term' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobyobject.mysql,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Database/mobyobject.mysql 2003/06/10 23:01:26 1.8 +++ /home/repository/moby/moby-live/Database/mobyobject.mysql 2005/07/08 19:03:17 1.9 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobyobject --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'object' +-- Table structure for table `object` -- CREATE TABLE object ( @@ -17,21 +17,10 @@ contact_email varchar(255) NOT NULL default '', PRIMARY KEY (object_id), UNIQUE KEY object_type (object_type) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'object' --- - - -INSERT INTO object VALUES (1,'urn:lsid:biomoby.org:objectclass:object','Object','an object','openinformatics.com','jason@openinformatics.com'); -INSERT INTO object VALUES (2,'urn:lsid:biomoby.org:objectclass:integer','Integer','an int','openinformatics.com','jason@openinformatics.com'); -INSERT INTO object VALUES (3,'urn:lsid:biomoby.org:objectclass:string','String','a string','openinformatics.com','jason@openinformatics.com'); -INSERT INTO object VALUES (4,'urn:lsid:biomoby.org:objectclass:float','Float','a floating point number','openinformatics.com','jason@openinformatics.com'); -INSERT INTO object VALUES (5,'urn:lsid:biomoby.org:objectclass:datetime','DateTime','a date or time in ISO-8601 format','openinformatics.com','jason@openinformatics.com'); - --- --- Table structure for table 'object_term2term' +-- Table structure for table `object_term2term` -- CREATE TABLE object_term2term ( @@ -41,14 +30,5 @@ object2_id int(11) NOT NULL default '0', object2_articlename varchar(255) default NULL, PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'object_term2term' --- - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -INSERT INTO object_term2term VALUES (1,'urn:lsid:biomoby.org:objectrelation:isa',2,1,NULL); -INSERT INTO object_term2term VALUES (2,'urn:lsid:biomoby.org:objectrelation:isa',3,1,NULL); -INSERT INTO object_term2term VALUES (3,'urn:lsid:biomoby.org:objectrelation:isa',4,1,NULL); -INSERT INTO object_term2term VALUES (4,'urn:lsid:biomoby.org:objectrelation:isa',5,3,NULL); =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobyrelationship.mysql,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Database/mobyrelationship.mysql 2003/05/24 20:26:07 1.4 +++ /home/repository/moby/moby-live/Database/mobyrelationship.mysql 2005/07/08 19:03:17 1.5 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobyrelationship --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'relationship' +-- Table structure for table `relationship` -- CREATE TABLE relationship ( @@ -19,20 +19,10 @@ ontology varchar(200) NOT NULL default '', PRIMARY KEY (relationship_id), UNIQUE KEY LSID (relationship_lsid) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'relationship' --- - - -INSERT INTO relationship VALUES (1,'urn:lsid:biomoby.org:objectrelation:hasa','hasa','1','Describes a container relationship where the predicate object is contained within the subject object in one copy only','www.biomoby.org','markw@illuminae.com','object'); -INSERT INTO relationship VALUES (2,'urn:lsid:biomoby.org:objectrelation:has','has','1','Describes a container relationship where the predicate object is contained within the subject object in one or more copies','www.biomoby.org','markw@illuminae.com','object'); -INSERT INTO relationship VALUES (3,'urn:lsid:biomoby.org:objectrelation:isa','isa','0','Describes an inheritence relationship where all attributes of the parent must be in the child','www.biomoby.org','markw@illuminae.com','object'); -INSERT INTO relationship VALUES (4,'urn:lsid:biomoby.org:servicerelation:isa','isa','0','Describes an inheritence relationship where the predicate service performs a more specific operation compared to the subject service','www.biomoby.org','markw@illuminae.com','service'); - --- --- Table structure for table 'relationship_term2term' +-- Table structure for table `relationship_term2term` -- CREATE TABLE relationship_term2term ( @@ -42,9 +32,5 @@ relationship2_id int(10) unsigned NOT NULL default '0', object2_articlename varchar(255) default NULL, PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'relationship_term2term' --- +) ENGINE=MyISAM DEFAULT CHARSET=latin1; =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobyservice.mysql,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Database/mobyservice.mysql 2003/06/10 23:01:26 1.6 +++ /home/repository/moby/moby-live/Database/mobyservice.mysql 2005/07/08 19:03:17 1.7 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobyservice --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'service' +-- Table structure for table `service` -- CREATE TABLE service ( @@ -17,22 +17,10 @@ contact_email varchar(255) NOT NULL default '', PRIMARY KEY (service_id), UNIQUE KEY service_type (service_type) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'service' --- - - -INSERT INTO service VALUES (1,'urn:lsid:biomoby.org:servicetype:service','Service','The base type','openinformatics.com','email'); -INSERT INTO service VALUES (2,'urn:lsid:biomoby.org:servicetype:retrieval','Retrieval','The base retrieval type','openinformatics.com','email'); -INSERT INTO service VALUES (3,'urn:lsid:biomoby.org:servicetype:resolution','Resolution','resolve data','openinformatics.com','email'); -INSERT INTO service VALUES (4,'urn:lsid:biomoby.org:servicetype:parsing','Parsing','parse data','openinformatics.com','email'); -INSERT INTO service VALUES (5,'urn:lsid:biomoby.org:servicetype:registration','Registration','register data','openinformatics.com','email'); -INSERT INTO service VALUES (6,'urn:lsid:biomoby.org:servicetype:analysis','Analysis','analyze data','openinformatics.com','email'); - --- --- Table structure for table 'service_term2term' +-- Table structure for table `service_term2term` -- CREATE TABLE service_term2term ( @@ -41,15 +29,5 @@ service1_id int(11) NOT NULL default '0', service2_id int(11) NOT NULL default '0', PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'service_term2term' --- - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -INSERT INTO service_term2term VALUES (8,'urn:lsid:biomoby.org:servicerelation:isa',2,1); -INSERT INTO service_term2term VALUES (4,'urn:lsid:biomoby.org:servicerelation:isa',3,1); -INSERT INTO service_term2term VALUES (5,'urn:lsid:biomoby.org:servicerelation:isa',4,1); -INSERT INTO service_term2term VALUES (6,'urn:lsid:biomoby.org:servicerelation:isa',5,1); -INSERT INTO service_term2term VALUES (7,'urn:lsid:biomoby.org:servicerelation:isa',6,1); =================================================================== RCS file: /home/repository/moby/moby-live/Database/reset,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Database/reset 2003/05/24 20:41:44 1.1 +++ /home/repository/moby/moby-live/Database/reset 2005/07/08 19:03:17 1.2 @@ -1,6 +1,7 @@ +#!/bin/bash mysql -u root -p < reset2 mysql -u root -p mobycentral < mobycentral.mysql -mysql -u root -p mobyobject < mobyobject.mysql -mysql -u root -p mobyservice < mobyservice.mysql +mysql -u root -p mobyobject < mobyobject.data +mysql -u root -p mobyservice < mobyservice.data mysql -u root -p mobynamespace < mobynamespace.mysql mysql -u root -p mobyrelationship < mobyrelationship.mysql From mwilkinson at pub.open-bio.org Fri Jul 8 15:22:21 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 8 16:11:44 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081922.j68JMLnS025097@pub.open-bio.org> mwilkinson Fri Jul 8 15:22:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv25078/t Modified Files: Client-Central.t Log Message: added a test for Eddie's changes to the test harness moby-live/Perl/t Client-Central.t,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/04 17:52:18 1.7 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/08 19:22:21 1.8 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; -use Test::More tests => 13; # perldoc Test::More for details +use Test::More tests => 14; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; @@ -96,7 +96,33 @@ ( ok($r->success,"Service Type registration successful") ) or diag("Service Type registration failure: ".$r->message) ; -# Test 8 +# Test 8 # should fail +$r = $C->registerService( + serviceName => "myfirstservice", + serviceType => "Retrieval", + authURI => "test.suite.com", + contactEmail => 'your@mail.address', + description => "this is my first service", + category => "moby", + URL => "http://illuminae/cgi-bin/service.pl", + input =>[ + ['articleName1', [Object => ['UglyNamespace']]], # Simple + ], + output =>[ + ['articleName2', [String => ['UglyNamespace']]], # Simple + ], + secondary => { + parametername1 => { + datatype => 'INTEGER', + default => 0, + max => 10, + min => -10, + enum => [-10, 10, 0]}}); + +( ok(!$r->success,"Service registration correctly failed") +) or diag("Service registration failure: ".$r->message) ; + +# Test 9 $r = $C->registerService( serviceName => "myfirstservice", serviceType => "Retrieval", @@ -123,7 +149,7 @@ ) or diag("Service registration failure: ".$r->message) ; -# Test 9 +# Test 10 $r = $C->deregisterService( serviceName => "myfirstservice", @@ -133,17 +159,17 @@ ) or diag("Service deregistration failure: ".$r->message) ; -# Test 10 +# Test 11 $r = $C->deregisterObjectClass(objectType => "TotalCrap"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; -# Test 11 +# Test 12 $r = $C->deregisterServiceType(serviceType => "CrappyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; -# Test 12 +# Test 13 $r = $C->deregisterNamespace(namespaceType =>'UglyNamespace'); ( ok($r->success,"namespace deregistration successful") ) or diag("namespace deregistration failure: ".$r->message) ; @@ -152,7 +178,7 @@ # #my @service ; # -## Tests 7,8: locateServiceByOutput with output 'Object' and full_objects + full_services +## Tests 14,15: locateServiceByOutput with output 'Object' and full_objects + full_services #@service = $C->locateServiceByOutput( # objectType => "Object", # fullObjects => 1, @@ -166,7 +192,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 9,10: Testing locateServiceByOutput with output "Object" and full_services only +## Tests 16,17: Testing locateServiceByOutput with output "Object" and full_services only #@service = $C->locateServiceByOutput( # objectType => "Object", # fullObjects => 0, @@ -179,7 +205,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 11,12: Testing locateServiceByInput with input +## Tests 18,19: Testing locateServiceByInput with input ## 'Object' => Genbank/GI and full_objects + full_services #@service = $C->locateServiceByInput( # input => {"Sequence" => ["Genbank/GI"]}, @@ -194,7 +220,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 13,14: Testing locateServiceByInput with input +## Tests 20,21: Testing locateServiceByInput with input ## 'Object' => Genbank/GI and full_services only #@service = $C->locateServiceByInput( # input => {"Object" => ["Genbank/GI"]}, @@ -209,7 +235,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 15,16: Testing locateServiceByType with type 'Retrieve' + full_services +## Tests 22,23: Testing locateServiceByType with type 'Retrieve' + full_services #@service = $C->locateServiceByType( # serviceType => "Retrieve", # fullServices => 1, From dwang at pub.open-bio.org Wed Jul 13 14:18:39 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 13 15:07:00 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507131818.j6DIIdA6020839@pub.open-bio.org> dwang Wed Jul 13 14:18:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20813/Perl/MOBY Modified Files: Central.pm Log Message: 1st commit by Dennis moby-live/Perl/MOBY Central.pm,1.157,1.158 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.157 retrieving revision 1.158 diff -u -r1.157 -r1.158 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/08 18:57:00 1.157 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 18:18:39 1.158 @@ -470,6 +470,9 @@ =cut sub deregisterObjectClass { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'object' ); return &_error( "Message Format Incorrect", "" ) unless ($payload); @@ -482,42 +485,14 @@ return &_error( "Object class $class does not exist", "" ) unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return &_error( - "Object class $class is used by a service and may not be deregistered", - "" - ) - if ($id); - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); - return &_error( - "Object class $class is used by a service and may not be deregistered", - "" - ) - if ($id); - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return &_error( - "Object class $class is used by a service and may not be deregistered", - "" - ) - if ($id); - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); + + my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); return &_error( "Object class $class is used by a service and may not be deregistered", "" ) - if ($id); + if ($errormsg); + my ( $success2, $message2, $URI ) = $OntologyServer->deleteObject( term => $class ); $success2 == 0 && return &_error( $message2, $URI ); @@ -767,6 +742,9 @@ =cut sub deregisterServiceType { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'service' ); return &_error( "Message Format Incorrect", "" ) unless ($payload); @@ -781,10 +759,10 @@ return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance where service_type_uri = ?}, - undef, $existingURI - ); + + my $result = $adaptor->query_service_instance({service_type_uri => $existingURI}); + my $id = @$result[0]->{service_instance_id}; + return &_error( "A registered service depends on this service type", "" ) if ($id); my ( $success2, $message2, $deleteURI ) = @@ -924,6 +902,9 @@ =cut sub deregisterNamespace { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'namespace' ); return &_error( "Message Format Incorrect", "" ) unless ($payload); @@ -936,71 +917,10 @@ return &_error( "Namespace Type $term does not exist", "" ) unless ($existingURI); my $dbh = MOBY::central_db_connection->new->dbh; - my $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } + my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term}); + return &_error( $errstr, "") + if ($err); + my ( $success2, $message2, $URI ) = $OntologyServer->deleteNamespace( term => $term ); $success2 == 0 && return &_error( $message2, $URI ); @@ -1936,6 +1856,9 @@ =cut sub findService { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; $debug && &_LOG("\nLOOKING FOR SERVICES\n"); my %findme = &_findServicePayload($payload); @@ -1965,18 +1888,16 @@ $debug && _LOG( "authoritative added; criterion count is now $criterion_count\n"); - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where authoritative=?}, - undef, $findme{authoritative} - ); + my $ids = $adaptor->query_service_instance({authoritative => $findme{authoritative}}); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instnace_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2002,10 +1923,8 @@ $children_string .= ( join ',', map { "\'$_\'" } @children ); } $children_string =~ s/\,$//; - my $ids = - $dbh->selectall_arrayref( -"select service_instance_id from service_instance where service_type_uri in ($children_string)" - ); + my $ids = $adaptor->match_service_type_uri({service_type_uri => $children_string}); + $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { @@ -2018,26 +1937,24 @@ ++$criterion_count; $debug && _LOG("authURI added; criterion count is now $criterion_count\n"); - my ($id) = $dbh->selectrow_array( -q{select authority_id from authority where authority_uri = ? or authority_common_name = ?}, - undef, - ( $findme{authURI}, $findme{authURI} ) - ); + + my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}}); + my $id = @$result[0]->{authority_id}; + unless ($id) { return &_serviceListResponse( $dbh, undef ); } - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where authority_id=?}, - undef, $id - ); + + my $ids = $adaptor->query_service_instance({authority_id => $id}); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2046,18 +1963,17 @@ $debug && _LOG( "servicename added; criterion count is now $criterion_count\n"); - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where servicename=?}, - undef, $findme{servicename} - ); + + my $ids = $adaptor->query_service_instance({servicename => $findme{servicename}}); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2066,19 +1982,17 @@ ++$criterion_count; $debug && _LOG("category added; criterion count is now $criterion_count\n"); - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where category=?}, - undef, - lc( $findme{category} ) - ); + + my $ids = $adaptor->query_service_instance({category => lc( $findme{category}) }); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2086,19 +2000,9 @@ ++$criterion_count; $debug && _LOG("Keywords added; criterion count is now $criterion_count\n"); - my $searchstring; - foreach my $kw ( @{ $findme{keywords} } ) { - $debug && &_LOG("KEYWORD $kw\n"); - $kw =~ s/\*//g; - $kw = $dbh->quote("%$kw%"); - $searchstring .= " OR description like $kw "; - } - $searchstring =~ s/OR//; # just the first one - $debug && &_LOG("search $searchstring\n"); - my $ids = - $dbh->selectall_arrayref( -"select service_instance_id from service_instance where $searchstring" - ); + + my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + unless ( scalar @{$ids} ) { $debug && &_LOG( @@ -2264,6 +2168,8 @@ } sub _searchForSimple { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); # returns list of service_instance ID's # that match this simple @@ -2282,24 +2188,17 @@ $ancestor_string .= ( join ',', map { "\'$_\'" } @ancestors ); } $ancestor_string =~ s/\,$//; - my $query = -"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " - ; # if service_instance_id is null then it must be a collection input. - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/OR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; - } + + my ($query, $result) = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); + $debug && _LOG("\nQUERY $query\n"); my @valid_services; - my $sth = $dbh->prepare($query); - $sth->execute; - while ( my ( $id, $nss ) = $sth->fetchrow_array ) - { # get the service instance ID and the namespaces that matched + + foreach my $row (@$result) + { + # get the service instance ID and the namespaces that matched + my $id = $row->{service_instance_id}; + my $nss = $row->{namespace_type_uris}; if ( $nss && scalar @{$namespaceURIs} ) { # if this service cares about namespaces at all, # and if namespaces were specified in the query, @@ -2327,9 +2226,11 @@ #Eddie - converted sub _searchForCollection { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, $node, $expand, $inout ) = @_; # $node in this case is a Collection object - my $query; # luckily, we can return a redundant list of service id's and # this will be cleaned up in the caller @@ -2339,30 +2240,15 @@ next unless ( $simple->nodeName =~ /simple/i ); my ( $objectURI, $namespaceURIs ) = &_extractObjectTypesAndNamespaces($simple); - $query = "select - c.service_instance_id, - s.namespace_type_uris - from - simple_$inout as s, - collection_$inout as c - where - s.collection_${inout}_id IS NOT NULL - AND s.collection_${inout}_id = c.collection_${inout}_id - AND object_type_uri = '$objectURI' "; - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/^\sOR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; # add the AND clause - } + + my ($query, $result) = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); + $debug && &_LOG("QUERY: $query"); - my $sth = $dbh->prepare($query); - $sth->execute; - while ( my ( $id, $nss ) = $sth->fetchrow_array ) + + foreach my $row (@$result ) { # get the service instance ID and the namespaces that matched + my $id = $row->{service_instance_id}; + my $nss = $row->{namespace_type_uris}; if ( $nss && scalar @{$namespaceURIs} ) { # if this service cares about namespaces at all, # and if namespaces were specified in the query, @@ -2582,13 +2468,17 @@ =cut sub retrieveServiceProviders { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ($pkg) = @_; my $dbh = MOBY::central_db_connection->new()->dbh; - my $sth = $dbh->prepare("select distinct authority_uri from authority"); - $sth->execute; + + my $result = $adaptor->getUniqueAuthorityURI(); + my $providers = "\n"; - while ( my ($prov) = $sth->fetchrow_array ) { - $providers .= "\n"; + foreach my $prov (@$result) { + $providers .= "\n"; } $providers .= "\n"; return $providers; @@ -2612,16 +2502,15 @@ =cut sub retrieveServiceNames { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ($pkg) = shift; my $dbh = MOBY::central_db_connection->new()->dbh; - my $sth = - $dbh->prepare( -"select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id" - ); - $sth->execute; + my $result = $adaptor->getServiceNames(); my $names = "\n"; - while ( my ( $auth, $name ) = $sth->fetchrow_array ) { - $names .= "\n"; + foreach my $row (@$result) { + $names .= "\n"; } $names .= "\n"; return $names; @@ -3051,25 +2940,17 @@ *DUMP = \&DUMP_MySQL; # alias it for backward compatibility sub _flatten { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); # from a given term, traverse the ontology # and flatten it into a list of parent terms my ( $dbh, $type, $term, $seen ) = @_; - my $sth = $dbh->prepare( " - select - OE1.term - from - OntologyEntry as OE1, - OntologyEntry as OE2, - Term2Term as TT - where - ontologyentry2_id = OE2.id - and ontologyentry1_id = OE1.id - and relationship_type_id = $type - and OE2.term = ?" - ); - $sth->execute($term); - while ( my ($term) = $sth->fetchrow_array ) { + + my $result = $adaptor->getParentTerms({relationship_type_id => $type}, {term => $term}); + + foreach my $row (@$result) { + my $term = $row->{term}; next if ${$seen}{$term}; &_flatten( $dbh, $type, $term, $seen ); ${$seen}{$term} = 1; @@ -3232,12 +3113,17 @@ =cut sub _traverseServiceDAG { + + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, $serviceType, $sth_hash ) = @_; my %sth = %{$sth_hash}; my %ServiceIDs; - my $sth = $dbh->prepare( $sth{get_service_type_id} ); - $sth->execute($serviceType); - my ($root_id) = $sth->fetchrow_array; + + my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); + my $row = shift(@$result); + my ($root_id) = @$row; return undef unless $root_id; # we have to do a traversal of the DAG here to get all child nodes... @@ -3250,11 +3136,13 @@ next if ( $ServiceIDs{$service} eq "tested" ) ; # if it has been tested already then move on - my $sth = $dbh->prepare( $sth{get_service_hierarchy_list} ); - $sth->execute($service); # execute the query for child nodes + + my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); + # execute the query for child nodes $ServiceIDs{$service} = "tested"; # mark it as tested - while ( my $new = $sth->fetchrow_array ) + foreach my $row (@$result) { # now get each of the child nodes + my $new = @$row; next if ( defined $ServiceIDs{$new} ) ; # if we have already heard about it then move on @@ -3278,22 +3166,19 @@ =cut sub _traverseObjectDAG { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, $objectType, $sth_hash, $dir ) = @_; my %sth = %{$sth_hash}; my %ObjectIDs; - my $sth = $dbh->prepare( $sth{get_object_type_id} ); - $sth->execute($objectType); - my ($root_id) = $sth->fetchrow_array; - return undef unless $root_id; - if ( $dir eq "p" ) { - $debug && &_LOG("getting parents"); - $sth = $dbh->prepare( $sth{get_object_parent_list} ); - } - else { - $debug && &_LOG("getting children"); - $sth = $dbh->prepare( $sth{get_object_child_list} ); - } + my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); + + my $row = shift (@$result); + my ($root_id) = @$row; + return undef unless $root_id; + # we have to do a traversal of the DAG here to get all child nodes... # this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested @@ -3304,10 +3189,22 @@ next if ( $ObjectIDs{$object} eq "tested" ) ; # if it has been tested already then move on - $sth->execute($object); # execute the query for child nodes + + my $result; + if ( $dir eq "p" ) { + $debug && &_LOG("getting parents"); + $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); + } + else { + $debug && &_LOG("getting children"); + $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); + } + # execute the query for child nodes + $ObjectIDs{$object} = "tested"; # mark it as tested - while ( my $new = $sth->fetchrow_array ) + foreach my $row (@$result) { # now get each of the child nodes + my $new = @$row; next if ( defined $ObjectIDs{$new} ) ; # if we have already heard about it then move on @@ -3461,56 +3358,28 @@ } sub _serviceListResponse { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, @ids ) = @_; my $output = ""; - my $sth = $dbh->prepare( - q{ - select - category, url, servicename, service_type_uri, authority_id, description, authoritative, contact_email, signatureURL, lsid - from service_instance where - service_instance_id = ?} - ); - my $sth_simple_in = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_input where service_instance_id=? and collection_input_id IS NULL" - ); - my $sth_simple_out = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_output where service_instance_id=? and collection_output_id IS NULL" - ); - my $sth_collection_ins = - $dbh->prepare( -"select collection_input_id, article_name from collection_input where service_instance_id=?" - ); - my $sth_collection_outs = - $dbh->prepare( -"select collection_output_id, article_name from collection_output where service_instance_id=?" - ); - my $sth_collection_in = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_input where service_instance_id IS NULL and collection_input_id =?" - ); - my $sth_collection_out = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_output where service_instance_id IS NULL and collection_output_id =?" - ); - my $sth_secondary_in = - $dbh->prepare( -"select default_value, maximum_value, minimum_value, enum_value, datatype, article_name from secondary_input where service_instance_id=?" - ); my $OSobj = MOBY::OntologyServer->new( ontology => 'object' ); my $OSns = MOBY::OntologyServer->new( ontology => 'namespace' ); my $OSserv = MOBY::OntologyServer->new( ontology => 'service' ); foreach (@ids) { - $sth->execute($_); - my ( - $category, $url, $servicename, - $service_type_uri, $authority_id, $desc, - $authoritative, $email, $signatureURL, - $lsid - ) - = $sth->fetchrow_array; + my $result = $adaptor->query_service_instance({service_instance_id => $_}); + my $category = @$result[0]->{category}; + my $url = @$result[0]->{url}; + my $servicename = @$result[0]->{servicename}; + my $service_type_uri = @$result[0]->{service_type_uri}; + my $authority_id = @$result[0]->{authority_id}; + my $desc = @$result[0]->{description}; + my $authoritative = @$result[0]->{authoritative}; + my $email = @$result[0]->{contact_email}; + my $signatureURL = @$result[0]->{signatureURL}; + my $lsid = @$result[0]->{lsid}; + if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } @@ -3519,10 +3388,9 @@ $signatureURL ||= ""; next unless ( $servicename && $authority_id ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); - my ($authURI) = - $dbh->selectrow_array( - q{select authority_uri from authority where authority_id=?}, - undef, $authority_id ); + + $result = $adaptor->query_authority({authority_id => $authority_id}); + my $authURI = @$result[0]->{authority_uri}; $output .= "\t\n"; $output .= "\t$service_type\n"; @@ -3533,11 +3401,15 @@ $output .= "\t$signatureURL\n"; $output .= "\t$url\n"; $output .= "\t\n"; - $sth_simple_in->execute($_); - - while ( my ( $objURI, $nsURI, $article ) = - $sth_simple_in->fetchrow_array() ) + + $result = $adaptor->query_simple_input({service_instance_id => $_}, 'and', {collection_input_id => undef}); + + foreach my $row (@$result) { + my $objURI = $row->{object_type_uri}; + my $nsURI = $row->{namespace_type_uris}; + my $article = $row->{article_name}; + my $objName = $OSobj->getObjectCommonName($objURI); $nsURI ||= ""; my @nsURIs = split ",", $nsURI; @@ -3550,15 +3422,23 @@ } $output .= "\t\t\n"; } + $result = $adaptor->query_collection_input({service_instance => $_}); $sth_collection_ins->execute($_); - while ( my ( $collid, $articlename ) = - $sth_collection_ins->fetchrow_array ) + + foreach my $row (@$result) { - $output .= "\t\t\n"; - $sth_collection_in->execute($collid); - while ( my ( $objURI, $nsURI, $article ) = - $sth_collection_in->fetchrow_array() ) + my $collid = $row->{collection_input_id}; + my $articlename = $row->{article_name}; + + $output .= "\t\t\n"; + + my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, 'and', {collection_input_id => $collid}); + foreach my $row2 (@$result2) { + my $objURI = $row2->{object_type_uri}; + my $nsURI = $row2->{namespace_type_uri}; + my $article = $row2->{article_name}; + my $objName = $OSobj->getObjectCommonName($objURI); $nsURI ||= ""; my @nsURIs = split ",", $nsURI; @@ -3576,57 +3456,68 @@ } $output .= "\t\n"; $output .= "\t\n"; - $sth_simple_out->execute($_); - while ( my ( $objURI, $nsURI, $article ) = - $sth_simple_out->fetchrow_array() ) + + $result = query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); + + foreach my $row (@$result) { + my $objURI = $row->{object_type_uri}; + my $nsURI = $row->{namespace_type_uris}; + my $article = $row->{article_name}; + + my $objName = $OSobj->getObjectCommonName($objURI); + $nsURI ||= ""; + my @nsURIs = split ",", $nsURI; + $article ||= ""; + $output .= "\t\t\n"; + $output .= "\t\t\t$objName\n"; + foreach my $ns (@nsURIs) { + my $NSname = $OSns->getNamespaceCommonName($ns); + $output .= "\t\t\t$NSname\n" if $NSname; + } + $output .= "\t\t\n"; + } + + $result = query_collection_output({service_instance_id => $_}); + foreach my $row (@$result) + { + my $collid = $row->{collection_output_id}; + my $articlename = $row->{article_name}; + $output .= "\t\t\n"; + + my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id = $collid}); + foreach my $row2 (@$result2 ) + { + my $objURI = $row2->{object_type_uri}; + my $nsURI = $row2->{namespace_type_uris}; + my $article = $row2->{article_name}; my $objName = $OSobj->getObjectCommonName($objURI); $nsURI ||= ""; my @nsURIs = split ",", $nsURI; $article ||= ""; - $output .= "\t\t\n"; - $output .= "\t\t\t$objName\n"; + $output .= "\t\t\t\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { - my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t$NSname\n" if $NSname; - } - $output .= "\t\t\n"; - } - $sth_collection_outs->execute($_); - while ( my ( $collid, $articlename ) = - $sth_collection_outs->fetchrow_array ) - { - $output .= "\t\t\n"; - $sth_collection_out->execute($collid); - while ( my ( $objURI, $nsURI, $article ) = - $sth_collection_out->fetchrow_array() ) - { - my $objName = $OSobj->getObjectCommonName($objURI); - $nsURI ||= ""; - my @nsURIs = split ",", $nsURI; - $article ||= ""; - $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; - foreach my $ns (@nsURIs) { - my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t\t$NSname\n" - if $NSname; - } - $output .= "\t\t\t\n"; - } - $output .= "\t\t\n"; + my $NSname = $OSns->getNamespaceCommonName($ns); + $output .= "\t\t\t\t$NSname\n" + if $NSname; + } + $output .= "\t\t\t\n"; + } + $output .= "\t\t\n"; } $output .= "\t\n"; $output .= "\t\n"; - $sth_secondary_in->execute($_); - while ( - my ( - $default_value, $maximum_value, $minimum_value, - $enum_value, $datatype, $article_name - ) - = $sth_secondary_in->fetchrow_array() - ) + $result = $adaptor->query_secondary_input({service_instance_id => $_}); + foreach my $row (@$result) { + my $default_value = $row->{default_value}; + my $maximum_value = $row->{maximum_value}; + my $minimum_value = $row->{minimum_value}; + my $enum_value = $row->{enum_value}; + my $datatype = $row->{datatype}; + my $article_name = $row->{article_name}; + $article_name ||= ""; $datatype ||= ""; $default_value ||= ""; From dwang at pub.open-bio.org Wed Jul 13 14:19:09 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 13 15:07:23 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507131819.j6DIJ9P4020874@pub.open-bio.org> dwang Wed Jul 13 14:19:09 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20848/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: 1st commit by Dennis moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2004/07/09 00:21:53 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/13 18:19:09 1.3 @@ -3,6 +3,7 @@ use Carp; use vars qw($AUTOLOAD); +# Modified by Dennis { #Encapsulated class data @@ -107,28 +108,44 @@ } -sub insert_collection_input { - die "insert_collection_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} + +# +# authority table functions +# +sub query_authority{ + + } -sub insert_collection_output { - die "insert_collection_output not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} +sub insert_authority{ + +} + +sub delete_authority{ + +} + + +# +# service_instance table functions +# +sub query_service_instance { + die "query_service_instance not implemented in adaptor\n"; +} + +sub insert_service_instance { + die "insert_service_instance not implemented in adaptor\n"; +} + +sub delete_service_intance{ + +} + +# +# simple_output table functions +# +sub query_simple_input{ + } sub insert_simple_input { @@ -153,6 +170,16 @@ #return $id; } +sub delete_simple_input{ + +} + +# +# simple_output table functions +# +sub query_simple_output{ + +} sub insert_simple_output { die "insert_simple_output not implemented in adaptor\n"; @@ -177,14 +204,180 @@ } -sub query_service_instance { - die "query_service_instance not implemented in adaptor\n"; +sub delete_simple_output{ + } -sub insert_service_instance { - die "insert_service_instance not implemented in adaptor\n"; +# +# collection_input table functions +# +sub query_collection_input{ + +} + +sub insert_collection_input { + die "insert_collection_input not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} +} + +sub delete_collection_input{ + +} + +# +# collection_output table fuctions +# +sub query_collection_output{ + +} + +sub insert_collection_output { + die "insert_collection_output not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} +} + +sub delete_collection_output{ + +} + +# +# object table functions +# +sub query_object{ + +} + +sub insert_object{ + +} + +sub delete_object{ + +} + +# +# object_term2term table functions +# +sub query_object_term2term{ + +} + +sub insert_object_term2term{ + +} + +sub delete_object_term2term{ + +} + +# +# relationship table functions +# +sub query_relationship{ + +} + +sub insert_relationship{ + +} + +sub delete_relationship{ + +} + +# +# service table fuctions +# +sub query_service{ + +} + +sub insert_service{ + +} + +sub delete_service{ + +} + +# +# service_term2term table functions +# +sub query_service_term2term{ + +} + +sub insert_service_term2term{ + +} + +sub delete_service_term2term{ + } +# +# namespace table functions +# +sub query_namespace{ + +} + +sub insert_namespace{ + +} + +sub delete_namespace{ + +} + +# +# namespace_term2term table functions +# +sub query_namespace_term2term{ + +} + +sub insert_namespace_term2term{ + +} + +sub delete_namespace_term2term{ + +} + +# secondary_input table functions +sub query_secondary_input{ + +} + +sub insert_secondary_input{ + +} + +sub delete_secondary_input{ + +} + +# +# query term2term tables - queries relation between two tables +# +sub select_term2term{ + +} sub _dump { my ($self) = @_; From dwang at pub.open-bio.org Wed Jul 13 14:33:41 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 13 15:21:53 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507131833.j6DIXfP0021170@pub.open-bio.org> dwang Wed Jul 13 14:33:41 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21144/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: 1st commit by Dennis moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/05/30 23:33:43 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 18:33:41 1.11 @@ -98,33 +98,222 @@ } +sub add_condition{ + my ($statement, @params) = @_; + my @bindvalues = (); + my $condition = "where "; + + foreach my $param (@params ) + { + if (($param eq 'and') || ($param eq 'or')) + { + $condition .= $param . " "; + } + else + { + my %pair = %$param; + + for my $key (keys %pair) + { + if (defined $pair{$key}) + { + $condition .= $key . " = ? "; + push(@bindvalues, $pair{$key}); + } + else + { + $condition .= $key . " IS NULL " + } + } + } + } + $statement .= $condition; + return ($statement, @bindvalues); + } + +# preforms query but returns a reference to an array containing hash references +sub do_query{ + my ($dbh, $statement, @bindvalues) = @_; + my $sth = $dbh -> prepare($statement); + if (@bindvalues < 1) + { + $sth->execute; + } + else + { + $sth->execute(@bindvalues); + } + # returns an array of hash references + my $arrayHashRef = $sth->fetchall_arrayref({}); + return $arrayHashRef; +} + +sub get_value{ + my ($key, @params) = @_; + + foreach my $param (@params ) + { + my %pair = %$param; + for my $tmp (keys %pair) + { + if ($tmp eq $key){ + return $pair{$key}; + } + } + } +} + +# general query subroutine +# parameters: +# statement - a string SQL statement +# bind_values - an array of values to be bound to the parameters +# returns: +# resultset - reference to an array containing array references +sub general_query{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = get_value('statement', @args); + my $sth = $dbh->prepare($statement}; + if (@args > 1) + { + my $bindvalues = get_value('bind_values', @args); + $sth->execute(@$bindvalues); + } + else { + $sth->execute; + } + my $result = $sth->fetchall_arrayref(); + return result; +} + +sub query_collection_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + collection_input_id, + article_name, + service_instance_id + from collection_input "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} sub insert_collection_input { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; # if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ # this should be dropped down into the mysql.pm module?? probably... - $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", + undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); my $id=$self->dbh->{mysql_insertid}; return $id; # } } +sub delete_collection_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from collection_input "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# query subroutine selects all columns +sub query_collection_output{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + collection_output_id, + article_name, + service_instance_id + from collection_output "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + sub insert_collection_output { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; # if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ # this should be dropped down into the mysql.pm module?? probably... - $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", + undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); my $id=$self->dbh->{mysql_insertid}; return $id; # } } +sub delete_collection_output{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from collection_output "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + + +sub query_simple_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + simple_input_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id + from simple_input "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + + sub insert_simple_input { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; - my $si = $args{collection_input_id}?undef:$args{service_instance_id}; + my $si = get_value('collection_input_id', @args)?undef:get_value('service_instance_id', @args); $dbh->do("insert into simple_input (object_type_uri, @@ -134,21 +323,59 @@ collection_input_id) values (?,?,?,?,?)", undef, - ($args{object_type_uri}, - $args{namespace_type_uris}, - $args{article_name}, + (get_value('object_type_uri', @args), + get_value('namespace_type_uris', @args), + get_value('article_name', @args), # here $si, - $args{collection_input_id})); + get_value('collection_input_id', @args))); my $id=$dbh->{mysql_insertid}; return $id; } +sub delete_simple_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from simple_input "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ) + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_simple_output{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + simple_output_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id + from simple_output "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} sub insert_simple_output { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; - my $si = $args{collection_output_id}?undef:$args{service_instance_id}; + my $si = get_value('collection_output_id', @args)?undef:get_value('service_instance_id', @args); $dbh->do("insert into simple_output (object_type_uri, @@ -158,78 +385,813 @@ collection_output_id) values (?,?,?,?,?)", undef, - ($args{object_type_uri}, - $args{namespace_type_uris}, - $args{article_name}, + (get_value('object_type_uri', @args), + get_value('namespace_type_uris', @args), + get_value('article_name', @args), # and here $si, - $args{collection_output_id})); + get_value('collection_output_id', @args))); my $id=$dbh->{mysql_insertid}; return $id; } -sub query_service_instance { - my ($self, %args) = @_; +sub delete_simple_output{ + my ($self, @args) = @_; my $dbh = $self->dbh; + my $statement = "delete from simple_output "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} - my ($serviceid, $category, $name, $typeURI, $authURI,$url,$email,$authoritative,$desc, $signatureURL, $lsid) = $dbh->selectrow_array( # does this service already exist? - q{select +sub query_secondary_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + secondary_input_id, + default_value, + maximum_value, + minimum_value, + enum_value, + datatype, + article_name, + service_instance_id + from secondary_input "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_secondary_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $dbh->do( +q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, + undef, + ( + get_value('default_value', @args), get_value('maximum_value', @args), + get_value('minimum_value', @args), get_value('enum_value', @args), + get_value('datatype', @args), get_value('article_name', @args), + get_value('service_instance_id', @args), + ) + ); + return $dbh->{mysql_insertid}; +} + +sub delete_secondary_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from secondary_input "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# query subroutine will selects all rows from object table +sub query_object +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + object_id, + object_lsid, + object_type, + description, + authority, + contact_email + from object "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# inserts a new tuple into object table +sub insert_object{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into object + (object_type, + object_lsid, + description, + authority, + contact_email) + values (?,?,?,?,?)", + undef, + (get_value('object_type', @args), + get_value('object_lsid', @args), + get_value('description', @args), + get_value('authority', @args), + get_value('contact_email', @args))); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +sub delete_object{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from object "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_object_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + object1_id, + object2_id, + object2_articlename + from object_term2term "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_object_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, + undef, + ( get_value('relationship_type', @args), + get_value('object1_id', @args), + get_value('object2_id', @args), + get_value('object2_articlename', @args) ) + ); + + return $dbh->{mysql_insertid}; +} + +# selects all the columns from service_instance table +# where is lsid? +sub query_service_instance { + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select service_instance_id, category, - serviceName, + servicename, service_type_uri, - authority.authority_uri, + authority_id, url, - service_instance.contact_email, + contact_email, authoritative, description, signatureURL, lsid - from service_instance, authority - where - service_instance.authority_id = authority.authority_id - and servicename=? and authority.authority_uri = ? - }, - undef,($args{servicename}, $args{authURI})); - return undef unless $serviceid; - return {serviceid => $serviceid, - category => $category, - name => $name, - servcetype => $typeURI, - authURI => $authURI, - signatureURL => $signatureURL, - url => $url, - email => $email, - authoritative => $authoritative, - desc => $desc, - lsid => $lsid - }; + from service_instance "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; } +# custom query for Moby::Central.pm->findService() +sub match_service_type_uri{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $uri_list = get_value('service_type_uri', @args); + + my $result = $dbh->selectall_arrayref( +"select service_instance_id from service_instance where service_type_uri in ($uri_list)" + ); + return $result; +} sub insert_service_instance { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, - undef, - $args{'category'}, - $args{'servicename'}, - $args{'service_type_uri'}, - $args{'authority_id'}, - $args{'url'}, - $args{'contact_email'}, - $args{'authoritative'}, - $args{'description'}, - $args{'signatureURL'}, - $args{'lsid'}); + undef,( + get_value('category', @args), + get_value('servicename', @args), + get_value('service_type_uri', @args), + get_value('authority_id', @args), + get_value('url', @args), + get_value('contact_email', @args), + get_value('authoritative', @args), + get_value('description', @args), + get_value('signatureURL', @args), + get_value('lsid', @args))); my $id = $dbh->{mysql_insertid}; return $id; } +sub delete_service_instance{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service_instance "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# Selects all columns +sub query_authority { + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + authority_id, + authority_common_name, + authority_uri, + contact_email + from authority "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub getUniqueAuthorityURI{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $statement = "select distinct authority_uri from authority"; + $bindvalues = (); + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_authority{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into authority + (authority_common_name, + authority_uri, + contact_email) + values (?,?,?)", + undef, + (get_value('authority_common_name', @args), + get_value('authority_uri' @args), + get_value('contact_email', @args))); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +sub query_service{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select + service_id, + service_lsid, + service_type, + description, + authority, + contact_email + from service "; + my @bindvalues = (); + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_service{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, + undef, + ( + get_value('service_type', @args), get_value('service_lsid', @args), get_value('description', @args), + get_value('authority', @args), get_value('contact_email', @args) + ) + ); + return dbh->{mysql_insertid}; +} + +sub delete_service{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_service_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select + assertion_id, + relationship_type, + service1_id, + service2_id + from service_term2term "; + my @bindvalues = (); + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_service_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, + undef, + ( get_value('relationship_type', @args), get_value('service1_id', @args), get_value('service2_id', @args)) + ); + return dbh->{mysql_insertid}; +} + +sub delete_service_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service_term2term "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_relationship{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + relationship_id, + relationship_lsid, + relationship_type, + container, + description, + authority, + contact_email, + ontology + from relationship "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub query_namespace{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + namespace_id, + namespace_lsid, + namespace_type, + description, + authority, + contact_email + from namespace "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_namespace{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, + undef, + ( + get_value('namespace_type', @args), get_value('namespace_lsid', @args), get_value('description', @args), + get_value('authority', @args), get_value('contact_email', @args) + ) + ); + return dbh->{mysql_insertid}; +} + +sub delete_namespace{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from namespace "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} +sub query_namespace_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + namespace1_id, + namespace2_id + from namespace_term2term "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub delete_namespace_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from namespace_term2term "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# custom query subroutine for Moby::Central.pm->deregisterObjectClass() +sub checkClassUsedByService +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $errorMsg = 1; + my $existingURI = get_value('object_type_uri', @args); + + my ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + return 0; +} + +# custom query routine for Moby::Central.pm -> deregisterNamespace() +sub checkNamespaceUsedByService{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $existingURI = get_value('namespace_type_uris', @args); + my $term = get_value('term', @args); + +my $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + return (0, $errstr); +} + +# custom query routine for Moby::Central.pm -> findService() +sub checkKeywords{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $param = get_value('findme', @args); + my %findme = %$param; + my $searchstring; + + foreach my $kw ( @{ $findme{keywords} } ) { + $debug && &_LOG("KEYWORD $kw\n"); + $kw =~ s/\*//g; + $kw = $dbh->quote("%$kw%"); + $searchstring .= " OR description like $kw "; + } + $searchstring =~ s/OR//; # just the first one + $debug && &_LOG("search $searchstring\n"); + + my $ids = + $dbh->selectall_arrayref( +"select service_instance_id from service_instance where $searchstring" + ); + + return ($ids, $searchstring); +} + +# custom query subroutine for Moby::Central.pm->_searchForSimple() +sub getFromSimple{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $ancestor_string = get_value('ancestor_string', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = +"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " + ; # if service_instance_id is null then it must be a collection input. + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/OR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; + } + + my $result = do_query($dbh, $query, ()); + return ($query, $result); +} + +# custom query subroutine for Moby::Central.pm->_searchForCollection() +sub getFromCollection +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $objectURI = get_value('objectURI', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = "select + c.service_instance_id, + s.namespace_type_uris + from + simple_$inout as s, + collection_$inout as c + where + s.collection_${inout}_id IS NOT NULL + AND s.collection_${inout}_id = c.collection_${inout}_id + AND object_type_uri = '$objectURI' " + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/^\sOR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; # add the AND clause + } + + my $result = do_query($dbh, $query, ()); + return ($query, $result); +} + +# custom query subroutine for Moby::Central.pm->RetrieveServiceNames +sub getServiceNames +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; + my @bindvalues = (); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query for Moby::Central.pm->_flatten +sub getParentTerms +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $type_id = get_value('relationship_type_id', @args); + my $statement = " + select + OE1.term + from + OntologyEntry as OE1, + OntologyEntry as OE2, + Term2Term as TT + where + ontologyentry2_id = OE2.id + and ontologyentry1_id = OE1.id + and relationship_type_id = $type_id + and OE2.term = ?"; + + my @bindvalues = (); + push(@bindvalues, get_value('term', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query subroutine for selecting from object_term2term and object tables +# used in Moby::OntologyServer.pm->retrieveObject() +sub getObjectRelationships{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + relationship_type, + object_lsid, + object2_articlename + from object_term2term, object + where object1_id = ? and object2_id = object_id"; + + my @bindvalues = (); + push(@bindvalues, get_value('object1_id', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() +getRelationship{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $defs; + my $ontology = $args{ontology}; + + unless ( defined $args{$relationship} ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $args{lsid} ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $args{$relationship}, $args{lsid} ); # ") + } + return $defs; +} sub _checkURI { From dwang at pub.open-bio.org Wed Jul 13 17:53:12 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 13 18:41:29 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507132153.j6DLrCUE022059@pub.open-bio.org> dwang Wed Jul 13 17:53:12 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22025/Perl/MOBY Modified Files: Central.pm OntologyServer.pm authority.pm Log Message: Moved all SQL statements in authority.pm and Central.pm to Moby::Adaptor::queryapi::mysql.pm In its place are calls to routines in Moby::Adaptor::queryapi.pm moby-live/Perl/MOBY Central.pm,1.158,1.159 OntologyServer.pm,1.49,1.50 authority.pm,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.158 retrieving revision 1.159 diff -u -r1.158 -r1.159 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 18:18:39 1.158 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 21:53:11 1.159 @@ -1928,8 +1928,8 @@ $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2001,7 +2001,7 @@ $debug && _LOG("Keywords added; criterion count is now $criterion_count\n"); - my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); unless ( scalar @{$ids} ) { $debug @@ -2013,8 +2013,8 @@ $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2004/12/14 20:47:04 1.49 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/13 21:53:12 1.50 @@ -191,19 +191,21 @@ # if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objecttype/)){ # return (1, "external ontology", $term); # } + my $result; if ( $term =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_lsid = ?" - ); + $result = $adaptor->query_object({object_lsid => $term}); + } else { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_type = ?" - ); + $result = $adaptor->query_object({object_type => $term}); + } - $sth->execute($term); - my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $lsid = $row->{object_lsid}; + my $type = $row->{object_type}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($lsid) { # if it is in there, then it has been discovered regardless of being foreign or not return ( 1, $desc, $lsid ); @@ -263,20 +265,20 @@ ? $args{'node'} : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $sth; + my $result; if ( $args{'node'} =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_lsid = ?" - ); + + $result = $adaptor->query_object({object_lsid => $term}); } else { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_type = ?" - ); + $result = $adaptor->query_object({object_type => $term}); } - $sth->execute($term); - my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $lsid = $row->{object_lsid}; + my $type = $row->{object_type}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($lsid) { # if it is in there, then the object exists return ( 0, "This term already exists: $lsid", $lsid ); } @@ -284,15 +286,13 @@ $args{node} =~ s/^\s+(.*?)\s+$/$1/s; $args{contact_email} =~ s/^\s+(.*?)\s+$/$1/s; $args{authority} =~ s/^\s+(.*?)\s+$/$1/s; - $self->dbh->do( -q{insert into object (object_type, object_lsid, description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - $args{'node'}, $LSID, $args{'description'}, - $args{'authority'}, $args{'contact_email'} - ) - ); - unless ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_object({object_type => $args{'node'}}, + {object_lsid => $LSID}, + {description => $args{'description'}}, + {authority => $args{'authority'}}, + {contact_email => $args{'contact_email'}}); + unless ( $insertid ) { return ( 0, "Object creation failed for unknown reasons", '' ); } return ( 1, "Object creation succeeded", $LSID ); @@ -313,24 +313,28 @@ ? $args{'node'} : $self->getObjectURI($term); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my ( $id, $type, $lsid, $desc, $auth, $contact ) = - $self->dbh->selectrow_array( -q{select object_id, object_type, object_lsid, description, authority,contact_email from object where object_lsid = ?}, - undef, $LSID - ); + my $result = $adaptor->query_object({object_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{object_id}; + my $type = $row->{object_type}; + my $lsid = $row->{object_lsid}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $contact = $row->{contact_email}; + unless ($id) { return ( 0, "Object doesn't exist in ontology", "" ) } # my $OS = MOBY::OntologyServer->new(ontology => "relationship"); - my $sth = - $self->dbh->prepare( -q{select relationship_type, object_lsid, object2_articlename from object_term2term, object where object1_id = ? and object2_id = object_id} - ); - $sth->execute($id); + + $result = $adaptor->getObjectRelationships({object1_id => $id}); my %rel; - while ( my ( $relationship_type, $objectlsid, $article ) = - $sth->fetchrow_array ) + foreach my $row (@$result) { - push @{ $rel{$relationship_type} }, [ $objectlsid, $article ]; + my $relationship_type = $row->{relationship_type}; + my $objectlsid = $row->{object_lsid}; + my $article = $row->{object2_articlename}; + + push @{ $rel{$relationship_type} }, [ $objectlsid, $article ]; } return { objectType => $lsid, =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2004/11/18 17:41:14 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/13 21:53:12 1.3 @@ -2,6 +2,7 @@ package MOBY::authority; use strict; use Carp; +use MOBY::Config; use vars qw($AUTOLOAD @ISA); =head1 NAME @@ -86,20 +87,21 @@ } } my $dbh = $self->dbh; - my ( $authority_id, $common, $uri, $contact ) = $dbh->selectrow_array( -q{select authority_id, authority_common_name,authority_uri,contact_email from authority where authority_uri = ?}, - undef, $self->authority_uri - ); + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + + my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $authority_id = @$result[0]->{authority_id}; + my $common = @$result[0]->{authority_common_name}; + my $uri = @$result[0]->{authority_uri}; + my $contact = @$result[0]->{contact_email}; + unless ($authority_id) { - $dbh->do( -q{insert into authority (authority_common_name, authority_uri, contact_email) values (?,?,?)}, - undef, - ( - $self->authority_common_name, $self->authority_uri, - $self->contact_email - ) - ); - $self->authority_id( $dbh->{mysql_insertid} ); + my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, + {authority_uri => $self->authority_uri}, + {contact_email => $self->contact_email}); + + $self->authority_id( $insertid ); } else { $self->authority_id($authority_id); } From dwang at pub.open-bio.org Wed Jul 13 17:55:36 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 13 18:43:41 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507132155.j6DLtaxK022106@pub.open-bio.org> dwang Wed Jul 13 17:55:36 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22080/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: Implementation of queryapi.pm Contains all SQL statements used in Moby::authority.pm and Moby::Central.pm. Changed all query routines to return reference of an array containing hash references, with the exception of general_quer(). moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 18:33:41 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 21:55:36 1.12 @@ -168,7 +168,7 @@ # statement - a string SQL statement # bind_values - an array of values to be bound to the parameters # returns: -# resultset - reference to an array containing array references +# resultset - reference to an array containing ARRAY references sub general_query{ my ($self, @args) = @_; my $dbh = $self->dbh; @@ -604,12 +604,11 @@ sub match_service_type_uri{ my ($self, @args) = @_; my $dbh = $self->dbh; - my $uri_list = get_value('service_type_uri', @args); + my $statement = "select service_instance_id from service_instance where service_type_uri in ($uri_list)"; + my @bindvalues = (); - my $result = $dbh->selectall_arrayref( -"select service_instance_id from service_instance where service_type_uri in ($uri_list)" - ); + my $result = do_query($dbh, $statement, @bindvalues); return $result; } @@ -672,6 +671,7 @@ return $result; } +# custom query routine used in Moby::Central.pm -> retrieveServiceProviders() sub getUniqueAuthorityURI{ my ($self, @args) = @_; my $dbh = $self->dbh; @@ -693,7 +693,7 @@ (get_value('authority_common_name', @args), get_value('authority_uri' @args), get_value('contact_email', @args))); - my $id=$dbh->{mysql_insertid}; + my $id = $dbh->{mysql_insertid}; return $id; } @@ -1036,11 +1036,10 @@ $searchstring =~ s/OR//; # just the first one $debug && &_LOG("search $searchstring\n"); - my $ids = - $dbh->selectall_arrayref( -"select service_instance_id from service_instance where $searchstring" - ); - + my $statement = "select service_instance_id from service_instance where $searchstring"; + my @bindvalues = (); + + my $ids = do_query($dbh, $statement, @bindvalues); return ($ids, $searchstring); } @@ -1162,7 +1161,8 @@ } # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() -getRelationship{ +# note: returns a reference to an array containing ARRAY references +sub getRelationship{ my ($self, %args) = @_; my $dbh = $self->dbh; my $defs; From dwang at pub.open-bio.org Fri Jul 15 12:39:11 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Fri Jul 15 13:27:03 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507151639.j6FGdBMc030093@pub.open-bio.org> dwang Fri Jul 15 12:39:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30067/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: All subroutines in mysql.pm should take in array of hashes as arguments. Delete tuple subroutines now returns 0 if successful or 1 if error moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 21:55:36 1.12 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/15 16:39:11 1.13 @@ -228,10 +228,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -278,10 +278,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -342,10 +342,10 @@ $dbh->do( $statement, undef, @bindvalues ) if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -405,10 +405,10 @@ $dbh->do( $statement, undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -463,10 +463,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -526,10 +526,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -570,6 +570,24 @@ return $dbh->{mysql_insertid}; } +sub delete_object_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "delete from object_term2term "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (1, dbh->errstr); + } + else{ + return 0; + } +} + # selects all the columns from service_instance table # where is lsid? sub query_service_instance { @@ -642,10 +660,10 @@ $dbh->do( $statement, undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -742,10 +760,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -789,10 +807,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -868,10 +886,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -906,10 +924,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -1163,12 +1181,39 @@ # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references sub getRelationship{ - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; + my $direction = get_value('direction', @args); + my $ontology = get_value('ontology', @args); + my $term = get_value('term', @args); + my $relationship = get_value('relationship', @args); my $defs; - my $ontology = $args{ontology}; - unless ( defined $args{$relationship} ) { + if ( $direction eq 'root' ) { + unless ( defined $relationship ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $term ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + } + } else { + unless ( defined $relationship ) { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from ${ontology}_term2term as t2t, @@ -1177,7 +1222,7 @@ where s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $args{lsid} ); # ") + s2.${ontology}_lsid = ?", undef, $term ); # ") } else { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from @@ -1188,8 +1233,9 @@ relationship_type = ? and s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $args{$relationship}, $args{lsid} ); # ") + s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") } + } return $defs; } From dwang at pub.open-bio.org Fri Jul 15 12:40:45 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Fri Jul 15 13:28:40 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507151640.j6FGejJK030156@pub.open-bio.org> dwang Fri Jul 15 12:40:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30130/Perl/MOBY Modified Files: OntologyServer.pm Log Message: All SQL statements in OntologyServer.pm has been moved into Moby::Adaptor::moby::queryapi::mysql.pm Note: Still may contain many syntactic errors moby-live/Perl/MOBY OntologyServer.pm,1.50,1.51 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/13 21:53:12 1.50 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/15 16:40:45 1.51 @@ -183,6 +183,10 @@ sub objectExists { my ( $self, %args ) = @_; + + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that my $sth; @@ -243,7 +247,8 @@ sub createObject { my ( $self, %args ) = @_; - + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); #node => $term, #desc => $desc, #authURI => $auth, @@ -304,6 +309,8 @@ sub retrieveObject { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $term = $args{'node'}; return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node as an argument", '' ) @@ -351,6 +358,9 @@ sub deprecateObject { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY", '' ) unless ( $self->ontology eq 'object' ); my $term = $args{term}; @@ -361,31 +371,29 @@ unless ( $term =~ /urn\:lsid/ ) { $LSID = $self->getObjectURI($term) } else { $LSID = $term } return ( 0, q{Object type $term cannot be resolved to an LSID}, "" ) unless $LSID; - my ( $id, $lsid ) = - $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_lsid = ?}, - undef, $LSID ); + + my $result = $adaptor->query_object({object_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{object_id}; + my $lsid = $row->{object_lsid}; # object1_id ISA object2_id? - my (@isa) = - $self->dbh->selectrow_array( - q{select * from object_term2term where object2_id = ?}, - undef, $id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_object_term2term({object2_id => $id}); + if ( scalar @$isa ) { return ( 0, qq{Object type $term has object dependencies in the ontology}, $lsid ); } - $self->dbh->do( q{delete from object where object_id = ?}, undef, $id ); - if ( $self->dbh->err ) { - return ( 0, "Delete from Object Class table failed: $self->dbh->errstr", + + my ($err, $errstr) = $adaptor->delete_object({object_id => $id}); + if ( $err ) { + return ( 0, "Delete from Object Class table failed: $errstr", $lsid ); } - $self->dbh->do( q{delete from object_term2term where object1_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { + ($err, $errstr) = $adaptor->delete_object_term2term({object1_id => $id}); + if ( $err ) { return ( 0, - "Delete from Object term2term table failed: $self->dbh->errstr", + "Delete from Object term2term table failed: $errstr", $lsid ); } return ( 1, "Object $term Deleted", $lsid ); @@ -409,6 +417,9 @@ # term => $term # ontology => $ontology my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'relationship' ); my $term = lc( $args{term} ); @@ -416,21 +427,22 @@ my $ont = $args{ontology}; return ( 0, "requires both term and ontology arguments\n", '' ) unless ( defined($term) && defined($ont) ); - my $sth; - + my $result; if ( $term =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select relationship_lsid, relationship_type, description, authority, contact_email from relationship where relationship_lsid = ? and ontology=?" - ); + + $result = $adaptor->query_relationship({relationship_lsid => $term}, 'and', {ontology => $ont}); + } else { - $sth = - $self->dbh->prepare( -"select relationship_lsid, relationship_type, description, authority, contact_email from relationship where relationship_type = ? and ontology=?" - ); + + $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ont}); + } - $sth->execute( $term, $ont ); - my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $lsid = $row->{relationship_lsid}; + my $type = $row->{relationship_type}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; if ($lsid) { return ( 1, $desc, $lsid ); } else { @@ -456,43 +468,49 @@ #authority => $auth, #contact_email => $email my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); if ( $args{subject_node} =~ /^urn:lsid/ ) { - ( $subj_id, $subj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_lsid = ?}, - undef, $args{subject_node} - ); + + my $result = $adaptor->query_object({object_lsid => $args{subject_node}}); + my $row = shift(@$result); + $subj_id = $row->{object_id}; + $subj_lsid = $row->{object_lsid}; + } else { - ( $subj_id, $subj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_type = ?}, - undef, $args{subject_node} - ); + my $result = $adaptor->query_object({object_type => $args{subject_node}}); + my $row = shift(@$result); + $subj_id = $row->{object_id}; + $subj_lsid = $row->{object_lsid}; + } return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) unless defined $subj_id; if ( $args{object_node} =~ /^urn:lsid/ ) { - ( $obj_id, $obj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_lsid = ?}, - undef, $args{object_node} - ); + + my $result = $adaptor->query_object({object_lsid => $args{object_node}}); + my $row = shift(@$result); + $obj_id = $row->{object_id}; + $obj_lsid = $row->{object_lsid}; + } else { - ( $obj_id, $obj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_type = ?}, - undef, $args{object_node} - ); + my $result = $adaptor->query_object({object_type => $args{object_node}}); + my $row = shift(@$result); + $obj_id = $row->{object_id}; + $obj_lsid = $row->{object_lsid}; } return ( 0, qq{Object type $args{object_node} does not exist in the ontology}, '' ) unless defined $obj_id; - my (@isa) = - $self->dbh->selectrow_array( - q{select * from object_term2term where object2_id = ?}, - undef, $subj_id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_object_term2term({object2_id => $subj_id}); + + if ( scalar @$isa ) { return ( 0, qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, @@ -507,12 +525,11 @@ || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - $self->dbh->do( -q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, - undef, - ( $rel_lsid, $subj_id, $obj_id, $args{articleName} ) - ); - if ( $self->dbh->{mysql_insertid} ) { + my $insertid = $adaptor->insert_object_term2term({relationship_type => $rel_lsid}, + {object1_id => $subj_id}, + {object2_id => $obj_id}, + {object2_articlename => $args{articleName}}); + if ($insertid ) { return ( 1, "Object relationsihp created successfully", '' ); } else { return ( 0, "Object relationship creation failed for unknown reasons", @@ -534,32 +551,37 @@ #authority => $auth, #contact_email => $email); my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); - my ( $sbj_id, $sbj_lsid ) = $self->dbh->selectrow_array( - q{select service_id, service_lsid from service where service_type = ?}, - undef, $args{subject_node} - ); + + my $result = $adaptor->query_service({service_type => $args{subject_node}}); + my $row = shift(@$result); + my $sbj_id = $row->{service_id}; + my $sbj_lsid = $row->{service_lsid}; + return ( 0, qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ) unless defined $sbj_id; - my (@isa) = - $self->dbh->selectrow_array( - q{select * from service_term2term where service2_id = ?}, - undef, $sbj_id ); - if ( scalar @isa ) { + + my $isa = $adaptor->query_service_term2term({service2_id => $sbj_id}); + if ( scalar @$isa ) { return ( 0, qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ); } - my ( $obj_id, $obj_lsid ) = $self->dbh->selectrow_array( - q{select service_id, service_lsid from service where service_type = ?}, - undef, $args{object_node} - ); # get ID of the related service + $result = $adaptor->query_service({service_type => $args{object_node}}); + $row = shift(@$result); + my $obj_id = $row->{service_id}; + my $obj_lsid = $row->{service_lsid}; + # get ID of the related service + defined $obj_id || return ( 0, qq{Service $args{object_node} does not exist in the service ontology}, @@ -572,12 +594,11 @@ || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - $self->dbh->do( -q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, - undef, - ( $rel_lsid, $sbj_id, $obj_id ) - ); - if ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_service_term2term({relationship_type => $rel_lsid}, + {service1_id => $sbj_id}, + {service2_id => $obj_id}); + if ( $insertid ) { return ( 1, "Service relationship created successfully", '' ); } else { return ( 0, "Service relationship creation failed for unknown reasons", @@ -591,6 +612,9 @@ sub serviceExists { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that @@ -599,20 +623,22 @@ { return ( 1, "external ontology", $term ); } - my $sth; + my $result; if ( $term =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select service_id, service_type, service_lsid, description, authority, contact_email from service where service_lsid = ?" - ); + $result = $adaptor->query_service({service_lsid => $term}); + } else { - $sth = - $self->dbh->prepare( -"select service_id, service_type, service_lsid, description, authority, contact_email from service where service_type = ?" - ); + $result = $adaptor->query_service({service_type => $term}); + } - $sth->execute($term); - my ( $id, $type, $lsid, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $id = $row->{service_id}; + my $type = $row->{service_type}; + my $lsid = $row->{service_lsid}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($id) { return ( 1, $desc, $lsid ); } else { @@ -630,6 +656,8 @@ sub createServiceType { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); #node => $term, #descrioption => $desc, @@ -653,15 +681,14 @@ ? $args{'node'} : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - $self->dbh->do( -q{insert into service (service_type, service_lsid, description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - $args{'node'}, $LSID, $args{'description'}, - $args{'authority'}, $args{'contact_email'} - ) - ); - unless ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_service({service_type => $args{'node'}}, + {service_lsid => $LSID}, + {description => $args{'description'}, + {authority => $args{'authority'}, + {contact_email => $args{'contact_email'}); + + unless ( $insertid ) { return ( 0, "Service creation failed for unknown reasons", '' ); } return ( 1, "Service creation succeeded", $LSID ); @@ -673,6 +700,9 @@ sub deleteServiceType { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; if ( $term =~ /^urn:lsid/ @@ -692,35 +722,37 @@ "" ) unless $LSID; - my ( $id, $lsid ) = $self->dbh->selectrow_array( - q{select service_id, service_lsid from service where service_lsid = ?}, - undef, $LSID - ); + + my $result = $adaptor->query_service({service_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{service_id}; + my $lsid = $row->{service_lsid}; + if ( !defined $id ) { return ( 0, q{Service type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my (@isa) = - $self->dbh->selectrow_array( - q{select * from service_term2term where service2_id = ?}, - undef, $id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_service_term2term({service2_id => $id}); + + if ( scalar @$isa ) { return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } - $self->dbh->do( q{delete from service where service_id = ?}, undef, $id ); - if ( $self->dbh->err ) { - return ( 0, "Delete from Service Type table failed: $self->dbh->errstr", + my ($err, $errstr) = $adaptor->delete_service({service_id => $id}); + + if ( $err ) { + return ( 0, "Delete from Service Type table failed: $errstr", $lsid ); } - $self->dbh->do( q{delete from service_term2term where service1_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { + + ($err, $errstr) = $adaptor->delete_service_term2term({service1_id => $id}); + + if ( $err ) { return ( 0, -"Delete from Service Type Term2Term table failed: $self->dbh->errstr", +"Delete from Service Type Term2Term table failed: $errstr", $lsid ); } @@ -733,29 +765,34 @@ sub namespaceExists { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that - my $sth; if ( $term =~ /^urn:lsid/ && !( $term =~ /^urn:lsid:biomoby.org:namespacetype/ ) ) { return ( 1, "external ontology", $term ); } + my $result; if ( $term =~ /^urn:lsid:biomoby.org:namespacetype/ ) { - $sth = - $self->dbh->prepare( -"select namespace_id, namespace_type, namespace_lsid,description, authority, contact_email from namespace where namespace_lsid = ?" - ); + $result = $adaptor->query_namespace({namespace_lsid => $term}); + } else { - $sth = - $self->dbh->prepare( -"select namespace_id, namespace_type, namespace_lsid,description, authority, contact_email from namespace where namespace_type = ?" - ); + $result = $adaptor->query_namespace({namespace_type => $term}); + } - $sth->execute($term); - my ( $id, $type, $lsid, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $id = $row->{namespace_id}; + my $type = $row->{namespace_type}; + my $lsid = $row->{namespace_lsid}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($id) { return ( 1, $desc, $lsid ); } else { @@ -773,7 +810,8 @@ sub createNamespace { my ( $self, %args ) = @_; - + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); #node => $term, #descrioption => $desc, #authority => $auth, @@ -797,15 +835,14 @@ ? $args{'node'} : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - $self->dbh->do( -q{insert into namespace (namespace_type, namespace_lsid,description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - $args{'node'}, $LSID, $args{'description'}, - $args{'authority'}, $args{'contact_email'} - ) - ); - unless ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_namespace({namespace_type => $args{'node'}}, + {namespace_lsid => $LSID}, + {description => $args{'description'}}, + {authority => $args{'authority'}}, + {contact_email => $args{'contact_email'}}); + + unless ( $insertid ) { return ( 0, "Namespace creation failed for unknown reasons", '' ); } return ( 1, "Namespace creation succeeded", $LSID ); @@ -817,6 +854,8 @@ sub deleteNamespace { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); my $term = $args{term}; @@ -829,36 +868,38 @@ { return ( 0, "cannot delete a term from an external ontology", $term ); } - my ( $id, $lsid ) = $self->dbh->selectrow_array( -q{select namespace_id, namespace_lsid from namespace where namespace_lsid = ?}, - undef, $LSID - ); + + my $result = $adaptor->query_namespace({namespace_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{namespace_id}; + my $lsid = $row->{namespace_lsid}; + unless ($id) { return ( 0, q{Namespace type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my (@isa) = - $self->dbh->selectrow_array( - q{select * from namespace_term2term where namespace2_id = ?}, - undef, $id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_namespace_term2term({namespace2_id => $id}); + + if ( scalar @$isa ) { return ( 0, qq{Namespace type $term has dependencies in the ontology}, $lsid ); } - $self->dbh->do( q{delete from namespace where namespace_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { - return ( 0, "Delete from namespace table failed: $self->dbh->errstr", + + my ($err, $errstr) = $adaptor->delete_namespace({namespace_id => $id}); + + if ( $err ) { + return ( 0, "Delete from namespace table failed: $errstr", $lsid ); } - $self->dbh->do( q{delete from namespace_term2term where namespace1_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { + + ($err, $errstr) = $adaptor->delete_namespace_term2term({namespace1_id => $id}); + + if ( $err ) { return ( 0, - "Delete from namespace term2term table failed: $self->dbh->errstr", + "Delete from namespace term2term table failed: $errstr", $lsid ); } @@ -871,13 +912,13 @@ sub retrieveAllServiceTypes { my ($self) = @_; - my $types = - $self->dbh->selectall_arrayref( - q{select service_type, description from service}); - my @types = @{$types}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $types = $adaptor->query_service(); + my %response; - foreach (@types) { - $response{ $_->[0] } = $_->[1]; + foreach (@$types) { + $response{ $_->{service_type} } = $_->{description}; } return \%response; } @@ -888,13 +929,13 @@ sub retrieveAllNamespaceTypes { my ($self) = @_; - my $types = - $self->dbh->selectall_arrayref( - q{select namespace_type, description from namespace}); - my @types = @{$types}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $types = $adaptor->query_namespace(); + my %response; - foreach (@types) { - $response{ $_->[0] } = $_->[1]; + foreach (@$types) { + $response{ $_->{namespace_type} } = $_->{description}; } return \%response; } @@ -905,13 +946,13 @@ sub retrieveAllObjectClasses { my ($self) = @_; - my $types = - $self->dbh->selectall_arrayref( - q{select object_type, description from object}); - my @types = @{$types}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $types = $adaptor->query_object(); + my %response; - foreach (@types) { - $response{ $_->[0] } = $_->[1]; + foreach (@$types) { + $response{ $_->{object_type} } = $_->{description}; } return \%response; } @@ -924,11 +965,13 @@ sub getObjectCommonName { my ( $self, $URI ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return undef unless $URI =~ /urn\:lsid/; - my ($name) = - $self->dbh->selectrow_array( - q{select object_type from object where object_lsid = ?}, - undef, $URI ); + my $result = $adaptor->query_object({object_lsid => $URI}); + my $row = shift(@$result); + my $name = $row->{object_type}; + return $name ? $name : $URI; } @@ -938,11 +981,13 @@ sub getNamespaceCommonName { my ( $self, $URI ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return undef unless $URI =~ /urn\:lsid/; - my ($name) = - $self->dbh->selectrow_array( - q{select namespace_type from namespace where namespace_lsid = ?}, - undef, $URI ); + my $result = $adaptor->query_namespace({namespace_lsid => $URI}); + my $row = shift(@$result); + my $name = $row->{namespace_type}; + return $name ? $name : $URI; } @@ -952,11 +997,13 @@ sub getServiceCommonName { my ( $self, $URI ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return undef unless $URI =~ /urn\:lsid/; - my ($name) = - $self->dbh->selectrow_array( - q{select service_type from service where service_lsid = ?}, - undef, $URI ); + my $result = $adaptor->query_service({service_lsid => $URI}); + my $row = shift(@$result); + my $name = $row->{service_type}; + return $name ? $name : $URI; } @@ -966,11 +1013,14 @@ sub getServiceURI { my ( $self, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return $term if $term =~ /urn\:lsid/; - my ($id) = - $self->dbh->selectrow_array( - q{select service_lsid from service where service_type = ?}, - undef, $term ); + + my $result = $adaptor->query_service({service_type => $term}); + my $row = shift(@$result); + my $id = $row->{service_lsid}; + return $id; } @@ -980,11 +1030,14 @@ sub getObjectURI { my ( $self, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return $term if $term =~ /urn\:lsid/; - my ($id) = - $self->dbh->selectrow_array( - q{select object_lsid from object where object_type = ?}, - undef, $term ); + + my $result = $adaptor->query_object({object_type => $term}); + my $row = shift(@$result); + my $id = $row->{object_lsid}; + return $id; } @@ -994,11 +1047,15 @@ sub getNamespaceURI { my ( $self, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return $term if $term =~ /urn\:lsid/; - my ($id) = - $self->dbh->selectrow_array( - q{select namespace_lsid from namespace where namespace_type = ?}, - undef, $term ); + + my $result = $adaptor->query_namespace({namespace_type => $term}); + my $row = shift(@$result); + my $id = $row->{namespace_lsid}; + return $id; } @@ -1008,11 +1065,15 @@ sub getRelationshipURI { my ( $self, $ontology, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return $term if $term =~ /urn\:lsid/; - my ($id) = $self->dbh->selectrow_array( -q{select relationship_lsid from relationship where relationship_type = ? and ontology = ?}, - undef, $term, $ontology - ); + + my $result = $adaptor->query_relationship({relationship_type => $term}, 'and' {ontology => $ontology}); + my $row = shift(@$result); + my $id = $row->{relationship_lsid}; + return $id; } @@ -1022,15 +1083,17 @@ sub getRelationshipTypes { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $ontology = $args{'ontology'}; my $OS = MOBY::OntologyServer->new( ontology => "relationship" ); - my $defs = $OS->dbh->selectall_arrayref( -q{select relationship_lsid, relationship_type, authority, description from relationship where ontology = ?}, - undef, $ontology - ); + + my $defs = $adaptor->query_relationship({ontology => $ontology}); + my %result; - foreach ( @{$defs} ) { - $result{ $_->[0] } = [ $_->[1], $_->[2], $_->[3] ]; + foreach ( @$defs ) { + $result{ $_->{relationship_lsid} } = [ $_->{relationship_type}, $_->{authority}, $_->{description} ]; } return \%result; } @@ -1086,54 +1149,12 @@ sub _doRelationshipsQuery { my ( $self, $ontology, $term, $relationship, $direction ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $defs; - if ( $direction eq 'root' ) { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } else { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } + # query returns a reference to an array containing array references + $defs = $adaptor->getRelationship({direction => $direction}, {ontology => $ontology}, {term => $term}, {relationship => $relationship}); + # a very long piece of SQL statements have been refactored into Moby::Adaptor::moby::queryapi::mysql.pm return $defs; } From dwang at pub.open-bio.org Mon Jul 18 12:53:04 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon Jul 18 13:40:36 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507181653.j6IGr478016252@pub.open-bio.org> dwang Mon Jul 18 12:53:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv16206/Perl/MOBY Modified Files: simple_input.pm collection_output.pm collection_input.pm simple_output.pm secondary_input.pm service_instance.pm Log Message: SQL statements replaced by generic api subroutines. Actual SQL exists in Moby::Adaptor::moby::queryapi::mysql.pm moby-live/Perl/MOBY simple_input.pm,1.5,1.6 collection_output.pm,1.3,1.4 collection_input.pm,1.3,1.4 simple_output.pm,1.4,1.5 secondary_input.pm,1.2,1.3 service_instance.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2004/11/18 17:41:14 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/18 16:53:03 1.6 @@ -100,11 +100,11 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_input( - object_type_uri => $self->object_type_uri, - namespace_type_uris => $self->namespace_type_uris, - article_name => $self->article_name, - service_instance_id => $self->service_instance_id, - collection_input_id => $self->collection_input_id, + {object_type_uri => $self->object_type_uri}, + {namespace_type_uris => $self->namespace_type_uris}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}, + {collection_input_id => $self->collection_input_id} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2004/11/18 17:41:14 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/18 16:53:03 1.4 @@ -94,8 +94,8 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_collection_output( - service_instance => $self->service_instance_id, - article_name => $self->article_name, ); + {service_instance => $self->service_instance_id}, + {article_name => $self->article_name} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2004/11/18 17:41:14 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/18 16:53:03 1.4 @@ -95,8 +95,8 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_collection_input( - service_instance => $self->service_instance_id, - article_name => $self->article_name, ); + {service_instance => $self->service_instance_id}, + {article_name => $self->article_name} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2004/11/18 17:41:15 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/18 16:53:03 1.5 @@ -99,11 +99,11 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_output( - object_type_uri => $self->object_type_uri, - namespace_type_uris => $self->namespace_type_uris, - article_name => $self->article_name, - service_instance_id => $self->service_instance_id, - collection_output_id => $self->collection_output_id, + {object_type_uri => $self->object_type_uri}, + {namespace_type_uris => $self->namespace_type_uris}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}, + {collection_output_id => $self->collection_output_id} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2004/11/18 17:41:14 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 16:53:03 1.3 @@ -2,6 +2,7 @@ package MOBY::secondary_input; use strict; use Carp; +use MOBY::Config; use vars qw($AUTOLOAD @ISA); =head1 NAME @@ -110,18 +111,17 @@ sub WRITE { my ($self) = @_; - my $dbh = $self->_dbh; - $dbh->do( -q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, - undef, - ( - $self->default_value, $self->maximum_value, - $self->minimum_value, $self->enum_value, - $self->datatype, $self->article_name, - $self->service_instance_id, - ) - ); - my $id = $dbh->{mysql_insertid}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, + {maximum_value => $self->maximum_value}, + {minimum_value => $self->minimum_value}, + {enum_value => $self->enum_value}, + {datatype => $self->datatype}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}); + + my $id = $dbh->{$insertid}; return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/05/30 23:33:44 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 16:53:03 1.12 @@ -272,16 +272,16 @@ . $self->servicename; my $id = $self->adaptor->insert_service_instance( - category => $self->category, - servicename => $self->servicename, - service_type_uri => $self->service_type_uri, - authority_id => $self->authority_id, - url => $self->url, - contact_email => $self->contact_email, - authoritative => $self->authoritative, - description => $self->description, - signatureURL => $self->signatureURL, - lsid => $service_lsid + {category => $self->category}, + {servicename => $self->servicename}, + {service_type_uri => $self->service_type_uri}, + {authority_id => $self->authority_id}, + {url => $self->url}, + {contact_email => $self->contact_email}, + {authoritative => $self->authoritative}, + {description => $self->description}, + {signatureURL => $self->signatureURL}, + {lsid => $service_lsid} ); $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists @@ -298,36 +298,29 @@ return undef; } $CONFIG ||= MOBY::Config->new; - $dbh->do( q{delete from service_instance where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from simple_input where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from simple_output where service_instance_id = ?}, - undef, $self->service_instance_id ); - my $sth = - $dbh->prepare( -q{select collection_input_id from collection_input where service_instance_id = ?} - ); - $sth->execute( $self->service_instance_id ); - while ( my ($id) = $sth->fetchrow_array ) { - $dbh->do( q{delete from simple_input where collection_input_id = ?}, - undef, $id ); - } - $sth = - $dbh->prepare( -q{select collection_output_id from collection_output where service_instance_id = ?} - ); - $sth->execute( $self->service_instance_id ); - while ( my ($id) = $sth->fetchrow_array ) { - $dbh->do( q{delete from simple_output where collection_output_id = ?}, - undef, $id ); - } - $dbh->do( q{delete from collection_input where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from collection_output where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from secondary_input where service_instance_id=?}, - undef, $self->service_instance_id ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + + $adaptor->delete_service_instance({service_instance_id => $self->service_instance_id}); + $adaptor->delete_simple_input({service_instance_id => $self->service_instance_id}); + $adaptor->delete_simple_output({service_instance_id => $self->service_instance_id}); + + my $result = $adaptor->query_collection_input({service_instance_id => $self->service_instance_id}); + + foreach my $row (@$result) { + my $id = $row->{collection_input_id}; + $adaptor->delete_simple_input({collection_input_id => $id}); + } + $result = $adaptor->query_collection_output({service_instance_id => $self->service_instance_id}); + + foreach my $row (@$result) { + my $id = $row->{collection_output_id}; + + $adaptor->delete_simple_output({collection_output_id => $id}); + } + $adaptor->delete_collection_input({service_instance_id => $self->service_instance_id}); + $adaptor->delete_collection_output({service_instance_id => $self->service_instance_id}); + $adaptor->delete_secondary_input({service_instance_id => $self->service_instance_id}); + return 1; } @@ -338,18 +331,21 @@ sub service_instance_exists { my ($self) = @_; + $CONFIG ||= MOBY::Config->new; + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; my $authority; - my ($id) = - $dbh->selectrow_array( - q{select authority_id from authority where authority_uri = ?}, - undef, $self->authority_uri ); + + my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $row = shift(@$result); + my $id = $row->{authority_id}; + return undef unless $id; - my ($svc) = $dbh->selectrow_array( -q{select service_instance_id from service_instance where authority_id = ? and servicename = ?}, - undef, - ( $id, $self->servicename ) - ); + + $result = $adaptor->query_service_instance({authority_id => $id}, 'and', {servicename => $self->servicename}); + $row = shift(@$result); + my $svc = $row->{service_instance_id}; + return $svc; } @@ -358,10 +354,14 @@ my ($self) = @_; my $dbh = $self->dbh; my $authority; - my ( $id, $name, $uri, $email ) = $dbh->selectrow_array( -q{select authority_id, authority_common_name, authority_uri, contact_email from authority where authority_uri = ?}, - undef, $self->authority_uri - ); + + my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $row = shift(@$result); + my $id = $row->{authority_id}; + my $name = $row->{authority_common_name}; + my $uri = $row->{authority_uri}; + my $email = $row->{contact_email}; + if ( defined $id ) { $authority = MOBY::authority->new( dbh => $self->dbh, From dwang at pub.open-bio.org Mon Jul 18 12:53:49 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon Jul 18 13:41:22 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507181653.j6IGrnpY016287@pub.open-bio.org> dwang Mon Jul 18 12:53:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv16261/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: All routines that are implementated in mysql.pm now exists in queryapi interface moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/13 18:19:09 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/18 16:53:49 1.4 @@ -108,44 +108,67 @@ } - +# general query subroutine +# parameters: +# statement - a string SQL statement +# bind_values - an array of values to be bound to the parameters +# returns: +# resultset - reference to an array containing ARRAY references +sub general_query{ + die "general_query not implemented in adaptor\n"; +} + # -# authority table functions +# collection_input table functions # -sub query_authority{ - - +sub query_collection_input{ + die "query_collection_input not implemented in adaptor\n"; } -sub insert_authority{ - +sub insert_collection_input { + die "insert_collection_input not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} } -sub delete_authority{ - +sub delete_collection_input{ + die "delete_collection_input not implemented in adaptor\n"; } - # -# service_instance table functions +# collection_output table fuctions # -sub query_service_instance { - die "query_service_instance not implemented in adaptor\n"; +sub query_collection_output{ + die "query_collection_output not implemented in adaptor\n"; } -sub insert_service_instance { - die "insert_service_instance not implemented in adaptor\n"; +sub insert_collection_output { + die "insert_collection_output not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} } -sub delete_service_intance{ - +sub delete_collection_output{ + die "delete_collection_output not implemented in adaptor\n"; } - + # # simple_output table functions # sub query_simple_input{ - + die "query_simple_input not implemented in adaptor\n"; } sub insert_simple_input { @@ -171,14 +194,14 @@ } sub delete_simple_input{ - + die "delete_simple_input not implemented in adaptor\n"; } # # simple_output table functions # sub query_simple_output{ - + die "query_simple_output not implemented in adaptor\n"; } sub insert_simple_output { @@ -205,178 +228,214 @@ } sub delete_simple_output{ - -} - -# -# collection_input table functions -# -sub query_collection_input{ - + die "delete_simple_output not implemented in adaptor\n"; } -sub insert_collection_input { - die "insert_collection_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} -} - -sub delete_collection_input{ - -} - -# -# collection_output table fuctions -# -sub query_collection_output{ - +# secondary_input table functions +sub query_secondary_input{ + die "query_secondary_input not implemented in adaptor\n"; } -sub insert_collection_output { - die "insert_collection_output not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} +sub insert_secondary_input{ + die "insert_secondary_input not implemented in adaptor\n"; } -sub delete_collection_output{ - +sub delete_secondary_input{ + die "delete_secondary_input not implemented in adaptor\n"; } # # object table functions # sub query_object{ - + die "query_object not implemented in adaptor\n"; } sub insert_object{ - + die "insert_object not implemented in adaptor\n"; } sub delete_object{ - + die "delete_object not implemented in adaptor\n"; } # # object_term2term table functions # sub query_object_term2term{ - + die "query_object_term2term not implemented in adaptor\n"; } sub insert_object_term2term{ - + die "insert_object_term2term not implemented in adaptor\n"; } sub delete_object_term2term{ - + die "delete_object_term2term not implemented in adaptor\n"; } # -# relationship table functions +# service_instance table functions # -sub query_relationship{ - +sub query_service_instance { + die "query_service_instance not implemented in adaptor\n"; } -sub insert_relationship{ - +sub match_service_type_uri{ + die "match_service_type_uri not implemented in adaptor\n"; } -sub delete_relationship{ +sub insert_service_instance { + die "insert_service_instance not implemented in adaptor\n"; +} + +sub delete_service_intance{ + die "delete_service_intance not implemented in adaptor\n"; +} +# +# authority table functions +# +sub query_authority{ + die "query_authority not implemented in adaptor\n"; +} + +sub getUniqueAuthorityURI{ + die "getUniqueAuthorityURI not implemented in adaptor\n"; +} + +sub insert_authority{ + die "insert_authority not implemented in adaptor\n"; +} + +sub delete_authority{ + die "delete_authority not implemented in adaptor\n"; } # # service table fuctions # sub query_service{ - + die "query_service not implemented in adaptor\n"; } sub insert_service{ - + die "insert_service not implemented in adaptor\n"; } sub delete_service{ - + die "delete_service not implemented in adaptor\n"; } # # service_term2term table functions # sub query_service_term2term{ - + die "query_service_term2term not implemented in adaptor\n"; } sub insert_service_term2term{ - + die "insert_service_term2term not implemented in adaptor\n"; } sub delete_service_term2term{ - + die "delete_service_term2term not implemented in adaptor\n"; +} + +# +# relationship table functions +# +sub query_relationship{ + die "query_relationship not implemented in adaptor\n"; +} + +sub insert_relationship{ + die "insert_relationship not implemented in adaptor\n"; +} + +sub delete_relationship{ + die "delete_relationship not implemented in adaptor\n"; } # # namespace table functions # sub query_namespace{ - + die "query_namespace not implemented in adaptor\n"; } sub insert_namespace{ - + die "insert_namespace not implemented in adaptor\n"; } sub delete_namespace{ - + die "delete_namespace not implemented in adaptor\n"; } # # namespace_term2term table functions # sub query_namespace_term2term{ - + die "query_namespace_term2term not implemented in adaptor\n"; } sub insert_namespace_term2term{ - + die "insert_namespace_term2term not implemented in adaptor\n"; } sub delete_namespace_term2term{ - + die "delete_namespace_term2term not implemented in adaptor\n"; } -# secondary_input table functions -sub query_secondary_input{ - +# custom query subroutine for Moby::Central.pm->deregisterObjectClass() +sub checkClassUsedByService{ + die "checkClassUsedByService not implemented in adaptor\n"; } -sub insert_secondary_input{ - +# custom query routine for Moby::Central.pm -> deregisterNamespace() +sub checkNamespaceUsedByService{ + die "checkNamespaceUsedByService not implemented in adaptor\n"; } -sub delete_secondary_input{ - +# custom query routine for Moby::Central.pm -> findService() +sub checkKeywords{ + die "checkKeywords not implemented in adaptor\n"; } -# -# query term2term tables - queries relation between two tables -# -sub select_term2term{ - +# custom query subroutine for Moby::Central.pm->_searchForSimple() +sub getFromSimple{ + die "getFromSimple not implemented in adaptor\n"; +} + +# custom query subroutine for Moby::Central.pm->_searchForCollection() +sub getFromCollection{ + die "getFromCollection not implemented in adaptor\n"; +} + +# custom query subroutine for Moby::Central.pm->RetrieveServiceNames +sub getServiceNames{ + die "getServiceNames not implemented in adaptor\n"; +} + +# custom query for Moby::Central.pm->_flatten +sub getParentTerms{ + die "getParentTerms not implemented in adaptor\n"; +} + +# custom query subroutine for selecting from object_term2term and object tables +# used in Moby::OntologyServer.pm->retrieveObject() +sub getObjectRelationships{ + die "getObjectRelationships not implemented in adaptor\n"; +} + +# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() +# note: returns a reference to an array containing ARRAY references +sub getRelationship{ + die "getRelationship not implemented in adaptor\n"; +} + +sub _checkURI { + die "_checkURI not implemented in adaptor\n"; } sub _dump { From dwang at pub.open-bio.org Mon Jul 18 12:54:29 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon Jul 18 13:42:01 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507181654.j6IGsTme016332@pub.open-bio.org> dwang Mon Jul 18 12:54:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv16306/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: minor changes to comments and indentation moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/15 16:39:11 1.13 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 16:54:29 1.14 @@ -1087,8 +1087,7 @@ } # custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection -{ +sub getFromCollection{ my ($self, @args) = @_; my $dbh = $self->dbh; my $inout = get_value('inout', @args); @@ -1120,8 +1119,7 @@ } # custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames -{ +sub getServiceNames{ my ($self, @args) = @_; my $dbh = $self->dbh; my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; @@ -1132,8 +1130,7 @@ } # custom query for Moby::Central.pm->_flatten -sub getParentTerms -{ +sub getParentTerms{ my ($self, @args) = @_; my $dbh = $self->dbh; From mwilkinson at pub.open-bio.org Mon Jul 18 18:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 18 19:20:10 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182232.j6IMWK1W017179@pub.open-bio.org> mwilkinson Mon Jul 18 18:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv17143/MOBY Modified Files: OntologyServer.pm Log Message: fixing brackets and semicolons moby-live/Perl/MOBY OntologyServer.pm,1.51,1.52 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/15 16:40:45 1.51 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/18 22:32:20 1.52 @@ -684,9 +684,9 @@ my $insertid = $adaptor->insert_service({service_type => $args{'node'}}, {service_lsid => $LSID}, - {description => $args{'description'}, - {authority => $args{'authority'}, - {contact_email => $args{'contact_email'}); + {description => $args{'description'}}, + {authority => $args{'authority'}}, + {contact_email => $args{'contact_email'}}); unless ( $insertid ) { return ( 0, "Service creation failed for unknown reasons", '' ); @@ -1070,7 +1070,7 @@ return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_relationship({relationship_type => $term}, 'and' {ontology => $ontology}); + my $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ontology}); my $row = shift(@$result); my $id = $row->{relationship_lsid}; From mwilkinson at pub.open-bio.org Mon Jul 18 18:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 18 19:20:20 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182232.j6IMWKUb017159@pub.open-bio.org> mwilkinson Mon Jul 18 18:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/Accessories In directory pub.open-bio.org:/tmp/cvs-serv17143/Accessories Removed Files: RESOURCES Log Message: fixing brackets and semicolons moby-live/Perl/Accessories RESOURCES,1.1,NONE rcsdiff: /home/repository/moby/moby-live/Perl/Accessories/RCS/RESOURCES,v: No such file or directory From mwilkinson at pub.open-bio.org Mon Jul 18 18:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 18 19:20:21 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182232.j6IMWKIE017198@pub.open-bio.org> mwilkinson Mon Jul 18 18:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv17143/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing brackets and semicolons moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 16:54:29 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 22:32:20 1.15 @@ -173,7 +173,7 @@ my ($self, @args) = @_; my $dbh = $self->dbh; my $statement = get_value('statement', @args); - my $sth = $dbh->prepare($statement}; + my $sth = $dbh->prepare($statement); if (@args > 1) { my $bindvalues = get_value('bind_values', @args); @@ -183,7 +183,7 @@ $sth->execute; } my $result = $sth->fetchall_arrayref(); - return result; + return $result; } sub query_collection_input{ @@ -340,7 +340,7 @@ my @bindvalues = (); ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, - undef, @bindvalues ) + undef, @bindvalues ); if (dbh->err){ return (1, dbh->errstr); } @@ -693,8 +693,8 @@ sub getUniqueAuthorityURI{ my ($self, @args) = @_; my $dbh = $self->dbh; - $statement = "select distinct authority_uri from authority"; - $bindvalues = (); + my $statement = "select distinct authority_uri from authority"; + my @bindvalues = (); my $result = do_query($dbh, $statement, @bindvalues); return $result; } @@ -709,7 +709,7 @@ values (?,?,?)", undef, (get_value('authority_common_name', @args), - get_value('authority_uri' @args), + get_value('authority_uri', @args), get_value('contact_email', @args))); my $id = $dbh->{mysql_insertid}; return $id; @@ -976,9 +976,9 @@ my $dbh = $self->dbh; my $existingURI = get_value('namespace_type_uris', @args); my $term = get_value('term', @args); + my $errstr; -my $sth = - $dbh->prepare( + my $sth = $dbh->prepare( "select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" ); $sth->execute; @@ -988,12 +988,11 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } - $sth = - $dbh->prepare( + $sth = $dbh->prepare( "select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" ); $sth->execute; @@ -1002,7 +1001,7 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } @@ -1016,7 +1015,7 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } @@ -1030,11 +1029,11 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } - return (0, $errstr); + return (0, ""); } # custom query routine for Moby::Central.pm -> findService() @@ -1046,13 +1045,13 @@ my $searchstring; foreach my $kw ( @{ $findme{keywords} } ) { - $debug && &_LOG("KEYWORD $kw\n"); +# $debug && &_LOG("KEYWORD $kw\n"); $kw =~ s/\*//g; $kw = $dbh->quote("%$kw%"); $searchstring .= " OR description like $kw "; } $searchstring =~ s/OR//; # just the first one - $debug && &_LOG("search $searchstring\n"); +# $debug && &_LOG("search $searchstring\n"); my $statement = "select service_instance_id from service_instance where $searchstring"; my @bindvalues = (); @@ -1103,7 +1102,7 @@ where s.collection_${inout}_id IS NOT NULL AND s.collection_${inout}_id = c.collection_${inout}_id - AND object_type_uri = '$objectURI' " + AND object_type_uri = '$objectURI' "; my $nsquery; foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; From mwilkinson at pub.open-bio.org Mon Jul 18 18:46:00 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 18 19:33:32 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182246.j6IMk0oR017294@pub.open-bio.org> mwilkinson Mon Jul 18 18:46:00 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv17267/MOBY Modified Files: Central.pm secondary_input.pm service_instance.pm Log Message: fixing brackets and semicolons moby-live/Perl/MOBY Central.pm,1.159,1.160 secondary_input.pm,1.3,1.4 service_instance.pm,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.159 retrieving revision 1.160 diff -u -r1.159 -r1.160 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 21:53:11 1.159 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/18 22:46:00 1.160 @@ -22,14 +22,16 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::RDF::ServiceInstanceRDF; -use RDF::Core; -use RDF::Core::Model; -use RDF::Core::Literal; -use RDF::Core::Statement; -use RDF::Core::Model::Serializer; -use RDF::Core::Storage::Memory; -use RDF::Core::Constants qw(:xml :rdf :rdfs); +use MOBY::Client::Central; + +#use MOBY::RDF::ServiceInstanceRDF; +#use RDF::Core; +#use RDF::Core::Model; +#use RDF::Core::Literal; +#use RDF::Core::Statement; +#use RDF::Core::Model::Serializer; +#use RDF::Core::Storage::Memory; +#use RDF::Core::Constants qw(:xml :rdf :rdfs); use MOBY::MobyXMLConstants; my $debug = 0; @@ -1329,8 +1331,6 @@ "" ); } - - use MOBY::Client::Central; my $services = MOBY::Client::Central::_parseServices( '', '', $si ); my $service_instance = shift @{$services}; @@ -3423,7 +3423,7 @@ $output .= "\t\t\n"; } $result = $adaptor->query_collection_input({service_instance => $_}); - $sth_collection_ins->execute($_); +# $sth_collection_ins->execute($_); foreach my $row (@$result) { @@ -3485,7 +3485,7 @@ my $articlename = $row->{article_name}; $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id = $collid}); + my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id => $collid}); foreach my $row2 (@$result2 ) { my $objURI = $row2->{object_type_uri}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 16:53:03 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 22:46:00 1.4 @@ -113,6 +113,7 @@ my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $dbh = $self->dbh; my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, {maximum_value => $self->maximum_value}, {minimum_value => $self->minimum_value}, =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 16:53:03 1.12 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 22:46:00 1.13 @@ -354,6 +354,8 @@ my ($self) = @_; my $dbh = $self->dbh; my $authority; + $CONFIG ||= MOBY::Config->new; + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); my $row = shift(@$result); From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 09:31:08 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxZv019448@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/Clients/help In directory pub.open-bio.org:/tmp/cvs-serv19358/src/Clients/help Modified Files: MobyCmdLineClient_usage.txt Log Message: moby-live/Java/src/Clients/help MobyCmdLineClient_usage.txt,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/help/MobyCmdLineClient_usage.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/Clients/help/MobyCmdLineClient_usage.txt 2004/12/05 22:28:02 1.7 +++ /home/repository/moby/moby-live/Java/src/Clients/help/MobyCmdLineClient_usage.txt 2005/07/19 12:39:58 1.8 @@ -9,16 +9,17 @@ -e ia an endpoint of a Moby registry - (default: http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY-Central.pl) + (default: http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl) -uri is a URI defining Moby registry's namespace - (default: http://mobycentral.cbr.nrc.ca/MOBY/Central) + (default: http://mobycentral.icapture.ubc.ca/MOBY/Central) where specify what to ask a Moby registry to do: To get lists of various entities registered by Moby: -ls ... list names of all available services + -la ... list names of all available services sorted by authorities -lp ... list names of all available service providers -lt ... list names and descriptions of all service types -ln ... list names and descriptions of all namespaces From senger at pub.open-bio.org Tue Jul 19 08:39:58 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 09:31:30 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdwHn019429@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/Clients In directory pub.open-bio.org:/tmp/cvs-serv19358/src/Clients Modified Files: MobyCmdLineClient.java MobyGraphs.java Log Message: moby-live/Java/src/Clients MobyCmdLineClient.java,1.8,1.9 MobyGraphs.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java 2004/12/05 22:28:02 1.8 +++ /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java 2005/07/19 12:39:58 1.9 @@ -95,12 +95,29 @@ if (cmd.hasOption ("-ls")) { decorationLn ("Service names:"); decorationLn ("--------------"); - Map names = worker.getServiceNames(); + Map authorities = worker.getServiceNamesByAuthority(); - for (Iterator it = names.entrySet().iterator(); it.hasNext(); ) { + for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) { + Map.Entry entry = (Map.Entry)it.next(); + String[] names = (String[])entry.getValue(); + for (int i = 0; i < names.length; i++) { + System.out.println (names[i]); + System.out.println ("\t" + entry.getKey()); + } + } + } + + if (cmd.hasOption ("-la")) { + decorationLn ("Service names by authorities:"); + decorationLn ("-----------------------------"); + Map authorities = worker.getServiceNamesByAuthority(); + + for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry)it.next(); System.out.println (entry.getKey()); - System.out.println ("\t" + entry.getValue()); + String[] names = (String[])entry.getValue(); + for (int i = 0; i < names.length; i++) + System.out.println ("\t" + names[i]); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java 2004/11/12 23:09:02 1.7 +++ /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java 2005/07/19 12:39:58 1.8 @@ -126,7 +126,55 @@ decorationLn ("Retrieving services..."); MobyService[] services = worker.getServices(); decorationLn ("Creating a graph of the services..."); - ServicesEdge[] edges = ServiceConnections.build (dataTypes, services); + ServicesEdge[] edges = null; + DataServiceEdge[] debugStartingEdges = null; + DataServiceEdge[] debugEndingEdges = null; + + // an undocumented option for debugging (see an + // example file in 'data' directory) + String xfile = cmd.getParam ("-X"); + boolean xfileing = (xfile != null); + + if (xfileing) { + Vector ev = new Vector(); + Vector evs = new Vector(); + Vector eve = new Vector(); + String line; + BufferedReader data = null; + data = new BufferedReader + (new InputStreamReader (new FileInputStream (xfile))); + while ((line = data.readLine()) != null) { + if (line.trim().equals ("")) continue; + if (line.trim().startsWith ("#")) continue; + String[] fields = StringUtils.split (line); + if (fields.length > 1) { + if (fields[0].equalsIgnoreCase ("start")) { + DataServiceEdge dse = new DataServiceEdge (new MobyDataType ("start"), + new MobyService (fields[1]), + ""); + evs.addElement (dse); + } else if (fields[1].equalsIgnoreCase ("end")) { + DataServiceEdge dse = new DataServiceEdge (new MobyService (fields[0]), + new MobyDataType ("end"), + ""); + eve.addElement (dse); + } else ev.addElement (new ServicesEdge (new MobyService (fields[0]), + new MobyService (fields[1]), + "")); + } + } + edges = new ServicesEdge[ev.size()]; + ev.copyInto (edges); + debugStartingEdges = new DataServiceEdge[evs.size()]; + evs.copyInto (debugStartingEdges); + debugEndingEdges = new DataServiceEdge[eve.size()]; + eve.copyInto (debugEndingEdges); + + } else { + edges = ServiceConnections.build (dataTypes, services); + } + + System.out.println ("EDGES: " + edges.length); // filter edges String[] authorities = null; @@ -144,13 +192,23 @@ } edges = FilterServices.filter (edges, authorities, serviceNames, depth); + System.out.println ("Filtered EDGES: " + edges.length); + + if (xfileing) { + System.out.println ("List of EDGES: "); + for (int i = 0; i < edges.length; i++) { + System.out.println ("\t" + edges[i].toString()); + } + } + if (cmd.hasParam ("-path")) { String[] pathEnds = cmd.getParam ("-path", 2); if (pathEnds[0] == null || pathEnds[1] == null) { System.err.println ("Missing value for parameter '-path'. It should be followed by two service names."); System.exit (1); } - edges = FilterServices.pathes (edges, pathEnds[0], pathEnds[1]); +// edges = FilterServices.pathes (edges, pathEnds[0], pathEnds[1]); + edges = FilterServices.pathes2 (edges, pathEnds[0], pathEnds[1]); if (edges == null) { System.err.println ("No connection found between '" + pathEnds[0] + "' and '" + pathEnds[1] + "'"); @@ -170,20 +228,62 @@ MobyPrimaryDataSimple sourceData = createSimpleData (pathEnds[0]); MobyPrimaryDataSimple targetData = createSimpleData (pathEnds[1]); - DataServiceEdge[] startingEdges = ServiceConnections.findStartingEdges (sourceData, dataTypes, services); - DataServiceEdge[] endingEdges = ServiceConnections.findEndingEdges (targetData, dataTypes, services); + DataServiceEdge[] startingEdges = null; + if (debugStartingEdges == null) + startingEdges = ServiceConnections.findStartingEdges (sourceData, dataTypes, services); + else + startingEdges = debugStartingEdges; + DataServiceEdge[] endingEdges = null; + if (debugEndingEdges == null) + endingEdges = ServiceConnections.findEndingEdges (targetData, dataTypes, services); + else + endingEdges = debugEndingEdges; + + System.out.println ("SE: " + startingEdges.length); + if (xfileing) { + for (int i = 0; i < startingEdges.length; i++) { + System.out.println ("\t" + startingEdges[i].toString()); + } + } + System.out.println ("EE: " + endingEdges.length); + if (xfileing) { + for (int i = 0; i < endingEdges.length; i++) { + System.out.println ("\t" + endingEdges[i].toString()); + } + } // this creates *all* pathes, but some of them have cycles and inside branches - separatePaths = FilterServices.dataPaths (startingEdges, edges, endingEdges); + separatePaths = FilterServices.dataPaths (startingEdges, edges, endingEdges); if (separatePaths.length == 0) { System.err.println ("No connection found between '" + pathEnds[0] + "' and '" + pathEnds[1] + "'"); System.exit(1); } + + System.out.println ("After dataPaths: " + separatePaths.length); + if (xfileing) { + for (int i = 0; i < separatePaths.length; i++) { + System.out.println ("Separate data path " + (i+1)); + for (int j = 0; j < separatePaths[i].length; j++) { + System.out.println ("\t" + separatePaths[i][j]); + } + } + } + allPaths = FilterServices.joinPaths (separatePaths); + System.out.println ("After joinPaths: " + allPaths.length); + if (xfileing) { + System.out.println ("Join paths: "); + for (int i = 0; i < allPaths.length; i++) { + System.out.println ("\t" + allPaths[i].toString()); + } + } + + // separate paths to straight paths (no cycles, no branches) + separatePaths = FilterServices.straightDataPaths (startingEdges, allPaths, endingEdges); - // this separate paths to straight paths (no cycles, no branches) - separatePaths = FilterServices.straightDataPaths (startingEdges, allPaths, endingEdges); + System.out.println ("After straightDataPaths: " + separatePaths.length); +// System.exit (1); } // create a graph (in whatever format) @@ -236,7 +336,7 @@ } else { graphs = new String [1]; - graphs[0] = Graphviz.createServicesGraph (allPaths, props); + graphs[0] = Graphviz.createServicesGraph (allPaths, props); } String fn = cmd.getParam ("-fs"); From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 09:31:31 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxn1019586@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/xmls In directory pub.open-bio.org:/tmp/cvs-serv19358/xmls Modified Files: libraries.xml Log Message: moby-live/Java/xmls libraries.xml,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/libraries.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/xmls/libraries.xml 2005/05/19 20:18:54 1.1 +++ /home/repository/moby/moby-live/Java/xmls/libraries.xml 2005/07/19 12:39:59 1.2 @@ -8,7 +8,7 @@ - + From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 09:31:32 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxK1019525@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv19358/src/main/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/06/17 19:25:31 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/19 12:39:59 1.8 @@ -1015,7 +1015,7 @@ * the maximum value of the secondary input * @param min * the minimum value of the secondary input * - * @param enum + * @param enumeration * the enumeration value for the secondary input */ From senger at pub.open-bio.org Tue Jul 19 08:39:58 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 09:31:34 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdwY1019377@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java In directory pub.open-bio.org:/tmp/cvs-serv19358 Modified Files: build.xml Log Message: moby-live/Java build.xml,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Java/build.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Java/build.xml 2005/05/19 20:18:53 1.16 +++ /home/repository/moby/moby-live/Java/build.xml 2005/07/19 12:39:58 1.17 @@ -207,11 +207,13 @@ @@ -256,7 +258,7 @@ @@ -501,13 +502,28 @@ - Tomcat Catalina not found. - Please set environment variable CATALINA_HOME to point to it, or - create a file 'build.properties' and put there the line: - catalina.home = <location of your CATALINA> - (do not include '<' and '>' there) + + Tomcat Catalina not found. + ----------------------------------- + Please set environment variable CATALINA_HOME to point to it, or + create a file 'build.properties' and put there the line: + catalina.home = <location of your CATALINA> + (do not include '<' and '>' there) - + + + + + + + + + Tomcat does not seem to be running. + ----------------------------------- + I have just checked ${tomcat.host}:${tomcat.port}... + You may perhaps consider to start it. + + @@ -606,6 +622,9 @@ + + @@ -626,7 +645,7 @@ - + From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 09:31:42 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdx99019544@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv19358/src/main/org/biomoby/shared Modified Files: Central.java Log Message: moby-live/Java/src/main/org/biomoby/shared Central.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java 2005/04/07 16:37:02 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java 2005/07/19 12:39:59 1.10 @@ -28,20 +28,6 @@ * * http://biomoby.org. *

- * - *

Last changes (in backwards order)
- *
    - *
  • New methods retrieving location of a Moby registry have been added: - * {@link #getRegistryEndpoint}, - * {@link #getRegistryNamespace}, - *
  • Added new constants defining relationship types as integers. - *
  • New methods retrieving various types of relationships have been added: - * {@link #getDataTypeRelationships}, - * {@link #getServiceTypeRelationships} - *
  • Added constants defining recognizable relationship types - * ({@link #ISA}, {@link #HASA}, {@link #HAS}) - *
- *

* @author Martin Senger * @version $Id$ */ @@ -81,8 +67,13 @@ static final int iHAS = 3; /************************************************************************** - * Get a (redundant) list of all registered service names. - *

+ * Get a (redundant) list of all registered service names.

+ * + * @deprecated Replaced by {@link + * #getServiceNamesByAuthority}. The reason is that this method + * returns a random result if there are more services with the + * same name but belonging to different authorities.

+ * * @return a hash table where keys are names of services while * values are their authorities * @throws MobyException if communication with the Moby Registry fails @@ -91,6 +82,20 @@ throws MobyException; /************************************************************************** + * Get a list of all authorities - and for each of them a list of + * their registered service names.

+ * + * This method is a better replacement for the deprecated method + * {@link #getServiceNames}.

+ * + * @return a hash table where keys are authority names and values + * are arrays of service names provided by each authority + * @throws MobyException if communication with the Moby Registry fails + *************************************************************************/ + Map getServiceNamesByAuthority() + throws MobyException; + + /************************************************************************** * Get the list of all providers (each provider is represented by an * authority's URI. *

From senger at pub.open-bio.org Tue Jul 19 08:39:58 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 09:32:25 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdwhD019404@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv19358/docs Modified Files: 3rdPartyLibraries.html ChangeLog Download.html Added Files: CVS.html Log Message: moby-live/Java/docs CVS.html,NONE,1.1 3rdPartyLibraries.html,1.2,1.3 ChangeLog,1.30,1.31 Download.html,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/3rdPartyLibraries.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/docs/3rdPartyLibraries.html 2005/05/19 20:25:40 1.2 +++ /home/repository/moby/moby-live/Java/docs/3rdPartyLibraries.html 2005/07/19 12:39:58 1.3 @@ -10,20 +10,47 @@

Third-party Libraries Guidelines

-Comming soon.. -

+The third-party libraries are (mostly) .jar files whose +source code is not included in the jMoby CVS repository.

-For now, just look into xmls/libraries.xml - and it's almost -self-explanatory... +Neither their binary code (classes themselves). That's why the jMoby's +Ant tasks need to get it first from some remote repository. The +question is where is such remote repository and how to update it (if +needed). This document explains that.

+ +The third-party jar files are retrievable by HTTP protocol +from the place that is defined in the Ant property remote.dir +in the xmls/libraries file. In the same file, there is also a +full list of the third-party libraries needed in jMoby. If you need to +add a library, put it there (the name must appear in three places in +that file, actually).

+ +However, to put the new name there, it is not enough. You need also to +add such new jar file into the remote repository (or to +update there one if you wish jMoby to use a newer version). In order +to do that, you need to check-out and update/commit to the CVS module +jars-archive (note that you do not need to do this +if you are just using jMoby, or developing with jMoby). The module is +located together with other Biomoby CVS modules - so follow the normal +way: + +

+export CVS_RSH=ssh
+cvs -d :ext:your-user-name@pub.open-bio.org:/home/repository/moby co -P jars-archive
+
+ +Once you have committed there a new library, or a new version of an +existing library, you need to wait until it is propagated to the place +indicated by the remote.dir. This is done by a cron job that +runs at 20 past the hour every other hour.

-


Martin Senger
-Last modified: Thu May 19 20:35:23 2005 +Last modified: Tue Jul 19 14:16:23 2005
=================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/05/19 20:18:53 1.30 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/07/19 12:39:58 1.31 @@ -1,3 +1,16 @@ +2005-07-19 Martin Senger + + * Changed the remote repository for the third-party jar files. + + * Added a new option -la to the MobyCmdLineClient to list services + by authorities. + + * Added new method getServiceNamesByAuthority() to the + Central.java interface. getServiceNames() deprecated. + + * Default location and namespace of the Moby Central has been + changed (in CentralImpl.java). + 2005-05-19 Martin Senger * Updated build.xml; also separate some fragments into xmls =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Download.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/docs/Download.html 2005/05/19 20:18:53 1.4 +++ /home/repository/moby/moby-live/Java/docs/Download.html 2005/07/19 12:39:58 1.5 @@ -42,9 +42,10 @@

Using jMoby from CVS

-Once you checked out your local CVS copy, go to the -moby-live/Java subdirectory. All directory and files names -used below assume that you are in this directory.

+Once you checked out your local CVS copy (here is how to do it), go to the moby-live/Java +subdirectory. All directory and files names used below assume that you +are in this directory.

How to build it
@@ -367,7 +368,7 @@
Martin Senger
-Last modified: Thu May 19 19:07:17 2005 +Last modified: Tue Jul 19 11:34:08 2005
From gordonp at pub.open-bio.org Tue Jul 19 08:59:21 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Tue Jul 19 09:46:48 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191259.j6JCxLDe019685@pub.open-bio.org> gordonp Tue Jul 19 08:59:21 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory pub.open-bio.org:/tmp/cvs-serv19660 Modified Files: MobyDataSecondaryInstance.java Log Message: Changed data type variable name to not overshadow protected variable declaration in parent class moby-live/Java/src/main/org/biomoby/shared/data MobyDataSecondaryInstance.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/05/12 04:59:49 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/07/19 12:59:21 1.2 @@ -8,7 +8,7 @@ public class MobyDataSecondaryInstance extends MobySecondaryData{ protected String dataValue = null; - protected MobySecondaryData dataType = null; + protected MobySecondaryData secDataType = null; public MobyDataSecondaryInstance(MobySecondaryData type, String value){ this(type); @@ -26,7 +26,7 @@ setDefaultValue(type.getDefaultValue()); setMinimumValue(type.getMinimumValue()); setMaximumValue(type.getMaximumValue()); - dataType = type; + secDataType = type; } public void setValue(String value) throws IllegalArgumentException{ @@ -39,7 +39,7 @@ public String toXML(){ return " " + dataValue + "\n"; } } From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 09:56:04 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxlX019566@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory pub.open-bio.org:/tmp/cvs-serv19358/src/main/org/biomoby/shared/data Modified Files: MobyDataObject.java Log Message: moby-live/Java/src/main/org/biomoby/shared/data MobyDataObject.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/07/19 12:39:59 1.3 @@ -88,7 +88,7 @@ * will also parse a MOBY XML Object wrapped in a Simple tag when the Simple * is passed in as the main element. * - * @param the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag + * @param objectTag the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag */ public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws IllegalArgumentException{ MobyDataObject object = null; From senger at pub.open-bio.org Tue Jul 19 09:08:31 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 09:56:06 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191308.j6JD8VRn019766@pub.open-bio.org> senger Tue Jul 19 09:08:31 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv19747/docs Modified Files: Download.html Log Message: moby-live/Java/docs Download.html,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Download.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/docs/Download.html 2005/07/19 12:39:58 1.5 +++ /home/repository/moby/moby-live/Java/docs/Download.html 2005/07/19 13:08:31 1.6 @@ -272,11 +272,9 @@ some specific features. (Remember, however, that you can always get everything in one go from the CVS repository.)

-The binary distributions are available either from the main jMoby site (located on the same place as the main -BioMoby pages), or from http://industry.ebi.ac.uk/~senger/jMoby/dist/. -

+BioMoby pages).

Command-line clients exploring BioMoby
@@ -368,7 +366,7 @@
Martin Senger
-Last modified: Tue Jul 19 11:34:08 2005 +Last modified: Tue Jul 19 14:52:57 2005
From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 10:08:59 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGrTt019848@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs/dist In directory pub.open-bio.org:/tmp/cvs-serv19810/docs/dist Modified Files: _README_ Log Message: moby-live/Java/docs/dist _README_,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/dist/_README_,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/docs/dist/_README_ 2004/12/05 22:28:02 1.3 +++ /home/repository/moby/moby-live/Java/docs/dist/_README_ 2005/07/19 13:16:53 1.4 @@ -1,6 +1,5 @@ This is a distribution directory of jMoby project. -More details in http://www.biomoby.org/moby-live/Java/docs/index.html -Mirror: http://industry.ebi.ac.uk/~senger/jMoby/ +More details in http://www.biomoby.org/moby-live/Java/docs/index.html. Binary distribution has everything except sources and Ant files to build things: @@ -24,7 +23,7 @@ -------------------------------------------------------------------- File: README Comments to the biomoby mailing lists, or directly to -Martin Senger (senger@ebi.ac.uk). +Martin Senger (martin.senger@gmail.com). $Id$ -------------------------------------------------------------------- From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 10:09:28 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGroI019829@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java In directory pub.open-bio.org:/tmp/cvs-serv19810 Modified Files: README Log Message: moby-live/Java README,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/README,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/README 2004/12/05 22:28:01 1.8 +++ /home/repository/moby/moby-live/Java/README 2005/07/19 13:16:53 1.9 @@ -8,7 +8,7 @@ Find more in docs/index.html. If you do not want to build it you can use the binary distribution -which is available at http://industry.ebi.ac.uk/~senger/jMoby/dist/. +which is available at http://www.biomoby.org/moby-live/Java/docs/dist/. HOW TO BUILD IT --------------- From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 10:09:29 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGruI019907@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory pub.open-bio.org:/tmp/cvs-serv19810/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/19 12:39:59 1.12 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/19 13:16:53 1.13 @@ -45,7 +45,7 @@ * MOBY format. It depends on * having already retrieved the definition of the Web service via * the MOBY central registry using the - * jMOBY API, + * jMOBY API, * and for now it uses the * Apache * Axis Web services framework, as well as Apache Xalan. There are code comments for the From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 10:09:36 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGrYj019888@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/lib In directory pub.open-bio.org:/tmp/cvs-serv19810/lib Modified Files: README Log Message: moby-live/Java/lib README,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/lib/README,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/lib/README 2003/11/08 00:27:24 1.4 +++ /home/repository/moby/moby-live/Java/lib/README 2005/07/19 13:16:53 1.5 @@ -1,7 +1,7 @@ -------------------------------------------------------------------- File: README Comments to the biomoby mailing lists, or directly to Martin Senger -(senger@ebi.ac.uk). +(martin.senger@gmail.com). $Id$ -------------------------------------------------------------------- @@ -10,7 +10,7 @@ separate subdirectory) can be fetched automatically from a remote site. This is usually done by calling build.sh (which uses ant's target 'gather' to do it). The remote site that is used is defined in -the build.xml. +the xmls/libraries.xml. You are, of course, free to fetch them manually in any convenient time and from any convenient site. Doing that may be even more correct way @@ -24,26 +24,3 @@ build-dev.bat) (instead of build.sh or build.bat). Of course, time to time it is worth to use the build.sh (build.bat) script again to make sure that you have the latest versions of all fetched files. - -Files: -====== -* alltools.jar - A set of various tools and utilities. - Sources and documentation are available from - http://industry.ebi.ac.uk/~senger/tools/ - -* xerces*.jar, xml*.jar. - Library for SAX/DOM parser. They come from Apache Xerces-2.3.0. - -* axis-ant.jar, commons-discovery.jar, commons-logging.jar, jaxrpc.jar - wsdl4j.jar, axis.jar, log4j-1.2.4.jar, saaj.jar. - Libraries from the Apache Axis project (a toolkit for the SOAP protocol). - -* servlet.jar, activation.jar - Libraries dealing with servlets. They come from Apache Tomcat project. - -* jena.jar, adenine.jar - Libraries from 'haystack' (IBM) for producing RDF files. - They can be fetched from here: - http://www.ai.mit.edu/people/dquan/adenine.jar - http://www.ai.mit.edu/people/dquan/jena.jar From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue Jul 19 10:09:37 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGrch019868@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs/graphs In directory pub.open-bio.org:/tmp/cvs-serv19810/docs/graphs Modified Files: index.html Log Message: moby-live/Java/docs/graphs index.html,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/graphs/index.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/docs/graphs/index.html 2004/10/18 14:35:05 1.4 +++ /home/repository/moby/moby-live/Java/docs/graphs/index.html 2005/07/19 13:16:53 1.5 @@ -38,7 +38,7 @@ you have a popular Graphviz tool installed on your machine (the tool is available for many platforms). Just download the latest - binary distribution + binary distribution of jMoby (see details in jMoby main documentation.

@@ -129,7 +129,7 @@

Suggestions, comments, and bug reports to:
Martin Senger
-Last modified: Mon Oct 18 12:33:26 2004 +Last modified: Tue Jul 19 15:06:47 2005
From mwilkinson at pub.open-bio.org Tue Jul 19 10:33:46 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 19 11:21:41 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191433.j6JEXklc020185@pub.open-bio.org> mwilkinson Tue Jul 19 10:33:46 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20166/Perl/MOBY Modified Files: Central.pm Log Message: temporarily removing all LSID code to get a fresh start moby-live/Perl/MOBY Central.pm,1.160,1.161 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.160 retrieving revision 1.161 diff -u -r1.160 -r1.161 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/18 22:46:00 1.160 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/19 14:33:46 1.161 @@ -1340,7 +1340,7 @@ #model => $model, #service_instance => $service_instance ); # my $RDF_XML = $RDF_MODEL->serialize; - my $LSID = $service_instance->LSID; + #my $LSID = $service_instance->LSID; # my $RDF = _getServiceInstanceRDF($LSID); my $RDF = ""; @@ -1359,7 +1359,7 @@ sub _getServiceInstanceRDF { my ( $self, $LSID ) = @_; - my $lsid = LS::ID->new($LSID); + #my $lsid = LS::ID->new($LSID); my $RDF_XML = ""; my $lsid_error = ""; my $lsid_good = 1; @@ -1369,38 +1369,38 @@ #use LS::Client::BasicResolver; #use LS::Locator; - my $resolver = LS::Client::BasicResolver->new(); - my $authority = $resolver->resolve( lsid => $lsid ); - unless ($authority) { - $lsid_error .= "The authority for $LSID could not be located"; + #my $resolver = LS::Client::BasicResolver->new(); + #my $authority = $resolver->resolve( lsid => $lsid ); + #unless ($authority) { + # $lsid_error .= "The authority for $LSID could not be located"; + + #} + #return $lsid_error unless $authority; + #$authority->clean_cache(); + +# my $resource = $authority->getResource($lsid); +# unless ($resource) { +# $lsid_error .= $authority->error_string . " "; +# return $lsid_error; +# } - } - return $lsid_error unless $authority; - $authority->clean_cache(); - - my $resource = $authority->getResource($lsid); - unless ($resource) { - $lsid_error .= $authority->error_string . " "; - return $lsid_error; - } - - my $response = $resource->get_metadata; - unless ( ref($response) =~ /LS::Service::Response/ ) { +# my $response = $resource->get_metadata; +# unless ( ref($response) =~ /LS::Service::Response/ ) { #TODO raise an error - $lsid_error .= "Metadata response didn't come back"; - return $lsid_error; - } +# $lsid_error .= "Metadata response didn't come back"; +# return $lsid_error; +# } - my $rsp = $response->response; - unless ( ref($rsp) =~ /IO::File/ ) { +# my $rsp = $response->response; +# unless ( ref($rsp) =~ /IO::File/ ) { #TODO raise an error - $lsid_error .= "metadata response was not a filehandle"; - } - while (<$rsp>) { - $RDF_XML .= $_; - } +# $lsid_error .= "metadata response was not a filehandle"; +# } +# while (<$rsp>) { +# $RDF_XML .= $_; +# } return $RDF_XML } From mwilkinson at pub.open-bio.org Tue Jul 19 10:33:47 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 19 11:21:45 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191433.j6JEXlVY020205@pub.open-bio.org> mwilkinson Tue Jul 19 10:33:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv20166/Perl/MOBY/Client Modified Files: Central.pm Log Message: temporarily removing all LSID code to get a fresh start moby-live/Perl/MOBY/Client Central.pm,1.97,1.98 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.97 retrieving revision 1.98 diff -u -r1.97 -r1.98 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/05/30 22:54:43 1.97 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 14:33:46 1.98 @@ -1725,7 +1725,7 @@ my $Service = $Services->get_node($x); my $AuthURI = $Service->getAttributeNode('authURI')->getValue; my $servicename = $Service->getAttributeNode('serviceName')->getValue; - my $lsid = $Service->getAttributeNode('lsid')->getValue; + #my $lsid = $Service->getAttributeNode('lsid')->getValue; my $Type = &_nodeTextContent( $Service, 'serviceType' ); my $authoritative = &_nodeTextContent( $Service, 'authoritative' ); my $contactEmail = &_nodeTextContent( $Service, 'contactEmail' ); @@ -1789,7 +1789,7 @@ authority => $AuthURI, authoritative => $authoritative, URL => $URL, - LSID => $lsid, + #LSID => $lsid, contactEmail => $contactEmail, name => $servicename, type => $Type, From kawas at pub.open-bio.org Tue Jul 19 11:28:28 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 12:16:07 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191528.j6JFSSbc020394@pub.open-bio.org> kawas Tue Jul 19 11:28:28 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms In directory pub.open-bio.org:/tmp/cvs-serv20365/org/biomoby/client/ui/graphical/servlet/forms Modified Files: GetSignatureRDFResponse.java GetSignatureRDFForm.java Log Message: changed the mobycentral registry to become the new one. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms GetSignatureRDFResponse.java,1.2,1.3 GetSignatureRDFForm.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java 2005/04/07 21:02:01 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java 2005/07/19 15:28:28 1.3 @@ -47,7 +47,7 @@ + "

Unable to update your information

\r\n" + "
\r\n" + "

Make sure that you specify a valid signature url! This field looks like the following: http://myAuthority.domain/path/to/rdf/for/service. Also make sure that you have specified the right case-sensitive service name, if applicable.

\r\n" - + "

Back

\r\n" + + "

Back

\r\n" + "
\r\n" + "\r\n" + ""; protected void doGet(HttpServletRequest request, @@ -100,10 +100,10 @@ if (name.equals("")) { System.out.println("empty name"); - con = "http://mobycentral.cbr.nrc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + con = "http://mobycentral.icapture.ubc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + domain + "&URL=" + sigURL; } else { - con = "http://mobycentral.cbr.nrc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + con = "http://mobycentral.icapture.ubc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + domain + "&URL=" + sigURL + "&serviceName=" + name; } URL url = new URL(con); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java 2005/04/07 21:02:01 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java 2005/07/19 15:28:28 1.3 @@ -34,7 +34,7 @@ // some useful variables private final String newline = System.getProperty("line.separator"); - private static final String DOMAIN = "mobycentral.cbr.nrc.ca:8090"; + private static final String DOMAIN = "mobycentral.icapture.ubc.ca:8090"; /* (non-Javadoc) * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @@ -169,6 +169,7 @@ central = new CentralImpl(); domains = central.getProviders(); } catch (MobyException e) { + e.printStackTrace(); return; } // sort the array From kawas at pub.open-bio.org Tue Jul 19 11:29:32 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 12:17:01 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191529.j6JFTWuc020448@pub.open-bio.org> kawas Tue Jul 19 11:29:32 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes In directory pub.open-bio.org:/tmp/cvs-serv20423/org/biomoby/client/ui/graphical/servlet/jTypes Modified Files: Types.java Log Message: removed a print statement that eluded me for years (months... okay weeks!) Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes Types.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes/Types.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes/Types.java 2005/04/07 16:42:30 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes/Types.java 2005/07/19 15:29:32 1.2 @@ -35,7 +35,6 @@ p = Pattern.compile("/types/Services\\S*"); m = p.matcher(path); if (m.matches()) { - System.out.println("Matching services ..."); // get Services response.setContentType("text/plain"); PrintWriter out = response.getWriter(); @@ -46,7 +45,6 @@ response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, e.getLocalizedMessage()); return; } - System.out.println("done"); return; } p = Pattern.compile("/types/Namespaces\\S*"); From kawas at pub.open-bio.org Tue Jul 19 11:32:54 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 12:21:56 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191532.j6JFWs6r020518@pub.open-bio.org> kawas Tue Jul 19 11:32:54 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources In directory pub.open-bio.org:/tmp/cvs-serv20493/org/biomoby/client/ui/graphical/servlet/jresources Modified Files: RESOURCE.java Log Message: Code has mobycentral registry domain changes, as well as certain todo statements have been excised. The next version should a way to retrieve information regarding the BioMoby predicate vocabulary. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources RESOURCE.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/06/09 17:39:00 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/07/19 15:32:54 1.7 @@ -19,6 +19,7 @@ import org.biomoby.client.CentralDigestImpl; import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; +import org.biomoby.client.rdf.vocabulary.XMLTypes; import org.biomoby.registry.definitions.types.JNamespaces; import org.biomoby.registry.definitions.types.JObjects; import org.biomoby.registry.definitions.types.JServices; @@ -165,7 +166,7 @@ * @see javax.servlet.GenericServlet#init() */ public final void init() throws ServletException { - super.init(); + // super.init(); } protected final void doGet(HttpServletRequest request, @@ -366,8 +367,8 @@ .getURL())); subject.addProperty(DC.identifier, model .createTypedLiteral("urn:lsid:" - + properties.getProperty("lsid_domain") - + ":serviceinstance:" + services[i].getAuthority() + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_authority") + ":" + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_namespace") + ":" +services[i].getAuthority() + "," + services[i].getName())); subject.addProperty(Predicates.performs_task, model .createResource(SRV + services[i].getType())); @@ -783,7 +784,9 @@ Pattern p = Pattern.compile("urn:lsid.*:(\\S+)$"); Matcher m = p.matcher(thing); String label = (m.matches() ? m.group(1) : thing); + //TODO - add the ofType property if thing is String, Float, Integer, DataTime. Resource resource = model.createResource(ns + thing); + addOfTypeProperty(model, resource, thing); model.add(model.createStatement(resource, RDF.type, RDFS.Class)); model.add(model.createStatement(resource, RDFS.label, model .createLiteral(label, "en"))); @@ -792,7 +795,30 @@ return resource; } - private final String getTypes(String type) throws MobyException { + /** + * @param model + * @param resource + * @param thing + */ + private void addOfTypeProperty(Model model, Resource resource, String name) { + // make sure that we declare the ns for the datatype + Map map = model.getNsPrefixMap(); + if (!map.containsValue(XMLTypes.getURI())) { + map.put(XMLTypes.getPrefix(), XMLTypes.getURI()); + } + model.setNsPrefixes(map); + if (name.equalsIgnoreCase("string")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_STRING)); + } else if (name.equalsIgnoreCase("integer")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_INTEGER)); + } else if (name.equalsIgnoreCase("float")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_FLOAT)); + } else if (name.equalsIgnoreCase("datatime")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_DATE_TIME)); + } + } + + private final String getTypes(String type) throws MobyException { if (type.equalsIgnoreCase("objects")) { try { return new JObjects().getObjects(); @@ -800,7 +826,7 @@ e.printStackTrace(); } // resort to a secondary method for retrieval of JObjects - return getURL("http://mobycentral.cbr.nrc.ca:8090/types/Objects"); + return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Objects"); } else if (type.equalsIgnoreCase("services")) { try { return new JServices().getServices(); @@ -808,7 +834,7 @@ e.printStackTrace(); } // resort to a secondary method for retrieval of JServices - return getURL("http://mobycentral.cbr.nrc.ca:8090/types/Services"); + return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Services"); } else if (type.equalsIgnoreCase("namespaces")) { try { return new JNamespaces().getNamespaces(); @@ -816,7 +842,7 @@ e.printStackTrace(); } // resort to a secondary method for retrieval of JNamespaces - return getURL("http://mobycentral.cbr.nrc.ca:8090/types/Namespaces"); + return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Namespaces"); } return ""; } @@ -925,7 +951,7 @@ } public static void main(String[] args) throws MobyException { - System.out.println(new RESOURCE().getRESOURCES("ServiceInstances")); + System.out.println(new RESOURCE().getRESOURCES("Objects")); } } From kawas at pub.open-bio.org Tue Jul 19 11:44:11 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 12:31:49 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191544.j6JFiB5Q020750@pub.open-bio.org> kawas Tue Jul 19 11:44:10 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool In directory pub.open-bio.org:/tmp/cvs-serv20713/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool Modified Files: InputOutputFocusListener.java MobyInputOutputData.java ServiceInstancePanelFactory.java Service.java Log Message: Fixed a bug that occured upon registration of secondary inputs. ALso switch registry domains. moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool InputOutputFocusListener.java,1.3,1.4 MobyInputOutputData.java,1.1,1.2 ServiceInstancePanelFactory.java,1.2,1.3 Service.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/InputOutputFocusListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/InputOutputFocusListener.java 2005/04/20 21:42:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/InputOutputFocusListener.java 2005/07/19 15:44:10 1.4 @@ -50,7 +50,7 @@ if (_name.equals("name")) { InputOutputFocusListener.name = ((JTextField) (fe.getComponent())).getText(); - } else if (_name.equals("enumeration")) { + } else if (_name.equals("enum")) { InputOutputFocusListener.enumeration = ((JTextField) (fe.getComponent())).getText(); secondaryEnumerationField = (JTextField) (fe.getComponent()); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/MobyInputOutputData.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/MobyInputOutputData.java 2005/04/07 16:42:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/MobyInputOutputData.java 2005/07/19 15:44:10 1.2 @@ -34,10 +34,10 @@ * Variables for the test database. */ static final String ENDPOINT = - "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; + "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; static final String NAMESPACE = - "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; - private static String _URL = "http://mobycentral.cbr.nrc.ca/cgi-bin/applets/retrieveObjectXML.cgi?name="; + "http://mobycentral.icapture.ubc.ca/MOBY/Central"; + private static String _URL = "http://mobycentral.icapture.ubc.ca/cgi-bin/applets/retrieveObjectXML.cgi?name="; /** * =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/ServiceInstancePanelFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/ServiceInstancePanelFactory.java 2005/04/07 21:01:13 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/ServiceInstancePanelFactory.java 2005/07/19 15:44:10 1.3 @@ -43,7 +43,7 @@ private JButton edit; private JButton submit = null; - private static String datatype = "INT"; + private static String datatype = "Integer"; private JList namespaceDropdownList, enumerations; private DefaultListModel model = new DefaultListModel(), _enums = new DefaultListModel(); @@ -1161,8 +1161,8 @@ scrollingList.setPreferredSize(dim); scrollingList.setWheelScrollingEnabled(true); - JComboBox combo = new JComboBox(new String[] { "INT", "FLOAT", - "STRING", "DATE/TIME" }); + JComboBox combo = new JComboBox(new String[] { "Integer", "Float", + "String", "DateTime" }); combo.addActionListener(ioal); combo.setActionCommand("datatype"); combo.setName("datatype"); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/Service.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/Service.java 2005/04/07 21:01:13 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/Service.java 2005/07/19 15:44:10 1.3 @@ -27,9 +27,9 @@ private boolean PROTO = false; - static final String ENDPOINT = "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; + static final String ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; - static final String NAMESPACE = "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; + static final String NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; public static String REG_TEXT = ""; @@ -82,7 +82,7 @@ worker = new CentralImpl(CentralImpl.DEFAULT_ENDPOINT, CentralImpl.DEFAULT_NAMESPACE); worker.registerService(this); - success = true; + success = true || true; REG_TEXT = "Service has been registered!"; } catch (MobyException e) { From kawas at pub.open-bio.org Tue Jul 19 11:50:44 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 12:38:10 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191550.j6JFoiMg020800@pub.open-bio.org> kawas Tue Jul 19 11:50:43 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool In directory pub.open-bio.org:/tmp/cvs-serv20775/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool Modified Files: ServiceTypeApplet.java Log Message: changed the mobycentral registry to become the new one. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool ServiceTypeApplet.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool/ServiceTypeApplet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool/ServiceTypeApplet.java 2005/04/07 16:42:29 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool/ServiceTypeApplet.java 2005/07/19 15:50:43 1.2 @@ -107,9 +107,9 @@ private JFrame frame = null; - static final String ENDPOINT = "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; + static final String ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; - static final String NAMESPACE = "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; + static final String NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; /** * This method initializes From kawas at pub.open-bio.org Tue Jul 19 11:51:50 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 12:39:15 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191551.j6JFposr020854@pub.open-bio.org> kawas Tue Jul 19 11:51:50 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority In directory pub.open-bio.org:/tmp/cvs-serv20829/org/biomoby/client/ui/graphical/servlet/lsid/authority Modified Files: Test.java Log Message: turned caching off in this test lsid client. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority Test.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/Test.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/Test.java 2005/04/20 21:42:10 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/Test.java 2005/07/19 15:51:50 1.3 @@ -30,10 +30,12 @@ * @throws LSIDException */ public static void main(String[] args) throws LSIDException { - String lsid_to_use = "urn:lsid:biomoby.org:objectclass:DNASequence";//"urn:lsid:biomoby.org:objectclass:DNASequence"; + String lsid_to_use = "urn:lsid:biomoby.org:objectclass:DNASequence"; LSID lsid = new LSID(lsid_to_use); LSIDResolver resolver = new LSIDResolver(lsid); + resolver.setUseLocalCache(false); String output = lsid.toString() + "\n"; + System.out.println(resolver.getWSDLWrapper().toString()); try { LSIDWSDLWrapper wrapper = resolver.getWSDLWrapper(); // get metadata From kawas at pub.open-bio.org Tue Jul 19 11:54:02 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 12:41:29 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191554.j6JFs2Xd020974@pub.open-bio.org> kawas Tue Jul 19 11:54:02 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder In directory pub.open-bio.org:/tmp/cvs-serv20945/org/biomoby/client/rdf/builder Modified Files: ServiceInstanceRDF.java RDFConfigure.java Log Message: changed the way certain properties are accessed. Also updated the registry domain. ofType predicate added to datatypes as well. moby-live/Java/src/main/org/biomoby/client/rdf/builder ServiceInstanceRDF.java,1.4,1.5 RDFConfigure.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/06/09 17:35:59 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/07/19 15:54:02 1.5 @@ -15,13 +15,13 @@ import org.biomoby.registry.properties.MobyProperties; import org.biomoby.shared.Central; import org.biomoby.shared.MobyData; -import org.biomoby.shared.data.MobyDataSecondaryInstance; import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyNamespace; import org.biomoby.shared.MobyPrimaryDataSet; import org.biomoby.shared.MobyPrimaryDataSimple; import org.biomoby.shared.MobySecondaryData; import org.biomoby.shared.MobyService; +import org.biomoby.shared.data.MobyDataSecondaryInstance; import com.hp.hpl.jena.rdf.model.Bag; import com.hp.hpl.jena.rdf.model.Model; @@ -296,8 +296,8 @@ .getURL())); subject.addProperty(DC.identifier, model .createTypedLiteral("urn:lsid:" - + properties.getProperty("lsid_domain") - + ":serviceinstance:" + services[i].getAuthority() + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_authority") +":" + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_namespace") +":"+ services[i].getAuthority() + "," + services[i].getName())); subject.addProperty(Predicates.performs_task, model .createResource(SRV + services[i].getType())); @@ -488,7 +488,7 @@ return stream.getOutput(); } - + /* * convenience method that adds a resource to a model */ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/05/31 18:11:07 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/07/19 15:54:02 1.3 @@ -132,6 +132,14 @@ str = str.substring(0, str.indexOf("~")); newResource.addProperty(RDFS.label, rdf.createLiteral(str, "en")); } + // TODO - add the ofType property if it exists + if (sourceResource.hasProperty(Predicates.ofType)) { + String str = sourceResource.getProperty(Predicates.ofType).getObject() + .toString(); + if (str.indexOf("~") != -1) + str = str.substring(0, str.indexOf("~")); + newResource.addProperty(Predicates.ofType, str); + } if (sourceResource.hasProperty(RDFS.subClassOf)) { String parent = sourceResource.getProperty(RDFS.subClassOf) .getObject().asNode().getURI(); @@ -447,6 +455,11 @@ return false; } + public static void main(String[] args) throws IOException { + RDFConfigure rdfc = new RDFConfigure("http://biomoby.org/RESOURCES/MOBY-S/Objects#"); + System.out.println(new String(rdfc.retrieveObjectRDF("http://biomoby.org/RESOURCES/MOBY-S/Objects#MSF_DIRECT_DNA"))); + + } class FilteredStream extends FilterOutputStream { StringBuffer sb = null; From kawas at pub.open-bio.org Tue Jul 19 11:56:20 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 12:43:46 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191556.j6JFuKEI021054@pub.open-bio.org> kawas Tue Jul 19 11:56:20 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types In directory pub.open-bio.org:/tmp/cvs-serv21021/org/biomoby/registry/definitions/types Modified Files: JNamespaces.java JObjects.java JServices.java Log Message: changed the mobycentral registry to become the new one. Eddie moby-live/Java/src/main/org/biomoby/registry/definitions/types JNamespaces.java,1.3,1.4 JObjects.java,1.4,1.5 JServices.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespaces.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespaces.java 2005/04/20 21:42:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespaces.java 2005/07/19 15:56:20 1.4 @@ -45,7 +45,7 @@ String username = (String) map.get("username");//"moby_external"; String password = (String) map.get("password");//""; - /* String serverName = "mobycentral.cbr.nrc.ca:3306"; + /* String serverName = "mobycentral.icapture.ubc.ca:3306"; String mydatabase = "mobynamespace"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "moby_external"; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjects.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjects.java 2005/04/20 21:42:10 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjects.java 2005/07/19 15:56:20 1.5 @@ -48,7 +48,7 @@ String username = (String) map.get("username");//"moby_external"; String password = (String) map.get("password");//""; - /*String serverName = "mobycentral.cbr.nrc.ca:3306"; + /* String serverName = "mobycentral.icapture.ubc.ca:3306"; String mydatabase = "mobyobject"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "moby_external"; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServices.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServices.java 2005/04/20 21:42:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServices.java 2005/07/19 15:56:20 1.4 @@ -48,7 +48,7 @@ String username = (String) map.get("username");//"moby_external"; String password = (String) map.get("password");//""; - /* String serverName = "mobycentral.cbr.nrc.ca:3306"; + /* String serverName = "mobycentral.icapture.ubc.ca:3306"; String mydatabase = "mobyservice"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "moby_external"; From kawas at pub.open-bio.org Tue Jul 19 11:36:24 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 12:55:58 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191536.j6JFaOOG020642@pub.open-bio.org> kawas Tue Jul 19 11:36:24 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool In directory pub.open-bio.org:/tmp/cvs-serv20605/org/biomoby/client/ui/graphical/applets/objectCreationTool Modified Files: TreeWindow.java ObjectCreationTool.java retrieveObjectXML.cgi Registration.java Log Message: Changed code that refered to the old registry. As well, removed the ability to register datatypes with "" articlenames. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool TreeWindow.java,1.1,1.2 ObjectCreationTool.java,1.2,1.3 retrieveObjectXML.cgi,1.1,1.2 Registration.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/TreeWindow.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/TreeWindow.java 2005/04/07 16:42:26 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/TreeWindow.java 2005/07/19 15:36:24 1.2 @@ -46,7 +46,7 @@ private int type; private ObjectCreationTool tool = null; // TODO - place the file pointed to by _URL on mobycentral/cgi-bin/applets/ - private final static String _URL = "http://mobycentral.cbr.nrc.ca/cgi-bin/applets/retrieveObjectXML.cgi?name="; + private final static String _URL = "http://mobycentral.icapture.ubc.ca:8090/applets/cgi-bin/retrieveObjectXML.cgi?name="; /** * This is the default constructor */ @@ -119,16 +119,24 @@ case (2): { articleName = getSelected(); + if (articleName.equalsIgnoreCase("")) { + tool.createPopUpMsg("Please enter an article name for your object selection."); + return; + } tool.xml.addHas(selectedObject.toString(), articleName,tool.xml.getRootName()); - tool.toggleIsaButton(false); + //tool.toggleIsaButton(false); tool.closePopUpTreeWindow(); } break; case (3): { articleName = getSelected(); + if (articleName.equalsIgnoreCase("")) { + tool.createPopUpMsg("Please enter an article name for your object selection."); + return; + } tool.xml.addHasA(selectedObject.toString(), articleName,tool.xml.getRootName()); - tool.toggleIsaButton(false); + //tool.toggleIsaButton(false); tool.closePopUpTreeWindow(); } break; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/ObjectCreationTool.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/ObjectCreationTool.java 2005/06/02 15:48:01 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/ObjectCreationTool.java 2005/07/19 15:36:24 1.3 @@ -145,7 +145,7 @@ final TreeLoaderThread worker = new TreeLoaderThread() { public Object construct() { tree = new MobyTree(false, - "http://mobycentral.cbr.nrc.ca:8090/RESOURCES/MOBY-S/Objects","Objects"); + "http://mobycentral.icapture.ubc.ca:8090/RESOURCES/MOBY-S/Objects","Object"); tree.makeObjectTree("Object"); tree.setPreferredSize(new Dimension(400, 400)); tree.getTree().addMouseListener(mListener); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/retrieveObjectXML.cgi,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/retrieveObjectXML.cgi 2005/04/07 16:42:26 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/retrieveObjectXML.cgi 2005/07/19 15:36:24 1.2 @@ -4,7 +4,10 @@ use strict; use CGI qw( :cgi ); use MOBY::Client::Central; - my $Central = MOBY::Client::Central->new; + my $Central = MOBY::Client::Central->new(Registries => {mobycentral => { + URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} + }); # a simple MOBY_Central call to get service types my $DEFS; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/Registration.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/Registration.java 2005/06/02 15:48:01 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/Registration.java 2005/07/19 15:36:24 1.4 @@ -17,8 +17,8 @@ */ public class Registration extends MobyDataType{ - static final String ENDPOINT = "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; - static final String NAMESPACE = "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; + static final String ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; + static final String NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; private static boolean PROTO = false; /** From kawas at pub.open-bio.org Tue Jul 19 16:46:15 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 19 17:33:41 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192046.j6JKkFa6021853@pub.open-bio.org> kawas Tue Jul 19 16:46:15 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv21828/org/biomoby/client/rdf/vocabulary Modified Files: Predicates.java Added Files: XMLTypes.java Log Message: comitting 2 files that i forgot to update/commit ;-) Eddie moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary XMLTypes.java,NONE,1.1 Predicates.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/05/31 18:11:08 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/19 20:46:15 1.3 @@ -49,6 +49,7 @@ public static final Property SecondaryArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SecondaryArticle"); public static final Property SignatureURL = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SignatureURL"); public static final Property authoritative = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#authoritative"); + public static final Property ofType = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#ofType"); public final static String getURI() { return uri; } From senger at ebi.ac.uk Tue Jul 19 17:47:58 2005 From: senger at ebi.ac.uk (Martin Senger) Date: Tue Jul 19 17:38:36 2005 Subject: [MOBY-guts] biomoby commit In-Reply-To: <200507192046.j6JKkFa6021853@pub.open-bio.org> Message-ID: Eddie, I love you: jMoby workd again. Martin -- Martin Senger EMBL Outstation - Hinxton Senger@EBI.ac.uk European Bioinformatics Institute Phone: (+44) 1223 494636 Wellcome Trust Genome Campus (Switchboard: 494444) Hinxton Fax : (+44) 1223 494468 Cambridge CB10 1SD United Kingdom http://industry.ebi.ac.uk/~senger From mwilkinson at pub.open-bio.org Tue Jul 19 18:54:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 19 19:41:37 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192254.j6JMsAt7022213@pub.open-bio.org> mwilkinson Tue Jul 19 18:54:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22194/MOBY Modified Files: OntologyServer.pm Log Message: most calls in OntologyServer were mis-directed to the mobycentral data adaptor instead of teh mobyobject, mobyservice, mobynamespace etc adaptors. They should all direct properly now moby-live/Perl/MOBY OntologyServer.pm,1.52,1.53 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/18 22:32:20 1.52 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 22:54:10 1.53 @@ -185,7 +185,7 @@ my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that @@ -248,7 +248,7 @@ sub createObject { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); #node => $term, #desc => $desc, #authURI => $auth, @@ -310,7 +310,7 @@ sub retrieveObject { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my $term = $args{'node'}; return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node as an argument", '' ) @@ -359,7 +359,7 @@ sub deprecateObject { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return ( 0, "WRONG ONTOLOGY", '' ) unless ( $self->ontology eq 'object' ); my $term = $args{term}; @@ -418,8 +418,7 @@ # ontology => $ontology my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'relationship' ); my $term = lc( $args{term} ); @@ -469,7 +468,7 @@ #contact_email => $email my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); @@ -552,7 +551,7 @@ #contact_email => $email); my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); @@ -613,7 +612,7 @@ sub serviceExists { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; @@ -657,7 +656,7 @@ sub createServiceType { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); #node => $term, #descrioption => $desc, @@ -701,7 +700,7 @@ sub deleteServiceType { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; @@ -766,7 +765,7 @@ sub namespaceExists { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); @@ -811,7 +810,7 @@ sub createNamespace { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); #node => $term, #descrioption => $desc, #authority => $auth, @@ -855,7 +854,7 @@ sub deleteNamespace { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); my $term = $args{term}; @@ -913,7 +912,7 @@ sub retrieveAllServiceTypes { my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); my $types = $adaptor->query_service(); my %response; @@ -930,7 +929,7 @@ sub retrieveAllNamespaceTypes { my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); my $types = $adaptor->query_namespace(); my %response; @@ -947,7 +946,7 @@ sub retrieveAllObjectClasses { my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my $types = $adaptor->query_object(); my %response; @@ -966,7 +965,7 @@ sub getObjectCommonName { my ( $self, $URI ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return undef unless $URI =~ /urn\:lsid/; my $result = $adaptor->query_object({object_lsid => $URI}); my $row = shift(@$result); @@ -982,7 +981,7 @@ sub getNamespaceCommonName { my ( $self, $URI ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return undef unless $URI =~ /urn\:lsid/; my $result = $adaptor->query_namespace({namespace_lsid => $URI}); my $row = shift(@$result); @@ -998,7 +997,7 @@ sub getServiceCommonName { my ( $self, $URI ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return undef unless $URI =~ /urn\:lsid/; my $result = $adaptor->query_service({service_lsid => $URI}); my $row = shift(@$result); @@ -1014,7 +1013,7 @@ sub getServiceURI { my ( $self, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return $term if $term =~ /urn\:lsid/; my $result = $adaptor->query_service({service_type => $term}); @@ -1031,7 +1030,7 @@ sub getObjectURI { my ( $self, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return $term if $term =~ /urn\:lsid/; my $result = $adaptor->query_object({object_type => $term}); @@ -1048,7 +1047,7 @@ sub getNamespaceURI { my ( $self, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return $term if $term =~ /urn\:lsid/; @@ -1066,7 +1065,7 @@ sub getRelationshipURI { my ( $self, $ontology, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); return $term if $term =~ /urn\:lsid/; @@ -1084,7 +1083,7 @@ sub getRelationshipTypes { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); my $ontology = $args{'ontology'}; my $OS = MOBY::OntologyServer->new( ontology => "relationship" ); @@ -1150,7 +1149,8 @@ sub _doRelationshipsQuery { my ( $self, $ontology, $term, $relationship, $direction ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $datasource = "moby$ontology"; # like mobyobject, or mobyservice + my $adaptor = $CONFIG->getDataAdaptor( datasource => $datasource ); my $defs; # query returns a reference to an array containing array references $defs = $adaptor->getRelationship({direction => $direction}, {ontology => $ontology}, {term => $term}, {relationship => $relationship}); From mwilkinson at pub.open-bio.org Tue Jul 19 18:54:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 19 19:41:39 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192254.j6JMsAbi022233@pub.open-bio.org> mwilkinson Tue Jul 19 18:54:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv22194/MOBY/Client Modified Files: Central.pm Log Message: most calls in OntologyServer were mis-directed to the mobycentral data adaptor instead of teh mobyobject, mobyservice, mobynamespace etc adaptors. They should all direct properly now moby-live/Perl/MOBY/Client Central.pm,1.98,1.99 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.98 retrieving revision 1.99 diff -u -r1.98 -r1.99 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 14:33:46 1.98 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 22:54:10 1.99 @@ -1047,7 +1047,7 @@ Usage : $REG = $MOBY->deregisterService(%args) Function : deregister a registered MOBY Service Returns : MOBY::Registration object - Args : serviceID => $serviceID + Args : serviceName => $serviceID, authURI => $authority =cut From mwilkinson at pub.open-bio.org Tue Jul 19 19:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 19 20:25:28 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192337.j6JNbZrb022356@pub.open-bio.org> mwilkinson Tue Jul 19 19:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22337/MOBY Modified Files: OntologyServer.pm Log Message: still one misdirected call - now fixed. moby-live/Perl/MOBY OntologyServer.pm,1.53,1.54 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 22:54:10 1.53 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 23:37:35 1.54 @@ -468,7 +468,7 @@ #contact_email => $email my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); From mwilkinson at pub.open-bio.org Tue Jul 19 19:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 19 20:25:30 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192337.j6JNbZMt022375@pub.open-bio.org> mwilkinson Tue Jul 19 19:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22337/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: still one misdirected call - now fixed. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 22:32:20 1.15 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:37:35 1.16 @@ -519,7 +519,8 @@ sub delete_object{ my ($self, @args) = @_; my $dbh = $self->dbh; - my $statement = "delete from object "; + my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........********** + # ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ******************** my @bindvalues = (); ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, From mwilkinson at pub.open-bio.org Tue Jul 19 19:40:34 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 19 20:27:59 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192340.j6JNeY8a022460@pub.open-bio.org> mwilkinson Tue Jul 19 19:40:34 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22441/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: missed a $ in front of dbh moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:37:35 1.16 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:40:34 1.17 @@ -559,7 +559,7 @@ sub insert_object_term2term{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, undef, ( get_value('relationship_type', @args), From mwilkinson at pub.open-bio.org Tue Jul 19 19:47:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 19 20:34:50 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192347.j6JNlQYb022529@pub.open-bio.org> mwilkinson Tue Jul 19 19:47:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22510/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: missed several dozen more $. The problem with copy/paste when the original was erroneous moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:40:34 1.17 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:47:26 1.18 @@ -227,8 +227,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -277,8 +277,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -341,8 +341,8 @@ ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -404,8 +404,8 @@ ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -462,8 +462,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -526,8 +526,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -581,8 +581,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -660,8 +660,8 @@ ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -740,7 +740,7 @@ sub insert_service{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, undef, ( @@ -748,7 +748,7 @@ get_value('authority', @args), get_value('contact_email', @args) ) ); - return dbh->{mysql_insertid}; + return $dbh->{mysql_insertid}; } sub delete_service{ @@ -760,8 +760,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -790,12 +790,12 @@ sub insert_service_term2term{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, undef, ( get_value('relationship_type', @args), get_value('service1_id', @args), get_value('service2_id', @args)) ); - return dbh->{mysql_insertid}; + return $dbh->{mysql_insertid}; } sub delete_service_term2term{ @@ -807,8 +807,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -866,7 +866,7 @@ sub insert_namespace{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, undef, ( @@ -874,7 +874,7 @@ get_value('authority', @args), get_value('contact_email', @args) ) ); - return dbh->{mysql_insertid}; + return $dbh->{mysql_insertid}; } sub delete_namespace{ @@ -886,8 +886,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -924,8 +924,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; From mwilkinson at pub.open-bio.org Wed Jul 20 11:43:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 20 12:31:26 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201543.j6KFhv96024731@pub.open-bio.org> mwilkinson Wed Jul 20 11:43:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv24704/MOBY Modified Files: Central.pm authority.pm service_instance.pm Log Message: The logic for retrieving authority objects was faulty. It now creates a new db entry if the initial lookup fails moby-live/Perl/MOBY Central.pm,1.161,1.162 authority.pm,1.3,1.4 service_instance.pm,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.161 retrieving revision 1.162 diff -u -r1.161 -r1.162 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/19 14:33:46 1.161 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 15:43:57 1.162 @@ -1184,7 +1184,6 @@ if ( $ch == 0 ) { - use MOBY::Config; my $conf = MOBY::Config->new(); my $path = $conf->{mobycentral}->{rdfagent}; my $rez = system( $path. " " . $signatureURL ); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/13 21:53:12 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 15:43:57 1.4 @@ -91,19 +91,13 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); - my $authority_id = @$result[0]->{authority_id}; - my $common = @$result[0]->{authority_common_name}; - my $uri = @$result[0]->{authority_uri}; - my $contact = @$result[0]->{contact_email}; - - unless ($authority_id) { + unless (@$result[0]) { my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, {authority_uri => $self->authority_uri}, {contact_email => $self->contact_email}); - $self->authority_id( $insertid ); } else { - $self->authority_id($authority_id); + $self->authority_id(@$result[0]->{authority_id}); } return $self; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 22:46:00 1.13 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:43:57 1.14 @@ -358,13 +358,14 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); - my $row = shift(@$result); - my $id = $row->{authority_id}; - my $name = $row->{authority_common_name}; - my $uri = $row->{authority_uri}; - my $email = $row->{contact_email}; - if ( defined $id ) { + if ( @$result[0]) { + my $row = shift(@$result); + my $id = $row->{authority_id}; + my $name = $row->{authority_common_name}; + my $uri = $row->{authority_uri}; + my $email = $row->{contact_email}; + $authority = MOBY::authority->new( dbh => $self->dbh, authority_id => $id, From mwilkinson at pub.open-bio.org Wed Jul 20 11:58:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 20 12:45:42 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201558.j6KFwMDI024816@pub.open-bio.org> mwilkinson Wed Jul 20 11:58:22 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv24797/MOBY Modified Files: service_instance.pm Log Message: Parameters passed to the query_service_instance routine need to be hashified moby-live/Perl/MOBY service_instance.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:43:57 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:58:22 1.15 @@ -226,8 +226,9 @@ : $self->service_type_uri($servicetypeURI); } my $existing_service = $self->adaptor->query_service_instance( - servicename => $self->servicename, - authURI => $self->authority_uri ); + {servicename => $self->servicename}, + "and", + {authURI => $self->authority_uri}); if ( ($existing_service ) # if it exists, you are not allowed to have passed anything other than service name and authorityURI From mwilkinson at pub.open-bio.org Wed Jul 20 13:00:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 20 13:47:57 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201700.j6KH0QUj025091@pub.open-bio.org> mwilkinson Wed Jul 20 13:00:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25053/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: No, they don't have to be hashified at that pont, but the query itself is a two-step process, and the generic query builder can't do joins over multiple tables so we now do two consecutive queries moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:47:26 1.18 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 17:00:26 1.19 @@ -592,8 +592,16 @@ # selects all the columns from service_instance table # where is lsid? sub query_service_instance { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; + + my $servicename = $args{'servicename'}; + my $authURI = $args{'authority_uri'}; + + my $result = $self->query_authority({authority_uri => $authURI}); + return [{}] unless @$result[0]; + my $id = @$result[0]->{authority_id}; + return [{}] unless $id; my $statement = "select service_instance_id, @@ -608,15 +616,10 @@ signatureURL, lsid from service_instance "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) = add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my @bindvalues; + ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); + my $final = do_query($dbh, $statement, @bindvalues); + return $final; } # custom query for Moby::Central.pm->findService() From mwilkinson at pub.open-bio.org Wed Jul 20 13:00:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 20 13:48:00 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201700.j6KH0Q2Z025072@pub.open-bio.org> mwilkinson Wed Jul 20 13:00:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25053/MOBY Modified Files: service_instance.pm Log Message: No, they don't have to be hashified at that pont, but the query itself is a two-step process, and the generic query builder can't do joins over multiple tables so we now do two consecutive queries moby-live/Perl/MOBY service_instance.pm,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:58:22 1.15 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 17:00:26 1.16 @@ -226,9 +226,8 @@ : $self->service_type_uri($servicetypeURI); } my $existing_service = $self->adaptor->query_service_instance( - {servicename => $self->servicename}, - "and", - {authURI => $self->authority_uri}); + servicename => $self->servicename, + authority_uri => $self->authority_uri); if ( ($existing_service ) # if it exists, you are not allowed to have passed anything other than service name and authorityURI From dwang at pub.open-bio.org Wed Jul 20 13:12:20 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 20 13:59:43 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201712.j6KHCKIl025225@pub.open-bio.org> dwang Wed Jul 20 13:12:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25199/Perl/MOBY Modified Files: Central.pm Log Message: removed calls to first row of the result set (like @$result[0]), instead used shift to retrieve the first row of the result set moby-live/Perl/MOBY Central.pm,1.162,1.163 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.162 retrieving revision 1.163 diff -u -r1.162 -r1.163 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 15:43:57 1.162 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 17:12:20 1.163 @@ -763,7 +763,8 @@ my $dbh = MOBY::central_db_connection->new()->dbh; my $result = $adaptor->query_service_instance({service_type_uri => $existingURI}); - my $id = @$result[0]->{service_instance_id}; + my $row = shift(@$result); + my $id = $row->{service_instance_id}; return &_error( "A registered service depends on this service type", "" ) if ($id); @@ -1938,7 +1939,8 @@ && _LOG("authURI added; criterion count is now $criterion_count\n"); my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}}); - my $id = @$result[0]->{authority_id}; + my $row = shift(@$result); + my $id = $row->{authority_id}; unless ($id) { return &_serviceListResponse( $dbh, undef ); @@ -3368,16 +3370,17 @@ foreach (@ids) { my $result = $adaptor->query_service_instance({service_instance_id => $_}); - my $category = @$result[0]->{category}; - my $url = @$result[0]->{url}; - my $servicename = @$result[0]->{servicename}; - my $service_type_uri = @$result[0]->{service_type_uri}; - my $authority_id = @$result[0]->{authority_id}; - my $desc = @$result[0]->{description}; - my $authoritative = @$result[0]->{authoritative}; - my $email = @$result[0]->{contact_email}; - my $signatureURL = @$result[0]->{signatureURL}; - my $lsid = @$result[0]->{lsid}; + my $row = shift(@$result); + my $category = $row->{category}; + my $url = $row->{url}; + my $servicename = $row->{servicename}; + my $service_type_uri = $row->{service_type_uri}; + my $authority_id = $row->{authority_id}; + my $desc = $row->{description}; + my $authoritative = $row->{authoritative}; + my $email = $row->{contact_email}; + my $signatureURL = $row->{signatureURL}; + my $lsid = $row->{lsid}; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; @@ -3389,7 +3392,8 @@ my $service_type = $OSserv->getServiceCommonName($service_type_uri); $result = $adaptor->query_authority({authority_id => $authority_id}); - my $authURI = @$result[0]->{authority_uri}; + my $row = shift(@$result); + my $authURI = $row->{authority_uri}; $output .= "\t\n"; $output .= "\t$service_type\n"; From dwang at pub.open-bio.org Wed Jul 20 13:25:54 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 20 14:13:54 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201725.j6KHPs6o025292@pub.open-bio.org> dwang Wed Jul 20 13:25:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25266/Perl/MOBY Modified Files: authority.pm Log Message: removed explicit call to first row of result set, instead use shift to retrieve first row moby-live/Perl/MOBY authority.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 15:43:57 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 17:25:54 1.5 @@ -91,13 +91,14 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); - unless (@$result[0]) { + my $row = shift(@$result); + unless ($row) { my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, {authority_uri => $self->authority_uri}, {contact_email => $self->contact_email}); $self->authority_id( $insertid ); } else { - $self->authority_id(@$result[0]->{authority_id}); + $self->authority_id($row->{authority_id}); } return $self; } From kawas at pub.open-bio.org Wed Jul 20 13:42:31 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Wed Jul 20 14:30:02 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201742.j6KHgV3J025434@pub.open-bio.org> kawas Wed Jul 20 13:42:31 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv25405/org/biomoby/client/rdf/vocabulary Modified Files: Predicates.java MobyResources.java Log Message: Updated the predicates. Moved predicates from MobyResources to Predicates and deprecated MobyResources.java moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary Predicates.java,1.3,1.4 MobyResources.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/19 20:46:15 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/20 17:42:31 1.4 @@ -50,6 +50,11 @@ public static final Property SignatureURL = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SignatureURL"); public static final Property authoritative = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#authoritative"); public static final Property ofType = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#ofType"); + /* moved from MobyResources.java */ + public static final Property Simple = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Simple"); + public static final Property Secondary = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Secondary"); + public static final Property Collection = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Collection"); + public final static String getURI() { return uri; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/MobyResources.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/MobyResources.java 2005/05/31 18:11:08 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/MobyResources.java 2005/07/20 17:42:31 1.3 @@ -13,9 +13,12 @@ */ /** + * @deprecated Replaced by {@link + * Predicates}. The reason is that this class was + * redundant and ill conceived. From now on the + * BioMoby predicates, under the namespace moby, + * are located in Predicates.java. * @author Eddie Kawas - *

Created for - *

This class was created to ... *

For questions, comments, or bugs *

email me at edward.kawas@gmail.com */ @@ -24,9 +27,29 @@ private static final String uri = "http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#"; private static Model _model = ModelFactory.createDefaultModel(); + /** + * @deprecated Replaced by {@link + * Predicates#Simple}. The reason is that this property + * should not be under a different RDF document URI + */ public static final Property SimpleArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Simple"); + /** + * @deprecated Replaced by {@link + * Predicates#articleName}. The reason is that this property + * is never utilized and is redundant. + */ public static final Property CollectionArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#articleName"); + /** + * @deprecated Replaced by {@link + * Predicates#Secondary}. The reason is that this property + * should not be under a different RDF document URI + */ public static final Property SecondaryArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Secondary"); + /** + * @deprecated Replaced by {@link + * Predicates#Collection}. The reason is that this property + * should not be under a different RDF document URI + */ public static final Property Collection = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Collection"); public final static String getURI() { return uri; From kawas at pub.open-bio.org Wed Jul 20 16:33:22 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Wed Jul 20 17:20:52 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202033.j6KKXMhq025785@pub.open-bio.org> kawas Wed Jul 20 16:33:22 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources In directory pub.open-bio.org:/tmp/cvs-serv25760/org/biomoby/client/ui/graphical/servlet/jresources Modified Files: RESOURCE.java Log Message: Added the generation of the moby predicate vocabulary. If you run main, you can view the RDF document describing predicates. This implementation is only temporary. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources RESOURCE.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/07/19 15:32:54 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/07/20 20:33:22 1.8 @@ -17,7 +17,6 @@ import javax.servlet.http.HttpServletResponse; import org.biomoby.client.CentralDigestImpl; -import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; import org.biomoby.client.rdf.vocabulary.XMLTypes; import org.biomoby.registry.definitions.types.JNamespaces; @@ -52,13 +51,18 @@ */ /** - * @author Eddie Kawas

Created for

This class was created to ...

For - * questions, comments, or bugs

email me at edward.kawas@gmail.com + * + * @author Eddie Kawas + *

This class was created to replace the old perl RESOURCES script. Using this + * class provides access to the RDF documents describing the object, service type, + * services, namespace and predicate ontologies. + *

if you have any questions, please email me at ed.kawas@gmail.com + * */ public class RESOURCE extends HttpServlet { /** - * + * */ private static final long serialVersionUID = 1L; @@ -141,21 +145,23 @@ private static Properties properties = MobyProperties.PROPERTIES();; private static final String OBJ = "http://" - + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Objects#"; + + properties.getProperty("resources_script_domain") + + "/RESOURCES/MOBY-S/Objects#"; private static final String SRV = "http://" - + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Services#"; + + properties.getProperty("resources_script_domain") + + "/RESOURCES/MOBY-S/Services#"; private static final String NS = "http://" - + properties.getProperty("resources_script_domain") + + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Namespaces#"; private static final String MP = "http://" - + properties.getProperty("resources_script_domain") + + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#"; private static final String SI = "http://" - + properties.getProperty("resources_script_domain") + + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/ServiceInstances#"; private static boolean RUN_MAIN = false; @@ -166,7 +172,7 @@ * @see javax.servlet.GenericServlet#init() */ public final void init() throws ServletException { - // super.init(); + // super.init(); } protected final void doGet(HttpServletRequest request, @@ -272,6 +278,17 @@ writer.setProperty("showXmlDeclaration", "true"); writer.write(model, out, null); return; + } else if (ontology.equals("Predicates")) { + //TODO - create the predicates RDF/XML document describing + // the Predicates. + + response.setContentType("application/rdf+xml"); + response.setHeader("Content-Disposition", + "attachment;filename=Namespaces"); + RDFWriter writer = model.getWriter("RDF/XML-ABBREV"); + writer.setProperty("showXmlDeclaration", "true"); + writer.write(model, out, null); + return; } else if (ontology.equals("FULL")) { try { model = getAll(model); @@ -303,7 +320,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -313,6 +333,7 @@ model = getObjects(model); model = getServices(model); model = getNamespaces(model); + //TODO - add the predicates to the model. try { model = getServiceInstances(model); } catch (ModelException e) { @@ -323,7 +344,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -367,9 +391,13 @@ .getURL())); subject.addProperty(DC.identifier, model .createTypedLiteral("urn:lsid:" - + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_authority") + ":" - + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_namespace") + ":" +services[i].getAuthority() - + "," + services[i].getName())); + + MobyProperties.SERVICE_INSTANCE_PROPERTIES() + .getProperty("lsid_authority") + + ":" + + MobyProperties.SERVICE_INSTANCE_PROPERTIES() + .getProperty("lsid_namespace") + ":" + + services[i].getAuthority() + "," + + services[i].getName())); subject.addProperty(Predicates.performs_task, model .createResource(SRV + services[i].getType())); subject.addProperty(Predicates.SignatureURL, model @@ -408,7 +436,7 @@ } innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) primaryInputs[j]) .getName().equals("")) innerBag @@ -461,8 +489,7 @@ .getDefaultValue())); _li.addProperty(Predicates.datatype, model .createTypedLiteral(data.getDataType())); - _li.addProperty(RDF.type, - MobyResources.SecondaryArticle); + _li.addProperty(RDF.type, Predicates.Secondary); if (data.getDataType().equals("Integer")) { _li .addProperty(Predicates.min, model @@ -514,7 +541,7 @@ produceBag = model.createBag(); innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) outputs[j]) .getName().equals("")) innerBag @@ -559,7 +586,7 @@ private final Resource createSimpleDataItem(Model model, MobyPrimaryDataSimple simpleData, Resource _li) { - _li.addProperty(RDF.type, MobyResources.SimpleArticle); + _li.addProperty(RDF.type, Predicates.Simple); _li.addProperty(Predicates.object_type, model.createResource(OBJ + simpleData.getDataType().getName())); if (!simpleData.getName().equals("")) @@ -578,7 +605,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -615,7 +645,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -646,7 +679,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @throws MobyException @@ -664,8 +700,10 @@ // create the base object type "class" Resource subject = _addClassResource(model, OBJ, "Object", "a base object class consisting of a namespace and an identifier"); - model.add(model.createStatement(subject, DC.publisher, model.createLiteral("www.illuminae.com", "en"))); - model.add(model.createStatement(subject, DC.creator, model.createLiteral("markw@illuminae.com", "en"))); + model.add(model.createStatement(subject, DC.publisher, model + .createLiteral("www.illuminae.com", "en"))); + model.add(model.createStatement(subject, DC.creator, model + .createLiteral("markw@illuminae.com", "en"))); model.add(model.createStatement(subject, RDF.type, RDFS.Class)); for (int x = 0; x < objects.length; x++) { String[] _line = objects[x].split("\t"); @@ -684,7 +722,7 @@ obj = obj.substring(0, obj.indexOf("(")); Resource _subject = _addClassResource(model, OBJ, sub, def); - + m = Pattern.compile(".*:isa$", Pattern.CASE_INSENSITIVE).matcher( pred); if (m.matches()) { @@ -720,12 +758,14 @@ map.put("serviceInstances", SI); map.put("mobyNamespace", NS); map.put("mobyService", SRV); - map.put("moby", MobyResources.getURI()); model.setNsPrefixes(map); } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @param _resource @@ -749,7 +789,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @param mp2 @@ -763,7 +806,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @param subject @@ -784,7 +830,8 @@ Pattern p = Pattern.compile("urn:lsid.*:(\\S+)$"); Matcher m = p.matcher(thing); String label = (m.matches() ? m.group(1) : thing); - //TODO - add the ofType property if thing is String, Float, Integer, DataTime. + //TODO - add the ofType property if thing is String, Float, Integer, + // DataTime. Resource resource = model.createResource(ns + thing); addOfTypeProperty(model, resource, thing); model.add(model.createStatement(resource, RDF.type, RDFS.Class)); @@ -796,29 +843,33 @@ } /** - * @param model - * @param resource - * @param thing - */ - private void addOfTypeProperty(Model model, Resource resource, String name) { - // make sure that we declare the ns for the datatype - Map map = model.getNsPrefixMap(); - if (!map.containsValue(XMLTypes.getURI())) { - map.put(XMLTypes.getPrefix(), XMLTypes.getURI()); - } - model.setNsPrefixes(map); - if (name.equalsIgnoreCase("string")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_STRING)); - } else if (name.equalsIgnoreCase("integer")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_INTEGER)); - } else if (name.equalsIgnoreCase("float")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_FLOAT)); - } else if (name.equalsIgnoreCase("datatime")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_DATE_TIME)); - } - } + * @param model + * @param resource + * @param thing + */ + private void addOfTypeProperty(Model model, Resource resource, String name) { + // make sure that we declare the ns for the datatype + Map map = model.getNsPrefixMap(); + if (!map.containsValue(XMLTypes.getURI())) { + map.put(XMLTypes.getPrefix(), XMLTypes.getURI()); + } + model.setNsPrefixes(map); + if (name.equalsIgnoreCase("string")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_STRING)); + } else if (name.equalsIgnoreCase("integer")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_INTEGER)); + } else if (name.equalsIgnoreCase("float")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_FLOAT)); + } else if (name.equalsIgnoreCase("datatime")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_DATE_TIME)); + } + } - private final String getTypes(String type) throws MobyException { + private final String getTypes(String type) throws MobyException { if (type.equalsIgnoreCase("objects")) { try { return new JObjects().getObjects(); @@ -848,7 +899,7 @@ } /* - * + * */ private String getURL(String url) { StringBuffer sb = new StringBuffer(); @@ -858,7 +909,7 @@ .openStream())); String inputLine; while ((inputLine = in.readLine()) != null) - sb.append(inputLine+"\n"); + sb.append(inputLine + "\n"); in.close(); } catch (Exception e) { e.printStackTrace(); @@ -930,6 +981,12 @@ return out.getBuffer().toString(); } + /** + * + * @param str + * @return an RDF document describing the ontology represented by str. + * @throws MobyException + */ public final String getRESOURCES(String str) throws MobyException { String name = ""; if (str.lastIndexOf("/") > 0) { @@ -946,12 +1003,235 @@ return getServiceInstances(); } else if (name.equalsIgnoreCase("Namespaces")) { return getNamespaces(); + } else if (name.equalsIgnoreCase("Predicates")) { + return getPredicates(); } + return ""; } + private String getPredicates() { + StringBuffer buffer = new StringBuffer(); + buffer.append( + "\r\n"); + // add the predicates here + buffer.append(createOntologyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "The BioMoby Predicates Vocabulary (mobyPred)", + "This is the RDF Schema for the BioMoby Predicate vocabulary defined in the mobyPred namespace.")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#hasa", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "hasa","The subject contains exactly one object.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#has", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "has","The subject contains one or more object.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#articleName", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "articleName","The subject is known to be named object while in a relationship.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#namespace_type", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "namespace_type","The subject resource is applicable under the object namespace.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Resource")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#object_type", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "object_type","The subject resource is a resource object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Resource")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#consumes", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "consumes","The subject container takes as input object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#produces", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "produces","The subject container produces as output object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#performs_task", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "performs_task","The subject performs the task of the object resource.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Resource")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#default_value", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "default_value","The subject has a default value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#min", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "min","The subject has a minimum value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#max", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "max","The subject has a maximum value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#enum", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "enum","The subject may assume the value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#datatype", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "datatype","Idiomatic property used for structured values.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#signatureURL", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "signatureURL","Object is a URL that contains information on the subject.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#authoritative", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "authoritative","The object states whether the subject is authoritative.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#ofType", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "ofType","The subject is of primitive type object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#sampleInputData", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "sampleInputData","Object is a sample of valid input that subject can handle.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#sampleOutputData", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "sampleOutputData","Object is a sample of valid output created by running the subject.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#approvedBy", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "approvedBy","The subject has been approved by object.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Simple", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "Simple","A class representing a simple input or output.", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Secondary", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "Secondary","A class representing a secondary input.", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Collection", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "Collection","A container for objects representing Simples.", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + buffer.append(createEscapedComment("Not sure about the next 3 classes. I dont think that they are actually used anywhere. They represent the articleName of simples, collections and secondaries.")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#SimpleArticle", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "SimpleArticle","NOT SURE", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#CollectionArticle", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "CollectionArticle","NOT SURE", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#SecondaryArticle", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "SecondaryArticle","NOT SURE", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + + // end the addition of predicates here + buffer.append( + "\r\n" + + ""); + return buffer.toString(); + } + + private String createPropertyBlock(String about, String definedBy, + String label, String comment, String domain, String range) { + String s = + "\r\n\r\n" + + " \r\n" + + " " + label + "\r\n" + + " " + comment + "\r\n" + + " \r\n" + + " \r\n" + + "\r\n"; + return s; + } + + private String createClassBlock(String about, String definedBy, + String label, String comment, String subClassOf) { + String s = + "\r\n\r\n" + + " \r\n" + + " "+ label +"\r\n" + + " "+ comment +"\r\n" + + " \r\n" + + "\r\n"; + return s; + } + + private String createDescriptionBlock(String about, String[] seeAlsos) { + if (seeAlsos == null) + return "\r\n"; + StringBuffer sb = new StringBuffer(); + sb.append(" \r\n"); + for (int x = 0; x < seeAlsos.length; x++) { + sb.append(" \r\n"); + } + sb.append("\r\n"); + return sb.toString(); + } + + private String createOntologyBlock(String about, String title, + String description) { + String s ="\r\n\r\n" + " " + title + "\r\n" + + " " + description + "\r\n" + + "\r\n"; + return s; + } + + private String createEscapedComment(String comment) { + String s = "\r\n\r\n"; + return s; + } + public static void main(String[] args) throws MobyException { - System.out.println(new RESOURCE().getRESOURCES("Objects")); + System.out.println(new RESOURCE().getRESOURCES("Predicates")); } -} +} \ No newline at end of file From mwilkinson at pub.open-bio.org Wed Jul 20 17:23:54 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 20 18:11:22 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202123.j6KLNsgX025941@pub.open-bio.org> mwilkinson Wed Jul 20 17:23:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25922/MOBY Modified Files: service_instance.pm Log Message: query_service_instance does not return boolean, so the test has to be more explicit moby-live/Perl/MOBY service_instance.pm,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 17:00:26 1.16 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:23:54 1.17 @@ -225,12 +225,12 @@ ? $self->service_type_uri( $self->service_type ) : $self->service_type_uri($servicetypeURI); } - my $existing_service = $self->adaptor->query_service_instance( + my $existing_services = $self->adaptor->query_service_instance( servicename => $self->servicename, authority_uri => $self->authority_uri); + my $existing_service = shift(@$existing_services); if ( - ($existing_service - ) # if it exists, you are not allowed to have passed anything other than service name and authorityURI + ($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI && ( ( defined $self->category ) || ( defined $self->service_type ) || ( defined $self->url ) From mwilkinson at pub.open-bio.org Wed Jul 20 17:29:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 20 18:17:14 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202129.j6KLTc7b026019@pub.open-bio.org> mwilkinson Wed Jul 20 17:29:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26000/MOBY Modified Files: service_instance.pm Log Message: query_service_instance does not return boolean, so the test has to be more explicit moby-live/Perl/MOBY service_instance.pm,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:23:54 1.17 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:29:38 1.18 @@ -229,19 +229,15 @@ servicename => $self->servicename, authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); - if ( - ($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI + if (($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI && ( ( defined $self->category ) || ( defined $self->service_type ) || ( defined $self->url ) || ( defined $self->contact_email ) || ( defined $self->description ) ) - ) - { - return - -1; # no no no, not alowed to do that! I will not give you an object - } elsif ($existing_service) - { # if service exists, then instantiate it from the database retrieval we just did + ){ + return -1; # no no no, not alowed to do that! I will not give you an object + } elsif ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); $self->category( $existing_service->{'category'} ); $self->service_type( $existing_service->{'servicetype'} ); @@ -250,26 +246,22 @@ $self->description( $existing_service->{'desc'} ); $self->authority( $existing_service->{'authURI'} ); $self->signatureURL( $existing_service->{'signatureURL'} ); - $self->lsid( $existing_service->{'lsid'} ); + $self->lsid( $existing_service->{'lsid'} ); $self->{__exists__} = 1; # this service already existed - } elsif ( - !($existing_service) # if it doesn't exist - && ( - defined $self->category - ) # and you have given me things I need to create it + } elsif (!($existing_service->{servicename}) # if it doesn't exist + && (defined $self->category) # and you have given me things I need to create it && ( defined $self->service_type ) && ( defined $self->url ) && ( defined $self->contact_email ) && ( defined $self->description ) - ) - { # then create it de novo if we have enough information + ) { # then create it de novo if we have enough information #create LSID for service and register it in the DB - my $_config ||= MOBY::Config->new; - my $service_lsid = "urn:lsid:" - . $_config->{mobycentral}->{lsid_authority} . ":" - . $_config->{mobycentral}->{lsid_namespace} . ":" - . $self->authority_uri . "," - . $self->servicename; + my $_config ||= MOBY::Config->new; + my $service_lsid = "urn:lsid:" + . $_config->{mobycentral}->{lsid_authority} . ":" + . $_config->{mobycentral}->{lsid_namespace} . ":" + . $self->authority_uri . "," + . $self->servicename; my $id = $self->adaptor->insert_service_instance( {category => $self->category}, From mwilkinson at pub.open-bio.org Wed Jul 20 18:04:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 20 18:51:28 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202204.j6KM4AGI026133@pub.open-bio.org> mwilkinson Wed Jul 20 18:04:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26114/MOBY Modified Files: secondary_input.pm Log Message: secondary inputs not writing to databse because id returned was null. moby-live/Perl/MOBY secondary_input.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 22:46:00 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/20 22:04:10 1.5 @@ -122,8 +122,7 @@ {article_name => $self->article_name}, {service_instance_id => $self->service_instance_id}); - my $id = $dbh->{$insertid}; - return $id; + return $insertid; } sub AUTOLOAD { From mwilkinson at pub.open-bio.org Wed Jul 20 18:49:05 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 20 19:36:33 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202249.j6KMn5f5026327@pub.open-bio.org> mwilkinson Wed Jul 20 18:49:05 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26308/MOBY Modified Files: service_instance.pm Log Message: test for the pre-existing service seems to fail. Try this code instead moby-live/Perl/MOBY service_instance.pm,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:29:38 1.18 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 22:49:05 1.19 @@ -199,14 +199,11 @@ return undef unless $self->authority_uri; return undef unless $self->servicename; - #$self->_dbh(); - #return undef unless $self->dbh; - #my $dbh = $self->dbh; if ( $self->test ) { return $self->service_instance_exists } - $self->authority( $self->_get_authority() ) - ; # this might not be necessary - it simply converts auth_uri to auth_id and v.v.? - # it actually is necessary for the moment. We need to put the logic of determining - # service id into the mysql.pm module!! + if ($self->service_instance_exists){return -1} + + $self->authority( $self->_get_authority() ); + if ( $self->service_type ) { my $OE = MOBY::OntologyServer->new( ontology => 'service' ); my ( $success, $message, $servicetypeURI ) = @@ -229,15 +226,7 @@ servicename => $self->servicename, authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); - if (($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI - && ( ( defined $self->category ) - || ( defined $self->service_type ) - || ( defined $self->url ) - || ( defined $self->contact_email ) - || ( defined $self->description ) ) - ){ - return -1; # no no no, not alowed to do that! I will not give you an object - } elsif ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did + if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); $self->category( $existing_service->{'category'} ); $self->service_type( $existing_service->{'servicetype'} ); From mwilkinson at pub.open-bio.org Wed Jul 20 18:34:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 20 19:55:45 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202234.j6KMYn0j026242@pub.open-bio.org> mwilkinson Wed Jul 20 18:34:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv26223/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: can query authority by either URI or database id moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 17:00:26 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 22:34:48 1.20 @@ -597,12 +597,13 @@ my $servicename = $args{'servicename'}; my $authURI = $args{'authority_uri'}; - - my $result = $self->query_authority({authority_uri => $authURI}); - return [{}] unless @$result[0]; - my $id = @$result[0]->{authority_id}; - return [{}] unless $id; - + my $id = $args{'authority_id'}; + unless ($id){ + my $result = $self->query_authority({authority_uri => $authURI}); + return [{}] unless @$result[0]; + my $id = @$result[0]->{authority_id}; + return [{}] unless $id; + } my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Thu Jul 21 12:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 21 13:31:45 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211637.j6LGbZYt029162@pub.open-bio.org> mwilkinson Thu Jul 21 12:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29120/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: updating the service discovery code to be in-line with the new adaptor API moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 22:34:48 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/21 16:37:35 1.21 @@ -589,9 +589,7 @@ } } -# selects all the columns from service_instance table -# where is lsid? -sub query_service_instance { +sub query_service_existence { my ($self, %args) = @_; my $dbh = $self->dbh; @@ -600,9 +598,9 @@ my $id = $args{'authority_id'}; unless ($id){ my $result = $self->query_authority({authority_uri => $authURI}); - return [{}] unless @$result[0]; + return 0 unless @$result[0]; my $id = @$result[0]->{authority_id}; - return [{}] unless $id; + return 0 unless $id; } my $statement = "select service_instance_id, @@ -620,6 +618,32 @@ my @bindvalues; ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); my $final = do_query($dbh, $statement, @bindvalues); + if (@$final[0]){return 1} else {return 0} + +} +# selects all the columns from service_instance table +# where is lsid? + +sub query_service_instance { + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority_id, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance "; + my @bindvalues; + ($statement, @bindvalues) = add_condition($statement, @args); + my $final = do_query($dbh, $statement, @bindvalues); return $final; } @@ -628,7 +652,7 @@ my ($self, @args) = @_; my $dbh = $self->dbh; my $uri_list = get_value('service_type_uri', @args); - my $statement = "select service_instance_id from service_instance where service_type_uri in ($uri_list)"; + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; my @bindvalues = (); my $result = do_query($dbh, $statement, @bindvalues); @@ -1055,10 +1079,10 @@ $kw = $dbh->quote("%$kw%"); $searchstring .= " OR description like $kw "; } - $searchstring =~ s/OR//; # just the first one + $searchstring =~ s/OR//; # remove just the first OR in the longer statement # $debug && &_LOG("search $searchstring\n"); - my $statement = "select service_instance_id from service_instance where $searchstring"; + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; my @bindvalues = (); my $ids = do_query($dbh, $statement, @bindvalues); @@ -1087,7 +1111,7 @@ } my $result = do_query($dbh, $query, ()); - return ($query, $result); + return $result; } # custom query subroutine for Moby::Central.pm->_searchForCollection() @@ -1119,7 +1143,7 @@ } my $result = do_query($dbh, $query, ()); - return ($query, $result); + return $result; } # custom query subroutine for Moby::Central.pm->RetrieveServiceNames From mwilkinson at pub.open-bio.org Thu Jul 21 12:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 21 13:31:59 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211637.j6LGbZrO029143@pub.open-bio.org> mwilkinson Thu Jul 21 12:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29120/MOBY Modified Files: Central.pm service_instance.pm Log Message: updating the service discovery code to be in-line with the new adaptor API moby-live/Perl/MOBY Central.pm,1.163,1.164 service_instance.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.163 retrieving revision 1.164 diff -u -r1.163 -r1.164 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 17:12:20 1.163 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 16:37:35 1.164 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::Client::Central; +#use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -762,7 +762,7 @@ unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my $result = $adaptor->query_service_instance({service_type_uri => $existingURI}); + my $result = $adaptor->query_service({service_type_uri => $existingURI}); my $row = shift(@$result); my $id = $row->{service_instance_id}; @@ -1888,7 +1888,13 @@ $debug && _LOG( "authoritative added; criterion count is now $criterion_count\n"); - my $ids = $adaptor->query_service_instance({authoritative => $findme{authoritative}}); + my $ids = _extract_ids($adaptor->query_service_instance({authoritative => $findme{authoritative}})); + + + + ### MARK - we need to extract ids at each step... + + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1923,7 +1929,7 @@ $children_string .= ( join ',', map { "\'$_\'" } @children ); } $children_string =~ s/\,$//; - my $ids = $adaptor->match_service_type_uri({service_type_uri => $children_string}); + my $ids = _extract_ids($adaptor->match_service_type_uri({service_type_uri => $children_string})); $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); @@ -1946,7 +1952,7 @@ return &_serviceListResponse( $dbh, undef ); } - my $ids = $adaptor->query_service_instance({authority_id => $id}); + my $ids = _extract_ids($adaptor->query_service_instance({authority_id => $id})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1965,7 +1971,7 @@ && _LOG( "servicename added; criterion count is now $criterion_count\n"); - my $ids = $adaptor->query_service_instance({servicename => $findme{servicename}}); + my $ids = _extract_ids($adaptor->query_service_instance({servicename => $findme{servicename}})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1984,7 +1990,7 @@ $debug && _LOG("category added; criterion count is now $criterion_count\n"); - my $ids = $adaptor->query_service_instance({category => lc( $findme{category}) }); + my $ids = _extract_ids($adaptor->query_service_instance({category => lc( $findme{category}) })); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -2003,6 +2009,7 @@ && _LOG("Keywords added; criterion count is now $criterion_count\n"); my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + $ids = _extract_ids($ids); # this is the hash-list that comes back from do_query unless ( scalar @{$ids} ) { $debug @@ -2146,6 +2153,20 @@ return &_serviceListResponse( $dbh, @final ); } +sub _extract_ids { + my ($linehash) = @_; + # ths data comes from the do_query of the mysql call + # --> [{...}] + my @lines = @$linehash; + return [] unless scalar(@lines); + my @ids; + foreach (@lines){ + my $id = $_->{service_instance_id}; + push @ids, $id; + } + return \@ids +} + #Eddie - converted sub _searchForServicesWithArticle { my ( $dbh, $inout, $node, $expand, $coll ) = @_; @@ -2190,9 +2211,8 @@ } $ancestor_string =~ s/\,$//; - my ($query, $result) = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); - $debug && _LOG("\nQUERY $query\n"); my @valid_services; foreach my $row (@$result) @@ -2242,10 +2262,8 @@ my ( $objectURI, $namespaceURIs ) = &_extractObjectTypesAndNamespaces($simple); - my ($query, $result) = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); - $debug && &_LOG("QUERY: $query"); - foreach my $row (@$result ) { # get the service instance ID and the namespaces that matched my $id = $row->{service_instance_id}; @@ -3392,7 +3410,7 @@ my $service_type = $OSserv->getServiceCommonName($service_type_uri); $result = $adaptor->query_authority({authority_id => $authority_id}); - my $row = shift(@$result); + $row = shift(@$result); my $authURI = $row->{authority_uri}; $output .= "\t\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 22:49:05 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 16:37:35 1.20 @@ -186,16 +186,6 @@ $self->{$attrname} = $self->_default_for($attrname); } } - - # category => $Category, - # servicename => $serviceName, - # service_type => $serviceType, - # authority_uri => $AuthURI, - # url => $URL, - # contact_email => $contactEmail, - # authoritative => $authoritativeService, - # description => $desc, - # return undef unless $self->authority_uri; return undef unless $self->servicename; @@ -222,9 +212,8 @@ ? $self->service_type_uri( $self->service_type ) : $self->service_type_uri($servicetypeURI); } - my $existing_services = $self->adaptor->query_service_instance( - servicename => $self->servicename, - authority_uri => $self->authority_uri); + my $existing_services = $self->adaptor->query_service_instance({servicename => $self->servicename},"and", + {authority_uri => $self->authority_uri}); my $existing_service = shift(@$existing_services); if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); @@ -316,15 +305,9 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; my $authority; - - my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + + my $result = $adaptor->query_service_existence(authority_uri => $self->authority_uri, servicename => $self->servicename); my $row = shift(@$result); - my $id = $row->{authority_id}; - - return undef unless $id; - - $result = $adaptor->query_service_instance({authority_id => $id}, 'and', {servicename => $self->servicename}); - $row = shift(@$result); my $svc = $row->{service_instance_id}; return $svc; From mwilkinson at pub.open-bio.org Thu Jul 21 13:08:43 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 21 13:55:58 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211708.j6LH8hK2029352@pub.open-bio.org> mwilkinson Thu Jul 21 13:08:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29333/MOBY Modified Files: Central.pm Log Message: mistakenly commented out that line moby-live/Perl/MOBY Central.pm,1.164,1.165 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.164 retrieving revision 1.165 diff -u -r1.164 -r1.165 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 16:37:35 1.164 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 17:08:43 1.165 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -#use MOBY::Client::Central; +use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; From mwilkinson at pub.open-bio.org Thu Jul 21 13:43:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 21 14:32:31 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211743.j6LHhOxD029513@pub.open-bio.org> mwilkinson Thu Jul 21 13:43:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29494/MOBY Modified Files: service_instance.pm Log Message: service_instance_exists needs to return boolean moby-live/Perl/MOBY service_instance.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 16:37:35 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 17:43:24 1.21 @@ -307,10 +307,7 @@ my $authority; my $result = $adaptor->query_service_existence(authority_uri => $self->authority_uri, servicename => $self->servicename); - my $row = shift(@$result); - my $svc = $row->{service_instance_id}; - - return $svc; + return $result } sub _get_authority From gordonp at pub.open-bio.org Fri Jul 22 01:00:58 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri Jul 22 01:48:21 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220500.j6M50wgR030700@pub.open-bio.org> gordonp Fri Jul 22 01:00:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv30675 Modified Files: SimpleClient.html Log Message: Finally got around to creating the jMOBY data instance documentation moby-live/Java/docs SimpleClient.html,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/SimpleClient.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/docs/SimpleClient.html 2005/05/19 10:56:06 1.2 +++ /home/repository/moby/moby-live/Java/docs/SimpleClient.html 2005/07/22 05:00:58 1.3 @@ -1,24 +1,263 @@ - -Simple Client - - - - - - -

-

Simple Client

-
- -
-Coming soon... (or later) -
- -
-
-
Paul Gordon
+ + + + + + jMOBY Client/Server Quickstart + + + +

jMOBY Client/Server Quickstart

+ +

Motivation

+

+ This document is intended to get you up and running using the client-server service communication + code (i.e. calling or providing remote Web Services) in the Java implementation + (jMOBY) of + MOBY-S "Web Services for Molecular Biology". If you are looking + for more detailed information on how to query MOBY Central's yellow pages about what services are + available, please see this + document. This document assumes that you are familiar with Java and + XML. +

+ +

Syntax Notes

+

+

    +
  • jMOBY class, member and method names are display in this font face
  • +
  • System.out.println("Example code is treated like + a block quote (indented paragraph)");
  • +
  • MOBY-S XML elements and attributes are displayed in this font face
  • + +
+

+ +

Sections

+

+

+

+ + +
+ + +

Basic Anatomy of the Java API

+

+ Three main classes form the core of the API: +

    +
  1. org.biomoby.shared.data.MobyDataObject - + any valid + data object + you want to transmit will be encoded using methods in this class or its subclasses. You never + need to handcode any XML (but of course you can if you really want to).
  2. + +
  3. org.biomoby.shared.data.MobyDataObjectSet - for grouping MobyDataObjects together, + implements the Java Collection interface, + and is the equivalent of the + Collection + container + element in the current MOBY-S API.
  4. + +
  5. org.biomoby.shared.MobyRequest - this class handles all of the network communication + (SOAP + messaging) required between client and server.
  6. +
+

+ +

+ Be sure to include the following statements in the header for any class in which you plan to use jMOBY + service communication: +

import org.biomoby.client.*;
import org.biomoby.shared.*;
import org.biomoby.shared.data.*;
+

+ +
+ +

Hello World (or its bioinformatics equivalent)

+ +

+ The following code has two parts. First, a service called "MOBYSHoundGetGenBankff" is found via MOBY Central. + This service fetches sequences based on keys such as GenBank gi identifiers. Second, the service + is called using MobyRequest with a sample input MobyDataObject. The result of the + service invocation (a DNA sequence in XML) is printed. + +

+
            
+import org.biomoby.client.*;
+import org.biomoby.shared.*;
+import org.biomoby.shared.data.*;
+
+public class HelloMOBY {
+    public static void main(String[] args) throws Exception{
+
+        Central worker = new CentralImpl();
+        MobyService templateService = new MobyService("MOBYSHoundGetGenBankff");
+        MobyService[] validServices = worker.findService(templateService);
+
+	MobyRequest mr = new MobyRequest(worker);
+	mr.setService(validServices[0]);
+	mr.setInput(new MobyDataObject("NCBI_gi", "111076"));
+	System.out.println(mr.invokeService().toString());
+    }
+}
+	  
+ + A version of this code with comments and error checking is available in the +
MOBY CVS as Java/src/Clients/TestRequest.java +
+ +

Creating jMOBY Data

+

+ The Java API is designed so that all of the MOBY-S XML concepts can be "get" or "set" using Java primitives + (Strings, Numbers, etc.) as parameters to class methods. You do not need to + write or parse XML. There are several key features of jMOBY that minimize the number of classes you need to + familiarize yourself with: +

+

+ +

Because of the input/output symmetry of service data, MOBY objects are highly reusable when you are trying to chain + together multiple service discoveries and invocations. If you are interested in creating + reusable workflows (MOBY macros of sorts), you may wish to look at Taverna. +

+ + +

Creating a database identifier object

+

Database identifiers are often the starting point for workflows, as they can be used to retrieve sequence data, + which is then visualized or submitted to other services. All MOBY objects have +a namespace and an ID, +therefore a database identifier is the simplest form of a object. A MobyDataObject constructor is available +to easily build database identifiers (MobyDataObject(String namespace, String id)): + +

MobyDataObject dbid = new MobyDataObject("NCBI_gi", "111076");
+ +

+ +

Creating a "primitive" data object

+

+The following data are considered irreducible, atomic, or "primitive" in MOBY: + + + + + + + + + + + +
MOBY SpecificationjMOBY class in org.biomoby.shared.dataunderlying Java implementationCan be instantiated using any one of
ObjectMobyDataObjectimplements Comparable
  • "namespace", "id"
  • MOBYDataObject (cloning)
StringMobyDataStringjava.lang.StringBuffer
IntegerMobyDataIntjava.math.BigInteger
  • int
  • java.lang.Number (i.e. Byte, Double, Float, Integer, Long, Short, BigInteger, BigDecimal)
  • Strings like "2005"
FloatMobyDataFloatjava.math.BigDecimal
  • double
  • java.lang.Number
  • Strings like "2.0-e4" or "0.0002"
DateTimeMobyDataDateTimejava.util.GregorianCalendar
+Any object can also be instantiated using the corresponding XML data as an org.w3c.dom.Element. +

+

Below are some (hopefully) self-explanatory primitive object creation examples: +

MobyDataString sequenceString = new MobyDataString("MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSPGYVEHNPDEIWNAQMLAI");
+
MobyDataInt sequenceLength = new MobyDataInt(60);
+
MobyDataFloat sequencePI = new MobyDataFloat(3.67);
+
MobyDataFloat sequenceBlastEValue = new MobyDataFloat("1e-29");
+
MobyDataDateTime blastDBUpdated = new MobyDataDateTime("2005-03-24");
+
+

+ +

Creating composite objects

+

Many times, you will want to send a piece of data that is more complex than a primitive. These can be built using +MobyDataComposite, which implements the java.util.Map interface. For example, if a service requires an +AminoAcidSequence as input, +its two members, SequenceString and Length can be set like so: + +

+String aaSequence = "MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSPGYVEHNPDEIWNAQMLAI";
+MobyDataComposite aaSequenceObject = new MobyDataComposite("AminoAcidSequence");
+aaSequence.put("SequenceString", new MobyDataString(aaSequence));
+aaSequence.put("Length", new MobyDataInt(aaSequence.length()));
+
+ +

+
+ + +

Manipulating jMOBY data

+

+Coming soon. +

+ +

Dissecting queries and responses

+

Changing data objects

+
+
+

Creating MOBY XML (responses and queries)

+

+ It may at times be necessary to explicitly create a + full MOBY + XML document (i.e. serialize jMOBY objects). For example to store a response on disk for later usage, or + just so you can create your own SOAP response as a service provider. The + org.biomoby.shared.data.MobyDataUtils class provides the ability to output + XML documents, by specifiying an java.io.OutputStream and the contents. +

+ +

Create a blank MOBY XML response

+

+ Use the one-object convenience constructor for org.biomoby.shared.data.MobyContentInstance. + It will automatically create the content envelope. Since the object (first arg) is null, the mobyData + will be blank. This data envelope is then made into a proper XML file, with declarations and all, by + MobyDataUtils. + +

MobyDataUtils.toXMLDocument(System.out, new MobyContentInstance(null, null));
+

+ +

Create a MOBY XML response or query with a single data object

+

+ Use the one-object convenience constructor for MobyContentInstance. It will automatically + create the full content envelope and embed the XML for your object. The object must be or inherit from + MobyDataObject (Simples), or MobyDataObjectSet (Collections) + to form a valid content envelope. + +

MobyDataUtils.toXMLDocument(System.out, new MobyContentInstance(new + MobyDataObject("gi", "100089"), null));
+

+ +

Create a MOBY XML response or query envelope with multiple invocations

+

+ Use the default constructor for MobyContentInstance, then add at least one MobyDataInstance +to it using the java.lang.Map interface or the convenient one-arg put method. +

+MobyContentInstance queries = new MobyContentInstance();
+data.put(new MobyDataObject("gi", "100089"));
+data.put(new MobyDataObject("gi", "324442"));
+MobyDataUtils.toXMLDocument(System.out, queries);
+
+
+ +

Parsing MOBY XML

+ +

As a counterpart to the utility above, jMOBY provides a method to deserialize a response/request envelope: +

+MobyContentInstance queries = MobyDataUtils.fromXMLDocument(System.in);
+System.out.println("The document contained " + ((queries.size() == 1) ? "1 query" : (query.size() + " queries")));
+
+

+ + +
+
Paul Gordon
+ -Last modified: Tue May 17 15:34:15 2005 +Last modified: Thu Jul 21 23:45:59 MDT 2005 -
- + + From gordonp at pub.open-bio.org Fri Jul 22 01:11:54 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri Jul 22 01:59:16 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220511.j6M5Bsa7030848@pub.open-bio.org> gordonp Fri Jul 22 01:11:54 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory pub.open-bio.org:/tmp/cvs-serv30795 Modified Files: MobyDataComposite.java MobyDataDateTime.java MobyDataFloat.java MobyDataInt.java MobyDataObject.java MobyDataObjectSet.java MobyDataSecondaryInstance.java MobyDataString.java Added Files: MobyContentInstance.java MobyDataUtils.java Log Message: First major release of fully functional data instance code moby-live/Java/src/main/org/biomoby/shared/data MobyContentInstance.java,NONE,1.1 MobyDataUtils.java,NONE,1.1 MobyDataComposite.java,1.2,1.3 MobyDataDateTime.java,1.2,1.3 MobyDataFloat.java,1.2,1.3 MobyDataInt.java,1.2,1.3 MobyDataObject.java,1.3,1.4 MobyDataObjectSet.java,1.2,1.3 MobyDataSecondaryInstance.java,1.2,1.3 MobyDataString.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2005/07/22 05:11:54 1.3 @@ -11,6 +11,7 @@ import java.util.Vector; import org.biomoby.shared.MobyDataType; +import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyNamespace; /** @@ -28,9 +29,9 @@ /** * Construct the object using a DOM fragment. * - * @throws IllegalArgumentException if the element is not a MobyObject tag + * @throws MobyException if the element is not a MobyObject tag */ - public MobyDataComposite(org.w3c.dom.Element element) throws IllegalArgumentException{ + public MobyDataComposite(org.w3c.dom.Element element) throws MobyException{ this(new MobyDataType(element.getLocalName()), getName(element), getNamespace(element), getId(element)); // Decompose the children @@ -70,6 +71,23 @@ members = new HashMap(); } + public MobyDataComposite(MobyDataType type, String name){ + this(type, name, "", ""); + } + + public MobyDataComposite(String typeName, String name){ + this(new MobyDataType(typeName), name); + } + + public MobyDataComposite(MobyDataType type){ + this(type, ""); + } + + public MobyDataComposite(String typeName){ + this(new MobyDataType(typeName)); + } + + /** * Report whether all required fields for the object's datatype have been instantiated * (i.e. the object is ready to use as input to a service). @@ -108,6 +126,10 @@ for(int i = 0; i < fieldNames.length; i++){ //MobyDataObject mdsi = members.get(fieldNames[i]); //Java1.5 MobyDataObject mdsi = (MobyDataObject) members.get(fieldNames[i]); + // ensure the articleName is set correctly for the requirements of this object + if(!fieldNames[i].toString().equals(mdsi.getName())){ + mdsi.setName(fieldNames[i].toString()); + } int oldXmlMode = mdsi.getXmlMode(); if(oldXmlMode != MobyDataInstance.SERVICE_XML_MODE){ mdsi.setXmlMode(MobyDataInstance.SERVICE_XML_MODE); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2005/07/22 05:11:54 1.3 @@ -40,7 +40,7 @@ } /** - * Constructor to build a MOBY DateTime object using an ISO 8601 formatted input string. + * Constructor to build a MOBY DateTime object using the W3C profile of an ISO 8601 formatted input string. * @param stringISO8601 if null, the current local date and time is used */ public MobyDataDateTime(String articleName, String stringISO8601) throws IllegalArgumentException{ @@ -49,6 +49,10 @@ value = parseISO8601(stringISO8601); } + public MobyDataDateTime(String stringISO8601){ + this("", stringISO8601); + } + public MobyDataDateTime(String articleName, GregorianCalendar cal){ super(articleName, ""); setDataType(new MobyDataType("DateTime")); @@ -56,6 +60,10 @@ ((StringBuffer) super.getObject()).append(toString()); // set string representation in case super.toXML() is called explicitly } + public MobyDataDateTime(GregorianCalendar cal){ + this("", cal); + } + /** * For a description of ISO 8601 as used on the Web, see http://www.w3.org/TR/NOTE-datetime * This method is based on org.w3.util.DateParser v. 1.4 by Benoît Mahé (bmahe@w3.org) =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2005/07/22 05:11:54 1.3 @@ -49,6 +49,10 @@ } } + public MobyDataFloat(Number n){ + this("", n); + } + /** * Constructor to use if the incoming value is a primitive. * If you want to pass in a float or int, cast it to a double. @@ -59,6 +63,10 @@ value = new BigDecimal(d); } + public MobyDataFloat(double d){ + this("", d); + } + /** * Constructor to use if the incoming value is a string representing a number * (including mantissa/exponent format). @@ -71,6 +79,10 @@ value = new BigDecimal(stringNumber); } + public MobyDataFloat(String stringNumber){ + this("", stringNumber); + } + public Object clone(){ MobyDataFloat copy = new MobyDataFloat(getName(), value); copy.setDataType(getDataType()); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2005/07/22 05:11:54 1.3 @@ -50,6 +50,10 @@ } } + public MobyDataInt(Number n){ + this("", n); + } + /** * Constructor to use if the incoming value is a primitive. * If you want to pass in a float or double, cast it to an int. @@ -60,6 +64,10 @@ value = new BigInteger(""+i); } + public MobyDataInt(int i){ + this("", i); + } + /** * Constructor to use if the incoming value is a string representing an integer number. * =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/07/19 12:39:59 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/07/22 05:11:54 1.4 @@ -45,9 +45,9 @@ /** * Construct the object using a DOM fragment. * - * @throws IllegalArgumentException if the element is not an Object tag + * @throws MobyException if the element is not an Object tag, or is missing a required attribute */ - public MobyDataObject(Element element) throws IllegalArgumentException{ + public MobyDataObject(Element element) throws MobyException{ this(getNamespace(element).getName(), getId(element)); setName(getName(element)); } @@ -58,6 +58,7 @@ */ public MobyDataObject(String name){ super(name); + setDataType(staticObjectDataType); } /** @@ -84,13 +85,14 @@ /** * This method creates a MobyDataObject of the appropriate subclass for * a given input XML tree (e.g. base objects like MobyDataObject and MobyDataInt, - * or complex objects like MobyDataDateTime or MobyDataComposite). This method + * or complex objects like MobyDataDateTime or MobyDataComposite, or even a + * MobyDataSecondaryInstance). This method * will also parse a MOBY XML Object wrapped in a Simple tag when the Simple * is passed in as the main element. * * @param objectTag the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag */ - public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws IllegalArgumentException{ + public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws MobyException{ MobyDataObject object = null; if(objectTag == null){ @@ -99,23 +101,31 @@ String objectClass = objectTag.getLocalName(); if("Simple".equals(objectClass)){ - NodeList children = objectTag.getElementsByTagName("*"); + NodeList children = objectTag.getChildNodes(); + int elementChild = -1; + for(int i = 0; i < children.getLength(); i++){ + if(children.item(i) instanceof Element){ + // Second instance of element child + if(elementChild != -1){ + throw new IllegalArgumentException("Simple element has more than one " + + "child element, cannot create a MOBY data " + + "instance due to the ambiguity of the input XML"); + } + elementChild = i; + } + } // A Simple tag is allowed to have exactly one child element - if(children.getLength() == 0){ + if(elementChild == -1){ throw new IllegalArgumentException("Simple element has no MOBY " + "child element, there is no " + "instance to create"); } - else if(children.getLength() != 1){ - throw new IllegalArgumentException("Simple element has more than one " + - "child element, cannot create a MOBY data " + - "instance due to the ambiguity of the input XML"); - } - return createInstanceFromDOM((Element) children.item(0)); + + return createInstanceFromDOM((Element) children.item(elementChild)); } // There are six types of objects we can populate with data directly - // plus Collections. Otherwise its a composite. + // plus Collections and Secondary Parameters. Otherwise it is a composite. else if("Object".equals(objectClass)){ return new MobyDataObject(objectTag); } @@ -137,14 +147,22 @@ else if("Collection".equals(objectClass)){ return new MobyDataObjectSet(objectTag); } + else if(MobyDataSecondaryInstance.ELEMENT_NAME.equals(objectClass)){ + return new MobyDataSecondaryInstance(objectTag); + } // Must otherwise be a composite else{ return new MobyDataComposite(objectTag); } } - protected static String getTextContents(Element element){ - NodeList children = element.getChildNodes(); + /** + * Similar to DOM level 3 getTextContent, but only elements are excepted as input, and text + * inside children elements is not picked up. + * Actually calls MobyObjectDecompositionImpl.getTextContent() + */ + public static String getTextContents(Element element){ + /* NodeList children = element.getChildNodes(); int numChildren = children.getLength(); StringBuffer textContents = new StringBuffer(); for(int i = 0; i < numChildren; i++){ @@ -153,8 +171,8 @@ childNode instanceof org.w3c.dom.CDATASection){ textContents.append(childNode.getNodeValue()); } - } - return textContents.toString(); + }*/ + return MobyObjectDecompositionImpl.getTextContent(element, false); } protected static MobyNamespace getNamespace(Element e){ @@ -165,7 +183,7 @@ /** * Determine the name of the element if the parent Simple exists */ - protected static String getName(Element e){ + public static String getName(Element e){ Node p = e.getParentNode(); if(p == null || !(p instanceof Element)){ return ""; @@ -174,7 +192,7 @@ return name == null ? "" : name; } - protected static String getId(Element e){ + public static String getId(Element e){ String id = e.getAttribute("id"); return id == null ? "" : id; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2005/07/22 05:11:54 1.3 @@ -6,6 +6,7 @@ import java.util.Iterator; import java.util.Vector; +import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyPrimaryDataSet; import org.biomoby.shared.MobyPrefixResolver; @@ -26,11 +27,11 @@ Vector bag; private int xmlMode = MobyDataInstance.SERVICE_XML_MODE; - public MobyDataObjectSet(org.w3c.dom.Element e) throws IllegalArgumentException{ + public MobyDataObjectSet(org.w3c.dom.Element e) throws MobyException{ this(MobyDataObject.getName(e), getChildren(e)); } - public static Collection getChildren(org.w3c.dom.Element e){ + public static Collection getChildren(org.w3c.dom.Element e) throws MobyException{ Vector members = new Vector(); org.w3c.dom.NodeList children = e.getElementsByTagName("*"); //wildcard @@ -102,7 +103,8 @@ * @return the MobyDataObjects that comprise the collection */ public MobyDataObject[] getElementInstances(){ - return (MobyDataObject[]) bag.toArray(); + MobyDataObject instances[] = new MobyDataObject[bag.size()]; + return (MobyDataObject[]) bag.toArray(instances); } private void checkInputClass(String action, Object mdsi) throws ClassCastException, NullPointerException{ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/07/19 12:59:21 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/07/22 05:11:54 1.3 @@ -1,14 +1,18 @@ package org.biomoby.shared.data; -import org.biomoby.shared.MobySecondaryData; + +import org.biomoby.shared.*; +import org.w3c.dom.*; /** * A class that holds and displays secondary input data to a service. */ -public class MobyDataSecondaryInstance extends MobySecondaryData{ +public class MobyDataSecondaryInstance extends MobySecondaryData implements MobyDataInstance{ protected String dataValue = null; - protected MobySecondaryData secDataType = null; + protected int xmlMode = MobyDataInstance.CENTRAL_XML_MODE; + public static final String ELEMENT_NAME = "Parameter"; + public static final String VALUE_NAME = "Value"; public MobyDataSecondaryInstance(MobySecondaryData type, String value){ this(type); @@ -26,7 +30,40 @@ setDefaultValue(type.getDefaultValue()); setMinimumValue(type.getMinimumValue()); setMaximumValue(type.getMaximumValue()); - secDataType = type; + } + + /** + * Create an instance from XML input. Unfortunately, under the current scheme + * we have no way of knowing what the type of the parameter is (int, string, etc.). + * By default we will treat it as a string, as this is the most lenient. + */ + public MobyDataSecondaryInstance(Element objectTag) throws MobyException{ + // What is the parameter name? + super(MobyDataObject.getName(objectTag)); + setDataType("String"); + + if(objectTag == null){ + return; + } + + String objectClass = objectTag.getLocalName(); + if(!ELEMENT_NAME.equals(objectClass)){ + throw new MobyException("While creating a secondary parameter instance from XML: " + + "the passed in element (" +objectClass + ") was not a " + ELEMENT_NAME); + } + NodeList values = objectTag.getElementsByTagNameNS(MobyPrefixResolver.MOBY_XML_NAMESPACE, VALUE_NAME); + if(values.getLength() == 0){ + throw new MobyException("While creating a secondary parameter instance from XML: " + + "No " + VALUE_NAME + " element in the namespace " + + MobyPrefixResolver.MOBY_XML_NAMESPACE + " was found"); + } + if(values.getLength() > 1){ + throw new MobyException("While creating a secondary parameter instance from XML: " + + "More than one " + VALUE_NAME + " element ("+ + values.getLength() +") in the namespace " + + MobyPrefixResolver.MOBY_XML_NAMESPACE + " was found"); + } + setValue(MobyDataObject.getTextContents((Element) values.item(0))); } public void setValue(String value) throws IllegalArgumentException{ @@ -37,9 +74,51 @@ return dataValue; } + public void setXmlMode(int mode) throws IllegalArgumentException{ + if(mode != MobyDataInstance.CENTRAL_XML_MODE && mode != MobyDataInstance.SERVICE_XML_MODE){ + throw new IllegalArgumentException("Value passed to setXmlMode was neither " + + "MobyDataInstance.CENTRAL_XML_MODE nor MobyDataInstance.SERVICE_XML_MODE"); + } + xmlMode = mode; + } + + /** + * Report whether toXML will produce Central template or service call instance XML. + * + * @return one of CENTRAL_XML_MODE or SERVICE_XML_MODE + */ + public int getXmlMode(){ + return xmlMode; + } + + /** + * This method sanitizes parameter data value strings of XML escape characters such as the ampersand (&) and the + * less-than sign (<). WARNING: this method will not escape ampersand in the string "&amp;", + * or '&#x26;' style character references. We will assume that is this case you've probably + * already written the string as XML. Also note that null strings are treated as empty strings. + * + * WARNING: As of yet, we do not deal with the false escaping of strings containg already-escaped + * CDATA sections! + */ public String toXML(){ - return " " + dataValue + "\n"; + // Sanitize the data before adding to the XML + String tmpValue = dataValue; + if(tmpValue != null){ + tmpValue = tmpValue.replaceAll("&(?!(amp|#x\\d+);)", "&"); + tmpValue = tmpValue.replaceAll("<", "<"); + } + // A null value and an empty string are considered equivalent here + else{ + tmpValue = ""; + } + + if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ + return " " + tmpValue + "\n"; + } + else{ + return super.toXML(); + } } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2005/07/22 05:11:54 1.3 @@ -36,6 +36,10 @@ value = new StringBuffer(stringValue.toString()); } + public MobyDataString(CharSequence stringValue){ + this("", stringValue); + } + public String toString(){ return value.toString(); } @@ -63,7 +67,7 @@ * This method sanitizes strings of XML escape characters such as the ampersand (&) and the * less-than sign (<). WARNING: this method will not escape ampersand in the string "&amp;", * or '&#x26;' style character references. We will assume that is this case you've probably - * already written the string as XML. + * already written the string as XML. Also note that null strings are treated as empty strings. * * WARNING: As of yet, we do not deal with the false escaping of strings containg already-escaped * CDATA sections! @@ -76,6 +80,9 @@ tmpValue = tmpValue.replaceAll("&(?!(amp|#x\\d+);)", "&"); tmpValue = tmpValue.replaceAll("<", "<"); } + else{ + tmpValue = ""; + } return "" + tmpValue + ""; } From gordonp at pub.open-bio.org Fri Jul 22 01:16:08 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri Jul 22 02:03:46 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220516.j6M5G8cY030883@pub.open-bio.org> gordonp Fri Jul 22 01:16:08 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv30858 Modified Files: ChangeLog Log Message: Noted updates to code and documentation of org.biomoby.shared.data moby-live/Java/docs ChangeLog,1.31,1.32 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/07/19 12:39:58 1.31 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/07/22 05:16:08 1.32 @@ -1,3 +1,9 @@ +2005-07-21 Paul Gordon + + * Update of data instance code to fully functional status (pending minor changes to the MOBY-S API docs) + + * Inclusion of "quick start" guide to using the classes in org.biomoby.shared.data + 2005-07-19 Martin Senger * Changed the remote repository for the third-party jar files. From gordonp at pub.open-bio.org Fri Jul 22 01:23:00 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri Jul 22 02:10:30 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220523.j6M5N0nx030932@pub.open-bio.org> gordonp Fri Jul 22 01:23:00 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory pub.open-bio.org:/tmp/cvs-serv30907 Modified Files: MobyRequest.java Log Message: Updated to use the new data instance classes moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/19 13:16:53 1.13 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/22 05:23:00 1.14 @@ -23,10 +23,7 @@ import org.apache.xpath.objects.XObject; import org.biomoby.shared.Central; import org.biomoby.shared.MobyData; -import org.biomoby.shared.data.MobyDataInstance; -import org.biomoby.shared.data.MobyDataSecondaryInstance; -import org.biomoby.shared.data.MobyDataObjectSet; -import org.biomoby.shared.data.MobyDataObject; +import org.biomoby.shared.data.*; import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyPrefixResolver; import org.biomoby.shared.MobyService; @@ -58,7 +55,7 @@ protected MobyService mobyService = null; protected MobyDataInstance[] inputData = null; protected MobyDataSecondaryInstance[] secondaryData = null; - protected Vector outputData = null; + protected MobyContentInstance outputData = null; protected Central mobyCentral = null; protected PrefixResolver mobyPrefixResolver = null; @@ -76,7 +73,6 @@ private XPath stringEncodedXPath; private XPath base64EncodedXPath; - private XPath queryResponseXPath; private XPath simpleChildXPath; private XPath collectionChildXPath; @@ -117,9 +113,8 @@ MobyPrefixResolver.XSI1999_PREFIX+ ":type, ':')=\"string\" or substring-after(@"+ MobyPrefixResolver.XSI2001_PREFIX+ - ":type, ':')=\"string\"]", null, - mobyPrefixResolver, XPath.SELECT); - queryResponseXPath = new XPath("//moby:mobyData | //mobyData", null, + ":type, ':')=\"string\"] | //"+ + MobyPrefixResolver.SOAP_ENC_PREFIX+":string", null, mobyPrefixResolver, XPath.SELECT); simpleChildXPath = new XPath("moby:Simple | Simple", null, mobyPrefixResolver, XPath.SELECT); @@ -233,7 +228,7 @@ * * @throws MobyException if you try to get the results before calling InvokeService */ - public Vector getOutput() throws MobyException{ + public MobyContentInstance getOutput() throws MobyException{ if(outputData == null){ throw new MobyException("Trying to access MOBY service results " + "before the service is invoked"); @@ -255,7 +250,7 @@ * @throws MobyException i.e. there was something wrong with the input, output or remote service's logic * @throws SOAPException i.e. there was a problem with the underlying transaction/transport layer */ - public Vector invokeService() throws MobyException, SOAPException, NoSuccessException{ + public MobyContentInstance invokeService() throws Exception, MobyException, SOAPException, NoSuccessException{ if(mobyService == null){ throw new MobyException("Tries to invoke null service from MobyRequest (call setService first)"); } @@ -264,7 +259,8 @@ verifyInput(); String mobyXML = convertMOBYDataToMOBYRequest(inputData, secondaryData); Element mobyDOM = performSOAPRequest(mobyXML); - outputData = convertMOBYResponseToMOBYData(mobyDOM); + // The following parses the DOM and extracts all the appropriate jMOBY objects to represent the XML in Java + outputData = MobyDataUtils.fromXMLDocument(mobyDOM); return outputData; } @@ -418,8 +414,9 @@ XPath responseElementXPath = null; try{ responseElementXPath = new XPath("//"+ MobyPrefixResolver.MOBY_TRANSPORT_PREFIX+ - ":"+mobyService.getName()+"Response", - null, mobyPrefixResolver, XPath.SELECT); + ":"+mobyService.getName()+"Response | //" + + mobyService.getName()+"Response", + null, mobyPrefixResolver, XPath.SELECT); }catch(TransformerException te){ throw new SOAPException("Cannot select SOAP nodes due to exception "+ "while compiling XPath statement (code bug?):" +te); @@ -480,11 +477,11 @@ node_list = runXPath(stringEncodedXPath, responseNode); } catch(TransformerException te){ - throw new SOAPException("Cannot select base64 encoded SOAP nodes due to exception "+ + throw new SOAPException("Cannot select string encoded SOAP nodes due to exception "+ "while executing XPath statement:" +te); } - // Do decoding for each base64 part found + // Do concatenation for each plain string part found for(int i = 0; node_list != null && i < node_list.getLength(); i++){ org.w3c.dom.Node change = node_list.item(i); /* Make sure the text data is all put into one contiguous piece for decoding*/ @@ -497,11 +494,12 @@ Node child = children.item(j); if(child instanceof CDATASection || child instanceof Text){ plainString += child.getNodeValue(); + System.err.println("Plain string is now " + plainString); } } // Swap out this node for the decoded data - change.getParentNode().replaceChild(n.getOwnerDocument().createTextNode(plainString), change); + change.getParentNode().replaceChild(n.getOwnerDocument().createCDATASection(plainString), change); } if(debug && node_list != null){ debugPS.println("There were " + node_list.getLength() + @@ -523,7 +521,14 @@ for(int j = 0; j < children.getLength(); j++){ Node child = children.item(j); if(child instanceof CDATASection || child instanceof Text){ - responseString += child.getNodeValue(); + // Unescape XML special characters in the string, so we can later on + // parse the payload as regular XML. + // Ignore whitespace-only node + if(child.getNodeValue().matches("^\\s+$")){ + continue; + } + System.err.println("Concatenating text in response " + child.getNodeValue()); + responseString += child.getNodeValue();//.replaceAll("<", "<").replaceAll(">", ">").replaceAll("(&|F)", "&"); } } @@ -639,103 +644,6 @@ } /** - * This method takes the internally stored DOM, representing the MOBY response - * from the service and converst it into the standard jMOBY API Data representation. - * - * @throws MobyException if the MOBY message does not conform to the API - */ - public Vector convertMOBYResponseToMOBYData(Element n) throws MobyException{ - // - Vector responsesOutput = new Vector(); - - NodeList response_list = null; - try{ - response_list = runXPath(queryResponseXPath, n); - }catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyContent nodes due to exception "+ - "while executing XPath statement: " +te); - } - - if(response_list == null || response_list.getLength() == 0){ - throw new MobyException("Could not find any mobyContent elements in the output"); - } - if(debug){ - debugPS.println("Aha! Got " + response_list.getLength() + " mobyContent response elements"); - } - // Do data decoding for each response's mobyData - for(int i = 0; i < response_list.getLength(); i++){ - Node response = response_list.item(i); - - Vector out = new Vector(); - // Find all the collections in the response - NodeList collections = null; - try{ - collections = runXPath(collectionChildXPath, response); - }catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyData/Collection nodes due to exception "+ - "while executing XPath statement: " +te); - } - for(int j = 0; collections != null && j < collections.getLength(); j++){ - if(debug & j == 0) - debugPS.println("There are " + collections.getLength() + - " collections in response #" +i); - MobyDataObjectSet collection = new MobyDataObjectSet(""); - - // For each collection, find the simple children - NodeList subsimples = null; - try{subsimples = runXPath(simpleChildXPath, collections.item(j));} - catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyData/Collection/Simple " + - "nodes due to exception "+ - "while executing XPath statement: " +te); - } - - // And add their values to the collection - MobyDataObject[] subout = new MobyDataObject[subsimples.getLength()]; - for(int k = 0; k < subsimples.getLength(); k++){ - if(debug && k == 0) - debugPS.println("There are " + subsimples.getLength() + - " simples in response #" + i + - ", collection #" + j); - subout[k] = (MobyDataObject) MobyDataObject.createInstanceFromDOM((Element) subsimples.item(k)); - } - collection.setElements(subout); - releaseXPath(collections.item(j)); - // Add completed collection to the output list - out.add(collection); - } - - // Take all the top level simples and add them to the list - NodeList simples = null; - try{ - simples = runXPath(simpleChildXPath, response); - }catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyData/Collection nodes due to exception "+ - "while executing XPath statement: " +te); - } - if((collections == null || collections.getLength() == 0) && - (simples == null || simples.getLength() == 0)){ - debugPS.println("WARNING: There appears to be no output data in mobyData #" + i); - } - for(int j = 0; simples != null && j < simples.getLength(); j++){ - if(debug && j == 0) - debugPS.println("There are " + simples.getLength() + " simples in response #" +i); - out.add(MobyDataObject.createInstanceFromDOM((Element) simples.item(j))); - } - - // What we're building is a Vector, where each element represents - // a Response's DataInstance Output (i.e. Simple and Collection return values) - MobyDataInstance[] mdis = new MobyDataInstance[out.size()]; - responsesOutput.add(out.toArray(mdis)); - - releaseXPath(response); - } - // release resources related to the Xpath execution, since we won't be using this doc anymore - releaseXPath(n); - return responsesOutput; - } - - /** * A method that sets up the execution environm,ent for and runs a compiled XPath statement against a DOM node * You should call releaseXPath when you're done with the results * @return the list of Nodes that satisfy the XPath in this Node's context From gordonp at pub.open-bio.org Fri Jul 22 01:30:38 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri Jul 22 02:18:35 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220530.j6M5UcnE031024@pub.open-bio.org> gordonp Fri Jul 22 01:30:38 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv31003 Added Files: PrimitiveTypes.java Log Message: Moved this class from obsucred subpackage of client to shared, since it's pretty basic info moby-live/Java/src/main/org/biomoby/shared PrimitiveTypes.java,NONE,1.1 From gordonp at pub.open-bio.org Fri Jul 22 01:32:49 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri Jul 22 02:21:17 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220532.j6M5WnnO031059@pub.open-bio.org> gordonp Fri Jul 22 01:32:49 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv31034 Modified Files: MobyPrefixResolver.java Log Message: Utility methods added that are used by data instance classes for ease of parsing moby-live/Java/src/main/org/biomoby/shared MobyPrefixResolver.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrefixResolver.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrefixResolver.java 2005/02/09 17:39:17 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrefixResolver.java 2005/07/22 05:32:49 1.4 @@ -1,6 +1,8 @@ package org.biomoby.shared; import org.apache.xml.utils.PrefixResolver; +import org.w3c.dom.*; +import java.util.Vector; /** * The main purpose of this class is to provide default mapping from @@ -28,6 +30,8 @@ public static final String XSI_PREFIX = "xsi"; public static final String XSI1999_PREFIX = "xsi1999"; public static final String XSI2001_PREFIX = "xsi2001"; + public static final String SOAP_ENC_NAMESPACE ="http://schemas.xmlsoap.org/soap/encoding/"; + public static final String SOAP_ENC_PREFIX ="soap-enc"; /** * We don't really implement this as it can be extremely complicated. @@ -52,6 +56,45 @@ } /** + * Convenience method that matches attributes in the MOBY namespace or, for now + * at least, with no declared namespace. + * @return the value of the attribute, or null if the attribute does not exist + */ + public static NodeList getChildElements(org.w3c.dom.Element e, String elementName){ + MobyNodeList matches = new MobyNodeList(); + + NodeList children = e.getChildNodes(); + for(int j = 0; children != null && j < children.getLength(); j++){ + // Make sure it's an element, not a processing instruction, text, etc. + if(!(children.item(j) instanceof Element)){ + continue; + } + Element child = (Element) children.item(j); + // Make sure it has the right name + if(!elementName.equals(child.getLocalName())){ + continue; + } + // Make sure it's in the MOBY namespace, or no namespace at all + String uri = child.getNamespaceURI(); + if(uri != null && uri.length() != 0 && !uri.equals(MOBY_XML_NAMESPACE)){ + continue; + } + + // Everything looks good + matches.add(child); + } + return matches; + } + + static class MobyNodeList implements NodeList{ + private Vector nodes; + public MobyNodeList(){nodes = new Vector();} + public int getLength(){return nodes.size();} + public Node item(int index){return (Node) nodes.elementAt(index);} + public void add(Node n){nodes.add(n);} + }; + + /** * @return For now, default MOBY and XML Schema Instance (1999) prefices as defined in the class static variables */ public String getNamespaceForPrefix(java.lang.String prefix){ @@ -73,6 +116,9 @@ else if(XSI2001_PREFIX.equals(prefix)){ return XSI_NAMESPACE2001; //Used by Axis } + else if(SOAP_ENC_PREFIX.equals(prefix)){ + return SOAP_ENC_NAMESPACE; + } else{ return ""; // Indicates that we don't have a mapping for this prefix } @@ -81,7 +127,7 @@ /** * Don't use this class if this method will be used. We are not returning a * valid XML namespace mapping, but a convenience method for XPath, therefore - * we will not given context sensitive mapping. + * we will not give context sensitive mapping. */ public String getNamespaceForPrefix(java.lang.String prefix, org.w3c.dom.Node context){ return getNamespaceForPrefix(prefix); From gordonp at pub.open-bio.org Fri Jul 22 01:26:43 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri Jul 22 02:55:58 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220526.j6M5Qhhw030979@pub.open-bio.org> gordonp Fri Jul 22 01:26:43 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv30954 Modified Files: MobyObjectDecompositionImpl.java Log Message: Removed Java 1.5 (actually a DOM level 3) dependency by implementing getTextContent(Node) moby-live/Java/src/main/org/biomoby/shared MobyObjectDecompositionImpl.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyObjectDecompositionImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyObjectDecompositionImpl.java 2005/05/12 05:19:20 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyObjectDecompositionImpl.java 2005/07/22 05:26:43 1.5 @@ -21,7 +21,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.biomoby.client.CentralImpl; -import org.biomoby.client.ui.graphical.applets.util.PrimitiveTypes; +import org.biomoby.shared.PrimitiveTypes; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -41,7 +41,7 @@ */ public class MobyObjectDecompositionImpl implements MobyObjectDecomposition { - private static final String URL_OBJECT = "http://mobycentral.cbr.nrc.ca:8090/authority/metadata?lsid="; + private static final String URL_OBJECT = "http://mobycentral.icapture.ubc.ca:8090/authority/metadata?lsid="; /* (non-Javadoc) * @see org.biomoby.client.gui.util.MobyObjectDecomposition#getFlattenedPrims(java.lang.String) @@ -80,7 +80,7 @@ "mobyPred:articleName").item(0); String localName = child.getLocalName(); String articleName = (articleNode == null) ? "" - : articleNode.getTextContent(); + : getTextContent(articleNode); // TODO - recurse if object is not a primitive if (isPrimitive(localName)) { MobyDataObject mdsi = createPrimitiveType( @@ -103,7 +103,7 @@ "mobyPred:articleName").item(0); String localName = child.getLocalName(); String articleName = (articleNode == null) ? "" - : articleNode.getTextContent(); + : getTextContent(articleNode); // TODO - recurse if object is not a primitive if (isPrimitive(localName)) { MobyDataObject mdsi = createPrimitiveType( @@ -154,6 +154,52 @@ return convertArrayListToMoby(list); } + /** + * Method to simulate DOM level 3 (Java 1.5 default) method for recursively getting text children from a Node. + * A wrapper around getTextContent(Node, boolean) with boolean = true, since DOM 3 getTextContent() ignores + * things that match Text.isContentElementWhitespace(). + */ + public static String getTextContent(Node parent){ + return getTextContent(parent, true); + } + + /** + * Grabs the text and CDATA children of a Node (not necessairly contiguous) and returns them concatenated. + * Added by Paul Gordon. + * Simulates ignoring of DOM 3 Text.isContentElementWhitespace() fully, I *think*. + * + * @param parent the node who's text children should be concatenated + * @param includeChildrensText if true, recursively appends children's text depth first + * + * @return non-normalized text contents of the passed-in Node, and its children if so requested + */ + public static String getTextContent(Node parent, boolean includeChildrensText){ + if(parent.hasChildNodes()){ + java.util.regex.Pattern nonWhitespacePattern = Pattern.compile("[^ \t\r\n]"); + StringBuffer textbuffer = new StringBuffer(); + + for(Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()){ + // Append all the contiguous text data + if(node instanceof org.w3c.dom.Text || node instanceof org.w3c.dom.CDATASection){ + // Get rid of whitespace + String value = node.getNodeValue(); + // Add if not just whitespace. + if(nonWhitespacePattern.matcher(value).find()){ + textbuffer.append(value); + } + } + // Get contents of children elements too (recursive) + else{ + textbuffer.append(getTextContent(node, includeChildrensText)); + } + } + return textbuffer.toString(); + } + else{ + return ""; + } + } + /* (non-Javadoc) * @see org.biomoby.client.gui.util.MobyObjectDecomposition#getObjectComposition(java.lang.String) */ From mwilkinson at pub.open-bio.org Fri Jul 22 13:12:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 13:59:28 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221712.j6MHCDji000428@pub.open-bio.org> mwilkinson Fri Jul 22 13:12:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv390/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. This simplifies it and should fix it. Also fixed the documentation for the MOBY::Client::ServiceInstance object as per this mornings email moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/21 16:37:35 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:12:13 1.22 @@ -625,9 +625,23 @@ # where is lsid? sub query_service_instance { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - + + my $authority_id; + if ($args{'authority_uri'}){ # need to transform URI to a row ID + my $result = $self->query_authority({authority_uri => $args{'authority_uri'}}); + return 0 unless @$result[0]; + my $authority_id = @$result[0]->{authority_id}; + return 0 unless $authority_id; + } + delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table + my @args; + while (my ($k, $v) = each %args){ + push @args, ({$k => $v},"and"); # format for the add_condition subroutine + } + pop @args; # get rid of last "and" + my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 13:12:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 13:59:51 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221712.j6MHCDsv000452@pub.open-bio.org> mwilkinson Fri Jul 22 13:12:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv390/MOBY/Client Modified Files: ServiceInstance.pm Log Message: the logic for findig existing services was still wonky. This simplifies it and should fix it. Also fixed the documentation for the MOBY::Client::ServiceInstance object as per this mornings email moby-live/Perl/MOBY/Client ServiceInstance.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2005/05/30 21:39:05 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2005/07/22 17:12:13 1.15 @@ -17,8 +17,9 @@ contactEmail => markw@illumin.com, name => 'marksFabulousService', type => 'Retrieve', - category => 'moby', - output => 'Sequence', + input => [$SimpleArticle], + category => 'moby', + output => [$CollectionArticle, $SecondaryArticle], description => 'retrieves random sequences from a database', XML => $xml, # the XML from MOBY::Central::findService ); @@ -99,7 +100,8 @@ Title : input Usage : $input = $Service->input($args) - Args : (optional) listref of SimpleArticle and/or CollectionArticle objects + Args : (optional) listref of SimpleArticle, + CollectionArticle, or SecondaryArticle objects Function : get/set input Returns : listref of MOBY::Client::SimpleArticle and/or MOBY::Client::CollectionArticle objects @@ -110,7 +112,8 @@ Title : output Usage : $output = $Service->output($args) - Args : (optional) listref of SimpleArticle and/or CollectionArticle objects + Args : (optional) listref of SimpleArticle, + CollectionArticle, or SecondaryArticle objects Function : get/set output Returns : listref of MOBY::Client::SimpleArticle and/or MOBY::Client::CollectionArticle objects From mwilkinson at pub.open-bio.org Fri Jul 22 13:12:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 13:59:57 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221712.j6MHCDou000409@pub.open-bio.org> mwilkinson Fri Jul 22 13:12:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv390/MOBY Modified Files: Central.pm Log Message: the logic for findig existing services was still wonky. This simplifies it and should fix it. Also fixed the documentation for the MOBY::Client::ServiceInstance object as per this mornings email moby-live/Perl/MOBY Central.pm,1.165,1.166 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.165 retrieving revision 1.166 diff -u -r1.165 -r1.166 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 17:08:43 1.165 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 17:12:13 1.166 @@ -1888,7 +1888,7 @@ $debug && _LOG( "authoritative added; criterion count is now $criterion_count\n"); - my $ids = _extract_ids($adaptor->query_service_instance({authoritative => $findme{authoritative}})); + my $ids = _extract_ids($adaptor->query_service_instance(authoritative => $findme{authoritative})); @@ -1943,16 +1943,7 @@ ++$criterion_count; $debug && _LOG("authURI added; criterion count is now $criterion_count\n"); - - my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}}); - my $row = shift(@$result); - my $id = $row->{authority_id}; - - unless ($id) { - return &_serviceListResponse( $dbh, undef ); - } - - my $ids = _extract_ids($adaptor->query_service_instance({authority_id => $id})); + my $ids = _extract_ids($adaptor->query_service_instance(authority_uri => $findme{'authURI'})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1971,7 +1962,7 @@ && _LOG( "servicename added; criterion count is now $criterion_count\n"); - my $ids = _extract_ids($adaptor->query_service_instance({servicename => $findme{servicename}})); + my $ids = _extract_ids($adaptor->query_service_instance(servicename => $findme{servicename})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1990,7 +1981,7 @@ $debug && _LOG("category added; criterion count is now $criterion_count\n"); - my $ids = _extract_ids($adaptor->query_service_instance({category => lc( $findme{category}) })); + my $ids = _extract_ids($adaptor->query_service_instance(category => lc( $findme{category}) )); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -3387,7 +3378,7 @@ my $OSserv = MOBY::OntologyServer->new( ontology => 'service' ); foreach (@ids) { - my $result = $adaptor->query_service_instance({service_instance_id => $_}); + my $result = $adaptor->query_service_instance(service_instance_id => $_); my $row = shift(@$result); my $category = $row->{category}; my $url = $row->{url}; From mwilkinson at pub.open-bio.org Fri Jul 22 13:14:07 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 14:01:20 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221714.j6MHE75E000523@pub.open-bio.org> mwilkinson Fri Jul 22 13:14:07 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv504/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: added debugging info moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:12:13 1.22 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:14:07 1.23 @@ -641,7 +641,7 @@ push @args, ({$k => $v},"and"); # format for the add_condition subroutine } pop @args; # get rid of last "and" - + print STDERR join "", @args; my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 13:25:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 14:13:20 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221725.j6MHPOZt000610@pub.open-bio.org> mwilkinson Fri Jul 22 13:25:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv591/MOBY Modified Files: service_instance.pm Log Message: deanonymysing the arguents to query_service_instance moby-live/Perl/MOBY service_instance.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 17:43:24 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 17:25:24 1.22 @@ -212,8 +212,8 @@ ? $self->service_type_uri( $self->service_type ) : $self->service_type_uri($servicetypeURI); } - my $existing_services = $self->adaptor->query_service_instance({servicename => $self->servicename},"and", - {authority_uri => $self->authority_uri}); + my $existing_services = $self->adaptor->query_service_instance(servicename => $self->servicename, + authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); From mwilkinson at pub.open-bio.org Fri Jul 22 13:25:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 14:55:36 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221725.j6MHPO4t000631@pub.open-bio.org> mwilkinson Fri Jul 22 13:25:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv591/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: deanonymysing the arguents to query_service_instance moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:14:07 1.23 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:25:24 1.24 @@ -641,7 +641,6 @@ push @args, ({$k => $v},"and"); # format for the add_condition subroutine } pop @args; # get rid of last "and" - print STDERR join "", @args; my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 15:16:41 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 16:04:09 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221916.j6MJGf1M000874@pub.open-bio.org> mwilkinson Fri Jul 22 15:16:40 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv847/MOBY Modified Files: Central.pm secondary_input.pm service_instance.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY Central.pm,1.166,1.167 secondary_input.pm,1.5,1.6 service_instance.pm,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.166 retrieving revision 1.167 diff -u -r1.166 -r1.167 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 17:12:13 1.166 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:16:40 1.167 @@ -1236,7 +1236,15 @@ "Service categories other than 'moby' and 'wsdl' are not yet implemented", "" ) - unless ( ( $Category eq "moby" ) || ( $Category eq "wsdl" ) ); + unless ( ( $Category eq "moby" ) || ( $Category eq "wsdl" ) ); + +#test the existence of the service + return &_error( "This service already exists", "" ) if (MOBY::service_instance->new( + servicename => $serviceName, + authority_uri => $AuthURI, + test => 1)); + + my @IN = @{$INPUTS}; my @OUT = @{$OUTPUTS}; my @SECS = @{$SECONDARY}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/20 22:04:10 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/22 19:16:40 1.6 @@ -115,13 +115,13 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, - {maximum_value => $self->maximum_value}, - {minimum_value => $self->minimum_value}, - {enum_value => $self->enum_value}, - {datatype => $self->datatype}, - {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}); - + {maximum_value => $self->maximum_value}, + {minimum_value => $self->minimum_value}, + {enum_value => $self->enum_value}, + {datatype => $self->datatype}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}); + return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 17:25:24 1.22 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:16:40 1.23 @@ -216,12 +216,14 @@ authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did - $self->service_instance_id( $existing_service->{'serviceid'} ); + $self->servicename( $existing_service->{'servicename'} ); + $self->authoritative( $existing_service->{'authoritative'} ); + $self->service_instance_id( $existing_service->{'service_instance_id'} ); $self->category( $existing_service->{'category'} ); - $self->service_type( $existing_service->{'servicetype'} ); + $self->service_type( $existing_service->{'service_type_uri'} ); $self->url( $existing_service->{'url'} ); - $self->contact_email( $existing_service->{'email'} ); - $self->description( $existing_service->{'desc'} ); + $self->contact_email( $existing_service->{'contact_email'} ); + $self->description( $existing_service->{'description'} ); $self->authority( $existing_service->{'authURI'} ); $self->signatureURL( $existing_service->{'signatureURL'} ); $self->lsid( $existing_service->{'lsid'} ); From mwilkinson at pub.open-bio.org Fri Jul 22 15:23:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 16:12:36 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221923.j6MJNIRm000945@pub.open-bio.org> mwilkinson Fri Jul 22 15:23:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv926/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:25:24 1.24 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:23:18 1.25 @@ -638,9 +638,9 @@ delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ - push @args, ({$k => $v},"and"); # format for the add_condition subroutine + push @args, ("and",{$k => $v}); # format for the add_condition subroutine } - pop @args; # get rid of last "and" + push @args, ("and", {authority_id => $authority_id}) if ($authority_id); my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 15:29:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 16:16:55 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221929.j6MJTcEe001023@pub.open-bio.org> mwilkinson Fri Jul 22 15:29:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv1004/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.25,1.26 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:23:18 1.25 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:29:38 1.26 @@ -599,7 +599,7 @@ unless ($id){ my $result = $self->query_authority({authority_uri => $authURI}); return 0 unless @$result[0]; - my $id = @$result[0]->{authority_id}; + $id = @$result[0]->{authority_id}; return 0 unless $id; } my $statement = "select From mwilkinson at pub.open-bio.org Fri Jul 22 15:38:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 16:25:28 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221938.j6MJc2Ub001100@pub.open-bio.org> mwilkinson Fri Jul 22 15:38:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1077/MOBY Modified Files: Central.pm service_instance.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY Central.pm,1.167,1.168 service_instance.pm,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.167 retrieving revision 1.168 diff -u -r1.167 -r1.168 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:16:40 1.167 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:38:02 1.168 @@ -1292,11 +1292,8 @@ description => $desc, signatureURL => $signatureURL, ); - return &_error( "Service registration failed for unknown reasons", "" ) - if ( !defined $SVC ); - return &_error( "Service with this authority/servicename already exists", - "" ) - if ( $SVC == -1 ); + return &_error( "Service registration failed for unknown reasons", "" ) if ( !defined $SVC ); + $debug && &_LOG("new service instance created\n"); foreach my $IN (@IN) { @@ -1716,27 +1713,26 @@ my ( $authURI, $serviceName ) = &_deregisterServicePayload($payload); return &_error( "must provide an authority and a service name\n", "" ) unless ( $authURI && $serviceName ); - return &_error( -"The service specified by authority=$authURI servicename=$serviceName does not exist in the registry", - "" - ) + return &_error("The service specified by authority=$authURI servicename=$serviceName does not exist in the registry","") unless ( MOBY::service_instance->new( servicename => $serviceName, authority_uri => $authURI, test => 1 - ) - ); + )); my $SERVICE = MOBY::service_instance->new( servicename => $serviceName, authority_uri => $authURI ); + return &_error("service lookup failed for unknown reasons","") unless ($SERVICE); + if ( $SERVICE->signatureURL ) { return &_error( "it is illegal to deregister a service that has a signatureURL. Such services must be deregistered by deleting the RDF at the location identified by the signatureURL", "" ); } + my $result = $SERVICE->DELETE_THYSELF; if ($result) { return &_success( "Service Deregistered Successfully", "" ); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:16:40 1.23 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:38:02 1.24 @@ -190,7 +190,6 @@ return undef unless $self->servicename; if ( $self->test ) { return $self->service_instance_exists } - if ($self->service_instance_exists){return -1} $self->authority( $self->_get_authority() ); From mwilkinson at pub.open-bio.org Fri Jul 22 15:46:52 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 16:34:24 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221946.j6MJkq4I001183@pub.open-bio.org> mwilkinson Fri Jul 22 15:46:52 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv1164/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:29:38 1.26 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:46:52 1.27 @@ -638,9 +638,14 @@ delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ - push @args, ("and",{$k => $v}); # format for the add_condition subroutine + push @args, ({$k => $v}, "and"); # format for the add_condition subroutine } - push @args, ("and", {authority_id => $authority_id}) if ($authority_id); + if ($authority_id){ + push @args, ({authority_id => $authority_id}) ; + } else { + pop @args; # remove final "and" + } + my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 16:00:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 16:47:38 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222000.j6MK0Aef001271@pub.open-bio.org> mwilkinson Fri Jul 22 16:00:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv1252/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.27,1.28 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:46:52 1.27 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 20:00:10 1.28 @@ -632,7 +632,7 @@ if ($args{'authority_uri'}){ # need to transform URI to a row ID my $result = $self->query_authority({authority_uri => $args{'authority_uri'}}); return 0 unless @$result[0]; - my $authority_id = @$result[0]->{authority_id}; + $authority_id = @$result[0]->{authority_id}; return 0 unless $authority_id; } delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table From mwilkinson at pub.open-bio.org Fri Jul 22 16:05:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 16:52:36 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222005.j6MK5S01001341@pub.open-bio.org> mwilkinson Fri Jul 22 16:05:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1322/MOBY Modified Files: Central.pm Log Message: service discovery was failing because the searches were returning objects instead of id numbers moby-live/Perl/MOBY Central.pm,1.168,1.169 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.168 retrieving revision 1.169 diff -u -r1.168 -r1.169 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:38:02 1.168 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:05:28 1.169 @@ -1907,8 +1907,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instnace_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{serviceType} ) { # must have something more than empty content @@ -1939,8 +1938,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{authURI} ) { @@ -1956,8 +1954,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{servicename} ) { @@ -1975,8 +1972,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } $findme{category} = 'moby' unless $findme{category}; @@ -1994,8 +1990,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{keywords} && ( scalar @{ $findme{keywords} } ) ) { @@ -2008,17 +2003,14 @@ unless ( scalar @{$ids} ) { $debug - && &_LOG( -"found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n" - ); + && &_LOG("found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n"); return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{inputObjects} && ( scalar @{ $findme{inputObjects} } ) ) { @@ -2033,8 +2025,7 @@ $findme{'expandObjects'}, '' ) if defined $obj; $debug - && _LOG( - "Initial Search For Services with INPUT Article found @si_ids\n"); + && _LOG("Initial Search For Services with INPUT Article found @si_ids\n"); my %instances; # we need to do a join, without doing a join... @@ -2051,9 +2042,7 @@ &_searchForServicesWithArticle( $dbh, "input", $obj, $findme{'expandObjects'}, '' ); # get their service ids $debug - && _LOG( -"Subsequent Search For Services with INPUT Article found @new_ids\n" - ); + && _LOG("Subsequent Search For Services with INPUT Article found @new_ids\n"); my @good_ids; my %good_ids; foreach my $id (@new_ids) From mwilkinson at pub.open-bio.org Fri Jul 22 16:15:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 17:04:38 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222015.j6MKFmuB001439@pub.open-bio.org> mwilkinson Fri Jul 22 16:15:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1420/MOBY Modified Files: Central.pm Log Message: service discovery was failing because of incorrect column names in SQL moby-live/Perl/MOBY Central.pm,1.169,1.170 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.169 retrieving revision 1.170 diff -u -r1.169 -r1.170 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:05:28 1.169 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:15:48 1.170 @@ -3427,7 +3427,7 @@ } $output .= "\t\t\n"; } - $result = $adaptor->query_collection_input({service_instance => $_}); + $result = $adaptor->query_collection_input({service_instance_id => $_}); # $sth_collection_ins->execute($_); foreach my $row (@$result) From mwilkinson at pub.open-bio.org Fri Jul 22 16:25:39 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 17:14:23 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222025.j6MKPdeV001588@pub.open-bio.org> mwilkinson Fri Jul 22 16:25:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1569/MOBY Modified Files: Central.pm Log Message: various queries being sent to the wrong adaptors moby-live/Perl/MOBY Central.pm,1.171,1.172 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.171 retrieving revision 1.172 diff -u -r1.171 -r1.172 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:18:28 1.171 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:25:39 1.172 @@ -473,7 +473,7 @@ sub deregisterObjectClass { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'object' ); @@ -486,7 +486,6 @@ $OntologyServer->objectExists( term => $class ); return &_error( "Object class $class does not exist", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new()->dbh; my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); return &_error( @@ -745,7 +744,7 @@ sub deregisterServiceType { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'service' ); @@ -755,12 +754,9 @@ return &_error( "Must include an accession number to deregister a serviceType", "" ) unless ($term); - my ( $success, $message, $existingURI ) = - $OntologyServer->serviceExists( term => $term ) - ; # hopefully this situation will never happen! + my ( $success, $message, $existingURI ) = $OntologyServer->serviceExists( term => $term ); # hopefully this situation will never happen! return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new()->dbh; my $result = $adaptor->query_service({service_type_uri => $existingURI}); my $row = shift(@$result); @@ -906,7 +902,7 @@ sub deregisterNamespace { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'namespace' ); @@ -919,7 +915,6 @@ $OntologyServer->namespaceExists( term => $term ); return &_error( "Namespace Type $term does not exist", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new->dbh; my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term}); return &_error( $errstr, "") if ($err); From mwilkinson at pub.open-bio.org Fri Jul 22 16:29:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 17:16:45 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222029.j6MKTBx7001654@pub.open-bio.org> mwilkinson Fri Jul 22 16:29:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1635/MOBY Modified Files: Central.pm Log Message: various queries being sent to the wrong adaptors moby-live/Perl/MOBY Central.pm,1.172,1.173 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.172 retrieving revision 1.173 diff -u -r1.172 -r1.173 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:25:39 1.172 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:29:11 1.173 @@ -473,7 +473,7 @@ sub deregisterObjectClass { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'object' ); @@ -486,6 +486,7 @@ $OntologyServer->objectExists( term => $class ); return &_error( "Object class $class does not exist", "" ) unless ($existingURI); + my $dbh = MOBY::central_db_connection->new()->dbh; my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); return &_error( @@ -902,7 +903,7 @@ sub deregisterNamespace { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'namespace' ); From gordonp at pub.open-bio.org Fri Jul 22 16:59:05 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri Jul 22 17:46:25 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222059.j6MKx5BS001853@pub.open-bio.org> gordonp Fri Jul 22 16:59:05 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/Clients In directory pub.open-bio.org:/tmp/cvs-serv1828/src/Clients Modified Files: TestRequest.java Log Message: Upated to work with new data instance version moby-live/Java/src/Clients TestRequest.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/TestRequest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/Clients/TestRequest.java 2005/05/12 05:22:27 1.1 +++ /home/repository/moby/moby-live/Java/src/Clients/TestRequest.java 2005/07/22 20:59:05 1.2 @@ -10,9 +10,7 @@ import org.biomoby.client.MobyRequest; import org.biomoby.shared.Central; import org.biomoby.shared.MobyService; -import org.biomoby.shared.data.MobyDataInstance; -import org.biomoby.shared.data.MobyDataObject; -import org.biomoby.shared.data.MobyDataObjectSet; +import org.biomoby.shared.data.*; import java.util.Iterator; import java.util.Vector; @@ -57,27 +55,18 @@ mr.setDebugMode(true); mr.setService(validServices[0]); mr.setInput(input); // use convenient anonymous single arg service parameterization - java.util.Vector output = mr.invokeService(); - - String c = ""; - Iterator responses = output.iterator(); + MobyContentInstance responses = mr.invokeService(); // Process responses // The service invocation may have had many requests, there is a response // object for each request - while(responses.hasNext()){ - - Object o = responses.next(); - System.err.println("responses vector slot is a " + o.getClass().getName()); - if(o instanceof Object[]){ - System.err.println("responses vector slot is an array"); - } - MobyDataInstance[] responseObjects = (MobyDataInstance[]) o; + Iterator i = responses.keySet().iterator(); + while(i.hasNext()){ + Vector responseObjects = (Vector) responses.get(i.next()); // The response for a request may have many objects - for(int k = 0; k < responseObjects.length; k++){ - //MobyDataInstance responseObject = responseObjects[k]; - Object responseObject = responseObjects[k]; + for(int k = 0; k < responseObjects.size(); k++){ + Object responseObject = responseObjects.elementAt(k); // The response objects may either be simple data, or data sets if(responseObject instanceof MobyDataObject){ System.out.println("Plain simple instance is "+((MobyDataInstance)responseObject).toXML()); From mwilkinson at pub.open-bio.org Fri Jul 22 16:18:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 17:55:34 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222018.j6MKISjV001505@pub.open-bio.org> mwilkinson Fri Jul 22 16:18:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1486/MOBY Modified Files: Central.pm Log Message: various queries not being sent to the adaptor moby-live/Perl/MOBY Central.pm,1.170,1.171 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.170 retrieving revision 1.171 diff -u -r1.170 -r1.171 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:15:48 1.170 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:18:28 1.171 @@ -3462,7 +3462,7 @@ $output .= "\t\n"; $output .= "\t\n"; - $result = query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); + $result = $adaptor->query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); foreach my $row (@$result) { @@ -3483,7 +3483,7 @@ $output .= "\t\t\n"; } - $result = query_collection_output({service_instance_id => $_}); + $result = $adaptor->query_collection_output({service_instance_id => $_}); foreach my $row (@$result) { my $collid = $row->{collection_output_id}; From mwilkinson at pub.open-bio.org Fri Jul 22 16:47:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 17:55:35 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222047.j6MKlBoZ001767@pub.open-bio.org> mwilkinson Fri Jul 22 16:47:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1748/MOBY Modified Files: Central.pm Log Message: wrong column name for query moby-live/Perl/MOBY Central.pm,1.173,1.174 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.173 retrieving revision 1.174 diff -u -r1.173 -r1.174 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:29:11 1.173 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:47:10 1.174 @@ -759,7 +759,7 @@ return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); - my $result = $adaptor->query_service({service_type_uri => $existingURI}); + my $result = $adaptor->query_service({service_lsid => $existingURI}); my $row = shift(@$result); my $id = $row->{service_instance_id}; From mwilkinson at pub.open-bio.org Fri Jul 22 17:56:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 18:43:40 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222156.j6MLuZ3k001982@pub.open-bio.org> mwilkinson Fri Jul 22 17:56:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1963/MOBY Modified Files: Central.pm Log Message: all original tests now pass. findService was returning service descriptions with extra whitespace. Fixed that moby-live/Perl/MOBY Central.pm,1.174,1.175 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.174 retrieving revision 1.175 diff -u -r1.174 -r1.175 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:47:10 1.174 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 21:56:35 1.175 @@ -3397,7 +3397,7 @@ $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; $output .= "\t$category\n"; - $output .= "\t\n$desc\n\t\n"; + $output .= "\t\n"; $output .= "\t$email\n"; $output .= "\t$signatureURL\n"; $output .= "\t$url\n"; From mwilkinson at pub.open-bio.org Fri Jul 22 18:57:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 19:44:33 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222257.j6MMvSXp002203@pub.open-bio.org> mwilkinson Fri Jul 22 18:57:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv2184/MOBY/Client Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined moby-live/Perl/MOBY/Client Central.pm,1.99,1.100 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.99 retrieving revision 1.100 diff -u -r1.99 -r1.100 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 22:54:10 1.99 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 22:57:28 1.100 @@ -929,19 +929,17 @@ $message .= "\n"; while ( my ( $param, $desc ) = each %SEC ) { unless ( ( ref($desc) ) =~ /hash/i ) { - return $self->errorRegXML( -"invalid structure of secondary article $param; expected hashref of limitations" + return $self->errorRegXML( "invalid structure of secondary article $param; expected hashref of limitations" ); } my %data = %{$desc}; - my $default = $data{default} || ""; - my $max = $data{max} || ""; - my $min = $data{min} || ""; - my $datatype = $data{datatype} || ""; - my $enums = $data{enum} || []; + my $default = defined($data{default}) || ""; + my $max = defined($data{max}) || ""; + my $min = defined($data{min}) || ""; + my $datatype = defined($data{datatype}) || ""; + my $enums = defined($data{enum}) || []; unless ($datatype) { - return $self->errorRegXML( -"a secondaryArticle must contain at least a datatype value in secondary article $param" + return $self->errorRegXML("a secondaryArticle must contain at least a datatype value in secondary article $param" ); } unless ( ( $datatype =~ /Integer/ ) @@ -949,13 +947,11 @@ || ( $datatype =~ /String/ ) || ( $datatype =~ /DateTime/ ) ) { - return $self->errorRegXML( -"a secondaryArticle must have a datatype of Integer, Float, String, or DateTime" + return $self->errorRegXML("a secondaryArticle must have a datatype of Integer, Float, String, or DateTime" ); } unless ( ( ref($enums) ) =~ /array/i ) { - return $self->errorRegXML( -"invalid structure of enum limits in secondary article $param; expected arrayref" + return $self->errorRegXML("invalid structure of enum limits in secondary article $param; expected arrayref" ); } my @enums = @{$enums}; From mwilkinson at pub.open-bio.org Fri Jul 22 19:05:04 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 19:52:09 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222305.j6MN54tJ002278@pub.open-bio.org> mwilkinson Fri Jul 22 19:05:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv2259/MOBY/Client Modified Files: Central.pm Log Message: oops... got a little exuberant there moby-live/Perl/MOBY/Client Central.pm,1.100,1.101 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.100 retrieving revision 1.101 diff -u -r1.100 -r1.101 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 22:57:28 1.100 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 23:05:04 1.101 @@ -933,11 +933,11 @@ ); } my %data = %{$desc}; - my $default = defined($data{default}) || ""; - my $max = defined($data{max}) || ""; - my $min = defined($data{min}) || ""; - my $datatype = defined($data{datatype}) || ""; - my $enums = defined($data{enum}) || []; + my $default = defined($data{default})?$data{default}:""; + my $max = defined($data{max})?$data{max}:""; + my $min = defined($data{min})?$data{min}:""; + my $datatype = $data{datatype} || ""; + my $enums = $data{enum} || []; unless ($datatype) { return $self->errorRegXML("a secondaryArticle must contain at least a datatype value in secondary article $param" ); From mwilkinson at pub.open-bio.org Fri Jul 22 19:11:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 19:58:55 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222311.j6MNBoMl002361@pub.open-bio.org> mwilkinson Fri Jul 22 19:11:50 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv2342/MOBY Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined. Smae problem on the server side moby-live/Perl/MOBY Central.pm,1.175,1.176 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.175 retrieving revision 1.176 diff -u -r1.175 -r1.176 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 21:56:35 1.175 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:11:49 1.176 @@ -3519,11 +3519,11 @@ my $datatype = $row->{datatype}; my $article_name = $row->{article_name}; - $article_name ||= ""; - $datatype ||= ""; - $default_value ||= ""; - $maximum_value ||= ""; - $minimum_value ||= ""; + defined($article_name) ||= ""; + defined($datatype) ||= ""; + defined($default_value) ||= ""; + defined($maximum_value) ||= ""; + defined($minimum_value) ||= ""; $output .= "\t\t\t\n"; $output .= "\t\t\t\t$datatype\n"; $output .= "\t\t\t\t$default_value\n"; From mwilkinson at pub.open-bio.org Fri Jul 22 19:15:55 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 20:03:46 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222315.j6MNFtbV002429@pub.open-bio.org> mwilkinson Fri Jul 22 19:15:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv2410/MOBY Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined. Smae problem on the server side moby-live/Perl/MOBY Central.pm,1.176,1.177 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.176 retrieving revision 1.177 diff -u -r1.176 -r1.177 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:11:49 1.176 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:15:54 1.177 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::Client::Central; +#use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -3511,19 +3511,14 @@ $output .= "\t\n"; $result = $adaptor->query_secondary_input({service_instance_id => $_}); foreach my $row (@$result) - { - my $default_value = $row->{default_value}; - my $maximum_value = $row->{maximum_value}; - my $minimum_value = $row->{minimum_value}; - my $enum_value = $row->{enum_value}; - my $datatype = $row->{datatype}; - my $article_name = $row->{article_name}; - - defined($article_name) ||= ""; - defined($datatype) ||= ""; - defined($default_value) ||= ""; - defined($maximum_value) ||= ""; - defined($minimum_value) ||= ""; + { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ""; + $default_value = $row->{default_value}; + $maximum_value = $row->{maximum_value}; + $minimum_value = $row->{minimum_value}; + $enum_value = $row->{enum_value}; + $datatype = $row->{datatype}; + $article_name = $row->{article_name}; + $output .= "\t\t\t\n"; $output .= "\t\t\t\t$datatype\n"; $output .= "\t\t\t\t$default_value\n"; From mwilkinson at pub.open-bio.org Fri Jul 22 19:20:27 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 20:08:30 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222320.j6MNKREs002500@pub.open-bio.org> mwilkinson Fri Jul 22 19:20:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv2481/MOBY Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined. Smae problem on the server side moby-live/Perl/MOBY Central.pm,1.177,1.178 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.177 retrieving revision 1.178 diff -u -r1.177 -r1.178 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:15:54 1.177 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:20:26 1.178 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -#use MOBY::Client::Central; +use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -3511,7 +3511,7 @@ $output .= "\t\n"; $result = $adaptor->query_secondary_input({service_instance_id => $_}); foreach my $row (@$result) - { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ""; + { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ("","","","","",""); $default_value = $row->{default_value}; $maximum_value = $row->{maximum_value}; $minimum_value = $row->{minimum_value}; From mwilkinson at pub.open-bio.org Fri Jul 22 19:23:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 20:10:59 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222323.j6MNNQOu002568@pub.open-bio.org> mwilkinson Fri Jul 22 19:23:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv2549/t Modified Files: Client-Central.t Log Message: added about 50 new tests. now we're really getting tight. moby-live/Perl/t Client-Central.t,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/08 19:22:21 1.8 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:23:26 1.9 @@ -4,17 +4,19 @@ ######################### # change 'tests => 1' to 'tests => last_test_to_print'; - -use Test::More tests => 14; # perldoc Test::More for details +#use SOAP::Lite +trace; +use Test::More tests => 54; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; + + # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', - URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} + mobycentral => { URL => 'http://localhost/cgi-bin/MOBY-Central.pl', + URI => 'http://localhost/MOBY/Central'} } ); @@ -23,6 +25,8 @@ my %TestRegistry ; # to keep track of registry id's for the various tests + + ################## MOBY Registration Tests ################# # Test 3 @@ -40,6 +44,9 @@ ( ok(!$r->success,"Object registration correctly failed") or diag("Object registration failure: ".$r->message)); + + + # Test 4 $r = $C->registerObjectClass(objectType => "TotalCrap", description => "a human-readable description of the object", @@ -55,11 +62,17 @@ or diag("Object registration failure: ".$r->message)); + + + # Test 5 $r = $C->deregisterObjectClass(objectType => "TotalCrap"); ( ok($r->success,"Object deregistration successful")) or diag("Object deregistration failure: ".$r->message) ; + + + # Test 6 (identical to #4 $r = $C->registerObjectClass(objectType => "TotalCrap", description => "a human-readable description of the object", @@ -75,7 +88,10 @@ or diag("Object registration failure: ".$r->message)); -# Test 6 + + + +# Test 7 $r = $C->registerNamespace( namespaceType =>'UglyNamespace', authURI => 'your.authority.URI', @@ -85,7 +101,9 @@ ) or diag("Name space registration failure: ".$r->message) ; -# Test 7 + + +# Test 8 $r = $C->registerServiceType(serviceType => "CrappyService", description => "a human-readable description of the service", contactEmail => 'your@email.address', @@ -96,7 +114,10 @@ ( ok($r->success,"Service Type registration successful") ) or diag("Service Type registration failure: ".$r->message) ; -# Test 8 # should fail + + + +# Test 9 # should fail $r = $C->registerService( serviceName => "myfirstservice", serviceType => "Retrieval", @@ -119,10 +140,12 @@ min => -10, enum => [-10, 10, 0]}}); -( ok(!$r->success,"Service registration correctly failed") +( ok(!$r->success,"Service registration correctly failed testing secondary datatype format") ) or diag("Service registration failure: ".$r->message) ; -# Test 9 + + +# Test 10 $r = $C->registerService( serviceName => "myfirstservice", serviceType => "Retrieval", @@ -148,8 +171,75 @@ ( ok($r->success,"Service registration successful") ) or diag("Service registration failure: ".$r->message) ; +# test 11 - find by auth & name +($si, $r) = $C->findService( + serviceName => "myfirstservice", + authURI => "test.suite.com"); +( is($r, undef, "Service discovery successful") +) or diag("Service discovery failure") ; + +isa_ok($si, 'ARRAY') or diag("findService didn't return an array ref"); +is(scalar(@$si),1) or diag("findService found too many services"); +$SI = shift @$si; +print STDERR "$SI"; +isa_ok($SI, 'MOBY::Client::ServiceInstance') or diag("findService didn't return a MOBY::Client::ServceInstance"); +isa_ok($SI->input, ARRAY) or diag ("ServiceInstance object input is not a listref"); +isa_ok($SI->output, ARRAY) or diag ("ServiceInstance object output is not a listref"); +is($SI->name, "myfirstservice") or diag("servicename wrong"); +is($SI->authoritative, 0) or diag("service reported to be incorrectly authoritative"); +is($SI->authority, "test.suite.com") or diag("authURI incorrect"); +is($SI->type, "Retrieval") or diag("service type incorrect"); +is($SI->description, "this is my first service") or diag("service description wrong"); +is($SI->URL, "http://illuminae/cgi-bin/service.pl") or diag("service URL incorrect"); +is($SI->contactEmail, 'your@mail.address') or diag("contact email incorrect"); +is($SI->category, "moby") or diag("service category incorrect"); + +@ins = @{$SI->input}; +@outs = @{$SI->output}; +@secs = @{$SI->secondary}; +is(scalar(@ins), 1) or diag("incorrect number of inputs in servce instance"); +is(scalar(@outs), 1) or diag("incorrect number of outputs in servce instance"); +is(scalar(@secs), 1) or diag("incorrect number of secodary in servce instance"); + +$in = shift @ins; +$out = shift @outs; +$sec = shift @secs; + +isa_ok($in, 'MOBY::Client::SimpleArticle') or diag("->inputs did not return a MOBY::simple_input object"); +isa_ok($out, 'MOBY::Client::SimpleArticle') or diag("->outputs did not return a MOBY::simple_outputobject"); +isa_ok($sec, 'MOBY::Client::SecondaryArticle') or diag("->secondarues did not return a MOBY::secondary_input object"); + +is($in->objectType, "Object") or diag("simple input type reported incorrectly"); +is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly"); +isa_ok($in->namespaces, 'ARRAY') or diag("simple input namespaces not returned as an arrayref"); +@ns = @{$in->namespaces}; +is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace"); + +is($out->objectType, "String") or diag("simple output type reported incorrectly"); +is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly"); +isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref"); +@ns = @{$out->namespaces}; +is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace"); + +is($sec->articleName, 'parametername1') or diag("secondary article reporting wrong article name"); +is($sec->datatype, 'Integer') or diag("secondary article reporting wrong datatype"); +is($sec->default,"0") or diag("secondary article reporting wrong default"); +is($sec->max,"10") or diag("secondary article reporting wrong max"); +is($sec->min,"-10") or diag("secondary article reporting wrong min"); +isa_ok($sec->enum, 'ARRAY') or diag("enum is not returning an array ref"); +@enum = @{$sec->enum}; +is(scalar(@enum), 3) or diag("enum not returning correct number of elements"); +$enum = join "|",@enum; +$enum = "|".$enum."|"; +is($enum =~/\|-10\|/, 1) or diag("enum element missing"); +is($enum =~/\|10\|/, 1) or diag("enum element missing"); +is($enum =~/\|0\|/, 1) or diag("enum element missing"); -# Test 10 +# Test 12 $r = $C->deregisterService( serviceName => "myfirstservice", @@ -159,136 +249,29 @@ ) or diag("Service deregistration failure: ".$r->message) ; -# Test 11 + + + +# Test 12 $r = $C->deregisterObjectClass(objectType => "TotalCrap"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; -# Test 12 + + +# Test 13 $r = $C->deregisterServiceType(serviceType => "CrappyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; -# Test 13 + + + +# Test 44 $r = $C->deregisterNamespace(namespaceType =>'UglyNamespace'); ( ok($r->success,"namespace deregistration successful") ) or diag("namespace deregistration failure: ".$r->message) ; -################### MOBY Central Search Tests ################# -# -#my @service ; -# -## Tests 14,15: locateServiceByOutput with output 'Object' and full_objects + full_services -#@service = $C->locateServiceByOutput( -# objectType => "Object", -# fullObjects => 1, -# fullServices => 1, -#) ; -# -#SKIP: { -# skip "locateServiceByOutput w/full object & services". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 16,17: Testing locateServiceByOutput with output "Object" and full_services only -#@service = $C->locateServiceByOutput( -# objectType => "Object", -# fullObjects => 0, -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByOutput w/ output 'Object' and full services only ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 18,19: Testing locateServiceByInput with input -## 'Object' => Genbank/GI and full_objects + full_services -#@service = $C->locateServiceByInput( -# input => {"Sequence" => ["Genbank/GI"]}, -# fullObjects => 1, -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByInput w/input 'Object' => Genbank/GI ". -# "and full_objects + full_services ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 20,21: Testing locateServiceByInput with input -## 'Object' => Genbank/GI and full_services only -#@service = $C->locateServiceByInput( -# input => {"Object" => ["Genbank/GI"]}, -# fullObjects => 0, -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByInput w/input 'Object' => Genbank/GI ". -# "and full_services ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 22,23: Testing locateServiceByType with type 'Retrieve' + full_services -#@service = $C->locateServiceByType( -# serviceType => "Retrieve", -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByType w/type 'Retrieve' and full_services ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -################### MOBY Deregistration Tests ################# -# -## Test 17 -#SKIP: { -# skip "Skipping test DeregisterService since service registration failed", -# 1 unless(exists($TestRegistry{'Service'})) ; -# -# $r = $C->deregisterService( serviceID => $TestRegistry{'Service'} ); -# ok(!$r->success,"Service ID#".$r->registration_id." deregistration successful") -# or diag("Service ID#",$TestRegistry{'Service'}, -# "deregistration failure: ".$r->message) ; -#} -# -## Test 18 -#SKIP: { -# skip "Skipping test DeregisterNamespace since name space registration failed", -# 1 unless(exists($TestRegistry{'NameSpace'})) ; -# -# $r = $C->deregisterNamespace( namespaceAcc => $TestRegistry{'NameSpace'} ); -# ok(!$r->success,"Name space ID#".$r->registration_id." deregistration successful") -# or diag("Name space ID#",$TestRegistry{'NameSpace'}, -# "deregistration failure: ".$r->message) ; -#} -# -## Test 19 -#SKIP: { -# skip "Skipping test DeregisterServiceType since service registration failed", -# 1 unless(exists($TestRegistry{'ServiceType'})) ; -# -# $r = $C->deregisterServiceType( serviceID => $TestRegistry{'ServiceType'} ); -# ok(!$r->success,"Service type ID#".$r->registration_id." deregistration successful") -# or diag("Service type ID#",$TestRegistry{'ServiceType'}, -# "deregistration failure: ".$r->message) ; -#} -# -## Test 20 -#SKIP: { -# skip "Skipping test DeregisterObject since initial object registration failed", -# 1 unless(exists($TestRegistry{'Object'})) ; -# -# $r = $C->deregisterObject( serviceID => $TestRegistry{'Object'} ); -# ok(!$r->success,"Object ID#".$r->registration_id." deregistration successful") -# or diag("Object ID#",$TestRegistry{'Object'}, -# "deregistration failure: ".$r->message) ; -#} + + + From mwilkinson at pub.open-bio.org Fri Jul 22 19:25:06 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 22 20:12:10 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222325.j6MNP6CZ002625@pub.open-bio.org> mwilkinson Fri Jul 22 19:25:06 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv2606/t Modified Files: Client-Central.t Log Message: oops... committed the new tests without changnig the URl back to teh public address. moby-live/Perl/t Client-Central.t,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:23:26 1.9 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:25:06 1.10 @@ -15,8 +15,8 @@ # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://localhost/cgi-bin/MOBY-Central.pl', - URI => 'http://localhost/MOBY/Central'} + mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/MOBY-Central.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} } ); From mwilkinson at pub.open-bio.org Mon Jul 25 13:23:36 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 14:10:31 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251723.j6PHNaRo020358@pub.open-bio.org> mwilkinson Mon Jul 25 13:23:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20339/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: starting to document the adaptor layer moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/18 16:53:49 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:23:35 1.5 @@ -1,8 +1,85 @@ +#$Id$ package MOBY::Adaptor::moby::queryapi; use strict; use Carp; use vars qw($AUTOLOAD); + +=head1 NAME + +MOBY::Adaptor::moby::queryapi - An interface definition for MOBY Central underlying data-stores + +=cut + +=head1 SYNOPSIS + + use MOBY::Adaptor::moby::queryapi::mysql # implements this interface def + my $m = MOBY::Adaptor::moby::queryapi::mysql->new( + username => 'user', + password => 'pass', + dbname => 'mobycentral', + port => '3306', + sourcetype => 'DBD::mysql'); + my $objectid = $m->insert_object( + {object_type => "MyObject"}, + {description => "this represents a foo bar"}, + {authority => "www.example.org"}, + {contact_email, 'me@example.org'}) + + +=cut + +=head1 DESCRIPTION + +This is an interface definition. There is NO implementation in this module +with the exception that certain calls to required parameters have get/setter +functions in this module (that can be overridden) + +=head1 AUTHORS + +Mark Wilkinson markw_at_ illuminae dot com +Dennis Wang oikisai _at_ hotmail dot com +BioMOBY Project: http://www.biomoby.org + + +=cut + +=head1 METHODS + + +=head2 new + + Title : new + Usage : my $MOBY = MOBY::Client::Central->new(Registries => \%regrefs) + Function : connect to one or more MOBY-Central + registries for searching + Returns : MOBY::Client::Central object + Args : Registries - optional. + Notes : Each registry must have a different + + +=cut + + +sub new { + my ($caller, %args) = @_; + my $caller_is_obj = ref($caller); + my $class = $caller_is_obj || $caller; + + my $self = bless {}, $class; + + foreach my $attrname ( $self->_standard_keys_a ) { + if (exists $args{$attrname} && defined $args{$attrname}) { + $self->{$attrname} = $args{$attrname} } + elsif ($caller_is_obj) { + $self->{$attrname} = $caller->{$attrname} } + else { + $self->{$attrname} = $self->_default_for($attrname) } + } + return $self; +} + + # Modified by Dennis { @@ -14,10 +91,11 @@ ( username => [undef, 'read/write'], password => [undef, 'read/write'], - dbname => [undef, 'read/write'], - port => [undef, 'read/write'], - proxy => [undef, 'read/write'], - url => [undef, 'read/write'], + dbname => [undef, 'read/write'], + port => [undef, 'read/write'], + proxy => [undef, 'read/write'], + url => [undef, 'read/write'], + driver => [undef, 'read/write'], ); #_____________________________________________________________ @@ -41,46 +119,155 @@ keys %_attr_data; } +=head2 username + + Title : username + Usage : my $un = $API->username($arg) + Function : get/set username (if required) + Returns : String (username) + Args : String (username) - optional. + +=cut + + sub username { my ($self, $arg) = @_; $self->{username} = $arg if defined $arg; return $self->{username}; } + +=head2 password + + Title : password + Usage : my $un = $API->password($arg) + Function : get/set password (if required) + Returns : String (password) + Args : String (password) - optional. + +=cut + sub password { my ($self, $arg) = @_; $self->{password} = $arg if defined $arg; return $self->{password}; } + +=head2 dbname + + Title : dbname + Usage : my $un = $API->dbname($arg) + Function : get/set dbname (if required) + Returns : String (dbname) + Args : String (dbname) - optional. + +=cut + sub dbname { my ($self, $arg) = @_; $self->{dbname} = $arg if defined $arg; return $self->{dbname}; } + +=head2 port + + Title : port + Usage : my $un = $API->port($arg) + Function : get/set port (if required) + Returns : String (port) + Args : String (port) - optional. + +=cut + + sub port { my ($self, $arg) = @_; $self->{port} = $arg if defined $arg; return $self->{port}; } + +=head2 proxy + + Title : proxy + Usage : my $un = $API->proxy($arg) + Function : get/set proxy (if required) + Returns : String (proxy) + Args : String (proxy) - optional. + +=cut + sub proxy { my ($self, $arg) = @_; $self->{proxy} = $arg if defined $arg; return $self->{proxy}; } + + +=head2 sourcetype + + Title : sourcetype + Usage : my $un = $API->sourcetype($arg) + Function : get/set string name of sourcetype (e.g. mySQL) + Returns : String (sourcetype) + Args : String (sourcetype) - optional. + +=cut + sub sourcetype { my ($self, $arg) = @_; $self->{sourcetype} = $arg if defined $arg; return $self->{sourcetype}; } + + +=head2 driver + + Title : driver + Usage : my $un = $API->driver($arg) + Function : get/set string name of driver module (e.g. DBD::mySQL) + Returns : String (driver) + Args : String (driver) - optional. + +=cut + + sub driver { + my ($self, $arg) = @_; + $self->{driver} = $arg if defined $arg; + return $self->{driver}; + } + + +=head2 url + + Title : url + Usage : my $un = $API->url($arg) + Function : get/set url (if required) + Returns : String (url) + Args : String (url) - optional. + +=cut + sub url { my ($self, $arg) = @_; $self->{url} = $arg if defined $arg; return $self->{url}; } + sub _implementation { my ($self, $arg) = @_; $self->{'_implementation'} = $arg if defined $arg; return $self->{'_implementation'}; } + +=head2 dbh + + Title : dbh + Usage : my $un = $API->dbh($arg) + Function : get/set database handle (if required) + Returns : Database handle in whatever object is appropriate for sourcetype + Args : Database handle in whatever object is appropriate for sourcetype + +=cut + sub dbh { my ($self, $arg) = @_; $self->{dbh} = $arg if defined $arg; @@ -89,24 +276,6 @@ } -sub new { - my ($caller, %args) = @_; - my $caller_is_obj = ref($caller); - my $class = $caller_is_obj || $caller; - - my $self = bless {}, $class; - - foreach my $attrname ( $self->_standard_keys_a ) { - if (exists $args{$attrname} && defined $args{$attrname}) { - $self->{$attrname} = $args{$attrname} } - elsif ($caller_is_obj) { - $self->{$attrname} = $caller->{$attrname} } - else { - $self->{$attrname} = $self->_default_for($attrname) } - } - return $self; - -} # general query subroutine # parameters: @@ -114,6 +283,18 @@ # bind_values - an array of values to be bound to the parameters # returns: # resultset - reference to an array containing ARRAY references + +=head2 dbh + + Title : general_query + Usage : my $un = $API->general_query(@args) + Function : Execute a generic query on an underlying SQL-based data source + Returns : array of array-refs representing resulting rows + Args : String - sql statement + [String] - a set of bind values + +=cut + sub general_query{ die "general_query not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Mon Jul 25 13:50:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 14:36:51 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251750.j6PHo2qs020462@pub.open-bio.org> mwilkinson Mon Jul 25 13:50:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY Modified Files: Central.pm collection_input.pm Log Message: changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash moby-live/Perl/MOBY Central.pm,1.178,1.179 collection_input.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.178 retrieving revision 1.179 diff -u -r1.178 -r1.179 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:20:26 1.178 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 17:50:02 1.179 @@ -3100,120 +3100,120 @@ return ""; } -=head2 _traverseServiceDAG - - Title : _traverseServiceDAG - Usage : @valid = $MOBY->_traverseServiceDAG($dbh, $serviceType, $sth_hash) - Function : starting from $serviceType, find all child services non-redundantly - by traversing the DAG. - Returns : list of Service.id database entries. - Args : none - -=cut - -sub _traverseServiceDAG { - - $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - - my ( $dbh, $serviceType, $sth_hash ) = @_; - my %sth = %{$sth_hash}; - my %ServiceIDs; - - my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); - my $row = shift(@$result); - my ($root_id) = @$row; - return undef unless $root_id; - -# we have to do a traversal of the DAG here to get all child nodes... -# this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... - $ServiceIDs{$root_id} = "untested"; # mark the one in-hand as untested - while ( grep /untested/, ( values %ServiceIDs ) ) - { # now, while there are untested services in our list... - foreach my $service ( keys %ServiceIDs ) - { # start parsing through the list - next - if ( $ServiceIDs{$service} eq "tested" ) - ; # if it has been tested already then move on - - my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); - # execute the query for child nodes - $ServiceIDs{$service} = "tested"; # mark it as tested - foreach my $row (@$result) - { # now get each of the child nodes - my $new = @$row; - next - if ( defined $ServiceIDs{$new} ) - ; # if we have already heard about it then move on - $ServiceIDs{$new} = "untested" - ; #otherwise mark it as untested, and start all over again - } - } - } - return keys %ServiceIDs; -} - -=head2 _traverseObjectDAG - - Title : _traverseObjectDAG - Usage : @valid = $MOBY->_traverseObjectDAG( $dbh, $objectType, $sth_hash, "p|c") - Function : from $objectType, find all parent/child objects non-redundantly - by traversing the DAG. - Returns : list of Object.id database entries. - Args : objectType (by name), $statement ahngles, "p" parent, or "c" child - -=cut - -sub _traverseObjectDAG { - $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - - my ( $dbh, $objectType, $sth_hash, $dir ) = @_; - my %sth = %{$sth_hash}; - my %ObjectIDs; - - my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); - - my $row = shift (@$result); - my ($root_id) = @$row; - return undef unless $root_id; - -# we have to do a traversal of the DAG here to get all child nodes... -# this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... - $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested - while ( grep /untested/, ( values %ObjectIDs ) ) - { # now, while there are untested services in our list... - foreach my $object ( keys %ObjectIDs ) - { # start parsing through the list - next - if ( $ObjectIDs{$object} eq "tested" ) - ; # if it has been tested already then move on - - my $result; - if ( $dir eq "p" ) { - $debug && &_LOG("getting parents"); - $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); - } - else { - $debug && &_LOG("getting children"); - $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); - } - # execute the query for child nodes +#=head2 _traverseServiceDAG +# +# Title : _traverseServiceDAG +# Usage : @valid = $MOBY->_traverseServiceDAG($dbh, $serviceType, $sth_hash) +# Function : starting from $serviceType, find all child services non-redundantly +# by traversing the DAG. +# Returns : list of Service.id database entries. +# Args : none +# +#=cut +# +#sub _traverseServiceDAG { +# +# $CONFIG ||= MOBY::Config->new; # exported by Config.pm +# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); +# +# my ( $dbh, $serviceType, $sth_hash ) = @_; +# my %sth = %{$sth_hash}; +# my %ServiceIDs; +# +# my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); +# my $row = shift(@$result); +# my ($root_id) = @$row; +# return undef unless $root_id; +# +## we have to do a traversal of the DAG here to get all child nodes... +## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... +# $ServiceIDs{$root_id} = "untested"; # mark the one in-hand as untested +# while ( grep /untested/, ( values %ServiceIDs ) ) +# { # now, while there are untested services in our list... +# foreach my $service ( keys %ServiceIDs ) +# { # start parsing through the list +# next +# if ( $ServiceIDs{$service} eq "tested" ) +# ; # if it has been tested already then move on +# +# my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); +# # execute the query for child nodes +# $ServiceIDs{$service} = "tested"; # mark it as tested +# foreach my $row (@$result) +# { # now get each of the child nodes +# my $new = @$row; +# next +# if ( defined $ServiceIDs{$new} ) +# ; # if we have already heard about it then move on +# $ServiceIDs{$new} = "untested" +# ; #otherwise mark it as untested, and start all over again +# } +# } +# } +# return keys %ServiceIDs; +#} - $ObjectIDs{$object} = "tested"; # mark it as tested - foreach my $row (@$result) - { # now get each of the child nodes - my $new = @$row; - next - if ( defined $ObjectIDs{$new} ) - ; # if we have already heard about it then move on - $ObjectIDs{$new} = "untested" - ; #otherwise mark it as untested, and start all over again - } - } - } - return keys %ObjectIDs; -} +#=head2 _traverseObjectDAG +# +# Title : _traverseObjectDAG +# Usage : @valid = $MOBY->_traverseObjectDAG( $dbh, $objectType, $sth_hash, "p|c") +# Function : from $objectType, find all parent/child objects non-redundantly +# by traversing the DAG. +# Returns : list of Object.id database entries. +# Args : objectType (by name), $statement ahngles, "p" parent, or "c" child +# +#=cut +# +#sub _traverseObjectDAG { +# $CONFIG ||= MOBY::Config->new; # exported by Config.pm +# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); +# +# my ( $dbh, $objectType, $sth_hash, $dir ) = @_; +# my %sth = %{$sth_hash}; +# my %ObjectIDs; +# +# my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); +# +# my $row = shift (@$result); +# my ($root_id) = @$row; +# return undef unless $root_id; +# +## we have to do a traversal of the DAG here to get all child nodes... +## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... +# $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested +# while ( grep /untested/, ( values %ObjectIDs ) ) +# { # now, while there are untested services in our list... +# foreach my $object ( keys %ObjectIDs ) +# { # start parsing through the list +# next +# if ( $ObjectIDs{$object} eq "tested" ) +# ; # if it has been tested already then move on +# +# my $result; +# if ( $dir eq "p" ) { +# $debug && &_LOG("getting parents"); +# $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); +# } +# else { +# $debug && &_LOG("getting children"); +# $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); +# } +# # execute the query for child nodes +# +# $ObjectIDs{$object} = "tested"; # mark it as tested +# foreach my $row (@$result) +# { # now get each of the child nodes +# my $new = @$row; +# next +# if ( defined $ObjectIDs{$new} ) +# ; # if we have already heard about it then move on +# $ObjectIDs{$new} = "untested" +# ; #otherwise mark it as untested, and start all over again +# } +# } +# } +# return keys %ObjectIDs; +#} #Eddie - converted sub _nodeTextContent { =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/18 16:53:03 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/25 17:50:02 1.5 @@ -94,9 +94,8 @@ my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - my $id = $adaptor->insert_collection_input( - {service_instance => $self->service_instance_id}, - {article_name => $self->article_name} ); + my $id = $adaptor->insert_collection_input(service_instance => $self->service_instance_id, + article_name => $self->article_name); return $id; } From mwilkinson at pub.open-bio.org Mon Jul 25 13:50:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 14:36:53 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251750.j6PHo2nW020481@pub.open-bio.org> mwilkinson Mon Jul 25 13:50:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:23:35 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:50:02 1.6 @@ -277,28 +277,7 @@ } -# general query subroutine -# parameters: -# statement - a string SQL statement -# bind_values - an array of values to be bound to the parameters -# returns: -# resultset - reference to an array containing ARRAY references - -=head2 dbh - - Title : general_query - Usage : my $un = $API->general_query(@args) - Function : Execute a generic query on an underlying SQL-based data source - Returns : array of array-refs representing resulting rows - Args : String - sql statement - [String] - a set of bind values -=cut - -sub general_query{ - die "general_query not implemented in adaptor\n"; -} - # # collection_input table functions # @@ -308,14 +287,6 @@ sub insert_collection_input { die "insert_collection_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} } sub delete_collection_input{ From mwilkinson at pub.open-bio.org Mon Jul 25 13:50:03 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 14:37:02 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251750.j6PHo3EV020501@pub.open-bio.org> mwilkinson Mon Jul 25 13:50:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.28,1.29 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 20:00:10 1.28 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 17:50:02 1.29 @@ -75,25 +75,24 @@ my $driver = $self->driver; # inherited from the adaptorI (queryapi) my $username = $self->username; my $password = $self->password; - my $port = $self->port; - my $url = $self->url; - my $dbname = $self->dbname; - - my ($dsn) = "$driver:$dbname:$url:$port"; -# print STDERR "\n\nconnectiung to $driver:$dbname:$url:$port\n\n"; - my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; + my $port = $self->port; + my $url = $self->url; + my $dbname = $self->dbname; + + my ($dsn) = "$driver:$dbname:$url:$port"; + my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; - ############################################################## - unless ($dbh) { - print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; - return undef; - } - + ############################################################## + unless ($dbh) { + print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; + return undef; + } + $self->dbh($dbh); - ############################################################# + ############################################################# - return undef unless $self->dbh; + return undef unless $self->dbh; return $self; } @@ -162,29 +161,23 @@ } } } - -# general query subroutine -# parameters: -# statement - a string SQL statement -# bind_values - an array of values to be bound to the parameters -# returns: -# resultset - reference to an array containing ARRAY references -sub general_query{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = get_value('statement', @args); - my $sth = $dbh->prepare($statement); - if (@args > 1) - { - my $bindvalues = get_value('bind_values', @args); - $sth->execute(@$bindvalues); - } - else { - $sth->execute; - } - my $result = $sth->fetchall_arrayref(); - return $result; -} +# +#sub general_query{ +# my ($self, @args) = @_; +# my $dbh = $self->dbh; +# my $statement = get_value('statement', @args); +# my $sth = $dbh->prepare($statement); +# if (@args > 1) +# { +# my $bindvalues = get_value('bind_values', @args); +# $sth->execute(@$bindvalues); +# } +# else { +# $sth->execute; +# } +# my $result = $sth->fetchall_arrayref(); +# return $result; +#} sub query_collection_input{ my ($self, @args) = @_; @@ -207,15 +200,12 @@ } sub insert_collection_input { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; -# if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # this should be dropped down into the mysql.pm module?? probably... $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", - undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); + undef, $args{'service_instance_id'},$args{'article_name'}); my $id=$self->dbh->{mysql_insertid}; return $id; -# } } sub delete_collection_input{ From mwilkinson at pub.open-bio.org Mon Jul 25 14:17:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 15:04:44 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251817.j6PIHjei020657@pub.open-bio.org> mwilkinson Mon Jul 25 14:17:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:50:02 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:17:44 1.7 @@ -281,6 +281,21 @@ # # collection_input table functions # + +=head2 query_collection_input + + Title : query_collection_input + Usage : my $un = $API->query_collection_input(%arg) + Function : get the collection input information for a given service + Args : service_lsid => String + Returns : listref of hashrefs: + [{collection_input_id => Integer + article_name => String}, ...] + one hashref for each collection that service consumes + Notes : the fact that it returns a collection_input_id is bad since this + is only useful to an SQL-based API... +=cut + sub query_collection_input{ die "query_collection_input not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Mon Jul 25 14:17:44 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 15:04:46 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251817.j6PIHioA020638@pub.open-bio.org> mwilkinson Mon Jul 25 14:17:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY Modified Files: Central.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic moby-live/Perl/MOBY Central.pm,1.179,1.180 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.179 retrieving revision 1.180 diff -u -r1.179 -r1.180 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 17:50:02 1.179 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 18:17:44 1.180 @@ -3100,120 +3100,6 @@ return ""; } -#=head2 _traverseServiceDAG -# -# Title : _traverseServiceDAG -# Usage : @valid = $MOBY->_traverseServiceDAG($dbh, $serviceType, $sth_hash) -# Function : starting from $serviceType, find all child services non-redundantly -# by traversing the DAG. -# Returns : list of Service.id database entries. -# Args : none -# -#=cut -# -#sub _traverseServiceDAG { -# -# $CONFIG ||= MOBY::Config->new; # exported by Config.pm -# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); -# -# my ( $dbh, $serviceType, $sth_hash ) = @_; -# my %sth = %{$sth_hash}; -# my %ServiceIDs; -# -# my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); -# my $row = shift(@$result); -# my ($root_id) = @$row; -# return undef unless $root_id; -# -## we have to do a traversal of the DAG here to get all child nodes... -## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... -# $ServiceIDs{$root_id} = "untested"; # mark the one in-hand as untested -# while ( grep /untested/, ( values %ServiceIDs ) ) -# { # now, while there are untested services in our list... -# foreach my $service ( keys %ServiceIDs ) -# { # start parsing through the list -# next -# if ( $ServiceIDs{$service} eq "tested" ) -# ; # if it has been tested already then move on -# -# my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); -# # execute the query for child nodes -# $ServiceIDs{$service} = "tested"; # mark it as tested -# foreach my $row (@$result) -# { # now get each of the child nodes -# my $new = @$row; -# next -# if ( defined $ServiceIDs{$new} ) -# ; # if we have already heard about it then move on -# $ServiceIDs{$new} = "untested" -# ; #otherwise mark it as untested, and start all over again -# } -# } -# } -# return keys %ServiceIDs; -#} - -#=head2 _traverseObjectDAG -# -# Title : _traverseObjectDAG -# Usage : @valid = $MOBY->_traverseObjectDAG( $dbh, $objectType, $sth_hash, "p|c") -# Function : from $objectType, find all parent/child objects non-redundantly -# by traversing the DAG. -# Returns : list of Object.id database entries. -# Args : objectType (by name), $statement ahngles, "p" parent, or "c" child -# -#=cut -# -#sub _traverseObjectDAG { -# $CONFIG ||= MOBY::Config->new; # exported by Config.pm -# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); -# -# my ( $dbh, $objectType, $sth_hash, $dir ) = @_; -# my %sth = %{$sth_hash}; -# my %ObjectIDs; -# -# my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); -# -# my $row = shift (@$result); -# my ($root_id) = @$row; -# return undef unless $root_id; -# -## we have to do a traversal of the DAG here to get all child nodes... -## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... -# $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested -# while ( grep /untested/, ( values %ObjectIDs ) ) -# { # now, while there are untested services in our list... -# foreach my $object ( keys %ObjectIDs ) -# { # start parsing through the list -# next -# if ( $ObjectIDs{$object} eq "tested" ) -# ; # if it has been tested already then move on -# -# my $result; -# if ( $dir eq "p" ) { -# $debug && &_LOG("getting parents"); -# $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); -# } -# else { -# $debug && &_LOG("getting children"); -# $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); -# } -# # execute the query for child nodes -# -# $ObjectIDs{$object} = "tested"; # mark it as tested -# foreach my $row (@$result) -# { # now get each of the child nodes -# my $new = @$row; -# next -# if ( defined $ObjectIDs{$new} ) -# ; # if we have already heard about it then move on -# $ObjectIDs{$new} = "untested" -# ; #otherwise mark it as untested, and start all over again -# } -# } -# } -# return keys %ObjectIDs; -#} #Eddie - converted sub _nodeTextContent { From mwilkinson at pub.open-bio.org Mon Jul 25 14:17:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 15:04:47 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251817.j6PIHjxi020677@pub.open-bio.org> mwilkinson Mon Jul 25 14:17:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.29,1.30 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 17:50:02 1.29 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 18:17:44 1.30 @@ -97,7 +97,7 @@ } -sub add_condition{ +sub _add_condition{ my ($statement, @params) = @_; my @bindvalues = (); my $condition = "where "; @@ -161,41 +161,18 @@ } } } -# -#sub general_query{ -# my ($self, @args) = @_; -# my $dbh = $self->dbh; -# my $statement = get_value('statement', @args); -# my $sth = $dbh->prepare($statement); -# if (@args > 1) -# { -# my $bindvalues = get_value('bind_values', @args); -# $sth->execute(@$bindvalues); -# } -# else { -# $sth->execute; -# } -# my $result = $sth->fetchall_arrayref(); -# return $result; -#} - + +# this should NOT retun a collection ID... needs more work... sub query_collection_input{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; + my $serv_lsid = $args{'service_lsid'}; my $statement = "select collection_input_id, - article_name, - service_instance_id - from collection_input "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) = add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); + article_name + from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; + my $result = do_query($dbh, $statement, [$serv_lsid]); return $result; } @@ -213,7 +190,7 @@ my $dbh = $self->dbh; my $statement = "delete from collection_input "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -239,7 +216,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -263,7 +240,7 @@ my $dbh = $self->dbh; my $statement = "delete from collection_output "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -292,7 +269,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -328,7 +305,7 @@ my $dbh = $self->dbh; my $statement = "delete from simple_input "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); if ($dbh->err){ @@ -355,7 +332,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -391,7 +368,7 @@ my $dbh = $self->dbh; my $statement = "delete from simple_output "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); if ($dbh->err){ @@ -420,7 +397,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -448,7 +425,7 @@ my $dbh = $self->dbh; my $statement = "delete from secondary_input "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -478,7 +455,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -512,7 +489,7 @@ my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........********** # ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ******************** my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -539,7 +516,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -567,7 +544,7 @@ my $statement = "delete from object_term2term "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -606,7 +583,7 @@ lsid from service_instance "; my @bindvalues; - ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); + ($statement, @bindvalues) =_add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); my $final = do_query($dbh, $statement, @bindvalues); if (@$final[0]){return 1} else {return 0} @@ -628,7 +605,7 @@ delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ - push @args, ({$k => $v}, "and"); # format for the add_condition subroutine + push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine } if ($authority_id){ push @args, ({authority_id => $authority_id}) ; @@ -650,7 +627,7 @@ lsid from service_instance "; my @bindvalues; - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); return $final; } @@ -693,7 +670,7 @@ my $dbh = $self->dbh; my $statement = "delete from service_instance "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); if ($dbh->err){ @@ -719,7 +696,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -766,7 +743,7 @@ my @bindvalues = (); if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -792,7 +769,7 @@ my $dbh = $self->dbh; my $statement = "delete from service "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -816,7 +793,7 @@ my @bindvalues = (); if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -839,7 +816,7 @@ my $dbh = $self->dbh; my $statement = "delete from service_term2term "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -869,7 +846,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -892,7 +869,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -918,7 +895,7 @@ my $dbh = $self->dbh; my $statement = "delete from namespace "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -944,7 +921,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -956,7 +933,7 @@ my $dbh = $self->dbh; my $statement = "delete from namespace_term2term "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); From dwang at pub.open-bio.org Mon Jul 25 14:20:16 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon Jul 25 15:07:14 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251820.j6PIKGvG020735@pub.open-bio.org> dwang Mon Jul 25 14:20:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20709/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added documentation for getRelationship() moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:17:44 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:20:16 1.8 @@ -595,6 +595,18 @@ die "getObjectRelationships not implemented in adaptor\n"; } +=head2 getRelationship + + Title : getRelationship + Usage : my $un = $API->general_query(@args) + Function : Execute a query for a relationship between two tables on an underlying SQL-based data source + Returns : array of array-refs representing resulting rows + Args : String - direction in the ontology (eg. 'root') + String - name of the table ontology + Integer - a bind value for lsid + String - a bind value for relationship_type + +=cut # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references sub getRelationship{ From mwilkinson at pub.open-bio.org Mon Jul 25 15:53:36 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 16:40:26 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251953.j6PJra0j021023@pub.open-bio.org> mwilkinson Mon Jul 25 15:53:36 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv20961/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic. Lots more of these to come, but committing now so that Dennis can see what I am doing moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.30,1.31 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 18:17:44 1.30 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 19:53:36 1.31 @@ -162,7 +162,17 @@ } } +sub _getSIIDFromLSID { + my ($self, $lsid) = @_; + my $dbh = $self->dbh; + my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); + $sth->execute($lsid); + my ($siid) = $sth->fetchrow_array(); + return $siid; +} + # this should NOT retun a collection ID... needs more work... +# args passed in: service_lsid sub query_collection_input{ my ($self, %args) = @_; my $dbh = $self->dbh; @@ -176,144 +186,132 @@ return $result; } +# args passed in: service_instance_lsid, article_name sub insert_collection_input { - my ($self, %args) = @_; - my $dbh = $self->dbh; - $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", - undef, $args{'service_instance_id'},$args{'article_name'}); - my $id=$self->dbh->{mysql_insertid}; - return $id; + my ($self, %args) = @_; + my $article = $args{article_name}; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", + undef, $siid, $article); + my $id=$self->dbh->{mysql_insertid}; + return $id; } +# pass in service_instance_lsid sub delete_collection_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from collection_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + my $statement = "delete from collection_input where service_instance_id = ?"; + $self->dbh->do( $statement, undef, $siid); + + if ($self->dbh->err){ + return (1, $self->dbh->errstr); + } + else{ + return 0; + } } -# query subroutine selects all columns +# pass service_instance_lsid sub query_collection_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select collection_output_id, article_name, service_instance_id - from collection_output "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + from collection_output where service_instance_id = ? "; + my $result = do_query($dbh, $statement, [$siid]); + return $result; } +# pass service_instance_lsid, article_name sub insert_collection_output { - my ($self, @args) = @_; - my $dbh = $self->dbh; -# if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # this should be dropped down into the mysql.pm module?? probably... - $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", - undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); - my $id=$self->dbh->{mysql_insertid}; - return $id; -# } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", + undef, $siid,$args{'article_name'}); + my $id=$self->dbh->{mysql_insertid}; + return $id; } +# pass argument service_instance_lsid sub delete_collection_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from collection_output "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from collection_output where service_instance_id = ?"; + my @bindvalues = (); + $dbh->do( $statement, undef, ($siid)); + + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } - +# pass service_instance_lsid sub query_simple_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - simple_input_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id - from simple_input "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + simple_input_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id + from simple_input where service_instance_id = ? and collection_input_id IS NULL"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; } - +# pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id sub insert_simple_input { - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $si = get_value('collection_input_id', @args)?undef:get_value('service_instance_id', @args); - - $dbh->do("insert into simple_input - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id) - values (?,?,?,?,?)", - undef, - (get_value('object_type_uri', @args), - get_value('namespace_type_uris', @args), - get_value('article_name', @args), -# here - $si, - get_value('collection_input_id', @args))); - my $id=$dbh->{mysql_insertid}; - return $id; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do("insert into simple_input + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id) + values (?,?,?,?,?)", + undef, + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_input_id'}); + my $id=$dbh->{mysql_insertid}; + return $id; } sub delete_simple_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from simple_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, @args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $statement = "delete from simple_input "; + my @bindvalues = (); + ($statement, @bindvalues) =_add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } sub query_simple_output{ From mwilkinson at pub.open-bio.org Mon Jul 25 15:53:36 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 16:40:28 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251953.j6PJraI8021004@pub.open-bio.org> mwilkinson Mon Jul 25 15:53:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20961/MOBY Modified Files: Central.pm collection_input.pm collection_output.pm secondary_input.pm service_instance.pm simple_input.pm simple_output.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic. Lots more of these to come, but committing now so that Dennis can see what I am doing moby-live/Perl/MOBY Central.pm,1.180,1.181 collection_input.pm,1.5,1.6 collection_output.pm,1.4,1.5 secondary_input.pm,1.6,1.7 service_instance.pm,1.24,1.25 simple_input.pm,1.6,1.7 simple_output.pm,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.180 retrieving revision 1.181 diff -u -r1.180 -r1.181 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 18:17:44 1.180 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 19:53:35 1.181 @@ -3270,7 +3270,6 @@ $desc = $1; } -#print "\n\nAFTER EXECUTE $category, $servicename, $service_type_uri, $authority_id, $desc, $authoritative\n\n"; $signatureURL ||= ""; next unless ( $servicename && $authority_id ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); @@ -3278,8 +3277,7 @@ $result = $adaptor->query_authority({authority_id => $authority_id}); $row = shift(@$result); my $authURI = $row->{authority_uri}; - $output .= -"\t\n"; + $output .= "\t\n"; $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; $output .= "\t$category\n"; @@ -3288,8 +3286,10 @@ $output .= "\t$signatureURL\n"; $output .= "\t$url\n"; $output .= "\t\n"; - - $result = $adaptor->query_simple_input({service_instance_id => $_}, 'and', {collection_input_id => undef}); + +#************FIX +#************FIX : $_ here should also be an LSID... + $result = $adaptor->query_simple_input(service_instance_lsid => $lsid); foreach my $row (@$result) { @@ -3309,8 +3309,7 @@ } $output .= "\t\t\n"; } - $result = $adaptor->query_collection_input({service_instance_id => $_}); -# $sth_collection_ins->execute($_); + $result = $adaptor->query_collection_input(service_instance_lsid => $lsid); foreach my $row (@$result) { @@ -3319,7 +3318,7 @@ $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, 'and', {collection_input_id => $collid}); + my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_input_id => $collid); foreach my $row2 (@$result2) { my $objURI = $row2->{object_type_uri}; @@ -3344,7 +3343,7 @@ $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); + $result = $adaptor->query_simple_output(service_instance_lsid => $lsid}, collection_output_id => undef); foreach my $row (@$result) { @@ -3365,14 +3364,14 @@ $output .= "\t\t\n"; } - $result = $adaptor->query_collection_output({service_instance_id => $_}); + $result = $adaptor->query_collection_output(service_instance_lsid => $lsid); foreach my $row (@$result) { my $collid = $row->{collection_output_id}; my $articlename = $row->{article_name}; $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id => $collid}); + my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_output_id => $collid); foreach my $row2 (@$result2 ) { my $objURI = $row2->{object_type_uri}; @@ -3395,7 +3394,7 @@ } $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_secondary_input({service_instance_id => $_}); + $result = $adaptor->query_secondary_input(service_instance_lsid => $_); foreach my $row (@$result) { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ("","","","","",""); $default_value = $row->{default_value}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/25 17:50:02 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/25 19:53:35 1.6 @@ -46,6 +46,7 @@ collection_input_id => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -94,7 +95,7 @@ my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - my $id = $adaptor->insert_collection_input(service_instance => $self->service_instance_id, + my $id = $adaptor->insert_collection_input(service_instance_lsid => $self->service_instance_lsid, article_name => $self->article_name); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/18 16:53:03 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/25 19:53:35 1.5 @@ -45,6 +45,7 @@ collection_output_id => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -94,8 +95,8 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_collection_output( - {service_instance => $self->service_instance_id}, - {article_name => $self->article_name} ); + service_instance_lsid => $self->service_instance_lsid, + article_name => $self->article_name); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/22 19:16:40 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 19:53:35 1.7 @@ -50,6 +50,7 @@ datatype => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -120,7 +121,7 @@ {enum_value => $self->enum_value}, {datatype => $self->datatype}, {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}); + {service_instance_lsid => $self->service_instance_id}); return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:38:02 1.24 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 19:53:35 1.25 @@ -71,9 +71,9 @@ contact_email => [ undef, 'read/write' ], authoritative => [ 0, 'read/write' ], description => [ undef, 'read/write' ], - registry => [ 'MOBY_Central', 'read/write' ], - lsid => [ undef, 'read/write' ], - test => [ 0, 'read/write' ] + registry => [ 'MOBY_Central', 'read/write' ], + lsid => [ undef, 'read/write' ], + test => [ 0, 'read/write' ] , # toggles create or test_existence behaviour ); @@ -164,12 +164,6 @@ } } -#sub _dbh { -# my ($self) = @_; -# -# my $central_connect = MOBY::central_db_connection->new(); -# $self->dbh($central_connect->dbh); -#} sub new { my ( $caller, %args ) = @_; my $caller_is_obj = ref($caller); @@ -189,27 +183,23 @@ return undef unless $self->authority_uri; return undef unless $self->servicename; - if ( $self->test ) { return $self->service_instance_exists } + if ( $self->test ) { return $self->service_instance_exists } # returns boolean - $self->authority( $self->_get_authority() ); + $self->authority( $self->_get_authority() ); # as MOBY::authority object if ( $self->service_type ) { my $OE = MOBY::OntologyServer->new( ontology => 'service' ); my ( $success, $message, $servicetypeURI ) = $OE->serviceExists( term => $self->service_type ); unless ( - ( - $success - || ( ( $self->service_type =~ /urn:lsid/i ) - && !( $self->service_type =~ /urn:lsid:biomoby.org/i ) ) - ) - ) + $success || ( ( $self->service_type =~ /urn:lsid/i ) && !( $self->service_type =~ /urn:lsid:biomoby.org/i ) ) + ) { return undef; } - ( $self->service_type =~ /urn:lsid/ ) - ? $self->service_type_uri( $self->service_type ) - : $self->service_type_uri($servicetypeURI); + ( $self->service_type =~ /urn:lsid/ )? + $self->service_type_uri( $self->service_type ) + : $self->service_type_uri($servicetypeURI); } my $existing_services = $self->adaptor->query_service_instance(servicename => $self->servicename, authority_uri => $self->authority_uri); @@ -236,23 +226,25 @@ ) { # then create it de novo if we have enough information #create LSID for service and register it in the DB my $_config ||= MOBY::Config->new; - my $service_lsid = "urn:lsid:" - . $_config->{mobycentral}->{lsid_authority} . ":" - . $_config->{mobycentral}->{lsid_namespace} . ":" + my $LSID_Auth = $_config->{mobycentral}->{lsid_authority}; + my $LSID_NS = $_config->{mobycentral}->{lsid_namespace}; + $LSID_Auth ||="biomoby.org"; + $LSID_NS ||="serviceinstance"; + my $service_lsid = "urn:lsid:$LSID_Auth:$LSID_NS:" . $self->authority_uri . "," . $self->servicename; my $id = $self->adaptor->insert_service_instance( - {category => $self->category}, - {servicename => $self->servicename}, - {service_type_uri => $self->service_type_uri}, - {authority_id => $self->authority_id}, - {url => $self->url}, - {contact_email => $self->contact_email}, - {authoritative => $self->authoritative}, - {description => $self->description}, - {signatureURL => $self->signatureURL}, - {lsid => $service_lsid} + {category => $self->category}, + {servicename => $self->servicename}, + {service_type_uri => $self->service_type_uri}, + {authority_id => $self->authority_id}, + {url => $self->url}, + {contact_email => $self->contact_email}, + {authoritative => $self->authoritative}, + {description => $self->description}, + {signatureURL => $self->signatureURL}, + {lsid => $service_lsid} ); $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists @@ -271,26 +263,26 @@ $CONFIG ||= MOBY::Config->new; my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - $adaptor->delete_service_instance({service_instance_id => $self->service_instance_id}); - $adaptor->delete_simple_input({service_instance_id => $self->service_instance_id}); - $adaptor->delete_simple_output({service_instance_id => $self->service_instance_id}); + $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_input({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_output({service_instance_lsid => $self->lsid}); - my $result = $adaptor->query_collection_input({service_instance_id => $self->service_instance_id}); + my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); foreach my $row (@$result) { my $id = $row->{collection_input_id}; $adaptor->delete_simple_input({collection_input_id => $id}); } - $result = $adaptor->query_collection_output({service_instance_id => $self->service_instance_id}); + $result = $adaptor->query_collection_output(service_instance_lsid => $self->lsid); foreach my $row (@$result) { my $id = $row->{collection_output_id}; $adaptor->delete_simple_output({collection_output_id => $id}); } - $adaptor->delete_collection_input({service_instance_id => $self->service_instance_id}); - $adaptor->delete_collection_output({service_instance_id => $self->service_instance_id}); - $adaptor->delete_secondary_input({service_instance_id => $self->service_instance_id}); + $adaptor->delete_collection_input(service_instance_lsid => $self->lsid); + $adaptor->delete_collection_output(service_instance_lsid => $self->lsid); + $adaptor->delete_secondary_input({service_instance_lsid => $self->lsid}); return 1; } @@ -329,16 +321,16 @@ my $email = $row->{contact_email}; $authority = MOBY::authority->new( - dbh => $self->dbh, - authority_id => $id, - authority_uri => $uri, - contact_email => $email, + dbh => $self->dbh, + authority_id => $id, + authority_uri => $uri, + contact_email => $email, ); } else { $authority = MOBY::authority->new( - dbh => $self->dbh, - authority_uri => $self->authority_uri, - contact_email => $self->contact_email, + dbh => $self->dbh, + authority_uri => $self->authority_uri, + contact_email => $self->contact_email, ); } return $authority; @@ -349,11 +341,12 @@ # validate here... one day... my $simple = MOBY::simple_input->new( - object_type_uri => $a{'object_type_uri'}, - namespace_type_uris => $a{'namespace_type_uris'}, - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, - collection_input_id => $a{'collection_input_id'} + object_type_uri => $a{'object_type_uri'}, + namespace_type_uris => $a{'namespace_type_uris'}, + article_name => $a{'article_name'}, + service_instance_id => $self->service_instance_id, + service_instance_lsid => $self->lsid, + collection_input_id => $a{'collection_input_id'} ); push @{ $self->{inputs} }, $simple; return $simple->simple_input_id; @@ -364,11 +357,12 @@ # validate here... one day... my $simple = MOBY::simple_output->new( - object_type_uri => $a{'object_type_uri'}, - namespace_type_uris => $a{'namespace_type_uris'}, - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, - collection_output_id => $a{'collection_output_id'} + object_type_uri => $a{'object_type_uri'}, + namespace_type_uris => $a{'namespace_type_uris'}, + article_name => $a{'article_name'}, + service_instance_id => $self->service_instance_id, + service_instance_lsid => $self->lsid, + collection_output_id => $a{'collection_output_id'} ); push @{ $self->{outputs} }, $simple; return $simple->simple_output_id; @@ -379,8 +373,9 @@ # validate here... one day... my $coll = MOBY::collection_input->new( - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, ); + article_name => $a{'article_name'}, + service_instance_lsid => $self->lsid, + service_instance_id => $self->service_instance_id, ); push @{ $self->{inputs} }, $coll; return $coll->collection_input_id; } @@ -390,8 +385,9 @@ # validate here... one day... my $coll = MOBY::collection_output->new( - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, ); + article_name => $a{'article_name'}, + service_instance_lsid => $self->lsid, + service_instance_id => $self->service_instance_id, ); push @{ $self->{outputs} }, $coll; return $coll->collection_output_id; } @@ -401,13 +397,14 @@ # validate here... one day... my $sec = MOBY::secondary_input->new( - default_value => $a{'default_value'}, - maximum_value => $a{'maximum_value'}, - minimum_value => $a{'minimum_value'}, - enum_value => $a{'enum_value'}, - datatype => $a{'datatype'}, - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, + default_value => $a{'default_value'}, + maximum_value => $a{'maximum_value'}, + minimum_value => $a{'minimum_value'}, + enum_value => $a{'enum_value'}, + datatype => $a{'datatype'}, + article_name => $a{'article_name'}, + service_instance_id => $self->service_instance_id, + service_instance_lsid => $self->lsid, ); push @{ $self->{inputs} }, $sec; return $sec->secondary_input_id; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/18 16:53:03 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/25 19:53:35 1.7 @@ -50,6 +50,7 @@ namespace_type_uris => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], collection_input_id => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -100,11 +101,11 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_input( - {object_type_uri => $self->object_type_uri}, - {namespace_type_uris => $self->namespace_type_uris}, - {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}, - {collection_input_id => $self->collection_input_id} + object_type_uri => $self->object_type_uri, + namespace_type_uris => $self->namespace_type_uris, + article_name => $self->article_name, + service_instance_lsid => $self->service_instance_id, + collection_input_id => $self->collection_input_id ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/18 16:53:03 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 19:53:35 1.6 @@ -49,6 +49,7 @@ namespace_type_uris => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], collection_output_id => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -102,7 +103,7 @@ {object_type_uri => $self->object_type_uri}, {namespace_type_uris => $self->namespace_type_uris}, {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}, + {service_instance_lsid => $self->service_instance_id}, {collection_output_id => $self->collection_output_id} ); return $id; From mwilkinson at pub.open-bio.org Mon Jul 25 16:14:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 17:01:40 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252014.j6PKEZfM021182@pub.open-bio.org> mwilkinson Mon Jul 25 16:14:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21136/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.31,1.32 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 19:53:36 1.31 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:14:35 1.32 @@ -297,15 +297,14 @@ return $id; } +# pass service_instance_lsid sub delete_simple_input{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $statement = "delete from simple_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $statement = "delete from simple_input where service_instance_lsid = ?"; + + $dbh->do( $statement, undef,($siid)); if ($dbh->err){ return (1, $dbh->errstr); } @@ -314,50 +313,71 @@ } } +sub delete_inputs { # this should replace all other delete_*_input + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $result_ids = $adaptor->query_collection_input(service_instance_lsid => $self->lsid); + + my $statement = "delete from simple_input where service_instance_lsid = ?"; + + $dbh->do( $statement, undef,($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } + +} + +sub delete_output { # this should replace all other delete_*_output + +} + +# UGH this has to know too much bout the underlying database structure e.g. that one is null and other is full +# this problem is in MOBY::Central line 3321 3346 and 3374 +#****** FIX +# send service_instance_lsid, collection_input_id sub query_simple_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - simple_output_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id - from simple_output "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $collid = $args{collection_input_id}; + my $dbh = $self->dbh; + + my $statement = "select + simple_output_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id + from simple_output where service_instance_id = ? and collection_input_id= ?"; + my $result = do_query($dbh, $statement, ($siid, $collid)); + return $result; } +# pass args service_instance_id and collection_output_id sub insert_simple_output { - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $si = get_value('collection_output_id', @args)?undef:get_value('service_instance_id', @args); + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; - $dbh->do("insert into simple_output - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id) - values (?,?,?,?,?)", - undef, - (get_value('object_type_uri', @args), - get_value('namespace_type_uris', @args), - get_value('article_name', @args), -# and here - $si, - get_value('collection_output_id', @args))); - my $id=$dbh->{mysql_insertid}; - return $id; + $dbh->do("insert into simple_output + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id) + values (?,?,?,?,?)", + undef,( + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_output_id'})); + my $id=$dbh->{mysql_insertid}; + return $id; } From mwilkinson at pub.open-bio.org Mon Jul 25 16:14:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 17:02:08 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252014.j6PKEZde021163@pub.open-bio.org> mwilkinson Mon Jul 25 16:14:34 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21136/MOBY Modified Files: Central.pm service_instance.pm simple_output.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY Central.pm,1.181,1.182 service_instance.pm,1.25,1.26 simple_output.pm,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.181 retrieving revision 1.182 diff -u -r1.181 -r1.182 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 19:53:35 1.181 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 20:14:34 1.182 @@ -3343,7 +3343,7 @@ $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_simple_output(service_instance_lsid => $lsid}, collection_output_id => undef); + $result = $adaptor->query_simple_output(service_instance_lsid => $lsid, collection_output_id => undef); foreach my $row (@$result) { =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 19:53:35 1.25 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:14:34 1.26 @@ -262,9 +262,13 @@ } $CONFIG ||= MOBY::Config->new; my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - + +#********FIX this should really be delete_input and delete_output +# the routines below know too much about the database (e.g. that +# the delete_simple_input routines are broken into two parts - by LSID and +# by collecion ID... BAD BAD BAD $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); - $adaptor->delete_simple_input({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output({service_instance_lsid => $self->lsid}); my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 19:53:35 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 20:14:34 1.7 @@ -100,12 +100,12 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_output( - {object_type_uri => $self->object_type_uri}, - {namespace_type_uris => $self->namespace_type_uris}, - {article_name => $self->article_name}, - {service_instance_lsid => $self->service_instance_id}, - {collection_output_id => $self->collection_output_id} - ); + object_type_uri => $self->object_type_uri, + namespace_type_uris => $self->namespace_type_uris, + article_name => $self->article_name, + service_instance_lsid => $self->service_instance_id, + collection_output_id => $self->collection_output_id + ); return $id; } From kawas at pub.open-bio.org Mon Jul 25 16:18:52 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon Jul 25 17:05:42 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252018.j6PKIq0K021236@pub.open-bio.org> kawas Mon Jul 25 16:18:51 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util In directory pub.open-bio.org:/tmp/cvs-serv21211/org/biomoby/registry/rdfagent/util Modified Files: Report.java Log Message: changed the default send to address to be my address. moby-live/Java/src/main/org/biomoby/registry/rdfagent/util Report.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/04/16 14:32:47 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/07/25 20:18:51 1.4 @@ -73,7 +73,7 @@ to = DataMngr.getContactEmail(signURL); if (to.equals("")){ - to = "opushneva@yahoo.ca"; + to = "edward.kawas@gmail.com"; } String subject = "The RDFagent Report"; From kawas at pub.open-bio.org Mon Jul 25 16:20:02 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon Jul 25 17:06:49 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252020.j6PKK2Aw021287@pub.open-bio.org> kawas Mon Jul 25 16:20:02 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv21262/org/biomoby/registry/rdfagent/verifier Modified Files: ServiceDescrParser.java Log Message: changed the references from the old predicate vocabulary to the updated one. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServiceDescrParser.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/05/19 15:57:25 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/25 20:20:02 1.6 @@ -9,7 +9,6 @@ import org.biomoby.registry.rdfagent.util.Report; import org.biomoby.registry.rdfagent.util.XMLBuilder; import org.biomoby.registry.rdfagent.vocabulary.MP; -import org.biomoby.registry.rdfagent.vocabulary.MRes; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.rdf.model.Model; @@ -291,7 +290,7 @@ Object type = l3Res.getRequiredProperty(RDF.type).getObject(); - if (type.equals(MRes.Simple)){ + if (type.equals(MP.Simple)){ StmtIterator p34iter = l3Res.listProperties(); while (p34iter.hasNext()) { @@ -341,7 +340,7 @@ } } - else if (type.equals(MRes.Collection) | type.equals(RDF.Bag)){ + else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ // if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ if (l3Res.hasProperty(RDF.li(1))){ StmtIterator p34iter = l3Res.listProperties(); @@ -409,7 +408,7 @@ } } - if (type.equals(MRes.Secondary)){ + if (type.equals(MP.Secondary)){ StmtIterator p34iter = l3Res.listProperties(); while (p34iter.hasNext()) { @@ -507,7 +506,7 @@ if (l3Res.isAnon()){ Object type = l3Res.getRequiredProperty(RDF.type).getObject(); //System.out.println("type_out = "+type); - if (type.equals(MRes.Simple)){ + if (type.equals(MP.Simple)){ StmtIterator p34iter = l3Res.listProperties(); while (p34iter.hasNext()) { @@ -557,7 +556,7 @@ } } - else if (type.equals(MRes.Collection) | type.equals(RDF.Bag)){ + else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ // if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ if (l3Res.hasProperty(RDF.li(1))){ From kawas at pub.open-bio.org Mon Jul 25 16:20:44 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon Jul 25 17:07:30 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252020.j6PKKicE021321@pub.open-bio.org> kawas Mon Jul 25 16:20:44 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv21292/org/biomoby/registry/rdfagent/vocabulary Modified Files: MP.java MRes.java Log Message: deprecated the MRes class and modified the MP class to reflect the changes in the RESOURCES script. moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary MP.java,1.4,1.5 MRes.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/04/16 14:30:46 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/07/25 20:20:44 1.5 @@ -27,7 +27,7 @@ private static Model m = ModelFactory.createDefaultModel(); - + //TODO move mobyResource predicates here. public static final Property category = m.getProperty(uri + "category" ) ; public static final Property articleName = m.getProperty(uri + "articleName" ) ; public static final Property article_name = m.getProperty(uri + "article_name" ) ; @@ -49,7 +49,9 @@ public static final Property CollectionArticle = m.getProperty(uri + "CollectionArticle" ); public static final Property SecondaryArticle = m.getProperty(uri + "SecondaryArticle" ) ; public static final Property type = m.getProperty(uri + "type" ) ; - + public static final Property Simple = m.getProperty(uri + "Simple" ) ; + public static final Property Collection = m.getProperty(uri + "Collection" ) ; + public static final Property Secondary = m.getProperty(uri + "Secondary" ) ; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MRes.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MRes.java 2005/04/16 14:30:46 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MRes.java 2005/07/25 20:20:44 1.2 @@ -9,6 +9,7 @@ import com.hp.hpl.jena.rdf.model.*; /** MP vocabulary class for namespace http://biomoby.org/RESOURCES/MOBY-S/Predicates# + * @deprecated */ public class MRes { From dwang at pub.open-bio.org Mon Jul 25 16:43:49 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon Jul 25 17:30:56 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252043.j6PKhn5P021416@pub.open-bio.org> dwang Mon Jul 25 16:43:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv21390/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: updated getRelationship and getObjectRelationship documentation to be concurrent with Mark's moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:20:16 1.8 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 20:43:49 1.9 @@ -589,6 +589,20 @@ die "getParentTerms not implemented in adaptor\n"; } +=head2 getObjectRelationships + + Title : getObjectRelationships + Usage : my $un = $API->getObjectRelationships(%args) + Function : Execute a query for objects that have relationships with other objects + Args : object1_id => Integer - a bind value for object1_id on an underlying SQL-based data source + Returns : listref of hashrefs: + [{relationship_type => String, + object_lsid => Integer, + object2_articlename => String}, ...] + one hashref for each relationship between two objects + Notes : relationship_type from object_term2term, object_lsid from object, and object2_articlename from object_term2term + +=cut # custom query subroutine for selecting from object_term2term and object tables # used in Moby::OntologyServer.pm->retrieveObject() sub getObjectRelationships{ @@ -598,13 +612,16 @@ =head2 getRelationship Title : getRelationship - Usage : my $un = $API->general_query(@args) - Function : Execute a query for a relationship between two tables on an underlying SQL-based data source - Returns : array of array-refs representing resulting rows - Args : String - direction in the ontology (eg. 'root') - String - name of the table ontology - Integer - a bind value for lsid - String - a bind value for relationship_type + Usage : my $un = $API->getRelationships(%args) + Function : Execute a query for a relationship between two ontologies + Args : direction => String - direction in the ontology (eg. 'root') + ontology => String - name of the table ontology + term => Integer - a bind value for lsid + relationship => String - a bind value for relationship_type + Returns : reference to array containing array-refs representing the result set: + [[Integer lsid, String relationship_type], ...] + each array-ref represents one row + Notes : Only returns distinct lsid from $ontology and relationship_type from $ontology_term2term =cut # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() @@ -613,6 +630,7 @@ die "getRelationship not implemented in adaptor\n"; } +# Not quite sure what this does... sub _checkURI { die "_checkURI not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Mon Jul 25 16:55:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 17:42:21 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252055.j6PKtZ7n021533@pub.open-bio.org> mwilkinson Mon Jul 25 16:55:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21506/MOBY Modified Files: OntologyServer.pm secondary_input.pm service_instance.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY OntologyServer.pm,1.54,1.55 secondary_input.pm,1.7,1.8 service_instance.pm,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 23:37:35 1.54 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 20:55:35 1.55 @@ -192,17 +192,10 @@ my $sth; return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); -# if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objecttype/)){ -# return (1, "external ontology", $term); -# } my $result; - if ( $term =~ /^urn\:lsid/ ) { - $result = $adaptor->query_object({object_lsid => $term}); - - } else { - $result = $adaptor->query_object({object_type => $term}); - - } + + $result = $adaptor->query_object(type => $term); + my $row = shift(@$result); my $lsid = $row->{object_lsid}; my $type = $row->{object_type}; @@ -271,12 +264,7 @@ : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } my $result; - if ( $args{'node'} =~ /^urn\:lsid/ ) { - - $result = $adaptor->query_object({object_lsid => $term}); - } else { - $result = $adaptor->query_object({object_type => $term}); - } + $result = $adaptor->query_object(type => $term); my $row = shift(@$result); my $lsid = $row->{object_lsid}; my $type = $row->{object_type}; @@ -320,7 +308,7 @@ ? $args{'node'} : $self->getObjectURI($term); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $result = $adaptor->query_object({object_lsid => $LSID}); + my $result = $adaptor->query_object(type => $LSID); my $row = shift(@$result); my $id = $row->{object_id}; my $type = $row->{object_type}; @@ -372,7 +360,7 @@ return ( 0, q{Object type $term cannot be resolved to an LSID}, "" ) unless $LSID; - my $result = $adaptor->query_object({object_lsid => $LSID}); + my $result = $adaptor->query_object(type => $LSID); my $row = shift(@$result); my $id = $row->{object_id}; my $lsid = $row->{object_lsid}; @@ -471,41 +459,20 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); + my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); - if ( $args{subject_node} =~ /^urn:lsid/ ) { - - my $result = $adaptor->query_object({object_lsid => $args{subject_node}}); - my $row = shift(@$result); - $subj_id = $row->{object_id}; - $subj_lsid = $row->{object_lsid}; - - } else { - my $result = $adaptor->query_object({object_type => $args{subject_node}}); - my $row = shift(@$result); - $subj_id = $row->{object_id}; - $subj_lsid = $row->{object_lsid}; - - } - return ( 0, - qq{Object type $args{subject_node} does not exist in the ontology}, - '' ) + my $result = $adaptor->query_object(type => $args{subject_node}); + my $row = shift(@$result); + $subj_id = $row->{object_id}; + $subj_lsid = $row->{object_lsid}; + return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) unless defined $subj_id; - if ( $args{object_node} =~ /^urn:lsid/ ) { - - my $result = $adaptor->query_object({object_lsid => $args{object_node}}); - my $row = shift(@$result); - $obj_id = $row->{object_id}; - $obj_lsid = $row->{object_lsid}; - - } else { - my $result = $adaptor->query_object({object_type => $args{object_node}}); - my $row = shift(@$result); - $obj_id = $row->{object_id}; - $obj_lsid = $row->{object_lsid}; - } - return ( 0, - qq{Object type $args{object_node} does not exist in the ontology}, - '' ) + + $result = $adaptor->query_object(type => $args{object_node}); + $row = shift(@$result); + $obj_id = $row->{object_id}; + $obj_lsid = $row->{object_lsid}; + return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_id; my $isa = $adaptor->query_object_term2term({object2_id => $subj_id}); @@ -967,7 +934,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return undef unless $URI =~ /urn\:lsid/; - my $result = $adaptor->query_object({object_lsid => $URI}); + my $result = $adaptor->query_object(type => $URI); my $row = shift(@$result); my $name = $row->{object_type}; @@ -1033,7 +1000,7 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_object({object_type => $term}); + my $result = $adaptor->query_object(type => $term); my $row = shift(@$result); my $id = $row->{object_lsid}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 19:53:35 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 20:55:35 1.8 @@ -115,13 +115,13 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; - my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, - {maximum_value => $self->maximum_value}, - {minimum_value => $self->minimum_value}, - {enum_value => $self->enum_value}, - {datatype => $self->datatype}, - {article_name => $self->article_name}, - {service_instance_lsid => $self->service_instance_id}); + my $insertid = $adaptor->insert_secondary_input(default_value => $self->default_value, + maximum_value => $self->maximum_value, + minimum_value => $self->minimum_value, + enum_value => $self->enum_value, + datatype => $self->datatype, + article_name => $self->article_name, + service_instance_lsid => $self->service_instance_id); return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:14:34 1.26 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:55:35 1.27 @@ -269,24 +269,24 @@ # by collecion ID... BAD BAD BAD $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); - $adaptor->delete_simple_output({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); foreach my $row (@$result) { my $id = $row->{collection_input_id}; - $adaptor->delete_simple_input({collection_input_id => $id}); + $adaptor->delete_simple_input(collection_input_id => $id); } $result = $adaptor->query_collection_output(service_instance_lsid => $self->lsid); foreach my $row (@$result) { my $id = $row->{collection_output_id}; - $adaptor->delete_simple_output({collection_output_id => $id}); + $adaptor->delete_simple_output(collection_output_id => $id); } $adaptor->delete_collection_input(service_instance_lsid => $self->lsid); $adaptor->delete_collection_output(service_instance_lsid => $self->lsid); - $adaptor->delete_secondary_input({service_instance_lsid => $self->lsid}); + $adaptor->delete_secondary_input(service_instance_lsid => $self->lsid); return 1; } From mwilkinson at pub.open-bio.org Mon Jul 25 16:55:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 17:42:25 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252055.j6PKtZHB021552@pub.open-bio.org> mwilkinson Mon Jul 25 16:55:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21506/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.32,1.33 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:14:35 1.32 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:55:35 1.33 @@ -302,9 +302,13 @@ my ($self, %args) = @_; my $dbh = $self->dbh; my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $statement = "delete from simple_input where service_instance_lsid = ?"; - - $dbh->do( $statement, undef,($siid)); + my ($collid) = $args{collection_input_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); if ($dbh->err){ return (1, $dbh->errstr); } @@ -317,7 +321,7 @@ my ($self, %args) = @_; my $dbh = $self->dbh; my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $result_ids = $adaptor->query_collection_input(service_instance_lsid => $self->lsid); + my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); my $statement = "delete from simple_input where service_instance_lsid = ?"; @@ -381,86 +385,88 @@ } +# pass service_instance_id or collection_output_id sub delete_simple_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from simple_output "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($collid) = $args{collection_output_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } +# pass service_instance_lsid sub query_secondary_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - secondary_input_id, - default_value, - maximum_value, - minimum_value, - enum_value, - datatype, - article_name, - service_instance_id - from secondary_input "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + secondary_input_id, + default_value, + maximum_value, + minimum_value, + enum_value, + datatype, + article_name, + service_instance_id + from secondary_input where service_instance_id = ?"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; } +# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid sub insert_secondary_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, - undef, - ( - get_value('default_value', @args), get_value('maximum_value', @args), - get_value('minimum_value', @args), get_value('enum_value', @args), - get_value('datatype', @args), get_value('article_name', @args), - get_value('service_instance_id', @args), - ) - ); - return $dbh->{mysql_insertid}; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, + undef, + ( + $args{'default_value'}, $args{'maximum_value'}, + $args{'minimum_value'}, $args{'enum_value'}, + $args{'datatype'}, $args{'article_name'},$siid) + ); + return $dbh->{mysql_insertid}; } +# pass service_instance_lsid sub delete_secondary_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from secondary_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from secondary_input where service_instance_lsid=?"; + + $dbh->do( $statement, undef, ($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } -# query subroutine will selects all rows from object table -sub query_object -{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - + +# receives argument "type", that may be either an LSID or a type term +sub query_object { + my ($self, %args) = @_; + my $type = $args{type}; + my $condition; + if ($type =~ /^urn\:lsid/){ + $condition = "where object_lsid = ?"; + } else { + $condition = "where object_type = ?"; + } my $statement = "select object_id, object_lsid, @@ -468,15 +474,10 @@ description, authority, contact_email - from object "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); + from object $condition"; + + my $dbh = $self->dbh; + my $result = do_query($dbh, $statement, ($type)); return $result; } From mwilkinson at pub.open-bio.org Mon Jul 25 17:13:51 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 18:00:38 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252113.j6PLDpmi021624@pub.open-bio.org> mwilkinson Mon Jul 25 17:13:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21605/MOBY Modified Files: OntologyServer.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY OntologyServer.pm,1.55,1.56 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 20:55:35 1.55 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:13:51 1.56 @@ -242,10 +242,6 @@ my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); - #node => $term, - #desc => $desc, - #authURI => $auth, - #contact => $email return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node", '' ) unless ( $args{node} ); return ( 0, "requires an authURI ", '' ) unless ( $args{authority} ); @@ -255,9 +251,6 @@ unless ( $args{description} ); my $term = $args{node}; -# if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objectclass/)){ # if it is an LSID, but not a MOBY LSID, than barf -# return (0, "can't create a term in a non-MOBY ontology!", $term); -# } my $LSID = ( $args{'node'} =~ /urn\:lsid/ ) ? $args{'node'} @@ -280,11 +273,11 @@ $args{contact_email} =~ s/^\s+(.*?)\s+$/$1/s; $args{authority} =~ s/^\s+(.*?)\s+$/$1/s; - my $insertid = $adaptor->insert_object({object_type => $args{'node'}}, - {object_lsid => $LSID}, - {description => $args{'description'}}, - {authority => $args{'authority'}}, - {contact_email => $args{'contact_email'}}); + my $insertid = $adaptor->insert_object(object_type => $args{'node'}, + object_lsid => $LSID, + description => $args{'description'}, + authority => $args{'authority'}, + contact_email => $args{'contact_email'}); unless ( $insertid ) { return ( 0, "Object creation failed for unknown reasons", '' ); } @@ -373,7 +366,7 @@ $lsid ); } - my ($err, $errstr) = $adaptor->delete_object({object_id => $id}); + my ($err, $errstr) = $adaptor->delete_object(type => $lsid); if ( $err ) { return ( 0, "Delete from Object Class table failed: $errstr", $lsid ); @@ -463,14 +456,12 @@ my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); my $result = $adaptor->query_object(type => $args{subject_node}); my $row = shift(@$result); - $subj_id = $row->{object_id}; $subj_lsid = $row->{object_lsid}; return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) unless defined $subj_id; $result = $adaptor->query_object(type => $args{object_node}); $row = shift(@$result); - $obj_id = $row->{object_id}; $obj_lsid = $row->{object_lsid}; return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_id; @@ -491,10 +482,10 @@ || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - my $insertid = $adaptor->insert_object_term2term({relationship_type => $rel_lsid}, - {object1_id => $subj_id}, - {object2_id => $obj_id}, - {object2_articlename => $args{articleName}}); + my $insertid = $adaptor->insert_object_term2term(relationship_type => $rel_lsid, + object1_id => $subj_lsid, + object2_id => $obj_lsid, + object2_articlename => $args{articleName}); if ($insertid ) { return ( 1, "Object relationsihp created successfully", '' ); } else { From mwilkinson at pub.open-bio.org Mon Jul 25 17:13:51 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 18:00:39 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252113.j6PLDppZ021643@pub.open-bio.org> mwilkinson Mon Jul 25 17:13:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21605/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.33,1.34 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:55:35 1.33 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:13:51 1.34 @@ -482,8 +482,9 @@ } # inserts a new tuple into object table +# pass object_type object_lsid description authority contact_email sub insert_object{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; $dbh->do("insert into object (object_type, @@ -493,24 +494,30 @@ contact_email) values (?,?,?,?,?)", undef, - (get_value('object_type', @args), - get_value('object_lsid', @args), - get_value('description', @args), - get_value('authority', @args), - get_value('contact_email', @args))); + $args{'object_type'}, + $args{'object_lsid'}, + $args{'description'}, + $args{'authority'}, + $args{'contact_email'}); my $id=$dbh->{mysql_insertid}; return $id; } +# pass 'type' which is either an LSID or a term sub delete_object{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........********** - # ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ******************** - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $term = $args{type}; + return 0 unless $term; + my $statement = "delete from object where "; + my $condition; + if ($term =~ /^urn\:lsid/){ + $condition = " object_lsid = ?"; + } else { + $condition = " object_type = ?"; + } + $statement = $statement.$condition; + $dbh->do( $statement,undef, ($term) ); if ($dbh->err){ return (1, $dbh->errstr); @@ -520,8 +527,14 @@ } } +# pass "type" here, should be an LSID, preferably... sub query_object_term2term{ - my ($self, @args) = @_; + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_object(type => $type); + my $row = shift(@$result); + my $id = $row->{object_id}; + return [{}] unless $id; my $dbh = $self->dbh; my $statement = "select @@ -530,28 +543,33 @@ object1_id, object2_id, object2_articlename - from object_term2term "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + from object_term2term where object2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; } +# pass object1_type, object2_type, object2_articlename, relationship_type sub insert_object_term2term{ - my ($self, @args) = @_; + my ($self, %args) = @_; + my $type1 = $args{object1_type}; + my $result = $self->query_object(type => $type1); + my $row = shift(@$result); + my $id1 = $row->{object_id}; + my $type2 = $args{object2_type}; + $result = $self->query_object(type => $type2); + $row = shift(@$result); + my $id2 = $row->{object_id}; + my $relationship_type = $args{relationship_type}; + my $object2_articlename = $args{object2_articlename}; + my $dbh = $self->dbh; $dbh->do( -q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, + q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, undef, - ( get_value('relationship_type', @args), - get_value('object1_id', @args), - get_value('object2_id', @args), - get_value('object2_articlename', @args) ) + $relationship_type, + $id1, + $id2, + $object2_articlename ); return $dbh->{mysql_insertid}; From dwang at pub.open-bio.org Mon Jul 25 17:30:12 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon Jul 25 18:18:04 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252130.j6PLUCER021718@pub.open-bio.org> dwang Mon Jul 25 17:30:12 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv21692/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: documentation added for getServiceNames() and getParentTerms() moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 20:43:49 1.9 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 21:30:12 1.10 @@ -579,11 +579,35 @@ die "getFromCollection not implemented in adaptor\n"; } +=head2 getServiceNames + + Title : getServiceNames + Usage : my $un = $API->getServiceNames(%args) + Function : Execute a query for all service names + Args : no inputs needed + Returns : listref of hashrefs: + [{authority_uri => String, + servicename => String}, ...] + one hashref for each service + +=cut # custom query subroutine for Moby::Central.pm->RetrieveServiceNames sub getServiceNames{ die "getServiceNames not implemented in adaptor\n"; } +=head2 getParentTerms + + Title : getParentTerms + Usage : my $un = $API->getParentTerms(%args) + Function : From a given term, traverse the ontology and get all parent terms + Args : relationship_type_id => Integer - a bind value for relationship_type_id on an underlying SQL-based data source + term => String - bindvalue for OntologyEntry.term + Returns : listref of hashrefs: + [{term => String}, ...] + one hashref for each parent + +=cut # custom query for Moby::Central.pm->_flatten sub getParentTerms{ die "getParentTerms not implemented in adaptor\n"; From mwilkinson at pub.open-bio.org Mon Jul 25 17:30:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 18:18:24 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252130.j6PLUc34021761@pub.open-bio.org> mwilkinson Mon Jul 25 17:30:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21742/MOBY Modified Files: OntologyServer.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY OntologyServer.pm,1.56,1.57 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:13:51 1.56 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:30:38 1.57 @@ -371,12 +371,6 @@ return ( 0, "Delete from Object Class table failed: $errstr", $lsid ); } - ($err, $errstr) = $adaptor->delete_object_term2term({object1_id => $id}); - if ( $err ) { - return ( 0, - "Delete from Object term2term table failed: $errstr", - $lsid ); - } return ( 1, "Object $term Deleted", $lsid ); } From mwilkinson at pub.open-bio.org Mon Jul 25 17:30:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 18:18:25 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252130.j6PLUc7i021781@pub.open-bio.org> mwilkinson Mon Jul 25 17:30:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21742/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.34,1.35 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:13:51 1.34 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:30:38 1.35 @@ -519,6 +519,7 @@ $statement = $statement.$condition; $dbh->do( $statement,undef, ($term) ); + $self->_delete_object_term2term(type => $term); if ($dbh->err){ return (1, $dbh->errstr); } @@ -575,15 +576,20 @@ return $dbh->{mysql_insertid}; } -sub delete_object_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; +# pass object 'type' as term or lsid +# this should be a private routine, not a public one. +# SHOULD NOT BE DOCUMENTED IN THE API +sub _delete_object_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $id = $row->object_id; - my $statement = "delete from object_term2term "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $dbh = $self->dbh; + my $statement = "delete from object_term2term where object1_id=?"; + $dbh->do( $statement,undef, ($id)); if ($dbh->err){ return (1, $dbh->errstr); From mwilkinson at pub.open-bio.org Mon Jul 25 17:52:25 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 18:39:17 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252152.j6PLqPUu021905@pub.open-bio.org> mwilkinson Mon Jul 25 17:52:25 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21863/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.35,1.36 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:30:38 1.35 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:52:25 1.36 @@ -599,19 +599,20 @@ } } +# pass servicename and authority_uri sub query_service_existence { my ($self, %args) = @_; my $dbh = $self->dbh; my $servicename = $args{'servicename'}; my $authURI = $args{'authority_uri'}; - my $id = $args{'authority_id'}; - unless ($id){ +# my $id = $args{'authority_id'}; # is it safe to remove this? better be! +# unless ($id){ my $result = $self->query_authority({authority_uri => $authURI}); return 0 unless @$result[0]; - $id = @$result[0]->{authority_id}; + my $id = @$result[0]->{authority_id}; return 0 unless $id; - } +# } my $statement = "select service_instance_id, category, @@ -624,10 +625,8 @@ description, signatureURL, lsid - from service_instance "; - my @bindvalues; - ($statement, @bindvalues) =_add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); - my $final = do_query($dbh, $statement, @bindvalues); + from service_instance where servicename = ? and authority_id = ?"; + my $final = do_query($dbh, $statement, ($servicename, $id)); if (@$final[0]){return 1} else {return 0} } @@ -676,33 +675,38 @@ } # custom query for Moby::Central.pm->findService() +# hmmmmmmm.... I'm not sure that this routine should exist... +# it is redundant to the routine above, if the routine above were executed +# multiple times. I think that is the more correct (though less efficient) +# way to go, since it is "scalable" to every possible underlying data source +# ********FIX change this later... sub match_service_type_uri{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - my $uri_list = get_value('service_type_uri', @args); + my $uri_list = $args{'service_type_uri'}; my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; - my @bindvalues = (); - + my @bindvalues = (); my $result = do_query($dbh, $statement, @bindvalues); return $result; } +# passs........ blah blah..... sub insert_service_instance { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, undef,( - get_value('category', @args), - get_value('servicename', @args), - get_value('service_type_uri', @args), - get_value('authority_id', @args), - get_value('url', @args), - get_value('contact_email', @args), - get_value('authoritative', @args), - get_value('description', @args), - get_value('signatureURL', @args), - get_value('lsid', @args))); + $args{'category'}, + $args{'servicename'}, + $args{'service_type_uri'}, + $args{'authority_id'}, + $args{'url'}, + $args{'contact_email'}, + $args{'authoritative'}, + $args{'description'}, + $args{'signatureURL'}, + $args{'lsid'})); my $id = $dbh->{mysql_insertid}; return $id; From mwilkinson at pub.open-bio.org Mon Jul 25 17:52:25 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 18:39:19 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252152.j6PLqP45021886@pub.open-bio.org> mwilkinson Mon Jul 25 17:52:25 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21863/MOBY Modified Files: Central.pm service_instance.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY Central.pm,1.182,1.183 service_instance.pm,1.27,1.28 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.182 retrieving revision 1.183 diff -u -r1.182 -r1.183 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 20:14:34 1.182 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 21:52:25 1.183 @@ -1926,9 +1926,11 @@ my (@children) = @{ $relationships{'urn:lsid:biomoby.org:servicerelation:isa'} }; $children_string .= ( join ',', map { "\'$_\'" } @children ); + #*******FIX this isn't very perlish... sending a comma-delimited string to a subroutine instead of an array + # need to change that one day soon! } $children_string =~ s/\,$//; - my $ids = _extract_ids($adaptor->match_service_type_uri({service_type_uri => $children_string})); + my $ids = _extract_ids($adaptor->match_service_type_uri(service_type_uri => $children_string)); $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); @@ -3243,6 +3245,11 @@ } sub _serviceListResponse { + + + # *********FIX + # this routine is using service instances by their database ID, rather than their LSID + # this is BAD BAD BAD $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:55:35 1.27 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 21:52:25 1.28 @@ -235,16 +235,16 @@ . $self->servicename; my $id = $self->adaptor->insert_service_instance( - {category => $self->category}, - {servicename => $self->servicename}, - {service_type_uri => $self->service_type_uri}, - {authority_id => $self->authority_id}, - {url => $self->url}, - {contact_email => $self->contact_email}, - {authoritative => $self->authoritative}, - {description => $self->description}, - {signatureURL => $self->signatureURL}, - {lsid => $service_lsid} + category => $self->category, + servicename => $self->servicename, + service_type_uri => $self->service_type_uri, + authority_id => $self->authority_id, + url => $self->url, + contact_email => $self->contact_email, + authoritative => $self->authoritative, + description => $self->description, + signatureURL => $self->signatureURL, + lsid => $service_lsid ); $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists From mwilkinson at pub.open-bio.org Mon Jul 25 18:10:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 18:57:13 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252210.j6PMAQdZ022027@pub.open-bio.org> mwilkinson Mon Jul 25 18:10:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22004/MOBY Modified Files: Central.pm service_instance.pm Log Message: how do you know when you have done too much Perl coding? When you start to say %args like a pirate... This change might break things badly- I need to do a join in a dynamically generated SQL statement. It looks OK now. mySQL is weird in that you have to specify table names in natural joins. UGH moby-live/Perl/MOBY Central.pm,1.183,1.184 service_instance.pm,1.28,1.29 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.183 retrieving revision 1.184 diff -u -r1.183 -r1.184 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 21:52:25 1.183 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 22:10:25 1.184 @@ -3259,6 +3259,10 @@ my $OSns = MOBY::OntologyServer->new( ontology => 'namespace' ); my $OSserv = MOBY::OntologyServer->new( ontology => 'service' ); + # *********FIX + # this routine is using service instances by their database ID, rather than their LSID + # this is BAD BAD BAD + foreach (@ids) { my $result = $adaptor->query_service_instance(service_instance_id => $_); my $row = shift(@$result); @@ -3266,7 +3270,7 @@ my $url = $row->{url}; my $servicename = $row->{servicename}; my $service_type_uri = $row->{service_type_uri}; - my $authority_id = $row->{authority_id}; + my $authority_uri = $row->{authority_uri}; my $desc = $row->{description}; my $authoritative = $row->{authoritative}; my $email = $row->{contact_email}; @@ -3281,10 +3285,10 @@ next unless ( $servicename && $authority_id ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); - $result = $adaptor->query_authority({authority_id => $authority_id}); - $row = shift(@$result); - my $authURI = $row->{authority_uri}; - $output .= "\t\n"; + #$result = $adaptor->query_authority({authority_id => $authority_id}); + #$row = shift(@$result); + #my $authURI = $row->{authority_uri}; + $output .= "\t\n"; $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; $output .= "\t$category\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 21:52:25 1.28 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 22:10:26 1.29 @@ -267,7 +267,7 @@ # the routines below know too much about the database (e.g. that # the delete_simple_input routines are broken into two parts - by LSID and # by collecion ID... BAD BAD BAD - $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); + $adaptor->delete_service_instance(service_instance_lsid => $self->lsid); $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); @@ -313,9 +313,8 @@ my $dbh = $self->dbh; my $authority; $CONFIG ||= MOBY::Config->new; - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - - my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $result = $adaptor->query_authority(authority_uri => $self->authority_uri); if ( @$result[0]) { my $row = shift(@$result); From mwilkinson at pub.open-bio.org Mon Jul 25 18:10:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 18:57:14 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252210.j6PMAQTW022046@pub.open-bio.org> mwilkinson Mon Jul 25 18:10:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22004/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: how do you know when you have done too much Perl coding? When you start to say %args like a pirate... This change might break things badly- I need to do a join in a dynamically generated SQL statement. It looks OK now. mySQL is weird in that you have to specify table names in natural joins. UGH moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.36,1.37 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:52:25 1.36 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 22:10:26 1.37 @@ -608,7 +608,7 @@ my $authURI = $args{'authority_uri'}; # my $id = $args{'authority_id'}; # is it safe to remove this? better be! # unless ($id){ - my $result = $self->query_authority({authority_uri => $authURI}); + my $result = $self->query_authority(authority_uri => $authURI); return 0 unless @$result[0]; my $id = @$result[0]->{authority_id}; return 0 unless $id; @@ -638,36 +638,36 @@ my $dbh = $self->dbh; my $authority_id; - if ($args{'authority_uri'}){ # need to transform URI to a row ID - my $result = $self->query_authority({authority_uri => $args{'authority_uri'}}); - return 0 unless @$result[0]; - $authority_id = @$result[0]->{authority_id}; - return 0 unless $authority_id; - } - delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table + #if ($args{'authority_uri'}){ # need to transform URI to a row ID + # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); + # return 0 unless @$result[0]; + # $authority_id = @$result[0]->{authority_id}; + # return 0 unless $authority_id; + #} + #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine } - if ($authority_id){ - push @args, ({authority_id => $authority_id}) ; - } else { - pop @args; # remove final "and" - } +# if ($authority_id){ +# push @args, ({authority_id => $authority_id}) ; +# } else { +# pop @args; # remove final "and" +# } my $statement = "select service_instance_id, category, servicename, service_type_uri, - authority_id, + authority.authority_uri, url, contact_email, authoritative, description, signatureURL, lsid - from service_instance "; + from service_instance left join authority on authority.authority_id "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); @@ -712,14 +712,12 @@ return $id; } +# pass service_instance_lsid sub delete_service_instance{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - my $statement = "delete from service_instance "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $statement = "delete from service_instance where lsid = ?"; + $dbh->do( $statement,undef, ($args{service_instance_lsid}) ); if ($dbh->err){ return (1, $dbh->errstr); } @@ -729,8 +727,10 @@ } # Selects all columns +# pass authority_uri sub query_authority { - my ($self, @args) = @_; + my ($self, %args) = @_; + my $authURI = $args{authority_uri}; my $dbh = $self->dbh; my $statement = "select @@ -738,15 +738,8 @@ authority_common_name, authority_uri, contact_email - from authority "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); + from authority where authority_uri = ?"; + my $result = do_query($dbh, $statement, ($authURI)); return $result; } From dwang at pub.open-bio.org Mon Jul 25 19:31:56 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon Jul 25 20:18:57 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252331.j6PNVuYl022253@pub.open-bio.org> dwang Mon Jul 25 19:31:56 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv22227/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 21:30:12 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:31:56 1.11 @@ -564,16 +564,69 @@ die "checkNamespaceUsedByService not implemented in adaptor\n"; } +=head2 checkKeywords + + Title : checkKeywords + Usage : my $un = $API->checkKeywords(%args) + Function : Execute a custom query for services with keywords in its description + Args : findme => hashref - hash contains an array of keywords + Returns : listref of hashrefs: + [{service_instance_id => Integer, + category => String, + servicename => String, + service_type_uri => String, + authority_id => Integer, + url => String, + contact_email => String, + authoritative => String, + description => String, + signatureURL => String, + lsid => Integer}, ...] + Each hash represents a service + Notes : the fact that it returns a service_instance_id is bad since this + is only useful to an SQL-based API... + +=cut # custom query routine for Moby::Central.pm -> findService() sub checkKeywords{ die "checkKeywords not implemented in adaptor\n"; } +=head2 getFromSimple + + Title : getFromSimple + Usage : my $un = $API->getFromSimple(%args) + Function : Execute a custom query for service ids in simple_input/output + Args : inout => String - to specify if input or output + ancestor_string => String - values that occur in object_type_uri + namespaceURIs => array-ref - reference to an array of namespace URIs + Returns : listref of hashrefs: + [{service_instance_id => Integer, + namespace_type_uris => String}, ...] + Notes : the fact that it returns a service_instance_id is bad since this + is only useful to an SQL-based API... + +=cut # custom query subroutine for Moby::Central.pm->_searchForSimple() sub getFromSimple{ die "getFromSimple not implemented in adaptor\n"; } +=head2 getFromCollection + + Title : getFromCollection + Usage : my $un = $API->getFromCollection(%args) + Function : Execute a custom query for service ids from collections + Args : inout => String - to specify if input or output + objectURI => String - value that binds to object_type_uri + namespaceURIs => array-ref - reference to an array of namespace URIs + Returns : listref of hashrefs: + [{service_instance_id => Integer, + namespace_type_uris => String}, ...] + Notes : the fact that it returns a service_instance_id is bad since this + is only useful to an SQL-based API... + +=cut # custom query subroutine for Moby::Central.pm->_searchForCollection() sub getFromCollection{ die "getFromCollection not implemented in adaptor\n"; From dwang at pub.open-bio.org Mon Jul 25 19:43:43 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon Jul 25 20:30:39 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252343.j6PNhhpC022305@pub.open-bio.org> dwang Mon Jul 25 19:43:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv22279/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:31:56 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:43:43 1.12 @@ -559,6 +559,19 @@ die "checkClassUsedByService not implemented in adaptor\n"; } +=head2 checkNamespaceUsedByService + + Title : checkNamespaceUsedByService + Usage : my $un = $API->checkNamespaceUsedByService(%args) + Function : Execute a custom query for namespaces that are used by some service + Args : namespace_type_uris => String - namespace_type_uris you are checking for + term => String - the type of the namespace + Returns : a list: + ($err, $errstr) + $err = 1 if namespace is used by a service, 0 otherwise + $errstr = contains the error message + +=cut # custom query routine for Moby::Central.pm -> deregisterNamespace() sub checkNamespaceUsedByService{ die "checkNamespaceUsedByService not implemented in adaptor\n"; From mwilkinson at pub.open-bio.org Mon Jul 25 19:45:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 20:32:22 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252345.j6PNjTPX022383@pub.open-bio.org> mwilkinson Mon Jul 25 19:45:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22352/MOBY Modified Files: Central.pm OntologyServer.pm authority.pm service_instance.pm Log Message: almost finished perlifying the adaptor code. moby-live/Perl/MOBY Central.pm,1.184,1.185 OntologyServer.pm,1.57,1.58 authority.pm,1.5,1.6 service_instance.pm,1.29,1.30 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.184 retrieving revision 1.185 diff -u -r1.184 -r1.185 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 22:10:25 1.184 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 23:45:29 1.185 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::Client::Central; +#use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -488,7 +488,7 @@ unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); + my $errormsg = $adaptor->check_object_usage(type => $existingURI); return &_error( "Object class $class is used by a service and may not be deregistered", "" @@ -745,7 +745,7 @@ sub deregisterServiceType { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'service' ); @@ -759,12 +759,12 @@ return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); - my $result = $adaptor->query_service({service_lsid => $existingURI}); + my $result = $adaptor->query_service_instance(service_type_uri => $existingURI); my $row = shift(@$result); - my $id = $row->{service_instance_id}; + my $lsid = $row->{lsid}; return &_error( "A registered service depends on this service type", "" ) - if ($id); + if ($lsid); my ( $success2, $message2, $deleteURI ) = $OntologyServer->deleteServiceType( term => $term ) ; # hopefully this situation will never happen! @@ -2475,11 +2475,11 @@ my ($pkg) = @_; my $dbh = MOBY::central_db_connection->new()->dbh; - my $result = $adaptor->getUniqueAuthorityURI(); + my $result = $adaptor->get_all_authorities(); my $providers = "\n"; foreach my $prov (@$result) { - $providers .= "\n"; + $providers .= "\n"; } $providers .= "\n"; return $providers; @@ -3282,12 +3282,9 @@ } $signatureURL ||= ""; - next unless ( $servicename && $authority_id ); + next unless ( $servicename && $authority_uri ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); - #$result = $adaptor->query_authority({authority_id => $authority_id}); - #$row = shift(@$result); - #my $authURI = $row->{authority_uri}; $output .= "\t\n"; $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:30:38 1.57 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 23:45:29 1.58 @@ -404,11 +404,13 @@ my $result; if ( $term =~ /^urn\:lsid/ ) { - $result = $adaptor->query_relationship({relationship_lsid => $term}, 'and', {ontology => $ont}); + $result = $adaptor->query_relationship( + type => $term, + ontology => $ont); } else { - $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ont}); + $result = $adaptor->query_relationship(type => $term, ontology => $ont); } my $row = shift(@$result); @@ -507,9 +509,8 @@ return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); - my $result = $adaptor->query_service({service_type => $args{subject_node}}); + my $result = $adaptor->query_service(type => $args{subject_node}); my $row = shift(@$result); - my $sbj_id = $row->{service_id}; my $sbj_lsid = $row->{service_lsid}; return ( @@ -517,9 +518,9 @@ qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ) - unless defined $sbj_id; + unless defined $sbj_lsid; - my $isa = $adaptor->query_service_term2term({service2_id => $sbj_id}); + my $isa = $adaptor->query_service_term2term(service2_id => $sbj_lsid); if ( scalar @$isa ) { return ( 0, @@ -527,28 +528,27 @@ $sbj_lsid ); } - $result = $adaptor->query_service({service_type => $args{object_node}}); + $result = $adaptor->query_service(type => $args{object_node}); $row = shift(@$result); - my $obj_id = $row->{service_id}; my $obj_lsid = $row->{service_lsid}; # get ID of the related service - defined $obj_id + defined $obj_lsid || return ( 0, qq{Service $args{object_node} does not exist in the service ontology}, '' ); my $OE = MOBY::OntologyServer->new( ontology => 'relationship' ); my ( $success, $desc, $rel_lsid ) = $OE->relationshipExists( - term => $args{relationship}, - ontology => 'service' ); + term => $args{relationship}, + ontology => 'service' ); ($success) || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - my $insertid = $adaptor->insert_service_term2term({relationship_type => $rel_lsid}, - {service1_id => $sbj_id}, - {service2_id => $obj_id}); + my $insertid = $adaptor->insert_service_term2term(relationship_type => $rel_lsid, + service1_type => $sbj_lsid, + service2_type => $obj_lsid); if ( $insertid ) { return ( 1, "Service relationship created successfully", '' ); } else { @@ -575,13 +575,7 @@ return ( 1, "external ontology", $term ); } my $result; - if ( $term =~ /^urn\:lsid/ ) { - $result = $adaptor->query_service({service_lsid => $term}); - - } else { - $result = $adaptor->query_service({service_type => $term}); - - } + $result = $adaptor->query_service(type => $term); my $row = shift(@$result); my $id = $row->{service_id}; my $type = $row->{service_type}; @@ -633,11 +627,11 @@ : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $insertid = $adaptor->insert_service({service_type => $args{'node'}}, - {service_lsid => $LSID}, - {description => $args{'description'}}, - {authority => $args{'authority'}}, - {contact_email => $args{'contact_email'}}); + my $insertid = $adaptor->insert_service(service_type => $args{'node'}, + service_lsid => $LSID, + description => $args{'description'}, + authority => $args{'authority'}, + contact_email => $args{'contact_email'}); unless ( $insertid ) { return ( 0, "Service creation failed for unknown reasons", '' ); @@ -668,30 +662,26 @@ $LSID = $term; } return ( - 0, -q{Service type $term cannot be resolved to an LSID in the MOBY ontologies}, - "" - ) - unless $LSID; + 0, q{Service type $term cannot be resolved to an LSID in the MOBY ontologies},"" + ) unless $LSID; - my $result = $adaptor->query_service({service_lsid => $LSID}); + my $result = $adaptor->query_service(type => $LSID); my $row = shift(@$result); - my $id = $row->{service_id}; my $lsid = $row->{service_lsid}; - if ( !defined $id ) { + if ( !defined $lsid ) { return ( 0, q{Service type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my $isa = $adaptor->query_service_term2term({service2_id => $id}); + my $isa = $adaptor->query_service_term2term(service2_id => $lsid); if ( scalar @$isa ) { return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } - my ($err, $errstr) = $adaptor->delete_service({service_id => $id}); + my ($err, $errstr) = $adaptor->delete_service(service_lsid => $lsid); if ( $err ) { return ( 0, "Delete from Service Type table failed: $errstr", @@ -729,13 +719,7 @@ return ( 1, "external ontology", $term ); } my $result; - if ( $term =~ /^urn:lsid:biomoby.org:namespacetype/ ) { - $result = $adaptor->query_namespace({namespace_lsid => $term}); - - } else { - $result = $adaptor->query_namespace({namespace_type => $term}); - - } + $result = $adaptor->query_namespace(type => $term); my $row = shift(@$result); my $id = $row->{namespace_id}; my $type = $row->{namespace_type}; @@ -787,11 +771,11 @@ : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $insertid = $adaptor->insert_namespace({namespace_type => $args{'node'}}, - {namespace_lsid => $LSID}, - {description => $args{'description'}}, - {authority => $args{'authority'}}, - {contact_email => $args{'contact_email'}}); + my $insertid = $adaptor->insert_namespace(namespace_type => $args{'node'}, + namespace_lsid => $LSID, + description => $args{'description'}, + authority => $args{'authority'}, + contact_email => $args{'contact_email'}); unless ( $insertid ) { return ( 0, "Namespace creation failed for unknown reasons", '' ); @@ -820,25 +804,24 @@ return ( 0, "cannot delete a term from an external ontology", $term ); } - my $result = $adaptor->query_namespace({namespace_lsid => $LSID}); + my $result = $adaptor->query_namespace(type => $LSID); my $row = shift(@$result); - my $id = $row->{namespace_id}; my $lsid = $row->{namespace_lsid}; - unless ($id) { + unless ($lsid) { return ( 0, q{Namespace type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my $isa = $adaptor->query_namespace_term2term({namespace2_id => $id}); + my $isa = $adaptor->query_namespace_term2term(type => $lsid); if ( scalar @$isa ) { return ( 0, qq{Namespace type $term has dependencies in the ontology}, $lsid ); } - my ($err, $errstr) = $adaptor->delete_namespace({namespace_id => $id}); + my ($err, $errstr) = $adaptor->delete_namespace(namespace_lsid => $lsid); if ( $err ) { return ( 0, "Delete from namespace table failed: $errstr", @@ -935,7 +918,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return undef unless $URI =~ /urn\:lsid/; - my $result = $adaptor->query_namespace({namespace_lsid => $URI}); + my $result = $adaptor->query_namespace(type => $URI); my $row = shift(@$result); my $name = $row->{namespace_type}; @@ -951,7 +934,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return undef unless $URI =~ /urn\:lsid/; - my $result = $adaptor->query_service({service_lsid => $URI}); + my $result = $adaptor->query_service(type => $URI); my $row = shift(@$result); my $name = $row->{service_type}; @@ -968,7 +951,7 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_service({service_type => $term}); + my $result = $adaptor->query_service(type => $term); my $row = shift(@$result); my $id = $row->{service_lsid}; @@ -1003,7 +986,7 @@ return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_namespace({namespace_type => $term}); + my $result = $adaptor->query_namespace(type => $term); my $row = shift(@$result); my $id = $row->{namespace_lsid}; @@ -1021,7 +1004,7 @@ return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ontology}); + my $result = $adaptor->query_relationship(type => $term, ontology => $ontology); my $row = shift(@$result); my $id = $row->{relationship_lsid}; @@ -1040,7 +1023,7 @@ my $ontology = $args{'ontology'}; my $OS = MOBY::OntologyServer->new( ontology => "relationship" ); - my $defs = $adaptor->query_relationship({ontology => $ontology}); + my $defs = $adaptor->query_relationship(ontology => $ontology); my %result; foreach ( @$defs ) { =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 17:25:54 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/25 23:45:29 1.6 @@ -43,7 +43,6 @@ #ATTRIBUTES my %_attr_data = # DEFAULT ACCESSIBILITY ( - authority_id => [ undef, 'read/write' ], authority_common_name => [ undef, 'read/write' ], authority_uri => [ undef, 'read/write' ], contact_email => [ undef, 'read/write' ], @@ -68,6 +67,9 @@ sub _standard_keys { keys %_attr_data; } + sub authority_id { + die "AUTHORITY_ID is deprecated. fix your code!\n"; + } } sub new { @@ -93,12 +95,14 @@ my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); my $row = shift(@$result); unless ($row) { - my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, - {authority_uri => $self->authority_uri}, - {contact_email => $self->contact_email}); - $self->authority_id( $insertid ); + my $insertid = $adaptor->insert_authority( + authority_common_name => $self->authority_common_name, + authority_uri => $self->authority_uri, + contact_email => $self->contact_email); } else { - $self->authority_id($row->{authority_id}); + $self->authority_common_name($row->{authority_common_name}); + $self->authority_uri($row->{authority_uri}); + $self->contact_email($row->{contact_email}); } return $self; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 22:10:26 1.29 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 23:45:29 1.30 @@ -238,7 +238,7 @@ category => $self->category, servicename => $self->servicename, service_type_uri => $self->service_type_uri, - authority_id => $self->authority_id, + authority_uri => $self->authority_uri, url => $self->url, contact_email => $self->contact_email, authoritative => $self->authoritative, @@ -246,6 +246,7 @@ signatureURL => $self->signatureURL, lsid => $service_lsid ); + return undef unless $id; $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists } else { # if it doesn't exist, and you havne't given me anyting I need to create it, then bail out @@ -315,17 +316,17 @@ $CONFIG ||= MOBY::Config->new; my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority(authority_uri => $self->authority_uri); - +#*********FIX we should nver need to know the authority ID in this level of code! if ( @$result[0]) { my $row = shift(@$result); - my $id = $row->{authority_id}; + #my $id = $row->{authority_id}; my $name = $row->{authority_common_name}; my $uri = $row->{authority_uri}; my $email = $row->{contact_email}; $authority = MOBY::authority->new( dbh => $self->dbh, - authority_id => $id, +# authority_id => $id, authority_uri => $uri, contact_email => $email, ); From mwilkinson at pub.open-bio.org Mon Jul 25 19:45:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 20:32:23 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252345.j6PNjTOc022402@pub.open-bio.org> mwilkinson Mon Jul 25 19:45:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv22352/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: almost finished perlifying the adaptor code. moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:43:43 1.12 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:45:29 1.13 @@ -467,8 +467,8 @@ die "query_authority not implemented in adaptor\n"; } -sub getUniqueAuthorityURI{ - die "getUniqueAuthorityURI not implemented in adaptor\n"; +sub get_all_authorities{ + die "get_all_authorities not implemented in adaptor\n"; } sub insert_authority{ @@ -555,8 +555,8 @@ } # custom query subroutine for Moby::Central.pm->deregisterObjectClass() -sub checkClassUsedByService{ - die "checkClassUsedByService not implemented in adaptor\n"; +sub check_object_usage{ + die "check_object_usage not implemented in adaptor\n"; } =head2 checkNamespaceUsedByService From mwilkinson at pub.open-bio.org Mon Jul 25 19:45:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon Jul 25 20:37:00 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252345.j6PNjT9B022423@pub.open-bio.org> mwilkinson Mon Jul 25 19:45:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22352/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: almost finished perlifying the adaptor code. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.37,1.38 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 22:10:26 1.37 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 23:45:29 1.38 @@ -1,1331 +1,1382 @@ -package MOBY::Adaptor::moby::queryapi::mysql; - -use strict; -use vars qw($AUTOLOAD @ISA); -use Carp; -use MOBY::Adaptor::moby::queryapi; -use DBI; -use DBD::mysql; - -@ISA = qw{MOBY::Adaptor::moby::queryapi}; # implements the interface - -{ - #Encapsulated class data - - #___________________________________________________________ - #ATTRIBUTES - my %_attr_data = # DEFAULT ACCESSIBILITY - ( - driver => ["DBI:mysql", 'read/write'], - dbh => [undef, 'read/write'], - - ); - - #_____________________________________________________________ - - # METHODS, to operate on encapsulated class data - - # Is a specified object attribute accessible in a given mode - sub _accessible { - my ($self, $attr, $mode) = @_; - $_attr_data{$attr}[1] =~ /$mode/ - } - - # Classwide default value for a specified object attribute - sub _default_for { - my ($self, $attr) = @_; - $_attr_data{$attr}[0]; - } - - # List of names of all specified object attributes - sub _standard_keys { - keys %_attr_data; - } - - sub driver { - my ($self, $arg) = @_; - $self->{driver} = $arg if defined $arg; - return $self->{driver}; - } - sub dbh { - my ($self, $arg) = @_; - $self->{dbh} = $arg if defined $arg; - return $self->{dbh}; - } - -} - -sub new { - my ($caller, %args) = @_; - my $self = $caller->SUPER::new(%args); - - my $caller_is_obj = ref($caller); - my $class = $caller_is_obj || $caller; - - foreach my $attrname ( $self->_standard_keys ) { - if (exists $args{$attrname} && defined $args{$attrname}) { - $self->{$attrname} = $args{$attrname} } - elsif ($caller_is_obj) { - $self->{$attrname} = $caller->{$attrname} } - else { - $self->{$attrname} = $self->_default_for($attrname) } - } - - return unless $self->driver; - my $driver = $self->driver; # inherited from the adaptorI (queryapi) - my $username = $self->username; - my $password = $self->password; - my $port = $self->port; - my $url = $self->url; - my $dbname = $self->dbname; - - my ($dsn) = "$driver:$dbname:$url:$port"; - my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; - - - ############################################################## - unless ($dbh) { - print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; - return undef; - } - - $self->dbh($dbh); - ############################################################# - - return undef unless $self->dbh; - return $self; - -} - -sub _add_condition{ - my ($statement, @params) = @_; - my @bindvalues = (); - my $condition = "where "; - - foreach my $param (@params ) - { - if (($param eq 'and') || ($param eq 'or')) - { - $condition .= $param . " "; - } - else - { - my %pair = %$param; - - for my $key (keys %pair) - { - if (defined $pair{$key}) - { - $condition .= $key . " = ? "; - push(@bindvalues, $pair{$key}); - } - else - { - $condition .= $key . " IS NULL " - } - } - } - } - $statement .= $condition; - return ($statement, @bindvalues); - } - -# preforms query but returns a reference to an array containing hash references -sub do_query{ - my ($dbh, $statement, @bindvalues) = @_; - my $sth = $dbh -> prepare($statement); - if (@bindvalues < 1) - { - $sth->execute; - } - else - { - $sth->execute(@bindvalues); - } - # returns an array of hash references - my $arrayHashRef = $sth->fetchall_arrayref({}); - return $arrayHashRef; -} - -sub get_value{ - my ($key, @params) = @_; - - foreach my $param (@params ) - { - my %pair = %$param; - for my $tmp (keys %pair) - { - if ($tmp eq $key){ - return $pair{$key}; - } - } - } -} - -sub _getSIIDFromLSID { - my ($self, $lsid) = @_; - my $dbh = $self->dbh; - my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); - $sth->execute($lsid); - my ($siid) = $sth->fetchrow_array(); - return $siid; -} - -# this should NOT retun a collection ID... needs more work... -# args passed in: service_lsid -sub query_collection_input{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $serv_lsid = $args{'service_lsid'}; - - my $statement = "select - collection_input_id, - article_name - from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; - my $result = do_query($dbh, $statement, [$serv_lsid]); - return $result; -} - -# args passed in: service_instance_lsid, article_name -sub insert_collection_input { - my ($self, %args) = @_; - my $article = $args{article_name}; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - - $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", - undef, $siid, $article); - my $id=$self->dbh->{mysql_insertid}; - return $id; -} - -# pass in service_instance_lsid -sub delete_collection_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - - my $statement = "delete from collection_input where service_instance_id = ?"; - $self->dbh->do( $statement, undef, $siid); - - if ($self->dbh->err){ - return (1, $self->dbh->errstr); - } - else{ - return 0; - } -} - -# pass service_instance_lsid -sub query_collection_output{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - my $statement = "select - collection_output_id, - article_name, - service_instance_id - from collection_output where service_instance_id = ? "; - my $result = do_query($dbh, $statement, [$siid]); - return $result; -} - -# pass service_instance_lsid, article_name -sub insert_collection_output { - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", - undef, $siid,$args{'article_name'}); - my $id=$self->dbh->{mysql_insertid}; - return $id; -} - -# pass argument service_instance_lsid -sub delete_collection_output{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - my $statement = "delete from collection_output where service_instance_id = ?"; - my @bindvalues = (); - $dbh->do( $statement, undef, ($siid)); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass service_instance_lsid -sub query_simple_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - my $statement = "select - simple_input_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id - from simple_input where service_instance_id = ? and collection_input_id IS NULL"; - my $result = do_query($dbh, $statement, ($siid)); - return $result; -} - -# pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id -sub insert_simple_input { - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - $dbh->do("insert into simple_input - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id) - values (?,?,?,?,?)", - undef, - $args{'object_type_uri'}, - $args{'namespace_type_uris'}, - $args{'article_name'}, - $siid, - $args{'collection_input_id'}); - my $id=$dbh->{mysql_insertid}; - return $id; -} - -# pass service_instance_lsid -sub delete_simple_input{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my ($collid) = $args{collection_input_id}; - my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); - $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); - - $siid && ($dbh->do( $statement1, undef,($siid))); - $collid && ($dbh->do($statement2, undef,($collid))); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub delete_inputs { # this should replace all other delete_*_input - my ($self, %args) = @_; - my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); - - my $statement = "delete from simple_input where service_instance_lsid = ?"; - - $dbh->do( $statement, undef,($siid)); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } - -} - -sub delete_output { # this should replace all other delete_*_output - -} - -# UGH this has to know too much bout the underlying database structure e.g. that one is null and other is full -# this problem is in MOBY::Central line 3321 3346 and 3374 -#****** FIX -# send service_instance_lsid, collection_input_id -sub query_simple_output{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $collid = $args{collection_input_id}; - my $dbh = $self->dbh; - - my $statement = "select - simple_output_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id - from simple_output where service_instance_id = ? and collection_input_id= ?"; - my $result = do_query($dbh, $statement, ($siid, $collid)); - return $result; -} - -# pass args service_instance_id and collection_output_id -sub insert_simple_output { - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - $dbh->do("insert into simple_output - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id) - values (?,?,?,?,?)", - undef,( - $args{'object_type_uri'}, - $args{'namespace_type_uris'}, - $args{'article_name'}, - $siid, - $args{'collection_output_id'})); - my $id=$dbh->{mysql_insertid}; - return $id; - -} - -# pass service_instance_id or collection_output_id -sub delete_simple_output{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my ($collid) = $args{collection_output_id}; - my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); - $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); - - $siid && ($dbh->do( $statement1, undef,($siid))); - $collid && ($dbh->do($statement2, undef,($collid))); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass service_instance_lsid -sub query_secondary_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - my $statement = "select - secondary_input_id, - default_value, - maximum_value, - minimum_value, - enum_value, - datatype, - article_name, - service_instance_id - from secondary_input where service_instance_id = ?"; - my $result = do_query($dbh, $statement, ($siid)); - return $result; -} - -# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid -sub insert_secondary_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, - undef, - ( - $args{'default_value'}, $args{'maximum_value'}, - $args{'minimum_value'}, $args{'enum_value'}, - $args{'datatype'}, $args{'article_name'},$siid) - ); - return $dbh->{mysql_insertid}; -} - -# pass service_instance_lsid -sub delete_secondary_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - my $statement = "delete from secondary_input where service_instance_lsid=?"; - - $dbh->do( $statement, undef, ($siid)); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - - -# receives argument "type", that may be either an LSID or a type term -sub query_object { - my ($self, %args) = @_; - my $type = $args{type}; - my $condition; - if ($type =~ /^urn\:lsid/){ - $condition = "where object_lsid = ?"; - } else { - $condition = "where object_type = ?"; - } - my $statement = "select - object_id, - object_lsid, - object_type, - description, - authority, - contact_email - from object $condition"; - - my $dbh = $self->dbh; - my $result = do_query($dbh, $statement, ($type)); - return $result; -} - -# inserts a new tuple into object table -# pass object_type object_lsid description authority contact_email -sub insert_object{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - $dbh->do("insert into object - (object_type, - object_lsid, - description, - authority, - contact_email) - values (?,?,?,?,?)", - undef, - $args{'object_type'}, - $args{'object_lsid'}, - $args{'description'}, - $args{'authority'}, - $args{'contact_email'}); - my $id=$dbh->{mysql_insertid}; - return $id; -} - -# pass 'type' which is either an LSID or a term -sub delete_object{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $term = $args{type}; - return 0 unless $term; - my $statement = "delete from object where "; - my $condition; - if ($term =~ /^urn\:lsid/){ - $condition = " object_lsid = ?"; - } else { - $condition = " object_type = ?"; - } - $statement = $statement.$condition; - $dbh->do( $statement,undef, ($term) ); - - $self->_delete_object_term2term(type => $term); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass "type" here, should be an LSID, preferably... -sub query_object_term2term{ - my ($self, %args) = @_; - my $type = $args{type}; - my $result = $self->query_object(type => $type); - my $row = shift(@$result); - my $id = $row->{object_id}; - return [{}] unless $id; - my $dbh = $self->dbh; - - my $statement = "select - assertion_id, - relationship_type, - object1_id, - object2_id, - object2_articlename - from object_term2term where object2_id = ?"; - my $result2 = do_query($dbh, $statement, ($id)); - return $result2; -} - -# pass object1_type, object2_type, object2_articlename, relationship_type -sub insert_object_term2term{ - my ($self, %args) = @_; - my $type1 = $args{object1_type}; - my $result = $self->query_object(type => $type1); - my $row = shift(@$result); - my $id1 = $row->{object_id}; - my $type2 = $args{object2_type}; - $result = $self->query_object(type => $type2); - $row = shift(@$result); - my $id2 = $row->{object_id}; - my $relationship_type = $args{relationship_type}; - my $object2_articlename = $args{object2_articlename}; - - my $dbh = $self->dbh; - $dbh->do( - q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, - undef, - $relationship_type, - $id1, - $id2, - $object2_articlename - ); - - return $dbh->{mysql_insertid}; -} - -# pass object 'type' as term or lsid -# this should be a private routine, not a public one. -# SHOULD NOT BE DOCUMENTED IN THE API -sub _delete_object_term2term{ - my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_object(type => $type); - my $row = shift @$result; - my $id = $row->object_id; - - my $dbh = $self->dbh; - my $statement = "delete from object_term2term where object1_id=?"; - $dbh->do( $statement,undef, ($id)); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass servicename and authority_uri -sub query_service_existence { - my ($self, %args) = @_; - my $dbh = $self->dbh; - - my $servicename = $args{'servicename'}; - my $authURI = $args{'authority_uri'}; -# my $id = $args{'authority_id'}; # is it safe to remove this? better be! -# unless ($id){ - my $result = $self->query_authority(authority_uri => $authURI); - return 0 unless @$result[0]; - my $id = @$result[0]->{authority_id}; - return 0 unless $id; -# } - my $statement = "select - service_instance_id, - category, - servicename, - service_type_uri, - authority_id, - url, - contact_email, - authoritative, - description, - signatureURL, - lsid - from service_instance where servicename = ? and authority_id = ?"; - my $final = do_query($dbh, $statement, ($servicename, $id)); - if (@$final[0]){return 1} else {return 0} - -} -# selects all the columns from service_instance table -# where is lsid? - -sub query_service_instance { - my ($self, %args) = @_; - my $dbh = $self->dbh; - - my $authority_id; - #if ($args{'authority_uri'}){ # need to transform URI to a row ID - # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); - # return 0 unless @$result[0]; - # $authority_id = @$result[0]->{authority_id}; - # return 0 unless $authority_id; - #} - #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table - my @args; - while (my ($k, $v) = each %args){ - push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine - } -# if ($authority_id){ -# push @args, ({authority_id => $authority_id}) ; -# } else { -# pop @args; # remove final "and" -# } - - my $statement = "select - service_instance_id, - category, - servicename, - service_type_uri, - authority.authority_uri, - url, - contact_email, - authoritative, - description, - signatureURL, - lsid - from service_instance left join authority on authority.authority_id "; - my @bindvalues; - ($statement, @bindvalues) =_add_condition($statement, @args); - my $final = do_query($dbh, $statement, @bindvalues); - return $final; -} - -# custom query for Moby::Central.pm->findService() -# hmmmmmmm.... I'm not sure that this routine should exist... -# it is redundant to the routine above, if the routine above were executed -# multiple times. I think that is the more correct (though less efficient) -# way to go, since it is "scalable" to every possible underlying data source -# ********FIX change this later... -sub match_service_type_uri{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $uri_list = $args{'service_type_uri'}; - my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; - my @bindvalues = (); - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# passs........ blah blah..... -sub insert_service_instance { - my ($self, %args) = @_; - my $dbh = $self->dbh; - - $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, - undef,( - $args{'category'}, - $args{'servicename'}, - $args{'service_type_uri'}, - $args{'authority_id'}, - $args{'url'}, - $args{'contact_email'}, - $args{'authoritative'}, - $args{'description'}, - $args{'signatureURL'}, - $args{'lsid'})); - - my $id = $dbh->{mysql_insertid}; - return $id; -} - -# pass service_instance_lsid -sub delete_service_instance{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from service_instance where lsid = ?"; - $dbh->do( $statement,undef, ($args{service_instance_lsid}) ); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# Selects all columns -# pass authority_uri -sub query_authority { - my ($self, %args) = @_; - my $authURI = $args{authority_uri}; - my $dbh = $self->dbh; - - my $statement = "select - authority_id, - authority_common_name, - authority_uri, - contact_email - from authority where authority_uri = ?"; - my $result = do_query($dbh, $statement, ($authURI)); - return $result; -} - -# custom query routine used in Moby::Central.pm -> retrieveServiceProviders() -sub getUniqueAuthorityURI{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select distinct authority_uri from authority"; - my @bindvalues = (); - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_authority{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do("insert into authority - (authority_common_name, - authority_uri, - contact_email) - values (?,?,?)", - undef, - (get_value('authority_common_name', @args), - get_value('authority_uri', @args), - get_value('contact_email', @args))); - my $id = $dbh->{mysql_insertid}; - return $id; -} - -sub query_service{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select - service_id, - service_lsid, - service_type, - description, - authority, - contact_email - from service "; - my @bindvalues = (); - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_service{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, - undef, - ( - get_value('service_type', @args), get_value('service_lsid', @args), get_value('description', @args), - get_value('authority', @args), get_value('contact_email', @args) - ) - ); - return $dbh->{mysql_insertid}; -} - -sub delete_service{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from service "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub query_service_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select - assertion_id, - relationship_type, - service1_id, - service2_id - from service_term2term "; - my @bindvalues = (); - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_service_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, - undef, - ( get_value('relationship_type', @args), get_value('service1_id', @args), get_value('service2_id', @args)) - ); - return $dbh->{mysql_insertid}; -} - -sub delete_service_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from service_term2term "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub query_relationship{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - relationship_id, - relationship_lsid, - relationship_type, - container, - description, - authority, - contact_email, - ontology - from relationship "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub query_namespace{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - namespace_id, - namespace_lsid, - namespace_type, - description, - authority, - contact_email - from namespace "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_namespace{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - get_value('namespace_type', @args), get_value('namespace_lsid', @args), get_value('description', @args), - get_value('authority', @args), get_value('contact_email', @args) - ) - ); - return $dbh->{mysql_insertid}; -} - -sub delete_namespace{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from namespace "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub query_namespace_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - assertion_id, - relationship_type, - namespace1_id, - namespace2_id - from namespace_term2term "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub delete_namespace_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from namespace_term2term "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# custom query subroutine for Moby::Central.pm->deregisterObjectClass() -sub checkClassUsedByService -{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $errorMsg = 1; - my $existingURI = get_value('object_type_uri', @args); - - my ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - return 0; -} - -# custom query routine for Moby::Central.pm -> deregisterNamespace() -sub checkNamespaceUsedByService{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $existingURI = get_value('namespace_type_uris', @args); - my $term = get_value('term', @args); - my $errstr; - - my $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - return (0, ""); -} - -# custom query routine for Moby::Central.pm -> findService() -sub checkKeywords{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $param = get_value('findme', @args); - my %findme = %$param; - my $searchstring; - - foreach my $kw ( @{ $findme{keywords} } ) { -# $debug && &_LOG("KEYWORD $kw\n"); - $kw =~ s/\*//g; - $kw = $dbh->quote("%$kw%"); - $searchstring .= " OR description like $kw "; - } - $searchstring =~ s/OR//; # remove just the first OR in the longer statement -# $debug && &_LOG("search $searchstring\n"); - - my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; - my @bindvalues = (); - - my $ids = do_query($dbh, $statement, @bindvalues); - return ($ids, $searchstring); -} - -# custom query subroutine for Moby::Central.pm->_searchForSimple() -sub getFromSimple{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $ancestor_string = get_value('ancestor_string', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); - - my $query = -"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " - ; # if service_instance_id is null then it must be a collection input. - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/OR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; - } - - my $result = do_query($dbh, $query, ()); - return $result; -} - -# custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $objectURI = get_value('objectURI', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); - - my $query = "select - c.service_instance_id, - s.namespace_type_uris - from - simple_$inout as s, - collection_$inout as c - where - s.collection_${inout}_id IS NOT NULL - AND s.collection_${inout}_id = c.collection_${inout}_id - AND object_type_uri = '$objectURI' "; - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/^\sOR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; # add the AND clause - } - - my $result = do_query($dbh, $query, ()); - return $result; -} - -# custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; - my @bindvalues = (); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# custom query for Moby::Central.pm->_flatten -sub getParentTerms{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $type_id = get_value('relationship_type_id', @args); - my $statement = " - select - OE1.term - from - OntologyEntry as OE1, - OntologyEntry as OE2, - Term2Term as TT - where - ontologyentry2_id = OE2.id - and ontologyentry1_id = OE1.id - and relationship_type_id = $type_id - and OE2.term = ?"; - - my @bindvalues = (); - push(@bindvalues, get_value('term', @args)); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# custom query subroutine for selecting from object_term2term and object tables -# used in Moby::OntologyServer.pm->retrieveObject() -sub getObjectRelationships{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - relationship_type, - object_lsid, - object2_articlename - from object_term2term, object - where object1_id = ? and object2_id = object_id"; - - my @bindvalues = (); - push(@bindvalues, get_value('object1_id', @args)); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() -# note: returns a reference to an array containing ARRAY references -sub getRelationship{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $direction = get_value('direction', @args); - my $ontology = get_value('ontology', @args); - my $term = get_value('term', @args); - my $relationship = get_value('relationship', @args); - my $defs; - - if ( $direction eq 'root' ) { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } else { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } - return $defs; -} - -sub _checkURI { - -# my $uri = "http://www.ics.uci.edu/pub/ietf/uri/#Related"; -#print "$1, $2, $3, $4, $5, $6, $7, $8, $9" if -# $uri =~ m{^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?}; -# -#The license for this recipe is available here. -# -#Discussion: -# -#If the match is successful, a URL such as -# -#http://www.ics.uci.edu/pub/ietf/uri/#Related -# -#will be broken down into the following group match variables: -# -#$1 = http: -#$2 = http -#$3 = //www.ics.uci.edu -#$4 = www.ics.uci.edu -#$5 = /pub/ietf/uri/ -#$6 = -#$7 = -#$8 = #Related -#$9 = Related -# -#In general, this regular expression breaks a URI down into the following parts, -#as defined in the RFC: -# -#scheme = $2 -#authority = $4 -#path = $5 -#query = $7 -#fragment = $9 - -} - -sub DESTROY {} - -1; +package MOBY::Adaptor::moby::queryapi::mysql; + +use strict; +use vars qw($AUTOLOAD @ISA); +use Carp; +use MOBY::Adaptor::moby::queryapi; +use DBI; +use DBD::mysql; + +@ISA = qw{MOBY::Adaptor::moby::queryapi}; # implements the interface + +{ + #Encapsulated class data + + #___________________________________________________________ + #ATTRIBUTES + my %_attr_data = # DEFAULT ACCESSIBILITY + ( + driver => ["DBI:mysql", 'read/write'], + dbh => [undef, 'read/write'], + + ); + + #_____________________________________________________________ + + # METHODS, to operate on encapsulated class data + + # Is a specified object attribute accessible in a given mode + sub _accessible { + my ($self, $attr, $mode) = @_; + $_attr_data{$attr}[1] =~ /$mode/ + } + + # Classwide default value for a specified object attribute + sub _default_for { + my ($self, $attr) = @_; + $_attr_data{$attr}[0]; + } + + # List of names of all specified object attributes + sub _standard_keys { + keys %_attr_data; + } + + sub driver { + my ($self, $arg) = @_; + $self->{driver} = $arg if defined $arg; + return $self->{driver}; + } + sub dbh { + my ($self, $arg) = @_; + $self->{dbh} = $arg if defined $arg; + return $self->{dbh}; + } + +} + +sub new { + my ($caller, %args) = @_; + my $self = $caller->SUPER::new(%args); + + my $caller_is_obj = ref($caller); + my $class = $caller_is_obj || $caller; + + foreach my $attrname ( $self->_standard_keys ) { + if (exists $args{$attrname} && defined $args{$attrname}) { + $self->{$attrname} = $args{$attrname} } + elsif ($caller_is_obj) { + $self->{$attrname} = $caller->{$attrname} } + else { + $self->{$attrname} = $self->_default_for($attrname) } + } + + return unless $self->driver; + my $driver = $self->driver; # inherited from the adaptorI (queryapi) + my $username = $self->username; + my $password = $self->password; + my $port = $self->port; + my $url = $self->url; + my $dbname = $self->dbname; + + my ($dsn) = "$driver:$dbname:$url:$port"; + my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; + + + ############################################################## + unless ($dbh) { + print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; + return undef; + } + + $self->dbh($dbh); + ############################################################# + + return undef unless $self->dbh; + return $self; + +} + +sub _add_condition{ + my ($statement, @params) = @_; + my @bindvalues = (); + my $condition = "where "; + + foreach my $param (@params ) + { + if (($param eq 'and') || ($param eq 'or')) + { + $condition .= $param . " "; + } + else + { + my %pair = %$param; + + for my $key (keys %pair) + { + if (defined $pair{$key}) + { + $condition .= $key . " = ? "; + push(@bindvalues, $pair{$key}); + } + else + { + $condition .= $key . " IS NULL " + } + } + } + } + $statement .= $condition; + return ($statement, @bindvalues); + } + +# preforms query but returns a reference to an array containing hash references +sub do_query{ + my ($dbh, $statement, @bindvalues) = @_; + my $sth = $dbh -> prepare($statement); + if (@bindvalues < 1) + { + $sth->execute; + } + else + { + $sth->execute(@bindvalues); + } + # returns an array of hash references + my $arrayHashRef = $sth->fetchall_arrayref({}); + return $arrayHashRef; +} + +sub get_value{ + my ($key, @params) = @_; + + foreach my $param (@params ) + { + my %pair = %$param; + for my $tmp (keys %pair) + { + if ($tmp eq $key){ + return $pair{$key}; + } + } + } +} + +sub _getSIIDFromLSID { + my ($self, $lsid) = @_; + my $dbh = $self->dbh; + my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); + $sth->execute($lsid); + my ($siid) = $sth->fetchrow_array(); + return $siid; +} + +# this should NOT retun a collection ID... needs more work... +# args passed in: service_lsid +sub query_collection_input{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $serv_lsid = $args{'service_lsid'}; + + my $statement = "select + collection_input_id, + article_name + from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; + my $result = do_query($dbh, $statement, [$serv_lsid]); + return $result; +} + +# args passed in: service_instance_lsid, article_name +sub insert_collection_input { + my ($self, %args) = @_; + my $article = $args{article_name}; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", + undef, $siid, $article); + my $id=$self->dbh->{mysql_insertid}; + return $id; +} + +# pass in service_instance_lsid +sub delete_collection_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + my $statement = "delete from collection_input where service_instance_id = ?"; + $self->dbh->do( $statement, undef, $siid); + + if ($self->dbh->err){ + return (1, $self->dbh->errstr); + } + else{ + return 0; + } +} + +# pass service_instance_lsid +sub query_collection_output{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + collection_output_id, + article_name, + service_instance_id + from collection_output where service_instance_id = ? "; + my $result = do_query($dbh, $statement, [$siid]); + return $result; +} + +# pass service_instance_lsid, article_name +sub insert_collection_output { + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", + undef, $siid,$args{'article_name'}); + my $id=$self->dbh->{mysql_insertid}; + return $id; +} + +# pass argument service_instance_lsid +sub delete_collection_output{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from collection_output where service_instance_id = ?"; + my @bindvalues = (); + $dbh->do( $statement, undef, ($siid)); + + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass service_instance_lsid +sub query_simple_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + simple_input_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id + from simple_input where service_instance_id = ? and collection_input_id IS NULL"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; +} + +# pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id +sub insert_simple_input { + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do("insert into simple_input + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id) + values (?,?,?,?,?)", + undef, + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_input_id'}); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +# pass service_instance_lsid +sub delete_simple_input{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($collid) = $args{collection_input_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +sub delete_inputs { # this should replace all other delete_*_input + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); + + my $statement = "delete from simple_input where service_instance_lsid = ?"; + + $dbh->do( $statement, undef,($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } + +} + +sub delete_output { # this should replace all other delete_*_output + +} + +# UGH this has to know too much bout the underlying database structure e.g. that one is null and other is full +# this problem is in MOBY::Central line 3321 3346 and 3374 +#****** FIX +# send service_instance_lsid, collection_input_id +sub query_simple_output{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $collid = $args{collection_input_id}; + my $dbh = $self->dbh; + + my $statement = "select + simple_output_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id + from simple_output where service_instance_id = ? and collection_input_id= ?"; + my $result = do_query($dbh, $statement, ($siid, $collid)); + return $result; +} + +# pass args service_instance_id and collection_output_id +sub insert_simple_output { + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + $dbh->do("insert into simple_output + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id) + values (?,?,?,?,?)", + undef,( + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_output_id'})); + my $id=$dbh->{mysql_insertid}; + return $id; + +} + +# pass service_instance_id or collection_output_id +sub delete_simple_output{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($collid) = $args{collection_output_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass service_instance_lsid +sub query_secondary_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + secondary_input_id, + default_value, + maximum_value, + minimum_value, + enum_value, + datatype, + article_name, + service_instance_id + from secondary_input where service_instance_id = ?"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; +} + +# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid +sub insert_secondary_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, + undef, + ( + $args{'default_value'}, $args{'maximum_value'}, + $args{'minimum_value'}, $args{'enum_value'}, + $args{'datatype'}, $args{'article_name'},$siid) + ); + return $dbh->{mysql_insertid}; +} + +# pass service_instance_lsid +sub delete_secondary_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from secondary_input where service_instance_lsid=?"; + + $dbh->do( $statement, undef, ($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + + +# receives argument "type", that may be either an LSID or a type term +sub query_object { + my ($self, %args) = @_; + my $type = $args{type}; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where object_lsid = ?"; + } elsif ($type) { + $condition = "where object_type = ?"; + } + my $statement = "select + object_id, + object_lsid, + object_type, + description, + authority, + contact_email + from object $condition"; + + my $dbh = $self->dbh; + my $result = do_query($dbh, $statement, ($type)); + return $result; +} + +# inserts a new tuple into object table +# pass object_type object_lsid description authority contact_email +sub insert_object{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into object + (object_type, + object_lsid, + description, + authority, + contact_email) + values (?,?,?,?,?)", + undef, + $args{'object_type'}, + $args{'object_lsid'}, + $args{'description'}, + $args{'authority'}, + $args{'contact_email'}); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +# pass 'type' which is either an LSID or a term +sub delete_object{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $term = $args{type}; + return 0 unless $term; + my $statement = "delete from object where "; + my $condition; + if ($term =~ /^urn\:lsid/){ + $condition = " object_lsid = ?"; + } else { + $condition = " object_type = ?"; + } + $statement = $statement.$condition; + $dbh->do( $statement,undef, ($term) ); + + $self->_delete_object_term2term(type => $term); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass "type" here, should be an LSID, preferably... +sub query_object_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_object(type => $type); + my $row = shift(@$result); + my $id = $row->{object_id}; + return [{}] unless $id; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + object1_id, + object2_id, + object2_articlename + from object_term2term where object2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; +} + +# pass object1_type, object2_type, object2_articlename, relationship_type +sub insert_object_term2term{ + my ($self, %args) = @_; + my $type1 = $args{object1_type}; + my $result = $self->query_object(type => $type1); + my $row = shift(@$result); + my $id1 = $row->{object_id}; + my $type2 = $args{object2_type}; + $result = $self->query_object(type => $type2); + $row = shift(@$result); + my $id2 = $row->{object_id}; + my $relationship_type = $args{relationship_type}; + my $object2_articlename = $args{object2_articlename}; + + my $dbh = $self->dbh; + $dbh->do( + q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, + undef, + $relationship_type, + $id1, + $id2, + $object2_articlename + ); + + return $dbh->{mysql_insertid}; +} + +# pass object 'type' as term or lsid +# this should be a private routine, not a public one. +# SHOULD NOT BE DOCUMENTED IN THE API +sub _delete_object_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $id = $row->object_id; + + my $dbh = $self->dbh; + my $statement = "delete from object_term2term where object1_id=?"; + $dbh->do( $statement,undef, ($id)); + + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass servicename and authority_uri +sub query_service_existence { + my ($self, %args) = @_; + my $dbh = $self->dbh; + + my $servicename = $args{'servicename'}; + my $authURI = $args{'authority_uri'}; + my $result = $self->_query_authority(authority_uri => $authURI); + return 0 unless @$result[0]; + my $id = @$result[0]->{authority_id}; + return 0 unless $id; + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority_id, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance where servicename = ? and authority_id = ?"; + my $final = do_query($dbh, $statement, ($servicename, $id)); + if (@$final[0]){return 1} else {return 0} + +} +# selects all the columns from service_instance table +# PAY ATTENTION to what this returns. Not auth_id but auth_uri!! +sub query_service_instance { + my ($self, %args) = @_; + my $dbh = $self->dbh; + + #my $authority_id; + #if ($args{'authority_uri'}){ # need to transform URI to a row ID + # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); + # return 0 unless @$result[0]; + # $authority_id = @$result[0]->{authority_id}; + # return 0 unless $authority_id; + #} + #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table + my @args; + while (my ($k, $v) = each %args){ + push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine + } +# if ($authority_id){ +# push @args, ({authority_id => $authority_id}) ; +# } else { +# pop @args; # remove final "and" +# } + + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority.authority_uri, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance left join authority on authority.authority_id "; + my @bindvalues; + ($statement, @bindvalues) =_add_condition($statement, @args); + my $final = do_query($dbh, $statement, @bindvalues); + return $final; +} + +# custom query for Moby::Central.pm->findService() +# hmmmmmmm.... I'm not sure that this routine should exist... +# it is redundant to the routine above, if the routine above were executed +# multiple times. I think that is the more correct (though less efficient) +# way to go, since it is "scalable" to every possible underlying data source +# ********FIX change this later... +sub match_service_type_uri{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $uri_list = $args{'service_type_uri'}; + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; + my @bindvalues = (); + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# passs........ blah blah..... +sub insert_service_instance { + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $authority_id; + if ($args{'authority_uri'}){ # need to transform URI to a row ID + my $result = $self->_query_authority(authority_uri => $args{'authority_uri'}); + return undef unless @$result[0]; + $authority_id = @$result[0]->{authority_id}; + return undef unless $authority_id; + } + + $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, + undef,( + $args{'category'}, + $args{'servicename'}, + $args{'service_type_uri'}, + $authority_id, + $args{'url'}, + $args{'contact_email'}, + $args{'authoritative'}, + $args{'description'}, + $args{'signatureURL'}, + $args{'lsid'})); + + my $id = $dbh->{mysql_insertid}; + return $id; +} + +# pass service_instance_lsid +sub delete_service_instance{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service_instance where lsid = ?"; + $dbh->do( $statement,undef, ($args{service_instance_lsid}) ); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# Selects all columns EXCEPT authority_id +# pass authority_uri +sub query_authority { + my ($self, %args) = @_; + my $authURI = $args{authority_uri}; + my $dbh = $self->dbh; + + my $statement = "select + authority_common_name, + authority_uri, + contact_email + from authority where authority_uri = ?"; + my $result = do_query($dbh, $statement, ($authURI)); + return $result; +} + +# Selects all columns including authority_id +# pass authority_uri. NOTE THAT THIS IS A PRIVATE ROUTINE +# SHOULD NOT BE DOCUMENTED IN THE API +sub _query_authority { + my ($self, %args) = @_; + my $authURI = $args{authority_uri}; + my $dbh = $self->dbh; + + my $statement = "select + authority_common_name, + authority_uri, + authority_id, + contact_email + from authority where authority_uri = ?"; + my $result = do_query($dbh, $statement, ($authURI)); + return $result; +} + +# custom query routine used in Moby::Central.pm -> retrieveServiceProviders() +# no args passed +sub get_all_authorities{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select distinct authority_uri from authority"; + my @bindvalues = (); + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# pass authority_common_name, authority_uri, contact_email, return ID of some sort +sub insert_authority{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into authority + (authority_common_name, + authority_uri, + contact_email) + values (?,?,?)", + undef, + ($args{'authority_common_name'}, + $args{'authority_uri'}, + $args{'contact_email'})); + my $id = $dbh->{mysql_insertid}; + return $id; +} + +# pass service_type, as term or LSID +sub query_service{ + my ($self, %args) = @_; + my $type = $args{type}; + return [{}] unless $type; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where service_lsid = ?"; + } elsif ($type) { + $condition = "where service_type = ?"; + } + + my $dbh = $self->dbh; + my $statement = "select + service_id, + service_lsid, + service_type, + description, + authority, + contact_email + from service $condition"; + my $result = do_query($dbh, $statement, ($type)); + return $result; +} + +# pass in .... +sub insert_service{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do(q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, + undef, + ( + $args{'service_type'}, $args{'service_lsid'}, $args{'description'}, + $args{'authority'}, $args{'contact_email'} + ) + ); + return $dbh->{mysql_insertid}; +} + +# pass in service type as LSID (service_lsid) +sub delete_service{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service where service_lsid = ?"; + $dbh->do( $statement, undef, ($args{service_lsid})); + $self->_delete_service_term2term; + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +sub query_service_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_service(type => $type); + my $row = shift(@$result); + my $id = $row->{service_id}; + return [{}] unless $id; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + service1_id, + service2_id, + from service_term2term where service2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; +} + +#pass relationshiptype, servce1_type, service2_type +sub insert_service_term2term{ + my ($self, %args) = @_; + my $type1 = $args{service1_type}; + my $result = $self->query_service(type => $type1); + my $row = shift(@$result); + my $id1 = $row->{service_id}; + my $type2 = $args{service2_type}; + $result = $self->query_service(type => $type2); + $row = shift(@$result); + my $id2 = $row->{service_id}; + my $relationship_type = $args{relationship_type}; + + my $dbh = $self->dbh; + $dbh->do(q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, + undef, + ($relationship_type, + $id1, + $id2) + ); + + return $dbh->{mysql_insertid}; +} + + +# NOTE THAT THIS IS A PRIVATE FUNCTION AND SHOULD +# NOT BE DOCUMENTED IN THE API. +sub _delete_service_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_service(type => $type); + my $row = shift @$result; + my $id = $row->service_id; + + my $dbh = $self->dbh; + my $statement = "delete from service_term2term where service1_id=?"; + $dbh->do( $statement,undef, ($id)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + + +sub query_relationship{ + my ($self, %args) = @_; + my $type = $args{type}; + return [{}] unless $type; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where relationship_lsid = ? and "; + } elsif ($type) { + $condition = "where relationship_type = ? and"; + } + my $ont = $args{ontology}; + + my $dbh = $self->dbh; + + my $statement = "select + relationship_id, + relationship_lsid, + relationship_type, + container, + description, + authority, + contact_email, + ontology + from relationship where $condition ontology = ?"; + + if ($type){ + return do_query($dbh, $statement, ($type, $ont)); + } else { + return do_query($dbh, $statement, ($ont)); + } +} + +sub query_namespace{ + my ($self, %args) = @_; + my $type = $args{type}; + return [{}] unless $type; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where namespace_lsid = ? and "; + } elsif ($type) { + $condition = "where namespace_type = ? and"; + } + my $dbh = $self->dbh; + + my $statement = "select + namespace_id, + namespace_lsid, + namespace_type, + description, + authority, + contact_email + from namespace $condition"; + my $result = do_query($dbh, $statement, ($type)); + return $result; +} + + +sub insert_namespace{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do(q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, + undef, + ( + $args{'namespace_type'}, $args{'namespace_lsid'},$args{'description'},$args{'authority'},$args{'contact_email'} + ) + ); + return $dbh->{mysql_insertid}; +} + +# pass namesapce_lsid +sub delete_namespace{ + my ($self, %args) = @_; + my $lsid = $args{namespace_lsid}; + my $dbh = $self->dbh; + my $statement = "delete from namespace where namespace_lsid = ?"; + $dbh->do( $statement, undef, ($lsid)); + $self->_delete_namespace_term2term; + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +sub query_namespace_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_namespace(type => $type); + my $row = shift(@$result); + my $id = $row->{namespace_id}; + return [{}] unless $id; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + namespace1_id, + namespace2_id, + from namespace_term2term where namespace2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; +} + +# PRIVATE, NOT PART OF API! +sub _delete_namespace_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_namespace(type => $type); + my $row = shift @$result; + my $id = $row->namespace_id; + + my $dbh = $self->dbh; + my $statement = "delete from namespace_term2term where namespace1_id=?"; + $dbh->do( $statement,undef, ($id)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# custom query subroutine for Moby::Central.pm->deregisterObjectClass() +# MARK LOOK HERE!!! +# may need two different adaptors for this... one for the object table and other for the mobycentral table +sub check_object_usage{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $errorMsg = 1; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_namespace(type => $type); + my $row = shift @$result; + my $lsid = $row->{object_lsid}; + + my ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + return 0; +} + +# custom query routine for Moby::Central.pm -> deregisterNamespace() +sub checkNamespaceUsedByService{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $existingURI = get_value('namespace_type_uris', @args); + my $term = get_value('term', @args); + my $errstr; + + my $sth = $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + $sth = $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + return (0, ""); +} + +# custom query routine for Moby::Central.pm -> findService() +sub checkKeywords{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $param = get_value('findme', @args); + my %findme = %$param; + my $searchstring; + + foreach my $kw ( @{ $findme{keywords} } ) { +# $debug && &_LOG("KEYWORD $kw\n"); + $kw =~ s/\*//g; + $kw = $dbh->quote("%$kw%"); + $searchstring .= " OR description like $kw "; + } + $searchstring =~ s/OR//; # remove just the first OR in the longer statement +# $debug && &_LOG("search $searchstring\n"); + + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; + my @bindvalues = (); + + my $ids = do_query($dbh, $statement, @bindvalues); + return ($ids, $searchstring); +} + +# custom query subroutine for Moby::Central.pm->_searchForSimple() +sub getFromSimple{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $ancestor_string = get_value('ancestor_string', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = +"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " + ; # if service_instance_id is null then it must be a collection input. + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/OR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; + } + + my $result = do_query($dbh, $query, ()); + return $result; +} + +# custom query subroutine for Moby::Central.pm->_searchForCollection() +sub getFromCollection{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $objectURI = get_value('objectURI', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = "select + c.service_instance_id, + s.namespace_type_uris + from + simple_$inout as s, + collection_$inout as c + where + s.collection_${inout}_id IS NOT NULL + AND s.collection_${inout}_id = c.collection_${inout}_id + AND object_type_uri = '$objectURI' "; + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/^\sOR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; # add the AND clause + } + + my $result = do_query($dbh, $query, ()); + return $result; +} + +# custom query subroutine for Moby::Central.pm->RetrieveServiceNames +sub getServiceNames{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; + my @bindvalues = (); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query for Moby::Central.pm->_flatten +sub getParentTerms{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $type_id = get_value('relationship_type_id', @args); + my $statement = " + select + OE1.term + from + OntologyEntry as OE1, + OntologyEntry as OE2, + Term2Term as TT + where + ontologyentry2_id = OE2.id + and ontologyentry1_id = OE1.id + and relationship_type_id = $type_id + and OE2.term = ?"; + + my @bindvalues = (); + push(@bindvalues, get_value('term', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query subroutine for selecting from object_term2term and object tables +# used in Moby::OntologyServer.pm->retrieveObject() +sub getObjectRelationships{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + relationship_type, + object_lsid, + object2_articlename + from object_term2term, object + where object1_id = ? and object2_id = object_id"; + + my @bindvalues = (); + push(@bindvalues, get_value('object1_id', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() +# note: returns a reference to an array containing ARRAY references +sub getRelationship{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $direction = get_value('direction', @args); + my $ontology = get_value('ontology', @args); + my $term = get_value('term', @args); + my $relationship = get_value('relationship', @args); + my $defs; + + if ( $direction eq 'root' ) { + unless ( defined $relationship ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $term ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + } + } else { + unless ( defined $relationship ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s2.${ontology}_lsid = ?", undef, $term ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + } + } + return $defs; +} + +sub _checkURI { + +# my $uri = "http://www.ics.uci.edu/pub/ietf/uri/#Related"; +#print "$1, $2, $3, $4, $5, $6, $7, $8, $9" if +# $uri =~ m{^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?}; +# +#The license for this recipe is available here. +# +#Discussion: +# +#If the match is successful, a URL such as +# +#http://www.ics.uci.edu/pub/ietf/uri/#Related +# +#will be broken down into the following group match variables: +# +#$1 = http: +#$2 = http +#$3 = //www.ics.uci.edu +#$4 = www.ics.uci.edu +#$5 = /pub/ietf/uri/ +#$6 = +#$7 = +#$8 = #Related +#$9 = Related +# +#In general, this regular expression breaks a URI down into the following parts, +#as defined in the RFC: +# +#scheme = $2 +#authority = $4 +#path = $5 +#query = $7 +#fragment = $9 + +} + +sub DESTROY {} + +1; From dwang at pub.open-bio.org Tue Jul 26 01:19:37 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue Jul 26 02:06:53 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507260519.j6Q5JbK8023025@pub.open-bio.org> dwang Tue Jul 26 01:19:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv23000/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added some more comments. some subroutines are still under modification, so holding out for now... don't quite understand what $type is. moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:45:29 1.13 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 05:19:37 1.14 @@ -539,21 +539,36 @@ die "delete_namespace not implemented in adaptor\n"; } -# +=head2 query_namespace_term2term + + Title : query_namespace_term2term + Usage : my $un = $API->query_namespace_term2term(%args) + Function : Execute a query for namespaces_term2term + Args : type => String - namespace_type you are checking for + Returns : listref of hashrefs: + [{assertion_id => Integer, + relationship_type => String, + namespace1_id => Integer, + namespace2_id => Integer}] + +=cut # namespace_term2term table functions -# sub query_namespace_term2term{ die "query_namespace_term2term not implemented in adaptor\n"; } +# does not exist in mysql api, should this be removed? sub insert_namespace_term2term{ die "insert_namespace_term2term not implemented in adaptor\n"; } -sub delete_namespace_term2term{ +# changed to a private subroutine in mysql +# I guess this subroutine should be removed from here? +sub _delete_namespace_term2term{ die "delete_namespace_term2term not implemented in adaptor\n"; } +# still incomplete... # custom query subroutine for Moby::Central.pm->deregisterObjectClass() sub check_object_usage{ die "check_object_usage not implemented in adaptor\n"; From kawas at pub.open-bio.org Tue Jul 26 10:50:21 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 26 11:37:15 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261450.j6QEoL06024431@pub.open-bio.org> kawas Tue Jul 26 10:50:21 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv24406/org/biomoby/registry/rdfagent/vocabulary Modified Files: MP.java Log Message: updated the predicate vocabulary again to include the newest predicates. moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary MP.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/07/25 20:20:44 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/07/26 14:50:21 1.6 @@ -52,6 +52,10 @@ public static final Property Simple = m.getProperty(uri + "Simple" ) ; public static final Property Collection = m.getProperty(uri + "Collection" ) ; public static final Property Secondary = m.getProperty(uri + "Secondary" ) ; + /* new predicates */ + public static final Property sampleInputData = m.getProperty(uri + "sampleInputData"); + public static final Property sampleOutputData = m.getProperty(uri + "sampleOutputData"); + public static final Property approvedBy = m.getProperty(uri + "approvedBy"); } From kawas at pub.open-bio.org Tue Jul 26 10:53:12 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 26 11:39:55 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261453.j6QErCXa024480@pub.open-bio.org> kawas Tue Jul 26 10:53:12 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv24455/org/biomoby/client/rdf/vocabulary Modified Files: Predicates.java Log Message: *removed the ability to modify the domain of a URI. *added 3 predicates that were added to biomoby.org/RESOURCES/MOBY-S/Predicates. *removed any MobyResources.java references that existed directly or indirectly. moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary Predicates.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/20 17:42:31 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/26 14:53:12 1.5 @@ -14,46 +14,50 @@ /** * @author Eddie Kawas - *

Created for - *

This class was created to ... + *

Created for the BioMoby project. + *

This class was created to represent the RDF predicate vocabulary in BioMoby under the namespace mobyPred. *

For questions, comments, or bugs *

email me at edward.kawas@gmail.com */ public class Predicates { private final static Properties properties = MobyProperties.PROPERTIES(); - protected final static String uri = "http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#"; + protected final static String uri = "http://biomoby.org/RESOURCES/MOBY-S/Predicates#"; private final static Model _model = ModelFactory.createDefaultModel();; - public static final Property category = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#category"); - public static final Property isa = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#isa"); - public static final Property has = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#has"); - public static final Property hasa = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#hasa"); - public static final Property articleName = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#articleName"); - public static final Property article_name = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#article_name"); - public static final Property namespace_type = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#namespace_type"); - public static final Property object_type = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#object_type"); - public static final Property input = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#input"); - public static final Property output = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#output"); - public static final Property consumes = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#consumes"); - public static final Property produces = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#produces"); - public static final Property performs_task = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#performs_task"); - public static final Property comment = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#comment"); - public static final Property label = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#label"); - public static final Property default_value = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#default_value"); - public static final Property datatype = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#datatype"); - public static final Property max = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#max"); - public static final Property min = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#min"); - public static final Property enumeration = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#enum"); - public static final Property SimpleArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SimpleArticle"); - public static final Property CollectionArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#CollectionArticle"); - public static final Property SecondaryArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SecondaryArticle"); - public static final Property SignatureURL = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SignatureURL"); - public static final Property authoritative = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#authoritative"); - public static final Property ofType = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#ofType"); + public static final Property category = _model.getProperty(uri + "category"); + public static final Property isa = _model.getProperty(uri + "isa"); + public static final Property has = _model.getProperty(uri + "has"); + public static final Property hasa = _model.getProperty(uri + "hasa"); + public static final Property articleName = _model.getProperty(uri + "articleName"); + public static final Property article_name = _model.getProperty(uri + "article_name"); + public static final Property namespace_type = _model.getProperty(uri + "namespace_type"); + public static final Property object_type = _model.getProperty(uri + "object_type"); + public static final Property input = _model.getProperty(uri + "input"); + public static final Property output = _model.getProperty(uri + "output"); + public static final Property consumes = _model.getProperty(uri + "consumes"); + public static final Property produces = _model.getProperty(uri + "produces"); + public static final Property performs_task = _model.getProperty(uri + "performs_task"); + public static final Property comment = _model.getProperty(uri + "comment"); + public static final Property label = _model.getProperty(uri + "label"); + public static final Property default_value = _model.getProperty(uri + "default_value"); + public static final Property datatype = _model.getProperty(uri + "datatype"); + public static final Property max = _model.getProperty(uri + "max"); + public static final Property min = _model.getProperty(uri + "min"); + public static final Property enumeration = _model.getProperty(uri + "enum"); + public static final Property SimpleArticle = _model.getProperty(uri + "SimpleArticle"); + public static final Property CollectionArticle = _model.getProperty(uri + "CollectionArticle"); + public static final Property SecondaryArticle = _model.getProperty(uri + "SecondaryArticle"); + public static final Property SignatureURL = _model.getProperty(uri + "SignatureURL"); + public static final Property authoritative = _model.getProperty(uri + "authoritative"); + public static final Property ofType = _model.getProperty(uri + "ofType"); /* moved from MobyResources.java */ - public static final Property Simple = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Simple"); - public static final Property Secondary = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Secondary"); - public static final Property Collection = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Collection"); + public static final Property Simple = _model.getProperty(uri + "Simple"); + public static final Property Secondary = _model.getProperty(uri + "Secondary"); + public static final Property Collection = _model.getProperty(uri + "Collection"); + /* new predicates */ + public static final Property sampleInputData = _model.getProperty(uri + "sampleInputData"); + public static final Property sampleOutputData = _model.getProperty(uri + "sampleOutputData"); + public static final Property approvedBy = _model.getProperty(uri + "approvedBy"); public final static String getURI() { return uri; From kawas at pub.open-bio.org Tue Jul 26 10:56:19 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 26 11:43:00 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261456.j6QEuJsG024549@pub.open-bio.org> kawas Tue Jul 26 10:56:19 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder In directory pub.open-bio.org:/tmp/cvs-serv24524/org/biomoby/client/rdf/builder Modified Files: RDFConfigure.java Log Message: updated the old references to the MobyResources.java predicate vocabulary to the 'new' one. moby-live/Java/src/main/org/biomoby/client/rdf/builder RDFConfigure.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/07/19 15:54:02 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/07/26 14:56:19 1.4 @@ -7,7 +7,6 @@ import java.net.URL; import java.util.Properties; -import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; import org.biomoby.registry.properties.MobyProperties; @@ -268,10 +267,10 @@ // get the statements for the item in the bag // could be a bag or just a simple StmtIterator sit = item.listProperties(); - if (item.hasProperty(RDF.type, MobyResources.SimpleArticle)) { + if (item.hasProperty(RDF.type, Predicates.Simple)) { // create a simple article Resource _li = rdf.createResource(); - _li.addProperty(RDF.type, MobyResources.SimpleArticle); + _li.addProperty(RDF.type, Predicates.Simple); _li.addProperty(Predicates.object_type, model .getResource(item.getProperty( Predicates.object_type).getObject() @@ -295,11 +294,11 @@ _bag.add(_li); } if (item.hasProperty(RDF.type, - MobyResources.SecondaryArticle)) { + Predicates.Secondary)) { // create a secondary article Resource _li = rdf.createResource(); _li.addProperty(RDF.type, - MobyResources.SecondaryArticle); + Predicates.Secondary); boolean isInt = false; if (item.hasProperty(Predicates.datatype)) { String str = item.getProperty(Predicates.datatype) @@ -369,11 +368,11 @@ // add the item to the bag _bag.add(_li); } - if (item.hasProperty(RDF.type, MobyResources.Collection)) { + if (item.hasProperty(RDF.type, Predicates.Collection)) { // create a collection Bag collectionBag = rdf.createBag(); collectionBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); collectionBag.addProperty(RDFS.subClassOf, RDF.Bag); if (item.hasProperty(Predicates.articleName)) { String str = item.getProperty( @@ -392,7 +391,7 @@ Resource simple = cStatement.getResource(); Resource _li = rdf.createResource(); _li.addProperty(RDF.type, - MobyResources.SimpleArticle); + Predicates.Simple); _li.addProperty(Predicates.object_type, model .getResource(simple.getProperty( Predicates.object_type) From kawas at pub.open-bio.org Tue Jul 26 10:57:07 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 26 11:43:47 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261457.j6QEv7vx024603@pub.open-bio.org> kawas Tue Jul 26 10:57:07 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder In directory pub.open-bio.org:/tmp/cvs-serv24578/org/biomoby/client/rdf/builder Modified Files: ServiceInstanceRDF.java Log Message: updated the old references to the MobyResources.java predicate vocabulary to the 'new' one. moby-live/Java/src/main/org/biomoby/client/rdf/builder ServiceInstanceRDF.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/07/19 15:54:02 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/07/26 14:57:07 1.6 @@ -10,7 +10,6 @@ import java.util.regex.Pattern; import org.biomoby.client.CentralImpl; -import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; import org.biomoby.registry.properties.MobyProperties; import org.biomoby.shared.Central; @@ -270,7 +269,6 @@ map.put("serviceInstances", SI); map.put("mobyNamespace", NS); map.put("mobyService", SRV); - map.put("moby", MobyResources.getURI()); model.setNsPrefixes(map); for (int i = 0; i < services.length; i++) { @@ -336,7 +334,7 @@ } innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) primaryInputs[j]) .getName().equals("")) innerBag @@ -388,7 +386,7 @@ _li.addProperty(Predicates.datatype, model .createTypedLiteral(data.getDataType())); _li.addProperty(RDF.type, - MobyResources.SecondaryArticle); + Predicates.Secondary); if (data.getDataType().equals("Integer")) { _li .addProperty(Predicates.min, model @@ -440,7 +438,7 @@ produceBag = model.createBag(); innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) outputs[j]) .getName().equals("")) innerBag @@ -511,7 +509,7 @@ */ private final static Resource createSimpleDataItem(Model model, MobyPrimaryDataSimple simpleData, Resource _li) { - _li.addProperty(RDF.type, MobyResources.SimpleArticle); + _li.addProperty(RDF.type, Predicates.Simple); _li.addProperty(Predicates.object_type, model.createResource(OBJ + simpleData.getDataType().getName())); if (!simpleData.getName().equals("")) From dwang at pub.open-bio.org Tue Jul 26 17:55:28 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue Jul 26 18:42:08 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262155.j6QLtSwa025501@pub.open-bio.org> dwang Tue Jul 26 17:55:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv25475/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: slightly more comments moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 05:19:37 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 21:55:28 1.15 @@ -527,14 +527,53 @@ # # namespace table functions # +=head2 query_namespace + + Title : insert_namespace + Usage : my $un = $API->insert_namespace(%args) + Function : Deletes a namespace instance from the database + Args : namespace_type => String, + namespace_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer mysql_insertid + Notes : the fact that it returns a mysql_insertid is bad since this + is only useful to an SQL-based API... +=cut sub query_namespace{ die "query_namespace not implemented in adaptor\n"; } +=head2 insert_namespace + + Title : insert_namespace + Usage : my $un = $API->insert_namespace(%args) + Function : Deletes a namespace instance from the database + Args : namespace_type => String, + namespace_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer mysql_insertid + Notes : the fact that it returns a mysql_insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_namespace{ die "insert_namespace not implemented in adaptor\n"; } +=head2 delete_namespace + + Title : delete_namespace + Usage : my $un = $API->delete_namespace(%args) + Function : Deletes a namespace instance from the database + Args : namespace_lsid => String - lsid identifying a particular namespace + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 otherwise + $errstr = String error message if there was an error + +=cut sub delete_namespace{ die "delete_namespace not implemented in adaptor\n"; } @@ -609,7 +648,7 @@ authoritative => String, description => String, signatureURL => String, - lsid => Integer}, ...] + lsid => String}, ...] Each hash represents a service Notes : the fact that it returns a service_instance_id is bad since this is only useful to an SQL-based API... @@ -702,7 +741,7 @@ Args : object1_id => Integer - a bind value for object1_id on an underlying SQL-based data source Returns : listref of hashrefs: [{relationship_type => String, - object_lsid => Integer, + object_lsid => String, object2_articlename => String}, ...] one hashref for each relationship between two objects Notes : relationship_type from object_term2term, object_lsid from object, and object2_articlename from object_term2term @@ -721,10 +760,10 @@ Function : Execute a query for a relationship between two ontologies Args : direction => String - direction in the ontology (eg. 'root') ontology => String - name of the table ontology - term => Integer - a bind value for lsid + term => String - a bind value for lsid relationship => String - a bind value for relationship_type Returns : reference to array containing array-refs representing the result set: - [[Integer lsid, String relationship_type], ...] + [[String lsid, String relationship_type], ...] each array-ref represents one row Notes : Only returns distinct lsid from $ontology and relationship_type from $ontology_term2term From mwilkinson at pub.open-bio.org Tue Jul 26 19:32:48 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 26 20:19:58 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262332.j6QNWm8K025808@pub.open-bio.org> mwilkinson Tue Jul 26 19:32:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv25766/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: adaptor API should now be complete moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 21:55:28 1.15 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 23:32:48 1.16 @@ -613,10 +613,10 @@ die "check_object_usage not implemented in adaptor\n"; } -=head2 checkNamespaceUsedByService +=head2 check_namespace_usage - Title : checkNamespaceUsedByService - Usage : my $un = $API->checkNamespaceUsedByService(%args) + Title : check_namespace_usage + Usage : my $un = $API->check_namespace_usage(%args) Function : Execute a custom query for namespaces that are used by some service Args : namespace_type_uris => String - namespace_type_uris you are checking for term => String - the type of the namespace @@ -627,16 +627,16 @@ =cut # custom query routine for Moby::Central.pm -> deregisterNamespace() -sub checkNamespaceUsedByService{ - die "checkNamespaceUsedByService not implemented in adaptor\n"; +sub check_namespace_usage{ + die "check_namespace_usage not implemented in adaptor\n"; } -=head2 checkKeywords +=head2 check_keywords - Title : checkKeywords - Usage : my $un = $API->checkKeywords(%args) + Title : check_keywords + Usage : my $un = $API->check_keywords(%args) Function : Execute a custom query for services with keywords in its description - Args : findme => hashref - hash contains an array of keywords + Args : keywords => listref (of keywords) Returns : listref of hashrefs: [{service_instance_id => Integer, category => String, @@ -652,17 +652,18 @@ Each hash represents a service Notes : the fact that it returns a service_instance_id is bad since this is only useful to an SQL-based API... - + Keywords are assumed to be joined by "OR" for the query + =cut # custom query routine for Moby::Central.pm -> findService() -sub checkKeywords{ - die "checkKeywords not implemented in adaptor\n"; +sub check_keywords{ + die "check_keywords not implemented in adaptor\n"; } -=head2 getFromSimple +=head2 find_by_simple - Title : getFromSimple - Usage : my $un = $API->getFromSimple(%args) + Title : find_by_simple + Usage : my $un = $API->find_by_simple(%args) Function : Execute a custom query for service ids in simple_input/output Args : inout => String - to specify if input or output ancestor_string => String - values that occur in object_type_uri @@ -675,14 +676,14 @@ =cut # custom query subroutine for Moby::Central.pm->_searchForSimple() -sub getFromSimple{ - die "getFromSimple not implemented in adaptor\n"; +sub find_by_simple{ + die "find_by_simple not implemented in adaptor\n"; } -=head2 getFromCollection +=head2 find_by_collection - Title : getFromCollection - Usage : my $un = $API->getFromCollection(%args) + Title : find_by_collection + Usage : my $un = $API->find_by_collection(%args) Function : Execute a custom query for service ids from collections Args : inout => String - to specify if input or output objectURI => String - value that binds to object_type_uri @@ -695,14 +696,14 @@ =cut # custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection{ - die "getFromCollection not implemented in adaptor\n"; +sub find_by_collection{ + die "find_by_collection not implemented in adaptor\n"; } -=head2 getServiceNames +=head2 get_service_names - Title : getServiceNames - Usage : my $un = $API->getServiceNames(%args) + Title : get_service_names + Usage : my $un = $API->get_service_names(%args) Function : Execute a query for all service names Args : no inputs needed Returns : listref of hashrefs: @@ -712,14 +713,14 @@ =cut # custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames{ - die "getServiceNames not implemented in adaptor\n"; +sub get_service_names{ + die "get_service_names not implemented in adaptor\n"; } -=head2 getParentTerms +=head2 get_parent_terms - Title : getParentTerms - Usage : my $un = $API->getParentTerms(%args) + Title : get_parent_terms + Usage : my $un = $API->get_parent_terms(%args) Function : From a given term, traverse the ontology and get all parent terms Args : relationship_type_id => Integer - a bind value for relationship_type_id on an underlying SQL-based data source term => String - bindvalue for OntologyEntry.term @@ -729,16 +730,16 @@ =cut # custom query for Moby::Central.pm->_flatten -sub getParentTerms{ - die "getParentTerms not implemented in adaptor\n"; +sub get_parent_terms{ + die "get_parent_terms not implemented in adaptor\n"; } -=head2 getObjectRelationships +=head2 get_object_relationships - Title : getObjectRelationships - Usage : my $un = $API->getObjectRelationships(%args) + Title : get_object_relationships + Usage : my $un = $API->get_object_relationships(%args) Function : Execute a query for objects that have relationships with other objects - Args : object1_id => Integer - a bind value for object1_id on an underlying SQL-based data source + Args : type => String - either an object name or LSID Returns : listref of hashrefs: [{relationship_type => String, object_lsid => String, @@ -749,14 +750,14 @@ =cut # custom query subroutine for selecting from object_term2term and object tables # used in Moby::OntologyServer.pm->retrieveObject() -sub getObjectRelationships{ - die "getObjectRelationships not implemented in adaptor\n"; +sub get_object_relationships{ + die "get_object_relationships not implemented in adaptor\n"; } -=head2 getRelationship +=head2 get_relationship - Title : getRelationship - Usage : my $un = $API->getRelationships(%args) + Title : get_relationship + Usage : my $un = $API->get_relationship(%args) Function : Execute a query for a relationship between two ontologies Args : direction => String - direction in the ontology (eg. 'root') ontology => String - name of the table ontology @@ -770,8 +771,8 @@ =cut # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references -sub getRelationship{ - die "getRelationship not implemented in adaptor\n"; +sub get_relationship{ + die "get_relationship not implemented in adaptor\n"; } # Not quite sure what this does... From mwilkinson at pub.open-bio.org Tue Jul 26 19:32:48 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 26 20:20:50 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262332.j6QNWmYu025789@pub.open-bio.org> mwilkinson Tue Jul 26 19:32:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25766/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: adaptor API should now be complete moby-live/Perl/MOBY Central.pm,1.185,1.186 OntologyServer.pm,1.58,1.59 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.185 retrieving revision 1.186 diff -u -r1.185 -r1.186 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 23:45:29 1.185 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/26 23:32:48 1.186 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -#use MOBY::Client::Central; +use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -1996,12 +1996,10 @@ $debug && _LOG("Keywords added; criterion count is now $criterion_count\n"); - my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + my ($ids) = $adaptor->check_keywords(keywords => \@{$findme{keywords}}); $ids = _extract_ids($ids); # this is the hash-list that comes back from do_query unless ( scalar @{$ids} ) { - $debug - && &_LOG("found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n"); return &_serviceListResponse( $dbh, undef ); } $debug @@ -2193,7 +2191,9 @@ } $ancestor_string =~ s/\,$//; - my $result = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->find_by_simple(inout => $inout, + ancestor_string => $ancestor_string, + namespaceURIs => $namespaceURIs); my @valid_services; @@ -2244,7 +2244,9 @@ my ( $objectURI, $namespaceURIs ) = &_extractObjectTypesAndNamespaces($simple); - my $result = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->find_by_collection(inout => $inout, + objectURI => $objectURI, + namespaceURIs => $namespaceURIs); foreach my $row (@$result ) { # get the service instance ID and the namespaces that matched @@ -2508,7 +2510,7 @@ my ($pkg) = shift; my $dbh = MOBY::central_db_connection->new()->dbh; - my $result = $adaptor->getServiceNames(); + my $result = $adaptor->get_service_names(); my $names = "\n"; foreach my $row (@$result) { $names .= "\n"; @@ -2948,7 +2950,8 @@ # and flatten it into a list of parent terms my ( $dbh, $type, $term, $seen ) = @_; - my $result = $adaptor->getParentTerms({relationship_type_id => $type}, {term => $term}); + my $result = $adaptor->get_parent_terms(relationship_type_id => $type, + term => $term); foreach my $row (@$result) { my $term = $row->{term}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 23:45:29 1.58 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/26 23:32:48 1.59 @@ -303,18 +303,18 @@ unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } my $result = $adaptor->query_object(type => $LSID); my $row = shift(@$result); - my $id = $row->{object_id}; +# my $id = $row->{object_id}; my $type = $row->{object_type}; my $lsid = $row->{object_lsid}; my $desc = $row->{description}; my $auth = $row->{authority}; my $contact = $row->{contact_email}; - unless ($id) { return ( 0, "Object doesn't exist in ontology", "" ) } + unless ($lsid) { return ( 0, "Object doesn't exist in ontology", "" ) } # my $OS = MOBY::OntologyServer->new(ontology => "relationship"); - $result = $adaptor->getObjectRelationships({object1_id => $id}); + $result = $adaptor->get_object_relationships(type => $lsid); my %rel; foreach my $row (@$result) { @@ -688,7 +688,7 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_service_term2term({service1_id => $id}); + ($err, $errstr) = $adaptor->delete_service_term2term(service1_id => $lsid); if ( $err ) { return ( @@ -828,7 +828,7 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_namespace_term2term({namespace1_id => $id}); + ($err, $errstr) = $adaptor->delete_namespace_term2term(namespace1_id => $lsid); if ( $err ) { return ( @@ -1088,7 +1088,10 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => $datasource ); my $defs; # query returns a reference to an array containing array references - $defs = $adaptor->getRelationship({direction => $direction}, {ontology => $ontology}, {term => $term}, {relationship => $relationship}); + $defs = $adaptor->get_relationship(direction => $direction, + ontology => $ontology, + term => $term, + relationship => $relationship); # a very long piece of SQL statements have been refactored into Moby::Adaptor::moby::queryapi::mysql.pm return $defs; } From mwilkinson at pub.open-bio.org Tue Jul 26 19:32:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 26 20:20:54 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262332.j6QNWnDT025829@pub.open-bio.org> mwilkinson Tue Jul 26 19:32:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25766/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: adaptor API should now be complete moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.38,1.39 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 23:45:29 1.38 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:32:48 1.39 @@ -1034,40 +1034,37 @@ return 0; } } - -# custom query subroutine for Moby::Central.pm->deregisterObjectClass() -# MARK LOOK HERE!!! -# may need two different adaptors for this... one for the object table and other for the mobycentral table +# pass type as LSID or term sub check_object_usage{ my ($self, %args) = @_; my $dbh = $self->dbh; my $errorMsg = 1; my $type = $args{type}; return 0 unless $type; - my $result = $self->query_namespace(type => $type); + my $result = $self->query_object(type => $type); my $row = shift @$result; my $lsid = $row->{object_lsid}; my ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); @@ -1076,15 +1073,17 @@ } # custom query routine for Moby::Central.pm -> deregisterNamespace() -sub checkNamespaceUsedByService{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $existingURI = get_value('namespace_type_uris', @args); - my $term = get_value('term', @args); - my $errstr; +sub check_namespace_usage{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $errorMsg = 1; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_namespace(type => $type); + my $row = shift @$result; + my $lsid = $row->{namespace_lsid}; - my $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" + my $sth = $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$lsid')" ); $sth->execute; @@ -1092,89 +1091,84 @@ my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } - $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" + $sth = $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$lsid')" ); $sth->execute; while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" + $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$lsid')" ); $sth->execute; while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" + $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$lsid')" ); $sth->execute; while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } return (0, ""); } # custom query routine for Moby::Central.pm -> findService() -sub checkKeywords{ - my ($self, @args) = @_; +sub check_keywords{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $param = get_value('findme', @args); + my $param = $args{keywords}; + return ([{}]) unless (ref($param) =~ /ARRAY/); + my @keywords = @$param; my %findme = %$param; my $searchstring; - - foreach my $kw ( @{ $findme{keywords} } ) { -# $debug && &_LOG("KEYWORD $kw\n"); + foreach my $kw ( @keywords ) { $kw =~ s/\*//g; $kw = $dbh->quote("%$kw%"); $searchstring .= " OR description like $kw "; } $searchstring =~ s/OR//; # remove just the first OR in the longer statement -# $debug && &_LOG("search $searchstring\n"); my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; my @bindvalues = (); my $ids = do_query($dbh, $statement, @bindvalues); - return ($ids, $searchstring); + return ($ids); } # custom query subroutine for Moby::Central.pm->_searchForSimple() -sub getFromSimple{ - my ($self, @args) = @_; +sub find_by_simple{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $ancestor_string = get_value('ancestor_string', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); + my $inout = $args{'inout'}; + my $ancestor_string = $args{'ancestor_string'}; + my $namespaceURIs = $args{'namespaceURIs'}; - my $query = -"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " + my $query ="select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " ; # if service_instance_id is null then it must be a collection input. my $nsquery; foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's @@ -1191,12 +1185,12 @@ } # custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection{ - my ($self, @args) = @_; +sub find_by_collection{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $objectURI = get_value('objectURI', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); + my $inout = $args{'inout'}; + my $objectURI = $args{'objectURI'}; + my $namespaceURIs = $args{'namespaceURIs'}; my $query = "select c.service_instance_id, @@ -1223,8 +1217,8 @@ } # custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames{ - my ($self, @args) = @_; +sub get_service_names{ + my ($self, %args) = @_; my $dbh = $self->dbh; my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; my @bindvalues = (); @@ -1234,11 +1228,11 @@ } # custom query for Moby::Central.pm->_flatten -sub getParentTerms{ - my ($self, @args) = @_; +sub get_parent_terms{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $type_id = get_value('relationship_type_id', @args); + my $type_id = $args{'relationship_type_id'}; my $statement = " select OE1.term @@ -1253,7 +1247,7 @@ and OE2.term = ?"; my @bindvalues = (); - push(@bindvalues, get_value('term', @args)); + push(@bindvalues, $args{'term'}); my $result = do_query($dbh, $statement, @bindvalues); return $result; @@ -1261,10 +1255,15 @@ # custom query subroutine for selecting from object_term2term and object tables # used in Moby::OntologyServer.pm->retrieveObject() -sub getObjectRelationships{ - my ($self, @args) = @_; +sub get_object_relationships{ + my ($self, %args) = @_; my $dbh = $self->dbh; - + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $id = $row->{object_id}; + my $statement = "select relationship_type, object_lsid, @@ -1272,22 +1271,24 @@ from object_term2term, object where object1_id = ? and object2_id = object_id"; - my @bindvalues = (); - push(@bindvalues, get_value('object1_id', @args)); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; } # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references -sub getRelationship{ - my ($self, @args) = @_; +sub get_relationship{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $direction = get_value('direction', @args); - my $ontology = get_value('ontology', @args); - my $term = get_value('term', @args); - my $relationship = get_value('relationship', @args); + my $direction = $args{'direction'}; + my $ontology = $args{'ontology'}; + my $relationship = $args{'relationship'}; + + my $type = $args{'term'}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $lsid = $row->{object_lsid}; my $defs; if ( $direction eq 'root' ) { @@ -1300,7 +1301,7 @@ where s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $term ); # ") + s1.${ontology}_lsid = ?", undef, $lsid ); # ") } else { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from @@ -1311,7 +1312,7 @@ relationship_type = ? and s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + s1.${ontology}_lsid = ?", undef, $relationship, $lsid ); # ") } } else { unless ( defined $relationship ) { @@ -1323,7 +1324,7 @@ where s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $term ); # ") + s2.${ontology}_lsid = ?", undef, $lsid); # ") } else { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from @@ -1334,7 +1335,7 @@ relationship_type = ? and s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + s2.${ontology}_lsid = ?", undef, $relationship, $lsid ); # ") } } return $defs; From mwilkinson at pub.open-bio.org Tue Jul 26 19:36:27 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 26 20:23:06 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262336.j6QNaRQd025901@pub.open-bio.org> mwilkinson Tue Jul 26 19:36:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25882/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing spaces in SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.39,1.40 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:32:48 1.39 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:36:26 1.40 @@ -917,9 +917,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = "where relationship_lsid = ? and "; + $condition = " where relationship_lsid = ? and "; } elsif ($type) { - $condition = "where relationship_type = ? and"; + $condition = " where relationship_type = ? and "; } my $ont = $args{ontology}; @@ -949,9 +949,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = "where namespace_lsid = ? and "; + $condition = " where namespace_lsid = ? and "; } elsif ($type) { - $condition = "where namespace_type = ? and"; + $condition = " where namespace_type = ? and"; } my $dbh = $self->dbh; From mwilkinson at pub.open-bio.org Tue Jul 26 19:39:33 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 26 20:26:11 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262339.j6QNdXXs025969@pub.open-bio.org> mwilkinson Tue Jul 26 19:39:33 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25948/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing extra where in auto-generated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.40,1.41 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:36:26 1.40 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:39:33 1.41 @@ -917,9 +917,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = " where relationship_lsid = ? and "; + $condition = " relationship_lsid = ? and "; } elsif ($type) { - $condition = " where relationship_type = ? and "; + $condition = " relationship_type = ? and "; } my $ont = $args{ontology}; From mwilkinson at pub.open-bio.org Tue Jul 26 19:50:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 26 20:37:15 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262350.j6QNobNk026055@pub.open-bio.org> mwilkinson Tue Jul 26 19:50:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv26036/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing extra bind arguments in auto-generated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.41,1.42 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:39:33 1.41 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:50:37 1.42 @@ -476,8 +476,13 @@ contact_email from object $condition"; - my $dbh = $self->dbh; - my $result = do_query($dbh, $statement, ($type)); + my $dbh = $self->dbh; + my $result; + if ($type){ + $result = do_query($dbh, $statement, ($type)); + } else { + $result = do_query($dbh, $statement); + } return $result; } @@ -812,7 +817,12 @@ authority, contact_email from service $condition"; - my $result = do_query($dbh, $statement, ($type)); + my $result; + if ($type){ + $result = do_query($dbh, $statement, ($type)); + } else { + $result = do_query($dbh, $statement); + } return $result; } @@ -949,9 +959,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = " where namespace_lsid = ? and "; + $condition = " where namespace_lsid = ?"; } elsif ($type) { - $condition = " where namespace_type = ? and"; + $condition = " where namespace_type = ?"; } my $dbh = $self->dbh; @@ -963,7 +973,12 @@ authority, contact_email from namespace $condition"; - my $result = do_query($dbh, $statement, ($type)); + my $result; + if ($type){ + $result = do_query($dbh, $statement, ($type)); + } else { + $result = do_query($dbh, $statement); + } return $result; } From mwilkinson at pub.open-bio.org Tue Jul 26 20:00:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 26 20:47:23 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270000.j6R00jO7026161@pub.open-bio.org> mwilkinson Tue Jul 26 20:00:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv26119/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: a few arguments were still being passed as anon hashes instead of hashes moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.42,1.43 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:50:37 1.42 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 00:00:45 1.43 @@ -176,7 +176,7 @@ sub query_collection_input{ my ($self, %args) = @_; my $dbh = $self->dbh; - my $serv_lsid = $args{'service_lsid'}; + my $serv_lsid = $args{'service_instance_lsid'}; my $statement = "select collection_input_id, From mwilkinson at pub.open-bio.org Tue Jul 26 20:00:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue Jul 26 20:47:24 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270000.j6R00jSB026142@pub.open-bio.org> mwilkinson Tue Jul 26 20:00:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26119/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: a few arguments were still being passed as anon hashes instead of hashes moby-live/Perl/MOBY Central.pm,1.186,1.187 OntologyServer.pm,1.59,1.60 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.186 retrieving revision 1.187 diff -u -r1.186 -r1.187 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/26 23:32:48 1.186 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 00:00:44 1.187 @@ -916,7 +916,8 @@ $OntologyServer->namespaceExists( term => $term ); return &_error( "Namespace Type $term does not exist", "" ) unless ($existingURI); - my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term}); + my ($err, $errstr) = $adaptor->check_namespace_usage(namespace_type_uris => $existingURI, + type => $term); return &_error( $errstr, "") if ($err); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/26 23:32:48 1.59 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 00:00:44 1.60 @@ -359,7 +359,7 @@ my $lsid = $row->{object_lsid}; # object1_id ISA object2_id? - my $isa = $adaptor->query_object_term2term({object2_id => $id}); + my $isa = $adaptor->query_object_term2term(type => $lsid); if ( scalar @$isa ) { return ( 0, qq{Object type $term has object dependencies in the ontology}, @@ -461,7 +461,7 @@ $obj_lsid = $row->{object_lsid}; return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_id; - my $isa = $adaptor->query_object_term2term({object2_id => $subj_id}); + my $isa = $adaptor->query_object_term2term(type => $subj_lsid); if ( scalar @$isa ) { return ( From kawas at pub.open-bio.org Tue Jul 26 19:06:25 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue Jul 26 20:55:07 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262306.j6QN6Pfs025638@pub.open-bio.org> kawas Tue Jul 26 19:06:25 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv25613/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: who would have thought that there was an invalidURL.com site. Changed the generated URL so that the agent gets a 404 instead of a 200. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/19 12:39:59 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/26 23:06:25 1.9 @@ -58,7 +58,7 @@ if (rdfAddr == null) { //TODO - make this code more efficient! - maybe perform one sql call instead of many // update the signatureURL field using the service name and authority id - String bogusSigURL = "http://invalidURL.com/author/"+ authorityID + "/" + servName +".xml"; + String bogusSigURL = "http://invalidURL123.com/author/"+ authorityID + "/" + servName +".xml"; String updateSQLString = "UPDATE service_instance " + "SET signatureURL='"+ bogusSigURL +"' " + "WHERE authority_id=" + authorityID + " and servicename='" + servName +"'"; From dwang at pub.open-bio.org Tue Jul 26 20:15:49 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue Jul 26 21:02:36 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270015.j6R0Fn7d026297@pub.open-bio.org> dwang Tue Jul 26 20:15:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv26271/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added some more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 23:32:48 1.16 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:15:48 1.17 @@ -486,10 +486,35 @@ die "query_service not implemented in adaptor\n"; } +=head2 insert_service + + Title : insert_service + Usage : my $un = $API->insert_service(%args) + Function : Inserts a service class into the database + Args : service_type => String, + service_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_service{ die "insert_service not implemented in adaptor\n"; } +=head2 delete_service + + Title : delete_service + Usage : my $un = $API->delete_service(%args) + Function : Deletes a service from the database + Args : service_lsid => String + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 otherwise + $errstr = String error message if there was an error + +=cut sub delete_service{ die "delete_service not implemented in adaptor\n"; } @@ -497,14 +522,41 @@ # # service_term2term table functions # +=head2 query_service_term2term + + Title : query_service_term2term + Usage : my $un = $API->query_service_term2term(%args) + Function : Executes a query for service relationships + Args : type => String - either service_type or service_lsid + Returns : listref of hashrefs: + [{assertion_id => Integer, + relationship_type => String, + service1_id => Integer, + service2_id => Integer}] + Notes : the fact that it returns an service ids is bad since this + is only useful to an SQL-based API... +=cut sub query_service_term2term{ die "query_service_term2term not implemented in adaptor\n"; } +=head2 insert_service_term2term + + Title : insert_service_term2term + Usage : my $un = $API->insert_service_term2term(%args) + Function : Inserts a service relationship + Args : relationship_type => String, + service1_type => String, + service2_type => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_service_term2term{ die "insert_service_term2term not implemented in adaptor\n"; } +# private subroutine in mysql api sub delete_service_term2term{ die "delete_service_term2term not implemented in adaptor\n"; } @@ -512,14 +564,36 @@ # # relationship table functions # +=head2 query_relationship + + Title : query_relationship + Usage : my $un = $API->query_relationship(%args) + Function : Executes a query for a relationship in an ontology + Args : type => String, + ontology => String + Returns : listref of hashrefs: + [{relationship_id => Integer, + relationship_lsid => String, + relationship_type => String, + container => Integer, + description => String, + authority => String, + contact_email => String, + ontology => String}, ...] + one hashref for each relationship + Notes : the fact that it returns a relationship_id is bad since this + is only useful to an SQL-based API... +=cut sub query_relationship{ die "query_relationship not implemented in adaptor\n"; } +# probably no need for this and not implemented in mysql api sub insert_relationship{ die "insert_relationship not implemented in adaptor\n"; } +# is not implemented in mysql api either... should this be removed? sub delete_relationship{ die "delete_relationship not implemented in adaptor\n"; } @@ -555,8 +629,8 @@ description => String, authority => String, contact_email => String - Returns : Integer mysql_insertid - Notes : the fact that it returns a mysql_insertid is bad since this + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this is only useful to an SQL-based API... =cut sub insert_namespace{ From dwang at pub.open-bio.org Tue Jul 26 20:30:43 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue Jul 26 21:55:14 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270030.j6R0UhDK026354@pub.open-bio.org> dwang Tue Jul 26 20:30:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv26328/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: again more comments... noticed some deletes were not implemented in mysql api, should they be removed from queryapi? moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:15:48 1.17 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:30:43 1.18 @@ -467,14 +467,37 @@ die "query_authority not implemented in adaptor\n"; } +=head2 get_all_authorities + + Title : get_all_authorities + Usage : my $un = $API->get_all_authorities() + Function : Gets all unique authority URIs from the database + Args : no arguments + Returns : listref of hashrefs: + [{authority_uri => String}] + +=cut sub get_all_authorities{ die "get_all_authorities not implemented in adaptor\n"; } +=head2 insert_authority + + Title : insert_authority + Usage : my $un = $API->insert_authority(%args) + Function : Inserts an authority into the database + Args : authority_common_name => String, + authority_uri => String, + contact_email => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_authority{ die "insert_authority not implemented in adaptor\n"; } +# Not implemented in mysql... should we allow deleting the authority? sub delete_authority{ die "delete_authority not implemented in adaptor\n"; } @@ -482,6 +505,22 @@ # # service table fuctions # +=head2 query_service + + Title : query_service + Usage : my $un = $API->query_service(%args) + Function : Executes a query for service class + Args : type => String - either service_type or service_lsid + Returns : listref of hashrefs: + [{service_id => Integer, + service_lsid => String, + service_type => String, + description => String, + authority => String, + contact_email => String}] + Notes : the fact that it returns an service_id is bad since this + is only useful to an SQL-based API... +=cut sub query_service{ die "query_service not implemented in adaptor\n"; } From dwang at pub.open-bio.org Wed Jul 27 02:53:50 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 27 03:40:47 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270653.j6R6roR2027000@pub.open-bio.org> dwang Wed Jul 27 02:53:50 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv26975/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added documentation for authority subroutines moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:30:43 1.18 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 06:53:50 1.19 @@ -463,6 +463,18 @@ # # authority table functions # +=head2 query_authority + + Title : query_authority + Usage : my $un = $API->query_authority(%args) + Function : Executes a query for authorities in the database + Args : authority_uri => String + Returns : listref of hashrefs: + [{authority_common_name => String, + authority_uri => String, + contact_email => String}] + Notes : Only allows querying by URI of the authority +=cut sub query_authority{ die "query_authority not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Wed Jul 27 10:06:15 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 10:52:49 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271406.j6RE6FYi028526@pub.open-bio.org> mwilkinson Wed Jul 27 10:06:15 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv28503/MOBY Modified Files: authority.pm service_instance.pm Log Message: interesting architectural SNAFU. The adaptor is designed to know about one data-source at a time (mobycentral, mobyobject, mobynamespace, mobyservice). However, certain functions need to cross-reference these different data sources. Thus I need to create a new instance of the adaptor in the adaptor itself to support this. Ugly... not illegal... but ugly. I'll fix this one day. moby-live/Perl/MOBY authority.pm,1.6,1.7 service_instance.pm,1.30,1.31 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/25 23:45:29 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/27 14:06:15 1.7 @@ -92,7 +92,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $result = $adaptor->query_authority(authority_uri => $self->authority_uri); my $row = shift(@$result); unless ($row) { my $insertid = $adaptor->insert_authority( =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 23:45:29 1.30 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 14:06:15 1.31 @@ -272,7 +272,7 @@ $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); - my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); + my $result = $adaptor->query_collection_input(service_instance_lsid => $self->lsid); foreach my $row (@$result) { my $id = $row->{collection_input_id}; From mwilkinson at pub.open-bio.org Wed Jul 27 10:06:15 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 10:53:02 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271406.j6RE6FTZ028545@pub.open-bio.org> mwilkinson Wed Jul 27 10:06:15 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28503/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: interesting architectural SNAFU. The adaptor is designed to know about one data-source at a time (mobycentral, mobyobject, mobynamespace, mobyservice). However, certain functions need to cross-reference these different data sources. Thus I need to create a new instance of the adaptor in the adaptor itself to support this. Ugly... not illegal... but ugly. I'll fix this one day. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.43,1.44 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 00:00:45 1.43 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:06:15 1.44 @@ -55,6 +55,13 @@ } +sub _getDBHandle { + my ($ontology) = @_; + my $CONF = MOBY::Config->new; + $CONF->getDataAdaptor(source => $ontology); + return $CONF->dbh; +} + sub new { my ($caller, %args) = @_; my $self = $caller->SUPER::new(%args); @@ -476,7 +483,7 @@ contact_email from object $condition"; - my $dbh = $self->dbh; + my $dbh = _getDBHandle("mobyobject"); my $result; if ($type){ $result = do_query($dbh, $statement, ($type)); @@ -807,8 +814,9 @@ } elsif ($type) { $condition = "where service_type = ?"; } + + my $dbh = _getDBHandle("mobyservice"); - my $dbh = $self->dbh; my $statement = "select service_id, service_lsid, @@ -963,7 +971,7 @@ } elsif ($type) { $condition = " where namespace_type = ?"; } - my $dbh = $self->dbh; + my $dbh = _getDBHandle("mobynamespace"); my $statement = "select namespace_id, From mwilkinson at pub.open-bio.org Wed Jul 27 10:07:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 10:54:37 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271407.j6RE7vtm028614@pub.open-bio.org> mwilkinson Wed Jul 27 10:07:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28595/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: calling dbh on the config instead of the adaptor moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.44,1.45 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:06:15 1.44 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:07:57 1.45 @@ -58,8 +58,8 @@ sub _getDBHandle { my ($ontology) = @_; my $CONF = MOBY::Config->new; - $CONF->getDataAdaptor(source => $ontology); - return $CONF->dbh; + my $adap = $CONF->getDataAdaptor(source => $ontology); + return $adap->dbh; } sub new { From mwilkinson at pub.open-bio.org Wed Jul 27 10:19:42 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 11:08:00 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271419.j6REJgRG028806@pub.open-bio.org> mwilkinson Wed Jul 27 10:19:42 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28768/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: ontological relationships not being properly deleted since objects no longer existed moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.45,1.46 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:07:57 1.45 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:19:42 1.46 @@ -521,17 +521,14 @@ my $dbh = $self->dbh; my $term = $args{type}; return 0 unless $term; - my $statement = "delete from object where "; - my $condition; - if ($term =~ /^urn\:lsid/){ - $condition = " object_lsid = ?"; - } else { - $condition = " object_type = ?"; - } - $statement = $statement.$condition; - $dbh->do( $statement,undef, ($term) ); + my $result = $self->query_object(type => $term); + my $row = shift(@$result); + my $id = $row->{object_id}; + my $lsid = $row->{object_lsid}; + my $statement = "delete from object where object_lsid = ?"; + $dbh->do( $statement,undef, ($lsid) ); - $self->_delete_object_term2term(type => $term); + $self->_delete_object_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); } @@ -593,15 +590,11 @@ # SHOULD NOT BE DOCUMENTED IN THE API sub _delete_object_term2term{ my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_object(type => $type); - my $row = shift @$result; - my $id = $row->object_id; - + my $o1id = $args{id}; + return 0 unless defined($o1id); my $dbh = $self->dbh; my $statement = "delete from object_term2term where object1_id=?"; - $dbh->do( $statement,undef, ($id)); + $dbh->do( $statement,undef, ($o1id)); if ($dbh->err){ return (1, $dbh->errstr); @@ -848,13 +841,18 @@ return $dbh->{mysql_insertid}; } -# pass in service type as LSID (service_lsid) +# pass in 'type' as LSID term or lsid sub delete_service{ my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_service(type => $type); + my $row = shift(@$result); + my $id = $row->{service_id}; + my $lsid = $row->{service_lsid}; my $dbh = $self->dbh; my $statement = "delete from service where service_lsid = ?"; - $dbh->do( $statement, undef, ($args{service_lsid})); - $self->_delete_service_term2term; + $dbh->do( $statement, undef, ($args{lsid})); + $self->_delete_service_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); } @@ -911,12 +909,8 @@ # NOT BE DOCUMENTED IN THE API. sub _delete_service_term2term{ my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_service(type => $type); - my $row = shift @$result; - my $id = $row->service_id; - + my $id = $args{id}; + return 0 unless (defined($id)); my $dbh = $self->dbh; my $statement = "delete from service_term2term where service1_id=?"; $dbh->do( $statement,undef, ($id)); @@ -1006,11 +1000,15 @@ # pass namesapce_lsid sub delete_namespace{ my ($self, %args) = @_; - my $lsid = $args{namespace_lsid}; + my $type = $args{type}; + my $result = $self->query_namespace(type => $type); + my $row = shift(@$result); + my $id = $row->{namespace_id}; + my $lsid = $row->{namespace_lsid}; my $dbh = $self->dbh; my $statement = "delete from namespace where namespace_lsid = ?"; $dbh->do( $statement, undef, ($lsid)); - $self->_delete_namespace_term2term; + $self->_delete_namespace_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); } @@ -1041,12 +1039,8 @@ # PRIVATE, NOT PART OF API! sub _delete_namespace_term2term{ my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_namespace(type => $type); - my $row = shift @$result; - my $id = $row->namespace_id; - + my $id = $args{id}; + return 0 unless defined($id); my $dbh = $self->dbh; my $statement = "delete from namespace_term2term where namespace1_id=?"; $dbh->do( $statement,undef, ($id)); From mwilkinson at pub.open-bio.org Wed Jul 27 10:19:42 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 11:09:17 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271419.j6REJgXR028787@pub.open-bio.org> mwilkinson Wed Jul 27 10:19:42 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv28768/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: ontological relationships not being properly deleted since objects no longer existed moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 06:53:50 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 14:19:42 1.20 @@ -693,7 +693,7 @@ Title : delete_namespace Usage : my $un = $API->delete_namespace(%args) Function : Deletes a namespace instance from the database - Args : namespace_lsid => String - lsid identifying a particular namespace + Args : type => String - lsid or namespace term identifying a particular namespace Returns : ($err, $errstr) $err = 1 if there was an delete error, 0 otherwise $errstr = String error message if there was an error From mwilkinson at pub.open-bio.org Wed Jul 27 10:24:06 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 11:10:56 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271424.j6REO6i5028880@pub.open-bio.org> mwilkinson Wed Jul 27 10:24:06 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28861/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: missing where on auto-generated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.46,1.47 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:19:42 1.46 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:24:06 1.47 @@ -656,19 +656,19 @@ # pop @args; # remove final "and" # } - my $statement = "select - service_instance_id, - category, - servicename, - service_type_uri, - authority.authority_uri, - url, - contact_email, - authoritative, - description, - signatureURL, - lsid - from service_instance left join authority on authority.authority_id "; + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority.authority_uri, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance left join authority on authority.authority_id where "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); From mwilkinson at pub.open-bio.org Wed Jul 27 10:26:44 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 11:13:26 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271426.j6REQi8n028958@pub.open-bio.org> mwilkinson Wed Jul 27 10:26:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28939/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: extra and in autogenerated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.47,1.48 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:24:06 1.47 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:26:44 1.48 @@ -638,23 +638,12 @@ my ($self, %args) = @_; my $dbh = $self->dbh; - #my $authority_id; - #if ($args{'authority_uri'}){ # need to transform URI to a row ID - # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); - # return 0 unless @$result[0]; - # $authority_id = @$result[0]->{authority_id}; - # return 0 unless $authority_id; - #} - #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine } -# if ($authority_id){ -# push @args, ({authority_id => $authority_id}) ; -# } else { -# pop @args; # remove final "and" -# } + + if (keys(%args)){ pop @args;} # remove final "and" my $statement = "select service_instance_id, From mwilkinson at pub.open-bio.org Wed Jul 27 10:39:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 11:28:50 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271439.j6REd29J029031@pub.open-bio.org> mwilkinson Wed Jul 27 10:39:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29012/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: errors in method calls to extract service ids. Fixed some last things in the autogenerated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.48,1.49 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:26:44 1.48 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:39:02 1.49 @@ -197,7 +197,7 @@ sub insert_collection_input { my ($self, %args) = @_; my $article = $args{article_name}; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, $siid, $article); @@ -208,7 +208,7 @@ # pass in service_instance_lsid sub delete_collection_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $statement = "delete from collection_input where service_instance_id = ?"; $self->dbh->do( $statement, undef, $siid); @@ -224,7 +224,7 @@ # pass service_instance_lsid sub query_collection_output{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "select @@ -239,7 +239,7 @@ # pass service_instance_lsid, article_name sub insert_collection_output { my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, $siid,$args{'article_name'}); @@ -250,7 +250,7 @@ # pass argument service_instance_lsid sub delete_collection_output{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "delete from collection_output where service_instance_id = ?"; my @bindvalues = (); @@ -267,7 +267,7 @@ # pass service_instance_lsid sub query_simple_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "select @@ -285,7 +285,7 @@ # pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id sub insert_simple_input { my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $dbh->do("insert into simple_input (object_type_uri, @@ -308,7 +308,7 @@ sub delete_simple_input{ my ($self, %args) = @_; my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_input_id}; my $statement1; my $statement2; $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); @@ -327,7 +327,7 @@ sub delete_inputs { # this should replace all other delete_*_input my ($self, %args) = @_; my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); my $statement = "delete from simple_input where service_instance_lsid = ?"; @@ -352,7 +352,7 @@ # send service_instance_lsid, collection_input_id sub query_simple_output{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $collid = $args{collection_input_id}; my $dbh = $self->dbh; @@ -371,7 +371,7 @@ # pass args service_instance_id and collection_output_id sub insert_simple_output { my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $dbh->do("insert into simple_output @@ -396,7 +396,7 @@ sub delete_simple_output{ my ($self, %args) = @_; my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_output_id}; my $statement1; my $statement2; $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); @@ -415,7 +415,7 @@ # pass service_instance_lsid sub query_secondary_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "select @@ -435,7 +435,7 @@ # pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid sub insert_secondary_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, undef, @@ -450,7 +450,7 @@ # pass service_instance_lsid sub delete_secondary_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "delete from secondary_input where service_instance_lsid=?"; @@ -652,7 +652,7 @@ service_type_uri, authority.authority_uri, url, - contact_email, + service_instance.contact_email, authoritative, description, signatureURL, From mwilkinson at pub.open-bio.org Wed Jul 27 11:29:39 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 12:21:40 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271529.j6RFTdU1029397@pub.open-bio.org> mwilkinson Wed Jul 27 11:29:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29378/MOBY Modified Files: service_instance.pm Log Message: new service instance didnt know its own LSID moby-live/Perl/MOBY service_instance.pm,1.31,1.32 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 14:06:15 1.31 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 15:29:38 1.32 @@ -233,7 +233,7 @@ my $service_lsid = "urn:lsid:$LSID_Auth:$LSID_NS:" . $self->authority_uri . "," . $self->servicename; - + $self->lsid($service_lsid); my $id = $self->adaptor->insert_service_instance( category => $self->category, servicename => $self->servicename, From mwilkinson at pub.open-bio.org Wed Jul 27 11:41:12 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 12:28:08 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271541.j6RFfCa8029493@pub.open-bio.org> mwilkinson Wed Jul 27 11:41:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29466/MOBY Modified Files: secondary_input.pm simple_input.pm simple_output.pm Log Message: still passing ids instead of lsids in various places moby-live/Perl/MOBY secondary_input.pm,1.8,1.9 simple_input.pm,1.7,1.8 simple_output.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 20:55:35 1.8 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/27 15:41:11 1.9 @@ -121,7 +121,7 @@ enum_value => $self->enum_value, datatype => $self->datatype, article_name => $self->article_name, - service_instance_lsid => $self->service_instance_id); + service_instance_lsid => $self->service_instance_lsid); return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/25 19:53:35 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/27 15:41:11 1.8 @@ -104,7 +104,7 @@ object_type_uri => $self->object_type_uri, namespace_type_uris => $self->namespace_type_uris, article_name => $self->article_name, - service_instance_lsid => $self->service_instance_id, + service_instance_lsid => $self->service_instance_lsid, collection_input_id => $self->collection_input_id ); return $id; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 20:14:34 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/27 15:41:11 1.8 @@ -103,7 +103,7 @@ object_type_uri => $self->object_type_uri, namespace_type_uris => $self->namespace_type_uris, article_name => $self->article_name, - service_instance_lsid => $self->service_instance_id, + service_instance_lsid => $self->service_instance_lsid, collection_output_id => $self->collection_output_id ); return $id; From mwilkinson at pub.open-bio.org Wed Jul 27 11:58:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 12:47:39 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271558.j6RFwbmV029578@pub.open-bio.org> mwilkinson Wed Jul 27 11:58:36 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29559/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: simples of collections not being discovered properly moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.51,1.52 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:02:21 1.51 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:58:36 1.52 @@ -268,6 +268,7 @@ sub query_simple_input{ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); + my $collid = $args{collection_input_id}; my $dbh = $self->dbh; my $statement = "select @@ -277,8 +278,12 @@ article_name, service_instance_id, collection_input_id - from simple_input where service_instance_id = ? and collection_input_id IS NULL"; - my $result = do_query($dbh, $statement, ($siid)); + from simple_input where "; + + my $condition; + $siid && ($condition = " service_instance_id = ? and collection_input_id IS NULL"); + $collid && ($condition = " service_instance_id IS NULL and collection_input_id = ?"); + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; } @@ -353,7 +358,7 @@ sub query_simple_output{ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); - my $collid = $args{collection_input_id}; + my $collid = $args{collection_output_id}; my $dbh = $self->dbh; my $statement = "select @@ -363,8 +368,13 @@ article_name, service_instance_id, collection_output_id - from simple_output where service_instance_id = ? and collection_output_id= ?"; - my $result = do_query($dbh, $statement, ($siid, $collid)); + from simple_output where "; + my $condition; + $siid && ($condition = " service_instance_id = ? and collection_output_id IS NULL"); + $collid && ($condition = " service_instance_id IS NULL and collection_output_id = ?"); + + + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; } From mwilkinson at pub.open-bio.org Wed Jul 27 12:03:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 12:50:53 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271603.j6RG3Tam029653@pub.open-bio.org> mwilkinson Wed Jul 27 12:03:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29634/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: simples of collections not being discovered properly moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.52,1.53 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:58:36 1.52 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 16:03:29 1.53 @@ -283,6 +283,8 @@ my $condition; $siid && ($condition = " service_instance_id = ? and collection_input_id IS NULL"); $collid && ($condition = " service_instance_id IS NULL and collection_input_id = ?"); + $statement .= $condition; + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; } @@ -372,7 +374,8 @@ my $condition; $siid && ($condition = " service_instance_id = ? and collection_output_id IS NULL"); $collid && ($condition = " service_instance_id IS NULL and collection_output_id = ?"); - + $statement .= $condition; + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; From mwilkinson at pub.open-bio.org Wed Jul 27 11:15:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 12:55:56 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271515.j6RFFwrC029314@pub.open-bio.org> mwilkinson Wed Jul 27 11:15:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29295/MOBY Modified Files: OntologyServer.pm Log Message: ontology server was expecting databse ids instead of the new LSIDs moby-live/Perl/MOBY OntologyServer.pm,1.60,1.61 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 00:00:44 1.60 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 15:15:57 1.61 @@ -449,18 +449,18 @@ return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); - my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); +# my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); my $result = $adaptor->query_object(type => $args{subject_node}); my $row = shift(@$result); - $subj_lsid = $row->{object_lsid}; + my $subj_lsid = $row->{object_lsid}; return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) - unless defined $subj_id; + unless defined $subj_lsid; $result = $adaptor->query_object(type => $args{object_node}); $row = shift(@$result); - $obj_lsid = $row->{object_lsid}; + my $obj_lsid = $row->{object_lsid}; return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) - unless defined $obj_id; + unless defined $obj_lsid; my $isa = $adaptor->query_object_term2term(type => $subj_lsid); if ( scalar @$isa ) { From mwilkinson at pub.open-bio.org Wed Jul 27 10:58:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 12:56:07 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271458.j6REww7l029131@pub.open-bio.org> mwilkinson Wed Jul 27 10:58:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29112/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: misspelled where moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.49,1.50 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:39:02 1.49 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:58:58 1.50 @@ -172,7 +172,7 @@ sub _getSIIDFromLSID { my ($self, $lsid) = @_; my $dbh = $self->dbh; - my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); + my $sth = $dbh->prepare("select service_instance_id from service_instance where lsid = ?"); $sth->execute($lsid); my ($siid) = $sth->fetchrow_array(); return $siid; @@ -657,7 +657,7 @@ description, signatureURL, lsid - from service_instance left join authority on authority.authority_id where "; + from service_instance left join authority on authority.authority_id "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); From mwilkinson at pub.open-bio.org Wed Jul 27 11:02:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 12:56:08 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271502.j6RF2MfK029227@pub.open-bio.org> mwilkinson Wed Jul 27 11:02:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29208/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: output instead of input moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.50,1.51 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:58:58 1.50 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:02:21 1.51 @@ -363,7 +363,7 @@ article_name, service_instance_id, collection_output_id - from simple_output where service_instance_id = ? and collection_input_id= ?"; + from simple_output where service_instance_id = ? and collection_output_id= ?"; my $result = do_query($dbh, $statement, ($siid, $collid)); return $result; } From mwilkinson at pub.open-bio.org Wed Jul 27 13:29:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 14:17:38 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271729.j6RHTAYI029949@pub.open-bio.org> mwilkinson Wed Jul 27 13:29:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29930/MOBY Modified Files: Central.pm Log Message: secondaries was also receiving id instead of lsid moby-live/Perl/MOBY Central.pm,1.187,1.188 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.187 retrieving revision 1.188 diff -u -r1.187 -r1.188 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 00:00:44 1.187 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 17:29:10 1.188 @@ -3406,7 +3406,7 @@ } $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_secondary_input(service_instance_lsid => $_); + $result = $adaptor->query_secondary_input(service_instance_lsid => $lsid); foreach my $row (@$result) { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ("","","","","",""); $default_value = $row->{default_value}; From mwilkinson at pub.open-bio.org Wed Jul 27 13:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 14:19:11 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271732.j6RHWKbw030072@pub.open-bio.org> mwilkinson Wed Jul 27 13:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30053/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: secondaries was also receiving id instead of lsid moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.53,1.54 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 16:03:29 1.53 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:32:20 1.54 @@ -318,7 +318,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_input_id}; my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); + $siid && ($statement1 = "delete from simple_input where service_instance_id = ?"); $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); $siid && ($dbh->do( $statement1, undef,($siid))); @@ -337,7 +337,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); - my $statement = "delete from simple_input where service_instance_lsid = ?"; + my $statement = "delete from simple_input where service_instance_id = ?"; $dbh->do( $statement, undef,($siid)); if ($dbh->err){ @@ -412,7 +412,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_output_id}; my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); + $siid && ($statement1 = "delete from simple_output where service_instance_id = ?"); $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); $siid && ($dbh->do( $statement1, undef,($siid))); @@ -465,7 +465,7 @@ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; - my $statement = "delete from secondary_input where service_instance_lsid=?"; + my $statement = "delete from secondary_input where service_instance_id=?"; $dbh->do( $statement, undef, ($siid)); if ($dbh->err){ From mwilkinson at pub.open-bio.org Wed Jul 27 13:33:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 14:21:27 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271733.j6RHXwT5030138@pub.open-bio.org> mwilkinson Wed Jul 27 13:33:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30119/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: one comma too many ruins the batch moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.54,1.55 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:32:20 1.54 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:33:58 1.55 @@ -1032,7 +1032,7 @@ assertion_id, relationship_type, namespace1_id, - namespace2_id, + namespace2_id from namespace_term2term where namespace2_id = ?"; my $result2 = do_query($dbh, $statement, ($id)); return $result2; From mwilkinson at pub.open-bio.org Wed Jul 27 13:36:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 14:22:56 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271736.j6RHa2gD030206@pub.open-bio.org> mwilkinson Wed Jul 27 13:36:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30187/MOBY Modified Files: OntologyServer.pm Log Message: redundant deletion of namespace term relations moby-live/Perl/MOBY OntologyServer.pm,1.61,1.62 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 15:15:57 1.61 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 17:36:02 1.62 @@ -828,15 +828,15 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_namespace_term2term(namespace1_id => $lsid); - - if ( $err ) { - return ( - 0, - "Delete from namespace term2term table failed: $errstr", - $lsid - ); - } + #($err, $errstr) = $adaptor->delete_namespace_term2term(namespace1_id => $lsid); + # + #if ( $err ) { + # return ( + # 0, + # "Delete from namespace term2term table failed: $errstr", + # $lsid + # ); + #} return ( 1, "Namespace Type $term Deleted", $lsid ); } From mwilkinson at pub.open-bio.org Wed Jul 27 14:00:54 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 14:47:44 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271800.j6RI0sMx030311@pub.open-bio.org> mwilkinson Wed Jul 27 14:00:53 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30292/MOBY Modified Files: OntologyServer.pm Log Message: expecting a list of IDs instead of a database row moby-live/Perl/MOBY OntologyServer.pm,1.62,1.63 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 17:36:02 1.62 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:00:53 1.63 @@ -462,11 +462,11 @@ return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_lsid; my $isa = $adaptor->query_object_term2term(type => $subj_lsid); - - if ( scalar @$isa ) { + my $isarow = shift @$isa; + if ( $isarow->object_lsid ) { return ( 0, -qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, + qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, $subj_lsid ); } @@ -513,18 +513,17 @@ my $row = shift(@$result); my $sbj_lsid = $row->{service_lsid}; - return ( - 0, -qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, + return (0, + qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid - ) - unless defined $sbj_lsid; + ) unless defined $sbj_lsid; my $isa = $adaptor->query_service_term2term(service2_id => $sbj_lsid); - if ( scalar @$isa ) { + my $isarow = shift @$isa; + if ( $isarow->service_lsid ) { return ( 0, -qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, + qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ); } @@ -549,7 +548,7 @@ my $insertid = $adaptor->insert_service_term2term(relationship_type => $rel_lsid, service1_type => $sbj_lsid, service2_type => $obj_lsid); - if ( $insertid ) { + if ( defined($insertid)) { return ( 1, "Service relationship created successfully", '' ); } else { return ( 0, "Service relationship creation failed for unknown reasons", From mwilkinson at pub.open-bio.org Wed Jul 27 14:06:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed Jul 27 14:53:23 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271806.j6RI6oCo030429@pub.open-bio.org> mwilkinson Wed Jul 27 14:06:50 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30410/MOBY Modified Files: OntologyServer.pm Log Message: expecting a list of IDs instead of a database row moby-live/Perl/MOBY OntologyServer.pm,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:00:53 1.63 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:06:50 1.64 @@ -463,7 +463,7 @@ unless defined $obj_lsid; my $isa = $adaptor->query_object_term2term(type => $subj_lsid); my $isarow = shift @$isa; - if ( $isarow->object_lsid ) { + if ( $isarow->{object_lsid} ) { return ( 0, qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, @@ -520,7 +520,7 @@ my $isa = $adaptor->query_service_term2term(service2_id => $sbj_lsid); my $isarow = shift @$isa; - if ( $isarow->service_lsid ) { + if ( $isarow->{service_lsid} ) { return ( 0, qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, From dwang at pub.open-bio.org Wed Jul 27 17:25:28 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 27 18:14:07 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507272125.j6RLPSEN030891@pub.open-bio.org> dwang Wed Jul 27 17:25:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30865/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: added comment about quoting the keys in hashes if querying two or more tables (eg. 'authority.authority_uri' => $value) in order to avoid conflict with perl special operator '.' moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.55,1.56 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:33:58 1.55 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 21:25:28 1.56 @@ -647,6 +647,7 @@ } # selects all the columns from service_instance table # PAY ATTENTION to what this returns. Not auth_id but auth_uri!! +# IMPORTANT: must use quotes for the keys of the hash (eg. 'authority.authority_uri' => $value ) sub query_service_instance { my ($self, %args) = @_; my $dbh = $self->dbh; @@ -654,6 +655,7 @@ my @args; while (my ($k, $v) = each %args){ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine + # but too bad won't be scalable for "or" } if (keys(%args)){ pop @args;} # remove final "and" From dwang at pub.open-bio.org Wed Jul 27 17:26:52 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 27 18:14:22 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507272126.j6RLQqLx030926@pub.open-bio.org> dwang Wed Jul 27 17:26:52 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv30900/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added more comments... moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 14:19:42 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 21:26:52 1.21 @@ -433,10 +433,24 @@ die "query_object_term2term not implemented in adaptor\n"; } +=head2 insert_object_term2term + + Title : insert_object_term2term + Usage : my $un = $API->insert_object_term2term(%args) + Function : Inserts a object relationship into the database + Args : relationship_type => String, + object1_id => Integer, - but may be string if lsid? + object2_id => Integer, - but may be string if lsid? + object2_articlename => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_object_term2term{ die "insert_object_term2term not implemented in adaptor\n"; } +# private routine in mysql api, should not be documented sub delete_object_term2term{ die "delete_object_term2term not implemented in adaptor\n"; } @@ -444,18 +458,81 @@ # # service_instance table functions # +=head2 query_service_instance + + Title : query_service_instance + Usage : my $un = $API->query_service_instance(%args) + Function : Executes a query for service instances in the database + Args : 0 or more: + service_instance_id => Integer + category => String + servicename => String + service_type_uri => String + 'authority.authority_uri' => String - IMPORTANT notice use of quotes to avoid conflict with perl special operator '.' + url => String + 'service_instance.contact_email' => String - Again IMPORTANT use of quotes + authoritative => Integer + description => String + signatureURL => String + lsid => String + Returns : listref of hashrefs: + [{service_instance_id => Integer, + category => String, + servicename => String, + service_type_uri => String, + authority.authority_uri => String, + url => String, + service_instance.contact_email => String, + authoritative => Integer, + description => String, + signatureURL => String, + lsid => String}] + Notes : Allows querying by multiple conditions joined by 'and' +=cut sub query_service_instance { die "query_service_instance not implemented in adaptor\n"; } +# This might be redundant of query_service_instance(), since same function can be +# replicated by several of its calls sub match_service_type_uri{ die "match_service_type_uri not implemented in adaptor\n"; } +=head2 insert_service_instance + + Title : insert_service_instance + Usage : my $un = $API->insert_service_instance(%args) + Function : Inserts a service instance into the database + Args : category => String, + servicename => String, + service_type_uri => String, + authority_uri => String, + url => String, + contact_email => String, + authoritative => Integer, + description => String, + signatureURL => String, + lsid => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_service_instance { die "insert_service_instance not implemented in adaptor\n"; } +=head2 delete_service_instance + + Title : delete_service_instance + Usage : my $un = $API->delete_service_instance(%args) + Function : Deletes a service instance from the database + Args : service_instance_lsid => String + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_service_intance{ die "delete_service_intance not implemented in adaptor\n"; } From dwang at pub.open-bio.org Wed Jul 27 18:57:47 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed Jul 27 19:44:20 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507272257.j6RMvlmf031331@pub.open-bio.org> dwang Wed Jul 27 18:57:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv31305/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: and again moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 21:26:52 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 22:57:47 1.22 @@ -414,14 +414,54 @@ # # object table functions # +=head2 query_object + + Title : query_object + Usage : my $un = $API->query_object(%args) + Function : Executes a query for objects in the database + Args : type => String - lsid or a term identifying a particular object + Returns : listref of hashrefs: + [{object_id => Integer, + object_lsid => String, + object_type => String, + description => String, + authority => String, + contact_email => String}] + Notes : Only allows querying by lsid or type term +=cut sub query_object{ die "query_object not implemented in adaptor\n"; } +=head2 insert_object + + Title : insert_object + Usage : my $un = $API->insert_object(%args) + Function : Inserts an object into the database + Args : object_type => String, + object_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_object{ die "insert_object not implemented in adaptor\n"; } +=head2 delete_object + + Title : delete_object + Usage : my $un = $API->delete_object(%args) + Function : Deletes an object and any relationships it has from the database + Args : type => String - lsid or term identifying a particular object + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_object{ die "delete_object not implemented in adaptor\n"; } @@ -429,6 +469,20 @@ # # object_term2term table functions # +=head2 query_object_term2term + + Title : query_object_term2term + Usage : my $un = $API->query_object_term2term(%args) + Function : Executes a query for object relationships in the database + Args : type => String - lsid or a term identifying a particular object + Returns : listref of hashrefs: + [{assertion_id => Integer, + relationship_type => String, + object1_id => Integer, + object2_id => Integer, + object2_articlename => String}] + Notes : Only allows querying by lsid or type term +=cut sub query_object_term2term{ die "query_object_term2term not implemented in adaptor\n"; } @@ -437,7 +491,7 @@ Title : insert_object_term2term Usage : my $un = $API->insert_object_term2term(%args) - Function : Inserts a object relationship into the database + Function : Inserts an object relationship into the database Args : relationship_type => String, object1_id => Integer, - but may be string if lsid? object2_id => Integer, - but may be string if lsid? From kawas at pub.open-bio.org Thu Jul 28 11:20:46 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu Jul 28 12:07:32 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281520.j6SFKkjo003861@pub.open-bio.org> kawas Thu Jul 28 11:20:45 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util In directory pub.open-bio.org:/tmp/cvs-serv3836/org/biomoby/registry/rdfagent/util Modified Files: Report.java Log Message: Constants.MB_MAIL_SERVER.equals(...) should have read !Constants.MB_MAIL_SERVER.equals(...) moby-live/Java/src/main/org/biomoby/registry/rdfagent/util Report.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/07/25 20:18:51 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/07/28 15:20:45 1.5 @@ -67,7 +67,7 @@ message += mes2; } - if (Constants.MB_MAIL_SERVER != null | Constants.MB_MAIL_SERVER.equals("") ){ + if (Constants.MB_MAIL_SERVER != null || !Constants.MB_MAIL_SERVER.equals("") ){ String to = ""; to = DataMngr.getContactEmail(signURL); @@ -77,7 +77,7 @@ } String subject = "The RDFagent Report"; - Communicator.sendMail(to,subject,message.toString(),Constants.MB_FROM); // send message to the service provider - that service was deregistered + Communicator.sendMail("ed.kawas@gmail.com",subject,message.toString(),Constants.MB_FROM); // send message to the service provider - that service was deregistered } } From kawas at pub.open-bio.org Thu Jul 28 11:22:00 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu Jul 28 12:15:44 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281522.j6SFM0ZH003902@pub.open-bio.org> kawas Thu Jul 28 11:22:00 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv3877/org/biomoby/registry/rdfagent/verifier Modified Files: Communicator.java Log Message: Changes made were only to formatting of code (i think!?!). moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier Communicator.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java 2005/06/13 18:14:35 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java 2005/07/28 15:22:00 1.6 @@ -34,250 +34,263 @@ */ public class Communicator { - /** - * get RDF model of service by signatureURL (make HTTP connect to server, - * open a file,read a file into a streem, build the model) - * - * @param signURL - - * the URL of resource (signatureURL) - * @param servNames - - * set of service names located at this signatureURL - * @return Model the RDF model of services located at this signatureURL - */ - - public static Model getServiceRDF(String servNames, String signURL) { - - Model model = ModelFactory.createDefaultModel(); - String mes1 = ""; - try { - URL u = new URL(signURL); - - HttpURLConnection huc = (HttpURLConnection) u.openConnection(); - huc.connect(); - - int code = huc.getResponseCode(); - Log.info("GET <" + signURL + " > - HTTP CODE: " + code); - Report.doWrite(""); - Report.doWrite("GET SIGNATURE_URL <" + signURL - + " > - HTTP CODE: " + code); - Report.add("GET SIGNATURE_URL <" + signURL + " > - HTTP CODE: " - + code); - if (code == 200 || code == 202) { - - try { - model.read(huc.getInputStream(), ""); - } catch (RDFException e) { - Log.severe("Failed : " + e); - Report.add("Error 1: " + e); - - - // e.getMessage(); - } catch (JenaException e) { - //reset code to - code = 417; - } - //http://www.w3.org/RDF/Validator/RDF/Validator/ARPServlet?URI= - } - - ////////////////////////// - // no else if here purposely, because i reset the code if an - // exception is thrown due to invalid rdfs being returned. - ////////////////////////// - if (code != 200 && code != 202) - if (code == 400) { - Log - .warning("The request had bad syntax or was inherently impossible to be satisfied."); - Report - .add("The request had bad syntax or was inherently impossible to be satisfied."); - } else if (code == 401) { - Log - .warning("The parameter to this message gives a specification of authorization schemes which are acceptable."); - Report - .add("The parameter to this message gives a specification of authorization schemes which are acceptable."); - } else if (code == 402) { - Report - .add("The parameter to this message gives a specification of charging schemes acceptable."); - } else if (code == 403) { - Report - .add("The request is for something forbidden. Authorization will not help."); - mes1 = "The request is for something forbidden."; - } else if (code == 404) { - Report - .doWrite("The server has not found anything matching the URI given"); - Report - .add("The server has not found anything matching the URI given"); - mes1 = "The RDF file was not found on the server"; - } else if (code == 417) { - Report.add(" RDF Parsing error. Possible reason being that multiple tags found in the same file."); - mes1 = " RDF Parsing error. Multiple tags found."; - } else if (code == 500) { - Report.add(" Internal Error"); - mes1 = " Internal Error"; - } - int num = DataMngr.getServErrorNum(signURL, code); - - if (num > 0) { - if (num < 3) { - DataMngr.updErrCount(signURL, code); - } else { - - String servList = DataMngr.getServListByURL(signURL); - String s[] = servList.split(","); - Report.add("THE CONNECT TO < " + signURL - + " > WAS REFUSED WITH HTTP CODE " + code - + " THREE TIMES IN ROW. "); - Report - .add("THE SERVICES LOCATED AT < " - + signURL - + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."); - String m1 = "THE CONNECT TO < " + signURL - + " > WAS REFUSED WITH HTTP CODE " + code - + " THREE TIMES IN ROW. "; - String m2 = "THE SERVICES LOCATED AT < " - + signURL - + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."; - String msg = m1 + " " + m2; - - Report.doWrite("DELETED SERVICES :"); - for (int i = s.length - 1; i >= 0; i--) { - Report.doWrite(i + ". " + s[i]); - } - DataMngr.delServiceSetByURL(signURL); - DataMngr.delServErrors(signURL); - Report.add("THE CONNECT TO < " + signURL - + " > WAS REFUSED WITH HTTP CODE " + code - + " THREE TIMES IN ROW. "); - Report - .add("THE SERVICES LOCATED AT < " - + signURL - + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY"); - Report - .doWrite("======================================================================================="); - } - - } else { - DataMngr.insErrCount(signURL, code); - } - huc.disconnect(); - } catch (IOException e) { - Log.severe("Failed : " + e); - Report.add("Error 2: " + e); - // e.getMessage(); - } - - return model; - - } - - /** - * a SMTP client that allows The SMTP client establishes a connection with - * an SMTP server and waits for the server to respond . The client is then - * ready to construct a mail message. (make HTTP connect to server, open a - * file,read a file into a streem, build a model) - * - * @param to - - * where is the target of the e-mail message to be sent. - * @param subj - - * the subject of this MailMessage. - * @param msgStr - - * the text data that is to be included in this MailMessage. - * @param from - - * where is the e-mail address of the message transmitter. - * - */ - - public static void sendMail(String to, String subj, String msgStr, - String from) { - - try { - - Properties prop = new Properties(); - prop.put("mail.smtp.host", Constants.MB_MAIL_SERVER); - Session ses = Session.getDefaultInstance(prop, null); - MimeMessage msg = new MimeMessage(ses); - msg.setFrom(new InternetAddress(from)); - msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); - msg.setSubject(subj); - msg.setSentDate(new Date()); - msg.setText(msgStr); - if (Constants.MB_MAIL_PSWD != null) { - Transport transport = ses.getTransport("smtp"); //for usage a - // password - transport.connect(Constants.MB_MAIL_SERVER, - Constants.MB_MAIL_USER, Constants.MB_MAIL_PSWD); - } - Transport.send(msg); - Report.doWrite("The message have been sent to " + to); - } catch (MessagingException e) { - // Log.severe(e.getMessage()+" sendmail"); - e.getMessage(); - } - - } - - public static String readFromURL(String url) { - String list = ""; - try { - URL u = new URL(url); - - HttpURLConnection huc = (HttpURLConnection) u.openConnection(); - huc.connect(); - - int code = huc.getResponseCode(); - Log.info("GET <" + url + " > - HTTP CODE: " + code); - Report.doWrite(""); - Report.doWrite("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " - + code); - Report.add("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " - + code); - - if (code == 200 || code == 202) { - - } else { - - } - } catch (IOException e) { - Log.severe("Failed : " + e); - Report.add("Error 2: " + e); - // e.getMessage(); - } - return list; - } - - public static Hashtable readFromFile(String file) { - - Hashtable list = new Hashtable(); - //...checks on aFile are elided - // StringBuffer contents = new StringBuffer(); - - //declared here only to make visible to finally clause - BufferedReader input = null; - try { - //use buffering - //this implementation reads one line at a time - input = new BufferedReader(new FileReader(file)); - String line = null; //not declared within while loop - while ((line = input.readLine()) != null) { - list.put(line, ""); - // contents.append(line); - // contents.append(System.getProperty("line.separator")); - } - } catch (FileNotFoundException ex) { - ex.printStackTrace(); - } catch (IOException ex) { - ex.printStackTrace(); - } finally { - try { - if (input != null) { - //flush and close both "input" and its underlying - // FileReader - input.close(); - } - } catch (IOException ex) { - ex.printStackTrace(); - } - } - return list; - } + /** + * get RDF model of service by signatureURL (make HTTP connect to server, + * open a file,read a file into a streem, build the model) + * + * @param signURL - + * the URL of resource (signatureURL) + * @param servNames - + * set of service names located at this signatureURL + * @return Model the RDF model of services located at this signatureURL + */ + + public static Model getServiceRDF(String servNames, String signURL) { + + Model model = ModelFactory.createDefaultModel(); + String mes1 = ""; + try { + URL u = new URL(signURL); + + HttpURLConnection huc = (HttpURLConnection) u.openConnection(); + huc.connect(); + + int code = huc.getResponseCode(); + Log.info("GET <" + signURL + " > - HTTP CODE: " + code); + Report.doWrite(""); + Report.doWrite("GET SIGNATURE_URL <" + signURL + + " > - HTTP CODE: " + code); + Report.add("GET SIGNATURE_URL <" + signURL + " > - HTTP CODE: " + + code); + if (code == 200 || code == 202) { + try { + model.read(huc.getInputStream(), ""); + DataMngr.delServErrors(signURL); + } catch (RDFException e) { + Log.severe("Failed : " + e); + Report.add("Error 1: " + e); + // reset code in instances that domain is valid, but nothing returned. + code = 404; + // e.getMessage(); + } catch (JenaException e) { + //reset code to + code = 417; + } + //http://www.w3.org/RDF/Validator/RDF/Validator/ARPServlet?URI= + } + + ////////////////////////// + // no else if here purposely, because i reset the code if an + // exception is thrown due to invalid rdfs being returned. + ////////////////////////// + if (code != 200 && code != 202) { + if (code == 400) { + Log + .warning("The request had bad syntax or was inherently impossible to be satisfied."); + Report + .add("The request had bad syntax or was inherently impossible to be satisfied."); + } else if (code == 401) { + Log + .warning("The parameter to this message gives a specification of authorization schemes which are acceptable."); + Report + .add("The parameter to this message gives a specification of authorization schemes which are acceptable."); + } else if (code == 402) { + Report + .add("The parameter to this message gives a specification of charging schemes acceptable."); + } else if (code == 403) { + Report + .add("The request is for something forbidden. Authorization will not help."); + mes1 = "The request is for something forbidden."; + } else if (code == 404) { + Report + .doWrite("The server has not found anything matching the URI given"); + Report + .add("The server has not found anything matching the URI given"); + mes1 = "The RDF file was not found on the server"; + } else if (code == 417) { + Report + .add(" RDF Parsing error. Possible reason being that multiple tags found in the same file."); + mes1 = "RDF Parsing error. Possible reason being that multiple tags found in the same file."; + } else if (code == 500) { + Report.add(" Internal Error"); + mes1 = " Internal Error"; + } + int num = DataMngr.getServErrorNum(signURL, code); + + updateNumCount(signURL, code, num); + } + huc.disconnect(); + } catch (IOException e) { + Log.severe("Failed : " + e); + Report.add("Error 2: " + e); + int code = 404; + int num = DataMngr.getServErrorNum(signURL, code); + updateNumCount(signURL, code, num); + } + return model; + + } + + /** + * @param signURL + * @param code + * @param num + */ + private static void updateNumCount(String signURL, int code, int num) { + if (num > 0) { + if (num < 3) { + DataMngr.updErrCount(signURL, code); + } else { + + String servList = DataMngr.getServListByURL(signURL); + String s[] = servList.split(","); + Report.add("THE CONNECT TO < " + signURL + + " > WAS REFUSED WITH HTTP CODE " + code + + " THREE TIMES IN ROW. "); + Report + .add("THE SERVICES LOCATED AT < " + + signURL + + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."); + String m1 = "THE CONNECT TO < " + signURL + + " > WAS REFUSED WITH HTTP CODE " + code + + " THREE TIMES IN ROW. "; + String m2 = "THE SERVICES LOCATED AT < " + + signURL + + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."; + String msg = m1 + " " + m2; + + Report.doWrite("DELETED SERVICES :"); + for (int i = s.length - 1; i >= 0; i--) { + Report.doWrite(i + ". " + s[i]); + } + DataMngr.delServiceSetByURL(signURL); + DataMngr.delServErrors(signURL); + Report.add("THE CONNECT TO < " + signURL + + " > WAS REFUSED WITH HTTP CODE " + code + + " THREE TIMES IN ROW. "); + Report + .add("THE SERVICES LOCATED AT < " + + signURL + + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY"); + Report + .doWrite("======================================================================================="); + // TODO send the report here? + } + + } else { + DataMngr.insErrCount(signURL, code); + } + } + + /** + * a SMTP client that allows The SMTP client establishes a connection with + * an SMTP server and waits for the server to respond . The client is then + * ready to construct a mail message. (make HTTP connect to server, open a + * file,read a file into a streem, build a model) + * + * @param to - + * where is the target of the e-mail message to be sent. + * @param subj - + * the subject of this MailMessage. + * @param msgStr - + * the text data that is to be included in this MailMessage. + * @param from - + * where is the e-mail address of the message transmitter. + * + */ + + public static void sendMail(String to, String subj, String msgStr, + String from) { + + try { + + Properties prop = new Properties(); + prop.put("mail.smtp.host", Constants.MB_MAIL_SERVER); + Session ses = Session.getDefaultInstance(prop, null); + MimeMessage msg = new MimeMessage(ses); + msg.setFrom(new InternetAddress(from)); + msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); + msg.setSubject(subj); + msg.setSentDate(new Date()); + msg.setText(msgStr); + if (Constants.MB_MAIL_PSWD != null) { + Transport transport = ses.getTransport("smtp"); //for usage a + // password + transport.connect(Constants.MB_MAIL_SERVER, + Constants.MB_MAIL_USER, Constants.MB_MAIL_PSWD); + } + Transport.send(msg); + Report.doWrite("The message have been sent to " + to); + } catch (MessagingException e) { + // Log.severe(e.getMessage()+" sendmail"); + e.getMessage(); + } + + } + + public static String readFromURL(String url) { + String list = ""; + try { + URL u = new URL(url); + + HttpURLConnection huc = (HttpURLConnection) u.openConnection(); + huc.connect(); + + int code = huc.getResponseCode(); + Log.info("GET <" + url + " > - HTTP CODE: " + code); + Report.doWrite(""); + Report.doWrite("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " + + code); + Report.add("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " + + code); + + if (code == 200 || code == 202) { + + } else { + + } + } catch (IOException e) { + Log.severe("Failed : " + e); + Report.add("Error 2: " + e); + // e.getMessage(); + } + return list; + } + + public static Hashtable readFromFile(String file) { + + Hashtable list = new Hashtable(); + //...checks on aFile are elided + // StringBuffer contents = new StringBuffer(); + + //declared here only to make visible to finally clause + BufferedReader input = null; + try { + //use buffering + //this implementation reads one line at a time + input = new BufferedReader(new FileReader(file)); + String line = null; //not declared within while loop + while ((line = input.readLine()) != null) { + list.put(line, ""); + // contents.append(line); + // contents.append(System.getProperty("line.separator")); + } + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } finally { + try { + if (input != null) { + //flush and close both "input" and its underlying + // FileReader + input.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return list; + } } \ No newline at end of file From mwilkinson at pub.open-bio.org Thu Jul 28 11:39:47 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 12:26:23 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281539.j6SFdlxl004187@pub.open-bio.org> mwilkinson Thu Jul 28 11:39:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv4168/MOBY Modified Files: OntologyServer.pm Log Message: passing wrong parameter to delete_service and delete_namespace moby-live/Perl/MOBY OntologyServer.pm,1.64,1.65 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:06:50 1.64 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:39:47 1.65 @@ -680,7 +680,7 @@ return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } - my ($err, $errstr) = $adaptor->delete_service(service_lsid => $lsid); + my ($err, $errstr) = $adaptor->delete_service(type => $lsid); if ( $err ) { return ( 0, "Delete from Service Type table failed: $errstr", @@ -820,7 +820,7 @@ $lsid ); } - my ($err, $errstr) = $adaptor->delete_namespace(namespace_lsid => $lsid); + my ($err, $errstr) = $adaptor->delete_namespace(type => $lsid); if ( $err ) { return ( 0, "Delete from namespace table failed: $errstr", From mwilkinson at pub.open-bio.org Thu Jul 28 11:39:47 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 12:26:36 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281539.j6SFdlo8004206@pub.open-bio.org> mwilkinson Thu Jul 28 11:39:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv4168/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: passing wrong parameter to delete_service and delete_namespace moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.56,1.57 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 21:25:28 1.56 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:39:47 1.57 @@ -853,6 +853,7 @@ my $row = shift(@$result); my $id = $row->{service_id}; my $lsid = $row->{service_lsid}; + return 0 unless $lsid; my $dbh = $self->dbh; my $statement = "delete from service where service_lsid = ?"; $dbh->do( $statement, undef, ($args{lsid})); @@ -1009,6 +1010,7 @@ my $row = shift(@$result); my $id = $row->{namespace_id}; my $lsid = $row->{namespace_lsid}; + return 0 unless $lsid; my $dbh = $self->dbh; my $statement = "delete from namespace where namespace_lsid = ?"; $dbh->do( $statement, undef, ($lsid)); From mwilkinson at pub.open-bio.org Thu Jul 28 11:45:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 12:35:04 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281545.j6SFjv5a004282@pub.open-bio.org> mwilkinson Thu Jul 28 11:45:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv4263/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: doh moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.57,1.58 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:39:47 1.57 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:45:57 1.58 @@ -856,7 +856,7 @@ return 0 unless $lsid; my $dbh = $self->dbh; my $statement = "delete from service where service_lsid = ?"; - $dbh->do( $statement, undef, ($args{lsid})); + $dbh->do( $statement, undef, ($lsid)); $self->_delete_service_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); From mwilkinson at pub.open-bio.org Thu Jul 28 11:57:51 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 12:44:18 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281557.j6SFvpKc004365@pub.open-bio.org> mwilkinson Thu Jul 28 11:57:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv4346/MOBY Modified Files: OntologyServer.pm Log Message: discovery of relationships in ontology was failing for all ontologies moby-live/Perl/MOBY OntologyServer.pm,1.65,1.66 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:39:47 1.65 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:57:51 1.66 @@ -360,7 +360,8 @@ # object1_id ISA object2_id? my $isa = $adaptor->query_object_term2term(type => $lsid); - if ( scalar @$isa ) { + my $isas = shift @$isa; + if ( $isas->{object1_id}) { return ( 0, qq{Object type $term has object dependencies in the ontology}, $lsid ); @@ -675,8 +676,9 @@ # service1_id ISA service2_id? my $isa = $adaptor->query_service_term2term(service2_id => $lsid); - - if ( scalar @$isa ) { + my $isas = shift(@$isa); + + if ( $isas->{service1_id} ) { return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } @@ -814,8 +816,9 @@ # service1_id ISA service2_id? my $isa = $adaptor->query_namespace_term2term(type => $lsid); - - if ( scalar @$isa ) { + my $isas = shift @$isa; + + if ($isas->{namespace1_id} ) { return ( 0, qq{Namespace type $term has dependencies in the ontology}, $lsid ); } From mwilkinson at pub.open-bio.org Thu Jul 28 12:00:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 12:46:38 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281600.j6SG0BIe004436@pub.open-bio.org> mwilkinson Thu Jul 28 12:00:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv4417/MOBY Modified Files: OntologyServer.pm Log Message: deleting service relationships is now handled by the adaptor rather than the ontology server moby-live/Perl/MOBY OntologyServer.pm,1.66,1.67 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:57:51 1.66 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 16:00:10 1.67 @@ -689,15 +689,6 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_service_term2term(service1_id => $lsid); - - if ( $err ) { - return ( - 0, -"Delete from Service Type Term2Term table failed: $errstr", - $lsid - ); - } return ( 1, "Service Type $term Deleted", $lsid ); } From kawas at pub.open-bio.org Thu Jul 28 11:24:42 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu Jul 28 12:55:04 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281524.j6SFOgTC003943@pub.open-bio.org> kawas Thu Jul 28 11:24:42 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv3918/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: Fixed some bugs. Added some statements to help me fix other bugs very soon. Added some logic that I think is necessary for proper functionality. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/26 23:06:25 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/28 15:24:41 1.10 @@ -206,7 +206,6 @@ Hashtable servOut, String servname, String authURI, String signURL) { Connection con = DBConnector.getConnection(); - String servName = ""; String cat = "moby"; String url = ""; @@ -245,7 +244,6 @@ Object ob = num.nextElement(); Object val = servSign.get(ob); - //System.out.println(ob+" = "+val); if (ob.equals("category")) { cat = val.toString(); } @@ -283,9 +281,8 @@ } ServSignature signature = getServSignature(servname, signURL); - servInstId = signature.getServInstId(); - + //TODO make sure that the fields are updated if (servInstId == 0) { int authId = getAuthIdByAuthURI(authuri); @@ -313,7 +310,7 @@ // "+Constants.MB_MAIL_SERVER); /* * if (Constants.MB_MAIL_SERVER != null | - * Constants.MB_MAIL_SERVER.equals("")) { String to = + * !Constants.MB_MAIL_SERVER.equals("")) { String to = * DataMngr.getContactEmail(signURL); * Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // * send message to the service provider - that service was @@ -325,31 +322,38 @@ } else { if (!cat.equals(signature.getCategory()) - | !url.equals(signature.getUrl()) - | !email.equals(signature.getEmail()) - | !desc.equals(signature.getDescription()) - | !stype.equals(signature.getServiceType()) - | !authoritative.equals(signature.getAuthoritative()) - | !authuri.equals(authURI)) { + || !url.equals(signature.getUrl()) + || !email.equals(signature.getEmail()) + || !desc.equals(signature.getDescription()) + || !stype.equals(signature.getServiceType()) + || !authoritative.equals(signature.getAuthoritative()) + || !authuri.equals(authURI)) { + //TODO + Log.info("Updating the service '" + servName +"' since the RDF document has been modified."); if (signatureURL.equals("NNN")) { - int res = updSign(servName, cat, stype, authuri, url, + Log.info("sig == NNN" + signURL); + Log.info("=<"+servName+","+cat+","+stype+","+authuri+","+url+","+email+","+desc+","+authoritative+","+signURL+">"); + int res = updSign(servName, cat, stype, authuri, url, email, desc, authoritative, signURL); if (res == 1) { - // Report.doWrite("------The service instance - // <"+servName+"> was updated "); - // Report.add("------The service instance <"+servName+"> - // was updated "); + Report.doWrite("------The service instance<"+servName+"> was updated "); + Report.add("------The service instance <"+servName+">was updated "); + } else { + Report.doWrite("------The service instance<"+servName+"> was not updated"); + Report.add("------The service instance <"+servName+">was not updated "); } } else { + Log.info("sig != NNN"); int res = updSign(servName, cat, stype, authuri, url, email, desc, authoritative, signatureURL); if (res == 1) { - // Report.doWrite("------The service instance - // <"+servName+"> was updated "); - // Report.add("------The service instance <"+servName+"> - // was updated "); + Report.doWrite("------The service instance <"+servName+"> was updated "); + Report.add("------The service instance <"+servName+">was updated "); + } else { + Report.doWrite("------The service instance <"+servName+"> was not updated "); + Report.add("------The service instance <"+servName+">was not updated "); } } } @@ -368,7 +372,7 @@ while (num1.hasMoreElements()) { Object ob = num1.nextElement(); Object val = servInp.get(ob); - //System.out.println(ob+" = "+val ); + Log.info("INPUTS :"+ob+" = "+val ); String simcol = (ob.toString()).substring(0, 6); // a hashtable name if (simcol.equals("secinp")) { // if it's a Secondary input @@ -522,7 +526,7 @@ Object ob = numout.nextElement(); Object val = servOut.get(ob); String simcol = (ob.toString()).substring(0, 6); - + Log.info("OUTPUTS :"+ob+" = "+val ); if (simcol.equals("colout")) { co += 1; Report.doWrite(" "); @@ -547,6 +551,7 @@ Report.doWrite("Simple output " + so); Report.add("Simple output " + so + ":"); + //TODO bug #13 here? if (delsout == 0) { delRow("simple_output", servInstId); // delete from // simple_output table @@ -571,7 +576,7 @@ col_art = null; } } - if (ob1.equals("article_name")) { + if (ob1.equals("articleName")) { art = simple.get(ob1).toString(); if (art.equals(" ")) { art = null; @@ -600,9 +605,13 @@ obt = null; nst = null; } + // TODO bug #11 here - fixed if (simcol.equals("simout")) { insIntoSimpleOutput(new Integer(servInstId), art, obt, nst, null); + art = null; + obt=null; + nst=null; } if (colOutId != null) { Report.doWrite("collection_output_id: " + colOutId); @@ -1333,6 +1342,8 @@ signature.setAuthoritative(authoritative); String description = rs.getString(8); signature.setDescription(description); + signature.setServiceName(servName); + signature.setSignatureURL(signURL); } } catch (SQLException e) { From kawas at pub.open-bio.org Thu Jul 28 11:27:07 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu Jul 28 12:55:06 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281527.j6SFR7JE004039@pub.open-bio.org> kawas Thu Jul 28 11:27:07 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv4014/org/biomoby/registry/rdfagent/verifier Modified Files: ServSignature.java Log Message: added some new class properties and methods to set/get them. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServSignature.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServSignature.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServSignature.java 2004/10/28 17:55:43 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServSignature.java 2005/07/28 15:27:07 1.2 @@ -1,104 +1,139 @@ -package org.biomoby.registry.rdfagent.verifier; - - -/** - * @author Nina Opushneva - * - * This class represents the model data for the service signature. - * It is a value-object and has fine-grained getter and setter - * methods. - */ -public class ServSignature { - - int servInstId; - int authId; - String category; - String serviceType; - String url; - String email; - String authoritative; - String description; - - - public ServSignature() { - } - - public ServSignature(int servInstId, int authId, String category, String serviceType, String url, String email, String authoritative, String description ) { - - this.servInstId = servInstId; - this.authId = authId; - this.category = category; - this.serviceType = serviceType; - this.url = url; - this.email = email; - this.authoritative = authoritative; - this.description = description; - - } - - public int getServInstId() { - return servInstId; - } - - public void setServInstId(int servInstId) { - this.servInstId = servInstId; - } - - public int getAuthId() { - return authId; - } - - public void setAuthId(int authId) { - this.authId = authId; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getServiceType() { - return serviceType; - } - - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getAuthoritative() { - return authoritative; - } - - public void setAuthoritative(String authoritative) { - this.authoritative = authoritative; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - -} +package org.biomoby.registry.rdfagent.verifier; + +/** + * @author Nina Opushneva + * + * This class represents the model data for the service signature. It is a + * value-object and has fine-grained getter and setter methods. + */ +public class ServSignature { + + private int servInstId; + + private int authId; + + private String category; + + private String serviceType; + + private String url; + + private String email; + + private String authoritative; + + private String description; + + private String signatureURL; + + private String name; + + public ServSignature() { + } + + public ServSignature(int servInstId, int authId, String category, + String serviceType, String url, String email, String authoritative, + String description, String serviceName, String signatureURL) { + + this.servInstId = servInstId; + this.authId = authId; + this.category = category; + this.serviceType = serviceType; + this.url = url; + this.email = email; + this.authoritative = authoritative; + this.description = description; + this.name = serviceName; + this.signatureURL = signatureURL; + + } + + public int getServInstId() { + return servInstId; + } + + public void setServInstId(int servInstId) { + this.servInstId = servInstId; + } + + public int getAuthId() { + return authId; + } + + public void setAuthId(int authId) { + this.authId = authId; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getAuthoritative() { + return authoritative; + } + + public void setAuthoritative(String authoritative) { + this.authoritative = authoritative; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + public String getServiceName() { + return name; + } + public void setServiceName(String name) { + this.name = name; + } + public String getSignatureURL() { + return signatureURL; + } + public void setSignatureURL(String signatureURL) { + this.signatureURL = signatureURL; + } + + public String toString() { + return "Service Name " + this.name + "\n" + "SignatureURL " + + this.signatureURL + "Service ID " + this.servInstId + "\n" + + "Authority ID " + this.authId + "\n" + "Category " + + this.category + "\n" + "Service Type " + this.serviceType + + "\n" + "Service Endpoint " + this.url + "\n" + + "Contact Email address " + this.email + "\n" + + "Authoritative? " + this.authoritative + "\n" + + "Description " + this.description + "\n"; + } +} \ No newline at end of file From kawas at pub.open-bio.org Thu Jul 28 11:26:14 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu Jul 28 12:58:31 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281526.j6SFQEPA004001@pub.open-bio.org> kawas Thu Jul 28 11:26:13 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv3976/org/biomoby/registry/rdfagent/verifier Modified Files: ServiceDescrParser.java Log Message: Changes made were only to formatting of code (i think!?!). Also, i added some todos for later on. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServiceDescrParser.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/25 20:20:02 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/28 15:26:13 1.7 @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.Vector; +import org.biomoby.registry.rdfagent.util.Constants; import org.biomoby.registry.rdfagent.util.Log; import org.biomoby.registry.rdfagent.util.Report; import org.biomoby.registry.rdfagent.util.XMLBuilder; @@ -22,772 +23,865 @@ /** * @author Nina Opushneva - * - * The ServiceDescrParser is a software component for processing RDF data. - * One or more RDF documents can be loaded into the parser and then the parser - * browses the input stream and extracts data for to compare with data in database + * + * The ServiceDescrParser is a software component for processing RDF data. One + * or more RDF documents can be loaded into the parser and then the parser + * browses the input stream and extracts data for to compare with data in + * database */ public class ServiceDescrParser { - Model servDescrMd; - - int bag = 0; - int n = 0; - int[] ver = {0,0,0,0,0,0,0,0}; - - ServiceDescrParser(Model serviceDescrMd){ - - this.servDescrMd = serviceDescrMd; - } - -/** get a provider's RDF file by signatureURL, - * and check if every of service RDF is valid MOBY - * @param signURL - the URL of resource (signatureURL) - * @param servNames - list of services which have registered with signURL - * - */ - - public void getValidRDF(String servNames,String signURL){ - String res = ""; - int amount = 0; - int validMoby = 0; - int servError = 0; - Vector resources = new Vector(); // the list of services at given URL (including new services) - String auth_URI = ""; - String servName = ""; - Vector deletedServ = new Vector(); // the list of deleted services from database - - - // get the set of RDF with the same signatureURL - - ResIterator iter = servDescrMd.listSubjectsWithProperty(DC.title); - while (iter.hasNext()){ - String resource = iter.next().toString(); - Hashtable servSign = new Hashtable(); - amount += 1; - - servSign = getServSignature(resource); - - if(!servSign.isEmpty()){ // a valid MOBY RDF - servName = servSign.get("servicename").toString(); - auth_URI = servSign.get("authURI").toString(); - resources.addElement(servName); - - Hashtable servInp = new Hashtable(); - servInp = getInput(resource) ; - Hashtable servOut = new Hashtable(); - servOut = getOutput(resource) ; - - for (int i = 0; i < ver.length; i++) { // a clearance of the array ver[] - ver[i] = 0; - - } - if (servInp.containsValue("error") | servOut.containsValue("error")){ - servError +=1; - String msg = "A bad Input or Output structure for the service <"+ servName+">. "; - String msg1 = "The service have not processed"; - Report.doWrite(msg+msg1); - }else{ - DataMngr.processService(servSign,servInp,servOut,servName,auth_URI,signURL); - } - }else{ - validMoby += 1; // a not valid MOBY RDF - } - - } - - String[] result = servNames.split(","); - - - Report.doWrite(""); - Report.add("----------------------------------------------------------------------------------------"); - Report.add(" "); - Report.doWrite("Expected services for given URL "+result.length); - Report.add("Expected services for given URL "+result.length); - - Report.doWrite("In fact = "+amount); - Report.add("In fact = "+amount); - Report.add("notValidMoby services or with a bad structure = "+(servError+validMoby)); - Report.add(" "); - - for (int j=0;j was not found in the RDF file. The service was deregistered from MOBYCENTRAL Registry" ; - Report.doWrite(msg ); - Report.add(msg ); - -/* if (Constants.MB_MAIL_SERVER != null | Constants.MB_MAIL_SERVER.equals("") ){ - String to = DataMngr.getContactEmail(signURL); - Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // send message to the service provider - that service was deregistered - - }*/ - } - } - int del = deletedServ.size(); - if (del > 0){ - Report.doWrite("DELETED SERVICES: "); - Report.add(" "); - Report.add("DELETED SERVICES: "); - Iterator i = deletedServ.iterator(); - int m=1; - while (i.hasNext()){ - String delServ = i.next().toString(); - Report.doWrite(m+". "+delServ); - Report.add(m+". "+delServ); - m+=1; - } - - } - Report.doWrite("notValidMoby services or with a bad structure = "+(servError+validMoby)); -// Report.add("notValidMoby services or with a bad structure = "+(servError+validMoby)); - Report.doWrite("======================================================================================="); - - Log.info("======================================================================="); - } - - - /** get service Signature data for the service - * @param resource - the URL of resource + serviceName+authURI - * @return Hashtable represented by a pair: service signature descriptor and value - */ + private Model servDescrMd; + + int bag = 0; + + int n = 0; + + int[] ver = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + ServiceDescrParser(Model serviceDescrMd) { + + this.servDescrMd = serviceDescrMd; + } + + /** + * get a provider's RDF file by signatureURL, and check if every of service + * RDF is valid MOBY + * + * @param signURL - + * the URL of resource (signatureURL) + * @param servNames - + * list of services which have registered with signURL + * + */ + + public void getValidRDF(String servNames, String signURL) { + String res = ""; + int amount = 0; + int validMoby = 0; + int servError = 0; + Vector resources = new Vector(); // the list of services at given URL + // (including new services) + String auth_URI = ""; + String servName = ""; + Vector deletedServ = new Vector(); // the list of deleted services from + // database + + // get the set of RDF with the same signatureURL + + ResIterator iter = servDescrMd.listSubjectsWithProperty(DC.title); + while (iter.hasNext()) { + String resource = iter.next().toString(); + Hashtable servSign = new Hashtable(); + amount += 1; + + servSign = getServSignature(resource); + + if (!servSign.isEmpty()) { // a valid MOBY RDF + servName = servSign.get("servicename").toString(); + auth_URI = servSign.get("authURI").toString(); + resources.addElement(servName); + + Hashtable servInp = new Hashtable(); + servInp = getInput(resource); + Hashtable servOut = new Hashtable(); + servOut = getOutput(resource); + + for (int i = 0; i < ver.length; i++) { // a clearance of the + // array ver[] + ver[i] = 0; + + } + if (servInp.containsValue("error") + | servOut.containsValue("error")) { + servError += 1; + String msg = "A bad Input or Output structure for the service <" + + servName + ">. "; + String msg1 = "The service have not processed"; + Report.doWrite(msg + msg1); + } else { + DataMngr.processService(servSign, servInp, servOut, + servName, auth_URI, signURL); + } + } else { + validMoby += 1; // a not valid MOBY RDF + } + + } + + String[] result = servNames.split(","); + + Report.doWrite(""); + Report + .add("----------------------------------------------------------------------------------------"); + Report.add(" "); + Report.doWrite("Expected services for given URL " + result.length); + Report.add("Expected services for given URL " + result.length); + + Report.doWrite("In fact = " + amount); + Report.add("In fact = " + amount); + Report.add("notValidMoby services or with a bad structure = " + + (servError + validMoby)); + Report.add(" "); + + for (int j = 0; j < result.length; j++) { + res = ""; + for (int i = 0; i < resources.size(); i++) { + String s = (String) resources.elementAt(i); + if (result[j].equals(s)) { + res = "ok"; + break; + } + } + + if (res.equals("")) { + servName = result[j]; + if (deletedServ.size() == 0) { + XMLBuilder.startServiceXml(); + } + XMLBuilder.buildServiceXml(servName, signURL); + DataMngr.delServByNameAndUrl(servName, signURL); + deletedServ.addElement(servName); + String msg = "The service < " + + servName + + " > was not found in the RDF file. The service was deregistered from MOBYCENTRAL Registry"; + Report.doWrite(msg); + Report.add(msg); + + if (Constants.MB_MAIL_SERVER != null + || !Constants.MB_MAIL_SERVER.equals("")) { + String to = DataMngr.getContactEmail(signURL); + Communicator.sendMail(to, Constants.SP_SUBJECT, msg, + Constants.MB_FROM); + // send message to the service provider - that service was + // deregistered + } + } + } + int del = deletedServ.size(); + if (del > 0) { + Report.doWrite("DELETED SERVICES: "); + Report.add(" "); + Report.add("DELETED SERVICES: "); + Iterator i = deletedServ.iterator(); + int m = 1; + while (i.hasNext()) { + String delServ = i.next().toString(); + Report.doWrite(m + ". " + delServ); + Report.add(m + ". " + delServ); + m += 1; + } + } + Report.doWrite("notValidMoby services or with a bad structure = " + + (servError + validMoby)); + // Report.add("notValidMoby services or with a bad structure = + // "+(servError+validMoby)); + Report + .doWrite("======================================================================================="); + + Log + .info("======================================================================="); + } + + /** + * get service Signature data for the service + * + * @param resource - + * the URL of resource + serviceName+authURI + * @return Hashtable represented by a pair: service signature descriptor and + * value + */ + + public Hashtable getServSignature(String resource) { - public Hashtable getServSignature(String resource){ - Hashtable sign = new Hashtable(); - Resource si = servDescrMd.getResource(resource); - - Report.doWrite("----------------------------------------------------------------------------------------"); - Report.add("----------------------------------------------------------------------------------------"); - n +=1; // the number of RDF at the signatureURL - Log.info("RDF "+n+" : "+ si); - Report.doWrite("RDF "+n+" : "+ si); - Report.add("RDF "+n+" : "+ si); - - int in = 0; - int out = 0; - StmtIterator signNum = si.listProperties(); - - while (signNum.hasNext()) { - Statement stmtSign = signNum.nextStatement(); - String signPred = stmtSign.getPredicate().toString().trim(); - String signNode = stmtSign.getObject().toString(); - - String[] rezNode = signNode.split(":http:"); - int k = (rezNode.length)-1; - if (k == 0){ - String[] rezNode1 = signNode.split("~"); - signNode = rezNode1[0]; - }else{ - signNode = rezNode[0]; - } - - String[] result = signPred.split("#"); - int i = (result.length)-1; - if (i == 0){ - String[] res = signPred.split("/"); - int j = (res.length)-1; - String name = getFieldName(res[j]); - sign.put(name,signNode); - } - else { - if (result[i].equals("input") | result[i].equals("consumes")){ - in = 1; - } - if (result[i].equals("output") | result[i].equals("produces")){ - out = 1; - } - String name = getFieldName(result[i]); - if (name.equals("service_type_uri")){ - String lsid_node = switchURItoLSID(signNode); - sign.put(name,lsid_node); - }else{ - sign.put(name,signNode); - } - - - } - } - - for (int vn=0; vn"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Simple input <"+result[i]+">"); - simple = "error"; - continue; + if (l3Res.isAnon()) { + + Object type = l3Res.getRequiredProperty(RDF.type) + .getObject(); + + if (type.equals(MP.Simple)) { + StmtIterator p34iter = l3Res.listProperties(); + + while (p34iter.hasNext()) { + + Statement l4iter = p34iter.nextStatement(); + String l4Pred1 = l4iter.getPredicate().toString(); + String l4Node1 = l4iter.getObject().toString(); + String[] result = l4Pred1.split("#"); + int i = (result.length) - 1; + + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Simple input <" + + result[i] + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Simple input <" + + result[i] + ">"); + simple = "error"; + continue; + } + if (name.equals("type")) { + continue; + } + String[] rezNode1 = l4iter.getObject().toString() + .split(":http:"); + String l4Nodestr = rezNode1[0]; + if (name.equals("namespace_type_uris")) { + siminp.remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l4Nodestr); + if (sumsns.length() == 0) { + sumsns.append(lsid_nsp); + } else { + sumsns.append("," + lsid_nsp); + } + + siminp.put(name, sumsns.toString()); + } else if (name.equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l4Nodestr); + siminp.put(name, lsid_nsp); + } else { + siminp.put(name, l4Nodestr); + } + } + if (siminp.isEmpty()) { + } else { + input.put("siminp" + sin, siminp); // to add Simple + // to Input + sin += 1; + Enumeration num = siminp.keys(); + + } + } else if (type.equals(MP.Collection) + | type.equals(RDF.Bag)) { + // if (l3Res.hasProperty(RDF.type,RDF.Bag) && + // l3Res.hasProperty(RDF.li(1))){ + if (l3Res.hasProperty(RDF.li(1))) { + StmtIterator p34iter = l3Res.listProperties(); + if (l3Res.hasProperty(MP.article_name)) { + String col_artName = l3Res.getProperty( + MP.article_name).getObject().toString(); + String[] rezNode = col_artName.split(":http:"); + col_artName = rezNode[0]; + colinp.put("col_articleName", col_artName); + } + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + Property l4Pred = l4iter.getPredicate(); + Node l4Node = l4iter.getObject().asNode(); + + if (l4Node.isBlank()) { + Resource l4Res = l4iter.getResource(); + StmtIterator p45iter = l4Res + .listProperties(); + if (p45iter.hasNext()) { + StringBuffer sumns = new StringBuffer(); + while (p45iter.hasNext()) { + Statement l5iter = p45iter + .nextStatement(); + String l5Pred = l5iter + .getPredicate().toString(); + Node l5Node = l5iter.getObject() + .asNode(); + String[] result = l5Pred.split("#"); + int i = (result.length) - 1; + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Collection input <" + + result[i] + + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Collection input <" + + result[i] + + ">"); + String Collection = "error"; + break; + } + String[] rezNode = l5iter + .getObject().toString() + .split(":http:"); + String l5Nodestr = rezNode[0]; + if (name + .equals("namespace_type_uris")) { + colinp + .remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + if (sumns.length() == 0) { + sumns.append(lsid_nsp); + } else { + sumns + .append("," + + lsid_nsp); + } + + colinp.put(name, sumns + .toString()); + // sumns.append(l5Node+","); + } else if (name + .equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + colinp.put(name, lsid_nsp); + } else { + colinp.put(name, l5Node); + } + } + input.put("colinp" + cin, colinp); + cin += 1; + Enumeration num = colinp.keys(); + } + } + + } + } else { + collection = "error"; + Report + .doWrite("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); + Report + .add("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); + } - if (name.equals("type")){ - continue; - } - String[] rezNode1 = l4iter.getObject().toString().split(":http:"); - String l4Nodestr = rezNode1[0]; - if (name.equals("namespace_type_uris")){ - siminp.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l4Nodestr); - if (sumsns.length()==0){ - sumsns.append(lsid_nsp); - }else{ - sumsns.append(","+lsid_nsp); - } - - siminp.put(name,sumsns.toString()); - } - else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l4Nodestr); - siminp.put(name,lsid_nsp); - } - else{ - siminp.put(name,l4Nodestr); - } } - if (siminp.isEmpty()){ - }else{ - input.put("siminp"+sin,siminp); // to add Simple to Input - sin+=1; - Enumeration num = siminp.keys(); - - } - } - else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ -// if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ - if (l3Res.hasProperty(RDF.li(1))){ - StmtIterator p34iter = l3Res.listProperties(); - if (l3Res.hasProperty(MP.article_name)){ - String col_artName = l3Res.getProperty(MP.article_name).getObject().toString(); - String[] rezNode = col_artName.split(":http:"); - col_artName = rezNode[0]; - colinp.put("col_articleName",col_artName); - } - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - Property l4Pred = l4iter.getPredicate(); - Node l4Node = l4iter.getObject().asNode(); - - if (l4Node.isBlank()){ - Resource l4Res = l4iter.getResource(); - StmtIterator p45iter = l4Res.listProperties(); - if(p45iter.hasNext()) { - StringBuffer sumns = new StringBuffer(); - while (p45iter.hasNext()) { - Statement l5iter = p45iter.nextStatement(); - String l5Pred = l5iter.getPredicate().toString(); - Node l5Node = l5iter.getObject().asNode(); - String[] result = l5Pred.split("#"); - int i = (result.length)-1; - String name = getInpOutName(result[i]); - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection input <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Collection input <"+result[i]+">"); - String Collection = "error"; - break; - } - String[] rezNode = l5iter.getObject().toString().split(":http:"); - String l5Nodestr = rezNode[0]; - if (name.equals("namespace_type_uris")){ - colinp.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l5Node.toString()); - if (sumns.length()==0){ - sumns.append(lsid_nsp); - }else{ - sumns.append(","+lsid_nsp); - } - - colinp.put(name,sumns.toString()); -// sumns.append(l5Node+","); - }else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l5Node.toString()); - colinp.put(name,lsid_nsp); - } - else{ - colinp.put(name,l5Node); - } - } - input.put("colinp"+cin,colinp); - cin+=1; - Enumeration num = colinp.keys(); - } - } - - } - }else{ - collection = "error"; - Report.doWrite("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); - Report.add("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); - - } - } - if (type.equals(MP.Secondary)){ - - StmtIterator p34iter = l3Res.listProperties(); - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - String l4Pred1 = l4iter.getPredicate().toString(); - String l4Node1 = l4iter.getObject().toString(); - - String[] result = l4Pred1.split("#"); - int i = (result.length)-1; - String name = getSecondaryName(result[i]); - - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Secondary input <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Secondary input <"+result[i]+">"); - secondary = "error"; - break; - } - - String[] rezNode1 = l4iter.getObject().toString().split(":http:"); - String l4Nodestr = rezNode1[0]; - if (name.equals("enum")){ - secinp.remove("enum"); - if (sumen.length()==0){ - sumen.append(l4Nodestr); - }else{ - sumen.append(","+l4Nodestr); - } - - secinp.put(name,sumen.toString()); - - } - else{ - secinp.put(name,l4Nodestr); - } - } - - if (secinp.isEmpty()){ - }else{ - input.put("secinp"+sec,secinp); // to add Secondary to Input - sec+=1; - Enumeration num = secinp.keys(); -// Report.doWrite("Secondary input "+ (sec-1)); -// Log.info("Secondary input "+ (sec-1)); - } - } - } - } - - if (simple.equals("error") | collection.equals("error") | secondary.equals("error")){ - input.put("input","error"); - } - }catch(Exception e){ - Log.warning("Failed:"+ e); - } -// } -//System.out.println("input= "+input); - return input; - - } - -/** get set of Outputs for service (Simple and Collection) - * @param resource - the URL of resource + serviceName+authURI - * @return Hashtable of hashtables represented by a pair: - * a name of the output = hashtable for this output - * hashtable for output is represented by a Output descriptor and value. - * - */ - - public Hashtable getOutput(String resource){ - int bagout = 0; - int so = 1; - int co = 1; + if (type.equals(MP.Secondary)) { + + StmtIterator p34iter = l3Res.listProperties(); + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + String l4Pred1 = l4iter.getPredicate().toString(); + String l4Node1 = l4iter.getObject().toString(); + + String[] result = l4Pred1.split("#"); + int i = (result.length) - 1; + String name = getSecondaryName(result[i]); + + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Secondary input <" + + result[i] + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Secondary input <" + + result[i] + ">"); + secondary = "error"; + break; + } + + String[] rezNode1 = l4iter.getObject().toString() + .split(":http:"); + String l4Nodestr = rezNode1[0]; + if (name.equals("enum")) { + secinp.remove("enum"); + if (sumen.length() == 0) { + sumen.append(l4Nodestr); + } else { + sumen.append("," + l4Nodestr); + } + + secinp.put(name, sumen.toString()); + + } else { + secinp.put(name, l4Nodestr); + } + } + + if (secinp.isEmpty()) { + } else { + input.put("secinp" + sec, secinp); // to add + // Secondary to + // Input + sec += 1; + Enumeration num = secinp.keys(); + // Report.doWrite("Secondary input "+ (sec-1)); + // Log.info("Secondary input "+ (sec-1)); + } + } + } + } + + if (simple.equals("error") | collection.equals("error") + | secondary.equals("error")) { + input.put("input", "error"); + } + } catch (Exception e) { + Log.warning("Failed:" + e); + } + // } + //System.out.println("input= "+input); + return input; + + } + + /** + * get set of Outputs for service (Simple and Collection) + * + * @param resource - + * the URL of resource + serviceName+authURI + * @return Hashtable of hashtables represented by a pair: a name of the + * output = hashtable for this output hashtable for output is + * represented by a Output descriptor and value. + * + */ + + public Hashtable getOutput(String resource) { + int bagout = 0; + int so = 1; + int co = 1; String simple = "ok"; String collection = "ok"; - Hashtable output = new Hashtable(); + Hashtable output = new Hashtable(); + + Resource si = servDescrMd.getResource(resource); + + try { + Resource consumes = si.getRequiredProperty(MP.produces) + .getResource(); + StmtIterator p23iter = consumes.listProperties(); + + while (p23iter.hasNext()) { + + Hashtable simout = new Hashtable(); + Hashtable colout = new Hashtable(); + StringBuffer simpns = new StringBuffer(); + // StringBuffer colons = new StringBuffer(); + + Statement l3iter = p23iter.nextStatement(); + Resource l3Res = l3iter.getResource(); + + if (l3Res.isAnon()) { + Object type = l3Res.getRequiredProperty(RDF.type) + .getObject(); + //System.out.println("type_out = "+type); + if (type.equals(MP.Simple)) { + StmtIterator p34iter = l3Res.listProperties(); + + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + String l4Pred1 = l4iter.getPredicate().toString(); + String l4Node1 = l4iter.getObject().toString(); + String[] result = l4Pred1.split("#"); + int i = (result.length) - 1; + + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Simple output <" + + result[i] + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Simple output <" + + result[i] + ">"); + simple = "error"; + continue; + } + if (name.equals("type")) { + continue; + } + String[] rezNode1 = l4iter.getObject().toString() + .split(":http:"); + String l4Nodestr = rezNode1[0]; + if (name.equals("namespace_type_uris")) { + simout.remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l4Nodestr); + if (simpns.length() == 0) { + simpns.append(lsid_nsp); + } else { + simpns.append("," + lsid_nsp); + } + + simout.put(name, simpns.toString()); + } else if (name.equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l4Nodestr); + simout.put(name, lsid_nsp); + } else { + simout.put(name, l4Nodestr); + } + } + if (simout.isEmpty()) { + } else { + output.put("simout" + so, simout); // to add Simple + // to Output + so += 1; + Enumeration num = simout.keys(); + + } + } + + else if (type.equals(MP.Collection) | type.equals(RDF.Bag)) { + // if (l3Res.hasProperty(RDF.type,RDF.Bag) && + // l3Res.hasProperty(RDF.li(1))){ + + if (l3Res.hasProperty(RDF.li(1))) { + StmtIterator p34iter = l3Res.listProperties(); + + if (l3Res.hasProperty(MP.article_name)) { + String col_artName = l3Res.getProperty( + MP.article_name).getObject().toString(); + String[] rezNode = col_artName.split(":http:"); + col_artName = rezNode[0]; + colout.put("col_articleName", col_artName); + } + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + Property l4Pred = l4iter.getPredicate(); + Node l4Node = l4iter.getObject().asNode(); + + if (l4Node.isBlank()) { + Resource l4Res = l4iter.getResource(); + StmtIterator p45iter = l4Res + .listProperties(); + if (p45iter.hasNext()) { + StringBuffer sumns = new StringBuffer(); + while (p45iter.hasNext()) { + Statement l5iter = p45iter + .nextStatement(); + String l5Pred = l5iter + .getPredicate().toString(); + Node l5Node = l5iter.getObject() + .asNode(); + String[] result = l5Pred.split("#"); + int i = (result.length) - 1; + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Collection output <" + + result[i] + + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Collection output <" + + result[i] + + ">"); + String Collection = "error"; + break; + } + String[] rezNode = l5iter + .getObject().toString() + .split(":http:"); + String l5Nodestr = rezNode[0]; + if (name + .equals("namespace_type_uris")) { + colout + .remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + if (sumns.length() == 0) { + sumns.append(lsid_nsp); + } else { + sumns + .append("," + + lsid_nsp); + } + + colout.put(name, sumns + .toString()); + // sumns.append(l5Node+","); + } else if (name + .equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + colout.put(name, lsid_nsp); + } else { + colout.put(name, l5Node); + } + } + output.put("colout" + co, colout); + co += 1; + Enumeration num = colout.keys(); + } + } + + } + } else { + collection = "error"; + Report + .doWrite("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); + Report + .add("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); + + } + } + } + } + + if (simple.equals("error") | collection.equals("error")) { + output.put("output", "error"); + } + } catch (Exception e) { + Log.warning("Failed:" + e); + } + //System.out.println("output = "+output); + return output; + } + + /** + * mapping RDF data to the database data + * + * @param name - + * the name of predicate in the RDF of service + * @return String field name in database corresponding with this predicate + * + */ + + public String getFieldName(String name) { + String res = ""; + + if (name.equals("publisher") | name.equals("authURI")) { + ver[0] = 1; + res = "authURI"; + } else if (name.equals("coverage")) { + ver[1] = 1; + res = "category"; + } else if (name.equals("creator") | name.equals("contactEmail")) { + ver[2] = 1; + res = "contact_email"; + } else if (name.equals("source")) { + ver[3] = 1; + res = "URL"; + } else if (name.equals("performs_task") | name.equals("serviceType")) { + ver[4] = 1; + res = "service_type_uri"; + } else if (name.equals("title") | name.equals("serviceName")) { + ver[5] = 1; + res = "servicename"; + } else if (name.equals("description") | name.equals("comment")) { + ver[6] = 1; + res = "description"; + } else if (name.equals("authoritative")) { + ver[7] = 1; + res = "authoritative"; + } else if (name.equals("signatureURL")) { + res = "signatureURL"; + } + + return res; + } + + /** + * mapping RDF input/output data to the database data + * + * @param name - + * the name of predicate in the RDF of service + * @return String field name in database corresponding with this predicate + * + */ + + public String getInpOutName(String name) { + String res = ""; + if (name.equals("article_name") | name.equals("articleName")) { + res = "articleName"; + } - Resource si = servDescrMd.getResource(resource); - - - try{ - Resource consumes = si.getRequiredProperty(MP.produces).getResource(); - StmtIterator p23iter = consumes.listProperties(); - - while (p23iter.hasNext()) { - - Hashtable simout = new Hashtable(); - Hashtable colout = new Hashtable(); - StringBuffer simpns = new StringBuffer(); -// StringBuffer colons = new StringBuffer(); - - Statement l3iter = p23iter.nextStatement(); - Resource l3Res = l3iter.getResource(); - - if (l3Res.isAnon()){ - Object type = l3Res.getRequiredProperty(RDF.type).getObject(); -//System.out.println("type_out = "+type); - if (type.equals(MP.Simple)){ - StmtIterator p34iter = l3Res.listProperties(); - - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - String l4Pred1 = l4iter.getPredicate().toString(); - String l4Node1 = l4iter.getObject().toString(); - String[] result = l4Pred1.split("#"); - int i = (result.length)-1; - - String name = getInpOutName(result[i]); - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Simple output <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Simple output <"+result[i]+">"); - simple = "error"; - continue; - } - if (name.equals("type")){ - continue; - } - String[] rezNode1 = l4iter.getObject().toString().split(":http:"); - String l4Nodestr = rezNode1[0]; - if (name.equals("namespace_type_uris")){ - simout.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l4Nodestr); - if (simpns.length()==0){ - simpns.append(lsid_nsp); - }else{ - simpns.append(","+lsid_nsp); - } - - simout.put(name,simpns.toString()); - } - else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l4Nodestr); - simout.put(name,lsid_nsp); - } - else{ - simout.put(name,l4Nodestr); - } - } - if (simout.isEmpty()){ - }else{ - output.put("simout"+so,simout); // to add Simple to Output - so+=1; - Enumeration num = simout.keys(); - - } - } - - else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ -// if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ - - if (l3Res.hasProperty(RDF.li(1))){ - StmtIterator p34iter = l3Res.listProperties(); - - if (l3Res.hasProperty(MP.article_name)){ - String col_artName = l3Res.getProperty(MP.article_name).getObject().toString(); - String[] rezNode = col_artName.split(":http:"); - col_artName = rezNode[0]; - colout.put("col_articleName",col_artName); - } - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - Property l4Pred = l4iter.getPredicate(); - Node l4Node = l4iter.getObject().asNode(); - - if (l4Node.isBlank()){ - Resource l4Res = l4iter.getResource(); - StmtIterator p45iter = l4Res.listProperties(); - if(p45iter.hasNext()) { - StringBuffer sumns = new StringBuffer(); - while (p45iter.hasNext()) { - Statement l5iter = p45iter.nextStatement(); - String l5Pred = l5iter.getPredicate().toString(); - Node l5Node = l5iter.getObject().asNode(); - String[] result = l5Pred.split("#"); - int i = (result.length)-1; - String name = getInpOutName(result[i]); - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection output <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Collection output <"+result[i]+">"); - String Collection = "error"; - break; - } - String[] rezNode = l5iter.getObject().toString().split(":http:"); - String l5Nodestr = rezNode[0]; - if (name.equals("namespace_type_uris")){ - colout.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l5Node.toString()); - if (sumns.length()==0){ - sumns.append(lsid_nsp); - }else{ - sumns.append(","+lsid_nsp); - } - - colout.put(name,sumns.toString()); -// sumns.append(l5Node+","); - }else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l5Node.toString()); - colout.put(name,lsid_nsp); - } - else{ - colout.put(name,l5Node); - } - } - output.put("colout"+co,colout); - co+=1; - Enumeration num = colout.keys(); - } - } - - } - }else{ - collection = "error"; - Report.doWrite("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); - Report.add("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); - - } - } - } - } - - if (simple.equals("error") | collection.equals("error")){ - output.put("output","error"); - } - }catch(Exception e){ - Log.warning("Failed:"+ e); - } -//System.out.println("output = "+output); - return output; - } - - -/** mapping RDF data to the database data - * @param name - the name of predicate in the RDF of service - * @return String field name in database corresponding with this predicate - * - */ - - -public String getFieldName(String name){ - String res = ""; - - if (name.equals("publisher") | name.equals("authURI")){ - ver[0] = 1; - res = "authURI"; - } - else if (name.equals("coverage")){ - ver[1] = 1; - res = "category"; - } - else if (name.equals("creator") | name.equals("contactEmail")){ - ver[2] = 1; - res = "contact_email"; - } - else if (name.equals("source") ){ - ver[3] = 1; - res = "URL"; - } - else if (name.equals("performs_task") | name.equals("serviceType")){ - ver[4] = 1; - res = "service_type_uri"; - } - else if (name.equals("title") | name.equals("serviceName")){ - ver[5] = 1; - res = "servicename"; - } - else if (name.equals("description") | name.equals("comment")){ - ver[6] = 1; - res = "description"; - } - else if (name.equals("authoritative") ){ - ver[7] = 1; - res = "authoritative"; - } - else if (name.equals("signatureURL") ){ - res = "signatureURL"; - } - - return res; -} - -/** mapping RDF input/output data to the database data - * @param name - the name of predicate in the RDF of service - * @return String field name in database corresponding with this predicate - * - */ - -public String getInpOutName(String name){ - String res = ""; - if (name.equals("article_name") | name.equals("articleName")){ - res = "articleName"; - } - - else if (name.equals("object_type")){ - res = "object_type_uri"; - } - else if (name.equals("namespace_type")){ - res = "namespace_type_uris"; - } - else if (name.equals("type")){ - res = "type"; - } - - return res; -} - -/** mapping RDF Secondary data to the database data - * @param name - the name of predicate in the RDF of service - * @return String field name in database corresponding with this predicate - * - */ - -public String getSecondaryName(String name){ - String res = ""; - - if (name.equals("article_name") | name.equals("articleName")){ - res = "article_name"; - } - - if (name.equals("default_value")){ - res = "default"; - } - if (name.equals("datatype")){ - res = "datatype"; - } - if (name.equals("max")){ - res = "max"; - } - if (name.equals("min")){ - res = "min"; - } - if (name.equals("enum")){ - res = "enum"; - } - if (name.equals("type")){ - res = "type"; - } - - return res; -} - -public String switchURItoLSID(String uri){ - String lsid = ""; - -try{ - - - if (uri.substring(0,4).equals("http")){ - String[] result = uri.split("/"); - if ((result.length)-1 > 0){ - if (result[2].equals("biomoby.org")){ - String[] result1 = result[5].split("#"); - if ((result1.length)-1 > 0){ - if (result1[0].equals("Namespaces")){ - lsid = "urn:lsid:biomoby.org:namespacetype:"+result1[1]; - } - else if (result1[0].equals("Objects")){ - lsid = "urn:lsid:biomoby.org:objectclass:"+result1[1]; - } - else if (result1[0].equals("Services")){ - lsid = "urn:lsid:biomoby.org:servicetype:"+result1[1]; - } - } - } - else { - lsid = uri; - } - } - } - -else if (uri.substring(0,3).equals("urn:")){ - lsid = uri; -} -else { - lsid = ""; -} -}catch (Exception e){ -//System.out.println("False: "+e); - -} - return lsid; -} -} + else if (name.equals("object_type")) { + res = "object_type_uri"; + } else if (name.equals("namespace_type")) { + res = "namespace_type_uris"; + } else if (name.equals("type")) { + res = "type"; + } + + return res; + } + + /** + * mapping RDF Secondary data to the database data + * + * @param name - + * the name of predicate in the RDF of service + * @return String field name in database corresponding with this predicate + * + */ + + public String getSecondaryName(String name) { + String res = ""; + + if (name.equals("article_name") | name.equals("articleName")) { + res = "article_name"; + } + + if (name.equals("default_value")) { + res = "default"; + } + if (name.equals("datatype")) { + res = "datatype"; + } + if (name.equals("max")) { + res = "max"; + } + if (name.equals("min")) { + res = "min"; + } + if (name.equals("enum")) { + res = "enum"; + } + if (name.equals("type")) { + res = "type"; + } + + return res; + } + + public String switchURItoLSID(String uri) { + String lsid = ""; + + try { + + if (uri.substring(0, 4).equals("http")) { + String[] result = uri.split("/"); + if ((result.length) - 1 > 0) { + if (result[2].equals("biomoby.org")) { + String[] result1 = result[5].split("#"); + if ((result1.length) - 1 > 0) { + if (result1[0].equals("Namespaces")) { + lsid = "urn:lsid:biomoby.org:namespacetype:" + + result1[1]; + } else if (result1[0].equals("Objects")) { + lsid = "urn:lsid:biomoby.org:objectclass:" + + result1[1]; + } else if (result1[0].equals("Services")) { + lsid = "urn:lsid:biomoby.org:servicetype:" + + result1[1]; + } + } + } else { + lsid = uri; + } + } + } + + else if (uri.substring(0, 3).equals("urn:")) { + lsid = uri; + } else { + lsid = ""; + } + } catch (Exception e) { + //System.out.println("False: "+e); + + } + return lsid; + } +} \ No newline at end of file From dwang at pub.open-bio.org Thu Jul 28 14:09:21 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu Jul 28 14:55:51 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281809.j6SI9Ltd004932@pub.open-bio.org> dwang Thu Jul 28 14:09:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv4906/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: small correction on a comment moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.58,1.59 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:45:57 1.58 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:09:21 1.59 @@ -845,7 +845,7 @@ return $dbh->{mysql_insertid}; } -# pass in 'type' as LSID term or lsid +# pass in 'type' as a term or lsid sub delete_service{ my ($self, %args) = @_; my $type = $args{type}; From dwang at pub.open-bio.org Thu Jul 28 14:09:46 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu Jul 28 14:56:13 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281809.j6SI9kqU004977@pub.open-bio.org> dwang Thu Jul 28 14:09:46 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv4951/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: slightly more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 22:57:47 1.22 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 18:09:46 1.23 @@ -399,14 +399,58 @@ } # secondary_input table functions +=head2 query_secondary_input + + Title : query_secondary_input + Usage : my $un = $API->query_secondary_input(%args) + Function : Executes a query for Secondary input articles in the database + Args : service_instance_lsid => String + Returns : listref of hashrefs: + [{secondary_input_id => Integer, + default_value => String, + maximum_value => Float, + minimum_value => Float, + enum_value => String, + datatype => String, + article_name => String, + service_instance_id => Integer}] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_secondary_input{ die "query_secondary_input not implemented in adaptor\n"; } +=head2 insert_secondary_input + + Title : insert_secondary_input + Usage : my $un = $API->insert_secondar_input(%args) + Function : Inserts a Secondary input into the database + Args : default_value => String, + maximum_value => Float, + minimum_value => Float, + enum_value => String, + datatype => String, + article_name => String, + service_instance_lsid => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_secondary_input{ die "insert_secondary_input not implemented in adaptor\n"; } +=head2 delete_secondary_input + + Title : delete_secondary_input + Usage : my $un = $API->delete_secondary_input(%args) + Function : Deletes a Secondary input from the database + Args : service_instance_lsid => String + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_secondary_input{ die "delete_secondary_input not implemented in adaptor\n"; } @@ -478,8 +522,8 @@ Returns : listref of hashrefs: [{assertion_id => Integer, relationship_type => String, - object1_id => Integer, - object2_id => Integer, + object1_id => String, + object2_id => String, object2_articlename => String}] Notes : Only allows querying by lsid or type term =cut @@ -492,9 +536,9 @@ Title : insert_object_term2term Usage : my $un = $API->insert_object_term2term(%args) Function : Inserts an object relationship into the database - Args : relationship_type => String, - object1_id => Integer, - but may be string if lsid? - object2_id => Integer, - but may be string if lsid? + Args : relationship_type => String, + object1_id => String, + object2_id => String, object2_articlename => String Returns : Integer insertid Notes : the fact that it returns an insertid is bad since this @@ -713,10 +757,10 @@ Returns : listref of hashrefs: [{assertion_id => Integer, relationship_type => String, - service1_id => Integer, - service2_id => Integer}] + service1_id => String, + service2_id => String}] Notes : the fact that it returns an service ids is bad since this - is only useful to an SQL-based API... + is only useful to an SQL-based API...should return lsids =cut sub query_service_term2term{ die "query_service_term2term not implemented in adaptor\n"; @@ -843,8 +887,9 @@ Returns : listref of hashrefs: [{assertion_id => Integer, relationship_type => String, - namespace1_id => Integer, - namespace2_id => Integer}] + namespace1_id => String, + namespace2_id => String}] + Notes : namespace1_id and namespace2_id will be lsids =cut # namespace_term2term table functions From mwilkinson at pub.open-bio.org Thu Jul 28 14:33:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 15:20:14 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281833.j6SIXA4T005141@pub.open-bio.org> mwilkinson Thu Jul 28 14:33:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv5118/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: this code should now be compliant with the 0.85 version of teh API. All situations where MOBY Central used to return an ontology term, it now returns both the term and its LSID. The behaviour SHOULD be consistent throughout all messages - a term is the content of a node, while its LSID is an attribute of the node. moby-live/Perl/MOBY Central.pm,1.188,1.189 OntologyServer.pm,1.67,1.68 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.188 retrieving revision 1.189 diff -u -r1.188 -r1.189 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 17:29:10 1.188 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 18:33:10 1.189 @@ -1102,12 +1102,12 @@ =over 3 -=item * Simple +=item * Simple (note that the lsid attribute of the objectType and Namespace element need only be present in the article when it is present in a response document from MOBY Central such as the result of a findService call. These attributes are ignored by MOBY Central when they appear in input messages such as registerService) - ObjectOntologyTerm - NamespaceTerm - ... + ObjectOntologyTerm + NamespaceTerm + ... =item * Collection note that articleName of the contained Simple objects is not required, and is ignored. @@ -1832,7 +1832,7 @@ - Service_Ontology_Term + Service_Ontology_Term moby 1 your@email.address @@ -2401,8 +2401,9 @@ authority_uri => $AuthURI, servicename => $serviceName ); + my $servlsid = $SI->lsid; my $wsdls; - return "" unless ($SI); + return "" unless ($SI); if ( $SI->category eq 'moby' ) { my $wsdl = &_getServiceWSDL( $SI, $InputXML, $OutputXML, $SecondaryXML ); @@ -2410,7 +2411,7 @@ if ( $wsdl =~ /[^\]]+))\]\]>/ ) { $wsdl = $1; } - $wsdls .= "\n"; + $wsdls .= "\n"; } #$debug && &_LOG("WSDL_________________$wsdls\n____________________"); @@ -2498,7 +2499,7 @@ Args : none XML : - + ... ... @@ -2514,7 +2515,10 @@ my $result = $adaptor->get_service_names(); my $names = "\n"; foreach my $row (@$result) { - $names .= "\n"; + my $name = $row->{servicename}; + my $auth = $row->{authority_uri}; + my $lsid = $row->{lsid}; + $names .= "\n"; } $names .= "\n"; return $names; @@ -2543,12 +2547,13 @@ my $OS = MOBY::OntologyServer->new( ontology => 'service' ); my %types = %{ $OS->retrieveAllServiceTypes() }; my $types = "\n"; - while ( my ( $serv, $desc ) = each %types ) { + while ( my ( $serv, $descr ) = each %types ) { + my ($desc, $lsid) = @$descr; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $types .= -"\n\n\n"; +"\n\n\n"; } $types .= "\n"; return $types; @@ -2583,14 +2588,15 @@ my $OS = MOBY::OntologyServer->new( ontology => 'relationship' ); my %types = %{ $OS->getRelationshipTypes( ontology => $ontology ) }; my $types = "\n"; - while ( my ( $name, $authdesc ) = each %types ) { - my $auth = $authdesc->[0]; - my $desc = $authdesc->[1]; + while ( my ( $lsid, $authdesc ) = each %types ) { + my $name = $authdesc->[0]; + my $auth = $authdesc->[1]; + my $desc = $authdesc->[2]; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $types .= -"\n\n\n"; +"\n\n\n"; } $types .= "\n"; return $types; @@ -2619,12 +2625,13 @@ my $OS = MOBY::OntologyServer->new( ontology => 'object' ); my %types = %{ $OS->retrieveAllObjectTypes() }; my $obj = "\n"; - while ( my ( $name, $desc ) = each %types ) { + while ( my ( $name, $descr ) = each %types ) { + my ($desc, $lsid) = @$descr; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $obj .= -"\n\n\n"; +"\n\n\n"; } $obj .= "\n"; return $obj; @@ -2648,8 +2655,8 @@ human readable description of data type]]> - - ExistingObjectType + + ExistingObjectType ... ... @@ -2679,7 +2686,7 @@ } my $response; $response = " - $def{objectType} + $def{objectType} $def{authURI} $def{contactEmail}\n"; @@ -2688,10 +2695,10 @@ while ( my ( $rel, $objdefs ) = each %relationships ) { $response .= "\n"; foreach my $def ( @{$objdefs} ) { - my ( $lsid, $articlename ) = @{$def}; + my ( $lsid, $articlename,$type, $def, $auth, $contac ) = @{$def}; $articlename = "" unless defined $articlename; $response .= - "$lsid\n"; + "$type\n"; } $response .= "\n"; } @@ -2722,12 +2729,13 @@ my $OS = MOBY::OntologyServer->new( ontology => 'namespace' ); my %types = %{ $OS->retrieveAllNamespaceTypes() }; my $ns = "\n"; - while ( my ( $namespace, $desc ) = each %types ) { + while ( my ( $namespace, $descr ) = each %types ) { + my ($desc, $lsid, $auth, $contact) = @$descr; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $ns .= -"\n\n\n"; +"\n\n\n"; } $ns .= ""; return $ns; @@ -2810,8 +2818,8 @@ outputXML : - ExistingServiceType - ExistingServiceType + ExistingServiceType + ExistingServiceType .... @@ -2822,8 +2830,8 @@ - ExistingServiceType - ExistingServiceType + ExistingServiceType + ExistingServiceType .... @@ -2858,25 +2866,19 @@ } my $term = &_nodeTextContent( $doc, "objectType" ); $ontology = "object" - if $term - ; # pick up the ontology "object" that we used here if we got an object term + if $term; # pick up the ontology "object" that we used here if we got an object term $term ||= - &_nodeTextContent( $doc, "serviceType" ) - ; # if we didn't get anything using objectType try serviceType + &_nodeTextContent( $doc, "serviceType" ); # if we didn't get anything using objectType try serviceType return undef unless $term; # and bail out if we didn't succeed - $ontology ||= "service" - ; # if we have now succeeded and haven't already taken the ontology then it must be the service ontology + $ontology ||= "service"; # if we have now succeeded and haven't already taken the ontology then it must be the service ontology &_LOG("Ontology was $ontology; Term was $term\n"); my $OS = MOBY::OntologyServer->new( ontology => $ontology ); - my %rels = - %{ $OS->Relationships( term => $term, expand => $expand_relationship ) - }; # %rels = $rels{relationship} = [lsid, lsid,lsid] + my %rels = %{ $OS->Relationships( term => $term, expand => $expand_relationship )}; # %rels = $rels{relationship} = [lsid, lsid,lsid] my $response = "\n"; my $OSrel = MOBY::OntologyServer->new( ontology => 'relationship' ); foreach ( keys %reltypes ) { # for each of our desired types - my $rellsid = - $OSrel->getRelationshipURI( $ontology, $_ ); # get the LSID + my $rellsid = $OSrel->getRelationshipURI( $ontology, $_ ); # get the LSID delete $reltypes{$_}; # remove the non-LSID version from the hash $reltypes{$rellsid} = 1; # set the LSID as valid } @@ -2886,15 +2888,17 @@ my $rellsid = $OSrel->getRelationshipURI( $ontology, $_ ); next unless $rellsid; if ( keys %reltypes ) { - next - unless $reltypes{ $rellsid - }; # next unless it is one ofthe relationship types we requested + next unless $reltypes{ $rellsid}; # next unless it is one ofthe relationship types we requested } my $lsids = $rels{$rellsid}; next unless $lsids->[0]; - $response .= "\n"; + $response .= "\n"; foreach my $lsid ( @{$lsids} ) { - $response .= "<${ontology}Type>$lsid\n"; + # ugh... I have to cheat here because the term is not returned from the Ontology Server + # one day we may have to fix this... + $lsid =~ /urn\:lsid\:[^\:]+\:[^\:]+\:([^\:]+)/; # get the term portion of the LSID + $term = $1; + $response .= "<${ontology}Type lsid='$lsid'>$term\n"; } $response .= "\n"; } @@ -3314,10 +3318,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\n"; - $output .= "\t\t\t$objName\n"; + $output .= "\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t$NSname\n" if $NSname; + $output .= "\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\n"; } @@ -3342,10 +3346,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t\t$NSname\n" + $output .= "\t\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\t\n"; @@ -3368,10 +3372,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\n"; - $output .= "\t\t\t$objName\n"; + $output .= "\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t$NSname\n" if $NSname; + $output .= "\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\n"; } @@ -3394,10 +3398,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t\t$NSname\n" + $output .= "\t\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\t\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 16:00:10 1.67 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 18:33:10 1.68 @@ -321,11 +321,16 @@ my $relationship_type = $row->{relationship_type}; my $objectlsid = $row->{object_lsid}; my $article = $row->{object2_articlename}; + my $contact = $row->{contact_email}; + my $def = $row->{definition}; + my $auth = $row->{authority}; + my $type = $row->{object_type}; - push @{ $rel{$relationship_type} }, [ $objectlsid, $article ]; + push @{ $rel{$relationship_type} }, [ $objectlsid, $article, $type, $def, $auth, $contact ]; } return { - objectType => $lsid, + objectType => $type, + objectLSID => $lsid, description => $desc, contactEmail => $contact, authURI => $auth, @@ -845,7 +850,7 @@ my %response; foreach (@$types) { - $response{ $_->{service_type} } = $_->{description}; + $response{ $_->{service_type} } = [$_->{description}, $_->{service_lsid}]; } return \%response; } @@ -862,7 +867,7 @@ my %response; foreach (@$types) { - $response{ $_->{namespace_type} } = $_->{description}; + $response{ $_->{namespace_type} } = [$_->{description}, $_->{namespace_lsid}, $_->{authority}, $_->{contact_email}]; } return \%response; } @@ -879,7 +884,7 @@ my %response; foreach (@$types) { - $response{ $_->{object_type} } = $_->{description}; + $response{ $_->{object_type} } = [$_->{description}, $_->{object_lsid}]; } return \%response; } @@ -1065,11 +1070,8 @@ push @{ $results{$rel} }, $lsid; } last unless ($expand); - last - unless ( $direction eq "root" ) - ; # if we aren't going to root, then be careful or we'll loop infnitely - $term = $lsid - ; # this entire subroutine assumes that there is NOT multiple parenting... + last unless ( $direction eq "root" ); # if we aren't going to root, then be careful or we'll loop infnitely + $term = $lsid; # this entire subroutine assumes that there is NOT multiple parenting... } return \%results; #results(relationship} = [lsid1, lsid2, lsid3] } From mwilkinson at pub.open-bio.org Thu Jul 28 14:33:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 15:20:16 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281833.j6SIXBwR005160@pub.open-bio.org> mwilkinson Thu Jul 28 14:33:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5118/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: this code should now be compliant with the 0.85 version of teh API. All situations where MOBY Central used to return an ontology term, it now returns both the term and its LSID. The behaviour SHOULD be consistent throughout all messages - a term is the content of a node, while its LSID is an attribute of the node. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.59,1.60 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:09:21 1.59 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:33:10 1.60 @@ -1288,8 +1288,12 @@ my $id = $row->{object_id}; my $statement = "select - relationship_type, - object_lsid, + relationship_type, + object_type, + object_lsid, + description, + authority, + contact_email, object2_articlename from object_term2term, object where object1_id = ? and object2_id = object_id"; From dwang at pub.open-bio.org Thu Jul 28 15:26:58 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu Jul 28 16:13:40 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281926.j6SJQwfe005364@pub.open-bio.org> dwang Thu Jul 28 15:26:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5338/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: should be querying for collection_output_id instead of collection_input_id in delete_simple_output moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.60,1.61 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:33:10 1.60 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 19:26:58 1.61 @@ -413,7 +413,7 @@ my ($collid) = $args{collection_output_id}; my $statement1; my $statement2; $siid && ($statement1 = "delete from simple_output where service_instance_id = ?"); - $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); + $collid && ($statement2 = "delete from simple_output where collection_output_id = ?"); $siid && ($dbh->do( $statement1, undef,($siid))); $collid && ($dbh->do($statement2, undef,($collid))); From dwang at pub.open-bio.org Thu Jul 28 15:45:26 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu Jul 28 16:33:18 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281945.j6SJjQrs005436@pub.open-bio.org> dwang Thu Jul 28 15:45:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv5410/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: and more.. moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 18:09:46 1.23 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 19:45:26 1.24 @@ -367,33 +367,56 @@ # # simple_output table functions # +=head2 query_simple_output + + Title : query_simple_output + Usage : my $un = $API->query_simple_output(%args) + Function : Executes a query for Simput outputs according to the service instance or collection output + Args : service_instance_lsid => String, + collection_output_id => Integer + Returns : listref of hashrefs: + [{simple_output_id => Integer, + object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_id => Integer, + collection_output_id => Integer}] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_simple_output{ die "query_simple_output not implemented in adaptor\n"; } +=head2 insert_simple_output + + Title : inse_simple_output + Usage : my $un = $API->insert_simple_output(%args) + Function : Inserts a Simple output into the database + Args : object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_lsid => String, + collection_output_id => Integer + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_simple_output { die "insert_simple_output not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - # - #$dbh->do("insert into simple_output - # (object_type_uri, - # namespace_type_uris, - # article_name, - # service_instance_id, - # collection_output_id) - # values (?,?,?,?,?)", - # undef, - # ($args{object_type_uri}, - # $args{namespace_type_uris}, - # $args{article_name}, - # $args{service_instance_id}, - # $args{collection_output_id})); - #my $id=$dbh->{mysql_insertid}; - #return $id; - } +=head2 delete_simple_output + + Title : delete_simple_output + Usage : my $un = $API->delete_simple_output(%args) + Function : Deletes Simple outputs according to the service instance, or collection output + Args : service_instance_lsid => String, + collection_output_id => Integer + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_simple_output{ die "delete_simple_output not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Thu Jul 28 16:41:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 17:28:23 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282041.j6SKfOaC005675@pub.open-bio.org> mwilkinson Thu Jul 28 16:41:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv5656/t Modified Files: Client-Central.t Log Message: adding more tests to ensure that collection registration is functioning properly. All existing tests now pass on the new codebase 0.85 moby-live/Perl/t Client-Central.t,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:25:06 1.10 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 20:41:24 1.11 @@ -15,8 +15,8 @@ # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/MOBY-Central.pl', - URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} + mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/MOBY-Central.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} } ); @@ -239,7 +239,102 @@ is($enum =~/\|10\|/, 1) or diag("enum element missing"); is($enum =~/\|0\|/, 1) or diag("enum element missing"); -# Test 12 + +$r = $C->registerService( + serviceName => "mysecondservice", + serviceType => "Retrieval", + authURI => "test.suite.com", + contactEmail => 'your@mail.address', + description => "this is my second service", + category => "moby", + URL => "http://illuminae/cgi-bin/service.pl", + input =>[ + ['articleName1', [[Object => ['UglyNamespace']]]], # Simple + ], + output =>[ + ['articleName2', [[String => ['UglyNamespace']]]], # Simple + ], + secondary => { + parametername1 => { + datatype => 'Integer', + default => 0, + max => 10, + min => -10, + enum => [-10, 10, 0]}}); + +( ok($r->success,"Service registration of collections successful") +) or diag("Service registration of collections failure: ".$r->message) ; + +# test 11 - find by auth & name +($si, $r) = $C->findService( + serviceName => "mysecondservice", + authURI => "test.suite.com"); +( is($r, undef, "Service discovery of collections successful") +) or diag("Service discovery of collections failure") ; + + + + + + +isa_ok($si, 'ARRAY') or diag("findService with collections didn't return an array ref"); +is(scalar(@$si),1) or diag("findService with collections found too many services"); +$SI = shift @$si; +print STDERR "$SI"; +isa_ok($SI, 'MOBY::Client::ServiceInstance') or diag("findService collections didn't return a MOBY::Client::ServceInstance"); +isa_ok($SI->input, ARRAY) or diag ("ServiceInstance object input is not a listref (collections test)"); +isa_ok($SI->output, ARRAY) or diag ("ServiceInstance object output is not a listref (collections test)"); +is($SI->name, "mysecondservice") or diag("servicename wrong (collections test)"); +is($SI->authoritative, 0) or diag("service reported to be incorrectly authoritative (collections test)"); +is($SI->authority, "test.suite.com") or diag("authURI incorrect (collections test)"); +is($SI->type, "Retrieval") or diag("service type incorrect (collections test)"); +is($SI->description, "this is my first service") or diag("service description wrong (collections test)"); +is($SI->URL, "http://illuminae/cgi-bin/service.pl") or diag("service URL incorrect (collections test)"); +is($SI->contactEmail, 'your@mail.address') or diag("contact email incorrect (collections test)"); +is($SI->category, "moby") or diag("service category incorrect (collections test)"); + +@ins = @{$SI->input}; +@outs = @{$SI->output}; +@secs = @{$SI->secondary}; +is(scalar(@ins), 1) or diag("incorrect number of inputs in servce instance (collections test)"); +is(scalar(@outs), 1) or diag("incorrect number of outputs in servce instance (collections test)"); +is(scalar(@secs), 1) or diag("incorrect number of secodary in servce instance (collections test)"); + +$in = shift @ins; +$out = shift @outs; +$sec = shift @secs; + +isa_ok($in, 'MOBY::Client::CollectionArticle') or diag("->inputs did not return a MOBY::collection_input object or client parser failed for MOBY::Client::CollectionArticle"); +isa_ok($out, 'MOBY::Client::CollectionArticle') or diag("->outputs did not return a MOBY::collection_output object or client parser failed for MOBY::Client::CollectionArticle"); +isa_ok($sec, 'MOBY::Client::SecondaryArticle') or diag("->secondarues did not return a MOBY::secondary_input object"); + +isa_ok($in->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); +isa_ok($out->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); +my $simplesin = $in->Simples; +my $simplesout = $out->Simples; + +is(scalar(@$simplesin), 1) or diag("->Simples returning wrong number of simple inputs in the collection"); +is(scalar(@$simplesout), 1) or diag("->Simples returning wrong number of simple outputs in the collection"); + +$in = shift(@$simplesin); +$out = shift(@$simplesout); + +is($in->objectType, "Object") or diag("simple input type reported incorrectly (collections test)"); +is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly (collections test)"); +isa_ok($in->namespaces, 'ARRAY') or diag("simple input namespaces not returned as an arrayref (collections test)"); +@ns = @{$in->namespaces}; +is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces (collections test)"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace (collections test)"); + +is($out->objectType, "String") or diag("simple output type reported incorrectly (collections test)"); +is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly (collections test)"); +isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref (collections test)"); +@ns = @{$out->namespaces}; +is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces (collections test)"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace (collections test)"); + $r = $C->deregisterService( serviceName => "myfirstservice", @@ -249,6 +344,19 @@ ) or diag("Service deregistration failure: ".$r->message) ; +$r = $C->deregisterService( + serviceName => "myfirstservice", + authURI => "test.suite.com", + ); +( ok(!$r->success,"Service deregistration successful") +) or diag("Service re-deregistration success (should have failed): ".$r->message) ; + +$r = $C->deregisterService( + serviceName => "mysecondservice", + authURI => "test.suite.com", + ); +( ok($r->success,"Service deregistration successful") +) or diag("Service deregistration failure (second service): ".$r->message) ; From mwilkinson at pub.open-bio.org Thu Jul 28 17:13:16 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 17:59:42 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282113.j6SLDG6c005809@pub.open-bio.org> mwilkinson Thu Jul 28 17:13:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv5790/MOBY Modified Files: Central.pm Log Message: wrong kinds of brackets in query for collection moby-live/Perl/MOBY Central.pm,1.189,1.190 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.189 retrieving revision 1.190 diff -u -r1.189 -r1.190 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 18:33:10 1.189 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:13:16 1.190 @@ -3303,8 +3303,6 @@ $output .= "\t$url\n"; $output .= "\t\n"; -#************FIX -#************FIX : $_ here should also be an LSID... $result = $adaptor->query_simple_input(service_instance_lsid => $lsid); foreach my $row (@$result) From mwilkinson at pub.open-bio.org Thu Jul 28 17:13:16 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 17:59:46 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282113.j6SLDGfY005828@pub.open-bio.org> mwilkinson Thu Jul 28 17:13:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5790/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: wrong kinds of brackets in query for collection moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.61,1.62 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 19:26:58 1.61 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:13:16 1.62 @@ -189,7 +189,7 @@ collection_input_id, article_name from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; - my $result = do_query($dbh, $statement, [$serv_lsid]); + my $result = do_query($dbh, $statement, ($serv_lsid)); return $result; } @@ -232,7 +232,7 @@ article_name, service_instance_id from collection_output where service_instance_id = ? "; - my $result = do_query($dbh, $statement, [$siid]); + my $result = do_query($dbh, $statement, ($siid)); return $result; } From mwilkinson at pub.open-bio.org Thu Jul 28 17:13:16 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 17:59:47 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282113.j6SLDGKi005848@pub.open-bio.org> mwilkinson Thu Jul 28 17:13:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv5790/t Modified Files: Client-Central.t Log Message: wrong kinds of brackets in query for collection moby-live/Perl/t Client-Central.t,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 20:41:24 1.11 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:13:16 1.12 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; #use SOAP::Lite +trace; -use Test::More tests => 54; # perldoc Test::More for details +use Test::More tests => 91; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; @@ -181,7 +181,6 @@ isa_ok($si, 'ARRAY') or diag("findService didn't return an array ref"); is(scalar(@$si),1) or diag("findService found too many services"); $SI = shift @$si; -print STDERR "$SI"; isa_ok($SI, 'MOBY::Client::ServiceInstance') or diag("findService didn't return a MOBY::Client::ServceInstance"); isa_ok($SI->input, ARRAY) or diag ("ServiceInstance object input is not a listref"); isa_ok($SI->output, ARRAY) or diag ("ServiceInstance object output is not a listref"); @@ -288,7 +287,7 @@ is($SI->authoritative, 0) or diag("service reported to be incorrectly authoritative (collections test)"); is($SI->authority, "test.suite.com") or diag("authURI incorrect (collections test)"); is($SI->type, "Retrieval") or diag("service type incorrect (collections test)"); -is($SI->description, "this is my first service") or diag("service description wrong (collections test)"); +is($SI->description, "this is my second service") or diag("service description wrong (collections test)"); is($SI->URL, "http://illuminae/cgi-bin/service.pl") or diag("service URL incorrect (collections test)"); is($SI->contactEmail, 'your@mail.address') or diag("contact email incorrect (collections test)"); is($SI->category, "moby") or diag("service category incorrect (collections test)"); From mwilkinson at pub.open-bio.org Thu Jul 28 17:26:59 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 18:13:42 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282126.j6SLQx1O005938@pub.open-bio.org> mwilkinson Thu Jul 28 17:26:59 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv5919/MOBY Modified Files: Central.pm Log Message: query for collections was wrong moby-live/Perl/MOBY Central.pm,1.190,1.191 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.190 retrieving revision 1.191 diff -u -r1.190 -r1.191 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:13:16 1.190 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:26:59 1.191 @@ -3332,7 +3332,7 @@ $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_input_id => $collid); + my $result2 = $adaptor->query_simple_input(service_instance_lsid => undef, collection_input_id => $collid); foreach my $row2 (@$result2) { my $objURI = $row2->{object_type_uri}; From mwilkinson at pub.open-bio.org Thu Jul 28 17:26:59 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 18:13:52 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282126.j6SLQx0l005958@pub.open-bio.org> mwilkinson Thu Jul 28 17:26:59 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5919/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query for collections was wrong moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.62,1.63 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:13:16 1.62 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:26:59 1.63 @@ -269,6 +269,8 @@ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $collid = $args{collection_input_id}; + my $id_to_use = $siid?$siid:$collid; + my $dbh = $self->dbh; my $statement = "select @@ -282,10 +284,10 @@ my $condition; $siid && ($condition = " service_instance_id = ? and collection_input_id IS NULL"); - $collid && ($condition = " service_instance_id IS NULL and collection_input_id = ?"); + $collid && ($condition = " collection_input_id = ?"); $statement .= $condition; - my $result = do_query($dbh, $statement, ($siid || $collid)); + my $result = do_query($dbh, $statement, ($id_to_use)); return $result; } @@ -362,6 +364,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $collid = $args{collection_output_id}; my $dbh = $self->dbh; + my $id_to_use = $siid?$siid:$collid; my $statement = "select simple_output_id, @@ -373,11 +376,11 @@ from simple_output where "; my $condition; $siid && ($condition = " service_instance_id = ? and collection_output_id IS NULL"); - $collid && ($condition = " service_instance_id IS NULL and collection_output_id = ?"); + $collid && ($condition = " collection_output_id = ?"); $statement .= $condition; - my $result = do_query($dbh, $statement, ($siid || $collid)); + my $result = do_query($dbh, $statement, ($id_to_use)); return $result; } From mwilkinson at pub.open-bio.org Thu Jul 28 17:28:39 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 18:15:22 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282128.j6SLSdeB006026@pub.open-bio.org> mwilkinson Thu Jul 28 17:28:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv6007/MOBY Modified Files: Central.pm Log Message: missing quotes around XML attribute moby-live/Perl/MOBY Central.pm,1.191,1.192 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.191 retrieving revision 1.192 diff -u -r1.191 -r1.192 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:26:59 1.191 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:28:39 1.192 @@ -3344,7 +3344,7 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); $output .= "\t\t\t\t$NSname\n" From mwilkinson at pub.open-bio.org Thu Jul 28 17:32:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 18:20:01 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282132.j6SLWviB006097@pub.open-bio.org> mwilkinson Thu Jul 28 17:32:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv6078/t Modified Files: Client-Central.t Log Message: tests were wrong moby-live/Perl/t Client-Central.t,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:13:16 1.12 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:32:57 1.13 @@ -306,6 +306,8 @@ isa_ok($in, 'MOBY::Client::CollectionArticle') or diag("->inputs did not return a MOBY::collection_input object or client parser failed for MOBY::Client::CollectionArticle"); isa_ok($out, 'MOBY::Client::CollectionArticle') or diag("->outputs did not return a MOBY::collection_output object or client parser failed for MOBY::Client::CollectionArticle"); isa_ok($sec, 'MOBY::Client::SecondaryArticle') or diag("->secondarues did not return a MOBY::secondary_input object"); +is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly (collections test)"); +is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly (collections test)"); isa_ok($in->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); isa_ok($out->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); @@ -319,7 +321,6 @@ $out = shift(@$simplesout); is($in->objectType, "Object") or diag("simple input type reported incorrectly (collections test)"); -is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly (collections test)"); isa_ok($in->namespaces, 'ARRAY') or diag("simple input namespaces not returned as an arrayref (collections test)"); @ns = @{$in->namespaces}; is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces (collections test)"); From mwilkinson at pub.open-bio.org Thu Jul 28 17:36:07 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 18:23:00 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282136.j6SLa74C006165@pub.open-bio.org> mwilkinson Thu Jul 28 17:36:07 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv6146/MOBY Modified Files: Central.pm Log Message: looking for namespace_type_uri instead of ..._uris moby-live/Perl/MOBY Central.pm,1.192,1.193 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.192 retrieving revision 1.193 diff -u -r1.192 -r1.193 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:28:39 1.192 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:36:07 1.193 @@ -3336,7 +3336,7 @@ foreach my $row2 (@$result2) { my $objURI = $row2->{object_type_uri}; - my $nsURI = $row2->{namespace_type_uri}; + my $nsURI = $row2->{namespace_type_uris}; my $article = $row2->{article_name}; my $objName = $OSobj->getObjectCommonName($objURI); From mwilkinson at pub.open-bio.org Thu Jul 28 17:40:31 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 18:26:56 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282140.j6SLeVE3006292@pub.open-bio.org> mwilkinson Thu Jul 28 17:40:31 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv6273/t Modified Files: Client-Central.t Log Message: test was wrong moby-live/Perl/t Client-Central.t,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:32:57 1.13 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:40:31 1.14 @@ -328,7 +328,6 @@ is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace (collections test)"); is($out->objectType, "String") or diag("simple output type reported incorrectly (collections test)"); -is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly (collections test)"); isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref (collections test)"); @ns = @{$out->namespaces}; is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces (collections test)"); From mwilkinson at pub.open-bio.org Thu Jul 28 18:10:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 18:56:37 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282210.j6SMABVG006403@pub.open-bio.org> mwilkinson Thu Jul 28 18:10:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv6384/MOBY/Client Modified Files: Central.pm Log Message: starting to update Cient libraries to make LSID avialble moby-live/Perl/MOBY/Client Central.pm,1.101,1.102 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.101 retrieving revision 1.102 diff -u -r1.101 -r1.102 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 23:05:04 1.101 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:10:11 1.102 @@ -497,9 +497,10 @@ my ($return) = $self->_call( 'default', 'retrieveObjectDefinition', $message ); return \%def unless $return; - my ( $term, $desc, $relationships, $email, $authURI ) = + my ( $term, $lsid, $desc, $relationships, $email, $authURI ) = &_ObjectDefinitionPayload($return); $def{objectType} = $term; + $def{objectLSID} = $lsid; $def{description} = $desc; $def{contactEmail} = $email; $def{authURI} = $authURI; @@ -516,6 +517,7 @@ my $obj = $Object->nodeName; return undef unless ( $obj eq 'retrieveObjectDefinition' ); my $term = &_nodeTextContent( $Object, "objectType" ); + my $lsid = &_nodeAttributeValue( $Object, "objectType", "lsid"); my $desc = &_nodeCDATAContent( $Object, "Description" ); if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; @@ -1970,6 +1972,32 @@ return $content; } +sub _nodeAttributeContent { + + # will get text of **all** child $node from the given $DOM + # regardless of their depth!! + my ( $DOM, $node, $attr ) = @_; + my $x = $DOM->getElementsByTagName($node); + unless ( $x->get_node(1) ) { return } + my $n = $x->get_node(1); + my @att = $n->attributes($attr); + my $atval; + if (scalar(@att)){ + $atval = $attr->getValue; + } + my @child = $x->get_node(1)->childNodes; + my $content; + foreach (@child) { + + #print getNodeTypeName($_), "\t", $_->toString,"\n"; + next + unless ( ( $_->nodeType == TEXT_NODE ) + || ( $_->nodeType == CDATA_SECTION_NODE ) ); + $content = $_->textContent; + } + return $content; +} + sub _nodeRawContent { # will get XML of **all** child $node from the given $DOM From mwilkinson at pub.open-bio.org Thu Jul 28 18:18:05 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu Jul 28 19:04:47 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282218.j6SMI5bT006471@pub.open-bio.org> mwilkinson Thu Jul 28 18:18:05 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv6452/MOBY/Client Modified Files: Central.pm Log Message: starting to update Cient libraries to make LSID avialble moby-live/Perl/MOBY/Client Central.pm,1.102,1.103 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.102 retrieving revision 1.103 diff -u -r1.102 -r1.103 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:10:11 1.102 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:18:05 1.103 @@ -484,7 +484,8 @@ =cut sub retrieveObjectDefinition { - my ( $self, $id, $reg ) = @_; + my ( $self, %a ) = @_; + my $id = $a{objectType}; return $self->errorRegXML( "Function not allowed when querying multiple registries") if $self->multiple_registries; From dwang at pub.open-bio.org Fri Jul 29 03:50:04 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Fri Jul 29 04:36:43 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507290750.j6T7o4db007547@pub.open-bio.org> dwang Fri Jul 29 03:50:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv7522/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: almost there moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 19:45:26 1.24 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/29 07:50:04 1.25 @@ -295,15 +295,36 @@ Notes : the fact that it returns a collection_input_id is bad since this is only useful to an SQL-based API... =cut - sub query_collection_input{ die "query_collection_input not implemented in adaptor\n"; } +=head2 insert_collection_input + + Title : insert_collection_input + Usage : my $un = $API->insert_collection_input(%args) + Function : Inserts a Collection input into the database + Args : article_name => String, + service_instance_lsid => String, + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_collection_input { die "insert_collection_input not implemented in adaptor\n"; } +=head2 delete_collection_input + + Title : delete_collection_input + Usage : my $un = $API->delete_collection_input(%args) + Function : Deletes Collection inputs according to the service instance + Args : service_instance_lsid => String, + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_collection_input{ die "delete_collection_input not implemented in adaptor\n"; } @@ -311,10 +332,34 @@ # # collection_output table fuctions # +=head2 query_collection_output + + Title : query_collection_output + Usage : my $un = $API->query_collection_output(%args) + Function : Executes a query for Collection outputs according to the service instance + Args : service_instance_lsid => String, + Returns : listref of hashrefs: + [{collection_output_id => Integer, + article_name => String, + service_instance_id => Integer, + }] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_collection_output{ die "query_collection_output not implemented in adaptor\n"; } +=head2 insert_collection_output + + Title : insert_collection_output + Usage : my $un = $API->insert_collection_output(%args) + Function : Inserts a Collection output into the database + Args : article_name => String, + service_instance_lsid => String, + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_collection_output { die "insert_collection_output not implemented in adaptor\n"; #my ($self, %args) = @_; @@ -327,6 +372,17 @@ #} } +=head2 delete_collection_output + + Title : delete_collection_output + Usage : my $un = $API->delete_collection_output(%args) + Function : Deletes Collection outputs according to the service instance + Args : service_instance_lsid => String, + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_collection_output{ die "delete_collection_output not implemented in adaptor\n"; } @@ -334,32 +390,56 @@ # # simple_output table functions # +=head2 query_simple_input + + Title : query_simple_input + Usage : my $un = $API->query_simple_input(%args) + Function : Executes a query for Simple inputs according to the service instance or collection output + Args : service_instance_lsid => String, + collection_input_id => Integer + Returns : listref of hashrefs: + [{simple_input_id => Integer, + object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_id => Integer, + collection_input_id => Integer}] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_simple_input{ die "query_simple_input not implemented in adaptor\n"; } +=head2 insert_simple_input + + Title : insert_simple_input + Usage : my $un = $API->insert_simple_input(%args) + Function : Inserts a Simple input into the database + Args : object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_lsid => String, + collection_input_id => Integer + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_simple_input { die "insert_simple_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - # - #$dbh->do("insert into simple_input - # (object_type_uri, - # namespace_type_uris, - # article_name, - # service_instance_id, - # collection_input_id) - # values (?,?,?,?,?)", - # undef, - # ($args{object_type_uri}, - # $args{namespace_type_uris}, - # $args{article_name}, - # $args{service_instance_id}, - # $args{collection_input_id})); - #my $id=$dbh->{mysql_insertid}; - #return $id; } +=head2 delete_simple_input + + Title : delete_simple_input + Usage : my $un = $API->delete_simple_input(%args) + Function : Deletes Simple inputs according to the service instance, or collection input + Args : service_instance_lsid => String, + collection_input_id => Integer + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_simple_input{ die "delete_simple_input not implemented in adaptor\n"; } @@ -371,7 +451,7 @@ Title : query_simple_output Usage : my $un = $API->query_simple_output(%args) - Function : Executes a query for Simput outputs according to the service instance or collection output + Function : Executes a query for Simple outputs according to the service instance or collection output Args : service_instance_lsid => String, collection_output_id => Integer Returns : listref of hashrefs: From mwilkinson at pub.open-bio.org Fri Jul 29 10:17:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 11:04:36 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291417.j6TEHoZ3008780@pub.open-bio.org> mwilkinson Fri Jul 29 10:17:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv8757/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: OntologyServer passing wrong arguments when registering new relationships. Now passes LSIDs instead of database IDs moby-live/Perl/MOBY Central.pm,1.193,1.194 OntologyServer.pm,1.68,1.69 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.193 retrieving revision 1.194 diff -u -r1.193 -r1.194 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:36:07 1.193 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 14:17:49 1.194 @@ -486,7 +486,6 @@ $OntologyServer->objectExists( term => $class ); return &_error( "Object class $class does not exist", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new()->dbh; my $errormsg = $adaptor->check_object_usage(type => $existingURI); return &_error( =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 18:33:10 1.68 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 14:17:49 1.69 @@ -485,8 +485,8 @@ qq{Relationship $args{relationship} does not exist in the ontology}, '' ); my $insertid = $adaptor->insert_object_term2term(relationship_type => $rel_lsid, - object1_id => $subj_lsid, - object2_id => $obj_lsid, + object1_type => $subj_lsid, + object2_type => $obj_lsid, object2_articlename => $args{articleName}); if ($insertid ) { return ( 1, "Object relationsihp created successfully", '' ); From mwilkinson at pub.open-bio.org Fri Jul 29 10:27:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 11:14:09 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291427.j6TERjFd008863@pub.open-bio.org> mwilkinson Fri Jul 29 10:27:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv8844/MOBY Modified Files: service_instance.pm Log Message: deregistration of services was not cleaning up the inputs and outputs from the database because the service was deleted prior to the parameters, leaving them unable to look up the database id of their parent service LSID moby-live/Perl/MOBY service_instance.pm,1.32,1.33 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 15:29:38 1.32 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/29 14:27:45 1.33 @@ -268,7 +268,6 @@ # the routines below know too much about the database (e.g. that # the delete_simple_input routines are broken into two parts - by LSID and # by collecion ID... BAD BAD BAD - $adaptor->delete_service_instance(service_instance_lsid => $self->lsid); $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); @@ -288,6 +287,7 @@ $adaptor->delete_collection_input(service_instance_lsid => $self->lsid); $adaptor->delete_collection_output(service_instance_lsid => $self->lsid); $adaptor->delete_secondary_input(service_instance_lsid => $self->lsid); + $adaptor->delete_service_instance(service_instance_lsid => $self->lsid); return 1; } From mwilkinson at pub.open-bio.org Fri Jul 29 10:38:15 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 11:27:18 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291438.j6TEcFA7008957@pub.open-bio.org> mwilkinson Fri Jul 29 10:38:15 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv8938/t Modified Files: Client-Central.t Log Message: adding new tests for the less used mobycentral functions moby-live/Perl/t Client-Central.t,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:40:31 1.14 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 14:38:15 1.15 @@ -30,7 +30,7 @@ ################## MOBY Registration Tests ################# # Test 3 -$r = $C->registerObjectClass(objectType => "TotalCrap", +$r = $C->registerObjectClass(objectType => "Rubbish", description => "a human-readable description of the object", contactEmail => 'your@email.address', authURI => "test.suite.com", @@ -48,7 +48,7 @@ # Test 4 -$r = $C->registerObjectClass(objectType => "TotalCrap", +$r = $C->registerObjectClass(objectType => "Rubbish", description => "a human-readable description of the object", contactEmail => 'your@email.address', authURI => "test.suite.com", @@ -66,7 +66,7 @@ # Test 5 -$r = $C->deregisterObjectClass(objectType => "TotalCrap"); +$r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful")) or diag("Object deregistration failure: ".$r->message) ; @@ -74,7 +74,7 @@ # Test 6 (identical to #4 -$r = $C->registerObjectClass(objectType => "TotalCrap", +$r = $C->registerObjectClass(objectType => "Rubbish", description => "a human-readable description of the object", contactEmail => 'your@email.address', authURI => "test.suite.com", @@ -93,7 +93,7 @@ # Test 7 $r = $C->registerNamespace( - namespaceType =>'UglyNamespace', + namespaceType =>'RubbishNamespace', authURI => 'your.authority.URI', description => "human readable description of namespace", contactEmail => 'your@address.here'); @@ -104,7 +104,7 @@ # Test 8 -$r = $C->registerServiceType(serviceType => "CrappyService", +$r = $C->registerServiceType(serviceType => "RubbishyService", description => "a human-readable description of the service", contactEmail => 'your@email.address', authURI => "test.suite.com", @@ -127,10 +127,10 @@ category => "moby", URL => "http://illuminae/cgi-bin/service.pl", input =>[ - ['articleName1', [Object => ['UglyNamespace']]], # Simple + ['articleName1', [Object => ['RubbishNamespace']]], # Simple ], output =>[ - ['articleName2', [String => ['UglyNamespace']]], # Simple + ['articleName2', [String => ['RubbishNamespace']]], # Simple ], secondary => { parametername1 => { @@ -155,10 +155,10 @@ category => "moby", URL => "http://illuminae/cgi-bin/service.pl", input =>[ - ['articleName1', [Object => ['UglyNamespace']]], # Simple + ['articleName1', [Object => ['RubbishNamespace']]], # Simple ], output =>[ - ['articleName2', [String => ['UglyNamespace']]], # Simple + ['articleName2', [String => ['RubbishNamespace']]], # Simple ], secondary => { parametername1 => { @@ -214,7 +214,7 @@ @ns = @{$in->namespaces}; is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace"); +is($ns, 'RubbishNamespace') or diag("simple input reporting wrong namespace"); is($out->objectType, "String") or diag("simple output type reported incorrectly"); is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly"); @@ -222,7 +222,7 @@ @ns = @{$out->namespaces}; is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace"); +is($ns, 'RubbishNamespace') or diag("simple output reporting wrong namespace"); is($sec->articleName, 'parametername1') or diag("secondary article reporting wrong article name"); is($sec->datatype, 'Integer') or diag("secondary article reporting wrong datatype"); @@ -248,10 +248,10 @@ category => "moby", URL => "http://illuminae/cgi-bin/service.pl", input =>[ - ['articleName1', [[Object => ['UglyNamespace']]]], # Simple + ['articleName1', [[Object => ['RubbishNamespace']]]], # Simple ], output =>[ - ['articleName2', [[String => ['UglyNamespace']]]], # Simple + ['articleName2', [[String => ['RubbishNamespace']]]], # Simple ], secondary => { parametername1 => { @@ -325,14 +325,14 @@ @ns = @{$in->namespaces}; is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces (collections test)"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace (collections test)"); +is($ns, 'RubbishNamespace') or diag("simple input reporting wrong namespace (collections test)"); is($out->objectType, "String") or diag("simple output type reported incorrectly (collections test)"); isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref (collections test)"); @ns = @{$out->namespaces}; is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces (collections test)"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace (collections test)"); +is($ns, 'RubbishNamespace') or diag("simple output reporting wrong namespace (collections test)"); $r = $C->deregisterService( @@ -359,15 +359,22 @@ -# Test 12 -$r = $C->deregisterObjectClass(objectType => "TotalCrap"); +# TESTS FOR ONTOLOGY TRAVERSAL AND SO ON + +$r = $C->retrieveObjectDefinition(objectType => "Rubbish"); +isa_ok($r , "HASH", "Object definition returns hashref") or diag("Object definition did not return as a hashref") ; + + + + +$r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; # Test 13 -$r = $C->deregisterServiceType(serviceType => "CrappyService"); +$r = $C->deregisterServiceType(serviceType => "RubbishyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; @@ -375,7 +382,7 @@ # Test 44 -$r = $C->deregisterNamespace(namespaceType =>'UglyNamespace'); +$r = $C->deregisterNamespace(namespaceType =>'RubbishNamespace'); ( ok($r->success,"namespace deregistration successful") ) or diag("namespace deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 11:07:40 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 11:54:01 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291507.j6TF7eqY009070@pub.open-bio.org> mwilkinson Fri Jul 29 11:07:40 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv9047/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: subroutine misnamed moby-live/Perl/MOBY Central.pm,1.194,1.195 OntologyServer.pm,1.69,1.70 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.194 retrieving revision 1.195 diff -u -r1.194 -r1.195 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 14:17:49 1.194 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 15:07:40 1.195 @@ -2678,7 +2678,7 @@ $OS->retrieveObject( node => $term ) ; # will return undef if this term does not exist, and does not look like an LSID return "" unless $def; - my %def = %{ $OS->retrieveObject( node => $term ) }; + my %def = %{ $OS->retrieveObject( type => $term ) }; if ( $def{description} =~ /[^\]]+))\]\]>/ ) { $def{description} = $1; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 14:17:49 1.69 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 15:07:40 1.70 @@ -292,13 +292,15 @@ my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); - my $term = $args{'node'}; + my $term = $args{'type'}; + $term ||=$args{'node'}; + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node as an argument", '' ) - unless ( $args{'node'} ); + unless ( $term ); my $LSID = - ( $args{'node'} =~ /urn\:lsid/ ) - ? $args{'node'} + ( $term =~ /urn\:lsid/ ) + ? $term : $self->getObjectURI($term); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } my $result = $adaptor->query_object(type => $LSID); From mwilkinson at pub.open-bio.org Fri Jul 29 11:07:40 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 11:54:04 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291507.j6TF7eM6009090@pub.open-bio.org> mwilkinson Fri Jul 29 11:07:40 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv9047/MOBY/Client Modified Files: Central.pm Log Message: subroutine misnamed moby-live/Perl/MOBY/Client Central.pm,1.103,1.104 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:18:05 1.103 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:07:40 1.104 @@ -141,11 +141,11 @@ Connections => [ undef, 'read/write' ], default_MOBY_servername => [ 'mobycentral', 'read/write' ], default_MOBY_server => [ - 'http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY05/mobycentral.pl', + 'http://mobycentral.icpture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', 'read/write' ], default_MOBY_uri => - [ 'http://mobycentral.cbr.nrc.ca/MOBY/Central', 'read/write' ], + [ 'http://mobycentral.icapture.ubc.ca/MOBY/Central', 'read/write' ], default_MOBY_proxy => [ undef, 'read/write' ], default_MOBY_type => [ 'soap', 'read/write' ], Registries => [ undef, 'read/write' ], @@ -1973,7 +1973,7 @@ return $content; } -sub _nodeAttributeContent { +sub _nodeAttributeValue { # will get text of **all** child $node from the given $DOM # regardless of their depth!! From mwilkinson at pub.open-bio.org Fri Jul 29 11:41:01 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 12:28:37 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291541.j6TFf1a8009260@pub.open-bio.org> mwilkinson Fri Jul 29 11:41:01 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv9241/MOBY/Client Modified Files: Central.pm Log Message: XML::LibXML documentation is crappy. Had to read the source to figure out the NamedNodeMap interface. Can now retrieve the value of the LSID attribute moby-live/Perl/MOBY/Client Central.pm,1.104,1.105 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.104 retrieving revision 1.105 diff -u -r1.104 -r1.105 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:07:40 1.104 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:41:01 1.105 @@ -1975,28 +1975,15 @@ sub _nodeAttributeValue { - # will get text of **all** child $node from the given $DOM - # regardless of their depth!! my ( $DOM, $node, $attr ) = @_; + return "" unless $attr; my $x = $DOM->getElementsByTagName($node); - unless ( $x->get_node(1) ) { return } + unless ( $x->get_node(1) ) { return "" } my $n = $x->get_node(1); - my @att = $n->attributes($attr); - my $atval; - if (scalar(@att)){ - $atval = $attr->getValue; - } - my @child = $x->get_node(1)->childNodes; - my $content; - foreach (@child) { - - #print getNodeTypeName($_), "\t", $_->toString,"\n"; - next - unless ( ( $_->nodeType == TEXT_NODE ) - || ( $_->nodeType == CDATA_SECTION_NODE ) ); - $content = $_->textContent; - } - return $content; + my $nodemap = $n->attributes($attr); # XML::LibXML::NamedNodeMap - the worst documented (i.e. undocumented) piece of code ever written! You have to read the source to figure out the interface... + my $attrnode = $nodemap->getNamedItem($attr); + my $attrval = $attrnode?($attrnode->value):""; + return $attrval; } sub _nodeRawContent { From mwilkinson at pub.open-bio.org Fri Jul 29 11:43:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 12:29:50 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291543.j6TFhQ8a009326@pub.open-bio.org> mwilkinson Fri Jul 29 11:43:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv9307/MOBY/Client Modified Files: Central.pm Log Message: adding LSID to return values moby-live/Perl/MOBY/Client Central.pm,1.105,1.106 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.105 retrieving revision 1.106 diff -u -r1.105 -r1.106 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:41:01 1.105 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:43:26 1.106 @@ -556,7 +556,7 @@ } } } - return ( $term, $desc, \%relationships, $email, $authURI ); + return ( $term, $lsid, $desc, \%relationships, $email, $authURI ); } =head2 registerServiceType From mwilkinson at pub.open-bio.org Fri Jul 29 11:54:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 12:40:34 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291554.j6TFsDT0009399@pub.open-bio.org> mwilkinson Fri Jul 29 11:54:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9380/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 14:38:15 1.15 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:54:13 1.16 @@ -363,9 +363,33 @@ $r = $C->retrieveObjectDefinition(objectType => "Rubbish"); isa_ok($r , "HASH", "Object definition returns hashref") or diag("Object definition did not return as a hashref") ; - - - +is($r->objectType, "Rubbish", "Object reporting correct name") or diag("Object definition did not report correct name"); +is($r->description, "a human-readable description of the object", "Object reporting correct desc") or diag("Object definition did not report correct desc"); +is($r->contactEmail, 'your@email.address', "Object reporting correct email") or diag("Object definition did not report correct email"); +is($r->authURI, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); +isa_ok($r->Relationships, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); +%rel = %{$r->Relationships}; +isa_ok($rel{ISA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); +isa_ok($rel{HASA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); +$isa = shift@{$rel{ISA}}; +$hasa = shift@{$rel{HASA}}; +isa_ok($isa, "ARRAY","") or diag("Object didn't return an array of arrays for its ISA relationships"); +isa_ok($hasa, "ARRAY","") or diag("Object didn't return an array of arrays for its HASA relationships"); +is(${$isa}[0], 'Object') or diag("ISA reporting wrong object type"); +is(${$isa}[1], 'article1') or diag("ISA reporting wrong object type"); +is(${$hasa}[0], 'Object') or diag("ISA reporting wrong object type"); +is(${$hasa}[1], 'articleName3') or diag("ISA reporting wrong object type"); + +#objectType => "Rubbish", +# description => "a human-readable description of the object", +# contactEmail => 'your@email.address', +# authURI => "test.suite.com", +# Relationships => { +# ISA => [ +# ['Object', 'article1']], +# HASA => [ +# ['Object', 'articleName3']]} +# ); $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") From mwilkinson at pub.open-bio.org Fri Jul 29 11:55:17 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 12:41:38 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291555.j6TFtHaf009477@pub.open-bio.org> mwilkinson Fri Jul 29 11:55:17 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9458/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:54:13 1.16 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:55:17 1.17 @@ -363,12 +363,12 @@ $r = $C->retrieveObjectDefinition(objectType => "Rubbish"); isa_ok($r , "HASH", "Object definition returns hashref") or diag("Object definition did not return as a hashref") ; -is($r->objectType, "Rubbish", "Object reporting correct name") or diag("Object definition did not report correct name"); -is($r->description, "a human-readable description of the object", "Object reporting correct desc") or diag("Object definition did not report correct desc"); -is($r->contactEmail, 'your@email.address', "Object reporting correct email") or diag("Object definition did not report correct email"); -is($r->authURI, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); -isa_ok($r->Relationships, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); -%rel = %{$r->Relationships}; +is($r->{objectType}, "Rubbish", "Object reporting correct name") or diag("Object definition did not report correct name"); +is($r->{description}, "a human-readable description of the object", "Object reporting correct desc") or diag("Object definition did not report correct desc"); +is($r->{contactEmail}, 'your@email.address', "Object reporting correct email") or diag("Object definition did not report correct email"); +is($r->{authURI}, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); +isa_ok($r->{Relationships}, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); +%rel = %{$r->{Relationships}}; isa_ok($rel{ISA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); isa_ok($rel{HASA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); $isa = shift@{$rel{ISA}}; From mwilkinson at pub.open-bio.org Fri Jul 29 12:00:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 12:46:38 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291600.j6TG0I7O009571@pub.open-bio.org> mwilkinson Fri Jul 29 12:00:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9552/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:55:17 1.17 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:00:18 1.18 @@ -369,10 +369,10 @@ is($r->{authURI}, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); isa_ok($r->{Relationships}, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); %rel = %{$r->{Relationships}}; -isa_ok($rel{ISA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); -isa_ok($rel{HASA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); -$isa = shift@{$rel{ISA}}; -$hasa = shift@{$rel{HASA}}; +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:hasa'}, "ARRAY", "Object reporting correct HASA as arrayref") or diag("Object definition did not report HASA arrayref"); +$isa = shift@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}; +$hasa = shift@{$rel{'urn:lsid:biomoby.org:objectrelation:hasa'}}; isa_ok($isa, "ARRAY","") or diag("Object didn't return an array of arrays for its ISA relationships"); isa_ok($hasa, "ARRAY","") or diag("Object didn't return an array of arrays for its HASA relationships"); is(${$isa}[0], 'Object') or diag("ISA reporting wrong object type"); From mwilkinson at pub.open-bio.org Fri Jul 29 12:01:34 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 12:47:54 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291601.j6TG1YSb009616@pub.open-bio.org> mwilkinson Fri Jul 29 12:01:34 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9597/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:00:18 1.18 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:01:34 1.19 @@ -379,17 +379,8 @@ is(${$isa}[1], 'article1') or diag("ISA reporting wrong object type"); is(${$hasa}[0], 'Object') or diag("ISA reporting wrong object type"); is(${$hasa}[1], 'articleName3') or diag("ISA reporting wrong object type"); +is($r->{objectLSID}, "urn:lsid:biomoby.org:objectclass:Rubbish") or diag("Object class LSID reported incorrectly"); -#objectType => "Rubbish", -# description => "a human-readable description of the object", -# contactEmail => 'your@email.address', -# authURI => "test.suite.com", -# Relationships => { -# ISA => [ -# ['Object', 'article1']], -# HASA => [ -# ['Object', 'articleName3']]} -# ); $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") From mwilkinson at pub.open-bio.org Fri Jul 29 12:12:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 12:58:23 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291612.j6TGC2wZ009701@pub.open-bio.org> mwilkinson Fri Jul 29 12:12:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9682/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:01:34 1.19 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:12:02 1.20 @@ -335,6 +335,18 @@ is($ns, 'RubbishNamespace') or diag("simple output reporting wrong namespace (collections test)"); + +#$names{$AuthURI} = [serviceName_1, serviceName_2, serviceName3...] +$r = $C->retrieveServiceNames(); +isa_ok($r, "HASH", "Service Names Hash") or diag("retrieveServiceNames didn't return a hashref") ; +%sn = %{$r}; +isa_ok($sn{'test.suite.com'}, "ARRAY") or diag("retrieveServiceNames didn't return a hasref of arrayrefs"); +$s1 = shift@{$sn{'test.suite.com'}}; +$s2 = shift@{$sn{'test.suite.com'}}; +ok((($s1 =~ /myfirstservice/) || ($s1 =~ /mysecondservice/))) or diag("retrieveServiceNames didn't return myfirstservice"); +ok((($s2 =~ /myfirstservice/) || ($s2 =~ /mysecondservice/))) or diag("retrieveServiceNames didn't return mysecondservice"); + + $r = $C->deregisterService( serviceName => "myfirstservice", authURI => "test.suite.com", @@ -382,6 +394,13 @@ is($r->{objectLSID}, "urn:lsid:biomoby.org:objectclass:Rubbish") or diag("Object class LSID reported incorrectly"); +$r = $C->retrieveNamespaces(); +isa_ok($r, "HASH", "Namespace hash") or diag("retrieveNamespaces didn't return a hashref") ; +%ns = %{$r}; +is($ns{RubbishNamespace}, "human readable description of the namespace") or diag("namespace definition not returned correctly"); + + + $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 12:20:43 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 13:07:12 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291620.j6TGKhC0009774@pub.open-bio.org> mwilkinson Fri Jul 29 12:20:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv9755/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: querynamespace returned nothing if no parameter was passed. It should return everything moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:26:59 1.63 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:20:43 1.64 @@ -966,13 +966,15 @@ sub query_namespace{ my ($self, %args) = @_; my $type = $args{type}; - return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ $condition = " where namespace_lsid = ?"; } elsif ($type) { $condition = " where namespace_type = ?"; + } else { + $condition = ""; } + my $dbh = _getDBHandle("mobynamespace"); my $statement = "select From mwilkinson at pub.open-bio.org Fri Jul 29 12:35:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 13:22:36 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291635.j6TGZM4A010137@pub.open-bio.org> mwilkinson Fri Jul 29 12:35:22 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10118/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:12:02 1.20 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:35:22 1.21 @@ -397,8 +397,33 @@ $r = $C->retrieveNamespaces(); isa_ok($r, "HASH", "Namespace hash") or diag("retrieveNamespaces didn't return a hashref") ; %ns = %{$r}; -is($ns{RubbishNamespace}, "human readable description of the namespace") or diag("namespace definition not returned correctly"); +is($ns{RubbishNamespace}, "human readable description of namespace") or diag("namespace definition not returned correctly"); +$r = $C->retrieveServiceTypes(); +isa_ok($r, "HASH", "Service types hash") or diag("retrieveServiceTypes didn't return a hashref") ; +%st = %{$r}; +is($st{RubbishyService}, "a human-readable description of the service") or diag("service type definition not returned correctly"); + + +$r = $C->retrieveObjectNames(); +isa_ok($r, "HASH", "Object types hash") or diag("retrieveObjectNames didn't return a hashref") ; +%on = %{$r}; +is($on{Rubbish}, "a human-readable description of the object") or diag("object name definition not returned correctly"); + + +$r = $C->Relationships(objectType => "Rubbish"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; +%rel= %{$r}; +print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); +is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "urn:lsid:biomoby.org:objectclass:Object") or diag("Relationships arrayref didn't return the right parentage."); + +$r = $C->Relationships(serviceType => "RubbishyService"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; +%rel= %{$r}; +print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); +is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "urn:lsid:biomoby.org:servicetype:Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); $r = $C->deregisterObjectClass(objectType => "Rubbish"); @@ -407,7 +432,7 @@ -# Test 13 +# Test 13 is a retrieval $r = $C->deregisterServiceType(serviceType => "RubbishyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 12:42:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 13:29:16 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291642.j6TGgnxe010267@pub.open-bio.org> mwilkinson Fri Jul 29 12:42:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv10248/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query service needs to return everything instead of nothng when called with no parameter moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.64,1.65 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:20:43 1.64 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:42:49 1.65 @@ -807,12 +807,13 @@ sub query_service{ my ($self, %args) = @_; my $type = $args{type}; - return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ $condition = "where service_lsid = ?"; } elsif ($type) { $condition = "where service_type = ?"; + } else { + $condition = ""; } my $dbh = _getDBHandle("mobyservice"); From mwilkinson at pub.open-bio.org Fri Jul 29 12:46:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 13:32:42 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291646.j6TGkMiu010335@pub.open-bio.org> mwilkinson Fri Jul 29 12:46:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv10316/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: extra comma in SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.65,1.66 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:42:49 1.65 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:46:21 1.66 @@ -883,7 +883,7 @@ assertion_id, relationship_type, service1_id, - service2_id, + service2_id from service_term2term where service2_id = ?"; my $result2 = do_query($dbh, $statement, ($id)); return $result2; From mwilkinson at pub.open-bio.org Fri Jul 29 13:11:04 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 13:57:25 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291711.j6THB4gn010563@pub.open-bio.org> mwilkinson Fri Jul 29 13:11:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10538/t Modified Files: Client-Central.t Log Message: fixed test moby-live/Perl/t Client-Central.t,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:35:22 1.21 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:11:04 1.22 @@ -414,16 +414,16 @@ $r = $C->Relationships(objectType => "Rubbish"); isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; %rel= %{$r}; -print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); -is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "urn:lsid:biomoby.org:objectclass:Object") or diag("Relationships arrayref didn't return the right parentage."); +is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "Object") or diag("Relationships arrayref didn't return the right parentage."); $r = $C->Relationships(serviceType => "RubbishyService"); isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; %rel= %{$r}; print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); -is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "urn:lsid:biomoby.org:servicetype:Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); +is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); $r = $C->deregisterObjectClass(objectType => "Rubbish"); From mwilkinson at pub.open-bio.org Fri Jul 29 13:12:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 13:59:11 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291712.j6THCoao010629@pub.open-bio.org> mwilkinson Fri Jul 29 13:12:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10610/t Modified Files: Client-Central.t Log Message: fixed test moby-live/Perl/t Client-Central.t,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:11:04 1.22 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:12:49 1.23 @@ -117,6 +117,22 @@ +$r = $C->Relationships(objectType => "Rubbish"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; +%rel= %{$r}; +#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); +is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "Object") or diag("Relationships arrayref didn't return the right parentage."); + +$r = $C->Relationships(serviceType => "RubbishyService"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; +%rel= %{$r}; +print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); +is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); + + + # Test 9 # should fail $r = $C->registerService( serviceName => "myfirstservice", @@ -411,21 +427,6 @@ is($on{Rubbish}, "a human-readable description of the object") or diag("object name definition not returned correctly"); -$r = $C->Relationships(objectType => "Rubbish"); -isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; -%rel= %{$r}; -#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; -isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); -is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "Object") or diag("Relationships arrayref didn't return the right parentage."); - -$r = $C->Relationships(serviceType => "RubbishyService"); -isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; -%rel= %{$r}; -print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; -isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); -is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); - - $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 13:25:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 14:12:34 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291725.j6THPZ6o010727@pub.open-bio.org> mwilkinson Fri Jul 29 13:25:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv10708/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: sql adaptor was only able to create relatinships for object ontology. Now can retrieve relationships for both object and service moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.66,1.67 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:46:21 1.66 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 17:25:35 1.67 @@ -1319,9 +1319,16 @@ my $type = $args{'term'}; return 0 unless $type; - my $result = $self->query_object(type => $type); - my $row = shift @$result; - my $lsid = $row->{object_lsid}; + my $lsid; + if ($ontology eq "service"){ + my $result = $self->query_service(type => $type); + my $row = shift @$result; + $lsid = $row->{service_lsid}; + } else { + my $result = $self->query_object(type => $type); + my $row = shift @$result; + $lsid = $row->{object_lsid}; + } my $defs; if ( $direction eq 'root' ) { From mwilkinson at pub.open-bio.org Fri Jul 29 13:28:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 14:14:50 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291728.j6THSQUS010839@pub.open-bio.org> mwilkinson Fri Jul 29 13:28:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10820/t Modified Files: Client-Central.t Log Message: updating test plan number moby-live/Perl/t Client-Central.t,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:12:49 1.23 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:28:26 1.24 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; #use SOAP::Lite +trace; -use Test::More tests => 91; # perldoc Test::More for details +use Test::More tests => 122; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; From mwilkinson at pub.open-bio.org Fri Jul 29 13:39:32 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 14:27:01 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291739.j6THdWLU010916@pub.open-bio.org> mwilkinson Fri Jul 29 13:39:32 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv10893/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: deleting service type failed due to bad lookup of relationships. Fix reporting of errors from MOBY Central - need to bracket teh (==0) phrase of every test moby-live/Perl/MOBY Central.pm,1.195,1.196 OntologyServer.pm,1.70,1.71 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.195 retrieving revision 1.196 diff -u -r1.195 -r1.196 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 15:07:40 1.195 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 17:39:32 1.196 @@ -313,14 +313,14 @@ term => $reltype, ontology => 'object' ); # success = 1 if it does - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); foreach ( @{$obj} ) { ++$ISAs if ( $URI =~ /isa$/i ); my ( $objectType, $articleName ) = @{$_}; my ( $success, $message, $URI ) = $OntologyServer->objectExists( term => $objectType ) ; # success = 1 if it does - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); } } return &_error( @@ -341,12 +341,12 @@ if ( $clobber == 1 ) { my ( $success, $message ) = $OntologyServer->deprecateObject( term => $term ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); } elsif ( $clobber == 2 ) { my ( $success, $message ) = $OntologyServer->deleteObject( term => $term ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); } } ( $success, $message, $URI ) = $OntologyServer->createObject( @@ -355,7 +355,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); my @failures; if ( keys %{$relationships} ) { while ( my ( $reltype, $obj ) = each %{$relationships} ) { @@ -370,7 +370,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && push @failures, $objectType; + ($success == 0) && push @failures, $objectType; } } } @@ -378,7 +378,7 @@ my ( $success, $message, $deleteURI ) = $OntologyServer->deleteObject( term => $term ) ; # hopefully this situation will never happen! - $success == 0 && return &_error( + ($success == 0) && return &_error( "object failed ISA and/or HASA connections, and subsequently failed deletion. This is a critical error, and may indicate corruption of the MOBY Central registry.", $deleteURI @@ -635,7 +635,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); my @failures; if ( keys %{$relationships} ) { while ( my ( $reltype, $obj ) = each %{$relationships} ) { @@ -648,7 +648,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && push @failures, $serviceType; + ($success == 0) && push @failures, $serviceType; } } } @@ -656,7 +656,7 @@ my ( $success, $message, $deleteURI ) = $OntologyServer->deleteServiceType( term => $term ) ; # hopefully this situation will never happen! - $success == 0 && return &_error( + ($success == 0) && return &_error( "Service registration failed ISA connections, and subsequently failed deletion. This is a critical error, and may indicate corruption of the MOBY Central registry", $deleteURI @@ -767,7 +767,7 @@ my ( $success2, $message2, $deleteURI ) = $OntologyServer->deleteServiceType( term => $term ) ; # hopefully this situation will never happen! - $success == 0 && return &_error( $message2, $deleteURI ); + (($success == 0)) && return &_error( $message2, $deleteURI ); return &_success( "Service type $term deleted.", $deleteURI ); } @@ -855,7 +855,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); return &_success( "Namespace type $term registered successfully.", $URI ); } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 15:07:40 1.70 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 17:39:32 1.71 @@ -682,7 +682,7 @@ } # service1_id ISA service2_id? - my $isa = $adaptor->query_service_term2term(service2_id => $lsid); + my $isa = $adaptor->query_service_term2term(type => $lsid); my $isas = shift(@$isa); if ( $isas->{service1_id} ) { From mwilkinson at pub.open-bio.org Fri Jul 29 13:40:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 14:27:20 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291740.j6THewi4010997@pub.open-bio.org> mwilkinson Fri Jul 29 13:40:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10978/t Modified Files: Client-Central.t Log Message: cleaning comments out of the test suite. Now have 122 tests and all pass on the new codebase moby-live/Perl/t Client-Central.t,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:28:26 1.24 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:40:58 1.25 @@ -127,7 +127,7 @@ $r = $C->Relationships(serviceType => "RubbishyService"); isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; %rel= %{$r}; -print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); From mwilkinson at pub.open-bio.org Fri Jul 29 14:58:44 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 15:45:23 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291858.j6TIwiWm011359@pub.open-bio.org> mwilkinson Fri Jul 29 14:58:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv11340/MOBY Modified Files: Central.pm Log Message: updated pod documentation for MOBY Central and MOBY Client Central. MOBY Client Central now has ways of getting to the LSID for various things in the MOBY Central messages. See pod for details. moby-live/Perl/MOBY Central.pm,1.196,1.197 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.196 retrieving revision 1.197 diff -u -r1.196 -r1.197 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 17:39:32 1.196 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 18:58:44 1.197 @@ -2383,16 +2383,13 @@ outputXML (by category): - moby: + moby: =cut sub retrieveService { my ( $pkg, $payload ) = @_; - - # the payload here is actually the full XML from the findService call above... - #return "NOT YET IMPLEMENTED"; my ( $AuthURI, $serviceName, $InputXML, $OutputXML, $SecondaryXML ) = &_retrieveServicePayload($payload); unless ( $AuthURI && $serviceName ) { return "" } @@ -2532,7 +2529,7 @@ Args : none XML : - + ... @@ -2610,7 +2607,7 @@ Args : none XML : - + ... @@ -2649,7 +2646,7 @@ Ouptut XML : - NewObjectType + NewObjectType @@ -2714,7 +2711,7 @@ Args : none XML : - + ... From mwilkinson at pub.open-bio.org Fri Jul 29 14:58:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 15:45:32 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291858.j6TIwjow011383@pub.open-bio.org> mwilkinson Fri Jul 29 14:58:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv11340/MOBY/Client Modified Files: Central.pm SimpleArticle.pm Log Message: updated pod documentation for MOBY Central and MOBY Client Central. MOBY Client Central now has ways of getting to the LSID for various things in the MOBY Central messages. See pod for details. moby-live/Perl/MOBY/Client Central.pm,1.106,1.107 SimpleArticle.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.106 retrieving revision 1.107 diff -u -r1.106 -r1.107 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:43:26 1.106 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 18:58:44 1.107 @@ -467,16 +467,17 @@ an additional XML hash key that contains the actual XML containing the object definition as sent by MOBY Central (used for a visual overview, rather than parsing all of the hash keys) - objectType => "the name of the Object" + objectType => "the name of the Object" + objectLSID => "urn:lsid:..." description => "a human-readable description of the object" contactEmail => "your@email.address" authURI => "URI of the registrar of this object" Relationships => { relationshipType1 => [ - [Object1, articleName], - [Object2, articleName]], + [Object1, articleName, lsid], + [Object2, articleName, lsid]], relationshipType2 => [ - [Object1, articleName]]} + [Object1, articleName, lsid]]} XML => <....XML of object registration.../> Args : objectType => the name or LSID URI for an object @@ -545,14 +546,18 @@ next unless $_->nodeType == ELEMENT_NODE; my $article = $_->getAttributeNode('articleName'); # may or may not have a name + my $rlsid = + $_->getAttributeNode('lsid'); # may or may not have a name if ($article) { $article = $article->getValue() } + if ($rlsid) { $rlsid = $rlsid->getValue() } + my @child2 = $_->childNodes; foreach (@child2) { #print getNodeTypeName($_), "\t", $_->toString,"\n"; next unless $_->nodeType == TEXT_NODE; push @{ $relationships{$relationshipType} }, - [ $_->toString, $article ]; + [ $_->toString, $article, $rlsid ]; } } } @@ -1295,19 +1300,22 @@ =head2 retrieveServiceNames - Title : retrieveServiceNames + Title : retrieveServiceNames(%args) Usage : $names = $MOBY->retrieveServiceNames([$reg_name]) Function : get a (redundant) list of all registered service names (N.B. NOT service types!) Returns : hashref to the following hash $names{$AuthURI} = [serviceName_1, serviceName_2, serviceName3...] - Args : $reg_name: name of registry you wish to retrieve from (optional) + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: return service names as their corresponding LSID's (default off) =cut sub retrieveServiceNames { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; + my $aslsid = $args{as_lsid}; + $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); @@ -1324,7 +1332,14 @@ $names_list->get_node($x)->getAttributeNode('name')->getValue; my $auth = $names_list->get_node($x)->getAttributeNode('authURI')->getValue; - push @{ $servicenames{$auth} }, $name; + my $lsid = $names_list->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $name; + } + $lsid ||=$name; + push @{ $servicenames{$auth} }, $aslsid?$lsid:$name; } return \%servicenames; } @@ -1362,18 +1377,20 @@ =head2 retrieveServiceTypes - Title : retrieveServiceTypes + Title : retrieveServiceTypes(%args) Usage : $types = $MOBY->retrieveServiceTypes([$reg_name]) Function : get the list of all registered service types Returns : hashref of $types{$type} = $definition - Args : $reg_name: name of registry you wish to retrieve from (optional) - + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: return the $type as its corresponding LSID (defualt off) =cut sub retrieveServiceTypes { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; + my $as_lsid = $args{as_lsid}; + $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); @@ -1387,6 +1404,12 @@ for ( my $x = 1 ; $x <= $types->size() ; $x++ ) { next unless $types->get_node($x)->nodeType == ELEMENT_NODE; my $type = $types->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $types->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $type; + } my $desc; for my $elem ( $types->get_node($x)->getElementsByTagName('Description') ) @@ -1397,29 +1420,29 @@ } } $desc =~ s/[^\]]+))\]\]>/$1/gs; - $servicetypes{$type} = $desc; + $servicetypes{$as_lsid?$lsid:$type} = $desc; } return \%servicetypes; } =head2 retrieveObjectNames - Title : retrieveObjectNames + Title : retrieveObjectNames(%args) Usage : $names = $MOBY->retrieveObjectNames([$reg_name]) Function : get the list of all registered Object types Returns : hashref of hash: $names{$name} = $definition - Args : $reg_name: name of registry you wish to retrieve from (optional) + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: return $name as its correspnding LSID (default off) =cut sub retrieveObjectNames { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; + my $as_lsid = $args{as_lsid}; $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); - -#my $return = $self->SOAP_connection($reg)->call('retrieveObjectNames' => (@_))->paramsall; my ($return) = $self->_call( $reg, 'retrieveObjectNames', "" ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($return); @@ -1429,6 +1452,12 @@ for ( my $x = 1 ; $x <= $obnames->size() ; $x++ ) { next unless $obnames->get_node($x)->nodeType == ELEMENT_NODE; my $name = $obnames->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $obnames->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $name; + } my $desc; for my $elem ( $obnames->get_node($x)->getElementsByTagName('Description') ) @@ -1439,29 +1468,30 @@ } } $desc =~ s/[^\]]+))\]\]>/$1/gs; - $objectnames{$name} = $desc; + $objectnames{$as_lsid?$lsid:$name} = $desc; } return \%objectnames; } =head2 retrieveNamespaces - Title : retrieveNamespaces + Title : retrieveNamespaces(%args) Usage : $ns = $MOBY->retrieveNamespaces([$reg_name]) Function : get the list of all registered Namespace types Returns : hashref of hash: $ns{$namespace} = $definition - Args : $reg_name: name of registry you wish to retrieve from (optional) + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: retrieve $namespace as its corresponding LSID (default off) =cut sub retrieveNamespaces { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); - -# my $return = $self->SOAP_connection($reg)->call('retrieveNamespaces' => (@_))->paramsall; + my $as_lsid = $args{as_lsid}; + my ($return) = $self->_call( $reg, 'retrieveNamespaces', "" ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($return); @@ -1471,6 +1501,12 @@ for ( my $x = 1 ; $x <= $namesp->size() ; $x++ ) { next unless $namesp->get_node($x)->nodeType == ELEMENT_NODE; my $ns = $namesp->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $namesp->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $ns; + } my $desc; for my $elem ( $namesp->get_node($x)->getElementsByTagName('Description') ) @@ -1482,28 +1518,29 @@ } } $desc =~ s/[^\]]+))\]\]>/$1/gs; - $namespaces{$ns} = $desc; + $namespaces{$as_lsid?$lsid:$ns} = $desc; } return \%namespaces; } =head2 retrieveObject - NOT YET IMPLEMENTED Title : retrieveObject - Usage : $objects = $MOBY->retrieveObjectNames($reg, $name | "all") + Usage : $objects = $MOBY->retrieveObjectNames(%args) Function : get the object xsd Returns : hashref of hash: $objects{$name} = $W3C_XML_Schema_string - Args : $reg - name of MOBY Central you want to use (must pass undef otherwise) - $name - object name (from ontology) or "all" to get all objects - + Args : registry => $reg - name of MOBY Central you want to use (must pass undef otherwise) + objectType => $name - object name (from ontology) or undef to get all objects + as_lsid => $boolean - return $name as its corresponding LSID (default off) + =cut sub retrieveObject { - my ($self) = shift; - my ($reg) = shift; - my $type = shift; + my ($self, %args) = shift; + my ($reg) = $args{registry}; + my $type = $args{objectType}; + my $as_lsid = $args{as_lsid}; my $message = " $type @@ -1511,7 +1548,6 @@ $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); -# my $return = $self->SOAP_connection($reg)->call('retrieveObject' => ($message))->paramsall; my ($return) = $self->_call( $reg, 'retrieveObject', $message ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($return); @@ -1521,6 +1557,12 @@ for ( my $x = 1 ; $x <= $objects->size() ; $x++ ) { next unless $objects->get_node($x)->nodeType == ELEMENT_NODE; my $name = $objects->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $objects->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $name; + } my $desc; for my $elem ( $objects->get_node($x)->getElementsByTagName('Schema') ) { @@ -1724,7 +1766,12 @@ my $Service = $Services->get_node($x); my $AuthURI = $Service->getAttributeNode('authURI')->getValue; my $servicename = $Service->getAttributeNode('serviceName')->getValue; - #my $lsid = $Service->getAttributeNode('lsid')->getValue; + my $lsid = $Service->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = ""; + } my $Type = &_nodeTextContent( $Service, 'serviceType' ); my $authoritative = &_nodeTextContent( $Service, 'authoritative' ); my $contactEmail = &_nodeTextContent( $Service, 'contactEmail' ); @@ -1788,7 +1835,7 @@ authority => $AuthURI, authoritative => $authoritative, URL => $URL, - #LSID => $lsid, + LSID => $lsid, contactEmail => $contactEmail, name => $servicename, type => $Type, =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm 2004/12/14 22:31:30 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm 2005/07/29 18:58:44 1.8 @@ -86,6 +86,17 @@ =cut +=head2 objectLSID + + Title : objectLSID + Usage : $type = $SA->objectLSID($type) + Function : get/set LSID + Returns : string + Arguments : (optional) string representing objectLSID to set + +=cut + + =head2 namespaces Title : namespaces @@ -171,6 +182,7 @@ ( articleName => [ undef, 'read/write' ], objectType => [ undef, 'read/write' ], + objectLSID => [ undef, 'read/write' ], namespaces => [ [], 'read/write' ], id => [ undef, 'read/write' ], XML_DOM => [ undef, 'read/write' ], @@ -250,11 +262,15 @@ $self->articleName( "" ); $self->objectType( "" ); my $attr = $dom->getAttributeNode( 'articleName' ); + my $lsid = $dom->getAttributeNode( 'lsid' ); my $articleName = ""; $articleName = $attr->getValue if $attr; + $lsid = $attr->getValue if $lsid; + $self->articleName( $articleName ) if $articleName ; # it may have already been set if this Simple is part of a Collection... + $self->objectLSID( $lsid) if $lsid; # fork here - it may be an instantiated object (coming from a service invocation/response) # or it may be a template object as in the SimpleArticle element of a registration call From mwilkinson at pub.open-bio.org Fri Jul 29 15:28:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 16:15:35 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291928.j6TJSSW6011564@pub.open-bio.org> mwilkinson Fri Jul 29 15:28:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv11545/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query doesn't work on older versions of mySQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.67,1.68 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 17:25:35 1.67 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 19:28:27 1.68 @@ -675,7 +675,7 @@ description, signatureURL, lsid - from service_instance left join authority on authority.authority_id "; + from service_instance, authority where authority.authority_id = service_instance.authority_id "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); From mwilkinson at pub.open-bio.org Fri Jul 29 15:33:42 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 16:21:15 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291933.j6TJXgqt011633@pub.open-bio.org> mwilkinson Fri Jul 29 15:33:41 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv11614/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query doesn't work on older versions of mySQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.68,1.69 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 19:28:27 1.68 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 19:33:41 1.69 @@ -675,9 +675,14 @@ description, signatureURL, lsid - from service_instance, authority where authority.authority_id = service_instance.authority_id "; + from service_instance, authority "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); + if (keys(%args)){ + $statement .= " and authority.authority_id = service_instance.authority_id"; + } else { + $statement .= " where authority.authority_id = service_instance.authority_id"; + } my $final = do_query($dbh, $statement, @bindvalues); return $final; } From mwilkinson at pub.open-bio.org Fri Jul 29 15:37:52 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 16:24:40 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291937.j6TJbqLW011722@pub.open-bio.org> mwilkinson Fri Jul 29 15:37:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv11703/MOBY/Client Modified Files: Central.pm Log Message: redundant pattern substitution moby-live/Perl/MOBY/Client Central.pm,1.107,1.108 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.107 retrieving revision 1.108 diff -u -r1.107 -r1.108 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 18:58:44 1.107 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:37:51 1.108 @@ -1517,7 +1517,7 @@ $desc = $1; } } - $desc =~ s/[^\]]+))\]\]>/$1/gs; +# $desc =~ s/[^\]]+))\]\]>/$1/gs; $namespaces{$as_lsid?$lsid:$ns} = $desc; } return \%namespaces; From mwilkinson at pub.open-bio.org Fri Jul 29 15:39:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri Jul 29 16:26:08 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291939.j6TJdbLb011786@pub.open-bio.org> mwilkinson Fri Jul 29 15:39:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv11767/MOBY/Client Modified Files: Central.pm Log Message: redundant pattern substitution... can't figure out why this throws a warning every time on some systems but not others moby-live/Perl/MOBY/Client Central.pm,1.108,1.109 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.108 retrieving revision 1.109 diff -u -r1.108 -r1.109 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:37:51 1.108 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:39:37 1.109 @@ -1513,6 +1513,7 @@ { $desc = $elem->firstChild; $desc = $desc ? $desc->toString : ""; + $desc ||=""; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } From mng at pub.open-bio.org Fri Jul 29 16:06:37 2005 From: mng at pub.open-bio.org (michael ng) Date: Fri Jul 29 17:00:47 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507292006.j6TK6bXD011951@pub.open-bio.org> mng Fri Jul 29 16:06:37 EDT 2005 Update of /home/repository/moby/moby-live/Accessories In directory pub.open-bio.org:/tmp/cvs-serv11929 Added Files: code-generator0.6.cgi codebook.xml Log Message: new version of code-generator with command line function moby-live/Accessories code-generator0.6.cgi,NONE,1.1 codebook.xml,NONE,1.1 From kawas at pub.open-bio.org Fri Jul 29 18:17:40 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Fri Jul 29 19:04:59 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507292217.j6TMHecB012306@pub.open-bio.org> kawas Fri Jul 29 18:17:39 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv12281/org/biomoby/registry/rdfagent/verifier Modified Files: ServiceDescrParser.java Log Message: fixed some bugs that were due to the scope of certain variables. formatted the code. fixed a bug that ignored article names of collections. fixed a bug that over wrote preexisting simples in collections with new ones even though both should exist. fixed a bug that caused pre-existing ns to be associated with simples without ns. ... moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServiceDescrParser.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/28 15:26:13 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/29 22:17:39 1.8 @@ -78,20 +78,16 @@ servSign = getServSignature(resource); if (!servSign.isEmpty()) { // a valid MOBY RDF - servName = servSign.get("servicename").toString(); + servName = servSign.get("servicename").toString()+""; auth_URI = servSign.get("authURI").toString(); resources.addElement(servName); Hashtable servInp = new Hashtable(); - servInp = getInput(resource); + servInp = getInput(resource); //TODO modify collections and simples like getOutput(); Hashtable servOut = new Hashtable(); servOut = getOutput(resource); - for (int i = 0; i < ver.length; i++) { // a clearance of the - // array ver[] - ver[i] = 0; - - } + ver = new int[]{0,0,0,0,0,0,0,0}; if (servInp.containsValue("error") | servOut.containsValue("error")) { servError += 1; @@ -302,7 +298,7 @@ Hashtable input = new Hashtable(); Resource si = servDescrMd.getResource(resource); - + if (si.hasProperty(MP.consumes)) try { Resource consumes = si.getRequiredProperty(MP.consumes) .getResource(); @@ -375,7 +371,7 @@ // to Input sin += 1; Enumeration num = siminp.keys(); - + siminp= new Hashtable(); } } else if (type.equals(MP.Collection) | type.equals(RDF.Bag)) { @@ -383,9 +379,9 @@ // l3Res.hasProperty(RDF.li(1))){ if (l3Res.hasProperty(RDF.li(1))) { StmtIterator p34iter = l3Res.listProperties(); - if (l3Res.hasProperty(MP.article_name)) { + if (l3Res.hasProperty(MP.articleName)) { String col_artName = l3Res.getProperty( - MP.article_name).getObject().toString(); + MP.articleName).getObject().toString(); String[] rezNode = col_artName.split(":http:"); col_artName = rezNode[0]; colinp.put("col_articleName", col_artName); @@ -449,13 +445,18 @@ String lsid_nsp = switchURItoLSID(l5Node .toString()); colinp.put(name, lsid_nsp); - } else { + } else if (name.equals("articleName")) { + colinp.put(name, l5Node.getName()); + }else { colinp.put(name, l5Node); } } input.put("colinp" + cin, colinp); cin += 1; Enumeration num = colinp.keys(); + String col_name = (String)colinp.get("col_articleName"); + colinp = new Hashtable(); + colinp.put("col_articleName", col_name); } } @@ -529,7 +530,7 @@ input.put("input", "error"); } } catch (Exception e) { - Log.warning("Failed:" + e); + Log.warning("Failed (ServiceDescrParser.java - getInput): " + e); } // } //System.out.println("input= "+input); @@ -558,8 +559,9 @@ Hashtable output = new Hashtable(); Resource si = servDescrMd.getResource(resource); - + if (si.hasProperty(MP.produces)) try { + Resource consumes = si.getRequiredProperty(MP.produces) .getResource(); StmtIterator p23iter = consumes.listProperties(); @@ -628,7 +630,7 @@ // to Output so += 1; Enumeration num = simout.keys(); - + simout = new Hashtable(); } } @@ -636,12 +638,12 @@ // if (l3Res.hasProperty(RDF.type,RDF.Bag) && // l3Res.hasProperty(RDF.li(1))){ - if (l3Res.hasProperty(RDF.li(1))) { + if (l3Res.hasProperty(RDF.li(1))) { //TODO is this right? probably should iterate through the anon nodes, breaking when the hasProperty() fails. StmtIterator p34iter = l3Res.listProperties(); - if (l3Res.hasProperty(MP.article_name)) { + if (l3Res.hasProperty(MP.articleName)) { String col_artName = l3Res.getProperty( - MP.article_name).getObject().toString(); + MP.articleName).getObject().toString(); String[] rezNode = col_artName.split(":http:"); col_artName = rezNode[0]; colout.put("col_articleName", col_artName); @@ -705,13 +707,19 @@ String lsid_nsp = switchURItoLSID(l5Node .toString()); colout.put(name, lsid_nsp); - } else { + } else if (name.equals("articleName")) { + colout.put(name, rezNode[0]); + }else { colout.put(name, l5Node); } } + //TODO BUG here. colout should be 'new' and not recycled output.put("colout" + co, colout); co += 1; Enumeration num = colout.keys(); + String col_name = (String)colout.get("col_articleName"); + colout = new Hashtable(); + colout.put("col_articleName", col_name); } } @@ -732,7 +740,7 @@ output.put("output", "error"); } } catch (Exception e) { - Log.warning("Failed:" + e); + Log.warning("Failed (ServiceDescrParser.java-getOutput): " + e); } //System.out.println("output = "+output); return output; @@ -845,6 +853,7 @@ return res; } + //TODO - need to fix this to make it portable public String switchURItoLSID(String uri) { String lsid = ""; From mwilkinson at pub.open-bio.org Sun Jul 31 11:18:54 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Sun Jul 31 12:05:43 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507311518.j6VFIspd026387@pub.open-bio.org> mwilkinson Sun Jul 31 11:18:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv26368/MOBY/Client Modified Files: Central.pm Log Message: typo in the default server name moby-live/Perl/MOBY/Client Central.pm,1.109,1.110 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.109 retrieving revision 1.110 diff -u -r1.109 -r1.110 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:39:37 1.109 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/31 15:18:54 1.110 @@ -141,7 +141,8 @@ Connections => [ undef, 'read/write' ], default_MOBY_servername => [ 'mobycentral', 'read/write' ], default_MOBY_server => [ - 'http://mobycentral.icpture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', + +'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', 'read/write' ], default_MOBY_uri => From mwilkinson at pub.open-bio.org Sun Jul 31 11:30:30 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Sun Jul 31 12:16:55 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507311530.j6VFUUPk026469@pub.open-bio.org> mwilkinson Sun Jul 31 11:30:30 EDT 2005 Update of /home/repository/moby/moby-live/Database In directory pub.open-bio.org:/tmp/cvs-serv26454 Added Files: reset.bat Log Message: a batch file for reinitializing the databases in MS Windows moby-live/Database reset.bat,NONE,1.1 From kawas at pub.open-bio.org Fri Jul 29 19:05:46 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon Aug 15 11:29:18 2005 Subject: [MOBY-guts] biomoby commit Message-ID: <200507292219.j6TMJ6S5012347@pub.open-bio.org> kawas Fri Jul 29 18:19:05 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv12322/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: not sure what i did - cvs says that there are differences. Probably bug fixes and formatting. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/28 15:24:41 1.10 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/29 22:19:05 1.11 @@ -24,2428 +24,2508 @@ public class DataMngr { - /** - * get the list of signatureURL from service_instance table - * - * @return a Hashtable (signatureURL = string of servicenames for this URL - * separated by comma) - * - * - */ - - public static Hashtable getServices(String file) { - - Hashtable services = new Hashtable(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select servicename,signatureURL,authority_id from service_instance order by signatureURL"; - - PreparedStatement ps = null; - ResultSet rs = null; - - try { - ps = con.prepareStatement(sqlReq1); - rs = ps.executeQuery(); - String lastAddr = ""; - StringBuffer servNames = new StringBuffer(); - int lastID = -1; - - while (rs.next()) { - String servName = rs.getString(1); - String rdfAddr = rs.getString(2); - int authorityID = rs.getInt(3); - if (rdfAddr == null) { - //TODO - make this code more efficient! - maybe perform one sql call instead of many - // update the signatureURL field using the service name and authority id - String bogusSigURL = "http://invalidURL123.com/author/"+ authorityID + "/" + servName +".xml"; - String updateSQLString = "UPDATE service_instance " + - "SET signatureURL='"+ bogusSigURL +"' " + - "WHERE authority_id=" + authorityID + " and servicename='" + servName +"'"; - PreparedStatement preparedStatement = null; - try { - Connection updateCon = DBConnector.getConnection(); - preparedStatement = updateCon.prepareStatement(updateSQLString); - int resultSet = preparedStatement.executeUpdate(); - Log.info(resultSet + ": Updated the signatureURL field of the authority with id #" + authorityID + " to be " + bogusSigURL+"."); - } catch (SQLException e) { - Log.severe("Could not update SignatureURL field with a bogus signatureURL.\n" +e.getMessage()); - } - - } else { - if (rdfAddr.equals(lastAddr)) { - servNames.append("," + servName); - } else { - if (servNames.length() > 0) { - services.put(lastAddr, servNames); - servNames = new StringBuffer(); - } - servNames.append(servName); - lastAddr = rdfAddr; - Report.doSave(file, lastAddr); - } - } - } - services.put(lastAddr, servNames); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - //System.out.println("ListOFServices : "+services); - - return services; - } - - /** - * get the list of services by signatureURL - * - * @param signURL - - * URL of resource - * @return a Hashtable (signatureURL = string of servicenames for this URL - * separated by comma) - */ - - public static Hashtable getServicesByURL(String signURL) { - - Hashtable services = new Hashtable(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select servicename,signatureURL from service_instance where signatureURL=?"; - - PreparedStatement ps = null; - ResultSet rs = null; - - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - String lastAddr = ""; - StringBuffer servNames = new StringBuffer(); - - while (rs.next()) { - String servName = rs.getString(1); - String rdfAddr = rs.getString(2); - - if (rdfAddr.equals(lastAddr)) { - servNames.append("," + servName); - } else { - if (servNames.length() > 0) { - services.put(lastAddr, servNames); - servNames = new StringBuffer(); - } - servNames.append(servName); - lastAddr = rdfAddr; - } - } - services.put(lastAddr, servNames); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - // System.out.println("ListOFServices : "+services); - - return services; - } - - /** - * This method use for the update service_instance table, - * simple_input/output table, collection_input/output table, secondary_input - * table in accordance with data from RDF file. - * - * @param servSign - - * set of the serviceSignature data (name - value, an example: - * servicename - GoTerm); Hashtable of hashtables represented by - * a pair: a name of the input = hashtable for this output - * example:{siminp1={object_type_uri=urn:lsid:biomoby.org:objectclass:Object, - * namespace_type_uris=urn:lsid:biomoby.org:namespacetype:taxon}} - * @param servInp - - * Hashtable of hashtables represented by a pair: a name of the - * output = hashtable for this output - * @param servname - - * the name of service - * @param authURI - - * the authority URI - * @param signURL - - * URL of resource - */ - - public static void processService(Hashtable servSign, Hashtable servInp, - Hashtable servOut, String servname, String authURI, String signURL) { - - Connection con = DBConnector.getConnection(); - String servName = ""; - String cat = "moby"; - String url = ""; - String email = ""; - String desc = ""; - String stype = ""; - String authuri = ""; - String authoritative = ""; - String art = null; - String col_art = null; - String obt = null; - String nst = null; - String artsec = null; - String defsec = null; - String dtsec = null; - - BigDecimal maxsec = null; - BigDecimal minsec = null; - - String enumsec = null; - int colId = 0; - Integer colOutId = null; - Integer colInpId = null; - int serv = 0; // a flag - the given service was found - int checkServ = 0; // a flag - the service exist in the database - int new_serv = 0; // the number of new services - int ret; - int servInstId = 0; - String signatureURL = "NNN"; - - // ************** Update service Signature **************** - - Enumeration num = servSign.keys(); - - while (num.hasMoreElements()) { - - Object ob = num.nextElement(); - Object val = servSign.get(ob); - if (ob.equals("category")) { - cat = val.toString(); - } - if (ob.equals("URL")) { - url = val.toString(); - } - if (ob.equals("contact_email")) { - email = val.toString(); - } - if (ob.equals("description")) { - desc = val.toString(); - } - if (ob.equals("service_type_uri")) { - stype = val.toString(); - } - if (ob.equals("authURI")) { - authuri = val.toString(); - } - if (ob.equals("authoritative")) { - authoritative = val.toString(); - - if (authoritative.equals("non-authoritative")) { - authoritative = "0"; - } else if (authoritative.equals("authoritative")) { - authoritative = "1"; - } - } - if (ob.equals("servicename")) { - servName = val.toString(); - } - if (ob.equals("signatureURL")) { - signatureURL = val.toString(); - } - - } - - ServSignature signature = getServSignature(servname, signURL); - servInstId = signature.getServInstId(); - //TODO make sure that the fields are updated - if (servInstId == 0) { - - int authId = getAuthIdByAuthURI(authuri); - - if (authId == 0) { - insIntoAuthority(authuri, email); - authId = getAuthIdByAuthURI(authuri); - } - - if (signatureURL.equals("NNN")) { - ret = createSignature(servName, cat, stype, authId, url, email, - authoritative, desc, signURL); - } else { - ret = createSignature(servName, cat, stype, authId, url, email, - authoritative, desc, signatureURL); - } - - if (ret == 1) { - String msg = "------The service instance <" + servName - + "> was registered in the MOBYCENTRAL registry "; - Report.doWrite(msg); - Report.add(msg); - - //System.out.println("mail_server = - // "+Constants.MB_MAIL_SERVER); - /* - * if (Constants.MB_MAIL_SERVER != null | - * !Constants.MB_MAIL_SERVER.equals("")) { String to = - * DataMngr.getContactEmail(signURL); - * Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // - * send message to the service provider - that service was - * deregistered } - */ - new_serv += 1; - servInstId = getServInstId(servName, authId); - } - } else { - - if (!cat.equals(signature.getCategory()) - || !url.equals(signature.getUrl()) - || !email.equals(signature.getEmail()) - || !desc.equals(signature.getDescription()) - || !stype.equals(signature.getServiceType()) - || !authoritative.equals(signature.getAuthoritative()) - || !authuri.equals(authURI)) { - - //TODO - Log.info("Updating the service '" + servName +"' since the RDF document has been modified."); - if (signatureURL.equals("NNN")) { - Log.info("sig == NNN" + signURL); - Log.info("=<"+servName+","+cat+","+stype+","+authuri+","+url+","+email+","+desc+","+authoritative+","+signURL+">"); - int res = updSign(servName, cat, stype, authuri, url, - email, desc, authoritative, signURL); - if (res == 1) { - Report.doWrite("------The service instance<"+servName+"> was updated "); - Report.add("------The service instance <"+servName+">was updated "); - } else { - Report.doWrite("------The service instance<"+servName+"> was not updated"); - Report.add("------The service instance <"+servName+">was not updated "); - } - - } else { - Log.info("sig != NNN"); - int res = updSign(servName, cat, stype, authuri, url, - email, desc, authoritative, signatureURL); - if (res == 1) { - Report.doWrite("------The service instance <"+servName+"> was updated "); - Report.add("------The service instance <"+servName+">was updated "); - } else { - Report.doWrite("------The service instance <"+servName+"> was not updated "); - Report.add("------The service instance <"+servName+">was not updated "); - } - } - } - } - - // ************ add Input ********************* - - Enumeration num1 = servInp.keys(); - int dels = 0; - int delc = 0; - int delsec = 0; - int si = 0; - int ci = 0; - int sci = 0; - - while (num1.hasMoreElements()) { - Object ob = num1.nextElement(); - Object val = servInp.get(ob); - Log.info("INPUTS :"+ob+" = "+val ); - String simcol = (ob.toString()).substring(0, 6); // a hashtable name - - if (simcol.equals("secinp")) { // if it's a Secondary input - sci += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Secondary input " + sci); - Report.add("Secondary input " + sci + ":"); - if (delsec == 0) { - delRow("secondary_input", servInstId); // delete from - // simple_input table - delsec = 1; - } - } else if (simcol.equals("colinp")) { // if it's a Collection input - ci += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Collection input " + ci); - Report.add("Collection input " + ci + ":"); - if (delc == 0) { - // colInpId = new - // Integer(getCollectionId("collection_input","collection_input_id",servInstId)); - delCollectionMember("input", servInstId); // delete from - // simple_input - // table - delRow("collection_input", servInstId); // delete from the - // collection_input - // table - delc = 1; - } - - } else { // if it's a Simple input - Report.doWrite(" "); - Report.add(" "); - si += 1; - Report.doWrite("Simple input " + si); - Report.add("Simple input " + si + ":"); - if (dels == 0) { - delRow("simple_input", servInstId); // delete from - // simple_input table - dels = 1; - } - } - Hashtable simple = new Hashtable(); - simple = (Hashtable) val; - Enumeration num11 = simple.keys(); - - while (num11.hasMoreElements()) { - Object ob1 = num11.nextElement(); - if (!ob1.equals("type")) { - Report.doWrite(ob1 + " = " + simple.get(ob1)); - Report.add(ob1 + " = " + simple.get(ob1)); - } - - if (ob1.equals("col_articleName")) { - col_art = simple.get(ob1).toString(); - if (col_art.equals(" ")) { - col_art = null; - } - } else if (ob1.equals("articleName")) { - art = simple.get(ob1).toString(); - if (art.equals(" ")) { - art = null; - } - } else if (ob1.equals("article_name")) { - artsec = simple.get(ob1).toString(); - if (artsec.equals(" ")) { - artsec = null; - } - } else if (ob1.equals("object_type_uri")) { - obt = simple.get(ob1).toString(); - } else if (ob1.equals("namespace_type_uris")) { - nst = simple.get(ob1).toString(); - } else if (ob1.equals("default")) { - defsec = simple.get(ob1).toString(); - } else if (ob1.equals("datatype")) { - dtsec = simple.get(ob1).toString(); - } else if (ob1.equals("max")) { - String maxsec_s = simple.get(ob1).toString(); - try { - maxsec = new BigDecimal(maxsec_s); - - } catch (NumberFormatException nx) { - Log.severe(nx.getMessage()); - // nx.getMessage(); - } - } else if (ob1.equals("min")) { - String minsec_s = simple.get(ob1).toString(); - try { - minsec = new BigDecimal(minsec_s); - - } catch (NumberFormatException nx) { - Log.severe(nx.getMessage()); - // nx.getMessage(); - } - } else if (ob1.equals("enum")) { - enumsec = simple.get(ob1).toString(); - } - } - - if (simcol.equals("colinp")) { - insIntoCol("collection_input", col_art, servInstId); // insert - // the row - // into - // collection_input - // table - colId = getCollectionId("collection_input", - "collection_input_id", servInstId); - insIntoSimpleInput(null, art, obt, nst, new Integer(colId)); - - art = null; - col_art = null; - obt = null; - nst = null; - } else if (simcol.equals("siminp")) { - insIntoSimpleInput(new Integer(servInstId), art, obt, nst, null); - - art = null; - obt = null; - nst = null; - } else if (simcol.equals("secinp")) { - - insIntoSecondary(servInstId, artsec, defsec, dtsec, maxsec, - minsec, enumsec); - - artsec = null; - defsec = null; - dtsec = null; - maxsec = null; - minsec = null; - enumsec = null; - } - - if (colId != 0) { - Report.doWrite("collection_input_id: " + colId); - // Log.info("collection_input_id: "+colId); - } - } - - Report.doWrite("service_instance_id: " + servInstId); - // Log.info("service_instance_id: "+servInstId); - - // *********** add Output *********************** - - Enumeration numout = servOut.keys(); - int delsout = 0; - int delcout = 0; - int so = 0; - int co = 0; - while (numout.hasMoreElements()) { - Object ob = numout.nextElement(); - Object val = servOut.get(ob); - String simcol = (ob.toString()).substring(0, 6); - Log.info("OUTPUTS :"+ob+" = "+val ); - if (simcol.equals("colout")) { - co += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Collection output " + co); - Report.add("Collection output " + co + ":"); - if (delcout == 0) { - // colOutId = new - // Integer(getCollectionId("collection_output","collection_output_id",servInstId)); - delCollectionMember("output", servInstId); // delete from - // table - // simple_output - delRow("collection_output", servInstId); // delete from the - // collection_output - // table - delcout = 1; - } - } else { - so += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Simple output " + so); - Report.add("Simple output " + so + ":"); - - //TODO bug #13 here? - if (delsout == 0) { - delRow("simple_output", servInstId); // delete from - // simple_output table - delsout = 1; - } - } - Hashtable simple = new Hashtable(); - simple = (Hashtable) val; - Enumeration num11 = simple.keys(); - // Report.doWrite(""+simple); - - while (num11.hasMoreElements()) { - Object ob1 = num11.nextElement(); - if (!ob1.equals("type")) { - Report.doWrite(ob1 + " = " + simple.get(ob1)); - Report.add(ob1 + " = " + simple.get(ob1)); - } - - if (ob1.equals("col_articleName")) { - col_art = simple.get(ob1).toString(); - if (col_art.equals(" ")) { - col_art = null; - } - } - if (ob1.equals("articleName")) { - art = simple.get(ob1).toString(); - if (art.equals(" ")) { - art = null; - } - } - if (ob1.equals("object_type_uri")) { - obt = simple.get(ob1).toString(); - } - if (ob1.equals("namespace_type_uris")) { - nst = simple.get(ob1).toString(); - } - } - - if (simcol.equals("colout")) { - - insIntoCol("collection_output", col_art, servInstId); // insert - // the row - // into - // collection_input - // table - - colOutId = new Integer(getCollectionId("collection_output", - "collection_output_id", servInstId)); - insIntoSimpleOutput(null, art, obt, nst, colOutId); - art = null; - obt = null; - nst = null; - } - // TODO bug #11 here - fixed - if (simcol.equals("simout")) { - insIntoSimpleOutput(new Integer(servInstId), art, obt, nst, - null); - art = null; - obt=null; - nst=null; - } - if (colOutId != null) { - Report.doWrite("collection_output_id: " + colOutId); - // Log.info("collection_output_id: "+coloutId); - } - } - // return serv; - } - - /** - * delete the service instance by service name and authority URI - * - * @param servName - * the name of service which we want delete. - * @param authURI - * the authority URI for service which we want delete. - * - */ - - public static void delServByNameAndAuthURI(String servName, String authURI) { - - int authId = getAuthIdByAuthURI(authURI); - int servInstId = getServInstId(servName, authId); - - delSignature(servName, authId); // delete service from table - // service_instance - delRow("simple_input", servInstId); // delete from table simple_input - delRow("simple_output", servInstId); // delete from table simple_output - delRow("secondary_input", servInstId); //TODO - should this line be here? - delCollectionMember("input", servInstId); - delCollectionMember("output", servInstId); - delRow("collection_input", servInstId); // delete from table - // collection_input - delRow("collection_output", servInstId); // delete from table - // collection_output - } - - /** - * delete the service instance by service name and signature URL - * - * @param servName - * the name of service which we want delete. - * @param signURL - * the authority URI for service which we want delete. - * - */ - - public static void delServByNameAndUrl(String servName, String signURL) { - - int authId = getAuthIdByServNameAndSignURL(servName, signURL); - int servInstId = getServInstId(servName, authId); - - delSignature(servName, authId); // delete service from table - // service_instance - delRow("simple_input", servInstId); // delete from table simple_input - delRow("simple_output", servInstId); // delete from table simple_output - delRow("secondary_input", servInstId); //TODO - should this line be here? - delCollectionMember("input", servInstId); - delCollectionMember("output", servInstId); - delRow("collection_input", servInstId); // delete from table - // collection_input - delRow("collection_output", servInstId); // delete from table - // collection_output - } - - /** - * delete set of the service instances with the same signatureURL by - * signatureURL - * - * @param signURL - * the name of service which we want delete. - */ - - public static void delServiceSetByURL(String signURL) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id,servicename,authority_id from service_instance where signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - Vector del_serv = new Vector(); - - while (rs.next()) { - int servInstId = rs.getInt(1); - String servName = rs.getString(2); - int authId = rs.getInt(3); - - int rez = delSignature(servName, authId); // delete service from - // table - // service_instance - if (rez == 1) { - del_serv.addElement(servName); - } - delRow("secondary_input", servInstId); //TODO - should this line be here? - delRow("simple_input", servInstId); // delete from table - // simple_input - delRow("simple_output", servInstId); // delete from table - // simple_output - delCollectionMember("input", servInstId); // delete collection - // member from - // simple_input - delCollectionMember("output", servInstId); // delete collection - // member from - // simple_output - delRow("collection_input", servInstId); // delete from table - // collection_input - delRow("collection_output", servInstId); // delete from table - // collection_output - } - - int del = del_serv.size(); - if (del > 0) { - Report.doWrite("DELETED SERVICES: "); - Iterator i = del_serv.iterator(); - int n = 1; - while (i.hasNext()) { - String delServ = i.next().toString(); - Report.doWrite(n + ". " + delServ); - n += 1; - } - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } - } - - } - - /** - * add the record about new service instance in the service_instance table - * of mobycentral database - * - * @param servName - - * the name of service instance the record was added for. - * @param cat - - * the category of service instance. - * @param servTypeURI - - * the service type URI of service instance. - * @param authId - - * the authority Id of service instance. - * @param url - - * the URL of service instance. - * @param email - - * the contact e-Mail of service instance. - * @param authoritative - - * the authoritative of service instance. - * @param desc - - * the description of service instance. - * @param signURL - - * the URL for RDF of service instance. - * @return ret=1 if the record has added, and ret=-1 otherwise - */ - - public static int createSignature(String servName, String cat, - String servTypeURI, int authId, String url, String email, - String authoritative, String desc, String signURL) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into service_instance (servicename,category,service_type_uri,authority_id,url,contact_email,authoritative,description,signatureURL) values (?,?,?,?,?,?,?,?,?)"; - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setString(2, cat); - ps.setString(3, servTypeURI); - ps.setInt(4, authId); - ps.setString(5, url); - ps.setString(6, email); - ps.setString(7, authoritative); - ps.setString(8, desc); - ps.setString(9, signURL); - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * update the service instance data in the service_instance table of - * mobycentral database - * - * @param servName - * the name of service instance the record was updated for. - * @param cat - * the category of service instance. - * @param stype - * the service type URI of service instance. - * @param authuri - * the authority URI of service instance. - * @param url - * the URL of service instance. - * @param email - * the contact e-Mail of service instance. - * @param authoritative - * the authoritative of service instance. - * @param desc - * the description of service instance. - * @param signURL - * the URL for RDF of service instance. - * @return ret=1 if the record has updated, and ret=-1 otherwise - */ - - public static int updSign(String servName, String cat, String stype, - String authuri, String url, String email, String desc, - String authoritative, String signURL) { - - Connection con = DBConnector.getConnection(); - int cnt = -1; - int ret = -1; - final String sqlReq = "select authority_id from authority where authority_uri = ?"; - PreparedStatement ps = null; - - final String sqlReq1 = "update service_instance set category = ?,service_type_uri = ?,url = ?,contact_email = ?,description = ?,authoritative = ?,signatureURL = ? where servicename = ? && authority_id = ?"; - try { - ps = con.prepareStatement(sqlReq); - ps.setString(1, authuri); - ResultSet rs = ps.executeQuery(); - while (rs.next()) { - cnt = rs.getInt(1); - } - if (cnt > -1) { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, cat); - ps.setString(2, stype); - ps.setString(3, url); - ps.setString(4, email); - ps.setString(5, desc); - ps.setString(6, authoritative); - ps.setString(7, signURL); - ps.setString(8, servName); - ps.setInt(9, cnt); - ret = ps.executeUpdate(); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * add the record into the simple_input table - * - * @param servInstId - * the Id of service instance the simple input was added for. - * @param articleName - * the article name of the simple input. - * @param objTypeUri - * the object type URI of the simple input. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple input. - * @param colInpId - * the collection input Id if this simple input belongs to a - * collection, and blank otherwise. - */ - - public static void insIntoSimpleInput(Integer servInstId, - String articleName, String objTypeUri, String nsTypeUris, - Integer colInpId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into simple_input (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_input_id) values (?,?,?,?,?)"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - if (servInstId != null) { - ps.setInt(1, servInstId.intValue()); - } else { - ps.setNull(1, java.sql.Types.INTEGER); - } - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - if (colInpId != null) { - ps.setInt(5, colInpId.intValue()); - } else { - ps.setNull(5, java.sql.Types.INTEGER); - } - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - } - - /** - * update the record into the simple_input table - * - * @param servInstId - * the Id of service instance the simple input was added for. - * @param articleName - * the article name of the simple input. - * @param objTypeUri - * the object type URI of the simple input. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple input. - * @param colInpId - * the collection input Id if this simple input belongs to a - * collection, and blank otherwise. - * @return ret=1 if the record has added, and ret=-1 otherwise - */ - - public static int updateSimpleInput(int servInstId, String articleName, - String objTypeUri, String nsTypeUris, Integer colInpId, int minNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update simple_input set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_input_id=? where simple_input_id=?"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - if (colInpId != null) { - ps.setInt(5, colInpId.intValue()); - } else { - ps.setNull(5, java.sql.Types.INTEGER); - } - ps.setInt(6, minNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * add the record about secondary input in the secondary_input table of - * mobycentral database - * - * @param servInstId - * the Id of service instance the secondary input was added for. - * @param article_name - * the article name of the secondary input. - * @param def - * the default value of the secondary input. - * @param dataType - * the type of data of the secondary input. - * @param max - * the maximum value of the secondary input - * @param min - * the minimum value of the secondary input * - * @param enumeration - * the enumeration value for the secondary input - */ - - public static void insIntoSecondary(int servInstId, String article_name, - String def, String dataType, BigDecimal max, BigDecimal min, - String enumeration) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into secondary_input (service_instance_id,article_name,default_value,maximum_value,minimum_value,enum_value,datatype) values (?,?,?,?,?,?,?)"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - ps.setString(2, article_name); - ps.setString(3, def); - ps.setBigDecimal(4, max); - ps.setBigDecimal(5, min); - ps.setString(6, enumeration); - ps.setString(7, dataType); - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - } - - /** - * update the record into the secondary_input table - * - * @param servInstId - * the Id of service instance the secondary input was added for. - * @param article_name - * the article name of the secondary input. - * @param def - * the default value of the secondary input. - * @param dataType - * the type of data of the secondary input. - * @param max - * the maximum value of the secondary input - * @param min - * the minimum value of the secondary input - * @param enumeration - * the enumeration value for the secondary input - * @param minSecNum - * minimum free number for secondary_input_id - */ - - public static void updateSec(int servInstId, String article_name, - String def, String dataType, BigDecimal max, BigDecimal min, - String enumeration, int minSecNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update secondary_input set service_instance_id=?,article_name=?,default_value=?,maximum_value=?,minimum_value=?,enum_value=?,datatype=? where secondary_input_id=?"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - ps.setString(2, article_name); - ps.setString(3, def); - ps.setBigDecimal(4, max); - ps.setBigDecimal(5, min); - ps.setString(6, enumeration); - ps.setString(7, dataType); - ps.setInt(8, minSecNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } - } - } - - /** - * add the record into the simple_output table - * - * @param servInstId - * the Id of service instance the simple output was added for. - * @param articleName - * the article name of the simple output. - * @param objTypeUri - * the object type URI of the simple output. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple output. - * @param colOutId - * the collection input Id if this simple output belongs to a - * collection, and blank otherwise. - */ - - public static void insIntoSimpleOutput(Integer servInstId, - String articleName, String objTypeUri, String nsTypeUris, - Integer colOutId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into simple_output (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_output_id) values (?,?,?,?,?)"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - if (servInstId != null) { - ps.setInt(1, servInstId.intValue()); - } else { - ps.setNull(1, java.sql.Types.INTEGER); - } - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - if (colOutId != null) { - ps.setInt(5, colOutId.intValue()); - } else { - ps.setNull(5, java.sql.Types.INTEGER); - } - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - } - - /** - * update the record into the simple_output table - * - * @param servInstId - * the Id of service instance the simple output was added for. - * @param articleName - * the article name of the simple output. - * @param objTypeUri - * the object type URI of the simple output. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple output. - * @param colOutId - * the collection input Id if this simple output belongs to a - * collection, and blank otherwise. - * @return ret=1 if the record has added, and ret=-1 otherwise - */ - - public static int updateSimpleOutput(int servInstId, String articleName, - String objTypeUri, String nsTypeUris, int colOutId, int minNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update simple_output set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_output_id=? where simple_output_id=?"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setInt(1, servInstId); - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - ps.setInt(5, colOutId); - ps.setInt(6, minNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return ret; - } - - /** - * get the number of errors for the given return code and URL of resource - * - * @param signURL - - * the URL of resource was gotten the return code for. - * @param errCode - - * the error code, connection was refused - * @return Intrger number of error if was found in the database, zero - * otherwise - */ - - public static int getServErrorNum(String signURL, int errCode) { - - int num = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select counter from service_validation where signatureURL = ? and error_code = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - ps.setInt(2, errCode); - rs = ps.executeQuery(); - - while (rs.next()) { - int cnt = rs.getInt(1); - num = cnt; - - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return num; - - } - - /** - * get the service signature data for service instance by the service name - * and signatureURL - * - * @param signURL - - * the URL of service RDF - * @param servName - - * the name of service - * @return carrier class ServSignature - */ - - public static ServSignature getServSignature(String servName, String signURL) { - - ServSignature signature = new ServSignature(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id,authority_id,category,service_type_uri,url,contact_email,authoritative,description from service_instance where servicename=? and signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setString(2, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - int servInstId = rs.getInt(1); - signature.setServInstId(servInstId); - int authId = rs.getInt(2); - signature.setAuthId(authId); - String category = rs.getString(3); - signature.setCategory(category); - String serviceType = rs.getString(4); - signature.setServiceType(serviceType); - String url = rs.getString(5); - signature.setUrl(url); - String email = rs.getString(6); - signature.setEmail(email); - String authoritative = rs.getString(7); - signature.setAuthoritative(authoritative); - String description = rs.getString(8); - signature.setDescription(description); - signature.setServiceName(servName); - signature.setSignatureURL(signURL); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return signature; - - } - - /** - * get the secondary input data by the secondary input Id - * - * @param servInstId - - * the secondary input Id - * @return carrier class Secondary - */ - - public static Secondary getSecondary(int servInstId) { - - Secondary second = new Secondary(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select default_value,maximum_value,minimum_value,enum_value,datatype,article_name from secondary_input where service_instance_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - int open_sec = 0; - while (rs.next()) { - String defaultValue = rs.getString(1); - second.setDefaultValue(defaultValue); - BigDecimal maximumValue = rs.getBigDecimal(2); - second.setMaximumValue(maximumValue); - BigDecimal minimumValue = rs.getBigDecimal(3); - second.setMinimumValue(minimumValue); - String enumValue = rs.getString(4); - second.setEnumValue(enumValue); - String datatype = rs.getString(5); - second.setDatatype(datatype); - String articleName = rs.getString(6); - second.setArticleName(articleName); - - XMLBuilder.buildSecondXml(second); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return second; - - } - - /** - * get the simple/collection output data by the service instance Id and - * build xml representation - * - * @param servInstId - - * the service instance Id - */ - - public static void getSimpleCollectOutput(int servInstId) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_output_id from simple_output where service_instance_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - - while (rs.next()) { - String artName = rs.getString(1); - String nsType = rs.getString(2); - String objType = rs.getString(3); - // int colOutId = rs.getInt(4); - String type; - Integer colOutId = new Integer(rs.getInt(4)); - if (colOutId == null) { - type = "so"; - } else { - type = "co"; - } - - XMLBuilder.buildInpOutXml(artName, nsType, objType, type); - } - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - } - - /** - * get the simple/collection input data by the service instance Id and build - * xml representation - * - * @param servInstId - - * the service instance Id - */ - - public static void getSimpleCollectInput(int servInstId) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_input_id from simple_input where service_instance_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - - while (rs.next()) { - String artName = rs.getString(1); - String nsType = rs.getString(2); - String objType = rs.getString(3); - String type; - // int colInpId = rs.getInt(4); - Integer colInpId = new Integer(rs.getInt(4)); - if (colInpId == null) { - type = "si"; - } else { - type = "ci"; - } - - XMLBuilder.buildInpOutXml(artName, nsType, objType, type); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - } - - /** - * update the counter for the given return code and URL of resource - * - * @param signURL - - * the URL of resource was updated the counter for. - * @param errCode - - * the error code was encreased the counter for. - * @return Intrger ret=1 if the record was updated, ret=-1 otherwise - */ - - public static int updErrCount(String signURL, int errCode) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update service_validation set error_code = ?,counter=counter+1 where signatureURL = ?"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setInt(1, errCode); - ps.setString(2, signURL); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return ret; - } - - /** - * add new record to the service_validation table of the mobycentral - * database - * - * @param signURL - - * the URL of resource the connection was refused for. - * @param errCode - - * the error code, connection was refused - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int insErrCount(String signURL, int errCode) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into service_validation (signatureURL,error_code,counter) values (?,?,1)"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, signURL); - ps.setInt(2, errCode); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return ret; - } - - /** - * delete the record from service_validation table by signatureURL - * - * @param signURL - - * the URL of resource the record was deleted for. - * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. - */ - - public static int delServErrors(String signURL) { - - Connection con = DBConnector.getConnection(); - int ret = -1; - final String sqlReq1 = "delete from service_validation where signatureURL = ?"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.warning(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - - } - - /** - * get the service instance Id for the given service name and authority Id - * - * @param servName - - * the name of service instance . - * @param authId - - * the authority Id for the service instance. - * @return Intrger service instance Id if was found in the database, zero - * otherwise - */ - - public static int getServInstId(String servName, int authId) { - - int servInsId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && authority_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setInt(2, authId); - rs = ps.executeQuery(); - - while (rs.next()) { - servInsId = rs.getInt(1); - - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return servInsId; - } - - /** - * get the service instance Id for the given service name and signatureURL - * - * @param servName - - * the name of service instance . - * @param signURL - - * URL of resource for the service instance. - * @return Intrger service instance Id if was found in the database, zero - * otherwise - */ - - public static int getServInstId(String servName, String signURL) { - - int servInsId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setString(2, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - servInsId = rs.getInt(1); - - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return servInsId; - } - - /** - * get the set of services for the given URL of resource by signatureURL - * - * @param signURL - - * the URL of resource . - * @return String set of the services which was found in the database, empty - * string otherwise - */ - - public static String getServListByURL(String signURL) { - - StringBuffer servList = new StringBuffer(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select servicename from service_instance where signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - String servName = rs.getString(1); - servList.append(servName + ","); - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return servList.toString(); - } - - /** - * delete a record from given table by a service instance Id (the metod is - * working for simple_input/output, collection input/output tables) - * - * @param servInstId - - * the service instance Id. - * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. - */ - - public static int delRow(String tableName, int servInstId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "delete from " + tableName - + " where service_instance_id = ?"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setInt(1, servInstId); - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - return ret; - } - - /** - * delete a record from simple table by a service instance Id and - * collection_input_id (the metod is working for simple_input/output, - * collection input/output tables) - * - * @param servInstId - - * the service instance Id. - */ - - public static void delCollectionMember(String inout, int servInstId) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1; - //System.out.println("inout = "+inout); - if (inout.equals("input")) { - sqlReq1 = "select collection_input_id from collection_input where service_instance_id = ? "; - } else { - sqlReq1 = "select collection_output_id from collection_output where service_instance_id = ? "; - } - //System.out.println("sqlReq1 = "+sqlReq1); - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - while (rs.next()) { - int colId = rs.getInt(1); - //System.out.println("colId = "+colId); - final String sqlReq; - if (inout.equals("input")) { - sqlReq = "delete from simple_input where collection_input_id=" - + colId; - //System.out.println("sqlReq = "+sqlReq); - } else { - sqlReq = "delete from simple_output where collection_output_id=" - + colId; - } - PreparedStatement ps1 = null; - - try { - ps1 = con.prepareStatement(sqlReq); - // ps.setInt(1, servInstId); - ps1.executeUpdate(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } finally { - try { - if (ps1 != null) - ps1.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } - } - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } - } - - } - - /** - * delete a record from service_instance table by a servicename and - * authority Id - * - * @param servName - - * the service instance name. - * @param authId - - * the id of the authority - * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. - */ - - public static int delSignature(String servName, int authId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - // if (authId == 0){ - final String sqlReq1 = "delete from service_instance where servicename= ? and authority_id = ?"; - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setInt(2, authId); - ret = ps.executeUpdate(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * get the collection Id from collection_input or collection_output table by - * the service_instance_id - * - * @param table - - * the collection_input or collection_output table - * @param field - - * "collection_input_id" (for collection_input table) and - * "collection_output_id" (for collection_output table) - * @param servInstId - - * Id of service instance - * @return Integer collection Id if was found, zero otherwise. - */ - - public static int getCollectionId(String table, String field, int servInstId) { - - int colId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select " - + field - + " from " - + table - + " where service_instance_id = ? order by service_instance_id," - + field + " ASC"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - - while (rs.next()) { - colId = rs.getInt(1); - - } - - } catch (SQLException e) { - - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return colId; - - } - - /** - * add new record into the collection_input or collection_output table - * - * @param table - - * the collection_input or collection_output table - * @param artName - - * the artical name of the collection_input or collection_output - * @param servInstId - - * Id of service instance - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int insIntoCol(String table, String artName, int servInstId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into " + table - + " (article_name,service_instance_id) values (?,?)"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, artName); - ps.setInt(2, servInstId); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * update record into the collection_input or collection_output table - * - * @param table - - * the collection_input or collection_output table - * @param key_field - - * collection_input_id for collection_input table, - * collection_output_id for collection_output table; - * @param artName - - * the artical name of the collection_input or collection_output - * @param servInstId - - * Id of service instance - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int updateCol(String table, String key_field, String artName, - int servInstId, int minNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update " + table - + " set article_name=?,service_instance_id=? where " - + key_field + " =?"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, artName); - ps.setInt(2, servInstId); - ps.setInt(3, minNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * get the service authority URI from authority table by the servicename - * - * @param servName - - * the name of service - * @return String authority URI if was found, empty string otherwise. - */ - - public static String getServAuthURI(String servName) { - - Connection con = DBConnector.getConnection(); - - String authURI = ""; - - final String sqlReq1 = "select authority_uri from service_instance si,authority a where si.authority_id=a.authority_id and si.servicename=?"; - ; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - rs = ps.executeQuery(); - - while (rs.next()) { - authURI = rs.getString(1); - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return authURI; - - } - - /** - * get the service authority Id from service_instance table by the - * servicename and signatureURL - * - * @param serviceName - - * the name of service - * @param signURL - - * the signatureURL for the given service - * @return int authority Id if was found, zero otherwise. - */ - - public static int getAuthIdByServNameAndSignURL(String serviceName, - String signURL) { - - int authId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select authority_id from service_instance where servicename = ? and signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, serviceName); - ps.setString(2, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - authId = rs.getInt(1); - - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return authId; - } - - /** - * add new record to the authority table - * - * @param authURI - - * the authority URI - * @param email - - * the contact e-Mail - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int insIntoAuthority(String authURI, String email) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into authority (authority_common_name,authority_uri,contact_email) values (null,?,?)"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, authURI); - ps.setString(2, email); - ret = ps.executeUpdate(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - - return ret; - } - - /** - * get the service authority Id from authority table by the authority URI - * - * @param authURI - - * the authority URI - * @return int authority Id if was found, zero otherwise. - */ - - public static int getAuthIdByAuthURI(String authURI) { - - int authId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select authority_id from authority where authority_uri = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, authURI); - - rs = ps.executeQuery(); - - while (rs.next()) { - authId = rs.getInt(1); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return authId; - - } - - /** - * get the contact e-Mail from service_instance table by the servicename - * - * @param signURL - - * the URL of a resource - * @return String contact e-Mail if was found, empty string otherwise. - */ - - public static String getContactEmail(String signURL) { - - String email = ""; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select contact_email from service_instance where signatureURL = ? "; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - String cnt = rs.getString(1); - email = cnt; - - } - - } catch (SQLException e) { - - // e.printStackTrace(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - //System.out.println("email = "+email); - return email; - - } - - /** - * - * gets the min number of records with service instance id = 0 - * - * @param table - * @param key_field - * @return the number of records - */ - - public static int getMinFreeNumber(String table, String key_field) { - - int num = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select min(" + key_field + ") from " + table - + " where service_instance_id = 0 order by " + key_field; - - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - rs = ps.executeQuery(); - - while (rs.next()) { - num = rs.getInt(1); - } - - } catch (SQLException e) { - - // e.printStackTrace(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } + /** + * get the list of signatureURL from service_instance table + * + * @return a Hashtable (signatureURL = string of servicenames for this URL + * separated by comma) + * + * + */ + + public static Hashtable getServices(String file) { + + Hashtable services = new Hashtable(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select servicename,signatureURL,authority_id from service_instance order by signatureURL"; + + PreparedStatement ps = null; + ResultSet rs = null; + + try { + ps = con.prepareStatement(sqlReq1); + rs = ps.executeQuery(); + String lastAddr = ""; + StringBuffer servNames = new StringBuffer(); + int lastID = -1; + + while (rs.next()) { + String servName = rs.getString(1); + String rdfAddr = rs.getString(2); + int authorityID = rs.getInt(3); // value will never be null, so + // wasNull() not necessary + if (rdfAddr == null) { + //TODO - make this code more efficient! - maybe perform one + // sql call instead of many + // update the signatureURL field using the service name and + // authority id + String bogusSigURL = "http://invalidURL123.com/author/" + + authorityID + "/" + servName + ".xml"; + String updateSQLString = "UPDATE service_instance " + + "SET signatureURL='" + bogusSigURL + "' " + + "WHERE authority_id=" + authorityID + + " and servicename='" + servName + "'"; + PreparedStatement preparedStatement = null; + try { + Connection updateCon = DBConnector.getConnection(); + preparedStatement = updateCon + .prepareStatement(updateSQLString); + int resultSet = preparedStatement.executeUpdate(); + Log + .info(resultSet + + ": Updated the signatureURL field of the authority with id #" + + authorityID + " to be " + bogusSigURL + + "."); + } catch (SQLException e) { + Log + .severe("Could not update SignatureURL field with a bogus signatureURL.\n" + + e.getMessage()); + } + + } else { + if (rdfAddr.equals(lastAddr)) { + servNames.append("," + servName); + } else { + if (servNames.length() > 0) { + services.put(lastAddr, servNames); + servNames = new StringBuffer(); + } + servNames.append(servName); + lastAddr = rdfAddr; + Report.doSave(file, lastAddr); + } + } + } + services.put(lastAddr, servNames); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + //System.out.println("ListOFServices : "+services); + + return services; + } + + /** + * get the list of services by signatureURL + * + * @param signURL - + * URL of resource + * @return a Hashtable (signatureURL = string of servicenames for this URL + * separated by comma) + */ + + public static Hashtable getServicesByURL(String signURL) { + + Hashtable services = new Hashtable(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select servicename,signatureURL from service_instance where signatureURL=?"; + + PreparedStatement ps = null; + ResultSet rs = null; + + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + String lastAddr = ""; + StringBuffer servNames = new StringBuffer(); + + while (rs.next()) { + String servName = rs.getString(1); + String rdfAddr = rs.getString(2); + + if (rdfAddr.equals(lastAddr)) { + servNames.append("," + servName); + } else { + if (servNames.length() > 0) { + services.put(lastAddr, servNames); + servNames = new StringBuffer(); + } + servNames.append(servName); + lastAddr = rdfAddr; + } + } + services.put(lastAddr, servNames); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + // System.out.println("ListOFServices : "+services); + + return services; + } + + /** + * This method use for the update service_instance table, + * simple_input/output table, collection_input/output table, secondary_input + * table in accordance with data from RDF file. + * + * @param servSign - + * set of the serviceSignature data (name - value, an example: + * servicename - GoTerm); Hashtable of hashtables represented by + * a pair: a name of the input = hashtable for this output + * example:{siminp1={object_type_uri=urn:lsid:biomoby.org:objectclass:Object, + * namespace_type_uris=urn:lsid:biomoby.org:namespacetype:taxon}} + * @param servInp - + * Hashtable of hashtables represented by a pair: a name of the + * output = hashtable for this output + * @param servname - + * the name of service + * @param authURI - + * the authority URI + * @param signURL - + * URL of resource + */ + + public static void processService(Hashtable servSign, Hashtable servInp, + Hashtable servOut, String servname, String authURI, String signURL) { + + Connection con = DBConnector.getConnection(); + String servName = ""; + String cat = "moby"; + String url = ""; + String email = ""; + String desc = ""; + String stype = ""; + String authuri = ""; + String authoritative = ""; + String art = null; + String col_art = null; + String obt = null; + String nst = null; + String artsec = null; + String defsec = null; + String dtsec = null; + + BigDecimal maxsec = null; + BigDecimal minsec = null; + + String enumsec = null; + int colId = 0; + Integer colOutId = null; + Integer colInpId = null; + int serv = 0; // a flag - the given service was found + int checkServ = 0; // a flag - the service exist in the database + int new_serv = 0; // the number of new services + int ret; + int servInstId = 0; + String signatureURL = "NNN"; + + // ************** Update service Signature **************** + + Enumeration num = servSign.keys(); + + while (num.hasMoreElements()) { + + Object ob = num.nextElement(); + Object val = servSign.get(ob); + if (ob.equals("category")) { + cat = val.toString(); + } else if (ob.equals("URL")) { + url = val.toString(); + } else if (ob.equals("contact_email")) { + email = val.toString(); + } else if (ob.equals("description")) { + desc = val.toString(); + } else if (ob.equals("service_type_uri")) { + stype = val.toString(); + } else if (ob.equals("authURI")) { + authuri = val.toString(); + } else if (ob.equals("authoritative")) { + authoritative = val.toString(); + + if (authoritative.equals("non-authoritative")) { + authoritative = "0"; + } else if (authoritative.equals("authoritative")) { + authoritative = "1"; + } + } else if (ob.equals("servicename")) { + servName = val.toString(); + } else if (ob.equals("signatureURL")) { + signatureURL = val.toString(); + } + + } + + ServSignature signature = getServSignature(servname, signURL); + servInstId = signature.getServInstId(); + //TODO make sure that the fields are updated + if (servInstId == 0) { + + int authId = getAuthIdByAuthURI(authuri); + + if (authId == 0) { + insIntoAuthority(authuri, email); + authId = getAuthIdByAuthURI(authuri); + } + + if (signatureURL.equals("NNN")) { + ret = createSignature(servName, cat, stype, authId, url, email, + authoritative, desc, signURL); + } else { + ret = createSignature(servName, cat, stype, authId, url, email, + authoritative, desc, signatureURL); + } + + if (ret == 1) { + String msg = "------The service instance <" + servName + + "> was registered in the MOBYCENTRAL registry "; + Report.doWrite(msg); + Report.add(msg); + + //System.out.println("mail_server = + // "+Constants.MB_MAIL_SERVER); + /* + * if (Constants.MB_MAIL_SERVER != null | + * !Constants.MB_MAIL_SERVER.equals("")) { String to = + * DataMngr.getContactEmail(signURL); + * Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // + * send message to the service provider - that service was + * deregistered } + */ + new_serv += 1; + servInstId = getServInstId(servName, authId); + } + } else { + + if (!cat.equals(signature.getCategory()) + || !url.equals(signature.getUrl()) + || !email.equals(signature.getEmail()) + || !desc.equals(signature.getDescription()) + || !stype.equals(signature.getServiceType()) + || !authoritative.equals(signature.getAuthoritative()) + || !authuri.equals(authURI)) { + + //TODO + Log.info("Updating the service '" + servName + + "' since the RDF document has been modified."); + if (signatureURL.equals("NNN")) { + Log.info("sig == NNN" + signURL); + Log + .info("=<" + + servName + + "," + + cat + + "," + + stype + + "," + + authuri + + "," + + url + + "," + + email + + "," + + desc + + "," + + authoritative + + "," + + signURL + ">"); + int res = updSign(servName, cat, stype, authuri, url, + email, desc, authoritative, signURL); + if (res == 1) { + Report.doWrite("------The service instance<" + servName + + "> was updated "); + Report.add("------The service instance <" + servName + + ">was updated "); + } else { + Report.doWrite("------The service instance<" + servName + + "> was not updated"); + Report.add("------The service instance <" + servName + + ">was not updated "); + } + + } else { + Log.info("sig != NNN"); + int res = updSign(servName, cat, stype, authuri, url, + email, desc, authoritative, signatureURL); + if (res == 1) { + Report.doWrite("------The service instance <" + + servName + "> was updated "); + Report.add("------The service instance <" + servName + + ">was updated "); + } else { + Report.doWrite("------The service instance <" + + servName + "> was not updated "); + Report.add("------The service instance <" + servName + + ">was not updated "); + } + } + } + } + + // ************ add Input ********************* + + Enumeration num1 = servInp.keys(); + int dels = 0; + int delc = 0; + int delsec = 0; + int si = 0; + int ci = 0; + int sci = 0; + + /* if there are no inputs, delete all from mobycentral */ + if (servInp.size() == 0) { + //make sure that there are no inputs in the db (simples, secondary + // or collection) + if (delRow("secondary_input", servInstId) == 1) + delsec = 1; + delCollectionMember("input", servInstId); + if (delRow("collection_input", servInstId) == 1) + delc = 1; + if (delRow("simple_input", servInstId) == 1) + dels = 1; + } + if (!servInp.containsKey("siminp1")) { + if (delRow("simple_input", servInstId) == 1) + dels = 1; + } + if (!servInp.containsKey("colinp1")) { + delCollectionMember("input", servInstId); + if (delRow("collection_input", servInstId) == 1) + delc = 1; + } + /* + * going to remove any secondaries not in the hash - quick hack to + * bug#29 + */ + if (!servInp.containsKey("secinp1")) { + if (delRow("secondary_input", servInstId) == 1) + delsec = 1; + } + while (num1.hasMoreElements()) { + Object ob = num1.nextElement(); + Object val = servInp.get(ob); + String simcol = (ob.toString()).substring(0, 6); // a hashtable name + + if (simcol.equals("secinp")) { // if it's a Secondary input + sci += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Secondary input " + sci); + Report.add("Secondary input " + sci + ":"); + if (delsec == 0) { + delRow("secondary_input", servInstId); + delsec = 1; + } + } else if (simcol.equals("colinp")) { // if it's a Collection input + ci += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Collection input " + ci); + Report.add("Collection input " + ci + ":"); + if (delc == 0) { + // colInpId = new + // Integer(getCollectionId("collection_input","collection_input_id",servInstId)); + delCollectionMember("input", servInstId); // delete from + // simple_input + // table + delRow("collection_input", servInstId); // delete from the + // collection_input + // table + delc = 1; + } + + } else { // if it's a Simple input + Report.doWrite(" "); + Report.add(" "); + si += 1; + Report.doWrite("Simple input " + si); + Report.add("Simple input " + si + ":"); + if (dels == 0) { + delRow("simple_input", servInstId); // delete from + // simple_input table + dels = 1; + } + } + Hashtable simple = new Hashtable(); + simple = (Hashtable) val; + Enumeration num11 = simple.keys(); + + while (num11.hasMoreElements()) { + Object ob1 = num11.nextElement(); + if (!ob1.equals("type")) { + Report.doWrite(ob1 + " = " + simple.get(ob1)); + Report.add(ob1 + " = " + simple.get(ob1)); + } + + if (ob1.equals("col_articleName")) { + col_art = simple.get(ob1).toString(); + if (col_art.equals(" ")) { + col_art = null; + } + } else if (ob1.equals("articleName")) { + art = simple.get(ob1).toString(); + if (art.equals(" ")) { + art = null; + } + } else if (ob1.equals("article_name")) { + artsec = simple.get(ob1).toString(); + if (artsec.equals(" ")) { + artsec = null; + } + } else if (ob1.equals("object_type_uri")) { + obt = simple.get(ob1).toString(); + } else if (ob1.equals("namespace_type_uris")) { + nst = simple.get(ob1).toString(); + } else if (ob1.equals("default")) { + defsec = simple.get(ob1).toString(); + } else if (ob1.equals("datatype")) { + dtsec = simple.get(ob1).toString(); + } else if (ob1.equals("max")) { + String maxsec_s = simple.get(ob1).toString(); + try { + maxsec = new BigDecimal(maxsec_s); + + } catch (NumberFormatException nx) { + Log.severe(nx.getMessage()); + // nx.getMessage(); + } + } else if (ob1.equals("min")) { + String minsec_s = simple.get(ob1).toString(); + try { + minsec = new BigDecimal(minsec_s); + + } catch (NumberFormatException nx) { + Log.severe(nx.getMessage()); + // nx.getMessage(); + } + } else if (ob1.equals("enum")) { + enumsec = simple.get(ob1).toString(); + } + } + + if (simcol.equals("colinp")) { + insIntoCol("collection_input", col_art, servInstId); // insert + // the row + // into + // collection_input + // table + colId = getCollectionId("collection_input", + "collection_input_id", servInstId); + insIntoSimpleInput(null, art, obt, nst, new Integer(colId)); + + art = null; + col_art = null; + obt = null; + nst = null; + } else if (simcol.equals("siminp")) { + insIntoSimpleInput(new Integer(servInstId), art, obt, nst, null); + + art = null; + obt = null; + nst = null; + } else if (simcol.equals("secinp")) { + + insIntoSecondary(servInstId, artsec, defsec, dtsec, maxsec, + minsec, enumsec); + + artsec = null; + defsec = null; + dtsec = null; + maxsec = null; + minsec = null; + enumsec = null; + } + + if (colId != 0) { + Report.doWrite("collection_input_id: " + colId); + // Log.info("collection_input_id: "+colId); + } + } + + Report.doWrite("service_instance_id: " + servInstId); + // Log.info("service_instance_id: "+servInstId); + + // *********** add Output *********************** + + Enumeration numout = servOut.keys(); + int delsout = 0; + int delcout = 0; + int so = 0; + int co = 0; + if (servOut.size() == 0) { + //make sure that there are no outputs in the db (simples or + // collection) + delCollectionMember("output", servInstId); + if (delRow("collection_output", servInstId) == 1) + delcout = 1; + if (delRow("simple_output", servInstId) == 1) + delsout = 1; + Report.doWrite("Removed all outputs."); + Log.info("Removed all outputs."); + } + if (!servOut.containsKey("colout1")) { // using simout1 because counting starts at 1 + delCollectionMember("output", servInstId); + if (delRow("collection_output", servInstId) == 1) + delcout = 1; + } + if (!servOut.containsKey("simout1")) { // using simout1 because counting starts at 1 + if (delRow("simple_output", servInstId) == 1) + delsout = 1; + } + while (numout.hasMoreElements()) { + Object ob = numout.nextElement(); + Object val = servOut.get(ob); + String simcol = (ob.toString()).substring(0, 6); + if (simcol.equals("colout")) { + co += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Collection output " + co); + Report.add("Collection output " + co + ":"); + if (delcout == 0) { + // colOutId = new + // Integer(getCollectionId("collection_output","collection_output_id",servInstId)); + delCollectionMember("output", servInstId); // delete from + // table + // simple_output + delRow("collection_output", servInstId); // delete from the + // collection_output + // table + delcout = 1; + } + } else { + so += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Simple output " + so); + Report.add("Simple output " + so + ":"); + + //TODO bug #13 here? + if (delsout == 0) { + delRow("simple_output", servInstId); // delete from + // simple_output table + delsout = 1; + } + } + Hashtable simple = new Hashtable(); + simple = (Hashtable) val; + Enumeration num11 = simple.keys(); + // Report.doWrite(""+simple); + + while (num11.hasMoreElements()) { + Object ob1 = num11.nextElement(); + if (!ob1.equals("type")) { + Report.doWrite(ob1 + " = " + simple.get(ob1)); + Report.add(ob1 + " = " + simple.get(ob1)); + } + + if (ob1.equals("col_articleName")) { + col_art = simple.get(ob1).toString(); + if (col_art.equals(" ")) { + col_art = null; + } + } + if (ob1.equals("articleName")) { + art = simple.get(ob1).toString(); + if (art.equals(" ")) { + art = null; + } + } + if (ob1.equals("object_type_uri")) { + obt = simple.get(ob1).toString(); + } + if (ob1.equals("namespace_type_uris")) { + nst = simple.get(ob1).toString(); + } + } + + if (simcol.equals("colout")) { + + insIntoCol("collection_output", col_art, servInstId); // insert + // the row + // into + // collection_input + // table + + colOutId = new Integer(getCollectionId("collection_output", + "collection_output_id", servInstId)); + insIntoSimpleOutput(null, art, obt, nst, colOutId); + art = null; + obt = null; + nst = null; + } + // TODO bug #11 here - fixed + if (simcol.equals("simout")) { + insIntoSimpleOutput(new Integer(servInstId), art, obt, nst, + null); + art = null; + obt = null; + nst = null; + } + if (colOutId != null) { + Report.doWrite("collection_output_id: " + colOutId); + // Log.info("collection_output_id: "+coloutId); + } + } + // return serv; + } + + /** + * delete the service instance by service name and authority URI + * + * @param servName + * the name of service which we want delete. + * @param authURI + * the authority URI for service which we want delete. + * + */ + + public static void delServByNameAndAuthURI(String servName, String authURI) { + + int authId = getAuthIdByAuthURI(authURI); + int servInstId = getServInstId(servName, authId); + + delSignature(servName, authId); // delete service from table + // service_instance + delRow("simple_input", servInstId); // delete from table simple_input + delRow("simple_output", servInstId); // delete from table simple_output + delRow("secondary_input", servInstId); //TODO - should this line be + // here? + delCollectionMember("input", servInstId); + delCollectionMember("output", servInstId); + delRow("collection_input", servInstId); // delete from table + // collection_input + delRow("collection_output", servInstId); // delete from table + // collection_output + } + + /** + * delete the service instance by service name and signature URL + * + * @param servName + * the name of service which we want delete. + * @param signURL + * the authority URI for service which we want delete. + * + */ + + public static void delServByNameAndUrl(String servName, String signURL) { + + int authId = getAuthIdByServNameAndSignURL(servName, signURL); + int servInstId = getServInstId(servName, authId); + + delSignature(servName, authId); // delete service from table + // service_instance + delRow("simple_input", servInstId); // delete from table simple_input + delRow("simple_output", servInstId); // delete from table simple_output + delRow("secondary_input", servInstId); //TODO - should this line be + // here? + delCollectionMember("input", servInstId); + delCollectionMember("output", servInstId); + delRow("collection_input", servInstId); // delete from table + // collection_input + delRow("collection_output", servInstId); // delete from table + // collection_output + } + + /** + * delete set of the service instances with the same signatureURL by + * signatureURL + * + * @param signURL + * the name of service which we want delete. + */ + + public static void delServiceSetByURL(String signURL) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id,servicename,authority_id from service_instance where signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + Vector del_serv = new Vector(); + + while (rs.next()) { + int servInstId = rs.getInt(1); + String servName = rs.getString(2); + int authId = rs.getInt(3); + + int rez = delSignature(servName, authId); // delete service from + // table + // service_instance + if (rez == 1) { + del_serv.addElement(servName); + } + delRow("secondary_input", servInstId); //TODO - should this + // line be here? + delRow("simple_input", servInstId); // delete from table + // simple_input + delRow("simple_output", servInstId); // delete from table + // simple_output + delCollectionMember("input", servInstId); // delete collection + // member from + // simple_input + delCollectionMember("output", servInstId); // delete collection + // member from + // simple_output + delRow("collection_input", servInstId); // delete from table + // collection_input + delRow("collection_output", servInstId); // delete from table + // collection_output + } + + int del = del_serv.size(); + if (del > 0) { + Report.doWrite("DELETED SERVICES: "); + Iterator i = del_serv.iterator(); + int n = 1; + while (i.hasNext()) { + String delServ = i.next().toString(); + Report.doWrite(n + ". " + delServ); + n += 1; + } + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } + } + + } + + /** + * add the record about new service instance in the service_instance table + * of mobycentral database + * + * @param servName - + * the name of service instance the record was added for. + * @param cat - + * the category of service instance. + * @param servTypeURI - + * the service type URI of service instance. + * @param authId - + * the authority Id of service instance. + * @param url - + * the URL of service instance. + * @param email - + * the contact e-Mail of service instance. + * @param authoritative - + * the authoritative of service instance. + * @param desc - + * the description of service instance. + * @param signURL - + * the URL for RDF of service instance. + * @return ret=1 if the record has added, and ret=-1 otherwise + */ + + public static int createSignature(String servName, String cat, + String servTypeURI, int authId, String url, String email, + String authoritative, String desc, String signURL) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into service_instance (servicename,category,service_type_uri,authority_id,url,contact_email,authoritative,description,signatureURL) values (?,?,?,?,?,?,?,?,?)"; + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setString(2, cat); + ps.setString(3, servTypeURI); + ps.setInt(4, authId); + ps.setString(5, url); + ps.setString(6, email); + ps.setString(7, authoritative); + ps.setString(8, desc); + ps.setString(9, signURL); + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * update the service instance data in the service_instance table of + * mobycentral database + * + * @param servName + * the name of service instance the record was updated for. + * @param cat + * the category of service instance. + * @param stype + * the service type URI of service instance. + * @param authuri + * the authority URI of service instance. + * @param url + * the URL of service instance. + * @param email + * the contact e-Mail of service instance. + * @param authoritative + * the authoritative of service instance. + * @param desc + * the description of service instance. + * @param signURL + * the URL for RDF of service instance. + * @return ret=1 if the record has updated, and ret=-1 otherwise + */ + + public static int updSign(String servName, String cat, String stype, + String authuri, String url, String email, String desc, + String authoritative, String signURL) { + + Connection con = DBConnector.getConnection(); + int cnt = -1; + int ret = -1; + final String sqlReq = "select authority_id from authority where authority_uri = ?"; + PreparedStatement ps = null; + + final String sqlReq1 = "update service_instance set category = ?,service_type_uri = ?,url = ?,contact_email = ?,description = ?,authoritative = ?,signatureURL = ? where servicename = ? && authority_id = ?"; + try { + ps = con.prepareStatement(sqlReq); + ps.setString(1, authuri); + ResultSet rs = ps.executeQuery(); + while (rs.next()) { + cnt = rs.getInt(1); + } + if (cnt > -1) { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, cat); + ps.setString(2, stype); + ps.setString(3, url); + ps.setString(4, email); + ps.setString(5, desc); + ps.setString(6, authoritative); + ps.setString(7, signURL); + ps.setString(8, servName); + ps.setInt(9, cnt); + ret = ps.executeUpdate(); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * add the record into the simple_input table + * + * @param servInstId + * the Id of service instance the simple input was added for. + * @param articleName + * the article name of the simple input. + * @param objTypeUri + * the object type URI of the simple input. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple input. + * @param colInpId + * the collection input Id if this simple input belongs to a + * collection, and blank otherwise. + */ + + public static void insIntoSimpleInput(Integer servInstId, + String articleName, String objTypeUri, String nsTypeUris, + Integer colInpId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into simple_input (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_input_id) values (?,?,?,?,?)"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + if (servInstId != null) { + ps.setInt(1, servInstId.intValue()); + } else { + ps.setNull(1, java.sql.Types.INTEGER); + } + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + if (colInpId != null) { + ps.setInt(5, colInpId.intValue()); + } else { + ps.setNull(5, java.sql.Types.INTEGER); + } + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + } + + /** + * update the record into the simple_input table + * + * @param servInstId + * the Id of service instance the simple input was added for. + * @param articleName + * the article name of the simple input. + * @param objTypeUri + * the object type URI of the simple input. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple input. + * @param colInpId + * the collection input Id if this simple input belongs to a + * collection, and blank otherwise. + * @return ret=1 if the record has added, and ret=-1 otherwise + */ + + public static int updateSimpleInput(int servInstId, String articleName, + String objTypeUri, String nsTypeUris, Integer colInpId, int minNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update simple_input set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_input_id=? where simple_input_id=?"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + if (colInpId != null) { + ps.setInt(5, colInpId.intValue()); + } else { + ps.setNull(5, java.sql.Types.INTEGER); + } + ps.setInt(6, minNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * add the record about secondary input in the secondary_input table of + * mobycentral database + * + * @param servInstId + * the Id of service instance the secondary input was added for. + * @param article_name + * the article name of the secondary input. + * @param def + * the default value of the secondary input. + * @param dataType + * the type of data of the secondary input. + * @param max + * the maximum value of the secondary input + * @param min + * the minimum value of the secondary input * + * @param enumeration + * the enumeration value for the secondary input + */ + + public static void insIntoSecondary(int servInstId, String article_name, + String def, String dataType, BigDecimal max, BigDecimal min, + String enumeration) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into secondary_input (service_instance_id,article_name,default_value,maximum_value,minimum_value,enum_value,datatype) values (?,?,?,?,?,?,?)"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + ps.setString(2, article_name); + ps.setString(3, def); + ps.setBigDecimal(4, max); + ps.setBigDecimal(5, min); + ps.setString(6, enumeration); + ps.setString(7, dataType); + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + } + + /** + * update the record into the secondary_input table + * + * @param servInstId + * the Id of service instance the secondary input was added for. + * @param article_name + * the article name of the secondary input. + * @param def + * the default value of the secondary input. + * @param dataType + * the type of data of the secondary input. + * @param max + * the maximum value of the secondary input + * @param min + * the minimum value of the secondary input + * @param enumeration + * the enumeration value for the secondary input + * @param minSecNum + * minimum free number for secondary_input_id + */ + + public static void updateSec(int servInstId, String article_name, + String def, String dataType, BigDecimal max, BigDecimal min, + String enumeration, int minSecNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update secondary_input set service_instance_id=?,article_name=?,default_value=?,maximum_value=?,minimum_value=?,enum_value=?,datatype=? where secondary_input_id=?"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + ps.setString(2, article_name); + ps.setString(3, def); + ps.setBigDecimal(4, max); + ps.setBigDecimal(5, min); + ps.setString(6, enumeration); + ps.setString(7, dataType); + ps.setInt(8, minSecNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } + } + } + + /** + * add the record into the simple_output table + * + * @param servInstId + * the Id of service instance the simple output was added for. + * @param articleName + * the article name of the simple output. + * @param objTypeUri + * the object type URI of the simple output. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple output. + * @param colOutId + * the collection input Id if this simple output belongs to a + * collection, and blank otherwise. + */ + + public static void insIntoSimpleOutput(Integer servInstId, + String articleName, String objTypeUri, String nsTypeUris, + Integer colOutId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into simple_output (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_output_id) values (?,?,?,?,?)"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + if (servInstId != null) { + ps.setInt(1, servInstId.intValue()); + } else { + ps.setNull(1, java.sql.Types.INTEGER); + } + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + if (colOutId != null) { + ps.setInt(5, colOutId.intValue()); + } else { + ps.setNull(5, java.sql.Types.INTEGER); + } + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + } + + /** + * update the record into the simple_output table + * + * @param servInstId + * the Id of service instance the simple output was added for. + * @param articleName + * the article name of the simple output. + * @param objTypeUri + * the object type URI of the simple output. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple output. + * @param colOutId + * the collection input Id if this simple output belongs to a + * collection, and blank otherwise. + * @return ret=1 if the record has added, and ret=-1 otherwise + */ + + public static int updateSimpleOutput(int servInstId, String articleName, + String objTypeUri, String nsTypeUris, int colOutId, int minNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update simple_output set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_output_id=? where simple_output_id=?"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setInt(1, servInstId); + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + ps.setInt(5, colOutId); + ps.setInt(6, minNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return ret; + } + + /** + * get the number of errors for the given return code and URL of resource + * + * @param signURL - + * the URL of resource was gotten the return code for. + * @param errCode - + * the error code, connection was refused + * @return Intrger number of error if was found in the database, zero + * otherwise + */ + + public static int getServErrorNum(String signURL, int errCode) { + + int num = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select counter from service_validation where signatureURL = ? and error_code = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + ps.setInt(2, errCode); + rs = ps.executeQuery(); + + while (rs.next()) { + int cnt = rs.getInt(1); + num = cnt; + + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return num; + + } + + /** + * get the service signature data for service instance by the service name + * and signatureURL + * + * @param signURL - + * the URL of service RDF + * @param servName - + * the name of service + * @return carrier class ServSignature + */ + + public static ServSignature getServSignature(String servName, String signURL) { + + ServSignature signature = new ServSignature(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id,authority_id,category,service_type_uri,url,contact_email,authoritative,description from service_instance where servicename=? and signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setString(2, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + int servInstId = rs.getInt(1); + signature.setServInstId(servInstId); + int authId = rs.getInt(2); + signature.setAuthId(authId); + String category = rs.getString(3); + signature.setCategory(category); + String serviceType = rs.getString(4); + signature.setServiceType(serviceType); + String url = rs.getString(5); + signature.setUrl(url); + String email = rs.getString(6); + signature.setEmail(email); + String authoritative = rs.getString(7); + signature.setAuthoritative(authoritative); + String description = rs.getString(8); + signature.setDescription(description); + signature.setServiceName(servName); + signature.setSignatureURL(signURL); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return signature; + + } + + /** + * get the secondary input data by the secondary input Id + * + * @param servInstId - + * the secondary input Id + * @return carrier class Secondary + */ + + public static Secondary getSecondary(int servInstId) { + + Secondary second = new Secondary(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select default_value,maximum_value,minimum_value,enum_value,datatype,article_name from secondary_input where service_instance_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + int open_sec = 0; + while (rs.next()) { + String defaultValue = rs.getString(1); + second.setDefaultValue(defaultValue); + BigDecimal maximumValue = rs.getBigDecimal(2); + second.setMaximumValue(maximumValue); + BigDecimal minimumValue = rs.getBigDecimal(3); + second.setMinimumValue(minimumValue); + String enumValue = rs.getString(4); + second.setEnumValue(enumValue); + String datatype = rs.getString(5); + second.setDatatype(datatype); + String articleName = rs.getString(6); + second.setArticleName(articleName); + + XMLBuilder.buildSecondXml(second); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return second; + + } + + /** + * get the simple/collection output data by the service instance Id and + * build xml representation + * + * @param servInstId - + * the service instance Id + */ + + public static void getSimpleCollectOutput(int servInstId) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_output_id from simple_output where service_instance_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + + while (rs.next()) { + String artName = rs.getString(1); + String nsType = rs.getString(2); + String objType = rs.getString(3); + // int colOutId = rs.getInt(4); + String type; + Integer colOutId = new Integer(rs.getInt(4)); + if (colOutId == null) { + type = "so"; + } else { + type = "co"; + } + + XMLBuilder.buildInpOutXml(artName, nsType, objType, type); + } + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + } + + /** + * get the simple/collection input data by the service instance Id and build + * xml representation + * + * @param servInstId - + * the service instance Id + */ + + public static void getSimpleCollectInput(int servInstId) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_input_id from simple_input where service_instance_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + + while (rs.next()) { + String artName = rs.getString(1); + String nsType = rs.getString(2); + String objType = rs.getString(3); + String type; + // int colInpId = rs.getInt(4); + Integer colInpId = new Integer(rs.getInt(4)); + if (colInpId == null) { + type = "si"; + } else { + type = "ci"; + } + + XMLBuilder.buildInpOutXml(artName, nsType, objType, type); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + } + + /** + * update the counter for the given return code and URL of resource + * + * @param signURL - + * the URL of resource was updated the counter for. + * @param errCode - + * the error code was encreased the counter for. + * @return Intrger ret=1 if the record was updated, ret=-1 otherwise + */ + + public static int updErrCount(String signURL, int errCode) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update service_validation set error_code = ?,counter=counter+1 where signatureURL = ?"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setInt(1, errCode); + ps.setString(2, signURL); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return ret; + } + + /** + * add new record to the service_validation table of the mobycentral + * database + * + * @param signURL - + * the URL of resource the connection was refused for. + * @param errCode - + * the error code, connection was refused + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int insErrCount(String signURL, int errCode) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into service_validation (signatureURL,error_code,counter) values (?,?,1)"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, signURL); + ps.setInt(2, errCode); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return ret; + } + + /** + * delete the record from service_validation table by signatureURL + * + * @param signURL - + * the URL of resource the record was deleted for. + * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. + */ + + public static int delServErrors(String signURL) { + + Connection con = DBConnector.getConnection(); + int ret = -1; + final String sqlReq1 = "delete from service_validation where signatureURL = ?"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.warning(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + + } + + /** + * get the service instance Id for the given service name and authority Id + * + * @param servName - + * the name of service instance . + * @param authId - + * the authority Id for the service instance. + * @return Intrger service instance Id if was found in the database, zero + * otherwise + */ + + public static int getServInstId(String servName, int authId) { + + int servInsId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && authority_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setInt(2, authId); + rs = ps.executeQuery(); + + while (rs.next()) { + servInsId = rs.getInt(1); + + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return servInsId; + } + + /** + * get the service instance Id for the given service name and signatureURL + * + * @param servName - + * the name of service instance . + * @param signURL - + * URL of resource for the service instance. + * @return Intrger service instance Id if was found in the database, zero + * otherwise + */ + + public static int getServInstId(String servName, String signURL) { + + int servInsId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setString(2, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + servInsId = rs.getInt(1); + + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return servInsId; + } + + /** + * get the set of services for the given URL of resource by signatureURL + * + * @param signURL - + * the URL of resource . + * @return String set of the services which was found in the database, empty + * string otherwise + */ + + public static String getServListByURL(String signURL) { + + StringBuffer servList = new StringBuffer(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select servicename from service_instance where signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + String servName = rs.getString(1); + servList.append(servName + ","); + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return servList.toString(); + } + + /** + * delete a record from given table by a service instance Id (the metod is + * working for simple_input/output, collection input/output tables) + * + * @param servInstId - + * the service instance Id. + * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. + */ + + public static int delRow(String tableName, int servInstId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "delete from " + tableName + + " where service_instance_id = ?"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setInt(1, servInstId); + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + return ret; + } + + /** + * delete a record from simple table by a service instance Id and + * collection_input_id (the metod is working for simple_input/output, + * collection input/output tables) + * + * @param servInstId - + * the service instance Id. + */ + + public static void delCollectionMember(String inout, int servInstId) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1; + //System.out.println("inout = "+inout); + if (inout.equals("input")) { + sqlReq1 = "select collection_input_id from collection_input where service_instance_id = ? "; + } else { + sqlReq1 = "select collection_output_id from collection_output where service_instance_id = ? "; + } + //System.out.println("sqlReq1 = "+sqlReq1); + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + while (rs.next()) { + int colId = rs.getInt(1); + //System.out.println("colId = "+colId); + final String sqlReq; + if (inout.equals("input")) { + sqlReq = "delete from simple_input where collection_input_id=" + + colId; + //System.out.println("sqlReq = "+sqlReq); + } else { + sqlReq = "delete from simple_output where collection_output_id=" + + colId; + } + PreparedStatement ps1 = null; + + try { + ps1 = con.prepareStatement(sqlReq); + // ps.setInt(1, servInstId); + ps1.executeUpdate(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } finally { + try { + if (ps1 != null) + ps1.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } + } + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } + } + + } + + /** + * delete a record from service_instance table by a servicename and + * authority Id + * + * @param servName - + * the service instance name. + * @param authId - + * the id of the authority + * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. + */ + + public static int delSignature(String servName, int authId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + // if (authId == 0){ + final String sqlReq1 = "delete from service_instance where servicename= ? and authority_id = ?"; + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setInt(2, authId); + ret = ps.executeUpdate(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * get the collection Id from collection_input or collection_output table by + * the service_instance_id + * + * @param table - + * the collection_input or collection_output table + * @param field - + * "collection_input_id" (for collection_input table) and + * "collection_output_id" (for collection_output table) + * @param servInstId - + * Id of service instance + * @return Integer collection Id if was found, zero otherwise. + */ + + public static int getCollectionId(String table, String field, int servInstId) { + + int colId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select " + + field + + " from " + + table + + " where service_instance_id = ? order by service_instance_id," + + field + " ASC"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + + while (rs.next()) { + colId = rs.getInt(1); + + } + + } catch (SQLException e) { + + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return colId; + + } + + /** + * add new record into the collection_input or collection_output table + * + * @param table - + * the collection_input or collection_output table + * @param artName - + * the artical name of the collection_input or collection_output + * @param servInstId - + * Id of service instance + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int insIntoCol(String table, String artName, int servInstId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into " + table + + " (article_name,service_instance_id) values (?,?)"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, artName); + ps.setInt(2, servInstId); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * update record into the collection_input or collection_output table + * + * @param table - + * the collection_input or collection_output table + * @param key_field - + * collection_input_id for collection_input table, + * collection_output_id for collection_output table; + * @param artName - + * the artical name of the collection_input or collection_output + * @param servInstId - + * Id of service instance + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int updateCol(String table, String key_field, String artName, + int servInstId, int minNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update " + table + + " set article_name=?,service_instance_id=? where " + + key_field + " =?"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, artName); + ps.setInt(2, servInstId); + ps.setInt(3, minNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * get the service authority URI from authority table by the servicename + * + * @param servName - + * the name of service + * @return String authority URI if was found, empty string otherwise. + */ + + public static String getServAuthURI(String servName) { + + Connection con = DBConnector.getConnection(); + + String authURI = ""; + + final String sqlReq1 = "select authority_uri from service_instance si,authority a where si.authority_id=a.authority_id and si.servicename=?"; + ; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + rs = ps.executeQuery(); + + while (rs.next()) { + authURI = rs.getString(1); + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return authURI; + + } + + /** + * get the service authority Id from service_instance table by the + * servicename and signatureURL + * + * @param serviceName - + * the name of service + * @param signURL - + * the signatureURL for the given service + * @return int authority Id if was found, zero otherwise. + */ + + public static int getAuthIdByServNameAndSignURL(String serviceName, + String signURL) { + + int authId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select authority_id from service_instance where servicename = ? and signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, serviceName); + ps.setString(2, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + authId = rs.getInt(1); + + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return authId; + } + + /** + * add new record to the authority table + * + * @param authURI - + * the authority URI + * @param email - + * the contact e-Mail + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int insIntoAuthority(String authURI, String email) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into authority (authority_common_name,authority_uri,contact_email) values (null,?,?)"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, authURI); + ps.setString(2, email); + ret = ps.executeUpdate(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + + return ret; + } + + /** + * get the service authority Id from authority table by the authority URI + * + * @param authURI - + * the authority URI + * @return int authority Id if was found, zero otherwise. + */ + + public static int getAuthIdByAuthURI(String authURI) { + + int authId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select authority_id from authority where authority_uri = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, authURI); + + rs = ps.executeQuery(); + + while (rs.next()) { + authId = rs.getInt(1); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return authId; + + } + + /** + * get the contact e-Mail from service_instance table by the servicename + * + * @param signURL - + * the URL of a resource + * @return String contact e-Mail if was found, empty string otherwise. + */ + + public static String getContactEmail(String signURL) { + + String email = ""; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select contact_email from service_instance where signatureURL = ? "; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + String cnt = rs.getString(1); + email = cnt; + + } + + } catch (SQLException e) { + + // e.printStackTrace(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + //System.out.println("email = "+email); + return email; + + } + + /** + * + * gets the min number of records with service instance id = 0 + * + * @param table + * @param key_field + * @return the number of records + */ + + public static int getMinFreeNumber(String table, String key_field) { + + int num = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select min(" + key_field + ") from " + table + + " where service_instance_id = 0 order by " + key_field; + + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + rs = ps.executeQuery(); + + while (rs.next()) { + num = rs.getInt(1); + } + + } catch (SQLException e) { + + // e.printStackTrace(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } - } + } - return num; + return num; - } + } } From kawas at pub.open-bio.org Sat Jul 2 10:12:50 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Sat, 2 Jul 2005 10:12:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507021412.j62ECol4022638@pub.open-bio.org> kawas Sat Jul 2 10:12:49 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory pub.open-bio.org:/tmp/cvs-serv22613/org/biomoby/client Modified Files: CentralImpl.java Log Message: Changed the default endpoint to point to the new mobycentral registry. Eddie moby-live/Java/src/main/org/biomoby/client CentralImpl.java,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2005/04/07 16:37:02 1.20 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2005/07/02 14:12:49 1.21 @@ -88,10 +88,10 @@ /** Default location (endpoint) of a Moby registry. */ // public static final String DEFAULT_ENDPOINT = "http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY-Central.pl"; - public static final String DEFAULT_ENDPOINT = "http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY05/mobycentral.pl"; + public static final String DEFAULT_ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; /** Default namespace used by the contacted Moby registry. */ - public static final String DEFAULT_NAMESPACE = "http://mobycentral.cbr.nrc.ca/MOBY/Central"; + public static final String DEFAULT_NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; /************************************************************************* * Default constructor. It connects to a default Moby registry From mwilkinson at pub.open-bio.org Mon Jul 4 13:52:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 4 Jul 2005 13:52:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041752.j64HqIIr006715@pub.open-bio.org> mwilkinson Mon Jul 4 13:52:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv6677/Perl/MOBY Modified Files: Central.pm Log Message: preparing for an interim release while we wait for the lsid resolution code to be fixed by IBM moby-live/Perl/MOBY Central.pm,1.153,1.154 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.153 retrieving revision 1.154 diff -u -r1.153 -r1.154 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/05/31 15:09:25 1.153 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/04 17:52:18 1.154 @@ -1419,7 +1419,8 @@ #service_instance => $service_instance ); # my $RDF_XML = $RDF_MODEL->serialize; my $LSID = $service_instance->LSID; - my $RDF = _getServiceInstanceRDF($LSID); + # my $RDF = _getServiceInstanceRDF($LSID); +my $RDF=""; unless ($RDF){return &_success("Registration successful but LSID resolution error",$SVC->service_instance_id,"" )} unless ($RDF =~ /RDF/){ return &_success("Registration successful but LSID resolution error $RDF",$SVC->service_instance_id,"") @@ -1435,10 +1436,10 @@ my $RDF_XML = ""; my $lsid_error = ""; my $lsid_good = 1; - use LS::ID; - use LS::Authority::WSDL::Constants; - use LS::Client::BasicResolver; - use LS::Locator; + #use LS::ID; + #use LS::Authority::WSDL::Constants; + #use LS::Client::BasicResolver; + #use LS::Locator; my $resolver = LS::Client::BasicResolver->new(); my $authority = $resolver->resolve( lsid => $lsid ); From mwilkinson at pub.open-bio.org Mon Jul 4 13:52:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 4 Jul 2005 13:52:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041752.j64HqIv2006696@pub.open-bio.org> mwilkinson Mon Jul 4 13:52:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl In directory pub.open-bio.org:/tmp/cvs-serv6677/Perl Modified Files: Makefile.PL Log Message: preparing for an interim release while we wait for the lsid resolution code to be fixed by IBM moby-live/Perl Makefile.PL,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/Makefile.PL,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/Makefile.PL 2005/05/31 00:06:48 1.8 +++ /home/repository/moby/moby-live/Perl/Makefile.PL 2005/07/04 17:52:18 1.9 @@ -80,7 +80,7 @@ 'Text::Shellwords' => 1.00, 'SOAP::MIME' => 0.55, 'XML::XPath' => 1.12, - 'LS::ID' => 1.1.1, + # 'LS::ID' => 1.1.1, }, # e.g., Module::Name => 1.1 #'PM_FILTER' => "", ($] >= 5.005 ? ## Add these new keywords supported since 5.005 From mwilkinson at pub.open-bio.org Mon Jul 4 13:52:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 4 Jul 2005 13:52:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041752.j64HqI48006735@pub.open-bio.org> mwilkinson Mon Jul 4 13:52:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv6677/Perl/t Modified Files: Client-Central.t Log Message: preparing for an interim release while we wait for the lsid resolution code to be fixed by IBM moby-live/Perl/t Client-Central.t,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2004/08/18 23:06:03 1.6 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/04 17:52:18 1.7 @@ -13,8 +13,8 @@ # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl', - URI => 'http://mobycentral.cbr.nrc.ca:8080/MOBY/Central'} + mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} } ); From mwilkinson at pub.open-bio.org Mon Jul 4 14:11:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 4 Jul 2005 14:11:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041811.j64IBb6n006842@pub.open-bio.org> mwilkinson Mon Jul 4 14:11:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv6823/MOBY/Client Modified Files: OntologyServer.pm Log Message: point to new MOBY Central moby-live/Perl/MOBY/Client OntologyServer.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2004/12/14 20:47:04 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2005/07/04 18:11:37 1.11 @@ -84,7 +84,7 @@ my %_attr_data = # DEFAULT ACCESSIBILITY ( host => [ - "http://mobycentral.cbr.nrc.ca/cgi-bin/OntologyServer.cgi", + "http://mobycentral.capture.ubc.ca/cgi-bin/OntologyServer.cgi", 'read/write' ], proxy => [ undef, 'read/write' ], From mwilkinson at pub.open-bio.org Wed Jul 6 11:23:08 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 6 Jul 2005 11:23:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507061523.j66FN8Fv015701@pub.open-bio.org> mwilkinson Wed Jul 6 11:23:08 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv15682/MOBY/Client Modified Files: OntologyServer.pm Log Message: Doh... typo in my new domain name moby-live/Perl/MOBY/Client OntologyServer.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2005/07/04 18:11:37 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2005/07/06 15:23:07 1.12 @@ -84,7 +84,7 @@ my %_attr_data = # DEFAULT ACCESSIBILITY ( host => [ - "http://mobycentral.capture.ubc.ca/cgi-bin/OntologyServer.cgi", + "http://mobycentral.icapture.ubc.ca/cgi-bin/OntologyServer.cgi", 'read/write' ], proxy => [ undef, 'read/write' ], From mwilkinson at pub.open-bio.org Wed Jul 6 11:32:53 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 6 Jul 2005 11:32:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507061532.j66FWr7K015751@pub.open-bio.org> mwilkinson Wed Jul 6 11:32:53 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv15732 Modified Files: Central.pm Log Message: documentation for registration of secondary parameters was incorrect. It is an enum of String, Integer, Float, DateTime... not STRING, INT, FLOAT moby-live/Perl/MOBY Central.pm,1.155,1.156 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.155 retrieving revision 1.156 diff -u -r1.155 -r1.156 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/06 14:42:02 1.155 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/06 15:32:52 1.156 @@ -1201,7 +1201,7 @@ - INT|FLOAT|STRING + Integer|Float|String|DateTime ... ... ... From mwilkinson at pub.open-bio.org Wed Jul 6 12:46:41 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 6 Jul 2005 12:46:41 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507061646.j66GkfAQ015996@pub.open-bio.org> mwilkinson Wed Jul 6 12:46:41 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv15977 Modified Files: Config.pm Log Message: adding secondary datatypes to the config module moby-live/Perl/MOBY Config.pm,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Config.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/Config.pm 2004/11/18 17:41:14 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/Config.pm 2005/07/06 16:46:41 1.7 @@ -22,6 +22,8 @@ mobynamespace => [ undef, 'read/write' ], mobyservice => [ undef, 'read/write' ], mobyrelationship => [ undef, 'read/write' ], + valid_secondary_datatypes => [["String", "Integer", "DateTime", "Float"], 'read'], + ); #_____________________________________________________________ From mwilkinson at pub.open-bio.org Fri Jul 8 14:41:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 8 Jul 2005 14:41:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081841.j68IfAcx024586@pub.open-bio.org> mwilkinson Fri Jul 8 14:41:09 EDT 2005 Update of /home/repository/moby/moby-live/Perl/scripts In directory pub.open-bio.org:/tmp/cvs-serv24567/Perl/scripts Modified Files: testMOBYClientCentral_v05.pl Log Message: test script points to new, unfortunately production, registry moby-live/Perl/scripts testMOBYClientCentral_v05.pl,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/scripts/testMOBYClientCentral_v05.pl,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/scripts/testMOBYClientCentral_v05.pl 2004/08/11 16:30:57 1.24 +++ /home/repository/moby/moby-live/Perl/scripts/testMOBYClientCentral_v05.pl 2005/07/08 18:41:09 1.25 @@ -24,8 +24,8 @@ } } -my $URL = $ENV{MOBY_SERVER}?$ENV{MOBY_SERVER}:'http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl'; -my $URI = $ENV{MOBY_URI}?$ENV{MOBY_URI}:'http://mobycentral.cbr.nrc.ca:8080/MOBY/Central'; +my $URL = $ENV{MOBY_SERVER}?$ENV{MOBY_SERVER}:'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl'; +my $URI = $ENV{MOBY_URI}?$ENV{MOBY_URI}:'http://mobycentral.icapture.ubc.ca/MOBY/Central'; my $PROXY = $ENV{MOBY_PROXY}?$ENV{MOBY_PROXY}:'No Proxy Server'; my $C = MOBY::Client::Central->new( From kawas at pub.open-bio.org Fri Jul 8 14:57:00 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Fri, 8 Jul 2005 14:57:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081857.j68Iv0SB024748@pub.open-bio.org> kawas Fri Jul 8 14:57:00 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv24723 Modified Files: Central.pm Log Message: Implemented the check for valid secondary input types. moby-live/Perl/MOBY Central.pm,1.156,1.157 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.156 retrieving revision 1.157 diff -u -r1.156 -r1.157 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/06 15:32:52 1.156 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/08 18:57:00 1.157 @@ -185,6 +185,7 @@ + =head1 METHODS @@ -1409,33 +1410,40 @@ ); } - use MOBY::Client::Central; - my $services = MOBY::Client::Central::_parseServices( '', '', $si ); - my $service_instance = shift @{$services}; - # my $storage = new RDF::Core::Storage::Memory; - # my $model = new RDF::Core::Model( Storage => $storage ); - # my $RDF_MODEL = MOBY::RDF::ServiceInstanceRDF->new( - #model => $model, - #service_instance => $service_instance ); - # my $RDF_XML = $RDF_MODEL->serialize; - my $LSID = $service_instance->LSID; + use MOBY::Client::Central; + my $services = MOBY::Client::Central::_parseServices( '', '', $si ); + my $service_instance = shift @{$services}; + + # my $storage = new RDF::Core::Storage::Memory; + # my $model = new RDF::Core::Model( Storage => $storage ); + # my $RDF_MODEL = MOBY::RDF::ServiceInstanceRDF->new( + #model => $model, + #service_instance => $service_instance ); + # my $RDF_XML = $RDF_MODEL->serialize; + my $LSID = $service_instance->LSID; + # my $RDF = _getServiceInstanceRDF($LSID); -my $RDF=""; - unless ($RDF){return &_success("Registration successful but LSID resolution error",$SVC->service_instance_id,"" )} - unless ($RDF =~ /RDF/){ - return &_success("Registration successful but LSID resolution error $RDF",$SVC->service_instance_id,"") + my $RDF = ""; + unless ($RDF) { + return &_success( "Registration successful but LSID resolution error", + $SVC->service_instance_id, "" ); + } + unless ( $RDF =~ /RDF/ ) { + return &_success( + "Registration successful but LSID resolution error $RDF", + $SVC->service_instance_id, "" ); } - return &_success( "Registration successful", - $SVC->service_instance_id, $RDF ); + return &_success( "Registration successful", $SVC->service_instance_id, + $RDF ); } - sub _getServiceInstanceRDF { - my ($self, $LSID) = @_; + my ( $self, $LSID ) = @_; my $lsid = LS::ID->new($LSID); my $RDF_XML = ""; my $lsid_error = ""; - my $lsid_good = 1; + my $lsid_good = 1; + #use LS::ID; #use LS::Authority::WSDL::Constants; #use LS::Client::BasicResolver; @@ -1451,13 +1459,14 @@ $authority->clean_cache(); my $resource = $authority->getResource($lsid); - unless ($resource) { - $lsid_error .= $authority->error_string. " " ; - return $lsid_error + unless ($resource) { + $lsid_error .= $authority->error_string . " "; + return $lsid_error; } - + my $response = $resource->get_metadata; unless ( ref($response) =~ /LS::Service::Response/ ) { + #TODO raise an error $lsid_error .= "Metadata response didn't come back"; return $lsid_error; @@ -1471,7 +1480,7 @@ } while (<$rsp>) { $RDF_XML .= $_; - } + } return $RDF_XML } @@ -1614,6 +1623,19 @@ ( $_->nodeType == TEXT_NODE ) && ( $datatype .= $_->nodeValue ); } } + + #ensure that thet type is correct (Integer | String | Float | DateTime) + $datatype =~ s/\s//g; + my $secondaries = $CONFIG->{valid_secondary_datatypes}; + my $valid; + map { $valid = 1 if $datatype eq $_ } @{$secondaries}; + unless ($valid) { + $SVC->DELETE_THYSELF; + return ( -1, +"Registration failed. $datatype must be one of type Integer, String, DateTime, or Float." + ); + } + my $defs = $parameter->getElementsByTagName('default'); if ( $defs->get_node(1) ) { foreach ( $defs->get_node(1)->childNodes ) @@ -2998,20 +3020,26 @@ =cut sub DUMP_MySQL { - my ( $pkg ) = @_; - my $config = MOBY::Config->new(); - my @dbsections = ('mobycentral', 'mobyobject', 'mobyservice', 'mobynamespace', 'mobyrelationship'); + my ($pkg) = @_; + my $config = MOBY::Config->new(); + my @dbsections = ( + 'mobycentral', 'mobyobject', + 'mobyservice', 'mobynamespace', + 'mobyrelationship' + ); my @response; - foreach my $dbsection (@dbsections) { - my $dbname = ${${$config}{$dbsection}}{'dbname'}; - my $username = ${${$config}{$dbsection}}{'username'}; - my $password = ${${$config}{$dbsection}}{'password'}; - my $host = ${${$config}{$dbsection}}{'url'}; - my $port = ${${$config}{$dbsection}}{'port'}; - open( IN, "mysqldump -h $host -P $port -u $username --password=$password $dbname|" ) - || die "can't open $dbname for dumping"; + foreach my $dbsection (@dbsections) { + my $dbname = ${ ${$config}{$dbsection} }{'dbname'}; + my $username = ${ ${$config}{$dbsection} }{'username'}; + my $password = ${ ${$config}{$dbsection} }{'password'}; + my $host = ${ ${$config}{$dbsection} }{'url'}; + my $port = ${ ${$config}{$dbsection} }{'port'}; + open( IN, +"mysqldump -h $host -P $port -u $username --password=$password $dbname|" + ) + || die "can't open $dbname for dumping"; my @dbdump; - while ( ) { + while () { push @dbdump, $_; } my $dbdump = ( join "", @dbdump ); @@ -3067,6 +3095,7 @@ + =head1 Internal Object Methods From mwilkinson at pub.open-bio.org Fri Jul 8 15:03:17 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 8 Jul 2005 15:03:17 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081903.j68J3Hs2024881@pub.open-bio.org> mwilkinson Fri Jul 8 15:03:17 EDT 2005 Update of /home/repository/moby/moby-live/Database In directory pub.open-bio.org:/tmp/cvs-serv24842 Modified Files: mobycentral.mysql mobynamespace.mysql mobyobject.mysql mobyrelationship.mysql mobyservice.mysql reset Added Files: README mobyobject.data mobyservice.data Log Message: all files needed to create a new bootstrapped MOBY Central database moby-live/Database README,NONE,1.1 mobyobject.data,NONE,1.1 mobyservice.data,NONE,1.1 mobycentral.mysql,1.4,1.5 mobynamespace.mysql,1.5,1.6 mobyobject.mysql,1.8,1.9 mobyrelationship.mysql,1.4,1.5 mobyservice.mysql,1.6,1.7 reset,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobycentral.mysql,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Database/mobycentral.mysql 2004/09/14 21:32:35 1.4 +++ /home/repository/moby/moby-live/Database/mobycentral.mysql 2005/07/08 19:03:17 1.5 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobycentral --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'authority' +-- Table structure for table `authority` -- CREATE TABLE authority ( @@ -14,16 +14,10 @@ contact_email varchar(255) NOT NULL default '', authority_id int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (authority_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'authority' --- - - - --- --- Table structure for table 'collection_input' +-- Table structure for table `collection_input` -- CREATE TABLE collection_input ( @@ -31,16 +25,10 @@ article_name varchar(255) default NULL, service_instance_id int(10) unsigned NOT NULL default '0', PRIMARY KEY (collection_input_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'collection_input' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Table structure for table 'collection_output' +-- Table structure for table `collection_output` -- CREATE TABLE collection_output ( @@ -48,42 +36,30 @@ article_name varchar(255) default NULL, service_instance_id int(10) unsigned NOT NULL default '0', PRIMARY KEY (collection_output_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'collection_output' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Table structure for table 'secondary_input' +-- Table structure for table `secondary_input` -- CREATE TABLE secondary_input ( secondary_input_id int(10) unsigned NOT NULL auto_increment, default_value text, - maximum_value decimal(10,0) default NULL, - minimum_value decimal(10,0) default NULL, + maximum_value float default NULL, + minimum_value float default NULL, enum_value text, - datatype enum('INT','FLOAT','STRING') NOT NULL default 'INT', + datatype enum('String','Integer','DateTime','Float') default NULL, article_name varchar(255) default NULL, service_instance_id int(10) unsigned NOT NULL default '0', PRIMARY KEY (secondary_input_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'secondary_input' --- - - - --- --- Table structure for table 'service_instance' +-- Table structure for table `service_instance` -- CREATE TABLE service_instance ( - category enum('moby','cgi','soap') NOT NULL default 'moby', + category enum('moby','soap','wsdl','cgi') default NULL, servicename varchar(255) NOT NULL default '', service_type_uri varchar(255) NOT NULL default '', authority_id int(10) unsigned NOT NULL default '0', @@ -92,19 +68,25 @@ authoritative enum('1','0') NOT NULL default '0', description text NOT NULL, service_instance_id int(10) unsigned NOT NULL auto_increment, - signatureURL varchar(255), + signatureURL varchar(255) default NULL, + lsid varchar(255) NOT NULL default '', PRIMARY KEY (service_instance_id), UNIQUE KEY servicename (servicename,authority_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'service_instance' +-- Table structure for table `service_validation` -- - +CREATE TABLE service_validation ( + signatureURL varchar(255) NOT NULL default '', + error_code int(4) NOT NULL default '0', + counter int(1) NOT NULL default '0', + PRIMARY KEY (signatureURL) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Table structure for table 'simple_input' +-- Table structure for table `simple_input` -- CREATE TABLE simple_input ( @@ -115,16 +97,10 @@ service_instance_id int(10) unsigned default NULL, collection_input_id int(10) unsigned default NULL, PRIMARY KEY (simple_input_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'simple_input' --- - - - --- --- Table structure for table 'simple_output' +-- Table structure for table `simple_output` -- CREATE TABLE simple_output ( @@ -135,11 +111,5 @@ service_instance_id int(10) unsigned default NULL, collection_output_id int(10) unsigned default NULL, PRIMARY KEY (simple_output_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'simple_output' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobynamespace.mysql,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Database/mobynamespace.mysql 2003/05/24 20:22:15 1.5 +++ /home/repository/moby/moby-live/Database/mobynamespace.mysql 2005/07/08 19:03:17 1.6 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobynamespace --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'namespace' +-- Table structure for table `namespace` -- CREATE TABLE namespace ( @@ -15,18 +15,20 @@ description text NOT NULL, authority varchar(255) NOT NULL default '', contact_email varchar(255) NOT NULL default '', + object text, + generic_url tinytext, + synonym text, + url_syntax text, + url_example text, + shorthand_name varchar(255) default NULL, + example_id varchar(255) default NULL, + note mediumtext, PRIMARY KEY (namespace_id), UNIQUE KEY namespace_type (namespace_type) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'namespace' --- - - - --- --- Table structure for table 'namespace_term2term' +-- Table structure for table `namespace_term2term` -- CREATE TABLE namespace_term2term ( @@ -35,11 +37,5 @@ namespace1_id int(11) NOT NULL default '0', namespace2_id int(11) NOT NULL default '0', PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'namespace_term2term' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobyobject.mysql,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Database/mobyobject.mysql 2003/06/10 23:01:26 1.8 +++ /home/repository/moby/moby-live/Database/mobyobject.mysql 2005/07/08 19:03:17 1.9 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobyobject --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'object' +-- Table structure for table `object` -- CREATE TABLE object ( @@ -17,21 +17,10 @@ contact_email varchar(255) NOT NULL default '', PRIMARY KEY (object_id), UNIQUE KEY object_type (object_type) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'object' --- - - -INSERT INTO object VALUES (1,'urn:lsid:biomoby.org:objectclass:object','Object','an object','openinformatics.com','jason at openinformatics.com'); -INSERT INTO object VALUES (2,'urn:lsid:biomoby.org:objectclass:integer','Integer','an int','openinformatics.com','jason at openinformatics.com'); -INSERT INTO object VALUES (3,'urn:lsid:biomoby.org:objectclass:string','String','a string','openinformatics.com','jason at openinformatics.com'); -INSERT INTO object VALUES (4,'urn:lsid:biomoby.org:objectclass:float','Float','a floating point number','openinformatics.com','jason at openinformatics.com'); -INSERT INTO object VALUES (5,'urn:lsid:biomoby.org:objectclass:datetime','DateTime','a date or time in ISO-8601 format','openinformatics.com','jason at openinformatics.com'); - --- --- Table structure for table 'object_term2term' +-- Table structure for table `object_term2term` -- CREATE TABLE object_term2term ( @@ -41,14 +30,5 @@ object2_id int(11) NOT NULL default '0', object2_articlename varchar(255) default NULL, PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'object_term2term' --- - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -INSERT INTO object_term2term VALUES (1,'urn:lsid:biomoby.org:objectrelation:isa',2,1,NULL); -INSERT INTO object_term2term VALUES (2,'urn:lsid:biomoby.org:objectrelation:isa',3,1,NULL); -INSERT INTO object_term2term VALUES (3,'urn:lsid:biomoby.org:objectrelation:isa',4,1,NULL); -INSERT INTO object_term2term VALUES (4,'urn:lsid:biomoby.org:objectrelation:isa',5,3,NULL); =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobyrelationship.mysql,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Database/mobyrelationship.mysql 2003/05/24 20:26:07 1.4 +++ /home/repository/moby/moby-live/Database/mobyrelationship.mysql 2005/07/08 19:03:17 1.5 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobyrelationship --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'relationship' +-- Table structure for table `relationship` -- CREATE TABLE relationship ( @@ -19,20 +19,10 @@ ontology varchar(200) NOT NULL default '', PRIMARY KEY (relationship_id), UNIQUE KEY LSID (relationship_lsid) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'relationship' --- - - -INSERT INTO relationship VALUES (1,'urn:lsid:biomoby.org:objectrelation:hasa','hasa','1','Describes a container relationship where the predicate object is contained within the subject object in one copy only','www.biomoby.org','markw at illuminae.com','object'); -INSERT INTO relationship VALUES (2,'urn:lsid:biomoby.org:objectrelation:has','has','1','Describes a container relationship where the predicate object is contained within the subject object in one or more copies','www.biomoby.org','markw at illuminae.com','object'); -INSERT INTO relationship VALUES (3,'urn:lsid:biomoby.org:objectrelation:isa','isa','0','Describes an inheritence relationship where all attributes of the parent must be in the child','www.biomoby.org','markw at illuminae.com','object'); -INSERT INTO relationship VALUES (4,'urn:lsid:biomoby.org:servicerelation:isa','isa','0','Describes an inheritence relationship where the predicate service performs a more specific operation compared to the subject service','www.biomoby.org','markw at illuminae.com','service'); - --- --- Table structure for table 'relationship_term2term' +-- Table structure for table `relationship_term2term` -- CREATE TABLE relationship_term2term ( @@ -42,9 +32,5 @@ relationship2_id int(10) unsigned NOT NULL default '0', object2_articlename varchar(255) default NULL, PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'relationship_term2term' --- +) ENGINE=MyISAM DEFAULT CHARSET=latin1; =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobyservice.mysql,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Database/mobyservice.mysql 2003/06/10 23:01:26 1.6 +++ /home/repository/moby/moby-live/Database/mobyservice.mysql 2005/07/08 19:03:17 1.7 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobyservice --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'service' +-- Table structure for table `service` -- CREATE TABLE service ( @@ -17,22 +17,10 @@ contact_email varchar(255) NOT NULL default '', PRIMARY KEY (service_id), UNIQUE KEY service_type (service_type) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'service' --- - - -INSERT INTO service VALUES (1,'urn:lsid:biomoby.org:servicetype:service','Service','The base type','openinformatics.com','email'); -INSERT INTO service VALUES (2,'urn:lsid:biomoby.org:servicetype:retrieval','Retrieval','The base retrieval type','openinformatics.com','email'); -INSERT INTO service VALUES (3,'urn:lsid:biomoby.org:servicetype:resolution','Resolution','resolve data','openinformatics.com','email'); -INSERT INTO service VALUES (4,'urn:lsid:biomoby.org:servicetype:parsing','Parsing','parse data','openinformatics.com','email'); -INSERT INTO service VALUES (5,'urn:lsid:biomoby.org:servicetype:registration','Registration','register data','openinformatics.com','email'); -INSERT INTO service VALUES (6,'urn:lsid:biomoby.org:servicetype:analysis','Analysis','analyze data','openinformatics.com','email'); - --- --- Table structure for table 'service_term2term' +-- Table structure for table `service_term2term` -- CREATE TABLE service_term2term ( @@ -41,15 +29,5 @@ service1_id int(11) NOT NULL default '0', service2_id int(11) NOT NULL default '0', PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'service_term2term' --- - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -INSERT INTO service_term2term VALUES (8,'urn:lsid:biomoby.org:servicerelation:isa',2,1); -INSERT INTO service_term2term VALUES (4,'urn:lsid:biomoby.org:servicerelation:isa',3,1); -INSERT INTO service_term2term VALUES (5,'urn:lsid:biomoby.org:servicerelation:isa',4,1); -INSERT INTO service_term2term VALUES (6,'urn:lsid:biomoby.org:servicerelation:isa',5,1); -INSERT INTO service_term2term VALUES (7,'urn:lsid:biomoby.org:servicerelation:isa',6,1); =================================================================== RCS file: /home/repository/moby/moby-live/Database/reset,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Database/reset 2003/05/24 20:41:44 1.1 +++ /home/repository/moby/moby-live/Database/reset 2005/07/08 19:03:17 1.2 @@ -1,6 +1,7 @@ +#!/bin/bash mysql -u root -p < reset2 mysql -u root -p mobycentral < mobycentral.mysql -mysql -u root -p mobyobject < mobyobject.mysql -mysql -u root -p mobyservice < mobyservice.mysql +mysql -u root -p mobyobject < mobyobject.data +mysql -u root -p mobyservice < mobyservice.data mysql -u root -p mobynamespace < mobynamespace.mysql mysql -u root -p mobyrelationship < mobyrelationship.mysql From mwilkinson at pub.open-bio.org Fri Jul 8 15:22:21 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 8 Jul 2005 15:22:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081922.j68JMLnS025097@pub.open-bio.org> mwilkinson Fri Jul 8 15:22:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv25078/t Modified Files: Client-Central.t Log Message: added a test for Eddie's changes to the test harness moby-live/Perl/t Client-Central.t,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/04 17:52:18 1.7 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/08 19:22:21 1.8 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; -use Test::More tests => 13; # perldoc Test::More for details +use Test::More tests => 14; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; @@ -96,7 +96,33 @@ ( ok($r->success,"Service Type registration successful") ) or diag("Service Type registration failure: ".$r->message) ; -# Test 8 +# Test 8 # should fail +$r = $C->registerService( + serviceName => "myfirstservice", + serviceType => "Retrieval", + authURI => "test.suite.com", + contactEmail => 'your at mail.address', + description => "this is my first service", + category => "moby", + URL => "http://illuminae/cgi-bin/service.pl", + input =>[ + ['articleName1', [Object => ['UglyNamespace']]], # Simple + ], + output =>[ + ['articleName2', [String => ['UglyNamespace']]], # Simple + ], + secondary => { + parametername1 => { + datatype => 'INTEGER', + default => 0, + max => 10, + min => -10, + enum => [-10, 10, 0]}}); + +( ok(!$r->success,"Service registration correctly failed") +) or diag("Service registration failure: ".$r->message) ; + +# Test 9 $r = $C->registerService( serviceName => "myfirstservice", serviceType => "Retrieval", @@ -123,7 +149,7 @@ ) or diag("Service registration failure: ".$r->message) ; -# Test 9 +# Test 10 $r = $C->deregisterService( serviceName => "myfirstservice", @@ -133,17 +159,17 @@ ) or diag("Service deregistration failure: ".$r->message) ; -# Test 10 +# Test 11 $r = $C->deregisterObjectClass(objectType => "TotalCrap"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; -# Test 11 +# Test 12 $r = $C->deregisterServiceType(serviceType => "CrappyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; -# Test 12 +# Test 13 $r = $C->deregisterNamespace(namespaceType =>'UglyNamespace'); ( ok($r->success,"namespace deregistration successful") ) or diag("namespace deregistration failure: ".$r->message) ; @@ -152,7 +178,7 @@ # #my @service ; # -## Tests 7,8: locateServiceByOutput with output 'Object' and full_objects + full_services +## Tests 14,15: locateServiceByOutput with output 'Object' and full_objects + full_services #@service = $C->locateServiceByOutput( # objectType => "Object", # fullObjects => 1, @@ -166,7 +192,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 9,10: Testing locateServiceByOutput with output "Object" and full_services only +## Tests 16,17: Testing locateServiceByOutput with output "Object" and full_services only #@service = $C->locateServiceByOutput( # objectType => "Object", # fullObjects => 0, @@ -179,7 +205,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 11,12: Testing locateServiceByInput with input +## Tests 18,19: Testing locateServiceByInput with input ## 'Object' => Genbank/GI and full_objects + full_services #@service = $C->locateServiceByInput( # input => {"Sequence" => ["Genbank/GI"]}, @@ -194,7 +220,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 13,14: Testing locateServiceByInput with input +## Tests 20,21: Testing locateServiceByInput with input ## 'Object' => Genbank/GI and full_services only #@service = $C->locateServiceByInput( # input => {"Object" => ["Genbank/GI"]}, @@ -209,7 +235,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 15,16: Testing locateServiceByType with type 'Retrieve' + full_services +## Tests 22,23: Testing locateServiceByType with type 'Retrieve' + full_services #@service = $C->locateServiceByType( # serviceType => "Retrieve", # fullServices => 1, From dwang at pub.open-bio.org Wed Jul 13 14:18:39 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 14:18:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507131818.j6DIIdA6020839@pub.open-bio.org> dwang Wed Jul 13 14:18:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20813/Perl/MOBY Modified Files: Central.pm Log Message: 1st commit by Dennis moby-live/Perl/MOBY Central.pm,1.157,1.158 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.157 retrieving revision 1.158 diff -u -r1.157 -r1.158 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/08 18:57:00 1.157 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 18:18:39 1.158 @@ -470,6 +470,9 @@ =cut sub deregisterObjectClass { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'object' ); return &_error( "Message Format Incorrect", "" ) unless ($payload); @@ -482,42 +485,14 @@ return &_error( "Object class $class does not exist", "" ) unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return &_error( - "Object class $class is used by a service and may not be deregistered", - "" - ) - if ($id); - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); - return &_error( - "Object class $class is used by a service and may not be deregistered", - "" - ) - if ($id); - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return &_error( - "Object class $class is used by a service and may not be deregistered", - "" - ) - if ($id); - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); + + my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); return &_error( "Object class $class is used by a service and may not be deregistered", "" ) - if ($id); + if ($errormsg); + my ( $success2, $message2, $URI ) = $OntologyServer->deleteObject( term => $class ); $success2 == 0 && return &_error( $message2, $URI ); @@ -767,6 +742,9 @@ =cut sub deregisterServiceType { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'service' ); return &_error( "Message Format Incorrect", "" ) unless ($payload); @@ -781,10 +759,10 @@ return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance where service_type_uri = ?}, - undef, $existingURI - ); + + my $result = $adaptor->query_service_instance({service_type_uri => $existingURI}); + my $id = @$result[0]->{service_instance_id}; + return &_error( "A registered service depends on this service type", "" ) if ($id); my ( $success2, $message2, $deleteURI ) = @@ -924,6 +902,9 @@ =cut sub deregisterNamespace { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'namespace' ); return &_error( "Message Format Incorrect", "" ) unless ($payload); @@ -936,71 +917,10 @@ return &_error( "Namespace Type $term does not exist", "" ) unless ($existingURI); my $dbh = MOBY::central_db_connection->new->dbh; - my $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } + my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term}); + return &_error( $errstr, "") + if ($err); + my ( $success2, $message2, $URI ) = $OntologyServer->deleteNamespace( term => $term ); $success2 == 0 && return &_error( $message2, $URI ); @@ -1936,6 +1856,9 @@ =cut sub findService { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; $debug && &_LOG("\nLOOKING FOR SERVICES\n"); my %findme = &_findServicePayload($payload); @@ -1965,18 +1888,16 @@ $debug && _LOG( "authoritative added; criterion count is now $criterion_count\n"); - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where authoritative=?}, - undef, $findme{authoritative} - ); + my $ids = $adaptor->query_service_instance({authoritative => $findme{authoritative}}); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instnace_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2002,10 +1923,8 @@ $children_string .= ( join ',', map { "\'$_\'" } @children ); } $children_string =~ s/\,$//; - my $ids = - $dbh->selectall_arrayref( -"select service_instance_id from service_instance where service_type_uri in ($children_string)" - ); + my $ids = $adaptor->match_service_type_uri({service_type_uri => $children_string}); + $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { @@ -2018,26 +1937,24 @@ ++$criterion_count; $debug && _LOG("authURI added; criterion count is now $criterion_count\n"); - my ($id) = $dbh->selectrow_array( -q{select authority_id from authority where authority_uri = ? or authority_common_name = ?}, - undef, - ( $findme{authURI}, $findme{authURI} ) - ); + + my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}}); + my $id = @$result[0]->{authority_id}; + unless ($id) { return &_serviceListResponse( $dbh, undef ); } - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where authority_id=?}, - undef, $id - ); + + my $ids = $adaptor->query_service_instance({authority_id => $id}); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2046,18 +1963,17 @@ $debug && _LOG( "servicename added; criterion count is now $criterion_count\n"); - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where servicename=?}, - undef, $findme{servicename} - ); + + my $ids = $adaptor->query_service_instance({servicename => $findme{servicename}}); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2066,19 +1982,17 @@ ++$criterion_count; $debug && _LOG("category added; criterion count is now $criterion_count\n"); - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where category=?}, - undef, - lc( $findme{category} ) - ); + + my $ids = $adaptor->query_service_instance({category => lc( $findme{category}) }); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2086,19 +2000,9 @@ ++$criterion_count; $debug && _LOG("Keywords added; criterion count is now $criterion_count\n"); - my $searchstring; - foreach my $kw ( @{ $findme{keywords} } ) { - $debug && &_LOG("KEYWORD $kw\n"); - $kw =~ s/\*//g; - $kw = $dbh->quote("%$kw%"); - $searchstring .= " OR description like $kw "; - } - $searchstring =~ s/OR//; # just the first one - $debug && &_LOG("search $searchstring\n"); - my $ids = - $dbh->selectall_arrayref( -"select service_instance_id from service_instance where $searchstring" - ); + + my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + unless ( scalar @{$ids} ) { $debug && &_LOG( @@ -2264,6 +2168,8 @@ } sub _searchForSimple { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); # returns list of service_instance ID's # that match this simple @@ -2282,24 +2188,17 @@ $ancestor_string .= ( join ',', map { "\'$_\'" } @ancestors ); } $ancestor_string =~ s/\,$//; - my $query = -"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " - ; # if service_instance_id is null then it must be a collection input. - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/OR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; - } + + my ($query, $result) = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); + $debug && _LOG("\nQUERY $query\n"); my @valid_services; - my $sth = $dbh->prepare($query); - $sth->execute; - while ( my ( $id, $nss ) = $sth->fetchrow_array ) - { # get the service instance ID and the namespaces that matched + + foreach my $row (@$result) + { + # get the service instance ID and the namespaces that matched + my $id = $row->{service_instance_id}; + my $nss = $row->{namespace_type_uris}; if ( $nss && scalar @{$namespaceURIs} ) { # if this service cares about namespaces at all, # and if namespaces were specified in the query, @@ -2327,9 +2226,11 @@ #Eddie - converted sub _searchForCollection { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, $node, $expand, $inout ) = @_; # $node in this case is a Collection object - my $query; # luckily, we can return a redundant list of service id's and # this will be cleaned up in the caller @@ -2339,30 +2240,15 @@ next unless ( $simple->nodeName =~ /simple/i ); my ( $objectURI, $namespaceURIs ) = &_extractObjectTypesAndNamespaces($simple); - $query = "select - c.service_instance_id, - s.namespace_type_uris - from - simple_$inout as s, - collection_$inout as c - where - s.collection_${inout}_id IS NOT NULL - AND s.collection_${inout}_id = c.collection_${inout}_id - AND object_type_uri = '$objectURI' "; - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/^\sOR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; # add the AND clause - } + + my ($query, $result) = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); + $debug && &_LOG("QUERY: $query"); - my $sth = $dbh->prepare($query); - $sth->execute; - while ( my ( $id, $nss ) = $sth->fetchrow_array ) + + foreach my $row (@$result ) { # get the service instance ID and the namespaces that matched + my $id = $row->{service_instance_id}; + my $nss = $row->{namespace_type_uris}; if ( $nss && scalar @{$namespaceURIs} ) { # if this service cares about namespaces at all, # and if namespaces were specified in the query, @@ -2582,13 +2468,17 @@ =cut sub retrieveServiceProviders { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ($pkg) = @_; my $dbh = MOBY::central_db_connection->new()->dbh; - my $sth = $dbh->prepare("select distinct authority_uri from authority"); - $sth->execute; + + my $result = $adaptor->getUniqueAuthorityURI(); + my $providers = "\n"; - while ( my ($prov) = $sth->fetchrow_array ) { - $providers .= "\n"; + foreach my $prov (@$result) { + $providers .= "\n"; } $providers .= "\n"; return $providers; @@ -2612,16 +2502,15 @@ =cut sub retrieveServiceNames { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ($pkg) = shift; my $dbh = MOBY::central_db_connection->new()->dbh; - my $sth = - $dbh->prepare( -"select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id" - ); - $sth->execute; + my $result = $adaptor->getServiceNames(); my $names = "\n"; - while ( my ( $auth, $name ) = $sth->fetchrow_array ) { - $names .= "\n"; + foreach my $row (@$result) { + $names .= "\n"; } $names .= "\n"; return $names; @@ -3051,25 +2940,17 @@ *DUMP = \&DUMP_MySQL; # alias it for backward compatibility sub _flatten { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); # from a given term, traverse the ontology # and flatten it into a list of parent terms my ( $dbh, $type, $term, $seen ) = @_; - my $sth = $dbh->prepare( " - select - OE1.term - from - OntologyEntry as OE1, - OntologyEntry as OE2, - Term2Term as TT - where - ontologyentry2_id = OE2.id - and ontologyentry1_id = OE1.id - and relationship_type_id = $type - and OE2.term = ?" - ); - $sth->execute($term); - while ( my ($term) = $sth->fetchrow_array ) { + + my $result = $adaptor->getParentTerms({relationship_type_id => $type}, {term => $term}); + + foreach my $row (@$result) { + my $term = $row->{term}; next if ${$seen}{$term}; &_flatten( $dbh, $type, $term, $seen ); ${$seen}{$term} = 1; @@ -3232,12 +3113,17 @@ =cut sub _traverseServiceDAG { + + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, $serviceType, $sth_hash ) = @_; my %sth = %{$sth_hash}; my %ServiceIDs; - my $sth = $dbh->prepare( $sth{get_service_type_id} ); - $sth->execute($serviceType); - my ($root_id) = $sth->fetchrow_array; + + my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); + my $row = shift(@$result); + my ($root_id) = @$row; return undef unless $root_id; # we have to do a traversal of the DAG here to get all child nodes... @@ -3250,11 +3136,13 @@ next if ( $ServiceIDs{$service} eq "tested" ) ; # if it has been tested already then move on - my $sth = $dbh->prepare( $sth{get_service_hierarchy_list} ); - $sth->execute($service); # execute the query for child nodes + + my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); + # execute the query for child nodes $ServiceIDs{$service} = "tested"; # mark it as tested - while ( my $new = $sth->fetchrow_array ) + foreach my $row (@$result) { # now get each of the child nodes + my $new = @$row; next if ( defined $ServiceIDs{$new} ) ; # if we have already heard about it then move on @@ -3278,22 +3166,19 @@ =cut sub _traverseObjectDAG { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, $objectType, $sth_hash, $dir ) = @_; my %sth = %{$sth_hash}; my %ObjectIDs; - my $sth = $dbh->prepare( $sth{get_object_type_id} ); - $sth->execute($objectType); - my ($root_id) = $sth->fetchrow_array; - return undef unless $root_id; - if ( $dir eq "p" ) { - $debug && &_LOG("getting parents"); - $sth = $dbh->prepare( $sth{get_object_parent_list} ); - } - else { - $debug && &_LOG("getting children"); - $sth = $dbh->prepare( $sth{get_object_child_list} ); - } + my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); + + my $row = shift (@$result); + my ($root_id) = @$row; + return undef unless $root_id; + # we have to do a traversal of the DAG here to get all child nodes... # this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested @@ -3304,10 +3189,22 @@ next if ( $ObjectIDs{$object} eq "tested" ) ; # if it has been tested already then move on - $sth->execute($object); # execute the query for child nodes + + my $result; + if ( $dir eq "p" ) { + $debug && &_LOG("getting parents"); + $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); + } + else { + $debug && &_LOG("getting children"); + $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); + } + # execute the query for child nodes + $ObjectIDs{$object} = "tested"; # mark it as tested - while ( my $new = $sth->fetchrow_array ) + foreach my $row (@$result) { # now get each of the child nodes + my $new = @$row; next if ( defined $ObjectIDs{$new} ) ; # if we have already heard about it then move on @@ -3461,56 +3358,28 @@ } sub _serviceListResponse { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, @ids ) = @_; my $output = ""; - my $sth = $dbh->prepare( - q{ - select - category, url, servicename, service_type_uri, authority_id, description, authoritative, contact_email, signatureURL, lsid - from service_instance where - service_instance_id = ?} - ); - my $sth_simple_in = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_input where service_instance_id=? and collection_input_id IS NULL" - ); - my $sth_simple_out = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_output where service_instance_id=? and collection_output_id IS NULL" - ); - my $sth_collection_ins = - $dbh->prepare( -"select collection_input_id, article_name from collection_input where service_instance_id=?" - ); - my $sth_collection_outs = - $dbh->prepare( -"select collection_output_id, article_name from collection_output where service_instance_id=?" - ); - my $sth_collection_in = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_input where service_instance_id IS NULL and collection_input_id =?" - ); - my $sth_collection_out = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_output where service_instance_id IS NULL and collection_output_id =?" - ); - my $sth_secondary_in = - $dbh->prepare( -"select default_value, maximum_value, minimum_value, enum_value, datatype, article_name from secondary_input where service_instance_id=?" - ); my $OSobj = MOBY::OntologyServer->new( ontology => 'object' ); my $OSns = MOBY::OntologyServer->new( ontology => 'namespace' ); my $OSserv = MOBY::OntologyServer->new( ontology => 'service' ); foreach (@ids) { - $sth->execute($_); - my ( - $category, $url, $servicename, - $service_type_uri, $authority_id, $desc, - $authoritative, $email, $signatureURL, - $lsid - ) - = $sth->fetchrow_array; + my $result = $adaptor->query_service_instance({service_instance_id => $_}); + my $category = @$result[0]->{category}; + my $url = @$result[0]->{url}; + my $servicename = @$result[0]->{servicename}; + my $service_type_uri = @$result[0]->{service_type_uri}; + my $authority_id = @$result[0]->{authority_id}; + my $desc = @$result[0]->{description}; + my $authoritative = @$result[0]->{authoritative}; + my $email = @$result[0]->{contact_email}; + my $signatureURL = @$result[0]->{signatureURL}; + my $lsid = @$result[0]->{lsid}; + if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } @@ -3519,10 +3388,9 @@ $signatureURL ||= ""; next unless ( $servicename && $authority_id ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); - my ($authURI) = - $dbh->selectrow_array( - q{select authority_uri from authority where authority_id=?}, - undef, $authority_id ); + + $result = $adaptor->query_authority({authority_id => $authority_id}); + my $authURI = @$result[0]->{authority_uri}; $output .= "\t\n"; $output .= "\t$service_type\n"; @@ -3533,11 +3401,15 @@ $output .= "\t$signatureURL\n"; $output .= "\t$url\n"; $output .= "\t\n"; - $sth_simple_in->execute($_); - - while ( my ( $objURI, $nsURI, $article ) = - $sth_simple_in->fetchrow_array() ) + + $result = $adaptor->query_simple_input({service_instance_id => $_}, 'and', {collection_input_id => undef}); + + foreach my $row (@$result) { + my $objURI = $row->{object_type_uri}; + my $nsURI = $row->{namespace_type_uris}; + my $article = $row->{article_name}; + my $objName = $OSobj->getObjectCommonName($objURI); $nsURI ||= ""; my @nsURIs = split ",", $nsURI; @@ -3550,15 +3422,23 @@ } $output .= "\t\t\n"; } + $result = $adaptor->query_collection_input({service_instance => $_}); $sth_collection_ins->execute($_); - while ( my ( $collid, $articlename ) = - $sth_collection_ins->fetchrow_array ) + + foreach my $row (@$result) { - $output .= "\t\t\n"; - $sth_collection_in->execute($collid); - while ( my ( $objURI, $nsURI, $article ) = - $sth_collection_in->fetchrow_array() ) + my $collid = $row->{collection_input_id}; + my $articlename = $row->{article_name}; + + $output .= "\t\t\n"; + + my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, 'and', {collection_input_id => $collid}); + foreach my $row2 (@$result2) { + my $objURI = $row2->{object_type_uri}; + my $nsURI = $row2->{namespace_type_uri}; + my $article = $row2->{article_name}; + my $objName = $OSobj->getObjectCommonName($objURI); $nsURI ||= ""; my @nsURIs = split ",", $nsURI; @@ -3576,57 +3456,68 @@ } $output .= "\t\n"; $output .= "\t\n"; - $sth_simple_out->execute($_); - while ( my ( $objURI, $nsURI, $article ) = - $sth_simple_out->fetchrow_array() ) + + $result = query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); + + foreach my $row (@$result) { + my $objURI = $row->{object_type_uri}; + my $nsURI = $row->{namespace_type_uris}; + my $article = $row->{article_name}; + + my $objName = $OSobj->getObjectCommonName($objURI); + $nsURI ||= ""; + my @nsURIs = split ",", $nsURI; + $article ||= ""; + $output .= "\t\t\n"; + $output .= "\t\t\t$objName\n"; + foreach my $ns (@nsURIs) { + my $NSname = $OSns->getNamespaceCommonName($ns); + $output .= "\t\t\t$NSname\n" if $NSname; + } + $output .= "\t\t\n"; + } + + $result = query_collection_output({service_instance_id => $_}); + foreach my $row (@$result) + { + my $collid = $row->{collection_output_id}; + my $articlename = $row->{article_name}; + $output .= "\t\t\n"; + + my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id = $collid}); + foreach my $row2 (@$result2 ) + { + my $objURI = $row2->{object_type_uri}; + my $nsURI = $row2->{namespace_type_uris}; + my $article = $row2->{article_name}; my $objName = $OSobj->getObjectCommonName($objURI); $nsURI ||= ""; my @nsURIs = split ",", $nsURI; $article ||= ""; - $output .= "\t\t\n"; - $output .= "\t\t\t$objName\n"; + $output .= "\t\t\t\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { - my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t$NSname\n" if $NSname; - } - $output .= "\t\t\n"; - } - $sth_collection_outs->execute($_); - while ( my ( $collid, $articlename ) = - $sth_collection_outs->fetchrow_array ) - { - $output .= "\t\t\n"; - $sth_collection_out->execute($collid); - while ( my ( $objURI, $nsURI, $article ) = - $sth_collection_out->fetchrow_array() ) - { - my $objName = $OSobj->getObjectCommonName($objURI); - $nsURI ||= ""; - my @nsURIs = split ",", $nsURI; - $article ||= ""; - $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; - foreach my $ns (@nsURIs) { - my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t\t$NSname\n" - if $NSname; - } - $output .= "\t\t\t\n"; - } - $output .= "\t\t\n"; + my $NSname = $OSns->getNamespaceCommonName($ns); + $output .= "\t\t\t\t$NSname\n" + if $NSname; + } + $output .= "\t\t\t\n"; + } + $output .= "\t\t\n"; } $output .= "\t\n"; $output .= "\t\n"; - $sth_secondary_in->execute($_); - while ( - my ( - $default_value, $maximum_value, $minimum_value, - $enum_value, $datatype, $article_name - ) - = $sth_secondary_in->fetchrow_array() - ) + $result = $adaptor->query_secondary_input({service_instance_id => $_}); + foreach my $row (@$result) { + my $default_value = $row->{default_value}; + my $maximum_value = $row->{maximum_value}; + my $minimum_value = $row->{minimum_value}; + my $enum_value = $row->{enum_value}; + my $datatype = $row->{datatype}; + my $article_name = $row->{article_name}; + $article_name ||= ""; $datatype ||= ""; $default_value ||= ""; From dwang at pub.open-bio.org Wed Jul 13 14:19:09 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 14:19:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507131819.j6DIJ9P4020874@pub.open-bio.org> dwang Wed Jul 13 14:19:09 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20848/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: 1st commit by Dennis moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2004/07/09 00:21:53 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/13 18:19:09 1.3 @@ -3,6 +3,7 @@ use Carp; use vars qw($AUTOLOAD); +# Modified by Dennis { #Encapsulated class data @@ -107,28 +108,44 @@ } -sub insert_collection_input { - die "insert_collection_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} + +# +# authority table functions +# +sub query_authority{ + + } -sub insert_collection_output { - die "insert_collection_output not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} +sub insert_authority{ + +} + +sub delete_authority{ + +} + + +# +# service_instance table functions +# +sub query_service_instance { + die "query_service_instance not implemented in adaptor\n"; +} + +sub insert_service_instance { + die "insert_service_instance not implemented in adaptor\n"; +} + +sub delete_service_intance{ + +} + +# +# simple_output table functions +# +sub query_simple_input{ + } sub insert_simple_input { @@ -153,6 +170,16 @@ #return $id; } +sub delete_simple_input{ + +} + +# +# simple_output table functions +# +sub query_simple_output{ + +} sub insert_simple_output { die "insert_simple_output not implemented in adaptor\n"; @@ -177,14 +204,180 @@ } -sub query_service_instance { - die "query_service_instance not implemented in adaptor\n"; +sub delete_simple_output{ + } -sub insert_service_instance { - die "insert_service_instance not implemented in adaptor\n"; +# +# collection_input table functions +# +sub query_collection_input{ + +} + +sub insert_collection_input { + die "insert_collection_input not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} +} + +sub delete_collection_input{ + +} + +# +# collection_output table fuctions +# +sub query_collection_output{ + +} + +sub insert_collection_output { + die "insert_collection_output not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} +} + +sub delete_collection_output{ + +} + +# +# object table functions +# +sub query_object{ + +} + +sub insert_object{ + +} + +sub delete_object{ + +} + +# +# object_term2term table functions +# +sub query_object_term2term{ + +} + +sub insert_object_term2term{ + +} + +sub delete_object_term2term{ + +} + +# +# relationship table functions +# +sub query_relationship{ + +} + +sub insert_relationship{ + +} + +sub delete_relationship{ + +} + +# +# service table fuctions +# +sub query_service{ + +} + +sub insert_service{ + +} + +sub delete_service{ + +} + +# +# service_term2term table functions +# +sub query_service_term2term{ + +} + +sub insert_service_term2term{ + +} + +sub delete_service_term2term{ + } +# +# namespace table functions +# +sub query_namespace{ + +} + +sub insert_namespace{ + +} + +sub delete_namespace{ + +} + +# +# namespace_term2term table functions +# +sub query_namespace_term2term{ + +} + +sub insert_namespace_term2term{ + +} + +sub delete_namespace_term2term{ + +} + +# secondary_input table functions +sub query_secondary_input{ + +} + +sub insert_secondary_input{ + +} + +sub delete_secondary_input{ + +} + +# +# query term2term tables - queries relation between two tables +# +sub select_term2term{ + +} sub _dump { my ($self) = @_; From dwang at pub.open-bio.org Wed Jul 13 14:33:41 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 14:33:41 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507131833.j6DIXfP0021170@pub.open-bio.org> dwang Wed Jul 13 14:33:41 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21144/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: 1st commit by Dennis moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/05/30 23:33:43 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 18:33:41 1.11 @@ -98,33 +98,222 @@ } +sub add_condition{ + my ($statement, @params) = @_; + my @bindvalues = (); + my $condition = "where "; + + foreach my $param (@params ) + { + if (($param eq 'and') || ($param eq 'or')) + { + $condition .= $param . " "; + } + else + { + my %pair = %$param; + + for my $key (keys %pair) + { + if (defined $pair{$key}) + { + $condition .= $key . " = ? "; + push(@bindvalues, $pair{$key}); + } + else + { + $condition .= $key . " IS NULL " + } + } + } + } + $statement .= $condition; + return ($statement, @bindvalues); + } + +# preforms query but returns a reference to an array containing hash references +sub do_query{ + my ($dbh, $statement, @bindvalues) = @_; + my $sth = $dbh -> prepare($statement); + if (@bindvalues < 1) + { + $sth->execute; + } + else + { + $sth->execute(@bindvalues); + } + # returns an array of hash references + my $arrayHashRef = $sth->fetchall_arrayref({}); + return $arrayHashRef; +} + +sub get_value{ + my ($key, @params) = @_; + + foreach my $param (@params ) + { + my %pair = %$param; + for my $tmp (keys %pair) + { + if ($tmp eq $key){ + return $pair{$key}; + } + } + } +} + +# general query subroutine +# parameters: +# statement - a string SQL statement +# bind_values - an array of values to be bound to the parameters +# returns: +# resultset - reference to an array containing array references +sub general_query{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = get_value('statement', @args); + my $sth = $dbh->prepare($statement}; + if (@args > 1) + { + my $bindvalues = get_value('bind_values', @args); + $sth->execute(@$bindvalues); + } + else { + $sth->execute; + } + my $result = $sth->fetchall_arrayref(); + return result; +} + +sub query_collection_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + collection_input_id, + article_name, + service_instance_id + from collection_input "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} sub insert_collection_input { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; # if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ # this should be dropped down into the mysql.pm module?? probably... - $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", + undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); my $id=$self->dbh->{mysql_insertid}; return $id; # } } +sub delete_collection_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from collection_input "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# query subroutine selects all columns +sub query_collection_output{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + collection_output_id, + article_name, + service_instance_id + from collection_output "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + sub insert_collection_output { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; # if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ # this should be dropped down into the mysql.pm module?? probably... - $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", + undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); my $id=$self->dbh->{mysql_insertid}; return $id; # } } +sub delete_collection_output{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from collection_output "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + + +sub query_simple_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + simple_input_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id + from simple_input "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + + sub insert_simple_input { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; - my $si = $args{collection_input_id}?undef:$args{service_instance_id}; + my $si = get_value('collection_input_id', @args)?undef:get_value('service_instance_id', @args); $dbh->do("insert into simple_input (object_type_uri, @@ -134,21 +323,59 @@ collection_input_id) values (?,?,?,?,?)", undef, - ($args{object_type_uri}, - $args{namespace_type_uris}, - $args{article_name}, + (get_value('object_type_uri', @args), + get_value('namespace_type_uris', @args), + get_value('article_name', @args), # here $si, - $args{collection_input_id})); + get_value('collection_input_id', @args))); my $id=$dbh->{mysql_insertid}; return $id; } +sub delete_simple_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from simple_input "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ) + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_simple_output{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + simple_output_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id + from simple_output "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} sub insert_simple_output { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; - my $si = $args{collection_output_id}?undef:$args{service_instance_id}; + my $si = get_value('collection_output_id', @args)?undef:get_value('service_instance_id', @args); $dbh->do("insert into simple_output (object_type_uri, @@ -158,78 +385,813 @@ collection_output_id) values (?,?,?,?,?)", undef, - ($args{object_type_uri}, - $args{namespace_type_uris}, - $args{article_name}, + (get_value('object_type_uri', @args), + get_value('namespace_type_uris', @args), + get_value('article_name', @args), # and here $si, - $args{collection_output_id})); + get_value('collection_output_id', @args))); my $id=$dbh->{mysql_insertid}; return $id; } -sub query_service_instance { - my ($self, %args) = @_; +sub delete_simple_output{ + my ($self, @args) = @_; my $dbh = $self->dbh; + my $statement = "delete from simple_output "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} - my ($serviceid, $category, $name, $typeURI, $authURI,$url,$email,$authoritative,$desc, $signatureURL, $lsid) = $dbh->selectrow_array( # does this service already exist? - q{select +sub query_secondary_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + secondary_input_id, + default_value, + maximum_value, + minimum_value, + enum_value, + datatype, + article_name, + service_instance_id + from secondary_input "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_secondary_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $dbh->do( +q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, + undef, + ( + get_value('default_value', @args), get_value('maximum_value', @args), + get_value('minimum_value', @args), get_value('enum_value', @args), + get_value('datatype', @args), get_value('article_name', @args), + get_value('service_instance_id', @args), + ) + ); + return $dbh->{mysql_insertid}; +} + +sub delete_secondary_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from secondary_input "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# query subroutine will selects all rows from object table +sub query_object +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + object_id, + object_lsid, + object_type, + description, + authority, + contact_email + from object "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# inserts a new tuple into object table +sub insert_object{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into object + (object_type, + object_lsid, + description, + authority, + contact_email) + values (?,?,?,?,?)", + undef, + (get_value('object_type', @args), + get_value('object_lsid', @args), + get_value('description', @args), + get_value('authority', @args), + get_value('contact_email', @args))); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +sub delete_object{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from object "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_object_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + object1_id, + object2_id, + object2_articlename + from object_term2term "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_object_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, + undef, + ( get_value('relationship_type', @args), + get_value('object1_id', @args), + get_value('object2_id', @args), + get_value('object2_articlename', @args) ) + ); + + return $dbh->{mysql_insertid}; +} + +# selects all the columns from service_instance table +# where is lsid? +sub query_service_instance { + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select service_instance_id, category, - serviceName, + servicename, service_type_uri, - authority.authority_uri, + authority_id, url, - service_instance.contact_email, + contact_email, authoritative, description, signatureURL, lsid - from service_instance, authority - where - service_instance.authority_id = authority.authority_id - and servicename=? and authority.authority_uri = ? - }, - undef,($args{servicename}, $args{authURI})); - return undef unless $serviceid; - return {serviceid => $serviceid, - category => $category, - name => $name, - servcetype => $typeURI, - authURI => $authURI, - signatureURL => $signatureURL, - url => $url, - email => $email, - authoritative => $authoritative, - desc => $desc, - lsid => $lsid - }; + from service_instance "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; } +# custom query for Moby::Central.pm->findService() +sub match_service_type_uri{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $uri_list = get_value('service_type_uri', @args); + + my $result = $dbh->selectall_arrayref( +"select service_instance_id from service_instance where service_type_uri in ($uri_list)" + ); + return $result; +} sub insert_service_instance { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, - undef, - $args{'category'}, - $args{'servicename'}, - $args{'service_type_uri'}, - $args{'authority_id'}, - $args{'url'}, - $args{'contact_email'}, - $args{'authoritative'}, - $args{'description'}, - $args{'signatureURL'}, - $args{'lsid'}); + undef,( + get_value('category', @args), + get_value('servicename', @args), + get_value('service_type_uri', @args), + get_value('authority_id', @args), + get_value('url', @args), + get_value('contact_email', @args), + get_value('authoritative', @args), + get_value('description', @args), + get_value('signatureURL', @args), + get_value('lsid', @args))); my $id = $dbh->{mysql_insertid}; return $id; } +sub delete_service_instance{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service_instance "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# Selects all columns +sub query_authority { + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + authority_id, + authority_common_name, + authority_uri, + contact_email + from authority "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub getUniqueAuthorityURI{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $statement = "select distinct authority_uri from authority"; + $bindvalues = (); + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_authority{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into authority + (authority_common_name, + authority_uri, + contact_email) + values (?,?,?)", + undef, + (get_value('authority_common_name', @args), + get_value('authority_uri' @args), + get_value('contact_email', @args))); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +sub query_service{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select + service_id, + service_lsid, + service_type, + description, + authority, + contact_email + from service "; + my @bindvalues = (); + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_service{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, + undef, + ( + get_value('service_type', @args), get_value('service_lsid', @args), get_value('description', @args), + get_value('authority', @args), get_value('contact_email', @args) + ) + ); + return dbh->{mysql_insertid}; +} + +sub delete_service{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_service_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select + assertion_id, + relationship_type, + service1_id, + service2_id + from service_term2term "; + my @bindvalues = (); + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_service_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, + undef, + ( get_value('relationship_type', @args), get_value('service1_id', @args), get_value('service2_id', @args)) + ); + return dbh->{mysql_insertid}; +} + +sub delete_service_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service_term2term "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_relationship{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + relationship_id, + relationship_lsid, + relationship_type, + container, + description, + authority, + contact_email, + ontology + from relationship "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub query_namespace{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + namespace_id, + namespace_lsid, + namespace_type, + description, + authority, + contact_email + from namespace "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_namespace{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, + undef, + ( + get_value('namespace_type', @args), get_value('namespace_lsid', @args), get_value('description', @args), + get_value('authority', @args), get_value('contact_email', @args) + ) + ); + return dbh->{mysql_insertid}; +} + +sub delete_namespace{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from namespace "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} +sub query_namespace_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + namespace1_id, + namespace2_id + from namespace_term2term "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub delete_namespace_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from namespace_term2term "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# custom query subroutine for Moby::Central.pm->deregisterObjectClass() +sub checkClassUsedByService +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $errorMsg = 1; + my $existingURI = get_value('object_type_uri', @args); + + my ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + return 0; +} + +# custom query routine for Moby::Central.pm -> deregisterNamespace() +sub checkNamespaceUsedByService{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $existingURI = get_value('namespace_type_uris', @args); + my $term = get_value('term', @args); + +my $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + return (0, $errstr); +} + +# custom query routine for Moby::Central.pm -> findService() +sub checkKeywords{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $param = get_value('findme', @args); + my %findme = %$param; + my $searchstring; + + foreach my $kw ( @{ $findme{keywords} } ) { + $debug && &_LOG("KEYWORD $kw\n"); + $kw =~ s/\*//g; + $kw = $dbh->quote("%$kw%"); + $searchstring .= " OR description like $kw "; + } + $searchstring =~ s/OR//; # just the first one + $debug && &_LOG("search $searchstring\n"); + + my $ids = + $dbh->selectall_arrayref( +"select service_instance_id from service_instance where $searchstring" + ); + + return ($ids, $searchstring); +} + +# custom query subroutine for Moby::Central.pm->_searchForSimple() +sub getFromSimple{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $ancestor_string = get_value('ancestor_string', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = +"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " + ; # if service_instance_id is null then it must be a collection input. + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/OR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; + } + + my $result = do_query($dbh, $query, ()); + return ($query, $result); +} + +# custom query subroutine for Moby::Central.pm->_searchForCollection() +sub getFromCollection +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $objectURI = get_value('objectURI', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = "select + c.service_instance_id, + s.namespace_type_uris + from + simple_$inout as s, + collection_$inout as c + where + s.collection_${inout}_id IS NOT NULL + AND s.collection_${inout}_id = c.collection_${inout}_id + AND object_type_uri = '$objectURI' " + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/^\sOR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; # add the AND clause + } + + my $result = do_query($dbh, $query, ()); + return ($query, $result); +} + +# custom query subroutine for Moby::Central.pm->RetrieveServiceNames +sub getServiceNames +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; + my @bindvalues = (); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query for Moby::Central.pm->_flatten +sub getParentTerms +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $type_id = get_value('relationship_type_id', @args); + my $statement = " + select + OE1.term + from + OntologyEntry as OE1, + OntologyEntry as OE2, + Term2Term as TT + where + ontologyentry2_id = OE2.id + and ontologyentry1_id = OE1.id + and relationship_type_id = $type_id + and OE2.term = ?"; + + my @bindvalues = (); + push(@bindvalues, get_value('term', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query subroutine for selecting from object_term2term and object tables +# used in Moby::OntologyServer.pm->retrieveObject() +sub getObjectRelationships{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + relationship_type, + object_lsid, + object2_articlename + from object_term2term, object + where object1_id = ? and object2_id = object_id"; + + my @bindvalues = (); + push(@bindvalues, get_value('object1_id', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() +getRelationship{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $defs; + my $ontology = $args{ontology}; + + unless ( defined $args{$relationship} ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $args{lsid} ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $args{$relationship}, $args{lsid} ); # ") + } + return $defs; +} sub _checkURI { From dwang at pub.open-bio.org Wed Jul 13 17:53:12 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 17:53:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507132153.j6DLrCUE022059@pub.open-bio.org> dwang Wed Jul 13 17:53:12 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22025/Perl/MOBY Modified Files: Central.pm OntologyServer.pm authority.pm Log Message: Moved all SQL statements in authority.pm and Central.pm to Moby::Adaptor::queryapi::mysql.pm In its place are calls to routines in Moby::Adaptor::queryapi.pm moby-live/Perl/MOBY Central.pm,1.158,1.159 OntologyServer.pm,1.49,1.50 authority.pm,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.158 retrieving revision 1.159 diff -u -r1.158 -r1.159 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 18:18:39 1.158 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 21:53:11 1.159 @@ -1928,8 +1928,8 @@ $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2001,7 +2001,7 @@ $debug && _LOG("Keywords added; criterion count is now $criterion_count\n"); - my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); unless ( scalar @{$ids} ) { $debug @@ -2013,8 +2013,8 @@ $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2004/12/14 20:47:04 1.49 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/13 21:53:12 1.50 @@ -191,19 +191,21 @@ # if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objecttype/)){ # return (1, "external ontology", $term); # } + my $result; if ( $term =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_lsid = ?" - ); + $result = $adaptor->query_object({object_lsid => $term}); + } else { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_type = ?" - ); + $result = $adaptor->query_object({object_type => $term}); + } - $sth->execute($term); - my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $lsid = $row->{object_lsid}; + my $type = $row->{object_type}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($lsid) { # if it is in there, then it has been discovered regardless of being foreign or not return ( 1, $desc, $lsid ); @@ -263,20 +265,20 @@ ? $args{'node'} : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $sth; + my $result; if ( $args{'node'} =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_lsid = ?" - ); + + $result = $adaptor->query_object({object_lsid => $term}); } else { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_type = ?" - ); + $result = $adaptor->query_object({object_type => $term}); } - $sth->execute($term); - my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $lsid = $row->{object_lsid}; + my $type = $row->{object_type}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($lsid) { # if it is in there, then the object exists return ( 0, "This term already exists: $lsid", $lsid ); } @@ -284,15 +286,13 @@ $args{node} =~ s/^\s+(.*?)\s+$/$1/s; $args{contact_email} =~ s/^\s+(.*?)\s+$/$1/s; $args{authority} =~ s/^\s+(.*?)\s+$/$1/s; - $self->dbh->do( -q{insert into object (object_type, object_lsid, description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - $args{'node'}, $LSID, $args{'description'}, - $args{'authority'}, $args{'contact_email'} - ) - ); - unless ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_object({object_type => $args{'node'}}, + {object_lsid => $LSID}, + {description => $args{'description'}}, + {authority => $args{'authority'}}, + {contact_email => $args{'contact_email'}}); + unless ( $insertid ) { return ( 0, "Object creation failed for unknown reasons", '' ); } return ( 1, "Object creation succeeded", $LSID ); @@ -313,24 +313,28 @@ ? $args{'node'} : $self->getObjectURI($term); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my ( $id, $type, $lsid, $desc, $auth, $contact ) = - $self->dbh->selectrow_array( -q{select object_id, object_type, object_lsid, description, authority,contact_email from object where object_lsid = ?}, - undef, $LSID - ); + my $result = $adaptor->query_object({object_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{object_id}; + my $type = $row->{object_type}; + my $lsid = $row->{object_lsid}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $contact = $row->{contact_email}; + unless ($id) { return ( 0, "Object doesn't exist in ontology", "" ) } # my $OS = MOBY::OntologyServer->new(ontology => "relationship"); - my $sth = - $self->dbh->prepare( -q{select relationship_type, object_lsid, object2_articlename from object_term2term, object where object1_id = ? and object2_id = object_id} - ); - $sth->execute($id); + + $result = $adaptor->getObjectRelationships({object1_id => $id}); my %rel; - while ( my ( $relationship_type, $objectlsid, $article ) = - $sth->fetchrow_array ) + foreach my $row (@$result) { - push @{ $rel{$relationship_type} }, [ $objectlsid, $article ]; + my $relationship_type = $row->{relationship_type}; + my $objectlsid = $row->{object_lsid}; + my $article = $row->{object2_articlename}; + + push @{ $rel{$relationship_type} }, [ $objectlsid, $article ]; } return { objectType => $lsid, =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2004/11/18 17:41:14 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/13 21:53:12 1.3 @@ -2,6 +2,7 @@ package MOBY::authority; use strict; use Carp; +use MOBY::Config; use vars qw($AUTOLOAD @ISA); =head1 NAME @@ -86,20 +87,21 @@ } } my $dbh = $self->dbh; - my ( $authority_id, $common, $uri, $contact ) = $dbh->selectrow_array( -q{select authority_id, authority_common_name,authority_uri,contact_email from authority where authority_uri = ?}, - undef, $self->authority_uri - ); + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + + my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $authority_id = @$result[0]->{authority_id}; + my $common = @$result[0]->{authority_common_name}; + my $uri = @$result[0]->{authority_uri}; + my $contact = @$result[0]->{contact_email}; + unless ($authority_id) { - $dbh->do( -q{insert into authority (authority_common_name, authority_uri, contact_email) values (?,?,?)}, - undef, - ( - $self->authority_common_name, $self->authority_uri, - $self->contact_email - ) - ); - $self->authority_id( $dbh->{mysql_insertid} ); + my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, + {authority_uri => $self->authority_uri}, + {contact_email => $self->contact_email}); + + $self->authority_id( $insertid ); } else { $self->authority_id($authority_id); } From dwang at pub.open-bio.org Wed Jul 13 17:55:36 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 17:55:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507132155.j6DLtaxK022106@pub.open-bio.org> dwang Wed Jul 13 17:55:36 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22080/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: Implementation of queryapi.pm Contains all SQL statements used in Moby::authority.pm and Moby::Central.pm. Changed all query routines to return reference of an array containing hash references, with the exception of general_quer(). moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 18:33:41 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 21:55:36 1.12 @@ -168,7 +168,7 @@ # statement - a string SQL statement # bind_values - an array of values to be bound to the parameters # returns: -# resultset - reference to an array containing array references +# resultset - reference to an array containing ARRAY references sub general_query{ my ($self, @args) = @_; my $dbh = $self->dbh; @@ -604,12 +604,11 @@ sub match_service_type_uri{ my ($self, @args) = @_; my $dbh = $self->dbh; - my $uri_list = get_value('service_type_uri', @args); + my $statement = "select service_instance_id from service_instance where service_type_uri in ($uri_list)"; + my @bindvalues = (); - my $result = $dbh->selectall_arrayref( -"select service_instance_id from service_instance where service_type_uri in ($uri_list)" - ); + my $result = do_query($dbh, $statement, @bindvalues); return $result; } @@ -672,6 +671,7 @@ return $result; } +# custom query routine used in Moby::Central.pm -> retrieveServiceProviders() sub getUniqueAuthorityURI{ my ($self, @args) = @_; my $dbh = $self->dbh; @@ -693,7 +693,7 @@ (get_value('authority_common_name', @args), get_value('authority_uri' @args), get_value('contact_email', @args))); - my $id=$dbh->{mysql_insertid}; + my $id = $dbh->{mysql_insertid}; return $id; } @@ -1036,11 +1036,10 @@ $searchstring =~ s/OR//; # just the first one $debug && &_LOG("search $searchstring\n"); - my $ids = - $dbh->selectall_arrayref( -"select service_instance_id from service_instance where $searchstring" - ); - + my $statement = "select service_instance_id from service_instance where $searchstring"; + my @bindvalues = (); + + my $ids = do_query($dbh, $statement, @bindvalues); return ($ids, $searchstring); } @@ -1162,7 +1161,8 @@ } # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() -getRelationship{ +# note: returns a reference to an array containing ARRAY references +sub getRelationship{ my ($self, %args) = @_; my $dbh = $self->dbh; my $defs; From dwang at pub.open-bio.org Fri Jul 15 12:39:11 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Fri, 15 Jul 2005 12:39:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507151639.j6FGdBMc030093@pub.open-bio.org> dwang Fri Jul 15 12:39:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30067/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: All subroutines in mysql.pm should take in array of hashes as arguments. Delete tuple subroutines now returns 0 if successful or 1 if error moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 21:55:36 1.12 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/15 16:39:11 1.13 @@ -228,10 +228,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -278,10 +278,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -342,10 +342,10 @@ $dbh->do( $statement, undef, @bindvalues ) if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -405,10 +405,10 @@ $dbh->do( $statement, undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -463,10 +463,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -526,10 +526,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -570,6 +570,24 @@ return $dbh->{mysql_insertid}; } +sub delete_object_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "delete from object_term2term "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (1, dbh->errstr); + } + else{ + return 0; + } +} + # selects all the columns from service_instance table # where is lsid? sub query_service_instance { @@ -642,10 +660,10 @@ $dbh->do( $statement, undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -742,10 +760,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -789,10 +807,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -868,10 +886,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -906,10 +924,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -1163,12 +1181,39 @@ # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references sub getRelationship{ - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; + my $direction = get_value('direction', @args); + my $ontology = get_value('ontology', @args); + my $term = get_value('term', @args); + my $relationship = get_value('relationship', @args); my $defs; - my $ontology = $args{ontology}; - unless ( defined $args{$relationship} ) { + if ( $direction eq 'root' ) { + unless ( defined $relationship ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $term ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + } + } else { + unless ( defined $relationship ) { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from ${ontology}_term2term as t2t, @@ -1177,7 +1222,7 @@ where s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $args{lsid} ); # ") + s2.${ontology}_lsid = ?", undef, $term ); # ") } else { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from @@ -1188,8 +1233,9 @@ relationship_type = ? and s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $args{$relationship}, $args{lsid} ); # ") + s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") } + } return $defs; } From dwang at pub.open-bio.org Fri Jul 15 12:40:45 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Fri, 15 Jul 2005 12:40:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507151640.j6FGejJK030156@pub.open-bio.org> dwang Fri Jul 15 12:40:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30130/Perl/MOBY Modified Files: OntologyServer.pm Log Message: All SQL statements in OntologyServer.pm has been moved into Moby::Adaptor::moby::queryapi::mysql.pm Note: Still may contain many syntactic errors moby-live/Perl/MOBY OntologyServer.pm,1.50,1.51 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/13 21:53:12 1.50 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/15 16:40:45 1.51 @@ -183,6 +183,10 @@ sub objectExists { my ( $self, %args ) = @_; + + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that my $sth; @@ -243,7 +247,8 @@ sub createObject { my ( $self, %args ) = @_; - + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); #node => $term, #desc => $desc, #authURI => $auth, @@ -304,6 +309,8 @@ sub retrieveObject { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $term = $args{'node'}; return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node as an argument", '' ) @@ -351,6 +358,9 @@ sub deprecateObject { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY", '' ) unless ( $self->ontology eq 'object' ); my $term = $args{term}; @@ -361,31 +371,29 @@ unless ( $term =~ /urn\:lsid/ ) { $LSID = $self->getObjectURI($term) } else { $LSID = $term } return ( 0, q{Object type $term cannot be resolved to an LSID}, "" ) unless $LSID; - my ( $id, $lsid ) = - $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_lsid = ?}, - undef, $LSID ); + + my $result = $adaptor->query_object({object_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{object_id}; + my $lsid = $row->{object_lsid}; # object1_id ISA object2_id? - my (@isa) = - $self->dbh->selectrow_array( - q{select * from object_term2term where object2_id = ?}, - undef, $id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_object_term2term({object2_id => $id}); + if ( scalar @$isa ) { return ( 0, qq{Object type $term has object dependencies in the ontology}, $lsid ); } - $self->dbh->do( q{delete from object where object_id = ?}, undef, $id ); - if ( $self->dbh->err ) { - return ( 0, "Delete from Object Class table failed: $self->dbh->errstr", + + my ($err, $errstr) = $adaptor->delete_object({object_id => $id}); + if ( $err ) { + return ( 0, "Delete from Object Class table failed: $errstr", $lsid ); } - $self->dbh->do( q{delete from object_term2term where object1_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { + ($err, $errstr) = $adaptor->delete_object_term2term({object1_id => $id}); + if ( $err ) { return ( 0, - "Delete from Object term2term table failed: $self->dbh->errstr", + "Delete from Object term2term table failed: $errstr", $lsid ); } return ( 1, "Object $term Deleted", $lsid ); @@ -409,6 +417,9 @@ # term => $term # ontology => $ontology my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'relationship' ); my $term = lc( $args{term} ); @@ -416,21 +427,22 @@ my $ont = $args{ontology}; return ( 0, "requires both term and ontology arguments\n", '' ) unless ( defined($term) && defined($ont) ); - my $sth; - + my $result; if ( $term =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select relationship_lsid, relationship_type, description, authority, contact_email from relationship where relationship_lsid = ? and ontology=?" - ); + + $result = $adaptor->query_relationship({relationship_lsid => $term}, 'and', {ontology => $ont}); + } else { - $sth = - $self->dbh->prepare( -"select relationship_lsid, relationship_type, description, authority, contact_email from relationship where relationship_type = ? and ontology=?" - ); + + $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ont}); + } - $sth->execute( $term, $ont ); - my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $lsid = $row->{relationship_lsid}; + my $type = $row->{relationship_type}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; if ($lsid) { return ( 1, $desc, $lsid ); } else { @@ -456,43 +468,49 @@ #authority => $auth, #contact_email => $email my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); if ( $args{subject_node} =~ /^urn:lsid/ ) { - ( $subj_id, $subj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_lsid = ?}, - undef, $args{subject_node} - ); + + my $result = $adaptor->query_object({object_lsid => $args{subject_node}}); + my $row = shift(@$result); + $subj_id = $row->{object_id}; + $subj_lsid = $row->{object_lsid}; + } else { - ( $subj_id, $subj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_type = ?}, - undef, $args{subject_node} - ); + my $result = $adaptor->query_object({object_type => $args{subject_node}}); + my $row = shift(@$result); + $subj_id = $row->{object_id}; + $subj_lsid = $row->{object_lsid}; + } return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) unless defined $subj_id; if ( $args{object_node} =~ /^urn:lsid/ ) { - ( $obj_id, $obj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_lsid = ?}, - undef, $args{object_node} - ); + + my $result = $adaptor->query_object({object_lsid => $args{object_node}}); + my $row = shift(@$result); + $obj_id = $row->{object_id}; + $obj_lsid = $row->{object_lsid}; + } else { - ( $obj_id, $obj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_type = ?}, - undef, $args{object_node} - ); + my $result = $adaptor->query_object({object_type => $args{object_node}}); + my $row = shift(@$result); + $obj_id = $row->{object_id}; + $obj_lsid = $row->{object_lsid}; } return ( 0, qq{Object type $args{object_node} does not exist in the ontology}, '' ) unless defined $obj_id; - my (@isa) = - $self->dbh->selectrow_array( - q{select * from object_term2term where object2_id = ?}, - undef, $subj_id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_object_term2term({object2_id => $subj_id}); + + if ( scalar @$isa ) { return ( 0, qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, @@ -507,12 +525,11 @@ || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - $self->dbh->do( -q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, - undef, - ( $rel_lsid, $subj_id, $obj_id, $args{articleName} ) - ); - if ( $self->dbh->{mysql_insertid} ) { + my $insertid = $adaptor->insert_object_term2term({relationship_type => $rel_lsid}, + {object1_id => $subj_id}, + {object2_id => $obj_id}, + {object2_articlename => $args{articleName}}); + if ($insertid ) { return ( 1, "Object relationsihp created successfully", '' ); } else { return ( 0, "Object relationship creation failed for unknown reasons", @@ -534,32 +551,37 @@ #authority => $auth, #contact_email => $email); my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); - my ( $sbj_id, $sbj_lsid ) = $self->dbh->selectrow_array( - q{select service_id, service_lsid from service where service_type = ?}, - undef, $args{subject_node} - ); + + my $result = $adaptor->query_service({service_type => $args{subject_node}}); + my $row = shift(@$result); + my $sbj_id = $row->{service_id}; + my $sbj_lsid = $row->{service_lsid}; + return ( 0, qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ) unless defined $sbj_id; - my (@isa) = - $self->dbh->selectrow_array( - q{select * from service_term2term where service2_id = ?}, - undef, $sbj_id ); - if ( scalar @isa ) { + + my $isa = $adaptor->query_service_term2term({service2_id => $sbj_id}); + if ( scalar @$isa ) { return ( 0, qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ); } - my ( $obj_id, $obj_lsid ) = $self->dbh->selectrow_array( - q{select service_id, service_lsid from service where service_type = ?}, - undef, $args{object_node} - ); # get ID of the related service + $result = $adaptor->query_service({service_type => $args{object_node}}); + $row = shift(@$result); + my $obj_id = $row->{service_id}; + my $obj_lsid = $row->{service_lsid}; + # get ID of the related service + defined $obj_id || return ( 0, qq{Service $args{object_node} does not exist in the service ontology}, @@ -572,12 +594,11 @@ || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - $self->dbh->do( -q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, - undef, - ( $rel_lsid, $sbj_id, $obj_id ) - ); - if ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_service_term2term({relationship_type => $rel_lsid}, + {service1_id => $sbj_id}, + {service2_id => $obj_id}); + if ( $insertid ) { return ( 1, "Service relationship created successfully", '' ); } else { return ( 0, "Service relationship creation failed for unknown reasons", @@ -591,6 +612,9 @@ sub serviceExists { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that @@ -599,20 +623,22 @@ { return ( 1, "external ontology", $term ); } - my $sth; + my $result; if ( $term =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select service_id, service_type, service_lsid, description, authority, contact_email from service where service_lsid = ?" - ); + $result = $adaptor->query_service({service_lsid => $term}); + } else { - $sth = - $self->dbh->prepare( -"select service_id, service_type, service_lsid, description, authority, contact_email from service where service_type = ?" - ); + $result = $adaptor->query_service({service_type => $term}); + } - $sth->execute($term); - my ( $id, $type, $lsid, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $id = $row->{service_id}; + my $type = $row->{service_type}; + my $lsid = $row->{service_lsid}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($id) { return ( 1, $desc, $lsid ); } else { @@ -630,6 +656,8 @@ sub createServiceType { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); #node => $term, #descrioption => $desc, @@ -653,15 +681,14 @@ ? $args{'node'} : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - $self->dbh->do( -q{insert into service (service_type, service_lsid, description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - $args{'node'}, $LSID, $args{'description'}, - $args{'authority'}, $args{'contact_email'} - ) - ); - unless ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_service({service_type => $args{'node'}}, + {service_lsid => $LSID}, + {description => $args{'description'}, + {authority => $args{'authority'}, + {contact_email => $args{'contact_email'}); + + unless ( $insertid ) { return ( 0, "Service creation failed for unknown reasons", '' ); } return ( 1, "Service creation succeeded", $LSID ); @@ -673,6 +700,9 @@ sub deleteServiceType { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; if ( $term =~ /^urn:lsid/ @@ -692,35 +722,37 @@ "" ) unless $LSID; - my ( $id, $lsid ) = $self->dbh->selectrow_array( - q{select service_id, service_lsid from service where service_lsid = ?}, - undef, $LSID - ); + + my $result = $adaptor->query_service({service_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{service_id}; + my $lsid = $row->{service_lsid}; + if ( !defined $id ) { return ( 0, q{Service type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my (@isa) = - $self->dbh->selectrow_array( - q{select * from service_term2term where service2_id = ?}, - undef, $id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_service_term2term({service2_id => $id}); + + if ( scalar @$isa ) { return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } - $self->dbh->do( q{delete from service where service_id = ?}, undef, $id ); - if ( $self->dbh->err ) { - return ( 0, "Delete from Service Type table failed: $self->dbh->errstr", + my ($err, $errstr) = $adaptor->delete_service({service_id => $id}); + + if ( $err ) { + return ( 0, "Delete from Service Type table failed: $errstr", $lsid ); } - $self->dbh->do( q{delete from service_term2term where service1_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { + + ($err, $errstr) = $adaptor->delete_service_term2term({service1_id => $id}); + + if ( $err ) { return ( 0, -"Delete from Service Type Term2Term table failed: $self->dbh->errstr", +"Delete from Service Type Term2Term table failed: $errstr", $lsid ); } @@ -733,29 +765,34 @@ sub namespaceExists { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that - my $sth; if ( $term =~ /^urn:lsid/ && !( $term =~ /^urn:lsid:biomoby.org:namespacetype/ ) ) { return ( 1, "external ontology", $term ); } + my $result; if ( $term =~ /^urn:lsid:biomoby.org:namespacetype/ ) { - $sth = - $self->dbh->prepare( -"select namespace_id, namespace_type, namespace_lsid,description, authority, contact_email from namespace where namespace_lsid = ?" - ); + $result = $adaptor->query_namespace({namespace_lsid => $term}); + } else { - $sth = - $self->dbh->prepare( -"select namespace_id, namespace_type, namespace_lsid,description, authority, contact_email from namespace where namespace_type = ?" - ); + $result = $adaptor->query_namespace({namespace_type => $term}); + } - $sth->execute($term); - my ( $id, $type, $lsid, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $id = $row->{namespace_id}; + my $type = $row->{namespace_type}; + my $lsid = $row->{namespace_lsid}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($id) { return ( 1, $desc, $lsid ); } else { @@ -773,7 +810,8 @@ sub createNamespace { my ( $self, %args ) = @_; - + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); #node => $term, #descrioption => $desc, #authority => $auth, @@ -797,15 +835,14 @@ ? $args{'node'} : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - $self->dbh->do( -q{insert into namespace (namespace_type, namespace_lsid,description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - $args{'node'}, $LSID, $args{'description'}, - $args{'authority'}, $args{'contact_email'} - ) - ); - unless ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_namespace({namespace_type => $args{'node'}}, + {namespace_lsid => $LSID}, + {description => $args{'description'}}, + {authority => $args{'authority'}}, + {contact_email => $args{'contact_email'}}); + + unless ( $insertid ) { return ( 0, "Namespace creation failed for unknown reasons", '' ); } return ( 1, "Namespace creation succeeded", $LSID ); @@ -817,6 +854,8 @@ sub deleteNamespace { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); my $term = $args{term}; @@ -829,36 +868,38 @@ { return ( 0, "cannot delete a term from an external ontology", $term ); } - my ( $id, $lsid ) = $self->dbh->selectrow_array( -q{select namespace_id, namespace_lsid from namespace where namespace_lsid = ?}, - undef, $LSID - ); + + my $result = $adaptor->query_namespace({namespace_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{namespace_id}; + my $lsid = $row->{namespace_lsid}; + unless ($id) { return ( 0, q{Namespace type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my (@isa) = - $self->dbh->selectrow_array( - q{select * from namespace_term2term where namespace2_id = ?}, - undef, $id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_namespace_term2term({namespace2_id => $id}); + + if ( scalar @$isa ) { return ( 0, qq{Namespace type $term has dependencies in the ontology}, $lsid ); } - $self->dbh->do( q{delete from namespace where namespace_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { - return ( 0, "Delete from namespace table failed: $self->dbh->errstr", + + my ($err, $errstr) = $adaptor->delete_namespace({namespace_id => $id}); + + if ( $err ) { + return ( 0, "Delete from namespace table failed: $errstr", $lsid ); } - $self->dbh->do( q{delete from namespace_term2term where namespace1_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { + + ($err, $errstr) = $adaptor->delete_namespace_term2term({namespace1_id => $id}); + + if ( $err ) { return ( 0, - "Delete from namespace term2term table failed: $self->dbh->errstr", + "Delete from namespace term2term table failed: $errstr", $lsid ); } @@ -871,13 +912,13 @@ sub retrieveAllServiceTypes { my ($self) = @_; - my $types = - $self->dbh->selectall_arrayref( - q{select service_type, description from service}); - my @types = @{$types}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $types = $adaptor->query_service(); + my %response; - foreach (@types) { - $response{ $_->[0] } = $_->[1]; + foreach (@$types) { + $response{ $_->{service_type} } = $_->{description}; } return \%response; } @@ -888,13 +929,13 @@ sub retrieveAllNamespaceTypes { my ($self) = @_; - my $types = - $self->dbh->selectall_arrayref( - q{select namespace_type, description from namespace}); - my @types = @{$types}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $types = $adaptor->query_namespace(); + my %response; - foreach (@types) { - $response{ $_->[0] } = $_->[1]; + foreach (@$types) { + $response{ $_->{namespace_type} } = $_->{description}; } return \%response; } @@ -905,13 +946,13 @@ sub retrieveAllObjectClasses { my ($self) = @_; - my $types = - $self->dbh->selectall_arrayref( - q{select object_type, description from object}); - my @types = @{$types}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $types = $adaptor->query_object(); + my %response; - foreach (@types) { - $response{ $_->[0] } = $_->[1]; + foreach (@$types) { + $response{ $_->{object_type} } = $_->{description}; } return \%response; } @@ -924,11 +965,13 @@ sub getObjectCommonName { my ( $self, $URI ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return undef unless $URI =~ /urn\:lsid/; - my ($name) = - $self->dbh->selectrow_array( - q{select object_type from object where object_lsid = ?}, - undef, $URI ); + my $result = $adaptor->query_object({object_lsid => $URI}); + my $row = shift(@$result); + my $name = $row->{object_type}; + return $name ? $name : $URI; } @@ -938,11 +981,13 @@ sub getNamespaceCommonName { my ( $self, $URI ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return undef unless $URI =~ /urn\:lsid/; - my ($name) = - $self->dbh->selectrow_array( - q{select namespace_type from namespace where namespace_lsid = ?}, - undef, $URI ); + my $result = $adaptor->query_namespace({namespace_lsid => $URI}); + my $row = shift(@$result); + my $name = $row->{namespace_type}; + return $name ? $name : $URI; } @@ -952,11 +997,13 @@ sub getServiceCommonName { my ( $self, $URI ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return undef unless $URI =~ /urn\:lsid/; - my ($name) = - $self->dbh->selectrow_array( - q{select service_type from service where service_lsid = ?}, - undef, $URI ); + my $result = $adaptor->query_service({service_lsid => $URI}); + my $row = shift(@$result); + my $name = $row->{service_type}; + return $name ? $name : $URI; } @@ -966,11 +1013,14 @@ sub getServiceURI { my ( $self, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return $term if $term =~ /urn\:lsid/; - my ($id) = - $self->dbh->selectrow_array( - q{select service_lsid from service where service_type = ?}, - undef, $term ); + + my $result = $adaptor->query_service({service_type => $term}); + my $row = shift(@$result); + my $id = $row->{service_lsid}; + return $id; } @@ -980,11 +1030,14 @@ sub getObjectURI { my ( $self, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return $term if $term =~ /urn\:lsid/; - my ($id) = - $self->dbh->selectrow_array( - q{select object_lsid from object where object_type = ?}, - undef, $term ); + + my $result = $adaptor->query_object({object_type => $term}); + my $row = shift(@$result); + my $id = $row->{object_lsid}; + return $id; } @@ -994,11 +1047,15 @@ sub getNamespaceURI { my ( $self, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return $term if $term =~ /urn\:lsid/; - my ($id) = - $self->dbh->selectrow_array( - q{select namespace_lsid from namespace where namespace_type = ?}, - undef, $term ); + + my $result = $adaptor->query_namespace({namespace_type => $term}); + my $row = shift(@$result); + my $id = $row->{namespace_lsid}; + return $id; } @@ -1008,11 +1065,15 @@ sub getRelationshipURI { my ( $self, $ontology, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return $term if $term =~ /urn\:lsid/; - my ($id) = $self->dbh->selectrow_array( -q{select relationship_lsid from relationship where relationship_type = ? and ontology = ?}, - undef, $term, $ontology - ); + + my $result = $adaptor->query_relationship({relationship_type => $term}, 'and' {ontology => $ontology}); + my $row = shift(@$result); + my $id = $row->{relationship_lsid}; + return $id; } @@ -1022,15 +1083,17 @@ sub getRelationshipTypes { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $ontology = $args{'ontology'}; my $OS = MOBY::OntologyServer->new( ontology => "relationship" ); - my $defs = $OS->dbh->selectall_arrayref( -q{select relationship_lsid, relationship_type, authority, description from relationship where ontology = ?}, - undef, $ontology - ); + + my $defs = $adaptor->query_relationship({ontology => $ontology}); + my %result; - foreach ( @{$defs} ) { - $result{ $_->[0] } = [ $_->[1], $_->[2], $_->[3] ]; + foreach ( @$defs ) { + $result{ $_->{relationship_lsid} } = [ $_->{relationship_type}, $_->{authority}, $_->{description} ]; } return \%result; } @@ -1086,54 +1149,12 @@ sub _doRelationshipsQuery { my ( $self, $ontology, $term, $relationship, $direction ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $defs; - if ( $direction eq 'root' ) { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } else { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } + # query returns a reference to an array containing array references + $defs = $adaptor->getRelationship({direction => $direction}, {ontology => $ontology}, {term => $term}, {relationship => $relationship}); + # a very long piece of SQL statements have been refactored into Moby::Adaptor::moby::queryapi::mysql.pm return $defs; } From dwang at pub.open-bio.org Mon Jul 18 12:53:04 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 18 Jul 2005 12:53:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507181653.j6IGr478016252@pub.open-bio.org> dwang Mon Jul 18 12:53:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv16206/Perl/MOBY Modified Files: simple_input.pm collection_output.pm collection_input.pm simple_output.pm secondary_input.pm service_instance.pm Log Message: SQL statements replaced by generic api subroutines. Actual SQL exists in Moby::Adaptor::moby::queryapi::mysql.pm moby-live/Perl/MOBY simple_input.pm,1.5,1.6 collection_output.pm,1.3,1.4 collection_input.pm,1.3,1.4 simple_output.pm,1.4,1.5 secondary_input.pm,1.2,1.3 service_instance.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2004/11/18 17:41:14 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/18 16:53:03 1.6 @@ -100,11 +100,11 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_input( - object_type_uri => $self->object_type_uri, - namespace_type_uris => $self->namespace_type_uris, - article_name => $self->article_name, - service_instance_id => $self->service_instance_id, - collection_input_id => $self->collection_input_id, + {object_type_uri => $self->object_type_uri}, + {namespace_type_uris => $self->namespace_type_uris}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}, + {collection_input_id => $self->collection_input_id} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2004/11/18 17:41:14 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/18 16:53:03 1.4 @@ -94,8 +94,8 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_collection_output( - service_instance => $self->service_instance_id, - article_name => $self->article_name, ); + {service_instance => $self->service_instance_id}, + {article_name => $self->article_name} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2004/11/18 17:41:14 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/18 16:53:03 1.4 @@ -95,8 +95,8 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_collection_input( - service_instance => $self->service_instance_id, - article_name => $self->article_name, ); + {service_instance => $self->service_instance_id}, + {article_name => $self->article_name} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2004/11/18 17:41:15 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/18 16:53:03 1.5 @@ -99,11 +99,11 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_output( - object_type_uri => $self->object_type_uri, - namespace_type_uris => $self->namespace_type_uris, - article_name => $self->article_name, - service_instance_id => $self->service_instance_id, - collection_output_id => $self->collection_output_id, + {object_type_uri => $self->object_type_uri}, + {namespace_type_uris => $self->namespace_type_uris}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}, + {collection_output_id => $self->collection_output_id} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2004/11/18 17:41:14 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 16:53:03 1.3 @@ -2,6 +2,7 @@ package MOBY::secondary_input; use strict; use Carp; +use MOBY::Config; use vars qw($AUTOLOAD @ISA); =head1 NAME @@ -110,18 +111,17 @@ sub WRITE { my ($self) = @_; - my $dbh = $self->_dbh; - $dbh->do( -q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, - undef, - ( - $self->default_value, $self->maximum_value, - $self->minimum_value, $self->enum_value, - $self->datatype, $self->article_name, - $self->service_instance_id, - ) - ); - my $id = $dbh->{mysql_insertid}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, + {maximum_value => $self->maximum_value}, + {minimum_value => $self->minimum_value}, + {enum_value => $self->enum_value}, + {datatype => $self->datatype}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}); + + my $id = $dbh->{$insertid}; return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/05/30 23:33:44 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 16:53:03 1.12 @@ -272,16 +272,16 @@ . $self->servicename; my $id = $self->adaptor->insert_service_instance( - category => $self->category, - servicename => $self->servicename, - service_type_uri => $self->service_type_uri, - authority_id => $self->authority_id, - url => $self->url, - contact_email => $self->contact_email, - authoritative => $self->authoritative, - description => $self->description, - signatureURL => $self->signatureURL, - lsid => $service_lsid + {category => $self->category}, + {servicename => $self->servicename}, + {service_type_uri => $self->service_type_uri}, + {authority_id => $self->authority_id}, + {url => $self->url}, + {contact_email => $self->contact_email}, + {authoritative => $self->authoritative}, + {description => $self->description}, + {signatureURL => $self->signatureURL}, + {lsid => $service_lsid} ); $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists @@ -298,36 +298,29 @@ return undef; } $CONFIG ||= MOBY::Config->new; - $dbh->do( q{delete from service_instance where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from simple_input where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from simple_output where service_instance_id = ?}, - undef, $self->service_instance_id ); - my $sth = - $dbh->prepare( -q{select collection_input_id from collection_input where service_instance_id = ?} - ); - $sth->execute( $self->service_instance_id ); - while ( my ($id) = $sth->fetchrow_array ) { - $dbh->do( q{delete from simple_input where collection_input_id = ?}, - undef, $id ); - } - $sth = - $dbh->prepare( -q{select collection_output_id from collection_output where service_instance_id = ?} - ); - $sth->execute( $self->service_instance_id ); - while ( my ($id) = $sth->fetchrow_array ) { - $dbh->do( q{delete from simple_output where collection_output_id = ?}, - undef, $id ); - } - $dbh->do( q{delete from collection_input where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from collection_output where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from secondary_input where service_instance_id=?}, - undef, $self->service_instance_id ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + + $adaptor->delete_service_instance({service_instance_id => $self->service_instance_id}); + $adaptor->delete_simple_input({service_instance_id => $self->service_instance_id}); + $adaptor->delete_simple_output({service_instance_id => $self->service_instance_id}); + + my $result = $adaptor->query_collection_input({service_instance_id => $self->service_instance_id}); + + foreach my $row (@$result) { + my $id = $row->{collection_input_id}; + $adaptor->delete_simple_input({collection_input_id => $id}); + } + $result = $adaptor->query_collection_output({service_instance_id => $self->service_instance_id}); + + foreach my $row (@$result) { + my $id = $row->{collection_output_id}; + + $adaptor->delete_simple_output({collection_output_id => $id}); + } + $adaptor->delete_collection_input({service_instance_id => $self->service_instance_id}); + $adaptor->delete_collection_output({service_instance_id => $self->service_instance_id}); + $adaptor->delete_secondary_input({service_instance_id => $self->service_instance_id}); + return 1; } @@ -338,18 +331,21 @@ sub service_instance_exists { my ($self) = @_; + $CONFIG ||= MOBY::Config->new; + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; my $authority; - my ($id) = - $dbh->selectrow_array( - q{select authority_id from authority where authority_uri = ?}, - undef, $self->authority_uri ); + + my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $row = shift(@$result); + my $id = $row->{authority_id}; + return undef unless $id; - my ($svc) = $dbh->selectrow_array( -q{select service_instance_id from service_instance where authority_id = ? and servicename = ?}, - undef, - ( $id, $self->servicename ) - ); + + $result = $adaptor->query_service_instance({authority_id => $id}, 'and', {servicename => $self->servicename}); + $row = shift(@$result); + my $svc = $row->{service_instance_id}; + return $svc; } @@ -358,10 +354,14 @@ my ($self) = @_; my $dbh = $self->dbh; my $authority; - my ( $id, $name, $uri, $email ) = $dbh->selectrow_array( -q{select authority_id, authority_common_name, authority_uri, contact_email from authority where authority_uri = ?}, - undef, $self->authority_uri - ); + + my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $row = shift(@$result); + my $id = $row->{authority_id}; + my $name = $row->{authority_common_name}; + my $uri = $row->{authority_uri}; + my $email = $row->{contact_email}; + if ( defined $id ) { $authority = MOBY::authority->new( dbh => $self->dbh, From dwang at pub.open-bio.org Mon Jul 18 12:53:49 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 18 Jul 2005 12:53:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507181653.j6IGrnpY016287@pub.open-bio.org> dwang Mon Jul 18 12:53:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv16261/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: All routines that are implementated in mysql.pm now exists in queryapi interface moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/13 18:19:09 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/18 16:53:49 1.4 @@ -108,44 +108,67 @@ } - +# general query subroutine +# parameters: +# statement - a string SQL statement +# bind_values - an array of values to be bound to the parameters +# returns: +# resultset - reference to an array containing ARRAY references +sub general_query{ + die "general_query not implemented in adaptor\n"; +} + # -# authority table functions +# collection_input table functions # -sub query_authority{ - - +sub query_collection_input{ + die "query_collection_input not implemented in adaptor\n"; } -sub insert_authority{ - +sub insert_collection_input { + die "insert_collection_input not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} } -sub delete_authority{ - +sub delete_collection_input{ + die "delete_collection_input not implemented in adaptor\n"; } - # -# service_instance table functions +# collection_output table fuctions # -sub query_service_instance { - die "query_service_instance not implemented in adaptor\n"; +sub query_collection_output{ + die "query_collection_output not implemented in adaptor\n"; } -sub insert_service_instance { - die "insert_service_instance not implemented in adaptor\n"; +sub insert_collection_output { + die "insert_collection_output not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} } -sub delete_service_intance{ - +sub delete_collection_output{ + die "delete_collection_output not implemented in adaptor\n"; } - + # # simple_output table functions # sub query_simple_input{ - + die "query_simple_input not implemented in adaptor\n"; } sub insert_simple_input { @@ -171,14 +194,14 @@ } sub delete_simple_input{ - + die "delete_simple_input not implemented in adaptor\n"; } # # simple_output table functions # sub query_simple_output{ - + die "query_simple_output not implemented in adaptor\n"; } sub insert_simple_output { @@ -205,178 +228,214 @@ } sub delete_simple_output{ - -} - -# -# collection_input table functions -# -sub query_collection_input{ - + die "delete_simple_output not implemented in adaptor\n"; } -sub insert_collection_input { - die "insert_collection_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} -} - -sub delete_collection_input{ - -} - -# -# collection_output table fuctions -# -sub query_collection_output{ - +# secondary_input table functions +sub query_secondary_input{ + die "query_secondary_input not implemented in adaptor\n"; } -sub insert_collection_output { - die "insert_collection_output not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} +sub insert_secondary_input{ + die "insert_secondary_input not implemented in adaptor\n"; } -sub delete_collection_output{ - +sub delete_secondary_input{ + die "delete_secondary_input not implemented in adaptor\n"; } # # object table functions # sub query_object{ - + die "query_object not implemented in adaptor\n"; } sub insert_object{ - + die "insert_object not implemented in adaptor\n"; } sub delete_object{ - + die "delete_object not implemented in adaptor\n"; } # # object_term2term table functions # sub query_object_term2term{ - + die "query_object_term2term not implemented in adaptor\n"; } sub insert_object_term2term{ - + die "insert_object_term2term not implemented in adaptor\n"; } sub delete_object_term2term{ - + die "delete_object_term2term not implemented in adaptor\n"; } # -# relationship table functions +# service_instance table functions # -sub query_relationship{ - +sub query_service_instance { + die "query_service_instance not implemented in adaptor\n"; } -sub insert_relationship{ - +sub match_service_type_uri{ + die "match_service_type_uri not implemented in adaptor\n"; } -sub delete_relationship{ +sub insert_service_instance { + die "insert_service_instance not implemented in adaptor\n"; +} + +sub delete_service_intance{ + die "delete_service_intance not implemented in adaptor\n"; +} +# +# authority table functions +# +sub query_authority{ + die "query_authority not implemented in adaptor\n"; +} + +sub getUniqueAuthorityURI{ + die "getUniqueAuthorityURI not implemented in adaptor\n"; +} + +sub insert_authority{ + die "insert_authority not implemented in adaptor\n"; +} + +sub delete_authority{ + die "delete_authority not implemented in adaptor\n"; } # # service table fuctions # sub query_service{ - + die "query_service not implemented in adaptor\n"; } sub insert_service{ - + die "insert_service not implemented in adaptor\n"; } sub delete_service{ - + die "delete_service not implemented in adaptor\n"; } # # service_term2term table functions # sub query_service_term2term{ - + die "query_service_term2term not implemented in adaptor\n"; } sub insert_service_term2term{ - + die "insert_service_term2term not implemented in adaptor\n"; } sub delete_service_term2term{ - + die "delete_service_term2term not implemented in adaptor\n"; +} + +# +# relationship table functions +# +sub query_relationship{ + die "query_relationship not implemented in adaptor\n"; +} + +sub insert_relationship{ + die "insert_relationship not implemented in adaptor\n"; +} + +sub delete_relationship{ + die "delete_relationship not implemented in adaptor\n"; } # # namespace table functions # sub query_namespace{ - + die "query_namespace not implemented in adaptor\n"; } sub insert_namespace{ - + die "insert_namespace not implemented in adaptor\n"; } sub delete_namespace{ - + die "delete_namespace not implemented in adaptor\n"; } # # namespace_term2term table functions # sub query_namespace_term2term{ - + die "query_namespace_term2term not implemented in adaptor\n"; } sub insert_namespace_term2term{ - + die "insert_namespace_term2term not implemented in adaptor\n"; } sub delete_namespace_term2term{ - + die "delete_namespace_term2term not implemented in adaptor\n"; } -# secondary_input table functions -sub query_secondary_input{ - +# custom query subroutine for Moby::Central.pm->deregisterObjectClass() +sub checkClassUsedByService{ + die "checkClassUsedByService not implemented in adaptor\n"; } -sub insert_secondary_input{ - +# custom query routine for Moby::Central.pm -> deregisterNamespace() +sub checkNamespaceUsedByService{ + die "checkNamespaceUsedByService not implemented in adaptor\n"; } -sub delete_secondary_input{ - +# custom query routine for Moby::Central.pm -> findService() +sub checkKeywords{ + die "checkKeywords not implemented in adaptor\n"; } -# -# query term2term tables - queries relation between two tables -# -sub select_term2term{ - +# custom query subroutine for Moby::Central.pm->_searchForSimple() +sub getFromSimple{ + die "getFromSimple not implemented in adaptor\n"; +} + +# custom query subroutine for Moby::Central.pm->_searchForCollection() +sub getFromCollection{ + die "getFromCollection not implemented in adaptor\n"; +} + +# custom query subroutine for Moby::Central.pm->RetrieveServiceNames +sub getServiceNames{ + die "getServiceNames not implemented in adaptor\n"; +} + +# custom query for Moby::Central.pm->_flatten +sub getParentTerms{ + die "getParentTerms not implemented in adaptor\n"; +} + +# custom query subroutine for selecting from object_term2term and object tables +# used in Moby::OntologyServer.pm->retrieveObject() +sub getObjectRelationships{ + die "getObjectRelationships not implemented in adaptor\n"; +} + +# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() +# note: returns a reference to an array containing ARRAY references +sub getRelationship{ + die "getRelationship not implemented in adaptor\n"; +} + +sub _checkURI { + die "_checkURI not implemented in adaptor\n"; } sub _dump { From dwang at pub.open-bio.org Mon Jul 18 12:54:29 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 18 Jul 2005 12:54:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507181654.j6IGsTme016332@pub.open-bio.org> dwang Mon Jul 18 12:54:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv16306/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: minor changes to comments and indentation moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/15 16:39:11 1.13 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 16:54:29 1.14 @@ -1087,8 +1087,7 @@ } # custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection -{ +sub getFromCollection{ my ($self, @args) = @_; my $dbh = $self->dbh; my $inout = get_value('inout', @args); @@ -1120,8 +1119,7 @@ } # custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames -{ +sub getServiceNames{ my ($self, @args) = @_; my $dbh = $self->dbh; my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; @@ -1132,8 +1130,7 @@ } # custom query for Moby::Central.pm->_flatten -sub getParentTerms -{ +sub getParentTerms{ my ($self, @args) = @_; my $dbh = $self->dbh; From mwilkinson at pub.open-bio.org Mon Jul 18 18:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 18 Jul 2005 18:32:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182232.j6IMWK1W017179@pub.open-bio.org> mwilkinson Mon Jul 18 18:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv17143/MOBY Modified Files: OntologyServer.pm Log Message: fixing brackets and semicolons moby-live/Perl/MOBY OntologyServer.pm,1.51,1.52 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/15 16:40:45 1.51 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/18 22:32:20 1.52 @@ -684,9 +684,9 @@ my $insertid = $adaptor->insert_service({service_type => $args{'node'}}, {service_lsid => $LSID}, - {description => $args{'description'}, - {authority => $args{'authority'}, - {contact_email => $args{'contact_email'}); + {description => $args{'description'}}, + {authority => $args{'authority'}}, + {contact_email => $args{'contact_email'}}); unless ( $insertid ) { return ( 0, "Service creation failed for unknown reasons", '' ); @@ -1070,7 +1070,7 @@ return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_relationship({relationship_type => $term}, 'and' {ontology => $ontology}); + my $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ontology}); my $row = shift(@$result); my $id = $row->{relationship_lsid}; From mwilkinson at pub.open-bio.org Mon Jul 18 18:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 18 Jul 2005 18:32:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182232.j6IMWKUb017159@pub.open-bio.org> mwilkinson Mon Jul 18 18:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/Accessories In directory pub.open-bio.org:/tmp/cvs-serv17143/Accessories Removed Files: RESOURCES Log Message: fixing brackets and semicolons moby-live/Perl/Accessories RESOURCES,1.1,NONE rcsdiff: /home/repository/moby/moby-live/Perl/Accessories/RCS/RESOURCES,v: No such file or directory From mwilkinson at pub.open-bio.org Mon Jul 18 18:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 18 Jul 2005 18:32:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182232.j6IMWKIE017198@pub.open-bio.org> mwilkinson Mon Jul 18 18:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv17143/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing brackets and semicolons moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 16:54:29 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 22:32:20 1.15 @@ -173,7 +173,7 @@ my ($self, @args) = @_; my $dbh = $self->dbh; my $statement = get_value('statement', @args); - my $sth = $dbh->prepare($statement}; + my $sth = $dbh->prepare($statement); if (@args > 1) { my $bindvalues = get_value('bind_values', @args); @@ -183,7 +183,7 @@ $sth->execute; } my $result = $sth->fetchall_arrayref(); - return result; + return $result; } sub query_collection_input{ @@ -340,7 +340,7 @@ my @bindvalues = (); ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, - undef, @bindvalues ) + undef, @bindvalues ); if (dbh->err){ return (1, dbh->errstr); } @@ -693,8 +693,8 @@ sub getUniqueAuthorityURI{ my ($self, @args) = @_; my $dbh = $self->dbh; - $statement = "select distinct authority_uri from authority"; - $bindvalues = (); + my $statement = "select distinct authority_uri from authority"; + my @bindvalues = (); my $result = do_query($dbh, $statement, @bindvalues); return $result; } @@ -709,7 +709,7 @@ values (?,?,?)", undef, (get_value('authority_common_name', @args), - get_value('authority_uri' @args), + get_value('authority_uri', @args), get_value('contact_email', @args))); my $id = $dbh->{mysql_insertid}; return $id; @@ -976,9 +976,9 @@ my $dbh = $self->dbh; my $existingURI = get_value('namespace_type_uris', @args); my $term = get_value('term', @args); + my $errstr; -my $sth = - $dbh->prepare( + my $sth = $dbh->prepare( "select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" ); $sth->execute; @@ -988,12 +988,11 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } - $sth = - $dbh->prepare( + $sth = $dbh->prepare( "select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" ); $sth->execute; @@ -1002,7 +1001,7 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } @@ -1016,7 +1015,7 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } @@ -1030,11 +1029,11 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } - return (0, $errstr); + return (0, ""); } # custom query routine for Moby::Central.pm -> findService() @@ -1046,13 +1045,13 @@ my $searchstring; foreach my $kw ( @{ $findme{keywords} } ) { - $debug && &_LOG("KEYWORD $kw\n"); +# $debug && &_LOG("KEYWORD $kw\n"); $kw =~ s/\*//g; $kw = $dbh->quote("%$kw%"); $searchstring .= " OR description like $kw "; } $searchstring =~ s/OR//; # just the first one - $debug && &_LOG("search $searchstring\n"); +# $debug && &_LOG("search $searchstring\n"); my $statement = "select service_instance_id from service_instance where $searchstring"; my @bindvalues = (); @@ -1103,7 +1102,7 @@ where s.collection_${inout}_id IS NOT NULL AND s.collection_${inout}_id = c.collection_${inout}_id - AND object_type_uri = '$objectURI' " + AND object_type_uri = '$objectURI' "; my $nsquery; foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; From mwilkinson at pub.open-bio.org Mon Jul 18 18:46:00 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 18 Jul 2005 18:46:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182246.j6IMk0oR017294@pub.open-bio.org> mwilkinson Mon Jul 18 18:46:00 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv17267/MOBY Modified Files: Central.pm secondary_input.pm service_instance.pm Log Message: fixing brackets and semicolons moby-live/Perl/MOBY Central.pm,1.159,1.160 secondary_input.pm,1.3,1.4 service_instance.pm,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.159 retrieving revision 1.160 diff -u -r1.159 -r1.160 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 21:53:11 1.159 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/18 22:46:00 1.160 @@ -22,14 +22,16 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::RDF::ServiceInstanceRDF; -use RDF::Core; -use RDF::Core::Model; -use RDF::Core::Literal; -use RDF::Core::Statement; -use RDF::Core::Model::Serializer; -use RDF::Core::Storage::Memory; -use RDF::Core::Constants qw(:xml :rdf :rdfs); +use MOBY::Client::Central; + +#use MOBY::RDF::ServiceInstanceRDF; +#use RDF::Core; +#use RDF::Core::Model; +#use RDF::Core::Literal; +#use RDF::Core::Statement; +#use RDF::Core::Model::Serializer; +#use RDF::Core::Storage::Memory; +#use RDF::Core::Constants qw(:xml :rdf :rdfs); use MOBY::MobyXMLConstants; my $debug = 0; @@ -1329,8 +1331,6 @@ "" ); } - - use MOBY::Client::Central; my $services = MOBY::Client::Central::_parseServices( '', '', $si ); my $service_instance = shift @{$services}; @@ -3423,7 +3423,7 @@ $output .= "\t\t\n"; } $result = $adaptor->query_collection_input({service_instance => $_}); - $sth_collection_ins->execute($_); +# $sth_collection_ins->execute($_); foreach my $row (@$result) { @@ -3485,7 +3485,7 @@ my $articlename = $row->{article_name}; $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id = $collid}); + my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id => $collid}); foreach my $row2 (@$result2 ) { my $objURI = $row2->{object_type_uri}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 16:53:03 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 22:46:00 1.4 @@ -113,6 +113,7 @@ my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $dbh = $self->dbh; my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, {maximum_value => $self->maximum_value}, {minimum_value => $self->minimum_value}, =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 16:53:03 1.12 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 22:46:00 1.13 @@ -354,6 +354,8 @@ my ($self) = @_; my $dbh = $self->dbh; my $authority; + $CONFIG ||= MOBY::Config->new; + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); my $row = shift(@$result); From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxZv019448@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/Clients/help In directory pub.open-bio.org:/tmp/cvs-serv19358/src/Clients/help Modified Files: MobyCmdLineClient_usage.txt Log Message: moby-live/Java/src/Clients/help MobyCmdLineClient_usage.txt,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/help/MobyCmdLineClient_usage.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/Clients/help/MobyCmdLineClient_usage.txt 2004/12/05 22:28:02 1.7 +++ /home/repository/moby/moby-live/Java/src/Clients/help/MobyCmdLineClient_usage.txt 2005/07/19 12:39:58 1.8 @@ -9,16 +9,17 @@ -e ia an endpoint of a Moby registry - (default: http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY-Central.pl) + (default: http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl) -uri is a URI defining Moby registry's namespace - (default: http://mobycentral.cbr.nrc.ca/MOBY/Central) + (default: http://mobycentral.icapture.ubc.ca/MOBY/Central) where specify what to ask a Moby registry to do: To get lists of various entities registered by Moby: -ls ... list names of all available services + -la ... list names of all available services sorted by authorities -lp ... list names of all available service providers -lt ... list names and descriptions of all service types -ln ... list names and descriptions of all namespaces From senger at pub.open-bio.org Tue Jul 19 08:39:58 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdwHn019429@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/Clients In directory pub.open-bio.org:/tmp/cvs-serv19358/src/Clients Modified Files: MobyCmdLineClient.java MobyGraphs.java Log Message: moby-live/Java/src/Clients MobyCmdLineClient.java,1.8,1.9 MobyGraphs.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java 2004/12/05 22:28:02 1.8 +++ /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java 2005/07/19 12:39:58 1.9 @@ -95,12 +95,29 @@ if (cmd.hasOption ("-ls")) { decorationLn ("Service names:"); decorationLn ("--------------"); - Map names = worker.getServiceNames(); + Map authorities = worker.getServiceNamesByAuthority(); - for (Iterator it = names.entrySet().iterator(); it.hasNext(); ) { + for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) { + Map.Entry entry = (Map.Entry)it.next(); + String[] names = (String[])entry.getValue(); + for (int i = 0; i < names.length; i++) { + System.out.println (names[i]); + System.out.println ("\t" + entry.getKey()); + } + } + } + + if (cmd.hasOption ("-la")) { + decorationLn ("Service names by authorities:"); + decorationLn ("-----------------------------"); + Map authorities = worker.getServiceNamesByAuthority(); + + for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry)it.next(); System.out.println (entry.getKey()); - System.out.println ("\t" + entry.getValue()); + String[] names = (String[])entry.getValue(); + for (int i = 0; i < names.length; i++) + System.out.println ("\t" + names[i]); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java 2004/11/12 23:09:02 1.7 +++ /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java 2005/07/19 12:39:58 1.8 @@ -126,7 +126,55 @@ decorationLn ("Retrieving services..."); MobyService[] services = worker.getServices(); decorationLn ("Creating a graph of the services..."); - ServicesEdge[] edges = ServiceConnections.build (dataTypes, services); + ServicesEdge[] edges = null; + DataServiceEdge[] debugStartingEdges = null; + DataServiceEdge[] debugEndingEdges = null; + + // an undocumented option for debugging (see an + // example file in 'data' directory) + String xfile = cmd.getParam ("-X"); + boolean xfileing = (xfile != null); + + if (xfileing) { + Vector ev = new Vector(); + Vector evs = new Vector(); + Vector eve = new Vector(); + String line; + BufferedReader data = null; + data = new BufferedReader + (new InputStreamReader (new FileInputStream (xfile))); + while ((line = data.readLine()) != null) { + if (line.trim().equals ("")) continue; + if (line.trim().startsWith ("#")) continue; + String[] fields = StringUtils.split (line); + if (fields.length > 1) { + if (fields[0].equalsIgnoreCase ("start")) { + DataServiceEdge dse = new DataServiceEdge (new MobyDataType ("start"), + new MobyService (fields[1]), + ""); + evs.addElement (dse); + } else if (fields[1].equalsIgnoreCase ("end")) { + DataServiceEdge dse = new DataServiceEdge (new MobyService (fields[0]), + new MobyDataType ("end"), + ""); + eve.addElement (dse); + } else ev.addElement (new ServicesEdge (new MobyService (fields[0]), + new MobyService (fields[1]), + "")); + } + } + edges = new ServicesEdge[ev.size()]; + ev.copyInto (edges); + debugStartingEdges = new DataServiceEdge[evs.size()]; + evs.copyInto (debugStartingEdges); + debugEndingEdges = new DataServiceEdge[eve.size()]; + eve.copyInto (debugEndingEdges); + + } else { + edges = ServiceConnections.build (dataTypes, services); + } + + System.out.println ("EDGES: " + edges.length); // filter edges String[] authorities = null; @@ -144,13 +192,23 @@ } edges = FilterServices.filter (edges, authorities, serviceNames, depth); + System.out.println ("Filtered EDGES: " + edges.length); + + if (xfileing) { + System.out.println ("List of EDGES: "); + for (int i = 0; i < edges.length; i++) { + System.out.println ("\t" + edges[i].toString()); + } + } + if (cmd.hasParam ("-path")) { String[] pathEnds = cmd.getParam ("-path", 2); if (pathEnds[0] == null || pathEnds[1] == null) { System.err.println ("Missing value for parameter '-path'. It should be followed by two service names."); System.exit (1); } - edges = FilterServices.pathes (edges, pathEnds[0], pathEnds[1]); +// edges = FilterServices.pathes (edges, pathEnds[0], pathEnds[1]); + edges = FilterServices.pathes2 (edges, pathEnds[0], pathEnds[1]); if (edges == null) { System.err.println ("No connection found between '" + pathEnds[0] + "' and '" + pathEnds[1] + "'"); @@ -170,20 +228,62 @@ MobyPrimaryDataSimple sourceData = createSimpleData (pathEnds[0]); MobyPrimaryDataSimple targetData = createSimpleData (pathEnds[1]); - DataServiceEdge[] startingEdges = ServiceConnections.findStartingEdges (sourceData, dataTypes, services); - DataServiceEdge[] endingEdges = ServiceConnections.findEndingEdges (targetData, dataTypes, services); + DataServiceEdge[] startingEdges = null; + if (debugStartingEdges == null) + startingEdges = ServiceConnections.findStartingEdges (sourceData, dataTypes, services); + else + startingEdges = debugStartingEdges; + DataServiceEdge[] endingEdges = null; + if (debugEndingEdges == null) + endingEdges = ServiceConnections.findEndingEdges (targetData, dataTypes, services); + else + endingEdges = debugEndingEdges; + + System.out.println ("SE: " + startingEdges.length); + if (xfileing) { + for (int i = 0; i < startingEdges.length; i++) { + System.out.println ("\t" + startingEdges[i].toString()); + } + } + System.out.println ("EE: " + endingEdges.length); + if (xfileing) { + for (int i = 0; i < endingEdges.length; i++) { + System.out.println ("\t" + endingEdges[i].toString()); + } + } // this creates *all* pathes, but some of them have cycles and inside branches - separatePaths = FilterServices.dataPaths (startingEdges, edges, endingEdges); + separatePaths = FilterServices.dataPaths (startingEdges, edges, endingEdges); if (separatePaths.length == 0) { System.err.println ("No connection found between '" + pathEnds[0] + "' and '" + pathEnds[1] + "'"); System.exit(1); } + + System.out.println ("After dataPaths: " + separatePaths.length); + if (xfileing) { + for (int i = 0; i < separatePaths.length; i++) { + System.out.println ("Separate data path " + (i+1)); + for (int j = 0; j < separatePaths[i].length; j++) { + System.out.println ("\t" + separatePaths[i][j]); + } + } + } + allPaths = FilterServices.joinPaths (separatePaths); + System.out.println ("After joinPaths: " + allPaths.length); + if (xfileing) { + System.out.println ("Join paths: "); + for (int i = 0; i < allPaths.length; i++) { + System.out.println ("\t" + allPaths[i].toString()); + } + } + + // separate paths to straight paths (no cycles, no branches) + separatePaths = FilterServices.straightDataPaths (startingEdges, allPaths, endingEdges); - // this separate paths to straight paths (no cycles, no branches) - separatePaths = FilterServices.straightDataPaths (startingEdges, allPaths, endingEdges); + System.out.println ("After straightDataPaths: " + separatePaths.length); +// System.exit (1); } // create a graph (in whatever format) @@ -236,7 +336,7 @@ } else { graphs = new String [1]; - graphs[0] = Graphviz.createServicesGraph (allPaths, props); + graphs[0] = Graphviz.createServicesGraph (allPaths, props); } String fn = cmd.getParam ("-fs"); From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxn1019586@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/xmls In directory pub.open-bio.org:/tmp/cvs-serv19358/xmls Modified Files: libraries.xml Log Message: moby-live/Java/xmls libraries.xml,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/libraries.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/xmls/libraries.xml 2005/05/19 20:18:54 1.1 +++ /home/repository/moby/moby-live/Java/xmls/libraries.xml 2005/07/19 12:39:59 1.2 @@ -8,7 +8,7 @@ - + From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxK1019525@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv19358/src/main/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/06/17 19:25:31 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/19 12:39:59 1.8 @@ -1015,7 +1015,7 @@ * the maximum value of the secondary input * @param min * the minimum value of the secondary input * - * @param enum + * @param enumeration * the enumeration value for the secondary input */ From senger at pub.open-bio.org Tue Jul 19 08:39:58 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdwY1019377@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java In directory pub.open-bio.org:/tmp/cvs-serv19358 Modified Files: build.xml Log Message: moby-live/Java build.xml,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Java/build.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Java/build.xml 2005/05/19 20:18:53 1.16 +++ /home/repository/moby/moby-live/Java/build.xml 2005/07/19 12:39:58 1.17 @@ -207,11 +207,13 @@ @@ -256,7 +258,7 @@ @@ -501,13 +502,28 @@ - Tomcat Catalina not found. - Please set environment variable CATALINA_HOME to point to it, or - create a file 'build.properties' and put there the line: - catalina.home = <location of your CATALINA> - (do not include '<' and '>' there) + + Tomcat Catalina not found. + ----------------------------------- + Please set environment variable CATALINA_HOME to point to it, or + create a file 'build.properties' and put there the line: + catalina.home = <location of your CATALINA> + (do not include '<' and '>' there) - + + + + + + + + + Tomcat does not seem to be running. + ----------------------------------- + I have just checked ${tomcat.host}:${tomcat.port}... + You may perhaps consider to start it. + + @@ -606,6 +622,9 @@ + + @@ -626,7 +645,7 @@ - + From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdx99019544@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv19358/src/main/org/biomoby/shared Modified Files: Central.java Log Message: moby-live/Java/src/main/org/biomoby/shared Central.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java 2005/04/07 16:37:02 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java 2005/07/19 12:39:59 1.10 @@ -28,20 +28,6 @@ * * http://biomoby.org. *

- * - *

Last changes (in backwards order)
- *
    - *
  • New methods retrieving location of a Moby registry have been added: - * {@link #getRegistryEndpoint}, - * {@link #getRegistryNamespace}, - *
  • Added new constants defining relationship types as integers. - *
  • New methods retrieving various types of relationships have been added: - * {@link #getDataTypeRelationships}, - * {@link #getServiceTypeRelationships} - *
  • Added constants defining recognizable relationship types - * ({@link #ISA}, {@link #HASA}, {@link #HAS}) - *
- *

* @author Martin Senger * @version $Id$ */ @@ -81,8 +67,13 @@ static final int iHAS = 3; /************************************************************************** - * Get a (redundant) list of all registered service names. - *

+ * Get a (redundant) list of all registered service names.

+ * + * @deprecated Replaced by {@link + * #getServiceNamesByAuthority}. The reason is that this method + * returns a random result if there are more services with the + * same name but belonging to different authorities.

+ * * @return a hash table where keys are names of services while * values are their authorities * @throws MobyException if communication with the Moby Registry fails @@ -91,6 +82,20 @@ throws MobyException; /************************************************************************** + * Get a list of all authorities - and for each of them a list of + * their registered service names.

+ * + * This method is a better replacement for the deprecated method + * {@link #getServiceNames}.

+ * + * @return a hash table where keys are authority names and values + * are arrays of service names provided by each authority + * @throws MobyException if communication with the Moby Registry fails + *************************************************************************/ + Map getServiceNamesByAuthority() + throws MobyException; + + /************************************************************************** * Get the list of all providers (each provider is represented by an * authority's URI. *

From senger at pub.open-bio.org Tue Jul 19 08:39:58 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdwhD019404@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv19358/docs Modified Files: 3rdPartyLibraries.html ChangeLog Download.html Added Files: CVS.html Log Message: moby-live/Java/docs CVS.html,NONE,1.1 3rdPartyLibraries.html,1.2,1.3 ChangeLog,1.30,1.31 Download.html,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/3rdPartyLibraries.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/docs/3rdPartyLibraries.html 2005/05/19 20:25:40 1.2 +++ /home/repository/moby/moby-live/Java/docs/3rdPartyLibraries.html 2005/07/19 12:39:58 1.3 @@ -10,20 +10,47 @@

Third-party Libraries Guidelines

-Comming soon.. -

+The third-party libraries are (mostly) .jar files whose +source code is not included in the jMoby CVS repository.

-For now, just look into xmls/libraries.xml - and it's almost -self-explanatory... +Neither their binary code (classes themselves). That's why the jMoby's +Ant tasks need to get it first from some remote repository. The +question is where is such remote repository and how to update it (if +needed). This document explains that.

+ +The third-party jar files are retrievable by HTTP protocol +from the place that is defined in the Ant property remote.dir +in the xmls/libraries file. In the same file, there is also a +full list of the third-party libraries needed in jMoby. If you need to +add a library, put it there (the name must appear in three places in +that file, actually).

+ +However, to put the new name there, it is not enough. You need also to +add such new jar file into the remote repository (or to +update there one if you wish jMoby to use a newer version). In order +to do that, you need to check-out and update/commit to the CVS module +jars-archive (note that you do not need to do this +if you are just using jMoby, or developing with jMoby). The module is +located together with other Biomoby CVS modules - so follow the normal +way: + +

+export CVS_RSH=ssh
+cvs -d :ext:your-user-name at pub.open-bio.org:/home/repository/moby co -P jars-archive
+
+ +Once you have committed there a new library, or a new version of an +existing library, you need to wait until it is propagated to the place +indicated by the remote.dir. This is done by a cron job that +runs at 20 past the hour every other hour.

-


Martin Senger
-Last modified: Thu May 19 20:35:23 2005 +Last modified: Tue Jul 19 14:16:23 2005
=================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/05/19 20:18:53 1.30 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/07/19 12:39:58 1.31 @@ -1,3 +1,16 @@ +2005-07-19 Martin Senger + + * Changed the remote repository for the third-party jar files. + + * Added a new option -la to the MobyCmdLineClient to list services + by authorities. + + * Added new method getServiceNamesByAuthority() to the + Central.java interface. getServiceNames() deprecated. + + * Default location and namespace of the Moby Central has been + changed (in CentralImpl.java). + 2005-05-19 Martin Senger * Updated build.xml; also separate some fragments into xmls =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Download.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/docs/Download.html 2005/05/19 20:18:53 1.4 +++ /home/repository/moby/moby-live/Java/docs/Download.html 2005/07/19 12:39:58 1.5 @@ -42,9 +42,10 @@

Using jMoby from CVS

-Once you checked out your local CVS copy, go to the -moby-live/Java subdirectory. All directory and files names -used below assume that you are in this directory.

+Once you checked out your local CVS copy (here is how to do it), go to the moby-live/Java +subdirectory. All directory and files names used below assume that you +are in this directory.

How to build it
@@ -367,7 +368,7 @@
Martin Senger
-Last modified: Thu May 19 19:07:17 2005 +Last modified: Tue Jul 19 11:34:08 2005
From gordonp at pub.open-bio.org Tue Jul 19 08:59:21 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Tue, 19 Jul 2005 08:59:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191259.j6JCxLDe019685@pub.open-bio.org> gordonp Tue Jul 19 08:59:21 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory pub.open-bio.org:/tmp/cvs-serv19660 Modified Files: MobyDataSecondaryInstance.java Log Message: Changed data type variable name to not overshadow protected variable declaration in parent class moby-live/Java/src/main/org/biomoby/shared/data MobyDataSecondaryInstance.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/05/12 04:59:49 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/07/19 12:59:21 1.2 @@ -8,7 +8,7 @@ public class MobyDataSecondaryInstance extends MobySecondaryData{ protected String dataValue = null; - protected MobySecondaryData dataType = null; + protected MobySecondaryData secDataType = null; public MobyDataSecondaryInstance(MobySecondaryData type, String value){ this(type); @@ -26,7 +26,7 @@ setDefaultValue(type.getDefaultValue()); setMinimumValue(type.getMinimumValue()); setMaximumValue(type.getMaximumValue()); - dataType = type; + secDataType = type; } public void setValue(String value) throws IllegalArgumentException{ @@ -39,7 +39,7 @@ public String toXML(){ return " " + dataValue + "\n"; } } From senger at pub.open-bio.org Tue Jul 19 08:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxlX019566@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory pub.open-bio.org:/tmp/cvs-serv19358/src/main/org/biomoby/shared/data Modified Files: MobyDataObject.java Log Message: moby-live/Java/src/main/org/biomoby/shared/data MobyDataObject.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/07/19 12:39:59 1.3 @@ -88,7 +88,7 @@ * will also parse a MOBY XML Object wrapped in a Simple tag when the Simple * is passed in as the main element. * - * @param the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag + * @param objectTag the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag */ public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws IllegalArgumentException{ MobyDataObject object = null; From senger at pub.open-bio.org Tue Jul 19 09:08:31 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:08:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191308.j6JD8VRn019766@pub.open-bio.org> senger Tue Jul 19 09:08:31 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv19747/docs Modified Files: Download.html Log Message: moby-live/Java/docs Download.html,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Download.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/docs/Download.html 2005/07/19 12:39:58 1.5 +++ /home/repository/moby/moby-live/Java/docs/Download.html 2005/07/19 13:08:31 1.6 @@ -272,11 +272,9 @@ some specific features. (Remember, however, that you can always get everything in one go from the CVS repository.)

-The binary distributions are available either from the main jMoby site (located on the same place as the main -BioMoby pages), or from http://industry.ebi.ac.uk/~senger/jMoby/dist/. -

+BioMoby pages).

Command-line clients exploring BioMoby
@@ -368,7 +366,7 @@
Martin Senger
-Last modified: Tue Jul 19 11:34:08 2005 +Last modified: Tue Jul 19 14:52:57 2005
From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGrTt019848@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs/dist In directory pub.open-bio.org:/tmp/cvs-serv19810/docs/dist Modified Files: _README_ Log Message: moby-live/Java/docs/dist _README_,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/dist/_README_,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/docs/dist/_README_ 2004/12/05 22:28:02 1.3 +++ /home/repository/moby/moby-live/Java/docs/dist/_README_ 2005/07/19 13:16:53 1.4 @@ -1,6 +1,5 @@ This is a distribution directory of jMoby project. -More details in http://www.biomoby.org/moby-live/Java/docs/index.html -Mirror: http://industry.ebi.ac.uk/~senger/jMoby/ +More details in http://www.biomoby.org/moby-live/Java/docs/index.html. Binary distribution has everything except sources and Ant files to build things: @@ -24,7 +23,7 @@ -------------------------------------------------------------------- File: README Comments to the biomoby mailing lists, or directly to -Martin Senger (senger at ebi.ac.uk). +Martin Senger (martin.senger at gmail.com). $Id$ -------------------------------------------------------------------- From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGroI019829@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java In directory pub.open-bio.org:/tmp/cvs-serv19810 Modified Files: README Log Message: moby-live/Java README,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/README,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/README 2004/12/05 22:28:01 1.8 +++ /home/repository/moby/moby-live/Java/README 2005/07/19 13:16:53 1.9 @@ -8,7 +8,7 @@ Find more in docs/index.html. If you do not want to build it you can use the binary distribution -which is available at http://industry.ebi.ac.uk/~senger/jMoby/dist/. +which is available at http://www.biomoby.org/moby-live/Java/docs/dist/. HOW TO BUILD IT --------------- From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGruI019907@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory pub.open-bio.org:/tmp/cvs-serv19810/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/19 12:39:59 1.12 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/19 13:16:53 1.13 @@ -45,7 +45,7 @@ * MOBY format. It depends on * having already retrieved the definition of the Web service via * the MOBY central registry using the - * jMOBY API, + * jMOBY API, * and for now it uses the * Apache * Axis Web services framework, as well as Apache Xalan. There are code comments for the From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGrYj019888@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/lib In directory pub.open-bio.org:/tmp/cvs-serv19810/lib Modified Files: README Log Message: moby-live/Java/lib README,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/lib/README,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/lib/README 2003/11/08 00:27:24 1.4 +++ /home/repository/moby/moby-live/Java/lib/README 2005/07/19 13:16:53 1.5 @@ -1,7 +1,7 @@ -------------------------------------------------------------------- File: README Comments to the biomoby mailing lists, or directly to Martin Senger -(senger at ebi.ac.uk). +(martin.senger at gmail.com). $Id$ -------------------------------------------------------------------- @@ -10,7 +10,7 @@ separate subdirectory) can be fetched automatically from a remote site. This is usually done by calling build.sh (which uses ant's target 'gather' to do it). The remote site that is used is defined in -the build.xml. +the xmls/libraries.xml. You are, of course, free to fetch them manually in any convenient time and from any convenient site. Doing that may be even more correct way @@ -24,26 +24,3 @@ build-dev.bat) (instead of build.sh or build.bat). Of course, time to time it is worth to use the build.sh (build.bat) script again to make sure that you have the latest versions of all fetched files. - -Files: -====== -* alltools.jar - A set of various tools and utilities. - Sources and documentation are available from - http://industry.ebi.ac.uk/~senger/tools/ - -* xerces*.jar, xml*.jar. - Library for SAX/DOM parser. They come from Apache Xerces-2.3.0. - -* axis-ant.jar, commons-discovery.jar, commons-logging.jar, jaxrpc.jar - wsdl4j.jar, axis.jar, log4j-1.2.4.jar, saaj.jar. - Libraries from the Apache Axis project (a toolkit for the SOAP protocol). - -* servlet.jar, activation.jar - Libraries dealing with servlets. They come from Apache Tomcat project. - -* jena.jar, adenine.jar - Libraries from 'haystack' (IBM) for producing RDF files. - They can be fetched from here: - http://www.ai.mit.edu/people/dquan/adenine.jar - http://www.ai.mit.edu/people/dquan/jena.jar From senger at pub.open-bio.org Tue Jul 19 09:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGrch019868@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs/graphs In directory pub.open-bio.org:/tmp/cvs-serv19810/docs/graphs Modified Files: index.html Log Message: moby-live/Java/docs/graphs index.html,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/graphs/index.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/docs/graphs/index.html 2004/10/18 14:35:05 1.4 +++ /home/repository/moby/moby-live/Java/docs/graphs/index.html 2005/07/19 13:16:53 1.5 @@ -38,7 +38,7 @@ you have a popular Graphviz tool installed on your machine (the tool is available for many platforms). Just download the latest - binary distribution + binary distribution of jMoby (see details in jMoby main documentation.

@@ -129,7 +129,7 @@

Suggestions, comments, and bug reports to:
Martin Senger
-Last modified: Mon Oct 18 12:33:26 2004 +Last modified: Tue Jul 19 15:06:47 2005
From mwilkinson at pub.open-bio.org Tue Jul 19 10:33:46 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 10:33:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191433.j6JEXklc020185@pub.open-bio.org> mwilkinson Tue Jul 19 10:33:46 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20166/Perl/MOBY Modified Files: Central.pm Log Message: temporarily removing all LSID code to get a fresh start moby-live/Perl/MOBY Central.pm,1.160,1.161 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.160 retrieving revision 1.161 diff -u -r1.160 -r1.161 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/18 22:46:00 1.160 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/19 14:33:46 1.161 @@ -1340,7 +1340,7 @@ #model => $model, #service_instance => $service_instance ); # my $RDF_XML = $RDF_MODEL->serialize; - my $LSID = $service_instance->LSID; + #my $LSID = $service_instance->LSID; # my $RDF = _getServiceInstanceRDF($LSID); my $RDF = ""; @@ -1359,7 +1359,7 @@ sub _getServiceInstanceRDF { my ( $self, $LSID ) = @_; - my $lsid = LS::ID->new($LSID); + #my $lsid = LS::ID->new($LSID); my $RDF_XML = ""; my $lsid_error = ""; my $lsid_good = 1; @@ -1369,38 +1369,38 @@ #use LS::Client::BasicResolver; #use LS::Locator; - my $resolver = LS::Client::BasicResolver->new(); - my $authority = $resolver->resolve( lsid => $lsid ); - unless ($authority) { - $lsid_error .= "The authority for $LSID could not be located"; + #my $resolver = LS::Client::BasicResolver->new(); + #my $authority = $resolver->resolve( lsid => $lsid ); + #unless ($authority) { + # $lsid_error .= "The authority for $LSID could not be located"; + + #} + #return $lsid_error unless $authority; + #$authority->clean_cache(); + +# my $resource = $authority->getResource($lsid); +# unless ($resource) { +# $lsid_error .= $authority->error_string . " "; +# return $lsid_error; +# } - } - return $lsid_error unless $authority; - $authority->clean_cache(); - - my $resource = $authority->getResource($lsid); - unless ($resource) { - $lsid_error .= $authority->error_string . " "; - return $lsid_error; - } - - my $response = $resource->get_metadata; - unless ( ref($response) =~ /LS::Service::Response/ ) { +# my $response = $resource->get_metadata; +# unless ( ref($response) =~ /LS::Service::Response/ ) { #TODO raise an error - $lsid_error .= "Metadata response didn't come back"; - return $lsid_error; - } +# $lsid_error .= "Metadata response didn't come back"; +# return $lsid_error; +# } - my $rsp = $response->response; - unless ( ref($rsp) =~ /IO::File/ ) { +# my $rsp = $response->response; +# unless ( ref($rsp) =~ /IO::File/ ) { #TODO raise an error - $lsid_error .= "metadata response was not a filehandle"; - } - while (<$rsp>) { - $RDF_XML .= $_; - } +# $lsid_error .= "metadata response was not a filehandle"; +# } +# while (<$rsp>) { +# $RDF_XML .= $_; +# } return $RDF_XML } From mwilkinson at pub.open-bio.org Tue Jul 19 10:33:47 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 10:33:47 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191433.j6JEXlVY020205@pub.open-bio.org> mwilkinson Tue Jul 19 10:33:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv20166/Perl/MOBY/Client Modified Files: Central.pm Log Message: temporarily removing all LSID code to get a fresh start moby-live/Perl/MOBY/Client Central.pm,1.97,1.98 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.97 retrieving revision 1.98 diff -u -r1.97 -r1.98 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/05/30 22:54:43 1.97 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 14:33:46 1.98 @@ -1725,7 +1725,7 @@ my $Service = $Services->get_node($x); my $AuthURI = $Service->getAttributeNode('authURI')->getValue; my $servicename = $Service->getAttributeNode('serviceName')->getValue; - my $lsid = $Service->getAttributeNode('lsid')->getValue; + #my $lsid = $Service->getAttributeNode('lsid')->getValue; my $Type = &_nodeTextContent( $Service, 'serviceType' ); my $authoritative = &_nodeTextContent( $Service, 'authoritative' ); my $contactEmail = &_nodeTextContent( $Service, 'contactEmail' ); @@ -1789,7 +1789,7 @@ authority => $AuthURI, authoritative => $authoritative, URL => $URL, - LSID => $lsid, + #LSID => $lsid, contactEmail => $contactEmail, name => $servicename, type => $Type, From kawas at pub.open-bio.org Tue Jul 19 11:28:28 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:28:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191528.j6JFSSbc020394@pub.open-bio.org> kawas Tue Jul 19 11:28:28 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms In directory pub.open-bio.org:/tmp/cvs-serv20365/org/biomoby/client/ui/graphical/servlet/forms Modified Files: GetSignatureRDFResponse.java GetSignatureRDFForm.java Log Message: changed the mobycentral registry to become the new one. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms GetSignatureRDFResponse.java,1.2,1.3 GetSignatureRDFForm.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java 2005/04/07 21:02:01 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java 2005/07/19 15:28:28 1.3 @@ -47,7 +47,7 @@ + "

Unable to update your information

\r\n" + "
\r\n" + "

Make sure that you specify a valid signature url! This field looks like the following: http://myAuthority.domain/path/to/rdf/for/service. Also make sure that you have specified the right case-sensitive service name, if applicable.

\r\n" - + "

Back

\r\n" + + "

Back

\r\n" + "
\r\n" + "\r\n" + ""; protected void doGet(HttpServletRequest request, @@ -100,10 +100,10 @@ if (name.equals("")) { System.out.println("empty name"); - con = "http://mobycentral.cbr.nrc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + con = "http://mobycentral.icapture.ubc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + domain + "&URL=" + sigURL; } else { - con = "http://mobycentral.cbr.nrc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + con = "http://mobycentral.icapture.ubc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + domain + "&URL=" + sigURL + "&serviceName=" + name; } URL url = new URL(con); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java 2005/04/07 21:02:01 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java 2005/07/19 15:28:28 1.3 @@ -34,7 +34,7 @@ // some useful variables private final String newline = System.getProperty("line.separator"); - private static final String DOMAIN = "mobycentral.cbr.nrc.ca:8090"; + private static final String DOMAIN = "mobycentral.icapture.ubc.ca:8090"; /* (non-Javadoc) * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @@ -169,6 +169,7 @@ central = new CentralImpl(); domains = central.getProviders(); } catch (MobyException e) { + e.printStackTrace(); return; } // sort the array From kawas at pub.open-bio.org Tue Jul 19 11:29:32 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:29:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191529.j6JFTWuc020448@pub.open-bio.org> kawas Tue Jul 19 11:29:32 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes In directory pub.open-bio.org:/tmp/cvs-serv20423/org/biomoby/client/ui/graphical/servlet/jTypes Modified Files: Types.java Log Message: removed a print statement that eluded me for years (months... okay weeks!) Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes Types.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes/Types.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes/Types.java 2005/04/07 16:42:30 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes/Types.java 2005/07/19 15:29:32 1.2 @@ -35,7 +35,6 @@ p = Pattern.compile("/types/Services\\S*"); m = p.matcher(path); if (m.matches()) { - System.out.println("Matching services ..."); // get Services response.setContentType("text/plain"); PrintWriter out = response.getWriter(); @@ -46,7 +45,6 @@ response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, e.getLocalizedMessage()); return; } - System.out.println("done"); return; } p = Pattern.compile("/types/Namespaces\\S*"); From kawas at pub.open-bio.org Tue Jul 19 11:32:54 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:32:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191532.j6JFWs6r020518@pub.open-bio.org> kawas Tue Jul 19 11:32:54 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources In directory pub.open-bio.org:/tmp/cvs-serv20493/org/biomoby/client/ui/graphical/servlet/jresources Modified Files: RESOURCE.java Log Message: Code has mobycentral registry domain changes, as well as certain todo statements have been excised. The next version should a way to retrieve information regarding the BioMoby predicate vocabulary. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources RESOURCE.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/06/09 17:39:00 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/07/19 15:32:54 1.7 @@ -19,6 +19,7 @@ import org.biomoby.client.CentralDigestImpl; import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; +import org.biomoby.client.rdf.vocabulary.XMLTypes; import org.biomoby.registry.definitions.types.JNamespaces; import org.biomoby.registry.definitions.types.JObjects; import org.biomoby.registry.definitions.types.JServices; @@ -165,7 +166,7 @@ * @see javax.servlet.GenericServlet#init() */ public final void init() throws ServletException { - super.init(); + // super.init(); } protected final void doGet(HttpServletRequest request, @@ -366,8 +367,8 @@ .getURL())); subject.addProperty(DC.identifier, model .createTypedLiteral("urn:lsid:" - + properties.getProperty("lsid_domain") - + ":serviceinstance:" + services[i].getAuthority() + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_authority") + ":" + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_namespace") + ":" +services[i].getAuthority() + "," + services[i].getName())); subject.addProperty(Predicates.performs_task, model .createResource(SRV + services[i].getType())); @@ -783,7 +784,9 @@ Pattern p = Pattern.compile("urn:lsid.*:(\\S+)$"); Matcher m = p.matcher(thing); String label = (m.matches() ? m.group(1) : thing); + //TODO - add the ofType property if thing is String, Float, Integer, DataTime. Resource resource = model.createResource(ns + thing); + addOfTypeProperty(model, resource, thing); model.add(model.createStatement(resource, RDF.type, RDFS.Class)); model.add(model.createStatement(resource, RDFS.label, model .createLiteral(label, "en"))); @@ -792,7 +795,30 @@ return resource; } - private final String getTypes(String type) throws MobyException { + /** + * @param model + * @param resource + * @param thing + */ + private void addOfTypeProperty(Model model, Resource resource, String name) { + // make sure that we declare the ns for the datatype + Map map = model.getNsPrefixMap(); + if (!map.containsValue(XMLTypes.getURI())) { + map.put(XMLTypes.getPrefix(), XMLTypes.getURI()); + } + model.setNsPrefixes(map); + if (name.equalsIgnoreCase("string")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_STRING)); + } else if (name.equalsIgnoreCase("integer")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_INTEGER)); + } else if (name.equalsIgnoreCase("float")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_FLOAT)); + } else if (name.equalsIgnoreCase("datatime")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_DATE_TIME)); + } + } + + private final String getTypes(String type) throws MobyException { if (type.equalsIgnoreCase("objects")) { try { return new JObjects().getObjects(); @@ -800,7 +826,7 @@ e.printStackTrace(); } // resort to a secondary method for retrieval of JObjects - return getURL("http://mobycentral.cbr.nrc.ca:8090/types/Objects"); + return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Objects"); } else if (type.equalsIgnoreCase("services")) { try { return new JServices().getServices(); @@ -808,7 +834,7 @@ e.printStackTrace(); } // resort to a secondary method for retrieval of JServices - return getURL("http://mobycentral.cbr.nrc.ca:8090/types/Services"); + return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Services"); } else if (type.equalsIgnoreCase("namespaces")) { try { return new JNamespaces().getNamespaces(); @@ -816,7 +842,7 @@ e.printStackTrace(); } // resort to a secondary method for retrieval of JNamespaces - return getURL("http://mobycentral.cbr.nrc.ca:8090/types/Namespaces"); + return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Namespaces"); } return ""; } @@ -925,7 +951,7 @@ } public static void main(String[] args) throws MobyException { - System.out.println(new RESOURCE().getRESOURCES("ServiceInstances")); + System.out.println(new RESOURCE().getRESOURCES("Objects")); } } From kawas at pub.open-bio.org Tue Jul 19 11:44:11 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:44:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191544.j6JFiB5Q020750@pub.open-bio.org> kawas Tue Jul 19 11:44:10 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool In directory pub.open-bio.org:/tmp/cvs-serv20713/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool Modified Files: InputOutputFocusListener.java MobyInputOutputData.java ServiceInstancePanelFactory.java Service.java Log Message: Fixed a bug that occured upon registration of secondary inputs. ALso switch registry domains. moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool InputOutputFocusListener.java,1.3,1.4 MobyInputOutputData.java,1.1,1.2 ServiceInstancePanelFactory.java,1.2,1.3 Service.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/InputOutputFocusListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/InputOutputFocusListener.java 2005/04/20 21:42:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/InputOutputFocusListener.java 2005/07/19 15:44:10 1.4 @@ -50,7 +50,7 @@ if (_name.equals("name")) { InputOutputFocusListener.name = ((JTextField) (fe.getComponent())).getText(); - } else if (_name.equals("enumeration")) { + } else if (_name.equals("enum")) { InputOutputFocusListener.enumeration = ((JTextField) (fe.getComponent())).getText(); secondaryEnumerationField = (JTextField) (fe.getComponent()); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/MobyInputOutputData.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/MobyInputOutputData.java 2005/04/07 16:42:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/MobyInputOutputData.java 2005/07/19 15:44:10 1.2 @@ -34,10 +34,10 @@ * Variables for the test database. */ static final String ENDPOINT = - "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; + "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; static final String NAMESPACE = - "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; - private static String _URL = "http://mobycentral.cbr.nrc.ca/cgi-bin/applets/retrieveObjectXML.cgi?name="; + "http://mobycentral.icapture.ubc.ca/MOBY/Central"; + private static String _URL = "http://mobycentral.icapture.ubc.ca/cgi-bin/applets/retrieveObjectXML.cgi?name="; /** * =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/ServiceInstancePanelFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/ServiceInstancePanelFactory.java 2005/04/07 21:01:13 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/ServiceInstancePanelFactory.java 2005/07/19 15:44:10 1.3 @@ -43,7 +43,7 @@ private JButton edit; private JButton submit = null; - private static String datatype = "INT"; + private static String datatype = "Integer"; private JList namespaceDropdownList, enumerations; private DefaultListModel model = new DefaultListModel(), _enums = new DefaultListModel(); @@ -1161,8 +1161,8 @@ scrollingList.setPreferredSize(dim); scrollingList.setWheelScrollingEnabled(true); - JComboBox combo = new JComboBox(new String[] { "INT", "FLOAT", - "STRING", "DATE/TIME" }); + JComboBox combo = new JComboBox(new String[] { "Integer", "Float", + "String", "DateTime" }); combo.addActionListener(ioal); combo.setActionCommand("datatype"); combo.setName("datatype"); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/Service.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/Service.java 2005/04/07 21:01:13 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/Service.java 2005/07/19 15:44:10 1.3 @@ -27,9 +27,9 @@ private boolean PROTO = false; - static final String ENDPOINT = "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; + static final String ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; - static final String NAMESPACE = "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; + static final String NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; public static String REG_TEXT = ""; @@ -82,7 +82,7 @@ worker = new CentralImpl(CentralImpl.DEFAULT_ENDPOINT, CentralImpl.DEFAULT_NAMESPACE); worker.registerService(this); - success = true; + success = true || true; REG_TEXT = "Service has been registered!"; } catch (MobyException e) { From kawas at pub.open-bio.org Tue Jul 19 11:50:44 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:50:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191550.j6JFoiMg020800@pub.open-bio.org> kawas Tue Jul 19 11:50:43 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool In directory pub.open-bio.org:/tmp/cvs-serv20775/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool Modified Files: ServiceTypeApplet.java Log Message: changed the mobycentral registry to become the new one. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool ServiceTypeApplet.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool/ServiceTypeApplet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool/ServiceTypeApplet.java 2005/04/07 16:42:29 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool/ServiceTypeApplet.java 2005/07/19 15:50:43 1.2 @@ -107,9 +107,9 @@ private JFrame frame = null; - static final String ENDPOINT = "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; + static final String ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; - static final String NAMESPACE = "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; + static final String NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; /** * This method initializes From kawas at pub.open-bio.org Tue Jul 19 11:51:50 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:51:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191551.j6JFposr020854@pub.open-bio.org> kawas Tue Jul 19 11:51:50 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority In directory pub.open-bio.org:/tmp/cvs-serv20829/org/biomoby/client/ui/graphical/servlet/lsid/authority Modified Files: Test.java Log Message: turned caching off in this test lsid client. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority Test.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/Test.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/Test.java 2005/04/20 21:42:10 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/Test.java 2005/07/19 15:51:50 1.3 @@ -30,10 +30,12 @@ * @throws LSIDException */ public static void main(String[] args) throws LSIDException { - String lsid_to_use = "urn:lsid:biomoby.org:objectclass:DNASequence";//"urn:lsid:biomoby.org:objectclass:DNASequence"; + String lsid_to_use = "urn:lsid:biomoby.org:objectclass:DNASequence"; LSID lsid = new LSID(lsid_to_use); LSIDResolver resolver = new LSIDResolver(lsid); + resolver.setUseLocalCache(false); String output = lsid.toString() + "\n"; + System.out.println(resolver.getWSDLWrapper().toString()); try { LSIDWSDLWrapper wrapper = resolver.getWSDLWrapper(); // get metadata From kawas at pub.open-bio.org Tue Jul 19 11:54:02 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:54:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191554.j6JFs2Xd020974@pub.open-bio.org> kawas Tue Jul 19 11:54:02 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder In directory pub.open-bio.org:/tmp/cvs-serv20945/org/biomoby/client/rdf/builder Modified Files: ServiceInstanceRDF.java RDFConfigure.java Log Message: changed the way certain properties are accessed. Also updated the registry domain. ofType predicate added to datatypes as well. moby-live/Java/src/main/org/biomoby/client/rdf/builder ServiceInstanceRDF.java,1.4,1.5 RDFConfigure.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/06/09 17:35:59 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/07/19 15:54:02 1.5 @@ -15,13 +15,13 @@ import org.biomoby.registry.properties.MobyProperties; import org.biomoby.shared.Central; import org.biomoby.shared.MobyData; -import org.biomoby.shared.data.MobyDataSecondaryInstance; import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyNamespace; import org.biomoby.shared.MobyPrimaryDataSet; import org.biomoby.shared.MobyPrimaryDataSimple; import org.biomoby.shared.MobySecondaryData; import org.biomoby.shared.MobyService; +import org.biomoby.shared.data.MobyDataSecondaryInstance; import com.hp.hpl.jena.rdf.model.Bag; import com.hp.hpl.jena.rdf.model.Model; @@ -296,8 +296,8 @@ .getURL())); subject.addProperty(DC.identifier, model .createTypedLiteral("urn:lsid:" - + properties.getProperty("lsid_domain") - + ":serviceinstance:" + services[i].getAuthority() + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_authority") +":" + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_namespace") +":"+ services[i].getAuthority() + "," + services[i].getName())); subject.addProperty(Predicates.performs_task, model .createResource(SRV + services[i].getType())); @@ -488,7 +488,7 @@ return stream.getOutput(); } - + /* * convenience method that adds a resource to a model */ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/05/31 18:11:07 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/07/19 15:54:02 1.3 @@ -132,6 +132,14 @@ str = str.substring(0, str.indexOf("~")); newResource.addProperty(RDFS.label, rdf.createLiteral(str, "en")); } + // TODO - add the ofType property if it exists + if (sourceResource.hasProperty(Predicates.ofType)) { + String str = sourceResource.getProperty(Predicates.ofType).getObject() + .toString(); + if (str.indexOf("~") != -1) + str = str.substring(0, str.indexOf("~")); + newResource.addProperty(Predicates.ofType, str); + } if (sourceResource.hasProperty(RDFS.subClassOf)) { String parent = sourceResource.getProperty(RDFS.subClassOf) .getObject().asNode().getURI(); @@ -447,6 +455,11 @@ return false; } + public static void main(String[] args) throws IOException { + RDFConfigure rdfc = new RDFConfigure("http://biomoby.org/RESOURCES/MOBY-S/Objects#"); + System.out.println(new String(rdfc.retrieveObjectRDF("http://biomoby.org/RESOURCES/MOBY-S/Objects#MSF_DIRECT_DNA"))); + + } class FilteredStream extends FilterOutputStream { StringBuffer sb = null; From kawas at pub.open-bio.org Tue Jul 19 11:56:20 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:56:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191556.j6JFuKEI021054@pub.open-bio.org> kawas Tue Jul 19 11:56:20 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types In directory pub.open-bio.org:/tmp/cvs-serv21021/org/biomoby/registry/definitions/types Modified Files: JNamespaces.java JObjects.java JServices.java Log Message: changed the mobycentral registry to become the new one. Eddie moby-live/Java/src/main/org/biomoby/registry/definitions/types JNamespaces.java,1.3,1.4 JObjects.java,1.4,1.5 JServices.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespaces.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespaces.java 2005/04/20 21:42:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespaces.java 2005/07/19 15:56:20 1.4 @@ -45,7 +45,7 @@ String username = (String) map.get("username");//"moby_external"; String password = (String) map.get("password");//""; - /* String serverName = "mobycentral.cbr.nrc.ca:3306"; + /* String serverName = "mobycentral.icapture.ubc.ca:3306"; String mydatabase = "mobynamespace"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "moby_external"; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjects.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjects.java 2005/04/20 21:42:10 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjects.java 2005/07/19 15:56:20 1.5 @@ -48,7 +48,7 @@ String username = (String) map.get("username");//"moby_external"; String password = (String) map.get("password");//""; - /*String serverName = "mobycentral.cbr.nrc.ca:3306"; + /* String serverName = "mobycentral.icapture.ubc.ca:3306"; String mydatabase = "mobyobject"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "moby_external"; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServices.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServices.java 2005/04/20 21:42:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServices.java 2005/07/19 15:56:20 1.4 @@ -48,7 +48,7 @@ String username = (String) map.get("username");//"moby_external"; String password = (String) map.get("password");//""; - /* String serverName = "mobycentral.cbr.nrc.ca:3306"; + /* String serverName = "mobycentral.icapture.ubc.ca:3306"; String mydatabase = "mobyservice"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "moby_external"; From kawas at pub.open-bio.org Tue Jul 19 11:36:24 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:36:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191536.j6JFaOOG020642@pub.open-bio.org> kawas Tue Jul 19 11:36:24 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool In directory pub.open-bio.org:/tmp/cvs-serv20605/org/biomoby/client/ui/graphical/applets/objectCreationTool Modified Files: TreeWindow.java ObjectCreationTool.java retrieveObjectXML.cgi Registration.java Log Message: Changed code that refered to the old registry. As well, removed the ability to register datatypes with "" articlenames. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool TreeWindow.java,1.1,1.2 ObjectCreationTool.java,1.2,1.3 retrieveObjectXML.cgi,1.1,1.2 Registration.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/TreeWindow.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/TreeWindow.java 2005/04/07 16:42:26 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/TreeWindow.java 2005/07/19 15:36:24 1.2 @@ -46,7 +46,7 @@ private int type; private ObjectCreationTool tool = null; // TODO - place the file pointed to by _URL on mobycentral/cgi-bin/applets/ - private final static String _URL = "http://mobycentral.cbr.nrc.ca/cgi-bin/applets/retrieveObjectXML.cgi?name="; + private final static String _URL = "http://mobycentral.icapture.ubc.ca:8090/applets/cgi-bin/retrieveObjectXML.cgi?name="; /** * This is the default constructor */ @@ -119,16 +119,24 @@ case (2): { articleName = getSelected(); + if (articleName.equalsIgnoreCase("")) { + tool.createPopUpMsg("Please enter an article name for your object selection."); + return; + } tool.xml.addHas(selectedObject.toString(), articleName,tool.xml.getRootName()); - tool.toggleIsaButton(false); + //tool.toggleIsaButton(false); tool.closePopUpTreeWindow(); } break; case (3): { articleName = getSelected(); + if (articleName.equalsIgnoreCase("")) { + tool.createPopUpMsg("Please enter an article name for your object selection."); + return; + } tool.xml.addHasA(selectedObject.toString(), articleName,tool.xml.getRootName()); - tool.toggleIsaButton(false); + //tool.toggleIsaButton(false); tool.closePopUpTreeWindow(); } break; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/ObjectCreationTool.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/ObjectCreationTool.java 2005/06/02 15:48:01 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/ObjectCreationTool.java 2005/07/19 15:36:24 1.3 @@ -145,7 +145,7 @@ final TreeLoaderThread worker = new TreeLoaderThread() { public Object construct() { tree = new MobyTree(false, - "http://mobycentral.cbr.nrc.ca:8090/RESOURCES/MOBY-S/Objects","Objects"); + "http://mobycentral.icapture.ubc.ca:8090/RESOURCES/MOBY-S/Objects","Object"); tree.makeObjectTree("Object"); tree.setPreferredSize(new Dimension(400, 400)); tree.getTree().addMouseListener(mListener); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/retrieveObjectXML.cgi,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/retrieveObjectXML.cgi 2005/04/07 16:42:26 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/retrieveObjectXML.cgi 2005/07/19 15:36:24 1.2 @@ -4,7 +4,10 @@ use strict; use CGI qw( :cgi ); use MOBY::Client::Central; - my $Central = MOBY::Client::Central->new; + my $Central = MOBY::Client::Central->new(Registries => {mobycentral => { + URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} + }); # a simple MOBY_Central call to get service types my $DEFS; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/Registration.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/Registration.java 2005/06/02 15:48:01 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/Registration.java 2005/07/19 15:36:24 1.4 @@ -17,8 +17,8 @@ */ public class Registration extends MobyDataType{ - static final String ENDPOINT = "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; - static final String NAMESPACE = "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; + static final String ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; + static final String NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; private static boolean PROTO = false; /** From kawas at pub.open-bio.org Tue Jul 19 16:46:15 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 16:46:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192046.j6JKkFa6021853@pub.open-bio.org> kawas Tue Jul 19 16:46:15 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv21828/org/biomoby/client/rdf/vocabulary Modified Files: Predicates.java Added Files: XMLTypes.java Log Message: comitting 2 files that i forgot to update/commit ;-) Eddie moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary XMLTypes.java,NONE,1.1 Predicates.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/05/31 18:11:08 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/19 20:46:15 1.3 @@ -49,6 +49,7 @@ public static final Property SecondaryArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SecondaryArticle"); public static final Property SignatureURL = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SignatureURL"); public static final Property authoritative = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#authoritative"); + public static final Property ofType = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#ofType"); public final static String getURI() { return uri; } From senger at ebi.ac.uk Tue Jul 19 17:47:58 2005 From: senger at ebi.ac.uk (Martin Senger) Date: Tue, 19 Jul 2005 22:47:58 +0100 (BST) Subject: [MOBY-guts] biomoby commit In-Reply-To: <200507192046.j6JKkFa6021853@pub.open-bio.org> Message-ID: Eddie, I love you: jMoby workd again. Martin -- Martin Senger EMBL Outstation - Hinxton Senger at EBI.ac.uk European Bioinformatics Institute Phone: (+44) 1223 494636 Wellcome Trust Genome Campus (Switchboard: 494444) Hinxton Fax : (+44) 1223 494468 Cambridge CB10 1SD United Kingdom http://industry.ebi.ac.uk/~senger From mwilkinson at pub.open-bio.org Tue Jul 19 18:54:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 18:54:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192254.j6JMsAt7022213@pub.open-bio.org> mwilkinson Tue Jul 19 18:54:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22194/MOBY Modified Files: OntologyServer.pm Log Message: most calls in OntologyServer were mis-directed to the mobycentral data adaptor instead of teh mobyobject, mobyservice, mobynamespace etc adaptors. They should all direct properly now moby-live/Perl/MOBY OntologyServer.pm,1.52,1.53 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/18 22:32:20 1.52 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 22:54:10 1.53 @@ -185,7 +185,7 @@ my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that @@ -248,7 +248,7 @@ sub createObject { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); #node => $term, #desc => $desc, #authURI => $auth, @@ -310,7 +310,7 @@ sub retrieveObject { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my $term = $args{'node'}; return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node as an argument", '' ) @@ -359,7 +359,7 @@ sub deprecateObject { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return ( 0, "WRONG ONTOLOGY", '' ) unless ( $self->ontology eq 'object' ); my $term = $args{term}; @@ -418,8 +418,7 @@ # ontology => $ontology my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'relationship' ); my $term = lc( $args{term} ); @@ -469,7 +468,7 @@ #contact_email => $email my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); @@ -552,7 +551,7 @@ #contact_email => $email); my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); @@ -613,7 +612,7 @@ sub serviceExists { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; @@ -657,7 +656,7 @@ sub createServiceType { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); #node => $term, #descrioption => $desc, @@ -701,7 +700,7 @@ sub deleteServiceType { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; @@ -766,7 +765,7 @@ sub namespaceExists { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); @@ -811,7 +810,7 @@ sub createNamespace { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); #node => $term, #descrioption => $desc, #authority => $auth, @@ -855,7 +854,7 @@ sub deleteNamespace { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); my $term = $args{term}; @@ -913,7 +912,7 @@ sub retrieveAllServiceTypes { my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); my $types = $adaptor->query_service(); my %response; @@ -930,7 +929,7 @@ sub retrieveAllNamespaceTypes { my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); my $types = $adaptor->query_namespace(); my %response; @@ -947,7 +946,7 @@ sub retrieveAllObjectClasses { my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my $types = $adaptor->query_object(); my %response; @@ -966,7 +965,7 @@ sub getObjectCommonName { my ( $self, $URI ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return undef unless $URI =~ /urn\:lsid/; my $result = $adaptor->query_object({object_lsid => $URI}); my $row = shift(@$result); @@ -982,7 +981,7 @@ sub getNamespaceCommonName { my ( $self, $URI ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return undef unless $URI =~ /urn\:lsid/; my $result = $adaptor->query_namespace({namespace_lsid => $URI}); my $row = shift(@$result); @@ -998,7 +997,7 @@ sub getServiceCommonName { my ( $self, $URI ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return undef unless $URI =~ /urn\:lsid/; my $result = $adaptor->query_service({service_lsid => $URI}); my $row = shift(@$result); @@ -1014,7 +1013,7 @@ sub getServiceURI { my ( $self, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return $term if $term =~ /urn\:lsid/; my $result = $adaptor->query_service({service_type => $term}); @@ -1031,7 +1030,7 @@ sub getObjectURI { my ( $self, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return $term if $term =~ /urn\:lsid/; my $result = $adaptor->query_object({object_type => $term}); @@ -1048,7 +1047,7 @@ sub getNamespaceURI { my ( $self, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return $term if $term =~ /urn\:lsid/; @@ -1066,7 +1065,7 @@ sub getRelationshipURI { my ( $self, $ontology, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); return $term if $term =~ /urn\:lsid/; @@ -1084,7 +1083,7 @@ sub getRelationshipTypes { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); my $ontology = $args{'ontology'}; my $OS = MOBY::OntologyServer->new( ontology => "relationship" ); @@ -1150,7 +1149,8 @@ sub _doRelationshipsQuery { my ( $self, $ontology, $term, $relationship, $direction ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $datasource = "moby$ontology"; # like mobyobject, or mobyservice + my $adaptor = $CONFIG->getDataAdaptor( datasource => $datasource ); my $defs; # query returns a reference to an array containing array references $defs = $adaptor->getRelationship({direction => $direction}, {ontology => $ontology}, {term => $term}, {relationship => $relationship}); From mwilkinson at pub.open-bio.org Tue Jul 19 18:54:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 18:54:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192254.j6JMsAbi022233@pub.open-bio.org> mwilkinson Tue Jul 19 18:54:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv22194/MOBY/Client Modified Files: Central.pm Log Message: most calls in OntologyServer were mis-directed to the mobycentral data adaptor instead of teh mobyobject, mobyservice, mobynamespace etc adaptors. They should all direct properly now moby-live/Perl/MOBY/Client Central.pm,1.98,1.99 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.98 retrieving revision 1.99 diff -u -r1.98 -r1.99 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 14:33:46 1.98 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 22:54:10 1.99 @@ -1047,7 +1047,7 @@ Usage : $REG = $MOBY->deregisterService(%args) Function : deregister a registered MOBY Service Returns : MOBY::Registration object - Args : serviceID => $serviceID + Args : serviceName => $serviceID, authURI => $authority =cut From mwilkinson at pub.open-bio.org Tue Jul 19 19:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 19:37:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192337.j6JNbZrb022356@pub.open-bio.org> mwilkinson Tue Jul 19 19:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22337/MOBY Modified Files: OntologyServer.pm Log Message: still one misdirected call - now fixed. moby-live/Perl/MOBY OntologyServer.pm,1.53,1.54 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 22:54:10 1.53 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 23:37:35 1.54 @@ -468,7 +468,7 @@ #contact_email => $email my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); From mwilkinson at pub.open-bio.org Tue Jul 19 19:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 19:37:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192337.j6JNbZMt022375@pub.open-bio.org> mwilkinson Tue Jul 19 19:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22337/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: still one misdirected call - now fixed. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 22:32:20 1.15 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:37:35 1.16 @@ -519,7 +519,8 @@ sub delete_object{ my ($self, @args) = @_; my $dbh = $self->dbh; - my $statement = "delete from object "; + my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........********** + # ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ******************** my @bindvalues = (); ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, From mwilkinson at pub.open-bio.org Tue Jul 19 19:40:34 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 19:40:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192340.j6JNeY8a022460@pub.open-bio.org> mwilkinson Tue Jul 19 19:40:34 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22441/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: missed a $ in front of dbh moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:37:35 1.16 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:40:34 1.17 @@ -559,7 +559,7 @@ sub insert_object_term2term{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, undef, ( get_value('relationship_type', @args), From mwilkinson at pub.open-bio.org Tue Jul 19 19:47:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 19:47:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192347.j6JNlQYb022529@pub.open-bio.org> mwilkinson Tue Jul 19 19:47:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22510/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: missed several dozen more $. The problem with copy/paste when the original was erroneous moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:40:34 1.17 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:47:26 1.18 @@ -227,8 +227,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -277,8 +277,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -341,8 +341,8 @@ ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -404,8 +404,8 @@ ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -462,8 +462,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -526,8 +526,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -581,8 +581,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -660,8 +660,8 @@ ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -740,7 +740,7 @@ sub insert_service{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, undef, ( @@ -748,7 +748,7 @@ get_value('authority', @args), get_value('contact_email', @args) ) ); - return dbh->{mysql_insertid}; + return $dbh->{mysql_insertid}; } sub delete_service{ @@ -760,8 +760,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -790,12 +790,12 @@ sub insert_service_term2term{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, undef, ( get_value('relationship_type', @args), get_value('service1_id', @args), get_value('service2_id', @args)) ); - return dbh->{mysql_insertid}; + return $dbh->{mysql_insertid}; } sub delete_service_term2term{ @@ -807,8 +807,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -866,7 +866,7 @@ sub insert_namespace{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, undef, ( @@ -874,7 +874,7 @@ get_value('authority', @args), get_value('contact_email', @args) ) ); - return dbh->{mysql_insertid}; + return $dbh->{mysql_insertid}; } sub delete_namespace{ @@ -886,8 +886,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -924,8 +924,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; From mwilkinson at pub.open-bio.org Wed Jul 20 11:43:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 11:43:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201543.j6KFhv96024731@pub.open-bio.org> mwilkinson Wed Jul 20 11:43:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv24704/MOBY Modified Files: Central.pm authority.pm service_instance.pm Log Message: The logic for retrieving authority objects was faulty. It now creates a new db entry if the initial lookup fails moby-live/Perl/MOBY Central.pm,1.161,1.162 authority.pm,1.3,1.4 service_instance.pm,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.161 retrieving revision 1.162 diff -u -r1.161 -r1.162 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/19 14:33:46 1.161 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 15:43:57 1.162 @@ -1184,7 +1184,6 @@ if ( $ch == 0 ) { - use MOBY::Config; my $conf = MOBY::Config->new(); my $path = $conf->{mobycentral}->{rdfagent}; my $rez = system( $path. " " . $signatureURL ); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/13 21:53:12 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 15:43:57 1.4 @@ -91,19 +91,13 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); - my $authority_id = @$result[0]->{authority_id}; - my $common = @$result[0]->{authority_common_name}; - my $uri = @$result[0]->{authority_uri}; - my $contact = @$result[0]->{contact_email}; - - unless ($authority_id) { + unless (@$result[0]) { my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, {authority_uri => $self->authority_uri}, {contact_email => $self->contact_email}); - $self->authority_id( $insertid ); } else { - $self->authority_id($authority_id); + $self->authority_id(@$result[0]->{authority_id}); } return $self; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 22:46:00 1.13 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:43:57 1.14 @@ -358,13 +358,14 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); - my $row = shift(@$result); - my $id = $row->{authority_id}; - my $name = $row->{authority_common_name}; - my $uri = $row->{authority_uri}; - my $email = $row->{contact_email}; - if ( defined $id ) { + if ( @$result[0]) { + my $row = shift(@$result); + my $id = $row->{authority_id}; + my $name = $row->{authority_common_name}; + my $uri = $row->{authority_uri}; + my $email = $row->{contact_email}; + $authority = MOBY::authority->new( dbh => $self->dbh, authority_id => $id, From mwilkinson at pub.open-bio.org Wed Jul 20 11:58:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 11:58:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201558.j6KFwMDI024816@pub.open-bio.org> mwilkinson Wed Jul 20 11:58:22 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv24797/MOBY Modified Files: service_instance.pm Log Message: Parameters passed to the query_service_instance routine need to be hashified moby-live/Perl/MOBY service_instance.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:43:57 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:58:22 1.15 @@ -226,8 +226,9 @@ : $self->service_type_uri($servicetypeURI); } my $existing_service = $self->adaptor->query_service_instance( - servicename => $self->servicename, - authURI => $self->authority_uri ); + {servicename => $self->servicename}, + "and", + {authURI => $self->authority_uri}); if ( ($existing_service ) # if it exists, you are not allowed to have passed anything other than service name and authorityURI From mwilkinson at pub.open-bio.org Wed Jul 20 13:00:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 13:00:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201700.j6KH0QUj025091@pub.open-bio.org> mwilkinson Wed Jul 20 13:00:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25053/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: No, they don't have to be hashified at that pont, but the query itself is a two-step process, and the generic query builder can't do joins over multiple tables so we now do two consecutive queries moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:47:26 1.18 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 17:00:26 1.19 @@ -592,8 +592,16 @@ # selects all the columns from service_instance table # where is lsid? sub query_service_instance { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; + + my $servicename = $args{'servicename'}; + my $authURI = $args{'authority_uri'}; + + my $result = $self->query_authority({authority_uri => $authURI}); + return [{}] unless @$result[0]; + my $id = @$result[0]->{authority_id}; + return [{}] unless $id; my $statement = "select service_instance_id, @@ -608,15 +616,10 @@ signatureURL, lsid from service_instance "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) = add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my @bindvalues; + ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); + my $final = do_query($dbh, $statement, @bindvalues); + return $final; } # custom query for Moby::Central.pm->findService() From mwilkinson at pub.open-bio.org Wed Jul 20 13:00:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 13:00:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201700.j6KH0Q2Z025072@pub.open-bio.org> mwilkinson Wed Jul 20 13:00:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25053/MOBY Modified Files: service_instance.pm Log Message: No, they don't have to be hashified at that pont, but the query itself is a two-step process, and the generic query builder can't do joins over multiple tables so we now do two consecutive queries moby-live/Perl/MOBY service_instance.pm,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:58:22 1.15 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 17:00:26 1.16 @@ -226,9 +226,8 @@ : $self->service_type_uri($servicetypeURI); } my $existing_service = $self->adaptor->query_service_instance( - {servicename => $self->servicename}, - "and", - {authURI => $self->authority_uri}); + servicename => $self->servicename, + authority_uri => $self->authority_uri); if ( ($existing_service ) # if it exists, you are not allowed to have passed anything other than service name and authorityURI From dwang at pub.open-bio.org Wed Jul 20 13:12:20 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 20 Jul 2005 13:12:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201712.j6KHCKIl025225@pub.open-bio.org> dwang Wed Jul 20 13:12:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25199/Perl/MOBY Modified Files: Central.pm Log Message: removed calls to first row of the result set (like @$result[0]), instead used shift to retrieve the first row of the result set moby-live/Perl/MOBY Central.pm,1.162,1.163 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.162 retrieving revision 1.163 diff -u -r1.162 -r1.163 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 15:43:57 1.162 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 17:12:20 1.163 @@ -763,7 +763,8 @@ my $dbh = MOBY::central_db_connection->new()->dbh; my $result = $adaptor->query_service_instance({service_type_uri => $existingURI}); - my $id = @$result[0]->{service_instance_id}; + my $row = shift(@$result); + my $id = $row->{service_instance_id}; return &_error( "A registered service depends on this service type", "" ) if ($id); @@ -1938,7 +1939,8 @@ && _LOG("authURI added; criterion count is now $criterion_count\n"); my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}}); - my $id = @$result[0]->{authority_id}; + my $row = shift(@$result); + my $id = $row->{authority_id}; unless ($id) { return &_serviceListResponse( $dbh, undef ); @@ -3368,16 +3370,17 @@ foreach (@ids) { my $result = $adaptor->query_service_instance({service_instance_id => $_}); - my $category = @$result[0]->{category}; - my $url = @$result[0]->{url}; - my $servicename = @$result[0]->{servicename}; - my $service_type_uri = @$result[0]->{service_type_uri}; - my $authority_id = @$result[0]->{authority_id}; - my $desc = @$result[0]->{description}; - my $authoritative = @$result[0]->{authoritative}; - my $email = @$result[0]->{contact_email}; - my $signatureURL = @$result[0]->{signatureURL}; - my $lsid = @$result[0]->{lsid}; + my $row = shift(@$result); + my $category = $row->{category}; + my $url = $row->{url}; + my $servicename = $row->{servicename}; + my $service_type_uri = $row->{service_type_uri}; + my $authority_id = $row->{authority_id}; + my $desc = $row->{description}; + my $authoritative = $row->{authoritative}; + my $email = $row->{contact_email}; + my $signatureURL = $row->{signatureURL}; + my $lsid = $row->{lsid}; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; @@ -3389,7 +3392,8 @@ my $service_type = $OSserv->getServiceCommonName($service_type_uri); $result = $adaptor->query_authority({authority_id => $authority_id}); - my $authURI = @$result[0]->{authority_uri}; + my $row = shift(@$result); + my $authURI = $row->{authority_uri}; $output .= "\t\n"; $output .= "\t$service_type\n"; From dwang at pub.open-bio.org Wed Jul 20 13:25:54 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 20 Jul 2005 13:25:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201725.j6KHPs6o025292@pub.open-bio.org> dwang Wed Jul 20 13:25:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25266/Perl/MOBY Modified Files: authority.pm Log Message: removed explicit call to first row of result set, instead use shift to retrieve first row moby-live/Perl/MOBY authority.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 15:43:57 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 17:25:54 1.5 @@ -91,13 +91,14 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); - unless (@$result[0]) { + my $row = shift(@$result); + unless ($row) { my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, {authority_uri => $self->authority_uri}, {contact_email => $self->contact_email}); $self->authority_id( $insertid ); } else { - $self->authority_id(@$result[0]->{authority_id}); + $self->authority_id($row->{authority_id}); } return $self; } From kawas at pub.open-bio.org Wed Jul 20 13:42:31 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Wed, 20 Jul 2005 13:42:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201742.j6KHgV3J025434@pub.open-bio.org> kawas Wed Jul 20 13:42:31 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv25405/org/biomoby/client/rdf/vocabulary Modified Files: Predicates.java MobyResources.java Log Message: Updated the predicates. Moved predicates from MobyResources to Predicates and deprecated MobyResources.java moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary Predicates.java,1.3,1.4 MobyResources.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/19 20:46:15 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/20 17:42:31 1.4 @@ -50,6 +50,11 @@ public static final Property SignatureURL = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SignatureURL"); public static final Property authoritative = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#authoritative"); public static final Property ofType = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#ofType"); + /* moved from MobyResources.java */ + public static final Property Simple = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Simple"); + public static final Property Secondary = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Secondary"); + public static final Property Collection = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Collection"); + public final static String getURI() { return uri; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/MobyResources.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/MobyResources.java 2005/05/31 18:11:08 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/MobyResources.java 2005/07/20 17:42:31 1.3 @@ -13,9 +13,12 @@ */ /** + * @deprecated Replaced by {@link + * Predicates}. The reason is that this class was + * redundant and ill conceived. From now on the + * BioMoby predicates, under the namespace moby, + * are located in Predicates.java. * @author Eddie Kawas - *

Created for - *

This class was created to ... *

For questions, comments, or bugs *

email me at edward.kawas at gmail.com */ @@ -24,9 +27,29 @@ private static final String uri = "http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#"; private static Model _model = ModelFactory.createDefaultModel(); + /** + * @deprecated Replaced by {@link + * Predicates#Simple}. The reason is that this property + * should not be under a different RDF document URI + */ public static final Property SimpleArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Simple"); + /** + * @deprecated Replaced by {@link + * Predicates#articleName}. The reason is that this property + * is never utilized and is redundant. + */ public static final Property CollectionArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#articleName"); + /** + * @deprecated Replaced by {@link + * Predicates#Secondary}. The reason is that this property + * should not be under a different RDF document URI + */ public static final Property SecondaryArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Secondary"); + /** + * @deprecated Replaced by {@link + * Predicates#Collection}. The reason is that this property + * should not be under a different RDF document URI + */ public static final Property Collection = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Collection"); public final static String getURI() { return uri; From kawas at pub.open-bio.org Wed Jul 20 16:33:22 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Wed, 20 Jul 2005 16:33:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202033.j6KKXMhq025785@pub.open-bio.org> kawas Wed Jul 20 16:33:22 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources In directory pub.open-bio.org:/tmp/cvs-serv25760/org/biomoby/client/ui/graphical/servlet/jresources Modified Files: RESOURCE.java Log Message: Added the generation of the moby predicate vocabulary. If you run main, you can view the RDF document describing predicates. This implementation is only temporary. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources RESOURCE.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/07/19 15:32:54 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/07/20 20:33:22 1.8 @@ -17,7 +17,6 @@ import javax.servlet.http.HttpServletResponse; import org.biomoby.client.CentralDigestImpl; -import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; import org.biomoby.client.rdf.vocabulary.XMLTypes; import org.biomoby.registry.definitions.types.JNamespaces; @@ -52,13 +51,18 @@ */ /** - * @author Eddie Kawas

Created for

This class was created to ...

For - * questions, comments, or bugs

email me at edward.kawas at gmail.com + * + * @author Eddie Kawas + *

This class was created to replace the old perl RESOURCES script. Using this + * class provides access to the RDF documents describing the object, service type, + * services, namespace and predicate ontologies. + *

if you have any questions, please email me at ed.kawas at gmail.com + * */ public class RESOURCE extends HttpServlet { /** - * + * */ private static final long serialVersionUID = 1L; @@ -141,21 +145,23 @@ private static Properties properties = MobyProperties.PROPERTIES();; private static final String OBJ = "http://" - + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Objects#"; + + properties.getProperty("resources_script_domain") + + "/RESOURCES/MOBY-S/Objects#"; private static final String SRV = "http://" - + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Services#"; + + properties.getProperty("resources_script_domain") + + "/RESOURCES/MOBY-S/Services#"; private static final String NS = "http://" - + properties.getProperty("resources_script_domain") + + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Namespaces#"; private static final String MP = "http://" - + properties.getProperty("resources_script_domain") + + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#"; private static final String SI = "http://" - + properties.getProperty("resources_script_domain") + + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/ServiceInstances#"; private static boolean RUN_MAIN = false; @@ -166,7 +172,7 @@ * @see javax.servlet.GenericServlet#init() */ public final void init() throws ServletException { - // super.init(); + // super.init(); } protected final void doGet(HttpServletRequest request, @@ -272,6 +278,17 @@ writer.setProperty("showXmlDeclaration", "true"); writer.write(model, out, null); return; + } else if (ontology.equals("Predicates")) { + //TODO - create the predicates RDF/XML document describing + // the Predicates. + + response.setContentType("application/rdf+xml"); + response.setHeader("Content-Disposition", + "attachment;filename=Namespaces"); + RDFWriter writer = model.getWriter("RDF/XML-ABBREV"); + writer.setProperty("showXmlDeclaration", "true"); + writer.write(model, out, null); + return; } else if (ontology.equals("FULL")) { try { model = getAll(model); @@ -303,7 +320,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -313,6 +333,7 @@ model = getObjects(model); model = getServices(model); model = getNamespaces(model); + //TODO - add the predicates to the model. try { model = getServiceInstances(model); } catch (ModelException e) { @@ -323,7 +344,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -367,9 +391,13 @@ .getURL())); subject.addProperty(DC.identifier, model .createTypedLiteral("urn:lsid:" - + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_authority") + ":" - + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_namespace") + ":" +services[i].getAuthority() - + "," + services[i].getName())); + + MobyProperties.SERVICE_INSTANCE_PROPERTIES() + .getProperty("lsid_authority") + + ":" + + MobyProperties.SERVICE_INSTANCE_PROPERTIES() + .getProperty("lsid_namespace") + ":" + + services[i].getAuthority() + "," + + services[i].getName())); subject.addProperty(Predicates.performs_task, model .createResource(SRV + services[i].getType())); subject.addProperty(Predicates.SignatureURL, model @@ -408,7 +436,7 @@ } innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) primaryInputs[j]) .getName().equals("")) innerBag @@ -461,8 +489,7 @@ .getDefaultValue())); _li.addProperty(Predicates.datatype, model .createTypedLiteral(data.getDataType())); - _li.addProperty(RDF.type, - MobyResources.SecondaryArticle); + _li.addProperty(RDF.type, Predicates.Secondary); if (data.getDataType().equals("Integer")) { _li .addProperty(Predicates.min, model @@ -514,7 +541,7 @@ produceBag = model.createBag(); innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) outputs[j]) .getName().equals("")) innerBag @@ -559,7 +586,7 @@ private final Resource createSimpleDataItem(Model model, MobyPrimaryDataSimple simpleData, Resource _li) { - _li.addProperty(RDF.type, MobyResources.SimpleArticle); + _li.addProperty(RDF.type, Predicates.Simple); _li.addProperty(Predicates.object_type, model.createResource(OBJ + simpleData.getDataType().getName())); if (!simpleData.getName().equals("")) @@ -578,7 +605,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -615,7 +645,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -646,7 +679,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @throws MobyException @@ -664,8 +700,10 @@ // create the base object type "class" Resource subject = _addClassResource(model, OBJ, "Object", "a base object class consisting of a namespace and an identifier"); - model.add(model.createStatement(subject, DC.publisher, model.createLiteral("www.illuminae.com", "en"))); - model.add(model.createStatement(subject, DC.creator, model.createLiteral("markw at illuminae.com", "en"))); + model.add(model.createStatement(subject, DC.publisher, model + .createLiteral("www.illuminae.com", "en"))); + model.add(model.createStatement(subject, DC.creator, model + .createLiteral("markw at illuminae.com", "en"))); model.add(model.createStatement(subject, RDF.type, RDFS.Class)); for (int x = 0; x < objects.length; x++) { String[] _line = objects[x].split("\t"); @@ -684,7 +722,7 @@ obj = obj.substring(0, obj.indexOf("(")); Resource _subject = _addClassResource(model, OBJ, sub, def); - + m = Pattern.compile(".*:isa$", Pattern.CASE_INSENSITIVE).matcher( pred); if (m.matches()) { @@ -720,12 +758,14 @@ map.put("serviceInstances", SI); map.put("mobyNamespace", NS); map.put("mobyService", SRV); - map.put("moby", MobyResources.getURI()); model.setNsPrefixes(map); } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @param _resource @@ -749,7 +789,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @param mp2 @@ -763,7 +806,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @param subject @@ -784,7 +830,8 @@ Pattern p = Pattern.compile("urn:lsid.*:(\\S+)$"); Matcher m = p.matcher(thing); String label = (m.matches() ? m.group(1) : thing); - //TODO - add the ofType property if thing is String, Float, Integer, DataTime. + //TODO - add the ofType property if thing is String, Float, Integer, + // DataTime. Resource resource = model.createResource(ns + thing); addOfTypeProperty(model, resource, thing); model.add(model.createStatement(resource, RDF.type, RDFS.Class)); @@ -796,29 +843,33 @@ } /** - * @param model - * @param resource - * @param thing - */ - private void addOfTypeProperty(Model model, Resource resource, String name) { - // make sure that we declare the ns for the datatype - Map map = model.getNsPrefixMap(); - if (!map.containsValue(XMLTypes.getURI())) { - map.put(XMLTypes.getPrefix(), XMLTypes.getURI()); - } - model.setNsPrefixes(map); - if (name.equalsIgnoreCase("string")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_STRING)); - } else if (name.equalsIgnoreCase("integer")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_INTEGER)); - } else if (name.equalsIgnoreCase("float")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_FLOAT)); - } else if (name.equalsIgnoreCase("datatime")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_DATE_TIME)); - } - } + * @param model + * @param resource + * @param thing + */ + private void addOfTypeProperty(Model model, Resource resource, String name) { + // make sure that we declare the ns for the datatype + Map map = model.getNsPrefixMap(); + if (!map.containsValue(XMLTypes.getURI())) { + map.put(XMLTypes.getPrefix(), XMLTypes.getURI()); + } + model.setNsPrefixes(map); + if (name.equalsIgnoreCase("string")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_STRING)); + } else if (name.equalsIgnoreCase("integer")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_INTEGER)); + } else if (name.equalsIgnoreCase("float")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_FLOAT)); + } else if (name.equalsIgnoreCase("datatime")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_DATE_TIME)); + } + } - private final String getTypes(String type) throws MobyException { + private final String getTypes(String type) throws MobyException { if (type.equalsIgnoreCase("objects")) { try { return new JObjects().getObjects(); @@ -848,7 +899,7 @@ } /* - * + * */ private String getURL(String url) { StringBuffer sb = new StringBuffer(); @@ -858,7 +909,7 @@ .openStream())); String inputLine; while ((inputLine = in.readLine()) != null) - sb.append(inputLine+"\n"); + sb.append(inputLine + "\n"); in.close(); } catch (Exception e) { e.printStackTrace(); @@ -930,6 +981,12 @@ return out.getBuffer().toString(); } + /** + * + * @param str + * @return an RDF document describing the ontology represented by str. + * @throws MobyException + */ public final String getRESOURCES(String str) throws MobyException { String name = ""; if (str.lastIndexOf("/") > 0) { @@ -946,12 +1003,235 @@ return getServiceInstances(); } else if (name.equalsIgnoreCase("Namespaces")) { return getNamespaces(); + } else if (name.equalsIgnoreCase("Predicates")) { + return getPredicates(); } + return ""; } + private String getPredicates() { + StringBuffer buffer = new StringBuffer(); + buffer.append( + "\r\n"); + // add the predicates here + buffer.append(createOntologyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "The BioMoby Predicates Vocabulary (mobyPred)", + "This is the RDF Schema for the BioMoby Predicate vocabulary defined in the mobyPred namespace.")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#hasa", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "hasa","The subject contains exactly one object.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#has", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "has","The subject contains one or more object.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#articleName", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "articleName","The subject is known to be named object while in a relationship.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#namespace_type", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "namespace_type","The subject resource is applicable under the object namespace.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Resource")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#object_type", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "object_type","The subject resource is a resource object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Resource")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#consumes", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "consumes","The subject container takes as input object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#produces", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "produces","The subject container produces as output object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#performs_task", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "performs_task","The subject performs the task of the object resource.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Resource")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#default_value", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "default_value","The subject has a default value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#min", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "min","The subject has a minimum value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#max", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "max","The subject has a maximum value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#enum", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "enum","The subject may assume the value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#datatype", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "datatype","Idiomatic property used for structured values.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#signatureURL", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "signatureURL","Object is a URL that contains information on the subject.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#authoritative", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "authoritative","The object states whether the subject is authoritative.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#ofType", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "ofType","The subject is of primitive type object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#sampleInputData", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "sampleInputData","Object is a sample of valid input that subject can handle.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#sampleOutputData", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "sampleOutputData","Object is a sample of valid output created by running the subject.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#approvedBy", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "approvedBy","The subject has been approved by object.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Simple", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "Simple","A class representing a simple input or output.", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Secondary", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "Secondary","A class representing a secondary input.", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Collection", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "Collection","A container for objects representing Simples.", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + buffer.append(createEscapedComment("Not sure about the next 3 classes. I dont think that they are actually used anywhere. They represent the articleName of simples, collections and secondaries.")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#SimpleArticle", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "SimpleArticle","NOT SURE", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#CollectionArticle", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "CollectionArticle","NOT SURE", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#SecondaryArticle", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "SecondaryArticle","NOT SURE", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + + // end the addition of predicates here + buffer.append( + "\r\n" + + ""); + return buffer.toString(); + } + + private String createPropertyBlock(String about, String definedBy, + String label, String comment, String domain, String range) { + String s = + "\r\n\r\n" + + " \r\n" + + " " + label + "\r\n" + + " " + comment + "\r\n" + + " \r\n" + + " \r\n" + + "\r\n"; + return s; + } + + private String createClassBlock(String about, String definedBy, + String label, String comment, String subClassOf) { + String s = + "\r\n\r\n" + + " \r\n" + + " "+ label +"\r\n" + + " "+ comment +"\r\n" + + " \r\n" + + "\r\n"; + return s; + } + + private String createDescriptionBlock(String about, String[] seeAlsos) { + if (seeAlsos == null) + return "\r\n"; + StringBuffer sb = new StringBuffer(); + sb.append(" \r\n"); + for (int x = 0; x < seeAlsos.length; x++) { + sb.append(" \r\n"); + } + sb.append("\r\n"); + return sb.toString(); + } + + private String createOntologyBlock(String about, String title, + String description) { + String s ="\r\n\r\n" + " " + title + "\r\n" + + " " + description + "\r\n" + + "\r\n"; + return s; + } + + private String createEscapedComment(String comment) { + String s = "\r\n\r\n"; + return s; + } + public static void main(String[] args) throws MobyException { - System.out.println(new RESOURCE().getRESOURCES("Objects")); + System.out.println(new RESOURCE().getRESOURCES("Predicates")); } -} +} \ No newline at end of file From mwilkinson at pub.open-bio.org Wed Jul 20 17:23:54 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 17:23:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202123.j6KLNsgX025941@pub.open-bio.org> mwilkinson Wed Jul 20 17:23:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25922/MOBY Modified Files: service_instance.pm Log Message: query_service_instance does not return boolean, so the test has to be more explicit moby-live/Perl/MOBY service_instance.pm,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 17:00:26 1.16 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:23:54 1.17 @@ -225,12 +225,12 @@ ? $self->service_type_uri( $self->service_type ) : $self->service_type_uri($servicetypeURI); } - my $existing_service = $self->adaptor->query_service_instance( + my $existing_services = $self->adaptor->query_service_instance( servicename => $self->servicename, authority_uri => $self->authority_uri); + my $existing_service = shift(@$existing_services); if ( - ($existing_service - ) # if it exists, you are not allowed to have passed anything other than service name and authorityURI + ($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI && ( ( defined $self->category ) || ( defined $self->service_type ) || ( defined $self->url ) From mwilkinson at pub.open-bio.org Wed Jul 20 17:29:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 17:29:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202129.j6KLTc7b026019@pub.open-bio.org> mwilkinson Wed Jul 20 17:29:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26000/MOBY Modified Files: service_instance.pm Log Message: query_service_instance does not return boolean, so the test has to be more explicit moby-live/Perl/MOBY service_instance.pm,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:23:54 1.17 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:29:38 1.18 @@ -229,19 +229,15 @@ servicename => $self->servicename, authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); - if ( - ($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI + if (($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI && ( ( defined $self->category ) || ( defined $self->service_type ) || ( defined $self->url ) || ( defined $self->contact_email ) || ( defined $self->description ) ) - ) - { - return - -1; # no no no, not alowed to do that! I will not give you an object - } elsif ($existing_service) - { # if service exists, then instantiate it from the database retrieval we just did + ){ + return -1; # no no no, not alowed to do that! I will not give you an object + } elsif ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); $self->category( $existing_service->{'category'} ); $self->service_type( $existing_service->{'servicetype'} ); @@ -250,26 +246,22 @@ $self->description( $existing_service->{'desc'} ); $self->authority( $existing_service->{'authURI'} ); $self->signatureURL( $existing_service->{'signatureURL'} ); - $self->lsid( $existing_service->{'lsid'} ); + $self->lsid( $existing_service->{'lsid'} ); $self->{__exists__} = 1; # this service already existed - } elsif ( - !($existing_service) # if it doesn't exist - && ( - defined $self->category - ) # and you have given me things I need to create it + } elsif (!($existing_service->{servicename}) # if it doesn't exist + && (defined $self->category) # and you have given me things I need to create it && ( defined $self->service_type ) && ( defined $self->url ) && ( defined $self->contact_email ) && ( defined $self->description ) - ) - { # then create it de novo if we have enough information + ) { # then create it de novo if we have enough information #create LSID for service and register it in the DB - my $_config ||= MOBY::Config->new; - my $service_lsid = "urn:lsid:" - . $_config->{mobycentral}->{lsid_authority} . ":" - . $_config->{mobycentral}->{lsid_namespace} . ":" - . $self->authority_uri . "," - . $self->servicename; + my $_config ||= MOBY::Config->new; + my $service_lsid = "urn:lsid:" + . $_config->{mobycentral}->{lsid_authority} . ":" + . $_config->{mobycentral}->{lsid_namespace} . ":" + . $self->authority_uri . "," + . $self->servicename; my $id = $self->adaptor->insert_service_instance( {category => $self->category}, From mwilkinson at pub.open-bio.org Wed Jul 20 18:04:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 18:04:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202204.j6KM4AGI026133@pub.open-bio.org> mwilkinson Wed Jul 20 18:04:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26114/MOBY Modified Files: secondary_input.pm Log Message: secondary inputs not writing to databse because id returned was null. moby-live/Perl/MOBY secondary_input.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 22:46:00 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/20 22:04:10 1.5 @@ -122,8 +122,7 @@ {article_name => $self->article_name}, {service_instance_id => $self->service_instance_id}); - my $id = $dbh->{$insertid}; - return $id; + return $insertid; } sub AUTOLOAD { From mwilkinson at pub.open-bio.org Wed Jul 20 18:49:05 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 18:49:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202249.j6KMn5f5026327@pub.open-bio.org> mwilkinson Wed Jul 20 18:49:05 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26308/MOBY Modified Files: service_instance.pm Log Message: test for the pre-existing service seems to fail. Try this code instead moby-live/Perl/MOBY service_instance.pm,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:29:38 1.18 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 22:49:05 1.19 @@ -199,14 +199,11 @@ return undef unless $self->authority_uri; return undef unless $self->servicename; - #$self->_dbh(); - #return undef unless $self->dbh; - #my $dbh = $self->dbh; if ( $self->test ) { return $self->service_instance_exists } - $self->authority( $self->_get_authority() ) - ; # this might not be necessary - it simply converts auth_uri to auth_id and v.v.? - # it actually is necessary for the moment. We need to put the logic of determining - # service id into the mysql.pm module!! + if ($self->service_instance_exists){return -1} + + $self->authority( $self->_get_authority() ); + if ( $self->service_type ) { my $OE = MOBY::OntologyServer->new( ontology => 'service' ); my ( $success, $message, $servicetypeURI ) = @@ -229,15 +226,7 @@ servicename => $self->servicename, authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); - if (($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI - && ( ( defined $self->category ) - || ( defined $self->service_type ) - || ( defined $self->url ) - || ( defined $self->contact_email ) - || ( defined $self->description ) ) - ){ - return -1; # no no no, not alowed to do that! I will not give you an object - } elsif ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did + if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); $self->category( $existing_service->{'category'} ); $self->service_type( $existing_service->{'servicetype'} ); From mwilkinson at pub.open-bio.org Wed Jul 20 18:34:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 18:34:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202234.j6KMYn0j026242@pub.open-bio.org> mwilkinson Wed Jul 20 18:34:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv26223/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: can query authority by either URI or database id moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 17:00:26 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 22:34:48 1.20 @@ -597,12 +597,13 @@ my $servicename = $args{'servicename'}; my $authURI = $args{'authority_uri'}; - - my $result = $self->query_authority({authority_uri => $authURI}); - return [{}] unless @$result[0]; - my $id = @$result[0]->{authority_id}; - return [{}] unless $id; - + my $id = $args{'authority_id'}; + unless ($id){ + my $result = $self->query_authority({authority_uri => $authURI}); + return [{}] unless @$result[0]; + my $id = @$result[0]->{authority_id}; + return [{}] unless $id; + } my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Thu Jul 21 12:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jul 2005 12:37:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211637.j6LGbZYt029162@pub.open-bio.org> mwilkinson Thu Jul 21 12:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29120/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: updating the service discovery code to be in-line with the new adaptor API moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 22:34:48 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/21 16:37:35 1.21 @@ -589,9 +589,7 @@ } } -# selects all the columns from service_instance table -# where is lsid? -sub query_service_instance { +sub query_service_existence { my ($self, %args) = @_; my $dbh = $self->dbh; @@ -600,9 +598,9 @@ my $id = $args{'authority_id'}; unless ($id){ my $result = $self->query_authority({authority_uri => $authURI}); - return [{}] unless @$result[0]; + return 0 unless @$result[0]; my $id = @$result[0]->{authority_id}; - return [{}] unless $id; + return 0 unless $id; } my $statement = "select service_instance_id, @@ -620,6 +618,32 @@ my @bindvalues; ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); my $final = do_query($dbh, $statement, @bindvalues); + if (@$final[0]){return 1} else {return 0} + +} +# selects all the columns from service_instance table +# where is lsid? + +sub query_service_instance { + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority_id, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance "; + my @bindvalues; + ($statement, @bindvalues) = add_condition($statement, @args); + my $final = do_query($dbh, $statement, @bindvalues); return $final; } @@ -628,7 +652,7 @@ my ($self, @args) = @_; my $dbh = $self->dbh; my $uri_list = get_value('service_type_uri', @args); - my $statement = "select service_instance_id from service_instance where service_type_uri in ($uri_list)"; + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; my @bindvalues = (); my $result = do_query($dbh, $statement, @bindvalues); @@ -1055,10 +1079,10 @@ $kw = $dbh->quote("%$kw%"); $searchstring .= " OR description like $kw "; } - $searchstring =~ s/OR//; # just the first one + $searchstring =~ s/OR//; # remove just the first OR in the longer statement # $debug && &_LOG("search $searchstring\n"); - my $statement = "select service_instance_id from service_instance where $searchstring"; + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; my @bindvalues = (); my $ids = do_query($dbh, $statement, @bindvalues); @@ -1087,7 +1111,7 @@ } my $result = do_query($dbh, $query, ()); - return ($query, $result); + return $result; } # custom query subroutine for Moby::Central.pm->_searchForCollection() @@ -1119,7 +1143,7 @@ } my $result = do_query($dbh, $query, ()); - return ($query, $result); + return $result; } # custom query subroutine for Moby::Central.pm->RetrieveServiceNames From mwilkinson at pub.open-bio.org Thu Jul 21 12:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jul 2005 12:37:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211637.j6LGbZrO029143@pub.open-bio.org> mwilkinson Thu Jul 21 12:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29120/MOBY Modified Files: Central.pm service_instance.pm Log Message: updating the service discovery code to be in-line with the new adaptor API moby-live/Perl/MOBY Central.pm,1.163,1.164 service_instance.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.163 retrieving revision 1.164 diff -u -r1.163 -r1.164 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 17:12:20 1.163 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 16:37:35 1.164 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::Client::Central; +#use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -762,7 +762,7 @@ unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my $result = $adaptor->query_service_instance({service_type_uri => $existingURI}); + my $result = $adaptor->query_service({service_type_uri => $existingURI}); my $row = shift(@$result); my $id = $row->{service_instance_id}; @@ -1888,7 +1888,13 @@ $debug && _LOG( "authoritative added; criterion count is now $criterion_count\n"); - my $ids = $adaptor->query_service_instance({authoritative => $findme{authoritative}}); + my $ids = _extract_ids($adaptor->query_service_instance({authoritative => $findme{authoritative}})); + + + + ### MARK - we need to extract ids at each step... + + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1923,7 +1929,7 @@ $children_string .= ( join ',', map { "\'$_\'" } @children ); } $children_string =~ s/\,$//; - my $ids = $adaptor->match_service_type_uri({service_type_uri => $children_string}); + my $ids = _extract_ids($adaptor->match_service_type_uri({service_type_uri => $children_string})); $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); @@ -1946,7 +1952,7 @@ return &_serviceListResponse( $dbh, undef ); } - my $ids = $adaptor->query_service_instance({authority_id => $id}); + my $ids = _extract_ids($adaptor->query_service_instance({authority_id => $id})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1965,7 +1971,7 @@ && _LOG( "servicename added; criterion count is now $criterion_count\n"); - my $ids = $adaptor->query_service_instance({servicename => $findme{servicename}}); + my $ids = _extract_ids($adaptor->query_service_instance({servicename => $findme{servicename}})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1984,7 +1990,7 @@ $debug && _LOG("category added; criterion count is now $criterion_count\n"); - my $ids = $adaptor->query_service_instance({category => lc( $findme{category}) }); + my $ids = _extract_ids($adaptor->query_service_instance({category => lc( $findme{category}) })); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -2003,6 +2009,7 @@ && _LOG("Keywords added; criterion count is now $criterion_count\n"); my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + $ids = _extract_ids($ids); # this is the hash-list that comes back from do_query unless ( scalar @{$ids} ) { $debug @@ -2146,6 +2153,20 @@ return &_serviceListResponse( $dbh, @final ); } +sub _extract_ids { + my ($linehash) = @_; + # ths data comes from the do_query of the mysql call + # --> [{...}] + my @lines = @$linehash; + return [] unless scalar(@lines); + my @ids; + foreach (@lines){ + my $id = $_->{service_instance_id}; + push @ids, $id; + } + return \@ids +} + #Eddie - converted sub _searchForServicesWithArticle { my ( $dbh, $inout, $node, $expand, $coll ) = @_; @@ -2190,9 +2211,8 @@ } $ancestor_string =~ s/\,$//; - my ($query, $result) = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); - $debug && _LOG("\nQUERY $query\n"); my @valid_services; foreach my $row (@$result) @@ -2242,10 +2262,8 @@ my ( $objectURI, $namespaceURIs ) = &_extractObjectTypesAndNamespaces($simple); - my ($query, $result) = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); - $debug && &_LOG("QUERY: $query"); - foreach my $row (@$result ) { # get the service instance ID and the namespaces that matched my $id = $row->{service_instance_id}; @@ -3392,7 +3410,7 @@ my $service_type = $OSserv->getServiceCommonName($service_type_uri); $result = $adaptor->query_authority({authority_id => $authority_id}); - my $row = shift(@$result); + $row = shift(@$result); my $authURI = $row->{authority_uri}; $output .= "\t\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 22:49:05 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 16:37:35 1.20 @@ -186,16 +186,6 @@ $self->{$attrname} = $self->_default_for($attrname); } } - - # category => $Category, - # servicename => $serviceName, - # service_type => $serviceType, - # authority_uri => $AuthURI, - # url => $URL, - # contact_email => $contactEmail, - # authoritative => $authoritativeService, - # description => $desc, - # return undef unless $self->authority_uri; return undef unless $self->servicename; @@ -222,9 +212,8 @@ ? $self->service_type_uri( $self->service_type ) : $self->service_type_uri($servicetypeURI); } - my $existing_services = $self->adaptor->query_service_instance( - servicename => $self->servicename, - authority_uri => $self->authority_uri); + my $existing_services = $self->adaptor->query_service_instance({servicename => $self->servicename},"and", + {authority_uri => $self->authority_uri}); my $existing_service = shift(@$existing_services); if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); @@ -316,15 +305,9 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; my $authority; - - my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + + my $result = $adaptor->query_service_existence(authority_uri => $self->authority_uri, servicename => $self->servicename); my $row = shift(@$result); - my $id = $row->{authority_id}; - - return undef unless $id; - - $result = $adaptor->query_service_instance({authority_id => $id}, 'and', {servicename => $self->servicename}); - $row = shift(@$result); my $svc = $row->{service_instance_id}; return $svc; From mwilkinson at pub.open-bio.org Thu Jul 21 13:08:43 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jul 2005 13:08:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211708.j6LH8hK2029352@pub.open-bio.org> mwilkinson Thu Jul 21 13:08:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29333/MOBY Modified Files: Central.pm Log Message: mistakenly commented out that line moby-live/Perl/MOBY Central.pm,1.164,1.165 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.164 retrieving revision 1.165 diff -u -r1.164 -r1.165 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 16:37:35 1.164 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 17:08:43 1.165 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -#use MOBY::Client::Central; +use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; From mwilkinson at pub.open-bio.org Thu Jul 21 13:43:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jul 2005 13:43:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211743.j6LHhOxD029513@pub.open-bio.org> mwilkinson Thu Jul 21 13:43:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29494/MOBY Modified Files: service_instance.pm Log Message: service_instance_exists needs to return boolean moby-live/Perl/MOBY service_instance.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 16:37:35 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 17:43:24 1.21 @@ -307,10 +307,7 @@ my $authority; my $result = $adaptor->query_service_existence(authority_uri => $self->authority_uri, servicename => $self->servicename); - my $row = shift(@$result); - my $svc = $row->{service_instance_id}; - - return $svc; + return $result } sub _get_authority From gordonp at pub.open-bio.org Fri Jul 22 01:00:58 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:00:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220500.j6M50wgR030700@pub.open-bio.org> gordonp Fri Jul 22 01:00:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv30675 Modified Files: SimpleClient.html Log Message: Finally got around to creating the jMOBY data instance documentation moby-live/Java/docs SimpleClient.html,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/SimpleClient.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/docs/SimpleClient.html 2005/05/19 10:56:06 1.2 +++ /home/repository/moby/moby-live/Java/docs/SimpleClient.html 2005/07/22 05:00:58 1.3 @@ -1,24 +1,263 @@ - -Simple Client - - - - - - -

-

Simple Client

-
- -
-Coming soon... (or later) -
- -
-
-
Paul Gordon
+ + + + + + jMOBY Client/Server Quickstart + + + +

jMOBY Client/Server Quickstart

+ +

Motivation

+

+ This document is intended to get you up and running using the client-server service communication + code (i.e. calling or providing remote Web Services) in the Java implementation + (jMOBY) of + MOBY-S "Web Services for Molecular Biology". If you are looking + for more detailed information on how to query MOBY Central's yellow pages about what services are + available, please see this + document. This document assumes that you are familiar with Java and + XML. +

+ +

Syntax Notes

+

+

    +
  • jMOBY class, member and method names are display in this font face
  • +
  • System.out.println("Example code is treated like + a block quote (indented paragraph)");
  • +
  • MOBY-S XML elements and attributes are displayed in this font face
  • + +
+

+ +

Sections

+

+

+

+ + +
+ + +

Basic Anatomy of the Java API

+

+ Three main classes form the core of the API: +

    +
  1. org.biomoby.shared.data.MobyDataObject - + any valid + data object + you want to transmit will be encoded using methods in this class or its subclasses. You never + need to handcode any XML (but of course you can if you really want to).
  2. + +
  3. org.biomoby.shared.data.MobyDataObjectSet - for grouping MobyDataObjects together, + implements the Java Collection interface, + and is the equivalent of the + Collection + container + element in the current MOBY-S API.
  4. + +
  5. org.biomoby.shared.MobyRequest - this class handles all of the network communication + (SOAP + messaging) required between client and server.
  6. +
+

+ +

+ Be sure to include the following statements in the header for any class in which you plan to use jMOBY + service communication: +

import org.biomoby.client.*;
import org.biomoby.shared.*;
import org.biomoby.shared.data.*;
+

+ +
+ +

Hello World (or its bioinformatics equivalent)

+ +

+ The following code has two parts. First, a service called "MOBYSHoundGetGenBankff" is found via MOBY Central. + This service fetches sequences based on keys such as GenBank gi identifiers. Second, the service + is called using MobyRequest with a sample input MobyDataObject. The result of the + service invocation (a DNA sequence in XML) is printed. + +

+
            
+import org.biomoby.client.*;
+import org.biomoby.shared.*;
+import org.biomoby.shared.data.*;
+
+public class HelloMOBY {
+    public static void main(String[] args) throws Exception{
+
+        Central worker = new CentralImpl();
+        MobyService templateService = new MobyService("MOBYSHoundGetGenBankff");
+        MobyService[] validServices = worker.findService(templateService);
+
+	MobyRequest mr = new MobyRequest(worker);
+	mr.setService(validServices[0]);
+	mr.setInput(new MobyDataObject("NCBI_gi", "111076"));
+	System.out.println(mr.invokeService().toString());
+    }
+}
+	  
+ + A version of this code with comments and error checking is available in the +
MOBY CVS as Java/src/Clients/TestRequest.java +
+ +

Creating jMOBY Data

+

+ The Java API is designed so that all of the MOBY-S XML concepts can be "get" or "set" using Java primitives + (Strings, Numbers, etc.) as parameters to class methods. You do not need to + write or parse XML. There are several key features of jMOBY that minimize the number of classes you need to + familiarize yourself with: +

+

+ +

Because of the input/output symmetry of service data, MOBY objects are highly reusable when you are trying to chain + together multiple service discoveries and invocations. If you are interested in creating + reusable workflows (MOBY macros of sorts), you may wish to look at Taverna. +

+ + +

Creating a database identifier object

+

Database identifiers are often the starting point for workflows, as they can be used to retrieve sequence data, + which is then visualized or submitted to other services. All MOBY objects have +a namespace and an ID, +therefore a database identifier is the simplest form of a object. A MobyDataObject constructor is available +to easily build database identifiers (MobyDataObject(String namespace, String id)): + +

MobyDataObject dbid = new MobyDataObject("NCBI_gi", "111076");
+ +

+ +

Creating a "primitive" data object

+

+The following data are considered irreducible, atomic, or "primitive" in MOBY: + + + + + + + + + + + +
MOBY SpecificationjMOBY class in org.biomoby.shared.dataunderlying Java implementationCan be instantiated using any one of
ObjectMobyDataObjectimplements Comparable
  • "namespace", "id"
  • MOBYDataObject (cloning)
StringMobyDataStringjava.lang.StringBuffer
IntegerMobyDataIntjava.math.BigInteger
  • int
  • java.lang.Number (i.e. Byte, Double, Float, Integer, Long, Short, BigInteger, BigDecimal)
  • Strings like "2005"
FloatMobyDataFloatjava.math.BigDecimal
  • double
  • java.lang.Number
  • Strings like "2.0-e4" or "0.0002"
DateTimeMobyDataDateTimejava.util.GregorianCalendar
+Any object can also be instantiated using the corresponding XML data as an org.w3c.dom.Element. +

+

Below are some (hopefully) self-explanatory primitive object creation examples: +

MobyDataString sequenceString = new MobyDataString("MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSPGYVEHNPDEIWNAQMLAI");
+
MobyDataInt sequenceLength = new MobyDataInt(60);
+
MobyDataFloat sequencePI = new MobyDataFloat(3.67);
+
MobyDataFloat sequenceBlastEValue = new MobyDataFloat("1e-29");
+
MobyDataDateTime blastDBUpdated = new MobyDataDateTime("2005-03-24");
+
+

+ +

Creating composite objects

+

Many times, you will want to send a piece of data that is more complex than a primitive. These can be built using +MobyDataComposite, which implements the java.util.Map interface. For example, if a service requires an +AminoAcidSequence as input, +its two members, SequenceString and Length can be set like so: + +

+String aaSequence = "MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSPGYVEHNPDEIWNAQMLAI";
+MobyDataComposite aaSequenceObject = new MobyDataComposite("AminoAcidSequence");
+aaSequence.put("SequenceString", new MobyDataString(aaSequence));
+aaSequence.put("Length", new MobyDataInt(aaSequence.length()));
+
+ +

+
+ + +

Manipulating jMOBY data

+

+Coming soon. +

+ +

Dissecting queries and responses

+

Changing data objects

+
+
+

Creating MOBY XML (responses and queries)

+

+ It may at times be necessary to explicitly create a + full MOBY + XML document (i.e. serialize jMOBY objects). For example to store a response on disk for later usage, or + just so you can create your own SOAP response as a service provider. The + org.biomoby.shared.data.MobyDataUtils class provides the ability to output + XML documents, by specifiying an java.io.OutputStream and the contents. +

+ +

Create a blank MOBY XML response

+

+ Use the one-object convenience constructor for org.biomoby.shared.data.MobyContentInstance. + It will automatically create the content envelope. Since the object (first arg) is null, the mobyData + will be blank. This data envelope is then made into a proper XML file, with declarations and all, by + MobyDataUtils. + +

MobyDataUtils.toXMLDocument(System.out, new MobyContentInstance(null, null));
+

+ +

Create a MOBY XML response or query with a single data object

+

+ Use the one-object convenience constructor for MobyContentInstance. It will automatically + create the full content envelope and embed the XML for your object. The object must be or inherit from + MobyDataObject (Simples), or MobyDataObjectSet (Collections) + to form a valid content envelope. + +

MobyDataUtils.toXMLDocument(System.out, new MobyContentInstance(new + MobyDataObject("gi", "100089"), null));
+

+ +

Create a MOBY XML response or query envelope with multiple invocations

+

+ Use the default constructor for MobyContentInstance, then add at least one MobyDataInstance +to it using the java.lang.Map interface or the convenient one-arg put method. +

+MobyContentInstance queries = new MobyContentInstance();
+data.put(new MobyDataObject("gi", "100089"));
+data.put(new MobyDataObject("gi", "324442"));
+MobyDataUtils.toXMLDocument(System.out, queries);
+
+
+ +

Parsing MOBY XML

+ +

As a counterpart to the utility above, jMOBY provides a method to deserialize a response/request envelope: +

+MobyContentInstance queries = MobyDataUtils.fromXMLDocument(System.in);
+System.out.println("The document contained " + ((queries.size() == 1) ? "1 query" : (query.size() + " queries")));
+
+

+ + +
+
Paul Gordon
+ -Last modified: Tue May 17 15:34:15 2005 +Last modified: Thu Jul 21 23:45:59 MDT 2005 -
- + + From gordonp at pub.open-bio.org Fri Jul 22 01:11:54 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:11:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220511.j6M5Bsa7030848@pub.open-bio.org> gordonp Fri Jul 22 01:11:54 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory pub.open-bio.org:/tmp/cvs-serv30795 Modified Files: MobyDataComposite.java MobyDataDateTime.java MobyDataFloat.java MobyDataInt.java MobyDataObject.java MobyDataObjectSet.java MobyDataSecondaryInstance.java MobyDataString.java Added Files: MobyContentInstance.java MobyDataUtils.java Log Message: First major release of fully functional data instance code moby-live/Java/src/main/org/biomoby/shared/data MobyContentInstance.java,NONE,1.1 MobyDataUtils.java,NONE,1.1 MobyDataComposite.java,1.2,1.3 MobyDataDateTime.java,1.2,1.3 MobyDataFloat.java,1.2,1.3 MobyDataInt.java,1.2,1.3 MobyDataObject.java,1.3,1.4 MobyDataObjectSet.java,1.2,1.3 MobyDataSecondaryInstance.java,1.2,1.3 MobyDataString.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2005/07/22 05:11:54 1.3 @@ -11,6 +11,7 @@ import java.util.Vector; import org.biomoby.shared.MobyDataType; +import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyNamespace; /** @@ -28,9 +29,9 @@ /** * Construct the object using a DOM fragment. * - * @throws IllegalArgumentException if the element is not a MobyObject tag + * @throws MobyException if the element is not a MobyObject tag */ - public MobyDataComposite(org.w3c.dom.Element element) throws IllegalArgumentException{ + public MobyDataComposite(org.w3c.dom.Element element) throws MobyException{ this(new MobyDataType(element.getLocalName()), getName(element), getNamespace(element), getId(element)); // Decompose the children @@ -70,6 +71,23 @@ members = new HashMap(); } + public MobyDataComposite(MobyDataType type, String name){ + this(type, name, "", ""); + } + + public MobyDataComposite(String typeName, String name){ + this(new MobyDataType(typeName), name); + } + + public MobyDataComposite(MobyDataType type){ + this(type, ""); + } + + public MobyDataComposite(String typeName){ + this(new MobyDataType(typeName)); + } + + /** * Report whether all required fields for the object's datatype have been instantiated * (i.e. the object is ready to use as input to a service). @@ -108,6 +126,10 @@ for(int i = 0; i < fieldNames.length; i++){ //MobyDataObject mdsi = members.get(fieldNames[i]); //Java1.5 MobyDataObject mdsi = (MobyDataObject) members.get(fieldNames[i]); + // ensure the articleName is set correctly for the requirements of this object + if(!fieldNames[i].toString().equals(mdsi.getName())){ + mdsi.setName(fieldNames[i].toString()); + } int oldXmlMode = mdsi.getXmlMode(); if(oldXmlMode != MobyDataInstance.SERVICE_XML_MODE){ mdsi.setXmlMode(MobyDataInstance.SERVICE_XML_MODE); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2005/07/22 05:11:54 1.3 @@ -40,7 +40,7 @@ } /** - * Constructor to build a MOBY DateTime object using an ISO 8601 formatted input string. + * Constructor to build a MOBY DateTime object using the W3C profile of an ISO 8601 formatted input string. * @param stringISO8601 if null, the current local date and time is used */ public MobyDataDateTime(String articleName, String stringISO8601) throws IllegalArgumentException{ @@ -49,6 +49,10 @@ value = parseISO8601(stringISO8601); } + public MobyDataDateTime(String stringISO8601){ + this("", stringISO8601); + } + public MobyDataDateTime(String articleName, GregorianCalendar cal){ super(articleName, ""); setDataType(new MobyDataType("DateTime")); @@ -56,6 +60,10 @@ ((StringBuffer) super.getObject()).append(toString()); // set string representation in case super.toXML() is called explicitly } + public MobyDataDateTime(GregorianCalendar cal){ + this("", cal); + } + /** * For a description of ISO 8601 as used on the Web, see http://www.w3.org/TR/NOTE-datetime * This method is based on org.w3.util.DateParser v. 1.4 by Benoît Mahé (bmahe at w3.org) =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2005/07/22 05:11:54 1.3 @@ -49,6 +49,10 @@ } } + public MobyDataFloat(Number n){ + this("", n); + } + /** * Constructor to use if the incoming value is a primitive. * If you want to pass in a float or int, cast it to a double. @@ -59,6 +63,10 @@ value = new BigDecimal(d); } + public MobyDataFloat(double d){ + this("", d); + } + /** * Constructor to use if the incoming value is a string representing a number * (including mantissa/exponent format). @@ -71,6 +79,10 @@ value = new BigDecimal(stringNumber); } + public MobyDataFloat(String stringNumber){ + this("", stringNumber); + } + public Object clone(){ MobyDataFloat copy = new MobyDataFloat(getName(), value); copy.setDataType(getDataType()); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2005/07/22 05:11:54 1.3 @@ -50,6 +50,10 @@ } } + public MobyDataInt(Number n){ + this("", n); + } + /** * Constructor to use if the incoming value is a primitive. * If you want to pass in a float or double, cast it to an int. @@ -60,6 +64,10 @@ value = new BigInteger(""+i); } + public MobyDataInt(int i){ + this("", i); + } + /** * Constructor to use if the incoming value is a string representing an integer number. * =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/07/19 12:39:59 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/07/22 05:11:54 1.4 @@ -45,9 +45,9 @@ /** * Construct the object using a DOM fragment. * - * @throws IllegalArgumentException if the element is not an Object tag + * @throws MobyException if the element is not an Object tag, or is missing a required attribute */ - public MobyDataObject(Element element) throws IllegalArgumentException{ + public MobyDataObject(Element element) throws MobyException{ this(getNamespace(element).getName(), getId(element)); setName(getName(element)); } @@ -58,6 +58,7 @@ */ public MobyDataObject(String name){ super(name); + setDataType(staticObjectDataType); } /** @@ -84,13 +85,14 @@ /** * This method creates a MobyDataObject of the appropriate subclass for * a given input XML tree (e.g. base objects like MobyDataObject and MobyDataInt, - * or complex objects like MobyDataDateTime or MobyDataComposite). This method + * or complex objects like MobyDataDateTime or MobyDataComposite, or even a + * MobyDataSecondaryInstance). This method * will also parse a MOBY XML Object wrapped in a Simple tag when the Simple * is passed in as the main element. * * @param objectTag the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag */ - public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws IllegalArgumentException{ + public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws MobyException{ MobyDataObject object = null; if(objectTag == null){ @@ -99,23 +101,31 @@ String objectClass = objectTag.getLocalName(); if("Simple".equals(objectClass)){ - NodeList children = objectTag.getElementsByTagName("*"); + NodeList children = objectTag.getChildNodes(); + int elementChild = -1; + for(int i = 0; i < children.getLength(); i++){ + if(children.item(i) instanceof Element){ + // Second instance of element child + if(elementChild != -1){ + throw new IllegalArgumentException("Simple element has more than one " + + "child element, cannot create a MOBY data " + + "instance due to the ambiguity of the input XML"); + } + elementChild = i; + } + } // A Simple tag is allowed to have exactly one child element - if(children.getLength() == 0){ + if(elementChild == -1){ throw new IllegalArgumentException("Simple element has no MOBY " + "child element, there is no " + "instance to create"); } - else if(children.getLength() != 1){ - throw new IllegalArgumentException("Simple element has more than one " + - "child element, cannot create a MOBY data " + - "instance due to the ambiguity of the input XML"); - } - return createInstanceFromDOM((Element) children.item(0)); + + return createInstanceFromDOM((Element) children.item(elementChild)); } // There are six types of objects we can populate with data directly - // plus Collections. Otherwise its a composite. + // plus Collections and Secondary Parameters. Otherwise it is a composite. else if("Object".equals(objectClass)){ return new MobyDataObject(objectTag); } @@ -137,14 +147,22 @@ else if("Collection".equals(objectClass)){ return new MobyDataObjectSet(objectTag); } + else if(MobyDataSecondaryInstance.ELEMENT_NAME.equals(objectClass)){ + return new MobyDataSecondaryInstance(objectTag); + } // Must otherwise be a composite else{ return new MobyDataComposite(objectTag); } } - protected static String getTextContents(Element element){ - NodeList children = element.getChildNodes(); + /** + * Similar to DOM level 3 getTextContent, but only elements are excepted as input, and text + * inside children elements is not picked up. + * Actually calls MobyObjectDecompositionImpl.getTextContent() + */ + public static String getTextContents(Element element){ + /* NodeList children = element.getChildNodes(); int numChildren = children.getLength(); StringBuffer textContents = new StringBuffer(); for(int i = 0; i < numChildren; i++){ @@ -153,8 +171,8 @@ childNode instanceof org.w3c.dom.CDATASection){ textContents.append(childNode.getNodeValue()); } - } - return textContents.toString(); + }*/ + return MobyObjectDecompositionImpl.getTextContent(element, false); } protected static MobyNamespace getNamespace(Element e){ @@ -165,7 +183,7 @@ /** * Determine the name of the element if the parent Simple exists */ - protected static String getName(Element e){ + public static String getName(Element e){ Node p = e.getParentNode(); if(p == null || !(p instanceof Element)){ return ""; @@ -174,7 +192,7 @@ return name == null ? "" : name; } - protected static String getId(Element e){ + public static String getId(Element e){ String id = e.getAttribute("id"); return id == null ? "" : id; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2005/07/22 05:11:54 1.3 @@ -6,6 +6,7 @@ import java.util.Iterator; import java.util.Vector; +import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyPrimaryDataSet; import org.biomoby.shared.MobyPrefixResolver; @@ -26,11 +27,11 @@ Vector bag; private int xmlMode = MobyDataInstance.SERVICE_XML_MODE; - public MobyDataObjectSet(org.w3c.dom.Element e) throws IllegalArgumentException{ + public MobyDataObjectSet(org.w3c.dom.Element e) throws MobyException{ this(MobyDataObject.getName(e), getChildren(e)); } - public static Collection getChildren(org.w3c.dom.Element e){ + public static Collection getChildren(org.w3c.dom.Element e) throws MobyException{ Vector members = new Vector(); org.w3c.dom.NodeList children = e.getElementsByTagName("*"); //wildcard @@ -102,7 +103,8 @@ * @return the MobyDataObjects that comprise the collection */ public MobyDataObject[] getElementInstances(){ - return (MobyDataObject[]) bag.toArray(); + MobyDataObject instances[] = new MobyDataObject[bag.size()]; + return (MobyDataObject[]) bag.toArray(instances); } private void checkInputClass(String action, Object mdsi) throws ClassCastException, NullPointerException{ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/07/19 12:59:21 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/07/22 05:11:54 1.3 @@ -1,14 +1,18 @@ package org.biomoby.shared.data; -import org.biomoby.shared.MobySecondaryData; + +import org.biomoby.shared.*; +import org.w3c.dom.*; /** * A class that holds and displays secondary input data to a service. */ -public class MobyDataSecondaryInstance extends MobySecondaryData{ +public class MobyDataSecondaryInstance extends MobySecondaryData implements MobyDataInstance{ protected String dataValue = null; - protected MobySecondaryData secDataType = null; + protected int xmlMode = MobyDataInstance.CENTRAL_XML_MODE; + public static final String ELEMENT_NAME = "Parameter"; + public static final String VALUE_NAME = "Value"; public MobyDataSecondaryInstance(MobySecondaryData type, String value){ this(type); @@ -26,7 +30,40 @@ setDefaultValue(type.getDefaultValue()); setMinimumValue(type.getMinimumValue()); setMaximumValue(type.getMaximumValue()); - secDataType = type; + } + + /** + * Create an instance from XML input. Unfortunately, under the current scheme + * we have no way of knowing what the type of the parameter is (int, string, etc.). + * By default we will treat it as a string, as this is the most lenient. + */ + public MobyDataSecondaryInstance(Element objectTag) throws MobyException{ + // What is the parameter name? + super(MobyDataObject.getName(objectTag)); + setDataType("String"); + + if(objectTag == null){ + return; + } + + String objectClass = objectTag.getLocalName(); + if(!ELEMENT_NAME.equals(objectClass)){ + throw new MobyException("While creating a secondary parameter instance from XML: " + + "the passed in element (" +objectClass + ") was not a " + ELEMENT_NAME); + } + NodeList values = objectTag.getElementsByTagNameNS(MobyPrefixResolver.MOBY_XML_NAMESPACE, VALUE_NAME); + if(values.getLength() == 0){ + throw new MobyException("While creating a secondary parameter instance from XML: " + + "No " + VALUE_NAME + " element in the namespace " + + MobyPrefixResolver.MOBY_XML_NAMESPACE + " was found"); + } + if(values.getLength() > 1){ + throw new MobyException("While creating a secondary parameter instance from XML: " + + "More than one " + VALUE_NAME + " element ("+ + values.getLength() +") in the namespace " + + MobyPrefixResolver.MOBY_XML_NAMESPACE + " was found"); + } + setValue(MobyDataObject.getTextContents((Element) values.item(0))); } public void setValue(String value) throws IllegalArgumentException{ @@ -37,9 +74,51 @@ return dataValue; } + public void setXmlMode(int mode) throws IllegalArgumentException{ + if(mode != MobyDataInstance.CENTRAL_XML_MODE && mode != MobyDataInstance.SERVICE_XML_MODE){ + throw new IllegalArgumentException("Value passed to setXmlMode was neither " + + "MobyDataInstance.CENTRAL_XML_MODE nor MobyDataInstance.SERVICE_XML_MODE"); + } + xmlMode = mode; + } + + /** + * Report whether toXML will produce Central template or service call instance XML. + * + * @return one of CENTRAL_XML_MODE or SERVICE_XML_MODE + */ + public int getXmlMode(){ + return xmlMode; + } + + /** + * This method sanitizes parameter data value strings of XML escape characters such as the ampersand (&) and the + * less-than sign (<). WARNING: this method will not escape ampersand in the string "&amp;", + * or '&#x26;' style character references. We will assume that is this case you've probably + * already written the string as XML. Also note that null strings are treated as empty strings. + * + * WARNING: As of yet, we do not deal with the false escaping of strings containg already-escaped + * CDATA sections! + */ public String toXML(){ - return " " + dataValue + "\n"; + // Sanitize the data before adding to the XML + String tmpValue = dataValue; + if(tmpValue != null){ + tmpValue = tmpValue.replaceAll("&(?!(amp|#x\\d+);)", "&"); + tmpValue = tmpValue.replaceAll("<", "<"); + } + // A null value and an empty string are considered equivalent here + else{ + tmpValue = ""; + } + + if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ + return " " + tmpValue + "\n"; + } + else{ + return super.toXML(); + } } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2005/07/22 05:11:54 1.3 @@ -36,6 +36,10 @@ value = new StringBuffer(stringValue.toString()); } + public MobyDataString(CharSequence stringValue){ + this("", stringValue); + } + public String toString(){ return value.toString(); } @@ -63,7 +67,7 @@ * This method sanitizes strings of XML escape characters such as the ampersand (&) and the * less-than sign (<). WARNING: this method will not escape ampersand in the string "&amp;", * or '&#x26;' style character references. We will assume that is this case you've probably - * already written the string as XML. + * already written the string as XML. Also note that null strings are treated as empty strings. * * WARNING: As of yet, we do not deal with the false escaping of strings containg already-escaped * CDATA sections! @@ -76,6 +80,9 @@ tmpValue = tmpValue.replaceAll("&(?!(amp|#x\\d+);)", "&"); tmpValue = tmpValue.replaceAll("<", "<"); } + else{ + tmpValue = ""; + } return "" + tmpValue + ""; } From gordonp at pub.open-bio.org Fri Jul 22 01:16:08 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:16:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220516.j6M5G8cY030883@pub.open-bio.org> gordonp Fri Jul 22 01:16:08 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv30858 Modified Files: ChangeLog Log Message: Noted updates to code and documentation of org.biomoby.shared.data moby-live/Java/docs ChangeLog,1.31,1.32 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/07/19 12:39:58 1.31 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/07/22 05:16:08 1.32 @@ -1,3 +1,9 @@ +2005-07-21 Paul Gordon + + * Update of data instance code to fully functional status (pending minor changes to the MOBY-S API docs) + + * Inclusion of "quick start" guide to using the classes in org.biomoby.shared.data + 2005-07-19 Martin Senger * Changed the remote repository for the third-party jar files. From gordonp at pub.open-bio.org Fri Jul 22 01:23:00 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:23:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220523.j6M5N0nx030932@pub.open-bio.org> gordonp Fri Jul 22 01:23:00 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory pub.open-bio.org:/tmp/cvs-serv30907 Modified Files: MobyRequest.java Log Message: Updated to use the new data instance classes moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/19 13:16:53 1.13 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/22 05:23:00 1.14 @@ -23,10 +23,7 @@ import org.apache.xpath.objects.XObject; import org.biomoby.shared.Central; import org.biomoby.shared.MobyData; -import org.biomoby.shared.data.MobyDataInstance; -import org.biomoby.shared.data.MobyDataSecondaryInstance; -import org.biomoby.shared.data.MobyDataObjectSet; -import org.biomoby.shared.data.MobyDataObject; +import org.biomoby.shared.data.*; import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyPrefixResolver; import org.biomoby.shared.MobyService; @@ -58,7 +55,7 @@ protected MobyService mobyService = null; protected MobyDataInstance[] inputData = null; protected MobyDataSecondaryInstance[] secondaryData = null; - protected Vector outputData = null; + protected MobyContentInstance outputData = null; protected Central mobyCentral = null; protected PrefixResolver mobyPrefixResolver = null; @@ -76,7 +73,6 @@ private XPath stringEncodedXPath; private XPath base64EncodedXPath; - private XPath queryResponseXPath; private XPath simpleChildXPath; private XPath collectionChildXPath; @@ -117,9 +113,8 @@ MobyPrefixResolver.XSI1999_PREFIX+ ":type, ':')=\"string\" or substring-after(@"+ MobyPrefixResolver.XSI2001_PREFIX+ - ":type, ':')=\"string\"]", null, - mobyPrefixResolver, XPath.SELECT); - queryResponseXPath = new XPath("//moby:mobyData | //mobyData", null, + ":type, ':')=\"string\"] | //"+ + MobyPrefixResolver.SOAP_ENC_PREFIX+":string", null, mobyPrefixResolver, XPath.SELECT); simpleChildXPath = new XPath("moby:Simple | Simple", null, mobyPrefixResolver, XPath.SELECT); @@ -233,7 +228,7 @@ * * @throws MobyException if you try to get the results before calling InvokeService */ - public Vector getOutput() throws MobyException{ + public MobyContentInstance getOutput() throws MobyException{ if(outputData == null){ throw new MobyException("Trying to access MOBY service results " + "before the service is invoked"); @@ -255,7 +250,7 @@ * @throws MobyException i.e. there was something wrong with the input, output or remote service's logic * @throws SOAPException i.e. there was a problem with the underlying transaction/transport layer */ - public Vector invokeService() throws MobyException, SOAPException, NoSuccessException{ + public MobyContentInstance invokeService() throws Exception, MobyException, SOAPException, NoSuccessException{ if(mobyService == null){ throw new MobyException("Tries to invoke null service from MobyRequest (call setService first)"); } @@ -264,7 +259,8 @@ verifyInput(); String mobyXML = convertMOBYDataToMOBYRequest(inputData, secondaryData); Element mobyDOM = performSOAPRequest(mobyXML); - outputData = convertMOBYResponseToMOBYData(mobyDOM); + // The following parses the DOM and extracts all the appropriate jMOBY objects to represent the XML in Java + outputData = MobyDataUtils.fromXMLDocument(mobyDOM); return outputData; } @@ -418,8 +414,9 @@ XPath responseElementXPath = null; try{ responseElementXPath = new XPath("//"+ MobyPrefixResolver.MOBY_TRANSPORT_PREFIX+ - ":"+mobyService.getName()+"Response", - null, mobyPrefixResolver, XPath.SELECT); + ":"+mobyService.getName()+"Response | //" + + mobyService.getName()+"Response", + null, mobyPrefixResolver, XPath.SELECT); }catch(TransformerException te){ throw new SOAPException("Cannot select SOAP nodes due to exception "+ "while compiling XPath statement (code bug?):" +te); @@ -480,11 +477,11 @@ node_list = runXPath(stringEncodedXPath, responseNode); } catch(TransformerException te){ - throw new SOAPException("Cannot select base64 encoded SOAP nodes due to exception "+ + throw new SOAPException("Cannot select string encoded SOAP nodes due to exception "+ "while executing XPath statement:" +te); } - // Do decoding for each base64 part found + // Do concatenation for each plain string part found for(int i = 0; node_list != null && i < node_list.getLength(); i++){ org.w3c.dom.Node change = node_list.item(i); /* Make sure the text data is all put into one contiguous piece for decoding*/ @@ -497,11 +494,12 @@ Node child = children.item(j); if(child instanceof CDATASection || child instanceof Text){ plainString += child.getNodeValue(); + System.err.println("Plain string is now " + plainString); } } // Swap out this node for the decoded data - change.getParentNode().replaceChild(n.getOwnerDocument().createTextNode(plainString), change); + change.getParentNode().replaceChild(n.getOwnerDocument().createCDATASection(plainString), change); } if(debug && node_list != null){ debugPS.println("There were " + node_list.getLength() + @@ -523,7 +521,14 @@ for(int j = 0; j < children.getLength(); j++){ Node child = children.item(j); if(child instanceof CDATASection || child instanceof Text){ - responseString += child.getNodeValue(); + // Unescape XML special characters in the string, so we can later on + // parse the payload as regular XML. + // Ignore whitespace-only node + if(child.getNodeValue().matches("^\\s+$")){ + continue; + } + System.err.println("Concatenating text in response " + child.getNodeValue()); + responseString += child.getNodeValue();//.replaceAll("<", "<").replaceAll(">", ">").replaceAll("(&|F)", "&"); } } @@ -639,103 +644,6 @@ } /** - * This method takes the internally stored DOM, representing the MOBY response - * from the service and converst it into the standard jMOBY API Data representation. - * - * @throws MobyException if the MOBY message does not conform to the API - */ - public Vector convertMOBYResponseToMOBYData(Element n) throws MobyException{ - // - Vector responsesOutput = new Vector(); - - NodeList response_list = null; - try{ - response_list = runXPath(queryResponseXPath, n); - }catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyContent nodes due to exception "+ - "while executing XPath statement: " +te); - } - - if(response_list == null || response_list.getLength() == 0){ - throw new MobyException("Could not find any mobyContent elements in the output"); - } - if(debug){ - debugPS.println("Aha! Got " + response_list.getLength() + " mobyContent response elements"); - } - // Do data decoding for each response's mobyData - for(int i = 0; i < response_list.getLength(); i++){ - Node response = response_list.item(i); - - Vector out = new Vector(); - // Find all the collections in the response - NodeList collections = null; - try{ - collections = runXPath(collectionChildXPath, response); - }catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyData/Collection nodes due to exception "+ - "while executing XPath statement: " +te); - } - for(int j = 0; collections != null && j < collections.getLength(); j++){ - if(debug & j == 0) - debugPS.println("There are " + collections.getLength() + - " collections in response #" +i); - MobyDataObjectSet collection = new MobyDataObjectSet(""); - - // For each collection, find the simple children - NodeList subsimples = null; - try{subsimples = runXPath(simpleChildXPath, collections.item(j));} - catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyData/Collection/Simple " + - "nodes due to exception "+ - "while executing XPath statement: " +te); - } - - // And add their values to the collection - MobyDataObject[] subout = new MobyDataObject[subsimples.getLength()]; - for(int k = 0; k < subsimples.getLength(); k++){ - if(debug && k == 0) - debugPS.println("There are " + subsimples.getLength() + - " simples in response #" + i + - ", collection #" + j); - subout[k] = (MobyDataObject) MobyDataObject.createInstanceFromDOM((Element) subsimples.item(k)); - } - collection.setElements(subout); - releaseXPath(collections.item(j)); - // Add completed collection to the output list - out.add(collection); - } - - // Take all the top level simples and add them to the list - NodeList simples = null; - try{ - simples = runXPath(simpleChildXPath, response); - }catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyData/Collection nodes due to exception "+ - "while executing XPath statement: " +te); - } - if((collections == null || collections.getLength() == 0) && - (simples == null || simples.getLength() == 0)){ - debugPS.println("WARNING: There appears to be no output data in mobyData #" + i); - } - for(int j = 0; simples != null && j < simples.getLength(); j++){ - if(debug && j == 0) - debugPS.println("There are " + simples.getLength() + " simples in response #" +i); - out.add(MobyDataObject.createInstanceFromDOM((Element) simples.item(j))); - } - - // What we're building is a Vector, where each element represents - // a Response's DataInstance Output (i.e. Simple and Collection return values) - MobyDataInstance[] mdis = new MobyDataInstance[out.size()]; - responsesOutput.add(out.toArray(mdis)); - - releaseXPath(response); - } - // release resources related to the Xpath execution, since we won't be using this doc anymore - releaseXPath(n); - return responsesOutput; - } - - /** * A method that sets up the execution environm,ent for and runs a compiled XPath statement against a DOM node * You should call releaseXPath when you're done with the results * @return the list of Nodes that satisfy the XPath in this Node's context From gordonp at pub.open-bio.org Fri Jul 22 01:30:38 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:30:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220530.j6M5UcnE031024@pub.open-bio.org> gordonp Fri Jul 22 01:30:38 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv31003 Added Files: PrimitiveTypes.java Log Message: Moved this class from obsucred subpackage of client to shared, since it's pretty basic info moby-live/Java/src/main/org/biomoby/shared PrimitiveTypes.java,NONE,1.1 From gordonp at pub.open-bio.org Fri Jul 22 01:32:49 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:32:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220532.j6M5WnnO031059@pub.open-bio.org> gordonp Fri Jul 22 01:32:49 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv31034 Modified Files: MobyPrefixResolver.java Log Message: Utility methods added that are used by data instance classes for ease of parsing moby-live/Java/src/main/org/biomoby/shared MobyPrefixResolver.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrefixResolver.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrefixResolver.java 2005/02/09 17:39:17 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrefixResolver.java 2005/07/22 05:32:49 1.4 @@ -1,6 +1,8 @@ package org.biomoby.shared; import org.apache.xml.utils.PrefixResolver; +import org.w3c.dom.*; +import java.util.Vector; /** * The main purpose of this class is to provide default mapping from @@ -28,6 +30,8 @@ public static final String XSI_PREFIX = "xsi"; public static final String XSI1999_PREFIX = "xsi1999"; public static final String XSI2001_PREFIX = "xsi2001"; + public static final String SOAP_ENC_NAMESPACE ="http://schemas.xmlsoap.org/soap/encoding/"; + public static final String SOAP_ENC_PREFIX ="soap-enc"; /** * We don't really implement this as it can be extremely complicated. @@ -52,6 +56,45 @@ } /** + * Convenience method that matches attributes in the MOBY namespace or, for now + * at least, with no declared namespace. + * @return the value of the attribute, or null if the attribute does not exist + */ + public static NodeList getChildElements(org.w3c.dom.Element e, String elementName){ + MobyNodeList matches = new MobyNodeList(); + + NodeList children = e.getChildNodes(); + for(int j = 0; children != null && j < children.getLength(); j++){ + // Make sure it's an element, not a processing instruction, text, etc. + if(!(children.item(j) instanceof Element)){ + continue; + } + Element child = (Element) children.item(j); + // Make sure it has the right name + if(!elementName.equals(child.getLocalName())){ + continue; + } + // Make sure it's in the MOBY namespace, or no namespace at all + String uri = child.getNamespaceURI(); + if(uri != null && uri.length() != 0 && !uri.equals(MOBY_XML_NAMESPACE)){ + continue; + } + + // Everything looks good + matches.add(child); + } + return matches; + } + + static class MobyNodeList implements NodeList{ + private Vector nodes; + public MobyNodeList(){nodes = new Vector();} + public int getLength(){return nodes.size();} + public Node item(int index){return (Node) nodes.elementAt(index);} + public void add(Node n){nodes.add(n);} + }; + + /** * @return For now, default MOBY and XML Schema Instance (1999) prefices as defined in the class static variables */ public String getNamespaceForPrefix(java.lang.String prefix){ @@ -73,6 +116,9 @@ else if(XSI2001_PREFIX.equals(prefix)){ return XSI_NAMESPACE2001; //Used by Axis } + else if(SOAP_ENC_PREFIX.equals(prefix)){ + return SOAP_ENC_NAMESPACE; + } else{ return ""; // Indicates that we don't have a mapping for this prefix } @@ -81,7 +127,7 @@ /** * Don't use this class if this method will be used. We are not returning a * valid XML namespace mapping, but a convenience method for XPath, therefore - * we will not given context sensitive mapping. + * we will not give context sensitive mapping. */ public String getNamespaceForPrefix(java.lang.String prefix, org.w3c.dom.Node context){ return getNamespaceForPrefix(prefix); From gordonp at pub.open-bio.org Fri Jul 22 01:26:43 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:26:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220526.j6M5Qhhw030979@pub.open-bio.org> gordonp Fri Jul 22 01:26:43 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv30954 Modified Files: MobyObjectDecompositionImpl.java Log Message: Removed Java 1.5 (actually a DOM level 3) dependency by implementing getTextContent(Node) moby-live/Java/src/main/org/biomoby/shared MobyObjectDecompositionImpl.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyObjectDecompositionImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyObjectDecompositionImpl.java 2005/05/12 05:19:20 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyObjectDecompositionImpl.java 2005/07/22 05:26:43 1.5 @@ -21,7 +21,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.biomoby.client.CentralImpl; -import org.biomoby.client.ui.graphical.applets.util.PrimitiveTypes; +import org.biomoby.shared.PrimitiveTypes; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -41,7 +41,7 @@ */ public class MobyObjectDecompositionImpl implements MobyObjectDecomposition { - private static final String URL_OBJECT = "http://mobycentral.cbr.nrc.ca:8090/authority/metadata?lsid="; + private static final String URL_OBJECT = "http://mobycentral.icapture.ubc.ca:8090/authority/metadata?lsid="; /* (non-Javadoc) * @see org.biomoby.client.gui.util.MobyObjectDecomposition#getFlattenedPrims(java.lang.String) @@ -80,7 +80,7 @@ "mobyPred:articleName").item(0); String localName = child.getLocalName(); String articleName = (articleNode == null) ? "" - : articleNode.getTextContent(); + : getTextContent(articleNode); // TODO - recurse if object is not a primitive if (isPrimitive(localName)) { MobyDataObject mdsi = createPrimitiveType( @@ -103,7 +103,7 @@ "mobyPred:articleName").item(0); String localName = child.getLocalName(); String articleName = (articleNode == null) ? "" - : articleNode.getTextContent(); + : getTextContent(articleNode); // TODO - recurse if object is not a primitive if (isPrimitive(localName)) { MobyDataObject mdsi = createPrimitiveType( @@ -154,6 +154,52 @@ return convertArrayListToMoby(list); } + /** + * Method to simulate DOM level 3 (Java 1.5 default) method for recursively getting text children from a Node. + * A wrapper around getTextContent(Node, boolean) with boolean = true, since DOM 3 getTextContent() ignores + * things that match Text.isContentElementWhitespace(). + */ + public static String getTextContent(Node parent){ + return getTextContent(parent, true); + } + + /** + * Grabs the text and CDATA children of a Node (not necessairly contiguous) and returns them concatenated. + * Added by Paul Gordon. + * Simulates ignoring of DOM 3 Text.isContentElementWhitespace() fully, I *think*. + * + * @param parent the node who's text children should be concatenated + * @param includeChildrensText if true, recursively appends children's text depth first + * + * @return non-normalized text contents of the passed-in Node, and its children if so requested + */ + public static String getTextContent(Node parent, boolean includeChildrensText){ + if(parent.hasChildNodes()){ + java.util.regex.Pattern nonWhitespacePattern = Pattern.compile("[^ \t\r\n]"); + StringBuffer textbuffer = new StringBuffer(); + + for(Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()){ + // Append all the contiguous text data + if(node instanceof org.w3c.dom.Text || node instanceof org.w3c.dom.CDATASection){ + // Get rid of whitespace + String value = node.getNodeValue(); + // Add if not just whitespace. + if(nonWhitespacePattern.matcher(value).find()){ + textbuffer.append(value); + } + } + // Get contents of children elements too (recursive) + else{ + textbuffer.append(getTextContent(node, includeChildrensText)); + } + } + return textbuffer.toString(); + } + else{ + return ""; + } + } + /* (non-Javadoc) * @see org.biomoby.client.gui.util.MobyObjectDecomposition#getObjectComposition(java.lang.String) */ From mwilkinson at pub.open-bio.org Fri Jul 22 13:12:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:12:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221712.j6MHCDji000428@pub.open-bio.org> mwilkinson Fri Jul 22 13:12:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv390/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. This simplifies it and should fix it. Also fixed the documentation for the MOBY::Client::ServiceInstance object as per this mornings email moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/21 16:37:35 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:12:13 1.22 @@ -625,9 +625,23 @@ # where is lsid? sub query_service_instance { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - + + my $authority_id; + if ($args{'authority_uri'}){ # need to transform URI to a row ID + my $result = $self->query_authority({authority_uri => $args{'authority_uri'}}); + return 0 unless @$result[0]; + my $authority_id = @$result[0]->{authority_id}; + return 0 unless $authority_id; + } + delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table + my @args; + while (my ($k, $v) = each %args){ + push @args, ({$k => $v},"and"); # format for the add_condition subroutine + } + pop @args; # get rid of last "and" + my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 13:12:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:12:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221712.j6MHCDsv000452@pub.open-bio.org> mwilkinson Fri Jul 22 13:12:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv390/MOBY/Client Modified Files: ServiceInstance.pm Log Message: the logic for findig existing services was still wonky. This simplifies it and should fix it. Also fixed the documentation for the MOBY::Client::ServiceInstance object as per this mornings email moby-live/Perl/MOBY/Client ServiceInstance.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2005/05/30 21:39:05 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2005/07/22 17:12:13 1.15 @@ -17,8 +17,9 @@ contactEmail => markw at illumin.com, name => 'marksFabulousService', type => 'Retrieve', - category => 'moby', - output => 'Sequence', + input => [$SimpleArticle], + category => 'moby', + output => [$CollectionArticle, $SecondaryArticle], description => 'retrieves random sequences from a database', XML => $xml, # the XML from MOBY::Central::findService ); @@ -99,7 +100,8 @@ Title : input Usage : $input = $Service->input($args) - Args : (optional) listref of SimpleArticle and/or CollectionArticle objects + Args : (optional) listref of SimpleArticle, + CollectionArticle, or SecondaryArticle objects Function : get/set input Returns : listref of MOBY::Client::SimpleArticle and/or MOBY::Client::CollectionArticle objects @@ -110,7 +112,8 @@ Title : output Usage : $output = $Service->output($args) - Args : (optional) listref of SimpleArticle and/or CollectionArticle objects + Args : (optional) listref of SimpleArticle, + CollectionArticle, or SecondaryArticle objects Function : get/set output Returns : listref of MOBY::Client::SimpleArticle and/or MOBY::Client::CollectionArticle objects From mwilkinson at pub.open-bio.org Fri Jul 22 13:12:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:12:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221712.j6MHCDou000409@pub.open-bio.org> mwilkinson Fri Jul 22 13:12:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv390/MOBY Modified Files: Central.pm Log Message: the logic for findig existing services was still wonky. This simplifies it and should fix it. Also fixed the documentation for the MOBY::Client::ServiceInstance object as per this mornings email moby-live/Perl/MOBY Central.pm,1.165,1.166 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.165 retrieving revision 1.166 diff -u -r1.165 -r1.166 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 17:08:43 1.165 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 17:12:13 1.166 @@ -1888,7 +1888,7 @@ $debug && _LOG( "authoritative added; criterion count is now $criterion_count\n"); - my $ids = _extract_ids($adaptor->query_service_instance({authoritative => $findme{authoritative}})); + my $ids = _extract_ids($adaptor->query_service_instance(authoritative => $findme{authoritative})); @@ -1943,16 +1943,7 @@ ++$criterion_count; $debug && _LOG("authURI added; criterion count is now $criterion_count\n"); - - my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}}); - my $row = shift(@$result); - my $id = $row->{authority_id}; - - unless ($id) { - return &_serviceListResponse( $dbh, undef ); - } - - my $ids = _extract_ids($adaptor->query_service_instance({authority_id => $id})); + my $ids = _extract_ids($adaptor->query_service_instance(authority_uri => $findme{'authURI'})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1971,7 +1962,7 @@ && _LOG( "servicename added; criterion count is now $criterion_count\n"); - my $ids = _extract_ids($adaptor->query_service_instance({servicename => $findme{servicename}})); + my $ids = _extract_ids($adaptor->query_service_instance(servicename => $findme{servicename})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1990,7 +1981,7 @@ $debug && _LOG("category added; criterion count is now $criterion_count\n"); - my $ids = _extract_ids($adaptor->query_service_instance({category => lc( $findme{category}) })); + my $ids = _extract_ids($adaptor->query_service_instance(category => lc( $findme{category}) )); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -3387,7 +3378,7 @@ my $OSserv = MOBY::OntologyServer->new( ontology => 'service' ); foreach (@ids) { - my $result = $adaptor->query_service_instance({service_instance_id => $_}); + my $result = $adaptor->query_service_instance(service_instance_id => $_); my $row = shift(@$result); my $category = $row->{category}; my $url = $row->{url}; From mwilkinson at pub.open-bio.org Fri Jul 22 13:14:07 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:14:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221714.j6MHE75E000523@pub.open-bio.org> mwilkinson Fri Jul 22 13:14:07 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv504/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: added debugging info moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:12:13 1.22 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:14:07 1.23 @@ -641,7 +641,7 @@ push @args, ({$k => $v},"and"); # format for the add_condition subroutine } pop @args; # get rid of last "and" - + print STDERR join "", @args; my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 13:25:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:25:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221725.j6MHPOZt000610@pub.open-bio.org> mwilkinson Fri Jul 22 13:25:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv591/MOBY Modified Files: service_instance.pm Log Message: deanonymysing the arguents to query_service_instance moby-live/Perl/MOBY service_instance.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 17:43:24 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 17:25:24 1.22 @@ -212,8 +212,8 @@ ? $self->service_type_uri( $self->service_type ) : $self->service_type_uri($servicetypeURI); } - my $existing_services = $self->adaptor->query_service_instance({servicename => $self->servicename},"and", - {authority_uri => $self->authority_uri}); + my $existing_services = $self->adaptor->query_service_instance(servicename => $self->servicename, + authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); From mwilkinson at pub.open-bio.org Fri Jul 22 13:25:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:25:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221725.j6MHPO4t000631@pub.open-bio.org> mwilkinson Fri Jul 22 13:25:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv591/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: deanonymysing the arguents to query_service_instance moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:14:07 1.23 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:25:24 1.24 @@ -641,7 +641,6 @@ push @args, ({$k => $v},"and"); # format for the add_condition subroutine } pop @args; # get rid of last "and" - print STDERR join "", @args; my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 15:16:41 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:16:41 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221916.j6MJGf1M000874@pub.open-bio.org> mwilkinson Fri Jul 22 15:16:40 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv847/MOBY Modified Files: Central.pm secondary_input.pm service_instance.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY Central.pm,1.166,1.167 secondary_input.pm,1.5,1.6 service_instance.pm,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.166 retrieving revision 1.167 diff -u -r1.166 -r1.167 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 17:12:13 1.166 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:16:40 1.167 @@ -1236,7 +1236,15 @@ "Service categories other than 'moby' and 'wsdl' are not yet implemented", "" ) - unless ( ( $Category eq "moby" ) || ( $Category eq "wsdl" ) ); + unless ( ( $Category eq "moby" ) || ( $Category eq "wsdl" ) ); + +#test the existence of the service + return &_error( "This service already exists", "" ) if (MOBY::service_instance->new( + servicename => $serviceName, + authority_uri => $AuthURI, + test => 1)); + + my @IN = @{$INPUTS}; my @OUT = @{$OUTPUTS}; my @SECS = @{$SECONDARY}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/20 22:04:10 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/22 19:16:40 1.6 @@ -115,13 +115,13 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, - {maximum_value => $self->maximum_value}, - {minimum_value => $self->minimum_value}, - {enum_value => $self->enum_value}, - {datatype => $self->datatype}, - {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}); - + {maximum_value => $self->maximum_value}, + {minimum_value => $self->minimum_value}, + {enum_value => $self->enum_value}, + {datatype => $self->datatype}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}); + return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 17:25:24 1.22 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:16:40 1.23 @@ -216,12 +216,14 @@ authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did - $self->service_instance_id( $existing_service->{'serviceid'} ); + $self->servicename( $existing_service->{'servicename'} ); + $self->authoritative( $existing_service->{'authoritative'} ); + $self->service_instance_id( $existing_service->{'service_instance_id'} ); $self->category( $existing_service->{'category'} ); - $self->service_type( $existing_service->{'servicetype'} ); + $self->service_type( $existing_service->{'service_type_uri'} ); $self->url( $existing_service->{'url'} ); - $self->contact_email( $existing_service->{'email'} ); - $self->description( $existing_service->{'desc'} ); + $self->contact_email( $existing_service->{'contact_email'} ); + $self->description( $existing_service->{'description'} ); $self->authority( $existing_service->{'authURI'} ); $self->signatureURL( $existing_service->{'signatureURL'} ); $self->lsid( $existing_service->{'lsid'} ); From mwilkinson at pub.open-bio.org Fri Jul 22 15:23:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:23:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221923.j6MJNIRm000945@pub.open-bio.org> mwilkinson Fri Jul 22 15:23:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv926/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:25:24 1.24 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:23:18 1.25 @@ -638,9 +638,9 @@ delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ - push @args, ({$k => $v},"and"); # format for the add_condition subroutine + push @args, ("and",{$k => $v}); # format for the add_condition subroutine } - pop @args; # get rid of last "and" + push @args, ("and", {authority_id => $authority_id}) if ($authority_id); my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 15:29:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:29:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221929.j6MJTcEe001023@pub.open-bio.org> mwilkinson Fri Jul 22 15:29:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv1004/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.25,1.26 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:23:18 1.25 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:29:38 1.26 @@ -599,7 +599,7 @@ unless ($id){ my $result = $self->query_authority({authority_uri => $authURI}); return 0 unless @$result[0]; - my $id = @$result[0]->{authority_id}; + $id = @$result[0]->{authority_id}; return 0 unless $id; } my $statement = "select From mwilkinson at pub.open-bio.org Fri Jul 22 15:38:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:38:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221938.j6MJc2Ub001100@pub.open-bio.org> mwilkinson Fri Jul 22 15:38:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1077/MOBY Modified Files: Central.pm service_instance.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY Central.pm,1.167,1.168 service_instance.pm,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.167 retrieving revision 1.168 diff -u -r1.167 -r1.168 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:16:40 1.167 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:38:02 1.168 @@ -1292,11 +1292,8 @@ description => $desc, signatureURL => $signatureURL, ); - return &_error( "Service registration failed for unknown reasons", "" ) - if ( !defined $SVC ); - return &_error( "Service with this authority/servicename already exists", - "" ) - if ( $SVC == -1 ); + return &_error( "Service registration failed for unknown reasons", "" ) if ( !defined $SVC ); + $debug && &_LOG("new service instance created\n"); foreach my $IN (@IN) { @@ -1716,27 +1713,26 @@ my ( $authURI, $serviceName ) = &_deregisterServicePayload($payload); return &_error( "must provide an authority and a service name\n", "" ) unless ( $authURI && $serviceName ); - return &_error( -"The service specified by authority=$authURI servicename=$serviceName does not exist in the registry", - "" - ) + return &_error("The service specified by authority=$authURI servicename=$serviceName does not exist in the registry","") unless ( MOBY::service_instance->new( servicename => $serviceName, authority_uri => $authURI, test => 1 - ) - ); + )); my $SERVICE = MOBY::service_instance->new( servicename => $serviceName, authority_uri => $authURI ); + return &_error("service lookup failed for unknown reasons","") unless ($SERVICE); + if ( $SERVICE->signatureURL ) { return &_error( "it is illegal to deregister a service that has a signatureURL. Such services must be deregistered by deleting the RDF at the location identified by the signatureURL", "" ); } + my $result = $SERVICE->DELETE_THYSELF; if ($result) { return &_success( "Service Deregistered Successfully", "" ); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:16:40 1.23 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:38:02 1.24 @@ -190,7 +190,6 @@ return undef unless $self->servicename; if ( $self->test ) { return $self->service_instance_exists } - if ($self->service_instance_exists){return -1} $self->authority( $self->_get_authority() ); From mwilkinson at pub.open-bio.org Fri Jul 22 15:46:52 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:46:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221946.j6MJkq4I001183@pub.open-bio.org> mwilkinson Fri Jul 22 15:46:52 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv1164/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:29:38 1.26 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:46:52 1.27 @@ -638,9 +638,14 @@ delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ - push @args, ("and",{$k => $v}); # format for the add_condition subroutine + push @args, ({$k => $v}, "and"); # format for the add_condition subroutine } - push @args, ("and", {authority_id => $authority_id}) if ($authority_id); + if ($authority_id){ + push @args, ({authority_id => $authority_id}) ; + } else { + pop @args; # remove final "and" + } + my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 16:00:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:00:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222000.j6MK0Aef001271@pub.open-bio.org> mwilkinson Fri Jul 22 16:00:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv1252/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.27,1.28 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:46:52 1.27 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 20:00:10 1.28 @@ -632,7 +632,7 @@ if ($args{'authority_uri'}){ # need to transform URI to a row ID my $result = $self->query_authority({authority_uri => $args{'authority_uri'}}); return 0 unless @$result[0]; - my $authority_id = @$result[0]->{authority_id}; + $authority_id = @$result[0]->{authority_id}; return 0 unless $authority_id; } delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table From mwilkinson at pub.open-bio.org Fri Jul 22 16:05:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:05:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222005.j6MK5S01001341@pub.open-bio.org> mwilkinson Fri Jul 22 16:05:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1322/MOBY Modified Files: Central.pm Log Message: service discovery was failing because the searches were returning objects instead of id numbers moby-live/Perl/MOBY Central.pm,1.168,1.169 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.168 retrieving revision 1.169 diff -u -r1.168 -r1.169 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:38:02 1.168 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:05:28 1.169 @@ -1907,8 +1907,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instnace_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{serviceType} ) { # must have something more than empty content @@ -1939,8 +1938,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{authURI} ) { @@ -1956,8 +1954,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{servicename} ) { @@ -1975,8 +1972,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } $findme{category} = 'moby' unless $findme{category}; @@ -1994,8 +1990,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{keywords} && ( scalar @{ $findme{keywords} } ) ) { @@ -2008,17 +2003,14 @@ unless ( scalar @{$ids} ) { $debug - && &_LOG( -"found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n" - ); + && &_LOG("found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n"); return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{inputObjects} && ( scalar @{ $findme{inputObjects} } ) ) { @@ -2033,8 +2025,7 @@ $findme{'expandObjects'}, '' ) if defined $obj; $debug - && _LOG( - "Initial Search For Services with INPUT Article found @si_ids\n"); + && _LOG("Initial Search For Services with INPUT Article found @si_ids\n"); my %instances; # we need to do a join, without doing a join... @@ -2051,9 +2042,7 @@ &_searchForServicesWithArticle( $dbh, "input", $obj, $findme{'expandObjects'}, '' ); # get their service ids $debug - && _LOG( -"Subsequent Search For Services with INPUT Article found @new_ids\n" - ); + && _LOG("Subsequent Search For Services with INPUT Article found @new_ids\n"); my @good_ids; my %good_ids; foreach my $id (@new_ids) From mwilkinson at pub.open-bio.org Fri Jul 22 16:15:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:15:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222015.j6MKFmuB001439@pub.open-bio.org> mwilkinson Fri Jul 22 16:15:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1420/MOBY Modified Files: Central.pm Log Message: service discovery was failing because of incorrect column names in SQL moby-live/Perl/MOBY Central.pm,1.169,1.170 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.169 retrieving revision 1.170 diff -u -r1.169 -r1.170 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:05:28 1.169 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:15:48 1.170 @@ -3427,7 +3427,7 @@ } $output .= "\t\t\n"; } - $result = $adaptor->query_collection_input({service_instance => $_}); + $result = $adaptor->query_collection_input({service_instance_id => $_}); # $sth_collection_ins->execute($_); foreach my $row (@$result) From mwilkinson at pub.open-bio.org Fri Jul 22 16:25:39 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:25:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222025.j6MKPdeV001588@pub.open-bio.org> mwilkinson Fri Jul 22 16:25:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1569/MOBY Modified Files: Central.pm Log Message: various queries being sent to the wrong adaptors moby-live/Perl/MOBY Central.pm,1.171,1.172 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.171 retrieving revision 1.172 diff -u -r1.171 -r1.172 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:18:28 1.171 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:25:39 1.172 @@ -473,7 +473,7 @@ sub deregisterObjectClass { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'object' ); @@ -486,7 +486,6 @@ $OntologyServer->objectExists( term => $class ); return &_error( "Object class $class does not exist", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new()->dbh; my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); return &_error( @@ -745,7 +744,7 @@ sub deregisterServiceType { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'service' ); @@ -755,12 +754,9 @@ return &_error( "Must include an accession number to deregister a serviceType", "" ) unless ($term); - my ( $success, $message, $existingURI ) = - $OntologyServer->serviceExists( term => $term ) - ; # hopefully this situation will never happen! + my ( $success, $message, $existingURI ) = $OntologyServer->serviceExists( term => $term ); # hopefully this situation will never happen! return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new()->dbh; my $result = $adaptor->query_service({service_type_uri => $existingURI}); my $row = shift(@$result); @@ -906,7 +902,7 @@ sub deregisterNamespace { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'namespace' ); @@ -919,7 +915,6 @@ $OntologyServer->namespaceExists( term => $term ); return &_error( "Namespace Type $term does not exist", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new->dbh; my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term}); return &_error( $errstr, "") if ($err); From mwilkinson at pub.open-bio.org Fri Jul 22 16:29:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:29:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222029.j6MKTBx7001654@pub.open-bio.org> mwilkinson Fri Jul 22 16:29:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1635/MOBY Modified Files: Central.pm Log Message: various queries being sent to the wrong adaptors moby-live/Perl/MOBY Central.pm,1.172,1.173 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.172 retrieving revision 1.173 diff -u -r1.172 -r1.173 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:25:39 1.172 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:29:11 1.173 @@ -473,7 +473,7 @@ sub deregisterObjectClass { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'object' ); @@ -486,6 +486,7 @@ $OntologyServer->objectExists( term => $class ); return &_error( "Object class $class does not exist", "" ) unless ($existingURI); + my $dbh = MOBY::central_db_connection->new()->dbh; my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); return &_error( @@ -902,7 +903,7 @@ sub deregisterNamespace { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'namespace' ); From gordonp at pub.open-bio.org Fri Jul 22 16:59:05 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 16:59:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222059.j6MKx5BS001853@pub.open-bio.org> gordonp Fri Jul 22 16:59:05 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/Clients In directory pub.open-bio.org:/tmp/cvs-serv1828/src/Clients Modified Files: TestRequest.java Log Message: Upated to work with new data instance version moby-live/Java/src/Clients TestRequest.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/TestRequest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/Clients/TestRequest.java 2005/05/12 05:22:27 1.1 +++ /home/repository/moby/moby-live/Java/src/Clients/TestRequest.java 2005/07/22 20:59:05 1.2 @@ -10,9 +10,7 @@ import org.biomoby.client.MobyRequest; import org.biomoby.shared.Central; import org.biomoby.shared.MobyService; -import org.biomoby.shared.data.MobyDataInstance; -import org.biomoby.shared.data.MobyDataObject; -import org.biomoby.shared.data.MobyDataObjectSet; +import org.biomoby.shared.data.*; import java.util.Iterator; import java.util.Vector; @@ -57,27 +55,18 @@ mr.setDebugMode(true); mr.setService(validServices[0]); mr.setInput(input); // use convenient anonymous single arg service parameterization - java.util.Vector output = mr.invokeService(); - - String c = ""; - Iterator responses = output.iterator(); + MobyContentInstance responses = mr.invokeService(); // Process responses // The service invocation may have had many requests, there is a response // object for each request - while(responses.hasNext()){ - - Object o = responses.next(); - System.err.println("responses vector slot is a " + o.getClass().getName()); - if(o instanceof Object[]){ - System.err.println("responses vector slot is an array"); - } - MobyDataInstance[] responseObjects = (MobyDataInstance[]) o; + Iterator i = responses.keySet().iterator(); + while(i.hasNext()){ + Vector responseObjects = (Vector) responses.get(i.next()); // The response for a request may have many objects - for(int k = 0; k < responseObjects.length; k++){ - //MobyDataInstance responseObject = responseObjects[k]; - Object responseObject = responseObjects[k]; + for(int k = 0; k < responseObjects.size(); k++){ + Object responseObject = responseObjects.elementAt(k); // The response objects may either be simple data, or data sets if(responseObject instanceof MobyDataObject){ System.out.println("Plain simple instance is "+((MobyDataInstance)responseObject).toXML()); From mwilkinson at pub.open-bio.org Fri Jul 22 16:18:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:18:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222018.j6MKISjV001505@pub.open-bio.org> mwilkinson Fri Jul 22 16:18:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1486/MOBY Modified Files: Central.pm Log Message: various queries not being sent to the adaptor moby-live/Perl/MOBY Central.pm,1.170,1.171 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.170 retrieving revision 1.171 diff -u -r1.170 -r1.171 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:15:48 1.170 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:18:28 1.171 @@ -3462,7 +3462,7 @@ $output .= "\t\n"; $output .= "\t\n"; - $result = query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); + $result = $adaptor->query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); foreach my $row (@$result) { @@ -3483,7 +3483,7 @@ $output .= "\t\t\n"; } - $result = query_collection_output({service_instance_id => $_}); + $result = $adaptor->query_collection_output({service_instance_id => $_}); foreach my $row (@$result) { my $collid = $row->{collection_output_id}; From mwilkinson at pub.open-bio.org Fri Jul 22 16:47:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:47:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222047.j6MKlBoZ001767@pub.open-bio.org> mwilkinson Fri Jul 22 16:47:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1748/MOBY Modified Files: Central.pm Log Message: wrong column name for query moby-live/Perl/MOBY Central.pm,1.173,1.174 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.173 retrieving revision 1.174 diff -u -r1.173 -r1.174 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:29:11 1.173 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:47:10 1.174 @@ -759,7 +759,7 @@ return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); - my $result = $adaptor->query_service({service_type_uri => $existingURI}); + my $result = $adaptor->query_service({service_lsid => $existingURI}); my $row = shift(@$result); my $id = $row->{service_instance_id}; From mwilkinson at pub.open-bio.org Fri Jul 22 17:56:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 17:56:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222156.j6MLuZ3k001982@pub.open-bio.org> mwilkinson Fri Jul 22 17:56:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1963/MOBY Modified Files: Central.pm Log Message: all original tests now pass. findService was returning service descriptions with extra whitespace. Fixed that moby-live/Perl/MOBY Central.pm,1.174,1.175 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.174 retrieving revision 1.175 diff -u -r1.174 -r1.175 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:47:10 1.174 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 21:56:35 1.175 @@ -3397,7 +3397,7 @@ $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; $output .= "\t$category\n"; - $output .= "\t\n$desc\n\t\n"; + $output .= "\t\n"; $output .= "\t$email\n"; $output .= "\t$signatureURL\n"; $output .= "\t$url\n"; From mwilkinson at pub.open-bio.org Fri Jul 22 18:57:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 18:57:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222257.j6MMvSXp002203@pub.open-bio.org> mwilkinson Fri Jul 22 18:57:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv2184/MOBY/Client Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined moby-live/Perl/MOBY/Client Central.pm,1.99,1.100 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.99 retrieving revision 1.100 diff -u -r1.99 -r1.100 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 22:54:10 1.99 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 22:57:28 1.100 @@ -929,19 +929,17 @@ $message .= "\n"; while ( my ( $param, $desc ) = each %SEC ) { unless ( ( ref($desc) ) =~ /hash/i ) { - return $self->errorRegXML( -"invalid structure of secondary article $param; expected hashref of limitations" + return $self->errorRegXML( "invalid structure of secondary article $param; expected hashref of limitations" ); } my %data = %{$desc}; - my $default = $data{default} || ""; - my $max = $data{max} || ""; - my $min = $data{min} || ""; - my $datatype = $data{datatype} || ""; - my $enums = $data{enum} || []; + my $default = defined($data{default}) || ""; + my $max = defined($data{max}) || ""; + my $min = defined($data{min}) || ""; + my $datatype = defined($data{datatype}) || ""; + my $enums = defined($data{enum}) || []; unless ($datatype) { - return $self->errorRegXML( -"a secondaryArticle must contain at least a datatype value in secondary article $param" + return $self->errorRegXML("a secondaryArticle must contain at least a datatype value in secondary article $param" ); } unless ( ( $datatype =~ /Integer/ ) @@ -949,13 +947,11 @@ || ( $datatype =~ /String/ ) || ( $datatype =~ /DateTime/ ) ) { - return $self->errorRegXML( -"a secondaryArticle must have a datatype of Integer, Float, String, or DateTime" + return $self->errorRegXML("a secondaryArticle must have a datatype of Integer, Float, String, or DateTime" ); } unless ( ( ref($enums) ) =~ /array/i ) { - return $self->errorRegXML( -"invalid structure of enum limits in secondary article $param; expected arrayref" + return $self->errorRegXML("invalid structure of enum limits in secondary article $param; expected arrayref" ); } my @enums = @{$enums}; From mwilkinson at pub.open-bio.org Fri Jul 22 19:05:04 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:05:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222305.j6MN54tJ002278@pub.open-bio.org> mwilkinson Fri Jul 22 19:05:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv2259/MOBY/Client Modified Files: Central.pm Log Message: oops... got a little exuberant there moby-live/Perl/MOBY/Client Central.pm,1.100,1.101 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.100 retrieving revision 1.101 diff -u -r1.100 -r1.101 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 22:57:28 1.100 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 23:05:04 1.101 @@ -933,11 +933,11 @@ ); } my %data = %{$desc}; - my $default = defined($data{default}) || ""; - my $max = defined($data{max}) || ""; - my $min = defined($data{min}) || ""; - my $datatype = defined($data{datatype}) || ""; - my $enums = defined($data{enum}) || []; + my $default = defined($data{default})?$data{default}:""; + my $max = defined($data{max})?$data{max}:""; + my $min = defined($data{min})?$data{min}:""; + my $datatype = $data{datatype} || ""; + my $enums = $data{enum} || []; unless ($datatype) { return $self->errorRegXML("a secondaryArticle must contain at least a datatype value in secondary article $param" ); From mwilkinson at pub.open-bio.org Fri Jul 22 19:11:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:11:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222311.j6MNBoMl002361@pub.open-bio.org> mwilkinson Fri Jul 22 19:11:50 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv2342/MOBY Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined. Smae problem on the server side moby-live/Perl/MOBY Central.pm,1.175,1.176 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.175 retrieving revision 1.176 diff -u -r1.175 -r1.176 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 21:56:35 1.175 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:11:49 1.176 @@ -3519,11 +3519,11 @@ my $datatype = $row->{datatype}; my $article_name = $row->{article_name}; - $article_name ||= ""; - $datatype ||= ""; - $default_value ||= ""; - $maximum_value ||= ""; - $minimum_value ||= ""; + defined($article_name) ||= ""; + defined($datatype) ||= ""; + defined($default_value) ||= ""; + defined($maximum_value) ||= ""; + defined($minimum_value) ||= ""; $output .= "\t\t\t\n"; $output .= "\t\t\t\t$datatype\n"; $output .= "\t\t\t\t$default_value\n"; From mwilkinson at pub.open-bio.org Fri Jul 22 19:15:55 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:15:55 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222315.j6MNFtbV002429@pub.open-bio.org> mwilkinson Fri Jul 22 19:15:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv2410/MOBY Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined. Smae problem on the server side moby-live/Perl/MOBY Central.pm,1.176,1.177 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.176 retrieving revision 1.177 diff -u -r1.176 -r1.177 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:11:49 1.176 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:15:54 1.177 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::Client::Central; +#use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -3511,19 +3511,14 @@ $output .= "\t\n"; $result = $adaptor->query_secondary_input({service_instance_id => $_}); foreach my $row (@$result) - { - my $default_value = $row->{default_value}; - my $maximum_value = $row->{maximum_value}; - my $minimum_value = $row->{minimum_value}; - my $enum_value = $row->{enum_value}; - my $datatype = $row->{datatype}; - my $article_name = $row->{article_name}; - - defined($article_name) ||= ""; - defined($datatype) ||= ""; - defined($default_value) ||= ""; - defined($maximum_value) ||= ""; - defined($minimum_value) ||= ""; + { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ""; + $default_value = $row->{default_value}; + $maximum_value = $row->{maximum_value}; + $minimum_value = $row->{minimum_value}; + $enum_value = $row->{enum_value}; + $datatype = $row->{datatype}; + $article_name = $row->{article_name}; + $output .= "\t\t\t\n"; $output .= "\t\t\t\t$datatype\n"; $output .= "\t\t\t\t$default_value\n"; From mwilkinson at pub.open-bio.org Fri Jul 22 19:20:27 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:20:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222320.j6MNKREs002500@pub.open-bio.org> mwilkinson Fri Jul 22 19:20:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv2481/MOBY Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined. Smae problem on the server side moby-live/Perl/MOBY Central.pm,1.177,1.178 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.177 retrieving revision 1.178 diff -u -r1.177 -r1.178 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:15:54 1.177 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:20:26 1.178 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -#use MOBY::Client::Central; +use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -3511,7 +3511,7 @@ $output .= "\t\n"; $result = $adaptor->query_secondary_input({service_instance_id => $_}); foreach my $row (@$result) - { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ""; + { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ("","","","","",""); $default_value = $row->{default_value}; $maximum_value = $row->{maximum_value}; $minimum_value = $row->{minimum_value}; From mwilkinson at pub.open-bio.org Fri Jul 22 19:23:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:23:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222323.j6MNNQOu002568@pub.open-bio.org> mwilkinson Fri Jul 22 19:23:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv2549/t Modified Files: Client-Central.t Log Message: added about 50 new tests. now we're really getting tight. moby-live/Perl/t Client-Central.t,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/08 19:22:21 1.8 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:23:26 1.9 @@ -4,17 +4,19 @@ ######################### # change 'tests => 1' to 'tests => last_test_to_print'; - -use Test::More tests => 14; # perldoc Test::More for details +#use SOAP::Lite +trace; +use Test::More tests => 54; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; + + # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', - URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} + mobycentral => { URL => 'http://localhost/cgi-bin/MOBY-Central.pl', + URI => 'http://localhost/MOBY/Central'} } ); @@ -23,6 +25,8 @@ my %TestRegistry ; # to keep track of registry id's for the various tests + + ################## MOBY Registration Tests ################# # Test 3 @@ -40,6 +44,9 @@ ( ok(!$r->success,"Object registration correctly failed") or diag("Object registration failure: ".$r->message)); + + + # Test 4 $r = $C->registerObjectClass(objectType => "TotalCrap", description => "a human-readable description of the object", @@ -55,11 +62,17 @@ or diag("Object registration failure: ".$r->message)); + + + # Test 5 $r = $C->deregisterObjectClass(objectType => "TotalCrap"); ( ok($r->success,"Object deregistration successful")) or diag("Object deregistration failure: ".$r->message) ; + + + # Test 6 (identical to #4 $r = $C->registerObjectClass(objectType => "TotalCrap", description => "a human-readable description of the object", @@ -75,7 +88,10 @@ or diag("Object registration failure: ".$r->message)); -# Test 6 + + + +# Test 7 $r = $C->registerNamespace( namespaceType =>'UglyNamespace', authURI => 'your.authority.URI', @@ -85,7 +101,9 @@ ) or diag("Name space registration failure: ".$r->message) ; -# Test 7 + + +# Test 8 $r = $C->registerServiceType(serviceType => "CrappyService", description => "a human-readable description of the service", contactEmail => 'your at email.address', @@ -96,7 +114,10 @@ ( ok($r->success,"Service Type registration successful") ) or diag("Service Type registration failure: ".$r->message) ; -# Test 8 # should fail + + + +# Test 9 # should fail $r = $C->registerService( serviceName => "myfirstservice", serviceType => "Retrieval", @@ -119,10 +140,12 @@ min => -10, enum => [-10, 10, 0]}}); -( ok(!$r->success,"Service registration correctly failed") +( ok(!$r->success,"Service registration correctly failed testing secondary datatype format") ) or diag("Service registration failure: ".$r->message) ; -# Test 9 + + +# Test 10 $r = $C->registerService( serviceName => "myfirstservice", serviceType => "Retrieval", @@ -148,8 +171,75 @@ ( ok($r->success,"Service registration successful") ) or diag("Service registration failure: ".$r->message) ; +# test 11 - find by auth & name +($si, $r) = $C->findService( + serviceName => "myfirstservice", + authURI => "test.suite.com"); +( is($r, undef, "Service discovery successful") +) or diag("Service discovery failure") ; + +isa_ok($si, 'ARRAY') or diag("findService didn't return an array ref"); +is(scalar(@$si),1) or diag("findService found too many services"); +$SI = shift @$si; +print STDERR "$SI"; +isa_ok($SI, 'MOBY::Client::ServiceInstance') or diag("findService didn't return a MOBY::Client::ServceInstance"); +isa_ok($SI->input, ARRAY) or diag ("ServiceInstance object input is not a listref"); +isa_ok($SI->output, ARRAY) or diag ("ServiceInstance object output is not a listref"); +is($SI->name, "myfirstservice") or diag("servicename wrong"); +is($SI->authoritative, 0) or diag("service reported to be incorrectly authoritative"); +is($SI->authority, "test.suite.com") or diag("authURI incorrect"); +is($SI->type, "Retrieval") or diag("service type incorrect"); +is($SI->description, "this is my first service") or diag("service description wrong"); +is($SI->URL, "http://illuminae/cgi-bin/service.pl") or diag("service URL incorrect"); +is($SI->contactEmail, 'your at mail.address') or diag("contact email incorrect"); +is($SI->category, "moby") or diag("service category incorrect"); + + at ins = @{$SI->input}; + at outs = @{$SI->output}; + at secs = @{$SI->secondary}; +is(scalar(@ins), 1) or diag("incorrect number of inputs in servce instance"); +is(scalar(@outs), 1) or diag("incorrect number of outputs in servce instance"); +is(scalar(@secs), 1) or diag("incorrect number of secodary in servce instance"); + +$in = shift @ins; +$out = shift @outs; +$sec = shift @secs; + +isa_ok($in, 'MOBY::Client::SimpleArticle') or diag("->inputs did not return a MOBY::simple_input object"); +isa_ok($out, 'MOBY::Client::SimpleArticle') or diag("->outputs did not return a MOBY::simple_outputobject"); +isa_ok($sec, 'MOBY::Client::SecondaryArticle') or diag("->secondarues did not return a MOBY::secondary_input object"); + +is($in->objectType, "Object") or diag("simple input type reported incorrectly"); +is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly"); +isa_ok($in->namespaces, 'ARRAY') or diag("simple input namespaces not returned as an arrayref"); + at ns = @{$in->namespaces}; +is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace"); + +is($out->objectType, "String") or diag("simple output type reported incorrectly"); +is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly"); +isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref"); + at ns = @{$out->namespaces}; +is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace"); + +is($sec->articleName, 'parametername1') or diag("secondary article reporting wrong article name"); +is($sec->datatype, 'Integer') or diag("secondary article reporting wrong datatype"); +is($sec->default,"0") or diag("secondary article reporting wrong default"); +is($sec->max,"10") or diag("secondary article reporting wrong max"); +is($sec->min,"-10") or diag("secondary article reporting wrong min"); +isa_ok($sec->enum, 'ARRAY') or diag("enum is not returning an array ref"); + at enum = @{$sec->enum}; +is(scalar(@enum), 3) or diag("enum not returning correct number of elements"); +$enum = join "|", at enum; +$enum = "|".$enum."|"; +is($enum =~/\|-10\|/, 1) or diag("enum element missing"); +is($enum =~/\|10\|/, 1) or diag("enum element missing"); +is($enum =~/\|0\|/, 1) or diag("enum element missing"); -# Test 10 +# Test 12 $r = $C->deregisterService( serviceName => "myfirstservice", @@ -159,136 +249,29 @@ ) or diag("Service deregistration failure: ".$r->message) ; -# Test 11 + + + +# Test 12 $r = $C->deregisterObjectClass(objectType => "TotalCrap"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; -# Test 12 + + +# Test 13 $r = $C->deregisterServiceType(serviceType => "CrappyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; -# Test 13 + + + +# Test 44 $r = $C->deregisterNamespace(namespaceType =>'UglyNamespace'); ( ok($r->success,"namespace deregistration successful") ) or diag("namespace deregistration failure: ".$r->message) ; -################### MOBY Central Search Tests ################# -# -#my @service ; -# -## Tests 14,15: locateServiceByOutput with output 'Object' and full_objects + full_services -#@service = $C->locateServiceByOutput( -# objectType => "Object", -# fullObjects => 1, -# fullServices => 1, -#) ; -# -#SKIP: { -# skip "locateServiceByOutput w/full object & services". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 16,17: Testing locateServiceByOutput with output "Object" and full_services only -#@service = $C->locateServiceByOutput( -# objectType => "Object", -# fullObjects => 0, -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByOutput w/ output 'Object' and full services only ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 18,19: Testing locateServiceByInput with input -## 'Object' => Genbank/GI and full_objects + full_services -#@service = $C->locateServiceByInput( -# input => {"Sequence" => ["Genbank/GI"]}, -# fullObjects => 1, -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByInput w/input 'Object' => Genbank/GI ". -# "and full_objects + full_services ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 20,21: Testing locateServiceByInput with input -## 'Object' => Genbank/GI and full_services only -#@service = $C->locateServiceByInput( -# input => {"Object" => ["Genbank/GI"]}, -# fullObjects => 0, -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByInput w/input 'Object' => Genbank/GI ". -# "and full_services ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 22,23: Testing locateServiceByType with type 'Retrieve' + full_services -#@service = $C->locateServiceByType( -# serviceType => "Retrieve", -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByType w/type 'Retrieve' and full_services ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -################### MOBY Deregistration Tests ################# -# -## Test 17 -#SKIP: { -# skip "Skipping test DeregisterService since service registration failed", -# 1 unless(exists($TestRegistry{'Service'})) ; -# -# $r = $C->deregisterService( serviceID => $TestRegistry{'Service'} ); -# ok(!$r->success,"Service ID#".$r->registration_id." deregistration successful") -# or diag("Service ID#",$TestRegistry{'Service'}, -# "deregistration failure: ".$r->message) ; -#} -# -## Test 18 -#SKIP: { -# skip "Skipping test DeregisterNamespace since name space registration failed", -# 1 unless(exists($TestRegistry{'NameSpace'})) ; -# -# $r = $C->deregisterNamespace( namespaceAcc => $TestRegistry{'NameSpace'} ); -# ok(!$r->success,"Name space ID#".$r->registration_id." deregistration successful") -# or diag("Name space ID#",$TestRegistry{'NameSpace'}, -# "deregistration failure: ".$r->message) ; -#} -# -## Test 19 -#SKIP: { -# skip "Skipping test DeregisterServiceType since service registration failed", -# 1 unless(exists($TestRegistry{'ServiceType'})) ; -# -# $r = $C->deregisterServiceType( serviceID => $TestRegistry{'ServiceType'} ); -# ok(!$r->success,"Service type ID#".$r->registration_id." deregistration successful") -# or diag("Service type ID#",$TestRegistry{'ServiceType'}, -# "deregistration failure: ".$r->message) ; -#} -# -## Test 20 -#SKIP: { -# skip "Skipping test DeregisterObject since initial object registration failed", -# 1 unless(exists($TestRegistry{'Object'})) ; -# -# $r = $C->deregisterObject( serviceID => $TestRegistry{'Object'} ); -# ok(!$r->success,"Object ID#".$r->registration_id." deregistration successful") -# or diag("Object ID#",$TestRegistry{'Object'}, -# "deregistration failure: ".$r->message) ; -#} + + + From mwilkinson at pub.open-bio.org Fri Jul 22 19:25:06 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:25:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222325.j6MNP6CZ002625@pub.open-bio.org> mwilkinson Fri Jul 22 19:25:06 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv2606/t Modified Files: Client-Central.t Log Message: oops... committed the new tests without changnig the URl back to teh public address. moby-live/Perl/t Client-Central.t,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:23:26 1.9 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:25:06 1.10 @@ -15,8 +15,8 @@ # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://localhost/cgi-bin/MOBY-Central.pl', - URI => 'http://localhost/MOBY/Central'} + mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/MOBY-Central.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} } ); From mwilkinson at pub.open-bio.org Mon Jul 25 13:23:36 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 13:23:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251723.j6PHNaRo020358@pub.open-bio.org> mwilkinson Mon Jul 25 13:23:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20339/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: starting to document the adaptor layer moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/18 16:53:49 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:23:35 1.5 @@ -1,8 +1,85 @@ +#$Id$ package MOBY::Adaptor::moby::queryapi; use strict; use Carp; use vars qw($AUTOLOAD); + +=head1 NAME + +MOBY::Adaptor::moby::queryapi - An interface definition for MOBY Central underlying data-stores + +=cut + +=head1 SYNOPSIS + + use MOBY::Adaptor::moby::queryapi::mysql # implements this interface def + my $m = MOBY::Adaptor::moby::queryapi::mysql->new( + username => 'user', + password => 'pass', + dbname => 'mobycentral', + port => '3306', + sourcetype => 'DBD::mysql'); + my $objectid = $m->insert_object( + {object_type => "MyObject"}, + {description => "this represents a foo bar"}, + {authority => "www.example.org"}, + {contact_email, 'me at example.org'}) + + +=cut + +=head1 DESCRIPTION + +This is an interface definition. There is NO implementation in this module +with the exception that certain calls to required parameters have get/setter +functions in this module (that can be overridden) + +=head1 AUTHORS + +Mark Wilkinson markw_at_ illuminae dot com +Dennis Wang oikisai _at_ hotmail dot com +BioMOBY Project: http://www.biomoby.org + + +=cut + +=head1 METHODS + + +=head2 new + + Title : new + Usage : my $MOBY = MOBY::Client::Central->new(Registries => \%regrefs) + Function : connect to one or more MOBY-Central + registries for searching + Returns : MOBY::Client::Central object + Args : Registries - optional. + Notes : Each registry must have a different + + +=cut + + +sub new { + my ($caller, %args) = @_; + my $caller_is_obj = ref($caller); + my $class = $caller_is_obj || $caller; + + my $self = bless {}, $class; + + foreach my $attrname ( $self->_standard_keys_a ) { + if (exists $args{$attrname} && defined $args{$attrname}) { + $self->{$attrname} = $args{$attrname} } + elsif ($caller_is_obj) { + $self->{$attrname} = $caller->{$attrname} } + else { + $self->{$attrname} = $self->_default_for($attrname) } + } + return $self; +} + + # Modified by Dennis { @@ -14,10 +91,11 @@ ( username => [undef, 'read/write'], password => [undef, 'read/write'], - dbname => [undef, 'read/write'], - port => [undef, 'read/write'], - proxy => [undef, 'read/write'], - url => [undef, 'read/write'], + dbname => [undef, 'read/write'], + port => [undef, 'read/write'], + proxy => [undef, 'read/write'], + url => [undef, 'read/write'], + driver => [undef, 'read/write'], ); #_____________________________________________________________ @@ -41,46 +119,155 @@ keys %_attr_data; } +=head2 username + + Title : username + Usage : my $un = $API->username($arg) + Function : get/set username (if required) + Returns : String (username) + Args : String (username) - optional. + +=cut + + sub username { my ($self, $arg) = @_; $self->{username} = $arg if defined $arg; return $self->{username}; } + +=head2 password + + Title : password + Usage : my $un = $API->password($arg) + Function : get/set password (if required) + Returns : String (password) + Args : String (password) - optional. + +=cut + sub password { my ($self, $arg) = @_; $self->{password} = $arg if defined $arg; return $self->{password}; } + +=head2 dbname + + Title : dbname + Usage : my $un = $API->dbname($arg) + Function : get/set dbname (if required) + Returns : String (dbname) + Args : String (dbname) - optional. + +=cut + sub dbname { my ($self, $arg) = @_; $self->{dbname} = $arg if defined $arg; return $self->{dbname}; } + +=head2 port + + Title : port + Usage : my $un = $API->port($arg) + Function : get/set port (if required) + Returns : String (port) + Args : String (port) - optional. + +=cut + + sub port { my ($self, $arg) = @_; $self->{port} = $arg if defined $arg; return $self->{port}; } + +=head2 proxy + + Title : proxy + Usage : my $un = $API->proxy($arg) + Function : get/set proxy (if required) + Returns : String (proxy) + Args : String (proxy) - optional. + +=cut + sub proxy { my ($self, $arg) = @_; $self->{proxy} = $arg if defined $arg; return $self->{proxy}; } + + +=head2 sourcetype + + Title : sourcetype + Usage : my $un = $API->sourcetype($arg) + Function : get/set string name of sourcetype (e.g. mySQL) + Returns : String (sourcetype) + Args : String (sourcetype) - optional. + +=cut + sub sourcetype { my ($self, $arg) = @_; $self->{sourcetype} = $arg if defined $arg; return $self->{sourcetype}; } + + +=head2 driver + + Title : driver + Usage : my $un = $API->driver($arg) + Function : get/set string name of driver module (e.g. DBD::mySQL) + Returns : String (driver) + Args : String (driver) - optional. + +=cut + + sub driver { + my ($self, $arg) = @_; + $self->{driver} = $arg if defined $arg; + return $self->{driver}; + } + + +=head2 url + + Title : url + Usage : my $un = $API->url($arg) + Function : get/set url (if required) + Returns : String (url) + Args : String (url) - optional. + +=cut + sub url { my ($self, $arg) = @_; $self->{url} = $arg if defined $arg; return $self->{url}; } + sub _implementation { my ($self, $arg) = @_; $self->{'_implementation'} = $arg if defined $arg; return $self->{'_implementation'}; } + +=head2 dbh + + Title : dbh + Usage : my $un = $API->dbh($arg) + Function : get/set database handle (if required) + Returns : Database handle in whatever object is appropriate for sourcetype + Args : Database handle in whatever object is appropriate for sourcetype + +=cut + sub dbh { my ($self, $arg) = @_; $self->{dbh} = $arg if defined $arg; @@ -89,24 +276,6 @@ } -sub new { - my ($caller, %args) = @_; - my $caller_is_obj = ref($caller); - my $class = $caller_is_obj || $caller; - - my $self = bless {}, $class; - - foreach my $attrname ( $self->_standard_keys_a ) { - if (exists $args{$attrname} && defined $args{$attrname}) { - $self->{$attrname} = $args{$attrname} } - elsif ($caller_is_obj) { - $self->{$attrname} = $caller->{$attrname} } - else { - $self->{$attrname} = $self->_default_for($attrname) } - } - return $self; - -} # general query subroutine # parameters: @@ -114,6 +283,18 @@ # bind_values - an array of values to be bound to the parameters # returns: # resultset - reference to an array containing ARRAY references + +=head2 dbh + + Title : general_query + Usage : my $un = $API->general_query(@args) + Function : Execute a generic query on an underlying SQL-based data source + Returns : array of array-refs representing resulting rows + Args : String - sql statement + [String] - a set of bind values + +=cut + sub general_query{ die "general_query not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Mon Jul 25 13:50:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 13:50:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251750.j6PHo2qs020462@pub.open-bio.org> mwilkinson Mon Jul 25 13:50:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY Modified Files: Central.pm collection_input.pm Log Message: changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash moby-live/Perl/MOBY Central.pm,1.178,1.179 collection_input.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.178 retrieving revision 1.179 diff -u -r1.178 -r1.179 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:20:26 1.178 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 17:50:02 1.179 @@ -3100,120 +3100,120 @@ return ""; } -=head2 _traverseServiceDAG - - Title : _traverseServiceDAG - Usage : @valid = $MOBY->_traverseServiceDAG($dbh, $serviceType, $sth_hash) - Function : starting from $serviceType, find all child services non-redundantly - by traversing the DAG. - Returns : list of Service.id database entries. - Args : none - -=cut - -sub _traverseServiceDAG { - - $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - - my ( $dbh, $serviceType, $sth_hash ) = @_; - my %sth = %{$sth_hash}; - my %ServiceIDs; - - my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); - my $row = shift(@$result); - my ($root_id) = @$row; - return undef unless $root_id; - -# we have to do a traversal of the DAG here to get all child nodes... -# this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... - $ServiceIDs{$root_id} = "untested"; # mark the one in-hand as untested - while ( grep /untested/, ( values %ServiceIDs ) ) - { # now, while there are untested services in our list... - foreach my $service ( keys %ServiceIDs ) - { # start parsing through the list - next - if ( $ServiceIDs{$service} eq "tested" ) - ; # if it has been tested already then move on - - my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); - # execute the query for child nodes - $ServiceIDs{$service} = "tested"; # mark it as tested - foreach my $row (@$result) - { # now get each of the child nodes - my $new = @$row; - next - if ( defined $ServiceIDs{$new} ) - ; # if we have already heard about it then move on - $ServiceIDs{$new} = "untested" - ; #otherwise mark it as untested, and start all over again - } - } - } - return keys %ServiceIDs; -} - -=head2 _traverseObjectDAG - - Title : _traverseObjectDAG - Usage : @valid = $MOBY->_traverseObjectDAG( $dbh, $objectType, $sth_hash, "p|c") - Function : from $objectType, find all parent/child objects non-redundantly - by traversing the DAG. - Returns : list of Object.id database entries. - Args : objectType (by name), $statement ahngles, "p" parent, or "c" child - -=cut - -sub _traverseObjectDAG { - $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - - my ( $dbh, $objectType, $sth_hash, $dir ) = @_; - my %sth = %{$sth_hash}; - my %ObjectIDs; - - my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); - - my $row = shift (@$result); - my ($root_id) = @$row; - return undef unless $root_id; - -# we have to do a traversal of the DAG here to get all child nodes... -# this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... - $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested - while ( grep /untested/, ( values %ObjectIDs ) ) - { # now, while there are untested services in our list... - foreach my $object ( keys %ObjectIDs ) - { # start parsing through the list - next - if ( $ObjectIDs{$object} eq "tested" ) - ; # if it has been tested already then move on - - my $result; - if ( $dir eq "p" ) { - $debug && &_LOG("getting parents"); - $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); - } - else { - $debug && &_LOG("getting children"); - $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); - } - # execute the query for child nodes +#=head2 _traverseServiceDAG +# +# Title : _traverseServiceDAG +# Usage : @valid = $MOBY->_traverseServiceDAG($dbh, $serviceType, $sth_hash) +# Function : starting from $serviceType, find all child services non-redundantly +# by traversing the DAG. +# Returns : list of Service.id database entries. +# Args : none +# +#=cut +# +#sub _traverseServiceDAG { +# +# $CONFIG ||= MOBY::Config->new; # exported by Config.pm +# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); +# +# my ( $dbh, $serviceType, $sth_hash ) = @_; +# my %sth = %{$sth_hash}; +# my %ServiceIDs; +# +# my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); +# my $row = shift(@$result); +# my ($root_id) = @$row; +# return undef unless $root_id; +# +## we have to do a traversal of the DAG here to get all child nodes... +## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... +# $ServiceIDs{$root_id} = "untested"; # mark the one in-hand as untested +# while ( grep /untested/, ( values %ServiceIDs ) ) +# { # now, while there are untested services in our list... +# foreach my $service ( keys %ServiceIDs ) +# { # start parsing through the list +# next +# if ( $ServiceIDs{$service} eq "tested" ) +# ; # if it has been tested already then move on +# +# my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); +# # execute the query for child nodes +# $ServiceIDs{$service} = "tested"; # mark it as tested +# foreach my $row (@$result) +# { # now get each of the child nodes +# my $new = @$row; +# next +# if ( defined $ServiceIDs{$new} ) +# ; # if we have already heard about it then move on +# $ServiceIDs{$new} = "untested" +# ; #otherwise mark it as untested, and start all over again +# } +# } +# } +# return keys %ServiceIDs; +#} - $ObjectIDs{$object} = "tested"; # mark it as tested - foreach my $row (@$result) - { # now get each of the child nodes - my $new = @$row; - next - if ( defined $ObjectIDs{$new} ) - ; # if we have already heard about it then move on - $ObjectIDs{$new} = "untested" - ; #otherwise mark it as untested, and start all over again - } - } - } - return keys %ObjectIDs; -} +#=head2 _traverseObjectDAG +# +# Title : _traverseObjectDAG +# Usage : @valid = $MOBY->_traverseObjectDAG( $dbh, $objectType, $sth_hash, "p|c") +# Function : from $objectType, find all parent/child objects non-redundantly +# by traversing the DAG. +# Returns : list of Object.id database entries. +# Args : objectType (by name), $statement ahngles, "p" parent, or "c" child +# +#=cut +# +#sub _traverseObjectDAG { +# $CONFIG ||= MOBY::Config->new; # exported by Config.pm +# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); +# +# my ( $dbh, $objectType, $sth_hash, $dir ) = @_; +# my %sth = %{$sth_hash}; +# my %ObjectIDs; +# +# my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); +# +# my $row = shift (@$result); +# my ($root_id) = @$row; +# return undef unless $root_id; +# +## we have to do a traversal of the DAG here to get all child nodes... +## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... +# $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested +# while ( grep /untested/, ( values %ObjectIDs ) ) +# { # now, while there are untested services in our list... +# foreach my $object ( keys %ObjectIDs ) +# { # start parsing through the list +# next +# if ( $ObjectIDs{$object} eq "tested" ) +# ; # if it has been tested already then move on +# +# my $result; +# if ( $dir eq "p" ) { +# $debug && &_LOG("getting parents"); +# $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); +# } +# else { +# $debug && &_LOG("getting children"); +# $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); +# } +# # execute the query for child nodes +# +# $ObjectIDs{$object} = "tested"; # mark it as tested +# foreach my $row (@$result) +# { # now get each of the child nodes +# my $new = @$row; +# next +# if ( defined $ObjectIDs{$new} ) +# ; # if we have already heard about it then move on +# $ObjectIDs{$new} = "untested" +# ; #otherwise mark it as untested, and start all over again +# } +# } +# } +# return keys %ObjectIDs; +#} #Eddie - converted sub _nodeTextContent { =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/18 16:53:03 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/25 17:50:02 1.5 @@ -94,9 +94,8 @@ my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - my $id = $adaptor->insert_collection_input( - {service_instance => $self->service_instance_id}, - {article_name => $self->article_name} ); + my $id = $adaptor->insert_collection_input(service_instance => $self->service_instance_id, + article_name => $self->article_name); return $id; } From mwilkinson at pub.open-bio.org Mon Jul 25 13:50:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 13:50:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251750.j6PHo2nW020481@pub.open-bio.org> mwilkinson Mon Jul 25 13:50:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:23:35 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:50:02 1.6 @@ -277,28 +277,7 @@ } -# general query subroutine -# parameters: -# statement - a string SQL statement -# bind_values - an array of values to be bound to the parameters -# returns: -# resultset - reference to an array containing ARRAY references - -=head2 dbh - - Title : general_query - Usage : my $un = $API->general_query(@args) - Function : Execute a generic query on an underlying SQL-based data source - Returns : array of array-refs representing resulting rows - Args : String - sql statement - [String] - a set of bind values -=cut - -sub general_query{ - die "general_query not implemented in adaptor\n"; -} - # # collection_input table functions # @@ -308,14 +287,6 @@ sub insert_collection_input { die "insert_collection_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} } sub delete_collection_input{ From mwilkinson at pub.open-bio.org Mon Jul 25 13:50:03 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 13:50:03 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251750.j6PHo3EV020501@pub.open-bio.org> mwilkinson Mon Jul 25 13:50:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.28,1.29 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 20:00:10 1.28 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 17:50:02 1.29 @@ -75,25 +75,24 @@ my $driver = $self->driver; # inherited from the adaptorI (queryapi) my $username = $self->username; my $password = $self->password; - my $port = $self->port; - my $url = $self->url; - my $dbname = $self->dbname; - - my ($dsn) = "$driver:$dbname:$url:$port"; -# print STDERR "\n\nconnectiung to $driver:$dbname:$url:$port\n\n"; - my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; + my $port = $self->port; + my $url = $self->url; + my $dbname = $self->dbname; + + my ($dsn) = "$driver:$dbname:$url:$port"; + my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; - ############################################################## - unless ($dbh) { - print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; - return undef; - } - + ############################################################## + unless ($dbh) { + print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; + return undef; + } + $self->dbh($dbh); - ############################################################# + ############################################################# - return undef unless $self->dbh; + return undef unless $self->dbh; return $self; } @@ -162,29 +161,23 @@ } } } - -# general query subroutine -# parameters: -# statement - a string SQL statement -# bind_values - an array of values to be bound to the parameters -# returns: -# resultset - reference to an array containing ARRAY references -sub general_query{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = get_value('statement', @args); - my $sth = $dbh->prepare($statement); - if (@args > 1) - { - my $bindvalues = get_value('bind_values', @args); - $sth->execute(@$bindvalues); - } - else { - $sth->execute; - } - my $result = $sth->fetchall_arrayref(); - return $result; -} +# +#sub general_query{ +# my ($self, @args) = @_; +# my $dbh = $self->dbh; +# my $statement = get_value('statement', @args); +# my $sth = $dbh->prepare($statement); +# if (@args > 1) +# { +# my $bindvalues = get_value('bind_values', @args); +# $sth->execute(@$bindvalues); +# } +# else { +# $sth->execute; +# } +# my $result = $sth->fetchall_arrayref(); +# return $result; +#} sub query_collection_input{ my ($self, @args) = @_; @@ -207,15 +200,12 @@ } sub insert_collection_input { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; -# if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # this should be dropped down into the mysql.pm module?? probably... $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", - undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); + undef, $args{'service_instance_id'},$args{'article_name'}); my $id=$self->dbh->{mysql_insertid}; return $id; -# } } sub delete_collection_input{ From mwilkinson at pub.open-bio.org Mon Jul 25 14:17:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 14:17:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251817.j6PIHjei020657@pub.open-bio.org> mwilkinson Mon Jul 25 14:17:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:50:02 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:17:44 1.7 @@ -281,6 +281,21 @@ # # collection_input table functions # + +=head2 query_collection_input + + Title : query_collection_input + Usage : my $un = $API->query_collection_input(%arg) + Function : get the collection input information for a given service + Args : service_lsid => String + Returns : listref of hashrefs: + [{collection_input_id => Integer + article_name => String}, ...] + one hashref for each collection that service consumes + Notes : the fact that it returns a collection_input_id is bad since this + is only useful to an SQL-based API... +=cut + sub query_collection_input{ die "query_collection_input not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Mon Jul 25 14:17:44 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 14:17:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251817.j6PIHioA020638@pub.open-bio.org> mwilkinson Mon Jul 25 14:17:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY Modified Files: Central.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic moby-live/Perl/MOBY Central.pm,1.179,1.180 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.179 retrieving revision 1.180 diff -u -r1.179 -r1.180 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 17:50:02 1.179 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 18:17:44 1.180 @@ -3100,120 +3100,6 @@ return ""; } -#=head2 _traverseServiceDAG -# -# Title : _traverseServiceDAG -# Usage : @valid = $MOBY->_traverseServiceDAG($dbh, $serviceType, $sth_hash) -# Function : starting from $serviceType, find all child services non-redundantly -# by traversing the DAG. -# Returns : list of Service.id database entries. -# Args : none -# -#=cut -# -#sub _traverseServiceDAG { -# -# $CONFIG ||= MOBY::Config->new; # exported by Config.pm -# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); -# -# my ( $dbh, $serviceType, $sth_hash ) = @_; -# my %sth = %{$sth_hash}; -# my %ServiceIDs; -# -# my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); -# my $row = shift(@$result); -# my ($root_id) = @$row; -# return undef unless $root_id; -# -## we have to do a traversal of the DAG here to get all child nodes... -## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... -# $ServiceIDs{$root_id} = "untested"; # mark the one in-hand as untested -# while ( grep /untested/, ( values %ServiceIDs ) ) -# { # now, while there are untested services in our list... -# foreach my $service ( keys %ServiceIDs ) -# { # start parsing through the list -# next -# if ( $ServiceIDs{$service} eq "tested" ) -# ; # if it has been tested already then move on -# -# my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); -# # execute the query for child nodes -# $ServiceIDs{$service} = "tested"; # mark it as tested -# foreach my $row (@$result) -# { # now get each of the child nodes -# my $new = @$row; -# next -# if ( defined $ServiceIDs{$new} ) -# ; # if we have already heard about it then move on -# $ServiceIDs{$new} = "untested" -# ; #otherwise mark it as untested, and start all over again -# } -# } -# } -# return keys %ServiceIDs; -#} - -#=head2 _traverseObjectDAG -# -# Title : _traverseObjectDAG -# Usage : @valid = $MOBY->_traverseObjectDAG( $dbh, $objectType, $sth_hash, "p|c") -# Function : from $objectType, find all parent/child objects non-redundantly -# by traversing the DAG. -# Returns : list of Object.id database entries. -# Args : objectType (by name), $statement ahngles, "p" parent, or "c" child -# -#=cut -# -#sub _traverseObjectDAG { -# $CONFIG ||= MOBY::Config->new; # exported by Config.pm -# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); -# -# my ( $dbh, $objectType, $sth_hash, $dir ) = @_; -# my %sth = %{$sth_hash}; -# my %ObjectIDs; -# -# my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); -# -# my $row = shift (@$result); -# my ($root_id) = @$row; -# return undef unless $root_id; -# -## we have to do a traversal of the DAG here to get all child nodes... -## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... -# $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested -# while ( grep /untested/, ( values %ObjectIDs ) ) -# { # now, while there are untested services in our list... -# foreach my $object ( keys %ObjectIDs ) -# { # start parsing through the list -# next -# if ( $ObjectIDs{$object} eq "tested" ) -# ; # if it has been tested already then move on -# -# my $result; -# if ( $dir eq "p" ) { -# $debug && &_LOG("getting parents"); -# $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); -# } -# else { -# $debug && &_LOG("getting children"); -# $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); -# } -# # execute the query for child nodes -# -# $ObjectIDs{$object} = "tested"; # mark it as tested -# foreach my $row (@$result) -# { # now get each of the child nodes -# my $new = @$row; -# next -# if ( defined $ObjectIDs{$new} ) -# ; # if we have already heard about it then move on -# $ObjectIDs{$new} = "untested" -# ; #otherwise mark it as untested, and start all over again -# } -# } -# } -# return keys %ObjectIDs; -#} #Eddie - converted sub _nodeTextContent { From mwilkinson at pub.open-bio.org Mon Jul 25 14:17:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 14:17:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251817.j6PIHjxi020677@pub.open-bio.org> mwilkinson Mon Jul 25 14:17:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.29,1.30 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 17:50:02 1.29 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 18:17:44 1.30 @@ -97,7 +97,7 @@ } -sub add_condition{ +sub _add_condition{ my ($statement, @params) = @_; my @bindvalues = (); my $condition = "where "; @@ -161,41 +161,18 @@ } } } -# -#sub general_query{ -# my ($self, @args) = @_; -# my $dbh = $self->dbh; -# my $statement = get_value('statement', @args); -# my $sth = $dbh->prepare($statement); -# if (@args > 1) -# { -# my $bindvalues = get_value('bind_values', @args); -# $sth->execute(@$bindvalues); -# } -# else { -# $sth->execute; -# } -# my $result = $sth->fetchall_arrayref(); -# return $result; -#} - + +# this should NOT retun a collection ID... needs more work... sub query_collection_input{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; + my $serv_lsid = $args{'service_lsid'}; my $statement = "select collection_input_id, - article_name, - service_instance_id - from collection_input "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) = add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); + article_name + from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; + my $result = do_query($dbh, $statement, [$serv_lsid]); return $result; } @@ -213,7 +190,7 @@ my $dbh = $self->dbh; my $statement = "delete from collection_input "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -239,7 +216,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -263,7 +240,7 @@ my $dbh = $self->dbh; my $statement = "delete from collection_output "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -292,7 +269,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -328,7 +305,7 @@ my $dbh = $self->dbh; my $statement = "delete from simple_input "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); if ($dbh->err){ @@ -355,7 +332,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -391,7 +368,7 @@ my $dbh = $self->dbh; my $statement = "delete from simple_output "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); if ($dbh->err){ @@ -420,7 +397,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -448,7 +425,7 @@ my $dbh = $self->dbh; my $statement = "delete from secondary_input "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -478,7 +455,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -512,7 +489,7 @@ my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........********** # ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ******************** my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -539,7 +516,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -567,7 +544,7 @@ my $statement = "delete from object_term2term "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -606,7 +583,7 @@ lsid from service_instance "; my @bindvalues; - ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); + ($statement, @bindvalues) =_add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); my $final = do_query($dbh, $statement, @bindvalues); if (@$final[0]){return 1} else {return 0} @@ -628,7 +605,7 @@ delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ - push @args, ({$k => $v}, "and"); # format for the add_condition subroutine + push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine } if ($authority_id){ push @args, ({authority_id => $authority_id}) ; @@ -650,7 +627,7 @@ lsid from service_instance "; my @bindvalues; - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); return $final; } @@ -693,7 +670,7 @@ my $dbh = $self->dbh; my $statement = "delete from service_instance "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); if ($dbh->err){ @@ -719,7 +696,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -766,7 +743,7 @@ my @bindvalues = (); if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -792,7 +769,7 @@ my $dbh = $self->dbh; my $statement = "delete from service "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -816,7 +793,7 @@ my @bindvalues = (); if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -839,7 +816,7 @@ my $dbh = $self->dbh; my $statement = "delete from service_term2term "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -869,7 +846,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -892,7 +869,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -918,7 +895,7 @@ my $dbh = $self->dbh; my $statement = "delete from namespace "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -944,7 +921,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -956,7 +933,7 @@ my $dbh = $self->dbh; my $statement = "delete from namespace_term2term "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); From dwang at pub.open-bio.org Mon Jul 25 14:20:16 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 14:20:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251820.j6PIKGvG020735@pub.open-bio.org> dwang Mon Jul 25 14:20:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20709/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added documentation for getRelationship() moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:17:44 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:20:16 1.8 @@ -595,6 +595,18 @@ die "getObjectRelationships not implemented in adaptor\n"; } +=head2 getRelationship + + Title : getRelationship + Usage : my $un = $API->general_query(@args) + Function : Execute a query for a relationship between two tables on an underlying SQL-based data source + Returns : array of array-refs representing resulting rows + Args : String - direction in the ontology (eg. 'root') + String - name of the table ontology + Integer - a bind value for lsid + String - a bind value for relationship_type + +=cut # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references sub getRelationship{ From mwilkinson at pub.open-bio.org Mon Jul 25 15:53:36 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 15:53:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251953.j6PJra0j021023@pub.open-bio.org> mwilkinson Mon Jul 25 15:53:36 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv20961/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic. Lots more of these to come, but committing now so that Dennis can see what I am doing moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.30,1.31 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 18:17:44 1.30 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 19:53:36 1.31 @@ -162,7 +162,17 @@ } } +sub _getSIIDFromLSID { + my ($self, $lsid) = @_; + my $dbh = $self->dbh; + my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); + $sth->execute($lsid); + my ($siid) = $sth->fetchrow_array(); + return $siid; +} + # this should NOT retun a collection ID... needs more work... +# args passed in: service_lsid sub query_collection_input{ my ($self, %args) = @_; my $dbh = $self->dbh; @@ -176,144 +186,132 @@ return $result; } +# args passed in: service_instance_lsid, article_name sub insert_collection_input { - my ($self, %args) = @_; - my $dbh = $self->dbh; - $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", - undef, $args{'service_instance_id'},$args{'article_name'}); - my $id=$self->dbh->{mysql_insertid}; - return $id; + my ($self, %args) = @_; + my $article = $args{article_name}; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", + undef, $siid, $article); + my $id=$self->dbh->{mysql_insertid}; + return $id; } +# pass in service_instance_lsid sub delete_collection_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from collection_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + my $statement = "delete from collection_input where service_instance_id = ?"; + $self->dbh->do( $statement, undef, $siid); + + if ($self->dbh->err){ + return (1, $self->dbh->errstr); + } + else{ + return 0; + } } -# query subroutine selects all columns +# pass service_instance_lsid sub query_collection_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select collection_output_id, article_name, service_instance_id - from collection_output "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + from collection_output where service_instance_id = ? "; + my $result = do_query($dbh, $statement, [$siid]); + return $result; } +# pass service_instance_lsid, article_name sub insert_collection_output { - my ($self, @args) = @_; - my $dbh = $self->dbh; -# if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # this should be dropped down into the mysql.pm module?? probably... - $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", - undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); - my $id=$self->dbh->{mysql_insertid}; - return $id; -# } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", + undef, $siid,$args{'article_name'}); + my $id=$self->dbh->{mysql_insertid}; + return $id; } +# pass argument service_instance_lsid sub delete_collection_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from collection_output "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from collection_output where service_instance_id = ?"; + my @bindvalues = (); + $dbh->do( $statement, undef, ($siid)); + + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } - +# pass service_instance_lsid sub query_simple_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - simple_input_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id - from simple_input "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + simple_input_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id + from simple_input where service_instance_id = ? and collection_input_id IS NULL"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; } - +# pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id sub insert_simple_input { - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $si = get_value('collection_input_id', @args)?undef:get_value('service_instance_id', @args); - - $dbh->do("insert into simple_input - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id) - values (?,?,?,?,?)", - undef, - (get_value('object_type_uri', @args), - get_value('namespace_type_uris', @args), - get_value('article_name', @args), -# here - $si, - get_value('collection_input_id', @args))); - my $id=$dbh->{mysql_insertid}; - return $id; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do("insert into simple_input + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id) + values (?,?,?,?,?)", + undef, + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_input_id'}); + my $id=$dbh->{mysql_insertid}; + return $id; } sub delete_simple_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from simple_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, @args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $statement = "delete from simple_input "; + my @bindvalues = (); + ($statement, @bindvalues) =_add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } sub query_simple_output{ From mwilkinson at pub.open-bio.org Mon Jul 25 15:53:36 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 15:53:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251953.j6PJraI8021004@pub.open-bio.org> mwilkinson Mon Jul 25 15:53:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20961/MOBY Modified Files: Central.pm collection_input.pm collection_output.pm secondary_input.pm service_instance.pm simple_input.pm simple_output.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic. Lots more of these to come, but committing now so that Dennis can see what I am doing moby-live/Perl/MOBY Central.pm,1.180,1.181 collection_input.pm,1.5,1.6 collection_output.pm,1.4,1.5 secondary_input.pm,1.6,1.7 service_instance.pm,1.24,1.25 simple_input.pm,1.6,1.7 simple_output.pm,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.180 retrieving revision 1.181 diff -u -r1.180 -r1.181 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 18:17:44 1.180 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 19:53:35 1.181 @@ -3270,7 +3270,6 @@ $desc = $1; } -#print "\n\nAFTER EXECUTE $category, $servicename, $service_type_uri, $authority_id, $desc, $authoritative\n\n"; $signatureURL ||= ""; next unless ( $servicename && $authority_id ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); @@ -3278,8 +3277,7 @@ $result = $adaptor->query_authority({authority_id => $authority_id}); $row = shift(@$result); my $authURI = $row->{authority_uri}; - $output .= -"\t\n"; + $output .= "\t\n"; $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; $output .= "\t$category\n"; @@ -3288,8 +3286,10 @@ $output .= "\t$signatureURL\n"; $output .= "\t$url\n"; $output .= "\t\n"; - - $result = $adaptor->query_simple_input({service_instance_id => $_}, 'and', {collection_input_id => undef}); + +#************FIX +#************FIX : $_ here should also be an LSID... + $result = $adaptor->query_simple_input(service_instance_lsid => $lsid); foreach my $row (@$result) { @@ -3309,8 +3309,7 @@ } $output .= "\t\t\n"; } - $result = $adaptor->query_collection_input({service_instance_id => $_}); -# $sth_collection_ins->execute($_); + $result = $adaptor->query_collection_input(service_instance_lsid => $lsid); foreach my $row (@$result) { @@ -3319,7 +3318,7 @@ $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, 'and', {collection_input_id => $collid}); + my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_input_id => $collid); foreach my $row2 (@$result2) { my $objURI = $row2->{object_type_uri}; @@ -3344,7 +3343,7 @@ $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); + $result = $adaptor->query_simple_output(service_instance_lsid => $lsid}, collection_output_id => undef); foreach my $row (@$result) { @@ -3365,14 +3364,14 @@ $output .= "\t\t\n"; } - $result = $adaptor->query_collection_output({service_instance_id => $_}); + $result = $adaptor->query_collection_output(service_instance_lsid => $lsid); foreach my $row (@$result) { my $collid = $row->{collection_output_id}; my $articlename = $row->{article_name}; $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id => $collid}); + my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_output_id => $collid); foreach my $row2 (@$result2 ) { my $objURI = $row2->{object_type_uri}; @@ -3395,7 +3394,7 @@ } $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_secondary_input({service_instance_id => $_}); + $result = $adaptor->query_secondary_input(service_instance_lsid => $_); foreach my $row (@$result) { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ("","","","","",""); $default_value = $row->{default_value}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/25 17:50:02 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/25 19:53:35 1.6 @@ -46,6 +46,7 @@ collection_input_id => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -94,7 +95,7 @@ my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - my $id = $adaptor->insert_collection_input(service_instance => $self->service_instance_id, + my $id = $adaptor->insert_collection_input(service_instance_lsid => $self->service_instance_lsid, article_name => $self->article_name); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/18 16:53:03 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/25 19:53:35 1.5 @@ -45,6 +45,7 @@ collection_output_id => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -94,8 +95,8 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_collection_output( - {service_instance => $self->service_instance_id}, - {article_name => $self->article_name} ); + service_instance_lsid => $self->service_instance_lsid, + article_name => $self->article_name); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/22 19:16:40 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 19:53:35 1.7 @@ -50,6 +50,7 @@ datatype => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -120,7 +121,7 @@ {enum_value => $self->enum_value}, {datatype => $self->datatype}, {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}); + {service_instance_lsid => $self->service_instance_id}); return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:38:02 1.24 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 19:53:35 1.25 @@ -71,9 +71,9 @@ contact_email => [ undef, 'read/write' ], authoritative => [ 0, 'read/write' ], description => [ undef, 'read/write' ], - registry => [ 'MOBY_Central', 'read/write' ], - lsid => [ undef, 'read/write' ], - test => [ 0, 'read/write' ] + registry => [ 'MOBY_Central', 'read/write' ], + lsid => [ undef, 'read/write' ], + test => [ 0, 'read/write' ] , # toggles create or test_existence behaviour ); @@ -164,12 +164,6 @@ } } -#sub _dbh { -# my ($self) = @_; -# -# my $central_connect = MOBY::central_db_connection->new(); -# $self->dbh($central_connect->dbh); -#} sub new { my ( $caller, %args ) = @_; my $caller_is_obj = ref($caller); @@ -189,27 +183,23 @@ return undef unless $self->authority_uri; return undef unless $self->servicename; - if ( $self->test ) { return $self->service_instance_exists } + if ( $self->test ) { return $self->service_instance_exists } # returns boolean - $self->authority( $self->_get_authority() ); + $self->authority( $self->_get_authority() ); # as MOBY::authority object if ( $self->service_type ) { my $OE = MOBY::OntologyServer->new( ontology => 'service' ); my ( $success, $message, $servicetypeURI ) = $OE->serviceExists( term => $self->service_type ); unless ( - ( - $success - || ( ( $self->service_type =~ /urn:lsid/i ) - && !( $self->service_type =~ /urn:lsid:biomoby.org/i ) ) - ) - ) + $success || ( ( $self->service_type =~ /urn:lsid/i ) && !( $self->service_type =~ /urn:lsid:biomoby.org/i ) ) + ) { return undef; } - ( $self->service_type =~ /urn:lsid/ ) - ? $self->service_type_uri( $self->service_type ) - : $self->service_type_uri($servicetypeURI); + ( $self->service_type =~ /urn:lsid/ )? + $self->service_type_uri( $self->service_type ) + : $self->service_type_uri($servicetypeURI); } my $existing_services = $self->adaptor->query_service_instance(servicename => $self->servicename, authority_uri => $self->authority_uri); @@ -236,23 +226,25 @@ ) { # then create it de novo if we have enough information #create LSID for service and register it in the DB my $_config ||= MOBY::Config->new; - my $service_lsid = "urn:lsid:" - . $_config->{mobycentral}->{lsid_authority} . ":" - . $_config->{mobycentral}->{lsid_namespace} . ":" + my $LSID_Auth = $_config->{mobycentral}->{lsid_authority}; + my $LSID_NS = $_config->{mobycentral}->{lsid_namespace}; + $LSID_Auth ||="biomoby.org"; + $LSID_NS ||="serviceinstance"; + my $service_lsid = "urn:lsid:$LSID_Auth:$LSID_NS:" . $self->authority_uri . "," . $self->servicename; my $id = $self->adaptor->insert_service_instance( - {category => $self->category}, - {servicename => $self->servicename}, - {service_type_uri => $self->service_type_uri}, - {authority_id => $self->authority_id}, - {url => $self->url}, - {contact_email => $self->contact_email}, - {authoritative => $self->authoritative}, - {description => $self->description}, - {signatureURL => $self->signatureURL}, - {lsid => $service_lsid} + {category => $self->category}, + {servicename => $self->servicename}, + {service_type_uri => $self->service_type_uri}, + {authority_id => $self->authority_id}, + {url => $self->url}, + {contact_email => $self->contact_email}, + {authoritative => $self->authoritative}, + {description => $self->description}, + {signatureURL => $self->signatureURL}, + {lsid => $service_lsid} ); $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists @@ -271,26 +263,26 @@ $CONFIG ||= MOBY::Config->new; my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - $adaptor->delete_service_instance({service_instance_id => $self->service_instance_id}); - $adaptor->delete_simple_input({service_instance_id => $self->service_instance_id}); - $adaptor->delete_simple_output({service_instance_id => $self->service_instance_id}); + $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_input({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_output({service_instance_lsid => $self->lsid}); - my $result = $adaptor->query_collection_input({service_instance_id => $self->service_instance_id}); + my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); foreach my $row (@$result) { my $id = $row->{collection_input_id}; $adaptor->delete_simple_input({collection_input_id => $id}); } - $result = $adaptor->query_collection_output({service_instance_id => $self->service_instance_id}); + $result = $adaptor->query_collection_output(service_instance_lsid => $self->lsid); foreach my $row (@$result) { my $id = $row->{collection_output_id}; $adaptor->delete_simple_output({collection_output_id => $id}); } - $adaptor->delete_collection_input({service_instance_id => $self->service_instance_id}); - $adaptor->delete_collection_output({service_instance_id => $self->service_instance_id}); - $adaptor->delete_secondary_input({service_instance_id => $self->service_instance_id}); + $adaptor->delete_collection_input(service_instance_lsid => $self->lsid); + $adaptor->delete_collection_output(service_instance_lsid => $self->lsid); + $adaptor->delete_secondary_input({service_instance_lsid => $self->lsid}); return 1; } @@ -329,16 +321,16 @@ my $email = $row->{contact_email}; $authority = MOBY::authority->new( - dbh => $self->dbh, - authority_id => $id, - authority_uri => $uri, - contact_email => $email, + dbh => $self->dbh, + authority_id => $id, + authority_uri => $uri, + contact_email => $email, ); } else { $authority = MOBY::authority->new( - dbh => $self->dbh, - authority_uri => $self->authority_uri, - contact_email => $self->contact_email, + dbh => $self->dbh, + authority_uri => $self->authority_uri, + contact_email => $self->contact_email, ); } return $authority; @@ -349,11 +341,12 @@ # validate here... one day... my $simple = MOBY::simple_input->new( - object_type_uri => $a{'object_type_uri'}, - namespace_type_uris => $a{'namespace_type_uris'}, - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, - collection_input_id => $a{'collection_input_id'} + object_type_uri => $a{'object_type_uri'}, + namespace_type_uris => $a{'namespace_type_uris'}, + article_name => $a{'article_name'}, + service_instance_id => $self->service_instance_id, + service_instance_lsid => $self->lsid, + collection_input_id => $a{'collection_input_id'} ); push @{ $self->{inputs} }, $simple; return $simple->simple_input_id; @@ -364,11 +357,12 @@ # validate here... one day... my $simple = MOBY::simple_output->new( - object_type_uri => $a{'object_type_uri'}, - namespace_type_uris => $a{'namespace_type_uris'}, - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, - collection_output_id => $a{'collection_output_id'} + object_type_uri => $a{'object_type_uri'}, + namespace_type_uris => $a{'namespace_type_uris'}, + article_name => $a{'article_name'}, + service_instance_id => $self->service_instance_id, + service_instance_lsid => $self->lsid, + collection_output_id => $a{'collection_output_id'} ); push @{ $self->{outputs} }, $simple; return $simple->simple_output_id; @@ -379,8 +373,9 @@ # validate here... one day... my $coll = MOBY::collection_input->new( - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, ); + article_name => $a{'article_name'}, + service_instance_lsid => $self->lsid, + service_instance_id => $self->service_instance_id, ); push @{ $self->{inputs} }, $coll; return $coll->collection_input_id; } @@ -390,8 +385,9 @@ # validate here... one day... my $coll = MOBY::collection_output->new( - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, ); + article_name => $a{'article_name'}, + service_instance_lsid => $self->lsid, + service_instance_id => $self->service_instance_id, ); push @{ $self->{outputs} }, $coll; return $coll->collection_output_id; } @@ -401,13 +397,14 @@ # validate here... one day... my $sec = MOBY::secondary_input->new( - default_value => $a{'default_value'}, - maximum_value => $a{'maximum_value'}, - minimum_value => $a{'minimum_value'}, - enum_value => $a{'enum_value'}, - datatype => $a{'datatype'}, - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, + default_value => $a{'default_value'}, + maximum_value => $a{'maximum_value'}, + minimum_value => $a{'minimum_value'}, + enum_value => $a{'enum_value'}, + datatype => $a{'datatype'}, + article_name => $a{'article_name'}, + service_instance_id => $self->service_instance_id, + service_instance_lsid => $self->lsid, ); push @{ $self->{inputs} }, $sec; return $sec->secondary_input_id; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/18 16:53:03 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/25 19:53:35 1.7 @@ -50,6 +50,7 @@ namespace_type_uris => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], collection_input_id => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -100,11 +101,11 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_input( - {object_type_uri => $self->object_type_uri}, - {namespace_type_uris => $self->namespace_type_uris}, - {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}, - {collection_input_id => $self->collection_input_id} + object_type_uri => $self->object_type_uri, + namespace_type_uris => $self->namespace_type_uris, + article_name => $self->article_name, + service_instance_lsid => $self->service_instance_id, + collection_input_id => $self->collection_input_id ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/18 16:53:03 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 19:53:35 1.6 @@ -49,6 +49,7 @@ namespace_type_uris => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], collection_output_id => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -102,7 +103,7 @@ {object_type_uri => $self->object_type_uri}, {namespace_type_uris => $self->namespace_type_uris}, {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}, + {service_instance_lsid => $self->service_instance_id}, {collection_output_id => $self->collection_output_id} ); return $id; From mwilkinson at pub.open-bio.org Mon Jul 25 16:14:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 16:14:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252014.j6PKEZfM021182@pub.open-bio.org> mwilkinson Mon Jul 25 16:14:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21136/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.31,1.32 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 19:53:36 1.31 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:14:35 1.32 @@ -297,15 +297,14 @@ return $id; } +# pass service_instance_lsid sub delete_simple_input{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $statement = "delete from simple_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $statement = "delete from simple_input where service_instance_lsid = ?"; + + $dbh->do( $statement, undef,($siid)); if ($dbh->err){ return (1, $dbh->errstr); } @@ -314,50 +313,71 @@ } } +sub delete_inputs { # this should replace all other delete_*_input + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $result_ids = $adaptor->query_collection_input(service_instance_lsid => $self->lsid); + + my $statement = "delete from simple_input where service_instance_lsid = ?"; + + $dbh->do( $statement, undef,($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } + +} + +sub delete_output { # this should replace all other delete_*_output + +} + +# UGH this has to know too much bout the underlying database structure e.g. that one is null and other is full +# this problem is in MOBY::Central line 3321 3346 and 3374 +#****** FIX +# send service_instance_lsid, collection_input_id sub query_simple_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - simple_output_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id - from simple_output "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $collid = $args{collection_input_id}; + my $dbh = $self->dbh; + + my $statement = "select + simple_output_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id + from simple_output where service_instance_id = ? and collection_input_id= ?"; + my $result = do_query($dbh, $statement, ($siid, $collid)); + return $result; } +# pass args service_instance_id and collection_output_id sub insert_simple_output { - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $si = get_value('collection_output_id', @args)?undef:get_value('service_instance_id', @args); + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; - $dbh->do("insert into simple_output - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id) - values (?,?,?,?,?)", - undef, - (get_value('object_type_uri', @args), - get_value('namespace_type_uris', @args), - get_value('article_name', @args), -# and here - $si, - get_value('collection_output_id', @args))); - my $id=$dbh->{mysql_insertid}; - return $id; + $dbh->do("insert into simple_output + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id) + values (?,?,?,?,?)", + undef,( + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_output_id'})); + my $id=$dbh->{mysql_insertid}; + return $id; } From mwilkinson at pub.open-bio.org Mon Jul 25 16:14:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 16:14:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252014.j6PKEZde021163@pub.open-bio.org> mwilkinson Mon Jul 25 16:14:34 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21136/MOBY Modified Files: Central.pm service_instance.pm simple_output.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY Central.pm,1.181,1.182 service_instance.pm,1.25,1.26 simple_output.pm,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.181 retrieving revision 1.182 diff -u -r1.181 -r1.182 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 19:53:35 1.181 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 20:14:34 1.182 @@ -3343,7 +3343,7 @@ $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_simple_output(service_instance_lsid => $lsid}, collection_output_id => undef); + $result = $adaptor->query_simple_output(service_instance_lsid => $lsid, collection_output_id => undef); foreach my $row (@$result) { =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 19:53:35 1.25 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:14:34 1.26 @@ -262,9 +262,13 @@ } $CONFIG ||= MOBY::Config->new; my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - + +#********FIX this should really be delete_input and delete_output +# the routines below know too much about the database (e.g. that +# the delete_simple_input routines are broken into two parts - by LSID and +# by collecion ID... BAD BAD BAD $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); - $adaptor->delete_simple_input({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output({service_instance_lsid => $self->lsid}); my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 19:53:35 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 20:14:34 1.7 @@ -100,12 +100,12 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_output( - {object_type_uri => $self->object_type_uri}, - {namespace_type_uris => $self->namespace_type_uris}, - {article_name => $self->article_name}, - {service_instance_lsid => $self->service_instance_id}, - {collection_output_id => $self->collection_output_id} - ); + object_type_uri => $self->object_type_uri, + namespace_type_uris => $self->namespace_type_uris, + article_name => $self->article_name, + service_instance_lsid => $self->service_instance_id, + collection_output_id => $self->collection_output_id + ); return $id; } From kawas at pub.open-bio.org Mon Jul 25 16:18:52 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon, 25 Jul 2005 16:18:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252018.j6PKIq0K021236@pub.open-bio.org> kawas Mon Jul 25 16:18:51 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util In directory pub.open-bio.org:/tmp/cvs-serv21211/org/biomoby/registry/rdfagent/util Modified Files: Report.java Log Message: changed the default send to address to be my address. moby-live/Java/src/main/org/biomoby/registry/rdfagent/util Report.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/04/16 14:32:47 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/07/25 20:18:51 1.4 @@ -73,7 +73,7 @@ to = DataMngr.getContactEmail(signURL); if (to.equals("")){ - to = "opushneva at yahoo.ca"; + to = "edward.kawas at gmail.com"; } String subject = "The RDFagent Report"; From kawas at pub.open-bio.org Mon Jul 25 16:20:02 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon, 25 Jul 2005 16:20:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252020.j6PKK2Aw021287@pub.open-bio.org> kawas Mon Jul 25 16:20:02 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv21262/org/biomoby/registry/rdfagent/verifier Modified Files: ServiceDescrParser.java Log Message: changed the references from the old predicate vocabulary to the updated one. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServiceDescrParser.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/05/19 15:57:25 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/25 20:20:02 1.6 @@ -9,7 +9,6 @@ import org.biomoby.registry.rdfagent.util.Report; import org.biomoby.registry.rdfagent.util.XMLBuilder; import org.biomoby.registry.rdfagent.vocabulary.MP; -import org.biomoby.registry.rdfagent.vocabulary.MRes; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.rdf.model.Model; @@ -291,7 +290,7 @@ Object type = l3Res.getRequiredProperty(RDF.type).getObject(); - if (type.equals(MRes.Simple)){ + if (type.equals(MP.Simple)){ StmtIterator p34iter = l3Res.listProperties(); while (p34iter.hasNext()) { @@ -341,7 +340,7 @@ } } - else if (type.equals(MRes.Collection) | type.equals(RDF.Bag)){ + else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ // if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ if (l3Res.hasProperty(RDF.li(1))){ StmtIterator p34iter = l3Res.listProperties(); @@ -409,7 +408,7 @@ } } - if (type.equals(MRes.Secondary)){ + if (type.equals(MP.Secondary)){ StmtIterator p34iter = l3Res.listProperties(); while (p34iter.hasNext()) { @@ -507,7 +506,7 @@ if (l3Res.isAnon()){ Object type = l3Res.getRequiredProperty(RDF.type).getObject(); //System.out.println("type_out = "+type); - if (type.equals(MRes.Simple)){ + if (type.equals(MP.Simple)){ StmtIterator p34iter = l3Res.listProperties(); while (p34iter.hasNext()) { @@ -557,7 +556,7 @@ } } - else if (type.equals(MRes.Collection) | type.equals(RDF.Bag)){ + else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ // if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ if (l3Res.hasProperty(RDF.li(1))){ From kawas at pub.open-bio.org Mon Jul 25 16:20:44 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon, 25 Jul 2005 16:20:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252020.j6PKKicE021321@pub.open-bio.org> kawas Mon Jul 25 16:20:44 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv21292/org/biomoby/registry/rdfagent/vocabulary Modified Files: MP.java MRes.java Log Message: deprecated the MRes class and modified the MP class to reflect the changes in the RESOURCES script. moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary MP.java,1.4,1.5 MRes.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/04/16 14:30:46 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/07/25 20:20:44 1.5 @@ -27,7 +27,7 @@ private static Model m = ModelFactory.createDefaultModel(); - + //TODO move mobyResource predicates here. public static final Property category = m.getProperty(uri + "category" ) ; public static final Property articleName = m.getProperty(uri + "articleName" ) ; public static final Property article_name = m.getProperty(uri + "article_name" ) ; @@ -49,7 +49,9 @@ public static final Property CollectionArticle = m.getProperty(uri + "CollectionArticle" ); public static final Property SecondaryArticle = m.getProperty(uri + "SecondaryArticle" ) ; public static final Property type = m.getProperty(uri + "type" ) ; - + public static final Property Simple = m.getProperty(uri + "Simple" ) ; + public static final Property Collection = m.getProperty(uri + "Collection" ) ; + public static final Property Secondary = m.getProperty(uri + "Secondary" ) ; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MRes.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MRes.java 2005/04/16 14:30:46 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MRes.java 2005/07/25 20:20:44 1.2 @@ -9,6 +9,7 @@ import com.hp.hpl.jena.rdf.model.*; /** MP vocabulary class for namespace http://biomoby.org/RESOURCES/MOBY-S/Predicates# + * @deprecated */ public class MRes { From dwang at pub.open-bio.org Mon Jul 25 16:43:49 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 16:43:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252043.j6PKhn5P021416@pub.open-bio.org> dwang Mon Jul 25 16:43:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv21390/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: updated getRelationship and getObjectRelationship documentation to be concurrent with Mark's moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:20:16 1.8 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 20:43:49 1.9 @@ -589,6 +589,20 @@ die "getParentTerms not implemented in adaptor\n"; } +=head2 getObjectRelationships + + Title : getObjectRelationships + Usage : my $un = $API->getObjectRelationships(%args) + Function : Execute a query for objects that have relationships with other objects + Args : object1_id => Integer - a bind value for object1_id on an underlying SQL-based data source + Returns : listref of hashrefs: + [{relationship_type => String, + object_lsid => Integer, + object2_articlename => String}, ...] + one hashref for each relationship between two objects + Notes : relationship_type from object_term2term, object_lsid from object, and object2_articlename from object_term2term + +=cut # custom query subroutine for selecting from object_term2term and object tables # used in Moby::OntologyServer.pm->retrieveObject() sub getObjectRelationships{ @@ -598,13 +612,16 @@ =head2 getRelationship Title : getRelationship - Usage : my $un = $API->general_query(@args) - Function : Execute a query for a relationship between two tables on an underlying SQL-based data source - Returns : array of array-refs representing resulting rows - Args : String - direction in the ontology (eg. 'root') - String - name of the table ontology - Integer - a bind value for lsid - String - a bind value for relationship_type + Usage : my $un = $API->getRelationships(%args) + Function : Execute a query for a relationship between two ontologies + Args : direction => String - direction in the ontology (eg. 'root') + ontology => String - name of the table ontology + term => Integer - a bind value for lsid + relationship => String - a bind value for relationship_type + Returns : reference to array containing array-refs representing the result set: + [[Integer lsid, String relationship_type], ...] + each array-ref represents one row + Notes : Only returns distinct lsid from $ontology and relationship_type from $ontology_term2term =cut # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() @@ -613,6 +630,7 @@ die "getRelationship not implemented in adaptor\n"; } +# Not quite sure what this does... sub _checkURI { die "_checkURI not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Mon Jul 25 16:55:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 16:55:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252055.j6PKtZ7n021533@pub.open-bio.org> mwilkinson Mon Jul 25 16:55:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21506/MOBY Modified Files: OntologyServer.pm secondary_input.pm service_instance.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY OntologyServer.pm,1.54,1.55 secondary_input.pm,1.7,1.8 service_instance.pm,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 23:37:35 1.54 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 20:55:35 1.55 @@ -192,17 +192,10 @@ my $sth; return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); -# if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objecttype/)){ -# return (1, "external ontology", $term); -# } my $result; - if ( $term =~ /^urn\:lsid/ ) { - $result = $adaptor->query_object({object_lsid => $term}); - - } else { - $result = $adaptor->query_object({object_type => $term}); - - } + + $result = $adaptor->query_object(type => $term); + my $row = shift(@$result); my $lsid = $row->{object_lsid}; my $type = $row->{object_type}; @@ -271,12 +264,7 @@ : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } my $result; - if ( $args{'node'} =~ /^urn\:lsid/ ) { - - $result = $adaptor->query_object({object_lsid => $term}); - } else { - $result = $adaptor->query_object({object_type => $term}); - } + $result = $adaptor->query_object(type => $term); my $row = shift(@$result); my $lsid = $row->{object_lsid}; my $type = $row->{object_type}; @@ -320,7 +308,7 @@ ? $args{'node'} : $self->getObjectURI($term); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $result = $adaptor->query_object({object_lsid => $LSID}); + my $result = $adaptor->query_object(type => $LSID); my $row = shift(@$result); my $id = $row->{object_id}; my $type = $row->{object_type}; @@ -372,7 +360,7 @@ return ( 0, q{Object type $term cannot be resolved to an LSID}, "" ) unless $LSID; - my $result = $adaptor->query_object({object_lsid => $LSID}); + my $result = $adaptor->query_object(type => $LSID); my $row = shift(@$result); my $id = $row->{object_id}; my $lsid = $row->{object_lsid}; @@ -471,41 +459,20 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); + my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); - if ( $args{subject_node} =~ /^urn:lsid/ ) { - - my $result = $adaptor->query_object({object_lsid => $args{subject_node}}); - my $row = shift(@$result); - $subj_id = $row->{object_id}; - $subj_lsid = $row->{object_lsid}; - - } else { - my $result = $adaptor->query_object({object_type => $args{subject_node}}); - my $row = shift(@$result); - $subj_id = $row->{object_id}; - $subj_lsid = $row->{object_lsid}; - - } - return ( 0, - qq{Object type $args{subject_node} does not exist in the ontology}, - '' ) + my $result = $adaptor->query_object(type => $args{subject_node}); + my $row = shift(@$result); + $subj_id = $row->{object_id}; + $subj_lsid = $row->{object_lsid}; + return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) unless defined $subj_id; - if ( $args{object_node} =~ /^urn:lsid/ ) { - - my $result = $adaptor->query_object({object_lsid => $args{object_node}}); - my $row = shift(@$result); - $obj_id = $row->{object_id}; - $obj_lsid = $row->{object_lsid}; - - } else { - my $result = $adaptor->query_object({object_type => $args{object_node}}); - my $row = shift(@$result); - $obj_id = $row->{object_id}; - $obj_lsid = $row->{object_lsid}; - } - return ( 0, - qq{Object type $args{object_node} does not exist in the ontology}, - '' ) + + $result = $adaptor->query_object(type => $args{object_node}); + $row = shift(@$result); + $obj_id = $row->{object_id}; + $obj_lsid = $row->{object_lsid}; + return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_id; my $isa = $adaptor->query_object_term2term({object2_id => $subj_id}); @@ -967,7 +934,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return undef unless $URI =~ /urn\:lsid/; - my $result = $adaptor->query_object({object_lsid => $URI}); + my $result = $adaptor->query_object(type => $URI); my $row = shift(@$result); my $name = $row->{object_type}; @@ -1033,7 +1000,7 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_object({object_type => $term}); + my $result = $adaptor->query_object(type => $term); my $row = shift(@$result); my $id = $row->{object_lsid}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 19:53:35 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 20:55:35 1.8 @@ -115,13 +115,13 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; - my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, - {maximum_value => $self->maximum_value}, - {minimum_value => $self->minimum_value}, - {enum_value => $self->enum_value}, - {datatype => $self->datatype}, - {article_name => $self->article_name}, - {service_instance_lsid => $self->service_instance_id}); + my $insertid = $adaptor->insert_secondary_input(default_value => $self->default_value, + maximum_value => $self->maximum_value, + minimum_value => $self->minimum_value, + enum_value => $self->enum_value, + datatype => $self->datatype, + article_name => $self->article_name, + service_instance_lsid => $self->service_instance_id); return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:14:34 1.26 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:55:35 1.27 @@ -269,24 +269,24 @@ # by collecion ID... BAD BAD BAD $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); - $adaptor->delete_simple_output({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); foreach my $row (@$result) { my $id = $row->{collection_input_id}; - $adaptor->delete_simple_input({collection_input_id => $id}); + $adaptor->delete_simple_input(collection_input_id => $id); } $result = $adaptor->query_collection_output(service_instance_lsid => $self->lsid); foreach my $row (@$result) { my $id = $row->{collection_output_id}; - $adaptor->delete_simple_output({collection_output_id => $id}); + $adaptor->delete_simple_output(collection_output_id => $id); } $adaptor->delete_collection_input(service_instance_lsid => $self->lsid); $adaptor->delete_collection_output(service_instance_lsid => $self->lsid); - $adaptor->delete_secondary_input({service_instance_lsid => $self->lsid}); + $adaptor->delete_secondary_input(service_instance_lsid => $self->lsid); return 1; } From mwilkinson at pub.open-bio.org Mon Jul 25 16:55:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 16:55:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252055.j6PKtZHB021552@pub.open-bio.org> mwilkinson Mon Jul 25 16:55:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21506/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.32,1.33 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:14:35 1.32 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:55:35 1.33 @@ -302,9 +302,13 @@ my ($self, %args) = @_; my $dbh = $self->dbh; my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $statement = "delete from simple_input where service_instance_lsid = ?"; - - $dbh->do( $statement, undef,($siid)); + my ($collid) = $args{collection_input_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); if ($dbh->err){ return (1, $dbh->errstr); } @@ -317,7 +321,7 @@ my ($self, %args) = @_; my $dbh = $self->dbh; my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $result_ids = $adaptor->query_collection_input(service_instance_lsid => $self->lsid); + my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); my $statement = "delete from simple_input where service_instance_lsid = ?"; @@ -381,86 +385,88 @@ } +# pass service_instance_id or collection_output_id sub delete_simple_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from simple_output "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($collid) = $args{collection_output_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } +# pass service_instance_lsid sub query_secondary_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - secondary_input_id, - default_value, - maximum_value, - minimum_value, - enum_value, - datatype, - article_name, - service_instance_id - from secondary_input "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + secondary_input_id, + default_value, + maximum_value, + minimum_value, + enum_value, + datatype, + article_name, + service_instance_id + from secondary_input where service_instance_id = ?"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; } +# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid sub insert_secondary_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, - undef, - ( - get_value('default_value', @args), get_value('maximum_value', @args), - get_value('minimum_value', @args), get_value('enum_value', @args), - get_value('datatype', @args), get_value('article_name', @args), - get_value('service_instance_id', @args), - ) - ); - return $dbh->{mysql_insertid}; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, + undef, + ( + $args{'default_value'}, $args{'maximum_value'}, + $args{'minimum_value'}, $args{'enum_value'}, + $args{'datatype'}, $args{'article_name'},$siid) + ); + return $dbh->{mysql_insertid}; } +# pass service_instance_lsid sub delete_secondary_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from secondary_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from secondary_input where service_instance_lsid=?"; + + $dbh->do( $statement, undef, ($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } -# query subroutine will selects all rows from object table -sub query_object -{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - + +# receives argument "type", that may be either an LSID or a type term +sub query_object { + my ($self, %args) = @_; + my $type = $args{type}; + my $condition; + if ($type =~ /^urn\:lsid/){ + $condition = "where object_lsid = ?"; + } else { + $condition = "where object_type = ?"; + } my $statement = "select object_id, object_lsid, @@ -468,15 +474,10 @@ description, authority, contact_email - from object "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); + from object $condition"; + + my $dbh = $self->dbh; + my $result = do_query($dbh, $statement, ($type)); return $result; } From mwilkinson at pub.open-bio.org Mon Jul 25 17:13:51 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:13:51 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252113.j6PLDpmi021624@pub.open-bio.org> mwilkinson Mon Jul 25 17:13:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21605/MOBY Modified Files: OntologyServer.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY OntologyServer.pm,1.55,1.56 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 20:55:35 1.55 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:13:51 1.56 @@ -242,10 +242,6 @@ my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); - #node => $term, - #desc => $desc, - #authURI => $auth, - #contact => $email return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node", '' ) unless ( $args{node} ); return ( 0, "requires an authURI ", '' ) unless ( $args{authority} ); @@ -255,9 +251,6 @@ unless ( $args{description} ); my $term = $args{node}; -# if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objectclass/)){ # if it is an LSID, but not a MOBY LSID, than barf -# return (0, "can't create a term in a non-MOBY ontology!", $term); -# } my $LSID = ( $args{'node'} =~ /urn\:lsid/ ) ? $args{'node'} @@ -280,11 +273,11 @@ $args{contact_email} =~ s/^\s+(.*?)\s+$/$1/s; $args{authority} =~ s/^\s+(.*?)\s+$/$1/s; - my $insertid = $adaptor->insert_object({object_type => $args{'node'}}, - {object_lsid => $LSID}, - {description => $args{'description'}}, - {authority => $args{'authority'}}, - {contact_email => $args{'contact_email'}}); + my $insertid = $adaptor->insert_object(object_type => $args{'node'}, + object_lsid => $LSID, + description => $args{'description'}, + authority => $args{'authority'}, + contact_email => $args{'contact_email'}); unless ( $insertid ) { return ( 0, "Object creation failed for unknown reasons", '' ); } @@ -373,7 +366,7 @@ $lsid ); } - my ($err, $errstr) = $adaptor->delete_object({object_id => $id}); + my ($err, $errstr) = $adaptor->delete_object(type => $lsid); if ( $err ) { return ( 0, "Delete from Object Class table failed: $errstr", $lsid ); @@ -463,14 +456,12 @@ my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); my $result = $adaptor->query_object(type => $args{subject_node}); my $row = shift(@$result); - $subj_id = $row->{object_id}; $subj_lsid = $row->{object_lsid}; return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) unless defined $subj_id; $result = $adaptor->query_object(type => $args{object_node}); $row = shift(@$result); - $obj_id = $row->{object_id}; $obj_lsid = $row->{object_lsid}; return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_id; @@ -491,10 +482,10 @@ || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - my $insertid = $adaptor->insert_object_term2term({relationship_type => $rel_lsid}, - {object1_id => $subj_id}, - {object2_id => $obj_id}, - {object2_articlename => $args{articleName}}); + my $insertid = $adaptor->insert_object_term2term(relationship_type => $rel_lsid, + object1_id => $subj_lsid, + object2_id => $obj_lsid, + object2_articlename => $args{articleName}); if ($insertid ) { return ( 1, "Object relationsihp created successfully", '' ); } else { From mwilkinson at pub.open-bio.org Mon Jul 25 17:13:51 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:13:51 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252113.j6PLDppZ021643@pub.open-bio.org> mwilkinson Mon Jul 25 17:13:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21605/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.33,1.34 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:55:35 1.33 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:13:51 1.34 @@ -482,8 +482,9 @@ } # inserts a new tuple into object table +# pass object_type object_lsid description authority contact_email sub insert_object{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; $dbh->do("insert into object (object_type, @@ -493,24 +494,30 @@ contact_email) values (?,?,?,?,?)", undef, - (get_value('object_type', @args), - get_value('object_lsid', @args), - get_value('description', @args), - get_value('authority', @args), - get_value('contact_email', @args))); + $args{'object_type'}, + $args{'object_lsid'}, + $args{'description'}, + $args{'authority'}, + $args{'contact_email'}); my $id=$dbh->{mysql_insertid}; return $id; } +# pass 'type' which is either an LSID or a term sub delete_object{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........********** - # ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ******************** - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $term = $args{type}; + return 0 unless $term; + my $statement = "delete from object where "; + my $condition; + if ($term =~ /^urn\:lsid/){ + $condition = " object_lsid = ?"; + } else { + $condition = " object_type = ?"; + } + $statement = $statement.$condition; + $dbh->do( $statement,undef, ($term) ); if ($dbh->err){ return (1, $dbh->errstr); @@ -520,8 +527,14 @@ } } +# pass "type" here, should be an LSID, preferably... sub query_object_term2term{ - my ($self, @args) = @_; + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_object(type => $type); + my $row = shift(@$result); + my $id = $row->{object_id}; + return [{}] unless $id; my $dbh = $self->dbh; my $statement = "select @@ -530,28 +543,33 @@ object1_id, object2_id, object2_articlename - from object_term2term "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + from object_term2term where object2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; } +# pass object1_type, object2_type, object2_articlename, relationship_type sub insert_object_term2term{ - my ($self, @args) = @_; + my ($self, %args) = @_; + my $type1 = $args{object1_type}; + my $result = $self->query_object(type => $type1); + my $row = shift(@$result); + my $id1 = $row->{object_id}; + my $type2 = $args{object2_type}; + $result = $self->query_object(type => $type2); + $row = shift(@$result); + my $id2 = $row->{object_id}; + my $relationship_type = $args{relationship_type}; + my $object2_articlename = $args{object2_articlename}; + my $dbh = $self->dbh; $dbh->do( -q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, + q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, undef, - ( get_value('relationship_type', @args), - get_value('object1_id', @args), - get_value('object2_id', @args), - get_value('object2_articlename', @args) ) + $relationship_type, + $id1, + $id2, + $object2_articlename ); return $dbh->{mysql_insertid}; From dwang at pub.open-bio.org Mon Jul 25 17:30:12 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 17:30:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252130.j6PLUCER021718@pub.open-bio.org> dwang Mon Jul 25 17:30:12 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv21692/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: documentation added for getServiceNames() and getParentTerms() moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 20:43:49 1.9 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 21:30:12 1.10 @@ -579,11 +579,35 @@ die "getFromCollection not implemented in adaptor\n"; } +=head2 getServiceNames + + Title : getServiceNames + Usage : my $un = $API->getServiceNames(%args) + Function : Execute a query for all service names + Args : no inputs needed + Returns : listref of hashrefs: + [{authority_uri => String, + servicename => String}, ...] + one hashref for each service + +=cut # custom query subroutine for Moby::Central.pm->RetrieveServiceNames sub getServiceNames{ die "getServiceNames not implemented in adaptor\n"; } +=head2 getParentTerms + + Title : getParentTerms + Usage : my $un = $API->getParentTerms(%args) + Function : From a given term, traverse the ontology and get all parent terms + Args : relationship_type_id => Integer - a bind value for relationship_type_id on an underlying SQL-based data source + term => String - bindvalue for OntologyEntry.term + Returns : listref of hashrefs: + [{term => String}, ...] + one hashref for each parent + +=cut # custom query for Moby::Central.pm->_flatten sub getParentTerms{ die "getParentTerms not implemented in adaptor\n"; From mwilkinson at pub.open-bio.org Mon Jul 25 17:30:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:30:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252130.j6PLUc34021761@pub.open-bio.org> mwilkinson Mon Jul 25 17:30:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21742/MOBY Modified Files: OntologyServer.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY OntologyServer.pm,1.56,1.57 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:13:51 1.56 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:30:38 1.57 @@ -371,12 +371,6 @@ return ( 0, "Delete from Object Class table failed: $errstr", $lsid ); } - ($err, $errstr) = $adaptor->delete_object_term2term({object1_id => $id}); - if ( $err ) { - return ( 0, - "Delete from Object term2term table failed: $errstr", - $lsid ); - } return ( 1, "Object $term Deleted", $lsid ); } From mwilkinson at pub.open-bio.org Mon Jul 25 17:30:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:30:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252130.j6PLUc7i021781@pub.open-bio.org> mwilkinson Mon Jul 25 17:30:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21742/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.34,1.35 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:13:51 1.34 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:30:38 1.35 @@ -519,6 +519,7 @@ $statement = $statement.$condition; $dbh->do( $statement,undef, ($term) ); + $self->_delete_object_term2term(type => $term); if ($dbh->err){ return (1, $dbh->errstr); } @@ -575,15 +576,20 @@ return $dbh->{mysql_insertid}; } -sub delete_object_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; +# pass object 'type' as term or lsid +# this should be a private routine, not a public one. +# SHOULD NOT BE DOCUMENTED IN THE API +sub _delete_object_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $id = $row->object_id; - my $statement = "delete from object_term2term "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $dbh = $self->dbh; + my $statement = "delete from object_term2term where object1_id=?"; + $dbh->do( $statement,undef, ($id)); if ($dbh->err){ return (1, $dbh->errstr); From mwilkinson at pub.open-bio.org Mon Jul 25 17:52:25 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:52:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252152.j6PLqPUu021905@pub.open-bio.org> mwilkinson Mon Jul 25 17:52:25 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21863/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.35,1.36 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:30:38 1.35 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:52:25 1.36 @@ -599,19 +599,20 @@ } } +# pass servicename and authority_uri sub query_service_existence { my ($self, %args) = @_; my $dbh = $self->dbh; my $servicename = $args{'servicename'}; my $authURI = $args{'authority_uri'}; - my $id = $args{'authority_id'}; - unless ($id){ +# my $id = $args{'authority_id'}; # is it safe to remove this? better be! +# unless ($id){ my $result = $self->query_authority({authority_uri => $authURI}); return 0 unless @$result[0]; - $id = @$result[0]->{authority_id}; + my $id = @$result[0]->{authority_id}; return 0 unless $id; - } +# } my $statement = "select service_instance_id, category, @@ -624,10 +625,8 @@ description, signatureURL, lsid - from service_instance "; - my @bindvalues; - ($statement, @bindvalues) =_add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); - my $final = do_query($dbh, $statement, @bindvalues); + from service_instance where servicename = ? and authority_id = ?"; + my $final = do_query($dbh, $statement, ($servicename, $id)); if (@$final[0]){return 1} else {return 0} } @@ -676,33 +675,38 @@ } # custom query for Moby::Central.pm->findService() +# hmmmmmmm.... I'm not sure that this routine should exist... +# it is redundant to the routine above, if the routine above were executed +# multiple times. I think that is the more correct (though less efficient) +# way to go, since it is "scalable" to every possible underlying data source +# ********FIX change this later... sub match_service_type_uri{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - my $uri_list = get_value('service_type_uri', @args); + my $uri_list = $args{'service_type_uri'}; my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; - my @bindvalues = (); - + my @bindvalues = (); my $result = do_query($dbh, $statement, @bindvalues); return $result; } +# passs........ blah blah..... sub insert_service_instance { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, undef,( - get_value('category', @args), - get_value('servicename', @args), - get_value('service_type_uri', @args), - get_value('authority_id', @args), - get_value('url', @args), - get_value('contact_email', @args), - get_value('authoritative', @args), - get_value('description', @args), - get_value('signatureURL', @args), - get_value('lsid', @args))); + $args{'category'}, + $args{'servicename'}, + $args{'service_type_uri'}, + $args{'authority_id'}, + $args{'url'}, + $args{'contact_email'}, + $args{'authoritative'}, + $args{'description'}, + $args{'signatureURL'}, + $args{'lsid'})); my $id = $dbh->{mysql_insertid}; return $id; From mwilkinson at pub.open-bio.org Mon Jul 25 17:52:25 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:52:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252152.j6PLqP45021886@pub.open-bio.org> mwilkinson Mon Jul 25 17:52:25 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21863/MOBY Modified Files: Central.pm service_instance.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY Central.pm,1.182,1.183 service_instance.pm,1.27,1.28 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.182 retrieving revision 1.183 diff -u -r1.182 -r1.183 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 20:14:34 1.182 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 21:52:25 1.183 @@ -1926,9 +1926,11 @@ my (@children) = @{ $relationships{'urn:lsid:biomoby.org:servicerelation:isa'} }; $children_string .= ( join ',', map { "\'$_\'" } @children ); + #*******FIX this isn't very perlish... sending a comma-delimited string to a subroutine instead of an array + # need to change that one day soon! } $children_string =~ s/\,$//; - my $ids = _extract_ids($adaptor->match_service_type_uri({service_type_uri => $children_string})); + my $ids = _extract_ids($adaptor->match_service_type_uri(service_type_uri => $children_string)); $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); @@ -3243,6 +3245,11 @@ } sub _serviceListResponse { + + + # *********FIX + # this routine is using service instances by their database ID, rather than their LSID + # this is BAD BAD BAD $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:55:35 1.27 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 21:52:25 1.28 @@ -235,16 +235,16 @@ . $self->servicename; my $id = $self->adaptor->insert_service_instance( - {category => $self->category}, - {servicename => $self->servicename}, - {service_type_uri => $self->service_type_uri}, - {authority_id => $self->authority_id}, - {url => $self->url}, - {contact_email => $self->contact_email}, - {authoritative => $self->authoritative}, - {description => $self->description}, - {signatureURL => $self->signatureURL}, - {lsid => $service_lsid} + category => $self->category, + servicename => $self->servicename, + service_type_uri => $self->service_type_uri, + authority_id => $self->authority_id, + url => $self->url, + contact_email => $self->contact_email, + authoritative => $self->authoritative, + description => $self->description, + signatureURL => $self->signatureURL, + lsid => $service_lsid ); $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists From mwilkinson at pub.open-bio.org Mon Jul 25 18:10:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 18:10:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252210.j6PMAQdZ022027@pub.open-bio.org> mwilkinson Mon Jul 25 18:10:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22004/MOBY Modified Files: Central.pm service_instance.pm Log Message: how do you know when you have done too much Perl coding? When you start to say %args like a pirate... This change might break things badly- I need to do a join in a dynamically generated SQL statement. It looks OK now. mySQL is weird in that you have to specify table names in natural joins. UGH moby-live/Perl/MOBY Central.pm,1.183,1.184 service_instance.pm,1.28,1.29 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.183 retrieving revision 1.184 diff -u -r1.183 -r1.184 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 21:52:25 1.183 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 22:10:25 1.184 @@ -3259,6 +3259,10 @@ my $OSns = MOBY::OntologyServer->new( ontology => 'namespace' ); my $OSserv = MOBY::OntologyServer->new( ontology => 'service' ); + # *********FIX + # this routine is using service instances by their database ID, rather than their LSID + # this is BAD BAD BAD + foreach (@ids) { my $result = $adaptor->query_service_instance(service_instance_id => $_); my $row = shift(@$result); @@ -3266,7 +3270,7 @@ my $url = $row->{url}; my $servicename = $row->{servicename}; my $service_type_uri = $row->{service_type_uri}; - my $authority_id = $row->{authority_id}; + my $authority_uri = $row->{authority_uri}; my $desc = $row->{description}; my $authoritative = $row->{authoritative}; my $email = $row->{contact_email}; @@ -3281,10 +3285,10 @@ next unless ( $servicename && $authority_id ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); - $result = $adaptor->query_authority({authority_id => $authority_id}); - $row = shift(@$result); - my $authURI = $row->{authority_uri}; - $output .= "\t\n"; + #$result = $adaptor->query_authority({authority_id => $authority_id}); + #$row = shift(@$result); + #my $authURI = $row->{authority_uri}; + $output .= "\t\n"; $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; $output .= "\t$category\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 21:52:25 1.28 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 22:10:26 1.29 @@ -267,7 +267,7 @@ # the routines below know too much about the database (e.g. that # the delete_simple_input routines are broken into two parts - by LSID and # by collecion ID... BAD BAD BAD - $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); + $adaptor->delete_service_instance(service_instance_lsid => $self->lsid); $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); @@ -313,9 +313,8 @@ my $dbh = $self->dbh; my $authority; $CONFIG ||= MOBY::Config->new; - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - - my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $result = $adaptor->query_authority(authority_uri => $self->authority_uri); if ( @$result[0]) { my $row = shift(@$result); From mwilkinson at pub.open-bio.org Mon Jul 25 18:10:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 18:10:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252210.j6PMAQTW022046@pub.open-bio.org> mwilkinson Mon Jul 25 18:10:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22004/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: how do you know when you have done too much Perl coding? When you start to say %args like a pirate... This change might break things badly- I need to do a join in a dynamically generated SQL statement. It looks OK now. mySQL is weird in that you have to specify table names in natural joins. UGH moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.36,1.37 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:52:25 1.36 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 22:10:26 1.37 @@ -608,7 +608,7 @@ my $authURI = $args{'authority_uri'}; # my $id = $args{'authority_id'}; # is it safe to remove this? better be! # unless ($id){ - my $result = $self->query_authority({authority_uri => $authURI}); + my $result = $self->query_authority(authority_uri => $authURI); return 0 unless @$result[0]; my $id = @$result[0]->{authority_id}; return 0 unless $id; @@ -638,36 +638,36 @@ my $dbh = $self->dbh; my $authority_id; - if ($args{'authority_uri'}){ # need to transform URI to a row ID - my $result = $self->query_authority({authority_uri => $args{'authority_uri'}}); - return 0 unless @$result[0]; - $authority_id = @$result[0]->{authority_id}; - return 0 unless $authority_id; - } - delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table + #if ($args{'authority_uri'}){ # need to transform URI to a row ID + # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); + # return 0 unless @$result[0]; + # $authority_id = @$result[0]->{authority_id}; + # return 0 unless $authority_id; + #} + #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine } - if ($authority_id){ - push @args, ({authority_id => $authority_id}) ; - } else { - pop @args; # remove final "and" - } +# if ($authority_id){ +# push @args, ({authority_id => $authority_id}) ; +# } else { +# pop @args; # remove final "and" +# } my $statement = "select service_instance_id, category, servicename, service_type_uri, - authority_id, + authority.authority_uri, url, contact_email, authoritative, description, signatureURL, lsid - from service_instance "; + from service_instance left join authority on authority.authority_id "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); @@ -712,14 +712,12 @@ return $id; } +# pass service_instance_lsid sub delete_service_instance{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - my $statement = "delete from service_instance "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $statement = "delete from service_instance where lsid = ?"; + $dbh->do( $statement,undef, ($args{service_instance_lsid}) ); if ($dbh->err){ return (1, $dbh->errstr); } @@ -729,8 +727,10 @@ } # Selects all columns +# pass authority_uri sub query_authority { - my ($self, @args) = @_; + my ($self, %args) = @_; + my $authURI = $args{authority_uri}; my $dbh = $self->dbh; my $statement = "select @@ -738,15 +738,8 @@ authority_common_name, authority_uri, contact_email - from authority "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); + from authority where authority_uri = ?"; + my $result = do_query($dbh, $statement, ($authURI)); return $result; } From dwang at pub.open-bio.org Mon Jul 25 19:31:56 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 19:31:56 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252331.j6PNVuYl022253@pub.open-bio.org> dwang Mon Jul 25 19:31:56 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv22227/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 21:30:12 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:31:56 1.11 @@ -564,16 +564,69 @@ die "checkNamespaceUsedByService not implemented in adaptor\n"; } +=head2 checkKeywords + + Title : checkKeywords + Usage : my $un = $API->checkKeywords(%args) + Function : Execute a custom query for services with keywords in its description + Args : findme => hashref - hash contains an array of keywords + Returns : listref of hashrefs: + [{service_instance_id => Integer, + category => String, + servicename => String, + service_type_uri => String, + authority_id => Integer, + url => String, + contact_email => String, + authoritative => String, + description => String, + signatureURL => String, + lsid => Integer}, ...] + Each hash represents a service + Notes : the fact that it returns a service_instance_id is bad since this + is only useful to an SQL-based API... + +=cut # custom query routine for Moby::Central.pm -> findService() sub checkKeywords{ die "checkKeywords not implemented in adaptor\n"; } +=head2 getFromSimple + + Title : getFromSimple + Usage : my $un = $API->getFromSimple(%args) + Function : Execute a custom query for service ids in simple_input/output + Args : inout => String - to specify if input or output + ancestor_string => String - values that occur in object_type_uri + namespaceURIs => array-ref - reference to an array of namespace URIs + Returns : listref of hashrefs: + [{service_instance_id => Integer, + namespace_type_uris => String}, ...] + Notes : the fact that it returns a service_instance_id is bad since this + is only useful to an SQL-based API... + +=cut # custom query subroutine for Moby::Central.pm->_searchForSimple() sub getFromSimple{ die "getFromSimple not implemented in adaptor\n"; } +=head2 getFromCollection + + Title : getFromCollection + Usage : my $un = $API->getFromCollection(%args) + Function : Execute a custom query for service ids from collections + Args : inout => String - to specify if input or output + objectURI => String - value that binds to object_type_uri + namespaceURIs => array-ref - reference to an array of namespace URIs + Returns : listref of hashrefs: + [{service_instance_id => Integer, + namespace_type_uris => String}, ...] + Notes : the fact that it returns a service_instance_id is bad since this + is only useful to an SQL-based API... + +=cut # custom query subroutine for Moby::Central.pm->_searchForCollection() sub getFromCollection{ die "getFromCollection not implemented in adaptor\n"; From dwang at pub.open-bio.org Mon Jul 25 19:43:43 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 19:43:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252343.j6PNhhpC022305@pub.open-bio.org> dwang Mon Jul 25 19:43:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv22279/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:31:56 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:43:43 1.12 @@ -559,6 +559,19 @@ die "checkClassUsedByService not implemented in adaptor\n"; } +=head2 checkNamespaceUsedByService + + Title : checkNamespaceUsedByService + Usage : my $un = $API->checkNamespaceUsedByService(%args) + Function : Execute a custom query for namespaces that are used by some service + Args : namespace_type_uris => String - namespace_type_uris you are checking for + term => String - the type of the namespace + Returns : a list: + ($err, $errstr) + $err = 1 if namespace is used by a service, 0 otherwise + $errstr = contains the error message + +=cut # custom query routine for Moby::Central.pm -> deregisterNamespace() sub checkNamespaceUsedByService{ die "checkNamespaceUsedByService not implemented in adaptor\n"; From mwilkinson at pub.open-bio.org Mon Jul 25 19:45:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 19:45:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252345.j6PNjTPX022383@pub.open-bio.org> mwilkinson Mon Jul 25 19:45:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22352/MOBY Modified Files: Central.pm OntologyServer.pm authority.pm service_instance.pm Log Message: almost finished perlifying the adaptor code. moby-live/Perl/MOBY Central.pm,1.184,1.185 OntologyServer.pm,1.57,1.58 authority.pm,1.5,1.6 service_instance.pm,1.29,1.30 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.184 retrieving revision 1.185 diff -u -r1.184 -r1.185 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 22:10:25 1.184 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 23:45:29 1.185 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::Client::Central; +#use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -488,7 +488,7 @@ unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); + my $errormsg = $adaptor->check_object_usage(type => $existingURI); return &_error( "Object class $class is used by a service and may not be deregistered", "" @@ -745,7 +745,7 @@ sub deregisterServiceType { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'service' ); @@ -759,12 +759,12 @@ return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); - my $result = $adaptor->query_service({service_lsid => $existingURI}); + my $result = $adaptor->query_service_instance(service_type_uri => $existingURI); my $row = shift(@$result); - my $id = $row->{service_instance_id}; + my $lsid = $row->{lsid}; return &_error( "A registered service depends on this service type", "" ) - if ($id); + if ($lsid); my ( $success2, $message2, $deleteURI ) = $OntologyServer->deleteServiceType( term => $term ) ; # hopefully this situation will never happen! @@ -2475,11 +2475,11 @@ my ($pkg) = @_; my $dbh = MOBY::central_db_connection->new()->dbh; - my $result = $adaptor->getUniqueAuthorityURI(); + my $result = $adaptor->get_all_authorities(); my $providers = "\n"; foreach my $prov (@$result) { - $providers .= "\n"; + $providers .= "\n"; } $providers .= "\n"; return $providers; @@ -3282,12 +3282,9 @@ } $signatureURL ||= ""; - next unless ( $servicename && $authority_id ); + next unless ( $servicename && $authority_uri ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); - #$result = $adaptor->query_authority({authority_id => $authority_id}); - #$row = shift(@$result); - #my $authURI = $row->{authority_uri}; $output .= "\t\n"; $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:30:38 1.57 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 23:45:29 1.58 @@ -404,11 +404,13 @@ my $result; if ( $term =~ /^urn\:lsid/ ) { - $result = $adaptor->query_relationship({relationship_lsid => $term}, 'and', {ontology => $ont}); + $result = $adaptor->query_relationship( + type => $term, + ontology => $ont); } else { - $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ont}); + $result = $adaptor->query_relationship(type => $term, ontology => $ont); } my $row = shift(@$result); @@ -507,9 +509,8 @@ return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); - my $result = $adaptor->query_service({service_type => $args{subject_node}}); + my $result = $adaptor->query_service(type => $args{subject_node}); my $row = shift(@$result); - my $sbj_id = $row->{service_id}; my $sbj_lsid = $row->{service_lsid}; return ( @@ -517,9 +518,9 @@ qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ) - unless defined $sbj_id; + unless defined $sbj_lsid; - my $isa = $adaptor->query_service_term2term({service2_id => $sbj_id}); + my $isa = $adaptor->query_service_term2term(service2_id => $sbj_lsid); if ( scalar @$isa ) { return ( 0, @@ -527,28 +528,27 @@ $sbj_lsid ); } - $result = $adaptor->query_service({service_type => $args{object_node}}); + $result = $adaptor->query_service(type => $args{object_node}); $row = shift(@$result); - my $obj_id = $row->{service_id}; my $obj_lsid = $row->{service_lsid}; # get ID of the related service - defined $obj_id + defined $obj_lsid || return ( 0, qq{Service $args{object_node} does not exist in the service ontology}, '' ); my $OE = MOBY::OntologyServer->new( ontology => 'relationship' ); my ( $success, $desc, $rel_lsid ) = $OE->relationshipExists( - term => $args{relationship}, - ontology => 'service' ); + term => $args{relationship}, + ontology => 'service' ); ($success) || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - my $insertid = $adaptor->insert_service_term2term({relationship_type => $rel_lsid}, - {service1_id => $sbj_id}, - {service2_id => $obj_id}); + my $insertid = $adaptor->insert_service_term2term(relationship_type => $rel_lsid, + service1_type => $sbj_lsid, + service2_type => $obj_lsid); if ( $insertid ) { return ( 1, "Service relationship created successfully", '' ); } else { @@ -575,13 +575,7 @@ return ( 1, "external ontology", $term ); } my $result; - if ( $term =~ /^urn\:lsid/ ) { - $result = $adaptor->query_service({service_lsid => $term}); - - } else { - $result = $adaptor->query_service({service_type => $term}); - - } + $result = $adaptor->query_service(type => $term); my $row = shift(@$result); my $id = $row->{service_id}; my $type = $row->{service_type}; @@ -633,11 +627,11 @@ : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $insertid = $adaptor->insert_service({service_type => $args{'node'}}, - {service_lsid => $LSID}, - {description => $args{'description'}}, - {authority => $args{'authority'}}, - {contact_email => $args{'contact_email'}}); + my $insertid = $adaptor->insert_service(service_type => $args{'node'}, + service_lsid => $LSID, + description => $args{'description'}, + authority => $args{'authority'}, + contact_email => $args{'contact_email'}); unless ( $insertid ) { return ( 0, "Service creation failed for unknown reasons", '' ); @@ -668,30 +662,26 @@ $LSID = $term; } return ( - 0, -q{Service type $term cannot be resolved to an LSID in the MOBY ontologies}, - "" - ) - unless $LSID; + 0, q{Service type $term cannot be resolved to an LSID in the MOBY ontologies},"" + ) unless $LSID; - my $result = $adaptor->query_service({service_lsid => $LSID}); + my $result = $adaptor->query_service(type => $LSID); my $row = shift(@$result); - my $id = $row->{service_id}; my $lsid = $row->{service_lsid}; - if ( !defined $id ) { + if ( !defined $lsid ) { return ( 0, q{Service type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my $isa = $adaptor->query_service_term2term({service2_id => $id}); + my $isa = $adaptor->query_service_term2term(service2_id => $lsid); if ( scalar @$isa ) { return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } - my ($err, $errstr) = $adaptor->delete_service({service_id => $id}); + my ($err, $errstr) = $adaptor->delete_service(service_lsid => $lsid); if ( $err ) { return ( 0, "Delete from Service Type table failed: $errstr", @@ -729,13 +719,7 @@ return ( 1, "external ontology", $term ); } my $result; - if ( $term =~ /^urn:lsid:biomoby.org:namespacetype/ ) { - $result = $adaptor->query_namespace({namespace_lsid => $term}); - - } else { - $result = $adaptor->query_namespace({namespace_type => $term}); - - } + $result = $adaptor->query_namespace(type => $term); my $row = shift(@$result); my $id = $row->{namespace_id}; my $type = $row->{namespace_type}; @@ -787,11 +771,11 @@ : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $insertid = $adaptor->insert_namespace({namespace_type => $args{'node'}}, - {namespace_lsid => $LSID}, - {description => $args{'description'}}, - {authority => $args{'authority'}}, - {contact_email => $args{'contact_email'}}); + my $insertid = $adaptor->insert_namespace(namespace_type => $args{'node'}, + namespace_lsid => $LSID, + description => $args{'description'}, + authority => $args{'authority'}, + contact_email => $args{'contact_email'}); unless ( $insertid ) { return ( 0, "Namespace creation failed for unknown reasons", '' ); @@ -820,25 +804,24 @@ return ( 0, "cannot delete a term from an external ontology", $term ); } - my $result = $adaptor->query_namespace({namespace_lsid => $LSID}); + my $result = $adaptor->query_namespace(type => $LSID); my $row = shift(@$result); - my $id = $row->{namespace_id}; my $lsid = $row->{namespace_lsid}; - unless ($id) { + unless ($lsid) { return ( 0, q{Namespace type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my $isa = $adaptor->query_namespace_term2term({namespace2_id => $id}); + my $isa = $adaptor->query_namespace_term2term(type => $lsid); if ( scalar @$isa ) { return ( 0, qq{Namespace type $term has dependencies in the ontology}, $lsid ); } - my ($err, $errstr) = $adaptor->delete_namespace({namespace_id => $id}); + my ($err, $errstr) = $adaptor->delete_namespace(namespace_lsid => $lsid); if ( $err ) { return ( 0, "Delete from namespace table failed: $errstr", @@ -935,7 +918,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return undef unless $URI =~ /urn\:lsid/; - my $result = $adaptor->query_namespace({namespace_lsid => $URI}); + my $result = $adaptor->query_namespace(type => $URI); my $row = shift(@$result); my $name = $row->{namespace_type}; @@ -951,7 +934,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return undef unless $URI =~ /urn\:lsid/; - my $result = $adaptor->query_service({service_lsid => $URI}); + my $result = $adaptor->query_service(type => $URI); my $row = shift(@$result); my $name = $row->{service_type}; @@ -968,7 +951,7 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_service({service_type => $term}); + my $result = $adaptor->query_service(type => $term); my $row = shift(@$result); my $id = $row->{service_lsid}; @@ -1003,7 +986,7 @@ return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_namespace({namespace_type => $term}); + my $result = $adaptor->query_namespace(type => $term); my $row = shift(@$result); my $id = $row->{namespace_lsid}; @@ -1021,7 +1004,7 @@ return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ontology}); + my $result = $adaptor->query_relationship(type => $term, ontology => $ontology); my $row = shift(@$result); my $id = $row->{relationship_lsid}; @@ -1040,7 +1023,7 @@ my $ontology = $args{'ontology'}; my $OS = MOBY::OntologyServer->new( ontology => "relationship" ); - my $defs = $adaptor->query_relationship({ontology => $ontology}); + my $defs = $adaptor->query_relationship(ontology => $ontology); my %result; foreach ( @$defs ) { =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 17:25:54 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/25 23:45:29 1.6 @@ -43,7 +43,6 @@ #ATTRIBUTES my %_attr_data = # DEFAULT ACCESSIBILITY ( - authority_id => [ undef, 'read/write' ], authority_common_name => [ undef, 'read/write' ], authority_uri => [ undef, 'read/write' ], contact_email => [ undef, 'read/write' ], @@ -68,6 +67,9 @@ sub _standard_keys { keys %_attr_data; } + sub authority_id { + die "AUTHORITY_ID is deprecated. fix your code!\n"; + } } sub new { @@ -93,12 +95,14 @@ my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); my $row = shift(@$result); unless ($row) { - my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, - {authority_uri => $self->authority_uri}, - {contact_email => $self->contact_email}); - $self->authority_id( $insertid ); + my $insertid = $adaptor->insert_authority( + authority_common_name => $self->authority_common_name, + authority_uri => $self->authority_uri, + contact_email => $self->contact_email); } else { - $self->authority_id($row->{authority_id}); + $self->authority_common_name($row->{authority_common_name}); + $self->authority_uri($row->{authority_uri}); + $self->contact_email($row->{contact_email}); } return $self; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 22:10:26 1.29 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 23:45:29 1.30 @@ -238,7 +238,7 @@ category => $self->category, servicename => $self->servicename, service_type_uri => $self->service_type_uri, - authority_id => $self->authority_id, + authority_uri => $self->authority_uri, url => $self->url, contact_email => $self->contact_email, authoritative => $self->authoritative, @@ -246,6 +246,7 @@ signatureURL => $self->signatureURL, lsid => $service_lsid ); + return undef unless $id; $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists } else { # if it doesn't exist, and you havne't given me anyting I need to create it, then bail out @@ -315,17 +316,17 @@ $CONFIG ||= MOBY::Config->new; my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority(authority_uri => $self->authority_uri); - +#*********FIX we should nver need to know the authority ID in this level of code! if ( @$result[0]) { my $row = shift(@$result); - my $id = $row->{authority_id}; + #my $id = $row->{authority_id}; my $name = $row->{authority_common_name}; my $uri = $row->{authority_uri}; my $email = $row->{contact_email}; $authority = MOBY::authority->new( dbh => $self->dbh, - authority_id => $id, +# authority_id => $id, authority_uri => $uri, contact_email => $email, ); From mwilkinson at pub.open-bio.org Mon Jul 25 19:45:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 19:45:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252345.j6PNjTOc022402@pub.open-bio.org> mwilkinson Mon Jul 25 19:45:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv22352/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: almost finished perlifying the adaptor code. moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:43:43 1.12 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:45:29 1.13 @@ -467,8 +467,8 @@ die "query_authority not implemented in adaptor\n"; } -sub getUniqueAuthorityURI{ - die "getUniqueAuthorityURI not implemented in adaptor\n"; +sub get_all_authorities{ + die "get_all_authorities not implemented in adaptor\n"; } sub insert_authority{ @@ -555,8 +555,8 @@ } # custom query subroutine for Moby::Central.pm->deregisterObjectClass() -sub checkClassUsedByService{ - die "checkClassUsedByService not implemented in adaptor\n"; +sub check_object_usage{ + die "check_object_usage not implemented in adaptor\n"; } =head2 checkNamespaceUsedByService From mwilkinson at pub.open-bio.org Mon Jul 25 19:45:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 19:45:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252345.j6PNjT9B022423@pub.open-bio.org> mwilkinson Mon Jul 25 19:45:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22352/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: almost finished perlifying the adaptor code. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.37,1.38 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 22:10:26 1.37 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 23:45:29 1.38 @@ -1,1331 +1,1382 @@ -package MOBY::Adaptor::moby::queryapi::mysql; - -use strict; -use vars qw($AUTOLOAD @ISA); -use Carp; -use MOBY::Adaptor::moby::queryapi; -use DBI; -use DBD::mysql; - - at ISA = qw{MOBY::Adaptor::moby::queryapi}; # implements the interface - -{ - #Encapsulated class data - - #___________________________________________________________ - #ATTRIBUTES - my %_attr_data = # DEFAULT ACCESSIBILITY - ( - driver => ["DBI:mysql", 'read/write'], - dbh => [undef, 'read/write'], - - ); - - #_____________________________________________________________ - - # METHODS, to operate on encapsulated class data - - # Is a specified object attribute accessible in a given mode - sub _accessible { - my ($self, $attr, $mode) = @_; - $_attr_data{$attr}[1] =~ /$mode/ - } - - # Classwide default value for a specified object attribute - sub _default_for { - my ($self, $attr) = @_; - $_attr_data{$attr}[0]; - } - - # List of names of all specified object attributes - sub _standard_keys { - keys %_attr_data; - } - - sub driver { - my ($self, $arg) = @_; - $self->{driver} = $arg if defined $arg; - return $self->{driver}; - } - sub dbh { - my ($self, $arg) = @_; - $self->{dbh} = $arg if defined $arg; - return $self->{dbh}; - } - -} - -sub new { - my ($caller, %args) = @_; - my $self = $caller->SUPER::new(%args); - - my $caller_is_obj = ref($caller); - my $class = $caller_is_obj || $caller; - - foreach my $attrname ( $self->_standard_keys ) { - if (exists $args{$attrname} && defined $args{$attrname}) { - $self->{$attrname} = $args{$attrname} } - elsif ($caller_is_obj) { - $self->{$attrname} = $caller->{$attrname} } - else { - $self->{$attrname} = $self->_default_for($attrname) } - } - - return unless $self->driver; - my $driver = $self->driver; # inherited from the adaptorI (queryapi) - my $username = $self->username; - my $password = $self->password; - my $port = $self->port; - my $url = $self->url; - my $dbname = $self->dbname; - - my ($dsn) = "$driver:$dbname:$url:$port"; - my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; - - - ############################################################## - unless ($dbh) { - print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; - return undef; - } - - $self->dbh($dbh); - ############################################################# - - return undef unless $self->dbh; - return $self; - -} - -sub _add_condition{ - my ($statement, @params) = @_; - my @bindvalues = (); - my $condition = "where "; - - foreach my $param (@params ) - { - if (($param eq 'and') || ($param eq 'or')) - { - $condition .= $param . " "; - } - else - { - my %pair = %$param; - - for my $key (keys %pair) - { - if (defined $pair{$key}) - { - $condition .= $key . " = ? "; - push(@bindvalues, $pair{$key}); - } - else - { - $condition .= $key . " IS NULL " - } - } - } - } - $statement .= $condition; - return ($statement, @bindvalues); - } - -# preforms query but returns a reference to an array containing hash references -sub do_query{ - my ($dbh, $statement, @bindvalues) = @_; - my $sth = $dbh -> prepare($statement); - if (@bindvalues < 1) - { - $sth->execute; - } - else - { - $sth->execute(@bindvalues); - } - # returns an array of hash references - my $arrayHashRef = $sth->fetchall_arrayref({}); - return $arrayHashRef; -} - -sub get_value{ - my ($key, @params) = @_; - - foreach my $param (@params ) - { - my %pair = %$param; - for my $tmp (keys %pair) - { - if ($tmp eq $key){ - return $pair{$key}; - } - } - } -} - -sub _getSIIDFromLSID { - my ($self, $lsid) = @_; - my $dbh = $self->dbh; - my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); - $sth->execute($lsid); - my ($siid) = $sth->fetchrow_array(); - return $siid; -} - -# this should NOT retun a collection ID... needs more work... -# args passed in: service_lsid -sub query_collection_input{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $serv_lsid = $args{'service_lsid'}; - - my $statement = "select - collection_input_id, - article_name - from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; - my $result = do_query($dbh, $statement, [$serv_lsid]); - return $result; -} - -# args passed in: service_instance_lsid, article_name -sub insert_collection_input { - my ($self, %args) = @_; - my $article = $args{article_name}; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - - $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", - undef, $siid, $article); - my $id=$self->dbh->{mysql_insertid}; - return $id; -} - -# pass in service_instance_lsid -sub delete_collection_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - - my $statement = "delete from collection_input where service_instance_id = ?"; - $self->dbh->do( $statement, undef, $siid); - - if ($self->dbh->err){ - return (1, $self->dbh->errstr); - } - else{ - return 0; - } -} - -# pass service_instance_lsid -sub query_collection_output{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - my $statement = "select - collection_output_id, - article_name, - service_instance_id - from collection_output where service_instance_id = ? "; - my $result = do_query($dbh, $statement, [$siid]); - return $result; -} - -# pass service_instance_lsid, article_name -sub insert_collection_output { - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", - undef, $siid,$args{'article_name'}); - my $id=$self->dbh->{mysql_insertid}; - return $id; -} - -# pass argument service_instance_lsid -sub delete_collection_output{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - my $statement = "delete from collection_output where service_instance_id = ?"; - my @bindvalues = (); - $dbh->do( $statement, undef, ($siid)); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass service_instance_lsid -sub query_simple_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - my $statement = "select - simple_input_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id - from simple_input where service_instance_id = ? and collection_input_id IS NULL"; - my $result = do_query($dbh, $statement, ($siid)); - return $result; -} - -# pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id -sub insert_simple_input { - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - $dbh->do("insert into simple_input - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id) - values (?,?,?,?,?)", - undef, - $args{'object_type_uri'}, - $args{'namespace_type_uris'}, - $args{'article_name'}, - $siid, - $args{'collection_input_id'}); - my $id=$dbh->{mysql_insertid}; - return $id; -} - -# pass service_instance_lsid -sub delete_simple_input{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my ($collid) = $args{collection_input_id}; - my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); - $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); - - $siid && ($dbh->do( $statement1, undef,($siid))); - $collid && ($dbh->do($statement2, undef,($collid))); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub delete_inputs { # this should replace all other delete_*_input - my ($self, %args) = @_; - my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); - - my $statement = "delete from simple_input where service_instance_lsid = ?"; - - $dbh->do( $statement, undef,($siid)); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } - -} - -sub delete_output { # this should replace all other delete_*_output - -} - -# UGH this has to know too much bout the underlying database structure e.g. that one is null and other is full -# this problem is in MOBY::Central line 3321 3346 and 3374 -#****** FIX -# send service_instance_lsid, collection_input_id -sub query_simple_output{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $collid = $args{collection_input_id}; - my $dbh = $self->dbh; - - my $statement = "select - simple_output_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id - from simple_output where service_instance_id = ? and collection_input_id= ?"; - my $result = do_query($dbh, $statement, ($siid, $collid)); - return $result; -} - -# pass args service_instance_id and collection_output_id -sub insert_simple_output { - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - $dbh->do("insert into simple_output - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id) - values (?,?,?,?,?)", - undef,( - $args{'object_type_uri'}, - $args{'namespace_type_uris'}, - $args{'article_name'}, - $siid, - $args{'collection_output_id'})); - my $id=$dbh->{mysql_insertid}; - return $id; - -} - -# pass service_instance_id or collection_output_id -sub delete_simple_output{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my ($collid) = $args{collection_output_id}; - my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); - $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); - - $siid && ($dbh->do( $statement1, undef,($siid))); - $collid && ($dbh->do($statement2, undef,($collid))); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass service_instance_lsid -sub query_secondary_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - my $statement = "select - secondary_input_id, - default_value, - maximum_value, - minimum_value, - enum_value, - datatype, - article_name, - service_instance_id - from secondary_input where service_instance_id = ?"; - my $result = do_query($dbh, $statement, ($siid)); - return $result; -} - -# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid -sub insert_secondary_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, - undef, - ( - $args{'default_value'}, $args{'maximum_value'}, - $args{'minimum_value'}, $args{'enum_value'}, - $args{'datatype'}, $args{'article_name'},$siid) - ); - return $dbh->{mysql_insertid}; -} - -# pass service_instance_lsid -sub delete_secondary_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - my $statement = "delete from secondary_input where service_instance_lsid=?"; - - $dbh->do( $statement, undef, ($siid)); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - - -# receives argument "type", that may be either an LSID or a type term -sub query_object { - my ($self, %args) = @_; - my $type = $args{type}; - my $condition; - if ($type =~ /^urn\:lsid/){ - $condition = "where object_lsid = ?"; - } else { - $condition = "where object_type = ?"; - } - my $statement = "select - object_id, - object_lsid, - object_type, - description, - authority, - contact_email - from object $condition"; - - my $dbh = $self->dbh; - my $result = do_query($dbh, $statement, ($type)); - return $result; -} - -# inserts a new tuple into object table -# pass object_type object_lsid description authority contact_email -sub insert_object{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - $dbh->do("insert into object - (object_type, - object_lsid, - description, - authority, - contact_email) - values (?,?,?,?,?)", - undef, - $args{'object_type'}, - $args{'object_lsid'}, - $args{'description'}, - $args{'authority'}, - $args{'contact_email'}); - my $id=$dbh->{mysql_insertid}; - return $id; -} - -# pass 'type' which is either an LSID or a term -sub delete_object{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $term = $args{type}; - return 0 unless $term; - my $statement = "delete from object where "; - my $condition; - if ($term =~ /^urn\:lsid/){ - $condition = " object_lsid = ?"; - } else { - $condition = " object_type = ?"; - } - $statement = $statement.$condition; - $dbh->do( $statement,undef, ($term) ); - - $self->_delete_object_term2term(type => $term); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass "type" here, should be an LSID, preferably... -sub query_object_term2term{ - my ($self, %args) = @_; - my $type = $args{type}; - my $result = $self->query_object(type => $type); - my $row = shift(@$result); - my $id = $row->{object_id}; - return [{}] unless $id; - my $dbh = $self->dbh; - - my $statement = "select - assertion_id, - relationship_type, - object1_id, - object2_id, - object2_articlename - from object_term2term where object2_id = ?"; - my $result2 = do_query($dbh, $statement, ($id)); - return $result2; -} - -# pass object1_type, object2_type, object2_articlename, relationship_type -sub insert_object_term2term{ - my ($self, %args) = @_; - my $type1 = $args{object1_type}; - my $result = $self->query_object(type => $type1); - my $row = shift(@$result); - my $id1 = $row->{object_id}; - my $type2 = $args{object2_type}; - $result = $self->query_object(type => $type2); - $row = shift(@$result); - my $id2 = $row->{object_id}; - my $relationship_type = $args{relationship_type}; - my $object2_articlename = $args{object2_articlename}; - - my $dbh = $self->dbh; - $dbh->do( - q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, - undef, - $relationship_type, - $id1, - $id2, - $object2_articlename - ); - - return $dbh->{mysql_insertid}; -} - -# pass object 'type' as term or lsid -# this should be a private routine, not a public one. -# SHOULD NOT BE DOCUMENTED IN THE API -sub _delete_object_term2term{ - my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_object(type => $type); - my $row = shift @$result; - my $id = $row->object_id; - - my $dbh = $self->dbh; - my $statement = "delete from object_term2term where object1_id=?"; - $dbh->do( $statement,undef, ($id)); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass servicename and authority_uri -sub query_service_existence { - my ($self, %args) = @_; - my $dbh = $self->dbh; - - my $servicename = $args{'servicename'}; - my $authURI = $args{'authority_uri'}; -# my $id = $args{'authority_id'}; # is it safe to remove this? better be! -# unless ($id){ - my $result = $self->query_authority(authority_uri => $authURI); - return 0 unless @$result[0]; - my $id = @$result[0]->{authority_id}; - return 0 unless $id; -# } - my $statement = "select - service_instance_id, - category, - servicename, - service_type_uri, - authority_id, - url, - contact_email, - authoritative, - description, - signatureURL, - lsid - from service_instance where servicename = ? and authority_id = ?"; - my $final = do_query($dbh, $statement, ($servicename, $id)); - if (@$final[0]){return 1} else {return 0} - -} -# selects all the columns from service_instance table -# where is lsid? - -sub query_service_instance { - my ($self, %args) = @_; - my $dbh = $self->dbh; - - my $authority_id; - #if ($args{'authority_uri'}){ # need to transform URI to a row ID - # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); - # return 0 unless @$result[0]; - # $authority_id = @$result[0]->{authority_id}; - # return 0 unless $authority_id; - #} - #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table - my @args; - while (my ($k, $v) = each %args){ - push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine - } -# if ($authority_id){ -# push @args, ({authority_id => $authority_id}) ; -# } else { -# pop @args; # remove final "and" -# } - - my $statement = "select - service_instance_id, - category, - servicename, - service_type_uri, - authority.authority_uri, - url, - contact_email, - authoritative, - description, - signatureURL, - lsid - from service_instance left join authority on authority.authority_id "; - my @bindvalues; - ($statement, @bindvalues) =_add_condition($statement, @args); - my $final = do_query($dbh, $statement, @bindvalues); - return $final; -} - -# custom query for Moby::Central.pm->findService() -# hmmmmmmm.... I'm not sure that this routine should exist... -# it is redundant to the routine above, if the routine above were executed -# multiple times. I think that is the more correct (though less efficient) -# way to go, since it is "scalable" to every possible underlying data source -# ********FIX change this later... -sub match_service_type_uri{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $uri_list = $args{'service_type_uri'}; - my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; - my @bindvalues = (); - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# passs........ blah blah..... -sub insert_service_instance { - my ($self, %args) = @_; - my $dbh = $self->dbh; - - $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, - undef,( - $args{'category'}, - $args{'servicename'}, - $args{'service_type_uri'}, - $args{'authority_id'}, - $args{'url'}, - $args{'contact_email'}, - $args{'authoritative'}, - $args{'description'}, - $args{'signatureURL'}, - $args{'lsid'})); - - my $id = $dbh->{mysql_insertid}; - return $id; -} - -# pass service_instance_lsid -sub delete_service_instance{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from service_instance where lsid = ?"; - $dbh->do( $statement,undef, ($args{service_instance_lsid}) ); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# Selects all columns -# pass authority_uri -sub query_authority { - my ($self, %args) = @_; - my $authURI = $args{authority_uri}; - my $dbh = $self->dbh; - - my $statement = "select - authority_id, - authority_common_name, - authority_uri, - contact_email - from authority where authority_uri = ?"; - my $result = do_query($dbh, $statement, ($authURI)); - return $result; -} - -# custom query routine used in Moby::Central.pm -> retrieveServiceProviders() -sub getUniqueAuthorityURI{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select distinct authority_uri from authority"; - my @bindvalues = (); - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_authority{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do("insert into authority - (authority_common_name, - authority_uri, - contact_email) - values (?,?,?)", - undef, - (get_value('authority_common_name', @args), - get_value('authority_uri', @args), - get_value('contact_email', @args))); - my $id = $dbh->{mysql_insertid}; - return $id; -} - -sub query_service{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select - service_id, - service_lsid, - service_type, - description, - authority, - contact_email - from service "; - my @bindvalues = (); - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_service{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, - undef, - ( - get_value('service_type', @args), get_value('service_lsid', @args), get_value('description', @args), - get_value('authority', @args), get_value('contact_email', @args) - ) - ); - return $dbh->{mysql_insertid}; -} - -sub delete_service{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from service "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub query_service_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select - assertion_id, - relationship_type, - service1_id, - service2_id - from service_term2term "; - my @bindvalues = (); - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_service_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, - undef, - ( get_value('relationship_type', @args), get_value('service1_id', @args), get_value('service2_id', @args)) - ); - return $dbh->{mysql_insertid}; -} - -sub delete_service_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from service_term2term "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub query_relationship{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - relationship_id, - relationship_lsid, - relationship_type, - container, - description, - authority, - contact_email, - ontology - from relationship "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub query_namespace{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - namespace_id, - namespace_lsid, - namespace_type, - description, - authority, - contact_email - from namespace "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_namespace{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - get_value('namespace_type', @args), get_value('namespace_lsid', @args), get_value('description', @args), - get_value('authority', @args), get_value('contact_email', @args) - ) - ); - return $dbh->{mysql_insertid}; -} - -sub delete_namespace{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from namespace "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub query_namespace_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - assertion_id, - relationship_type, - namespace1_id, - namespace2_id - from namespace_term2term "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub delete_namespace_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from namespace_term2term "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# custom query subroutine for Moby::Central.pm->deregisterObjectClass() -sub checkClassUsedByService -{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $errorMsg = 1; - my $existingURI = get_value('object_type_uri', @args); - - my ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - return 0; -} - -# custom query routine for Moby::Central.pm -> deregisterNamespace() -sub checkNamespaceUsedByService{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $existingURI = get_value('namespace_type_uris', @args); - my $term = get_value('term', @args); - my $errstr; - - my $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - return (0, ""); -} - -# custom query routine for Moby::Central.pm -> findService() -sub checkKeywords{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $param = get_value('findme', @args); - my %findme = %$param; - my $searchstring; - - foreach my $kw ( @{ $findme{keywords} } ) { -# $debug && &_LOG("KEYWORD $kw\n"); - $kw =~ s/\*//g; - $kw = $dbh->quote("%$kw%"); - $searchstring .= " OR description like $kw "; - } - $searchstring =~ s/OR//; # remove just the first OR in the longer statement -# $debug && &_LOG("search $searchstring\n"); - - my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; - my @bindvalues = (); - - my $ids = do_query($dbh, $statement, @bindvalues); - return ($ids, $searchstring); -} - -# custom query subroutine for Moby::Central.pm->_searchForSimple() -sub getFromSimple{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $ancestor_string = get_value('ancestor_string', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); - - my $query = -"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " - ; # if service_instance_id is null then it must be a collection input. - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/OR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; - } - - my $result = do_query($dbh, $query, ()); - return $result; -} - -# custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $objectURI = get_value('objectURI', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); - - my $query = "select - c.service_instance_id, - s.namespace_type_uris - from - simple_$inout as s, - collection_$inout as c - where - s.collection_${inout}_id IS NOT NULL - AND s.collection_${inout}_id = c.collection_${inout}_id - AND object_type_uri = '$objectURI' "; - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/^\sOR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; # add the AND clause - } - - my $result = do_query($dbh, $query, ()); - return $result; -} - -# custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; - my @bindvalues = (); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# custom query for Moby::Central.pm->_flatten -sub getParentTerms{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $type_id = get_value('relationship_type_id', @args); - my $statement = " - select - OE1.term - from - OntologyEntry as OE1, - OntologyEntry as OE2, - Term2Term as TT - where - ontologyentry2_id = OE2.id - and ontologyentry1_id = OE1.id - and relationship_type_id = $type_id - and OE2.term = ?"; - - my @bindvalues = (); - push(@bindvalues, get_value('term', @args)); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# custom query subroutine for selecting from object_term2term and object tables -# used in Moby::OntologyServer.pm->retrieveObject() -sub getObjectRelationships{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - relationship_type, - object_lsid, - object2_articlename - from object_term2term, object - where object1_id = ? and object2_id = object_id"; - - my @bindvalues = (); - push(@bindvalues, get_value('object1_id', @args)); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() -# note: returns a reference to an array containing ARRAY references -sub getRelationship{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $direction = get_value('direction', @args); - my $ontology = get_value('ontology', @args); - my $term = get_value('term', @args); - my $relationship = get_value('relationship', @args); - my $defs; - - if ( $direction eq 'root' ) { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } else { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } - return $defs; -} - -sub _checkURI { - -# my $uri = "http://www.ics.uci.edu/pub/ietf/uri/#Related"; -#print "$1, $2, $3, $4, $5, $6, $7, $8, $9" if -# $uri =~ m{^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?}; -# -#The license for this recipe is available here. -# -#Discussion: -# -#If the match is successful, a URL such as -# -#http://www.ics.uci.edu/pub/ietf/uri/#Related -# -#will be broken down into the following group match variables: -# -#$1 = http: -#$2 = http -#$3 = //www.ics.uci.edu -#$4 = www.ics.uci.edu -#$5 = /pub/ietf/uri/ -#$6 = -#$7 = -#$8 = #Related -#$9 = Related -# -#In general, this regular expression breaks a URI down into the following parts, -#as defined in the RFC: -# -#scheme = $2 -#authority = $4 -#path = $5 -#query = $7 -#fragment = $9 - -} - -sub DESTROY {} - -1; +package MOBY::Adaptor::moby::queryapi::mysql; + +use strict; +use vars qw($AUTOLOAD @ISA); +use Carp; +use MOBY::Adaptor::moby::queryapi; +use DBI; +use DBD::mysql; + + at ISA = qw{MOBY::Adaptor::moby::queryapi}; # implements the interface + +{ + #Encapsulated class data + + #___________________________________________________________ + #ATTRIBUTES + my %_attr_data = # DEFAULT ACCESSIBILITY + ( + driver => ["DBI:mysql", 'read/write'], + dbh => [undef, 'read/write'], + + ); + + #_____________________________________________________________ + + # METHODS, to operate on encapsulated class data + + # Is a specified object attribute accessible in a given mode + sub _accessible { + my ($self, $attr, $mode) = @_; + $_attr_data{$attr}[1] =~ /$mode/ + } + + # Classwide default value for a specified object attribute + sub _default_for { + my ($self, $attr) = @_; + $_attr_data{$attr}[0]; + } + + # List of names of all specified object attributes + sub _standard_keys { + keys %_attr_data; + } + + sub driver { + my ($self, $arg) = @_; + $self->{driver} = $arg if defined $arg; + return $self->{driver}; + } + sub dbh { + my ($self, $arg) = @_; + $self->{dbh} = $arg if defined $arg; + return $self->{dbh}; + } + +} + +sub new { + my ($caller, %args) = @_; + my $self = $caller->SUPER::new(%args); + + my $caller_is_obj = ref($caller); + my $class = $caller_is_obj || $caller; + + foreach my $attrname ( $self->_standard_keys ) { + if (exists $args{$attrname} && defined $args{$attrname}) { + $self->{$attrname} = $args{$attrname} } + elsif ($caller_is_obj) { + $self->{$attrname} = $caller->{$attrname} } + else { + $self->{$attrname} = $self->_default_for($attrname) } + } + + return unless $self->driver; + my $driver = $self->driver; # inherited from the adaptorI (queryapi) + my $username = $self->username; + my $password = $self->password; + my $port = $self->port; + my $url = $self->url; + my $dbname = $self->dbname; + + my ($dsn) = "$driver:$dbname:$url:$port"; + my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; + + + ############################################################## + unless ($dbh) { + print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; + return undef; + } + + $self->dbh($dbh); + ############################################################# + + return undef unless $self->dbh; + return $self; + +} + +sub _add_condition{ + my ($statement, @params) = @_; + my @bindvalues = (); + my $condition = "where "; + + foreach my $param (@params ) + { + if (($param eq 'and') || ($param eq 'or')) + { + $condition .= $param . " "; + } + else + { + my %pair = %$param; + + for my $key (keys %pair) + { + if (defined $pair{$key}) + { + $condition .= $key . " = ? "; + push(@bindvalues, $pair{$key}); + } + else + { + $condition .= $key . " IS NULL " + } + } + } + } + $statement .= $condition; + return ($statement, @bindvalues); + } + +# preforms query but returns a reference to an array containing hash references +sub do_query{ + my ($dbh, $statement, @bindvalues) = @_; + my $sth = $dbh -> prepare($statement); + if (@bindvalues < 1) + { + $sth->execute; + } + else + { + $sth->execute(@bindvalues); + } + # returns an array of hash references + my $arrayHashRef = $sth->fetchall_arrayref({}); + return $arrayHashRef; +} + +sub get_value{ + my ($key, @params) = @_; + + foreach my $param (@params ) + { + my %pair = %$param; + for my $tmp (keys %pair) + { + if ($tmp eq $key){ + return $pair{$key}; + } + } + } +} + +sub _getSIIDFromLSID { + my ($self, $lsid) = @_; + my $dbh = $self->dbh; + my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); + $sth->execute($lsid); + my ($siid) = $sth->fetchrow_array(); + return $siid; +} + +# this should NOT retun a collection ID... needs more work... +# args passed in: service_lsid +sub query_collection_input{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $serv_lsid = $args{'service_lsid'}; + + my $statement = "select + collection_input_id, + article_name + from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; + my $result = do_query($dbh, $statement, [$serv_lsid]); + return $result; +} + +# args passed in: service_instance_lsid, article_name +sub insert_collection_input { + my ($self, %args) = @_; + my $article = $args{article_name}; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", + undef, $siid, $article); + my $id=$self->dbh->{mysql_insertid}; + return $id; +} + +# pass in service_instance_lsid +sub delete_collection_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + my $statement = "delete from collection_input where service_instance_id = ?"; + $self->dbh->do( $statement, undef, $siid); + + if ($self->dbh->err){ + return (1, $self->dbh->errstr); + } + else{ + return 0; + } +} + +# pass service_instance_lsid +sub query_collection_output{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + collection_output_id, + article_name, + service_instance_id + from collection_output where service_instance_id = ? "; + my $result = do_query($dbh, $statement, [$siid]); + return $result; +} + +# pass service_instance_lsid, article_name +sub insert_collection_output { + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", + undef, $siid,$args{'article_name'}); + my $id=$self->dbh->{mysql_insertid}; + return $id; +} + +# pass argument service_instance_lsid +sub delete_collection_output{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from collection_output where service_instance_id = ?"; + my @bindvalues = (); + $dbh->do( $statement, undef, ($siid)); + + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass service_instance_lsid +sub query_simple_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + simple_input_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id + from simple_input where service_instance_id = ? and collection_input_id IS NULL"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; +} + +# pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id +sub insert_simple_input { + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do("insert into simple_input + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id) + values (?,?,?,?,?)", + undef, + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_input_id'}); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +# pass service_instance_lsid +sub delete_simple_input{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($collid) = $args{collection_input_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +sub delete_inputs { # this should replace all other delete_*_input + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); + + my $statement = "delete from simple_input where service_instance_lsid = ?"; + + $dbh->do( $statement, undef,($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } + +} + +sub delete_output { # this should replace all other delete_*_output + +} + +# UGH this has to know too much bout the underlying database structure e.g. that one is null and other is full +# this problem is in MOBY::Central line 3321 3346 and 3374 +#****** FIX +# send service_instance_lsid, collection_input_id +sub query_simple_output{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $collid = $args{collection_input_id}; + my $dbh = $self->dbh; + + my $statement = "select + simple_output_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id + from simple_output where service_instance_id = ? and collection_input_id= ?"; + my $result = do_query($dbh, $statement, ($siid, $collid)); + return $result; +} + +# pass args service_instance_id and collection_output_id +sub insert_simple_output { + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + $dbh->do("insert into simple_output + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id) + values (?,?,?,?,?)", + undef,( + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_output_id'})); + my $id=$dbh->{mysql_insertid}; + return $id; + +} + +# pass service_instance_id or collection_output_id +sub delete_simple_output{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($collid) = $args{collection_output_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass service_instance_lsid +sub query_secondary_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + secondary_input_id, + default_value, + maximum_value, + minimum_value, + enum_value, + datatype, + article_name, + service_instance_id + from secondary_input where service_instance_id = ?"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; +} + +# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid +sub insert_secondary_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, + undef, + ( + $args{'default_value'}, $args{'maximum_value'}, + $args{'minimum_value'}, $args{'enum_value'}, + $args{'datatype'}, $args{'article_name'},$siid) + ); + return $dbh->{mysql_insertid}; +} + +# pass service_instance_lsid +sub delete_secondary_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from secondary_input where service_instance_lsid=?"; + + $dbh->do( $statement, undef, ($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + + +# receives argument "type", that may be either an LSID or a type term +sub query_object { + my ($self, %args) = @_; + my $type = $args{type}; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where object_lsid = ?"; + } elsif ($type) { + $condition = "where object_type = ?"; + } + my $statement = "select + object_id, + object_lsid, + object_type, + description, + authority, + contact_email + from object $condition"; + + my $dbh = $self->dbh; + my $result = do_query($dbh, $statement, ($type)); + return $result; +} + +# inserts a new tuple into object table +# pass object_type object_lsid description authority contact_email +sub insert_object{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into object + (object_type, + object_lsid, + description, + authority, + contact_email) + values (?,?,?,?,?)", + undef, + $args{'object_type'}, + $args{'object_lsid'}, + $args{'description'}, + $args{'authority'}, + $args{'contact_email'}); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +# pass 'type' which is either an LSID or a term +sub delete_object{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $term = $args{type}; + return 0 unless $term; + my $statement = "delete from object where "; + my $condition; + if ($term =~ /^urn\:lsid/){ + $condition = " object_lsid = ?"; + } else { + $condition = " object_type = ?"; + } + $statement = $statement.$condition; + $dbh->do( $statement,undef, ($term) ); + + $self->_delete_object_term2term(type => $term); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass "type" here, should be an LSID, preferably... +sub query_object_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_object(type => $type); + my $row = shift(@$result); + my $id = $row->{object_id}; + return [{}] unless $id; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + object1_id, + object2_id, + object2_articlename + from object_term2term where object2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; +} + +# pass object1_type, object2_type, object2_articlename, relationship_type +sub insert_object_term2term{ + my ($self, %args) = @_; + my $type1 = $args{object1_type}; + my $result = $self->query_object(type => $type1); + my $row = shift(@$result); + my $id1 = $row->{object_id}; + my $type2 = $args{object2_type}; + $result = $self->query_object(type => $type2); + $row = shift(@$result); + my $id2 = $row->{object_id}; + my $relationship_type = $args{relationship_type}; + my $object2_articlename = $args{object2_articlename}; + + my $dbh = $self->dbh; + $dbh->do( + q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, + undef, + $relationship_type, + $id1, + $id2, + $object2_articlename + ); + + return $dbh->{mysql_insertid}; +} + +# pass object 'type' as term or lsid +# this should be a private routine, not a public one. +# SHOULD NOT BE DOCUMENTED IN THE API +sub _delete_object_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $id = $row->object_id; + + my $dbh = $self->dbh; + my $statement = "delete from object_term2term where object1_id=?"; + $dbh->do( $statement,undef, ($id)); + + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass servicename and authority_uri +sub query_service_existence { + my ($self, %args) = @_; + my $dbh = $self->dbh; + + my $servicename = $args{'servicename'}; + my $authURI = $args{'authority_uri'}; + my $result = $self->_query_authority(authority_uri => $authURI); + return 0 unless @$result[0]; + my $id = @$result[0]->{authority_id}; + return 0 unless $id; + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority_id, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance where servicename = ? and authority_id = ?"; + my $final = do_query($dbh, $statement, ($servicename, $id)); + if (@$final[0]){return 1} else {return 0} + +} +# selects all the columns from service_instance table +# PAY ATTENTION to what this returns. Not auth_id but auth_uri!! +sub query_service_instance { + my ($self, %args) = @_; + my $dbh = $self->dbh; + + #my $authority_id; + #if ($args{'authority_uri'}){ # need to transform URI to a row ID + # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); + # return 0 unless @$result[0]; + # $authority_id = @$result[0]->{authority_id}; + # return 0 unless $authority_id; + #} + #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table + my @args; + while (my ($k, $v) = each %args){ + push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine + } +# if ($authority_id){ +# push @args, ({authority_id => $authority_id}) ; +# } else { +# pop @args; # remove final "and" +# } + + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority.authority_uri, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance left join authority on authority.authority_id "; + my @bindvalues; + ($statement, @bindvalues) =_add_condition($statement, @args); + my $final = do_query($dbh, $statement, @bindvalues); + return $final; +} + +# custom query for Moby::Central.pm->findService() +# hmmmmmmm.... I'm not sure that this routine should exist... +# it is redundant to the routine above, if the routine above were executed +# multiple times. I think that is the more correct (though less efficient) +# way to go, since it is "scalable" to every possible underlying data source +# ********FIX change this later... +sub match_service_type_uri{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $uri_list = $args{'service_type_uri'}; + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; + my @bindvalues = (); + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# passs........ blah blah..... +sub insert_service_instance { + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $authority_id; + if ($args{'authority_uri'}){ # need to transform URI to a row ID + my $result = $self->_query_authority(authority_uri => $args{'authority_uri'}); + return undef unless @$result[0]; + $authority_id = @$result[0]->{authority_id}; + return undef unless $authority_id; + } + + $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, + undef,( + $args{'category'}, + $args{'servicename'}, + $args{'service_type_uri'}, + $authority_id, + $args{'url'}, + $args{'contact_email'}, + $args{'authoritative'}, + $args{'description'}, + $args{'signatureURL'}, + $args{'lsid'})); + + my $id = $dbh->{mysql_insertid}; + return $id; +} + +# pass service_instance_lsid +sub delete_service_instance{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service_instance where lsid = ?"; + $dbh->do( $statement,undef, ($args{service_instance_lsid}) ); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# Selects all columns EXCEPT authority_id +# pass authority_uri +sub query_authority { + my ($self, %args) = @_; + my $authURI = $args{authority_uri}; + my $dbh = $self->dbh; + + my $statement = "select + authority_common_name, + authority_uri, + contact_email + from authority where authority_uri = ?"; + my $result = do_query($dbh, $statement, ($authURI)); + return $result; +} + +# Selects all columns including authority_id +# pass authority_uri. NOTE THAT THIS IS A PRIVATE ROUTINE +# SHOULD NOT BE DOCUMENTED IN THE API +sub _query_authority { + my ($self, %args) = @_; + my $authURI = $args{authority_uri}; + my $dbh = $self->dbh; + + my $statement = "select + authority_common_name, + authority_uri, + authority_id, + contact_email + from authority where authority_uri = ?"; + my $result = do_query($dbh, $statement, ($authURI)); + return $result; +} + +# custom query routine used in Moby::Central.pm -> retrieveServiceProviders() +# no args passed +sub get_all_authorities{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select distinct authority_uri from authority"; + my @bindvalues = (); + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# pass authority_common_name, authority_uri, contact_email, return ID of some sort +sub insert_authority{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into authority + (authority_common_name, + authority_uri, + contact_email) + values (?,?,?)", + undef, + ($args{'authority_common_name'}, + $args{'authority_uri'}, + $args{'contact_email'})); + my $id = $dbh->{mysql_insertid}; + return $id; +} + +# pass service_type, as term or LSID +sub query_service{ + my ($self, %args) = @_; + my $type = $args{type}; + return [{}] unless $type; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where service_lsid = ?"; + } elsif ($type) { + $condition = "where service_type = ?"; + } + + my $dbh = $self->dbh; + my $statement = "select + service_id, + service_lsid, + service_type, + description, + authority, + contact_email + from service $condition"; + my $result = do_query($dbh, $statement, ($type)); + return $result; +} + +# pass in .... +sub insert_service{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do(q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, + undef, + ( + $args{'service_type'}, $args{'service_lsid'}, $args{'description'}, + $args{'authority'}, $args{'contact_email'} + ) + ); + return $dbh->{mysql_insertid}; +} + +# pass in service type as LSID (service_lsid) +sub delete_service{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service where service_lsid = ?"; + $dbh->do( $statement, undef, ($args{service_lsid})); + $self->_delete_service_term2term; + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +sub query_service_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_service(type => $type); + my $row = shift(@$result); + my $id = $row->{service_id}; + return [{}] unless $id; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + service1_id, + service2_id, + from service_term2term where service2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; +} + +#pass relationshiptype, servce1_type, service2_type +sub insert_service_term2term{ + my ($self, %args) = @_; + my $type1 = $args{service1_type}; + my $result = $self->query_service(type => $type1); + my $row = shift(@$result); + my $id1 = $row->{service_id}; + my $type2 = $args{service2_type}; + $result = $self->query_service(type => $type2); + $row = shift(@$result); + my $id2 = $row->{service_id}; + my $relationship_type = $args{relationship_type}; + + my $dbh = $self->dbh; + $dbh->do(q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, + undef, + ($relationship_type, + $id1, + $id2) + ); + + return $dbh->{mysql_insertid}; +} + + +# NOTE THAT THIS IS A PRIVATE FUNCTION AND SHOULD +# NOT BE DOCUMENTED IN THE API. +sub _delete_service_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_service(type => $type); + my $row = shift @$result; + my $id = $row->service_id; + + my $dbh = $self->dbh; + my $statement = "delete from service_term2term where service1_id=?"; + $dbh->do( $statement,undef, ($id)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + + +sub query_relationship{ + my ($self, %args) = @_; + my $type = $args{type}; + return [{}] unless $type; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where relationship_lsid = ? and "; + } elsif ($type) { + $condition = "where relationship_type = ? and"; + } + my $ont = $args{ontology}; + + my $dbh = $self->dbh; + + my $statement = "select + relationship_id, + relationship_lsid, + relationship_type, + container, + description, + authority, + contact_email, + ontology + from relationship where $condition ontology = ?"; + + if ($type){ + return do_query($dbh, $statement, ($type, $ont)); + } else { + return do_query($dbh, $statement, ($ont)); + } +} + +sub query_namespace{ + my ($self, %args) = @_; + my $type = $args{type}; + return [{}] unless $type; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where namespace_lsid = ? and "; + } elsif ($type) { + $condition = "where namespace_type = ? and"; + } + my $dbh = $self->dbh; + + my $statement = "select + namespace_id, + namespace_lsid, + namespace_type, + description, + authority, + contact_email + from namespace $condition"; + my $result = do_query($dbh, $statement, ($type)); + return $result; +} + + +sub insert_namespace{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do(q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, + undef, + ( + $args{'namespace_type'}, $args{'namespace_lsid'},$args{'description'},$args{'authority'},$args{'contact_email'} + ) + ); + return $dbh->{mysql_insertid}; +} + +# pass namesapce_lsid +sub delete_namespace{ + my ($self, %args) = @_; + my $lsid = $args{namespace_lsid}; + my $dbh = $self->dbh; + my $statement = "delete from namespace where namespace_lsid = ?"; + $dbh->do( $statement, undef, ($lsid)); + $self->_delete_namespace_term2term; + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +sub query_namespace_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_namespace(type => $type); + my $row = shift(@$result); + my $id = $row->{namespace_id}; + return [{}] unless $id; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + namespace1_id, + namespace2_id, + from namespace_term2term where namespace2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; +} + +# PRIVATE, NOT PART OF API! +sub _delete_namespace_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_namespace(type => $type); + my $row = shift @$result; + my $id = $row->namespace_id; + + my $dbh = $self->dbh; + my $statement = "delete from namespace_term2term where namespace1_id=?"; + $dbh->do( $statement,undef, ($id)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# custom query subroutine for Moby::Central.pm->deregisterObjectClass() +# MARK LOOK HERE!!! +# may need two different adaptors for this... one for the object table and other for the mobycentral table +sub check_object_usage{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $errorMsg = 1; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_namespace(type => $type); + my $row = shift @$result; + my $lsid = $row->{object_lsid}; + + my ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + return 0; +} + +# custom query routine for Moby::Central.pm -> deregisterNamespace() +sub checkNamespaceUsedByService{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $existingURI = get_value('namespace_type_uris', @args); + my $term = get_value('term', @args); + my $errstr; + + my $sth = $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + $sth = $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + return (0, ""); +} + +# custom query routine for Moby::Central.pm -> findService() +sub checkKeywords{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $param = get_value('findme', @args); + my %findme = %$param; + my $searchstring; + + foreach my $kw ( @{ $findme{keywords} } ) { +# $debug && &_LOG("KEYWORD $kw\n"); + $kw =~ s/\*//g; + $kw = $dbh->quote("%$kw%"); + $searchstring .= " OR description like $kw "; + } + $searchstring =~ s/OR//; # remove just the first OR in the longer statement +# $debug && &_LOG("search $searchstring\n"); + + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; + my @bindvalues = (); + + my $ids = do_query($dbh, $statement, @bindvalues); + return ($ids, $searchstring); +} + +# custom query subroutine for Moby::Central.pm->_searchForSimple() +sub getFromSimple{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $ancestor_string = get_value('ancestor_string', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = +"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " + ; # if service_instance_id is null then it must be a collection input. + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/OR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; + } + + my $result = do_query($dbh, $query, ()); + return $result; +} + +# custom query subroutine for Moby::Central.pm->_searchForCollection() +sub getFromCollection{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $objectURI = get_value('objectURI', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = "select + c.service_instance_id, + s.namespace_type_uris + from + simple_$inout as s, + collection_$inout as c + where + s.collection_${inout}_id IS NOT NULL + AND s.collection_${inout}_id = c.collection_${inout}_id + AND object_type_uri = '$objectURI' "; + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/^\sOR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; # add the AND clause + } + + my $result = do_query($dbh, $query, ()); + return $result; +} + +# custom query subroutine for Moby::Central.pm->RetrieveServiceNames +sub getServiceNames{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; + my @bindvalues = (); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query for Moby::Central.pm->_flatten +sub getParentTerms{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $type_id = get_value('relationship_type_id', @args); + my $statement = " + select + OE1.term + from + OntologyEntry as OE1, + OntologyEntry as OE2, + Term2Term as TT + where + ontologyentry2_id = OE2.id + and ontologyentry1_id = OE1.id + and relationship_type_id = $type_id + and OE2.term = ?"; + + my @bindvalues = (); + push(@bindvalues, get_value('term', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query subroutine for selecting from object_term2term and object tables +# used in Moby::OntologyServer.pm->retrieveObject() +sub getObjectRelationships{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + relationship_type, + object_lsid, + object2_articlename + from object_term2term, object + where object1_id = ? and object2_id = object_id"; + + my @bindvalues = (); + push(@bindvalues, get_value('object1_id', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() +# note: returns a reference to an array containing ARRAY references +sub getRelationship{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $direction = get_value('direction', @args); + my $ontology = get_value('ontology', @args); + my $term = get_value('term', @args); + my $relationship = get_value('relationship', @args); + my $defs; + + if ( $direction eq 'root' ) { + unless ( defined $relationship ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $term ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + } + } else { + unless ( defined $relationship ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s2.${ontology}_lsid = ?", undef, $term ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + } + } + return $defs; +} + +sub _checkURI { + +# my $uri = "http://www.ics.uci.edu/pub/ietf/uri/#Related"; +#print "$1, $2, $3, $4, $5, $6, $7, $8, $9" if +# $uri =~ m{^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?}; +# +#The license for this recipe is available here. +# +#Discussion: +# +#If the match is successful, a URL such as +# +#http://www.ics.uci.edu/pub/ietf/uri/#Related +# +#will be broken down into the following group match variables: +# +#$1 = http: +#$2 = http +#$3 = //www.ics.uci.edu +#$4 = www.ics.uci.edu +#$5 = /pub/ietf/uri/ +#$6 = +#$7 = +#$8 = #Related +#$9 = Related +# +#In general, this regular expression breaks a URI down into the following parts, +#as defined in the RFC: +# +#scheme = $2 +#authority = $4 +#path = $5 +#query = $7 +#fragment = $9 + +} + +sub DESTROY {} + +1; From dwang at pub.open-bio.org Tue Jul 26 01:19:37 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue, 26 Jul 2005 01:19:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507260519.j6Q5JbK8023025@pub.open-bio.org> dwang Tue Jul 26 01:19:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv23000/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added some more comments. some subroutines are still under modification, so holding out for now... don't quite understand what $type is. moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:45:29 1.13 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 05:19:37 1.14 @@ -539,21 +539,36 @@ die "delete_namespace not implemented in adaptor\n"; } -# +=head2 query_namespace_term2term + + Title : query_namespace_term2term + Usage : my $un = $API->query_namespace_term2term(%args) + Function : Execute a query for namespaces_term2term + Args : type => String - namespace_type you are checking for + Returns : listref of hashrefs: + [{assertion_id => Integer, + relationship_type => String, + namespace1_id => Integer, + namespace2_id => Integer}] + +=cut # namespace_term2term table functions -# sub query_namespace_term2term{ die "query_namespace_term2term not implemented in adaptor\n"; } +# does not exist in mysql api, should this be removed? sub insert_namespace_term2term{ die "insert_namespace_term2term not implemented in adaptor\n"; } -sub delete_namespace_term2term{ +# changed to a private subroutine in mysql +# I guess this subroutine should be removed from here? +sub _delete_namespace_term2term{ die "delete_namespace_term2term not implemented in adaptor\n"; } +# still incomplete... # custom query subroutine for Moby::Central.pm->deregisterObjectClass() sub check_object_usage{ die "check_object_usage not implemented in adaptor\n"; From kawas at pub.open-bio.org Tue Jul 26 10:50:21 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 10:50:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261450.j6QEoL06024431@pub.open-bio.org> kawas Tue Jul 26 10:50:21 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv24406/org/biomoby/registry/rdfagent/vocabulary Modified Files: MP.java Log Message: updated the predicate vocabulary again to include the newest predicates. moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary MP.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/07/25 20:20:44 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/07/26 14:50:21 1.6 @@ -52,6 +52,10 @@ public static final Property Simple = m.getProperty(uri + "Simple" ) ; public static final Property Collection = m.getProperty(uri + "Collection" ) ; public static final Property Secondary = m.getProperty(uri + "Secondary" ) ; + /* new predicates */ + public static final Property sampleInputData = m.getProperty(uri + "sampleInputData"); + public static final Property sampleOutputData = m.getProperty(uri + "sampleOutputData"); + public static final Property approvedBy = m.getProperty(uri + "approvedBy"); } From kawas at pub.open-bio.org Tue Jul 26 10:53:12 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 10:53:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261453.j6QErCXa024480@pub.open-bio.org> kawas Tue Jul 26 10:53:12 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv24455/org/biomoby/client/rdf/vocabulary Modified Files: Predicates.java Log Message: *removed the ability to modify the domain of a URI. *added 3 predicates that were added to biomoby.org/RESOURCES/MOBY-S/Predicates. *removed any MobyResources.java references that existed directly or indirectly. moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary Predicates.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/20 17:42:31 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/26 14:53:12 1.5 @@ -14,46 +14,50 @@ /** * @author Eddie Kawas - *

Created for - *

This class was created to ... + *

Created for the BioMoby project. + *

This class was created to represent the RDF predicate vocabulary in BioMoby under the namespace mobyPred. *

For questions, comments, or bugs *

email me at edward.kawas at gmail.com */ public class Predicates { private final static Properties properties = MobyProperties.PROPERTIES(); - protected final static String uri = "http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#"; + protected final static String uri = "http://biomoby.org/RESOURCES/MOBY-S/Predicates#"; private final static Model _model = ModelFactory.createDefaultModel();; - public static final Property category = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#category"); - public static final Property isa = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#isa"); - public static final Property has = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#has"); - public static final Property hasa = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#hasa"); - public static final Property articleName = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#articleName"); - public static final Property article_name = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#article_name"); - public static final Property namespace_type = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#namespace_type"); - public static final Property object_type = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#object_type"); - public static final Property input = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#input"); - public static final Property output = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#output"); - public static final Property consumes = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#consumes"); - public static final Property produces = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#produces"); - public static final Property performs_task = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#performs_task"); - public static final Property comment = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#comment"); - public static final Property label = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#label"); - public static final Property default_value = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#default_value"); - public static final Property datatype = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#datatype"); - public static final Property max = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#max"); - public static final Property min = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#min"); - public static final Property enumeration = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#enum"); - public static final Property SimpleArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SimpleArticle"); - public static final Property CollectionArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#CollectionArticle"); - public static final Property SecondaryArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SecondaryArticle"); - public static final Property SignatureURL = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SignatureURL"); - public static final Property authoritative = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#authoritative"); - public static final Property ofType = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#ofType"); + public static final Property category = _model.getProperty(uri + "category"); + public static final Property isa = _model.getProperty(uri + "isa"); + public static final Property has = _model.getProperty(uri + "has"); + public static final Property hasa = _model.getProperty(uri + "hasa"); + public static final Property articleName = _model.getProperty(uri + "articleName"); + public static final Property article_name = _model.getProperty(uri + "article_name"); + public static final Property namespace_type = _model.getProperty(uri + "namespace_type"); + public static final Property object_type = _model.getProperty(uri + "object_type"); + public static final Property input = _model.getProperty(uri + "input"); + public static final Property output = _model.getProperty(uri + "output"); + public static final Property consumes = _model.getProperty(uri + "consumes"); + public static final Property produces = _model.getProperty(uri + "produces"); + public static final Property performs_task = _model.getProperty(uri + "performs_task"); + public static final Property comment = _model.getProperty(uri + "comment"); + public static final Property label = _model.getProperty(uri + "label"); + public static final Property default_value = _model.getProperty(uri + "default_value"); + public static final Property datatype = _model.getProperty(uri + "datatype"); + public static final Property max = _model.getProperty(uri + "max"); + public static final Property min = _model.getProperty(uri + "min"); + public static final Property enumeration = _model.getProperty(uri + "enum"); + public static final Property SimpleArticle = _model.getProperty(uri + "SimpleArticle"); + public static final Property CollectionArticle = _model.getProperty(uri + "CollectionArticle"); + public static final Property SecondaryArticle = _model.getProperty(uri + "SecondaryArticle"); + public static final Property SignatureURL = _model.getProperty(uri + "SignatureURL"); + public static final Property authoritative = _model.getProperty(uri + "authoritative"); + public static final Property ofType = _model.getProperty(uri + "ofType"); /* moved from MobyResources.java */ - public static final Property Simple = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Simple"); - public static final Property Secondary = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Secondary"); - public static final Property Collection = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Collection"); + public static final Property Simple = _model.getProperty(uri + "Simple"); + public static final Property Secondary = _model.getProperty(uri + "Secondary"); + public static final Property Collection = _model.getProperty(uri + "Collection"); + /* new predicates */ + public static final Property sampleInputData = _model.getProperty(uri + "sampleInputData"); + public static final Property sampleOutputData = _model.getProperty(uri + "sampleOutputData"); + public static final Property approvedBy = _model.getProperty(uri + "approvedBy"); public final static String getURI() { return uri; From kawas at pub.open-bio.org Tue Jul 26 10:56:19 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 10:56:19 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261456.j6QEuJsG024549@pub.open-bio.org> kawas Tue Jul 26 10:56:19 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder In directory pub.open-bio.org:/tmp/cvs-serv24524/org/biomoby/client/rdf/builder Modified Files: RDFConfigure.java Log Message: updated the old references to the MobyResources.java predicate vocabulary to the 'new' one. moby-live/Java/src/main/org/biomoby/client/rdf/builder RDFConfigure.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/07/19 15:54:02 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/07/26 14:56:19 1.4 @@ -7,7 +7,6 @@ import java.net.URL; import java.util.Properties; -import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; import org.biomoby.registry.properties.MobyProperties; @@ -268,10 +267,10 @@ // get the statements for the item in the bag // could be a bag or just a simple StmtIterator sit = item.listProperties(); - if (item.hasProperty(RDF.type, MobyResources.SimpleArticle)) { + if (item.hasProperty(RDF.type, Predicates.Simple)) { // create a simple article Resource _li = rdf.createResource(); - _li.addProperty(RDF.type, MobyResources.SimpleArticle); + _li.addProperty(RDF.type, Predicates.Simple); _li.addProperty(Predicates.object_type, model .getResource(item.getProperty( Predicates.object_type).getObject() @@ -295,11 +294,11 @@ _bag.add(_li); } if (item.hasProperty(RDF.type, - MobyResources.SecondaryArticle)) { + Predicates.Secondary)) { // create a secondary article Resource _li = rdf.createResource(); _li.addProperty(RDF.type, - MobyResources.SecondaryArticle); + Predicates.Secondary); boolean isInt = false; if (item.hasProperty(Predicates.datatype)) { String str = item.getProperty(Predicates.datatype) @@ -369,11 +368,11 @@ // add the item to the bag _bag.add(_li); } - if (item.hasProperty(RDF.type, MobyResources.Collection)) { + if (item.hasProperty(RDF.type, Predicates.Collection)) { // create a collection Bag collectionBag = rdf.createBag(); collectionBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); collectionBag.addProperty(RDFS.subClassOf, RDF.Bag); if (item.hasProperty(Predicates.articleName)) { String str = item.getProperty( @@ -392,7 +391,7 @@ Resource simple = cStatement.getResource(); Resource _li = rdf.createResource(); _li.addProperty(RDF.type, - MobyResources.SimpleArticle); + Predicates.Simple); _li.addProperty(Predicates.object_type, model .getResource(simple.getProperty( Predicates.object_type) From kawas at pub.open-bio.org Tue Jul 26 10:57:07 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 10:57:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261457.j6QEv7vx024603@pub.open-bio.org> kawas Tue Jul 26 10:57:07 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder In directory pub.open-bio.org:/tmp/cvs-serv24578/org/biomoby/client/rdf/builder Modified Files: ServiceInstanceRDF.java Log Message: updated the old references to the MobyResources.java predicate vocabulary to the 'new' one. moby-live/Java/src/main/org/biomoby/client/rdf/builder ServiceInstanceRDF.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/07/19 15:54:02 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/07/26 14:57:07 1.6 @@ -10,7 +10,6 @@ import java.util.regex.Pattern; import org.biomoby.client.CentralImpl; -import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; import org.biomoby.registry.properties.MobyProperties; import org.biomoby.shared.Central; @@ -270,7 +269,6 @@ map.put("serviceInstances", SI); map.put("mobyNamespace", NS); map.put("mobyService", SRV); - map.put("moby", MobyResources.getURI()); model.setNsPrefixes(map); for (int i = 0; i < services.length; i++) { @@ -336,7 +334,7 @@ } innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) primaryInputs[j]) .getName().equals("")) innerBag @@ -388,7 +386,7 @@ _li.addProperty(Predicates.datatype, model .createTypedLiteral(data.getDataType())); _li.addProperty(RDF.type, - MobyResources.SecondaryArticle); + Predicates.Secondary); if (data.getDataType().equals("Integer")) { _li .addProperty(Predicates.min, model @@ -440,7 +438,7 @@ produceBag = model.createBag(); innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) outputs[j]) .getName().equals("")) innerBag @@ -511,7 +509,7 @@ */ private final static Resource createSimpleDataItem(Model model, MobyPrimaryDataSimple simpleData, Resource _li) { - _li.addProperty(RDF.type, MobyResources.SimpleArticle); + _li.addProperty(RDF.type, Predicates.Simple); _li.addProperty(Predicates.object_type, model.createResource(OBJ + simpleData.getDataType().getName())); if (!simpleData.getName().equals("")) From dwang at pub.open-bio.org Tue Jul 26 17:55:28 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue, 26 Jul 2005 17:55:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262155.j6QLtSwa025501@pub.open-bio.org> dwang Tue Jul 26 17:55:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv25475/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: slightly more comments moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 05:19:37 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 21:55:28 1.15 @@ -527,14 +527,53 @@ # # namespace table functions # +=head2 query_namespace + + Title : insert_namespace + Usage : my $un = $API->insert_namespace(%args) + Function : Deletes a namespace instance from the database + Args : namespace_type => String, + namespace_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer mysql_insertid + Notes : the fact that it returns a mysql_insertid is bad since this + is only useful to an SQL-based API... +=cut sub query_namespace{ die "query_namespace not implemented in adaptor\n"; } +=head2 insert_namespace + + Title : insert_namespace + Usage : my $un = $API->insert_namespace(%args) + Function : Deletes a namespace instance from the database + Args : namespace_type => String, + namespace_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer mysql_insertid + Notes : the fact that it returns a mysql_insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_namespace{ die "insert_namespace not implemented in adaptor\n"; } +=head2 delete_namespace + + Title : delete_namespace + Usage : my $un = $API->delete_namespace(%args) + Function : Deletes a namespace instance from the database + Args : namespace_lsid => String - lsid identifying a particular namespace + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 otherwise + $errstr = String error message if there was an error + +=cut sub delete_namespace{ die "delete_namespace not implemented in adaptor\n"; } @@ -609,7 +648,7 @@ authoritative => String, description => String, signatureURL => String, - lsid => Integer}, ...] + lsid => String}, ...] Each hash represents a service Notes : the fact that it returns a service_instance_id is bad since this is only useful to an SQL-based API... @@ -702,7 +741,7 @@ Args : object1_id => Integer - a bind value for object1_id on an underlying SQL-based data source Returns : listref of hashrefs: [{relationship_type => String, - object_lsid => Integer, + object_lsid => String, object2_articlename => String}, ...] one hashref for each relationship between two objects Notes : relationship_type from object_term2term, object_lsid from object, and object2_articlename from object_term2term @@ -721,10 +760,10 @@ Function : Execute a query for a relationship between two ontologies Args : direction => String - direction in the ontology (eg. 'root') ontology => String - name of the table ontology - term => Integer - a bind value for lsid + term => String - a bind value for lsid relationship => String - a bind value for relationship_type Returns : reference to array containing array-refs representing the result set: - [[Integer lsid, String relationship_type], ...] + [[String lsid, String relationship_type], ...] each array-ref represents one row Notes : Only returns distinct lsid from $ontology and relationship_type from $ontology_term2term From mwilkinson at pub.open-bio.org Tue Jul 26 19:32:48 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:32:48 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262332.j6QNWm8K025808@pub.open-bio.org> mwilkinson Tue Jul 26 19:32:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv25766/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: adaptor API should now be complete moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 21:55:28 1.15 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 23:32:48 1.16 @@ -613,10 +613,10 @@ die "check_object_usage not implemented in adaptor\n"; } -=head2 checkNamespaceUsedByService +=head2 check_namespace_usage - Title : checkNamespaceUsedByService - Usage : my $un = $API->checkNamespaceUsedByService(%args) + Title : check_namespace_usage + Usage : my $un = $API->check_namespace_usage(%args) Function : Execute a custom query for namespaces that are used by some service Args : namespace_type_uris => String - namespace_type_uris you are checking for term => String - the type of the namespace @@ -627,16 +627,16 @@ =cut # custom query routine for Moby::Central.pm -> deregisterNamespace() -sub checkNamespaceUsedByService{ - die "checkNamespaceUsedByService not implemented in adaptor\n"; +sub check_namespace_usage{ + die "check_namespace_usage not implemented in adaptor\n"; } -=head2 checkKeywords +=head2 check_keywords - Title : checkKeywords - Usage : my $un = $API->checkKeywords(%args) + Title : check_keywords + Usage : my $un = $API->check_keywords(%args) Function : Execute a custom query for services with keywords in its description - Args : findme => hashref - hash contains an array of keywords + Args : keywords => listref (of keywords) Returns : listref of hashrefs: [{service_instance_id => Integer, category => String, @@ -652,17 +652,18 @@ Each hash represents a service Notes : the fact that it returns a service_instance_id is bad since this is only useful to an SQL-based API... - + Keywords are assumed to be joined by "OR" for the query + =cut # custom query routine for Moby::Central.pm -> findService() -sub checkKeywords{ - die "checkKeywords not implemented in adaptor\n"; +sub check_keywords{ + die "check_keywords not implemented in adaptor\n"; } -=head2 getFromSimple +=head2 find_by_simple - Title : getFromSimple - Usage : my $un = $API->getFromSimple(%args) + Title : find_by_simple + Usage : my $un = $API->find_by_simple(%args) Function : Execute a custom query for service ids in simple_input/output Args : inout => String - to specify if input or output ancestor_string => String - values that occur in object_type_uri @@ -675,14 +676,14 @@ =cut # custom query subroutine for Moby::Central.pm->_searchForSimple() -sub getFromSimple{ - die "getFromSimple not implemented in adaptor\n"; +sub find_by_simple{ + die "find_by_simple not implemented in adaptor\n"; } -=head2 getFromCollection +=head2 find_by_collection - Title : getFromCollection - Usage : my $un = $API->getFromCollection(%args) + Title : find_by_collection + Usage : my $un = $API->find_by_collection(%args) Function : Execute a custom query for service ids from collections Args : inout => String - to specify if input or output objectURI => String - value that binds to object_type_uri @@ -695,14 +696,14 @@ =cut # custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection{ - die "getFromCollection not implemented in adaptor\n"; +sub find_by_collection{ + die "find_by_collection not implemented in adaptor\n"; } -=head2 getServiceNames +=head2 get_service_names - Title : getServiceNames - Usage : my $un = $API->getServiceNames(%args) + Title : get_service_names + Usage : my $un = $API->get_service_names(%args) Function : Execute a query for all service names Args : no inputs needed Returns : listref of hashrefs: @@ -712,14 +713,14 @@ =cut # custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames{ - die "getServiceNames not implemented in adaptor\n"; +sub get_service_names{ + die "get_service_names not implemented in adaptor\n"; } -=head2 getParentTerms +=head2 get_parent_terms - Title : getParentTerms - Usage : my $un = $API->getParentTerms(%args) + Title : get_parent_terms + Usage : my $un = $API->get_parent_terms(%args) Function : From a given term, traverse the ontology and get all parent terms Args : relationship_type_id => Integer - a bind value for relationship_type_id on an underlying SQL-based data source term => String - bindvalue for OntologyEntry.term @@ -729,16 +730,16 @@ =cut # custom query for Moby::Central.pm->_flatten -sub getParentTerms{ - die "getParentTerms not implemented in adaptor\n"; +sub get_parent_terms{ + die "get_parent_terms not implemented in adaptor\n"; } -=head2 getObjectRelationships +=head2 get_object_relationships - Title : getObjectRelationships - Usage : my $un = $API->getObjectRelationships(%args) + Title : get_object_relationships + Usage : my $un = $API->get_object_relationships(%args) Function : Execute a query for objects that have relationships with other objects - Args : object1_id => Integer - a bind value for object1_id on an underlying SQL-based data source + Args : type => String - either an object name or LSID Returns : listref of hashrefs: [{relationship_type => String, object_lsid => String, @@ -749,14 +750,14 @@ =cut # custom query subroutine for selecting from object_term2term and object tables # used in Moby::OntologyServer.pm->retrieveObject() -sub getObjectRelationships{ - die "getObjectRelationships not implemented in adaptor\n"; +sub get_object_relationships{ + die "get_object_relationships not implemented in adaptor\n"; } -=head2 getRelationship +=head2 get_relationship - Title : getRelationship - Usage : my $un = $API->getRelationships(%args) + Title : get_relationship + Usage : my $un = $API->get_relationship(%args) Function : Execute a query for a relationship between two ontologies Args : direction => String - direction in the ontology (eg. 'root') ontology => String - name of the table ontology @@ -770,8 +771,8 @@ =cut # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references -sub getRelationship{ - die "getRelationship not implemented in adaptor\n"; +sub get_relationship{ + die "get_relationship not implemented in adaptor\n"; } # Not quite sure what this does... From mwilkinson at pub.open-bio.org Tue Jul 26 19:32:48 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:32:48 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262332.j6QNWmYu025789@pub.open-bio.org> mwilkinson Tue Jul 26 19:32:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25766/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: adaptor API should now be complete moby-live/Perl/MOBY Central.pm,1.185,1.186 OntologyServer.pm,1.58,1.59 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.185 retrieving revision 1.186 diff -u -r1.185 -r1.186 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 23:45:29 1.185 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/26 23:32:48 1.186 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -#use MOBY::Client::Central; +use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -1996,12 +1996,10 @@ $debug && _LOG("Keywords added; criterion count is now $criterion_count\n"); - my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + my ($ids) = $adaptor->check_keywords(keywords => \@{$findme{keywords}}); $ids = _extract_ids($ids); # this is the hash-list that comes back from do_query unless ( scalar @{$ids} ) { - $debug - && &_LOG("found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n"); return &_serviceListResponse( $dbh, undef ); } $debug @@ -2193,7 +2191,9 @@ } $ancestor_string =~ s/\,$//; - my $result = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->find_by_simple(inout => $inout, + ancestor_string => $ancestor_string, + namespaceURIs => $namespaceURIs); my @valid_services; @@ -2244,7 +2244,9 @@ my ( $objectURI, $namespaceURIs ) = &_extractObjectTypesAndNamespaces($simple); - my $result = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->find_by_collection(inout => $inout, + objectURI => $objectURI, + namespaceURIs => $namespaceURIs); foreach my $row (@$result ) { # get the service instance ID and the namespaces that matched @@ -2508,7 +2510,7 @@ my ($pkg) = shift; my $dbh = MOBY::central_db_connection->new()->dbh; - my $result = $adaptor->getServiceNames(); + my $result = $adaptor->get_service_names(); my $names = "\n"; foreach my $row (@$result) { $names .= "\n"; @@ -2948,7 +2950,8 @@ # and flatten it into a list of parent terms my ( $dbh, $type, $term, $seen ) = @_; - my $result = $adaptor->getParentTerms({relationship_type_id => $type}, {term => $term}); + my $result = $adaptor->get_parent_terms(relationship_type_id => $type, + term => $term); foreach my $row (@$result) { my $term = $row->{term}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 23:45:29 1.58 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/26 23:32:48 1.59 @@ -303,18 +303,18 @@ unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } my $result = $adaptor->query_object(type => $LSID); my $row = shift(@$result); - my $id = $row->{object_id}; +# my $id = $row->{object_id}; my $type = $row->{object_type}; my $lsid = $row->{object_lsid}; my $desc = $row->{description}; my $auth = $row->{authority}; my $contact = $row->{contact_email}; - unless ($id) { return ( 0, "Object doesn't exist in ontology", "" ) } + unless ($lsid) { return ( 0, "Object doesn't exist in ontology", "" ) } # my $OS = MOBY::OntologyServer->new(ontology => "relationship"); - $result = $adaptor->getObjectRelationships({object1_id => $id}); + $result = $adaptor->get_object_relationships(type => $lsid); my %rel; foreach my $row (@$result) { @@ -688,7 +688,7 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_service_term2term({service1_id => $id}); + ($err, $errstr) = $adaptor->delete_service_term2term(service1_id => $lsid); if ( $err ) { return ( @@ -828,7 +828,7 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_namespace_term2term({namespace1_id => $id}); + ($err, $errstr) = $adaptor->delete_namespace_term2term(namespace1_id => $lsid); if ( $err ) { return ( @@ -1088,7 +1088,10 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => $datasource ); my $defs; # query returns a reference to an array containing array references - $defs = $adaptor->getRelationship({direction => $direction}, {ontology => $ontology}, {term => $term}, {relationship => $relationship}); + $defs = $adaptor->get_relationship(direction => $direction, + ontology => $ontology, + term => $term, + relationship => $relationship); # a very long piece of SQL statements have been refactored into Moby::Adaptor::moby::queryapi::mysql.pm return $defs; } From mwilkinson at pub.open-bio.org Tue Jul 26 19:32:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:32:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262332.j6QNWnDT025829@pub.open-bio.org> mwilkinson Tue Jul 26 19:32:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25766/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: adaptor API should now be complete moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.38,1.39 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 23:45:29 1.38 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:32:48 1.39 @@ -1034,40 +1034,37 @@ return 0; } } - -# custom query subroutine for Moby::Central.pm->deregisterObjectClass() -# MARK LOOK HERE!!! -# may need two different adaptors for this... one for the object table and other for the mobycentral table +# pass type as LSID or term sub check_object_usage{ my ($self, %args) = @_; my $dbh = $self->dbh; my $errorMsg = 1; my $type = $args{type}; return 0 unless $type; - my $result = $self->query_namespace(type => $type); + my $result = $self->query_object(type => $type); my $row = shift @$result; my $lsid = $row->{object_lsid}; my ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); @@ -1076,15 +1073,17 @@ } # custom query routine for Moby::Central.pm -> deregisterNamespace() -sub checkNamespaceUsedByService{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $existingURI = get_value('namespace_type_uris', @args); - my $term = get_value('term', @args); - my $errstr; +sub check_namespace_usage{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $errorMsg = 1; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_namespace(type => $type); + my $row = shift @$result; + my $lsid = $row->{namespace_lsid}; - my $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" + my $sth = $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$lsid')" ); $sth->execute; @@ -1092,89 +1091,84 @@ my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } - $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" + $sth = $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$lsid')" ); $sth->execute; while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" + $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$lsid')" ); $sth->execute; while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" + $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$lsid')" ); $sth->execute; while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } return (0, ""); } # custom query routine for Moby::Central.pm -> findService() -sub checkKeywords{ - my ($self, @args) = @_; +sub check_keywords{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $param = get_value('findme', @args); + my $param = $args{keywords}; + return ([{}]) unless (ref($param) =~ /ARRAY/); + my @keywords = @$param; my %findme = %$param; my $searchstring; - - foreach my $kw ( @{ $findme{keywords} } ) { -# $debug && &_LOG("KEYWORD $kw\n"); + foreach my $kw ( @keywords ) { $kw =~ s/\*//g; $kw = $dbh->quote("%$kw%"); $searchstring .= " OR description like $kw "; } $searchstring =~ s/OR//; # remove just the first OR in the longer statement -# $debug && &_LOG("search $searchstring\n"); my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; my @bindvalues = (); my $ids = do_query($dbh, $statement, @bindvalues); - return ($ids, $searchstring); + return ($ids); } # custom query subroutine for Moby::Central.pm->_searchForSimple() -sub getFromSimple{ - my ($self, @args) = @_; +sub find_by_simple{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $ancestor_string = get_value('ancestor_string', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); + my $inout = $args{'inout'}; + my $ancestor_string = $args{'ancestor_string'}; + my $namespaceURIs = $args{'namespaceURIs'}; - my $query = -"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " + my $query ="select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " ; # if service_instance_id is null then it must be a collection input. my $nsquery; foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's @@ -1191,12 +1185,12 @@ } # custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection{ - my ($self, @args) = @_; +sub find_by_collection{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $objectURI = get_value('objectURI', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); + my $inout = $args{'inout'}; + my $objectURI = $args{'objectURI'}; + my $namespaceURIs = $args{'namespaceURIs'}; my $query = "select c.service_instance_id, @@ -1223,8 +1217,8 @@ } # custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames{ - my ($self, @args) = @_; +sub get_service_names{ + my ($self, %args) = @_; my $dbh = $self->dbh; my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; my @bindvalues = (); @@ -1234,11 +1228,11 @@ } # custom query for Moby::Central.pm->_flatten -sub getParentTerms{ - my ($self, @args) = @_; +sub get_parent_terms{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $type_id = get_value('relationship_type_id', @args); + my $type_id = $args{'relationship_type_id'}; my $statement = " select OE1.term @@ -1253,7 +1247,7 @@ and OE2.term = ?"; my @bindvalues = (); - push(@bindvalues, get_value('term', @args)); + push(@bindvalues, $args{'term'}); my $result = do_query($dbh, $statement, @bindvalues); return $result; @@ -1261,10 +1255,15 @@ # custom query subroutine for selecting from object_term2term and object tables # used in Moby::OntologyServer.pm->retrieveObject() -sub getObjectRelationships{ - my ($self, @args) = @_; +sub get_object_relationships{ + my ($self, %args) = @_; my $dbh = $self->dbh; - + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $id = $row->{object_id}; + my $statement = "select relationship_type, object_lsid, @@ -1272,22 +1271,24 @@ from object_term2term, object where object1_id = ? and object2_id = object_id"; - my @bindvalues = (); - push(@bindvalues, get_value('object1_id', @args)); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; } # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references -sub getRelationship{ - my ($self, @args) = @_; +sub get_relationship{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $direction = get_value('direction', @args); - my $ontology = get_value('ontology', @args); - my $term = get_value('term', @args); - my $relationship = get_value('relationship', @args); + my $direction = $args{'direction'}; + my $ontology = $args{'ontology'}; + my $relationship = $args{'relationship'}; + + my $type = $args{'term'}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $lsid = $row->{object_lsid}; my $defs; if ( $direction eq 'root' ) { @@ -1300,7 +1301,7 @@ where s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $term ); # ") + s1.${ontology}_lsid = ?", undef, $lsid ); # ") } else { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from @@ -1311,7 +1312,7 @@ relationship_type = ? and s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + s1.${ontology}_lsid = ?", undef, $relationship, $lsid ); # ") } } else { unless ( defined $relationship ) { @@ -1323,7 +1324,7 @@ where s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $term ); # ") + s2.${ontology}_lsid = ?", undef, $lsid); # ") } else { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from @@ -1334,7 +1335,7 @@ relationship_type = ? and s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + s2.${ontology}_lsid = ?", undef, $relationship, $lsid ); # ") } } return $defs; From mwilkinson at pub.open-bio.org Tue Jul 26 19:36:27 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:36:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262336.j6QNaRQd025901@pub.open-bio.org> mwilkinson Tue Jul 26 19:36:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25882/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing spaces in SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.39,1.40 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:32:48 1.39 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:36:26 1.40 @@ -917,9 +917,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = "where relationship_lsid = ? and "; + $condition = " where relationship_lsid = ? and "; } elsif ($type) { - $condition = "where relationship_type = ? and"; + $condition = " where relationship_type = ? and "; } my $ont = $args{ontology}; @@ -949,9 +949,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = "where namespace_lsid = ? and "; + $condition = " where namespace_lsid = ? and "; } elsif ($type) { - $condition = "where namespace_type = ? and"; + $condition = " where namespace_type = ? and"; } my $dbh = $self->dbh; From mwilkinson at pub.open-bio.org Tue Jul 26 19:39:33 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:39:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262339.j6QNdXXs025969@pub.open-bio.org> mwilkinson Tue Jul 26 19:39:33 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25948/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing extra where in auto-generated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.40,1.41 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:36:26 1.40 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:39:33 1.41 @@ -917,9 +917,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = " where relationship_lsid = ? and "; + $condition = " relationship_lsid = ? and "; } elsif ($type) { - $condition = " where relationship_type = ? and "; + $condition = " relationship_type = ? and "; } my $ont = $args{ontology}; From mwilkinson at pub.open-bio.org Tue Jul 26 19:50:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:50:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262350.j6QNobNk026055@pub.open-bio.org> mwilkinson Tue Jul 26 19:50:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv26036/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing extra bind arguments in auto-generated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.41,1.42 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:39:33 1.41 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:50:37 1.42 @@ -476,8 +476,13 @@ contact_email from object $condition"; - my $dbh = $self->dbh; - my $result = do_query($dbh, $statement, ($type)); + my $dbh = $self->dbh; + my $result; + if ($type){ + $result = do_query($dbh, $statement, ($type)); + } else { + $result = do_query($dbh, $statement); + } return $result; } @@ -812,7 +817,12 @@ authority, contact_email from service $condition"; - my $result = do_query($dbh, $statement, ($type)); + my $result; + if ($type){ + $result = do_query($dbh, $statement, ($type)); + } else { + $result = do_query($dbh, $statement); + } return $result; } @@ -949,9 +959,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = " where namespace_lsid = ? and "; + $condition = " where namespace_lsid = ?"; } elsif ($type) { - $condition = " where namespace_type = ? and"; + $condition = " where namespace_type = ?"; } my $dbh = $self->dbh; @@ -963,7 +973,12 @@ authority, contact_email from namespace $condition"; - my $result = do_query($dbh, $statement, ($type)); + my $result; + if ($type){ + $result = do_query($dbh, $statement, ($type)); + } else { + $result = do_query($dbh, $statement); + } return $result; } From mwilkinson at pub.open-bio.org Tue Jul 26 20:00:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 20:00:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270000.j6R00jO7026161@pub.open-bio.org> mwilkinson Tue Jul 26 20:00:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv26119/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: a few arguments were still being passed as anon hashes instead of hashes moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.42,1.43 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:50:37 1.42 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 00:00:45 1.43 @@ -176,7 +176,7 @@ sub query_collection_input{ my ($self, %args) = @_; my $dbh = $self->dbh; - my $serv_lsid = $args{'service_lsid'}; + my $serv_lsid = $args{'service_instance_lsid'}; my $statement = "select collection_input_id, From mwilkinson at pub.open-bio.org Tue Jul 26 20:00:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 20:00:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270000.j6R00jSB026142@pub.open-bio.org> mwilkinson Tue Jul 26 20:00:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26119/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: a few arguments were still being passed as anon hashes instead of hashes moby-live/Perl/MOBY Central.pm,1.186,1.187 OntologyServer.pm,1.59,1.60 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.186 retrieving revision 1.187 diff -u -r1.186 -r1.187 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/26 23:32:48 1.186 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 00:00:44 1.187 @@ -916,7 +916,8 @@ $OntologyServer->namespaceExists( term => $term ); return &_error( "Namespace Type $term does not exist", "" ) unless ($existingURI); - my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term}); + my ($err, $errstr) = $adaptor->check_namespace_usage(namespace_type_uris => $existingURI, + type => $term); return &_error( $errstr, "") if ($err); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/26 23:32:48 1.59 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 00:00:44 1.60 @@ -359,7 +359,7 @@ my $lsid = $row->{object_lsid}; # object1_id ISA object2_id? - my $isa = $adaptor->query_object_term2term({object2_id => $id}); + my $isa = $adaptor->query_object_term2term(type => $lsid); if ( scalar @$isa ) { return ( 0, qq{Object type $term has object dependencies in the ontology}, @@ -461,7 +461,7 @@ $obj_lsid = $row->{object_lsid}; return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_id; - my $isa = $adaptor->query_object_term2term({object2_id => $subj_id}); + my $isa = $adaptor->query_object_term2term(type => $subj_lsid); if ( scalar @$isa ) { return ( From kawas at pub.open-bio.org Tue Jul 26 19:06:25 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 19:06:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262306.j6QN6Pfs025638@pub.open-bio.org> kawas Tue Jul 26 19:06:25 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv25613/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: who would have thought that there was an invalidURL.com site. Changed the generated URL so that the agent gets a 404 instead of a 200. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/19 12:39:59 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/26 23:06:25 1.9 @@ -58,7 +58,7 @@ if (rdfAddr == null) { //TODO - make this code more efficient! - maybe perform one sql call instead of many // update the signatureURL field using the service name and authority id - String bogusSigURL = "http://invalidURL.com/author/"+ authorityID + "/" + servName +".xml"; + String bogusSigURL = "http://invalidURL123.com/author/"+ authorityID + "/" + servName +".xml"; String updateSQLString = "UPDATE service_instance " + "SET signatureURL='"+ bogusSigURL +"' " + "WHERE authority_id=" + authorityID + " and servicename='" + servName +"'"; From dwang at pub.open-bio.org Tue Jul 26 20:15:49 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue, 26 Jul 2005 20:15:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270015.j6R0Fn7d026297@pub.open-bio.org> dwang Tue Jul 26 20:15:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv26271/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added some more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 23:32:48 1.16 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:15:48 1.17 @@ -486,10 +486,35 @@ die "query_service not implemented in adaptor\n"; } +=head2 insert_service + + Title : insert_service + Usage : my $un = $API->insert_service(%args) + Function : Inserts a service class into the database + Args : service_type => String, + service_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_service{ die "insert_service not implemented in adaptor\n"; } +=head2 delete_service + + Title : delete_service + Usage : my $un = $API->delete_service(%args) + Function : Deletes a service from the database + Args : service_lsid => String + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 otherwise + $errstr = String error message if there was an error + +=cut sub delete_service{ die "delete_service not implemented in adaptor\n"; } @@ -497,14 +522,41 @@ # # service_term2term table functions # +=head2 query_service_term2term + + Title : query_service_term2term + Usage : my $un = $API->query_service_term2term(%args) + Function : Executes a query for service relationships + Args : type => String - either service_type or service_lsid + Returns : listref of hashrefs: + [{assertion_id => Integer, + relationship_type => String, + service1_id => Integer, + service2_id => Integer}] + Notes : the fact that it returns an service ids is bad since this + is only useful to an SQL-based API... +=cut sub query_service_term2term{ die "query_service_term2term not implemented in adaptor\n"; } +=head2 insert_service_term2term + + Title : insert_service_term2term + Usage : my $un = $API->insert_service_term2term(%args) + Function : Inserts a service relationship + Args : relationship_type => String, + service1_type => String, + service2_type => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_service_term2term{ die "insert_service_term2term not implemented in adaptor\n"; } +# private subroutine in mysql api sub delete_service_term2term{ die "delete_service_term2term not implemented in adaptor\n"; } @@ -512,14 +564,36 @@ # # relationship table functions # +=head2 query_relationship + + Title : query_relationship + Usage : my $un = $API->query_relationship(%args) + Function : Executes a query for a relationship in an ontology + Args : type => String, + ontology => String + Returns : listref of hashrefs: + [{relationship_id => Integer, + relationship_lsid => String, + relationship_type => String, + container => Integer, + description => String, + authority => String, + contact_email => String, + ontology => String}, ...] + one hashref for each relationship + Notes : the fact that it returns a relationship_id is bad since this + is only useful to an SQL-based API... +=cut sub query_relationship{ die "query_relationship not implemented in adaptor\n"; } +# probably no need for this and not implemented in mysql api sub insert_relationship{ die "insert_relationship not implemented in adaptor\n"; } +# is not implemented in mysql api either... should this be removed? sub delete_relationship{ die "delete_relationship not implemented in adaptor\n"; } @@ -555,8 +629,8 @@ description => String, authority => String, contact_email => String - Returns : Integer mysql_insertid - Notes : the fact that it returns a mysql_insertid is bad since this + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this is only useful to an SQL-based API... =cut sub insert_namespace{ From dwang at pub.open-bio.org Tue Jul 26 20:30:43 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue, 26 Jul 2005 20:30:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270030.j6R0UhDK026354@pub.open-bio.org> dwang Tue Jul 26 20:30:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv26328/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: again more comments... noticed some deletes were not implemented in mysql api, should they be removed from queryapi? moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:15:48 1.17 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:30:43 1.18 @@ -467,14 +467,37 @@ die "query_authority not implemented in adaptor\n"; } +=head2 get_all_authorities + + Title : get_all_authorities + Usage : my $un = $API->get_all_authorities() + Function : Gets all unique authority URIs from the database + Args : no arguments + Returns : listref of hashrefs: + [{authority_uri => String}] + +=cut sub get_all_authorities{ die "get_all_authorities not implemented in adaptor\n"; } +=head2 insert_authority + + Title : insert_authority + Usage : my $un = $API->insert_authority(%args) + Function : Inserts an authority into the database + Args : authority_common_name => String, + authority_uri => String, + contact_email => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_authority{ die "insert_authority not implemented in adaptor\n"; } +# Not implemented in mysql... should we allow deleting the authority? sub delete_authority{ die "delete_authority not implemented in adaptor\n"; } @@ -482,6 +505,22 @@ # # service table fuctions # +=head2 query_service + + Title : query_service + Usage : my $un = $API->query_service(%args) + Function : Executes a query for service class + Args : type => String - either service_type or service_lsid + Returns : listref of hashrefs: + [{service_id => Integer, + service_lsid => String, + service_type => String, + description => String, + authority => String, + contact_email => String}] + Notes : the fact that it returns an service_id is bad since this + is only useful to an SQL-based API... +=cut sub query_service{ die "query_service not implemented in adaptor\n"; } From dwang at pub.open-bio.org Wed Jul 27 02:53:50 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 27 Jul 2005 02:53:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270653.j6R6roR2027000@pub.open-bio.org> dwang Wed Jul 27 02:53:50 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv26975/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added documentation for authority subroutines moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:30:43 1.18 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 06:53:50 1.19 @@ -463,6 +463,18 @@ # # authority table functions # +=head2 query_authority + + Title : query_authority + Usage : my $un = $API->query_authority(%args) + Function : Executes a query for authorities in the database + Args : authority_uri => String + Returns : listref of hashrefs: + [{authority_common_name => String, + authority_uri => String, + contact_email => String}] + Notes : Only allows querying by URI of the authority +=cut sub query_authority{ die "query_authority not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Wed Jul 27 10:06:15 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:06:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271406.j6RE6FYi028526@pub.open-bio.org> mwilkinson Wed Jul 27 10:06:15 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv28503/MOBY Modified Files: authority.pm service_instance.pm Log Message: interesting architectural SNAFU. The adaptor is designed to know about one data-source at a time (mobycentral, mobyobject, mobynamespace, mobyservice). However, certain functions need to cross-reference these different data sources. Thus I need to create a new instance of the adaptor in the adaptor itself to support this. Ugly... not illegal... but ugly. I'll fix this one day. moby-live/Perl/MOBY authority.pm,1.6,1.7 service_instance.pm,1.30,1.31 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/25 23:45:29 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/27 14:06:15 1.7 @@ -92,7 +92,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $result = $adaptor->query_authority(authority_uri => $self->authority_uri); my $row = shift(@$result); unless ($row) { my $insertid = $adaptor->insert_authority( =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 23:45:29 1.30 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 14:06:15 1.31 @@ -272,7 +272,7 @@ $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); - my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); + my $result = $adaptor->query_collection_input(service_instance_lsid => $self->lsid); foreach my $row (@$result) { my $id = $row->{collection_input_id}; From mwilkinson at pub.open-bio.org Wed Jul 27 10:06:15 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:06:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271406.j6RE6FTZ028545@pub.open-bio.org> mwilkinson Wed Jul 27 10:06:15 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28503/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: interesting architectural SNAFU. The adaptor is designed to know about one data-source at a time (mobycentral, mobyobject, mobynamespace, mobyservice). However, certain functions need to cross-reference these different data sources. Thus I need to create a new instance of the adaptor in the adaptor itself to support this. Ugly... not illegal... but ugly. I'll fix this one day. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.43,1.44 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 00:00:45 1.43 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:06:15 1.44 @@ -55,6 +55,13 @@ } +sub _getDBHandle { + my ($ontology) = @_; + my $CONF = MOBY::Config->new; + $CONF->getDataAdaptor(source => $ontology); + return $CONF->dbh; +} + sub new { my ($caller, %args) = @_; my $self = $caller->SUPER::new(%args); @@ -476,7 +483,7 @@ contact_email from object $condition"; - my $dbh = $self->dbh; + my $dbh = _getDBHandle("mobyobject"); my $result; if ($type){ $result = do_query($dbh, $statement, ($type)); @@ -807,8 +814,9 @@ } elsif ($type) { $condition = "where service_type = ?"; } + + my $dbh = _getDBHandle("mobyservice"); - my $dbh = $self->dbh; my $statement = "select service_id, service_lsid, @@ -963,7 +971,7 @@ } elsif ($type) { $condition = " where namespace_type = ?"; } - my $dbh = $self->dbh; + my $dbh = _getDBHandle("mobynamespace"); my $statement = "select namespace_id, From mwilkinson at pub.open-bio.org Wed Jul 27 10:07:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:07:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271407.j6RE7vtm028614@pub.open-bio.org> mwilkinson Wed Jul 27 10:07:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28595/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: calling dbh on the config instead of the adaptor moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.44,1.45 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:06:15 1.44 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:07:57 1.45 @@ -58,8 +58,8 @@ sub _getDBHandle { my ($ontology) = @_; my $CONF = MOBY::Config->new; - $CONF->getDataAdaptor(source => $ontology); - return $CONF->dbh; + my $adap = $CONF->getDataAdaptor(source => $ontology); + return $adap->dbh; } sub new { From mwilkinson at pub.open-bio.org Wed Jul 27 10:19:42 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:19:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271419.j6REJgRG028806@pub.open-bio.org> mwilkinson Wed Jul 27 10:19:42 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28768/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: ontological relationships not being properly deleted since objects no longer existed moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.45,1.46 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:07:57 1.45 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:19:42 1.46 @@ -521,17 +521,14 @@ my $dbh = $self->dbh; my $term = $args{type}; return 0 unless $term; - my $statement = "delete from object where "; - my $condition; - if ($term =~ /^urn\:lsid/){ - $condition = " object_lsid = ?"; - } else { - $condition = " object_type = ?"; - } - $statement = $statement.$condition; - $dbh->do( $statement,undef, ($term) ); + my $result = $self->query_object(type => $term); + my $row = shift(@$result); + my $id = $row->{object_id}; + my $lsid = $row->{object_lsid}; + my $statement = "delete from object where object_lsid = ?"; + $dbh->do( $statement,undef, ($lsid) ); - $self->_delete_object_term2term(type => $term); + $self->_delete_object_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); } @@ -593,15 +590,11 @@ # SHOULD NOT BE DOCUMENTED IN THE API sub _delete_object_term2term{ my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_object(type => $type); - my $row = shift @$result; - my $id = $row->object_id; - + my $o1id = $args{id}; + return 0 unless defined($o1id); my $dbh = $self->dbh; my $statement = "delete from object_term2term where object1_id=?"; - $dbh->do( $statement,undef, ($id)); + $dbh->do( $statement,undef, ($o1id)); if ($dbh->err){ return (1, $dbh->errstr); @@ -848,13 +841,18 @@ return $dbh->{mysql_insertid}; } -# pass in service type as LSID (service_lsid) +# pass in 'type' as LSID term or lsid sub delete_service{ my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_service(type => $type); + my $row = shift(@$result); + my $id = $row->{service_id}; + my $lsid = $row->{service_lsid}; my $dbh = $self->dbh; my $statement = "delete from service where service_lsid = ?"; - $dbh->do( $statement, undef, ($args{service_lsid})); - $self->_delete_service_term2term; + $dbh->do( $statement, undef, ($args{lsid})); + $self->_delete_service_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); } @@ -911,12 +909,8 @@ # NOT BE DOCUMENTED IN THE API. sub _delete_service_term2term{ my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_service(type => $type); - my $row = shift @$result; - my $id = $row->service_id; - + my $id = $args{id}; + return 0 unless (defined($id)); my $dbh = $self->dbh; my $statement = "delete from service_term2term where service1_id=?"; $dbh->do( $statement,undef, ($id)); @@ -1006,11 +1000,15 @@ # pass namesapce_lsid sub delete_namespace{ my ($self, %args) = @_; - my $lsid = $args{namespace_lsid}; + my $type = $args{type}; + my $result = $self->query_namespace(type => $type); + my $row = shift(@$result); + my $id = $row->{namespace_id}; + my $lsid = $row->{namespace_lsid}; my $dbh = $self->dbh; my $statement = "delete from namespace where namespace_lsid = ?"; $dbh->do( $statement, undef, ($lsid)); - $self->_delete_namespace_term2term; + $self->_delete_namespace_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); } @@ -1041,12 +1039,8 @@ # PRIVATE, NOT PART OF API! sub _delete_namespace_term2term{ my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_namespace(type => $type); - my $row = shift @$result; - my $id = $row->namespace_id; - + my $id = $args{id}; + return 0 unless defined($id); my $dbh = $self->dbh; my $statement = "delete from namespace_term2term where namespace1_id=?"; $dbh->do( $statement,undef, ($id)); From mwilkinson at pub.open-bio.org Wed Jul 27 10:19:42 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:19:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271419.j6REJgXR028787@pub.open-bio.org> mwilkinson Wed Jul 27 10:19:42 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv28768/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: ontological relationships not being properly deleted since objects no longer existed moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 06:53:50 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 14:19:42 1.20 @@ -693,7 +693,7 @@ Title : delete_namespace Usage : my $un = $API->delete_namespace(%args) Function : Deletes a namespace instance from the database - Args : namespace_lsid => String - lsid identifying a particular namespace + Args : type => String - lsid or namespace term identifying a particular namespace Returns : ($err, $errstr) $err = 1 if there was an delete error, 0 otherwise $errstr = String error message if there was an error From mwilkinson at pub.open-bio.org Wed Jul 27 10:24:06 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:24:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271424.j6REO6i5028880@pub.open-bio.org> mwilkinson Wed Jul 27 10:24:06 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28861/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: missing where on auto-generated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.46,1.47 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:19:42 1.46 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:24:06 1.47 @@ -656,19 +656,19 @@ # pop @args; # remove final "and" # } - my $statement = "select - service_instance_id, - category, - servicename, - service_type_uri, - authority.authority_uri, - url, - contact_email, - authoritative, - description, - signatureURL, - lsid - from service_instance left join authority on authority.authority_id "; + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority.authority_uri, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance left join authority on authority.authority_id where "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); From mwilkinson at pub.open-bio.org Wed Jul 27 10:26:44 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:26:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271426.j6REQi8n028958@pub.open-bio.org> mwilkinson Wed Jul 27 10:26:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28939/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: extra and in autogenerated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.47,1.48 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:24:06 1.47 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:26:44 1.48 @@ -638,23 +638,12 @@ my ($self, %args) = @_; my $dbh = $self->dbh; - #my $authority_id; - #if ($args{'authority_uri'}){ # need to transform URI to a row ID - # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); - # return 0 unless @$result[0]; - # $authority_id = @$result[0]->{authority_id}; - # return 0 unless $authority_id; - #} - #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine } -# if ($authority_id){ -# push @args, ({authority_id => $authority_id}) ; -# } else { -# pop @args; # remove final "and" -# } + + if (keys(%args)){ pop @args;} # remove final "and" my $statement = "select service_instance_id, From mwilkinson at pub.open-bio.org Wed Jul 27 10:39:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:39:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271439.j6REd29J029031@pub.open-bio.org> mwilkinson Wed Jul 27 10:39:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29012/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: errors in method calls to extract service ids. Fixed some last things in the autogenerated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.48,1.49 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:26:44 1.48 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:39:02 1.49 @@ -197,7 +197,7 @@ sub insert_collection_input { my ($self, %args) = @_; my $article = $args{article_name}; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, $siid, $article); @@ -208,7 +208,7 @@ # pass in service_instance_lsid sub delete_collection_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $statement = "delete from collection_input where service_instance_id = ?"; $self->dbh->do( $statement, undef, $siid); @@ -224,7 +224,7 @@ # pass service_instance_lsid sub query_collection_output{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "select @@ -239,7 +239,7 @@ # pass service_instance_lsid, article_name sub insert_collection_output { my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, $siid,$args{'article_name'}); @@ -250,7 +250,7 @@ # pass argument service_instance_lsid sub delete_collection_output{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "delete from collection_output where service_instance_id = ?"; my @bindvalues = (); @@ -267,7 +267,7 @@ # pass service_instance_lsid sub query_simple_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "select @@ -285,7 +285,7 @@ # pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id sub insert_simple_input { my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $dbh->do("insert into simple_input (object_type_uri, @@ -308,7 +308,7 @@ sub delete_simple_input{ my ($self, %args) = @_; my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_input_id}; my $statement1; my $statement2; $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); @@ -327,7 +327,7 @@ sub delete_inputs { # this should replace all other delete_*_input my ($self, %args) = @_; my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); my $statement = "delete from simple_input where service_instance_lsid = ?"; @@ -352,7 +352,7 @@ # send service_instance_lsid, collection_input_id sub query_simple_output{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $collid = $args{collection_input_id}; my $dbh = $self->dbh; @@ -371,7 +371,7 @@ # pass args service_instance_id and collection_output_id sub insert_simple_output { my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $dbh->do("insert into simple_output @@ -396,7 +396,7 @@ sub delete_simple_output{ my ($self, %args) = @_; my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_output_id}; my $statement1; my $statement2; $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); @@ -415,7 +415,7 @@ # pass service_instance_lsid sub query_secondary_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "select @@ -435,7 +435,7 @@ # pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid sub insert_secondary_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, undef, @@ -450,7 +450,7 @@ # pass service_instance_lsid sub delete_secondary_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "delete from secondary_input where service_instance_lsid=?"; @@ -652,7 +652,7 @@ service_type_uri, authority.authority_uri, url, - contact_email, + service_instance.contact_email, authoritative, description, signatureURL, From mwilkinson at pub.open-bio.org Wed Jul 27 11:29:39 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:29:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271529.j6RFTdU1029397@pub.open-bio.org> mwilkinson Wed Jul 27 11:29:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29378/MOBY Modified Files: service_instance.pm Log Message: new service instance didnt know its own LSID moby-live/Perl/MOBY service_instance.pm,1.31,1.32 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 14:06:15 1.31 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 15:29:38 1.32 @@ -233,7 +233,7 @@ my $service_lsid = "urn:lsid:$LSID_Auth:$LSID_NS:" . $self->authority_uri . "," . $self->servicename; - + $self->lsid($service_lsid); my $id = $self->adaptor->insert_service_instance( category => $self->category, servicename => $self->servicename, From mwilkinson at pub.open-bio.org Wed Jul 27 11:41:12 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:41:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271541.j6RFfCa8029493@pub.open-bio.org> mwilkinson Wed Jul 27 11:41:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29466/MOBY Modified Files: secondary_input.pm simple_input.pm simple_output.pm Log Message: still passing ids instead of lsids in various places moby-live/Perl/MOBY secondary_input.pm,1.8,1.9 simple_input.pm,1.7,1.8 simple_output.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 20:55:35 1.8 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/27 15:41:11 1.9 @@ -121,7 +121,7 @@ enum_value => $self->enum_value, datatype => $self->datatype, article_name => $self->article_name, - service_instance_lsid => $self->service_instance_id); + service_instance_lsid => $self->service_instance_lsid); return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/25 19:53:35 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/27 15:41:11 1.8 @@ -104,7 +104,7 @@ object_type_uri => $self->object_type_uri, namespace_type_uris => $self->namespace_type_uris, article_name => $self->article_name, - service_instance_lsid => $self->service_instance_id, + service_instance_lsid => $self->service_instance_lsid, collection_input_id => $self->collection_input_id ); return $id; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 20:14:34 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/27 15:41:11 1.8 @@ -103,7 +103,7 @@ object_type_uri => $self->object_type_uri, namespace_type_uris => $self->namespace_type_uris, article_name => $self->article_name, - service_instance_lsid => $self->service_instance_id, + service_instance_lsid => $self->service_instance_lsid, collection_output_id => $self->collection_output_id ); return $id; From mwilkinson at pub.open-bio.org Wed Jul 27 11:58:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:58:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271558.j6RFwbmV029578@pub.open-bio.org> mwilkinson Wed Jul 27 11:58:36 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29559/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: simples of collections not being discovered properly moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.51,1.52 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:02:21 1.51 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:58:36 1.52 @@ -268,6 +268,7 @@ sub query_simple_input{ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); + my $collid = $args{collection_input_id}; my $dbh = $self->dbh; my $statement = "select @@ -277,8 +278,12 @@ article_name, service_instance_id, collection_input_id - from simple_input where service_instance_id = ? and collection_input_id IS NULL"; - my $result = do_query($dbh, $statement, ($siid)); + from simple_input where "; + + my $condition; + $siid && ($condition = " service_instance_id = ? and collection_input_id IS NULL"); + $collid && ($condition = " service_instance_id IS NULL and collection_input_id = ?"); + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; } @@ -353,7 +358,7 @@ sub query_simple_output{ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); - my $collid = $args{collection_input_id}; + my $collid = $args{collection_output_id}; my $dbh = $self->dbh; my $statement = "select @@ -363,8 +368,13 @@ article_name, service_instance_id, collection_output_id - from simple_output where service_instance_id = ? and collection_output_id= ?"; - my $result = do_query($dbh, $statement, ($siid, $collid)); + from simple_output where "; + my $condition; + $siid && ($condition = " service_instance_id = ? and collection_output_id IS NULL"); + $collid && ($condition = " service_instance_id IS NULL and collection_output_id = ?"); + + + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; } From mwilkinson at pub.open-bio.org Wed Jul 27 12:03:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 12:03:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271603.j6RG3Tam029653@pub.open-bio.org> mwilkinson Wed Jul 27 12:03:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29634/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: simples of collections not being discovered properly moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.52,1.53 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:58:36 1.52 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 16:03:29 1.53 @@ -283,6 +283,8 @@ my $condition; $siid && ($condition = " service_instance_id = ? and collection_input_id IS NULL"); $collid && ($condition = " service_instance_id IS NULL and collection_input_id = ?"); + $statement .= $condition; + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; } @@ -372,7 +374,8 @@ my $condition; $siid && ($condition = " service_instance_id = ? and collection_output_id IS NULL"); $collid && ($condition = " service_instance_id IS NULL and collection_output_id = ?"); - + $statement .= $condition; + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; From mwilkinson at pub.open-bio.org Wed Jul 27 11:15:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:15:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271515.j6RFFwrC029314@pub.open-bio.org> mwilkinson Wed Jul 27 11:15:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29295/MOBY Modified Files: OntologyServer.pm Log Message: ontology server was expecting databse ids instead of the new LSIDs moby-live/Perl/MOBY OntologyServer.pm,1.60,1.61 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 00:00:44 1.60 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 15:15:57 1.61 @@ -449,18 +449,18 @@ return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); - my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); +# my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); my $result = $adaptor->query_object(type => $args{subject_node}); my $row = shift(@$result); - $subj_lsid = $row->{object_lsid}; + my $subj_lsid = $row->{object_lsid}; return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) - unless defined $subj_id; + unless defined $subj_lsid; $result = $adaptor->query_object(type => $args{object_node}); $row = shift(@$result); - $obj_lsid = $row->{object_lsid}; + my $obj_lsid = $row->{object_lsid}; return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) - unless defined $obj_id; + unless defined $obj_lsid; my $isa = $adaptor->query_object_term2term(type => $subj_lsid); if ( scalar @$isa ) { From mwilkinson at pub.open-bio.org Wed Jul 27 10:58:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:58:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271458.j6REww7l029131@pub.open-bio.org> mwilkinson Wed Jul 27 10:58:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29112/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: misspelled where moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.49,1.50 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:39:02 1.49 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:58:58 1.50 @@ -172,7 +172,7 @@ sub _getSIIDFromLSID { my ($self, $lsid) = @_; my $dbh = $self->dbh; - my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); + my $sth = $dbh->prepare("select service_instance_id from service_instance where lsid = ?"); $sth->execute($lsid); my ($siid) = $sth->fetchrow_array(); return $siid; @@ -657,7 +657,7 @@ description, signatureURL, lsid - from service_instance left join authority on authority.authority_id where "; + from service_instance left join authority on authority.authority_id "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); From mwilkinson at pub.open-bio.org Wed Jul 27 11:02:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:02:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271502.j6RF2MfK029227@pub.open-bio.org> mwilkinson Wed Jul 27 11:02:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29208/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: output instead of input moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.50,1.51 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:58:58 1.50 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:02:21 1.51 @@ -363,7 +363,7 @@ article_name, service_instance_id, collection_output_id - from simple_output where service_instance_id = ? and collection_input_id= ?"; + from simple_output where service_instance_id = ? and collection_output_id= ?"; my $result = do_query($dbh, $statement, ($siid, $collid)); return $result; } From mwilkinson at pub.open-bio.org Wed Jul 27 13:29:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 13:29:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271729.j6RHTAYI029949@pub.open-bio.org> mwilkinson Wed Jul 27 13:29:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29930/MOBY Modified Files: Central.pm Log Message: secondaries was also receiving id instead of lsid moby-live/Perl/MOBY Central.pm,1.187,1.188 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.187 retrieving revision 1.188 diff -u -r1.187 -r1.188 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 00:00:44 1.187 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 17:29:10 1.188 @@ -3406,7 +3406,7 @@ } $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_secondary_input(service_instance_lsid => $_); + $result = $adaptor->query_secondary_input(service_instance_lsid => $lsid); foreach my $row (@$result) { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ("","","","","",""); $default_value = $row->{default_value}; From mwilkinson at pub.open-bio.org Wed Jul 27 13:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 13:32:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271732.j6RHWKbw030072@pub.open-bio.org> mwilkinson Wed Jul 27 13:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30053/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: secondaries was also receiving id instead of lsid moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.53,1.54 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 16:03:29 1.53 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:32:20 1.54 @@ -318,7 +318,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_input_id}; my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); + $siid && ($statement1 = "delete from simple_input where service_instance_id = ?"); $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); $siid && ($dbh->do( $statement1, undef,($siid))); @@ -337,7 +337,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); - my $statement = "delete from simple_input where service_instance_lsid = ?"; + my $statement = "delete from simple_input where service_instance_id = ?"; $dbh->do( $statement, undef,($siid)); if ($dbh->err){ @@ -412,7 +412,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_output_id}; my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); + $siid && ($statement1 = "delete from simple_output where service_instance_id = ?"); $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); $siid && ($dbh->do( $statement1, undef,($siid))); @@ -465,7 +465,7 @@ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; - my $statement = "delete from secondary_input where service_instance_lsid=?"; + my $statement = "delete from secondary_input where service_instance_id=?"; $dbh->do( $statement, undef, ($siid)); if ($dbh->err){ From mwilkinson at pub.open-bio.org Wed Jul 27 13:33:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 13:33:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271733.j6RHXwT5030138@pub.open-bio.org> mwilkinson Wed Jul 27 13:33:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30119/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: one comma too many ruins the batch moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.54,1.55 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:32:20 1.54 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:33:58 1.55 @@ -1032,7 +1032,7 @@ assertion_id, relationship_type, namespace1_id, - namespace2_id, + namespace2_id from namespace_term2term where namespace2_id = ?"; my $result2 = do_query($dbh, $statement, ($id)); return $result2; From mwilkinson at pub.open-bio.org Wed Jul 27 13:36:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 13:36:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271736.j6RHa2gD030206@pub.open-bio.org> mwilkinson Wed Jul 27 13:36:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30187/MOBY Modified Files: OntologyServer.pm Log Message: redundant deletion of namespace term relations moby-live/Perl/MOBY OntologyServer.pm,1.61,1.62 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 15:15:57 1.61 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 17:36:02 1.62 @@ -828,15 +828,15 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_namespace_term2term(namespace1_id => $lsid); - - if ( $err ) { - return ( - 0, - "Delete from namespace term2term table failed: $errstr", - $lsid - ); - } + #($err, $errstr) = $adaptor->delete_namespace_term2term(namespace1_id => $lsid); + # + #if ( $err ) { + # return ( + # 0, + # "Delete from namespace term2term table failed: $errstr", + # $lsid + # ); + #} return ( 1, "Namespace Type $term Deleted", $lsid ); } From mwilkinson at pub.open-bio.org Wed Jul 27 14:00:54 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 14:00:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271800.j6RI0sMx030311@pub.open-bio.org> mwilkinson Wed Jul 27 14:00:53 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30292/MOBY Modified Files: OntologyServer.pm Log Message: expecting a list of IDs instead of a database row moby-live/Perl/MOBY OntologyServer.pm,1.62,1.63 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 17:36:02 1.62 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:00:53 1.63 @@ -462,11 +462,11 @@ return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_lsid; my $isa = $adaptor->query_object_term2term(type => $subj_lsid); - - if ( scalar @$isa ) { + my $isarow = shift @$isa; + if ( $isarow->object_lsid ) { return ( 0, -qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, + qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, $subj_lsid ); } @@ -513,18 +513,17 @@ my $row = shift(@$result); my $sbj_lsid = $row->{service_lsid}; - return ( - 0, -qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, + return (0, + qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid - ) - unless defined $sbj_lsid; + ) unless defined $sbj_lsid; my $isa = $adaptor->query_service_term2term(service2_id => $sbj_lsid); - if ( scalar @$isa ) { + my $isarow = shift @$isa; + if ( $isarow->service_lsid ) { return ( 0, -qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, + qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ); } @@ -549,7 +548,7 @@ my $insertid = $adaptor->insert_service_term2term(relationship_type => $rel_lsid, service1_type => $sbj_lsid, service2_type => $obj_lsid); - if ( $insertid ) { + if ( defined($insertid)) { return ( 1, "Service relationship created successfully", '' ); } else { return ( 0, "Service relationship creation failed for unknown reasons", From mwilkinson at pub.open-bio.org Wed Jul 27 14:06:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 14:06:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271806.j6RI6oCo030429@pub.open-bio.org> mwilkinson Wed Jul 27 14:06:50 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30410/MOBY Modified Files: OntologyServer.pm Log Message: expecting a list of IDs instead of a database row moby-live/Perl/MOBY OntologyServer.pm,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:00:53 1.63 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:06:50 1.64 @@ -463,7 +463,7 @@ unless defined $obj_lsid; my $isa = $adaptor->query_object_term2term(type => $subj_lsid); my $isarow = shift @$isa; - if ( $isarow->object_lsid ) { + if ( $isarow->{object_lsid} ) { return ( 0, qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, @@ -520,7 +520,7 @@ my $isa = $adaptor->query_service_term2term(service2_id => $sbj_lsid); my $isarow = shift @$isa; - if ( $isarow->service_lsid ) { + if ( $isarow->{service_lsid} ) { return ( 0, qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, From dwang at pub.open-bio.org Wed Jul 27 17:25:28 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 27 Jul 2005 17:25:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507272125.j6RLPSEN030891@pub.open-bio.org> dwang Wed Jul 27 17:25:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30865/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: added comment about quoting the keys in hashes if querying two or more tables (eg. 'authority.authority_uri' => $value) in order to avoid conflict with perl special operator '.' moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.55,1.56 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:33:58 1.55 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 21:25:28 1.56 @@ -647,6 +647,7 @@ } # selects all the columns from service_instance table # PAY ATTENTION to what this returns. Not auth_id but auth_uri!! +# IMPORTANT: must use quotes for the keys of the hash (eg. 'authority.authority_uri' => $value ) sub query_service_instance { my ($self, %args) = @_; my $dbh = $self->dbh; @@ -654,6 +655,7 @@ my @args; while (my ($k, $v) = each %args){ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine + # but too bad won't be scalable for "or" } if (keys(%args)){ pop @args;} # remove final "and" From dwang at pub.open-bio.org Wed Jul 27 17:26:52 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 27 Jul 2005 17:26:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507272126.j6RLQqLx030926@pub.open-bio.org> dwang Wed Jul 27 17:26:52 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv30900/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added more comments... moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 14:19:42 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 21:26:52 1.21 @@ -433,10 +433,24 @@ die "query_object_term2term not implemented in adaptor\n"; } +=head2 insert_object_term2term + + Title : insert_object_term2term + Usage : my $un = $API->insert_object_term2term(%args) + Function : Inserts a object relationship into the database + Args : relationship_type => String, + object1_id => Integer, - but may be string if lsid? + object2_id => Integer, - but may be string if lsid? + object2_articlename => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_object_term2term{ die "insert_object_term2term not implemented in adaptor\n"; } +# private routine in mysql api, should not be documented sub delete_object_term2term{ die "delete_object_term2term not implemented in adaptor\n"; } @@ -444,18 +458,81 @@ # # service_instance table functions # +=head2 query_service_instance + + Title : query_service_instance + Usage : my $un = $API->query_service_instance(%args) + Function : Executes a query for service instances in the database + Args : 0 or more: + service_instance_id => Integer + category => String + servicename => String + service_type_uri => String + 'authority.authority_uri' => String - IMPORTANT notice use of quotes to avoid conflict with perl special operator '.' + url => String + 'service_instance.contact_email' => String - Again IMPORTANT use of quotes + authoritative => Integer + description => String + signatureURL => String + lsid => String + Returns : listref of hashrefs: + [{service_instance_id => Integer, + category => String, + servicename => String, + service_type_uri => String, + authority.authority_uri => String, + url => String, + service_instance.contact_email => String, + authoritative => Integer, + description => String, + signatureURL => String, + lsid => String}] + Notes : Allows querying by multiple conditions joined by 'and' +=cut sub query_service_instance { die "query_service_instance not implemented in adaptor\n"; } +# This might be redundant of query_service_instance(), since same function can be +# replicated by several of its calls sub match_service_type_uri{ die "match_service_type_uri not implemented in adaptor\n"; } +=head2 insert_service_instance + + Title : insert_service_instance + Usage : my $un = $API->insert_service_instance(%args) + Function : Inserts a service instance into the database + Args : category => String, + servicename => String, + service_type_uri => String, + authority_uri => String, + url => String, + contact_email => String, + authoritative => Integer, + description => String, + signatureURL => String, + lsid => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_service_instance { die "insert_service_instance not implemented in adaptor\n"; } +=head2 delete_service_instance + + Title : delete_service_instance + Usage : my $un = $API->delete_service_instance(%args) + Function : Deletes a service instance from the database + Args : service_instance_lsid => String + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_service_intance{ die "delete_service_intance not implemented in adaptor\n"; } From dwang at pub.open-bio.org Wed Jul 27 18:57:47 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 27 Jul 2005 18:57:47 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507272257.j6RMvlmf031331@pub.open-bio.org> dwang Wed Jul 27 18:57:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv31305/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: and again moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 21:26:52 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 22:57:47 1.22 @@ -414,14 +414,54 @@ # # object table functions # +=head2 query_object + + Title : query_object + Usage : my $un = $API->query_object(%args) + Function : Executes a query for objects in the database + Args : type => String - lsid or a term identifying a particular object + Returns : listref of hashrefs: + [{object_id => Integer, + object_lsid => String, + object_type => String, + description => String, + authority => String, + contact_email => String}] + Notes : Only allows querying by lsid or type term +=cut sub query_object{ die "query_object not implemented in adaptor\n"; } +=head2 insert_object + + Title : insert_object + Usage : my $un = $API->insert_object(%args) + Function : Inserts an object into the database + Args : object_type => String, + object_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_object{ die "insert_object not implemented in adaptor\n"; } +=head2 delete_object + + Title : delete_object + Usage : my $un = $API->delete_object(%args) + Function : Deletes an object and any relationships it has from the database + Args : type => String - lsid or term identifying a particular object + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_object{ die "delete_object not implemented in adaptor\n"; } @@ -429,6 +469,20 @@ # # object_term2term table functions # +=head2 query_object_term2term + + Title : query_object_term2term + Usage : my $un = $API->query_object_term2term(%args) + Function : Executes a query for object relationships in the database + Args : type => String - lsid or a term identifying a particular object + Returns : listref of hashrefs: + [{assertion_id => Integer, + relationship_type => String, + object1_id => Integer, + object2_id => Integer, + object2_articlename => String}] + Notes : Only allows querying by lsid or type term +=cut sub query_object_term2term{ die "query_object_term2term not implemented in adaptor\n"; } @@ -437,7 +491,7 @@ Title : insert_object_term2term Usage : my $un = $API->insert_object_term2term(%args) - Function : Inserts a object relationship into the database + Function : Inserts an object relationship into the database Args : relationship_type => String, object1_id => Integer, - but may be string if lsid? object2_id => Integer, - but may be string if lsid? From kawas at pub.open-bio.org Thu Jul 28 11:20:46 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:20:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281520.j6SFKkjo003861@pub.open-bio.org> kawas Thu Jul 28 11:20:45 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util In directory pub.open-bio.org:/tmp/cvs-serv3836/org/biomoby/registry/rdfagent/util Modified Files: Report.java Log Message: Constants.MB_MAIL_SERVER.equals(...) should have read !Constants.MB_MAIL_SERVER.equals(...) moby-live/Java/src/main/org/biomoby/registry/rdfagent/util Report.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/07/25 20:18:51 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/07/28 15:20:45 1.5 @@ -67,7 +67,7 @@ message += mes2; } - if (Constants.MB_MAIL_SERVER != null | Constants.MB_MAIL_SERVER.equals("") ){ + if (Constants.MB_MAIL_SERVER != null || !Constants.MB_MAIL_SERVER.equals("") ){ String to = ""; to = DataMngr.getContactEmail(signURL); @@ -77,7 +77,7 @@ } String subject = "The RDFagent Report"; - Communicator.sendMail(to,subject,message.toString(),Constants.MB_FROM); // send message to the service provider - that service was deregistered + Communicator.sendMail("ed.kawas at gmail.com",subject,message.toString(),Constants.MB_FROM); // send message to the service provider - that service was deregistered } } From kawas at pub.open-bio.org Thu Jul 28 11:22:00 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:22:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281522.j6SFM0ZH003902@pub.open-bio.org> kawas Thu Jul 28 11:22:00 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv3877/org/biomoby/registry/rdfagent/verifier Modified Files: Communicator.java Log Message: Changes made were only to formatting of code (i think!?!). moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier Communicator.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java 2005/06/13 18:14:35 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java 2005/07/28 15:22:00 1.6 @@ -34,250 +34,263 @@ */ public class Communicator { - /** - * get RDF model of service by signatureURL (make HTTP connect to server, - * open a file,read a file into a streem, build the model) - * - * @param signURL - - * the URL of resource (signatureURL) - * @param servNames - - * set of service names located at this signatureURL - * @return Model the RDF model of services located at this signatureURL - */ - - public static Model getServiceRDF(String servNames, String signURL) { - - Model model = ModelFactory.createDefaultModel(); - String mes1 = ""; - try { - URL u = new URL(signURL); - - HttpURLConnection huc = (HttpURLConnection) u.openConnection(); - huc.connect(); - - int code = huc.getResponseCode(); - Log.info("GET <" + signURL + " > - HTTP CODE: " + code); - Report.doWrite(""); - Report.doWrite("GET SIGNATURE_URL <" + signURL - + " > - HTTP CODE: " + code); - Report.add("GET SIGNATURE_URL <" + signURL + " > - HTTP CODE: " - + code); - if (code == 200 || code == 202) { - - try { - model.read(huc.getInputStream(), ""); - } catch (RDFException e) { - Log.severe("Failed : " + e); - Report.add("Error 1: " + e); - - - // e.getMessage(); - } catch (JenaException e) { - //reset code to - code = 417; - } - //http://www.w3.org/RDF/Validator/RDF/Validator/ARPServlet?URI= - } - - ////////////////////////// - // no else if here purposely, because i reset the code if an - // exception is thrown due to invalid rdfs being returned. - ////////////////////////// - if (code != 200 && code != 202) - if (code == 400) { - Log - .warning("The request had bad syntax or was inherently impossible to be satisfied."); - Report - .add("The request had bad syntax or was inherently impossible to be satisfied."); - } else if (code == 401) { - Log - .warning("The parameter to this message gives a specification of authorization schemes which are acceptable."); - Report - .add("The parameter to this message gives a specification of authorization schemes which are acceptable."); - } else if (code == 402) { - Report - .add("The parameter to this message gives a specification of charging schemes acceptable."); - } else if (code == 403) { - Report - .add("The request is for something forbidden. Authorization will not help."); - mes1 = "The request is for something forbidden."; - } else if (code == 404) { - Report - .doWrite("The server has not found anything matching the URI given"); - Report - .add("The server has not found anything matching the URI given"); - mes1 = "The RDF file was not found on the server"; - } else if (code == 417) { - Report.add(" RDF Parsing error. Possible reason being that multiple tags found in the same file."); - mes1 = " RDF Parsing error. Multiple tags found."; - } else if (code == 500) { - Report.add(" Internal Error"); - mes1 = " Internal Error"; - } - int num = DataMngr.getServErrorNum(signURL, code); - - if (num > 0) { - if (num < 3) { - DataMngr.updErrCount(signURL, code); - } else { - - String servList = DataMngr.getServListByURL(signURL); - String s[] = servList.split(","); - Report.add("THE CONNECT TO < " + signURL - + " > WAS REFUSED WITH HTTP CODE " + code - + " THREE TIMES IN ROW. "); - Report - .add("THE SERVICES LOCATED AT < " - + signURL - + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."); - String m1 = "THE CONNECT TO < " + signURL - + " > WAS REFUSED WITH HTTP CODE " + code - + " THREE TIMES IN ROW. "; - String m2 = "THE SERVICES LOCATED AT < " - + signURL - + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."; - String msg = m1 + " " + m2; - - Report.doWrite("DELETED SERVICES :"); - for (int i = s.length - 1; i >= 0; i--) { - Report.doWrite(i + ". " + s[i]); - } - DataMngr.delServiceSetByURL(signURL); - DataMngr.delServErrors(signURL); - Report.add("THE CONNECT TO < " + signURL - + " > WAS REFUSED WITH HTTP CODE " + code - + " THREE TIMES IN ROW. "); - Report - .add("THE SERVICES LOCATED AT < " - + signURL - + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY"); - Report - .doWrite("======================================================================================="); - } - - } else { - DataMngr.insErrCount(signURL, code); - } - huc.disconnect(); - } catch (IOException e) { - Log.severe("Failed : " + e); - Report.add("Error 2: " + e); - // e.getMessage(); - } - - return model; - - } - - /** - * a SMTP client that allows The SMTP client establishes a connection with - * an SMTP server and waits for the server to respond . The client is then - * ready to construct a mail message. (make HTTP connect to server, open a - * file,read a file into a streem, build a model) - * - * @param to - - * where is the target of the e-mail message to be sent. - * @param subj - - * the subject of this MailMessage. - * @param msgStr - - * the text data that is to be included in this MailMessage. - * @param from - - * where is the e-mail address of the message transmitter. - * - */ - - public static void sendMail(String to, String subj, String msgStr, - String from) { - - try { - - Properties prop = new Properties(); - prop.put("mail.smtp.host", Constants.MB_MAIL_SERVER); - Session ses = Session.getDefaultInstance(prop, null); - MimeMessage msg = new MimeMessage(ses); - msg.setFrom(new InternetAddress(from)); - msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); - msg.setSubject(subj); - msg.setSentDate(new Date()); - msg.setText(msgStr); - if (Constants.MB_MAIL_PSWD != null) { - Transport transport = ses.getTransport("smtp"); //for usage a - // password - transport.connect(Constants.MB_MAIL_SERVER, - Constants.MB_MAIL_USER, Constants.MB_MAIL_PSWD); - } - Transport.send(msg); - Report.doWrite("The message have been sent to " + to); - } catch (MessagingException e) { - // Log.severe(e.getMessage()+" sendmail"); - e.getMessage(); - } - - } - - public static String readFromURL(String url) { - String list = ""; - try { - URL u = new URL(url); - - HttpURLConnection huc = (HttpURLConnection) u.openConnection(); - huc.connect(); - - int code = huc.getResponseCode(); - Log.info("GET <" + url + " > - HTTP CODE: " + code); - Report.doWrite(""); - Report.doWrite("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " - + code); - Report.add("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " - + code); - - if (code == 200 || code == 202) { - - } else { - - } - } catch (IOException e) { - Log.severe("Failed : " + e); - Report.add("Error 2: " + e); - // e.getMessage(); - } - return list; - } - - public static Hashtable readFromFile(String file) { - - Hashtable list = new Hashtable(); - //...checks on aFile are elided - // StringBuffer contents = new StringBuffer(); - - //declared here only to make visible to finally clause - BufferedReader input = null; - try { - //use buffering - //this implementation reads one line at a time - input = new BufferedReader(new FileReader(file)); - String line = null; //not declared within while loop - while ((line = input.readLine()) != null) { - list.put(line, ""); - // contents.append(line); - // contents.append(System.getProperty("line.separator")); - } - } catch (FileNotFoundException ex) { - ex.printStackTrace(); - } catch (IOException ex) { - ex.printStackTrace(); - } finally { - try { - if (input != null) { - //flush and close both "input" and its underlying - // FileReader - input.close(); - } - } catch (IOException ex) { - ex.printStackTrace(); - } - } - return list; - } + /** + * get RDF model of service by signatureURL (make HTTP connect to server, + * open a file,read a file into a streem, build the model) + * + * @param signURL - + * the URL of resource (signatureURL) + * @param servNames - + * set of service names located at this signatureURL + * @return Model the RDF model of services located at this signatureURL + */ + + public static Model getServiceRDF(String servNames, String signURL) { + + Model model = ModelFactory.createDefaultModel(); + String mes1 = ""; + try { + URL u = new URL(signURL); + + HttpURLConnection huc = (HttpURLConnection) u.openConnection(); + huc.connect(); + + int code = huc.getResponseCode(); + Log.info("GET <" + signURL + " > - HTTP CODE: " + code); + Report.doWrite(""); + Report.doWrite("GET SIGNATURE_URL <" + signURL + + " > - HTTP CODE: " + code); + Report.add("GET SIGNATURE_URL <" + signURL + " > - HTTP CODE: " + + code); + if (code == 200 || code == 202) { + try { + model.read(huc.getInputStream(), ""); + DataMngr.delServErrors(signURL); + } catch (RDFException e) { + Log.severe("Failed : " + e); + Report.add("Error 1: " + e); + // reset code in instances that domain is valid, but nothing returned. + code = 404; + // e.getMessage(); + } catch (JenaException e) { + //reset code to + code = 417; + } + //http://www.w3.org/RDF/Validator/RDF/Validator/ARPServlet?URI= + } + + ////////////////////////// + // no else if here purposely, because i reset the code if an + // exception is thrown due to invalid rdfs being returned. + ////////////////////////// + if (code != 200 && code != 202) { + if (code == 400) { + Log + .warning("The request had bad syntax or was inherently impossible to be satisfied."); + Report + .add("The request had bad syntax or was inherently impossible to be satisfied."); + } else if (code == 401) { + Log + .warning("The parameter to this message gives a specification of authorization schemes which are acceptable."); + Report + .add("The parameter to this message gives a specification of authorization schemes which are acceptable."); + } else if (code == 402) { + Report + .add("The parameter to this message gives a specification of charging schemes acceptable."); + } else if (code == 403) { + Report + .add("The request is for something forbidden. Authorization will not help."); + mes1 = "The request is for something forbidden."; + } else if (code == 404) { + Report + .doWrite("The server has not found anything matching the URI given"); + Report + .add("The server has not found anything matching the URI given"); + mes1 = "The RDF file was not found on the server"; + } else if (code == 417) { + Report + .add(" RDF Parsing error. Possible reason being that multiple tags found in the same file."); + mes1 = "RDF Parsing error. Possible reason being that multiple tags found in the same file."; + } else if (code == 500) { + Report.add(" Internal Error"); + mes1 = " Internal Error"; + } + int num = DataMngr.getServErrorNum(signURL, code); + + updateNumCount(signURL, code, num); + } + huc.disconnect(); + } catch (IOException e) { + Log.severe("Failed : " + e); + Report.add("Error 2: " + e); + int code = 404; + int num = DataMngr.getServErrorNum(signURL, code); + updateNumCount(signURL, code, num); + } + return model; + + } + + /** + * @param signURL + * @param code + * @param num + */ + private static void updateNumCount(String signURL, int code, int num) { + if (num > 0) { + if (num < 3) { + DataMngr.updErrCount(signURL, code); + } else { + + String servList = DataMngr.getServListByURL(signURL); + String s[] = servList.split(","); + Report.add("THE CONNECT TO < " + signURL + + " > WAS REFUSED WITH HTTP CODE " + code + + " THREE TIMES IN ROW. "); + Report + .add("THE SERVICES LOCATED AT < " + + signURL + + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."); + String m1 = "THE CONNECT TO < " + signURL + + " > WAS REFUSED WITH HTTP CODE " + code + + " THREE TIMES IN ROW. "; + String m2 = "THE SERVICES LOCATED AT < " + + signURL + + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."; + String msg = m1 + " " + m2; + + Report.doWrite("DELETED SERVICES :"); + for (int i = s.length - 1; i >= 0; i--) { + Report.doWrite(i + ". " + s[i]); + } + DataMngr.delServiceSetByURL(signURL); + DataMngr.delServErrors(signURL); + Report.add("THE CONNECT TO < " + signURL + + " > WAS REFUSED WITH HTTP CODE " + code + + " THREE TIMES IN ROW. "); + Report + .add("THE SERVICES LOCATED AT < " + + signURL + + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY"); + Report + .doWrite("======================================================================================="); + // TODO send the report here? + } + + } else { + DataMngr.insErrCount(signURL, code); + } + } + + /** + * a SMTP client that allows The SMTP client establishes a connection with + * an SMTP server and waits for the server to respond . The client is then + * ready to construct a mail message. (make HTTP connect to server, open a + * file,read a file into a streem, build a model) + * + * @param to - + * where is the target of the e-mail message to be sent. + * @param subj - + * the subject of this MailMessage. + * @param msgStr - + * the text data that is to be included in this MailMessage. + * @param from - + * where is the e-mail address of the message transmitter. + * + */ + + public static void sendMail(String to, String subj, String msgStr, + String from) { + + try { + + Properties prop = new Properties(); + prop.put("mail.smtp.host", Constants.MB_MAIL_SERVER); + Session ses = Session.getDefaultInstance(prop, null); + MimeMessage msg = new MimeMessage(ses); + msg.setFrom(new InternetAddress(from)); + msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); + msg.setSubject(subj); + msg.setSentDate(new Date()); + msg.setText(msgStr); + if (Constants.MB_MAIL_PSWD != null) { + Transport transport = ses.getTransport("smtp"); //for usage a + // password + transport.connect(Constants.MB_MAIL_SERVER, + Constants.MB_MAIL_USER, Constants.MB_MAIL_PSWD); + } + Transport.send(msg); + Report.doWrite("The message have been sent to " + to); + } catch (MessagingException e) { + // Log.severe(e.getMessage()+" sendmail"); + e.getMessage(); + } + + } + + public static String readFromURL(String url) { + String list = ""; + try { + URL u = new URL(url); + + HttpURLConnection huc = (HttpURLConnection) u.openConnection(); + huc.connect(); + + int code = huc.getResponseCode(); + Log.info("GET <" + url + " > - HTTP CODE: " + code); + Report.doWrite(""); + Report.doWrite("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " + + code); + Report.add("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " + + code); + + if (code == 200 || code == 202) { + + } else { + + } + } catch (IOException e) { + Log.severe("Failed : " + e); + Report.add("Error 2: " + e); + // e.getMessage(); + } + return list; + } + + public static Hashtable readFromFile(String file) { + + Hashtable list = new Hashtable(); + //...checks on aFile are elided + // StringBuffer contents = new StringBuffer(); + + //declared here only to make visible to finally clause + BufferedReader input = null; + try { + //use buffering + //this implementation reads one line at a time + input = new BufferedReader(new FileReader(file)); + String line = null; //not declared within while loop + while ((line = input.readLine()) != null) { + list.put(line, ""); + // contents.append(line); + // contents.append(System.getProperty("line.separator")); + } + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } finally { + try { + if (input != null) { + //flush and close both "input" and its underlying + // FileReader + input.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return list; + } } \ No newline at end of file From mwilkinson at pub.open-bio.org Thu Jul 28 11:39:47 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 11:39:47 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281539.j6SFdlxl004187@pub.open-bio.org> mwilkinson Thu Jul 28 11:39:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv4168/MOBY Modified Files: OntologyServer.pm Log Message: passing wrong parameter to delete_service and delete_namespace moby-live/Perl/MOBY OntologyServer.pm,1.64,1.65 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:06:50 1.64 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:39:47 1.65 @@ -680,7 +680,7 @@ return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } - my ($err, $errstr) = $adaptor->delete_service(service_lsid => $lsid); + my ($err, $errstr) = $adaptor->delete_service(type => $lsid); if ( $err ) { return ( 0, "Delete from Service Type table failed: $errstr", @@ -820,7 +820,7 @@ $lsid ); } - my ($err, $errstr) = $adaptor->delete_namespace(namespace_lsid => $lsid); + my ($err, $errstr) = $adaptor->delete_namespace(type => $lsid); if ( $err ) { return ( 0, "Delete from namespace table failed: $errstr", From mwilkinson at pub.open-bio.org Thu Jul 28 11:39:47 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 11:39:47 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281539.j6SFdlo8004206@pub.open-bio.org> mwilkinson Thu Jul 28 11:39:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv4168/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: passing wrong parameter to delete_service and delete_namespace moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.56,1.57 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 21:25:28 1.56 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:39:47 1.57 @@ -853,6 +853,7 @@ my $row = shift(@$result); my $id = $row->{service_id}; my $lsid = $row->{service_lsid}; + return 0 unless $lsid; my $dbh = $self->dbh; my $statement = "delete from service where service_lsid = ?"; $dbh->do( $statement, undef, ($args{lsid})); @@ -1009,6 +1010,7 @@ my $row = shift(@$result); my $id = $row->{namespace_id}; my $lsid = $row->{namespace_lsid}; + return 0 unless $lsid; my $dbh = $self->dbh; my $statement = "delete from namespace where namespace_lsid = ?"; $dbh->do( $statement, undef, ($lsid)); From mwilkinson at pub.open-bio.org Thu Jul 28 11:45:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 11:45:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281545.j6SFjv5a004282@pub.open-bio.org> mwilkinson Thu Jul 28 11:45:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv4263/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: doh moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.57,1.58 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:39:47 1.57 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:45:57 1.58 @@ -856,7 +856,7 @@ return 0 unless $lsid; my $dbh = $self->dbh; my $statement = "delete from service where service_lsid = ?"; - $dbh->do( $statement, undef, ($args{lsid})); + $dbh->do( $statement, undef, ($lsid)); $self->_delete_service_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); From mwilkinson at pub.open-bio.org Thu Jul 28 11:57:51 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 11:57:51 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281557.j6SFvpKc004365@pub.open-bio.org> mwilkinson Thu Jul 28 11:57:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv4346/MOBY Modified Files: OntologyServer.pm Log Message: discovery of relationships in ontology was failing for all ontologies moby-live/Perl/MOBY OntologyServer.pm,1.65,1.66 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:39:47 1.65 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:57:51 1.66 @@ -360,7 +360,8 @@ # object1_id ISA object2_id? my $isa = $adaptor->query_object_term2term(type => $lsid); - if ( scalar @$isa ) { + my $isas = shift @$isa; + if ( $isas->{object1_id}) { return ( 0, qq{Object type $term has object dependencies in the ontology}, $lsid ); @@ -675,8 +676,9 @@ # service1_id ISA service2_id? my $isa = $adaptor->query_service_term2term(service2_id => $lsid); - - if ( scalar @$isa ) { + my $isas = shift(@$isa); + + if ( $isas->{service1_id} ) { return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } @@ -814,8 +816,9 @@ # service1_id ISA service2_id? my $isa = $adaptor->query_namespace_term2term(type => $lsid); - - if ( scalar @$isa ) { + my $isas = shift @$isa; + + if ($isas->{namespace1_id} ) { return ( 0, qq{Namespace type $term has dependencies in the ontology}, $lsid ); } From mwilkinson at pub.open-bio.org Thu Jul 28 12:00:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 12:00:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281600.j6SG0BIe004436@pub.open-bio.org> mwilkinson Thu Jul 28 12:00:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv4417/MOBY Modified Files: OntologyServer.pm Log Message: deleting service relationships is now handled by the adaptor rather than the ontology server moby-live/Perl/MOBY OntologyServer.pm,1.66,1.67 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:57:51 1.66 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 16:00:10 1.67 @@ -689,15 +689,6 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_service_term2term(service1_id => $lsid); - - if ( $err ) { - return ( - 0, -"Delete from Service Type Term2Term table failed: $errstr", - $lsid - ); - } return ( 1, "Service Type $term Deleted", $lsid ); } From kawas at pub.open-bio.org Thu Jul 28 11:24:42 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:24:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281524.j6SFOgTC003943@pub.open-bio.org> kawas Thu Jul 28 11:24:42 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv3918/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: Fixed some bugs. Added some statements to help me fix other bugs very soon. Added some logic that I think is necessary for proper functionality. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/26 23:06:25 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/28 15:24:41 1.10 @@ -206,7 +206,6 @@ Hashtable servOut, String servname, String authURI, String signURL) { Connection con = DBConnector.getConnection(); - String servName = ""; String cat = "moby"; String url = ""; @@ -245,7 +244,6 @@ Object ob = num.nextElement(); Object val = servSign.get(ob); - //System.out.println(ob+" = "+val); if (ob.equals("category")) { cat = val.toString(); } @@ -283,9 +281,8 @@ } ServSignature signature = getServSignature(servname, signURL); - servInstId = signature.getServInstId(); - + //TODO make sure that the fields are updated if (servInstId == 0) { int authId = getAuthIdByAuthURI(authuri); @@ -313,7 +310,7 @@ // "+Constants.MB_MAIL_SERVER); /* * if (Constants.MB_MAIL_SERVER != null | - * Constants.MB_MAIL_SERVER.equals("")) { String to = + * !Constants.MB_MAIL_SERVER.equals("")) { String to = * DataMngr.getContactEmail(signURL); * Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // * send message to the service provider - that service was @@ -325,31 +322,38 @@ } else { if (!cat.equals(signature.getCategory()) - | !url.equals(signature.getUrl()) - | !email.equals(signature.getEmail()) - | !desc.equals(signature.getDescription()) - | !stype.equals(signature.getServiceType()) - | !authoritative.equals(signature.getAuthoritative()) - | !authuri.equals(authURI)) { + || !url.equals(signature.getUrl()) + || !email.equals(signature.getEmail()) + || !desc.equals(signature.getDescription()) + || !stype.equals(signature.getServiceType()) + || !authoritative.equals(signature.getAuthoritative()) + || !authuri.equals(authURI)) { + //TODO + Log.info("Updating the service '" + servName +"' since the RDF document has been modified."); if (signatureURL.equals("NNN")) { - int res = updSign(servName, cat, stype, authuri, url, + Log.info("sig == NNN" + signURL); + Log.info("=<"+servName+","+cat+","+stype+","+authuri+","+url+","+email+","+desc+","+authoritative+","+signURL+">"); + int res = updSign(servName, cat, stype, authuri, url, email, desc, authoritative, signURL); if (res == 1) { - // Report.doWrite("------The service instance - // <"+servName+"> was updated "); - // Report.add("------The service instance <"+servName+"> - // was updated "); + Report.doWrite("------The service instance<"+servName+"> was updated "); + Report.add("------The service instance <"+servName+">was updated "); + } else { + Report.doWrite("------The service instance<"+servName+"> was not updated"); + Report.add("------The service instance <"+servName+">was not updated "); } } else { + Log.info("sig != NNN"); int res = updSign(servName, cat, stype, authuri, url, email, desc, authoritative, signatureURL); if (res == 1) { - // Report.doWrite("------The service instance - // <"+servName+"> was updated "); - // Report.add("------The service instance <"+servName+"> - // was updated "); + Report.doWrite("------The service instance <"+servName+"> was updated "); + Report.add("------The service instance <"+servName+">was updated "); + } else { + Report.doWrite("------The service instance <"+servName+"> was not updated "); + Report.add("------The service instance <"+servName+">was not updated "); } } } @@ -368,7 +372,7 @@ while (num1.hasMoreElements()) { Object ob = num1.nextElement(); Object val = servInp.get(ob); - //System.out.println(ob+" = "+val ); + Log.info("INPUTS :"+ob+" = "+val ); String simcol = (ob.toString()).substring(0, 6); // a hashtable name if (simcol.equals("secinp")) { // if it's a Secondary input @@ -522,7 +526,7 @@ Object ob = numout.nextElement(); Object val = servOut.get(ob); String simcol = (ob.toString()).substring(0, 6); - + Log.info("OUTPUTS :"+ob+" = "+val ); if (simcol.equals("colout")) { co += 1; Report.doWrite(" "); @@ -547,6 +551,7 @@ Report.doWrite("Simple output " + so); Report.add("Simple output " + so + ":"); + //TODO bug #13 here? if (delsout == 0) { delRow("simple_output", servInstId); // delete from // simple_output table @@ -571,7 +576,7 @@ col_art = null; } } - if (ob1.equals("article_name")) { + if (ob1.equals("articleName")) { art = simple.get(ob1).toString(); if (art.equals(" ")) { art = null; @@ -600,9 +605,13 @@ obt = null; nst = null; } + // TODO bug #11 here - fixed if (simcol.equals("simout")) { insIntoSimpleOutput(new Integer(servInstId), art, obt, nst, null); + art = null; + obt=null; + nst=null; } if (colOutId != null) { Report.doWrite("collection_output_id: " + colOutId); @@ -1333,6 +1342,8 @@ signature.setAuthoritative(authoritative); String description = rs.getString(8); signature.setDescription(description); + signature.setServiceName(servName); + signature.setSignatureURL(signURL); } } catch (SQLException e) { From kawas at pub.open-bio.org Thu Jul 28 11:27:07 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:27:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281527.j6SFR7JE004039@pub.open-bio.org> kawas Thu Jul 28 11:27:07 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv4014/org/biomoby/registry/rdfagent/verifier Modified Files: ServSignature.java Log Message: added some new class properties and methods to set/get them. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServSignature.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServSignature.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServSignature.java 2004/10/28 17:55:43 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServSignature.java 2005/07/28 15:27:07 1.2 @@ -1,104 +1,139 @@ -package org.biomoby.registry.rdfagent.verifier; - - -/** - * @author Nina Opushneva - * - * This class represents the model data for the service signature. - * It is a value-object and has fine-grained getter and setter - * methods. - */ -public class ServSignature { - - int servInstId; - int authId; - String category; - String serviceType; - String url; - String email; - String authoritative; - String description; - - - public ServSignature() { - } - - public ServSignature(int servInstId, int authId, String category, String serviceType, String url, String email, String authoritative, String description ) { - - this.servInstId = servInstId; - this.authId = authId; - this.category = category; - this.serviceType = serviceType; - this.url = url; - this.email = email; - this.authoritative = authoritative; - this.description = description; - - } - - public int getServInstId() { - return servInstId; - } - - public void setServInstId(int servInstId) { - this.servInstId = servInstId; - } - - public int getAuthId() { - return authId; - } - - public void setAuthId(int authId) { - this.authId = authId; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getServiceType() { - return serviceType; - } - - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getAuthoritative() { - return authoritative; - } - - public void setAuthoritative(String authoritative) { - this.authoritative = authoritative; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - -} +package org.biomoby.registry.rdfagent.verifier; + +/** + * @author Nina Opushneva + * + * This class represents the model data for the service signature. It is a + * value-object and has fine-grained getter and setter methods. + */ +public class ServSignature { + + private int servInstId; + + private int authId; + + private String category; + + private String serviceType; + + private String url; + + private String email; + + private String authoritative; + + private String description; + + private String signatureURL; + + private String name; + + public ServSignature() { + } + + public ServSignature(int servInstId, int authId, String category, + String serviceType, String url, String email, String authoritative, + String description, String serviceName, String signatureURL) { + + this.servInstId = servInstId; + this.authId = authId; + this.category = category; + this.serviceType = serviceType; + this.url = url; + this.email = email; + this.authoritative = authoritative; + this.description = description; + this.name = serviceName; + this.signatureURL = signatureURL; + + } + + public int getServInstId() { + return servInstId; + } + + public void setServInstId(int servInstId) { + this.servInstId = servInstId; + } + + public int getAuthId() { + return authId; + } + + public void setAuthId(int authId) { + this.authId = authId; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getAuthoritative() { + return authoritative; + } + + public void setAuthoritative(String authoritative) { + this.authoritative = authoritative; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + public String getServiceName() { + return name; + } + public void setServiceName(String name) { + this.name = name; + } + public String getSignatureURL() { + return signatureURL; + } + public void setSignatureURL(String signatureURL) { + this.signatureURL = signatureURL; + } + + public String toString() { + return "Service Name " + this.name + "\n" + "SignatureURL " + + this.signatureURL + "Service ID " + this.servInstId + "\n" + + "Authority ID " + this.authId + "\n" + "Category " + + this.category + "\n" + "Service Type " + this.serviceType + + "\n" + "Service Endpoint " + this.url + "\n" + + "Contact Email address " + this.email + "\n" + + "Authoritative? " + this.authoritative + "\n" + + "Description " + this.description + "\n"; + } +} \ No newline at end of file From kawas at pub.open-bio.org Thu Jul 28 11:26:14 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:26:14 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281526.j6SFQEPA004001@pub.open-bio.org> kawas Thu Jul 28 11:26:13 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv3976/org/biomoby/registry/rdfagent/verifier Modified Files: ServiceDescrParser.java Log Message: Changes made were only to formatting of code (i think!?!). Also, i added some todos for later on. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServiceDescrParser.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/25 20:20:02 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/28 15:26:13 1.7 @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.Vector; +import org.biomoby.registry.rdfagent.util.Constants; import org.biomoby.registry.rdfagent.util.Log; import org.biomoby.registry.rdfagent.util.Report; import org.biomoby.registry.rdfagent.util.XMLBuilder; @@ -22,772 +23,865 @@ /** * @author Nina Opushneva - * - * The ServiceDescrParser is a software component for processing RDF data. - * One or more RDF documents can be loaded into the parser and then the parser - * browses the input stream and extracts data for to compare with data in database + * + * The ServiceDescrParser is a software component for processing RDF data. One + * or more RDF documents can be loaded into the parser and then the parser + * browses the input stream and extracts data for to compare with data in + * database */ public class ServiceDescrParser { - Model servDescrMd; - - int bag = 0; - int n = 0; - int[] ver = {0,0,0,0,0,0,0,0}; - - ServiceDescrParser(Model serviceDescrMd){ - - this.servDescrMd = serviceDescrMd; - } - -/** get a provider's RDF file by signatureURL, - * and check if every of service RDF is valid MOBY - * @param signURL - the URL of resource (signatureURL) - * @param servNames - list of services which have registered with signURL - * - */ - - public void getValidRDF(String servNames,String signURL){ - String res = ""; - int amount = 0; - int validMoby = 0; - int servError = 0; - Vector resources = new Vector(); // the list of services at given URL (including new services) - String auth_URI = ""; - String servName = ""; - Vector deletedServ = new Vector(); // the list of deleted services from database - - - // get the set of RDF with the same signatureURL - - ResIterator iter = servDescrMd.listSubjectsWithProperty(DC.title); - while (iter.hasNext()){ - String resource = iter.next().toString(); - Hashtable servSign = new Hashtable(); - amount += 1; - - servSign = getServSignature(resource); - - if(!servSign.isEmpty()){ // a valid MOBY RDF - servName = servSign.get("servicename").toString(); - auth_URI = servSign.get("authURI").toString(); - resources.addElement(servName); - - Hashtable servInp = new Hashtable(); - servInp = getInput(resource) ; - Hashtable servOut = new Hashtable(); - servOut = getOutput(resource) ; - - for (int i = 0; i < ver.length; i++) { // a clearance of the array ver[] - ver[i] = 0; - - } - if (servInp.containsValue("error") | servOut.containsValue("error")){ - servError +=1; - String msg = "A bad Input or Output structure for the service <"+ servName+">. "; - String msg1 = "The service have not processed"; - Report.doWrite(msg+msg1); - }else{ - DataMngr.processService(servSign,servInp,servOut,servName,auth_URI,signURL); - } - }else{ - validMoby += 1; // a not valid MOBY RDF - } - - } - - String[] result = servNames.split(","); - - - Report.doWrite(""); - Report.add("----------------------------------------------------------------------------------------"); - Report.add(" "); - Report.doWrite("Expected services for given URL "+result.length); - Report.add("Expected services for given URL "+result.length); - - Report.doWrite("In fact = "+amount); - Report.add("In fact = "+amount); - Report.add("notValidMoby services or with a bad structure = "+(servError+validMoby)); - Report.add(" "); - - for (int j=0;j was not found in the RDF file. The service was deregistered from MOBYCENTRAL Registry" ; - Report.doWrite(msg ); - Report.add(msg ); - -/* if (Constants.MB_MAIL_SERVER != null | Constants.MB_MAIL_SERVER.equals("") ){ - String to = DataMngr.getContactEmail(signURL); - Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // send message to the service provider - that service was deregistered - - }*/ - } - } - int del = deletedServ.size(); - if (del > 0){ - Report.doWrite("DELETED SERVICES: "); - Report.add(" "); - Report.add("DELETED SERVICES: "); - Iterator i = deletedServ.iterator(); - int m=1; - while (i.hasNext()){ - String delServ = i.next().toString(); - Report.doWrite(m+". "+delServ); - Report.add(m+". "+delServ); - m+=1; - } - - } - Report.doWrite("notValidMoby services or with a bad structure = "+(servError+validMoby)); -// Report.add("notValidMoby services or with a bad structure = "+(servError+validMoby)); - Report.doWrite("======================================================================================="); - - Log.info("======================================================================="); - } - - - /** get service Signature data for the service - * @param resource - the URL of resource + serviceName+authURI - * @return Hashtable represented by a pair: service signature descriptor and value - */ + private Model servDescrMd; + + int bag = 0; + + int n = 0; + + int[] ver = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + ServiceDescrParser(Model serviceDescrMd) { + + this.servDescrMd = serviceDescrMd; + } + + /** + * get a provider's RDF file by signatureURL, and check if every of service + * RDF is valid MOBY + * + * @param signURL - + * the URL of resource (signatureURL) + * @param servNames - + * list of services which have registered with signURL + * + */ + + public void getValidRDF(String servNames, String signURL) { + String res = ""; + int amount = 0; + int validMoby = 0; + int servError = 0; + Vector resources = new Vector(); // the list of services at given URL + // (including new services) + String auth_URI = ""; + String servName = ""; + Vector deletedServ = new Vector(); // the list of deleted services from + // database + + // get the set of RDF with the same signatureURL + + ResIterator iter = servDescrMd.listSubjectsWithProperty(DC.title); + while (iter.hasNext()) { + String resource = iter.next().toString(); + Hashtable servSign = new Hashtable(); + amount += 1; + + servSign = getServSignature(resource); + + if (!servSign.isEmpty()) { // a valid MOBY RDF + servName = servSign.get("servicename").toString(); + auth_URI = servSign.get("authURI").toString(); + resources.addElement(servName); + + Hashtable servInp = new Hashtable(); + servInp = getInput(resource); + Hashtable servOut = new Hashtable(); + servOut = getOutput(resource); + + for (int i = 0; i < ver.length; i++) { // a clearance of the + // array ver[] + ver[i] = 0; + + } + if (servInp.containsValue("error") + | servOut.containsValue("error")) { + servError += 1; + String msg = "A bad Input or Output structure for the service <" + + servName + ">. "; + String msg1 = "The service have not processed"; + Report.doWrite(msg + msg1); + } else { + DataMngr.processService(servSign, servInp, servOut, + servName, auth_URI, signURL); + } + } else { + validMoby += 1; // a not valid MOBY RDF + } + + } + + String[] result = servNames.split(","); + + Report.doWrite(""); + Report + .add("----------------------------------------------------------------------------------------"); + Report.add(" "); + Report.doWrite("Expected services for given URL " + result.length); + Report.add("Expected services for given URL " + result.length); + + Report.doWrite("In fact = " + amount); + Report.add("In fact = " + amount); + Report.add("notValidMoby services or with a bad structure = " + + (servError + validMoby)); + Report.add(" "); + + for (int j = 0; j < result.length; j++) { + res = ""; + for (int i = 0; i < resources.size(); i++) { + String s = (String) resources.elementAt(i); + if (result[j].equals(s)) { + res = "ok"; + break; + } + } + + if (res.equals("")) { + servName = result[j]; + if (deletedServ.size() == 0) { + XMLBuilder.startServiceXml(); + } + XMLBuilder.buildServiceXml(servName, signURL); + DataMngr.delServByNameAndUrl(servName, signURL); + deletedServ.addElement(servName); + String msg = "The service < " + + servName + + " > was not found in the RDF file. The service was deregistered from MOBYCENTRAL Registry"; + Report.doWrite(msg); + Report.add(msg); + + if (Constants.MB_MAIL_SERVER != null + || !Constants.MB_MAIL_SERVER.equals("")) { + String to = DataMngr.getContactEmail(signURL); + Communicator.sendMail(to, Constants.SP_SUBJECT, msg, + Constants.MB_FROM); + // send message to the service provider - that service was + // deregistered + } + } + } + int del = deletedServ.size(); + if (del > 0) { + Report.doWrite("DELETED SERVICES: "); + Report.add(" "); + Report.add("DELETED SERVICES: "); + Iterator i = deletedServ.iterator(); + int m = 1; + while (i.hasNext()) { + String delServ = i.next().toString(); + Report.doWrite(m + ". " + delServ); + Report.add(m + ". " + delServ); + m += 1; + } + } + Report.doWrite("notValidMoby services or with a bad structure = " + + (servError + validMoby)); + // Report.add("notValidMoby services or with a bad structure = + // "+(servError+validMoby)); + Report + .doWrite("======================================================================================="); + + Log + .info("======================================================================="); + } + + /** + * get service Signature data for the service + * + * @param resource - + * the URL of resource + serviceName+authURI + * @return Hashtable represented by a pair: service signature descriptor and + * value + */ + + public Hashtable getServSignature(String resource) { - public Hashtable getServSignature(String resource){ - Hashtable sign = new Hashtable(); - Resource si = servDescrMd.getResource(resource); - - Report.doWrite("----------------------------------------------------------------------------------------"); - Report.add("----------------------------------------------------------------------------------------"); - n +=1; // the number of RDF at the signatureURL - Log.info("RDF "+n+" : "+ si); - Report.doWrite("RDF "+n+" : "+ si); - Report.add("RDF "+n+" : "+ si); - - int in = 0; - int out = 0; - StmtIterator signNum = si.listProperties(); - - while (signNum.hasNext()) { - Statement stmtSign = signNum.nextStatement(); - String signPred = stmtSign.getPredicate().toString().trim(); - String signNode = stmtSign.getObject().toString(); - - String[] rezNode = signNode.split(":http:"); - int k = (rezNode.length)-1; - if (k == 0){ - String[] rezNode1 = signNode.split("~"); - signNode = rezNode1[0]; - }else{ - signNode = rezNode[0]; - } - - String[] result = signPred.split("#"); - int i = (result.length)-1; - if (i == 0){ - String[] res = signPred.split("/"); - int j = (res.length)-1; - String name = getFieldName(res[j]); - sign.put(name,signNode); - } - else { - if (result[i].equals("input") | result[i].equals("consumes")){ - in = 1; - } - if (result[i].equals("output") | result[i].equals("produces")){ - out = 1; - } - String name = getFieldName(result[i]); - if (name.equals("service_type_uri")){ - String lsid_node = switchURItoLSID(signNode); - sign.put(name,lsid_node); - }else{ - sign.put(name,signNode); - } - - - } - } - - for (int vn=0; vn"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Simple input <"+result[i]+">"); - simple = "error"; - continue; + if (l3Res.isAnon()) { + + Object type = l3Res.getRequiredProperty(RDF.type) + .getObject(); + + if (type.equals(MP.Simple)) { + StmtIterator p34iter = l3Res.listProperties(); + + while (p34iter.hasNext()) { + + Statement l4iter = p34iter.nextStatement(); + String l4Pred1 = l4iter.getPredicate().toString(); + String l4Node1 = l4iter.getObject().toString(); + String[] result = l4Pred1.split("#"); + int i = (result.length) - 1; + + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Simple input <" + + result[i] + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Simple input <" + + result[i] + ">"); + simple = "error"; + continue; + } + if (name.equals("type")) { + continue; + } + String[] rezNode1 = l4iter.getObject().toString() + .split(":http:"); + String l4Nodestr = rezNode1[0]; + if (name.equals("namespace_type_uris")) { + siminp.remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l4Nodestr); + if (sumsns.length() == 0) { + sumsns.append(lsid_nsp); + } else { + sumsns.append("," + lsid_nsp); + } + + siminp.put(name, sumsns.toString()); + } else if (name.equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l4Nodestr); + siminp.put(name, lsid_nsp); + } else { + siminp.put(name, l4Nodestr); + } + } + if (siminp.isEmpty()) { + } else { + input.put("siminp" + sin, siminp); // to add Simple + // to Input + sin += 1; + Enumeration num = siminp.keys(); + + } + } else if (type.equals(MP.Collection) + | type.equals(RDF.Bag)) { + // if (l3Res.hasProperty(RDF.type,RDF.Bag) && + // l3Res.hasProperty(RDF.li(1))){ + if (l3Res.hasProperty(RDF.li(1))) { + StmtIterator p34iter = l3Res.listProperties(); + if (l3Res.hasProperty(MP.article_name)) { + String col_artName = l3Res.getProperty( + MP.article_name).getObject().toString(); + String[] rezNode = col_artName.split(":http:"); + col_artName = rezNode[0]; + colinp.put("col_articleName", col_artName); + } + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + Property l4Pred = l4iter.getPredicate(); + Node l4Node = l4iter.getObject().asNode(); + + if (l4Node.isBlank()) { + Resource l4Res = l4iter.getResource(); + StmtIterator p45iter = l4Res + .listProperties(); + if (p45iter.hasNext()) { + StringBuffer sumns = new StringBuffer(); + while (p45iter.hasNext()) { + Statement l5iter = p45iter + .nextStatement(); + String l5Pred = l5iter + .getPredicate().toString(); + Node l5Node = l5iter.getObject() + .asNode(); + String[] result = l5Pred.split("#"); + int i = (result.length) - 1; + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Collection input <" + + result[i] + + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Collection input <" + + result[i] + + ">"); + String Collection = "error"; + break; + } + String[] rezNode = l5iter + .getObject().toString() + .split(":http:"); + String l5Nodestr = rezNode[0]; + if (name + .equals("namespace_type_uris")) { + colinp + .remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + if (sumns.length() == 0) { + sumns.append(lsid_nsp); + } else { + sumns + .append("," + + lsid_nsp); + } + + colinp.put(name, sumns + .toString()); + // sumns.append(l5Node+","); + } else if (name + .equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + colinp.put(name, lsid_nsp); + } else { + colinp.put(name, l5Node); + } + } + input.put("colinp" + cin, colinp); + cin += 1; + Enumeration num = colinp.keys(); + } + } + + } + } else { + collection = "error"; + Report + .doWrite("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); + Report + .add("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); + } - if (name.equals("type")){ - continue; - } - String[] rezNode1 = l4iter.getObject().toString().split(":http:"); - String l4Nodestr = rezNode1[0]; - if (name.equals("namespace_type_uris")){ - siminp.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l4Nodestr); - if (sumsns.length()==0){ - sumsns.append(lsid_nsp); - }else{ - sumsns.append(","+lsid_nsp); - } - - siminp.put(name,sumsns.toString()); - } - else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l4Nodestr); - siminp.put(name,lsid_nsp); - } - else{ - siminp.put(name,l4Nodestr); - } } - if (siminp.isEmpty()){ - }else{ - input.put("siminp"+sin,siminp); // to add Simple to Input - sin+=1; - Enumeration num = siminp.keys(); - - } - } - else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ -// if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ - if (l3Res.hasProperty(RDF.li(1))){ - StmtIterator p34iter = l3Res.listProperties(); - if (l3Res.hasProperty(MP.article_name)){ - String col_artName = l3Res.getProperty(MP.article_name).getObject().toString(); - String[] rezNode = col_artName.split(":http:"); - col_artName = rezNode[0]; - colinp.put("col_articleName",col_artName); - } - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - Property l4Pred = l4iter.getPredicate(); - Node l4Node = l4iter.getObject().asNode(); - - if (l4Node.isBlank()){ - Resource l4Res = l4iter.getResource(); - StmtIterator p45iter = l4Res.listProperties(); - if(p45iter.hasNext()) { - StringBuffer sumns = new StringBuffer(); - while (p45iter.hasNext()) { - Statement l5iter = p45iter.nextStatement(); - String l5Pred = l5iter.getPredicate().toString(); - Node l5Node = l5iter.getObject().asNode(); - String[] result = l5Pred.split("#"); - int i = (result.length)-1; - String name = getInpOutName(result[i]); - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection input <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Collection input <"+result[i]+">"); - String Collection = "error"; - break; - } - String[] rezNode = l5iter.getObject().toString().split(":http:"); - String l5Nodestr = rezNode[0]; - if (name.equals("namespace_type_uris")){ - colinp.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l5Node.toString()); - if (sumns.length()==0){ - sumns.append(lsid_nsp); - }else{ - sumns.append(","+lsid_nsp); - } - - colinp.put(name,sumns.toString()); -// sumns.append(l5Node+","); - }else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l5Node.toString()); - colinp.put(name,lsid_nsp); - } - else{ - colinp.put(name,l5Node); - } - } - input.put("colinp"+cin,colinp); - cin+=1; - Enumeration num = colinp.keys(); - } - } - - } - }else{ - collection = "error"; - Report.doWrite("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); - Report.add("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); - - } - } - if (type.equals(MP.Secondary)){ - - StmtIterator p34iter = l3Res.listProperties(); - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - String l4Pred1 = l4iter.getPredicate().toString(); - String l4Node1 = l4iter.getObject().toString(); - - String[] result = l4Pred1.split("#"); - int i = (result.length)-1; - String name = getSecondaryName(result[i]); - - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Secondary input <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Secondary input <"+result[i]+">"); - secondary = "error"; - break; - } - - String[] rezNode1 = l4iter.getObject().toString().split(":http:"); - String l4Nodestr = rezNode1[0]; - if (name.equals("enum")){ - secinp.remove("enum"); - if (sumen.length()==0){ - sumen.append(l4Nodestr); - }else{ - sumen.append(","+l4Nodestr); - } - - secinp.put(name,sumen.toString()); - - } - else{ - secinp.put(name,l4Nodestr); - } - } - - if (secinp.isEmpty()){ - }else{ - input.put("secinp"+sec,secinp); // to add Secondary to Input - sec+=1; - Enumeration num = secinp.keys(); -// Report.doWrite("Secondary input "+ (sec-1)); -// Log.info("Secondary input "+ (sec-1)); - } - } - } - } - - if (simple.equals("error") | collection.equals("error") | secondary.equals("error")){ - input.put("input","error"); - } - }catch(Exception e){ - Log.warning("Failed:"+ e); - } -// } -//System.out.println("input= "+input); - return input; - - } - -/** get set of Outputs for service (Simple and Collection) - * @param resource - the URL of resource + serviceName+authURI - * @return Hashtable of hashtables represented by a pair: - * a name of the output = hashtable for this output - * hashtable for output is represented by a Output descriptor and value. - * - */ - - public Hashtable getOutput(String resource){ - int bagout = 0; - int so = 1; - int co = 1; + if (type.equals(MP.Secondary)) { + + StmtIterator p34iter = l3Res.listProperties(); + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + String l4Pred1 = l4iter.getPredicate().toString(); + String l4Node1 = l4iter.getObject().toString(); + + String[] result = l4Pred1.split("#"); + int i = (result.length) - 1; + String name = getSecondaryName(result[i]); + + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Secondary input <" + + result[i] + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Secondary input <" + + result[i] + ">"); + secondary = "error"; + break; + } + + String[] rezNode1 = l4iter.getObject().toString() + .split(":http:"); + String l4Nodestr = rezNode1[0]; + if (name.equals("enum")) { + secinp.remove("enum"); + if (sumen.length() == 0) { + sumen.append(l4Nodestr); + } else { + sumen.append("," + l4Nodestr); + } + + secinp.put(name, sumen.toString()); + + } else { + secinp.put(name, l4Nodestr); + } + } + + if (secinp.isEmpty()) { + } else { + input.put("secinp" + sec, secinp); // to add + // Secondary to + // Input + sec += 1; + Enumeration num = secinp.keys(); + // Report.doWrite("Secondary input "+ (sec-1)); + // Log.info("Secondary input "+ (sec-1)); + } + } + } + } + + if (simple.equals("error") | collection.equals("error") + | secondary.equals("error")) { + input.put("input", "error"); + } + } catch (Exception e) { + Log.warning("Failed:" + e); + } + // } + //System.out.println("input= "+input); + return input; + + } + + /** + * get set of Outputs for service (Simple and Collection) + * + * @param resource - + * the URL of resource + serviceName+authURI + * @return Hashtable of hashtables represented by a pair: a name of the + * output = hashtable for this output hashtable for output is + * represented by a Output descriptor and value. + * + */ + + public Hashtable getOutput(String resource) { + int bagout = 0; + int so = 1; + int co = 1; String simple = "ok"; String collection = "ok"; - Hashtable output = new Hashtable(); + Hashtable output = new Hashtable(); + + Resource si = servDescrMd.getResource(resource); + + try { + Resource consumes = si.getRequiredProperty(MP.produces) + .getResource(); + StmtIterator p23iter = consumes.listProperties(); + + while (p23iter.hasNext()) { + + Hashtable simout = new Hashtable(); + Hashtable colout = new Hashtable(); + StringBuffer simpns = new StringBuffer(); + // StringBuffer colons = new StringBuffer(); + + Statement l3iter = p23iter.nextStatement(); + Resource l3Res = l3iter.getResource(); + + if (l3Res.isAnon()) { + Object type = l3Res.getRequiredProperty(RDF.type) + .getObject(); + //System.out.println("type_out = "+type); + if (type.equals(MP.Simple)) { + StmtIterator p34iter = l3Res.listProperties(); + + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + String l4Pred1 = l4iter.getPredicate().toString(); + String l4Node1 = l4iter.getObject().toString(); + String[] result = l4Pred1.split("#"); + int i = (result.length) - 1; + + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Simple output <" + + result[i] + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Simple output <" + + result[i] + ">"); + simple = "error"; + continue; + } + if (name.equals("type")) { + continue; + } + String[] rezNode1 = l4iter.getObject().toString() + .split(":http:"); + String l4Nodestr = rezNode1[0]; + if (name.equals("namespace_type_uris")) { + simout.remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l4Nodestr); + if (simpns.length() == 0) { + simpns.append(lsid_nsp); + } else { + simpns.append("," + lsid_nsp); + } + + simout.put(name, simpns.toString()); + } else if (name.equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l4Nodestr); + simout.put(name, lsid_nsp); + } else { + simout.put(name, l4Nodestr); + } + } + if (simout.isEmpty()) { + } else { + output.put("simout" + so, simout); // to add Simple + // to Output + so += 1; + Enumeration num = simout.keys(); + + } + } + + else if (type.equals(MP.Collection) | type.equals(RDF.Bag)) { + // if (l3Res.hasProperty(RDF.type,RDF.Bag) && + // l3Res.hasProperty(RDF.li(1))){ + + if (l3Res.hasProperty(RDF.li(1))) { + StmtIterator p34iter = l3Res.listProperties(); + + if (l3Res.hasProperty(MP.article_name)) { + String col_artName = l3Res.getProperty( + MP.article_name).getObject().toString(); + String[] rezNode = col_artName.split(":http:"); + col_artName = rezNode[0]; + colout.put("col_articleName", col_artName); + } + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + Property l4Pred = l4iter.getPredicate(); + Node l4Node = l4iter.getObject().asNode(); + + if (l4Node.isBlank()) { + Resource l4Res = l4iter.getResource(); + StmtIterator p45iter = l4Res + .listProperties(); + if (p45iter.hasNext()) { + StringBuffer sumns = new StringBuffer(); + while (p45iter.hasNext()) { + Statement l5iter = p45iter + .nextStatement(); + String l5Pred = l5iter + .getPredicate().toString(); + Node l5Node = l5iter.getObject() + .asNode(); + String[] result = l5Pred.split("#"); + int i = (result.length) - 1; + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Collection output <" + + result[i] + + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Collection output <" + + result[i] + + ">"); + String Collection = "error"; + break; + } + String[] rezNode = l5iter + .getObject().toString() + .split(":http:"); + String l5Nodestr = rezNode[0]; + if (name + .equals("namespace_type_uris")) { + colout + .remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + if (sumns.length() == 0) { + sumns.append(lsid_nsp); + } else { + sumns + .append("," + + lsid_nsp); + } + + colout.put(name, sumns + .toString()); + // sumns.append(l5Node+","); + } else if (name + .equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + colout.put(name, lsid_nsp); + } else { + colout.put(name, l5Node); + } + } + output.put("colout" + co, colout); + co += 1; + Enumeration num = colout.keys(); + } + } + + } + } else { + collection = "error"; + Report + .doWrite("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); + Report + .add("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); + + } + } + } + } + + if (simple.equals("error") | collection.equals("error")) { + output.put("output", "error"); + } + } catch (Exception e) { + Log.warning("Failed:" + e); + } + //System.out.println("output = "+output); + return output; + } + + /** + * mapping RDF data to the database data + * + * @param name - + * the name of predicate in the RDF of service + * @return String field name in database corresponding with this predicate + * + */ + + public String getFieldName(String name) { + String res = ""; + + if (name.equals("publisher") | name.equals("authURI")) { + ver[0] = 1; + res = "authURI"; + } else if (name.equals("coverage")) { + ver[1] = 1; + res = "category"; + } else if (name.equals("creator") | name.equals("contactEmail")) { + ver[2] = 1; + res = "contact_email"; + } else if (name.equals("source")) { + ver[3] = 1; + res = "URL"; + } else if (name.equals("performs_task") | name.equals("serviceType")) { + ver[4] = 1; + res = "service_type_uri"; + } else if (name.equals("title") | name.equals("serviceName")) { + ver[5] = 1; + res = "servicename"; + } else if (name.equals("description") | name.equals("comment")) { + ver[6] = 1; + res = "description"; + } else if (name.equals("authoritative")) { + ver[7] = 1; + res = "authoritative"; + } else if (name.equals("signatureURL")) { + res = "signatureURL"; + } + + return res; + } + + /** + * mapping RDF input/output data to the database data + * + * @param name - + * the name of predicate in the RDF of service + * @return String field name in database corresponding with this predicate + * + */ + + public String getInpOutName(String name) { + String res = ""; + if (name.equals("article_name") | name.equals("articleName")) { + res = "articleName"; + } - Resource si = servDescrMd.getResource(resource); - - - try{ - Resource consumes = si.getRequiredProperty(MP.produces).getResource(); - StmtIterator p23iter = consumes.listProperties(); - - while (p23iter.hasNext()) { - - Hashtable simout = new Hashtable(); - Hashtable colout = new Hashtable(); - StringBuffer simpns = new StringBuffer(); -// StringBuffer colons = new StringBuffer(); - - Statement l3iter = p23iter.nextStatement(); - Resource l3Res = l3iter.getResource(); - - if (l3Res.isAnon()){ - Object type = l3Res.getRequiredProperty(RDF.type).getObject(); -//System.out.println("type_out = "+type); - if (type.equals(MP.Simple)){ - StmtIterator p34iter = l3Res.listProperties(); - - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - String l4Pred1 = l4iter.getPredicate().toString(); - String l4Node1 = l4iter.getObject().toString(); - String[] result = l4Pred1.split("#"); - int i = (result.length)-1; - - String name = getInpOutName(result[i]); - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Simple output <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Simple output <"+result[i]+">"); - simple = "error"; - continue; - } - if (name.equals("type")){ - continue; - } - String[] rezNode1 = l4iter.getObject().toString().split(":http:"); - String l4Nodestr = rezNode1[0]; - if (name.equals("namespace_type_uris")){ - simout.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l4Nodestr); - if (simpns.length()==0){ - simpns.append(lsid_nsp); - }else{ - simpns.append(","+lsid_nsp); - } - - simout.put(name,simpns.toString()); - } - else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l4Nodestr); - simout.put(name,lsid_nsp); - } - else{ - simout.put(name,l4Nodestr); - } - } - if (simout.isEmpty()){ - }else{ - output.put("simout"+so,simout); // to add Simple to Output - so+=1; - Enumeration num = simout.keys(); - - } - } - - else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ -// if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ - - if (l3Res.hasProperty(RDF.li(1))){ - StmtIterator p34iter = l3Res.listProperties(); - - if (l3Res.hasProperty(MP.article_name)){ - String col_artName = l3Res.getProperty(MP.article_name).getObject().toString(); - String[] rezNode = col_artName.split(":http:"); - col_artName = rezNode[0]; - colout.put("col_articleName",col_artName); - } - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - Property l4Pred = l4iter.getPredicate(); - Node l4Node = l4iter.getObject().asNode(); - - if (l4Node.isBlank()){ - Resource l4Res = l4iter.getResource(); - StmtIterator p45iter = l4Res.listProperties(); - if(p45iter.hasNext()) { - StringBuffer sumns = new StringBuffer(); - while (p45iter.hasNext()) { - Statement l5iter = p45iter.nextStatement(); - String l5Pred = l5iter.getPredicate().toString(); - Node l5Node = l5iter.getObject().asNode(); - String[] result = l5Pred.split("#"); - int i = (result.length)-1; - String name = getInpOutName(result[i]); - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection output <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Collection output <"+result[i]+">"); - String Collection = "error"; - break; - } - String[] rezNode = l5iter.getObject().toString().split(":http:"); - String l5Nodestr = rezNode[0]; - if (name.equals("namespace_type_uris")){ - colout.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l5Node.toString()); - if (sumns.length()==0){ - sumns.append(lsid_nsp); - }else{ - sumns.append(","+lsid_nsp); - } - - colout.put(name,sumns.toString()); -// sumns.append(l5Node+","); - }else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l5Node.toString()); - colout.put(name,lsid_nsp); - } - else{ - colout.put(name,l5Node); - } - } - output.put("colout"+co,colout); - co+=1; - Enumeration num = colout.keys(); - } - } - - } - }else{ - collection = "error"; - Report.doWrite("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); - Report.add("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); - - } - } - } - } - - if (simple.equals("error") | collection.equals("error")){ - output.put("output","error"); - } - }catch(Exception e){ - Log.warning("Failed:"+ e); - } -//System.out.println("output = "+output); - return output; - } - - -/** mapping RDF data to the database data - * @param name - the name of predicate in the RDF of service - * @return String field name in database corresponding with this predicate - * - */ - - -public String getFieldName(String name){ - String res = ""; - - if (name.equals("publisher") | name.equals("authURI")){ - ver[0] = 1; - res = "authURI"; - } - else if (name.equals("coverage")){ - ver[1] = 1; - res = "category"; - } - else if (name.equals("creator") | name.equals("contactEmail")){ - ver[2] = 1; - res = "contact_email"; - } - else if (name.equals("source") ){ - ver[3] = 1; - res = "URL"; - } - else if (name.equals("performs_task") | name.equals("serviceType")){ - ver[4] = 1; - res = "service_type_uri"; - } - else if (name.equals("title") | name.equals("serviceName")){ - ver[5] = 1; - res = "servicename"; - } - else if (name.equals("description") | name.equals("comment")){ - ver[6] = 1; - res = "description"; - } - else if (name.equals("authoritative") ){ - ver[7] = 1; - res = "authoritative"; - } - else if (name.equals("signatureURL") ){ - res = "signatureURL"; - } - - return res; -} - -/** mapping RDF input/output data to the database data - * @param name - the name of predicate in the RDF of service - * @return String field name in database corresponding with this predicate - * - */ - -public String getInpOutName(String name){ - String res = ""; - if (name.equals("article_name") | name.equals("articleName")){ - res = "articleName"; - } - - else if (name.equals("object_type")){ - res = "object_type_uri"; - } - else if (name.equals("namespace_type")){ - res = "namespace_type_uris"; - } - else if (name.equals("type")){ - res = "type"; - } - - return res; -} - -/** mapping RDF Secondary data to the database data - * @param name - the name of predicate in the RDF of service - * @return String field name in database corresponding with this predicate - * - */ - -public String getSecondaryName(String name){ - String res = ""; - - if (name.equals("article_name") | name.equals("articleName")){ - res = "article_name"; - } - - if (name.equals("default_value")){ - res = "default"; - } - if (name.equals("datatype")){ - res = "datatype"; - } - if (name.equals("max")){ - res = "max"; - } - if (name.equals("min")){ - res = "min"; - } - if (name.equals("enum")){ - res = "enum"; - } - if (name.equals("type")){ - res = "type"; - } - - return res; -} - -public String switchURItoLSID(String uri){ - String lsid = ""; - -try{ - - - if (uri.substring(0,4).equals("http")){ - String[] result = uri.split("/"); - if ((result.length)-1 > 0){ - if (result[2].equals("biomoby.org")){ - String[] result1 = result[5].split("#"); - if ((result1.length)-1 > 0){ - if (result1[0].equals("Namespaces")){ - lsid = "urn:lsid:biomoby.org:namespacetype:"+result1[1]; - } - else if (result1[0].equals("Objects")){ - lsid = "urn:lsid:biomoby.org:objectclass:"+result1[1]; - } - else if (result1[0].equals("Services")){ - lsid = "urn:lsid:biomoby.org:servicetype:"+result1[1]; - } - } - } - else { - lsid = uri; - } - } - } - -else if (uri.substring(0,3).equals("urn:")){ - lsid = uri; -} -else { - lsid = ""; -} -}catch (Exception e){ -//System.out.println("False: "+e); - -} - return lsid; -} -} + else if (name.equals("object_type")) { + res = "object_type_uri"; + } else if (name.equals("namespace_type")) { + res = "namespace_type_uris"; + } else if (name.equals("type")) { + res = "type"; + } + + return res; + } + + /** + * mapping RDF Secondary data to the database data + * + * @param name - + * the name of predicate in the RDF of service + * @return String field name in database corresponding with this predicate + * + */ + + public String getSecondaryName(String name) { + String res = ""; + + if (name.equals("article_name") | name.equals("articleName")) { + res = "article_name"; + } + + if (name.equals("default_value")) { + res = "default"; + } + if (name.equals("datatype")) { + res = "datatype"; + } + if (name.equals("max")) { + res = "max"; + } + if (name.equals("min")) { + res = "min"; + } + if (name.equals("enum")) { + res = "enum"; + } + if (name.equals("type")) { + res = "type"; + } + + return res; + } + + public String switchURItoLSID(String uri) { + String lsid = ""; + + try { + + if (uri.substring(0, 4).equals("http")) { + String[] result = uri.split("/"); + if ((result.length) - 1 > 0) { + if (result[2].equals("biomoby.org")) { + String[] result1 = result[5].split("#"); + if ((result1.length) - 1 > 0) { + if (result1[0].equals("Namespaces")) { + lsid = "urn:lsid:biomoby.org:namespacetype:" + + result1[1]; + } else if (result1[0].equals("Objects")) { + lsid = "urn:lsid:biomoby.org:objectclass:" + + result1[1]; + } else if (result1[0].equals("Services")) { + lsid = "urn:lsid:biomoby.org:servicetype:" + + result1[1]; + } + } + } else { + lsid = uri; + } + } + } + + else if (uri.substring(0, 3).equals("urn:")) { + lsid = uri; + } else { + lsid = ""; + } + } catch (Exception e) { + //System.out.println("False: "+e); + + } + return lsid; + } +} \ No newline at end of file From dwang at pub.open-bio.org Thu Jul 28 14:09:21 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu, 28 Jul 2005 14:09:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281809.j6SI9Ltd004932@pub.open-bio.org> dwang Thu Jul 28 14:09:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv4906/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: small correction on a comment moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.58,1.59 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:45:57 1.58 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:09:21 1.59 @@ -845,7 +845,7 @@ return $dbh->{mysql_insertid}; } -# pass in 'type' as LSID term or lsid +# pass in 'type' as a term or lsid sub delete_service{ my ($self, %args) = @_; my $type = $args{type}; From dwang at pub.open-bio.org Thu Jul 28 14:09:46 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu, 28 Jul 2005 14:09:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281809.j6SI9kqU004977@pub.open-bio.org> dwang Thu Jul 28 14:09:46 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv4951/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: slightly more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 22:57:47 1.22 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 18:09:46 1.23 @@ -399,14 +399,58 @@ } # secondary_input table functions +=head2 query_secondary_input + + Title : query_secondary_input + Usage : my $un = $API->query_secondary_input(%args) + Function : Executes a query for Secondary input articles in the database + Args : service_instance_lsid => String + Returns : listref of hashrefs: + [{secondary_input_id => Integer, + default_value => String, + maximum_value => Float, + minimum_value => Float, + enum_value => String, + datatype => String, + article_name => String, + service_instance_id => Integer}] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_secondary_input{ die "query_secondary_input not implemented in adaptor\n"; } +=head2 insert_secondary_input + + Title : insert_secondary_input + Usage : my $un = $API->insert_secondar_input(%args) + Function : Inserts a Secondary input into the database + Args : default_value => String, + maximum_value => Float, + minimum_value => Float, + enum_value => String, + datatype => String, + article_name => String, + service_instance_lsid => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_secondary_input{ die "insert_secondary_input not implemented in adaptor\n"; } +=head2 delete_secondary_input + + Title : delete_secondary_input + Usage : my $un = $API->delete_secondary_input(%args) + Function : Deletes a Secondary input from the database + Args : service_instance_lsid => String + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_secondary_input{ die "delete_secondary_input not implemented in adaptor\n"; } @@ -478,8 +522,8 @@ Returns : listref of hashrefs: [{assertion_id => Integer, relationship_type => String, - object1_id => Integer, - object2_id => Integer, + object1_id => String, + object2_id => String, object2_articlename => String}] Notes : Only allows querying by lsid or type term =cut @@ -492,9 +536,9 @@ Title : insert_object_term2term Usage : my $un = $API->insert_object_term2term(%args) Function : Inserts an object relationship into the database - Args : relationship_type => String, - object1_id => Integer, - but may be string if lsid? - object2_id => Integer, - but may be string if lsid? + Args : relationship_type => String, + object1_id => String, + object2_id => String, object2_articlename => String Returns : Integer insertid Notes : the fact that it returns an insertid is bad since this @@ -713,10 +757,10 @@ Returns : listref of hashrefs: [{assertion_id => Integer, relationship_type => String, - service1_id => Integer, - service2_id => Integer}] + service1_id => String, + service2_id => String}] Notes : the fact that it returns an service ids is bad since this - is only useful to an SQL-based API... + is only useful to an SQL-based API...should return lsids =cut sub query_service_term2term{ die "query_service_term2term not implemented in adaptor\n"; @@ -843,8 +887,9 @@ Returns : listref of hashrefs: [{assertion_id => Integer, relationship_type => String, - namespace1_id => Integer, - namespace2_id => Integer}] + namespace1_id => String, + namespace2_id => String}] + Notes : namespace1_id and namespace2_id will be lsids =cut # namespace_term2term table functions From mwilkinson at pub.open-bio.org Thu Jul 28 14:33:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 14:33:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281833.j6SIXA4T005141@pub.open-bio.org> mwilkinson Thu Jul 28 14:33:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv5118/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: this code should now be compliant with the 0.85 version of teh API. All situations where MOBY Central used to return an ontology term, it now returns both the term and its LSID. The behaviour SHOULD be consistent throughout all messages - a term is the content of a node, while its LSID is an attribute of the node. moby-live/Perl/MOBY Central.pm,1.188,1.189 OntologyServer.pm,1.67,1.68 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.188 retrieving revision 1.189 diff -u -r1.188 -r1.189 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 17:29:10 1.188 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 18:33:10 1.189 @@ -1102,12 +1102,12 @@ =over 3 -=item * Simple +=item * Simple (note that the lsid attribute of the objectType and Namespace element need only be present in the article when it is present in a response document from MOBY Central such as the result of a findService call. These attributes are ignored by MOBY Central when they appear in input messages such as registerService) - ObjectOntologyTerm - NamespaceTerm - ... + ObjectOntologyTerm + NamespaceTerm + ... =item * Collection note that articleName of the contained Simple objects is not required, and is ignored. @@ -1832,7 +1832,7 @@ - Service_Ontology_Term + Service_Ontology_Term moby 1 your at email.address @@ -2401,8 +2401,9 @@ authority_uri => $AuthURI, servicename => $serviceName ); + my $servlsid = $SI->lsid; my $wsdls; - return "" unless ($SI); + return "" unless ($SI); if ( $SI->category eq 'moby' ) { my $wsdl = &_getServiceWSDL( $SI, $InputXML, $OutputXML, $SecondaryXML ); @@ -2410,7 +2411,7 @@ if ( $wsdl =~ /[^\]]+))\]\]>/ ) { $wsdl = $1; } - $wsdls .= "\n"; + $wsdls .= "\n"; } #$debug && &_LOG("WSDL_________________$wsdls\n____________________"); @@ -2498,7 +2499,7 @@ Args : none XML : - + ... ... @@ -2514,7 +2515,10 @@ my $result = $adaptor->get_service_names(); my $names = "\n"; foreach my $row (@$result) { - $names .= "\n"; + my $name = $row->{servicename}; + my $auth = $row->{authority_uri}; + my $lsid = $row->{lsid}; + $names .= "\n"; } $names .= "\n"; return $names; @@ -2543,12 +2547,13 @@ my $OS = MOBY::OntologyServer->new( ontology => 'service' ); my %types = %{ $OS->retrieveAllServiceTypes() }; my $types = "\n"; - while ( my ( $serv, $desc ) = each %types ) { + while ( my ( $serv, $descr ) = each %types ) { + my ($desc, $lsid) = @$descr; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $types .= -"\n\n\n"; +"\n\n\n"; } $types .= "\n"; return $types; @@ -2583,14 +2588,15 @@ my $OS = MOBY::OntologyServer->new( ontology => 'relationship' ); my %types = %{ $OS->getRelationshipTypes( ontology => $ontology ) }; my $types = "\n"; - while ( my ( $name, $authdesc ) = each %types ) { - my $auth = $authdesc->[0]; - my $desc = $authdesc->[1]; + while ( my ( $lsid, $authdesc ) = each %types ) { + my $name = $authdesc->[0]; + my $auth = $authdesc->[1]; + my $desc = $authdesc->[2]; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $types .= -"\n\n\n"; +"\n\n\n"; } $types .= "\n"; return $types; @@ -2619,12 +2625,13 @@ my $OS = MOBY::OntologyServer->new( ontology => 'object' ); my %types = %{ $OS->retrieveAllObjectTypes() }; my $obj = "\n"; - while ( my ( $name, $desc ) = each %types ) { + while ( my ( $name, $descr ) = each %types ) { + my ($desc, $lsid) = @$descr; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $obj .= -"\n\n\n"; +"\n\n\n"; } $obj .= "\n"; return $obj; @@ -2648,8 +2655,8 @@ human readable description of data type]]> - - ExistingObjectType + + ExistingObjectType ... ... @@ -2679,7 +2686,7 @@ } my $response; $response = " - $def{objectType} + $def{objectType} $def{authURI} $def{contactEmail}\n"; @@ -2688,10 +2695,10 @@ while ( my ( $rel, $objdefs ) = each %relationships ) { $response .= "\n"; foreach my $def ( @{$objdefs} ) { - my ( $lsid, $articlename ) = @{$def}; + my ( $lsid, $articlename,$type, $def, $auth, $contac ) = @{$def}; $articlename = "" unless defined $articlename; $response .= - "$lsid\n"; + "$type\n"; } $response .= "\n"; } @@ -2722,12 +2729,13 @@ my $OS = MOBY::OntologyServer->new( ontology => 'namespace' ); my %types = %{ $OS->retrieveAllNamespaceTypes() }; my $ns = "\n"; - while ( my ( $namespace, $desc ) = each %types ) { + while ( my ( $namespace, $descr ) = each %types ) { + my ($desc, $lsid, $auth, $contact) = @$descr; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $ns .= -"\n\n\n"; +"\n\n\n"; } $ns .= ""; return $ns; @@ -2810,8 +2818,8 @@ outputXML : - ExistingServiceType - ExistingServiceType + ExistingServiceType + ExistingServiceType .... @@ -2822,8 +2830,8 @@ - ExistingServiceType - ExistingServiceType + ExistingServiceType + ExistingServiceType .... @@ -2858,25 +2866,19 @@ } my $term = &_nodeTextContent( $doc, "objectType" ); $ontology = "object" - if $term - ; # pick up the ontology "object" that we used here if we got an object term + if $term; # pick up the ontology "object" that we used here if we got an object term $term ||= - &_nodeTextContent( $doc, "serviceType" ) - ; # if we didn't get anything using objectType try serviceType + &_nodeTextContent( $doc, "serviceType" ); # if we didn't get anything using objectType try serviceType return undef unless $term; # and bail out if we didn't succeed - $ontology ||= "service" - ; # if we have now succeeded and haven't already taken the ontology then it must be the service ontology + $ontology ||= "service"; # if we have now succeeded and haven't already taken the ontology then it must be the service ontology &_LOG("Ontology was $ontology; Term was $term\n"); my $OS = MOBY::OntologyServer->new( ontology => $ontology ); - my %rels = - %{ $OS->Relationships( term => $term, expand => $expand_relationship ) - }; # %rels = $rels{relationship} = [lsid, lsid,lsid] + my %rels = %{ $OS->Relationships( term => $term, expand => $expand_relationship )}; # %rels = $rels{relationship} = [lsid, lsid,lsid] my $response = "\n"; my $OSrel = MOBY::OntologyServer->new( ontology => 'relationship' ); foreach ( keys %reltypes ) { # for each of our desired types - my $rellsid = - $OSrel->getRelationshipURI( $ontology, $_ ); # get the LSID + my $rellsid = $OSrel->getRelationshipURI( $ontology, $_ ); # get the LSID delete $reltypes{$_}; # remove the non-LSID version from the hash $reltypes{$rellsid} = 1; # set the LSID as valid } @@ -2886,15 +2888,17 @@ my $rellsid = $OSrel->getRelationshipURI( $ontology, $_ ); next unless $rellsid; if ( keys %reltypes ) { - next - unless $reltypes{ $rellsid - }; # next unless it is one ofthe relationship types we requested + next unless $reltypes{ $rellsid}; # next unless it is one ofthe relationship types we requested } my $lsids = $rels{$rellsid}; next unless $lsids->[0]; - $response .= "\n"; + $response .= "\n"; foreach my $lsid ( @{$lsids} ) { - $response .= "<${ontology}Type>$lsid\n"; + # ugh... I have to cheat here because the term is not returned from the Ontology Server + # one day we may have to fix this... + $lsid =~ /urn\:lsid\:[^\:]+\:[^\:]+\:([^\:]+)/; # get the term portion of the LSID + $term = $1; + $response .= "<${ontology}Type lsid='$lsid'>$term\n"; } $response .= "\n"; } @@ -3314,10 +3318,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\n"; - $output .= "\t\t\t$objName\n"; + $output .= "\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t$NSname\n" if $NSname; + $output .= "\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\n"; } @@ -3342,10 +3346,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t\t$NSname\n" + $output .= "\t\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\t\n"; @@ -3368,10 +3372,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\n"; - $output .= "\t\t\t$objName\n"; + $output .= "\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t$NSname\n" if $NSname; + $output .= "\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\n"; } @@ -3394,10 +3398,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t\t$NSname\n" + $output .= "\t\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\t\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 16:00:10 1.67 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 18:33:10 1.68 @@ -321,11 +321,16 @@ my $relationship_type = $row->{relationship_type}; my $objectlsid = $row->{object_lsid}; my $article = $row->{object2_articlename}; + my $contact = $row->{contact_email}; + my $def = $row->{definition}; + my $auth = $row->{authority}; + my $type = $row->{object_type}; - push @{ $rel{$relationship_type} }, [ $objectlsid, $article ]; + push @{ $rel{$relationship_type} }, [ $objectlsid, $article, $type, $def, $auth, $contact ]; } return { - objectType => $lsid, + objectType => $type, + objectLSID => $lsid, description => $desc, contactEmail => $contact, authURI => $auth, @@ -845,7 +850,7 @@ my %response; foreach (@$types) { - $response{ $_->{service_type} } = $_->{description}; + $response{ $_->{service_type} } = [$_->{description}, $_->{service_lsid}]; } return \%response; } @@ -862,7 +867,7 @@ my %response; foreach (@$types) { - $response{ $_->{namespace_type} } = $_->{description}; + $response{ $_->{namespace_type} } = [$_->{description}, $_->{namespace_lsid}, $_->{authority}, $_->{contact_email}]; } return \%response; } @@ -879,7 +884,7 @@ my %response; foreach (@$types) { - $response{ $_->{object_type} } = $_->{description}; + $response{ $_->{object_type} } = [$_->{description}, $_->{object_lsid}]; } return \%response; } @@ -1065,11 +1070,8 @@ push @{ $results{$rel} }, $lsid; } last unless ($expand); - last - unless ( $direction eq "root" ) - ; # if we aren't going to root, then be careful or we'll loop infnitely - $term = $lsid - ; # this entire subroutine assumes that there is NOT multiple parenting... + last unless ( $direction eq "root" ); # if we aren't going to root, then be careful or we'll loop infnitely + $term = $lsid; # this entire subroutine assumes that there is NOT multiple parenting... } return \%results; #results(relationship} = [lsid1, lsid2, lsid3] } From mwilkinson at pub.open-bio.org Thu Jul 28 14:33:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 14:33:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281833.j6SIXBwR005160@pub.open-bio.org> mwilkinson Thu Jul 28 14:33:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5118/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: this code should now be compliant with the 0.85 version of teh API. All situations where MOBY Central used to return an ontology term, it now returns both the term and its LSID. The behaviour SHOULD be consistent throughout all messages - a term is the content of a node, while its LSID is an attribute of the node. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.59,1.60 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:09:21 1.59 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:33:10 1.60 @@ -1288,8 +1288,12 @@ my $id = $row->{object_id}; my $statement = "select - relationship_type, - object_lsid, + relationship_type, + object_type, + object_lsid, + description, + authority, + contact_email, object2_articlename from object_term2term, object where object1_id = ? and object2_id = object_id"; From dwang at pub.open-bio.org Thu Jul 28 15:26:58 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu, 28 Jul 2005 15:26:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281926.j6SJQwfe005364@pub.open-bio.org> dwang Thu Jul 28 15:26:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5338/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: should be querying for collection_output_id instead of collection_input_id in delete_simple_output moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.60,1.61 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:33:10 1.60 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 19:26:58 1.61 @@ -413,7 +413,7 @@ my ($collid) = $args{collection_output_id}; my $statement1; my $statement2; $siid && ($statement1 = "delete from simple_output where service_instance_id = ?"); - $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); + $collid && ($statement2 = "delete from simple_output where collection_output_id = ?"); $siid && ($dbh->do( $statement1, undef,($siid))); $collid && ($dbh->do($statement2, undef,($collid))); From dwang at pub.open-bio.org Thu Jul 28 15:45:26 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu, 28 Jul 2005 15:45:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281945.j6SJjQrs005436@pub.open-bio.org> dwang Thu Jul 28 15:45:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv5410/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: and more.. moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 18:09:46 1.23 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 19:45:26 1.24 @@ -367,33 +367,56 @@ # # simple_output table functions # +=head2 query_simple_output + + Title : query_simple_output + Usage : my $un = $API->query_simple_output(%args) + Function : Executes a query for Simput outputs according to the service instance or collection output + Args : service_instance_lsid => String, + collection_output_id => Integer + Returns : listref of hashrefs: + [{simple_output_id => Integer, + object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_id => Integer, + collection_output_id => Integer}] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_simple_output{ die "query_simple_output not implemented in adaptor\n"; } +=head2 insert_simple_output + + Title : inse_simple_output + Usage : my $un = $API->insert_simple_output(%args) + Function : Inserts a Simple output into the database + Args : object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_lsid => String, + collection_output_id => Integer + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_simple_output { die "insert_simple_output not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - # - #$dbh->do("insert into simple_output - # (object_type_uri, - # namespace_type_uris, - # article_name, - # service_instance_id, - # collection_output_id) - # values (?,?,?,?,?)", - # undef, - # ($args{object_type_uri}, - # $args{namespace_type_uris}, - # $args{article_name}, - # $args{service_instance_id}, - # $args{collection_output_id})); - #my $id=$dbh->{mysql_insertid}; - #return $id; - } +=head2 delete_simple_output + + Title : delete_simple_output + Usage : my $un = $API->delete_simple_output(%args) + Function : Deletes Simple outputs according to the service instance, or collection output + Args : service_instance_lsid => String, + collection_output_id => Integer + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_simple_output{ die "delete_simple_output not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Thu Jul 28 16:41:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 16:41:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282041.j6SKfOaC005675@pub.open-bio.org> mwilkinson Thu Jul 28 16:41:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv5656/t Modified Files: Client-Central.t Log Message: adding more tests to ensure that collection registration is functioning properly. All existing tests now pass on the new codebase 0.85 moby-live/Perl/t Client-Central.t,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:25:06 1.10 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 20:41:24 1.11 @@ -15,8 +15,8 @@ # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/MOBY-Central.pl', - URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} + mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/MOBY-Central.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} } ); @@ -239,7 +239,102 @@ is($enum =~/\|10\|/, 1) or diag("enum element missing"); is($enum =~/\|0\|/, 1) or diag("enum element missing"); -# Test 12 + +$r = $C->registerService( + serviceName => "mysecondservice", + serviceType => "Retrieval", + authURI => "test.suite.com", + contactEmail => 'your at mail.address', + description => "this is my second service", + category => "moby", + URL => "http://illuminae/cgi-bin/service.pl", + input =>[ + ['articleName1', [[Object => ['UglyNamespace']]]], # Simple + ], + output =>[ + ['articleName2', [[String => ['UglyNamespace']]]], # Simple + ], + secondary => { + parametername1 => { + datatype => 'Integer', + default => 0, + max => 10, + min => -10, + enum => [-10, 10, 0]}}); + +( ok($r->success,"Service registration of collections successful") +) or diag("Service registration of collections failure: ".$r->message) ; + +# test 11 - find by auth & name +($si, $r) = $C->findService( + serviceName => "mysecondservice", + authURI => "test.suite.com"); +( is($r, undef, "Service discovery of collections successful") +) or diag("Service discovery of collections failure") ; + + + + + + +isa_ok($si, 'ARRAY') or diag("findService with collections didn't return an array ref"); +is(scalar(@$si),1) or diag("findService with collections found too many services"); +$SI = shift @$si; +print STDERR "$SI"; +isa_ok($SI, 'MOBY::Client::ServiceInstance') or diag("findService collections didn't return a MOBY::Client::ServceInstance"); +isa_ok($SI->input, ARRAY) or diag ("ServiceInstance object input is not a listref (collections test)"); +isa_ok($SI->output, ARRAY) or diag ("ServiceInstance object output is not a listref (collections test)"); +is($SI->name, "mysecondservice") or diag("servicename wrong (collections test)"); +is($SI->authoritative, 0) or diag("service reported to be incorrectly authoritative (collections test)"); +is($SI->authority, "test.suite.com") or diag("authURI incorrect (collections test)"); +is($SI->type, "Retrieval") or diag("service type incorrect (collections test)"); +is($SI->description, "this is my first service") or diag("service description wrong (collections test)"); +is($SI->URL, "http://illuminae/cgi-bin/service.pl") or diag("service URL incorrect (collections test)"); +is($SI->contactEmail, 'your at mail.address') or diag("contact email incorrect (collections test)"); +is($SI->category, "moby") or diag("service category incorrect (collections test)"); + + at ins = @{$SI->input}; + at outs = @{$SI->output}; + at secs = @{$SI->secondary}; +is(scalar(@ins), 1) or diag("incorrect number of inputs in servce instance (collections test)"); +is(scalar(@outs), 1) or diag("incorrect number of outputs in servce instance (collections test)"); +is(scalar(@secs), 1) or diag("incorrect number of secodary in servce instance (collections test)"); + +$in = shift @ins; +$out = shift @outs; +$sec = shift @secs; + +isa_ok($in, 'MOBY::Client::CollectionArticle') or diag("->inputs did not return a MOBY::collection_input object or client parser failed for MOBY::Client::CollectionArticle"); +isa_ok($out, 'MOBY::Client::CollectionArticle') or diag("->outputs did not return a MOBY::collection_output object or client parser failed for MOBY::Client::CollectionArticle"); +isa_ok($sec, 'MOBY::Client::SecondaryArticle') or diag("->secondarues did not return a MOBY::secondary_input object"); + +isa_ok($in->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); +isa_ok($out->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); +my $simplesin = $in->Simples; +my $simplesout = $out->Simples; + +is(scalar(@$simplesin), 1) or diag("->Simples returning wrong number of simple inputs in the collection"); +is(scalar(@$simplesout), 1) or diag("->Simples returning wrong number of simple outputs in the collection"); + +$in = shift(@$simplesin); +$out = shift(@$simplesout); + +is($in->objectType, "Object") or diag("simple input type reported incorrectly (collections test)"); +is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly (collections test)"); +isa_ok($in->namespaces, 'ARRAY') or diag("simple input namespaces not returned as an arrayref (collections test)"); + at ns = @{$in->namespaces}; +is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces (collections test)"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace (collections test)"); + +is($out->objectType, "String") or diag("simple output type reported incorrectly (collections test)"); +is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly (collections test)"); +isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref (collections test)"); + at ns = @{$out->namespaces}; +is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces (collections test)"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace (collections test)"); + $r = $C->deregisterService( serviceName => "myfirstservice", @@ -249,6 +344,19 @@ ) or diag("Service deregistration failure: ".$r->message) ; +$r = $C->deregisterService( + serviceName => "myfirstservice", + authURI => "test.suite.com", + ); +( ok(!$r->success,"Service deregistration successful") +) or diag("Service re-deregistration success (should have failed): ".$r->message) ; + +$r = $C->deregisterService( + serviceName => "mysecondservice", + authURI => "test.suite.com", + ); +( ok($r->success,"Service deregistration successful") +) or diag("Service deregistration failure (second service): ".$r->message) ; From mwilkinson at pub.open-bio.org Thu Jul 28 17:13:16 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:13:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282113.j6SLDG6c005809@pub.open-bio.org> mwilkinson Thu Jul 28 17:13:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv5790/MOBY Modified Files: Central.pm Log Message: wrong kinds of brackets in query for collection moby-live/Perl/MOBY Central.pm,1.189,1.190 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.189 retrieving revision 1.190 diff -u -r1.189 -r1.190 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 18:33:10 1.189 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:13:16 1.190 @@ -3303,8 +3303,6 @@ $output .= "\t$url\n"; $output .= "\t\n"; -#************FIX -#************FIX : $_ here should also be an LSID... $result = $adaptor->query_simple_input(service_instance_lsid => $lsid); foreach my $row (@$result) From mwilkinson at pub.open-bio.org Thu Jul 28 17:13:16 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:13:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282113.j6SLDGfY005828@pub.open-bio.org> mwilkinson Thu Jul 28 17:13:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5790/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: wrong kinds of brackets in query for collection moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.61,1.62 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 19:26:58 1.61 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:13:16 1.62 @@ -189,7 +189,7 @@ collection_input_id, article_name from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; - my $result = do_query($dbh, $statement, [$serv_lsid]); + my $result = do_query($dbh, $statement, ($serv_lsid)); return $result; } @@ -232,7 +232,7 @@ article_name, service_instance_id from collection_output where service_instance_id = ? "; - my $result = do_query($dbh, $statement, [$siid]); + my $result = do_query($dbh, $statement, ($siid)); return $result; } From mwilkinson at pub.open-bio.org Thu Jul 28 17:13:16 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:13:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282113.j6SLDGKi005848@pub.open-bio.org> mwilkinson Thu Jul 28 17:13:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv5790/t Modified Files: Client-Central.t Log Message: wrong kinds of brackets in query for collection moby-live/Perl/t Client-Central.t,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 20:41:24 1.11 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:13:16 1.12 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; #use SOAP::Lite +trace; -use Test::More tests => 54; # perldoc Test::More for details +use Test::More tests => 91; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; @@ -181,7 +181,6 @@ isa_ok($si, 'ARRAY') or diag("findService didn't return an array ref"); is(scalar(@$si),1) or diag("findService found too many services"); $SI = shift @$si; -print STDERR "$SI"; isa_ok($SI, 'MOBY::Client::ServiceInstance') or diag("findService didn't return a MOBY::Client::ServceInstance"); isa_ok($SI->input, ARRAY) or diag ("ServiceInstance object input is not a listref"); isa_ok($SI->output, ARRAY) or diag ("ServiceInstance object output is not a listref"); @@ -288,7 +287,7 @@ is($SI->authoritative, 0) or diag("service reported to be incorrectly authoritative (collections test)"); is($SI->authority, "test.suite.com") or diag("authURI incorrect (collections test)"); is($SI->type, "Retrieval") or diag("service type incorrect (collections test)"); -is($SI->description, "this is my first service") or diag("service description wrong (collections test)"); +is($SI->description, "this is my second service") or diag("service description wrong (collections test)"); is($SI->URL, "http://illuminae/cgi-bin/service.pl") or diag("service URL incorrect (collections test)"); is($SI->contactEmail, 'your at mail.address') or diag("contact email incorrect (collections test)"); is($SI->category, "moby") or diag("service category incorrect (collections test)"); From mwilkinson at pub.open-bio.org Thu Jul 28 17:26:59 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:26:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282126.j6SLQx1O005938@pub.open-bio.org> mwilkinson Thu Jul 28 17:26:59 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv5919/MOBY Modified Files: Central.pm Log Message: query for collections was wrong moby-live/Perl/MOBY Central.pm,1.190,1.191 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.190 retrieving revision 1.191 diff -u -r1.190 -r1.191 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:13:16 1.190 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:26:59 1.191 @@ -3332,7 +3332,7 @@ $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_input_id => $collid); + my $result2 = $adaptor->query_simple_input(service_instance_lsid => undef, collection_input_id => $collid); foreach my $row2 (@$result2) { my $objURI = $row2->{object_type_uri}; From mwilkinson at pub.open-bio.org Thu Jul 28 17:26:59 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:26:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282126.j6SLQx0l005958@pub.open-bio.org> mwilkinson Thu Jul 28 17:26:59 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5919/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query for collections was wrong moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.62,1.63 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:13:16 1.62 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:26:59 1.63 @@ -269,6 +269,8 @@ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $collid = $args{collection_input_id}; + my $id_to_use = $siid?$siid:$collid; + my $dbh = $self->dbh; my $statement = "select @@ -282,10 +284,10 @@ my $condition; $siid && ($condition = " service_instance_id = ? and collection_input_id IS NULL"); - $collid && ($condition = " service_instance_id IS NULL and collection_input_id = ?"); + $collid && ($condition = " collection_input_id = ?"); $statement .= $condition; - my $result = do_query($dbh, $statement, ($siid || $collid)); + my $result = do_query($dbh, $statement, ($id_to_use)); return $result; } @@ -362,6 +364,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $collid = $args{collection_output_id}; my $dbh = $self->dbh; + my $id_to_use = $siid?$siid:$collid; my $statement = "select simple_output_id, @@ -373,11 +376,11 @@ from simple_output where "; my $condition; $siid && ($condition = " service_instance_id = ? and collection_output_id IS NULL"); - $collid && ($condition = " service_instance_id IS NULL and collection_output_id = ?"); + $collid && ($condition = " collection_output_id = ?"); $statement .= $condition; - my $result = do_query($dbh, $statement, ($siid || $collid)); + my $result = do_query($dbh, $statement, ($id_to_use)); return $result; } From mwilkinson at pub.open-bio.org Thu Jul 28 17:28:39 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:28:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282128.j6SLSdeB006026@pub.open-bio.org> mwilkinson Thu Jul 28 17:28:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv6007/MOBY Modified Files: Central.pm Log Message: missing quotes around XML attribute moby-live/Perl/MOBY Central.pm,1.191,1.192 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.191 retrieving revision 1.192 diff -u -r1.191 -r1.192 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:26:59 1.191 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:28:39 1.192 @@ -3344,7 +3344,7 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); $output .= "\t\t\t\t$NSname\n" From mwilkinson at pub.open-bio.org Thu Jul 28 17:32:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:32:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282132.j6SLWviB006097@pub.open-bio.org> mwilkinson Thu Jul 28 17:32:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv6078/t Modified Files: Client-Central.t Log Message: tests were wrong moby-live/Perl/t Client-Central.t,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:13:16 1.12 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:32:57 1.13 @@ -306,6 +306,8 @@ isa_ok($in, 'MOBY::Client::CollectionArticle') or diag("->inputs did not return a MOBY::collection_input object or client parser failed for MOBY::Client::CollectionArticle"); isa_ok($out, 'MOBY::Client::CollectionArticle') or diag("->outputs did not return a MOBY::collection_output object or client parser failed for MOBY::Client::CollectionArticle"); isa_ok($sec, 'MOBY::Client::SecondaryArticle') or diag("->secondarues did not return a MOBY::secondary_input object"); +is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly (collections test)"); +is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly (collections test)"); isa_ok($in->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); isa_ok($out->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); @@ -319,7 +321,6 @@ $out = shift(@$simplesout); is($in->objectType, "Object") or diag("simple input type reported incorrectly (collections test)"); -is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly (collections test)"); isa_ok($in->namespaces, 'ARRAY') or diag("simple input namespaces not returned as an arrayref (collections test)"); @ns = @{$in->namespaces}; is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces (collections test)"); From mwilkinson at pub.open-bio.org Thu Jul 28 17:36:07 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:36:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282136.j6SLa74C006165@pub.open-bio.org> mwilkinson Thu Jul 28 17:36:07 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv6146/MOBY Modified Files: Central.pm Log Message: looking for namespace_type_uri instead of ..._uris moby-live/Perl/MOBY Central.pm,1.192,1.193 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.192 retrieving revision 1.193 diff -u -r1.192 -r1.193 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:28:39 1.192 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:36:07 1.193 @@ -3336,7 +3336,7 @@ foreach my $row2 (@$result2) { my $objURI = $row2->{object_type_uri}; - my $nsURI = $row2->{namespace_type_uri}; + my $nsURI = $row2->{namespace_type_uris}; my $article = $row2->{article_name}; my $objName = $OSobj->getObjectCommonName($objURI); From mwilkinson at pub.open-bio.org Thu Jul 28 17:40:31 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:40:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282140.j6SLeVE3006292@pub.open-bio.org> mwilkinson Thu Jul 28 17:40:31 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv6273/t Modified Files: Client-Central.t Log Message: test was wrong moby-live/Perl/t Client-Central.t,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:32:57 1.13 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:40:31 1.14 @@ -328,7 +328,6 @@ is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace (collections test)"); is($out->objectType, "String") or diag("simple output type reported incorrectly (collections test)"); -is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly (collections test)"); isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref (collections test)"); @ns = @{$out->namespaces}; is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces (collections test)"); From mwilkinson at pub.open-bio.org Thu Jul 28 18:10:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 18:10:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282210.j6SMABVG006403@pub.open-bio.org> mwilkinson Thu Jul 28 18:10:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv6384/MOBY/Client Modified Files: Central.pm Log Message: starting to update Cient libraries to make LSID avialble moby-live/Perl/MOBY/Client Central.pm,1.101,1.102 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.101 retrieving revision 1.102 diff -u -r1.101 -r1.102 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 23:05:04 1.101 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:10:11 1.102 @@ -497,9 +497,10 @@ my ($return) = $self->_call( 'default', 'retrieveObjectDefinition', $message ); return \%def unless $return; - my ( $term, $desc, $relationships, $email, $authURI ) = + my ( $term, $lsid, $desc, $relationships, $email, $authURI ) = &_ObjectDefinitionPayload($return); $def{objectType} = $term; + $def{objectLSID} = $lsid; $def{description} = $desc; $def{contactEmail} = $email; $def{authURI} = $authURI; @@ -516,6 +517,7 @@ my $obj = $Object->nodeName; return undef unless ( $obj eq 'retrieveObjectDefinition' ); my $term = &_nodeTextContent( $Object, "objectType" ); + my $lsid = &_nodeAttributeValue( $Object, "objectType", "lsid"); my $desc = &_nodeCDATAContent( $Object, "Description" ); if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; @@ -1970,6 +1972,32 @@ return $content; } +sub _nodeAttributeContent { + + # will get text of **all** child $node from the given $DOM + # regardless of their depth!! + my ( $DOM, $node, $attr ) = @_; + my $x = $DOM->getElementsByTagName($node); + unless ( $x->get_node(1) ) { return } + my $n = $x->get_node(1); + my @att = $n->attributes($attr); + my $atval; + if (scalar(@att)){ + $atval = $attr->getValue; + } + my @child = $x->get_node(1)->childNodes; + my $content; + foreach (@child) { + + #print getNodeTypeName($_), "\t", $_->toString,"\n"; + next + unless ( ( $_->nodeType == TEXT_NODE ) + || ( $_->nodeType == CDATA_SECTION_NODE ) ); + $content = $_->textContent; + } + return $content; +} + sub _nodeRawContent { # will get XML of **all** child $node from the given $DOM From mwilkinson at pub.open-bio.org Thu Jul 28 18:18:05 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 18:18:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282218.j6SMI5bT006471@pub.open-bio.org> mwilkinson Thu Jul 28 18:18:05 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv6452/MOBY/Client Modified Files: Central.pm Log Message: starting to update Cient libraries to make LSID avialble moby-live/Perl/MOBY/Client Central.pm,1.102,1.103 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.102 retrieving revision 1.103 diff -u -r1.102 -r1.103 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:10:11 1.102 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:18:05 1.103 @@ -484,7 +484,8 @@ =cut sub retrieveObjectDefinition { - my ( $self, $id, $reg ) = @_; + my ( $self, %a ) = @_; + my $id = $a{objectType}; return $self->errorRegXML( "Function not allowed when querying multiple registries") if $self->multiple_registries; From dwang at pub.open-bio.org Fri Jul 29 03:50:04 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Fri, 29 Jul 2005 03:50:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507290750.j6T7o4db007547@pub.open-bio.org> dwang Fri Jul 29 03:50:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv7522/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: almost there moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 19:45:26 1.24 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/29 07:50:04 1.25 @@ -295,15 +295,36 @@ Notes : the fact that it returns a collection_input_id is bad since this is only useful to an SQL-based API... =cut - sub query_collection_input{ die "query_collection_input not implemented in adaptor\n"; } +=head2 insert_collection_input + + Title : insert_collection_input + Usage : my $un = $API->insert_collection_input(%args) + Function : Inserts a Collection input into the database + Args : article_name => String, + service_instance_lsid => String, + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_collection_input { die "insert_collection_input not implemented in adaptor\n"; } +=head2 delete_collection_input + + Title : delete_collection_input + Usage : my $un = $API->delete_collection_input(%args) + Function : Deletes Collection inputs according to the service instance + Args : service_instance_lsid => String, + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_collection_input{ die "delete_collection_input not implemented in adaptor\n"; } @@ -311,10 +332,34 @@ # # collection_output table fuctions # +=head2 query_collection_output + + Title : query_collection_output + Usage : my $un = $API->query_collection_output(%args) + Function : Executes a query for Collection outputs according to the service instance + Args : service_instance_lsid => String, + Returns : listref of hashrefs: + [{collection_output_id => Integer, + article_name => String, + service_instance_id => Integer, + }] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_collection_output{ die "query_collection_output not implemented in adaptor\n"; } +=head2 insert_collection_output + + Title : insert_collection_output + Usage : my $un = $API->insert_collection_output(%args) + Function : Inserts a Collection output into the database + Args : article_name => String, + service_instance_lsid => String, + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_collection_output { die "insert_collection_output not implemented in adaptor\n"; #my ($self, %args) = @_; @@ -327,6 +372,17 @@ #} } +=head2 delete_collection_output + + Title : delete_collection_output + Usage : my $un = $API->delete_collection_output(%args) + Function : Deletes Collection outputs according to the service instance + Args : service_instance_lsid => String, + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_collection_output{ die "delete_collection_output not implemented in adaptor\n"; } @@ -334,32 +390,56 @@ # # simple_output table functions # +=head2 query_simple_input + + Title : query_simple_input + Usage : my $un = $API->query_simple_input(%args) + Function : Executes a query for Simple inputs according to the service instance or collection output + Args : service_instance_lsid => String, + collection_input_id => Integer + Returns : listref of hashrefs: + [{simple_input_id => Integer, + object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_id => Integer, + collection_input_id => Integer}] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_simple_input{ die "query_simple_input not implemented in adaptor\n"; } +=head2 insert_simple_input + + Title : insert_simple_input + Usage : my $un = $API->insert_simple_input(%args) + Function : Inserts a Simple input into the database + Args : object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_lsid => String, + collection_input_id => Integer + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_simple_input { die "insert_simple_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - # - #$dbh->do("insert into simple_input - # (object_type_uri, - # namespace_type_uris, - # article_name, - # service_instance_id, - # collection_input_id) - # values (?,?,?,?,?)", - # undef, - # ($args{object_type_uri}, - # $args{namespace_type_uris}, - # $args{article_name}, - # $args{service_instance_id}, - # $args{collection_input_id})); - #my $id=$dbh->{mysql_insertid}; - #return $id; } +=head2 delete_simple_input + + Title : delete_simple_input + Usage : my $un = $API->delete_simple_input(%args) + Function : Deletes Simple inputs according to the service instance, or collection input + Args : service_instance_lsid => String, + collection_input_id => Integer + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_simple_input{ die "delete_simple_input not implemented in adaptor\n"; } @@ -371,7 +451,7 @@ Title : query_simple_output Usage : my $un = $API->query_simple_output(%args) - Function : Executes a query for Simput outputs according to the service instance or collection output + Function : Executes a query for Simple outputs according to the service instance or collection output Args : service_instance_lsid => String, collection_output_id => Integer Returns : listref of hashrefs: From mwilkinson at pub.open-bio.org Fri Jul 29 10:17:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 10:17:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291417.j6TEHoZ3008780@pub.open-bio.org> mwilkinson Fri Jul 29 10:17:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv8757/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: OntologyServer passing wrong arguments when registering new relationships. Now passes LSIDs instead of database IDs moby-live/Perl/MOBY Central.pm,1.193,1.194 OntologyServer.pm,1.68,1.69 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.193 retrieving revision 1.194 diff -u -r1.193 -r1.194 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:36:07 1.193 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 14:17:49 1.194 @@ -486,7 +486,6 @@ $OntologyServer->objectExists( term => $class ); return &_error( "Object class $class does not exist", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new()->dbh; my $errormsg = $adaptor->check_object_usage(type => $existingURI); return &_error( =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 18:33:10 1.68 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 14:17:49 1.69 @@ -485,8 +485,8 @@ qq{Relationship $args{relationship} does not exist in the ontology}, '' ); my $insertid = $adaptor->insert_object_term2term(relationship_type => $rel_lsid, - object1_id => $subj_lsid, - object2_id => $obj_lsid, + object1_type => $subj_lsid, + object2_type => $obj_lsid, object2_articlename => $args{articleName}); if ($insertid ) { return ( 1, "Object relationsihp created successfully", '' ); From mwilkinson at pub.open-bio.org Fri Jul 29 10:27:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 10:27:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291427.j6TERjFd008863@pub.open-bio.org> mwilkinson Fri Jul 29 10:27:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv8844/MOBY Modified Files: service_instance.pm Log Message: deregistration of services was not cleaning up the inputs and outputs from the database because the service was deleted prior to the parameters, leaving them unable to look up the database id of their parent service LSID moby-live/Perl/MOBY service_instance.pm,1.32,1.33 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 15:29:38 1.32 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/29 14:27:45 1.33 @@ -268,7 +268,6 @@ # the routines below know too much about the database (e.g. that # the delete_simple_input routines are broken into two parts - by LSID and # by collecion ID... BAD BAD BAD - $adaptor->delete_service_instance(service_instance_lsid => $self->lsid); $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); @@ -288,6 +287,7 @@ $adaptor->delete_collection_input(service_instance_lsid => $self->lsid); $adaptor->delete_collection_output(service_instance_lsid => $self->lsid); $adaptor->delete_secondary_input(service_instance_lsid => $self->lsid); + $adaptor->delete_service_instance(service_instance_lsid => $self->lsid); return 1; } From mwilkinson at pub.open-bio.org Fri Jul 29 10:38:15 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 10:38:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291438.j6TEcFA7008957@pub.open-bio.org> mwilkinson Fri Jul 29 10:38:15 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv8938/t Modified Files: Client-Central.t Log Message: adding new tests for the less used mobycentral functions moby-live/Perl/t Client-Central.t,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:40:31 1.14 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 14:38:15 1.15 @@ -30,7 +30,7 @@ ################## MOBY Registration Tests ################# # Test 3 -$r = $C->registerObjectClass(objectType => "TotalCrap", +$r = $C->registerObjectClass(objectType => "Rubbish", description => "a human-readable description of the object", contactEmail => 'your at email.address', authURI => "test.suite.com", @@ -48,7 +48,7 @@ # Test 4 -$r = $C->registerObjectClass(objectType => "TotalCrap", +$r = $C->registerObjectClass(objectType => "Rubbish", description => "a human-readable description of the object", contactEmail => 'your at email.address', authURI => "test.suite.com", @@ -66,7 +66,7 @@ # Test 5 -$r = $C->deregisterObjectClass(objectType => "TotalCrap"); +$r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful")) or diag("Object deregistration failure: ".$r->message) ; @@ -74,7 +74,7 @@ # Test 6 (identical to #4 -$r = $C->registerObjectClass(objectType => "TotalCrap", +$r = $C->registerObjectClass(objectType => "Rubbish", description => "a human-readable description of the object", contactEmail => 'your at email.address', authURI => "test.suite.com", @@ -93,7 +93,7 @@ # Test 7 $r = $C->registerNamespace( - namespaceType =>'UglyNamespace', + namespaceType =>'RubbishNamespace', authURI => 'your.authority.URI', description => "human readable description of namespace", contactEmail => 'your at address.here'); @@ -104,7 +104,7 @@ # Test 8 -$r = $C->registerServiceType(serviceType => "CrappyService", +$r = $C->registerServiceType(serviceType => "RubbishyService", description => "a human-readable description of the service", contactEmail => 'your at email.address', authURI => "test.suite.com", @@ -127,10 +127,10 @@ category => "moby", URL => "http://illuminae/cgi-bin/service.pl", input =>[ - ['articleName1', [Object => ['UglyNamespace']]], # Simple + ['articleName1', [Object => ['RubbishNamespace']]], # Simple ], output =>[ - ['articleName2', [String => ['UglyNamespace']]], # Simple + ['articleName2', [String => ['RubbishNamespace']]], # Simple ], secondary => { parametername1 => { @@ -155,10 +155,10 @@ category => "moby", URL => "http://illuminae/cgi-bin/service.pl", input =>[ - ['articleName1', [Object => ['UglyNamespace']]], # Simple + ['articleName1', [Object => ['RubbishNamespace']]], # Simple ], output =>[ - ['articleName2', [String => ['UglyNamespace']]], # Simple + ['articleName2', [String => ['RubbishNamespace']]], # Simple ], secondary => { parametername1 => { @@ -214,7 +214,7 @@ @ns = @{$in->namespaces}; is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace"); +is($ns, 'RubbishNamespace') or diag("simple input reporting wrong namespace"); is($out->objectType, "String") or diag("simple output type reported incorrectly"); is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly"); @@ -222,7 +222,7 @@ @ns = @{$out->namespaces}; is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace"); +is($ns, 'RubbishNamespace') or diag("simple output reporting wrong namespace"); is($sec->articleName, 'parametername1') or diag("secondary article reporting wrong article name"); is($sec->datatype, 'Integer') or diag("secondary article reporting wrong datatype"); @@ -248,10 +248,10 @@ category => "moby", URL => "http://illuminae/cgi-bin/service.pl", input =>[ - ['articleName1', [[Object => ['UglyNamespace']]]], # Simple + ['articleName1', [[Object => ['RubbishNamespace']]]], # Simple ], output =>[ - ['articleName2', [[String => ['UglyNamespace']]]], # Simple + ['articleName2', [[String => ['RubbishNamespace']]]], # Simple ], secondary => { parametername1 => { @@ -325,14 +325,14 @@ @ns = @{$in->namespaces}; is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces (collections test)"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace (collections test)"); +is($ns, 'RubbishNamespace') or diag("simple input reporting wrong namespace (collections test)"); is($out->objectType, "String") or diag("simple output type reported incorrectly (collections test)"); isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref (collections test)"); @ns = @{$out->namespaces}; is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces (collections test)"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace (collections test)"); +is($ns, 'RubbishNamespace') or diag("simple output reporting wrong namespace (collections test)"); $r = $C->deregisterService( @@ -359,15 +359,22 @@ -# Test 12 -$r = $C->deregisterObjectClass(objectType => "TotalCrap"); +# TESTS FOR ONTOLOGY TRAVERSAL AND SO ON + +$r = $C->retrieveObjectDefinition(objectType => "Rubbish"); +isa_ok($r , "HASH", "Object definition returns hashref") or diag("Object definition did not return as a hashref") ; + + + + +$r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; # Test 13 -$r = $C->deregisterServiceType(serviceType => "CrappyService"); +$r = $C->deregisterServiceType(serviceType => "RubbishyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; @@ -375,7 +382,7 @@ # Test 44 -$r = $C->deregisterNamespace(namespaceType =>'UglyNamespace'); +$r = $C->deregisterNamespace(namespaceType =>'RubbishNamespace'); ( ok($r->success,"namespace deregistration successful") ) or diag("namespace deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 11:07:40 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:07:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291507.j6TF7eqY009070@pub.open-bio.org> mwilkinson Fri Jul 29 11:07:40 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv9047/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: subroutine misnamed moby-live/Perl/MOBY Central.pm,1.194,1.195 OntologyServer.pm,1.69,1.70 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.194 retrieving revision 1.195 diff -u -r1.194 -r1.195 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 14:17:49 1.194 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 15:07:40 1.195 @@ -2678,7 +2678,7 @@ $OS->retrieveObject( node => $term ) ; # will return undef if this term does not exist, and does not look like an LSID return "" unless $def; - my %def = %{ $OS->retrieveObject( node => $term ) }; + my %def = %{ $OS->retrieveObject( type => $term ) }; if ( $def{description} =~ /[^\]]+))\]\]>/ ) { $def{description} = $1; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 14:17:49 1.69 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 15:07:40 1.70 @@ -292,13 +292,15 @@ my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); - my $term = $args{'node'}; + my $term = $args{'type'}; + $term ||=$args{'node'}; + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node as an argument", '' ) - unless ( $args{'node'} ); + unless ( $term ); my $LSID = - ( $args{'node'} =~ /urn\:lsid/ ) - ? $args{'node'} + ( $term =~ /urn\:lsid/ ) + ? $term : $self->getObjectURI($term); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } my $result = $adaptor->query_object(type => $LSID); From mwilkinson at pub.open-bio.org Fri Jul 29 11:07:40 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:07:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291507.j6TF7eM6009090@pub.open-bio.org> mwilkinson Fri Jul 29 11:07:40 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv9047/MOBY/Client Modified Files: Central.pm Log Message: subroutine misnamed moby-live/Perl/MOBY/Client Central.pm,1.103,1.104 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:18:05 1.103 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:07:40 1.104 @@ -141,11 +141,11 @@ Connections => [ undef, 'read/write' ], default_MOBY_servername => [ 'mobycentral', 'read/write' ], default_MOBY_server => [ - 'http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY05/mobycentral.pl', + 'http://mobycentral.icpture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', 'read/write' ], default_MOBY_uri => - [ 'http://mobycentral.cbr.nrc.ca/MOBY/Central', 'read/write' ], + [ 'http://mobycentral.icapture.ubc.ca/MOBY/Central', 'read/write' ], default_MOBY_proxy => [ undef, 'read/write' ], default_MOBY_type => [ 'soap', 'read/write' ], Registries => [ undef, 'read/write' ], @@ -1973,7 +1973,7 @@ return $content; } -sub _nodeAttributeContent { +sub _nodeAttributeValue { # will get text of **all** child $node from the given $DOM # regardless of their depth!! From mwilkinson at pub.open-bio.org Fri Jul 29 11:41:01 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:41:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291541.j6TFf1a8009260@pub.open-bio.org> mwilkinson Fri Jul 29 11:41:01 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv9241/MOBY/Client Modified Files: Central.pm Log Message: XML::LibXML documentation is crappy. Had to read the source to figure out the NamedNodeMap interface. Can now retrieve the value of the LSID attribute moby-live/Perl/MOBY/Client Central.pm,1.104,1.105 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.104 retrieving revision 1.105 diff -u -r1.104 -r1.105 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:07:40 1.104 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:41:01 1.105 @@ -1975,28 +1975,15 @@ sub _nodeAttributeValue { - # will get text of **all** child $node from the given $DOM - # regardless of their depth!! my ( $DOM, $node, $attr ) = @_; + return "" unless $attr; my $x = $DOM->getElementsByTagName($node); - unless ( $x->get_node(1) ) { return } + unless ( $x->get_node(1) ) { return "" } my $n = $x->get_node(1); - my @att = $n->attributes($attr); - my $atval; - if (scalar(@att)){ - $atval = $attr->getValue; - } - my @child = $x->get_node(1)->childNodes; - my $content; - foreach (@child) { - - #print getNodeTypeName($_), "\t", $_->toString,"\n"; - next - unless ( ( $_->nodeType == TEXT_NODE ) - || ( $_->nodeType == CDATA_SECTION_NODE ) ); - $content = $_->textContent; - } - return $content; + my $nodemap = $n->attributes($attr); # XML::LibXML::NamedNodeMap - the worst documented (i.e. undocumented) piece of code ever written! You have to read the source to figure out the interface... + my $attrnode = $nodemap->getNamedItem($attr); + my $attrval = $attrnode?($attrnode->value):""; + return $attrval; } sub _nodeRawContent { From mwilkinson at pub.open-bio.org Fri Jul 29 11:43:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:43:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291543.j6TFhQ8a009326@pub.open-bio.org> mwilkinson Fri Jul 29 11:43:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv9307/MOBY/Client Modified Files: Central.pm Log Message: adding LSID to return values moby-live/Perl/MOBY/Client Central.pm,1.105,1.106 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.105 retrieving revision 1.106 diff -u -r1.105 -r1.106 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:41:01 1.105 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:43:26 1.106 @@ -556,7 +556,7 @@ } } } - return ( $term, $desc, \%relationships, $email, $authURI ); + return ( $term, $lsid, $desc, \%relationships, $email, $authURI ); } =head2 registerServiceType From mwilkinson at pub.open-bio.org Fri Jul 29 11:54:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:54:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291554.j6TFsDT0009399@pub.open-bio.org> mwilkinson Fri Jul 29 11:54:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9380/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 14:38:15 1.15 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:54:13 1.16 @@ -363,9 +363,33 @@ $r = $C->retrieveObjectDefinition(objectType => "Rubbish"); isa_ok($r , "HASH", "Object definition returns hashref") or diag("Object definition did not return as a hashref") ; - - - +is($r->objectType, "Rubbish", "Object reporting correct name") or diag("Object definition did not report correct name"); +is($r->description, "a human-readable description of the object", "Object reporting correct desc") or diag("Object definition did not report correct desc"); +is($r->contactEmail, 'your at email.address', "Object reporting correct email") or diag("Object definition did not report correct email"); +is($r->authURI, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); +isa_ok($r->Relationships, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); +%rel = %{$r->Relationships}; +isa_ok($rel{ISA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); +isa_ok($rel{HASA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); +$isa = shift@{$rel{ISA}}; +$hasa = shift@{$rel{HASA}}; +isa_ok($isa, "ARRAY","") or diag("Object didn't return an array of arrays for its ISA relationships"); +isa_ok($hasa, "ARRAY","") or diag("Object didn't return an array of arrays for its HASA relationships"); +is(${$isa}[0], 'Object') or diag("ISA reporting wrong object type"); +is(${$isa}[1], 'article1') or diag("ISA reporting wrong object type"); +is(${$hasa}[0], 'Object') or diag("ISA reporting wrong object type"); +is(${$hasa}[1], 'articleName3') or diag("ISA reporting wrong object type"); + +#objectType => "Rubbish", +# description => "a human-readable description of the object", +# contactEmail => 'your at email.address', +# authURI => "test.suite.com", +# Relationships => { +# ISA => [ +# ['Object', 'article1']], +# HASA => [ +# ['Object', 'articleName3']]} +# ); $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") From mwilkinson at pub.open-bio.org Fri Jul 29 11:55:17 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:55:17 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291555.j6TFtHaf009477@pub.open-bio.org> mwilkinson Fri Jul 29 11:55:17 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9458/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:54:13 1.16 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:55:17 1.17 @@ -363,12 +363,12 @@ $r = $C->retrieveObjectDefinition(objectType => "Rubbish"); isa_ok($r , "HASH", "Object definition returns hashref") or diag("Object definition did not return as a hashref") ; -is($r->objectType, "Rubbish", "Object reporting correct name") or diag("Object definition did not report correct name"); -is($r->description, "a human-readable description of the object", "Object reporting correct desc") or diag("Object definition did not report correct desc"); -is($r->contactEmail, 'your at email.address', "Object reporting correct email") or diag("Object definition did not report correct email"); -is($r->authURI, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); -isa_ok($r->Relationships, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); -%rel = %{$r->Relationships}; +is($r->{objectType}, "Rubbish", "Object reporting correct name") or diag("Object definition did not report correct name"); +is($r->{description}, "a human-readable description of the object", "Object reporting correct desc") or diag("Object definition did not report correct desc"); +is($r->{contactEmail}, 'your at email.address', "Object reporting correct email") or diag("Object definition did not report correct email"); +is($r->{authURI}, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); +isa_ok($r->{Relationships}, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); +%rel = %{$r->{Relationships}}; isa_ok($rel{ISA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); isa_ok($rel{HASA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); $isa = shift@{$rel{ISA}}; From mwilkinson at pub.open-bio.org Fri Jul 29 12:00:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:00:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291600.j6TG0I7O009571@pub.open-bio.org> mwilkinson Fri Jul 29 12:00:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9552/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:55:17 1.17 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:00:18 1.18 @@ -369,10 +369,10 @@ is($r->{authURI}, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); isa_ok($r->{Relationships}, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); %rel = %{$r->{Relationships}}; -isa_ok($rel{ISA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); -isa_ok($rel{HASA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); -$isa = shift@{$rel{ISA}}; -$hasa = shift@{$rel{HASA}}; +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:hasa'}, "ARRAY", "Object reporting correct HASA as arrayref") or diag("Object definition did not report HASA arrayref"); +$isa = shift@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}; +$hasa = shift@{$rel{'urn:lsid:biomoby.org:objectrelation:hasa'}}; isa_ok($isa, "ARRAY","") or diag("Object didn't return an array of arrays for its ISA relationships"); isa_ok($hasa, "ARRAY","") or diag("Object didn't return an array of arrays for its HASA relationships"); is(${$isa}[0], 'Object') or diag("ISA reporting wrong object type"); From mwilkinson at pub.open-bio.org Fri Jul 29 12:01:34 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:01:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291601.j6TG1YSb009616@pub.open-bio.org> mwilkinson Fri Jul 29 12:01:34 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9597/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:00:18 1.18 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:01:34 1.19 @@ -379,17 +379,8 @@ is(${$isa}[1], 'article1') or diag("ISA reporting wrong object type"); is(${$hasa}[0], 'Object') or diag("ISA reporting wrong object type"); is(${$hasa}[1], 'articleName3') or diag("ISA reporting wrong object type"); +is($r->{objectLSID}, "urn:lsid:biomoby.org:objectclass:Rubbish") or diag("Object class LSID reported incorrectly"); -#objectType => "Rubbish", -# description => "a human-readable description of the object", -# contactEmail => 'your at email.address', -# authURI => "test.suite.com", -# Relationships => { -# ISA => [ -# ['Object', 'article1']], -# HASA => [ -# ['Object', 'articleName3']]} -# ); $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") From mwilkinson at pub.open-bio.org Fri Jul 29 12:12:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:12:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291612.j6TGC2wZ009701@pub.open-bio.org> mwilkinson Fri Jul 29 12:12:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9682/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:01:34 1.19 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:12:02 1.20 @@ -335,6 +335,18 @@ is($ns, 'RubbishNamespace') or diag("simple output reporting wrong namespace (collections test)"); + +#$names{$AuthURI} = [serviceName_1, serviceName_2, serviceName3...] +$r = $C->retrieveServiceNames(); +isa_ok($r, "HASH", "Service Names Hash") or diag("retrieveServiceNames didn't return a hashref") ; +%sn = %{$r}; +isa_ok($sn{'test.suite.com'}, "ARRAY") or diag("retrieveServiceNames didn't return a hasref of arrayrefs"); +$s1 = shift@{$sn{'test.suite.com'}}; +$s2 = shift@{$sn{'test.suite.com'}}; +ok((($s1 =~ /myfirstservice/) || ($s1 =~ /mysecondservice/))) or diag("retrieveServiceNames didn't return myfirstservice"); +ok((($s2 =~ /myfirstservice/) || ($s2 =~ /mysecondservice/))) or diag("retrieveServiceNames didn't return mysecondservice"); + + $r = $C->deregisterService( serviceName => "myfirstservice", authURI => "test.suite.com", @@ -382,6 +394,13 @@ is($r->{objectLSID}, "urn:lsid:biomoby.org:objectclass:Rubbish") or diag("Object class LSID reported incorrectly"); +$r = $C->retrieveNamespaces(); +isa_ok($r, "HASH", "Namespace hash") or diag("retrieveNamespaces didn't return a hashref") ; +%ns = %{$r}; +is($ns{RubbishNamespace}, "human readable description of the namespace") or diag("namespace definition not returned correctly"); + + + $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 12:20:43 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:20:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291620.j6TGKhC0009774@pub.open-bio.org> mwilkinson Fri Jul 29 12:20:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv9755/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: querynamespace returned nothing if no parameter was passed. It should return everything moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:26:59 1.63 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:20:43 1.64 @@ -966,13 +966,15 @@ sub query_namespace{ my ($self, %args) = @_; my $type = $args{type}; - return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ $condition = " where namespace_lsid = ?"; } elsif ($type) { $condition = " where namespace_type = ?"; + } else { + $condition = ""; } + my $dbh = _getDBHandle("mobynamespace"); my $statement = "select From mwilkinson at pub.open-bio.org Fri Jul 29 12:35:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:35:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291635.j6TGZM4A010137@pub.open-bio.org> mwilkinson Fri Jul 29 12:35:22 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10118/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:12:02 1.20 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:35:22 1.21 @@ -397,8 +397,33 @@ $r = $C->retrieveNamespaces(); isa_ok($r, "HASH", "Namespace hash") or diag("retrieveNamespaces didn't return a hashref") ; %ns = %{$r}; -is($ns{RubbishNamespace}, "human readable description of the namespace") or diag("namespace definition not returned correctly"); +is($ns{RubbishNamespace}, "human readable description of namespace") or diag("namespace definition not returned correctly"); +$r = $C->retrieveServiceTypes(); +isa_ok($r, "HASH", "Service types hash") or diag("retrieveServiceTypes didn't return a hashref") ; +%st = %{$r}; +is($st{RubbishyService}, "a human-readable description of the service") or diag("service type definition not returned correctly"); + + +$r = $C->retrieveObjectNames(); +isa_ok($r, "HASH", "Object types hash") or diag("retrieveObjectNames didn't return a hashref") ; +%on = %{$r}; +is($on{Rubbish}, "a human-readable description of the object") or diag("object name definition not returned correctly"); + + +$r = $C->Relationships(objectType => "Rubbish"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; +%rel= %{$r}; +print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); +is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "urn:lsid:biomoby.org:objectclass:Object") or diag("Relationships arrayref didn't return the right parentage."); + +$r = $C->Relationships(serviceType => "RubbishyService"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; +%rel= %{$r}; +print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); +is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "urn:lsid:biomoby.org:servicetype:Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); $r = $C->deregisterObjectClass(objectType => "Rubbish"); @@ -407,7 +432,7 @@ -# Test 13 +# Test 13 is a retrieval $r = $C->deregisterServiceType(serviceType => "RubbishyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 12:42:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:42:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291642.j6TGgnxe010267@pub.open-bio.org> mwilkinson Fri Jul 29 12:42:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv10248/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query service needs to return everything instead of nothng when called with no parameter moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.64,1.65 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:20:43 1.64 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:42:49 1.65 @@ -807,12 +807,13 @@ sub query_service{ my ($self, %args) = @_; my $type = $args{type}; - return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ $condition = "where service_lsid = ?"; } elsif ($type) { $condition = "where service_type = ?"; + } else { + $condition = ""; } my $dbh = _getDBHandle("mobyservice"); From mwilkinson at pub.open-bio.org Fri Jul 29 12:46:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:46:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291646.j6TGkMiu010335@pub.open-bio.org> mwilkinson Fri Jul 29 12:46:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv10316/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: extra comma in SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.65,1.66 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:42:49 1.65 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:46:21 1.66 @@ -883,7 +883,7 @@ assertion_id, relationship_type, service1_id, - service2_id, + service2_id from service_term2term where service2_id = ?"; my $result2 = do_query($dbh, $statement, ($id)); return $result2; From mwilkinson at pub.open-bio.org Fri Jul 29 13:11:04 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:11:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291711.j6THB4gn010563@pub.open-bio.org> mwilkinson Fri Jul 29 13:11:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10538/t Modified Files: Client-Central.t Log Message: fixed test moby-live/Perl/t Client-Central.t,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:35:22 1.21 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:11:04 1.22 @@ -414,16 +414,16 @@ $r = $C->Relationships(objectType => "Rubbish"); isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; %rel= %{$r}; -print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); -is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "urn:lsid:biomoby.org:objectclass:Object") or diag("Relationships arrayref didn't return the right parentage."); +is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "Object") or diag("Relationships arrayref didn't return the right parentage."); $r = $C->Relationships(serviceType => "RubbishyService"); isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; %rel= %{$r}; print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); -is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "urn:lsid:biomoby.org:servicetype:Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); +is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); $r = $C->deregisterObjectClass(objectType => "Rubbish"); From mwilkinson at pub.open-bio.org Fri Jul 29 13:12:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:12:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291712.j6THCoao010629@pub.open-bio.org> mwilkinson Fri Jul 29 13:12:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10610/t Modified Files: Client-Central.t Log Message: fixed test moby-live/Perl/t Client-Central.t,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:11:04 1.22 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:12:49 1.23 @@ -117,6 +117,22 @@ +$r = $C->Relationships(objectType => "Rubbish"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; +%rel= %{$r}; +#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); +is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "Object") or diag("Relationships arrayref didn't return the right parentage."); + +$r = $C->Relationships(serviceType => "RubbishyService"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; +%rel= %{$r}; +print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); +is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); + + + # Test 9 # should fail $r = $C->registerService( serviceName => "myfirstservice", @@ -411,21 +427,6 @@ is($on{Rubbish}, "a human-readable description of the object") or diag("object name definition not returned correctly"); -$r = $C->Relationships(objectType => "Rubbish"); -isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; -%rel= %{$r}; -#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; -isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); -is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "Object") or diag("Relationships arrayref didn't return the right parentage."); - -$r = $C->Relationships(serviceType => "RubbishyService"); -isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; -%rel= %{$r}; -print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; -isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); -is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); - - $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 13:25:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:25:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291725.j6THPZ6o010727@pub.open-bio.org> mwilkinson Fri Jul 29 13:25:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv10708/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: sql adaptor was only able to create relatinships for object ontology. Now can retrieve relationships for both object and service moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.66,1.67 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:46:21 1.66 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 17:25:35 1.67 @@ -1319,9 +1319,16 @@ my $type = $args{'term'}; return 0 unless $type; - my $result = $self->query_object(type => $type); - my $row = shift @$result; - my $lsid = $row->{object_lsid}; + my $lsid; + if ($ontology eq "service"){ + my $result = $self->query_service(type => $type); + my $row = shift @$result; + $lsid = $row->{service_lsid}; + } else { + my $result = $self->query_object(type => $type); + my $row = shift @$result; + $lsid = $row->{object_lsid}; + } my $defs; if ( $direction eq 'root' ) { From mwilkinson at pub.open-bio.org Fri Jul 29 13:28:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:28:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291728.j6THSQUS010839@pub.open-bio.org> mwilkinson Fri Jul 29 13:28:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10820/t Modified Files: Client-Central.t Log Message: updating test plan number moby-live/Perl/t Client-Central.t,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:12:49 1.23 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:28:26 1.24 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; #use SOAP::Lite +trace; -use Test::More tests => 91; # perldoc Test::More for details +use Test::More tests => 122; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; From mwilkinson at pub.open-bio.org Fri Jul 29 13:39:32 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:39:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291739.j6THdWLU010916@pub.open-bio.org> mwilkinson Fri Jul 29 13:39:32 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv10893/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: deleting service type failed due to bad lookup of relationships. Fix reporting of errors from MOBY Central - need to bracket teh (==0) phrase of every test moby-live/Perl/MOBY Central.pm,1.195,1.196 OntologyServer.pm,1.70,1.71 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.195 retrieving revision 1.196 diff -u -r1.195 -r1.196 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 15:07:40 1.195 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 17:39:32 1.196 @@ -313,14 +313,14 @@ term => $reltype, ontology => 'object' ); # success = 1 if it does - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); foreach ( @{$obj} ) { ++$ISAs if ( $URI =~ /isa$/i ); my ( $objectType, $articleName ) = @{$_}; my ( $success, $message, $URI ) = $OntologyServer->objectExists( term => $objectType ) ; # success = 1 if it does - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); } } return &_error( @@ -341,12 +341,12 @@ if ( $clobber == 1 ) { my ( $success, $message ) = $OntologyServer->deprecateObject( term => $term ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); } elsif ( $clobber == 2 ) { my ( $success, $message ) = $OntologyServer->deleteObject( term => $term ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); } } ( $success, $message, $URI ) = $OntologyServer->createObject( @@ -355,7 +355,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); my @failures; if ( keys %{$relationships} ) { while ( my ( $reltype, $obj ) = each %{$relationships} ) { @@ -370,7 +370,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && push @failures, $objectType; + ($success == 0) && push @failures, $objectType; } } } @@ -378,7 +378,7 @@ my ( $success, $message, $deleteURI ) = $OntologyServer->deleteObject( term => $term ) ; # hopefully this situation will never happen! - $success == 0 && return &_error( + ($success == 0) && return &_error( "object failed ISA and/or HASA connections, and subsequently failed deletion. This is a critical error, and may indicate corruption of the MOBY Central registry.", $deleteURI @@ -635,7 +635,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); my @failures; if ( keys %{$relationships} ) { while ( my ( $reltype, $obj ) = each %{$relationships} ) { @@ -648,7 +648,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && push @failures, $serviceType; + ($success == 0) && push @failures, $serviceType; } } } @@ -656,7 +656,7 @@ my ( $success, $message, $deleteURI ) = $OntologyServer->deleteServiceType( term => $term ) ; # hopefully this situation will never happen! - $success == 0 && return &_error( + ($success == 0) && return &_error( "Service registration failed ISA connections, and subsequently failed deletion. This is a critical error, and may indicate corruption of the MOBY Central registry", $deleteURI @@ -767,7 +767,7 @@ my ( $success2, $message2, $deleteURI ) = $OntologyServer->deleteServiceType( term => $term ) ; # hopefully this situation will never happen! - $success == 0 && return &_error( $message2, $deleteURI ); + (($success == 0)) && return &_error( $message2, $deleteURI ); return &_success( "Service type $term deleted.", $deleteURI ); } @@ -855,7 +855,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); return &_success( "Namespace type $term registered successfully.", $URI ); } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 15:07:40 1.70 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 17:39:32 1.71 @@ -682,7 +682,7 @@ } # service1_id ISA service2_id? - my $isa = $adaptor->query_service_term2term(service2_id => $lsid); + my $isa = $adaptor->query_service_term2term(type => $lsid); my $isas = shift(@$isa); if ( $isas->{service1_id} ) { From mwilkinson at pub.open-bio.org Fri Jul 29 13:40:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:40:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291740.j6THewi4010997@pub.open-bio.org> mwilkinson Fri Jul 29 13:40:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10978/t Modified Files: Client-Central.t Log Message: cleaning comments out of the test suite. Now have 122 tests and all pass on the new codebase moby-live/Perl/t Client-Central.t,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:28:26 1.24 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:40:58 1.25 @@ -127,7 +127,7 @@ $r = $C->Relationships(serviceType => "RubbishyService"); isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; %rel= %{$r}; -print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); From mwilkinson at pub.open-bio.org Fri Jul 29 14:58:44 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 14:58:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291858.j6TIwiWm011359@pub.open-bio.org> mwilkinson Fri Jul 29 14:58:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv11340/MOBY Modified Files: Central.pm Log Message: updated pod documentation for MOBY Central and MOBY Client Central. MOBY Client Central now has ways of getting to the LSID for various things in the MOBY Central messages. See pod for details. moby-live/Perl/MOBY Central.pm,1.196,1.197 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.196 retrieving revision 1.197 diff -u -r1.196 -r1.197 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 17:39:32 1.196 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 18:58:44 1.197 @@ -2383,16 +2383,13 @@ outputXML (by category): - moby: + moby: =cut sub retrieveService { my ( $pkg, $payload ) = @_; - - # the payload here is actually the full XML from the findService call above... - #return "NOT YET IMPLEMENTED"; my ( $AuthURI, $serviceName, $InputXML, $OutputXML, $SecondaryXML ) = &_retrieveServicePayload($payload); unless ( $AuthURI && $serviceName ) { return "" } @@ -2532,7 +2529,7 @@ Args : none XML : - + ... @@ -2610,7 +2607,7 @@ Args : none XML : - + ... @@ -2649,7 +2646,7 @@ Ouptut XML : - NewObjectType + NewObjectType @@ -2714,7 +2711,7 @@ Args : none XML : - + ... From mwilkinson at pub.open-bio.org Fri Jul 29 14:58:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 14:58:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291858.j6TIwjow011383@pub.open-bio.org> mwilkinson Fri Jul 29 14:58:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv11340/MOBY/Client Modified Files: Central.pm SimpleArticle.pm Log Message: updated pod documentation for MOBY Central and MOBY Client Central. MOBY Client Central now has ways of getting to the LSID for various things in the MOBY Central messages. See pod for details. moby-live/Perl/MOBY/Client Central.pm,1.106,1.107 SimpleArticle.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.106 retrieving revision 1.107 diff -u -r1.106 -r1.107 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:43:26 1.106 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 18:58:44 1.107 @@ -467,16 +467,17 @@ an additional XML hash key that contains the actual XML containing the object definition as sent by MOBY Central (used for a visual overview, rather than parsing all of the hash keys) - objectType => "the name of the Object" + objectType => "the name of the Object" + objectLSID => "urn:lsid:..." description => "a human-readable description of the object" contactEmail => "your at email.address" authURI => "URI of the registrar of this object" Relationships => { relationshipType1 => [ - [Object1, articleName], - [Object2, articleName]], + [Object1, articleName, lsid], + [Object2, articleName, lsid]], relationshipType2 => [ - [Object1, articleName]]} + [Object1, articleName, lsid]]} XML => <....XML of object registration.../> Args : objectType => the name or LSID URI for an object @@ -545,14 +546,18 @@ next unless $_->nodeType == ELEMENT_NODE; my $article = $_->getAttributeNode('articleName'); # may or may not have a name + my $rlsid = + $_->getAttributeNode('lsid'); # may or may not have a name if ($article) { $article = $article->getValue() } + if ($rlsid) { $rlsid = $rlsid->getValue() } + my @child2 = $_->childNodes; foreach (@child2) { #print getNodeTypeName($_), "\t", $_->toString,"\n"; next unless $_->nodeType == TEXT_NODE; push @{ $relationships{$relationshipType} }, - [ $_->toString, $article ]; + [ $_->toString, $article, $rlsid ]; } } } @@ -1295,19 +1300,22 @@ =head2 retrieveServiceNames - Title : retrieveServiceNames + Title : retrieveServiceNames(%args) Usage : $names = $MOBY->retrieveServiceNames([$reg_name]) Function : get a (redundant) list of all registered service names (N.B. NOT service types!) Returns : hashref to the following hash $names{$AuthURI} = [serviceName_1, serviceName_2, serviceName3...] - Args : $reg_name: name of registry you wish to retrieve from (optional) + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: return service names as their corresponding LSID's (default off) =cut sub retrieveServiceNames { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; + my $aslsid = $args{as_lsid}; + $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); @@ -1324,7 +1332,14 @@ $names_list->get_node($x)->getAttributeNode('name')->getValue; my $auth = $names_list->get_node($x)->getAttributeNode('authURI')->getValue; - push @{ $servicenames{$auth} }, $name; + my $lsid = $names_list->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $name; + } + $lsid ||=$name; + push @{ $servicenames{$auth} }, $aslsid?$lsid:$name; } return \%servicenames; } @@ -1362,18 +1377,20 @@ =head2 retrieveServiceTypes - Title : retrieveServiceTypes + Title : retrieveServiceTypes(%args) Usage : $types = $MOBY->retrieveServiceTypes([$reg_name]) Function : get the list of all registered service types Returns : hashref of $types{$type} = $definition - Args : $reg_name: name of registry you wish to retrieve from (optional) - + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: return the $type as its corresponding LSID (defualt off) =cut sub retrieveServiceTypes { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; + my $as_lsid = $args{as_lsid}; + $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); @@ -1387,6 +1404,12 @@ for ( my $x = 1 ; $x <= $types->size() ; $x++ ) { next unless $types->get_node($x)->nodeType == ELEMENT_NODE; my $type = $types->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $types->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $type; + } my $desc; for my $elem ( $types->get_node($x)->getElementsByTagName('Description') ) @@ -1397,29 +1420,29 @@ } } $desc =~ s/[^\]]+))\]\]>/$1/gs; - $servicetypes{$type} = $desc; + $servicetypes{$as_lsid?$lsid:$type} = $desc; } return \%servicetypes; } =head2 retrieveObjectNames - Title : retrieveObjectNames + Title : retrieveObjectNames(%args) Usage : $names = $MOBY->retrieveObjectNames([$reg_name]) Function : get the list of all registered Object types Returns : hashref of hash: $names{$name} = $definition - Args : $reg_name: name of registry you wish to retrieve from (optional) + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: return $name as its correspnding LSID (default off) =cut sub retrieveObjectNames { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; + my $as_lsid = $args{as_lsid}; $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); - -#my $return = $self->SOAP_connection($reg)->call('retrieveObjectNames' => (@_))->paramsall; my ($return) = $self->_call( $reg, 'retrieveObjectNames', "" ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($return); @@ -1429,6 +1452,12 @@ for ( my $x = 1 ; $x <= $obnames->size() ; $x++ ) { next unless $obnames->get_node($x)->nodeType == ELEMENT_NODE; my $name = $obnames->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $obnames->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $name; + } my $desc; for my $elem ( $obnames->get_node($x)->getElementsByTagName('Description') ) @@ -1439,29 +1468,30 @@ } } $desc =~ s/[^\]]+))\]\]>/$1/gs; - $objectnames{$name} = $desc; + $objectnames{$as_lsid?$lsid:$name} = $desc; } return \%objectnames; } =head2 retrieveNamespaces - Title : retrieveNamespaces + Title : retrieveNamespaces(%args) Usage : $ns = $MOBY->retrieveNamespaces([$reg_name]) Function : get the list of all registered Namespace types Returns : hashref of hash: $ns{$namespace} = $definition - Args : $reg_name: name of registry you wish to retrieve from (optional) + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: retrieve $namespace as its corresponding LSID (default off) =cut sub retrieveNamespaces { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); - -# my $return = $self->SOAP_connection($reg)->call('retrieveNamespaces' => (@_))->paramsall; + my $as_lsid = $args{as_lsid}; + my ($return) = $self->_call( $reg, 'retrieveNamespaces', "" ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($return); @@ -1471,6 +1501,12 @@ for ( my $x = 1 ; $x <= $namesp->size() ; $x++ ) { next unless $namesp->get_node($x)->nodeType == ELEMENT_NODE; my $ns = $namesp->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $namesp->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $ns; + } my $desc; for my $elem ( $namesp->get_node($x)->getElementsByTagName('Description') ) @@ -1482,28 +1518,29 @@ } } $desc =~ s/[^\]]+))\]\]>/$1/gs; - $namespaces{$ns} = $desc; + $namespaces{$as_lsid?$lsid:$ns} = $desc; } return \%namespaces; } =head2 retrieveObject - NOT YET IMPLEMENTED Title : retrieveObject - Usage : $objects = $MOBY->retrieveObjectNames($reg, $name | "all") + Usage : $objects = $MOBY->retrieveObjectNames(%args) Function : get the object xsd Returns : hashref of hash: $objects{$name} = $W3C_XML_Schema_string - Args : $reg - name of MOBY Central you want to use (must pass undef otherwise) - $name - object name (from ontology) or "all" to get all objects - + Args : registry => $reg - name of MOBY Central you want to use (must pass undef otherwise) + objectType => $name - object name (from ontology) or undef to get all objects + as_lsid => $boolean - return $name as its corresponding LSID (default off) + =cut sub retrieveObject { - my ($self) = shift; - my ($reg) = shift; - my $type = shift; + my ($self, %args) = shift; + my ($reg) = $args{registry}; + my $type = $args{objectType}; + my $as_lsid = $args{as_lsid}; my $message = " $type @@ -1511,7 +1548,6 @@ $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); -# my $return = $self->SOAP_connection($reg)->call('retrieveObject' => ($message))->paramsall; my ($return) = $self->_call( $reg, 'retrieveObject', $message ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($return); @@ -1521,6 +1557,12 @@ for ( my $x = 1 ; $x <= $objects->size() ; $x++ ) { next unless $objects->get_node($x)->nodeType == ELEMENT_NODE; my $name = $objects->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $objects->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $name; + } my $desc; for my $elem ( $objects->get_node($x)->getElementsByTagName('Schema') ) { @@ -1724,7 +1766,12 @@ my $Service = $Services->get_node($x); my $AuthURI = $Service->getAttributeNode('authURI')->getValue; my $servicename = $Service->getAttributeNode('serviceName')->getValue; - #my $lsid = $Service->getAttributeNode('lsid')->getValue; + my $lsid = $Service->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = ""; + } my $Type = &_nodeTextContent( $Service, 'serviceType' ); my $authoritative = &_nodeTextContent( $Service, 'authoritative' ); my $contactEmail = &_nodeTextContent( $Service, 'contactEmail' ); @@ -1788,7 +1835,7 @@ authority => $AuthURI, authoritative => $authoritative, URL => $URL, - #LSID => $lsid, + LSID => $lsid, contactEmail => $contactEmail, name => $servicename, type => $Type, =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm 2004/12/14 22:31:30 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm 2005/07/29 18:58:44 1.8 @@ -86,6 +86,17 @@ =cut +=head2 objectLSID + + Title : objectLSID + Usage : $type = $SA->objectLSID($type) + Function : get/set LSID + Returns : string + Arguments : (optional) string representing objectLSID to set + +=cut + + =head2 namespaces Title : namespaces @@ -171,6 +182,7 @@ ( articleName => [ undef, 'read/write' ], objectType => [ undef, 'read/write' ], + objectLSID => [ undef, 'read/write' ], namespaces => [ [], 'read/write' ], id => [ undef, 'read/write' ], XML_DOM => [ undef, 'read/write' ], @@ -250,11 +262,15 @@ $self->articleName( "" ); $self->objectType( "" ); my $attr = $dom->getAttributeNode( 'articleName' ); + my $lsid = $dom->getAttributeNode( 'lsid' ); my $articleName = ""; $articleName = $attr->getValue if $attr; + $lsid = $attr->getValue if $lsid; + $self->articleName( $articleName ) if $articleName ; # it may have already been set if this Simple is part of a Collection... + $self->objectLSID( $lsid) if $lsid; # fork here - it may be an instantiated object (coming from a service invocation/response) # or it may be a template object as in the SimpleArticle element of a registration call From mwilkinson at pub.open-bio.org Fri Jul 29 15:28:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 15:28:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291928.j6TJSSW6011564@pub.open-bio.org> mwilkinson Fri Jul 29 15:28:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv11545/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query doesn't work on older versions of mySQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.67,1.68 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 17:25:35 1.67 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 19:28:27 1.68 @@ -675,7 +675,7 @@ description, signatureURL, lsid - from service_instance left join authority on authority.authority_id "; + from service_instance, authority where authority.authority_id = service_instance.authority_id "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); From mwilkinson at pub.open-bio.org Fri Jul 29 15:33:42 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 15:33:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291933.j6TJXgqt011633@pub.open-bio.org> mwilkinson Fri Jul 29 15:33:41 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv11614/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query doesn't work on older versions of mySQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.68,1.69 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 19:28:27 1.68 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 19:33:41 1.69 @@ -675,9 +675,14 @@ description, signatureURL, lsid - from service_instance, authority where authority.authority_id = service_instance.authority_id "; + from service_instance, authority "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); + if (keys(%args)){ + $statement .= " and authority.authority_id = service_instance.authority_id"; + } else { + $statement .= " where authority.authority_id = service_instance.authority_id"; + } my $final = do_query($dbh, $statement, @bindvalues); return $final; } From mwilkinson at pub.open-bio.org Fri Jul 29 15:37:52 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 15:37:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291937.j6TJbqLW011722@pub.open-bio.org> mwilkinson Fri Jul 29 15:37:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv11703/MOBY/Client Modified Files: Central.pm Log Message: redundant pattern substitution moby-live/Perl/MOBY/Client Central.pm,1.107,1.108 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.107 retrieving revision 1.108 diff -u -r1.107 -r1.108 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 18:58:44 1.107 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:37:51 1.108 @@ -1517,7 +1517,7 @@ $desc = $1; } } - $desc =~ s/[^\]]+))\]\]>/$1/gs; +# $desc =~ s/[^\]]+))\]\]>/$1/gs; $namespaces{$as_lsid?$lsid:$ns} = $desc; } return \%namespaces; From mwilkinson at pub.open-bio.org Fri Jul 29 15:39:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 15:39:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291939.j6TJdbLb011786@pub.open-bio.org> mwilkinson Fri Jul 29 15:39:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv11767/MOBY/Client Modified Files: Central.pm Log Message: redundant pattern substitution... can't figure out why this throws a warning every time on some systems but not others moby-live/Perl/MOBY/Client Central.pm,1.108,1.109 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.108 retrieving revision 1.109 diff -u -r1.108 -r1.109 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:37:51 1.108 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:39:37 1.109 @@ -1513,6 +1513,7 @@ { $desc = $elem->firstChild; $desc = $desc ? $desc->toString : ""; + $desc ||=""; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } From mng at pub.open-bio.org Fri Jul 29 16:06:37 2005 From: mng at pub.open-bio.org (michael ng) Date: Fri, 29 Jul 2005 16:06:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507292006.j6TK6bXD011951@pub.open-bio.org> mng Fri Jul 29 16:06:37 EDT 2005 Update of /home/repository/moby/moby-live/Accessories In directory pub.open-bio.org:/tmp/cvs-serv11929 Added Files: code-generator0.6.cgi codebook.xml Log Message: new version of code-generator with command line function moby-live/Accessories code-generator0.6.cgi,NONE,1.1 codebook.xml,NONE,1.1 From kawas at pub.open-bio.org Fri Jul 29 18:17:40 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Fri, 29 Jul 2005 18:17:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507292217.j6TMHecB012306@pub.open-bio.org> kawas Fri Jul 29 18:17:39 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv12281/org/biomoby/registry/rdfagent/verifier Modified Files: ServiceDescrParser.java Log Message: fixed some bugs that were due to the scope of certain variables. formatted the code. fixed a bug that ignored article names of collections. fixed a bug that over wrote preexisting simples in collections with new ones even though both should exist. fixed a bug that caused pre-existing ns to be associated with simples without ns. ... moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServiceDescrParser.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/28 15:26:13 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/29 22:17:39 1.8 @@ -78,20 +78,16 @@ servSign = getServSignature(resource); if (!servSign.isEmpty()) { // a valid MOBY RDF - servName = servSign.get("servicename").toString(); + servName = servSign.get("servicename").toString()+""; auth_URI = servSign.get("authURI").toString(); resources.addElement(servName); Hashtable servInp = new Hashtable(); - servInp = getInput(resource); + servInp = getInput(resource); //TODO modify collections and simples like getOutput(); Hashtable servOut = new Hashtable(); servOut = getOutput(resource); - for (int i = 0; i < ver.length; i++) { // a clearance of the - // array ver[] - ver[i] = 0; - - } + ver = new int[]{0,0,0,0,0,0,0,0}; if (servInp.containsValue("error") | servOut.containsValue("error")) { servError += 1; @@ -302,7 +298,7 @@ Hashtable input = new Hashtable(); Resource si = servDescrMd.getResource(resource); - + if (si.hasProperty(MP.consumes)) try { Resource consumes = si.getRequiredProperty(MP.consumes) .getResource(); @@ -375,7 +371,7 @@ // to Input sin += 1; Enumeration num = siminp.keys(); - + siminp= new Hashtable(); } } else if (type.equals(MP.Collection) | type.equals(RDF.Bag)) { @@ -383,9 +379,9 @@ // l3Res.hasProperty(RDF.li(1))){ if (l3Res.hasProperty(RDF.li(1))) { StmtIterator p34iter = l3Res.listProperties(); - if (l3Res.hasProperty(MP.article_name)) { + if (l3Res.hasProperty(MP.articleName)) { String col_artName = l3Res.getProperty( - MP.article_name).getObject().toString(); + MP.articleName).getObject().toString(); String[] rezNode = col_artName.split(":http:"); col_artName = rezNode[0]; colinp.put("col_articleName", col_artName); @@ -449,13 +445,18 @@ String lsid_nsp = switchURItoLSID(l5Node .toString()); colinp.put(name, lsid_nsp); - } else { + } else if (name.equals("articleName")) { + colinp.put(name, l5Node.getName()); + }else { colinp.put(name, l5Node); } } input.put("colinp" + cin, colinp); cin += 1; Enumeration num = colinp.keys(); + String col_name = (String)colinp.get("col_articleName"); + colinp = new Hashtable(); + colinp.put("col_articleName", col_name); } } @@ -529,7 +530,7 @@ input.put("input", "error"); } } catch (Exception e) { - Log.warning("Failed:" + e); + Log.warning("Failed (ServiceDescrParser.java - getInput): " + e); } // } //System.out.println("input= "+input); @@ -558,8 +559,9 @@ Hashtable output = new Hashtable(); Resource si = servDescrMd.getResource(resource); - + if (si.hasProperty(MP.produces)) try { + Resource consumes = si.getRequiredProperty(MP.produces) .getResource(); StmtIterator p23iter = consumes.listProperties(); @@ -628,7 +630,7 @@ // to Output so += 1; Enumeration num = simout.keys(); - + simout = new Hashtable(); } } @@ -636,12 +638,12 @@ // if (l3Res.hasProperty(RDF.type,RDF.Bag) && // l3Res.hasProperty(RDF.li(1))){ - if (l3Res.hasProperty(RDF.li(1))) { + if (l3Res.hasProperty(RDF.li(1))) { //TODO is this right? probably should iterate through the anon nodes, breaking when the hasProperty() fails. StmtIterator p34iter = l3Res.listProperties(); - if (l3Res.hasProperty(MP.article_name)) { + if (l3Res.hasProperty(MP.articleName)) { String col_artName = l3Res.getProperty( - MP.article_name).getObject().toString(); + MP.articleName).getObject().toString(); String[] rezNode = col_artName.split(":http:"); col_artName = rezNode[0]; colout.put("col_articleName", col_artName); @@ -705,13 +707,19 @@ String lsid_nsp = switchURItoLSID(l5Node .toString()); colout.put(name, lsid_nsp); - } else { + } else if (name.equals("articleName")) { + colout.put(name, rezNode[0]); + }else { colout.put(name, l5Node); } } + //TODO BUG here. colout should be 'new' and not recycled output.put("colout" + co, colout); co += 1; Enumeration num = colout.keys(); + String col_name = (String)colout.get("col_articleName"); + colout = new Hashtable(); + colout.put("col_articleName", col_name); } } @@ -732,7 +740,7 @@ output.put("output", "error"); } } catch (Exception e) { - Log.warning("Failed:" + e); + Log.warning("Failed (ServiceDescrParser.java-getOutput): " + e); } //System.out.println("output = "+output); return output; @@ -845,6 +853,7 @@ return res; } + //TODO - need to fix this to make it portable public String switchURItoLSID(String uri) { String lsid = ""; From mwilkinson at pub.open-bio.org Sun Jul 31 11:18:54 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Sun, 31 Jul 2005 11:18:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507311518.j6VFIspd026387@pub.open-bio.org> mwilkinson Sun Jul 31 11:18:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv26368/MOBY/Client Modified Files: Central.pm Log Message: typo in the default server name moby-live/Perl/MOBY/Client Central.pm,1.109,1.110 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.109 retrieving revision 1.110 diff -u -r1.109 -r1.110 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:39:37 1.109 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/31 15:18:54 1.110 @@ -141,7 +141,8 @@ Connections => [ undef, 'read/write' ], default_MOBY_servername => [ 'mobycentral', 'read/write' ], default_MOBY_server => [ - 'http://mobycentral.icpture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', + +'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', 'read/write' ], default_MOBY_uri => From mwilkinson at pub.open-bio.org Sun Jul 31 11:30:30 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Sun, 31 Jul 2005 11:30:30 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507311530.j6VFUUPk026469@pub.open-bio.org> mwilkinson Sun Jul 31 11:30:30 EDT 2005 Update of /home/repository/moby/moby-live/Database In directory pub.open-bio.org:/tmp/cvs-serv26454 Added Files: reset.bat Log Message: a batch file for reinitializing the databases in MS Windows moby-live/Database reset.bat,NONE,1.1 From kawas at pub.open-bio.org Fri Jul 29 19:05:46 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Fri, 29 Jul 2005 23:05:46 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200507292219.j6TMJ6S5012347@pub.open-bio.org> kawas Fri Jul 29 18:19:05 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv12322/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: not sure what i did - cvs says that there are differences. Probably bug fixes and formatting. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/28 15:24:41 1.10 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/29 22:19:05 1.11 @@ -24,2428 +24,2508 @@ public class DataMngr { - /** - * get the list of signatureURL from service_instance table - * - * @return a Hashtable (signatureURL = string of servicenames for this URL - * separated by comma) - * - * - */ - - public static Hashtable getServices(String file) { - - Hashtable services = new Hashtable(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select servicename,signatureURL,authority_id from service_instance order by signatureURL"; - - PreparedStatement ps = null; - ResultSet rs = null; - - try { - ps = con.prepareStatement(sqlReq1); - rs = ps.executeQuery(); - String lastAddr = ""; - StringBuffer servNames = new StringBuffer(); - int lastID = -1; - - while (rs.next()) { - String servName = rs.getString(1); - String rdfAddr = rs.getString(2); - int authorityID = rs.getInt(3); - if (rdfAddr == null) { - //TODO - make this code more efficient! - maybe perform one sql call instead of many - // update the signatureURL field using the service name and authority id - String bogusSigURL = "http://invalidURL123.com/author/"+ authorityID + "/" + servName +".xml"; - String updateSQLString = "UPDATE service_instance " + - "SET signatureURL='"+ bogusSigURL +"' " + - "WHERE authority_id=" + authorityID + " and servicename='" + servName +"'"; - PreparedStatement preparedStatement = null; - try { - Connection updateCon = DBConnector.getConnection(); - preparedStatement = updateCon.prepareStatement(updateSQLString); - int resultSet = preparedStatement.executeUpdate(); - Log.info(resultSet + ": Updated the signatureURL field of the authority with id #" + authorityID + " to be " + bogusSigURL+"."); - } catch (SQLException e) { - Log.severe("Could not update SignatureURL field with a bogus signatureURL.\n" +e.getMessage()); - } - - } else { - if (rdfAddr.equals(lastAddr)) { - servNames.append("," + servName); - } else { - if (servNames.length() > 0) { - services.put(lastAddr, servNames); - servNames = new StringBuffer(); - } - servNames.append(servName); - lastAddr = rdfAddr; - Report.doSave(file, lastAddr); - } - } - } - services.put(lastAddr, servNames); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - //System.out.println("ListOFServices : "+services); - - return services; - } - - /** - * get the list of services by signatureURL - * - * @param signURL - - * URL of resource - * @return a Hashtable (signatureURL = string of servicenames for this URL - * separated by comma) - */ - - public static Hashtable getServicesByURL(String signURL) { - - Hashtable services = new Hashtable(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select servicename,signatureURL from service_instance where signatureURL=?"; - - PreparedStatement ps = null; - ResultSet rs = null; - - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - String lastAddr = ""; - StringBuffer servNames = new StringBuffer(); - - while (rs.next()) { - String servName = rs.getString(1); - String rdfAddr = rs.getString(2); - - if (rdfAddr.equals(lastAddr)) { - servNames.append("," + servName); - } else { - if (servNames.length() > 0) { - services.put(lastAddr, servNames); - servNames = new StringBuffer(); - } - servNames.append(servName); - lastAddr = rdfAddr; - } - } - services.put(lastAddr, servNames); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - // System.out.println("ListOFServices : "+services); - - return services; - } - - /** - * This method use for the update service_instance table, - * simple_input/output table, collection_input/output table, secondary_input - * table in accordance with data from RDF file. - * - * @param servSign - - * set of the serviceSignature data (name - value, an example: - * servicename - GoTerm); Hashtable of hashtables represented by - * a pair: a name of the input = hashtable for this output - * example:{siminp1={object_type_uri=urn:lsid:biomoby.org:objectclass:Object, - * namespace_type_uris=urn:lsid:biomoby.org:namespacetype:taxon}} - * @param servInp - - * Hashtable of hashtables represented by a pair: a name of the - * output = hashtable for this output - * @param servname - - * the name of service - * @param authURI - - * the authority URI - * @param signURL - - * URL of resource - */ - - public static void processService(Hashtable servSign, Hashtable servInp, - Hashtable servOut, String servname, String authURI, String signURL) { - - Connection con = DBConnector.getConnection(); - String servName = ""; - String cat = "moby"; - String url = ""; - String email = ""; - String desc = ""; - String stype = ""; - String authuri = ""; - String authoritative = ""; - String art = null; - String col_art = null; - String obt = null; - String nst = null; - String artsec = null; - String defsec = null; - String dtsec = null; - - BigDecimal maxsec = null; - BigDecimal minsec = null; - - String enumsec = null; - int colId = 0; - Integer colOutId = null; - Integer colInpId = null; - int serv = 0; // a flag - the given service was found - int checkServ = 0; // a flag - the service exist in the database - int new_serv = 0; // the number of new services - int ret; - int servInstId = 0; - String signatureURL = "NNN"; - - // ************** Update service Signature **************** - - Enumeration num = servSign.keys(); - - while (num.hasMoreElements()) { - - Object ob = num.nextElement(); - Object val = servSign.get(ob); - if (ob.equals("category")) { - cat = val.toString(); - } - if (ob.equals("URL")) { - url = val.toString(); - } - if (ob.equals("contact_email")) { - email = val.toString(); - } - if (ob.equals("description")) { - desc = val.toString(); - } - if (ob.equals("service_type_uri")) { - stype = val.toString(); - } - if (ob.equals("authURI")) { - authuri = val.toString(); - } - if (ob.equals("authoritative")) { - authoritative = val.toString(); - - if (authoritative.equals("non-authoritative")) { - authoritative = "0"; - } else if (authoritative.equals("authoritative")) { - authoritative = "1"; - } - } - if (ob.equals("servicename")) { - servName = val.toString(); - } - if (ob.equals("signatureURL")) { - signatureURL = val.toString(); - } - - } - - ServSignature signature = getServSignature(servname, signURL); - servInstId = signature.getServInstId(); - //TODO make sure that the fields are updated - if (servInstId == 0) { - - int authId = getAuthIdByAuthURI(authuri); - - if (authId == 0) { - insIntoAuthority(authuri, email); - authId = getAuthIdByAuthURI(authuri); - } - - if (signatureURL.equals("NNN")) { - ret = createSignature(servName, cat, stype, authId, url, email, - authoritative, desc, signURL); - } else { - ret = createSignature(servName, cat, stype, authId, url, email, - authoritative, desc, signatureURL); - } - - if (ret == 1) { - String msg = "------The service instance <" + servName - + "> was registered in the MOBYCENTRAL registry "; - Report.doWrite(msg); - Report.add(msg); - - //System.out.println("mail_server = - // "+Constants.MB_MAIL_SERVER); - /* - * if (Constants.MB_MAIL_SERVER != null | - * !Constants.MB_MAIL_SERVER.equals("")) { String to = - * DataMngr.getContactEmail(signURL); - * Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // - * send message to the service provider - that service was - * deregistered } - */ - new_serv += 1; - servInstId = getServInstId(servName, authId); - } - } else { - - if (!cat.equals(signature.getCategory()) - || !url.equals(signature.getUrl()) - || !email.equals(signature.getEmail()) - || !desc.equals(signature.getDescription()) - || !stype.equals(signature.getServiceType()) - || !authoritative.equals(signature.getAuthoritative()) - || !authuri.equals(authURI)) { - - //TODO - Log.info("Updating the service '" + servName +"' since the RDF document has been modified."); - if (signatureURL.equals("NNN")) { - Log.info("sig == NNN" + signURL); - Log.info("=<"+servName+","+cat+","+stype+","+authuri+","+url+","+email+","+desc+","+authoritative+","+signURL+">"); - int res = updSign(servName, cat, stype, authuri, url, - email, desc, authoritative, signURL); - if (res == 1) { - Report.doWrite("------The service instance<"+servName+"> was updated "); - Report.add("------The service instance <"+servName+">was updated "); - } else { - Report.doWrite("------The service instance<"+servName+"> was not updated"); - Report.add("------The service instance <"+servName+">was not updated "); - } - - } else { - Log.info("sig != NNN"); - int res = updSign(servName, cat, stype, authuri, url, - email, desc, authoritative, signatureURL); - if (res == 1) { - Report.doWrite("------The service instance <"+servName+"> was updated "); - Report.add("------The service instance <"+servName+">was updated "); - } else { - Report.doWrite("------The service instance <"+servName+"> was not updated "); - Report.add("------The service instance <"+servName+">was not updated "); - } - } - } - } - - // ************ add Input ********************* - - Enumeration num1 = servInp.keys(); - int dels = 0; - int delc = 0; - int delsec = 0; - int si = 0; - int ci = 0; - int sci = 0; - - while (num1.hasMoreElements()) { - Object ob = num1.nextElement(); - Object val = servInp.get(ob); - Log.info("INPUTS :"+ob+" = "+val ); - String simcol = (ob.toString()).substring(0, 6); // a hashtable name - - if (simcol.equals("secinp")) { // if it's a Secondary input - sci += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Secondary input " + sci); - Report.add("Secondary input " + sci + ":"); - if (delsec == 0) { - delRow("secondary_input", servInstId); // delete from - // simple_input table - delsec = 1; - } - } else if (simcol.equals("colinp")) { // if it's a Collection input - ci += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Collection input " + ci); - Report.add("Collection input " + ci + ":"); - if (delc == 0) { - // colInpId = new - // Integer(getCollectionId("collection_input","collection_input_id",servInstId)); - delCollectionMember("input", servInstId); // delete from - // simple_input - // table - delRow("collection_input", servInstId); // delete from the - // collection_input - // table - delc = 1; - } - - } else { // if it's a Simple input - Report.doWrite(" "); - Report.add(" "); - si += 1; - Report.doWrite("Simple input " + si); - Report.add("Simple input " + si + ":"); - if (dels == 0) { - delRow("simple_input", servInstId); // delete from - // simple_input table - dels = 1; - } - } - Hashtable simple = new Hashtable(); - simple = (Hashtable) val; - Enumeration num11 = simple.keys(); - - while (num11.hasMoreElements()) { - Object ob1 = num11.nextElement(); - if (!ob1.equals("type")) { - Report.doWrite(ob1 + " = " + simple.get(ob1)); - Report.add(ob1 + " = " + simple.get(ob1)); - } - - if (ob1.equals("col_articleName")) { - col_art = simple.get(ob1).toString(); - if (col_art.equals(" ")) { - col_art = null; - } - } else if (ob1.equals("articleName")) { - art = simple.get(ob1).toString(); - if (art.equals(" ")) { - art = null; - } - } else if (ob1.equals("article_name")) { - artsec = simple.get(ob1).toString(); - if (artsec.equals(" ")) { - artsec = null; - } - } else if (ob1.equals("object_type_uri")) { - obt = simple.get(ob1).toString(); - } else if (ob1.equals("namespace_type_uris")) { - nst = simple.get(ob1).toString(); - } else if (ob1.equals("default")) { - defsec = simple.get(ob1).toString(); - } else if (ob1.equals("datatype")) { - dtsec = simple.get(ob1).toString(); - } else if (ob1.equals("max")) { - String maxsec_s = simple.get(ob1).toString(); - try { - maxsec = new BigDecimal(maxsec_s); - - } catch (NumberFormatException nx) { - Log.severe(nx.getMessage()); - // nx.getMessage(); - } - } else if (ob1.equals("min")) { - String minsec_s = simple.get(ob1).toString(); - try { - minsec = new BigDecimal(minsec_s); - - } catch (NumberFormatException nx) { - Log.severe(nx.getMessage()); - // nx.getMessage(); - } - } else if (ob1.equals("enum")) { - enumsec = simple.get(ob1).toString(); - } - } - - if (simcol.equals("colinp")) { - insIntoCol("collection_input", col_art, servInstId); // insert - // the row - // into - // collection_input - // table - colId = getCollectionId("collection_input", - "collection_input_id", servInstId); - insIntoSimpleInput(null, art, obt, nst, new Integer(colId)); - - art = null; - col_art = null; - obt = null; - nst = null; - } else if (simcol.equals("siminp")) { - insIntoSimpleInput(new Integer(servInstId), art, obt, nst, null); - - art = null; - obt = null; - nst = null; - } else if (simcol.equals("secinp")) { - - insIntoSecondary(servInstId, artsec, defsec, dtsec, maxsec, - minsec, enumsec); - - artsec = null; - defsec = null; - dtsec = null; - maxsec = null; - minsec = null; - enumsec = null; - } - - if (colId != 0) { - Report.doWrite("collection_input_id: " + colId); - // Log.info("collection_input_id: "+colId); - } - } - - Report.doWrite("service_instance_id: " + servInstId); - // Log.info("service_instance_id: "+servInstId); - - // *********** add Output *********************** - - Enumeration numout = servOut.keys(); - int delsout = 0; - int delcout = 0; - int so = 0; - int co = 0; - while (numout.hasMoreElements()) { - Object ob = numout.nextElement(); - Object val = servOut.get(ob); - String simcol = (ob.toString()).substring(0, 6); - Log.info("OUTPUTS :"+ob+" = "+val ); - if (simcol.equals("colout")) { - co += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Collection output " + co); - Report.add("Collection output " + co + ":"); - if (delcout == 0) { - // colOutId = new - // Integer(getCollectionId("collection_output","collection_output_id",servInstId)); - delCollectionMember("output", servInstId); // delete from - // table - // simple_output - delRow("collection_output", servInstId); // delete from the - // collection_output - // table - delcout = 1; - } - } else { - so += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Simple output " + so); - Report.add("Simple output " + so + ":"); - - //TODO bug #13 here? - if (delsout == 0) { - delRow("simple_output", servInstId); // delete from - // simple_output table - delsout = 1; - } - } - Hashtable simple = new Hashtable(); - simple = (Hashtable) val; - Enumeration num11 = simple.keys(); - // Report.doWrite(""+simple); - - while (num11.hasMoreElements()) { - Object ob1 = num11.nextElement(); - if (!ob1.equals("type")) { - Report.doWrite(ob1 + " = " + simple.get(ob1)); - Report.add(ob1 + " = " + simple.get(ob1)); - } - - if (ob1.equals("col_articleName")) { - col_art = simple.get(ob1).toString(); - if (col_art.equals(" ")) { - col_art = null; - } - } - if (ob1.equals("articleName")) { - art = simple.get(ob1).toString(); - if (art.equals(" ")) { - art = null; - } - } - if (ob1.equals("object_type_uri")) { - obt = simple.get(ob1).toString(); - } - if (ob1.equals("namespace_type_uris")) { - nst = simple.get(ob1).toString(); - } - } - - if (simcol.equals("colout")) { - - insIntoCol("collection_output", col_art, servInstId); // insert - // the row - // into - // collection_input - // table - - colOutId = new Integer(getCollectionId("collection_output", - "collection_output_id", servInstId)); - insIntoSimpleOutput(null, art, obt, nst, colOutId); - art = null; - obt = null; - nst = null; - } - // TODO bug #11 here - fixed - if (simcol.equals("simout")) { - insIntoSimpleOutput(new Integer(servInstId), art, obt, nst, - null); - art = null; - obt=null; - nst=null; - } - if (colOutId != null) { - Report.doWrite("collection_output_id: " + colOutId); - // Log.info("collection_output_id: "+coloutId); - } - } - // return serv; - } - - /** - * delete the service instance by service name and authority URI - * - * @param servName - * the name of service which we want delete. - * @param authURI - * the authority URI for service which we want delete. - * - */ - - public static void delServByNameAndAuthURI(String servName, String authURI) { - - int authId = getAuthIdByAuthURI(authURI); - int servInstId = getServInstId(servName, authId); - - delSignature(servName, authId); // delete service from table - // service_instance - delRow("simple_input", servInstId); // delete from table simple_input - delRow("simple_output", servInstId); // delete from table simple_output - delRow("secondary_input", servInstId); //TODO - should this line be here? - delCollectionMember("input", servInstId); - delCollectionMember("output", servInstId); - delRow("collection_input", servInstId); // delete from table - // collection_input - delRow("collection_output", servInstId); // delete from table - // collection_output - } - - /** - * delete the service instance by service name and signature URL - * - * @param servName - * the name of service which we want delete. - * @param signURL - * the authority URI for service which we want delete. - * - */ - - public static void delServByNameAndUrl(String servName, String signURL) { - - int authId = getAuthIdByServNameAndSignURL(servName, signURL); - int servInstId = getServInstId(servName, authId); - - delSignature(servName, authId); // delete service from table - // service_instance - delRow("simple_input", servInstId); // delete from table simple_input - delRow("simple_output", servInstId); // delete from table simple_output - delRow("secondary_input", servInstId); //TODO - should this line be here? - delCollectionMember("input", servInstId); - delCollectionMember("output", servInstId); - delRow("collection_input", servInstId); // delete from table - // collection_input - delRow("collection_output", servInstId); // delete from table - // collection_output - } - - /** - * delete set of the service instances with the same signatureURL by - * signatureURL - * - * @param signURL - * the name of service which we want delete. - */ - - public static void delServiceSetByURL(String signURL) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id,servicename,authority_id from service_instance where signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - Vector del_serv = new Vector(); - - while (rs.next()) { - int servInstId = rs.getInt(1); - String servName = rs.getString(2); - int authId = rs.getInt(3); - - int rez = delSignature(servName, authId); // delete service from - // table - // service_instance - if (rez == 1) { - del_serv.addElement(servName); - } - delRow("secondary_input", servInstId); //TODO - should this line be here? - delRow("simple_input", servInstId); // delete from table - // simple_input - delRow("simple_output", servInstId); // delete from table - // simple_output - delCollectionMember("input", servInstId); // delete collection - // member from - // simple_input - delCollectionMember("output", servInstId); // delete collection - // member from - // simple_output - delRow("collection_input", servInstId); // delete from table - // collection_input - delRow("collection_output", servInstId); // delete from table - // collection_output - } - - int del = del_serv.size(); - if (del > 0) { - Report.doWrite("DELETED SERVICES: "); - Iterator i = del_serv.iterator(); - int n = 1; - while (i.hasNext()) { - String delServ = i.next().toString(); - Report.doWrite(n + ". " + delServ); - n += 1; - } - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } - } - - } - - /** - * add the record about new service instance in the service_instance table - * of mobycentral database - * - * @param servName - - * the name of service instance the record was added for. - * @param cat - - * the category of service instance. - * @param servTypeURI - - * the service type URI of service instance. - * @param authId - - * the authority Id of service instance. - * @param url - - * the URL of service instance. - * @param email - - * the contact e-Mail of service instance. - * @param authoritative - - * the authoritative of service instance. - * @param desc - - * the description of service instance. - * @param signURL - - * the URL for RDF of service instance. - * @return ret=1 if the record has added, and ret=-1 otherwise - */ - - public static int createSignature(String servName, String cat, - String servTypeURI, int authId, String url, String email, - String authoritative, String desc, String signURL) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into service_instance (servicename,category,service_type_uri,authority_id,url,contact_email,authoritative,description,signatureURL) values (?,?,?,?,?,?,?,?,?)"; - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setString(2, cat); - ps.setString(3, servTypeURI); - ps.setInt(4, authId); - ps.setString(5, url); - ps.setString(6, email); - ps.setString(7, authoritative); - ps.setString(8, desc); - ps.setString(9, signURL); - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * update the service instance data in the service_instance table of - * mobycentral database - * - * @param servName - * the name of service instance the record was updated for. - * @param cat - * the category of service instance. - * @param stype - * the service type URI of service instance. - * @param authuri - * the authority URI of service instance. - * @param url - * the URL of service instance. - * @param email - * the contact e-Mail of service instance. - * @param authoritative - * the authoritative of service instance. - * @param desc - * the description of service instance. - * @param signURL - * the URL for RDF of service instance. - * @return ret=1 if the record has updated, and ret=-1 otherwise - */ - - public static int updSign(String servName, String cat, String stype, - String authuri, String url, String email, String desc, - String authoritative, String signURL) { - - Connection con = DBConnector.getConnection(); - int cnt = -1; - int ret = -1; - final String sqlReq = "select authority_id from authority where authority_uri = ?"; - PreparedStatement ps = null; - - final String sqlReq1 = "update service_instance set category = ?,service_type_uri = ?,url = ?,contact_email = ?,description = ?,authoritative = ?,signatureURL = ? where servicename = ? && authority_id = ?"; - try { - ps = con.prepareStatement(sqlReq); - ps.setString(1, authuri); - ResultSet rs = ps.executeQuery(); - while (rs.next()) { - cnt = rs.getInt(1); - } - if (cnt > -1) { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, cat); - ps.setString(2, stype); - ps.setString(3, url); - ps.setString(4, email); - ps.setString(5, desc); - ps.setString(6, authoritative); - ps.setString(7, signURL); - ps.setString(8, servName); - ps.setInt(9, cnt); - ret = ps.executeUpdate(); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * add the record into the simple_input table - * - * @param servInstId - * the Id of service instance the simple input was added for. - * @param articleName - * the article name of the simple input. - * @param objTypeUri - * the object type URI of the simple input. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple input. - * @param colInpId - * the collection input Id if this simple input belongs to a - * collection, and blank otherwise. - */ - - public static void insIntoSimpleInput(Integer servInstId, - String articleName, String objTypeUri, String nsTypeUris, - Integer colInpId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into simple_input (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_input_id) values (?,?,?,?,?)"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - if (servInstId != null) { - ps.setInt(1, servInstId.intValue()); - } else { - ps.setNull(1, java.sql.Types.INTEGER); - } - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - if (colInpId != null) { - ps.setInt(5, colInpId.intValue()); - } else { - ps.setNull(5, java.sql.Types.INTEGER); - } - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - } - - /** - * update the record into the simple_input table - * - * @param servInstId - * the Id of service instance the simple input was added for. - * @param articleName - * the article name of the simple input. - * @param objTypeUri - * the object type URI of the simple input. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple input. - * @param colInpId - * the collection input Id if this simple input belongs to a - * collection, and blank otherwise. - * @return ret=1 if the record has added, and ret=-1 otherwise - */ - - public static int updateSimpleInput(int servInstId, String articleName, - String objTypeUri, String nsTypeUris, Integer colInpId, int minNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update simple_input set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_input_id=? where simple_input_id=?"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - if (colInpId != null) { - ps.setInt(5, colInpId.intValue()); - } else { - ps.setNull(5, java.sql.Types.INTEGER); - } - ps.setInt(6, minNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * add the record about secondary input in the secondary_input table of - * mobycentral database - * - * @param servInstId - * the Id of service instance the secondary input was added for. - * @param article_name - * the article name of the secondary input. - * @param def - * the default value of the secondary input. - * @param dataType - * the type of data of the secondary input. - * @param max - * the maximum value of the secondary input - * @param min - * the minimum value of the secondary input * - * @param enumeration - * the enumeration value for the secondary input - */ - - public static void insIntoSecondary(int servInstId, String article_name, - String def, String dataType, BigDecimal max, BigDecimal min, - String enumeration) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into secondary_input (service_instance_id,article_name,default_value,maximum_value,minimum_value,enum_value,datatype) values (?,?,?,?,?,?,?)"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - ps.setString(2, article_name); - ps.setString(3, def); - ps.setBigDecimal(4, max); - ps.setBigDecimal(5, min); - ps.setString(6, enumeration); - ps.setString(7, dataType); - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - } - - /** - * update the record into the secondary_input table - * - * @param servInstId - * the Id of service instance the secondary input was added for. - * @param article_name - * the article name of the secondary input. - * @param def - * the default value of the secondary input. - * @param dataType - * the type of data of the secondary input. - * @param max - * the maximum value of the secondary input - * @param min - * the minimum value of the secondary input - * @param enumeration - * the enumeration value for the secondary input - * @param minSecNum - * minimum free number for secondary_input_id - */ - - public static void updateSec(int servInstId, String article_name, - String def, String dataType, BigDecimal max, BigDecimal min, - String enumeration, int minSecNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update secondary_input set service_instance_id=?,article_name=?,default_value=?,maximum_value=?,minimum_value=?,enum_value=?,datatype=? where secondary_input_id=?"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - ps.setString(2, article_name); - ps.setString(3, def); - ps.setBigDecimal(4, max); - ps.setBigDecimal(5, min); - ps.setString(6, enumeration); - ps.setString(7, dataType); - ps.setInt(8, minSecNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } - } - } - - /** - * add the record into the simple_output table - * - * @param servInstId - * the Id of service instance the simple output was added for. - * @param articleName - * the article name of the simple output. - * @param objTypeUri - * the object type URI of the simple output. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple output. - * @param colOutId - * the collection input Id if this simple output belongs to a - * collection, and blank otherwise. - */ - - public static void insIntoSimpleOutput(Integer servInstId, - String articleName, String objTypeUri, String nsTypeUris, - Integer colOutId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into simple_output (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_output_id) values (?,?,?,?,?)"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - if (servInstId != null) { - ps.setInt(1, servInstId.intValue()); - } else { - ps.setNull(1, java.sql.Types.INTEGER); - } - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - if (colOutId != null) { - ps.setInt(5, colOutId.intValue()); - } else { - ps.setNull(5, java.sql.Types.INTEGER); - } - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - } - - /** - * update the record into the simple_output table - * - * @param servInstId - * the Id of service instance the simple output was added for. - * @param articleName - * the article name of the simple output. - * @param objTypeUri - * the object type URI of the simple output. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple output. - * @param colOutId - * the collection input Id if this simple output belongs to a - * collection, and blank otherwise. - * @return ret=1 if the record has added, and ret=-1 otherwise - */ - - public static int updateSimpleOutput(int servInstId, String articleName, - String objTypeUri, String nsTypeUris, int colOutId, int minNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update simple_output set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_output_id=? where simple_output_id=?"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setInt(1, servInstId); - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - ps.setInt(5, colOutId); - ps.setInt(6, minNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return ret; - } - - /** - * get the number of errors for the given return code and URL of resource - * - * @param signURL - - * the URL of resource was gotten the return code for. - * @param errCode - - * the error code, connection was refused - * @return Intrger number of error if was found in the database, zero - * otherwise - */ - - public static int getServErrorNum(String signURL, int errCode) { - - int num = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select counter from service_validation where signatureURL = ? and error_code = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - ps.setInt(2, errCode); - rs = ps.executeQuery(); - - while (rs.next()) { - int cnt = rs.getInt(1); - num = cnt; - - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return num; - - } - - /** - * get the service signature data for service instance by the service name - * and signatureURL - * - * @param signURL - - * the URL of service RDF - * @param servName - - * the name of service - * @return carrier class ServSignature - */ - - public static ServSignature getServSignature(String servName, String signURL) { - - ServSignature signature = new ServSignature(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id,authority_id,category,service_type_uri,url,contact_email,authoritative,description from service_instance where servicename=? and signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setString(2, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - int servInstId = rs.getInt(1); - signature.setServInstId(servInstId); - int authId = rs.getInt(2); - signature.setAuthId(authId); - String category = rs.getString(3); - signature.setCategory(category); - String serviceType = rs.getString(4); - signature.setServiceType(serviceType); - String url = rs.getString(5); - signature.setUrl(url); - String email = rs.getString(6); - signature.setEmail(email); - String authoritative = rs.getString(7); - signature.setAuthoritative(authoritative); - String description = rs.getString(8); - signature.setDescription(description); - signature.setServiceName(servName); - signature.setSignatureURL(signURL); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return signature; - - } - - /** - * get the secondary input data by the secondary input Id - * - * @param servInstId - - * the secondary input Id - * @return carrier class Secondary - */ - - public static Secondary getSecondary(int servInstId) { - - Secondary second = new Secondary(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select default_value,maximum_value,minimum_value,enum_value,datatype,article_name from secondary_input where service_instance_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - int open_sec = 0; - while (rs.next()) { - String defaultValue = rs.getString(1); - second.setDefaultValue(defaultValue); - BigDecimal maximumValue = rs.getBigDecimal(2); - second.setMaximumValue(maximumValue); - BigDecimal minimumValue = rs.getBigDecimal(3); - second.setMinimumValue(minimumValue); - String enumValue = rs.getString(4); - second.setEnumValue(enumValue); - String datatype = rs.getString(5); - second.setDatatype(datatype); - String articleName = rs.getString(6); - second.setArticleName(articleName); - - XMLBuilder.buildSecondXml(second); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return second; - - } - - /** - * get the simple/collection output data by the service instance Id and - * build xml representation - * - * @param servInstId - - * the service instance Id - */ - - public static void getSimpleCollectOutput(int servInstId) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_output_id from simple_output where service_instance_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - - while (rs.next()) { - String artName = rs.getString(1); - String nsType = rs.getString(2); - String objType = rs.getString(3); - // int colOutId = rs.getInt(4); - String type; - Integer colOutId = new Integer(rs.getInt(4)); - if (colOutId == null) { - type = "so"; - } else { - type = "co"; - } - - XMLBuilder.buildInpOutXml(artName, nsType, objType, type); - } - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - } - - /** - * get the simple/collection input data by the service instance Id and build - * xml representation - * - * @param servInstId - - * the service instance Id - */ - - public static void getSimpleCollectInput(int servInstId) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_input_id from simple_input where service_instance_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - - while (rs.next()) { - String artName = rs.getString(1); - String nsType = rs.getString(2); - String objType = rs.getString(3); - String type; - // int colInpId = rs.getInt(4); - Integer colInpId = new Integer(rs.getInt(4)); - if (colInpId == null) { - type = "si"; - } else { - type = "ci"; - } - - XMLBuilder.buildInpOutXml(artName, nsType, objType, type); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - } - - /** - * update the counter for the given return code and URL of resource - * - * @param signURL - - * the URL of resource was updated the counter for. - * @param errCode - - * the error code was encreased the counter for. - * @return Intrger ret=1 if the record was updated, ret=-1 otherwise - */ - - public static int updErrCount(String signURL, int errCode) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update service_validation set error_code = ?,counter=counter+1 where signatureURL = ?"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setInt(1, errCode); - ps.setString(2, signURL); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return ret; - } - - /** - * add new record to the service_validation table of the mobycentral - * database - * - * @param signURL - - * the URL of resource the connection was refused for. - * @param errCode - - * the error code, connection was refused - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int insErrCount(String signURL, int errCode) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into service_validation (signatureURL,error_code,counter) values (?,?,1)"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, signURL); - ps.setInt(2, errCode); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return ret; - } - - /** - * delete the record from service_validation table by signatureURL - * - * @param signURL - - * the URL of resource the record was deleted for. - * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. - */ - - public static int delServErrors(String signURL) { - - Connection con = DBConnector.getConnection(); - int ret = -1; - final String sqlReq1 = "delete from service_validation where signatureURL = ?"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.warning(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - - } - - /** - * get the service instance Id for the given service name and authority Id - * - * @param servName - - * the name of service instance . - * @param authId - - * the authority Id for the service instance. - * @return Intrger service instance Id if was found in the database, zero - * otherwise - */ - - public static int getServInstId(String servName, int authId) { - - int servInsId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && authority_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setInt(2, authId); - rs = ps.executeQuery(); - - while (rs.next()) { - servInsId = rs.getInt(1); - - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return servInsId; - } - - /** - * get the service instance Id for the given service name and signatureURL - * - * @param servName - - * the name of service instance . - * @param signURL - - * URL of resource for the service instance. - * @return Intrger service instance Id if was found in the database, zero - * otherwise - */ - - public static int getServInstId(String servName, String signURL) { - - int servInsId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setString(2, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - servInsId = rs.getInt(1); - - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return servInsId; - } - - /** - * get the set of services for the given URL of resource by signatureURL - * - * @param signURL - - * the URL of resource . - * @return String set of the services which was found in the database, empty - * string otherwise - */ - - public static String getServListByURL(String signURL) { - - StringBuffer servList = new StringBuffer(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select servicename from service_instance where signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - String servName = rs.getString(1); - servList.append(servName + ","); - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return servList.toString(); - } - - /** - * delete a record from given table by a service instance Id (the metod is - * working for simple_input/output, collection input/output tables) - * - * @param servInstId - - * the service instance Id. - * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. - */ - - public static int delRow(String tableName, int servInstId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "delete from " + tableName - + " where service_instance_id = ?"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setInt(1, servInstId); - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - return ret; - } - - /** - * delete a record from simple table by a service instance Id and - * collection_input_id (the metod is working for simple_input/output, - * collection input/output tables) - * - * @param servInstId - - * the service instance Id. - */ - - public static void delCollectionMember(String inout, int servInstId) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1; - //System.out.println("inout = "+inout); - if (inout.equals("input")) { - sqlReq1 = "select collection_input_id from collection_input where service_instance_id = ? "; - } else { - sqlReq1 = "select collection_output_id from collection_output where service_instance_id = ? "; - } - //System.out.println("sqlReq1 = "+sqlReq1); - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - while (rs.next()) { - int colId = rs.getInt(1); - //System.out.println("colId = "+colId); - final String sqlReq; - if (inout.equals("input")) { - sqlReq = "delete from simple_input where collection_input_id=" - + colId; - //System.out.println("sqlReq = "+sqlReq); - } else { - sqlReq = "delete from simple_output where collection_output_id=" - + colId; - } - PreparedStatement ps1 = null; - - try { - ps1 = con.prepareStatement(sqlReq); - // ps.setInt(1, servInstId); - ps1.executeUpdate(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } finally { - try { - if (ps1 != null) - ps1.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } - } - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } - } - - } - - /** - * delete a record from service_instance table by a servicename and - * authority Id - * - * @param servName - - * the service instance name. - * @param authId - - * the id of the authority - * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. - */ - - public static int delSignature(String servName, int authId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - // if (authId == 0){ - final String sqlReq1 = "delete from service_instance where servicename= ? and authority_id = ?"; - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setInt(2, authId); - ret = ps.executeUpdate(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * get the collection Id from collection_input or collection_output table by - * the service_instance_id - * - * @param table - - * the collection_input or collection_output table - * @param field - - * "collection_input_id" (for collection_input table) and - * "collection_output_id" (for collection_output table) - * @param servInstId - - * Id of service instance - * @return Integer collection Id if was found, zero otherwise. - */ - - public static int getCollectionId(String table, String field, int servInstId) { - - int colId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select " - + field - + " from " - + table - + " where service_instance_id = ? order by service_instance_id," - + field + " ASC"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - - while (rs.next()) { - colId = rs.getInt(1); - - } - - } catch (SQLException e) { - - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return colId; - - } - - /** - * add new record into the collection_input or collection_output table - * - * @param table - - * the collection_input or collection_output table - * @param artName - - * the artical name of the collection_input or collection_output - * @param servInstId - - * Id of service instance - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int insIntoCol(String table, String artName, int servInstId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into " + table - + " (article_name,service_instance_id) values (?,?)"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, artName); - ps.setInt(2, servInstId); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * update record into the collection_input or collection_output table - * - * @param table - - * the collection_input or collection_output table - * @param key_field - - * collection_input_id for collection_input table, - * collection_output_id for collection_output table; - * @param artName - - * the artical name of the collection_input or collection_output - * @param servInstId - - * Id of service instance - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int updateCol(String table, String key_field, String artName, - int servInstId, int minNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update " + table - + " set article_name=?,service_instance_id=? where " - + key_field + " =?"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, artName); - ps.setInt(2, servInstId); - ps.setInt(3, minNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * get the service authority URI from authority table by the servicename - * - * @param servName - - * the name of service - * @return String authority URI if was found, empty string otherwise. - */ - - public static String getServAuthURI(String servName) { - - Connection con = DBConnector.getConnection(); - - String authURI = ""; - - final String sqlReq1 = "select authority_uri from service_instance si,authority a where si.authority_id=a.authority_id and si.servicename=?"; - ; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - rs = ps.executeQuery(); - - while (rs.next()) { - authURI = rs.getString(1); - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return authURI; - - } - - /** - * get the service authority Id from service_instance table by the - * servicename and signatureURL - * - * @param serviceName - - * the name of service - * @param signURL - - * the signatureURL for the given service - * @return int authority Id if was found, zero otherwise. - */ - - public static int getAuthIdByServNameAndSignURL(String serviceName, - String signURL) { - - int authId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select authority_id from service_instance where servicename = ? and signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, serviceName); - ps.setString(2, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - authId = rs.getInt(1); - - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return authId; - } - - /** - * add new record to the authority table - * - * @param authURI - - * the authority URI - * @param email - - * the contact e-Mail - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int insIntoAuthority(String authURI, String email) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into authority (authority_common_name,authority_uri,contact_email) values (null,?,?)"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, authURI); - ps.setString(2, email); - ret = ps.executeUpdate(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - - return ret; - } - - /** - * get the service authority Id from authority table by the authority URI - * - * @param authURI - - * the authority URI - * @return int authority Id if was found, zero otherwise. - */ - - public static int getAuthIdByAuthURI(String authURI) { - - int authId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select authority_id from authority where authority_uri = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, authURI); - - rs = ps.executeQuery(); - - while (rs.next()) { - authId = rs.getInt(1); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return authId; - - } - - /** - * get the contact e-Mail from service_instance table by the servicename - * - * @param signURL - - * the URL of a resource - * @return String contact e-Mail if was found, empty string otherwise. - */ - - public static String getContactEmail(String signURL) { - - String email = ""; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select contact_email from service_instance where signatureURL = ? "; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - String cnt = rs.getString(1); - email = cnt; - - } - - } catch (SQLException e) { - - // e.printStackTrace(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - //System.out.println("email = "+email); - return email; - - } - - /** - * - * gets the min number of records with service instance id = 0 - * - * @param table - * @param key_field - * @return the number of records - */ - - public static int getMinFreeNumber(String table, String key_field) { - - int num = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select min(" + key_field + ") from " + table - + " where service_instance_id = 0 order by " + key_field; - - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - rs = ps.executeQuery(); - - while (rs.next()) { - num = rs.getInt(1); - } - - } catch (SQLException e) { - - // e.printStackTrace(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } + /** + * get the list of signatureURL from service_instance table + * + * @return a Hashtable (signatureURL = string of servicenames for this URL + * separated by comma) + * + * + */ + + public static Hashtable getServices(String file) { + + Hashtable services = new Hashtable(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select servicename,signatureURL,authority_id from service_instance order by signatureURL"; + + PreparedStatement ps = null; + ResultSet rs = null; + + try { + ps = con.prepareStatement(sqlReq1); + rs = ps.executeQuery(); + String lastAddr = ""; + StringBuffer servNames = new StringBuffer(); + int lastID = -1; + + while (rs.next()) { + String servName = rs.getString(1); + String rdfAddr = rs.getString(2); + int authorityID = rs.getInt(3); // value will never be null, so + // wasNull() not necessary + if (rdfAddr == null) { + //TODO - make this code more efficient! - maybe perform one + // sql call instead of many + // update the signatureURL field using the service name and + // authority id + String bogusSigURL = "http://invalidURL123.com/author/" + + authorityID + "/" + servName + ".xml"; + String updateSQLString = "UPDATE service_instance " + + "SET signatureURL='" + bogusSigURL + "' " + + "WHERE authority_id=" + authorityID + + " and servicename='" + servName + "'"; + PreparedStatement preparedStatement = null; + try { + Connection updateCon = DBConnector.getConnection(); + preparedStatement = updateCon + .prepareStatement(updateSQLString); + int resultSet = preparedStatement.executeUpdate(); + Log + .info(resultSet + + ": Updated the signatureURL field of the authority with id #" + + authorityID + " to be " + bogusSigURL + + "."); + } catch (SQLException e) { + Log + .severe("Could not update SignatureURL field with a bogus signatureURL.\n" + + e.getMessage()); + } + + } else { + if (rdfAddr.equals(lastAddr)) { + servNames.append("," + servName); + } else { + if (servNames.length() > 0) { + services.put(lastAddr, servNames); + servNames = new StringBuffer(); + } + servNames.append(servName); + lastAddr = rdfAddr; + Report.doSave(file, lastAddr); + } + } + } + services.put(lastAddr, servNames); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + //System.out.println("ListOFServices : "+services); + + return services; + } + + /** + * get the list of services by signatureURL + * + * @param signURL - + * URL of resource + * @return a Hashtable (signatureURL = string of servicenames for this URL + * separated by comma) + */ + + public static Hashtable getServicesByURL(String signURL) { + + Hashtable services = new Hashtable(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select servicename,signatureURL from service_instance where signatureURL=?"; + + PreparedStatement ps = null; + ResultSet rs = null; + + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + String lastAddr = ""; + StringBuffer servNames = new StringBuffer(); + + while (rs.next()) { + String servName = rs.getString(1); + String rdfAddr = rs.getString(2); + + if (rdfAddr.equals(lastAddr)) { + servNames.append("," + servName); + } else { + if (servNames.length() > 0) { + services.put(lastAddr, servNames); + servNames = new StringBuffer(); + } + servNames.append(servName); + lastAddr = rdfAddr; + } + } + services.put(lastAddr, servNames); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + // System.out.println("ListOFServices : "+services); + + return services; + } + + /** + * This method use for the update service_instance table, + * simple_input/output table, collection_input/output table, secondary_input + * table in accordance with data from RDF file. + * + * @param servSign - + * set of the serviceSignature data (name - value, an example: + * servicename - GoTerm); Hashtable of hashtables represented by + * a pair: a name of the input = hashtable for this output + * example:{siminp1={object_type_uri=urn:lsid:biomoby.org:objectclass:Object, + * namespace_type_uris=urn:lsid:biomoby.org:namespacetype:taxon}} + * @param servInp - + * Hashtable of hashtables represented by a pair: a name of the + * output = hashtable for this output + * @param servname - + * the name of service + * @param authURI - + * the authority URI + * @param signURL - + * URL of resource + */ + + public static void processService(Hashtable servSign, Hashtable servInp, + Hashtable servOut, String servname, String authURI, String signURL) { + + Connection con = DBConnector.getConnection(); + String servName = ""; + String cat = "moby"; + String url = ""; + String email = ""; + String desc = ""; + String stype = ""; + String authuri = ""; + String authoritative = ""; + String art = null; + String col_art = null; + String obt = null; + String nst = null; + String artsec = null; + String defsec = null; + String dtsec = null; + + BigDecimal maxsec = null; + BigDecimal minsec = null; + + String enumsec = null; + int colId = 0; + Integer colOutId = null; + Integer colInpId = null; + int serv = 0; // a flag - the given service was found + int checkServ = 0; // a flag - the service exist in the database + int new_serv = 0; // the number of new services + int ret; + int servInstId = 0; + String signatureURL = "NNN"; + + // ************** Update service Signature **************** + + Enumeration num = servSign.keys(); + + while (num.hasMoreElements()) { + + Object ob = num.nextElement(); + Object val = servSign.get(ob); + if (ob.equals("category")) { + cat = val.toString(); + } else if (ob.equals("URL")) { + url = val.toString(); + } else if (ob.equals("contact_email")) { + email = val.toString(); + } else if (ob.equals("description")) { + desc = val.toString(); + } else if (ob.equals("service_type_uri")) { + stype = val.toString(); + } else if (ob.equals("authURI")) { + authuri = val.toString(); + } else if (ob.equals("authoritative")) { + authoritative = val.toString(); + + if (authoritative.equals("non-authoritative")) { + authoritative = "0"; + } else if (authoritative.equals("authoritative")) { + authoritative = "1"; + } + } else if (ob.equals("servicename")) { + servName = val.toString(); + } else if (ob.equals("signatureURL")) { + signatureURL = val.toString(); + } + + } + + ServSignature signature = getServSignature(servname, signURL); + servInstId = signature.getServInstId(); + //TODO make sure that the fields are updated + if (servInstId == 0) { + + int authId = getAuthIdByAuthURI(authuri); + + if (authId == 0) { + insIntoAuthority(authuri, email); + authId = getAuthIdByAuthURI(authuri); + } + + if (signatureURL.equals("NNN")) { + ret = createSignature(servName, cat, stype, authId, url, email, + authoritative, desc, signURL); + } else { + ret = createSignature(servName, cat, stype, authId, url, email, + authoritative, desc, signatureURL); + } + + if (ret == 1) { + String msg = "------The service instance <" + servName + + "> was registered in the MOBYCENTRAL registry "; + Report.doWrite(msg); + Report.add(msg); + + //System.out.println("mail_server = + // "+Constants.MB_MAIL_SERVER); + /* + * if (Constants.MB_MAIL_SERVER != null | + * !Constants.MB_MAIL_SERVER.equals("")) { String to = + * DataMngr.getContactEmail(signURL); + * Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // + * send message to the service provider - that service was + * deregistered } + */ + new_serv += 1; + servInstId = getServInstId(servName, authId); + } + } else { + + if (!cat.equals(signature.getCategory()) + || !url.equals(signature.getUrl()) + || !email.equals(signature.getEmail()) + || !desc.equals(signature.getDescription()) + || !stype.equals(signature.getServiceType()) + || !authoritative.equals(signature.getAuthoritative()) + || !authuri.equals(authURI)) { + + //TODO + Log.info("Updating the service '" + servName + + "' since the RDF document has been modified."); + if (signatureURL.equals("NNN")) { + Log.info("sig == NNN" + signURL); + Log + .info("=<" + + servName + + "," + + cat + + "," + + stype + + "," + + authuri + + "," + + url + + "," + + email + + "," + + desc + + "," + + authoritative + + "," + + signURL + ">"); + int res = updSign(servName, cat, stype, authuri, url, + email, desc, authoritative, signURL); + if (res == 1) { + Report.doWrite("------The service instance<" + servName + + "> was updated "); + Report.add("------The service instance <" + servName + + ">was updated "); + } else { + Report.doWrite("------The service instance<" + servName + + "> was not updated"); + Report.add("------The service instance <" + servName + + ">was not updated "); + } + + } else { + Log.info("sig != NNN"); + int res = updSign(servName, cat, stype, authuri, url, + email, desc, authoritative, signatureURL); + if (res == 1) { + Report.doWrite("------The service instance <" + + servName + "> was updated "); + Report.add("------The service instance <" + servName + + ">was updated "); + } else { + Report.doWrite("------The service instance <" + + servName + "> was not updated "); + Report.add("------The service instance <" + servName + + ">was not updated "); + } + } + } + } + + // ************ add Input ********************* + + Enumeration num1 = servInp.keys(); + int dels = 0; + int delc = 0; + int delsec = 0; + int si = 0; + int ci = 0; + int sci = 0; + + /* if there are no inputs, delete all from mobycentral */ + if (servInp.size() == 0) { + //make sure that there are no inputs in the db (simples, secondary + // or collection) + if (delRow("secondary_input", servInstId) == 1) + delsec = 1; + delCollectionMember("input", servInstId); + if (delRow("collection_input", servInstId) == 1) + delc = 1; + if (delRow("simple_input", servInstId) == 1) + dels = 1; + } + if (!servInp.containsKey("siminp1")) { + if (delRow("simple_input", servInstId) == 1) + dels = 1; + } + if (!servInp.containsKey("colinp1")) { + delCollectionMember("input", servInstId); + if (delRow("collection_input", servInstId) == 1) + delc = 1; + } + /* + * going to remove any secondaries not in the hash - quick hack to + * bug#29 + */ + if (!servInp.containsKey("secinp1")) { + if (delRow("secondary_input", servInstId) == 1) + delsec = 1; + } + while (num1.hasMoreElements()) { + Object ob = num1.nextElement(); + Object val = servInp.get(ob); + String simcol = (ob.toString()).substring(0, 6); // a hashtable name + + if (simcol.equals("secinp")) { // if it's a Secondary input + sci += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Secondary input " + sci); + Report.add("Secondary input " + sci + ":"); + if (delsec == 0) { + delRow("secondary_input", servInstId); + delsec = 1; + } + } else if (simcol.equals("colinp")) { // if it's a Collection input + ci += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Collection input " + ci); + Report.add("Collection input " + ci + ":"); + if (delc == 0) { + // colInpId = new + // Integer(getCollectionId("collection_input","collection_input_id",servInstId)); + delCollectionMember("input", servInstId); // delete from + // simple_input + // table + delRow("collection_input", servInstId); // delete from the + // collection_input + // table + delc = 1; + } + + } else { // if it's a Simple input + Report.doWrite(" "); + Report.add(" "); + si += 1; + Report.doWrite("Simple input " + si); + Report.add("Simple input " + si + ":"); + if (dels == 0) { + delRow("simple_input", servInstId); // delete from + // simple_input table + dels = 1; + } + } + Hashtable simple = new Hashtable(); + simple = (Hashtable) val; + Enumeration num11 = simple.keys(); + + while (num11.hasMoreElements()) { + Object ob1 = num11.nextElement(); + if (!ob1.equals("type")) { + Report.doWrite(ob1 + " = " + simple.get(ob1)); + Report.add(ob1 + " = " + simple.get(ob1)); + } + + if (ob1.equals("col_articleName")) { + col_art = simple.get(ob1).toString(); + if (col_art.equals(" ")) { + col_art = null; + } + } else if (ob1.equals("articleName")) { + art = simple.get(ob1).toString(); + if (art.equals(" ")) { + art = null; + } + } else if (ob1.equals("article_name")) { + artsec = simple.get(ob1).toString(); + if (artsec.equals(" ")) { + artsec = null; + } + } else if (ob1.equals("object_type_uri")) { + obt = simple.get(ob1).toString(); + } else if (ob1.equals("namespace_type_uris")) { + nst = simple.get(ob1).toString(); + } else if (ob1.equals("default")) { + defsec = simple.get(ob1).toString(); + } else if (ob1.equals("datatype")) { + dtsec = simple.get(ob1).toString(); + } else if (ob1.equals("max")) { + String maxsec_s = simple.get(ob1).toString(); + try { + maxsec = new BigDecimal(maxsec_s); + + } catch (NumberFormatException nx) { + Log.severe(nx.getMessage()); + // nx.getMessage(); + } + } else if (ob1.equals("min")) { + String minsec_s = simple.get(ob1).toString(); + try { + minsec = new BigDecimal(minsec_s); + + } catch (NumberFormatException nx) { + Log.severe(nx.getMessage()); + // nx.getMessage(); + } + } else if (ob1.equals("enum")) { + enumsec = simple.get(ob1).toString(); + } + } + + if (simcol.equals("colinp")) { + insIntoCol("collection_input", col_art, servInstId); // insert + // the row + // into + // collection_input + // table + colId = getCollectionId("collection_input", + "collection_input_id", servInstId); + insIntoSimpleInput(null, art, obt, nst, new Integer(colId)); + + art = null; + col_art = null; + obt = null; + nst = null; + } else if (simcol.equals("siminp")) { + insIntoSimpleInput(new Integer(servInstId), art, obt, nst, null); + + art = null; + obt = null; + nst = null; + } else if (simcol.equals("secinp")) { + + insIntoSecondary(servInstId, artsec, defsec, dtsec, maxsec, + minsec, enumsec); + + artsec = null; + defsec = null; + dtsec = null; + maxsec = null; + minsec = null; + enumsec = null; + } + + if (colId != 0) { + Report.doWrite("collection_input_id: " + colId); + // Log.info("collection_input_id: "+colId); + } + } + + Report.doWrite("service_instance_id: " + servInstId); + // Log.info("service_instance_id: "+servInstId); + + // *********** add Output *********************** + + Enumeration numout = servOut.keys(); + int delsout = 0; + int delcout = 0; + int so = 0; + int co = 0; + if (servOut.size() == 0) { + //make sure that there are no outputs in the db (simples or + // collection) + delCollectionMember("output", servInstId); + if (delRow("collection_output", servInstId) == 1) + delcout = 1; + if (delRow("simple_output", servInstId) == 1) + delsout = 1; + Report.doWrite("Removed all outputs."); + Log.info("Removed all outputs."); + } + if (!servOut.containsKey("colout1")) { // using simout1 because counting starts at 1 + delCollectionMember("output", servInstId); + if (delRow("collection_output", servInstId) == 1) + delcout = 1; + } + if (!servOut.containsKey("simout1")) { // using simout1 because counting starts at 1 + if (delRow("simple_output", servInstId) == 1) + delsout = 1; + } + while (numout.hasMoreElements()) { + Object ob = numout.nextElement(); + Object val = servOut.get(ob); + String simcol = (ob.toString()).substring(0, 6); + if (simcol.equals("colout")) { + co += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Collection output " + co); + Report.add("Collection output " + co + ":"); + if (delcout == 0) { + // colOutId = new + // Integer(getCollectionId("collection_output","collection_output_id",servInstId)); + delCollectionMember("output", servInstId); // delete from + // table + // simple_output + delRow("collection_output", servInstId); // delete from the + // collection_output + // table + delcout = 1; + } + } else { + so += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Simple output " + so); + Report.add("Simple output " + so + ":"); + + //TODO bug #13 here? + if (delsout == 0) { + delRow("simple_output", servInstId); // delete from + // simple_output table + delsout = 1; + } + } + Hashtable simple = new Hashtable(); + simple = (Hashtable) val; + Enumeration num11 = simple.keys(); + // Report.doWrite(""+simple); + + while (num11.hasMoreElements()) { + Object ob1 = num11.nextElement(); + if (!ob1.equals("type")) { + Report.doWrite(ob1 + " = " + simple.get(ob1)); + Report.add(ob1 + " = " + simple.get(ob1)); + } + + if (ob1.equals("col_articleName")) { + col_art = simple.get(ob1).toString(); + if (col_art.equals(" ")) { + col_art = null; + } + } + if (ob1.equals("articleName")) { + art = simple.get(ob1).toString(); + if (art.equals(" ")) { + art = null; + } + } + if (ob1.equals("object_type_uri")) { + obt = simple.get(ob1).toString(); + } + if (ob1.equals("namespace_type_uris")) { + nst = simple.get(ob1).toString(); + } + } + + if (simcol.equals("colout")) { + + insIntoCol("collection_output", col_art, servInstId); // insert + // the row + // into + // collection_input + // table + + colOutId = new Integer(getCollectionId("collection_output", + "collection_output_id", servInstId)); + insIntoSimpleOutput(null, art, obt, nst, colOutId); + art = null; + obt = null; + nst = null; + } + // TODO bug #11 here - fixed + if (simcol.equals("simout")) { + insIntoSimpleOutput(new Integer(servInstId), art, obt, nst, + null); + art = null; + obt = null; + nst = null; + } + if (colOutId != null) { + Report.doWrite("collection_output_id: " + colOutId); + // Log.info("collection_output_id: "+coloutId); + } + } + // return serv; + } + + /** + * delete the service instance by service name and authority URI + * + * @param servName + * the name of service which we want delete. + * @param authURI + * the authority URI for service which we want delete. + * + */ + + public static void delServByNameAndAuthURI(String servName, String authURI) { + + int authId = getAuthIdByAuthURI(authURI); + int servInstId = getServInstId(servName, authId); + + delSignature(servName, authId); // delete service from table + // service_instance + delRow("simple_input", servInstId); // delete from table simple_input + delRow("simple_output", servInstId); // delete from table simple_output + delRow("secondary_input", servInstId); //TODO - should this line be + // here? + delCollectionMember("input", servInstId); + delCollectionMember("output", servInstId); + delRow("collection_input", servInstId); // delete from table + // collection_input + delRow("collection_output", servInstId); // delete from table + // collection_output + } + + /** + * delete the service instance by service name and signature URL + * + * @param servName + * the name of service which we want delete. + * @param signURL + * the authority URI for service which we want delete. + * + */ + + public static void delServByNameAndUrl(String servName, String signURL) { + + int authId = getAuthIdByServNameAndSignURL(servName, signURL); + int servInstId = getServInstId(servName, authId); + + delSignature(servName, authId); // delete service from table + // service_instance + delRow("simple_input", servInstId); // delete from table simple_input + delRow("simple_output", servInstId); // delete from table simple_output + delRow("secondary_input", servInstId); //TODO - should this line be + // here? + delCollectionMember("input", servInstId); + delCollectionMember("output", servInstId); + delRow("collection_input", servInstId); // delete from table + // collection_input + delRow("collection_output", servInstId); // delete from table + // collection_output + } + + /** + * delete set of the service instances with the same signatureURL by + * signatureURL + * + * @param signURL + * the name of service which we want delete. + */ + + public static void delServiceSetByURL(String signURL) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id,servicename,authority_id from service_instance where signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + Vector del_serv = new Vector(); + + while (rs.next()) { + int servInstId = rs.getInt(1); + String servName = rs.getString(2); + int authId = rs.getInt(3); + + int rez = delSignature(servName, authId); // delete service from + // table + // service_instance + if (rez == 1) { + del_serv.addElement(servName); + } + delRow("secondary_input", servInstId); //TODO - should this + // line be here? + delRow("simple_input", servInstId); // delete from table + // simple_input + delRow("simple_output", servInstId); // delete from table + // simple_output + delCollectionMember("input", servInstId); // delete collection + // member from + // simple_input + delCollectionMember("output", servInstId); // delete collection + // member from + // simple_output + delRow("collection_input", servInstId); // delete from table + // collection_input + delRow("collection_output", servInstId); // delete from table + // collection_output + } + + int del = del_serv.size(); + if (del > 0) { + Report.doWrite("DELETED SERVICES: "); + Iterator i = del_serv.iterator(); + int n = 1; + while (i.hasNext()) { + String delServ = i.next().toString(); + Report.doWrite(n + ". " + delServ); + n += 1; + } + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } + } + + } + + /** + * add the record about new service instance in the service_instance table + * of mobycentral database + * + * @param servName - + * the name of service instance the record was added for. + * @param cat - + * the category of service instance. + * @param servTypeURI - + * the service type URI of service instance. + * @param authId - + * the authority Id of service instance. + * @param url - + * the URL of service instance. + * @param email - + * the contact e-Mail of service instance. + * @param authoritative - + * the authoritative of service instance. + * @param desc - + * the description of service instance. + * @param signURL - + * the URL for RDF of service instance. + * @return ret=1 if the record has added, and ret=-1 otherwise + */ + + public static int createSignature(String servName, String cat, + String servTypeURI, int authId, String url, String email, + String authoritative, String desc, String signURL) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into service_instance (servicename,category,service_type_uri,authority_id,url,contact_email,authoritative,description,signatureURL) values (?,?,?,?,?,?,?,?,?)"; + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setString(2, cat); + ps.setString(3, servTypeURI); + ps.setInt(4, authId); + ps.setString(5, url); + ps.setString(6, email); + ps.setString(7, authoritative); + ps.setString(8, desc); + ps.setString(9, signURL); + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * update the service instance data in the service_instance table of + * mobycentral database + * + * @param servName + * the name of service instance the record was updated for. + * @param cat + * the category of service instance. + * @param stype + * the service type URI of service instance. + * @param authuri + * the authority URI of service instance. + * @param url + * the URL of service instance. + * @param email + * the contact e-Mail of service instance. + * @param authoritative + * the authoritative of service instance. + * @param desc + * the description of service instance. + * @param signURL + * the URL for RDF of service instance. + * @return ret=1 if the record has updated, and ret=-1 otherwise + */ + + public static int updSign(String servName, String cat, String stype, + String authuri, String url, String email, String desc, + String authoritative, String signURL) { + + Connection con = DBConnector.getConnection(); + int cnt = -1; + int ret = -1; + final String sqlReq = "select authority_id from authority where authority_uri = ?"; + PreparedStatement ps = null; + + final String sqlReq1 = "update service_instance set category = ?,service_type_uri = ?,url = ?,contact_email = ?,description = ?,authoritative = ?,signatureURL = ? where servicename = ? && authority_id = ?"; + try { + ps = con.prepareStatement(sqlReq); + ps.setString(1, authuri); + ResultSet rs = ps.executeQuery(); + while (rs.next()) { + cnt = rs.getInt(1); + } + if (cnt > -1) { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, cat); + ps.setString(2, stype); + ps.setString(3, url); + ps.setString(4, email); + ps.setString(5, desc); + ps.setString(6, authoritative); + ps.setString(7, signURL); + ps.setString(8, servName); + ps.setInt(9, cnt); + ret = ps.executeUpdate(); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * add the record into the simple_input table + * + * @param servInstId + * the Id of service instance the simple input was added for. + * @param articleName + * the article name of the simple input. + * @param objTypeUri + * the object type URI of the simple input. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple input. + * @param colInpId + * the collection input Id if this simple input belongs to a + * collection, and blank otherwise. + */ + + public static void insIntoSimpleInput(Integer servInstId, + String articleName, String objTypeUri, String nsTypeUris, + Integer colInpId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into simple_input (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_input_id) values (?,?,?,?,?)"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + if (servInstId != null) { + ps.setInt(1, servInstId.intValue()); + } else { + ps.setNull(1, java.sql.Types.INTEGER); + } + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + if (colInpId != null) { + ps.setInt(5, colInpId.intValue()); + } else { + ps.setNull(5, java.sql.Types.INTEGER); + } + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + } + + /** + * update the record into the simple_input table + * + * @param servInstId + * the Id of service instance the simple input was added for. + * @param articleName + * the article name of the simple input. + * @param objTypeUri + * the object type URI of the simple input. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple input. + * @param colInpId + * the collection input Id if this simple input belongs to a + * collection, and blank otherwise. + * @return ret=1 if the record has added, and ret=-1 otherwise + */ + + public static int updateSimpleInput(int servInstId, String articleName, + String objTypeUri, String nsTypeUris, Integer colInpId, int minNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update simple_input set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_input_id=? where simple_input_id=?"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + if (colInpId != null) { + ps.setInt(5, colInpId.intValue()); + } else { + ps.setNull(5, java.sql.Types.INTEGER); + } + ps.setInt(6, minNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * add the record about secondary input in the secondary_input table of + * mobycentral database + * + * @param servInstId + * the Id of service instance the secondary input was added for. + * @param article_name + * the article name of the secondary input. + * @param def + * the default value of the secondary input. + * @param dataType + * the type of data of the secondary input. + * @param max + * the maximum value of the secondary input + * @param min + * the minimum value of the secondary input * + * @param enumeration + * the enumeration value for the secondary input + */ + + public static void insIntoSecondary(int servInstId, String article_name, + String def, String dataType, BigDecimal max, BigDecimal min, + String enumeration) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into secondary_input (service_instance_id,article_name,default_value,maximum_value,minimum_value,enum_value,datatype) values (?,?,?,?,?,?,?)"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + ps.setString(2, article_name); + ps.setString(3, def); + ps.setBigDecimal(4, max); + ps.setBigDecimal(5, min); + ps.setString(6, enumeration); + ps.setString(7, dataType); + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + } + + /** + * update the record into the secondary_input table + * + * @param servInstId + * the Id of service instance the secondary input was added for. + * @param article_name + * the article name of the secondary input. + * @param def + * the default value of the secondary input. + * @param dataType + * the type of data of the secondary input. + * @param max + * the maximum value of the secondary input + * @param min + * the minimum value of the secondary input + * @param enumeration + * the enumeration value for the secondary input + * @param minSecNum + * minimum free number for secondary_input_id + */ + + public static void updateSec(int servInstId, String article_name, + String def, String dataType, BigDecimal max, BigDecimal min, + String enumeration, int minSecNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update secondary_input set service_instance_id=?,article_name=?,default_value=?,maximum_value=?,minimum_value=?,enum_value=?,datatype=? where secondary_input_id=?"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + ps.setString(2, article_name); + ps.setString(3, def); + ps.setBigDecimal(4, max); + ps.setBigDecimal(5, min); + ps.setString(6, enumeration); + ps.setString(7, dataType); + ps.setInt(8, minSecNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } + } + } + + /** + * add the record into the simple_output table + * + * @param servInstId + * the Id of service instance the simple output was added for. + * @param articleName + * the article name of the simple output. + * @param objTypeUri + * the object type URI of the simple output. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple output. + * @param colOutId + * the collection input Id if this simple output belongs to a + * collection, and blank otherwise. + */ + + public static void insIntoSimpleOutput(Integer servInstId, + String articleName, String objTypeUri, String nsTypeUris, + Integer colOutId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into simple_output (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_output_id) values (?,?,?,?,?)"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + if (servInstId != null) { + ps.setInt(1, servInstId.intValue()); + } else { + ps.setNull(1, java.sql.Types.INTEGER); + } + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + if (colOutId != null) { + ps.setInt(5, colOutId.intValue()); + } else { + ps.setNull(5, java.sql.Types.INTEGER); + } + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + } + + /** + * update the record into the simple_output table + * + * @param servInstId + * the Id of service instance the simple output was added for. + * @param articleName + * the article name of the simple output. + * @param objTypeUri + * the object type URI of the simple output. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple output. + * @param colOutId + * the collection input Id if this simple output belongs to a + * collection, and blank otherwise. + * @return ret=1 if the record has added, and ret=-1 otherwise + */ + + public static int updateSimpleOutput(int servInstId, String articleName, + String objTypeUri, String nsTypeUris, int colOutId, int minNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update simple_output set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_output_id=? where simple_output_id=?"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setInt(1, servInstId); + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + ps.setInt(5, colOutId); + ps.setInt(6, minNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return ret; + } + + /** + * get the number of errors for the given return code and URL of resource + * + * @param signURL - + * the URL of resource was gotten the return code for. + * @param errCode - + * the error code, connection was refused + * @return Intrger number of error if was found in the database, zero + * otherwise + */ + + public static int getServErrorNum(String signURL, int errCode) { + + int num = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select counter from service_validation where signatureURL = ? and error_code = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + ps.setInt(2, errCode); + rs = ps.executeQuery(); + + while (rs.next()) { + int cnt = rs.getInt(1); + num = cnt; + + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return num; + + } + + /** + * get the service signature data for service instance by the service name + * and signatureURL + * + * @param signURL - + * the URL of service RDF + * @param servName - + * the name of service + * @return carrier class ServSignature + */ + + public static ServSignature getServSignature(String servName, String signURL) { + + ServSignature signature = new ServSignature(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id,authority_id,category,service_type_uri,url,contact_email,authoritative,description from service_instance where servicename=? and signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setString(2, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + int servInstId = rs.getInt(1); + signature.setServInstId(servInstId); + int authId = rs.getInt(2); + signature.setAuthId(authId); + String category = rs.getString(3); + signature.setCategory(category); + String serviceType = rs.getString(4); + signature.setServiceType(serviceType); + String url = rs.getString(5); + signature.setUrl(url); + String email = rs.getString(6); + signature.setEmail(email); + String authoritative = rs.getString(7); + signature.setAuthoritative(authoritative); + String description = rs.getString(8); + signature.setDescription(description); + signature.setServiceName(servName); + signature.setSignatureURL(signURL); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return signature; + + } + + /** + * get the secondary input data by the secondary input Id + * + * @param servInstId - + * the secondary input Id + * @return carrier class Secondary + */ + + public static Secondary getSecondary(int servInstId) { + + Secondary second = new Secondary(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select default_value,maximum_value,minimum_value,enum_value,datatype,article_name from secondary_input where service_instance_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + int open_sec = 0; + while (rs.next()) { + String defaultValue = rs.getString(1); + second.setDefaultValue(defaultValue); + BigDecimal maximumValue = rs.getBigDecimal(2); + second.setMaximumValue(maximumValue); + BigDecimal minimumValue = rs.getBigDecimal(3); + second.setMinimumValue(minimumValue); + String enumValue = rs.getString(4); + second.setEnumValue(enumValue); + String datatype = rs.getString(5); + second.setDatatype(datatype); + String articleName = rs.getString(6); + second.setArticleName(articleName); + + XMLBuilder.buildSecondXml(second); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return second; + + } + + /** + * get the simple/collection output data by the service instance Id and + * build xml representation + * + * @param servInstId - + * the service instance Id + */ + + public static void getSimpleCollectOutput(int servInstId) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_output_id from simple_output where service_instance_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + + while (rs.next()) { + String artName = rs.getString(1); + String nsType = rs.getString(2); + String objType = rs.getString(3); + // int colOutId = rs.getInt(4); + String type; + Integer colOutId = new Integer(rs.getInt(4)); + if (colOutId == null) { + type = "so"; + } else { + type = "co"; + } + + XMLBuilder.buildInpOutXml(artName, nsType, objType, type); + } + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + } + + /** + * get the simple/collection input data by the service instance Id and build + * xml representation + * + * @param servInstId - + * the service instance Id + */ + + public static void getSimpleCollectInput(int servInstId) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_input_id from simple_input where service_instance_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + + while (rs.next()) { + String artName = rs.getString(1); + String nsType = rs.getString(2); + String objType = rs.getString(3); + String type; + // int colInpId = rs.getInt(4); + Integer colInpId = new Integer(rs.getInt(4)); + if (colInpId == null) { + type = "si"; + } else { + type = "ci"; + } + + XMLBuilder.buildInpOutXml(artName, nsType, objType, type); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + } + + /** + * update the counter for the given return code and URL of resource + * + * @param signURL - + * the URL of resource was updated the counter for. + * @param errCode - + * the error code was encreased the counter for. + * @return Intrger ret=1 if the record was updated, ret=-1 otherwise + */ + + public static int updErrCount(String signURL, int errCode) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update service_validation set error_code = ?,counter=counter+1 where signatureURL = ?"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setInt(1, errCode); + ps.setString(2, signURL); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return ret; + } + + /** + * add new record to the service_validation table of the mobycentral + * database + * + * @param signURL - + * the URL of resource the connection was refused for. + * @param errCode - + * the error code, connection was refused + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int insErrCount(String signURL, int errCode) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into service_validation (signatureURL,error_code,counter) values (?,?,1)"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, signURL); + ps.setInt(2, errCode); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return ret; + } + + /** + * delete the record from service_validation table by signatureURL + * + * @param signURL - + * the URL of resource the record was deleted for. + * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. + */ + + public static int delServErrors(String signURL) { + + Connection con = DBConnector.getConnection(); + int ret = -1; + final String sqlReq1 = "delete from service_validation where signatureURL = ?"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.warning(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + + } + + /** + * get the service instance Id for the given service name and authority Id + * + * @param servName - + * the name of service instance . + * @param authId - + * the authority Id for the service instance. + * @return Intrger service instance Id if was found in the database, zero + * otherwise + */ + + public static int getServInstId(String servName, int authId) { + + int servInsId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && authority_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setInt(2, authId); + rs = ps.executeQuery(); + + while (rs.next()) { + servInsId = rs.getInt(1); + + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return servInsId; + } + + /** + * get the service instance Id for the given service name and signatureURL + * + * @param servName - + * the name of service instance . + * @param signURL - + * URL of resource for the service instance. + * @return Intrger service instance Id if was found in the database, zero + * otherwise + */ + + public static int getServInstId(String servName, String signURL) { + + int servInsId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setString(2, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + servInsId = rs.getInt(1); + + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return servInsId; + } + + /** + * get the set of services for the given URL of resource by signatureURL + * + * @param signURL - + * the URL of resource . + * @return String set of the services which was found in the database, empty + * string otherwise + */ + + public static String getServListByURL(String signURL) { + + StringBuffer servList = new StringBuffer(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select servicename from service_instance where signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + String servName = rs.getString(1); + servList.append(servName + ","); + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return servList.toString(); + } + + /** + * delete a record from given table by a service instance Id (the metod is + * working for simple_input/output, collection input/output tables) + * + * @param servInstId - + * the service instance Id. + * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. + */ + + public static int delRow(String tableName, int servInstId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "delete from " + tableName + + " where service_instance_id = ?"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setInt(1, servInstId); + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + return ret; + } + + /** + * delete a record from simple table by a service instance Id and + * collection_input_id (the metod is working for simple_input/output, + * collection input/output tables) + * + * @param servInstId - + * the service instance Id. + */ + + public static void delCollectionMember(String inout, int servInstId) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1; + //System.out.println("inout = "+inout); + if (inout.equals("input")) { + sqlReq1 = "select collection_input_id from collection_input where service_instance_id = ? "; + } else { + sqlReq1 = "select collection_output_id from collection_output where service_instance_id = ? "; + } + //System.out.println("sqlReq1 = "+sqlReq1); + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + while (rs.next()) { + int colId = rs.getInt(1); + //System.out.println("colId = "+colId); + final String sqlReq; + if (inout.equals("input")) { + sqlReq = "delete from simple_input where collection_input_id=" + + colId; + //System.out.println("sqlReq = "+sqlReq); + } else { + sqlReq = "delete from simple_output where collection_output_id=" + + colId; + } + PreparedStatement ps1 = null; + + try { + ps1 = con.prepareStatement(sqlReq); + // ps.setInt(1, servInstId); + ps1.executeUpdate(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } finally { + try { + if (ps1 != null) + ps1.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } + } + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } + } + + } + + /** + * delete a record from service_instance table by a servicename and + * authority Id + * + * @param servName - + * the service instance name. + * @param authId - + * the id of the authority + * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. + */ + + public static int delSignature(String servName, int authId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + // if (authId == 0){ + final String sqlReq1 = "delete from service_instance where servicename= ? and authority_id = ?"; + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setInt(2, authId); + ret = ps.executeUpdate(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * get the collection Id from collection_input or collection_output table by + * the service_instance_id + * + * @param table - + * the collection_input or collection_output table + * @param field - + * "collection_input_id" (for collection_input table) and + * "collection_output_id" (for collection_output table) + * @param servInstId - + * Id of service instance + * @return Integer collection Id if was found, zero otherwise. + */ + + public static int getCollectionId(String table, String field, int servInstId) { + + int colId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select " + + field + + " from " + + table + + " where service_instance_id = ? order by service_instance_id," + + field + " ASC"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + + while (rs.next()) { + colId = rs.getInt(1); + + } + + } catch (SQLException e) { + + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return colId; + + } + + /** + * add new record into the collection_input or collection_output table + * + * @param table - + * the collection_input or collection_output table + * @param artName - + * the artical name of the collection_input or collection_output + * @param servInstId - + * Id of service instance + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int insIntoCol(String table, String artName, int servInstId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into " + table + + " (article_name,service_instance_id) values (?,?)"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, artName); + ps.setInt(2, servInstId); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * update record into the collection_input or collection_output table + * + * @param table - + * the collection_input or collection_output table + * @param key_field - + * collection_input_id for collection_input table, + * collection_output_id for collection_output table; + * @param artName - + * the artical name of the collection_input or collection_output + * @param servInstId - + * Id of service instance + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int updateCol(String table, String key_field, String artName, + int servInstId, int minNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update " + table + + " set article_name=?,service_instance_id=? where " + + key_field + " =?"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, artName); + ps.setInt(2, servInstId); + ps.setInt(3, minNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * get the service authority URI from authority table by the servicename + * + * @param servName - + * the name of service + * @return String authority URI if was found, empty string otherwise. + */ + + public static String getServAuthURI(String servName) { + + Connection con = DBConnector.getConnection(); + + String authURI = ""; + + final String sqlReq1 = "select authority_uri from service_instance si,authority a where si.authority_id=a.authority_id and si.servicename=?"; + ; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + rs = ps.executeQuery(); + + while (rs.next()) { + authURI = rs.getString(1); + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return authURI; + + } + + /** + * get the service authority Id from service_instance table by the + * servicename and signatureURL + * + * @param serviceName - + * the name of service + * @param signURL - + * the signatureURL for the given service + * @return int authority Id if was found, zero otherwise. + */ + + public static int getAuthIdByServNameAndSignURL(String serviceName, + String signURL) { + + int authId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select authority_id from service_instance where servicename = ? and signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, serviceName); + ps.setString(2, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + authId = rs.getInt(1); + + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return authId; + } + + /** + * add new record to the authority table + * + * @param authURI - + * the authority URI + * @param email - + * the contact e-Mail + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int insIntoAuthority(String authURI, String email) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into authority (authority_common_name,authority_uri,contact_email) values (null,?,?)"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, authURI); + ps.setString(2, email); + ret = ps.executeUpdate(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + + return ret; + } + + /** + * get the service authority Id from authority table by the authority URI + * + * @param authURI - + * the authority URI + * @return int authority Id if was found, zero otherwise. + */ + + public static int getAuthIdByAuthURI(String authURI) { + + int authId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select authority_id from authority where authority_uri = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, authURI); + + rs = ps.executeQuery(); + + while (rs.next()) { + authId = rs.getInt(1); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return authId; + + } + + /** + * get the contact e-Mail from service_instance table by the servicename + * + * @param signURL - + * the URL of a resource + * @return String contact e-Mail if was found, empty string otherwise. + */ + + public static String getContactEmail(String signURL) { + + String email = ""; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select contact_email from service_instance where signatureURL = ? "; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + String cnt = rs.getString(1); + email = cnt; + + } + + } catch (SQLException e) { + + // e.printStackTrace(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + //System.out.println("email = "+email); + return email; + + } + + /** + * + * gets the min number of records with service instance id = 0 + * + * @param table + * @param key_field + * @return the number of records + */ + + public static int getMinFreeNumber(String table, String key_field) { + + int num = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select min(" + key_field + ") from " + table + + " where service_instance_id = 0 order by " + key_field; + + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + rs = ps.executeQuery(); + + while (rs.next()) { + num = rs.getInt(1); + } + + } catch (SQLException e) { + + // e.printStackTrace(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } - } + } - return num; + return num; - } + } } From kawas at pub.open-bio.org Sat Jul 2 14:12:50 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Sat, 2 Jul 2005 10:12:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507021412.j62ECol4022638@pub.open-bio.org> kawas Sat Jul 2 10:12:49 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory pub.open-bio.org:/tmp/cvs-serv22613/org/biomoby/client Modified Files: CentralImpl.java Log Message: Changed the default endpoint to point to the new mobycentral registry. Eddie moby-live/Java/src/main/org/biomoby/client CentralImpl.java,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2005/04/07 16:37:02 1.20 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2005/07/02 14:12:49 1.21 @@ -88,10 +88,10 @@ /** Default location (endpoint) of a Moby registry. */ // public static final String DEFAULT_ENDPOINT = "http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY-Central.pl"; - public static final String DEFAULT_ENDPOINT = "http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY05/mobycentral.pl"; + public static final String DEFAULT_ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; /** Default namespace used by the contacted Moby registry. */ - public static final String DEFAULT_NAMESPACE = "http://mobycentral.cbr.nrc.ca/MOBY/Central"; + public static final String DEFAULT_NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; /************************************************************************* * Default constructor. It connects to a default Moby registry From mwilkinson at pub.open-bio.org Mon Jul 4 17:52:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 4 Jul 2005 13:52:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041752.j64HqIIr006715@pub.open-bio.org> mwilkinson Mon Jul 4 13:52:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv6677/Perl/MOBY Modified Files: Central.pm Log Message: preparing for an interim release while we wait for the lsid resolution code to be fixed by IBM moby-live/Perl/MOBY Central.pm,1.153,1.154 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.153 retrieving revision 1.154 diff -u -r1.153 -r1.154 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/05/31 15:09:25 1.153 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/04 17:52:18 1.154 @@ -1419,7 +1419,8 @@ #service_instance => $service_instance ); # my $RDF_XML = $RDF_MODEL->serialize; my $LSID = $service_instance->LSID; - my $RDF = _getServiceInstanceRDF($LSID); + # my $RDF = _getServiceInstanceRDF($LSID); +my $RDF=""; unless ($RDF){return &_success("Registration successful but LSID resolution error",$SVC->service_instance_id,"" )} unless ($RDF =~ /RDF/){ return &_success("Registration successful but LSID resolution error $RDF",$SVC->service_instance_id,"") @@ -1435,10 +1436,10 @@ my $RDF_XML = ""; my $lsid_error = ""; my $lsid_good = 1; - use LS::ID; - use LS::Authority::WSDL::Constants; - use LS::Client::BasicResolver; - use LS::Locator; + #use LS::ID; + #use LS::Authority::WSDL::Constants; + #use LS::Client::BasicResolver; + #use LS::Locator; my $resolver = LS::Client::BasicResolver->new(); my $authority = $resolver->resolve( lsid => $lsid ); From mwilkinson at pub.open-bio.org Mon Jul 4 17:52:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 4 Jul 2005 13:52:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041752.j64HqIv2006696@pub.open-bio.org> mwilkinson Mon Jul 4 13:52:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl In directory pub.open-bio.org:/tmp/cvs-serv6677/Perl Modified Files: Makefile.PL Log Message: preparing for an interim release while we wait for the lsid resolution code to be fixed by IBM moby-live/Perl Makefile.PL,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/Makefile.PL,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/Makefile.PL 2005/05/31 00:06:48 1.8 +++ /home/repository/moby/moby-live/Perl/Makefile.PL 2005/07/04 17:52:18 1.9 @@ -80,7 +80,7 @@ 'Text::Shellwords' => 1.00, 'SOAP::MIME' => 0.55, 'XML::XPath' => 1.12, - 'LS::ID' => 1.1.1, + # 'LS::ID' => 1.1.1, }, # e.g., Module::Name => 1.1 #'PM_FILTER' => "", ($] >= 5.005 ? ## Add these new keywords supported since 5.005 From mwilkinson at pub.open-bio.org Mon Jul 4 17:52:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 4 Jul 2005 13:52:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041752.j64HqI48006735@pub.open-bio.org> mwilkinson Mon Jul 4 13:52:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv6677/Perl/t Modified Files: Client-Central.t Log Message: preparing for an interim release while we wait for the lsid resolution code to be fixed by IBM moby-live/Perl/t Client-Central.t,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2004/08/18 23:06:03 1.6 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/04 17:52:18 1.7 @@ -13,8 +13,8 @@ # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl', - URI => 'http://mobycentral.cbr.nrc.ca:8080/MOBY/Central'} + mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} } ); From mwilkinson at pub.open-bio.org Mon Jul 4 18:11:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 4 Jul 2005 14:11:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507041811.j64IBb6n006842@pub.open-bio.org> mwilkinson Mon Jul 4 14:11:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv6823/MOBY/Client Modified Files: OntologyServer.pm Log Message: point to new MOBY Central moby-live/Perl/MOBY/Client OntologyServer.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2004/12/14 20:47:04 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2005/07/04 18:11:37 1.11 @@ -84,7 +84,7 @@ my %_attr_data = # DEFAULT ACCESSIBILITY ( host => [ - "http://mobycentral.cbr.nrc.ca/cgi-bin/OntologyServer.cgi", + "http://mobycentral.capture.ubc.ca/cgi-bin/OntologyServer.cgi", 'read/write' ], proxy => [ undef, 'read/write' ], From mwilkinson at pub.open-bio.org Wed Jul 6 15:23:08 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 6 Jul 2005 11:23:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507061523.j66FN8Fv015701@pub.open-bio.org> mwilkinson Wed Jul 6 11:23:08 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv15682/MOBY/Client Modified Files: OntologyServer.pm Log Message: Doh... typo in my new domain name moby-live/Perl/MOBY/Client OntologyServer.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2005/07/04 18:11:37 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/OntologyServer.pm 2005/07/06 15:23:07 1.12 @@ -84,7 +84,7 @@ my %_attr_data = # DEFAULT ACCESSIBILITY ( host => [ - "http://mobycentral.capture.ubc.ca/cgi-bin/OntologyServer.cgi", + "http://mobycentral.icapture.ubc.ca/cgi-bin/OntologyServer.cgi", 'read/write' ], proxy => [ undef, 'read/write' ], From mwilkinson at pub.open-bio.org Wed Jul 6 15:32:53 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 6 Jul 2005 11:32:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507061532.j66FWr7K015751@pub.open-bio.org> mwilkinson Wed Jul 6 11:32:53 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv15732 Modified Files: Central.pm Log Message: documentation for registration of secondary parameters was incorrect. It is an enum of String, Integer, Float, DateTime... not STRING, INT, FLOAT moby-live/Perl/MOBY Central.pm,1.155,1.156 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.155 retrieving revision 1.156 diff -u -r1.155 -r1.156 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/06 14:42:02 1.155 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/06 15:32:52 1.156 @@ -1201,7 +1201,7 @@ - INT|FLOAT|STRING + Integer|Float|String|DateTime ... ... ... From mwilkinson at pub.open-bio.org Wed Jul 6 16:46:41 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 6 Jul 2005 12:46:41 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507061646.j66GkfAQ015996@pub.open-bio.org> mwilkinson Wed Jul 6 12:46:41 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv15977 Modified Files: Config.pm Log Message: adding secondary datatypes to the config module moby-live/Perl/MOBY Config.pm,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Config.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/Config.pm 2004/11/18 17:41:14 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/Config.pm 2005/07/06 16:46:41 1.7 @@ -22,6 +22,8 @@ mobynamespace => [ undef, 'read/write' ], mobyservice => [ undef, 'read/write' ], mobyrelationship => [ undef, 'read/write' ], + valid_secondary_datatypes => [["String", "Integer", "DateTime", "Float"], 'read'], + ); #_____________________________________________________________ From mwilkinson at pub.open-bio.org Fri Jul 8 18:41:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 8 Jul 2005 14:41:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081841.j68IfAcx024586@pub.open-bio.org> mwilkinson Fri Jul 8 14:41:09 EDT 2005 Update of /home/repository/moby/moby-live/Perl/scripts In directory pub.open-bio.org:/tmp/cvs-serv24567/Perl/scripts Modified Files: testMOBYClientCentral_v05.pl Log Message: test script points to new, unfortunately production, registry moby-live/Perl/scripts testMOBYClientCentral_v05.pl,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/scripts/testMOBYClientCentral_v05.pl,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/scripts/testMOBYClientCentral_v05.pl 2004/08/11 16:30:57 1.24 +++ /home/repository/moby/moby-live/Perl/scripts/testMOBYClientCentral_v05.pl 2005/07/08 18:41:09 1.25 @@ -24,8 +24,8 @@ } } -my $URL = $ENV{MOBY_SERVER}?$ENV{MOBY_SERVER}:'http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl'; -my $URI = $ENV{MOBY_URI}?$ENV{MOBY_URI}:'http://mobycentral.cbr.nrc.ca:8080/MOBY/Central'; +my $URL = $ENV{MOBY_SERVER}?$ENV{MOBY_SERVER}:'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl'; +my $URI = $ENV{MOBY_URI}?$ENV{MOBY_URI}:'http://mobycentral.icapture.ubc.ca/MOBY/Central'; my $PROXY = $ENV{MOBY_PROXY}?$ENV{MOBY_PROXY}:'No Proxy Server'; my $C = MOBY::Client::Central->new( From kawas at pub.open-bio.org Fri Jul 8 18:57:00 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Fri, 8 Jul 2005 14:57:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081857.j68Iv0SB024748@pub.open-bio.org> kawas Fri Jul 8 14:57:00 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv24723 Modified Files: Central.pm Log Message: Implemented the check for valid secondary input types. moby-live/Perl/MOBY Central.pm,1.156,1.157 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.156 retrieving revision 1.157 diff -u -r1.156 -r1.157 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/06 15:32:52 1.156 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/08 18:57:00 1.157 @@ -185,6 +185,7 @@ + =head1 METHODS @@ -1409,33 +1410,40 @@ ); } - use MOBY::Client::Central; - my $services = MOBY::Client::Central::_parseServices( '', '', $si ); - my $service_instance = shift @{$services}; - # my $storage = new RDF::Core::Storage::Memory; - # my $model = new RDF::Core::Model( Storage => $storage ); - # my $RDF_MODEL = MOBY::RDF::ServiceInstanceRDF->new( - #model => $model, - #service_instance => $service_instance ); - # my $RDF_XML = $RDF_MODEL->serialize; - my $LSID = $service_instance->LSID; + use MOBY::Client::Central; + my $services = MOBY::Client::Central::_parseServices( '', '', $si ); + my $service_instance = shift @{$services}; + + # my $storage = new RDF::Core::Storage::Memory; + # my $model = new RDF::Core::Model( Storage => $storage ); + # my $RDF_MODEL = MOBY::RDF::ServiceInstanceRDF->new( + #model => $model, + #service_instance => $service_instance ); + # my $RDF_XML = $RDF_MODEL->serialize; + my $LSID = $service_instance->LSID; + # my $RDF = _getServiceInstanceRDF($LSID); -my $RDF=""; - unless ($RDF){return &_success("Registration successful but LSID resolution error",$SVC->service_instance_id,"" )} - unless ($RDF =~ /RDF/){ - return &_success("Registration successful but LSID resolution error $RDF",$SVC->service_instance_id,"") + my $RDF = ""; + unless ($RDF) { + return &_success( "Registration successful but LSID resolution error", + $SVC->service_instance_id, "" ); + } + unless ( $RDF =~ /RDF/ ) { + return &_success( + "Registration successful but LSID resolution error $RDF", + $SVC->service_instance_id, "" ); } - return &_success( "Registration successful", - $SVC->service_instance_id, $RDF ); + return &_success( "Registration successful", $SVC->service_instance_id, + $RDF ); } - sub _getServiceInstanceRDF { - my ($self, $LSID) = @_; + my ( $self, $LSID ) = @_; my $lsid = LS::ID->new($LSID); my $RDF_XML = ""; my $lsid_error = ""; - my $lsid_good = 1; + my $lsid_good = 1; + #use LS::ID; #use LS::Authority::WSDL::Constants; #use LS::Client::BasicResolver; @@ -1451,13 +1459,14 @@ $authority->clean_cache(); my $resource = $authority->getResource($lsid); - unless ($resource) { - $lsid_error .= $authority->error_string. " " ; - return $lsid_error + unless ($resource) { + $lsid_error .= $authority->error_string . " "; + return $lsid_error; } - + my $response = $resource->get_metadata; unless ( ref($response) =~ /LS::Service::Response/ ) { + #TODO raise an error $lsid_error .= "Metadata response didn't come back"; return $lsid_error; @@ -1471,7 +1480,7 @@ } while (<$rsp>) { $RDF_XML .= $_; - } + } return $RDF_XML } @@ -1614,6 +1623,19 @@ ( $_->nodeType == TEXT_NODE ) && ( $datatype .= $_->nodeValue ); } } + + #ensure that thet type is correct (Integer | String | Float | DateTime) + $datatype =~ s/\s//g; + my $secondaries = $CONFIG->{valid_secondary_datatypes}; + my $valid; + map { $valid = 1 if $datatype eq $_ } @{$secondaries}; + unless ($valid) { + $SVC->DELETE_THYSELF; + return ( -1, +"Registration failed. $datatype must be one of type Integer, String, DateTime, or Float." + ); + } + my $defs = $parameter->getElementsByTagName('default'); if ( $defs->get_node(1) ) { foreach ( $defs->get_node(1)->childNodes ) @@ -2998,20 +3020,26 @@ =cut sub DUMP_MySQL { - my ( $pkg ) = @_; - my $config = MOBY::Config->new(); - my @dbsections = ('mobycentral', 'mobyobject', 'mobyservice', 'mobynamespace', 'mobyrelationship'); + my ($pkg) = @_; + my $config = MOBY::Config->new(); + my @dbsections = ( + 'mobycentral', 'mobyobject', + 'mobyservice', 'mobynamespace', + 'mobyrelationship' + ); my @response; - foreach my $dbsection (@dbsections) { - my $dbname = ${${$config}{$dbsection}}{'dbname'}; - my $username = ${${$config}{$dbsection}}{'username'}; - my $password = ${${$config}{$dbsection}}{'password'}; - my $host = ${${$config}{$dbsection}}{'url'}; - my $port = ${${$config}{$dbsection}}{'port'}; - open( IN, "mysqldump -h $host -P $port -u $username --password=$password $dbname|" ) - || die "can't open $dbname for dumping"; + foreach my $dbsection (@dbsections) { + my $dbname = ${ ${$config}{$dbsection} }{'dbname'}; + my $username = ${ ${$config}{$dbsection} }{'username'}; + my $password = ${ ${$config}{$dbsection} }{'password'}; + my $host = ${ ${$config}{$dbsection} }{'url'}; + my $port = ${ ${$config}{$dbsection} }{'port'}; + open( IN, +"mysqldump -h $host -P $port -u $username --password=$password $dbname|" + ) + || die "can't open $dbname for dumping"; my @dbdump; - while ( ) { + while () { push @dbdump, $_; } my $dbdump = ( join "", @dbdump ); @@ -3067,6 +3095,7 @@ + =head1 Internal Object Methods From mwilkinson at pub.open-bio.org Fri Jul 8 19:03:17 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 8 Jul 2005 15:03:17 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081903.j68J3Hs2024881@pub.open-bio.org> mwilkinson Fri Jul 8 15:03:17 EDT 2005 Update of /home/repository/moby/moby-live/Database In directory pub.open-bio.org:/tmp/cvs-serv24842 Modified Files: mobycentral.mysql mobynamespace.mysql mobyobject.mysql mobyrelationship.mysql mobyservice.mysql reset Added Files: README mobyobject.data mobyservice.data Log Message: all files needed to create a new bootstrapped MOBY Central database moby-live/Database README,NONE,1.1 mobyobject.data,NONE,1.1 mobyservice.data,NONE,1.1 mobycentral.mysql,1.4,1.5 mobynamespace.mysql,1.5,1.6 mobyobject.mysql,1.8,1.9 mobyrelationship.mysql,1.4,1.5 mobyservice.mysql,1.6,1.7 reset,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobycentral.mysql,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Database/mobycentral.mysql 2004/09/14 21:32:35 1.4 +++ /home/repository/moby/moby-live/Database/mobycentral.mysql 2005/07/08 19:03:17 1.5 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobycentral --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'authority' +-- Table structure for table `authority` -- CREATE TABLE authority ( @@ -14,16 +14,10 @@ contact_email varchar(255) NOT NULL default '', authority_id int(10) unsigned NOT NULL auto_increment, PRIMARY KEY (authority_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'authority' --- - - - --- --- Table structure for table 'collection_input' +-- Table structure for table `collection_input` -- CREATE TABLE collection_input ( @@ -31,16 +25,10 @@ article_name varchar(255) default NULL, service_instance_id int(10) unsigned NOT NULL default '0', PRIMARY KEY (collection_input_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'collection_input' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Table structure for table 'collection_output' +-- Table structure for table `collection_output` -- CREATE TABLE collection_output ( @@ -48,42 +36,30 @@ article_name varchar(255) default NULL, service_instance_id int(10) unsigned NOT NULL default '0', PRIMARY KEY (collection_output_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'collection_output' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Table structure for table 'secondary_input' +-- Table structure for table `secondary_input` -- CREATE TABLE secondary_input ( secondary_input_id int(10) unsigned NOT NULL auto_increment, default_value text, - maximum_value decimal(10,0) default NULL, - minimum_value decimal(10,0) default NULL, + maximum_value float default NULL, + minimum_value float default NULL, enum_value text, - datatype enum('INT','FLOAT','STRING') NOT NULL default 'INT', + datatype enum('String','Integer','DateTime','Float') default NULL, article_name varchar(255) default NULL, service_instance_id int(10) unsigned NOT NULL default '0', PRIMARY KEY (secondary_input_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'secondary_input' --- - - - --- --- Table structure for table 'service_instance' +-- Table structure for table `service_instance` -- CREATE TABLE service_instance ( - category enum('moby','cgi','soap') NOT NULL default 'moby', + category enum('moby','soap','wsdl','cgi') default NULL, servicename varchar(255) NOT NULL default '', service_type_uri varchar(255) NOT NULL default '', authority_id int(10) unsigned NOT NULL default '0', @@ -92,19 +68,25 @@ authoritative enum('1','0') NOT NULL default '0', description text NOT NULL, service_instance_id int(10) unsigned NOT NULL auto_increment, - signatureURL varchar(255), + signatureURL varchar(255) default NULL, + lsid varchar(255) NOT NULL default '', PRIMARY KEY (service_instance_id), UNIQUE KEY servicename (servicename,authority_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'service_instance' +-- Table structure for table `service_validation` -- - +CREATE TABLE service_validation ( + signatureURL varchar(255) NOT NULL default '', + error_code int(4) NOT NULL default '0', + counter int(1) NOT NULL default '0', + PRIMARY KEY (signatureURL) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Table structure for table 'simple_input' +-- Table structure for table `simple_input` -- CREATE TABLE simple_input ( @@ -115,16 +97,10 @@ service_instance_id int(10) unsigned default NULL, collection_input_id int(10) unsigned default NULL, PRIMARY KEY (simple_input_id) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'simple_input' --- - - - --- --- Table structure for table 'simple_output' +-- Table structure for table `simple_output` -- CREATE TABLE simple_output ( @@ -135,11 +111,5 @@ service_instance_id int(10) unsigned default NULL, collection_output_id int(10) unsigned default NULL, PRIMARY KEY (simple_output_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'simple_output' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobynamespace.mysql,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Database/mobynamespace.mysql 2003/05/24 20:22:15 1.5 +++ /home/repository/moby/moby-live/Database/mobynamespace.mysql 2005/07/08 19:03:17 1.6 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobynamespace --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'namespace' +-- Table structure for table `namespace` -- CREATE TABLE namespace ( @@ -15,18 +15,20 @@ description text NOT NULL, authority varchar(255) NOT NULL default '', contact_email varchar(255) NOT NULL default '', + object text, + generic_url tinytext, + synonym text, + url_syntax text, + url_example text, + shorthand_name varchar(255) default NULL, + example_id varchar(255) default NULL, + note mediumtext, PRIMARY KEY (namespace_id), UNIQUE KEY namespace_type (namespace_type) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'namespace' --- - - - --- --- Table structure for table 'namespace_term2term' +-- Table structure for table `namespace_term2term` -- CREATE TABLE namespace_term2term ( @@ -35,11 +37,5 @@ namespace1_id int(11) NOT NULL default '0', namespace2_id int(11) NOT NULL default '0', PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'namespace_term2term' --- - - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobyobject.mysql,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Database/mobyobject.mysql 2003/06/10 23:01:26 1.8 +++ /home/repository/moby/moby-live/Database/mobyobject.mysql 2005/07/08 19:03:17 1.9 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobyobject --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'object' +-- Table structure for table `object` -- CREATE TABLE object ( @@ -17,21 +17,10 @@ contact_email varchar(255) NOT NULL default '', PRIMARY KEY (object_id), UNIQUE KEY object_type (object_type) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'object' --- - - -INSERT INTO object VALUES (1,'urn:lsid:biomoby.org:objectclass:object','Object','an object','openinformatics.com','jason at openinformatics.com'); -INSERT INTO object VALUES (2,'urn:lsid:biomoby.org:objectclass:integer','Integer','an int','openinformatics.com','jason at openinformatics.com'); -INSERT INTO object VALUES (3,'urn:lsid:biomoby.org:objectclass:string','String','a string','openinformatics.com','jason at openinformatics.com'); -INSERT INTO object VALUES (4,'urn:lsid:biomoby.org:objectclass:float','Float','a floating point number','openinformatics.com','jason at openinformatics.com'); -INSERT INTO object VALUES (5,'urn:lsid:biomoby.org:objectclass:datetime','DateTime','a date or time in ISO-8601 format','openinformatics.com','jason at openinformatics.com'); - --- --- Table structure for table 'object_term2term' +-- Table structure for table `object_term2term` -- CREATE TABLE object_term2term ( @@ -41,14 +30,5 @@ object2_id int(11) NOT NULL default '0', object2_articlename varchar(255) default NULL, PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'object_term2term' --- - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -INSERT INTO object_term2term VALUES (1,'urn:lsid:biomoby.org:objectrelation:isa',2,1,NULL); -INSERT INTO object_term2term VALUES (2,'urn:lsid:biomoby.org:objectrelation:isa',3,1,NULL); -INSERT INTO object_term2term VALUES (3,'urn:lsid:biomoby.org:objectrelation:isa',4,1,NULL); -INSERT INTO object_term2term VALUES (4,'urn:lsid:biomoby.org:objectrelation:isa',5,3,NULL); =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobyrelationship.mysql,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Database/mobyrelationship.mysql 2003/05/24 20:26:07 1.4 +++ /home/repository/moby/moby-live/Database/mobyrelationship.mysql 2005/07/08 19:03:17 1.5 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobyrelationship --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'relationship' +-- Table structure for table `relationship` -- CREATE TABLE relationship ( @@ -19,20 +19,10 @@ ontology varchar(200) NOT NULL default '', PRIMARY KEY (relationship_id), UNIQUE KEY LSID (relationship_lsid) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'relationship' --- - - -INSERT INTO relationship VALUES (1,'urn:lsid:biomoby.org:objectrelation:hasa','hasa','1','Describes a container relationship where the predicate object is contained within the subject object in one copy only','www.biomoby.org','markw at illuminae.com','object'); -INSERT INTO relationship VALUES (2,'urn:lsid:biomoby.org:objectrelation:has','has','1','Describes a container relationship where the predicate object is contained within the subject object in one or more copies','www.biomoby.org','markw at illuminae.com','object'); -INSERT INTO relationship VALUES (3,'urn:lsid:biomoby.org:objectrelation:isa','isa','0','Describes an inheritence relationship where all attributes of the parent must be in the child','www.biomoby.org','markw at illuminae.com','object'); -INSERT INTO relationship VALUES (4,'urn:lsid:biomoby.org:servicerelation:isa','isa','0','Describes an inheritence relationship where the predicate service performs a more specific operation compared to the subject service','www.biomoby.org','markw at illuminae.com','service'); - --- --- Table structure for table 'relationship_term2term' +-- Table structure for table `relationship_term2term` -- CREATE TABLE relationship_term2term ( @@ -42,9 +32,5 @@ relationship2_id int(10) unsigned NOT NULL default '0', object2_articlename varchar(255) default NULL, PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'relationship_term2term' --- +) ENGINE=MyISAM DEFAULT CHARSET=latin1; =================================================================== RCS file: /home/repository/moby/moby-live/Database/mobyservice.mysql,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Database/mobyservice.mysql 2003/06/10 23:01:26 1.6 +++ /home/repository/moby/moby-live/Database/mobyservice.mysql 2005/07/08 19:03:17 1.7 @@ -1,11 +1,11 @@ --- MySQL dump 8.22 +-- MySQL dump 8.23 -- -- Host: localhost Database: mobyservice --------------------------------------------------------- --- Server version 3.23.52 +-- Server version 4.1.12-standard -- --- Table structure for table 'service' +-- Table structure for table `service` -- CREATE TABLE service ( @@ -17,22 +17,10 @@ contact_email varchar(255) NOT NULL default '', PRIMARY KEY (service_id), UNIQUE KEY service_type (service_type) -) TYPE=MyISAM; +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- --- Dumping data for table 'service' --- - - -INSERT INTO service VALUES (1,'urn:lsid:biomoby.org:servicetype:service','Service','The base type','openinformatics.com','email'); -INSERT INTO service VALUES (2,'urn:lsid:biomoby.org:servicetype:retrieval','Retrieval','The base retrieval type','openinformatics.com','email'); -INSERT INTO service VALUES (3,'urn:lsid:biomoby.org:servicetype:resolution','Resolution','resolve data','openinformatics.com','email'); -INSERT INTO service VALUES (4,'urn:lsid:biomoby.org:servicetype:parsing','Parsing','parse data','openinformatics.com','email'); -INSERT INTO service VALUES (5,'urn:lsid:biomoby.org:servicetype:registration','Registration','register data','openinformatics.com','email'); -INSERT INTO service VALUES (6,'urn:lsid:biomoby.org:servicetype:analysis','Analysis','analyze data','openinformatics.com','email'); - --- --- Table structure for table 'service_term2term' +-- Table structure for table `service_term2term` -- CREATE TABLE service_term2term ( @@ -41,15 +29,5 @@ service1_id int(11) NOT NULL default '0', service2_id int(11) NOT NULL default '0', PRIMARY KEY (assertion_id) -) TYPE=MyISAM; - --- --- Dumping data for table 'service_term2term' --- - +) ENGINE=MyISAM DEFAULT CHARSET=latin1; -INSERT INTO service_term2term VALUES (8,'urn:lsid:biomoby.org:servicerelation:isa',2,1); -INSERT INTO service_term2term VALUES (4,'urn:lsid:biomoby.org:servicerelation:isa',3,1); -INSERT INTO service_term2term VALUES (5,'urn:lsid:biomoby.org:servicerelation:isa',4,1); -INSERT INTO service_term2term VALUES (6,'urn:lsid:biomoby.org:servicerelation:isa',5,1); -INSERT INTO service_term2term VALUES (7,'urn:lsid:biomoby.org:servicerelation:isa',6,1); =================================================================== RCS file: /home/repository/moby/moby-live/Database/reset,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Database/reset 2003/05/24 20:41:44 1.1 +++ /home/repository/moby/moby-live/Database/reset 2005/07/08 19:03:17 1.2 @@ -1,6 +1,7 @@ +#!/bin/bash mysql -u root -p < reset2 mysql -u root -p mobycentral < mobycentral.mysql -mysql -u root -p mobyobject < mobyobject.mysql -mysql -u root -p mobyservice < mobyservice.mysql +mysql -u root -p mobyobject < mobyobject.data +mysql -u root -p mobyservice < mobyservice.data mysql -u root -p mobynamespace < mobynamespace.mysql mysql -u root -p mobyrelationship < mobyrelationship.mysql From mwilkinson at pub.open-bio.org Fri Jul 8 19:22:21 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 8 Jul 2005 15:22:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507081922.j68JMLnS025097@pub.open-bio.org> mwilkinson Fri Jul 8 15:22:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv25078/t Modified Files: Client-Central.t Log Message: added a test for Eddie's changes to the test harness moby-live/Perl/t Client-Central.t,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/04 17:52:18 1.7 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/08 19:22:21 1.8 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; -use Test::More tests => 13; # perldoc Test::More for details +use Test::More tests => 14; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; @@ -96,7 +96,33 @@ ( ok($r->success,"Service Type registration successful") ) or diag("Service Type registration failure: ".$r->message) ; -# Test 8 +# Test 8 # should fail +$r = $C->registerService( + serviceName => "myfirstservice", + serviceType => "Retrieval", + authURI => "test.suite.com", + contactEmail => 'your at mail.address', + description => "this is my first service", + category => "moby", + URL => "http://illuminae/cgi-bin/service.pl", + input =>[ + ['articleName1', [Object => ['UglyNamespace']]], # Simple + ], + output =>[ + ['articleName2', [String => ['UglyNamespace']]], # Simple + ], + secondary => { + parametername1 => { + datatype => 'INTEGER', + default => 0, + max => 10, + min => -10, + enum => [-10, 10, 0]}}); + +( ok(!$r->success,"Service registration correctly failed") +) or diag("Service registration failure: ".$r->message) ; + +# Test 9 $r = $C->registerService( serviceName => "myfirstservice", serviceType => "Retrieval", @@ -123,7 +149,7 @@ ) or diag("Service registration failure: ".$r->message) ; -# Test 9 +# Test 10 $r = $C->deregisterService( serviceName => "myfirstservice", @@ -133,17 +159,17 @@ ) or diag("Service deregistration failure: ".$r->message) ; -# Test 10 +# Test 11 $r = $C->deregisterObjectClass(objectType => "TotalCrap"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; -# Test 11 +# Test 12 $r = $C->deregisterServiceType(serviceType => "CrappyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; -# Test 12 +# Test 13 $r = $C->deregisterNamespace(namespaceType =>'UglyNamespace'); ( ok($r->success,"namespace deregistration successful") ) or diag("namespace deregistration failure: ".$r->message) ; @@ -152,7 +178,7 @@ # #my @service ; # -## Tests 7,8: locateServiceByOutput with output 'Object' and full_objects + full_services +## Tests 14,15: locateServiceByOutput with output 'Object' and full_objects + full_services #@service = $C->locateServiceByOutput( # objectType => "Object", # fullObjects => 1, @@ -166,7 +192,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 9,10: Testing locateServiceByOutput with output "Object" and full_services only +## Tests 16,17: Testing locateServiceByOutput with output "Object" and full_services only #@service = $C->locateServiceByOutput( # objectType => "Object", # fullObjects => 0, @@ -179,7 +205,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 11,12: Testing locateServiceByInput with input +## Tests 18,19: Testing locateServiceByInput with input ## 'Object' => Genbank/GI and full_objects + full_services #@service = $C->locateServiceByInput( # input => {"Sequence" => ["Genbank/GI"]}, @@ -194,7 +220,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 13,14: Testing locateServiceByInput with input +## Tests 20,21: Testing locateServiceByInput with input ## 'Object' => Genbank/GI and full_services only #@service = $C->locateServiceByInput( # input => {"Object" => ["Genbank/GI"]}, @@ -209,7 +235,7 @@ # is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; #} ; # -## Tests 15,16: Testing locateServiceByType with type 'Retrieve' + full_services +## Tests 22,23: Testing locateServiceByType with type 'Retrieve' + full_services #@service = $C->locateServiceByType( # serviceType => "Retrieve", # fullServices => 1, From dwang at pub.open-bio.org Wed Jul 13 18:18:39 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 14:18:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507131818.j6DIIdA6020839@pub.open-bio.org> dwang Wed Jul 13 14:18:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20813/Perl/MOBY Modified Files: Central.pm Log Message: 1st commit by Dennis moby-live/Perl/MOBY Central.pm,1.157,1.158 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.157 retrieving revision 1.158 diff -u -r1.157 -r1.158 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/08 18:57:00 1.157 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 18:18:39 1.158 @@ -470,6 +470,9 @@ =cut sub deregisterObjectClass { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'object' ); return &_error( "Message Format Incorrect", "" ) unless ($payload); @@ -482,42 +485,14 @@ return &_error( "Object class $class does not exist", "" ) unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return &_error( - "Object class $class is used by a service and may not be deregistered", - "" - ) - if ($id); - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); - return &_error( - "Object class $class is used by a service and may not be deregistered", - "" - ) - if ($id); - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return &_error( - "Object class $class is used by a service and may not be deregistered", - "" - ) - if ($id); - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); + + my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); return &_error( "Object class $class is used by a service and may not be deregistered", "" ) - if ($id); + if ($errormsg); + my ( $success2, $message2, $URI ) = $OntologyServer->deleteObject( term => $class ); $success2 == 0 && return &_error( $message2, $URI ); @@ -767,6 +742,9 @@ =cut sub deregisterServiceType { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'service' ); return &_error( "Message Format Incorrect", "" ) unless ($payload); @@ -781,10 +759,10 @@ return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance where service_type_uri = ?}, - undef, $existingURI - ); + + my $result = $adaptor->query_service_instance({service_type_uri => $existingURI}); + my $id = @$result[0]->{service_instance_id}; + return &_error( "A registered service depends on this service type", "" ) if ($id); my ( $success2, $message2, $deleteURI ) = @@ -924,6 +902,9 @@ =cut sub deregisterNamespace { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'namespace' ); return &_error( "Message Format Incorrect", "" ) unless ($payload); @@ -936,71 +917,10 @@ return &_error( "Namespace Type $term does not exist", "" ) unless ($existingURI); my $dbh = MOBY::central_db_connection->new->dbh; - my $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - return &_error( -"Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered", - "" - ) - if ( $_ eq $existingURI ); - } - } + my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term}); + return &_error( $errstr, "") + if ($err); + my ( $success2, $message2, $URI ) = $OntologyServer->deleteNamespace( term => $term ); $success2 == 0 && return &_error( $message2, $URI ); @@ -1936,6 +1856,9 @@ =cut sub findService { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $pkg, $payload ) = @_; $debug && &_LOG("\nLOOKING FOR SERVICES\n"); my %findme = &_findServicePayload($payload); @@ -1965,18 +1888,16 @@ $debug && _LOG( "authoritative added; criterion count is now $criterion_count\n"); - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where authoritative=?}, - undef, $findme{authoritative} - ); + my $ids = $adaptor->query_service_instance({authoritative => $findme{authoritative}}); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instnace_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2002,10 +1923,8 @@ $children_string .= ( join ',', map { "\'$_\'" } @children ); } $children_string =~ s/\,$//; - my $ids = - $dbh->selectall_arrayref( -"select service_instance_id from service_instance where service_type_uri in ($children_string)" - ); + my $ids = $adaptor->match_service_type_uri({service_type_uri => $children_string}); + $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { @@ -2018,26 +1937,24 @@ ++$criterion_count; $debug && _LOG("authURI added; criterion count is now $criterion_count\n"); - my ($id) = $dbh->selectrow_array( -q{select authority_id from authority where authority_uri = ? or authority_common_name = ?}, - undef, - ( $findme{authURI}, $findme{authURI} ) - ); + + my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}}); + my $id = @$result[0]->{authority_id}; + unless ($id) { return &_serviceListResponse( $dbh, undef ); } - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where authority_id=?}, - undef, $id - ); + + my $ids = $adaptor->query_service_instance({authority_id => $id}); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2046,18 +1963,17 @@ $debug && _LOG( "servicename added; criterion count is now $criterion_count\n"); - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where servicename=?}, - undef, $findme{servicename} - ); + + my $ids = $adaptor->query_service_instance({servicename => $findme{servicename}}); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2066,19 +1982,17 @@ ++$criterion_count; $debug && _LOG("category added; criterion count is now $criterion_count\n"); - my $ids = $dbh->selectall_arrayref( -q{select service_instance_id from service_instance where category=?}, - undef, - lc( $findme{category} ) - ); + + my $ids = $adaptor->query_service_instance({category => lc( $findme{category}) }); + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2086,19 +2000,9 @@ ++$criterion_count; $debug && _LOG("Keywords added; criterion count is now $criterion_count\n"); - my $searchstring; - foreach my $kw ( @{ $findme{keywords} } ) { - $debug && &_LOG("KEYWORD $kw\n"); - $kw =~ s/\*//g; - $kw = $dbh->quote("%$kw%"); - $searchstring .= " OR description like $kw "; - } - $searchstring =~ s/OR//; # just the first one - $debug && &_LOG("search $searchstring\n"); - my $ids = - $dbh->selectall_arrayref( -"select service_instance_id from service_instance where $searchstring" - ); + + my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + unless ( scalar @{$ids} ) { $debug && &_LOG( @@ -2264,6 +2168,8 @@ } sub _searchForSimple { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); # returns list of service_instance ID's # that match this simple @@ -2282,24 +2188,17 @@ $ancestor_string .= ( join ',', map { "\'$_\'" } @ancestors ); } $ancestor_string =~ s/\,$//; - my $query = -"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " - ; # if service_instance_id is null then it must be a collection input. - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/OR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; - } + + my ($query, $result) = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); + $debug && _LOG("\nQUERY $query\n"); my @valid_services; - my $sth = $dbh->prepare($query); - $sth->execute; - while ( my ( $id, $nss ) = $sth->fetchrow_array ) - { # get the service instance ID and the namespaces that matched + + foreach my $row (@$result) + { + # get the service instance ID and the namespaces that matched + my $id = $row->{service_instance_id}; + my $nss = $row->{namespace_type_uris}; if ( $nss && scalar @{$namespaceURIs} ) { # if this service cares about namespaces at all, # and if namespaces were specified in the query, @@ -2327,9 +2226,11 @@ #Eddie - converted sub _searchForCollection { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, $node, $expand, $inout ) = @_; # $node in this case is a Collection object - my $query; # luckily, we can return a redundant list of service id's and # this will be cleaned up in the caller @@ -2339,30 +2240,15 @@ next unless ( $simple->nodeName =~ /simple/i ); my ( $objectURI, $namespaceURIs ) = &_extractObjectTypesAndNamespaces($simple); - $query = "select - c.service_instance_id, - s.namespace_type_uris - from - simple_$inout as s, - collection_$inout as c - where - s.collection_${inout}_id IS NOT NULL - AND s.collection_${inout}_id = c.collection_${inout}_id - AND object_type_uri = '$objectURI' "; - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/^\sOR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; # add the AND clause - } + + my ($query, $result) = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); + $debug && &_LOG("QUERY: $query"); - my $sth = $dbh->prepare($query); - $sth->execute; - while ( my ( $id, $nss ) = $sth->fetchrow_array ) + + foreach my $row (@$result ) { # get the service instance ID and the namespaces that matched + my $id = $row->{service_instance_id}; + my $nss = $row->{namespace_type_uris}; if ( $nss && scalar @{$namespaceURIs} ) { # if this service cares about namespaces at all, # and if namespaces were specified in the query, @@ -2582,13 +2468,17 @@ =cut sub retrieveServiceProviders { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ($pkg) = @_; my $dbh = MOBY::central_db_connection->new()->dbh; - my $sth = $dbh->prepare("select distinct authority_uri from authority"); - $sth->execute; + + my $result = $adaptor->getUniqueAuthorityURI(); + my $providers = "\n"; - while ( my ($prov) = $sth->fetchrow_array ) { - $providers .= "\n"; + foreach my $prov (@$result) { + $providers .= "\n"; } $providers .= "\n"; return $providers; @@ -2612,16 +2502,15 @@ =cut sub retrieveServiceNames { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ($pkg) = shift; my $dbh = MOBY::central_db_connection->new()->dbh; - my $sth = - $dbh->prepare( -"select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id" - ); - $sth->execute; + my $result = $adaptor->getServiceNames(); my $names = "\n"; - while ( my ( $auth, $name ) = $sth->fetchrow_array ) { - $names .= "\n"; + foreach my $row (@$result) { + $names .= "\n"; } $names .= "\n"; return $names; @@ -3051,25 +2940,17 @@ *DUMP = \&DUMP_MySQL; # alias it for backward compatibility sub _flatten { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); # from a given term, traverse the ontology # and flatten it into a list of parent terms my ( $dbh, $type, $term, $seen ) = @_; - my $sth = $dbh->prepare( " - select - OE1.term - from - OntologyEntry as OE1, - OntologyEntry as OE2, - Term2Term as TT - where - ontologyentry2_id = OE2.id - and ontologyentry1_id = OE1.id - and relationship_type_id = $type - and OE2.term = ?" - ); - $sth->execute($term); - while ( my ($term) = $sth->fetchrow_array ) { + + my $result = $adaptor->getParentTerms({relationship_type_id => $type}, {term => $term}); + + foreach my $row (@$result) { + my $term = $row->{term}; next if ${$seen}{$term}; &_flatten( $dbh, $type, $term, $seen ); ${$seen}{$term} = 1; @@ -3232,12 +3113,17 @@ =cut sub _traverseServiceDAG { + + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, $serviceType, $sth_hash ) = @_; my %sth = %{$sth_hash}; my %ServiceIDs; - my $sth = $dbh->prepare( $sth{get_service_type_id} ); - $sth->execute($serviceType); - my ($root_id) = $sth->fetchrow_array; + + my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); + my $row = shift(@$result); + my ($root_id) = @$row; return undef unless $root_id; # we have to do a traversal of the DAG here to get all child nodes... @@ -3250,11 +3136,13 @@ next if ( $ServiceIDs{$service} eq "tested" ) ; # if it has been tested already then move on - my $sth = $dbh->prepare( $sth{get_service_hierarchy_list} ); - $sth->execute($service); # execute the query for child nodes + + my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); + # execute the query for child nodes $ServiceIDs{$service} = "tested"; # mark it as tested - while ( my $new = $sth->fetchrow_array ) + foreach my $row (@$result) { # now get each of the child nodes + my $new = @$row; next if ( defined $ServiceIDs{$new} ) ; # if we have already heard about it then move on @@ -3278,22 +3166,19 @@ =cut sub _traverseObjectDAG { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, $objectType, $sth_hash, $dir ) = @_; my %sth = %{$sth_hash}; my %ObjectIDs; - my $sth = $dbh->prepare( $sth{get_object_type_id} ); - $sth->execute($objectType); - my ($root_id) = $sth->fetchrow_array; - return undef unless $root_id; - if ( $dir eq "p" ) { - $debug && &_LOG("getting parents"); - $sth = $dbh->prepare( $sth{get_object_parent_list} ); - } - else { - $debug && &_LOG("getting children"); - $sth = $dbh->prepare( $sth{get_object_child_list} ); - } + my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); + + my $row = shift (@$result); + my ($root_id) = @$row; + return undef unless $root_id; + # we have to do a traversal of the DAG here to get all child nodes... # this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested @@ -3304,10 +3189,22 @@ next if ( $ObjectIDs{$object} eq "tested" ) ; # if it has been tested already then move on - $sth->execute($object); # execute the query for child nodes + + my $result; + if ( $dir eq "p" ) { + $debug && &_LOG("getting parents"); + $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); + } + else { + $debug && &_LOG("getting children"); + $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); + } + # execute the query for child nodes + $ObjectIDs{$object} = "tested"; # mark it as tested - while ( my $new = $sth->fetchrow_array ) + foreach my $row (@$result) { # now get each of the child nodes + my $new = @$row; next if ( defined $ObjectIDs{$new} ) ; # if we have already heard about it then move on @@ -3461,56 +3358,28 @@ } sub _serviceListResponse { + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my ( $dbh, @ids ) = @_; my $output = ""; - my $sth = $dbh->prepare( - q{ - select - category, url, servicename, service_type_uri, authority_id, description, authoritative, contact_email, signatureURL, lsid - from service_instance where - service_instance_id = ?} - ); - my $sth_simple_in = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_input where service_instance_id=? and collection_input_id IS NULL" - ); - my $sth_simple_out = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_output where service_instance_id=? and collection_output_id IS NULL" - ); - my $sth_collection_ins = - $dbh->prepare( -"select collection_input_id, article_name from collection_input where service_instance_id=?" - ); - my $sth_collection_outs = - $dbh->prepare( -"select collection_output_id, article_name from collection_output where service_instance_id=?" - ); - my $sth_collection_in = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_input where service_instance_id IS NULL and collection_input_id =?" - ); - my $sth_collection_out = - $dbh->prepare( -"select object_type_uri, namespace_type_uris, article_name from simple_output where service_instance_id IS NULL and collection_output_id =?" - ); - my $sth_secondary_in = - $dbh->prepare( -"select default_value, maximum_value, minimum_value, enum_value, datatype, article_name from secondary_input where service_instance_id=?" - ); my $OSobj = MOBY::OntologyServer->new( ontology => 'object' ); my $OSns = MOBY::OntologyServer->new( ontology => 'namespace' ); my $OSserv = MOBY::OntologyServer->new( ontology => 'service' ); foreach (@ids) { - $sth->execute($_); - my ( - $category, $url, $servicename, - $service_type_uri, $authority_id, $desc, - $authoritative, $email, $signatureURL, - $lsid - ) - = $sth->fetchrow_array; + my $result = $adaptor->query_service_instance({service_instance_id => $_}); + my $category = @$result[0]->{category}; + my $url = @$result[0]->{url}; + my $servicename = @$result[0]->{servicename}; + my $service_type_uri = @$result[0]->{service_type_uri}; + my $authority_id = @$result[0]->{authority_id}; + my $desc = @$result[0]->{description}; + my $authoritative = @$result[0]->{authoritative}; + my $email = @$result[0]->{contact_email}; + my $signatureURL = @$result[0]->{signatureURL}; + my $lsid = @$result[0]->{lsid}; + if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } @@ -3519,10 +3388,9 @@ $signatureURL ||= ""; next unless ( $servicename && $authority_id ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); - my ($authURI) = - $dbh->selectrow_array( - q{select authority_uri from authority where authority_id=?}, - undef, $authority_id ); + + $result = $adaptor->query_authority({authority_id => $authority_id}); + my $authURI = @$result[0]->{authority_uri}; $output .= "\t\n"; $output .= "\t$service_type\n"; @@ -3533,11 +3401,15 @@ $output .= "\t$signatureURL\n"; $output .= "\t$url\n"; $output .= "\t\n"; - $sth_simple_in->execute($_); - - while ( my ( $objURI, $nsURI, $article ) = - $sth_simple_in->fetchrow_array() ) + + $result = $adaptor->query_simple_input({service_instance_id => $_}, 'and', {collection_input_id => undef}); + + foreach my $row (@$result) { + my $objURI = $row->{object_type_uri}; + my $nsURI = $row->{namespace_type_uris}; + my $article = $row->{article_name}; + my $objName = $OSobj->getObjectCommonName($objURI); $nsURI ||= ""; my @nsURIs = split ",", $nsURI; @@ -3550,15 +3422,23 @@ } $output .= "\t\t\n"; } + $result = $adaptor->query_collection_input({service_instance => $_}); $sth_collection_ins->execute($_); - while ( my ( $collid, $articlename ) = - $sth_collection_ins->fetchrow_array ) + + foreach my $row (@$result) { - $output .= "\t\t\n"; - $sth_collection_in->execute($collid); - while ( my ( $objURI, $nsURI, $article ) = - $sth_collection_in->fetchrow_array() ) + my $collid = $row->{collection_input_id}; + my $articlename = $row->{article_name}; + + $output .= "\t\t\n"; + + my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, 'and', {collection_input_id => $collid}); + foreach my $row2 (@$result2) { + my $objURI = $row2->{object_type_uri}; + my $nsURI = $row2->{namespace_type_uri}; + my $article = $row2->{article_name}; + my $objName = $OSobj->getObjectCommonName($objURI); $nsURI ||= ""; my @nsURIs = split ",", $nsURI; @@ -3576,57 +3456,68 @@ } $output .= "\t\n"; $output .= "\t\n"; - $sth_simple_out->execute($_); - while ( my ( $objURI, $nsURI, $article ) = - $sth_simple_out->fetchrow_array() ) + + $result = query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); + + foreach my $row (@$result) { + my $objURI = $row->{object_type_uri}; + my $nsURI = $row->{namespace_type_uris}; + my $article = $row->{article_name}; + + my $objName = $OSobj->getObjectCommonName($objURI); + $nsURI ||= ""; + my @nsURIs = split ",", $nsURI; + $article ||= ""; + $output .= "\t\t\n"; + $output .= "\t\t\t$objName\n"; + foreach my $ns (@nsURIs) { + my $NSname = $OSns->getNamespaceCommonName($ns); + $output .= "\t\t\t$NSname\n" if $NSname; + } + $output .= "\t\t\n"; + } + + $result = query_collection_output({service_instance_id => $_}); + foreach my $row (@$result) + { + my $collid = $row->{collection_output_id}; + my $articlename = $row->{article_name}; + $output .= "\t\t\n"; + + my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id = $collid}); + foreach my $row2 (@$result2 ) + { + my $objURI = $row2->{object_type_uri}; + my $nsURI = $row2->{namespace_type_uris}; + my $article = $row2->{article_name}; my $objName = $OSobj->getObjectCommonName($objURI); $nsURI ||= ""; my @nsURIs = split ",", $nsURI; $article ||= ""; - $output .= "\t\t\n"; - $output .= "\t\t\t$objName\n"; + $output .= "\t\t\t\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { - my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t$NSname\n" if $NSname; - } - $output .= "\t\t\n"; - } - $sth_collection_outs->execute($_); - while ( my ( $collid, $articlename ) = - $sth_collection_outs->fetchrow_array ) - { - $output .= "\t\t\n"; - $sth_collection_out->execute($collid); - while ( my ( $objURI, $nsURI, $article ) = - $sth_collection_out->fetchrow_array() ) - { - my $objName = $OSobj->getObjectCommonName($objURI); - $nsURI ||= ""; - my @nsURIs = split ",", $nsURI; - $article ||= ""; - $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; - foreach my $ns (@nsURIs) { - my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t\t$NSname\n" - if $NSname; - } - $output .= "\t\t\t\n"; - } - $output .= "\t\t\n"; + my $NSname = $OSns->getNamespaceCommonName($ns); + $output .= "\t\t\t\t$NSname\n" + if $NSname; + } + $output .= "\t\t\t\n"; + } + $output .= "\t\t\n"; } $output .= "\t\n"; $output .= "\t\n"; - $sth_secondary_in->execute($_); - while ( - my ( - $default_value, $maximum_value, $minimum_value, - $enum_value, $datatype, $article_name - ) - = $sth_secondary_in->fetchrow_array() - ) + $result = $adaptor->query_secondary_input({service_instance_id => $_}); + foreach my $row (@$result) { + my $default_value = $row->{default_value}; + my $maximum_value = $row->{maximum_value}; + my $minimum_value = $row->{minimum_value}; + my $enum_value = $row->{enum_value}; + my $datatype = $row->{datatype}; + my $article_name = $row->{article_name}; + $article_name ||= ""; $datatype ||= ""; $default_value ||= ""; From dwang at pub.open-bio.org Wed Jul 13 18:19:09 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 14:19:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507131819.j6DIJ9P4020874@pub.open-bio.org> dwang Wed Jul 13 14:19:09 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20848/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: 1st commit by Dennis moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2004/07/09 00:21:53 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/13 18:19:09 1.3 @@ -3,6 +3,7 @@ use Carp; use vars qw($AUTOLOAD); +# Modified by Dennis { #Encapsulated class data @@ -107,28 +108,44 @@ } -sub insert_collection_input { - die "insert_collection_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} + +# +# authority table functions +# +sub query_authority{ + + } -sub insert_collection_output { - die "insert_collection_output not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} +sub insert_authority{ + +} + +sub delete_authority{ + +} + + +# +# service_instance table functions +# +sub query_service_instance { + die "query_service_instance not implemented in adaptor\n"; +} + +sub insert_service_instance { + die "insert_service_instance not implemented in adaptor\n"; +} + +sub delete_service_intance{ + +} + +# +# simple_output table functions +# +sub query_simple_input{ + } sub insert_simple_input { @@ -153,6 +170,16 @@ #return $id; } +sub delete_simple_input{ + +} + +# +# simple_output table functions +# +sub query_simple_output{ + +} sub insert_simple_output { die "insert_simple_output not implemented in adaptor\n"; @@ -177,14 +204,180 @@ } -sub query_service_instance { - die "query_service_instance not implemented in adaptor\n"; +sub delete_simple_output{ + } -sub insert_service_instance { - die "insert_service_instance not implemented in adaptor\n"; +# +# collection_input table functions +# +sub query_collection_input{ + +} + +sub insert_collection_input { + die "insert_collection_input not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} +} + +sub delete_collection_input{ + +} + +# +# collection_output table fuctions +# +sub query_collection_output{ + +} + +sub insert_collection_output { + die "insert_collection_output not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} +} + +sub delete_collection_output{ + +} + +# +# object table functions +# +sub query_object{ + +} + +sub insert_object{ + +} + +sub delete_object{ + +} + +# +# object_term2term table functions +# +sub query_object_term2term{ + +} + +sub insert_object_term2term{ + +} + +sub delete_object_term2term{ + +} + +# +# relationship table functions +# +sub query_relationship{ + +} + +sub insert_relationship{ + +} + +sub delete_relationship{ + +} + +# +# service table fuctions +# +sub query_service{ + +} + +sub insert_service{ + +} + +sub delete_service{ + +} + +# +# service_term2term table functions +# +sub query_service_term2term{ + +} + +sub insert_service_term2term{ + +} + +sub delete_service_term2term{ + } +# +# namespace table functions +# +sub query_namespace{ + +} + +sub insert_namespace{ + +} + +sub delete_namespace{ + +} + +# +# namespace_term2term table functions +# +sub query_namespace_term2term{ + +} + +sub insert_namespace_term2term{ + +} + +sub delete_namespace_term2term{ + +} + +# secondary_input table functions +sub query_secondary_input{ + +} + +sub insert_secondary_input{ + +} + +sub delete_secondary_input{ + +} + +# +# query term2term tables - queries relation between two tables +# +sub select_term2term{ + +} sub _dump { my ($self) = @_; From dwang at pub.open-bio.org Wed Jul 13 18:33:41 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 14:33:41 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507131833.j6DIXfP0021170@pub.open-bio.org> dwang Wed Jul 13 14:33:41 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21144/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: 1st commit by Dennis moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/05/30 23:33:43 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 18:33:41 1.11 @@ -98,33 +98,222 @@ } +sub add_condition{ + my ($statement, @params) = @_; + my @bindvalues = (); + my $condition = "where "; + + foreach my $param (@params ) + { + if (($param eq 'and') || ($param eq 'or')) + { + $condition .= $param . " "; + } + else + { + my %pair = %$param; + + for my $key (keys %pair) + { + if (defined $pair{$key}) + { + $condition .= $key . " = ? "; + push(@bindvalues, $pair{$key}); + } + else + { + $condition .= $key . " IS NULL " + } + } + } + } + $statement .= $condition; + return ($statement, @bindvalues); + } + +# preforms query but returns a reference to an array containing hash references +sub do_query{ + my ($dbh, $statement, @bindvalues) = @_; + my $sth = $dbh -> prepare($statement); + if (@bindvalues < 1) + { + $sth->execute; + } + else + { + $sth->execute(@bindvalues); + } + # returns an array of hash references + my $arrayHashRef = $sth->fetchall_arrayref({}); + return $arrayHashRef; +} + +sub get_value{ + my ($key, @params) = @_; + + foreach my $param (@params ) + { + my %pair = %$param; + for my $tmp (keys %pair) + { + if ($tmp eq $key){ + return $pair{$key}; + } + } + } +} + +# general query subroutine +# parameters: +# statement - a string SQL statement +# bind_values - an array of values to be bound to the parameters +# returns: +# resultset - reference to an array containing array references +sub general_query{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = get_value('statement', @args); + my $sth = $dbh->prepare($statement}; + if (@args > 1) + { + my $bindvalues = get_value('bind_values', @args); + $sth->execute(@$bindvalues); + } + else { + $sth->execute; + } + my $result = $sth->fetchall_arrayref(); + return result; +} + +sub query_collection_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + collection_input_id, + article_name, + service_instance_id + from collection_input "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} sub insert_collection_input { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; # if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ # this should be dropped down into the mysql.pm module?? probably... - $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", + undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); my $id=$self->dbh->{mysql_insertid}; return $id; # } } +sub delete_collection_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from collection_input "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# query subroutine selects all columns +sub query_collection_output{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + collection_output_id, + article_name, + service_instance_id + from collection_output "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + sub insert_collection_output { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; # if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ # this should be dropped down into the mysql.pm module?? probably... - $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", + undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); my $id=$self->dbh->{mysql_insertid}; return $id; # } } +sub delete_collection_output{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from collection_output "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + + +sub query_simple_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + simple_input_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id + from simple_input "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + + sub insert_simple_input { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; - my $si = $args{collection_input_id}?undef:$args{service_instance_id}; + my $si = get_value('collection_input_id', @args)?undef:get_value('service_instance_id', @args); $dbh->do("insert into simple_input (object_type_uri, @@ -134,21 +323,59 @@ collection_input_id) values (?,?,?,?,?)", undef, - ($args{object_type_uri}, - $args{namespace_type_uris}, - $args{article_name}, + (get_value('object_type_uri', @args), + get_value('namespace_type_uris', @args), + get_value('article_name', @args), # here $si, - $args{collection_input_id})); + get_value('collection_input_id', @args))); my $id=$dbh->{mysql_insertid}; return $id; } +sub delete_simple_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from simple_input "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ) + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_simple_output{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + simple_output_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id + from simple_output "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} sub insert_simple_output { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; - my $si = $args{collection_output_id}?undef:$args{service_instance_id}; + my $si = get_value('collection_output_id', @args)?undef:get_value('service_instance_id', @args); $dbh->do("insert into simple_output (object_type_uri, @@ -158,78 +385,813 @@ collection_output_id) values (?,?,?,?,?)", undef, - ($args{object_type_uri}, - $args{namespace_type_uris}, - $args{article_name}, + (get_value('object_type_uri', @args), + get_value('namespace_type_uris', @args), + get_value('article_name', @args), # and here $si, - $args{collection_output_id})); + get_value('collection_output_id', @args))); my $id=$dbh->{mysql_insertid}; return $id; } -sub query_service_instance { - my ($self, %args) = @_; +sub delete_simple_output{ + my ($self, @args) = @_; my $dbh = $self->dbh; + my $statement = "delete from simple_output "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} - my ($serviceid, $category, $name, $typeURI, $authURI,$url,$email,$authoritative,$desc, $signatureURL, $lsid) = $dbh->selectrow_array( # does this service already exist? - q{select +sub query_secondary_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + secondary_input_id, + default_value, + maximum_value, + minimum_value, + enum_value, + datatype, + article_name, + service_instance_id + from secondary_input "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_secondary_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $dbh->do( +q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, + undef, + ( + get_value('default_value', @args), get_value('maximum_value', @args), + get_value('minimum_value', @args), get_value('enum_value', @args), + get_value('datatype', @args), get_value('article_name', @args), + get_value('service_instance_id', @args), + ) + ); + return $dbh->{mysql_insertid}; +} + +sub delete_secondary_input{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from secondary_input "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# query subroutine will selects all rows from object table +sub query_object +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + object_id, + object_lsid, + object_type, + description, + authority, + contact_email + from object "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# inserts a new tuple into object table +sub insert_object{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into object + (object_type, + object_lsid, + description, + authority, + contact_email) + values (?,?,?,?,?)", + undef, + (get_value('object_type', @args), + get_value('object_lsid', @args), + get_value('description', @args), + get_value('authority', @args), + get_value('contact_email', @args))); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +sub delete_object{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from object "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_object_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + object1_id, + object2_id, + object2_articlename + from object_term2term "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_object_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, + undef, + ( get_value('relationship_type', @args), + get_value('object1_id', @args), + get_value('object2_id', @args), + get_value('object2_articlename', @args) ) + ); + + return $dbh->{mysql_insertid}; +} + +# selects all the columns from service_instance table +# where is lsid? +sub query_service_instance { + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select service_instance_id, category, - serviceName, + servicename, service_type_uri, - authority.authority_uri, + authority_id, url, - service_instance.contact_email, + contact_email, authoritative, description, signatureURL, lsid - from service_instance, authority - where - service_instance.authority_id = authority.authority_id - and servicename=? and authority.authority_uri = ? - }, - undef,($args{servicename}, $args{authURI})); - return undef unless $serviceid; - return {serviceid => $serviceid, - category => $category, - name => $name, - servcetype => $typeURI, - authURI => $authURI, - signatureURL => $signatureURL, - url => $url, - email => $email, - authoritative => $authoritative, - desc => $desc, - lsid => $lsid - }; + from service_instance "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; } +# custom query for Moby::Central.pm->findService() +sub match_service_type_uri{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $uri_list = get_value('service_type_uri', @args); + + my $result = $dbh->selectall_arrayref( +"select service_instance_id from service_instance where service_type_uri in ($uri_list)" + ); + return $result; +} sub insert_service_instance { - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, - undef, - $args{'category'}, - $args{'servicename'}, - $args{'service_type_uri'}, - $args{'authority_id'}, - $args{'url'}, - $args{'contact_email'}, - $args{'authoritative'}, - $args{'description'}, - $args{'signatureURL'}, - $args{'lsid'}); + undef,( + get_value('category', @args), + get_value('servicename', @args), + get_value('service_type_uri', @args), + get_value('authority_id', @args), + get_value('url', @args), + get_value('contact_email', @args), + get_value('authoritative', @args), + get_value('description', @args), + get_value('signatureURL', @args), + get_value('lsid', @args))); my $id = $dbh->{mysql_insertid}; return $id; } +sub delete_service_instance{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service_instance "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# Selects all columns +sub query_authority { + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + authority_id, + authority_common_name, + authority_uri, + contact_email + from authority "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub getUniqueAuthorityURI{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $statement = "select distinct authority_uri from authority"; + $bindvalues = (); + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_authority{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into authority + (authority_common_name, + authority_uri, + contact_email) + values (?,?,?)", + undef, + (get_value('authority_common_name', @args), + get_value('authority_uri' @args), + get_value('contact_email', @args))); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +sub query_service{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select + service_id, + service_lsid, + service_type, + description, + authority, + contact_email + from service "; + my @bindvalues = (); + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_service{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, + undef, + ( + get_value('service_type', @args), get_value('service_lsid', @args), get_value('description', @args), + get_value('authority', @args), get_value('contact_email', @args) + ) + ); + return dbh->{mysql_insertid}; +} + +sub delete_service{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_service_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select + assertion_id, + relationship_type, + service1_id, + service2_id + from service_term2term "; + my @bindvalues = (); + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_service_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, + undef, + ( get_value('relationship_type', @args), get_value('service1_id', @args), get_value('service2_id', @args)) + ); + return dbh->{mysql_insertid}; +} + +sub delete_service_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service_term2term "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +sub query_relationship{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + relationship_id, + relationship_lsid, + relationship_type, + container, + description, + authority, + contact_email, + ontology + from relationship "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub query_namespace{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + namespace_id, + namespace_lsid, + namespace_type, + description, + authority, + contact_email + from namespace "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub insert_namespace{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + dbh->do( +q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, + undef, + ( + get_value('namespace_type', @args), get_value('namespace_lsid', @args), get_value('description', @args), + get_value('authority', @args), get_value('contact_email', @args) + ) + ); + return dbh->{mysql_insertid}; +} + +sub delete_namespace{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from namespace "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} +sub query_namespace_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + namespace1_id, + namespace2_id + from namespace_term2term "; + my @bindvalues = (); + + if (@args > 0) + { + ($statement, @bindvalues) = add_condition($statement, @args); + } + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +sub delete_namespace_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from namespace_term2term "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (0, dbh->errstr); + } + else{ + return 1; + } +} + +# custom query subroutine for Moby::Central.pm->deregisterObjectClass() +sub checkClassUsedByService +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $errorMsg = 1; + my $existingURI = get_value('object_type_uri', @args); + + my ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array( +q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + return 0; +} + +# custom query routine for Moby::Central.pm -> deregisterNamespace() +sub checkNamespaceUsedByService{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $existingURI = get_value('namespace_type_uris', @args); + my $term = get_value('term', @args); + +my $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr); + if ( $_ eq $existingURI ); + } + } + return (0, $errstr); +} + +# custom query routine for Moby::Central.pm -> findService() +sub checkKeywords{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $param = get_value('findme', @args); + my %findme = %$param; + my $searchstring; + + foreach my $kw ( @{ $findme{keywords} } ) { + $debug && &_LOG("KEYWORD $kw\n"); + $kw =~ s/\*//g; + $kw = $dbh->quote("%$kw%"); + $searchstring .= " OR description like $kw "; + } + $searchstring =~ s/OR//; # just the first one + $debug && &_LOG("search $searchstring\n"); + + my $ids = + $dbh->selectall_arrayref( +"select service_instance_id from service_instance where $searchstring" + ); + + return ($ids, $searchstring); +} + +# custom query subroutine for Moby::Central.pm->_searchForSimple() +sub getFromSimple{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $ancestor_string = get_value('ancestor_string', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = +"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " + ; # if service_instance_id is null then it must be a collection input. + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/OR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; + } + + my $result = do_query($dbh, $query, ()); + return ($query, $result); +} + +# custom query subroutine for Moby::Central.pm->_searchForCollection() +sub getFromCollection +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $objectURI = get_value('objectURI', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = "select + c.service_instance_id, + s.namespace_type_uris + from + simple_$inout as s, + collection_$inout as c + where + s.collection_${inout}_id IS NOT NULL + AND s.collection_${inout}_id = c.collection_${inout}_id + AND object_type_uri = '$objectURI' " + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/^\sOR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; # add the AND clause + } + + my $result = do_query($dbh, $query, ()); + return ($query, $result); +} + +# custom query subroutine for Moby::Central.pm->RetrieveServiceNames +sub getServiceNames +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; + my @bindvalues = (); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query for Moby::Central.pm->_flatten +sub getParentTerms +{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $type_id = get_value('relationship_type_id', @args); + my $statement = " + select + OE1.term + from + OntologyEntry as OE1, + OntologyEntry as OE2, + Term2Term as TT + where + ontologyentry2_id = OE2.id + and ontologyentry1_id = OE1.id + and relationship_type_id = $type_id + and OE2.term = ?"; + + my @bindvalues = (); + push(@bindvalues, get_value('term', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query subroutine for selecting from object_term2term and object tables +# used in Moby::OntologyServer.pm->retrieveObject() +sub getObjectRelationships{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + relationship_type, + object_lsid, + object2_articlename + from object_term2term, object + where object1_id = ? and object2_id = object_id"; + + my @bindvalues = (); + push(@bindvalues, get_value('object1_id', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() +getRelationship{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $defs; + my $ontology = $args{ontology}; + + unless ( defined $args{$relationship} ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $args{lsid} ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $args{$relationship}, $args{lsid} ); # ") + } + return $defs; +} sub _checkURI { From dwang at pub.open-bio.org Wed Jul 13 21:53:12 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 17:53:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507132153.j6DLrCUE022059@pub.open-bio.org> dwang Wed Jul 13 17:53:12 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22025/Perl/MOBY Modified Files: Central.pm OntologyServer.pm authority.pm Log Message: Moved all SQL statements in authority.pm and Central.pm to Moby::Adaptor::queryapi::mysql.pm In its place are calls to routines in Moby::Adaptor::queryapi.pm moby-live/Perl/MOBY Central.pm,1.158,1.159 OntologyServer.pm,1.49,1.50 authority.pm,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.158 retrieving revision 1.159 diff -u -r1.158 -r1.159 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 18:18:39 1.158 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 21:53:11 1.159 @@ -1928,8 +1928,8 @@ $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } @@ -2001,7 +2001,7 @@ $debug && _LOG("Keywords added; criterion count is now $criterion_count\n"); - my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); unless ( scalar @{$ids} ) { $debug @@ -2013,8 +2013,8 @@ $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { - $debug && &_LOG("found id $_->[0]\n"); - ++$valid_service_ids{ $_->[0] + $debug && &_LOG("found id $_->{service_instance_id}\n"); + ++$valid_service_ids{ $_->{service_instance_id} }; # increment that particular id's count by one } } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2004/12/14 20:47:04 1.49 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/13 21:53:12 1.50 @@ -191,19 +191,21 @@ # if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objecttype/)){ # return (1, "external ontology", $term); # } + my $result; if ( $term =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_lsid = ?" - ); + $result = $adaptor->query_object({object_lsid => $term}); + } else { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_type = ?" - ); + $result = $adaptor->query_object({object_type => $term}); + } - $sth->execute($term); - my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $lsid = $row->{object_lsid}; + my $type = $row->{object_type}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($lsid) { # if it is in there, then it has been discovered regardless of being foreign or not return ( 1, $desc, $lsid ); @@ -263,20 +265,20 @@ ? $args{'node'} : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $sth; + my $result; if ( $args{'node'} =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_lsid = ?" - ); + + $result = $adaptor->query_object({object_lsid => $term}); } else { - $sth = - $self->dbh->prepare( -"select object_lsid, object_type, description, authority, contact_email from object where object_type = ?" - ); + $result = $adaptor->query_object({object_type => $term}); } - $sth->execute($term); - my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $lsid = $row->{object_lsid}; + my $type = $row->{object_type}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($lsid) { # if it is in there, then the object exists return ( 0, "This term already exists: $lsid", $lsid ); } @@ -284,15 +286,13 @@ $args{node} =~ s/^\s+(.*?)\s+$/$1/s; $args{contact_email} =~ s/^\s+(.*?)\s+$/$1/s; $args{authority} =~ s/^\s+(.*?)\s+$/$1/s; - $self->dbh->do( -q{insert into object (object_type, object_lsid, description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - $args{'node'}, $LSID, $args{'description'}, - $args{'authority'}, $args{'contact_email'} - ) - ); - unless ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_object({object_type => $args{'node'}}, + {object_lsid => $LSID}, + {description => $args{'description'}}, + {authority => $args{'authority'}}, + {contact_email => $args{'contact_email'}}); + unless ( $insertid ) { return ( 0, "Object creation failed for unknown reasons", '' ); } return ( 1, "Object creation succeeded", $LSID ); @@ -313,24 +313,28 @@ ? $args{'node'} : $self->getObjectURI($term); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my ( $id, $type, $lsid, $desc, $auth, $contact ) = - $self->dbh->selectrow_array( -q{select object_id, object_type, object_lsid, description, authority,contact_email from object where object_lsid = ?}, - undef, $LSID - ); + my $result = $adaptor->query_object({object_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{object_id}; + my $type = $row->{object_type}; + my $lsid = $row->{object_lsid}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $contact = $row->{contact_email}; + unless ($id) { return ( 0, "Object doesn't exist in ontology", "" ) } # my $OS = MOBY::OntologyServer->new(ontology => "relationship"); - my $sth = - $self->dbh->prepare( -q{select relationship_type, object_lsid, object2_articlename from object_term2term, object where object1_id = ? and object2_id = object_id} - ); - $sth->execute($id); + + $result = $adaptor->getObjectRelationships({object1_id => $id}); my %rel; - while ( my ( $relationship_type, $objectlsid, $article ) = - $sth->fetchrow_array ) + foreach my $row (@$result) { - push @{ $rel{$relationship_type} }, [ $objectlsid, $article ]; + my $relationship_type = $row->{relationship_type}; + my $objectlsid = $row->{object_lsid}; + my $article = $row->{object2_articlename}; + + push @{ $rel{$relationship_type} }, [ $objectlsid, $article ]; } return { objectType => $lsid, =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2004/11/18 17:41:14 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/13 21:53:12 1.3 @@ -2,6 +2,7 @@ package MOBY::authority; use strict; use Carp; +use MOBY::Config; use vars qw($AUTOLOAD @ISA); =head1 NAME @@ -86,20 +87,21 @@ } } my $dbh = $self->dbh; - my ( $authority_id, $common, $uri, $contact ) = $dbh->selectrow_array( -q{select authority_id, authority_common_name,authority_uri,contact_email from authority where authority_uri = ?}, - undef, $self->authority_uri - ); + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + + my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $authority_id = @$result[0]->{authority_id}; + my $common = @$result[0]->{authority_common_name}; + my $uri = @$result[0]->{authority_uri}; + my $contact = @$result[0]->{contact_email}; + unless ($authority_id) { - $dbh->do( -q{insert into authority (authority_common_name, authority_uri, contact_email) values (?,?,?)}, - undef, - ( - $self->authority_common_name, $self->authority_uri, - $self->contact_email - ) - ); - $self->authority_id( $dbh->{mysql_insertid} ); + my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, + {authority_uri => $self->authority_uri}, + {contact_email => $self->contact_email}); + + $self->authority_id( $insertid ); } else { $self->authority_id($authority_id); } From dwang at pub.open-bio.org Wed Jul 13 21:55:36 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 13 Jul 2005 17:55:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507132155.j6DLtaxK022106@pub.open-bio.org> dwang Wed Jul 13 17:55:36 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22080/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: Implementation of queryapi.pm Contains all SQL statements used in Moby::authority.pm and Moby::Central.pm. Changed all query routines to return reference of an array containing hash references, with the exception of general_quer(). moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 18:33:41 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 21:55:36 1.12 @@ -168,7 +168,7 @@ # statement - a string SQL statement # bind_values - an array of values to be bound to the parameters # returns: -# resultset - reference to an array containing array references +# resultset - reference to an array containing ARRAY references sub general_query{ my ($self, @args) = @_; my $dbh = $self->dbh; @@ -604,12 +604,11 @@ sub match_service_type_uri{ my ($self, @args) = @_; my $dbh = $self->dbh; - my $uri_list = get_value('service_type_uri', @args); + my $statement = "select service_instance_id from service_instance where service_type_uri in ($uri_list)"; + my @bindvalues = (); - my $result = $dbh->selectall_arrayref( -"select service_instance_id from service_instance where service_type_uri in ($uri_list)" - ); + my $result = do_query($dbh, $statement, @bindvalues); return $result; } @@ -672,6 +671,7 @@ return $result; } +# custom query routine used in Moby::Central.pm -> retrieveServiceProviders() sub getUniqueAuthorityURI{ my ($self, @args) = @_; my $dbh = $self->dbh; @@ -693,7 +693,7 @@ (get_value('authority_common_name', @args), get_value('authority_uri' @args), get_value('contact_email', @args))); - my $id=$dbh->{mysql_insertid}; + my $id = $dbh->{mysql_insertid}; return $id; } @@ -1036,11 +1036,10 @@ $searchstring =~ s/OR//; # just the first one $debug && &_LOG("search $searchstring\n"); - my $ids = - $dbh->selectall_arrayref( -"select service_instance_id from service_instance where $searchstring" - ); - + my $statement = "select service_instance_id from service_instance where $searchstring"; + my @bindvalues = (); + + my $ids = do_query($dbh, $statement, @bindvalues); return ($ids, $searchstring); } @@ -1162,7 +1161,8 @@ } # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() -getRelationship{ +# note: returns a reference to an array containing ARRAY references +sub getRelationship{ my ($self, %args) = @_; my $dbh = $self->dbh; my $defs; From dwang at pub.open-bio.org Fri Jul 15 16:39:11 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Fri, 15 Jul 2005 12:39:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507151639.j6FGdBMc030093@pub.open-bio.org> dwang Fri Jul 15 12:39:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30067/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: All subroutines in mysql.pm should take in array of hashes as arguments. Delete tuple subroutines now returns 0 if successful or 1 if error moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/13 21:55:36 1.12 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/15 16:39:11 1.13 @@ -228,10 +228,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -278,10 +278,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -342,10 +342,10 @@ $dbh->do( $statement, undef, @bindvalues ) if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -405,10 +405,10 @@ $dbh->do( $statement, undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -463,10 +463,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -526,10 +526,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -570,6 +570,24 @@ return $dbh->{mysql_insertid}; } +sub delete_object_term2term{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "delete from object_term2term "; + my @bindvalues = (); + ($statement, @bindvalues) = add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + + if (dbh->err){ + return (1, dbh->errstr); + } + else{ + return 0; + } +} + # selects all the columns from service_instance table # where is lsid? sub query_service_instance { @@ -642,10 +660,10 @@ $dbh->do( $statement, undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -742,10 +760,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -789,10 +807,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -868,10 +886,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -906,10 +924,10 @@ undef, @bindvalues ); if (dbh->err){ - return (0, dbh->errstr); + return (1, dbh->errstr); } else{ - return 1; + return 0; } } @@ -1163,12 +1181,39 @@ # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references sub getRelationship{ - my ($self, %args) = @_; + my ($self, @args) = @_; my $dbh = $self->dbh; + my $direction = get_value('direction', @args); + my $ontology = get_value('ontology', @args); + my $term = get_value('term', @args); + my $relationship = get_value('relationship', @args); my $defs; - my $ontology = $args{ontology}; - unless ( defined $args{$relationship} ) { + if ( $direction eq 'root' ) { + unless ( defined $relationship ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $term ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + } + } else { + unless ( defined $relationship ) { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from ${ontology}_term2term as t2t, @@ -1177,7 +1222,7 @@ where s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $args{lsid} ); # ") + s2.${ontology}_lsid = ?", undef, $term ); # ") } else { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from @@ -1188,8 +1233,9 @@ relationship_type = ? and s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $args{$relationship}, $args{lsid} ); # ") + s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") } + } return $defs; } From dwang at pub.open-bio.org Fri Jul 15 16:40:45 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Fri, 15 Jul 2005 12:40:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507151640.j6FGejJK030156@pub.open-bio.org> dwang Fri Jul 15 12:40:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30130/Perl/MOBY Modified Files: OntologyServer.pm Log Message: All SQL statements in OntologyServer.pm has been moved into Moby::Adaptor::moby::queryapi::mysql.pm Note: Still may contain many syntactic errors moby-live/Perl/MOBY OntologyServer.pm,1.50,1.51 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/13 21:53:12 1.50 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/15 16:40:45 1.51 @@ -183,6 +183,10 @@ sub objectExists { my ( $self, %args ) = @_; + + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that my $sth; @@ -243,7 +247,8 @@ sub createObject { my ( $self, %args ) = @_; - + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); #node => $term, #desc => $desc, #authURI => $auth, @@ -304,6 +309,8 @@ sub retrieveObject { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $term = $args{'node'}; return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node as an argument", '' ) @@ -351,6 +358,9 @@ sub deprecateObject { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY", '' ) unless ( $self->ontology eq 'object' ); my $term = $args{term}; @@ -361,31 +371,29 @@ unless ( $term =~ /urn\:lsid/ ) { $LSID = $self->getObjectURI($term) } else { $LSID = $term } return ( 0, q{Object type $term cannot be resolved to an LSID}, "" ) unless $LSID; - my ( $id, $lsid ) = - $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_lsid = ?}, - undef, $LSID ); + + my $result = $adaptor->query_object({object_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{object_id}; + my $lsid = $row->{object_lsid}; # object1_id ISA object2_id? - my (@isa) = - $self->dbh->selectrow_array( - q{select * from object_term2term where object2_id = ?}, - undef, $id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_object_term2term({object2_id => $id}); + if ( scalar @$isa ) { return ( 0, qq{Object type $term has object dependencies in the ontology}, $lsid ); } - $self->dbh->do( q{delete from object where object_id = ?}, undef, $id ); - if ( $self->dbh->err ) { - return ( 0, "Delete from Object Class table failed: $self->dbh->errstr", + + my ($err, $errstr) = $adaptor->delete_object({object_id => $id}); + if ( $err ) { + return ( 0, "Delete from Object Class table failed: $errstr", $lsid ); } - $self->dbh->do( q{delete from object_term2term where object1_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { + ($err, $errstr) = $adaptor->delete_object_term2term({object1_id => $id}); + if ( $err ) { return ( 0, - "Delete from Object term2term table failed: $self->dbh->errstr", + "Delete from Object term2term table failed: $errstr", $lsid ); } return ( 1, "Object $term Deleted", $lsid ); @@ -409,6 +417,9 @@ # term => $term # ontology => $ontology my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'relationship' ); my $term = lc( $args{term} ); @@ -416,21 +427,22 @@ my $ont = $args{ontology}; return ( 0, "requires both term and ontology arguments\n", '' ) unless ( defined($term) && defined($ont) ); - my $sth; - + my $result; if ( $term =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select relationship_lsid, relationship_type, description, authority, contact_email from relationship where relationship_lsid = ? and ontology=?" - ); + + $result = $adaptor->query_relationship({relationship_lsid => $term}, 'and', {ontology => $ont}); + } else { - $sth = - $self->dbh->prepare( -"select relationship_lsid, relationship_type, description, authority, contact_email from relationship where relationship_type = ? and ontology=?" - ); + + $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ont}); + } - $sth->execute( $term, $ont ); - my ( $lsid, $type, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $lsid = $row->{relationship_lsid}; + my $type = $row->{relationship_type}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; if ($lsid) { return ( 1, $desc, $lsid ); } else { @@ -456,43 +468,49 @@ #authority => $auth, #contact_email => $email my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); if ( $args{subject_node} =~ /^urn:lsid/ ) { - ( $subj_id, $subj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_lsid = ?}, - undef, $args{subject_node} - ); + + my $result = $adaptor->query_object({object_lsid => $args{subject_node}}); + my $row = shift(@$result); + $subj_id = $row->{object_id}; + $subj_lsid = $row->{object_lsid}; + } else { - ( $subj_id, $subj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_type = ?}, - undef, $args{subject_node} - ); + my $result = $adaptor->query_object({object_type => $args{subject_node}}); + my $row = shift(@$result); + $subj_id = $row->{object_id}; + $subj_lsid = $row->{object_lsid}; + } return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) unless defined $subj_id; if ( $args{object_node} =~ /^urn:lsid/ ) { - ( $obj_id, $obj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_lsid = ?}, - undef, $args{object_node} - ); + + my $result = $adaptor->query_object({object_lsid => $args{object_node}}); + my $row = shift(@$result); + $obj_id = $row->{object_id}; + $obj_lsid = $row->{object_lsid}; + } else { - ( $obj_id, $obj_lsid ) = $self->dbh->selectrow_array( - q{select object_id, object_lsid from object where object_type = ?}, - undef, $args{object_node} - ); + my $result = $adaptor->query_object({object_type => $args{object_node}}); + my $row = shift(@$result); + $obj_id = $row->{object_id}; + $obj_lsid = $row->{object_lsid}; } return ( 0, qq{Object type $args{object_node} does not exist in the ontology}, '' ) unless defined $obj_id; - my (@isa) = - $self->dbh->selectrow_array( - q{select * from object_term2term where object2_id = ?}, - undef, $subj_id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_object_term2term({object2_id => $subj_id}); + + if ( scalar @$isa ) { return ( 0, qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, @@ -507,12 +525,11 @@ || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - $self->dbh->do( -q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, - undef, - ( $rel_lsid, $subj_id, $obj_id, $args{articleName} ) - ); - if ( $self->dbh->{mysql_insertid} ) { + my $insertid = $adaptor->insert_object_term2term({relationship_type => $rel_lsid}, + {object1_id => $subj_id}, + {object2_id => $obj_id}, + {object2_articlename => $args{articleName}}); + if ($insertid ) { return ( 1, "Object relationsihp created successfully", '' ); } else { return ( 0, "Object relationship creation failed for unknown reasons", @@ -534,32 +551,37 @@ #authority => $auth, #contact_email => $email); my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); - my ( $sbj_id, $sbj_lsid ) = $self->dbh->selectrow_array( - q{select service_id, service_lsid from service where service_type = ?}, - undef, $args{subject_node} - ); + + my $result = $adaptor->query_service({service_type => $args{subject_node}}); + my $row = shift(@$result); + my $sbj_id = $row->{service_id}; + my $sbj_lsid = $row->{service_lsid}; + return ( 0, qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ) unless defined $sbj_id; - my (@isa) = - $self->dbh->selectrow_array( - q{select * from service_term2term where service2_id = ?}, - undef, $sbj_id ); - if ( scalar @isa ) { + + my $isa = $adaptor->query_service_term2term({service2_id => $sbj_id}); + if ( scalar @$isa ) { return ( 0, qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ); } - my ( $obj_id, $obj_lsid ) = $self->dbh->selectrow_array( - q{select service_id, service_lsid from service where service_type = ?}, - undef, $args{object_node} - ); # get ID of the related service + $result = $adaptor->query_service({service_type => $args{object_node}}); + $row = shift(@$result); + my $obj_id = $row->{service_id}; + my $obj_lsid = $row->{service_lsid}; + # get ID of the related service + defined $obj_id || return ( 0, qq{Service $args{object_node} does not exist in the service ontology}, @@ -572,12 +594,11 @@ || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - $self->dbh->do( -q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, - undef, - ( $rel_lsid, $sbj_id, $obj_id ) - ); - if ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_service_term2term({relationship_type => $rel_lsid}, + {service1_id => $sbj_id}, + {service2_id => $obj_id}); + if ( $insertid ) { return ( 1, "Service relationship created successfully", '' ); } else { return ( 0, "Service relationship creation failed for unknown reasons", @@ -591,6 +612,9 @@ sub serviceExists { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that @@ -599,20 +623,22 @@ { return ( 1, "external ontology", $term ); } - my $sth; + my $result; if ( $term =~ /^urn\:lsid/ ) { - $sth = - $self->dbh->prepare( -"select service_id, service_type, service_lsid, description, authority, contact_email from service where service_lsid = ?" - ); + $result = $adaptor->query_service({service_lsid => $term}); + } else { - $sth = - $self->dbh->prepare( -"select service_id, service_type, service_lsid, description, authority, contact_email from service where service_type = ?" - ); + $result = $adaptor->query_service({service_type => $term}); + } - $sth->execute($term); - my ( $id, $type, $lsid, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $id = $row->{service_id}; + my $type = $row->{service_type}; + my $lsid = $row->{service_lsid}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($id) { return ( 1, $desc, $lsid ); } else { @@ -630,6 +656,8 @@ sub createServiceType { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); #node => $term, #descrioption => $desc, @@ -653,15 +681,14 @@ ? $args{'node'} : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - $self->dbh->do( -q{insert into service (service_type, service_lsid, description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - $args{'node'}, $LSID, $args{'description'}, - $args{'authority'}, $args{'contact_email'} - ) - ); - unless ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_service({service_type => $args{'node'}}, + {service_lsid => $LSID}, + {description => $args{'description'}, + {authority => $args{'authority'}, + {contact_email => $args{'contact_email'}); + + unless ( $insertid ) { return ( 0, "Service creation failed for unknown reasons", '' ); } return ( 1, "Service creation succeeded", $LSID ); @@ -673,6 +700,9 @@ sub deleteServiceType { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; if ( $term =~ /^urn:lsid/ @@ -692,35 +722,37 @@ "" ) unless $LSID; - my ( $id, $lsid ) = $self->dbh->selectrow_array( - q{select service_id, service_lsid from service where service_lsid = ?}, - undef, $LSID - ); + + my $result = $adaptor->query_service({service_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{service_id}; + my $lsid = $row->{service_lsid}; + if ( !defined $id ) { return ( 0, q{Service type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my (@isa) = - $self->dbh->selectrow_array( - q{select * from service_term2term where service2_id = ?}, - undef, $id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_service_term2term({service2_id => $id}); + + if ( scalar @$isa ) { return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } - $self->dbh->do( q{delete from service where service_id = ?}, undef, $id ); - if ( $self->dbh->err ) { - return ( 0, "Delete from Service Type table failed: $self->dbh->errstr", + my ($err, $errstr) = $adaptor->delete_service({service_id => $id}); + + if ( $err ) { + return ( 0, "Delete from Service Type table failed: $errstr", $lsid ); } - $self->dbh->do( q{delete from service_term2term where service1_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { + + ($err, $errstr) = $adaptor->delete_service_term2term({service1_id => $id}); + + if ( $err ) { return ( 0, -"Delete from Service Type Term2Term table failed: $self->dbh->errstr", +"Delete from Service Type Term2Term table failed: $errstr", $lsid ); } @@ -733,29 +765,34 @@ sub namespaceExists { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that - my $sth; if ( $term =~ /^urn:lsid/ && !( $term =~ /^urn:lsid:biomoby.org:namespacetype/ ) ) { return ( 1, "external ontology", $term ); } + my $result; if ( $term =~ /^urn:lsid:biomoby.org:namespacetype/ ) { - $sth = - $self->dbh->prepare( -"select namespace_id, namespace_type, namespace_lsid,description, authority, contact_email from namespace where namespace_lsid = ?" - ); + $result = $adaptor->query_namespace({namespace_lsid => $term}); + } else { - $sth = - $self->dbh->prepare( -"select namespace_id, namespace_type, namespace_lsid,description, authority, contact_email from namespace where namespace_type = ?" - ); + $result = $adaptor->query_namespace({namespace_type => $term}); + } - $sth->execute($term); - my ( $id, $type, $lsid, $desc, $auth, $email ) = $sth->fetchrow_array; + my $row = shift(@$result); + my $id = $row->{namespace_id}; + my $type = $row->{namespace_type}; + my $lsid = $row->{namespace_lsid}; + my $desc = $row->{description}; + my $auth = $row->{authority}; + my $email = $row->{contact_email}; + if ($id) { return ( 1, $desc, $lsid ); } else { @@ -773,7 +810,8 @@ sub createNamespace { my ( $self, %args ) = @_; - + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); #node => $term, #descrioption => $desc, #authority => $auth, @@ -797,15 +835,14 @@ ? $args{'node'} : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - $self->dbh->do( -q{insert into namespace (namespace_type, namespace_lsid,description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - $args{'node'}, $LSID, $args{'description'}, - $args{'authority'}, $args{'contact_email'} - ) - ); - unless ( $self->dbh->{mysql_insertid} ) { + + my $insertid = $adaptor->insert_namespace({namespace_type => $args{'node'}}, + {namespace_lsid => $LSID}, + {description => $args{'description'}}, + {authority => $args{'authority'}}, + {contact_email => $args{'contact_email'}}); + + unless ( $insertid ) { return ( 0, "Namespace creation failed for unknown reasons", '' ); } return ( 1, "Namespace creation succeeded", $LSID ); @@ -817,6 +854,8 @@ sub deleteNamespace { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); my $term = $args{term}; @@ -829,36 +868,38 @@ { return ( 0, "cannot delete a term from an external ontology", $term ); } - my ( $id, $lsid ) = $self->dbh->selectrow_array( -q{select namespace_id, namespace_lsid from namespace where namespace_lsid = ?}, - undef, $LSID - ); + + my $result = $adaptor->query_namespace({namespace_lsid => $LSID}); + my $row = shift(@$result); + my $id = $row->{namespace_id}; + my $lsid = $row->{namespace_lsid}; + unless ($id) { return ( 0, q{Namespace type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my (@isa) = - $self->dbh->selectrow_array( - q{select * from namespace_term2term where namespace2_id = ?}, - undef, $id ); - if ( scalar @isa ) { + my $isa = $adaptor->query_namespace_term2term({namespace2_id => $id}); + + if ( scalar @$isa ) { return ( 0, qq{Namespace type $term has dependencies in the ontology}, $lsid ); } - $self->dbh->do( q{delete from namespace where namespace_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { - return ( 0, "Delete from namespace table failed: $self->dbh->errstr", + + my ($err, $errstr) = $adaptor->delete_namespace({namespace_id => $id}); + + if ( $err ) { + return ( 0, "Delete from namespace table failed: $errstr", $lsid ); } - $self->dbh->do( q{delete from namespace_term2term where namespace1_id = ?}, - undef, $id ); - if ( $self->dbh->err ) { + + ($err, $errstr) = $adaptor->delete_namespace_term2term({namespace1_id => $id}); + + if ( $err ) { return ( 0, - "Delete from namespace term2term table failed: $self->dbh->errstr", + "Delete from namespace term2term table failed: $errstr", $lsid ); } @@ -871,13 +912,13 @@ sub retrieveAllServiceTypes { my ($self) = @_; - my $types = - $self->dbh->selectall_arrayref( - q{select service_type, description from service}); - my @types = @{$types}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $types = $adaptor->query_service(); + my %response; - foreach (@types) { - $response{ $_->[0] } = $_->[1]; + foreach (@$types) { + $response{ $_->{service_type} } = $_->{description}; } return \%response; } @@ -888,13 +929,13 @@ sub retrieveAllNamespaceTypes { my ($self) = @_; - my $types = - $self->dbh->selectall_arrayref( - q{select namespace_type, description from namespace}); - my @types = @{$types}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $types = $adaptor->query_namespace(); + my %response; - foreach (@types) { - $response{ $_->[0] } = $_->[1]; + foreach (@$types) { + $response{ $_->{namespace_type} } = $_->{description}; } return \%response; } @@ -905,13 +946,13 @@ sub retrieveAllObjectClasses { my ($self) = @_; - my $types = - $self->dbh->selectall_arrayref( - q{select object_type, description from object}); - my @types = @{$types}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $types = $adaptor->query_object(); + my %response; - foreach (@types) { - $response{ $_->[0] } = $_->[1]; + foreach (@$types) { + $response{ $_->{object_type} } = $_->{description}; } return \%response; } @@ -924,11 +965,13 @@ sub getObjectCommonName { my ( $self, $URI ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return undef unless $URI =~ /urn\:lsid/; - my ($name) = - $self->dbh->selectrow_array( - q{select object_type from object where object_lsid = ?}, - undef, $URI ); + my $result = $adaptor->query_object({object_lsid => $URI}); + my $row = shift(@$result); + my $name = $row->{object_type}; + return $name ? $name : $URI; } @@ -938,11 +981,13 @@ sub getNamespaceCommonName { my ( $self, $URI ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return undef unless $URI =~ /urn\:lsid/; - my ($name) = - $self->dbh->selectrow_array( - q{select namespace_type from namespace where namespace_lsid = ?}, - undef, $URI ); + my $result = $adaptor->query_namespace({namespace_lsid => $URI}); + my $row = shift(@$result); + my $name = $row->{namespace_type}; + return $name ? $name : $URI; } @@ -952,11 +997,13 @@ sub getServiceCommonName { my ( $self, $URI ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return undef unless $URI =~ /urn\:lsid/; - my ($name) = - $self->dbh->selectrow_array( - q{select service_type from service where service_lsid = ?}, - undef, $URI ); + my $result = $adaptor->query_service({service_lsid => $URI}); + my $row = shift(@$result); + my $name = $row->{service_type}; + return $name ? $name : $URI; } @@ -966,11 +1013,14 @@ sub getServiceURI { my ( $self, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return $term if $term =~ /urn\:lsid/; - my ($id) = - $self->dbh->selectrow_array( - q{select service_lsid from service where service_type = ?}, - undef, $term ); + + my $result = $adaptor->query_service({service_type => $term}); + my $row = shift(@$result); + my $id = $row->{service_lsid}; + return $id; } @@ -980,11 +1030,14 @@ sub getObjectURI { my ( $self, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); return $term if $term =~ /urn\:lsid/; - my ($id) = - $self->dbh->selectrow_array( - q{select object_lsid from object where object_type = ?}, - undef, $term ); + + my $result = $adaptor->query_object({object_type => $term}); + my $row = shift(@$result); + my $id = $row->{object_lsid}; + return $id; } @@ -994,11 +1047,15 @@ sub getNamespaceURI { my ( $self, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return $term if $term =~ /urn\:lsid/; - my ($id) = - $self->dbh->selectrow_array( - q{select namespace_lsid from namespace where namespace_type = ?}, - undef, $term ); + + my $result = $adaptor->query_namespace({namespace_type => $term}); + my $row = shift(@$result); + my $id = $row->{namespace_lsid}; + return $id; } @@ -1008,11 +1065,15 @@ sub getRelationshipURI { my ( $self, $ontology, $term ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + return $term if $term =~ /urn\:lsid/; - my ($id) = $self->dbh->selectrow_array( -q{select relationship_lsid from relationship where relationship_type = ? and ontology = ?}, - undef, $term, $ontology - ); + + my $result = $adaptor->query_relationship({relationship_type => $term}, 'and' {ontology => $ontology}); + my $row = shift(@$result); + my $id = $row->{relationship_lsid}; + return $id; } @@ -1022,15 +1083,17 @@ sub getRelationshipTypes { my ( $self, %args ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $ontology = $args{'ontology'}; my $OS = MOBY::OntologyServer->new( ontology => "relationship" ); - my $defs = $OS->dbh->selectall_arrayref( -q{select relationship_lsid, relationship_type, authority, description from relationship where ontology = ?}, - undef, $ontology - ); + + my $defs = $adaptor->query_relationship({ontology => $ontology}); + my %result; - foreach ( @{$defs} ) { - $result{ $_->[0] } = [ $_->[1], $_->[2], $_->[3] ]; + foreach ( @$defs ) { + $result{ $_->{relationship_lsid} } = [ $_->{relationship_type}, $_->{authority}, $_->{description} ]; } return \%result; } @@ -1086,54 +1149,12 @@ sub _doRelationshipsQuery { my ( $self, $ontology, $term, $relationship, $direction ) = @_; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $defs; - if ( $direction eq 'root' ) { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } else { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } + # query returns a reference to an array containing array references + $defs = $adaptor->getRelationship({direction => $direction}, {ontology => $ontology}, {term => $term}, {relationship => $relationship}); + # a very long piece of SQL statements have been refactored into Moby::Adaptor::moby::queryapi::mysql.pm return $defs; } From dwang at pub.open-bio.org Mon Jul 18 16:53:04 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 18 Jul 2005 12:53:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507181653.j6IGr478016252@pub.open-bio.org> dwang Mon Jul 18 12:53:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv16206/Perl/MOBY Modified Files: simple_input.pm collection_output.pm collection_input.pm simple_output.pm secondary_input.pm service_instance.pm Log Message: SQL statements replaced by generic api subroutines. Actual SQL exists in Moby::Adaptor::moby::queryapi::mysql.pm moby-live/Perl/MOBY simple_input.pm,1.5,1.6 collection_output.pm,1.3,1.4 collection_input.pm,1.3,1.4 simple_output.pm,1.4,1.5 secondary_input.pm,1.2,1.3 service_instance.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2004/11/18 17:41:14 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/18 16:53:03 1.6 @@ -100,11 +100,11 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_input( - object_type_uri => $self->object_type_uri, - namespace_type_uris => $self->namespace_type_uris, - article_name => $self->article_name, - service_instance_id => $self->service_instance_id, - collection_input_id => $self->collection_input_id, + {object_type_uri => $self->object_type_uri}, + {namespace_type_uris => $self->namespace_type_uris}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}, + {collection_input_id => $self->collection_input_id} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2004/11/18 17:41:14 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/18 16:53:03 1.4 @@ -94,8 +94,8 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_collection_output( - service_instance => $self->service_instance_id, - article_name => $self->article_name, ); + {service_instance => $self->service_instance_id}, + {article_name => $self->article_name} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2004/11/18 17:41:14 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/18 16:53:03 1.4 @@ -95,8 +95,8 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_collection_input( - service_instance => $self->service_instance_id, - article_name => $self->article_name, ); + {service_instance => $self->service_instance_id}, + {article_name => $self->article_name} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2004/11/18 17:41:15 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/18 16:53:03 1.5 @@ -99,11 +99,11 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_output( - object_type_uri => $self->object_type_uri, - namespace_type_uris => $self->namespace_type_uris, - article_name => $self->article_name, - service_instance_id => $self->service_instance_id, - collection_output_id => $self->collection_output_id, + {object_type_uri => $self->object_type_uri}, + {namespace_type_uris => $self->namespace_type_uris}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}, + {collection_output_id => $self->collection_output_id} ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2004/11/18 17:41:14 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 16:53:03 1.3 @@ -2,6 +2,7 @@ package MOBY::secondary_input; use strict; use Carp; +use MOBY::Config; use vars qw($AUTOLOAD @ISA); =head1 NAME @@ -110,18 +111,17 @@ sub WRITE { my ($self) = @_; - my $dbh = $self->_dbh; - $dbh->do( -q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, - undef, - ( - $self->default_value, $self->maximum_value, - $self->minimum_value, $self->enum_value, - $self->datatype, $self->article_name, - $self->service_instance_id, - ) - ); - my $id = $dbh->{mysql_insertid}; + $CONFIG ||= MOBY::Config->new; # exported by Config.pm + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, + {maximum_value => $self->maximum_value}, + {minimum_value => $self->minimum_value}, + {enum_value => $self->enum_value}, + {datatype => $self->datatype}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}); + + my $id = $dbh->{$insertid}; return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/05/30 23:33:44 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 16:53:03 1.12 @@ -272,16 +272,16 @@ . $self->servicename; my $id = $self->adaptor->insert_service_instance( - category => $self->category, - servicename => $self->servicename, - service_type_uri => $self->service_type_uri, - authority_id => $self->authority_id, - url => $self->url, - contact_email => $self->contact_email, - authoritative => $self->authoritative, - description => $self->description, - signatureURL => $self->signatureURL, - lsid => $service_lsid + {category => $self->category}, + {servicename => $self->servicename}, + {service_type_uri => $self->service_type_uri}, + {authority_id => $self->authority_id}, + {url => $self->url}, + {contact_email => $self->contact_email}, + {authoritative => $self->authoritative}, + {description => $self->description}, + {signatureURL => $self->signatureURL}, + {lsid => $service_lsid} ); $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists @@ -298,36 +298,29 @@ return undef; } $CONFIG ||= MOBY::Config->new; - $dbh->do( q{delete from service_instance where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from simple_input where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from simple_output where service_instance_id = ?}, - undef, $self->service_instance_id ); - my $sth = - $dbh->prepare( -q{select collection_input_id from collection_input where service_instance_id = ?} - ); - $sth->execute( $self->service_instance_id ); - while ( my ($id) = $sth->fetchrow_array ) { - $dbh->do( q{delete from simple_input where collection_input_id = ?}, - undef, $id ); - } - $sth = - $dbh->prepare( -q{select collection_output_id from collection_output where service_instance_id = ?} - ); - $sth->execute( $self->service_instance_id ); - while ( my ($id) = $sth->fetchrow_array ) { - $dbh->do( q{delete from simple_output where collection_output_id = ?}, - undef, $id ); - } - $dbh->do( q{delete from collection_input where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from collection_output where service_instance_id = ?}, - undef, $self->service_instance_id ); - $dbh->do( q{delete from secondary_input where service_instance_id=?}, - undef, $self->service_instance_id ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + + $adaptor->delete_service_instance({service_instance_id => $self->service_instance_id}); + $adaptor->delete_simple_input({service_instance_id => $self->service_instance_id}); + $adaptor->delete_simple_output({service_instance_id => $self->service_instance_id}); + + my $result = $adaptor->query_collection_input({service_instance_id => $self->service_instance_id}); + + foreach my $row (@$result) { + my $id = $row->{collection_input_id}; + $adaptor->delete_simple_input({collection_input_id => $id}); + } + $result = $adaptor->query_collection_output({service_instance_id => $self->service_instance_id}); + + foreach my $row (@$result) { + my $id = $row->{collection_output_id}; + + $adaptor->delete_simple_output({collection_output_id => $id}); + } + $adaptor->delete_collection_input({service_instance_id => $self->service_instance_id}); + $adaptor->delete_collection_output({service_instance_id => $self->service_instance_id}); + $adaptor->delete_secondary_input({service_instance_id => $self->service_instance_id}); + return 1; } @@ -338,18 +331,21 @@ sub service_instance_exists { my ($self) = @_; + $CONFIG ||= MOBY::Config->new; + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; my $authority; - my ($id) = - $dbh->selectrow_array( - q{select authority_id from authority where authority_uri = ?}, - undef, $self->authority_uri ); + + my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $row = shift(@$result); + my $id = $row->{authority_id}; + return undef unless $id; - my ($svc) = $dbh->selectrow_array( -q{select service_instance_id from service_instance where authority_id = ? and servicename = ?}, - undef, - ( $id, $self->servicename ) - ); + + $result = $adaptor->query_service_instance({authority_id => $id}, 'and', {servicename => $self->servicename}); + $row = shift(@$result); + my $svc = $row->{service_instance_id}; + return $svc; } @@ -358,10 +354,14 @@ my ($self) = @_; my $dbh = $self->dbh; my $authority; - my ( $id, $name, $uri, $email ) = $dbh->selectrow_array( -q{select authority_id, authority_common_name, authority_uri, contact_email from authority where authority_uri = ?}, - undef, $self->authority_uri - ); + + my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $row = shift(@$result); + my $id = $row->{authority_id}; + my $name = $row->{authority_common_name}; + my $uri = $row->{authority_uri}; + my $email = $row->{contact_email}; + if ( defined $id ) { $authority = MOBY::authority->new( dbh => $self->dbh, From dwang at pub.open-bio.org Mon Jul 18 16:53:49 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 18 Jul 2005 12:53:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507181653.j6IGrnpY016287@pub.open-bio.org> dwang Mon Jul 18 12:53:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv16261/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: All routines that are implementated in mysql.pm now exists in queryapi interface moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/13 18:19:09 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/18 16:53:49 1.4 @@ -108,44 +108,67 @@ } - +# general query subroutine +# parameters: +# statement - a string SQL statement +# bind_values - an array of values to be bound to the parameters +# returns: +# resultset - reference to an array containing ARRAY references +sub general_query{ + die "general_query not implemented in adaptor\n"; +} + # -# authority table functions +# collection_input table functions # -sub query_authority{ - - +sub query_collection_input{ + die "query_collection_input not implemented in adaptor\n"; } -sub insert_authority{ - +sub insert_collection_input { + die "insert_collection_input not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} } -sub delete_authority{ - +sub delete_collection_input{ + die "delete_collection_input not implemented in adaptor\n"; } - # -# service_instance table functions +# collection_output table fuctions # -sub query_service_instance { - die "query_service_instance not implemented in adaptor\n"; +sub query_collection_output{ + die "query_collection_output not implemented in adaptor\n"; } -sub insert_service_instance { - die "insert_service_instance not implemented in adaptor\n"; +sub insert_collection_output { + die "insert_collection_output not implemented in adaptor\n"; + #my ($self, %args) = @_; + #my $dbh = $self->dbh; + #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ + # # this should be dropped down into the mysql.pm module?? probably... + # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); + # my $id=$self->dbh->{mysql_insertid}; + # return $id; + #} } -sub delete_service_intance{ - +sub delete_collection_output{ + die "delete_collection_output not implemented in adaptor\n"; } - + # # simple_output table functions # sub query_simple_input{ - + die "query_simple_input not implemented in adaptor\n"; } sub insert_simple_input { @@ -171,14 +194,14 @@ } sub delete_simple_input{ - + die "delete_simple_input not implemented in adaptor\n"; } # # simple_output table functions # sub query_simple_output{ - + die "query_simple_output not implemented in adaptor\n"; } sub insert_simple_output { @@ -205,178 +228,214 @@ } sub delete_simple_output{ - -} - -# -# collection_input table functions -# -sub query_collection_input{ - + die "delete_simple_output not implemented in adaptor\n"; } -sub insert_collection_input { - die "insert_collection_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} -} - -sub delete_collection_input{ - -} - -# -# collection_output table fuctions -# -sub query_collection_output{ - +# secondary_input table functions +sub query_secondary_input{ + die "query_secondary_input not implemented in adaptor\n"; } -sub insert_collection_output { - die "insert_collection_output not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} +sub insert_secondary_input{ + die "insert_secondary_input not implemented in adaptor\n"; } -sub delete_collection_output{ - +sub delete_secondary_input{ + die "delete_secondary_input not implemented in adaptor\n"; } # # object table functions # sub query_object{ - + die "query_object not implemented in adaptor\n"; } sub insert_object{ - + die "insert_object not implemented in adaptor\n"; } sub delete_object{ - + die "delete_object not implemented in adaptor\n"; } # # object_term2term table functions # sub query_object_term2term{ - + die "query_object_term2term not implemented in adaptor\n"; } sub insert_object_term2term{ - + die "insert_object_term2term not implemented in adaptor\n"; } sub delete_object_term2term{ - + die "delete_object_term2term not implemented in adaptor\n"; } # -# relationship table functions +# service_instance table functions # -sub query_relationship{ - +sub query_service_instance { + die "query_service_instance not implemented in adaptor\n"; } -sub insert_relationship{ - +sub match_service_type_uri{ + die "match_service_type_uri not implemented in adaptor\n"; } -sub delete_relationship{ +sub insert_service_instance { + die "insert_service_instance not implemented in adaptor\n"; +} + +sub delete_service_intance{ + die "delete_service_intance not implemented in adaptor\n"; +} +# +# authority table functions +# +sub query_authority{ + die "query_authority not implemented in adaptor\n"; +} + +sub getUniqueAuthorityURI{ + die "getUniqueAuthorityURI not implemented in adaptor\n"; +} + +sub insert_authority{ + die "insert_authority not implemented in adaptor\n"; +} + +sub delete_authority{ + die "delete_authority not implemented in adaptor\n"; } # # service table fuctions # sub query_service{ - + die "query_service not implemented in adaptor\n"; } sub insert_service{ - + die "insert_service not implemented in adaptor\n"; } sub delete_service{ - + die "delete_service not implemented in adaptor\n"; } # # service_term2term table functions # sub query_service_term2term{ - + die "query_service_term2term not implemented in adaptor\n"; } sub insert_service_term2term{ - + die "insert_service_term2term not implemented in adaptor\n"; } sub delete_service_term2term{ - + die "delete_service_term2term not implemented in adaptor\n"; +} + +# +# relationship table functions +# +sub query_relationship{ + die "query_relationship not implemented in adaptor\n"; +} + +sub insert_relationship{ + die "insert_relationship not implemented in adaptor\n"; +} + +sub delete_relationship{ + die "delete_relationship not implemented in adaptor\n"; } # # namespace table functions # sub query_namespace{ - + die "query_namespace not implemented in adaptor\n"; } sub insert_namespace{ - + die "insert_namespace not implemented in adaptor\n"; } sub delete_namespace{ - + die "delete_namespace not implemented in adaptor\n"; } # # namespace_term2term table functions # sub query_namespace_term2term{ - + die "query_namespace_term2term not implemented in adaptor\n"; } sub insert_namespace_term2term{ - + die "insert_namespace_term2term not implemented in adaptor\n"; } sub delete_namespace_term2term{ - + die "delete_namespace_term2term not implemented in adaptor\n"; } -# secondary_input table functions -sub query_secondary_input{ - +# custom query subroutine for Moby::Central.pm->deregisterObjectClass() +sub checkClassUsedByService{ + die "checkClassUsedByService not implemented in adaptor\n"; } -sub insert_secondary_input{ - +# custom query routine for Moby::Central.pm -> deregisterNamespace() +sub checkNamespaceUsedByService{ + die "checkNamespaceUsedByService not implemented in adaptor\n"; } -sub delete_secondary_input{ - +# custom query routine for Moby::Central.pm -> findService() +sub checkKeywords{ + die "checkKeywords not implemented in adaptor\n"; } -# -# query term2term tables - queries relation between two tables -# -sub select_term2term{ - +# custom query subroutine for Moby::Central.pm->_searchForSimple() +sub getFromSimple{ + die "getFromSimple not implemented in adaptor\n"; +} + +# custom query subroutine for Moby::Central.pm->_searchForCollection() +sub getFromCollection{ + die "getFromCollection not implemented in adaptor\n"; +} + +# custom query subroutine for Moby::Central.pm->RetrieveServiceNames +sub getServiceNames{ + die "getServiceNames not implemented in adaptor\n"; +} + +# custom query for Moby::Central.pm->_flatten +sub getParentTerms{ + die "getParentTerms not implemented in adaptor\n"; +} + +# custom query subroutine for selecting from object_term2term and object tables +# used in Moby::OntologyServer.pm->retrieveObject() +sub getObjectRelationships{ + die "getObjectRelationships not implemented in adaptor\n"; +} + +# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() +# note: returns a reference to an array containing ARRAY references +sub getRelationship{ + die "getRelationship not implemented in adaptor\n"; +} + +sub _checkURI { + die "_checkURI not implemented in adaptor\n"; } sub _dump { From dwang at pub.open-bio.org Mon Jul 18 16:54:29 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 18 Jul 2005 12:54:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507181654.j6IGsTme016332@pub.open-bio.org> dwang Mon Jul 18 12:54:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv16306/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: minor changes to comments and indentation moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/15 16:39:11 1.13 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 16:54:29 1.14 @@ -1087,8 +1087,7 @@ } # custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection -{ +sub getFromCollection{ my ($self, @args) = @_; my $dbh = $self->dbh; my $inout = get_value('inout', @args); @@ -1120,8 +1119,7 @@ } # custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames -{ +sub getServiceNames{ my ($self, @args) = @_; my $dbh = $self->dbh; my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; @@ -1132,8 +1130,7 @@ } # custom query for Moby::Central.pm->_flatten -sub getParentTerms -{ +sub getParentTerms{ my ($self, @args) = @_; my $dbh = $self->dbh; From mwilkinson at pub.open-bio.org Mon Jul 18 22:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 18 Jul 2005 18:32:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182232.j6IMWK1W017179@pub.open-bio.org> mwilkinson Mon Jul 18 18:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv17143/MOBY Modified Files: OntologyServer.pm Log Message: fixing brackets and semicolons moby-live/Perl/MOBY OntologyServer.pm,1.51,1.52 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/15 16:40:45 1.51 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/18 22:32:20 1.52 @@ -684,9 +684,9 @@ my $insertid = $adaptor->insert_service({service_type => $args{'node'}}, {service_lsid => $LSID}, - {description => $args{'description'}, - {authority => $args{'authority'}, - {contact_email => $args{'contact_email'}); + {description => $args{'description'}}, + {authority => $args{'authority'}}, + {contact_email => $args{'contact_email'}}); unless ( $insertid ) { return ( 0, "Service creation failed for unknown reasons", '' ); @@ -1070,7 +1070,7 @@ return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_relationship({relationship_type => $term}, 'and' {ontology => $ontology}); + my $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ontology}); my $row = shift(@$result); my $id = $row->{relationship_lsid}; From mwilkinson at pub.open-bio.org Mon Jul 18 22:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 18 Jul 2005 18:32:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182232.j6IMWKUb017159@pub.open-bio.org> mwilkinson Mon Jul 18 18:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/Accessories In directory pub.open-bio.org:/tmp/cvs-serv17143/Accessories Removed Files: RESOURCES Log Message: fixing brackets and semicolons moby-live/Perl/Accessories RESOURCES,1.1,NONE rcsdiff: /home/repository/moby/moby-live/Perl/Accessories/RCS/RESOURCES,v: No such file or directory From mwilkinson at pub.open-bio.org Mon Jul 18 22:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 18 Jul 2005 18:32:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182232.j6IMWKIE017198@pub.open-bio.org> mwilkinson Mon Jul 18 18:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv17143/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing brackets and semicolons moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 16:54:29 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 22:32:20 1.15 @@ -173,7 +173,7 @@ my ($self, @args) = @_; my $dbh = $self->dbh; my $statement = get_value('statement', @args); - my $sth = $dbh->prepare($statement}; + my $sth = $dbh->prepare($statement); if (@args > 1) { my $bindvalues = get_value('bind_values', @args); @@ -183,7 +183,7 @@ $sth->execute; } my $result = $sth->fetchall_arrayref(); - return result; + return $result; } sub query_collection_input{ @@ -340,7 +340,7 @@ my @bindvalues = (); ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, - undef, @bindvalues ) + undef, @bindvalues ); if (dbh->err){ return (1, dbh->errstr); } @@ -693,8 +693,8 @@ sub getUniqueAuthorityURI{ my ($self, @args) = @_; my $dbh = $self->dbh; - $statement = "select distinct authority_uri from authority"; - $bindvalues = (); + my $statement = "select distinct authority_uri from authority"; + my @bindvalues = (); my $result = do_query($dbh, $statement, @bindvalues); return $result; } @@ -709,7 +709,7 @@ values (?,?,?)", undef, (get_value('authority_common_name', @args), - get_value('authority_uri' @args), + get_value('authority_uri', @args), get_value('contact_email', @args))); my $id = $dbh->{mysql_insertid}; return $id; @@ -976,9 +976,9 @@ my $dbh = $self->dbh; my $existingURI = get_value('namespace_type_uris', @args); my $term = get_value('term', @args); + my $errstr; -my $sth = - $dbh->prepare( + my $sth = $dbh->prepare( "select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" ); $sth->execute; @@ -988,12 +988,11 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } - $sth = - $dbh->prepare( + $sth = $dbh->prepare( "select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" ); $sth->execute; @@ -1002,7 +1001,7 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } @@ -1016,7 +1015,7 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } @@ -1030,11 +1029,11 @@ foreach (@nss) { $_ =~ s/\s//g; my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr); + return (1, $errstr) if ( $_ eq $existingURI ); } } - return (0, $errstr); + return (0, ""); } # custom query routine for Moby::Central.pm -> findService() @@ -1046,13 +1045,13 @@ my $searchstring; foreach my $kw ( @{ $findme{keywords} } ) { - $debug && &_LOG("KEYWORD $kw\n"); +# $debug && &_LOG("KEYWORD $kw\n"); $kw =~ s/\*//g; $kw = $dbh->quote("%$kw%"); $searchstring .= " OR description like $kw "; } $searchstring =~ s/OR//; # just the first one - $debug && &_LOG("search $searchstring\n"); +# $debug && &_LOG("search $searchstring\n"); my $statement = "select service_instance_id from service_instance where $searchstring"; my @bindvalues = (); @@ -1103,7 +1102,7 @@ where s.collection_${inout}_id IS NOT NULL AND s.collection_${inout}_id = c.collection_${inout}_id - AND object_type_uri = '$objectURI' " + AND object_type_uri = '$objectURI' "; my $nsquery; foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; From mwilkinson at pub.open-bio.org Mon Jul 18 22:46:00 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 18 Jul 2005 18:46:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507182246.j6IMk0oR017294@pub.open-bio.org> mwilkinson Mon Jul 18 18:46:00 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv17267/MOBY Modified Files: Central.pm secondary_input.pm service_instance.pm Log Message: fixing brackets and semicolons moby-live/Perl/MOBY Central.pm,1.159,1.160 secondary_input.pm,1.3,1.4 service_instance.pm,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.159 retrieving revision 1.160 diff -u -r1.159 -r1.160 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/13 21:53:11 1.159 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/18 22:46:00 1.160 @@ -22,14 +22,16 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::RDF::ServiceInstanceRDF; -use RDF::Core; -use RDF::Core::Model; -use RDF::Core::Literal; -use RDF::Core::Statement; -use RDF::Core::Model::Serializer; -use RDF::Core::Storage::Memory; -use RDF::Core::Constants qw(:xml :rdf :rdfs); +use MOBY::Client::Central; + +#use MOBY::RDF::ServiceInstanceRDF; +#use RDF::Core; +#use RDF::Core::Model; +#use RDF::Core::Literal; +#use RDF::Core::Statement; +#use RDF::Core::Model::Serializer; +#use RDF::Core::Storage::Memory; +#use RDF::Core::Constants qw(:xml :rdf :rdfs); use MOBY::MobyXMLConstants; my $debug = 0; @@ -1329,8 +1331,6 @@ "" ); } - - use MOBY::Client::Central; my $services = MOBY::Client::Central::_parseServices( '', '', $si ); my $service_instance = shift @{$services}; @@ -3423,7 +3423,7 @@ $output .= "\t\t\n"; } $result = $adaptor->query_collection_input({service_instance => $_}); - $sth_collection_ins->execute($_); +# $sth_collection_ins->execute($_); foreach my $row (@$result) { @@ -3485,7 +3485,7 @@ my $articlename = $row->{article_name}; $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id = $collid}); + my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id => $collid}); foreach my $row2 (@$result2 ) { my $objURI = $row2->{object_type_uri}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 16:53:03 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 22:46:00 1.4 @@ -113,6 +113,7 @@ my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $dbh = $self->dbh; my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, {maximum_value => $self->maximum_value}, {minimum_value => $self->minimum_value}, =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 16:53:03 1.12 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 22:46:00 1.13 @@ -354,6 +354,8 @@ my ($self) = @_; my $dbh = $self->dbh; my $authority; + $CONFIG ||= MOBY::Config->new; + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); my $row = shift(@$result); From senger at pub.open-bio.org Tue Jul 19 12:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxZv019448@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/Clients/help In directory pub.open-bio.org:/tmp/cvs-serv19358/src/Clients/help Modified Files: MobyCmdLineClient_usage.txt Log Message: moby-live/Java/src/Clients/help MobyCmdLineClient_usage.txt,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/help/MobyCmdLineClient_usage.txt,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/Clients/help/MobyCmdLineClient_usage.txt 2004/12/05 22:28:02 1.7 +++ /home/repository/moby/moby-live/Java/src/Clients/help/MobyCmdLineClient_usage.txt 2005/07/19 12:39:58 1.8 @@ -9,16 +9,17 @@ -e ia an endpoint of a Moby registry - (default: http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY-Central.pl) + (default: http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl) -uri is a URI defining Moby registry's namespace - (default: http://mobycentral.cbr.nrc.ca/MOBY/Central) + (default: http://mobycentral.icapture.ubc.ca/MOBY/Central) where specify what to ask a Moby registry to do: To get lists of various entities registered by Moby: -ls ... list names of all available services + -la ... list names of all available services sorted by authorities -lp ... list names of all available service providers -lt ... list names and descriptions of all service types -ln ... list names and descriptions of all namespaces From senger at pub.open-bio.org Tue Jul 19 12:39:58 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdwHn019429@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/Clients In directory pub.open-bio.org:/tmp/cvs-serv19358/src/Clients Modified Files: MobyCmdLineClient.java MobyGraphs.java Log Message: moby-live/Java/src/Clients MobyCmdLineClient.java,1.8,1.9 MobyGraphs.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java 2004/12/05 22:28:02 1.8 +++ /home/repository/moby/moby-live/Java/src/Clients/MobyCmdLineClient.java 2005/07/19 12:39:58 1.9 @@ -95,12 +95,29 @@ if (cmd.hasOption ("-ls")) { decorationLn ("Service names:"); decorationLn ("--------------"); - Map names = worker.getServiceNames(); + Map authorities = worker.getServiceNamesByAuthority(); - for (Iterator it = names.entrySet().iterator(); it.hasNext(); ) { + for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) { + Map.Entry entry = (Map.Entry)it.next(); + String[] names = (String[])entry.getValue(); + for (int i = 0; i < names.length; i++) { + System.out.println (names[i]); + System.out.println ("\t" + entry.getKey()); + } + } + } + + if (cmd.hasOption ("-la")) { + decorationLn ("Service names by authorities:"); + decorationLn ("-----------------------------"); + Map authorities = worker.getServiceNamesByAuthority(); + + for (Iterator it = authorities.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry)it.next(); System.out.println (entry.getKey()); - System.out.println ("\t" + entry.getValue()); + String[] names = (String[])entry.getValue(); + for (int i = 0; i < names.length; i++) + System.out.println ("\t" + names[i]); } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java 2004/11/12 23:09:02 1.7 +++ /home/repository/moby/moby-live/Java/src/Clients/MobyGraphs.java 2005/07/19 12:39:58 1.8 @@ -126,7 +126,55 @@ decorationLn ("Retrieving services..."); MobyService[] services = worker.getServices(); decorationLn ("Creating a graph of the services..."); - ServicesEdge[] edges = ServiceConnections.build (dataTypes, services); + ServicesEdge[] edges = null; + DataServiceEdge[] debugStartingEdges = null; + DataServiceEdge[] debugEndingEdges = null; + + // an undocumented option for debugging (see an + // example file in 'data' directory) + String xfile = cmd.getParam ("-X"); + boolean xfileing = (xfile != null); + + if (xfileing) { + Vector ev = new Vector(); + Vector evs = new Vector(); + Vector eve = new Vector(); + String line; + BufferedReader data = null; + data = new BufferedReader + (new InputStreamReader (new FileInputStream (xfile))); + while ((line = data.readLine()) != null) { + if (line.trim().equals ("")) continue; + if (line.trim().startsWith ("#")) continue; + String[] fields = StringUtils.split (line); + if (fields.length > 1) { + if (fields[0].equalsIgnoreCase ("start")) { + DataServiceEdge dse = new DataServiceEdge (new MobyDataType ("start"), + new MobyService (fields[1]), + ""); + evs.addElement (dse); + } else if (fields[1].equalsIgnoreCase ("end")) { + DataServiceEdge dse = new DataServiceEdge (new MobyService (fields[0]), + new MobyDataType ("end"), + ""); + eve.addElement (dse); + } else ev.addElement (new ServicesEdge (new MobyService (fields[0]), + new MobyService (fields[1]), + "")); + } + } + edges = new ServicesEdge[ev.size()]; + ev.copyInto (edges); + debugStartingEdges = new DataServiceEdge[evs.size()]; + evs.copyInto (debugStartingEdges); + debugEndingEdges = new DataServiceEdge[eve.size()]; + eve.copyInto (debugEndingEdges); + + } else { + edges = ServiceConnections.build (dataTypes, services); + } + + System.out.println ("EDGES: " + edges.length); // filter edges String[] authorities = null; @@ -144,13 +192,23 @@ } edges = FilterServices.filter (edges, authorities, serviceNames, depth); + System.out.println ("Filtered EDGES: " + edges.length); + + if (xfileing) { + System.out.println ("List of EDGES: "); + for (int i = 0; i < edges.length; i++) { + System.out.println ("\t" + edges[i].toString()); + } + } + if (cmd.hasParam ("-path")) { String[] pathEnds = cmd.getParam ("-path", 2); if (pathEnds[0] == null || pathEnds[1] == null) { System.err.println ("Missing value for parameter '-path'. It should be followed by two service names."); System.exit (1); } - edges = FilterServices.pathes (edges, pathEnds[0], pathEnds[1]); +// edges = FilterServices.pathes (edges, pathEnds[0], pathEnds[1]); + edges = FilterServices.pathes2 (edges, pathEnds[0], pathEnds[1]); if (edges == null) { System.err.println ("No connection found between '" + pathEnds[0] + "' and '" + pathEnds[1] + "'"); @@ -170,20 +228,62 @@ MobyPrimaryDataSimple sourceData = createSimpleData (pathEnds[0]); MobyPrimaryDataSimple targetData = createSimpleData (pathEnds[1]); - DataServiceEdge[] startingEdges = ServiceConnections.findStartingEdges (sourceData, dataTypes, services); - DataServiceEdge[] endingEdges = ServiceConnections.findEndingEdges (targetData, dataTypes, services); + DataServiceEdge[] startingEdges = null; + if (debugStartingEdges == null) + startingEdges = ServiceConnections.findStartingEdges (sourceData, dataTypes, services); + else + startingEdges = debugStartingEdges; + DataServiceEdge[] endingEdges = null; + if (debugEndingEdges == null) + endingEdges = ServiceConnections.findEndingEdges (targetData, dataTypes, services); + else + endingEdges = debugEndingEdges; + + System.out.println ("SE: " + startingEdges.length); + if (xfileing) { + for (int i = 0; i < startingEdges.length; i++) { + System.out.println ("\t" + startingEdges[i].toString()); + } + } + System.out.println ("EE: " + endingEdges.length); + if (xfileing) { + for (int i = 0; i < endingEdges.length; i++) { + System.out.println ("\t" + endingEdges[i].toString()); + } + } // this creates *all* pathes, but some of them have cycles and inside branches - separatePaths = FilterServices.dataPaths (startingEdges, edges, endingEdges); + separatePaths = FilterServices.dataPaths (startingEdges, edges, endingEdges); if (separatePaths.length == 0) { System.err.println ("No connection found between '" + pathEnds[0] + "' and '" + pathEnds[1] + "'"); System.exit(1); } + + System.out.println ("After dataPaths: " + separatePaths.length); + if (xfileing) { + for (int i = 0; i < separatePaths.length; i++) { + System.out.println ("Separate data path " + (i+1)); + for (int j = 0; j < separatePaths[i].length; j++) { + System.out.println ("\t" + separatePaths[i][j]); + } + } + } + allPaths = FilterServices.joinPaths (separatePaths); + System.out.println ("After joinPaths: " + allPaths.length); + if (xfileing) { + System.out.println ("Join paths: "); + for (int i = 0; i < allPaths.length; i++) { + System.out.println ("\t" + allPaths[i].toString()); + } + } + + // separate paths to straight paths (no cycles, no branches) + separatePaths = FilterServices.straightDataPaths (startingEdges, allPaths, endingEdges); - // this separate paths to straight paths (no cycles, no branches) - separatePaths = FilterServices.straightDataPaths (startingEdges, allPaths, endingEdges); + System.out.println ("After straightDataPaths: " + separatePaths.length); +// System.exit (1); } // create a graph (in whatever format) @@ -236,7 +336,7 @@ } else { graphs = new String [1]; - graphs[0] = Graphviz.createServicesGraph (allPaths, props); + graphs[0] = Graphviz.createServicesGraph (allPaths, props); } String fn = cmd.getParam ("-fs"); From senger at pub.open-bio.org Tue Jul 19 12:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxn1019586@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/xmls In directory pub.open-bio.org:/tmp/cvs-serv19358/xmls Modified Files: libraries.xml Log Message: moby-live/Java/xmls libraries.xml,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/libraries.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/xmls/libraries.xml 2005/05/19 20:18:54 1.1 +++ /home/repository/moby/moby-live/Java/xmls/libraries.xml 2005/07/19 12:39:59 1.2 @@ -8,7 +8,7 @@ - + From senger at pub.open-bio.org Tue Jul 19 12:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxK1019525@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv19358/src/main/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/06/17 19:25:31 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/19 12:39:59 1.8 @@ -1015,7 +1015,7 @@ * the maximum value of the secondary input * @param min * the minimum value of the secondary input * - * @param enum + * @param enumeration * the enumeration value for the secondary input */ From senger at pub.open-bio.org Tue Jul 19 12:39:58 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdwY1019377@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java In directory pub.open-bio.org:/tmp/cvs-serv19358 Modified Files: build.xml Log Message: moby-live/Java build.xml,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Java/build.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Java/build.xml 2005/05/19 20:18:53 1.16 +++ /home/repository/moby/moby-live/Java/build.xml 2005/07/19 12:39:58 1.17 @@ -207,11 +207,13 @@ @@ -256,7 +258,7 @@ @@ -501,13 +502,28 @@ - Tomcat Catalina not found. - Please set environment variable CATALINA_HOME to point to it, or - create a file 'build.properties' and put there the line: - catalina.home = <location of your CATALINA> - (do not include '<' and '>' there) + + Tomcat Catalina not found. + ----------------------------------- + Please set environment variable CATALINA_HOME to point to it, or + create a file 'build.properties' and put there the line: + catalina.home = <location of your CATALINA> + (do not include '<' and '>' there) - + + + + + + + + + Tomcat does not seem to be running. + ----------------------------------- + I have just checked ${tomcat.host}:${tomcat.port}... + You may perhaps consider to start it. + + @@ -606,6 +622,9 @@ + + @@ -626,7 +645,7 @@ - + From senger at pub.open-bio.org Tue Jul 19 12:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdx99019544@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv19358/src/main/org/biomoby/shared Modified Files: Central.java Log Message: moby-live/Java/src/main/org/biomoby/shared Central.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java 2005/04/07 16:37:02 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/Central.java 2005/07/19 12:39:59 1.10 @@ -28,20 +28,6 @@ * * http://biomoby.org. *

- * - *

Last changes (in backwards order)
- *
    - *
  • New methods retrieving location of a Moby registry have been added: - * {@link #getRegistryEndpoint}, - * {@link #getRegistryNamespace}, - *
  • Added new constants defining relationship types as integers. - *
  • New methods retrieving various types of relationships have been added: - * {@link #getDataTypeRelationships}, - * {@link #getServiceTypeRelationships} - *
  • Added constants defining recognizable relationship types - * ({@link #ISA}, {@link #HASA}, {@link #HAS}) - *
- *

* @author Martin Senger * @version $Id$ */ @@ -81,8 +67,13 @@ static final int iHAS = 3; /************************************************************************** - * Get a (redundant) list of all registered service names. - *

+ * Get a (redundant) list of all registered service names.

+ * + * @deprecated Replaced by {@link + * #getServiceNamesByAuthority}. The reason is that this method + * returns a random result if there are more services with the + * same name but belonging to different authorities.

+ * * @return a hash table where keys are names of services while * values are their authorities * @throws MobyException if communication with the Moby Registry fails @@ -91,6 +82,20 @@ throws MobyException; /************************************************************************** + * Get a list of all authorities - and for each of them a list of + * their registered service names.

+ * + * This method is a better replacement for the deprecated method + * {@link #getServiceNames}.

+ * + * @return a hash table where keys are authority names and values + * are arrays of service names provided by each authority + * @throws MobyException if communication with the Moby Registry fails + *************************************************************************/ + Map getServiceNamesByAuthority() + throws MobyException; + + /************************************************************************** * Get the list of all providers (each provider is represented by an * authority's URI. *

From senger at pub.open-bio.org Tue Jul 19 12:39:58 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdwhD019404@pub.open-bio.org> senger Tue Jul 19 08:39:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv19358/docs Modified Files: 3rdPartyLibraries.html ChangeLog Download.html Added Files: CVS.html Log Message: moby-live/Java/docs CVS.html,NONE,1.1 3rdPartyLibraries.html,1.2,1.3 ChangeLog,1.30,1.31 Download.html,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/3rdPartyLibraries.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/docs/3rdPartyLibraries.html 2005/05/19 20:25:40 1.2 +++ /home/repository/moby/moby-live/Java/docs/3rdPartyLibraries.html 2005/07/19 12:39:58 1.3 @@ -10,20 +10,47 @@

Third-party Libraries Guidelines

-Comming soon.. -

+The third-party libraries are (mostly) .jar files whose +source code is not included in the jMoby CVS repository.

-For now, just look into xmls/libraries.xml - and it's almost -self-explanatory... +Neither their binary code (classes themselves). That's why the jMoby's +Ant tasks need to get it first from some remote repository. The +question is where is such remote repository and how to update it (if +needed). This document explains that.

+ +The third-party jar files are retrievable by HTTP protocol +from the place that is defined in the Ant property remote.dir +in the xmls/libraries file. In the same file, there is also a +full list of the third-party libraries needed in jMoby. If you need to +add a library, put it there (the name must appear in three places in +that file, actually).

+ +However, to put the new name there, it is not enough. You need also to +add such new jar file into the remote repository (or to +update there one if you wish jMoby to use a newer version). In order +to do that, you need to check-out and update/commit to the CVS module +jars-archive (note that you do not need to do this +if you are just using jMoby, or developing with jMoby). The module is +located together with other Biomoby CVS modules - so follow the normal +way: + +

+export CVS_RSH=ssh
+cvs -d :ext:your-user-name at pub.open-bio.org:/home/repository/moby co -P jars-archive
+
+ +Once you have committed there a new library, or a new version of an +existing library, you need to wait until it is propagated to the place +indicated by the remote.dir. This is done by a cron job that +runs at 20 past the hour every other hour.

-


Martin Senger
-Last modified: Thu May 19 20:35:23 2005 +Last modified: Tue Jul 19 14:16:23 2005
=================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/05/19 20:18:53 1.30 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/07/19 12:39:58 1.31 @@ -1,3 +1,16 @@ +2005-07-19 Martin Senger + + * Changed the remote repository for the third-party jar files. + + * Added a new option -la to the MobyCmdLineClient to list services + by authorities. + + * Added new method getServiceNamesByAuthority() to the + Central.java interface. getServiceNames() deprecated. + + * Default location and namespace of the Moby Central has been + changed (in CentralImpl.java). + 2005-05-19 Martin Senger * Updated build.xml; also separate some fragments into xmls =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Download.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/docs/Download.html 2005/05/19 20:18:53 1.4 +++ /home/repository/moby/moby-live/Java/docs/Download.html 2005/07/19 12:39:58 1.5 @@ -42,9 +42,10 @@

Using jMoby from CVS

-Once you checked out your local CVS copy, go to the -moby-live/Java subdirectory. All directory and files names -used below assume that you are in this directory.

+Once you checked out your local CVS copy (here is how to do it), go to the moby-live/Java +subdirectory. All directory and files names used below assume that you +are in this directory.

How to build it
@@ -367,7 +368,7 @@
Martin Senger
-Last modified: Thu May 19 19:07:17 2005 +Last modified: Tue Jul 19 11:34:08 2005
From gordonp at pub.open-bio.org Tue Jul 19 12:59:21 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Tue, 19 Jul 2005 08:59:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191259.j6JCxLDe019685@pub.open-bio.org> gordonp Tue Jul 19 08:59:21 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory pub.open-bio.org:/tmp/cvs-serv19660 Modified Files: MobyDataSecondaryInstance.java Log Message: Changed data type variable name to not overshadow protected variable declaration in parent class moby-live/Java/src/main/org/biomoby/shared/data MobyDataSecondaryInstance.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/05/12 04:59:49 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/07/19 12:59:21 1.2 @@ -8,7 +8,7 @@ public class MobyDataSecondaryInstance extends MobySecondaryData{ protected String dataValue = null; - protected MobySecondaryData dataType = null; + protected MobySecondaryData secDataType = null; public MobyDataSecondaryInstance(MobySecondaryData type, String value){ this(type); @@ -26,7 +26,7 @@ setDefaultValue(type.getDefaultValue()); setMinimumValue(type.getMinimumValue()); setMaximumValue(type.getMaximumValue()); - dataType = type; + secDataType = type; } public void setValue(String value) throws IllegalArgumentException{ @@ -39,7 +39,7 @@ public String toXML(){ return " " + dataValue + "\n"; } } From senger at pub.open-bio.org Tue Jul 19 12:39:59 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 08:39:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191239.j6JCdxlX019566@pub.open-bio.org> senger Tue Jul 19 08:39:59 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory pub.open-bio.org:/tmp/cvs-serv19358/src/main/org/biomoby/shared/data Modified Files: MobyDataObject.java Log Message: moby-live/Java/src/main/org/biomoby/shared/data MobyDataObject.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/07/19 12:39:59 1.3 @@ -88,7 +88,7 @@ * will also parse a MOBY XML Object wrapped in a Simple tag when the Simple * is passed in as the main element. * - * @param the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag + * @param objectTag the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag */ public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws IllegalArgumentException{ MobyDataObject object = null; From senger at pub.open-bio.org Tue Jul 19 13:08:31 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:08:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191308.j6JD8VRn019766@pub.open-bio.org> senger Tue Jul 19 09:08:31 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv19747/docs Modified Files: Download.html Log Message: moby-live/Java/docs Download.html,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/Download.html,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/docs/Download.html 2005/07/19 12:39:58 1.5 +++ /home/repository/moby/moby-live/Java/docs/Download.html 2005/07/19 13:08:31 1.6 @@ -272,11 +272,9 @@ some specific features. (Remember, however, that you can always get everything in one go from the CVS repository.)

-The binary distributions are available either from the main jMoby site (located on the same place as the main -BioMoby pages), or from http://industry.ebi.ac.uk/~senger/jMoby/dist/. -

+BioMoby pages).

Command-line clients exploring BioMoby
@@ -368,7 +366,7 @@
Martin Senger
-Last modified: Tue Jul 19 11:34:08 2005 +Last modified: Tue Jul 19 14:52:57 2005
From senger at pub.open-bio.org Tue Jul 19 13:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGrTt019848@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs/dist In directory pub.open-bio.org:/tmp/cvs-serv19810/docs/dist Modified Files: _README_ Log Message: moby-live/Java/docs/dist _README_,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/dist/_README_,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/docs/dist/_README_ 2004/12/05 22:28:02 1.3 +++ /home/repository/moby/moby-live/Java/docs/dist/_README_ 2005/07/19 13:16:53 1.4 @@ -1,6 +1,5 @@ This is a distribution directory of jMoby project. -More details in http://www.biomoby.org/moby-live/Java/docs/index.html -Mirror: http://industry.ebi.ac.uk/~senger/jMoby/ +More details in http://www.biomoby.org/moby-live/Java/docs/index.html. Binary distribution has everything except sources and Ant files to build things: @@ -24,7 +23,7 @@ -------------------------------------------------------------------- File: README Comments to the biomoby mailing lists, or directly to -Martin Senger (senger at ebi.ac.uk). +Martin Senger (martin.senger at gmail.com). $Id$ -------------------------------------------------------------------- From senger at pub.open-bio.org Tue Jul 19 13:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGroI019829@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java In directory pub.open-bio.org:/tmp/cvs-serv19810 Modified Files: README Log Message: moby-live/Java README,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/README,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/README 2004/12/05 22:28:01 1.8 +++ /home/repository/moby/moby-live/Java/README 2005/07/19 13:16:53 1.9 @@ -8,7 +8,7 @@ Find more in docs/index.html. If you do not want to build it you can use the binary distribution -which is available at http://industry.ebi.ac.uk/~senger/jMoby/dist/. +which is available at http://www.biomoby.org/moby-live/Java/docs/dist/. HOW TO BUILD IT --------------- From senger at pub.open-bio.org Tue Jul 19 13:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGruI019907@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory pub.open-bio.org:/tmp/cvs-serv19810/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/19 12:39:59 1.12 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/19 13:16:53 1.13 @@ -45,7 +45,7 @@ * MOBY format. It depends on * having already retrieved the definition of the Web service via * the MOBY central registry using the - * jMOBY API, + * jMOBY API, * and for now it uses the * Apache * Axis Web services framework, as well as Apache Xalan. There are code comments for the From senger at pub.open-bio.org Tue Jul 19 13:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGrYj019888@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/lib In directory pub.open-bio.org:/tmp/cvs-serv19810/lib Modified Files: README Log Message: moby-live/Java/lib README,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/lib/README,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/lib/README 2003/11/08 00:27:24 1.4 +++ /home/repository/moby/moby-live/Java/lib/README 2005/07/19 13:16:53 1.5 @@ -1,7 +1,7 @@ -------------------------------------------------------------------- File: README Comments to the biomoby mailing lists, or directly to Martin Senger -(senger at ebi.ac.uk). +(martin.senger at gmail.com). $Id$ -------------------------------------------------------------------- @@ -10,7 +10,7 @@ separate subdirectory) can be fetched automatically from a remote site. This is usually done by calling build.sh (which uses ant's target 'gather' to do it). The remote site that is used is defined in -the build.xml. +the xmls/libraries.xml. You are, of course, free to fetch them manually in any convenient time and from any convenient site. Doing that may be even more correct way @@ -24,26 +24,3 @@ build-dev.bat) (instead of build.sh or build.bat). Of course, time to time it is worth to use the build.sh (build.bat) script again to make sure that you have the latest versions of all fetched files. - -Files: -====== -* alltools.jar - A set of various tools and utilities. - Sources and documentation are available from - http://industry.ebi.ac.uk/~senger/tools/ - -* xerces*.jar, xml*.jar. - Library for SAX/DOM parser. They come from Apache Xerces-2.3.0. - -* axis-ant.jar, commons-discovery.jar, commons-logging.jar, jaxrpc.jar - wsdl4j.jar, axis.jar, log4j-1.2.4.jar, saaj.jar. - Libraries from the Apache Axis project (a toolkit for the SOAP protocol). - -* servlet.jar, activation.jar - Libraries dealing with servlets. They come from Apache Tomcat project. - -* jena.jar, adenine.jar - Libraries from 'haystack' (IBM) for producing RDF files. - They can be fetched from here: - http://www.ai.mit.edu/people/dquan/adenine.jar - http://www.ai.mit.edu/people/dquan/jena.jar From senger at pub.open-bio.org Tue Jul 19 13:16:53 2005 From: senger at pub.open-bio.org (Martin Senger) Date: Tue, 19 Jul 2005 09:16:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191316.j6JDGrch019868@pub.open-bio.org> senger Tue Jul 19 09:16:53 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs/graphs In directory pub.open-bio.org:/tmp/cvs-serv19810/docs/graphs Modified Files: index.html Log Message: moby-live/Java/docs/graphs index.html,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/graphs/index.html,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/docs/graphs/index.html 2004/10/18 14:35:05 1.4 +++ /home/repository/moby/moby-live/Java/docs/graphs/index.html 2005/07/19 13:16:53 1.5 @@ -38,7 +38,7 @@ you have a popular Graphviz tool installed on your machine (the tool is available for many platforms). Just download the latest - binary distribution + binary distribution of jMoby (see details in jMoby main documentation.

@@ -129,7 +129,7 @@

Suggestions, comments, and bug reports to:
Martin Senger
-Last modified: Mon Oct 18 12:33:26 2004 +Last modified: Tue Jul 19 15:06:47 2005
From mwilkinson at pub.open-bio.org Tue Jul 19 14:33:46 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 10:33:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191433.j6JEXklc020185@pub.open-bio.org> mwilkinson Tue Jul 19 10:33:46 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20166/Perl/MOBY Modified Files: Central.pm Log Message: temporarily removing all LSID code to get a fresh start moby-live/Perl/MOBY Central.pm,1.160,1.161 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.160 retrieving revision 1.161 diff -u -r1.160 -r1.161 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/18 22:46:00 1.160 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/19 14:33:46 1.161 @@ -1340,7 +1340,7 @@ #model => $model, #service_instance => $service_instance ); # my $RDF_XML = $RDF_MODEL->serialize; - my $LSID = $service_instance->LSID; + #my $LSID = $service_instance->LSID; # my $RDF = _getServiceInstanceRDF($LSID); my $RDF = ""; @@ -1359,7 +1359,7 @@ sub _getServiceInstanceRDF { my ( $self, $LSID ) = @_; - my $lsid = LS::ID->new($LSID); + #my $lsid = LS::ID->new($LSID); my $RDF_XML = ""; my $lsid_error = ""; my $lsid_good = 1; @@ -1369,38 +1369,38 @@ #use LS::Client::BasicResolver; #use LS::Locator; - my $resolver = LS::Client::BasicResolver->new(); - my $authority = $resolver->resolve( lsid => $lsid ); - unless ($authority) { - $lsid_error .= "The authority for $LSID could not be located"; + #my $resolver = LS::Client::BasicResolver->new(); + #my $authority = $resolver->resolve( lsid => $lsid ); + #unless ($authority) { + # $lsid_error .= "The authority for $LSID could not be located"; + + #} + #return $lsid_error unless $authority; + #$authority->clean_cache(); + +# my $resource = $authority->getResource($lsid); +# unless ($resource) { +# $lsid_error .= $authority->error_string . " "; +# return $lsid_error; +# } - } - return $lsid_error unless $authority; - $authority->clean_cache(); - - my $resource = $authority->getResource($lsid); - unless ($resource) { - $lsid_error .= $authority->error_string . " "; - return $lsid_error; - } - - my $response = $resource->get_metadata; - unless ( ref($response) =~ /LS::Service::Response/ ) { +# my $response = $resource->get_metadata; +# unless ( ref($response) =~ /LS::Service::Response/ ) { #TODO raise an error - $lsid_error .= "Metadata response didn't come back"; - return $lsid_error; - } +# $lsid_error .= "Metadata response didn't come back"; +# return $lsid_error; +# } - my $rsp = $response->response; - unless ( ref($rsp) =~ /IO::File/ ) { +# my $rsp = $response->response; +# unless ( ref($rsp) =~ /IO::File/ ) { #TODO raise an error - $lsid_error .= "metadata response was not a filehandle"; - } - while (<$rsp>) { - $RDF_XML .= $_; - } +# $lsid_error .= "metadata response was not a filehandle"; +# } +# while (<$rsp>) { +# $RDF_XML .= $_; +# } return $RDF_XML } From mwilkinson at pub.open-bio.org Tue Jul 19 14:33:47 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 10:33:47 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191433.j6JEXlVY020205@pub.open-bio.org> mwilkinson Tue Jul 19 10:33:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv20166/Perl/MOBY/Client Modified Files: Central.pm Log Message: temporarily removing all LSID code to get a fresh start moby-live/Perl/MOBY/Client Central.pm,1.97,1.98 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.97 retrieving revision 1.98 diff -u -r1.97 -r1.98 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/05/30 22:54:43 1.97 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 14:33:46 1.98 @@ -1725,7 +1725,7 @@ my $Service = $Services->get_node($x); my $AuthURI = $Service->getAttributeNode('authURI')->getValue; my $servicename = $Service->getAttributeNode('serviceName')->getValue; - my $lsid = $Service->getAttributeNode('lsid')->getValue; + #my $lsid = $Service->getAttributeNode('lsid')->getValue; my $Type = &_nodeTextContent( $Service, 'serviceType' ); my $authoritative = &_nodeTextContent( $Service, 'authoritative' ); my $contactEmail = &_nodeTextContent( $Service, 'contactEmail' ); @@ -1789,7 +1789,7 @@ authority => $AuthURI, authoritative => $authoritative, URL => $URL, - LSID => $lsid, + #LSID => $lsid, contactEmail => $contactEmail, name => $servicename, type => $Type, From kawas at pub.open-bio.org Tue Jul 19 15:28:28 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:28:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191528.j6JFSSbc020394@pub.open-bio.org> kawas Tue Jul 19 11:28:28 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms In directory pub.open-bio.org:/tmp/cvs-serv20365/org/biomoby/client/ui/graphical/servlet/forms Modified Files: GetSignatureRDFResponse.java GetSignatureRDFForm.java Log Message: changed the mobycentral registry to become the new one. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms GetSignatureRDFResponse.java,1.2,1.3 GetSignatureRDFForm.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java 2005/04/07 21:02:01 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFResponse.java 2005/07/19 15:28:28 1.3 @@ -47,7 +47,7 @@ + "

Unable to update your information

\r\n" + "
\r\n" + "

Make sure that you specify a valid signature url! This field looks like the following: http://myAuthority.domain/path/to/rdf/for/service. Also make sure that you have specified the right case-sensitive service name, if applicable.

\r\n" - + "

Back

\r\n" + + "

Back

\r\n" + "
\r\n" + "\r\n" + ""; protected void doGet(HttpServletRequest request, @@ -100,10 +100,10 @@ if (name.equals("")) { System.out.println("empty name"); - con = "http://mobycentral.cbr.nrc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + con = "http://mobycentral.icapture.ubc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + domain + "&URL=" + sigURL; } else { - con = "http://mobycentral.cbr.nrc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + con = "http://mobycentral.icapture.ubc.ca/cgi-bin/updateSignatureURL.cgi?authURI=" + domain + "&URL=" + sigURL + "&serviceName=" + name; } URL url = new URL(con); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java 2005/04/07 21:02:01 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/forms/GetSignatureRDFForm.java 2005/07/19 15:28:28 1.3 @@ -34,7 +34,7 @@ // some useful variables private final String newline = System.getProperty("line.separator"); - private static final String DOMAIN = "mobycentral.cbr.nrc.ca:8090"; + private static final String DOMAIN = "mobycentral.icapture.ubc.ca:8090"; /* (non-Javadoc) * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) @@ -169,6 +169,7 @@ central = new CentralImpl(); domains = central.getProviders(); } catch (MobyException e) { + e.printStackTrace(); return; } // sort the array From kawas at pub.open-bio.org Tue Jul 19 15:29:32 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:29:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191529.j6JFTWuc020448@pub.open-bio.org> kawas Tue Jul 19 11:29:32 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes In directory pub.open-bio.org:/tmp/cvs-serv20423/org/biomoby/client/ui/graphical/servlet/jTypes Modified Files: Types.java Log Message: removed a print statement that eluded me for years (months... okay weeks!) Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes Types.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes/Types.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes/Types.java 2005/04/07 16:42:30 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jTypes/Types.java 2005/07/19 15:29:32 1.2 @@ -35,7 +35,6 @@ p = Pattern.compile("/types/Services\\S*"); m = p.matcher(path); if (m.matches()) { - System.out.println("Matching services ..."); // get Services response.setContentType("text/plain"); PrintWriter out = response.getWriter(); @@ -46,7 +45,6 @@ response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, e.getLocalizedMessage()); return; } - System.out.println("done"); return; } p = Pattern.compile("/types/Namespaces\\S*"); From kawas at pub.open-bio.org Tue Jul 19 15:32:54 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:32:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191532.j6JFWs6r020518@pub.open-bio.org> kawas Tue Jul 19 11:32:54 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources In directory pub.open-bio.org:/tmp/cvs-serv20493/org/biomoby/client/ui/graphical/servlet/jresources Modified Files: RESOURCE.java Log Message: Code has mobycentral registry domain changes, as well as certain todo statements have been excised. The next version should a way to retrieve information regarding the BioMoby predicate vocabulary. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources RESOURCE.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/06/09 17:39:00 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/07/19 15:32:54 1.7 @@ -19,6 +19,7 @@ import org.biomoby.client.CentralDigestImpl; import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; +import org.biomoby.client.rdf.vocabulary.XMLTypes; import org.biomoby.registry.definitions.types.JNamespaces; import org.biomoby.registry.definitions.types.JObjects; import org.biomoby.registry.definitions.types.JServices; @@ -165,7 +166,7 @@ * @see javax.servlet.GenericServlet#init() */ public final void init() throws ServletException { - super.init(); + // super.init(); } protected final void doGet(HttpServletRequest request, @@ -366,8 +367,8 @@ .getURL())); subject.addProperty(DC.identifier, model .createTypedLiteral("urn:lsid:" - + properties.getProperty("lsid_domain") - + ":serviceinstance:" + services[i].getAuthority() + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_authority") + ":" + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_namespace") + ":" +services[i].getAuthority() + "," + services[i].getName())); subject.addProperty(Predicates.performs_task, model .createResource(SRV + services[i].getType())); @@ -783,7 +784,9 @@ Pattern p = Pattern.compile("urn:lsid.*:(\\S+)$"); Matcher m = p.matcher(thing); String label = (m.matches() ? m.group(1) : thing); + //TODO - add the ofType property if thing is String, Float, Integer, DataTime. Resource resource = model.createResource(ns + thing); + addOfTypeProperty(model, resource, thing); model.add(model.createStatement(resource, RDF.type, RDFS.Class)); model.add(model.createStatement(resource, RDFS.label, model .createLiteral(label, "en"))); @@ -792,7 +795,30 @@ return resource; } - private final String getTypes(String type) throws MobyException { + /** + * @param model + * @param resource + * @param thing + */ + private void addOfTypeProperty(Model model, Resource resource, String name) { + // make sure that we declare the ns for the datatype + Map map = model.getNsPrefixMap(); + if (!map.containsValue(XMLTypes.getURI())) { + map.put(XMLTypes.getPrefix(), XMLTypes.getURI()); + } + model.setNsPrefixes(map); + if (name.equalsIgnoreCase("string")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_STRING)); + } else if (name.equalsIgnoreCase("integer")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_INTEGER)); + } else if (name.equalsIgnoreCase("float")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_FLOAT)); + } else if (name.equalsIgnoreCase("datatime")) { + model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_DATE_TIME)); + } + } + + private final String getTypes(String type) throws MobyException { if (type.equalsIgnoreCase("objects")) { try { return new JObjects().getObjects(); @@ -800,7 +826,7 @@ e.printStackTrace(); } // resort to a secondary method for retrieval of JObjects - return getURL("http://mobycentral.cbr.nrc.ca:8090/types/Objects"); + return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Objects"); } else if (type.equalsIgnoreCase("services")) { try { return new JServices().getServices(); @@ -808,7 +834,7 @@ e.printStackTrace(); } // resort to a secondary method for retrieval of JServices - return getURL("http://mobycentral.cbr.nrc.ca:8090/types/Services"); + return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Services"); } else if (type.equalsIgnoreCase("namespaces")) { try { return new JNamespaces().getNamespaces(); @@ -816,7 +842,7 @@ e.printStackTrace(); } // resort to a secondary method for retrieval of JNamespaces - return getURL("http://mobycentral.cbr.nrc.ca:8090/types/Namespaces"); + return getURL("http://mobycentral.icapture.ubc.ca:8090/types/Namespaces"); } return ""; } @@ -925,7 +951,7 @@ } public static void main(String[] args) throws MobyException { - System.out.println(new RESOURCE().getRESOURCES("ServiceInstances")); + System.out.println(new RESOURCE().getRESOURCES("Objects")); } } From kawas at pub.open-bio.org Tue Jul 19 15:44:11 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:44:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191544.j6JFiB5Q020750@pub.open-bio.org> kawas Tue Jul 19 11:44:10 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool In directory pub.open-bio.org:/tmp/cvs-serv20713/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool Modified Files: InputOutputFocusListener.java MobyInputOutputData.java ServiceInstancePanelFactory.java Service.java Log Message: Fixed a bug that occured upon registration of secondary inputs. ALso switch registry domains. moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool InputOutputFocusListener.java,1.3,1.4 MobyInputOutputData.java,1.1,1.2 ServiceInstancePanelFactory.java,1.2,1.3 Service.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/InputOutputFocusListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/InputOutputFocusListener.java 2005/04/20 21:42:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/InputOutputFocusListener.java 2005/07/19 15:44:10 1.4 @@ -50,7 +50,7 @@ if (_name.equals("name")) { InputOutputFocusListener.name = ((JTextField) (fe.getComponent())).getText(); - } else if (_name.equals("enumeration")) { + } else if (_name.equals("enum")) { InputOutputFocusListener.enumeration = ((JTextField) (fe.getComponent())).getText(); secondaryEnumerationField = (JTextField) (fe.getComponent()); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/MobyInputOutputData.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/MobyInputOutputData.java 2005/04/07 16:42:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/MobyInputOutputData.java 2005/07/19 15:44:10 1.2 @@ -34,10 +34,10 @@ * Variables for the test database. */ static final String ENDPOINT = - "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; + "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; static final String NAMESPACE = - "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; - private static String _URL = "http://mobycentral.cbr.nrc.ca/cgi-bin/applets/retrieveObjectXML.cgi?name="; + "http://mobycentral.icapture.ubc.ca/MOBY/Central"; + private static String _URL = "http://mobycentral.icapture.ubc.ca/cgi-bin/applets/retrieveObjectXML.cgi?name="; /** * =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/ServiceInstancePanelFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/ServiceInstancePanelFactory.java 2005/04/07 21:01:13 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/ServiceInstancePanelFactory.java 2005/07/19 15:44:10 1.3 @@ -43,7 +43,7 @@ private JButton edit; private JButton submit = null; - private static String datatype = "INT"; + private static String datatype = "Integer"; private JList namespaceDropdownList, enumerations; private DefaultListModel model = new DefaultListModel(), _enums = new DefaultListModel(); @@ -1161,8 +1161,8 @@ scrollingList.setPreferredSize(dim); scrollingList.setWheelScrollingEnabled(true); - JComboBox combo = new JComboBox(new String[] { "INT", "FLOAT", - "STRING", "DATE/TIME" }); + JComboBox combo = new JComboBox(new String[] { "Integer", "Float", + "String", "DateTime" }); combo.addActionListener(ioal); combo.setActionCommand("datatype"); combo.setName("datatype"); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/Service.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/Service.java 2005/04/07 21:01:13 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceInstanceCreationTool/Service.java 2005/07/19 15:44:10 1.3 @@ -27,9 +27,9 @@ private boolean PROTO = false; - static final String ENDPOINT = "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; + static final String ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; - static final String NAMESPACE = "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; + static final String NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; public static String REG_TEXT = ""; @@ -82,7 +82,7 @@ worker = new CentralImpl(CentralImpl.DEFAULT_ENDPOINT, CentralImpl.DEFAULT_NAMESPACE); worker.registerService(this); - success = true; + success = true || true; REG_TEXT = "Service has been registered!"; } catch (MobyException e) { From kawas at pub.open-bio.org Tue Jul 19 15:50:44 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:50:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191550.j6JFoiMg020800@pub.open-bio.org> kawas Tue Jul 19 11:50:43 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool In directory pub.open-bio.org:/tmp/cvs-serv20775/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool Modified Files: ServiceTypeApplet.java Log Message: changed the mobycentral registry to become the new one. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool ServiceTypeApplet.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool/ServiceTypeApplet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool/ServiceTypeApplet.java 2005/04/07 16:42:29 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/serviceTypeCreationTool/ServiceTypeApplet.java 2005/07/19 15:50:43 1.2 @@ -107,9 +107,9 @@ private JFrame frame = null; - static final String ENDPOINT = "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; + static final String ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; - static final String NAMESPACE = "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; + static final String NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; /** * This method initializes From kawas at pub.open-bio.org Tue Jul 19 15:51:50 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:51:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191551.j6JFposr020854@pub.open-bio.org> kawas Tue Jul 19 11:51:50 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority In directory pub.open-bio.org:/tmp/cvs-serv20829/org/biomoby/client/ui/graphical/servlet/lsid/authority Modified Files: Test.java Log Message: turned caching off in this test lsid client. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority Test.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/Test.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/Test.java 2005/04/20 21:42:10 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/lsid/authority/Test.java 2005/07/19 15:51:50 1.3 @@ -30,10 +30,12 @@ * @throws LSIDException */ public static void main(String[] args) throws LSIDException { - String lsid_to_use = "urn:lsid:biomoby.org:objectclass:DNASequence";//"urn:lsid:biomoby.org:objectclass:DNASequence"; + String lsid_to_use = "urn:lsid:biomoby.org:objectclass:DNASequence"; LSID lsid = new LSID(lsid_to_use); LSIDResolver resolver = new LSIDResolver(lsid); + resolver.setUseLocalCache(false); String output = lsid.toString() + "\n"; + System.out.println(resolver.getWSDLWrapper().toString()); try { LSIDWSDLWrapper wrapper = resolver.getWSDLWrapper(); // get metadata From kawas at pub.open-bio.org Tue Jul 19 15:54:02 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:54:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191554.j6JFs2Xd020974@pub.open-bio.org> kawas Tue Jul 19 11:54:02 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder In directory pub.open-bio.org:/tmp/cvs-serv20945/org/biomoby/client/rdf/builder Modified Files: ServiceInstanceRDF.java RDFConfigure.java Log Message: changed the way certain properties are accessed. Also updated the registry domain. ofType predicate added to datatypes as well. moby-live/Java/src/main/org/biomoby/client/rdf/builder ServiceInstanceRDF.java,1.4,1.5 RDFConfigure.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/06/09 17:35:59 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/07/19 15:54:02 1.5 @@ -15,13 +15,13 @@ import org.biomoby.registry.properties.MobyProperties; import org.biomoby.shared.Central; import org.biomoby.shared.MobyData; -import org.biomoby.shared.data.MobyDataSecondaryInstance; import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyNamespace; import org.biomoby.shared.MobyPrimaryDataSet; import org.biomoby.shared.MobyPrimaryDataSimple; import org.biomoby.shared.MobySecondaryData; import org.biomoby.shared.MobyService; +import org.biomoby.shared.data.MobyDataSecondaryInstance; import com.hp.hpl.jena.rdf.model.Bag; import com.hp.hpl.jena.rdf.model.Model; @@ -296,8 +296,8 @@ .getURL())); subject.addProperty(DC.identifier, model .createTypedLiteral("urn:lsid:" - + properties.getProperty("lsid_domain") - + ":serviceinstance:" + services[i].getAuthority() + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_authority") +":" + + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_namespace") +":"+ services[i].getAuthority() + "," + services[i].getName())); subject.addProperty(Predicates.performs_task, model .createResource(SRV + services[i].getType())); @@ -488,7 +488,7 @@ return stream.getOutput(); } - + /* * convenience method that adds a resource to a model */ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/05/31 18:11:07 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/07/19 15:54:02 1.3 @@ -132,6 +132,14 @@ str = str.substring(0, str.indexOf("~")); newResource.addProperty(RDFS.label, rdf.createLiteral(str, "en")); } + // TODO - add the ofType property if it exists + if (sourceResource.hasProperty(Predicates.ofType)) { + String str = sourceResource.getProperty(Predicates.ofType).getObject() + .toString(); + if (str.indexOf("~") != -1) + str = str.substring(0, str.indexOf("~")); + newResource.addProperty(Predicates.ofType, str); + } if (sourceResource.hasProperty(RDFS.subClassOf)) { String parent = sourceResource.getProperty(RDFS.subClassOf) .getObject().asNode().getURI(); @@ -447,6 +455,11 @@ return false; } + public static void main(String[] args) throws IOException { + RDFConfigure rdfc = new RDFConfigure("http://biomoby.org/RESOURCES/MOBY-S/Objects#"); + System.out.println(new String(rdfc.retrieveObjectRDF("http://biomoby.org/RESOURCES/MOBY-S/Objects#MSF_DIRECT_DNA"))); + + } class FilteredStream extends FilterOutputStream { StringBuffer sb = null; From kawas at pub.open-bio.org Tue Jul 19 15:56:20 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:56:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191556.j6JFuKEI021054@pub.open-bio.org> kawas Tue Jul 19 11:56:20 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types In directory pub.open-bio.org:/tmp/cvs-serv21021/org/biomoby/registry/definitions/types Modified Files: JNamespaces.java JObjects.java JServices.java Log Message: changed the mobycentral registry to become the new one. Eddie moby-live/Java/src/main/org/biomoby/registry/definitions/types JNamespaces.java,1.3,1.4 JObjects.java,1.4,1.5 JServices.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespaces.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespaces.java 2005/04/20 21:42:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JNamespaces.java 2005/07/19 15:56:20 1.4 @@ -45,7 +45,7 @@ String username = (String) map.get("username");//"moby_external"; String password = (String) map.get("password");//""; - /* String serverName = "mobycentral.cbr.nrc.ca:3306"; + /* String serverName = "mobycentral.icapture.ubc.ca:3306"; String mydatabase = "mobynamespace"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "moby_external"; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjects.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjects.java 2005/04/20 21:42:10 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JObjects.java 2005/07/19 15:56:20 1.5 @@ -48,7 +48,7 @@ String username = (String) map.get("username");//"moby_external"; String password = (String) map.get("password");//""; - /*String serverName = "mobycentral.cbr.nrc.ca:3306"; + /* String serverName = "mobycentral.icapture.ubc.ca:3306"; String mydatabase = "mobyobject"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "moby_external"; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServices.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServices.java 2005/04/20 21:42:10 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/definitions/types/JServices.java 2005/07/19 15:56:20 1.4 @@ -48,7 +48,7 @@ String username = (String) map.get("username");//"moby_external"; String password = (String) map.get("password");//""; - /* String serverName = "mobycentral.cbr.nrc.ca:3306"; + /* String serverName = "mobycentral.icapture.ubc.ca:3306"; String mydatabase = "mobyservice"; String url = "jdbc:mysql://" + serverName + "/" + mydatabase; String username = "moby_external"; From kawas at pub.open-bio.org Tue Jul 19 15:36:24 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 11:36:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507191536.j6JFaOOG020642@pub.open-bio.org> kawas Tue Jul 19 11:36:24 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool In directory pub.open-bio.org:/tmp/cvs-serv20605/org/biomoby/client/ui/graphical/applets/objectCreationTool Modified Files: TreeWindow.java ObjectCreationTool.java retrieveObjectXML.cgi Registration.java Log Message: Changed code that refered to the old registry. As well, removed the ability to register datatypes with "" articlenames. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool TreeWindow.java,1.1,1.2 ObjectCreationTool.java,1.2,1.3 retrieveObjectXML.cgi,1.1,1.2 Registration.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/TreeWindow.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/TreeWindow.java 2005/04/07 16:42:26 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/TreeWindow.java 2005/07/19 15:36:24 1.2 @@ -46,7 +46,7 @@ private int type; private ObjectCreationTool tool = null; // TODO - place the file pointed to by _URL on mobycentral/cgi-bin/applets/ - private final static String _URL = "http://mobycentral.cbr.nrc.ca/cgi-bin/applets/retrieveObjectXML.cgi?name="; + private final static String _URL = "http://mobycentral.icapture.ubc.ca:8090/applets/cgi-bin/retrieveObjectXML.cgi?name="; /** * This is the default constructor */ @@ -119,16 +119,24 @@ case (2): { articleName = getSelected(); + if (articleName.equalsIgnoreCase("")) { + tool.createPopUpMsg("Please enter an article name for your object selection."); + return; + } tool.xml.addHas(selectedObject.toString(), articleName,tool.xml.getRootName()); - tool.toggleIsaButton(false); + //tool.toggleIsaButton(false); tool.closePopUpTreeWindow(); } break; case (3): { articleName = getSelected(); + if (articleName.equalsIgnoreCase("")) { + tool.createPopUpMsg("Please enter an article name for your object selection."); + return; + } tool.xml.addHasA(selectedObject.toString(), articleName,tool.xml.getRootName()); - tool.toggleIsaButton(false); + //tool.toggleIsaButton(false); tool.closePopUpTreeWindow(); } break; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/ObjectCreationTool.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/ObjectCreationTool.java 2005/06/02 15:48:01 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/ObjectCreationTool.java 2005/07/19 15:36:24 1.3 @@ -145,7 +145,7 @@ final TreeLoaderThread worker = new TreeLoaderThread() { public Object construct() { tree = new MobyTree(false, - "http://mobycentral.cbr.nrc.ca:8090/RESOURCES/MOBY-S/Objects","Objects"); + "http://mobycentral.icapture.ubc.ca:8090/RESOURCES/MOBY-S/Objects","Object"); tree.makeObjectTree("Object"); tree.setPreferredSize(new Dimension(400, 400)); tree.getTree().addMouseListener(mListener); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/retrieveObjectXML.cgi,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/retrieveObjectXML.cgi 2005/04/07 16:42:26 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/retrieveObjectXML.cgi 2005/07/19 15:36:24 1.2 @@ -4,7 +4,10 @@ use strict; use CGI qw( :cgi ); use MOBY::Client::Central; - my $Central = MOBY::Client::Central->new; + my $Central = MOBY::Client::Central->new(Registries => {mobycentral => { + URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} + }); # a simple MOBY_Central call to get service types my $DEFS; =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/Registration.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/Registration.java 2005/06/02 15:48:01 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/applets/objectCreationTool/Registration.java 2005/07/19 15:36:24 1.4 @@ -17,8 +17,8 @@ */ public class Registration extends MobyDataType{ - static final String ENDPOINT = "http://mobycentral.cbr.nrc.ca:8080/cgi-bin/MOBY05/mobycentral.pl"; - static final String NAMESPACE = "http://mobycentral.cbr.nrc.ca:8080/MOBY/Central"; + static final String ENDPOINT = "http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl"; + static final String NAMESPACE = "http://mobycentral.icapture.ubc.ca/MOBY/Central"; private static boolean PROTO = false; /** From kawas at pub.open-bio.org Tue Jul 19 20:46:15 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 19 Jul 2005 16:46:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192046.j6JKkFa6021853@pub.open-bio.org> kawas Tue Jul 19 16:46:15 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv21828/org/biomoby/client/rdf/vocabulary Modified Files: Predicates.java Added Files: XMLTypes.java Log Message: comitting 2 files that i forgot to update/commit ;-) Eddie moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary XMLTypes.java,NONE,1.1 Predicates.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/05/31 18:11:08 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/19 20:46:15 1.3 @@ -49,6 +49,7 @@ public static final Property SecondaryArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SecondaryArticle"); public static final Property SignatureURL = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SignatureURL"); public static final Property authoritative = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#authoritative"); + public static final Property ofType = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#ofType"); public final static String getURI() { return uri; } From senger at ebi.ac.uk Tue Jul 19 21:47:58 2005 From: senger at ebi.ac.uk (Martin Senger) Date: Tue, 19 Jul 2005 22:47:58 +0100 (BST) Subject: [MOBY-guts] biomoby commit In-Reply-To: <200507192046.j6JKkFa6021853@pub.open-bio.org> Message-ID: Eddie, I love you: jMoby workd again. Martin -- Martin Senger EMBL Outstation - Hinxton Senger at EBI.ac.uk European Bioinformatics Institute Phone: (+44) 1223 494636 Wellcome Trust Genome Campus (Switchboard: 494444) Hinxton Fax : (+44) 1223 494468 Cambridge CB10 1SD United Kingdom http://industry.ebi.ac.uk/~senger From mwilkinson at pub.open-bio.org Tue Jul 19 22:54:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 18:54:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192254.j6JMsAt7022213@pub.open-bio.org> mwilkinson Tue Jul 19 18:54:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22194/MOBY Modified Files: OntologyServer.pm Log Message: most calls in OntologyServer were mis-directed to the mobycentral data adaptor instead of teh mobyobject, mobyservice, mobynamespace etc adaptors. They should all direct properly now moby-live/Perl/MOBY OntologyServer.pm,1.52,1.53 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/18 22:32:20 1.52 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 22:54:10 1.53 @@ -185,7 +185,7 @@ my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my $term = $args{term}; $term =~ s/^moby://; # if the term is namespaced, then remove that @@ -248,7 +248,7 @@ sub createObject { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); #node => $term, #desc => $desc, #authURI => $auth, @@ -310,7 +310,7 @@ sub retrieveObject { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my $term = $args{'node'}; return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node as an argument", '' ) @@ -359,7 +359,7 @@ sub deprecateObject { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return ( 0, "WRONG ONTOLOGY", '' ) unless ( $self->ontology eq 'object' ); my $term = $args{term}; @@ -418,8 +418,7 @@ # ontology => $ontology my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'relationship' ); my $term = lc( $args{term} ); @@ -469,7 +468,7 @@ #contact_email => $email my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); @@ -552,7 +551,7 @@ #contact_email => $email); my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); @@ -613,7 +612,7 @@ sub serviceExists { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; @@ -657,7 +656,7 @@ sub createServiceType { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); #node => $term, #descrioption => $desc, @@ -701,7 +700,7 @@ sub deleteServiceType { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); my $term = $args{term}; @@ -766,7 +765,7 @@ sub namespaceExists { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); @@ -811,7 +810,7 @@ sub createNamespace { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); #node => $term, #descrioption => $desc, #authority => $auth, @@ -855,7 +854,7 @@ sub deleteNamespace { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'namespace' ); my $term = $args{term}; @@ -913,7 +912,7 @@ sub retrieveAllServiceTypes { my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); my $types = $adaptor->query_service(); my %response; @@ -930,7 +929,7 @@ sub retrieveAllNamespaceTypes { my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); my $types = $adaptor->query_namespace(); my %response; @@ -947,7 +946,7 @@ sub retrieveAllObjectClasses { my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my $types = $adaptor->query_object(); my %response; @@ -966,7 +965,7 @@ sub getObjectCommonName { my ( $self, $URI ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return undef unless $URI =~ /urn\:lsid/; my $result = $adaptor->query_object({object_lsid => $URI}); my $row = shift(@$result); @@ -982,7 +981,7 @@ sub getNamespaceCommonName { my ( $self, $URI ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return undef unless $URI =~ /urn\:lsid/; my $result = $adaptor->query_namespace({namespace_lsid => $URI}); my $row = shift(@$result); @@ -998,7 +997,7 @@ sub getServiceCommonName { my ( $self, $URI ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return undef unless $URI =~ /urn\:lsid/; my $result = $adaptor->query_service({service_lsid => $URI}); my $row = shift(@$result); @@ -1014,7 +1013,7 @@ sub getServiceURI { my ( $self, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return $term if $term =~ /urn\:lsid/; my $result = $adaptor->query_service({service_type => $term}); @@ -1031,7 +1030,7 @@ sub getObjectURI { my ( $self, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return $term if $term =~ /urn\:lsid/; my $result = $adaptor->query_object({object_type => $term}); @@ -1048,7 +1047,7 @@ sub getNamespaceURI { my ( $self, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return $term if $term =~ /urn\:lsid/; @@ -1066,7 +1065,7 @@ sub getRelationshipURI { my ( $self, $ontology, $term ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); return $term if $term =~ /urn\:lsid/; @@ -1084,7 +1083,7 @@ sub getRelationshipTypes { my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); my $ontology = $args{'ontology'}; my $OS = MOBY::OntologyServer->new( ontology => "relationship" ); @@ -1150,7 +1149,8 @@ sub _doRelationshipsQuery { my ( $self, $ontology, $term, $relationship, $direction ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $datasource = "moby$ontology"; # like mobyobject, or mobyservice + my $adaptor = $CONFIG->getDataAdaptor( datasource => $datasource ); my $defs; # query returns a reference to an array containing array references $defs = $adaptor->getRelationship({direction => $direction}, {ontology => $ontology}, {term => $term}, {relationship => $relationship}); From mwilkinson at pub.open-bio.org Tue Jul 19 22:54:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 18:54:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192254.j6JMsAbi022233@pub.open-bio.org> mwilkinson Tue Jul 19 18:54:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv22194/MOBY/Client Modified Files: Central.pm Log Message: most calls in OntologyServer were mis-directed to the mobycentral data adaptor instead of teh mobyobject, mobyservice, mobynamespace etc adaptors. They should all direct properly now moby-live/Perl/MOBY/Client Central.pm,1.98,1.99 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.98 retrieving revision 1.99 diff -u -r1.98 -r1.99 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 14:33:46 1.98 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 22:54:10 1.99 @@ -1047,7 +1047,7 @@ Usage : $REG = $MOBY->deregisterService(%args) Function : deregister a registered MOBY Service Returns : MOBY::Registration object - Args : serviceID => $serviceID + Args : serviceName => $serviceID, authURI => $authority =cut From mwilkinson at pub.open-bio.org Tue Jul 19 23:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 19:37:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192337.j6JNbZrb022356@pub.open-bio.org> mwilkinson Tue Jul 19 19:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22337/MOBY Modified Files: OntologyServer.pm Log Message: still one misdirected call - now fixed. moby-live/Perl/MOBY OntologyServer.pm,1.53,1.54 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 22:54:10 1.53 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 23:37:35 1.54 @@ -468,7 +468,7 @@ #contact_email => $email my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyrelationship' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); From mwilkinson at pub.open-bio.org Tue Jul 19 23:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 19:37:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192337.j6JNbZMt022375@pub.open-bio.org> mwilkinson Tue Jul 19 19:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22337/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: still one misdirected call - now fixed. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/18 22:32:20 1.15 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:37:35 1.16 @@ -519,7 +519,8 @@ sub delete_object{ my ($self, @args) = @_; my $dbh = $self->dbh; - my $statement = "delete from object "; + my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........********** + # ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ******************** my @bindvalues = (); ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, From mwilkinson at pub.open-bio.org Tue Jul 19 23:40:34 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 19:40:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192340.j6JNeY8a022460@pub.open-bio.org> mwilkinson Tue Jul 19 19:40:34 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22441/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: missed a $ in front of dbh moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:37:35 1.16 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:40:34 1.17 @@ -559,7 +559,7 @@ sub insert_object_term2term{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, undef, ( get_value('relationship_type', @args), From mwilkinson at pub.open-bio.org Tue Jul 19 23:47:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 19 Jul 2005 19:47:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507192347.j6JNlQYb022529@pub.open-bio.org> mwilkinson Tue Jul 19 19:47:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22510/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: missed several dozen more $. The problem with copy/paste when the original was erroneous moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:40:34 1.17 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:47:26 1.18 @@ -227,8 +227,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -277,8 +277,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -341,8 +341,8 @@ ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -404,8 +404,8 @@ ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -462,8 +462,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -526,8 +526,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -581,8 +581,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -660,8 +660,8 @@ ($statement, @bindvalues) = add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -740,7 +740,7 @@ sub insert_service{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, undef, ( @@ -748,7 +748,7 @@ get_value('authority', @args), get_value('contact_email', @args) ) ); - return dbh->{mysql_insertid}; + return $dbh->{mysql_insertid}; } sub delete_service{ @@ -760,8 +760,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -790,12 +790,12 @@ sub insert_service_term2term{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, undef, ( get_value('relationship_type', @args), get_value('service1_id', @args), get_value('service2_id', @args)) ); - return dbh->{mysql_insertid}; + return $dbh->{mysql_insertid}; } sub delete_service_term2term{ @@ -807,8 +807,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -866,7 +866,7 @@ sub insert_namespace{ my ($self, @args) = @_; my $dbh = $self->dbh; - dbh->do( + $dbh->do( q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, undef, ( @@ -874,7 +874,7 @@ get_value('authority', @args), get_value('contact_email', @args) ) ); - return dbh->{mysql_insertid}; + return $dbh->{mysql_insertid}; } sub delete_namespace{ @@ -886,8 +886,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; @@ -924,8 +924,8 @@ $dbh->do( $statement, undef, @bindvalues ); - if (dbh->err){ - return (1, dbh->errstr); + if ($dbh->err){ + return (1, $dbh->errstr); } else{ return 0; From mwilkinson at pub.open-bio.org Wed Jul 20 15:43:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 11:43:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201543.j6KFhv96024731@pub.open-bio.org> mwilkinson Wed Jul 20 11:43:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv24704/MOBY Modified Files: Central.pm authority.pm service_instance.pm Log Message: The logic for retrieving authority objects was faulty. It now creates a new db entry if the initial lookup fails moby-live/Perl/MOBY Central.pm,1.161,1.162 authority.pm,1.3,1.4 service_instance.pm,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.161 retrieving revision 1.162 diff -u -r1.161 -r1.162 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/19 14:33:46 1.161 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 15:43:57 1.162 @@ -1184,7 +1184,6 @@ if ( $ch == 0 ) { - use MOBY::Config; my $conf = MOBY::Config->new(); my $path = $conf->{mobycentral}->{rdfagent}; my $rez = system( $path. " " . $signatureURL ); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/13 21:53:12 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 15:43:57 1.4 @@ -91,19 +91,13 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); - my $authority_id = @$result[0]->{authority_id}; - my $common = @$result[0]->{authority_common_name}; - my $uri = @$result[0]->{authority_uri}; - my $contact = @$result[0]->{contact_email}; - - unless ($authority_id) { + unless (@$result[0]) { my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, {authority_uri => $self->authority_uri}, {contact_email => $self->contact_email}); - $self->authority_id( $insertid ); } else { - $self->authority_id($authority_id); + $self->authority_id(@$result[0]->{authority_id}); } return $self; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/18 22:46:00 1.13 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:43:57 1.14 @@ -358,13 +358,14 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); - my $row = shift(@$result); - my $id = $row->{authority_id}; - my $name = $row->{authority_common_name}; - my $uri = $row->{authority_uri}; - my $email = $row->{contact_email}; - if ( defined $id ) { + if ( @$result[0]) { + my $row = shift(@$result); + my $id = $row->{authority_id}; + my $name = $row->{authority_common_name}; + my $uri = $row->{authority_uri}; + my $email = $row->{contact_email}; + $authority = MOBY::authority->new( dbh => $self->dbh, authority_id => $id, From mwilkinson at pub.open-bio.org Wed Jul 20 15:58:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 11:58:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201558.j6KFwMDI024816@pub.open-bio.org> mwilkinson Wed Jul 20 11:58:22 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv24797/MOBY Modified Files: service_instance.pm Log Message: Parameters passed to the query_service_instance routine need to be hashified moby-live/Perl/MOBY service_instance.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:43:57 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:58:22 1.15 @@ -226,8 +226,9 @@ : $self->service_type_uri($servicetypeURI); } my $existing_service = $self->adaptor->query_service_instance( - servicename => $self->servicename, - authURI => $self->authority_uri ); + {servicename => $self->servicename}, + "and", + {authURI => $self->authority_uri}); if ( ($existing_service ) # if it exists, you are not allowed to have passed anything other than service name and authorityURI From mwilkinson at pub.open-bio.org Wed Jul 20 17:00:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 13:00:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201700.j6KH0QUj025091@pub.open-bio.org> mwilkinson Wed Jul 20 13:00:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25053/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: No, they don't have to be hashified at that pont, but the query itself is a two-step process, and the generic query builder can't do joins over multiple tables so we now do two consecutive queries moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/19 23:47:26 1.18 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 17:00:26 1.19 @@ -592,8 +592,16 @@ # selects all the columns from service_instance table # where is lsid? sub query_service_instance { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; + + my $servicename = $args{'servicename'}; + my $authURI = $args{'authority_uri'}; + + my $result = $self->query_authority({authority_uri => $authURI}); + return [{}] unless @$result[0]; + my $id = @$result[0]->{authority_id}; + return [{}] unless $id; my $statement = "select service_instance_id, @@ -608,15 +616,10 @@ signatureURL, lsid from service_instance "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) = add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my @bindvalues; + ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); + my $final = do_query($dbh, $statement, @bindvalues); + return $final; } # custom query for Moby::Central.pm->findService() From mwilkinson at pub.open-bio.org Wed Jul 20 17:00:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 13:00:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201700.j6KH0Q2Z025072@pub.open-bio.org> mwilkinson Wed Jul 20 13:00:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25053/MOBY Modified Files: service_instance.pm Log Message: No, they don't have to be hashified at that pont, but the query itself is a two-step process, and the generic query builder can't do joins over multiple tables so we now do two consecutive queries moby-live/Perl/MOBY service_instance.pm,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 15:58:22 1.15 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 17:00:26 1.16 @@ -226,9 +226,8 @@ : $self->service_type_uri($servicetypeURI); } my $existing_service = $self->adaptor->query_service_instance( - {servicename => $self->servicename}, - "and", - {authURI => $self->authority_uri}); + servicename => $self->servicename, + authority_uri => $self->authority_uri); if ( ($existing_service ) # if it exists, you are not allowed to have passed anything other than service name and authorityURI From dwang at pub.open-bio.org Wed Jul 20 17:12:20 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 20 Jul 2005 13:12:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201712.j6KHCKIl025225@pub.open-bio.org> dwang Wed Jul 20 13:12:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25199/Perl/MOBY Modified Files: Central.pm Log Message: removed calls to first row of the result set (like @$result[0]), instead used shift to retrieve the first row of the result set moby-live/Perl/MOBY Central.pm,1.162,1.163 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.162 retrieving revision 1.163 diff -u -r1.162 -r1.163 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 15:43:57 1.162 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 17:12:20 1.163 @@ -763,7 +763,8 @@ my $dbh = MOBY::central_db_connection->new()->dbh; my $result = $adaptor->query_service_instance({service_type_uri => $existingURI}); - my $id = @$result[0]->{service_instance_id}; + my $row = shift(@$result); + my $id = $row->{service_instance_id}; return &_error( "A registered service depends on this service type", "" ) if ($id); @@ -1938,7 +1939,8 @@ && _LOG("authURI added; criterion count is now $criterion_count\n"); my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}}); - my $id = @$result[0]->{authority_id}; + my $row = shift(@$result); + my $id = $row->{authority_id}; unless ($id) { return &_serviceListResponse( $dbh, undef ); @@ -3368,16 +3370,17 @@ foreach (@ids) { my $result = $adaptor->query_service_instance({service_instance_id => $_}); - my $category = @$result[0]->{category}; - my $url = @$result[0]->{url}; - my $servicename = @$result[0]->{servicename}; - my $service_type_uri = @$result[0]->{service_type_uri}; - my $authority_id = @$result[0]->{authority_id}; - my $desc = @$result[0]->{description}; - my $authoritative = @$result[0]->{authoritative}; - my $email = @$result[0]->{contact_email}; - my $signatureURL = @$result[0]->{signatureURL}; - my $lsid = @$result[0]->{lsid}; + my $row = shift(@$result); + my $category = $row->{category}; + my $url = $row->{url}; + my $servicename = $row->{servicename}; + my $service_type_uri = $row->{service_type_uri}; + my $authority_id = $row->{authority_id}; + my $desc = $row->{description}; + my $authoritative = $row->{authoritative}; + my $email = $row->{contact_email}; + my $signatureURL = $row->{signatureURL}; + my $lsid = $row->{lsid}; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; @@ -3389,7 +3392,8 @@ my $service_type = $OSserv->getServiceCommonName($service_type_uri); $result = $adaptor->query_authority({authority_id => $authority_id}); - my $authURI = @$result[0]->{authority_uri}; + my $row = shift(@$result); + my $authURI = $row->{authority_uri}; $output .= "\t\n"; $output .= "\t$service_type\n"; From dwang at pub.open-bio.org Wed Jul 20 17:25:54 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 20 Jul 2005 13:25:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201725.j6KHPs6o025292@pub.open-bio.org> dwang Wed Jul 20 13:25:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25266/Perl/MOBY Modified Files: authority.pm Log Message: removed explicit call to first row of result set, instead use shift to retrieve first row moby-live/Perl/MOBY authority.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 15:43:57 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 17:25:54 1.5 @@ -91,13 +91,14 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); - unless (@$result[0]) { + my $row = shift(@$result); + unless ($row) { my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, {authority_uri => $self->authority_uri}, {contact_email => $self->contact_email}); $self->authority_id( $insertid ); } else { - $self->authority_id(@$result[0]->{authority_id}); + $self->authority_id($row->{authority_id}); } return $self; } From kawas at pub.open-bio.org Wed Jul 20 17:42:31 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Wed, 20 Jul 2005 13:42:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507201742.j6KHgV3J025434@pub.open-bio.org> kawas Wed Jul 20 13:42:31 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv25405/org/biomoby/client/rdf/vocabulary Modified Files: Predicates.java MobyResources.java Log Message: Updated the predicates. Moved predicates from MobyResources to Predicates and deprecated MobyResources.java moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary Predicates.java,1.3,1.4 MobyResources.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/19 20:46:15 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/20 17:42:31 1.4 @@ -50,6 +50,11 @@ public static final Property SignatureURL = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SignatureURL"); public static final Property authoritative = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#authoritative"); public static final Property ofType = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#ofType"); + /* moved from MobyResources.java */ + public static final Property Simple = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Simple"); + public static final Property Secondary = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Secondary"); + public static final Property Collection = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Collection"); + public final static String getURI() { return uri; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/MobyResources.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/MobyResources.java 2005/05/31 18:11:08 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/MobyResources.java 2005/07/20 17:42:31 1.3 @@ -13,9 +13,12 @@ */ /** + * @deprecated Replaced by {@link + * Predicates}. The reason is that this class was + * redundant and ill conceived. From now on the + * BioMoby predicates, under the namespace moby, + * are located in Predicates.java. * @author Eddie Kawas - *

Created for - *

This class was created to ... *

For questions, comments, or bugs *

email me at edward.kawas at gmail.com */ @@ -24,9 +27,29 @@ private static final String uri = "http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#"; private static Model _model = ModelFactory.createDefaultModel(); + /** + * @deprecated Replaced by {@link + * Predicates#Simple}. The reason is that this property + * should not be under a different RDF document URI + */ public static final Property SimpleArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Simple"); + /** + * @deprecated Replaced by {@link + * Predicates#articleName}. The reason is that this property + * is never utilized and is redundant. + */ public static final Property CollectionArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#articleName"); + /** + * @deprecated Replaced by {@link + * Predicates#Secondary}. The reason is that this property + * should not be under a different RDF document URI + */ public static final Property SecondaryArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Secondary"); + /** + * @deprecated Replaced by {@link + * Predicates#Collection}. The reason is that this property + * should not be under a different RDF document URI + */ public static final Property Collection = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Collection"); public final static String getURI() { return uri; From kawas at pub.open-bio.org Wed Jul 20 20:33:22 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Wed, 20 Jul 2005 16:33:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202033.j6KKXMhq025785@pub.open-bio.org> kawas Wed Jul 20 16:33:22 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources In directory pub.open-bio.org:/tmp/cvs-serv25760/org/biomoby/client/ui/graphical/servlet/jresources Modified Files: RESOURCE.java Log Message: Added the generation of the moby predicate vocabulary. If you run main, you can view the RDF document describing predicates. This implementation is only temporary. Eddie moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources RESOURCE.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/07/19 15:32:54 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/ui/graphical/servlet/jresources/RESOURCE.java 2005/07/20 20:33:22 1.8 @@ -17,7 +17,6 @@ import javax.servlet.http.HttpServletResponse; import org.biomoby.client.CentralDigestImpl; -import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; import org.biomoby.client.rdf.vocabulary.XMLTypes; import org.biomoby.registry.definitions.types.JNamespaces; @@ -52,13 +51,18 @@ */ /** - * @author Eddie Kawas

Created for

This class was created to ...

For - * questions, comments, or bugs

email me at edward.kawas at gmail.com + * + * @author Eddie Kawas + *

This class was created to replace the old perl RESOURCES script. Using this + * class provides access to the RDF documents describing the object, service type, + * services, namespace and predicate ontologies. + *

if you have any questions, please email me at ed.kawas at gmail.com + * */ public class RESOURCE extends HttpServlet { /** - * + * */ private static final long serialVersionUID = 1L; @@ -141,21 +145,23 @@ private static Properties properties = MobyProperties.PROPERTIES();; private static final String OBJ = "http://" - + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Objects#"; + + properties.getProperty("resources_script_domain") + + "/RESOURCES/MOBY-S/Objects#"; private static final String SRV = "http://" - + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Services#"; + + properties.getProperty("resources_script_domain") + + "/RESOURCES/MOBY-S/Services#"; private static final String NS = "http://" - + properties.getProperty("resources_script_domain") + + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Namespaces#"; private static final String MP = "http://" - + properties.getProperty("resources_script_domain") + + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#"; private static final String SI = "http://" - + properties.getProperty("resources_script_domain") + + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/ServiceInstances#"; private static boolean RUN_MAIN = false; @@ -166,7 +172,7 @@ * @see javax.servlet.GenericServlet#init() */ public final void init() throws ServletException { - // super.init(); + // super.init(); } protected final void doGet(HttpServletRequest request, @@ -272,6 +278,17 @@ writer.setProperty("showXmlDeclaration", "true"); writer.write(model, out, null); return; + } else if (ontology.equals("Predicates")) { + //TODO - create the predicates RDF/XML document describing + // the Predicates. + + response.setContentType("application/rdf+xml"); + response.setHeader("Content-Disposition", + "attachment;filename=Namespaces"); + RDFWriter writer = model.getWriter("RDF/XML-ABBREV"); + writer.setProperty("showXmlDeclaration", "true"); + writer.write(model, out, null); + return; } else if (ontology.equals("FULL")) { try { model = getAll(model); @@ -303,7 +320,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -313,6 +333,7 @@ model = getObjects(model); model = getServices(model); model = getNamespaces(model); + //TODO - add the predicates to the model. try { model = getServiceInstances(model); } catch (ModelException e) { @@ -323,7 +344,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -367,9 +391,13 @@ .getURL())); subject.addProperty(DC.identifier, model .createTypedLiteral("urn:lsid:" - + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_authority") + ":" - + MobyProperties.SERVICE_INSTANCE_PROPERTIES().getProperty("lsid_namespace") + ":" +services[i].getAuthority() - + "," + services[i].getName())); + + MobyProperties.SERVICE_INSTANCE_PROPERTIES() + .getProperty("lsid_authority") + + ":" + + MobyProperties.SERVICE_INSTANCE_PROPERTIES() + .getProperty("lsid_namespace") + ":" + + services[i].getAuthority() + "," + + services[i].getName())); subject.addProperty(Predicates.performs_task, model .createResource(SRV + services[i].getType())); subject.addProperty(Predicates.SignatureURL, model @@ -408,7 +436,7 @@ } innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) primaryInputs[j]) .getName().equals("")) innerBag @@ -461,8 +489,7 @@ .getDefaultValue())); _li.addProperty(Predicates.datatype, model .createTypedLiteral(data.getDataType())); - _li.addProperty(RDF.type, - MobyResources.SecondaryArticle); + _li.addProperty(RDF.type, Predicates.Secondary); if (data.getDataType().equals("Integer")) { _li .addProperty(Predicates.min, model @@ -514,7 +541,7 @@ produceBag = model.createBag(); innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) outputs[j]) .getName().equals("")) innerBag @@ -559,7 +586,7 @@ private final Resource createSimpleDataItem(Model model, MobyPrimaryDataSimple simpleData, Resource _li) { - _li.addProperty(RDF.type, MobyResources.SimpleArticle); + _li.addProperty(RDF.type, Predicates.Simple); _li.addProperty(Predicates.object_type, model.createResource(OBJ + simpleData.getDataType().getName())); if (!simpleData.getName().equals("")) @@ -578,7 +605,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -615,7 +645,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @return @@ -646,7 +679,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @throws MobyException @@ -664,8 +700,10 @@ // create the base object type "class" Resource subject = _addClassResource(model, OBJ, "Object", "a base object class consisting of a namespace and an identifier"); - model.add(model.createStatement(subject, DC.publisher, model.createLiteral("www.illuminae.com", "en"))); - model.add(model.createStatement(subject, DC.creator, model.createLiteral("markw at illuminae.com", "en"))); + model.add(model.createStatement(subject, DC.publisher, model + .createLiteral("www.illuminae.com", "en"))); + model.add(model.createStatement(subject, DC.creator, model + .createLiteral("markw at illuminae.com", "en"))); model.add(model.createStatement(subject, RDF.type, RDFS.Class)); for (int x = 0; x < objects.length; x++) { String[] _line = objects[x].split("\t"); @@ -684,7 +722,7 @@ obj = obj.substring(0, obj.indexOf("(")); Resource _subject = _addClassResource(model, OBJ, sub, def); - + m = Pattern.compile(".*:isa$", Pattern.CASE_INSENSITIVE).matcher( pred); if (m.matches()) { @@ -720,12 +758,14 @@ map.put("serviceInstances", SI); map.put("mobyNamespace", NS); map.put("mobyService", SRV); - map.put("moby", MobyResources.getURI()); model.setNsPrefixes(map); } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @param _resource @@ -749,7 +789,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @param mp2 @@ -763,7 +806,10 @@ } /** - * PRE:

POST:

+ * PRE: + *

+ * POST: + *

* * @param model * @param subject @@ -784,7 +830,8 @@ Pattern p = Pattern.compile("urn:lsid.*:(\\S+)$"); Matcher m = p.matcher(thing); String label = (m.matches() ? m.group(1) : thing); - //TODO - add the ofType property if thing is String, Float, Integer, DataTime. + //TODO - add the ofType property if thing is String, Float, Integer, + // DataTime. Resource resource = model.createResource(ns + thing); addOfTypeProperty(model, resource, thing); model.add(model.createStatement(resource, RDF.type, RDFS.Class)); @@ -796,29 +843,33 @@ } /** - * @param model - * @param resource - * @param thing - */ - private void addOfTypeProperty(Model model, Resource resource, String name) { - // make sure that we declare the ns for the datatype - Map map = model.getNsPrefixMap(); - if (!map.containsValue(XMLTypes.getURI())) { - map.put(XMLTypes.getPrefix(), XMLTypes.getURI()); - } - model.setNsPrefixes(map); - if (name.equalsIgnoreCase("string")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_STRING)); - } else if (name.equalsIgnoreCase("integer")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_INTEGER)); - } else if (name.equalsIgnoreCase("float")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_FLOAT)); - } else if (name.equalsIgnoreCase("datatime")) { - model.add(model.createStatement(resource, Predicates.ofType, XMLTypes.XSD_DATE_TIME)); - } - } + * @param model + * @param resource + * @param thing + */ + private void addOfTypeProperty(Model model, Resource resource, String name) { + // make sure that we declare the ns for the datatype + Map map = model.getNsPrefixMap(); + if (!map.containsValue(XMLTypes.getURI())) { + map.put(XMLTypes.getPrefix(), XMLTypes.getURI()); + } + model.setNsPrefixes(map); + if (name.equalsIgnoreCase("string")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_STRING)); + } else if (name.equalsIgnoreCase("integer")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_INTEGER)); + } else if (name.equalsIgnoreCase("float")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_FLOAT)); + } else if (name.equalsIgnoreCase("datatime")) { + model.add(model.createStatement(resource, Predicates.ofType, + XMLTypes.XSD_DATE_TIME)); + } + } - private final String getTypes(String type) throws MobyException { + private final String getTypes(String type) throws MobyException { if (type.equalsIgnoreCase("objects")) { try { return new JObjects().getObjects(); @@ -848,7 +899,7 @@ } /* - * + * */ private String getURL(String url) { StringBuffer sb = new StringBuffer(); @@ -858,7 +909,7 @@ .openStream())); String inputLine; while ((inputLine = in.readLine()) != null) - sb.append(inputLine+"\n"); + sb.append(inputLine + "\n"); in.close(); } catch (Exception e) { e.printStackTrace(); @@ -930,6 +981,12 @@ return out.getBuffer().toString(); } + /** + * + * @param str + * @return an RDF document describing the ontology represented by str. + * @throws MobyException + */ public final String getRESOURCES(String str) throws MobyException { String name = ""; if (str.lastIndexOf("/") > 0) { @@ -946,12 +1003,235 @@ return getServiceInstances(); } else if (name.equalsIgnoreCase("Namespaces")) { return getNamespaces(); + } else if (name.equalsIgnoreCase("Predicates")) { + return getPredicates(); } + return ""; } + private String getPredicates() { + StringBuffer buffer = new StringBuffer(); + buffer.append( + "\r\n"); + // add the predicates here + buffer.append(createOntologyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "The BioMoby Predicates Vocabulary (mobyPred)", + "This is the RDF Schema for the BioMoby Predicate vocabulary defined in the mobyPred namespace.")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#hasa", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "hasa","The subject contains exactly one object.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#has", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "has","The subject contains one or more object.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#articleName", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "articleName","The subject is known to be named object while in a relationship.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#namespace_type", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "namespace_type","The subject resource is applicable under the object namespace.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Resource")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#object_type", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "object_type","The subject resource is a resource object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Resource")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#consumes", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "consumes","The subject container takes as input object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#produces", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "produces","The subject container produces as output object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#performs_task", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "performs_task","The subject performs the task of the object resource.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Resource")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#default_value", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "default_value","The subject has a default value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#min", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "min","The subject has a minimum value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#max", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "max","The subject has a maximum value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#enum", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "enum","The subject may assume the value of object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#datatype", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "datatype","Idiomatic property used for structured values.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#signatureURL", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "signatureURL","Object is a URL that contains information on the subject.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#authoritative", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "authoritative","The object states whether the subject is authoritative.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#ofType", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "ofType","The subject is of primitive type object.", + "http://www.w3.org/2000/01/rdf-schema#Class", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#sampleInputData", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "sampleInputData","Object is a sample of valid input that subject can handle.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#sampleOutputData", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "sampleOutputData","Object is a sample of valid output created by running the subject.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createPropertyBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#approvedBy", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "approvedBy","The subject has been approved by object.", + "http://www.w3.org/2000/01/rdf-schema#Property", + "http://www.w3.org/2000/01/rdf-schema#Literal")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Simple", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "Simple","A class representing a simple input or output.", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Secondary", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "Secondary","A class representing a secondary input.", + "http://www.w3.org/2000/01/rdf-schema#Class")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#Collection", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "Collection","A container for objects representing Simples.", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + buffer.append(createEscapedComment("Not sure about the next 3 classes. I dont think that they are actually used anywhere. They represent the articleName of simples, collections and secondaries.")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#SimpleArticle", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "SimpleArticle","NOT SURE", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#CollectionArticle", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "CollectionArticle","NOT SURE", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + buffer.append(createClassBlock("http://biomoby.org/RESOURCES/MOBY-S/Predicates#SecondaryArticle", + "http://biomoby.org/RESOURCES/MOBY-S/Predicates#", + "SecondaryArticle","NOT SURE", + "http://www.w3.org/2000/01/rdf-schema#Container")); + + + // end the addition of predicates here + buffer.append( + "\r\n" + + ""); + return buffer.toString(); + } + + private String createPropertyBlock(String about, String definedBy, + String label, String comment, String domain, String range) { + String s = + "\r\n\r\n" + + " \r\n" + + " " + label + "\r\n" + + " " + comment + "\r\n" + + " \r\n" + + " \r\n" + + "\r\n"; + return s; + } + + private String createClassBlock(String about, String definedBy, + String label, String comment, String subClassOf) { + String s = + "\r\n\r\n" + + " \r\n" + + " "+ label +"\r\n" + + " "+ comment +"\r\n" + + " \r\n" + + "\r\n"; + return s; + } + + private String createDescriptionBlock(String about, String[] seeAlsos) { + if (seeAlsos == null) + return "\r\n"; + StringBuffer sb = new StringBuffer(); + sb.append(" \r\n"); + for (int x = 0; x < seeAlsos.length; x++) { + sb.append(" \r\n"); + } + sb.append("\r\n"); + return sb.toString(); + } + + private String createOntologyBlock(String about, String title, + String description) { + String s ="\r\n\r\n" + " " + title + "\r\n" + + " " + description + "\r\n" + + "\r\n"; + return s; + } + + private String createEscapedComment(String comment) { + String s = "\r\n\r\n"; + return s; + } + public static void main(String[] args) throws MobyException { - System.out.println(new RESOURCE().getRESOURCES("Objects")); + System.out.println(new RESOURCE().getRESOURCES("Predicates")); } -} +} \ No newline at end of file From mwilkinson at pub.open-bio.org Wed Jul 20 21:23:54 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 17:23:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202123.j6KLNsgX025941@pub.open-bio.org> mwilkinson Wed Jul 20 17:23:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25922/MOBY Modified Files: service_instance.pm Log Message: query_service_instance does not return boolean, so the test has to be more explicit moby-live/Perl/MOBY service_instance.pm,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 17:00:26 1.16 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:23:54 1.17 @@ -225,12 +225,12 @@ ? $self->service_type_uri( $self->service_type ) : $self->service_type_uri($servicetypeURI); } - my $existing_service = $self->adaptor->query_service_instance( + my $existing_services = $self->adaptor->query_service_instance( servicename => $self->servicename, authority_uri => $self->authority_uri); + my $existing_service = shift(@$existing_services); if ( - ($existing_service - ) # if it exists, you are not allowed to have passed anything other than service name and authorityURI + ($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI && ( ( defined $self->category ) || ( defined $self->service_type ) || ( defined $self->url ) From mwilkinson at pub.open-bio.org Wed Jul 20 21:29:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 17:29:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202129.j6KLTc7b026019@pub.open-bio.org> mwilkinson Wed Jul 20 17:29:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26000/MOBY Modified Files: service_instance.pm Log Message: query_service_instance does not return boolean, so the test has to be more explicit moby-live/Perl/MOBY service_instance.pm,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:23:54 1.17 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:29:38 1.18 @@ -229,19 +229,15 @@ servicename => $self->servicename, authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); - if ( - ($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI + if (($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI && ( ( defined $self->category ) || ( defined $self->service_type ) || ( defined $self->url ) || ( defined $self->contact_email ) || ( defined $self->description ) ) - ) - { - return - -1; # no no no, not alowed to do that! I will not give you an object - } elsif ($existing_service) - { # if service exists, then instantiate it from the database retrieval we just did + ){ + return -1; # no no no, not alowed to do that! I will not give you an object + } elsif ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); $self->category( $existing_service->{'category'} ); $self->service_type( $existing_service->{'servicetype'} ); @@ -250,26 +246,22 @@ $self->description( $existing_service->{'desc'} ); $self->authority( $existing_service->{'authURI'} ); $self->signatureURL( $existing_service->{'signatureURL'} ); - $self->lsid( $existing_service->{'lsid'} ); + $self->lsid( $existing_service->{'lsid'} ); $self->{__exists__} = 1; # this service already existed - } elsif ( - !($existing_service) # if it doesn't exist - && ( - defined $self->category - ) # and you have given me things I need to create it + } elsif (!($existing_service->{servicename}) # if it doesn't exist + && (defined $self->category) # and you have given me things I need to create it && ( defined $self->service_type ) && ( defined $self->url ) && ( defined $self->contact_email ) && ( defined $self->description ) - ) - { # then create it de novo if we have enough information + ) { # then create it de novo if we have enough information #create LSID for service and register it in the DB - my $_config ||= MOBY::Config->new; - my $service_lsid = "urn:lsid:" - . $_config->{mobycentral}->{lsid_authority} . ":" - . $_config->{mobycentral}->{lsid_namespace} . ":" - . $self->authority_uri . "," - . $self->servicename; + my $_config ||= MOBY::Config->new; + my $service_lsid = "urn:lsid:" + . $_config->{mobycentral}->{lsid_authority} . ":" + . $_config->{mobycentral}->{lsid_namespace} . ":" + . $self->authority_uri . "," + . $self->servicename; my $id = $self->adaptor->insert_service_instance( {category => $self->category}, From mwilkinson at pub.open-bio.org Wed Jul 20 22:04:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 18:04:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202204.j6KM4AGI026133@pub.open-bio.org> mwilkinson Wed Jul 20 18:04:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26114/MOBY Modified Files: secondary_input.pm Log Message: secondary inputs not writing to databse because id returned was null. moby-live/Perl/MOBY secondary_input.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/18 22:46:00 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/20 22:04:10 1.5 @@ -122,8 +122,7 @@ {article_name => $self->article_name}, {service_instance_id => $self->service_instance_id}); - my $id = $dbh->{$insertid}; - return $id; + return $insertid; } sub AUTOLOAD { From mwilkinson at pub.open-bio.org Wed Jul 20 22:49:05 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 18:49:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202249.j6KMn5f5026327@pub.open-bio.org> mwilkinson Wed Jul 20 18:49:05 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26308/MOBY Modified Files: service_instance.pm Log Message: test for the pre-existing service seems to fail. Try this code instead moby-live/Perl/MOBY service_instance.pm,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 21:29:38 1.18 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 22:49:05 1.19 @@ -199,14 +199,11 @@ return undef unless $self->authority_uri; return undef unless $self->servicename; - #$self->_dbh(); - #return undef unless $self->dbh; - #my $dbh = $self->dbh; if ( $self->test ) { return $self->service_instance_exists } - $self->authority( $self->_get_authority() ) - ; # this might not be necessary - it simply converts auth_uri to auth_id and v.v.? - # it actually is necessary for the moment. We need to put the logic of determining - # service id into the mysql.pm module!! + if ($self->service_instance_exists){return -1} + + $self->authority( $self->_get_authority() ); + if ( $self->service_type ) { my $OE = MOBY::OntologyServer->new( ontology => 'service' ); my ( $success, $message, $servicetypeURI ) = @@ -229,15 +226,7 @@ servicename => $self->servicename, authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); - if (($existing_service->{servicename}) # if it exists, you are not allowed to have passed anything other than service name and authorityURI - && ( ( defined $self->category ) - || ( defined $self->service_type ) - || ( defined $self->url ) - || ( defined $self->contact_email ) - || ( defined $self->description ) ) - ){ - return -1; # no no no, not alowed to do that! I will not give you an object - } elsif ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did + if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); $self->category( $existing_service->{'category'} ); $self->service_type( $existing_service->{'servicetype'} ); From mwilkinson at pub.open-bio.org Wed Jul 20 22:34:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 20 Jul 2005 18:34:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507202234.j6KMYn0j026242@pub.open-bio.org> mwilkinson Wed Jul 20 18:34:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv26223/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: can query authority by either URI or database id moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 17:00:26 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 22:34:48 1.20 @@ -597,12 +597,13 @@ my $servicename = $args{'servicename'}; my $authURI = $args{'authority_uri'}; - - my $result = $self->query_authority({authority_uri => $authURI}); - return [{}] unless @$result[0]; - my $id = @$result[0]->{authority_id}; - return [{}] unless $id; - + my $id = $args{'authority_id'}; + unless ($id){ + my $result = $self->query_authority({authority_uri => $authURI}); + return [{}] unless @$result[0]; + my $id = @$result[0]->{authority_id}; + return [{}] unless $id; + } my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Thu Jul 21 16:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jul 2005 12:37:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211637.j6LGbZYt029162@pub.open-bio.org> mwilkinson Thu Jul 21 12:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29120/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: updating the service discovery code to be in-line with the new adaptor API moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/20 22:34:48 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/21 16:37:35 1.21 @@ -589,9 +589,7 @@ } } -# selects all the columns from service_instance table -# where is lsid? -sub query_service_instance { +sub query_service_existence { my ($self, %args) = @_; my $dbh = $self->dbh; @@ -600,9 +598,9 @@ my $id = $args{'authority_id'}; unless ($id){ my $result = $self->query_authority({authority_uri => $authURI}); - return [{}] unless @$result[0]; + return 0 unless @$result[0]; my $id = @$result[0]->{authority_id}; - return [{}] unless $id; + return 0 unless $id; } my $statement = "select service_instance_id, @@ -620,6 +618,32 @@ my @bindvalues; ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); my $final = do_query($dbh, $statement, @bindvalues); + if (@$final[0]){return 1} else {return 0} + +} +# selects all the columns from service_instance table +# where is lsid? + +sub query_service_instance { + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority_id, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance "; + my @bindvalues; + ($statement, @bindvalues) = add_condition($statement, @args); + my $final = do_query($dbh, $statement, @bindvalues); return $final; } @@ -628,7 +652,7 @@ my ($self, @args) = @_; my $dbh = $self->dbh; my $uri_list = get_value('service_type_uri', @args); - my $statement = "select service_instance_id from service_instance where service_type_uri in ($uri_list)"; + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; my @bindvalues = (); my $result = do_query($dbh, $statement, @bindvalues); @@ -1055,10 +1079,10 @@ $kw = $dbh->quote("%$kw%"); $searchstring .= " OR description like $kw "; } - $searchstring =~ s/OR//; # just the first one + $searchstring =~ s/OR//; # remove just the first OR in the longer statement # $debug && &_LOG("search $searchstring\n"); - my $statement = "select service_instance_id from service_instance where $searchstring"; + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; my @bindvalues = (); my $ids = do_query($dbh, $statement, @bindvalues); @@ -1087,7 +1111,7 @@ } my $result = do_query($dbh, $query, ()); - return ($query, $result); + return $result; } # custom query subroutine for Moby::Central.pm->_searchForCollection() @@ -1119,7 +1143,7 @@ } my $result = do_query($dbh, $query, ()); - return ($query, $result); + return $result; } # custom query subroutine for Moby::Central.pm->RetrieveServiceNames From mwilkinson at pub.open-bio.org Thu Jul 21 16:37:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jul 2005 12:37:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211637.j6LGbZrO029143@pub.open-bio.org> mwilkinson Thu Jul 21 12:37:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29120/MOBY Modified Files: Central.pm service_instance.pm Log Message: updating the service discovery code to be in-line with the new adaptor API moby-live/Perl/MOBY Central.pm,1.163,1.164 service_instance.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.163 retrieving revision 1.164 diff -u -r1.163 -r1.164 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/20 17:12:20 1.163 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 16:37:35 1.164 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::Client::Central; +#use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -762,7 +762,7 @@ unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my $result = $adaptor->query_service_instance({service_type_uri => $existingURI}); + my $result = $adaptor->query_service({service_type_uri => $existingURI}); my $row = shift(@$result); my $id = $row->{service_instance_id}; @@ -1888,7 +1888,13 @@ $debug && _LOG( "authoritative added; criterion count is now $criterion_count\n"); - my $ids = $adaptor->query_service_instance({authoritative => $findme{authoritative}}); + my $ids = _extract_ids($adaptor->query_service_instance({authoritative => $findme{authoritative}})); + + + + ### MARK - we need to extract ids at each step... + + unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1923,7 +1929,7 @@ $children_string .= ( join ',', map { "\'$_\'" } @children ); } $children_string =~ s/\,$//; - my $ids = $adaptor->match_service_type_uri({service_type_uri => $children_string}); + my $ids = _extract_ids($adaptor->match_service_type_uri({service_type_uri => $children_string})); $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); @@ -1946,7 +1952,7 @@ return &_serviceListResponse( $dbh, undef ); } - my $ids = $adaptor->query_service_instance({authority_id => $id}); + my $ids = _extract_ids($adaptor->query_service_instance({authority_id => $id})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1965,7 +1971,7 @@ && _LOG( "servicename added; criterion count is now $criterion_count\n"); - my $ids = $adaptor->query_service_instance({servicename => $findme{servicename}}); + my $ids = _extract_ids($adaptor->query_service_instance({servicename => $findme{servicename}})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1984,7 +1990,7 @@ $debug && _LOG("category added; criterion count is now $criterion_count\n"); - my $ids = $adaptor->query_service_instance({category => lc( $findme{category}) }); + my $ids = _extract_ids($adaptor->query_service_instance({category => lc( $findme{category}) })); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -2003,6 +2009,7 @@ && _LOG("Keywords added; criterion count is now $criterion_count\n"); my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + $ids = _extract_ids($ids); # this is the hash-list that comes back from do_query unless ( scalar @{$ids} ) { $debug @@ -2146,6 +2153,20 @@ return &_serviceListResponse( $dbh, @final ); } +sub _extract_ids { + my ($linehash) = @_; + # ths data comes from the do_query of the mysql call + # --> [{...}] + my @lines = @$linehash; + return [] unless scalar(@lines); + my @ids; + foreach (@lines){ + my $id = $_->{service_instance_id}; + push @ids, $id; + } + return \@ids +} + #Eddie - converted sub _searchForServicesWithArticle { my ( $dbh, $inout, $node, $expand, $coll ) = @_; @@ -2190,9 +2211,8 @@ } $ancestor_string =~ s/\,$//; - my ($query, $result) = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); - $debug && _LOG("\nQUERY $query\n"); my @valid_services; foreach my $row (@$result) @@ -2242,10 +2262,8 @@ my ( $objectURI, $namespaceURIs ) = &_extractObjectTypesAndNamespaces($simple); - my ($query, $result) = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); - $debug && &_LOG("QUERY: $query"); - foreach my $row (@$result ) { # get the service instance ID and the namespaces that matched my $id = $row->{service_instance_id}; @@ -3392,7 +3410,7 @@ my $service_type = $OSserv->getServiceCommonName($service_type_uri); $result = $adaptor->query_authority({authority_id => $authority_id}); - my $row = shift(@$result); + $row = shift(@$result); my $authURI = $row->{authority_uri}; $output .= "\t\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/20 22:49:05 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 16:37:35 1.20 @@ -186,16 +186,6 @@ $self->{$attrname} = $self->_default_for($attrname); } } - - # category => $Category, - # servicename => $serviceName, - # service_type => $serviceType, - # authority_uri => $AuthURI, - # url => $URL, - # contact_email => $contactEmail, - # authoritative => $authoritativeService, - # description => $desc, - # return undef unless $self->authority_uri; return undef unless $self->servicename; @@ -222,9 +212,8 @@ ? $self->service_type_uri( $self->service_type ) : $self->service_type_uri($servicetypeURI); } - my $existing_services = $self->adaptor->query_service_instance( - servicename => $self->servicename, - authority_uri => $self->authority_uri); + my $existing_services = $self->adaptor->query_service_instance({servicename => $self->servicename},"and", + {authority_uri => $self->authority_uri}); my $existing_service = shift(@$existing_services); if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); @@ -316,15 +305,9 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; my $authority; - - my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + + my $result = $adaptor->query_service_existence(authority_uri => $self->authority_uri, servicename => $self->servicename); my $row = shift(@$result); - my $id = $row->{authority_id}; - - return undef unless $id; - - $result = $adaptor->query_service_instance({authority_id => $id}, 'and', {servicename => $self->servicename}); - $row = shift(@$result); my $svc = $row->{service_instance_id}; return $svc; From mwilkinson at pub.open-bio.org Thu Jul 21 17:08:43 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jul 2005 13:08:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211708.j6LH8hK2029352@pub.open-bio.org> mwilkinson Thu Jul 21 13:08:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29333/MOBY Modified Files: Central.pm Log Message: mistakenly commented out that line moby-live/Perl/MOBY Central.pm,1.164,1.165 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.164 retrieving revision 1.165 diff -u -r1.164 -r1.165 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 16:37:35 1.164 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 17:08:43 1.165 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -#use MOBY::Client::Central; +use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; From mwilkinson at pub.open-bio.org Thu Jul 21 17:43:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 21 Jul 2005 13:43:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507211743.j6LHhOxD029513@pub.open-bio.org> mwilkinson Thu Jul 21 13:43:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29494/MOBY Modified Files: service_instance.pm Log Message: service_instance_exists needs to return boolean moby-live/Perl/MOBY service_instance.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 16:37:35 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 17:43:24 1.21 @@ -307,10 +307,7 @@ my $authority; my $result = $adaptor->query_service_existence(authority_uri => $self->authority_uri, servicename => $self->servicename); - my $row = shift(@$result); - my $svc = $row->{service_instance_id}; - - return $svc; + return $result } sub _get_authority From gordonp at pub.open-bio.org Fri Jul 22 05:00:58 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:00:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220500.j6M50wgR030700@pub.open-bio.org> gordonp Fri Jul 22 01:00:58 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv30675 Modified Files: SimpleClient.html Log Message: Finally got around to creating the jMOBY data instance documentation moby-live/Java/docs SimpleClient.html,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/SimpleClient.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/docs/SimpleClient.html 2005/05/19 10:56:06 1.2 +++ /home/repository/moby/moby-live/Java/docs/SimpleClient.html 2005/07/22 05:00:58 1.3 @@ -1,24 +1,263 @@ - -Simple Client - - - - - - -

-

Simple Client

-
- -
-Coming soon... (or later) -
- -
-
-
Paul Gordon
+ + + + + + jMOBY Client/Server Quickstart + + + +

jMOBY Client/Server Quickstart

+ +

Motivation

+

+ This document is intended to get you up and running using the client-server service communication + code (i.e. calling or providing remote Web Services) in the Java implementation + (jMOBY) of + MOBY-S "Web Services for Molecular Biology". If you are looking + for more detailed information on how to query MOBY Central's yellow pages about what services are + available, please see this + document. This document assumes that you are familiar with Java and + XML. +

+ +

Syntax Notes

+

+

    +
  • jMOBY class, member and method names are display in this font face
  • +
  • System.out.println("Example code is treated like + a block quote (indented paragraph)");
  • +
  • MOBY-S XML elements and attributes are displayed in this font face
  • + +
+

+ +

Sections

+

+

+

+ + +
+ + +

Basic Anatomy of the Java API

+

+ Three main classes form the core of the API: +

    +
  1. org.biomoby.shared.data.MobyDataObject - + any valid + data object + you want to transmit will be encoded using methods in this class or its subclasses. You never + need to handcode any XML (but of course you can if you really want to).
  2. + +
  3. org.biomoby.shared.data.MobyDataObjectSet - for grouping MobyDataObjects together, + implements the Java Collection interface, + and is the equivalent of the + Collection + container + element in the current MOBY-S API.
  4. + +
  5. org.biomoby.shared.MobyRequest - this class handles all of the network communication + (SOAP + messaging) required between client and server.
  6. +
+

+ +

+ Be sure to include the following statements in the header for any class in which you plan to use jMOBY + service communication: +

import org.biomoby.client.*;
import org.biomoby.shared.*;
import org.biomoby.shared.data.*;
+

+ +
+ +

Hello World (or its bioinformatics equivalent)

+ +

+ The following code has two parts. First, a service called "MOBYSHoundGetGenBankff" is found via MOBY Central. + This service fetches sequences based on keys such as GenBank gi identifiers. Second, the service + is called using MobyRequest with a sample input MobyDataObject. The result of the + service invocation (a DNA sequence in XML) is printed. + +

+
            
+import org.biomoby.client.*;
+import org.biomoby.shared.*;
+import org.biomoby.shared.data.*;
+
+public class HelloMOBY {
+    public static void main(String[] args) throws Exception{
+
+        Central worker = new CentralImpl();
+        MobyService templateService = new MobyService("MOBYSHoundGetGenBankff");
+        MobyService[] validServices = worker.findService(templateService);
+
+	MobyRequest mr = new MobyRequest(worker);
+	mr.setService(validServices[0]);
+	mr.setInput(new MobyDataObject("NCBI_gi", "111076"));
+	System.out.println(mr.invokeService().toString());
+    }
+}
+	  
+ + A version of this code with comments and error checking is available in the +
MOBY CVS as Java/src/Clients/TestRequest.java +
+ +

Creating jMOBY Data

+

+ The Java API is designed so that all of the MOBY-S XML concepts can be "get" or "set" using Java primitives + (Strings, Numbers, etc.) as parameters to class methods. You do not need to + write or parse XML. There are several key features of jMOBY that minimize the number of classes you need to + familiarize yourself with: +

+

+ +

Because of the input/output symmetry of service data, MOBY objects are highly reusable when you are trying to chain + together multiple service discoveries and invocations. If you are interested in creating + reusable workflows (MOBY macros of sorts), you may wish to look at Taverna. +

+ + +

Creating a database identifier object

+

Database identifiers are often the starting point for workflows, as they can be used to retrieve sequence data, + which is then visualized or submitted to other services. All MOBY objects have +a namespace and an ID, +therefore a database identifier is the simplest form of a object. A MobyDataObject constructor is available +to easily build database identifiers (MobyDataObject(String namespace, String id)): + +

MobyDataObject dbid = new MobyDataObject("NCBI_gi", "111076");
+ +

+ +

Creating a "primitive" data object

+

+The following data are considered irreducible, atomic, or "primitive" in MOBY: + + + + + + + + + + + +
MOBY SpecificationjMOBY class in org.biomoby.shared.dataunderlying Java implementationCan be instantiated using any one of
ObjectMobyDataObjectimplements Comparable
  • "namespace", "id"
  • MOBYDataObject (cloning)
StringMobyDataStringjava.lang.StringBuffer
IntegerMobyDataIntjava.math.BigInteger
  • int
  • java.lang.Number (i.e. Byte, Double, Float, Integer, Long, Short, BigInteger, BigDecimal)
  • Strings like "2005"
FloatMobyDataFloatjava.math.BigDecimal
  • double
  • java.lang.Number
  • Strings like "2.0-e4" or "0.0002"
DateTimeMobyDataDateTimejava.util.GregorianCalendar
+Any object can also be instantiated using the corresponding XML data as an org.w3c.dom.Element. +

+

Below are some (hopefully) self-explanatory primitive object creation examples: +

MobyDataString sequenceString = new MobyDataString("MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSPGYVEHNPDEIWNAQMLAI");
+
MobyDataInt sequenceLength = new MobyDataInt(60);
+
MobyDataFloat sequencePI = new MobyDataFloat(3.67);
+
MobyDataFloat sequenceBlastEValue = new MobyDataFloat("1e-29");
+
MobyDataDateTime blastDBUpdated = new MobyDataDateTime("2005-03-24");
+
+

+ +

Creating composite objects

+

Many times, you will want to send a piece of data that is more complex than a primitive. These can be built using +MobyDataComposite, which implements the java.util.Map interface. For example, if a service requires an +AminoAcidSequence as input, +its two members, SequenceString and Length can be set like so: + +

+String aaSequence = "MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSPGYVEHNPDEIWNAQMLAI";
+MobyDataComposite aaSequenceObject = new MobyDataComposite("AminoAcidSequence");
+aaSequence.put("SequenceString", new MobyDataString(aaSequence));
+aaSequence.put("Length", new MobyDataInt(aaSequence.length()));
+
+ +

+
+ + +

Manipulating jMOBY data

+

+Coming soon. +

+ +

Dissecting queries and responses

+

Changing data objects

+
+
+

Creating MOBY XML (responses and queries)

+

+ It may at times be necessary to explicitly create a + full MOBY + XML document (i.e. serialize jMOBY objects). For example to store a response on disk for later usage, or + just so you can create your own SOAP response as a service provider. The + org.biomoby.shared.data.MobyDataUtils class provides the ability to output + XML documents, by specifiying an java.io.OutputStream and the contents. +

+ +

Create a blank MOBY XML response

+

+ Use the one-object convenience constructor for org.biomoby.shared.data.MobyContentInstance. + It will automatically create the content envelope. Since the object (first arg) is null, the mobyData + will be blank. This data envelope is then made into a proper XML file, with declarations and all, by + MobyDataUtils. + +

MobyDataUtils.toXMLDocument(System.out, new MobyContentInstance(null, null));
+

+ +

Create a MOBY XML response or query with a single data object

+

+ Use the one-object convenience constructor for MobyContentInstance. It will automatically + create the full content envelope and embed the XML for your object. The object must be or inherit from + MobyDataObject (Simples), or MobyDataObjectSet (Collections) + to form a valid content envelope. + +

MobyDataUtils.toXMLDocument(System.out, new MobyContentInstance(new + MobyDataObject("gi", "100089"), null));
+

+ +

Create a MOBY XML response or query envelope with multiple invocations

+

+ Use the default constructor for MobyContentInstance, then add at least one MobyDataInstance +to it using the java.lang.Map interface or the convenient one-arg put method. +

+MobyContentInstance queries = new MobyContentInstance();
+data.put(new MobyDataObject("gi", "100089"));
+data.put(new MobyDataObject("gi", "324442"));
+MobyDataUtils.toXMLDocument(System.out, queries);
+
+
+ +

Parsing MOBY XML

+ +

As a counterpart to the utility above, jMOBY provides a method to deserialize a response/request envelope: +

+MobyContentInstance queries = MobyDataUtils.fromXMLDocument(System.in);
+System.out.println("The document contained " + ((queries.size() == 1) ? "1 query" : (query.size() + " queries")));
+
+

+ + +
+
Paul Gordon
+ -Last modified: Tue May 17 15:34:15 2005 +Last modified: Thu Jul 21 23:45:59 MDT 2005 -
- + + From gordonp at pub.open-bio.org Fri Jul 22 05:11:54 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:11:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220511.j6M5Bsa7030848@pub.open-bio.org> gordonp Fri Jul 22 01:11:54 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory pub.open-bio.org:/tmp/cvs-serv30795 Modified Files: MobyDataComposite.java MobyDataDateTime.java MobyDataFloat.java MobyDataInt.java MobyDataObject.java MobyDataObjectSet.java MobyDataSecondaryInstance.java MobyDataString.java Added Files: MobyContentInstance.java MobyDataUtils.java Log Message: First major release of fully functional data instance code moby-live/Java/src/main/org/biomoby/shared/data MobyContentInstance.java,NONE,1.1 MobyDataUtils.java,NONE,1.1 MobyDataComposite.java,1.2,1.3 MobyDataDateTime.java,1.2,1.3 MobyDataFloat.java,1.2,1.3 MobyDataInt.java,1.2,1.3 MobyDataObject.java,1.3,1.4 MobyDataObjectSet.java,1.2,1.3 MobyDataSecondaryInstance.java,1.2,1.3 MobyDataString.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataComposite.java 2005/07/22 05:11:54 1.3 @@ -11,6 +11,7 @@ import java.util.Vector; import org.biomoby.shared.MobyDataType; +import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyNamespace; /** @@ -28,9 +29,9 @@ /** * Construct the object using a DOM fragment. * - * @throws IllegalArgumentException if the element is not a MobyObject tag + * @throws MobyException if the element is not a MobyObject tag */ - public MobyDataComposite(org.w3c.dom.Element element) throws IllegalArgumentException{ + public MobyDataComposite(org.w3c.dom.Element element) throws MobyException{ this(new MobyDataType(element.getLocalName()), getName(element), getNamespace(element), getId(element)); // Decompose the children @@ -70,6 +71,23 @@ members = new HashMap(); } + public MobyDataComposite(MobyDataType type, String name){ + this(type, name, "", ""); + } + + public MobyDataComposite(String typeName, String name){ + this(new MobyDataType(typeName), name); + } + + public MobyDataComposite(MobyDataType type){ + this(type, ""); + } + + public MobyDataComposite(String typeName){ + this(new MobyDataType(typeName)); + } + + /** * Report whether all required fields for the object's datatype have been instantiated * (i.e. the object is ready to use as input to a service). @@ -108,6 +126,10 @@ for(int i = 0; i < fieldNames.length; i++){ //MobyDataObject mdsi = members.get(fieldNames[i]); //Java1.5 MobyDataObject mdsi = (MobyDataObject) members.get(fieldNames[i]); + // ensure the articleName is set correctly for the requirements of this object + if(!fieldNames[i].toString().equals(mdsi.getName())){ + mdsi.setName(fieldNames[i].toString()); + } int oldXmlMode = mdsi.getXmlMode(); if(oldXmlMode != MobyDataInstance.SERVICE_XML_MODE){ mdsi.setXmlMode(MobyDataInstance.SERVICE_XML_MODE); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataDateTime.java 2005/07/22 05:11:54 1.3 @@ -40,7 +40,7 @@ } /** - * Constructor to build a MOBY DateTime object using an ISO 8601 formatted input string. + * Constructor to build a MOBY DateTime object using the W3C profile of an ISO 8601 formatted input string. * @param stringISO8601 if null, the current local date and time is used */ public MobyDataDateTime(String articleName, String stringISO8601) throws IllegalArgumentException{ @@ -49,6 +49,10 @@ value = parseISO8601(stringISO8601); } + public MobyDataDateTime(String stringISO8601){ + this("", stringISO8601); + } + public MobyDataDateTime(String articleName, GregorianCalendar cal){ super(articleName, ""); setDataType(new MobyDataType("DateTime")); @@ -56,6 +60,10 @@ ((StringBuffer) super.getObject()).append(toString()); // set string representation in case super.toXML() is called explicitly } + public MobyDataDateTime(GregorianCalendar cal){ + this("", cal); + } + /** * For a description of ISO 8601 as used on the Web, see http://www.w3.org/TR/NOTE-datetime * This method is based on org.w3.util.DateParser v. 1.4 by Benoît Mahé (bmahe at w3.org) =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataFloat.java 2005/07/22 05:11:54 1.3 @@ -49,6 +49,10 @@ } } + public MobyDataFloat(Number n){ + this("", n); + } + /** * Constructor to use if the incoming value is a primitive. * If you want to pass in a float or int, cast it to a double. @@ -59,6 +63,10 @@ value = new BigDecimal(d); } + public MobyDataFloat(double d){ + this("", d); + } + /** * Constructor to use if the incoming value is a string representing a number * (including mantissa/exponent format). @@ -71,6 +79,10 @@ value = new BigDecimal(stringNumber); } + public MobyDataFloat(String stringNumber){ + this("", stringNumber); + } + public Object clone(){ MobyDataFloat copy = new MobyDataFloat(getName(), value); copy.setDataType(getDataType()); =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInt.java 2005/07/22 05:11:54 1.3 @@ -50,6 +50,10 @@ } } + public MobyDataInt(Number n){ + this("", n); + } + /** * Constructor to use if the incoming value is a primitive. * If you want to pass in a float or double, cast it to an int. @@ -60,6 +64,10 @@ value = new BigInteger(""+i); } + public MobyDataInt(int i){ + this("", i); + } + /** * Constructor to use if the incoming value is a string representing an integer number. * =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/07/19 12:39:59 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObject.java 2005/07/22 05:11:54 1.4 @@ -45,9 +45,9 @@ /** * Construct the object using a DOM fragment. * - * @throws IllegalArgumentException if the element is not an Object tag + * @throws MobyException if the element is not an Object tag, or is missing a required attribute */ - public MobyDataObject(Element element) throws IllegalArgumentException{ + public MobyDataObject(Element element) throws MobyException{ this(getNamespace(element).getName(), getId(element)); setName(getName(element)); } @@ -58,6 +58,7 @@ */ public MobyDataObject(String name){ super(name); + setDataType(staticObjectDataType); } /** @@ -84,13 +85,14 @@ /** * This method creates a MobyDataObject of the appropriate subclass for * a given input XML tree (e.g. base objects like MobyDataObject and MobyDataInt, - * or complex objects like MobyDataDateTime or MobyDataComposite). This method + * or complex objects like MobyDataDateTime or MobyDataComposite, or even a + * MobyDataSecondaryInstance). This method * will also parse a MOBY XML Object wrapped in a Simple tag when the Simple * is passed in as the main element. * * @param objectTag the W3C DOM Element node corresponding to the object's enclosing tag, or a Simple tag */ - public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws IllegalArgumentException{ + public static MobyDataInstance createInstanceFromDOM(Element objectTag) throws MobyException{ MobyDataObject object = null; if(objectTag == null){ @@ -99,23 +101,31 @@ String objectClass = objectTag.getLocalName(); if("Simple".equals(objectClass)){ - NodeList children = objectTag.getElementsByTagName("*"); + NodeList children = objectTag.getChildNodes(); + int elementChild = -1; + for(int i = 0; i < children.getLength(); i++){ + if(children.item(i) instanceof Element){ + // Second instance of element child + if(elementChild != -1){ + throw new IllegalArgumentException("Simple element has more than one " + + "child element, cannot create a MOBY data " + + "instance due to the ambiguity of the input XML"); + } + elementChild = i; + } + } // A Simple tag is allowed to have exactly one child element - if(children.getLength() == 0){ + if(elementChild == -1){ throw new IllegalArgumentException("Simple element has no MOBY " + "child element, there is no " + "instance to create"); } - else if(children.getLength() != 1){ - throw new IllegalArgumentException("Simple element has more than one " + - "child element, cannot create a MOBY data " + - "instance due to the ambiguity of the input XML"); - } - return createInstanceFromDOM((Element) children.item(0)); + + return createInstanceFromDOM((Element) children.item(elementChild)); } // There are six types of objects we can populate with data directly - // plus Collections. Otherwise its a composite. + // plus Collections and Secondary Parameters. Otherwise it is a composite. else if("Object".equals(objectClass)){ return new MobyDataObject(objectTag); } @@ -137,14 +147,22 @@ else if("Collection".equals(objectClass)){ return new MobyDataObjectSet(objectTag); } + else if(MobyDataSecondaryInstance.ELEMENT_NAME.equals(objectClass)){ + return new MobyDataSecondaryInstance(objectTag); + } // Must otherwise be a composite else{ return new MobyDataComposite(objectTag); } } - protected static String getTextContents(Element element){ - NodeList children = element.getChildNodes(); + /** + * Similar to DOM level 3 getTextContent, but only elements are excepted as input, and text + * inside children elements is not picked up. + * Actually calls MobyObjectDecompositionImpl.getTextContent() + */ + public static String getTextContents(Element element){ + /* NodeList children = element.getChildNodes(); int numChildren = children.getLength(); StringBuffer textContents = new StringBuffer(); for(int i = 0; i < numChildren; i++){ @@ -153,8 +171,8 @@ childNode instanceof org.w3c.dom.CDATASection){ textContents.append(childNode.getNodeValue()); } - } - return textContents.toString(); + }*/ + return MobyObjectDecompositionImpl.getTextContent(element, false); } protected static MobyNamespace getNamespace(Element e){ @@ -165,7 +183,7 @@ /** * Determine the name of the element if the parent Simple exists */ - protected static String getName(Element e){ + public static String getName(Element e){ Node p = e.getParentNode(); if(p == null || !(p instanceof Element)){ return ""; @@ -174,7 +192,7 @@ return name == null ? "" : name; } - protected static String getId(Element e){ + public static String getId(Element e){ String id = e.getAttribute("id"); return id == null ? "" : id; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSet.java 2005/07/22 05:11:54 1.3 @@ -6,6 +6,7 @@ import java.util.Iterator; import java.util.Vector; +import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyPrimaryDataSet; import org.biomoby.shared.MobyPrefixResolver; @@ -26,11 +27,11 @@ Vector bag; private int xmlMode = MobyDataInstance.SERVICE_XML_MODE; - public MobyDataObjectSet(org.w3c.dom.Element e) throws IllegalArgumentException{ + public MobyDataObjectSet(org.w3c.dom.Element e) throws MobyException{ this(MobyDataObject.getName(e), getChildren(e)); } - public static Collection getChildren(org.w3c.dom.Element e){ + public static Collection getChildren(org.w3c.dom.Element e) throws MobyException{ Vector members = new Vector(); org.w3c.dom.NodeList children = e.getElementsByTagName("*"); //wildcard @@ -102,7 +103,8 @@ * @return the MobyDataObjects that comprise the collection */ public MobyDataObject[] getElementInstances(){ - return (MobyDataObject[]) bag.toArray(); + MobyDataObject instances[] = new MobyDataObject[bag.size()]; + return (MobyDataObject[]) bag.toArray(instances); } private void checkInputClass(String action, Object mdsi) throws ClassCastException, NullPointerException{ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/07/19 12:59:21 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataSecondaryInstance.java 2005/07/22 05:11:54 1.3 @@ -1,14 +1,18 @@ package org.biomoby.shared.data; -import org.biomoby.shared.MobySecondaryData; + +import org.biomoby.shared.*; +import org.w3c.dom.*; /** * A class that holds and displays secondary input data to a service. */ -public class MobyDataSecondaryInstance extends MobySecondaryData{ +public class MobyDataSecondaryInstance extends MobySecondaryData implements MobyDataInstance{ protected String dataValue = null; - protected MobySecondaryData secDataType = null; + protected int xmlMode = MobyDataInstance.CENTRAL_XML_MODE; + public static final String ELEMENT_NAME = "Parameter"; + public static final String VALUE_NAME = "Value"; public MobyDataSecondaryInstance(MobySecondaryData type, String value){ this(type); @@ -26,7 +30,40 @@ setDefaultValue(type.getDefaultValue()); setMinimumValue(type.getMinimumValue()); setMaximumValue(type.getMaximumValue()); - secDataType = type; + } + + /** + * Create an instance from XML input. Unfortunately, under the current scheme + * we have no way of knowing what the type of the parameter is (int, string, etc.). + * By default we will treat it as a string, as this is the most lenient. + */ + public MobyDataSecondaryInstance(Element objectTag) throws MobyException{ + // What is the parameter name? + super(MobyDataObject.getName(objectTag)); + setDataType("String"); + + if(objectTag == null){ + return; + } + + String objectClass = objectTag.getLocalName(); + if(!ELEMENT_NAME.equals(objectClass)){ + throw new MobyException("While creating a secondary parameter instance from XML: " + + "the passed in element (" +objectClass + ") was not a " + ELEMENT_NAME); + } + NodeList values = objectTag.getElementsByTagNameNS(MobyPrefixResolver.MOBY_XML_NAMESPACE, VALUE_NAME); + if(values.getLength() == 0){ + throw new MobyException("While creating a secondary parameter instance from XML: " + + "No " + VALUE_NAME + " element in the namespace " + + MobyPrefixResolver.MOBY_XML_NAMESPACE + " was found"); + } + if(values.getLength() > 1){ + throw new MobyException("While creating a secondary parameter instance from XML: " + + "More than one " + VALUE_NAME + " element ("+ + values.getLength() +") in the namespace " + + MobyPrefixResolver.MOBY_XML_NAMESPACE + " was found"); + } + setValue(MobyDataObject.getTextContents((Element) values.item(0))); } public void setValue(String value) throws IllegalArgumentException{ @@ -37,9 +74,51 @@ return dataValue; } + public void setXmlMode(int mode) throws IllegalArgumentException{ + if(mode != MobyDataInstance.CENTRAL_XML_MODE && mode != MobyDataInstance.SERVICE_XML_MODE){ + throw new IllegalArgumentException("Value passed to setXmlMode was neither " + + "MobyDataInstance.CENTRAL_XML_MODE nor MobyDataInstance.SERVICE_XML_MODE"); + } + xmlMode = mode; + } + + /** + * Report whether toXML will produce Central template or service call instance XML. + * + * @return one of CENTRAL_XML_MODE or SERVICE_XML_MODE + */ + public int getXmlMode(){ + return xmlMode; + } + + /** + * This method sanitizes parameter data value strings of XML escape characters such as the ampersand (&) and the + * less-than sign (<). WARNING: this method will not escape ampersand in the string "&amp;", + * or '&#x26;' style character references. We will assume that is this case you've probably + * already written the string as XML. Also note that null strings are treated as empty strings. + * + * WARNING: As of yet, we do not deal with the false escaping of strings containg already-escaped + * CDATA sections! + */ public String toXML(){ - return " " + dataValue + "\n"; + // Sanitize the data before adding to the XML + String tmpValue = dataValue; + if(tmpValue != null){ + tmpValue = tmpValue.replaceAll("&(?!(amp|#x\\d+);)", "&"); + tmpValue = tmpValue.replaceAll("<", "<"); + } + // A null value and an empty string are considered equivalent here + else{ + tmpValue = ""; + } + + if(xmlMode == MobyDataInstance.SERVICE_XML_MODE){ + return " " + tmpValue + "\n"; + } + else{ + return super.toXML(); + } } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2005/05/19 15:57:26 1.2 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataString.java 2005/07/22 05:11:54 1.3 @@ -36,6 +36,10 @@ value = new StringBuffer(stringValue.toString()); } + public MobyDataString(CharSequence stringValue){ + this("", stringValue); + } + public String toString(){ return value.toString(); } @@ -63,7 +67,7 @@ * This method sanitizes strings of XML escape characters such as the ampersand (&) and the * less-than sign (<). WARNING: this method will not escape ampersand in the string "&amp;", * or '&#x26;' style character references. We will assume that is this case you've probably - * already written the string as XML. + * already written the string as XML. Also note that null strings are treated as empty strings. * * WARNING: As of yet, we do not deal with the false escaping of strings containg already-escaped * CDATA sections! @@ -76,6 +80,9 @@ tmpValue = tmpValue.replaceAll("&(?!(amp|#x\\d+);)", "&"); tmpValue = tmpValue.replaceAll("<", "<"); } + else{ + tmpValue = ""; + } return "" + tmpValue + ""; } From gordonp at pub.open-bio.org Fri Jul 22 05:16:08 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:16:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220516.j6M5G8cY030883@pub.open-bio.org> gordonp Fri Jul 22 01:16:08 EDT 2005 Update of /home/repository/moby/moby-live/Java/docs In directory pub.open-bio.org:/tmp/cvs-serv30858 Modified Files: ChangeLog Log Message: Noted updates to code and documentation of org.biomoby.shared.data moby-live/Java/docs ChangeLog,1.31,1.32 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/ChangeLog,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/07/19 12:39:58 1.31 +++ /home/repository/moby/moby-live/Java/docs/ChangeLog 2005/07/22 05:16:08 1.32 @@ -1,3 +1,9 @@ +2005-07-21 Paul Gordon + + * Update of data instance code to fully functional status (pending minor changes to the MOBY-S API docs) + + * Inclusion of "quick start" guide to using the classes in org.biomoby.shared.data + 2005-07-19 Martin Senger * Changed the remote repository for the third-party jar files. From gordonp at pub.open-bio.org Fri Jul 22 05:23:00 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:23:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220523.j6M5N0nx030932@pub.open-bio.org> gordonp Fri Jul 22 01:23:00 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory pub.open-bio.org:/tmp/cvs-serv30907 Modified Files: MobyRequest.java Log Message: Updated to use the new data instance classes moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/19 13:16:53 1.13 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/07/22 05:23:00 1.14 @@ -23,10 +23,7 @@ import org.apache.xpath.objects.XObject; import org.biomoby.shared.Central; import org.biomoby.shared.MobyData; -import org.biomoby.shared.data.MobyDataInstance; -import org.biomoby.shared.data.MobyDataSecondaryInstance; -import org.biomoby.shared.data.MobyDataObjectSet; -import org.biomoby.shared.data.MobyDataObject; +import org.biomoby.shared.data.*; import org.biomoby.shared.MobyException; import org.biomoby.shared.MobyPrefixResolver; import org.biomoby.shared.MobyService; @@ -58,7 +55,7 @@ protected MobyService mobyService = null; protected MobyDataInstance[] inputData = null; protected MobyDataSecondaryInstance[] secondaryData = null; - protected Vector outputData = null; + protected MobyContentInstance outputData = null; protected Central mobyCentral = null; protected PrefixResolver mobyPrefixResolver = null; @@ -76,7 +73,6 @@ private XPath stringEncodedXPath; private XPath base64EncodedXPath; - private XPath queryResponseXPath; private XPath simpleChildXPath; private XPath collectionChildXPath; @@ -117,9 +113,8 @@ MobyPrefixResolver.XSI1999_PREFIX+ ":type, ':')=\"string\" or substring-after(@"+ MobyPrefixResolver.XSI2001_PREFIX+ - ":type, ':')=\"string\"]", null, - mobyPrefixResolver, XPath.SELECT); - queryResponseXPath = new XPath("//moby:mobyData | //mobyData", null, + ":type, ':')=\"string\"] | //"+ + MobyPrefixResolver.SOAP_ENC_PREFIX+":string", null, mobyPrefixResolver, XPath.SELECT); simpleChildXPath = new XPath("moby:Simple | Simple", null, mobyPrefixResolver, XPath.SELECT); @@ -233,7 +228,7 @@ * * @throws MobyException if you try to get the results before calling InvokeService */ - public Vector getOutput() throws MobyException{ + public MobyContentInstance getOutput() throws MobyException{ if(outputData == null){ throw new MobyException("Trying to access MOBY service results " + "before the service is invoked"); @@ -255,7 +250,7 @@ * @throws MobyException i.e. there was something wrong with the input, output or remote service's logic * @throws SOAPException i.e. there was a problem with the underlying transaction/transport layer */ - public Vector invokeService() throws MobyException, SOAPException, NoSuccessException{ + public MobyContentInstance invokeService() throws Exception, MobyException, SOAPException, NoSuccessException{ if(mobyService == null){ throw new MobyException("Tries to invoke null service from MobyRequest (call setService first)"); } @@ -264,7 +259,8 @@ verifyInput(); String mobyXML = convertMOBYDataToMOBYRequest(inputData, secondaryData); Element mobyDOM = performSOAPRequest(mobyXML); - outputData = convertMOBYResponseToMOBYData(mobyDOM); + // The following parses the DOM and extracts all the appropriate jMOBY objects to represent the XML in Java + outputData = MobyDataUtils.fromXMLDocument(mobyDOM); return outputData; } @@ -418,8 +414,9 @@ XPath responseElementXPath = null; try{ responseElementXPath = new XPath("//"+ MobyPrefixResolver.MOBY_TRANSPORT_PREFIX+ - ":"+mobyService.getName()+"Response", - null, mobyPrefixResolver, XPath.SELECT); + ":"+mobyService.getName()+"Response | //" + + mobyService.getName()+"Response", + null, mobyPrefixResolver, XPath.SELECT); }catch(TransformerException te){ throw new SOAPException("Cannot select SOAP nodes due to exception "+ "while compiling XPath statement (code bug?):" +te); @@ -480,11 +477,11 @@ node_list = runXPath(stringEncodedXPath, responseNode); } catch(TransformerException te){ - throw new SOAPException("Cannot select base64 encoded SOAP nodes due to exception "+ + throw new SOAPException("Cannot select string encoded SOAP nodes due to exception "+ "while executing XPath statement:" +te); } - // Do decoding for each base64 part found + // Do concatenation for each plain string part found for(int i = 0; node_list != null && i < node_list.getLength(); i++){ org.w3c.dom.Node change = node_list.item(i); /* Make sure the text data is all put into one contiguous piece for decoding*/ @@ -497,11 +494,12 @@ Node child = children.item(j); if(child instanceof CDATASection || child instanceof Text){ plainString += child.getNodeValue(); + System.err.println("Plain string is now " + plainString); } } // Swap out this node for the decoded data - change.getParentNode().replaceChild(n.getOwnerDocument().createTextNode(plainString), change); + change.getParentNode().replaceChild(n.getOwnerDocument().createCDATASection(plainString), change); } if(debug && node_list != null){ debugPS.println("There were " + node_list.getLength() + @@ -523,7 +521,14 @@ for(int j = 0; j < children.getLength(); j++){ Node child = children.item(j); if(child instanceof CDATASection || child instanceof Text){ - responseString += child.getNodeValue(); + // Unescape XML special characters in the string, so we can later on + // parse the payload as regular XML. + // Ignore whitespace-only node + if(child.getNodeValue().matches("^\\s+$")){ + continue; + } + System.err.println("Concatenating text in response " + child.getNodeValue()); + responseString += child.getNodeValue();//.replaceAll("<", "<").replaceAll(">", ">").replaceAll("(&|F)", "&"); } } @@ -639,103 +644,6 @@ } /** - * This method takes the internally stored DOM, representing the MOBY response - * from the service and converst it into the standard jMOBY API Data representation. - * - * @throws MobyException if the MOBY message does not conform to the API - */ - public Vector convertMOBYResponseToMOBYData(Element n) throws MobyException{ - // - Vector responsesOutput = new Vector(); - - NodeList response_list = null; - try{ - response_list = runXPath(queryResponseXPath, n); - }catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyContent nodes due to exception "+ - "while executing XPath statement: " +te); - } - - if(response_list == null || response_list.getLength() == 0){ - throw new MobyException("Could not find any mobyContent elements in the output"); - } - if(debug){ - debugPS.println("Aha! Got " + response_list.getLength() + " mobyContent response elements"); - } - // Do data decoding for each response's mobyData - for(int i = 0; i < response_list.getLength(); i++){ - Node response = response_list.item(i); - - Vector out = new Vector(); - // Find all the collections in the response - NodeList collections = null; - try{ - collections = runXPath(collectionChildXPath, response); - }catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyData/Collection nodes due to exception "+ - "while executing XPath statement: " +te); - } - for(int j = 0; collections != null && j < collections.getLength(); j++){ - if(debug & j == 0) - debugPS.println("There are " + collections.getLength() + - " collections in response #" +i); - MobyDataObjectSet collection = new MobyDataObjectSet(""); - - // For each collection, find the simple children - NodeList subsimples = null; - try{subsimples = runXPath(simpleChildXPath, collections.item(j));} - catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyData/Collection/Simple " + - "nodes due to exception "+ - "while executing XPath statement: " +te); - } - - // And add their values to the collection - MobyDataObject[] subout = new MobyDataObject[subsimples.getLength()]; - for(int k = 0; k < subsimples.getLength(); k++){ - if(debug && k == 0) - debugPS.println("There are " + subsimples.getLength() + - " simples in response #" + i + - ", collection #" + j); - subout[k] = (MobyDataObject) MobyDataObject.createInstanceFromDOM((Element) subsimples.item(k)); - } - collection.setElements(subout); - releaseXPath(collections.item(j)); - // Add completed collection to the output list - out.add(collection); - } - - // Take all the top level simples and add them to the list - NodeList simples = null; - try{ - simples = runXPath(simpleChildXPath, response); - }catch(TransformerException te){ - throw new MobyException("Cannot select MOBY DOM mobyData/Collection nodes due to exception "+ - "while executing XPath statement: " +te); - } - if((collections == null || collections.getLength() == 0) && - (simples == null || simples.getLength() == 0)){ - debugPS.println("WARNING: There appears to be no output data in mobyData #" + i); - } - for(int j = 0; simples != null && j < simples.getLength(); j++){ - if(debug && j == 0) - debugPS.println("There are " + simples.getLength() + " simples in response #" +i); - out.add(MobyDataObject.createInstanceFromDOM((Element) simples.item(j))); - } - - // What we're building is a Vector, where each element represents - // a Response's DataInstance Output (i.e. Simple and Collection return values) - MobyDataInstance[] mdis = new MobyDataInstance[out.size()]; - responsesOutput.add(out.toArray(mdis)); - - releaseXPath(response); - } - // release resources related to the Xpath execution, since we won't be using this doc anymore - releaseXPath(n); - return responsesOutput; - } - - /** * A method that sets up the execution environm,ent for and runs a compiled XPath statement against a DOM node * You should call releaseXPath when you're done with the results * @return the list of Nodes that satisfy the XPath in this Node's context From gordonp at pub.open-bio.org Fri Jul 22 05:30:38 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:30:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220530.j6M5UcnE031024@pub.open-bio.org> gordonp Fri Jul 22 01:30:38 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv31003 Added Files: PrimitiveTypes.java Log Message: Moved this class from obsucred subpackage of client to shared, since it's pretty basic info moby-live/Java/src/main/org/biomoby/shared PrimitiveTypes.java,NONE,1.1 From gordonp at pub.open-bio.org Fri Jul 22 05:32:49 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:32:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220532.j6M5WnnO031059@pub.open-bio.org> gordonp Fri Jul 22 01:32:49 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv31034 Modified Files: MobyPrefixResolver.java Log Message: Utility methods added that are used by data instance classes for ease of parsing moby-live/Java/src/main/org/biomoby/shared MobyPrefixResolver.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrefixResolver.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrefixResolver.java 2005/02/09 17:39:17 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyPrefixResolver.java 2005/07/22 05:32:49 1.4 @@ -1,6 +1,8 @@ package org.biomoby.shared; import org.apache.xml.utils.PrefixResolver; +import org.w3c.dom.*; +import java.util.Vector; /** * The main purpose of this class is to provide default mapping from @@ -28,6 +30,8 @@ public static final String XSI_PREFIX = "xsi"; public static final String XSI1999_PREFIX = "xsi1999"; public static final String XSI2001_PREFIX = "xsi2001"; + public static final String SOAP_ENC_NAMESPACE ="http://schemas.xmlsoap.org/soap/encoding/"; + public static final String SOAP_ENC_PREFIX ="soap-enc"; /** * We don't really implement this as it can be extremely complicated. @@ -52,6 +56,45 @@ } /** + * Convenience method that matches attributes in the MOBY namespace or, for now + * at least, with no declared namespace. + * @return the value of the attribute, or null if the attribute does not exist + */ + public static NodeList getChildElements(org.w3c.dom.Element e, String elementName){ + MobyNodeList matches = new MobyNodeList(); + + NodeList children = e.getChildNodes(); + for(int j = 0; children != null && j < children.getLength(); j++){ + // Make sure it's an element, not a processing instruction, text, etc. + if(!(children.item(j) instanceof Element)){ + continue; + } + Element child = (Element) children.item(j); + // Make sure it has the right name + if(!elementName.equals(child.getLocalName())){ + continue; + } + // Make sure it's in the MOBY namespace, or no namespace at all + String uri = child.getNamespaceURI(); + if(uri != null && uri.length() != 0 && !uri.equals(MOBY_XML_NAMESPACE)){ + continue; + } + + // Everything looks good + matches.add(child); + } + return matches; + } + + static class MobyNodeList implements NodeList{ + private Vector nodes; + public MobyNodeList(){nodes = new Vector();} + public int getLength(){return nodes.size();} + public Node item(int index){return (Node) nodes.elementAt(index);} + public void add(Node n){nodes.add(n);} + }; + + /** * @return For now, default MOBY and XML Schema Instance (1999) prefices as defined in the class static variables */ public String getNamespaceForPrefix(java.lang.String prefix){ @@ -73,6 +116,9 @@ else if(XSI2001_PREFIX.equals(prefix)){ return XSI_NAMESPACE2001; //Used by Axis } + else if(SOAP_ENC_PREFIX.equals(prefix)){ + return SOAP_ENC_NAMESPACE; + } else{ return ""; // Indicates that we don't have a mapping for this prefix } @@ -81,7 +127,7 @@ /** * Don't use this class if this method will be used. We are not returning a * valid XML namespace mapping, but a convenience method for XPath, therefore - * we will not given context sensitive mapping. + * we will not give context sensitive mapping. */ public String getNamespaceForPrefix(java.lang.String prefix, org.w3c.dom.Node context){ return getNamespaceForPrefix(prefix); From gordonp at pub.open-bio.org Fri Jul 22 05:26:43 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 01:26:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507220526.j6M5Qhhw030979@pub.open-bio.org> gordonp Fri Jul 22 01:26:43 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory pub.open-bio.org:/tmp/cvs-serv30954 Modified Files: MobyObjectDecompositionImpl.java Log Message: Removed Java 1.5 (actually a DOM level 3) dependency by implementing getTextContent(Node) moby-live/Java/src/main/org/biomoby/shared MobyObjectDecompositionImpl.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyObjectDecompositionImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyObjectDecompositionImpl.java 2005/05/12 05:19:20 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyObjectDecompositionImpl.java 2005/07/22 05:26:43 1.5 @@ -21,7 +21,7 @@ import javax.xml.parsers.ParserConfigurationException; import org.biomoby.client.CentralImpl; -import org.biomoby.client.ui.graphical.applets.util.PrimitiveTypes; +import org.biomoby.shared.PrimitiveTypes; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -41,7 +41,7 @@ */ public class MobyObjectDecompositionImpl implements MobyObjectDecomposition { - private static final String URL_OBJECT = "http://mobycentral.cbr.nrc.ca:8090/authority/metadata?lsid="; + private static final String URL_OBJECT = "http://mobycentral.icapture.ubc.ca:8090/authority/metadata?lsid="; /* (non-Javadoc) * @see org.biomoby.client.gui.util.MobyObjectDecomposition#getFlattenedPrims(java.lang.String) @@ -80,7 +80,7 @@ "mobyPred:articleName").item(0); String localName = child.getLocalName(); String articleName = (articleNode == null) ? "" - : articleNode.getTextContent(); + : getTextContent(articleNode); // TODO - recurse if object is not a primitive if (isPrimitive(localName)) { MobyDataObject mdsi = createPrimitiveType( @@ -103,7 +103,7 @@ "mobyPred:articleName").item(0); String localName = child.getLocalName(); String articleName = (articleNode == null) ? "" - : articleNode.getTextContent(); + : getTextContent(articleNode); // TODO - recurse if object is not a primitive if (isPrimitive(localName)) { MobyDataObject mdsi = createPrimitiveType( @@ -154,6 +154,52 @@ return convertArrayListToMoby(list); } + /** + * Method to simulate DOM level 3 (Java 1.5 default) method for recursively getting text children from a Node. + * A wrapper around getTextContent(Node, boolean) with boolean = true, since DOM 3 getTextContent() ignores + * things that match Text.isContentElementWhitespace(). + */ + public static String getTextContent(Node parent){ + return getTextContent(parent, true); + } + + /** + * Grabs the text and CDATA children of a Node (not necessairly contiguous) and returns them concatenated. + * Added by Paul Gordon. + * Simulates ignoring of DOM 3 Text.isContentElementWhitespace() fully, I *think*. + * + * @param parent the node who's text children should be concatenated + * @param includeChildrensText if true, recursively appends children's text depth first + * + * @return non-normalized text contents of the passed-in Node, and its children if so requested + */ + public static String getTextContent(Node parent, boolean includeChildrensText){ + if(parent.hasChildNodes()){ + java.util.regex.Pattern nonWhitespacePattern = Pattern.compile("[^ \t\r\n]"); + StringBuffer textbuffer = new StringBuffer(); + + for(Node node = parent.getFirstChild(); node != null; node = node.getNextSibling()){ + // Append all the contiguous text data + if(node instanceof org.w3c.dom.Text || node instanceof org.w3c.dom.CDATASection){ + // Get rid of whitespace + String value = node.getNodeValue(); + // Add if not just whitespace. + if(nonWhitespacePattern.matcher(value).find()){ + textbuffer.append(value); + } + } + // Get contents of children elements too (recursive) + else{ + textbuffer.append(getTextContent(node, includeChildrensText)); + } + } + return textbuffer.toString(); + } + else{ + return ""; + } + } + /* (non-Javadoc) * @see org.biomoby.client.gui.util.MobyObjectDecomposition#getObjectComposition(java.lang.String) */ From mwilkinson at pub.open-bio.org Fri Jul 22 17:12:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:12:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221712.j6MHCDji000428@pub.open-bio.org> mwilkinson Fri Jul 22 13:12:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv390/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. This simplifies it and should fix it. Also fixed the documentation for the MOBY::Client::ServiceInstance object as per this mornings email moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/21 16:37:35 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:12:13 1.22 @@ -625,9 +625,23 @@ # where is lsid? sub query_service_instance { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - + + my $authority_id; + if ($args{'authority_uri'}){ # need to transform URI to a row ID + my $result = $self->query_authority({authority_uri => $args{'authority_uri'}}); + return 0 unless @$result[0]; + my $authority_id = @$result[0]->{authority_id}; + return 0 unless $authority_id; + } + delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table + my @args; + while (my ($k, $v) = each %args){ + push @args, ({$k => $v},"and"); # format for the add_condition subroutine + } + pop @args; # get rid of last "and" + my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 17:12:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:12:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221712.j6MHCDsv000452@pub.open-bio.org> mwilkinson Fri Jul 22 13:12:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv390/MOBY/Client Modified Files: ServiceInstance.pm Log Message: the logic for findig existing services was still wonky. This simplifies it and should fix it. Also fixed the documentation for the MOBY::Client::ServiceInstance object as per this mornings email moby-live/Perl/MOBY/Client ServiceInstance.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2005/05/30 21:39:05 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/ServiceInstance.pm 2005/07/22 17:12:13 1.15 @@ -17,8 +17,9 @@ contactEmail => markw at illumin.com, name => 'marksFabulousService', type => 'Retrieve', - category => 'moby', - output => 'Sequence', + input => [$SimpleArticle], + category => 'moby', + output => [$CollectionArticle, $SecondaryArticle], description => 'retrieves random sequences from a database', XML => $xml, # the XML from MOBY::Central::findService ); @@ -99,7 +100,8 @@ Title : input Usage : $input = $Service->input($args) - Args : (optional) listref of SimpleArticle and/or CollectionArticle objects + Args : (optional) listref of SimpleArticle, + CollectionArticle, or SecondaryArticle objects Function : get/set input Returns : listref of MOBY::Client::SimpleArticle and/or MOBY::Client::CollectionArticle objects @@ -110,7 +112,8 @@ Title : output Usage : $output = $Service->output($args) - Args : (optional) listref of SimpleArticle and/or CollectionArticle objects + Args : (optional) listref of SimpleArticle, + CollectionArticle, or SecondaryArticle objects Function : get/set output Returns : listref of MOBY::Client::SimpleArticle and/or MOBY::Client::CollectionArticle objects From mwilkinson at pub.open-bio.org Fri Jul 22 17:12:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:12:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221712.j6MHCDou000409@pub.open-bio.org> mwilkinson Fri Jul 22 13:12:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv390/MOBY Modified Files: Central.pm Log Message: the logic for findig existing services was still wonky. This simplifies it and should fix it. Also fixed the documentation for the MOBY::Client::ServiceInstance object as per this mornings email moby-live/Perl/MOBY Central.pm,1.165,1.166 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.165 retrieving revision 1.166 diff -u -r1.165 -r1.166 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/21 17:08:43 1.165 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 17:12:13 1.166 @@ -1888,7 +1888,7 @@ $debug && _LOG( "authoritative added; criterion count is now $criterion_count\n"); - my $ids = _extract_ids($adaptor->query_service_instance({authoritative => $findme{authoritative}})); + my $ids = _extract_ids($adaptor->query_service_instance(authoritative => $findme{authoritative})); @@ -1943,16 +1943,7 @@ ++$criterion_count; $debug && _LOG("authURI added; criterion count is now $criterion_count\n"); - - my $result = $adaptor->query_authority({authority_uri => $findme{authURI}}, 'or', {authority_common_name => $findme{authURI}}); - my $row = shift(@$result); - my $id = $row->{authority_id}; - - unless ($id) { - return &_serviceListResponse( $dbh, undef ); - } - - my $ids = _extract_ids($adaptor->query_service_instance({authority_id => $id})); + my $ids = _extract_ids($adaptor->query_service_instance(authority_uri => $findme{'authURI'})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1971,7 +1962,7 @@ && _LOG( "servicename added; criterion count is now $criterion_count\n"); - my $ids = _extract_ids($adaptor->query_service_instance({servicename => $findme{servicename}})); + my $ids = _extract_ids($adaptor->query_service_instance(servicename => $findme{servicename})); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -1990,7 +1981,7 @@ $debug && _LOG("category added; criterion count is now $criterion_count\n"); - my $ids = _extract_ids($adaptor->query_service_instance({category => lc( $findme{category}) })); + my $ids = _extract_ids($adaptor->query_service_instance(category => lc( $findme{category}) )); unless ( scalar @{$ids} ) { return &_serviceListResponse( $dbh, undef ); @@ -3387,7 +3378,7 @@ my $OSserv = MOBY::OntologyServer->new( ontology => 'service' ); foreach (@ids) { - my $result = $adaptor->query_service_instance({service_instance_id => $_}); + my $result = $adaptor->query_service_instance(service_instance_id => $_); my $row = shift(@$result); my $category = $row->{category}; my $url = $row->{url}; From mwilkinson at pub.open-bio.org Fri Jul 22 17:14:07 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:14:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221714.j6MHE75E000523@pub.open-bio.org> mwilkinson Fri Jul 22 13:14:07 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv504/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: added debugging info moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:12:13 1.22 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:14:07 1.23 @@ -641,7 +641,7 @@ push @args, ({$k => $v},"and"); # format for the add_condition subroutine } pop @args; # get rid of last "and" - + print STDERR join "", @args; my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 17:25:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:25:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221725.j6MHPOZt000610@pub.open-bio.org> mwilkinson Fri Jul 22 13:25:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv591/MOBY Modified Files: service_instance.pm Log Message: deanonymysing the arguents to query_service_instance moby-live/Perl/MOBY service_instance.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/21 17:43:24 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 17:25:24 1.22 @@ -212,8 +212,8 @@ ? $self->service_type_uri( $self->service_type ) : $self->service_type_uri($servicetypeURI); } - my $existing_services = $self->adaptor->query_service_instance({servicename => $self->servicename},"and", - {authority_uri => $self->authority_uri}); + my $existing_services = $self->adaptor->query_service_instance(servicename => $self->servicename, + authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did $self->service_instance_id( $existing_service->{'serviceid'} ); From mwilkinson at pub.open-bio.org Fri Jul 22 17:25:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 13:25:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221725.j6MHPO4t000631@pub.open-bio.org> mwilkinson Fri Jul 22 13:25:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv591/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: deanonymysing the arguents to query_service_instance moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:14:07 1.23 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:25:24 1.24 @@ -641,7 +641,6 @@ push @args, ({$k => $v},"and"); # format for the add_condition subroutine } pop @args; # get rid of last "and" - print STDERR join "", @args; my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 19:16:41 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:16:41 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221916.j6MJGf1M000874@pub.open-bio.org> mwilkinson Fri Jul 22 15:16:40 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv847/MOBY Modified Files: Central.pm secondary_input.pm service_instance.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY Central.pm,1.166,1.167 secondary_input.pm,1.5,1.6 service_instance.pm,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.166 retrieving revision 1.167 diff -u -r1.166 -r1.167 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 17:12:13 1.166 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:16:40 1.167 @@ -1236,7 +1236,15 @@ "Service categories other than 'moby' and 'wsdl' are not yet implemented", "" ) - unless ( ( $Category eq "moby" ) || ( $Category eq "wsdl" ) ); + unless ( ( $Category eq "moby" ) || ( $Category eq "wsdl" ) ); + +#test the existence of the service + return &_error( "This service already exists", "" ) if (MOBY::service_instance->new( + servicename => $serviceName, + authority_uri => $AuthURI, + test => 1)); + + my @IN = @{$INPUTS}; my @OUT = @{$OUTPUTS}; my @SECS = @{$SECONDARY}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/20 22:04:10 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/22 19:16:40 1.6 @@ -115,13 +115,13 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, - {maximum_value => $self->maximum_value}, - {minimum_value => $self->minimum_value}, - {enum_value => $self->enum_value}, - {datatype => $self->datatype}, - {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}); - + {maximum_value => $self->maximum_value}, + {minimum_value => $self->minimum_value}, + {enum_value => $self->enum_value}, + {datatype => $self->datatype}, + {article_name => $self->article_name}, + {service_instance_id => $self->service_instance_id}); + return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 17:25:24 1.22 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:16:40 1.23 @@ -216,12 +216,14 @@ authority_uri => $self->authority_uri); my $existing_service = shift(@$existing_services); if ($existing_service->{servicename}) { # if service exists, then instantiate it from the database retrieval we just did - $self->service_instance_id( $existing_service->{'serviceid'} ); + $self->servicename( $existing_service->{'servicename'} ); + $self->authoritative( $existing_service->{'authoritative'} ); + $self->service_instance_id( $existing_service->{'service_instance_id'} ); $self->category( $existing_service->{'category'} ); - $self->service_type( $existing_service->{'servicetype'} ); + $self->service_type( $existing_service->{'service_type_uri'} ); $self->url( $existing_service->{'url'} ); - $self->contact_email( $existing_service->{'email'} ); - $self->description( $existing_service->{'desc'} ); + $self->contact_email( $existing_service->{'contact_email'} ); + $self->description( $existing_service->{'description'} ); $self->authority( $existing_service->{'authURI'} ); $self->signatureURL( $existing_service->{'signatureURL'} ); $self->lsid( $existing_service->{'lsid'} ); From mwilkinson at pub.open-bio.org Fri Jul 22 19:23:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:23:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221923.j6MJNIRm000945@pub.open-bio.org> mwilkinson Fri Jul 22 15:23:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv926/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 17:25:24 1.24 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:23:18 1.25 @@ -638,9 +638,9 @@ delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ - push @args, ({$k => $v},"and"); # format for the add_condition subroutine + push @args, ("and",{$k => $v}); # format for the add_condition subroutine } - pop @args; # get rid of last "and" + push @args, ("and", {authority_id => $authority_id}) if ($authority_id); my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 19:29:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:29:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221929.j6MJTcEe001023@pub.open-bio.org> mwilkinson Fri Jul 22 15:29:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv1004/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.25,1.26 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:23:18 1.25 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:29:38 1.26 @@ -599,7 +599,7 @@ unless ($id){ my $result = $self->query_authority({authority_uri => $authURI}); return 0 unless @$result[0]; - my $id = @$result[0]->{authority_id}; + $id = @$result[0]->{authority_id}; return 0 unless $id; } my $statement = "select From mwilkinson at pub.open-bio.org Fri Jul 22 19:38:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:38:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221938.j6MJc2Ub001100@pub.open-bio.org> mwilkinson Fri Jul 22 15:38:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1077/MOBY Modified Files: Central.pm service_instance.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY Central.pm,1.167,1.168 service_instance.pm,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.167 retrieving revision 1.168 diff -u -r1.167 -r1.168 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:16:40 1.167 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:38:02 1.168 @@ -1292,11 +1292,8 @@ description => $desc, signatureURL => $signatureURL, ); - return &_error( "Service registration failed for unknown reasons", "" ) - if ( !defined $SVC ); - return &_error( "Service with this authority/servicename already exists", - "" ) - if ( $SVC == -1 ); + return &_error( "Service registration failed for unknown reasons", "" ) if ( !defined $SVC ); + $debug && &_LOG("new service instance created\n"); foreach my $IN (@IN) { @@ -1716,27 +1713,26 @@ my ( $authURI, $serviceName ) = &_deregisterServicePayload($payload); return &_error( "must provide an authority and a service name\n", "" ) unless ( $authURI && $serviceName ); - return &_error( -"The service specified by authority=$authURI servicename=$serviceName does not exist in the registry", - "" - ) + return &_error("The service specified by authority=$authURI servicename=$serviceName does not exist in the registry","") unless ( MOBY::service_instance->new( servicename => $serviceName, authority_uri => $authURI, test => 1 - ) - ); + )); my $SERVICE = MOBY::service_instance->new( servicename => $serviceName, authority_uri => $authURI ); + return &_error("service lookup failed for unknown reasons","") unless ($SERVICE); + if ( $SERVICE->signatureURL ) { return &_error( "it is illegal to deregister a service that has a signatureURL. Such services must be deregistered by deleting the RDF at the location identified by the signatureURL", "" ); } + my $result = $SERVICE->DELETE_THYSELF; if ($result) { return &_success( "Service Deregistered Successfully", "" ); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:16:40 1.23 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:38:02 1.24 @@ -190,7 +190,6 @@ return undef unless $self->servicename; if ( $self->test ) { return $self->service_instance_exists } - if ($self->service_instance_exists){return -1} $self->authority( $self->_get_authority() ); From mwilkinson at pub.open-bio.org Fri Jul 22 19:46:52 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 15:46:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507221946.j6MJkq4I001183@pub.open-bio.org> mwilkinson Fri Jul 22 15:46:52 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv1164/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:29:38 1.26 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:46:52 1.27 @@ -638,9 +638,14 @@ delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ - push @args, ("and",{$k => $v}); # format for the add_condition subroutine + push @args, ({$k => $v}, "and"); # format for the add_condition subroutine } - push @args, ("and", {authority_id => $authority_id}) if ($authority_id); + if ($authority_id){ + push @args, ({authority_id => $authority_id}) ; + } else { + pop @args; # remove final "and" + } + my $statement = "select service_instance_id, category, From mwilkinson at pub.open-bio.org Fri Jul 22 20:00:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:00:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222000.j6MK0Aef001271@pub.open-bio.org> mwilkinson Fri Jul 22 16:00:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv1252/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: the logic for findig existing services was still wonky. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.27,1.28 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 19:46:52 1.27 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 20:00:10 1.28 @@ -632,7 +632,7 @@ if ($args{'authority_uri'}){ # need to transform URI to a row ID my $result = $self->query_authority({authority_uri => $args{'authority_uri'}}); return 0 unless @$result[0]; - my $authority_id = @$result[0]->{authority_id}; + $authority_id = @$result[0]->{authority_id}; return 0 unless $authority_id; } delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table From mwilkinson at pub.open-bio.org Fri Jul 22 20:05:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:05:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222005.j6MK5S01001341@pub.open-bio.org> mwilkinson Fri Jul 22 16:05:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1322/MOBY Modified Files: Central.pm Log Message: service discovery was failing because the searches were returning objects instead of id numbers moby-live/Perl/MOBY Central.pm,1.168,1.169 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.168 retrieving revision 1.169 diff -u -r1.168 -r1.169 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 19:38:02 1.168 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:05:28 1.169 @@ -1907,8 +1907,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instnace_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{serviceType} ) { # must have something more than empty content @@ -1939,8 +1938,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{authURI} ) { @@ -1956,8 +1954,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{servicename} ) { @@ -1975,8 +1972,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } $findme{category} = 'moby' unless $findme{category}; @@ -1994,8 +1990,7 @@ && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{keywords} && ( scalar @{ $findme{keywords} } ) ) { @@ -2008,17 +2003,14 @@ unless ( scalar @{$ids} ) { $debug - && &_LOG( -"found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n" - ); + && &_LOG("found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n"); return &_serviceListResponse( $dbh, undef ); } $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); foreach ( @{$ids} ) { $debug && &_LOG("found id $_->{service_instance_id}\n"); - ++$valid_service_ids{ $_->{service_instance_id} - }; # increment that particular id's count by one + ++$valid_service_ids{$_}; # increment that particular id's count by one } } if ( $findme{inputObjects} && ( scalar @{ $findme{inputObjects} } ) ) { @@ -2033,8 +2025,7 @@ $findme{'expandObjects'}, '' ) if defined $obj; $debug - && _LOG( - "Initial Search For Services with INPUT Article found @si_ids\n"); + && _LOG("Initial Search For Services with INPUT Article found @si_ids\n"); my %instances; # we need to do a join, without doing a join... @@ -2051,9 +2042,7 @@ &_searchForServicesWithArticle( $dbh, "input", $obj, $findme{'expandObjects'}, '' ); # get their service ids $debug - && _LOG( -"Subsequent Search For Services with INPUT Article found @new_ids\n" - ); + && _LOG("Subsequent Search For Services with INPUT Article found @new_ids\n"); my @good_ids; my %good_ids; foreach my $id (@new_ids) From mwilkinson at pub.open-bio.org Fri Jul 22 20:15:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:15:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222015.j6MKFmuB001439@pub.open-bio.org> mwilkinson Fri Jul 22 16:15:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1420/MOBY Modified Files: Central.pm Log Message: service discovery was failing because of incorrect column names in SQL moby-live/Perl/MOBY Central.pm,1.169,1.170 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.169 retrieving revision 1.170 diff -u -r1.169 -r1.170 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:05:28 1.169 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:15:48 1.170 @@ -3427,7 +3427,7 @@ } $output .= "\t\t\n"; } - $result = $adaptor->query_collection_input({service_instance => $_}); + $result = $adaptor->query_collection_input({service_instance_id => $_}); # $sth_collection_ins->execute($_); foreach my $row (@$result) From mwilkinson at pub.open-bio.org Fri Jul 22 20:25:39 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:25:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222025.j6MKPdeV001588@pub.open-bio.org> mwilkinson Fri Jul 22 16:25:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1569/MOBY Modified Files: Central.pm Log Message: various queries being sent to the wrong adaptors moby-live/Perl/MOBY Central.pm,1.171,1.172 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.171 retrieving revision 1.172 diff -u -r1.171 -r1.172 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:18:28 1.171 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:25:39 1.172 @@ -473,7 +473,7 @@ sub deregisterObjectClass { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'object' ); @@ -486,7 +486,6 @@ $OntologyServer->objectExists( term => $class ); return &_error( "Object class $class does not exist", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new()->dbh; my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); return &_error( @@ -745,7 +744,7 @@ sub deregisterServiceType { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'service' ); @@ -755,12 +754,9 @@ return &_error( "Must include an accession number to deregister a serviceType", "" ) unless ($term); - my ( $success, $message, $existingURI ) = - $OntologyServer->serviceExists( term => $term ) - ; # hopefully this situation will never happen! + my ( $success, $message, $existingURI ) = $OntologyServer->serviceExists( term => $term ); # hopefully this situation will never happen! return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new()->dbh; my $result = $adaptor->query_service({service_type_uri => $existingURI}); my $row = shift(@$result); @@ -906,7 +902,7 @@ sub deregisterNamespace { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'namespace' ); @@ -919,7 +915,6 @@ $OntologyServer->namespaceExists( term => $term ); return &_error( "Namespace Type $term does not exist", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new->dbh; my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term}); return &_error( $errstr, "") if ($err); From mwilkinson at pub.open-bio.org Fri Jul 22 20:29:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:29:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222029.j6MKTBx7001654@pub.open-bio.org> mwilkinson Fri Jul 22 16:29:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1635/MOBY Modified Files: Central.pm Log Message: various queries being sent to the wrong adaptors moby-live/Perl/MOBY Central.pm,1.172,1.173 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.172 retrieving revision 1.173 diff -u -r1.172 -r1.173 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:25:39 1.172 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:29:11 1.173 @@ -473,7 +473,7 @@ sub deregisterObjectClass { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'object' ); @@ -486,6 +486,7 @@ $OntologyServer->objectExists( term => $class ); return &_error( "Object class $class does not exist", "" ) unless ($existingURI); + my $dbh = MOBY::central_db_connection->new()->dbh; my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); return &_error( @@ -902,7 +903,7 @@ sub deregisterNamespace { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'namespace' ); From gordonp at pub.open-bio.org Fri Jul 22 20:59:05 2005 From: gordonp at pub.open-bio.org (Paul Gordon) Date: Fri, 22 Jul 2005 16:59:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222059.j6MKx5BS001853@pub.open-bio.org> gordonp Fri Jul 22 16:59:05 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/Clients In directory pub.open-bio.org:/tmp/cvs-serv1828/src/Clients Modified Files: TestRequest.java Log Message: Upated to work with new data instance version moby-live/Java/src/Clients TestRequest.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/Clients/TestRequest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/Clients/TestRequest.java 2005/05/12 05:22:27 1.1 +++ /home/repository/moby/moby-live/Java/src/Clients/TestRequest.java 2005/07/22 20:59:05 1.2 @@ -10,9 +10,7 @@ import org.biomoby.client.MobyRequest; import org.biomoby.shared.Central; import org.biomoby.shared.MobyService; -import org.biomoby.shared.data.MobyDataInstance; -import org.biomoby.shared.data.MobyDataObject; -import org.biomoby.shared.data.MobyDataObjectSet; +import org.biomoby.shared.data.*; import java.util.Iterator; import java.util.Vector; @@ -57,27 +55,18 @@ mr.setDebugMode(true); mr.setService(validServices[0]); mr.setInput(input); // use convenient anonymous single arg service parameterization - java.util.Vector output = mr.invokeService(); - - String c = ""; - Iterator responses = output.iterator(); + MobyContentInstance responses = mr.invokeService(); // Process responses // The service invocation may have had many requests, there is a response // object for each request - while(responses.hasNext()){ - - Object o = responses.next(); - System.err.println("responses vector slot is a " + o.getClass().getName()); - if(o instanceof Object[]){ - System.err.println("responses vector slot is an array"); - } - MobyDataInstance[] responseObjects = (MobyDataInstance[]) o; + Iterator i = responses.keySet().iterator(); + while(i.hasNext()){ + Vector responseObjects = (Vector) responses.get(i.next()); // The response for a request may have many objects - for(int k = 0; k < responseObjects.length; k++){ - //MobyDataInstance responseObject = responseObjects[k]; - Object responseObject = responseObjects[k]; + for(int k = 0; k < responseObjects.size(); k++){ + Object responseObject = responseObjects.elementAt(k); // The response objects may either be simple data, or data sets if(responseObject instanceof MobyDataObject){ System.out.println("Plain simple instance is "+((MobyDataInstance)responseObject).toXML()); From mwilkinson at pub.open-bio.org Fri Jul 22 20:18:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:18:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222018.j6MKISjV001505@pub.open-bio.org> mwilkinson Fri Jul 22 16:18:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1486/MOBY Modified Files: Central.pm Log Message: various queries not being sent to the adaptor moby-live/Perl/MOBY Central.pm,1.170,1.171 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.170 retrieving revision 1.171 diff -u -r1.170 -r1.171 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:15:48 1.170 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:18:28 1.171 @@ -3462,7 +3462,7 @@ $output .= "\t\n"; $output .= "\t\n"; - $result = query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); + $result = $adaptor->query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); foreach my $row (@$result) { @@ -3483,7 +3483,7 @@ $output .= "\t\t\n"; } - $result = query_collection_output({service_instance_id => $_}); + $result = $adaptor->query_collection_output({service_instance_id => $_}); foreach my $row (@$result) { my $collid = $row->{collection_output_id}; From mwilkinson at pub.open-bio.org Fri Jul 22 20:47:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 16:47:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222047.j6MKlBoZ001767@pub.open-bio.org> mwilkinson Fri Jul 22 16:47:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1748/MOBY Modified Files: Central.pm Log Message: wrong column name for query moby-live/Perl/MOBY Central.pm,1.173,1.174 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.173 retrieving revision 1.174 diff -u -r1.173 -r1.174 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:29:11 1.173 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:47:10 1.174 @@ -759,7 +759,7 @@ return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); - my $result = $adaptor->query_service({service_type_uri => $existingURI}); + my $result = $adaptor->query_service({service_lsid => $existingURI}); my $row = shift(@$result); my $id = $row->{service_instance_id}; From mwilkinson at pub.open-bio.org Fri Jul 22 21:56:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 17:56:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222156.j6MLuZ3k001982@pub.open-bio.org> mwilkinson Fri Jul 22 17:56:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv1963/MOBY Modified Files: Central.pm Log Message: all original tests now pass. findService was returning service descriptions with extra whitespace. Fixed that moby-live/Perl/MOBY Central.pm,1.174,1.175 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.174 retrieving revision 1.175 diff -u -r1.174 -r1.175 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 20:47:10 1.174 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 21:56:35 1.175 @@ -3397,7 +3397,7 @@ $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; $output .= "\t$category\n"; - $output .= "\t\n$desc\n\t\n"; + $output .= "\t\n"; $output .= "\t$email\n"; $output .= "\t$signatureURL\n"; $output .= "\t$url\n"; From mwilkinson at pub.open-bio.org Fri Jul 22 22:57:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 18:57:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222257.j6MMvSXp002203@pub.open-bio.org> mwilkinson Fri Jul 22 18:57:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv2184/MOBY/Client Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined moby-live/Perl/MOBY/Client Central.pm,1.99,1.100 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.99 retrieving revision 1.100 diff -u -r1.99 -r1.100 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/19 22:54:10 1.99 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 22:57:28 1.100 @@ -929,19 +929,17 @@ $message .= "\n"; while ( my ( $param, $desc ) = each %SEC ) { unless ( ( ref($desc) ) =~ /hash/i ) { - return $self->errorRegXML( -"invalid structure of secondary article $param; expected hashref of limitations" + return $self->errorRegXML( "invalid structure of secondary article $param; expected hashref of limitations" ); } my %data = %{$desc}; - my $default = $data{default} || ""; - my $max = $data{max} || ""; - my $min = $data{min} || ""; - my $datatype = $data{datatype} || ""; - my $enums = $data{enum} || []; + my $default = defined($data{default}) || ""; + my $max = defined($data{max}) || ""; + my $min = defined($data{min}) || ""; + my $datatype = defined($data{datatype}) || ""; + my $enums = defined($data{enum}) || []; unless ($datatype) { - return $self->errorRegXML( -"a secondaryArticle must contain at least a datatype value in secondary article $param" + return $self->errorRegXML("a secondaryArticle must contain at least a datatype value in secondary article $param" ); } unless ( ( $datatype =~ /Integer/ ) @@ -949,13 +947,11 @@ || ( $datatype =~ /String/ ) || ( $datatype =~ /DateTime/ ) ) { - return $self->errorRegXML( -"a secondaryArticle must have a datatype of Integer, Float, String, or DateTime" + return $self->errorRegXML("a secondaryArticle must have a datatype of Integer, Float, String, or DateTime" ); } unless ( ( ref($enums) ) =~ /array/i ) { - return $self->errorRegXML( -"invalid structure of enum limits in secondary article $param; expected arrayref" + return $self->errorRegXML("invalid structure of enum limits in secondary article $param; expected arrayref" ); } my @enums = @{$enums}; From mwilkinson at pub.open-bio.org Fri Jul 22 23:05:04 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:05:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222305.j6MN54tJ002278@pub.open-bio.org> mwilkinson Fri Jul 22 19:05:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv2259/MOBY/Client Modified Files: Central.pm Log Message: oops... got a little exuberant there moby-live/Perl/MOBY/Client Central.pm,1.100,1.101 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.100 retrieving revision 1.101 diff -u -r1.100 -r1.101 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 22:57:28 1.100 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 23:05:04 1.101 @@ -933,11 +933,11 @@ ); } my %data = %{$desc}; - my $default = defined($data{default}) || ""; - my $max = defined($data{max}) || ""; - my $min = defined($data{min}) || ""; - my $datatype = defined($data{datatype}) || ""; - my $enums = defined($data{enum}) || []; + my $default = defined($data{default})?$data{default}:""; + my $max = defined($data{max})?$data{max}:""; + my $min = defined($data{min})?$data{min}:""; + my $datatype = $data{datatype} || ""; + my $enums = $data{enum} || []; unless ($datatype) { return $self->errorRegXML("a secondaryArticle must contain at least a datatype value in secondary article $param" ); From mwilkinson at pub.open-bio.org Fri Jul 22 23:11:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:11:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222311.j6MNBoMl002361@pub.open-bio.org> mwilkinson Fri Jul 22 19:11:50 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv2342/MOBY Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined. Smae problem on the server side moby-live/Perl/MOBY Central.pm,1.175,1.176 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.175 retrieving revision 1.176 diff -u -r1.175 -r1.176 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 21:56:35 1.175 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:11:49 1.176 @@ -3519,11 +3519,11 @@ my $datatype = $row->{datatype}; my $article_name = $row->{article_name}; - $article_name ||= ""; - $datatype ||= ""; - $default_value ||= ""; - $maximum_value ||= ""; - $minimum_value ||= ""; + defined($article_name) ||= ""; + defined($datatype) ||= ""; + defined($default_value) ||= ""; + defined($maximum_value) ||= ""; + defined($minimum_value) ||= ""; $output .= "\t\t\t\n"; $output .= "\t\t\t\t$datatype\n"; $output .= "\t\t\t\t$default_value\n"; From mwilkinson at pub.open-bio.org Fri Jul 22 23:15:55 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:15:55 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222315.j6MNFtbV002429@pub.open-bio.org> mwilkinson Fri Jul 22 19:15:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv2410/MOBY Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined. Smae problem on the server side moby-live/Perl/MOBY Central.pm,1.176,1.177 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.176 retrieving revision 1.177 diff -u -r1.176 -r1.177 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:11:49 1.176 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:15:54 1.177 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::Client::Central; +#use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -3511,19 +3511,14 @@ $output .= "\t\n"; $result = $adaptor->query_secondary_input({service_instance_id => $_}); foreach my $row (@$result) - { - my $default_value = $row->{default_value}; - my $maximum_value = $row->{maximum_value}; - my $minimum_value = $row->{minimum_value}; - my $enum_value = $row->{enum_value}; - my $datatype = $row->{datatype}; - my $article_name = $row->{article_name}; - - defined($article_name) ||= ""; - defined($datatype) ||= ""; - defined($default_value) ||= ""; - defined($maximum_value) ||= ""; - defined($minimum_value) ||= ""; + { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ""; + $default_value = $row->{default_value}; + $maximum_value = $row->{maximum_value}; + $minimum_value = $row->{minimum_value}; + $enum_value = $row->{enum_value}; + $datatype = $row->{datatype}; + $article_name = $row->{article_name}; + $output .= "\t\t\t\n"; $output .= "\t\t\t\t$datatype\n"; $output .= "\t\t\t\t$default_value\n"; From mwilkinson at pub.open-bio.org Fri Jul 22 23:20:27 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:20:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222320.j6MNKREs002500@pub.open-bio.org> mwilkinson Fri Jul 22 19:20:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv2481/MOBY Modified Files: Central.pm Log Message: secondaries that had 0 as their min, max, or default vaules were not registering properly because of a test for value rather than defined. Smae problem on the server side moby-live/Perl/MOBY Central.pm,1.177,1.178 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.177 retrieving revision 1.178 diff -u -r1.177 -r1.178 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:15:54 1.177 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:20:26 1.178 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -#use MOBY::Client::Central; +use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -3511,7 +3511,7 @@ $output .= "\t\n"; $result = $adaptor->query_secondary_input({service_instance_id => $_}); foreach my $row (@$result) - { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ""; + { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ("","","","","",""); $default_value = $row->{default_value}; $maximum_value = $row->{maximum_value}; $minimum_value = $row->{minimum_value}; From mwilkinson at pub.open-bio.org Fri Jul 22 23:23:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:23:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222323.j6MNNQOu002568@pub.open-bio.org> mwilkinson Fri Jul 22 19:23:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv2549/t Modified Files: Client-Central.t Log Message: added about 50 new tests. now we're really getting tight. moby-live/Perl/t Client-Central.t,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/08 19:22:21 1.8 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:23:26 1.9 @@ -4,17 +4,19 @@ ######################### # change 'tests => 1' to 'tests => last_test_to_print'; - -use Test::More tests => 14; # perldoc Test::More for details +#use SOAP::Lite +trace; +use Test::More tests => 54; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; + + # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', - URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} + mobycentral => { URL => 'http://localhost/cgi-bin/MOBY-Central.pl', + URI => 'http://localhost/MOBY/Central'} } ); @@ -23,6 +25,8 @@ my %TestRegistry ; # to keep track of registry id's for the various tests + + ################## MOBY Registration Tests ################# # Test 3 @@ -40,6 +44,9 @@ ( ok(!$r->success,"Object registration correctly failed") or diag("Object registration failure: ".$r->message)); + + + # Test 4 $r = $C->registerObjectClass(objectType => "TotalCrap", description => "a human-readable description of the object", @@ -55,11 +62,17 @@ or diag("Object registration failure: ".$r->message)); + + + # Test 5 $r = $C->deregisterObjectClass(objectType => "TotalCrap"); ( ok($r->success,"Object deregistration successful")) or diag("Object deregistration failure: ".$r->message) ; + + + # Test 6 (identical to #4 $r = $C->registerObjectClass(objectType => "TotalCrap", description => "a human-readable description of the object", @@ -75,7 +88,10 @@ or diag("Object registration failure: ".$r->message)); -# Test 6 + + + +# Test 7 $r = $C->registerNamespace( namespaceType =>'UglyNamespace', authURI => 'your.authority.URI', @@ -85,7 +101,9 @@ ) or diag("Name space registration failure: ".$r->message) ; -# Test 7 + + +# Test 8 $r = $C->registerServiceType(serviceType => "CrappyService", description => "a human-readable description of the service", contactEmail => 'your at email.address', @@ -96,7 +114,10 @@ ( ok($r->success,"Service Type registration successful") ) or diag("Service Type registration failure: ".$r->message) ; -# Test 8 # should fail + + + +# Test 9 # should fail $r = $C->registerService( serviceName => "myfirstservice", serviceType => "Retrieval", @@ -119,10 +140,12 @@ min => -10, enum => [-10, 10, 0]}}); -( ok(!$r->success,"Service registration correctly failed") +( ok(!$r->success,"Service registration correctly failed testing secondary datatype format") ) or diag("Service registration failure: ".$r->message) ; -# Test 9 + + +# Test 10 $r = $C->registerService( serviceName => "myfirstservice", serviceType => "Retrieval", @@ -148,8 +171,75 @@ ( ok($r->success,"Service registration successful") ) or diag("Service registration failure: ".$r->message) ; +# test 11 - find by auth & name +($si, $r) = $C->findService( + serviceName => "myfirstservice", + authURI => "test.suite.com"); +( is($r, undef, "Service discovery successful") +) or diag("Service discovery failure") ; + +isa_ok($si, 'ARRAY') or diag("findService didn't return an array ref"); +is(scalar(@$si),1) or diag("findService found too many services"); +$SI = shift @$si; +print STDERR "$SI"; +isa_ok($SI, 'MOBY::Client::ServiceInstance') or diag("findService didn't return a MOBY::Client::ServceInstance"); +isa_ok($SI->input, ARRAY) or diag ("ServiceInstance object input is not a listref"); +isa_ok($SI->output, ARRAY) or diag ("ServiceInstance object output is not a listref"); +is($SI->name, "myfirstservice") or diag("servicename wrong"); +is($SI->authoritative, 0) or diag("service reported to be incorrectly authoritative"); +is($SI->authority, "test.suite.com") or diag("authURI incorrect"); +is($SI->type, "Retrieval") or diag("service type incorrect"); +is($SI->description, "this is my first service") or diag("service description wrong"); +is($SI->URL, "http://illuminae/cgi-bin/service.pl") or diag("service URL incorrect"); +is($SI->contactEmail, 'your at mail.address') or diag("contact email incorrect"); +is($SI->category, "moby") or diag("service category incorrect"); + + at ins = @{$SI->input}; + at outs = @{$SI->output}; + at secs = @{$SI->secondary}; +is(scalar(@ins), 1) or diag("incorrect number of inputs in servce instance"); +is(scalar(@outs), 1) or diag("incorrect number of outputs in servce instance"); +is(scalar(@secs), 1) or diag("incorrect number of secodary in servce instance"); + +$in = shift @ins; +$out = shift @outs; +$sec = shift @secs; + +isa_ok($in, 'MOBY::Client::SimpleArticle') or diag("->inputs did not return a MOBY::simple_input object"); +isa_ok($out, 'MOBY::Client::SimpleArticle') or diag("->outputs did not return a MOBY::simple_outputobject"); +isa_ok($sec, 'MOBY::Client::SecondaryArticle') or diag("->secondarues did not return a MOBY::secondary_input object"); + +is($in->objectType, "Object") or diag("simple input type reported incorrectly"); +is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly"); +isa_ok($in->namespaces, 'ARRAY') or diag("simple input namespaces not returned as an arrayref"); + at ns = @{$in->namespaces}; +is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace"); + +is($out->objectType, "String") or diag("simple output type reported incorrectly"); +is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly"); +isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref"); + at ns = @{$out->namespaces}; +is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace"); + +is($sec->articleName, 'parametername1') or diag("secondary article reporting wrong article name"); +is($sec->datatype, 'Integer') or diag("secondary article reporting wrong datatype"); +is($sec->default,"0") or diag("secondary article reporting wrong default"); +is($sec->max,"10") or diag("secondary article reporting wrong max"); +is($sec->min,"-10") or diag("secondary article reporting wrong min"); +isa_ok($sec->enum, 'ARRAY') or diag("enum is not returning an array ref"); + at enum = @{$sec->enum}; +is(scalar(@enum), 3) or diag("enum not returning correct number of elements"); +$enum = join "|", at enum; +$enum = "|".$enum."|"; +is($enum =~/\|-10\|/, 1) or diag("enum element missing"); +is($enum =~/\|10\|/, 1) or diag("enum element missing"); +is($enum =~/\|0\|/, 1) or diag("enum element missing"); -# Test 10 +# Test 12 $r = $C->deregisterService( serviceName => "myfirstservice", @@ -159,136 +249,29 @@ ) or diag("Service deregistration failure: ".$r->message) ; -# Test 11 + + + +# Test 12 $r = $C->deregisterObjectClass(objectType => "TotalCrap"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; -# Test 12 + + +# Test 13 $r = $C->deregisterServiceType(serviceType => "CrappyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; -# Test 13 + + + +# Test 44 $r = $C->deregisterNamespace(namespaceType =>'UglyNamespace'); ( ok($r->success,"namespace deregistration successful") ) or diag("namespace deregistration failure: ".$r->message) ; -################### MOBY Central Search Tests ################# -# -#my @service ; -# -## Tests 14,15: locateServiceByOutput with output 'Object' and full_objects + full_services -#@service = $C->locateServiceByOutput( -# objectType => "Object", -# fullObjects => 1, -# fullServices => 1, -#) ; -# -#SKIP: { -# skip "locateServiceByOutput w/full object & services". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 16,17: Testing locateServiceByOutput with output "Object" and full_services only -#@service = $C->locateServiceByOutput( -# objectType => "Object", -# fullObjects => 0, -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByOutput w/ output 'Object' and full services only ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 18,19: Testing locateServiceByInput with input -## 'Object' => Genbank/GI and full_objects + full_services -#@service = $C->locateServiceByInput( -# input => {"Sequence" => ["Genbank/GI"]}, -# fullObjects => 1, -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByInput w/input 'Object' => Genbank/GI ". -# "and full_objects + full_services ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 20,21: Testing locateServiceByInput with input -## 'Object' => Genbank/GI and full_services only -#@service = $C->locateServiceByInput( -# input => {"Object" => ["Genbank/GI"]}, -# fullObjects => 0, -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByInput w/input 'Object' => Genbank/GI ". -# "and full_services ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -## Tests 22,23: Testing locateServiceByType with type 'Retrieve' + full_services -#@service = $C->locateServiceByType( -# serviceType => "Retrieve", -# fullServices => 1, -# ); -#SKIP: { -# skip "locateServiceByType w/type 'Retrieve' and full_services ". -# "did not return any services?", 2 unless scalar(@service) ; -# is($service[0]->authority,"illuminae.com","locateServiceByOutput authority") ; -# is($service[0]->name,"Servicetest2","locateServiceByOutput service name") ; -#} ; -# -################### MOBY Deregistration Tests ################# -# -## Test 17 -#SKIP: { -# skip "Skipping test DeregisterService since service registration failed", -# 1 unless(exists($TestRegistry{'Service'})) ; -# -# $r = $C->deregisterService( serviceID => $TestRegistry{'Service'} ); -# ok(!$r->success,"Service ID#".$r->registration_id." deregistration successful") -# or diag("Service ID#",$TestRegistry{'Service'}, -# "deregistration failure: ".$r->message) ; -#} -# -## Test 18 -#SKIP: { -# skip "Skipping test DeregisterNamespace since name space registration failed", -# 1 unless(exists($TestRegistry{'NameSpace'})) ; -# -# $r = $C->deregisterNamespace( namespaceAcc => $TestRegistry{'NameSpace'} ); -# ok(!$r->success,"Name space ID#".$r->registration_id." deregistration successful") -# or diag("Name space ID#",$TestRegistry{'NameSpace'}, -# "deregistration failure: ".$r->message) ; -#} -# -## Test 19 -#SKIP: { -# skip "Skipping test DeregisterServiceType since service registration failed", -# 1 unless(exists($TestRegistry{'ServiceType'})) ; -# -# $r = $C->deregisterServiceType( serviceID => $TestRegistry{'ServiceType'} ); -# ok(!$r->success,"Service type ID#".$r->registration_id." deregistration successful") -# or diag("Service type ID#",$TestRegistry{'ServiceType'}, -# "deregistration failure: ".$r->message) ; -#} -# -## Test 20 -#SKIP: { -# skip "Skipping test DeregisterObject since initial object registration failed", -# 1 unless(exists($TestRegistry{'Object'})) ; -# -# $r = $C->deregisterObject( serviceID => $TestRegistry{'Object'} ); -# ok(!$r->success,"Object ID#".$r->registration_id." deregistration successful") -# or diag("Object ID#",$TestRegistry{'Object'}, -# "deregistration failure: ".$r->message) ; -#} + + + From mwilkinson at pub.open-bio.org Fri Jul 22 23:25:06 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 22 Jul 2005 19:25:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507222325.j6MNP6CZ002625@pub.open-bio.org> mwilkinson Fri Jul 22 19:25:06 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv2606/t Modified Files: Client-Central.t Log Message: oops... committed the new tests without changnig the URl back to teh public address. moby-live/Perl/t Client-Central.t,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:23:26 1.9 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:25:06 1.10 @@ -15,8 +15,8 @@ # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://localhost/cgi-bin/MOBY-Central.pl', - URI => 'http://localhost/MOBY/Central'} + mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/MOBY-Central.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} } ); From mwilkinson at pub.open-bio.org Mon Jul 25 17:23:36 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 13:23:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251723.j6PHNaRo020358@pub.open-bio.org> mwilkinson Mon Jul 25 13:23:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20339/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: starting to document the adaptor layer moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/18 16:53:49 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:23:35 1.5 @@ -1,8 +1,85 @@ +#$Id$ package MOBY::Adaptor::moby::queryapi; use strict; use Carp; use vars qw($AUTOLOAD); + +=head1 NAME + +MOBY::Adaptor::moby::queryapi - An interface definition for MOBY Central underlying data-stores + +=cut + +=head1 SYNOPSIS + + use MOBY::Adaptor::moby::queryapi::mysql # implements this interface def + my $m = MOBY::Adaptor::moby::queryapi::mysql->new( + username => 'user', + password => 'pass', + dbname => 'mobycentral', + port => '3306', + sourcetype => 'DBD::mysql'); + my $objectid = $m->insert_object( + {object_type => "MyObject"}, + {description => "this represents a foo bar"}, + {authority => "www.example.org"}, + {contact_email, 'me at example.org'}) + + +=cut + +=head1 DESCRIPTION + +This is an interface definition. There is NO implementation in this module +with the exception that certain calls to required parameters have get/setter +functions in this module (that can be overridden) + +=head1 AUTHORS + +Mark Wilkinson markw_at_ illuminae dot com +Dennis Wang oikisai _at_ hotmail dot com +BioMOBY Project: http://www.biomoby.org + + +=cut + +=head1 METHODS + + +=head2 new + + Title : new + Usage : my $MOBY = MOBY::Client::Central->new(Registries => \%regrefs) + Function : connect to one or more MOBY-Central + registries for searching + Returns : MOBY::Client::Central object + Args : Registries - optional. + Notes : Each registry must have a different + + +=cut + + +sub new { + my ($caller, %args) = @_; + my $caller_is_obj = ref($caller); + my $class = $caller_is_obj || $caller; + + my $self = bless {}, $class; + + foreach my $attrname ( $self->_standard_keys_a ) { + if (exists $args{$attrname} && defined $args{$attrname}) { + $self->{$attrname} = $args{$attrname} } + elsif ($caller_is_obj) { + $self->{$attrname} = $caller->{$attrname} } + else { + $self->{$attrname} = $self->_default_for($attrname) } + } + return $self; +} + + # Modified by Dennis { @@ -14,10 +91,11 @@ ( username => [undef, 'read/write'], password => [undef, 'read/write'], - dbname => [undef, 'read/write'], - port => [undef, 'read/write'], - proxy => [undef, 'read/write'], - url => [undef, 'read/write'], + dbname => [undef, 'read/write'], + port => [undef, 'read/write'], + proxy => [undef, 'read/write'], + url => [undef, 'read/write'], + driver => [undef, 'read/write'], ); #_____________________________________________________________ @@ -41,46 +119,155 @@ keys %_attr_data; } +=head2 username + + Title : username + Usage : my $un = $API->username($arg) + Function : get/set username (if required) + Returns : String (username) + Args : String (username) - optional. + +=cut + + sub username { my ($self, $arg) = @_; $self->{username} = $arg if defined $arg; return $self->{username}; } + +=head2 password + + Title : password + Usage : my $un = $API->password($arg) + Function : get/set password (if required) + Returns : String (password) + Args : String (password) - optional. + +=cut + sub password { my ($self, $arg) = @_; $self->{password} = $arg if defined $arg; return $self->{password}; } + +=head2 dbname + + Title : dbname + Usage : my $un = $API->dbname($arg) + Function : get/set dbname (if required) + Returns : String (dbname) + Args : String (dbname) - optional. + +=cut + sub dbname { my ($self, $arg) = @_; $self->{dbname} = $arg if defined $arg; return $self->{dbname}; } + +=head2 port + + Title : port + Usage : my $un = $API->port($arg) + Function : get/set port (if required) + Returns : String (port) + Args : String (port) - optional. + +=cut + + sub port { my ($self, $arg) = @_; $self->{port} = $arg if defined $arg; return $self->{port}; } + +=head2 proxy + + Title : proxy + Usage : my $un = $API->proxy($arg) + Function : get/set proxy (if required) + Returns : String (proxy) + Args : String (proxy) - optional. + +=cut + sub proxy { my ($self, $arg) = @_; $self->{proxy} = $arg if defined $arg; return $self->{proxy}; } + + +=head2 sourcetype + + Title : sourcetype + Usage : my $un = $API->sourcetype($arg) + Function : get/set string name of sourcetype (e.g. mySQL) + Returns : String (sourcetype) + Args : String (sourcetype) - optional. + +=cut + sub sourcetype { my ($self, $arg) = @_; $self->{sourcetype} = $arg if defined $arg; return $self->{sourcetype}; } + + +=head2 driver + + Title : driver + Usage : my $un = $API->driver($arg) + Function : get/set string name of driver module (e.g. DBD::mySQL) + Returns : String (driver) + Args : String (driver) - optional. + +=cut + + sub driver { + my ($self, $arg) = @_; + $self->{driver} = $arg if defined $arg; + return $self->{driver}; + } + + +=head2 url + + Title : url + Usage : my $un = $API->url($arg) + Function : get/set url (if required) + Returns : String (url) + Args : String (url) - optional. + +=cut + sub url { my ($self, $arg) = @_; $self->{url} = $arg if defined $arg; return $self->{url}; } + sub _implementation { my ($self, $arg) = @_; $self->{'_implementation'} = $arg if defined $arg; return $self->{'_implementation'}; } + +=head2 dbh + + Title : dbh + Usage : my $un = $API->dbh($arg) + Function : get/set database handle (if required) + Returns : Database handle in whatever object is appropriate for sourcetype + Args : Database handle in whatever object is appropriate for sourcetype + +=cut + sub dbh { my ($self, $arg) = @_; $self->{dbh} = $arg if defined $arg; @@ -89,24 +276,6 @@ } -sub new { - my ($caller, %args) = @_; - my $caller_is_obj = ref($caller); - my $class = $caller_is_obj || $caller; - - my $self = bless {}, $class; - - foreach my $attrname ( $self->_standard_keys_a ) { - if (exists $args{$attrname} && defined $args{$attrname}) { - $self->{$attrname} = $args{$attrname} } - elsif ($caller_is_obj) { - $self->{$attrname} = $caller->{$attrname} } - else { - $self->{$attrname} = $self->_default_for($attrname) } - } - return $self; - -} # general query subroutine # parameters: @@ -114,6 +283,18 @@ # bind_values - an array of values to be bound to the parameters # returns: # resultset - reference to an array containing ARRAY references + +=head2 dbh + + Title : general_query + Usage : my $un = $API->general_query(@args) + Function : Execute a generic query on an underlying SQL-based data source + Returns : array of array-refs representing resulting rows + Args : String - sql statement + [String] - a set of bind values + +=cut + sub general_query{ die "general_query not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Mon Jul 25 17:50:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 13:50:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251750.j6PHo2qs020462@pub.open-bio.org> mwilkinson Mon Jul 25 13:50:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY Modified Files: Central.pm collection_input.pm Log Message: changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash moby-live/Perl/MOBY Central.pm,1.178,1.179 collection_input.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.178 retrieving revision 1.179 diff -u -r1.178 -r1.179 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/22 23:20:26 1.178 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 17:50:02 1.179 @@ -3100,120 +3100,120 @@ return ""; } -=head2 _traverseServiceDAG - - Title : _traverseServiceDAG - Usage : @valid = $MOBY->_traverseServiceDAG($dbh, $serviceType, $sth_hash) - Function : starting from $serviceType, find all child services non-redundantly - by traversing the DAG. - Returns : list of Service.id database entries. - Args : none - -=cut - -sub _traverseServiceDAG { - - $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - - my ( $dbh, $serviceType, $sth_hash ) = @_; - my %sth = %{$sth_hash}; - my %ServiceIDs; - - my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); - my $row = shift(@$result); - my ($root_id) = @$row; - return undef unless $root_id; - -# we have to do a traversal of the DAG here to get all child nodes... -# this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... - $ServiceIDs{$root_id} = "untested"; # mark the one in-hand as untested - while ( grep /untested/, ( values %ServiceIDs ) ) - { # now, while there are untested services in our list... - foreach my $service ( keys %ServiceIDs ) - { # start parsing through the list - next - if ( $ServiceIDs{$service} eq "tested" ) - ; # if it has been tested already then move on - - my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); - # execute the query for child nodes - $ServiceIDs{$service} = "tested"; # mark it as tested - foreach my $row (@$result) - { # now get each of the child nodes - my $new = @$row; - next - if ( defined $ServiceIDs{$new} ) - ; # if we have already heard about it then move on - $ServiceIDs{$new} = "untested" - ; #otherwise mark it as untested, and start all over again - } - } - } - return keys %ServiceIDs; -} - -=head2 _traverseObjectDAG - - Title : _traverseObjectDAG - Usage : @valid = $MOBY->_traverseObjectDAG( $dbh, $objectType, $sth_hash, "p|c") - Function : from $objectType, find all parent/child objects non-redundantly - by traversing the DAG. - Returns : list of Object.id database entries. - Args : objectType (by name), $statement ahngles, "p" parent, or "c" child - -=cut - -sub _traverseObjectDAG { - $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - - my ( $dbh, $objectType, $sth_hash, $dir ) = @_; - my %sth = %{$sth_hash}; - my %ObjectIDs; - - my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); - - my $row = shift (@$result); - my ($root_id) = @$row; - return undef unless $root_id; - -# we have to do a traversal of the DAG here to get all child nodes... -# this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... - $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested - while ( grep /untested/, ( values %ObjectIDs ) ) - { # now, while there are untested services in our list... - foreach my $object ( keys %ObjectIDs ) - { # start parsing through the list - next - if ( $ObjectIDs{$object} eq "tested" ) - ; # if it has been tested already then move on - - my $result; - if ( $dir eq "p" ) { - $debug && &_LOG("getting parents"); - $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); - } - else { - $debug && &_LOG("getting children"); - $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); - } - # execute the query for child nodes +#=head2 _traverseServiceDAG +# +# Title : _traverseServiceDAG +# Usage : @valid = $MOBY->_traverseServiceDAG($dbh, $serviceType, $sth_hash) +# Function : starting from $serviceType, find all child services non-redundantly +# by traversing the DAG. +# Returns : list of Service.id database entries. +# Args : none +# +#=cut +# +#sub _traverseServiceDAG { +# +# $CONFIG ||= MOBY::Config->new; # exported by Config.pm +# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); +# +# my ( $dbh, $serviceType, $sth_hash ) = @_; +# my %sth = %{$sth_hash}; +# my %ServiceIDs; +# +# my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); +# my $row = shift(@$result); +# my ($root_id) = @$row; +# return undef unless $root_id; +# +## we have to do a traversal of the DAG here to get all child nodes... +## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... +# $ServiceIDs{$root_id} = "untested"; # mark the one in-hand as untested +# while ( grep /untested/, ( values %ServiceIDs ) ) +# { # now, while there are untested services in our list... +# foreach my $service ( keys %ServiceIDs ) +# { # start parsing through the list +# next +# if ( $ServiceIDs{$service} eq "tested" ) +# ; # if it has been tested already then move on +# +# my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); +# # execute the query for child nodes +# $ServiceIDs{$service} = "tested"; # mark it as tested +# foreach my $row (@$result) +# { # now get each of the child nodes +# my $new = @$row; +# next +# if ( defined $ServiceIDs{$new} ) +# ; # if we have already heard about it then move on +# $ServiceIDs{$new} = "untested" +# ; #otherwise mark it as untested, and start all over again +# } +# } +# } +# return keys %ServiceIDs; +#} - $ObjectIDs{$object} = "tested"; # mark it as tested - foreach my $row (@$result) - { # now get each of the child nodes - my $new = @$row; - next - if ( defined $ObjectIDs{$new} ) - ; # if we have already heard about it then move on - $ObjectIDs{$new} = "untested" - ; #otherwise mark it as untested, and start all over again - } - } - } - return keys %ObjectIDs; -} +#=head2 _traverseObjectDAG +# +# Title : _traverseObjectDAG +# Usage : @valid = $MOBY->_traverseObjectDAG( $dbh, $objectType, $sth_hash, "p|c") +# Function : from $objectType, find all parent/child objects non-redundantly +# by traversing the DAG. +# Returns : list of Object.id database entries. +# Args : objectType (by name), $statement ahngles, "p" parent, or "c" child +# +#=cut +# +#sub _traverseObjectDAG { +# $CONFIG ||= MOBY::Config->new; # exported by Config.pm +# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); +# +# my ( $dbh, $objectType, $sth_hash, $dir ) = @_; +# my %sth = %{$sth_hash}; +# my %ObjectIDs; +# +# my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); +# +# my $row = shift (@$result); +# my ($root_id) = @$row; +# return undef unless $root_id; +# +## we have to do a traversal of the DAG here to get all child nodes... +## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... +# $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested +# while ( grep /untested/, ( values %ObjectIDs ) ) +# { # now, while there are untested services in our list... +# foreach my $object ( keys %ObjectIDs ) +# { # start parsing through the list +# next +# if ( $ObjectIDs{$object} eq "tested" ) +# ; # if it has been tested already then move on +# +# my $result; +# if ( $dir eq "p" ) { +# $debug && &_LOG("getting parents"); +# $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); +# } +# else { +# $debug && &_LOG("getting children"); +# $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); +# } +# # execute the query for child nodes +# +# $ObjectIDs{$object} = "tested"; # mark it as tested +# foreach my $row (@$result) +# { # now get each of the child nodes +# my $new = @$row; +# next +# if ( defined $ObjectIDs{$new} ) +# ; # if we have already heard about it then move on +# $ObjectIDs{$new} = "untested" +# ; #otherwise mark it as untested, and start all over again +# } +# } +# } +# return keys %ObjectIDs; +#} #Eddie - converted sub _nodeTextContent { =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/18 16:53:03 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/25 17:50:02 1.5 @@ -94,9 +94,8 @@ my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - my $id = $adaptor->insert_collection_input( - {service_instance => $self->service_instance_id}, - {article_name => $self->article_name} ); + my $id = $adaptor->insert_collection_input(service_instance => $self->service_instance_id, + article_name => $self->article_name); return $id; } From mwilkinson at pub.open-bio.org Mon Jul 25 17:50:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 13:50:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251750.j6PHo2nW020481@pub.open-bio.org> mwilkinson Mon Jul 25 13:50:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:23:35 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:50:02 1.6 @@ -277,28 +277,7 @@ } -# general query subroutine -# parameters: -# statement - a string SQL statement -# bind_values - an array of values to be bound to the parameters -# returns: -# resultset - reference to an array containing ARRAY references - -=head2 dbh - - Title : general_query - Usage : my $un = $API->general_query(@args) - Function : Execute a generic query on an underlying SQL-based data source - Returns : array of array-refs representing resulting rows - Args : String - sql statement - [String] - a set of bind values -=cut - -sub general_query{ - die "general_query not implemented in adaptor\n"; -} - # # collection_input table functions # @@ -308,14 +287,6 @@ sub insert_collection_input { die "insert_collection_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - #if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # # this should be dropped down into the mysql.pm module?? probably... - # $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, ($args{service_instance}, $args{article_name})); - # my $id=$self->dbh->{mysql_insertid}; - # return $id; - #} } sub delete_collection_input{ From mwilkinson at pub.open-bio.org Mon Jul 25 17:50:03 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 13:50:03 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251750.j6PHo3EV020501@pub.open-bio.org> mwilkinson Mon Jul 25 13:50:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv20439/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: changing the adaptor API to be more perlish. No longer passing a list of hashes, just a hash moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.28,1.29 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/22 20:00:10 1.28 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 17:50:02 1.29 @@ -75,25 +75,24 @@ my $driver = $self->driver; # inherited from the adaptorI (queryapi) my $username = $self->username; my $password = $self->password; - my $port = $self->port; - my $url = $self->url; - my $dbname = $self->dbname; - - my ($dsn) = "$driver:$dbname:$url:$port"; -# print STDERR "\n\nconnectiung to $driver:$dbname:$url:$port\n\n"; - my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; + my $port = $self->port; + my $url = $self->url; + my $dbname = $self->dbname; + + my ($dsn) = "$driver:$dbname:$url:$port"; + my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; - ############################################################## - unless ($dbh) { - print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; - return undef; - } - + ############################################################## + unless ($dbh) { + print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; + return undef; + } + $self->dbh($dbh); - ############################################################# + ############################################################# - return undef unless $self->dbh; + return undef unless $self->dbh; return $self; } @@ -162,29 +161,23 @@ } } } - -# general query subroutine -# parameters: -# statement - a string SQL statement -# bind_values - an array of values to be bound to the parameters -# returns: -# resultset - reference to an array containing ARRAY references -sub general_query{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = get_value('statement', @args); - my $sth = $dbh->prepare($statement); - if (@args > 1) - { - my $bindvalues = get_value('bind_values', @args); - $sth->execute(@$bindvalues); - } - else { - $sth->execute; - } - my $result = $sth->fetchall_arrayref(); - return $result; -} +# +#sub general_query{ +# my ($self, @args) = @_; +# my $dbh = $self->dbh; +# my $statement = get_value('statement', @args); +# my $sth = $dbh->prepare($statement); +# if (@args > 1) +# { +# my $bindvalues = get_value('bind_values', @args); +# $sth->execute(@$bindvalues); +# } +# else { +# $sth->execute; +# } +# my $result = $sth->fetchall_arrayref(); +# return $result; +#} sub query_collection_input{ my ($self, @args) = @_; @@ -207,15 +200,12 @@ } sub insert_collection_input { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; -# if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # this should be dropped down into the mysql.pm module?? probably... $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", - undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); + undef, $args{'service_instance_id'},$args{'article_name'}); my $id=$self->dbh->{mysql_insertid}; return $id; -# } } sub delete_collection_input{ From mwilkinson at pub.open-bio.org Mon Jul 25 18:17:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 14:17:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251817.j6PIHjei020657@pub.open-bio.org> mwilkinson Mon Jul 25 14:17:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 17:50:02 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:17:44 1.7 @@ -281,6 +281,21 @@ # # collection_input table functions # + +=head2 query_collection_input + + Title : query_collection_input + Usage : my $un = $API->query_collection_input(%arg) + Function : get the collection input information for a given service + Args : service_lsid => String + Returns : listref of hashrefs: + [{collection_input_id => Integer + article_name => String}, ...] + one hashref for each collection that service consumes + Notes : the fact that it returns a collection_input_id is bad since this + is only useful to an SQL-based API... +=cut + sub query_collection_input{ die "query_collection_input not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Mon Jul 25 18:17:44 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 14:17:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251817.j6PIHioA020638@pub.open-bio.org> mwilkinson Mon Jul 25 14:17:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY Modified Files: Central.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic moby-live/Perl/MOBY Central.pm,1.179,1.180 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.179 retrieving revision 1.180 diff -u -r1.179 -r1.180 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 17:50:02 1.179 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 18:17:44 1.180 @@ -3100,120 +3100,6 @@ return ""; } -#=head2 _traverseServiceDAG -# -# Title : _traverseServiceDAG -# Usage : @valid = $MOBY->_traverseServiceDAG($dbh, $serviceType, $sth_hash) -# Function : starting from $serviceType, find all child services non-redundantly -# by traversing the DAG. -# Returns : list of Service.id database entries. -# Args : none -# -#=cut -# -#sub _traverseServiceDAG { -# -# $CONFIG ||= MOBY::Config->new; # exported by Config.pm -# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); -# -# my ( $dbh, $serviceType, $sth_hash ) = @_; -# my %sth = %{$sth_hash}; -# my %ServiceIDs; -# -# my $result = $adaptor->general_query({statement => $sth{get_service_type_id}}, {bind_values => [$serviceType]}); -# my $row = shift(@$result); -# my ($root_id) = @$row; -# return undef unless $root_id; -# -## we have to do a traversal of the DAG here to get all child nodes... -## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... -# $ServiceIDs{$root_id} = "untested"; # mark the one in-hand as untested -# while ( grep /untested/, ( values %ServiceIDs ) ) -# { # now, while there are untested services in our list... -# foreach my $service ( keys %ServiceIDs ) -# { # start parsing through the list -# next -# if ( $ServiceIDs{$service} eq "tested" ) -# ; # if it has been tested already then move on -# -# my $result = $adaptor->general_query({statement => $sth{get_service_hierarchy_list}}, {bind_values => [$service]} ); -# # execute the query for child nodes -# $ServiceIDs{$service} = "tested"; # mark it as tested -# foreach my $row (@$result) -# { # now get each of the child nodes -# my $new = @$row; -# next -# if ( defined $ServiceIDs{$new} ) -# ; # if we have already heard about it then move on -# $ServiceIDs{$new} = "untested" -# ; #otherwise mark it as untested, and start all over again -# } -# } -# } -# return keys %ServiceIDs; -#} - -#=head2 _traverseObjectDAG -# -# Title : _traverseObjectDAG -# Usage : @valid = $MOBY->_traverseObjectDAG( $dbh, $objectType, $sth_hash, "p|c") -# Function : from $objectType, find all parent/child objects non-redundantly -# by traversing the DAG. -# Returns : list of Object.id database entries. -# Args : objectType (by name), $statement ahngles, "p" parent, or "c" child -# -#=cut -# -#sub _traverseObjectDAG { -# $CONFIG ||= MOBY::Config->new; # exported by Config.pm -# my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); -# -# my ( $dbh, $objectType, $sth_hash, $dir ) = @_; -# my %sth = %{$sth_hash}; -# my %ObjectIDs; -# -# my $result = $adaptor->general_query({statement => $sth{get_object_type_id}}, {bind_values => [$objectType]}); -# -# my $row = shift (@$result); -# my ($root_id) = @$row; -# return undef unless $root_id; -# -## we have to do a traversal of the DAG here to get all child nodes... -## this is one UGLY piece of code written in a hurry! Please, someone, shoot it and put it out of its misery... -# $ObjectIDs{$root_id} = "untested"; # mark the one in-hand as untested -# while ( grep /untested/, ( values %ObjectIDs ) ) -# { # now, while there are untested services in our list... -# foreach my $object ( keys %ObjectIDs ) -# { # start parsing through the list -# next -# if ( $ObjectIDs{$object} eq "tested" ) -# ; # if it has been tested already then move on -# -# my $result; -# if ( $dir eq "p" ) { -# $debug && &_LOG("getting parents"); -# $result = $adaptor->general_query({statement => $sth{get_object_parent_list}}, {bind_values => [$object]}); -# } -# else { -# $debug && &_LOG("getting children"); -# $result = $adaptor->general_query({statement => $sth{get_object_child_list}}, {bind_values => [$object]}); -# } -# # execute the query for child nodes -# -# $ObjectIDs{$object} = "tested"; # mark it as tested -# foreach my $row (@$result) -# { # now get each of the child nodes -# my $new = @$row; -# next -# if ( defined $ObjectIDs{$new} ) -# ; # if we have already heard about it then move on -# $ObjectIDs{$new} = "untested" -# ; #otherwise mark it as untested, and start all over again -# } -# } -# } -# return keys %ObjectIDs; -#} #Eddie - converted sub _nodeTextContent { From mwilkinson at pub.open-bio.org Mon Jul 25 18:17:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 14:17:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251817.j6PIHjxi020677@pub.open-bio.org> mwilkinson Mon Jul 25 14:17:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv20619/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.29,1.30 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 17:50:02 1.29 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 18:17:44 1.30 @@ -97,7 +97,7 @@ } -sub add_condition{ +sub _add_condition{ my ($statement, @params) = @_; my @bindvalues = (); my $condition = "where "; @@ -161,41 +161,18 @@ } } } -# -#sub general_query{ -# my ($self, @args) = @_; -# my $dbh = $self->dbh; -# my $statement = get_value('statement', @args); -# my $sth = $dbh->prepare($statement); -# if (@args > 1) -# { -# my $bindvalues = get_value('bind_values', @args); -# $sth->execute(@$bindvalues); -# } -# else { -# $sth->execute; -# } -# my $result = $sth->fetchall_arrayref(); -# return $result; -#} - + +# this should NOT retun a collection ID... needs more work... sub query_collection_input{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; + my $serv_lsid = $args{'service_lsid'}; my $statement = "select collection_input_id, - article_name, - service_instance_id - from collection_input "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) = add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); + article_name + from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; + my $result = do_query($dbh, $statement, [$serv_lsid]); return $result; } @@ -213,7 +190,7 @@ my $dbh = $self->dbh; my $statement = "delete from collection_input "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -239,7 +216,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -263,7 +240,7 @@ my $dbh = $self->dbh; my $statement = "delete from collection_output "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -292,7 +269,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -328,7 +305,7 @@ my $dbh = $self->dbh; my $statement = "delete from simple_input "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); if ($dbh->err){ @@ -355,7 +332,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -391,7 +368,7 @@ my $dbh = $self->dbh; my $statement = "delete from simple_output "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); if ($dbh->err){ @@ -420,7 +397,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -448,7 +425,7 @@ my $dbh = $self->dbh; my $statement = "delete from secondary_input "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -478,7 +455,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -512,7 +489,7 @@ my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........********** # ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ******************** my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -539,7 +516,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -567,7 +544,7 @@ my $statement = "delete from object_term2term "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -606,7 +583,7 @@ lsid from service_instance "; my @bindvalues; - ($statement, @bindvalues) = add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); + ($statement, @bindvalues) =_add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); my $final = do_query($dbh, $statement, @bindvalues); if (@$final[0]){return 1} else {return 0} @@ -628,7 +605,7 @@ delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ - push @args, ({$k => $v}, "and"); # format for the add_condition subroutine + push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine } if ($authority_id){ push @args, ({authority_id => $authority_id}) ; @@ -650,7 +627,7 @@ lsid from service_instance "; my @bindvalues; - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); return $final; } @@ -693,7 +670,7 @@ my $dbh = $self->dbh; my $statement = "delete from service_instance "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); if ($dbh->err){ @@ -719,7 +696,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -766,7 +743,7 @@ my @bindvalues = (); if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -792,7 +769,7 @@ my $dbh = $self->dbh; my $statement = "delete from service "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -816,7 +793,7 @@ my @bindvalues = (); if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -839,7 +816,7 @@ my $dbh = $self->dbh; my $statement = "delete from service_term2term "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -869,7 +846,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -892,7 +869,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -918,7 +895,7 @@ my $dbh = $self->dbh; my $statement = "delete from namespace "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); @@ -944,7 +921,7 @@ if (@args > 0) { - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); } my $result = do_query($dbh, $statement, @bindvalues); @@ -956,7 +933,7 @@ my $dbh = $self->dbh; my $statement = "delete from namespace_term2term "; my @bindvalues = (); - ($statement, @bindvalues) = add_condition($statement, @args); + ($statement, @bindvalues) =_add_condition($statement, @args); $dbh->do( $statement, undef, @bindvalues ); From dwang at pub.open-bio.org Mon Jul 25 18:20:16 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 14:20:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251820.j6PIKGvG020735@pub.open-bio.org> dwang Mon Jul 25 14:20:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv20709/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added documentation for getRelationship() moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:17:44 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:20:16 1.8 @@ -595,6 +595,18 @@ die "getObjectRelationships not implemented in adaptor\n"; } +=head2 getRelationship + + Title : getRelationship + Usage : my $un = $API->general_query(@args) + Function : Execute a query for a relationship between two tables on an underlying SQL-based data source + Returns : array of array-refs representing resulting rows + Args : String - direction in the ontology (eg. 'root') + String - name of the table ontology + Integer - a bind value for lsid + String - a bind value for relationship_type + +=cut # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references sub getRelationship{ From mwilkinson at pub.open-bio.org Mon Jul 25 19:53:36 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 15:53:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251953.j6PJra0j021023@pub.open-bio.org> mwilkinson Mon Jul 25 15:53:36 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv20961/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic. Lots more of these to come, but committing now so that Dennis can see what I am doing moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.30,1.31 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 18:17:44 1.30 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 19:53:36 1.31 @@ -162,7 +162,17 @@ } } +sub _getSIIDFromLSID { + my ($self, $lsid) = @_; + my $dbh = $self->dbh; + my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); + $sth->execute($lsid); + my ($siid) = $sth->fetchrow_array(); + return $siid; +} + # this should NOT retun a collection ID... needs more work... +# args passed in: service_lsid sub query_collection_input{ my ($self, %args) = @_; my $dbh = $self->dbh; @@ -176,144 +186,132 @@ return $result; } +# args passed in: service_instance_lsid, article_name sub insert_collection_input { - my ($self, %args) = @_; - my $dbh = $self->dbh; - $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", - undef, $args{'service_instance_id'},$args{'article_name'}); - my $id=$self->dbh->{mysql_insertid}; - return $id; + my ($self, %args) = @_; + my $article = $args{article_name}; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", + undef, $siid, $article); + my $id=$self->dbh->{mysql_insertid}; + return $id; } +# pass in service_instance_lsid sub delete_collection_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from collection_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + my $statement = "delete from collection_input where service_instance_id = ?"; + $self->dbh->do( $statement, undef, $siid); + + if ($self->dbh->err){ + return (1, $self->dbh->errstr); + } + else{ + return 0; + } } -# query subroutine selects all columns +# pass service_instance_lsid sub query_collection_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select collection_output_id, article_name, service_instance_id - from collection_output "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + from collection_output where service_instance_id = ? "; + my $result = do_query($dbh, $statement, [$siid]); + return $result; } +# pass service_instance_lsid, article_name sub insert_collection_output { - my ($self, @args) = @_; - my $dbh = $self->dbh; -# if ($self->sourcetype eq "MOBY::Adaptor::moby::queryapi::mysql"){ - # this should be dropped down into the mysql.pm module?? probably... - $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", - undef, (get_value('service_instance_id', @args), get_value('article_name', @args))); - my $id=$self->dbh->{mysql_insertid}; - return $id; -# } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", + undef, $siid,$args{'article_name'}); + my $id=$self->dbh->{mysql_insertid}; + return $id; } +# pass argument service_instance_lsid sub delete_collection_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from collection_output "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from collection_output where service_instance_id = ?"; + my @bindvalues = (); + $dbh->do( $statement, undef, ($siid)); + + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } - +# pass service_instance_lsid sub query_simple_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - simple_input_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id - from simple_input "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + simple_input_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id + from simple_input where service_instance_id = ? and collection_input_id IS NULL"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; } - +# pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id sub insert_simple_input { - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $si = get_value('collection_input_id', @args)?undef:get_value('service_instance_id', @args); - - $dbh->do("insert into simple_input - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id) - values (?,?,?,?,?)", - undef, - (get_value('object_type_uri', @args), - get_value('namespace_type_uris', @args), - get_value('article_name', @args), -# here - $si, - get_value('collection_input_id', @args))); - my $id=$dbh->{mysql_insertid}; - return $id; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do("insert into simple_input + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id) + values (?,?,?,?,?)", + undef, + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_input_id'}); + my $id=$dbh->{mysql_insertid}; + return $id; } sub delete_simple_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from simple_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, @args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $statement = "delete from simple_input "; + my @bindvalues = (); + ($statement, @bindvalues) =_add_condition($statement, @args); + $dbh->do( $statement, + undef, @bindvalues ); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } sub query_simple_output{ From mwilkinson at pub.open-bio.org Mon Jul 25 19:53:36 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 15:53:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507251953.j6PJraI8021004@pub.open-bio.org> mwilkinson Mon Jul 25 15:53:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv20961/MOBY Modified Files: Central.pm collection_input.pm collection_output.pm secondary_input.pm service_instance.pm simple_input.pm simple_output.pm Log Message: changing the adaptor API to be more perlish. Pass the service LSID rather than the database key to be more generic. Lots more of these to come, but committing now so that Dennis can see what I am doing moby-live/Perl/MOBY Central.pm,1.180,1.181 collection_input.pm,1.5,1.6 collection_output.pm,1.4,1.5 secondary_input.pm,1.6,1.7 service_instance.pm,1.24,1.25 simple_input.pm,1.6,1.7 simple_output.pm,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.180 retrieving revision 1.181 diff -u -r1.180 -r1.181 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 18:17:44 1.180 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 19:53:35 1.181 @@ -3270,7 +3270,6 @@ $desc = $1; } -#print "\n\nAFTER EXECUTE $category, $servicename, $service_type_uri, $authority_id, $desc, $authoritative\n\n"; $signatureURL ||= ""; next unless ( $servicename && $authority_id ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); @@ -3278,8 +3277,7 @@ $result = $adaptor->query_authority({authority_id => $authority_id}); $row = shift(@$result); my $authURI = $row->{authority_uri}; - $output .= -"\t\n"; + $output .= "\t\n"; $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; $output .= "\t$category\n"; @@ -3288,8 +3286,10 @@ $output .= "\t$signatureURL\n"; $output .= "\t$url\n"; $output .= "\t\n"; - - $result = $adaptor->query_simple_input({service_instance_id => $_}, 'and', {collection_input_id => undef}); + +#************FIX +#************FIX : $_ here should also be an LSID... + $result = $adaptor->query_simple_input(service_instance_lsid => $lsid); foreach my $row (@$result) { @@ -3309,8 +3309,7 @@ } $output .= "\t\t\n"; } - $result = $adaptor->query_collection_input({service_instance_id => $_}); -# $sth_collection_ins->execute($_); + $result = $adaptor->query_collection_input(service_instance_lsid => $lsid); foreach my $row (@$result) { @@ -3319,7 +3318,7 @@ $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, 'and', {collection_input_id => $collid}); + my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_input_id => $collid); foreach my $row2 (@$result2) { my $objURI = $row2->{object_type_uri}; @@ -3344,7 +3343,7 @@ $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_simple_output({service_instance_id => $_}, 'and', {collection_output_id => undef}); + $result = $adaptor->query_simple_output(service_instance_lsid => $lsid}, collection_output_id => undef); foreach my $row (@$result) { @@ -3365,14 +3364,14 @@ $output .= "\t\t\n"; } - $result = $adaptor->query_collection_output({service_instance_id => $_}); + $result = $adaptor->query_collection_output(service_instance_lsid => $lsid); foreach my $row (@$result) { my $collid = $row->{collection_output_id}; my $articlename = $row->{article_name}; $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output({service_instance_id => undef}, {collection_output_id => $collid}); + my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_output_id => $collid); foreach my $row2 (@$result2 ) { my $objURI = $row2->{object_type_uri}; @@ -3395,7 +3394,7 @@ } $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_secondary_input({service_instance_id => $_}); + $result = $adaptor->query_secondary_input(service_instance_lsid => $_); foreach my $row (@$result) { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ("","","","","",""); $default_value = $row->{default_value}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/25 17:50:02 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_input.pm 2005/07/25 19:53:35 1.6 @@ -46,6 +46,7 @@ collection_input_id => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -94,7 +95,7 @@ my ($self) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - my $id = $adaptor->insert_collection_input(service_instance => $self->service_instance_id, + my $id = $adaptor->insert_collection_input(service_instance_lsid => $self->service_instance_lsid, article_name => $self->article_name); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/18 16:53:03 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY/collection_output.pm 2005/07/25 19:53:35 1.5 @@ -45,6 +45,7 @@ collection_output_id => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -94,8 +95,8 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_collection_output( - {service_instance => $self->service_instance_id}, - {article_name => $self->article_name} ); + service_instance_lsid => $self->service_instance_lsid, + article_name => $self->article_name); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/22 19:16:40 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 19:53:35 1.7 @@ -50,6 +50,7 @@ datatype => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -120,7 +121,7 @@ {enum_value => $self->enum_value}, {datatype => $self->datatype}, {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}); + {service_instance_lsid => $self->service_instance_id}); return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/22 19:38:02 1.24 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 19:53:35 1.25 @@ -71,9 +71,9 @@ contact_email => [ undef, 'read/write' ], authoritative => [ 0, 'read/write' ], description => [ undef, 'read/write' ], - registry => [ 'MOBY_Central', 'read/write' ], - lsid => [ undef, 'read/write' ], - test => [ 0, 'read/write' ] + registry => [ 'MOBY_Central', 'read/write' ], + lsid => [ undef, 'read/write' ], + test => [ 0, 'read/write' ] , # toggles create or test_existence behaviour ); @@ -164,12 +164,6 @@ } } -#sub _dbh { -# my ($self) = @_; -# -# my $central_connect = MOBY::central_db_connection->new(); -# $self->dbh($central_connect->dbh); -#} sub new { my ( $caller, %args ) = @_; my $caller_is_obj = ref($caller); @@ -189,27 +183,23 @@ return undef unless $self->authority_uri; return undef unless $self->servicename; - if ( $self->test ) { return $self->service_instance_exists } + if ( $self->test ) { return $self->service_instance_exists } # returns boolean - $self->authority( $self->_get_authority() ); + $self->authority( $self->_get_authority() ); # as MOBY::authority object if ( $self->service_type ) { my $OE = MOBY::OntologyServer->new( ontology => 'service' ); my ( $success, $message, $servicetypeURI ) = $OE->serviceExists( term => $self->service_type ); unless ( - ( - $success - || ( ( $self->service_type =~ /urn:lsid/i ) - && !( $self->service_type =~ /urn:lsid:biomoby.org/i ) ) - ) - ) + $success || ( ( $self->service_type =~ /urn:lsid/i ) && !( $self->service_type =~ /urn:lsid:biomoby.org/i ) ) + ) { return undef; } - ( $self->service_type =~ /urn:lsid/ ) - ? $self->service_type_uri( $self->service_type ) - : $self->service_type_uri($servicetypeURI); + ( $self->service_type =~ /urn:lsid/ )? + $self->service_type_uri( $self->service_type ) + : $self->service_type_uri($servicetypeURI); } my $existing_services = $self->adaptor->query_service_instance(servicename => $self->servicename, authority_uri => $self->authority_uri); @@ -236,23 +226,25 @@ ) { # then create it de novo if we have enough information #create LSID for service and register it in the DB my $_config ||= MOBY::Config->new; - my $service_lsid = "urn:lsid:" - . $_config->{mobycentral}->{lsid_authority} . ":" - . $_config->{mobycentral}->{lsid_namespace} . ":" + my $LSID_Auth = $_config->{mobycentral}->{lsid_authority}; + my $LSID_NS = $_config->{mobycentral}->{lsid_namespace}; + $LSID_Auth ||="biomoby.org"; + $LSID_NS ||="serviceinstance"; + my $service_lsid = "urn:lsid:$LSID_Auth:$LSID_NS:" . $self->authority_uri . "," . $self->servicename; my $id = $self->adaptor->insert_service_instance( - {category => $self->category}, - {servicename => $self->servicename}, - {service_type_uri => $self->service_type_uri}, - {authority_id => $self->authority_id}, - {url => $self->url}, - {contact_email => $self->contact_email}, - {authoritative => $self->authoritative}, - {description => $self->description}, - {signatureURL => $self->signatureURL}, - {lsid => $service_lsid} + {category => $self->category}, + {servicename => $self->servicename}, + {service_type_uri => $self->service_type_uri}, + {authority_id => $self->authority_id}, + {url => $self->url}, + {contact_email => $self->contact_email}, + {authoritative => $self->authoritative}, + {description => $self->description}, + {signatureURL => $self->signatureURL}, + {lsid => $service_lsid} ); $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists @@ -271,26 +263,26 @@ $CONFIG ||= MOBY::Config->new; my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - $adaptor->delete_service_instance({service_instance_id => $self->service_instance_id}); - $adaptor->delete_simple_input({service_instance_id => $self->service_instance_id}); - $adaptor->delete_simple_output({service_instance_id => $self->service_instance_id}); + $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_input({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_output({service_instance_lsid => $self->lsid}); - my $result = $adaptor->query_collection_input({service_instance_id => $self->service_instance_id}); + my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); foreach my $row (@$result) { my $id = $row->{collection_input_id}; $adaptor->delete_simple_input({collection_input_id => $id}); } - $result = $adaptor->query_collection_output({service_instance_id => $self->service_instance_id}); + $result = $adaptor->query_collection_output(service_instance_lsid => $self->lsid); foreach my $row (@$result) { my $id = $row->{collection_output_id}; $adaptor->delete_simple_output({collection_output_id => $id}); } - $adaptor->delete_collection_input({service_instance_id => $self->service_instance_id}); - $adaptor->delete_collection_output({service_instance_id => $self->service_instance_id}); - $adaptor->delete_secondary_input({service_instance_id => $self->service_instance_id}); + $adaptor->delete_collection_input(service_instance_lsid => $self->lsid); + $adaptor->delete_collection_output(service_instance_lsid => $self->lsid); + $adaptor->delete_secondary_input({service_instance_lsid => $self->lsid}); return 1; } @@ -329,16 +321,16 @@ my $email = $row->{contact_email}; $authority = MOBY::authority->new( - dbh => $self->dbh, - authority_id => $id, - authority_uri => $uri, - contact_email => $email, + dbh => $self->dbh, + authority_id => $id, + authority_uri => $uri, + contact_email => $email, ); } else { $authority = MOBY::authority->new( - dbh => $self->dbh, - authority_uri => $self->authority_uri, - contact_email => $self->contact_email, + dbh => $self->dbh, + authority_uri => $self->authority_uri, + contact_email => $self->contact_email, ); } return $authority; @@ -349,11 +341,12 @@ # validate here... one day... my $simple = MOBY::simple_input->new( - object_type_uri => $a{'object_type_uri'}, - namespace_type_uris => $a{'namespace_type_uris'}, - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, - collection_input_id => $a{'collection_input_id'} + object_type_uri => $a{'object_type_uri'}, + namespace_type_uris => $a{'namespace_type_uris'}, + article_name => $a{'article_name'}, + service_instance_id => $self->service_instance_id, + service_instance_lsid => $self->lsid, + collection_input_id => $a{'collection_input_id'} ); push @{ $self->{inputs} }, $simple; return $simple->simple_input_id; @@ -364,11 +357,12 @@ # validate here... one day... my $simple = MOBY::simple_output->new( - object_type_uri => $a{'object_type_uri'}, - namespace_type_uris => $a{'namespace_type_uris'}, - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, - collection_output_id => $a{'collection_output_id'} + object_type_uri => $a{'object_type_uri'}, + namespace_type_uris => $a{'namespace_type_uris'}, + article_name => $a{'article_name'}, + service_instance_id => $self->service_instance_id, + service_instance_lsid => $self->lsid, + collection_output_id => $a{'collection_output_id'} ); push @{ $self->{outputs} }, $simple; return $simple->simple_output_id; @@ -379,8 +373,9 @@ # validate here... one day... my $coll = MOBY::collection_input->new( - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, ); + article_name => $a{'article_name'}, + service_instance_lsid => $self->lsid, + service_instance_id => $self->service_instance_id, ); push @{ $self->{inputs} }, $coll; return $coll->collection_input_id; } @@ -390,8 +385,9 @@ # validate here... one day... my $coll = MOBY::collection_output->new( - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, ); + article_name => $a{'article_name'}, + service_instance_lsid => $self->lsid, + service_instance_id => $self->service_instance_id, ); push @{ $self->{outputs} }, $coll; return $coll->collection_output_id; } @@ -401,13 +397,14 @@ # validate here... one day... my $sec = MOBY::secondary_input->new( - default_value => $a{'default_value'}, - maximum_value => $a{'maximum_value'}, - minimum_value => $a{'minimum_value'}, - enum_value => $a{'enum_value'}, - datatype => $a{'datatype'}, - article_name => $a{'article_name'}, - service_instance_id => $self->service_instance_id, + default_value => $a{'default_value'}, + maximum_value => $a{'maximum_value'}, + minimum_value => $a{'minimum_value'}, + enum_value => $a{'enum_value'}, + datatype => $a{'datatype'}, + article_name => $a{'article_name'}, + service_instance_id => $self->service_instance_id, + service_instance_lsid => $self->lsid, ); push @{ $self->{inputs} }, $sec; return $sec->secondary_input_id; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/18 16:53:03 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/25 19:53:35 1.7 @@ -50,6 +50,7 @@ namespace_type_uris => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], collection_input_id => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -100,11 +101,11 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_input( - {object_type_uri => $self->object_type_uri}, - {namespace_type_uris => $self->namespace_type_uris}, - {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}, - {collection_input_id => $self->collection_input_id} + object_type_uri => $self->object_type_uri, + namespace_type_uris => $self->namespace_type_uris, + article_name => $self->article_name, + service_instance_lsid => $self->service_instance_id, + collection_input_id => $self->collection_input_id ); return $id; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/18 16:53:03 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 19:53:35 1.6 @@ -49,6 +49,7 @@ namespace_type_uris => [ undef, 'read/write' ], article_name => [ undef, 'read/write' ], service_instance_id => [ undef, 'read/write' ], + service_instance_lsid => [ undef, 'read/write' ], collection_output_id => [ undef, 'read/write' ], dbh => [ undef, 'read/write' ], ); @@ -102,7 +103,7 @@ {object_type_uri => $self->object_type_uri}, {namespace_type_uris => $self->namespace_type_uris}, {article_name => $self->article_name}, - {service_instance_id => $self->service_instance_id}, + {service_instance_lsid => $self->service_instance_id}, {collection_output_id => $self->collection_output_id} ); return $id; From mwilkinson at pub.open-bio.org Mon Jul 25 20:14:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 16:14:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252014.j6PKEZfM021182@pub.open-bio.org> mwilkinson Mon Jul 25 16:14:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21136/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.31,1.32 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 19:53:36 1.31 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:14:35 1.32 @@ -297,15 +297,14 @@ return $id; } +# pass service_instance_lsid sub delete_simple_input{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $statement = "delete from simple_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $statement = "delete from simple_input where service_instance_lsid = ?"; + + $dbh->do( $statement, undef,($siid)); if ($dbh->err){ return (1, $dbh->errstr); } @@ -314,50 +313,71 @@ } } +sub delete_inputs { # this should replace all other delete_*_input + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $result_ids = $adaptor->query_collection_input(service_instance_lsid => $self->lsid); + + my $statement = "delete from simple_input where service_instance_lsid = ?"; + + $dbh->do( $statement, undef,($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } + +} + +sub delete_output { # this should replace all other delete_*_output + +} + +# UGH this has to know too much bout the underlying database structure e.g. that one is null and other is full +# this problem is in MOBY::Central line 3321 3346 and 3374 +#****** FIX +# send service_instance_lsid, collection_input_id sub query_simple_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - simple_output_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id - from simple_output "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $collid = $args{collection_input_id}; + my $dbh = $self->dbh; + + my $statement = "select + simple_output_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id + from simple_output where service_instance_id = ? and collection_input_id= ?"; + my $result = do_query($dbh, $statement, ($siid, $collid)); + return $result; } +# pass args service_instance_id and collection_output_id sub insert_simple_output { - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $si = get_value('collection_output_id', @args)?undef:get_value('service_instance_id', @args); + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; - $dbh->do("insert into simple_output - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id) - values (?,?,?,?,?)", - undef, - (get_value('object_type_uri', @args), - get_value('namespace_type_uris', @args), - get_value('article_name', @args), -# and here - $si, - get_value('collection_output_id', @args))); - my $id=$dbh->{mysql_insertid}; - return $id; + $dbh->do("insert into simple_output + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id) + values (?,?,?,?,?)", + undef,( + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_output_id'})); + my $id=$dbh->{mysql_insertid}; + return $id; } From mwilkinson at pub.open-bio.org Mon Jul 25 20:14:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 16:14:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252014.j6PKEZde021163@pub.open-bio.org> mwilkinson Mon Jul 25 16:14:34 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21136/MOBY Modified Files: Central.pm service_instance.pm simple_output.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY Central.pm,1.181,1.182 service_instance.pm,1.25,1.26 simple_output.pm,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.181 retrieving revision 1.182 diff -u -r1.181 -r1.182 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 19:53:35 1.181 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 20:14:34 1.182 @@ -3343,7 +3343,7 @@ $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_simple_output(service_instance_lsid => $lsid}, collection_output_id => undef); + $result = $adaptor->query_simple_output(service_instance_lsid => $lsid, collection_output_id => undef); foreach my $row (@$result) { =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 19:53:35 1.25 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:14:34 1.26 @@ -262,9 +262,13 @@ } $CONFIG ||= MOBY::Config->new; my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - + +#********FIX this should really be delete_input and delete_output +# the routines below know too much about the database (e.g. that +# the delete_simple_input routines are broken into two parts - by LSID and +# by collecion ID... BAD BAD BAD $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); - $adaptor->delete_simple_input({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output({service_instance_lsid => $self->lsid}); my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 19:53:35 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 20:14:34 1.7 @@ -100,12 +100,12 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $id = $adaptor->insert_simple_output( - {object_type_uri => $self->object_type_uri}, - {namespace_type_uris => $self->namespace_type_uris}, - {article_name => $self->article_name}, - {service_instance_lsid => $self->service_instance_id}, - {collection_output_id => $self->collection_output_id} - ); + object_type_uri => $self->object_type_uri, + namespace_type_uris => $self->namespace_type_uris, + article_name => $self->article_name, + service_instance_lsid => $self->service_instance_id, + collection_output_id => $self->collection_output_id + ); return $id; } From kawas at pub.open-bio.org Mon Jul 25 20:18:52 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon, 25 Jul 2005 16:18:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252018.j6PKIq0K021236@pub.open-bio.org> kawas Mon Jul 25 16:18:51 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util In directory pub.open-bio.org:/tmp/cvs-serv21211/org/biomoby/registry/rdfagent/util Modified Files: Report.java Log Message: changed the default send to address to be my address. moby-live/Java/src/main/org/biomoby/registry/rdfagent/util Report.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/04/16 14:32:47 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/07/25 20:18:51 1.4 @@ -73,7 +73,7 @@ to = DataMngr.getContactEmail(signURL); if (to.equals("")){ - to = "opushneva at yahoo.ca"; + to = "edward.kawas at gmail.com"; } String subject = "The RDFagent Report"; From kawas at pub.open-bio.org Mon Jul 25 20:20:02 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon, 25 Jul 2005 16:20:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252020.j6PKK2Aw021287@pub.open-bio.org> kawas Mon Jul 25 16:20:02 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv21262/org/biomoby/registry/rdfagent/verifier Modified Files: ServiceDescrParser.java Log Message: changed the references from the old predicate vocabulary to the updated one. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServiceDescrParser.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/05/19 15:57:25 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/25 20:20:02 1.6 @@ -9,7 +9,6 @@ import org.biomoby.registry.rdfagent.util.Report; import org.biomoby.registry.rdfagent.util.XMLBuilder; import org.biomoby.registry.rdfagent.vocabulary.MP; -import org.biomoby.registry.rdfagent.vocabulary.MRes; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.rdf.model.Model; @@ -291,7 +290,7 @@ Object type = l3Res.getRequiredProperty(RDF.type).getObject(); - if (type.equals(MRes.Simple)){ + if (type.equals(MP.Simple)){ StmtIterator p34iter = l3Res.listProperties(); while (p34iter.hasNext()) { @@ -341,7 +340,7 @@ } } - else if (type.equals(MRes.Collection) | type.equals(RDF.Bag)){ + else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ // if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ if (l3Res.hasProperty(RDF.li(1))){ StmtIterator p34iter = l3Res.listProperties(); @@ -409,7 +408,7 @@ } } - if (type.equals(MRes.Secondary)){ + if (type.equals(MP.Secondary)){ StmtIterator p34iter = l3Res.listProperties(); while (p34iter.hasNext()) { @@ -507,7 +506,7 @@ if (l3Res.isAnon()){ Object type = l3Res.getRequiredProperty(RDF.type).getObject(); //System.out.println("type_out = "+type); - if (type.equals(MRes.Simple)){ + if (type.equals(MP.Simple)){ StmtIterator p34iter = l3Res.listProperties(); while (p34iter.hasNext()) { @@ -557,7 +556,7 @@ } } - else if (type.equals(MRes.Collection) | type.equals(RDF.Bag)){ + else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ // if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ if (l3Res.hasProperty(RDF.li(1))){ From kawas at pub.open-bio.org Mon Jul 25 20:20:44 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Mon, 25 Jul 2005 16:20:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252020.j6PKKicE021321@pub.open-bio.org> kawas Mon Jul 25 16:20:44 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv21292/org/biomoby/registry/rdfagent/vocabulary Modified Files: MP.java MRes.java Log Message: deprecated the MRes class and modified the MP class to reflect the changes in the RESOURCES script. moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary MP.java,1.4,1.5 MRes.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/04/16 14:30:46 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/07/25 20:20:44 1.5 @@ -27,7 +27,7 @@ private static Model m = ModelFactory.createDefaultModel(); - + //TODO move mobyResource predicates here. public static final Property category = m.getProperty(uri + "category" ) ; public static final Property articleName = m.getProperty(uri + "articleName" ) ; public static final Property article_name = m.getProperty(uri + "article_name" ) ; @@ -49,7 +49,9 @@ public static final Property CollectionArticle = m.getProperty(uri + "CollectionArticle" ); public static final Property SecondaryArticle = m.getProperty(uri + "SecondaryArticle" ) ; public static final Property type = m.getProperty(uri + "type" ) ; - + public static final Property Simple = m.getProperty(uri + "Simple" ) ; + public static final Property Collection = m.getProperty(uri + "Collection" ) ; + public static final Property Secondary = m.getProperty(uri + "Secondary" ) ; } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MRes.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MRes.java 2005/04/16 14:30:46 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MRes.java 2005/07/25 20:20:44 1.2 @@ -9,6 +9,7 @@ import com.hp.hpl.jena.rdf.model.*; /** MP vocabulary class for namespace http://biomoby.org/RESOURCES/MOBY-S/Predicates# + * @deprecated */ public class MRes { From dwang at pub.open-bio.org Mon Jul 25 20:43:49 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 16:43:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252043.j6PKhn5P021416@pub.open-bio.org> dwang Mon Jul 25 16:43:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv21390/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: updated getRelationship and getObjectRelationship documentation to be concurrent with Mark's moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 18:20:16 1.8 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 20:43:49 1.9 @@ -589,6 +589,20 @@ die "getParentTerms not implemented in adaptor\n"; } +=head2 getObjectRelationships + + Title : getObjectRelationships + Usage : my $un = $API->getObjectRelationships(%args) + Function : Execute a query for objects that have relationships with other objects + Args : object1_id => Integer - a bind value for object1_id on an underlying SQL-based data source + Returns : listref of hashrefs: + [{relationship_type => String, + object_lsid => Integer, + object2_articlename => String}, ...] + one hashref for each relationship between two objects + Notes : relationship_type from object_term2term, object_lsid from object, and object2_articlename from object_term2term + +=cut # custom query subroutine for selecting from object_term2term and object tables # used in Moby::OntologyServer.pm->retrieveObject() sub getObjectRelationships{ @@ -598,13 +612,16 @@ =head2 getRelationship Title : getRelationship - Usage : my $un = $API->general_query(@args) - Function : Execute a query for a relationship between two tables on an underlying SQL-based data source - Returns : array of array-refs representing resulting rows - Args : String - direction in the ontology (eg. 'root') - String - name of the table ontology - Integer - a bind value for lsid - String - a bind value for relationship_type + Usage : my $un = $API->getRelationships(%args) + Function : Execute a query for a relationship between two ontologies + Args : direction => String - direction in the ontology (eg. 'root') + ontology => String - name of the table ontology + term => Integer - a bind value for lsid + relationship => String - a bind value for relationship_type + Returns : reference to array containing array-refs representing the result set: + [[Integer lsid, String relationship_type], ...] + each array-ref represents one row + Notes : Only returns distinct lsid from $ontology and relationship_type from $ontology_term2term =cut # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() @@ -613,6 +630,7 @@ die "getRelationship not implemented in adaptor\n"; } +# Not quite sure what this does... sub _checkURI { die "_checkURI not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Mon Jul 25 20:55:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 16:55:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252055.j6PKtZ7n021533@pub.open-bio.org> mwilkinson Mon Jul 25 16:55:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21506/MOBY Modified Files: OntologyServer.pm secondary_input.pm service_instance.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY OntologyServer.pm,1.54,1.55 secondary_input.pm,1.7,1.8 service_instance.pm,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/19 23:37:35 1.54 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 20:55:35 1.55 @@ -192,17 +192,10 @@ my $sth; return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); -# if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objecttype/)){ -# return (1, "external ontology", $term); -# } my $result; - if ( $term =~ /^urn\:lsid/ ) { - $result = $adaptor->query_object({object_lsid => $term}); - - } else { - $result = $adaptor->query_object({object_type => $term}); - - } + + $result = $adaptor->query_object(type => $term); + my $row = shift(@$result); my $lsid = $row->{object_lsid}; my $type = $row->{object_type}; @@ -271,12 +264,7 @@ : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } my $result; - if ( $args{'node'} =~ /^urn\:lsid/ ) { - - $result = $adaptor->query_object({object_lsid => $term}); - } else { - $result = $adaptor->query_object({object_type => $term}); - } + $result = $adaptor->query_object(type => $term); my $row = shift(@$result); my $lsid = $row->{object_lsid}; my $type = $row->{object_type}; @@ -320,7 +308,7 @@ ? $args{'node'} : $self->getObjectURI($term); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $result = $adaptor->query_object({object_lsid => $LSID}); + my $result = $adaptor->query_object(type => $LSID); my $row = shift(@$result); my $id = $row->{object_id}; my $type = $row->{object_type}; @@ -372,7 +360,7 @@ return ( 0, q{Object type $term cannot be resolved to an LSID}, "" ) unless $LSID; - my $result = $adaptor->query_object({object_lsid => $LSID}); + my $result = $adaptor->query_object(type => $LSID); my $row = shift(@$result); my $id = $row->{object_id}; my $lsid = $row->{object_lsid}; @@ -471,41 +459,20 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); + my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); - if ( $args{subject_node} =~ /^urn:lsid/ ) { - - my $result = $adaptor->query_object({object_lsid => $args{subject_node}}); - my $row = shift(@$result); - $subj_id = $row->{object_id}; - $subj_lsid = $row->{object_lsid}; - - } else { - my $result = $adaptor->query_object({object_type => $args{subject_node}}); - my $row = shift(@$result); - $subj_id = $row->{object_id}; - $subj_lsid = $row->{object_lsid}; - - } - return ( 0, - qq{Object type $args{subject_node} does not exist in the ontology}, - '' ) + my $result = $adaptor->query_object(type => $args{subject_node}); + my $row = shift(@$result); + $subj_id = $row->{object_id}; + $subj_lsid = $row->{object_lsid}; + return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) unless defined $subj_id; - if ( $args{object_node} =~ /^urn:lsid/ ) { - - my $result = $adaptor->query_object({object_lsid => $args{object_node}}); - my $row = shift(@$result); - $obj_id = $row->{object_id}; - $obj_lsid = $row->{object_lsid}; - - } else { - my $result = $adaptor->query_object({object_type => $args{object_node}}); - my $row = shift(@$result); - $obj_id = $row->{object_id}; - $obj_lsid = $row->{object_lsid}; - } - return ( 0, - qq{Object type $args{object_node} does not exist in the ontology}, - '' ) + + $result = $adaptor->query_object(type => $args{object_node}); + $row = shift(@$result); + $obj_id = $row->{object_id}; + $obj_lsid = $row->{object_lsid}; + return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_id; my $isa = $adaptor->query_object_term2term({object2_id => $subj_id}); @@ -967,7 +934,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return undef unless $URI =~ /urn\:lsid/; - my $result = $adaptor->query_object({object_lsid => $URI}); + my $result = $adaptor->query_object(type => $URI); my $row = shift(@$result); my $name = $row->{object_type}; @@ -1033,7 +1000,7 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_object({object_type => $term}); + my $result = $adaptor->query_object(type => $term); my $row = shift(@$result); my $id = $row->{object_lsid}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 19:53:35 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 20:55:35 1.8 @@ -115,13 +115,13 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $dbh = $self->dbh; - my $insertid = $adaptor->insert_secondary_input({default_value => $self->default_value}, - {maximum_value => $self->maximum_value}, - {minimum_value => $self->minimum_value}, - {enum_value => $self->enum_value}, - {datatype => $self->datatype}, - {article_name => $self->article_name}, - {service_instance_lsid => $self->service_instance_id}); + my $insertid = $adaptor->insert_secondary_input(default_value => $self->default_value, + maximum_value => $self->maximum_value, + minimum_value => $self->minimum_value, + enum_value => $self->enum_value, + datatype => $self->datatype, + article_name => $self->article_name, + service_instance_lsid => $self->service_instance_id); return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:14:34 1.26 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:55:35 1.27 @@ -269,24 +269,24 @@ # by collecion ID... BAD BAD BAD $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); - $adaptor->delete_simple_output({service_instance_lsid => $self->lsid}); + $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); foreach my $row (@$result) { my $id = $row->{collection_input_id}; - $adaptor->delete_simple_input({collection_input_id => $id}); + $adaptor->delete_simple_input(collection_input_id => $id); } $result = $adaptor->query_collection_output(service_instance_lsid => $self->lsid); foreach my $row (@$result) { my $id = $row->{collection_output_id}; - $adaptor->delete_simple_output({collection_output_id => $id}); + $adaptor->delete_simple_output(collection_output_id => $id); } $adaptor->delete_collection_input(service_instance_lsid => $self->lsid); $adaptor->delete_collection_output(service_instance_lsid => $self->lsid); - $adaptor->delete_secondary_input({service_instance_lsid => $self->lsid}); + $adaptor->delete_secondary_input(service_instance_lsid => $self->lsid); return 1; } From mwilkinson at pub.open-bio.org Mon Jul 25 20:55:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 16:55:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252055.j6PKtZHB021552@pub.open-bio.org> mwilkinson Mon Jul 25 16:55:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21506/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.32,1.33 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:14:35 1.32 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:55:35 1.33 @@ -302,9 +302,13 @@ my ($self, %args) = @_; my $dbh = $self->dbh; my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $statement = "delete from simple_input where service_instance_lsid = ?"; - - $dbh->do( $statement, undef,($siid)); + my ($collid) = $args{collection_input_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); if ($dbh->err){ return (1, $dbh->errstr); } @@ -317,7 +321,7 @@ my ($self, %args) = @_; my $dbh = $self->dbh; my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $result_ids = $adaptor->query_collection_input(service_instance_lsid => $self->lsid); + my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); my $statement = "delete from simple_input where service_instance_lsid = ?"; @@ -381,86 +385,88 @@ } +# pass service_instance_id or collection_output_id sub delete_simple_output{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from simple_output "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($collid) = $args{collection_output_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } +# pass service_instance_lsid sub query_secondary_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - secondary_input_id, - default_value, - maximum_value, - minimum_value, - enum_value, - datatype, - article_name, - service_instance_id - from secondary_input "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + secondary_input_id, + default_value, + maximum_value, + minimum_value, + enum_value, + datatype, + article_name, + service_instance_id + from secondary_input where service_instance_id = ?"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; } +# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid sub insert_secondary_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, - undef, - ( - get_value('default_value', @args), get_value('maximum_value', @args), - get_value('minimum_value', @args), get_value('enum_value', @args), - get_value('datatype', @args), get_value('article_name', @args), - get_value('service_instance_id', @args), - ) - ); - return $dbh->{mysql_insertid}; + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, + undef, + ( + $args{'default_value'}, $args{'maximum_value'}, + $args{'minimum_value'}, $args{'enum_value'}, + $args{'datatype'}, $args{'article_name'},$siid) + ); + return $dbh->{mysql_insertid}; } +# pass service_instance_lsid sub delete_secondary_input{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from secondary_input "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from secondary_input where service_instance_lsid=?"; + + $dbh->do( $statement, undef, ($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } } -# query subroutine will selects all rows from object table -sub query_object -{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - + +# receives argument "type", that may be either an LSID or a type term +sub query_object { + my ($self, %args) = @_; + my $type = $args{type}; + my $condition; + if ($type =~ /^urn\:lsid/){ + $condition = "where object_lsid = ?"; + } else { + $condition = "where object_type = ?"; + } my $statement = "select object_id, object_lsid, @@ -468,15 +474,10 @@ description, authority, contact_email - from object "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); + from object $condition"; + + my $dbh = $self->dbh; + my $result = do_query($dbh, $statement, ($type)); return $result; } From mwilkinson at pub.open-bio.org Mon Jul 25 21:13:51 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:13:51 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252113.j6PLDpmi021624@pub.open-bio.org> mwilkinson Mon Jul 25 17:13:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21605/MOBY Modified Files: OntologyServer.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY OntologyServer.pm,1.55,1.56 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 20:55:35 1.55 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:13:51 1.56 @@ -242,10 +242,6 @@ my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); - #node => $term, - #desc => $desc, - #authURI => $auth, - #contact => $email return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node", '' ) unless ( $args{node} ); return ( 0, "requires an authURI ", '' ) unless ( $args{authority} ); @@ -255,9 +251,6 @@ unless ( $args{description} ); my $term = $args{node}; -# if ($term =~ /^urn:lsid/ && !($term =~ /^urn:lsid:biomoby.org:objectclass/)){ # if it is an LSID, but not a MOBY LSID, than barf -# return (0, "can't create a term in a non-MOBY ontology!", $term); -# } my $LSID = ( $args{'node'} =~ /urn\:lsid/ ) ? $args{'node'} @@ -280,11 +273,11 @@ $args{contact_email} =~ s/^\s+(.*?)\s+$/$1/s; $args{authority} =~ s/^\s+(.*?)\s+$/$1/s; - my $insertid = $adaptor->insert_object({object_type => $args{'node'}}, - {object_lsid => $LSID}, - {description => $args{'description'}}, - {authority => $args{'authority'}}, - {contact_email => $args{'contact_email'}}); + my $insertid = $adaptor->insert_object(object_type => $args{'node'}, + object_lsid => $LSID, + description => $args{'description'}, + authority => $args{'authority'}, + contact_email => $args{'contact_email'}); unless ( $insertid ) { return ( 0, "Object creation failed for unknown reasons", '' ); } @@ -373,7 +366,7 @@ $lsid ); } - my ($err, $errstr) = $adaptor->delete_object({object_id => $id}); + my ($err, $errstr) = $adaptor->delete_object(type => $lsid); if ( $err ) { return ( 0, "Delete from Object Class table failed: $errstr", $lsid ); @@ -463,14 +456,12 @@ my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); my $result = $adaptor->query_object(type => $args{subject_node}); my $row = shift(@$result); - $subj_id = $row->{object_id}; $subj_lsid = $row->{object_lsid}; return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) unless defined $subj_id; $result = $adaptor->query_object(type => $args{object_node}); $row = shift(@$result); - $obj_id = $row->{object_id}; $obj_lsid = $row->{object_lsid}; return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_id; @@ -491,10 +482,10 @@ || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - my $insertid = $adaptor->insert_object_term2term({relationship_type => $rel_lsid}, - {object1_id => $subj_id}, - {object2_id => $obj_id}, - {object2_articlename => $args{articleName}}); + my $insertid = $adaptor->insert_object_term2term(relationship_type => $rel_lsid, + object1_id => $subj_lsid, + object2_id => $obj_lsid, + object2_articlename => $args{articleName}); if ($insertid ) { return ( 1, "Object relationsihp created successfully", '' ); } else { From mwilkinson at pub.open-bio.org Mon Jul 25 21:13:51 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:13:51 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252113.j6PLDppZ021643@pub.open-bio.org> mwilkinson Mon Jul 25 17:13:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21605/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.33,1.34 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 20:55:35 1.33 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:13:51 1.34 @@ -482,8 +482,9 @@ } # inserts a new tuple into object table +# pass object_type object_lsid description authority contact_email sub insert_object{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; $dbh->do("insert into object (object_type, @@ -493,24 +494,30 @@ contact_email) values (?,?,?,?,?)", undef, - (get_value('object_type', @args), - get_value('object_lsid', @args), - get_value('description', @args), - get_value('authority', @args), - get_value('contact_email', @args))); + $args{'object_type'}, + $args{'object_lsid'}, + $args{'description'}, + $args{'authority'}, + $args{'contact_email'}); my $id=$dbh->{mysql_insertid}; return $id; } +# pass 'type' which is either an LSID or a term sub delete_object{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - my $statement = "delete from object "; #OMG!! This is a very dangerous thing to start with.........********** - # ************** MUST FIX THAT LINE OR WE MAY BE DEAD ONE DAY ******************** - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $term = $args{type}; + return 0 unless $term; + my $statement = "delete from object where "; + my $condition; + if ($term =~ /^urn\:lsid/){ + $condition = " object_lsid = ?"; + } else { + $condition = " object_type = ?"; + } + $statement = $statement.$condition; + $dbh->do( $statement,undef, ($term) ); if ($dbh->err){ return (1, $dbh->errstr); @@ -520,8 +527,14 @@ } } +# pass "type" here, should be an LSID, preferably... sub query_object_term2term{ - my ($self, @args) = @_; + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_object(type => $type); + my $row = shift(@$result); + my $id = $row->{object_id}; + return [{}] unless $id; my $dbh = $self->dbh; my $statement = "select @@ -530,28 +543,33 @@ object1_id, object2_id, object2_articlename - from object_term2term "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + from object_term2term where object2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; } +# pass object1_type, object2_type, object2_articlename, relationship_type sub insert_object_term2term{ - my ($self, @args) = @_; + my ($self, %args) = @_; + my $type1 = $args{object1_type}; + my $result = $self->query_object(type => $type1); + my $row = shift(@$result); + my $id1 = $row->{object_id}; + my $type2 = $args{object2_type}; + $result = $self->query_object(type => $type2); + $row = shift(@$result); + my $id2 = $row->{object_id}; + my $relationship_type = $args{relationship_type}; + my $object2_articlename = $args{object2_articlename}; + my $dbh = $self->dbh; $dbh->do( -q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, + q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, undef, - ( get_value('relationship_type', @args), - get_value('object1_id', @args), - get_value('object2_id', @args), - get_value('object2_articlename', @args) ) + $relationship_type, + $id1, + $id2, + $object2_articlename ); return $dbh->{mysql_insertid}; From dwang at pub.open-bio.org Mon Jul 25 21:30:12 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 17:30:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252130.j6PLUCER021718@pub.open-bio.org> dwang Mon Jul 25 17:30:12 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv21692/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: documentation added for getServiceNames() and getParentTerms() moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 20:43:49 1.9 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 21:30:12 1.10 @@ -579,11 +579,35 @@ die "getFromCollection not implemented in adaptor\n"; } +=head2 getServiceNames + + Title : getServiceNames + Usage : my $un = $API->getServiceNames(%args) + Function : Execute a query for all service names + Args : no inputs needed + Returns : listref of hashrefs: + [{authority_uri => String, + servicename => String}, ...] + one hashref for each service + +=cut # custom query subroutine for Moby::Central.pm->RetrieveServiceNames sub getServiceNames{ die "getServiceNames not implemented in adaptor\n"; } +=head2 getParentTerms + + Title : getParentTerms + Usage : my $un = $API->getParentTerms(%args) + Function : From a given term, traverse the ontology and get all parent terms + Args : relationship_type_id => Integer - a bind value for relationship_type_id on an underlying SQL-based data source + term => String - bindvalue for OntologyEntry.term + Returns : listref of hashrefs: + [{term => String}, ...] + one hashref for each parent + +=cut # custom query for Moby::Central.pm->_flatten sub getParentTerms{ die "getParentTerms not implemented in adaptor\n"; From mwilkinson at pub.open-bio.org Mon Jul 25 21:30:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:30:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252130.j6PLUc34021761@pub.open-bio.org> mwilkinson Mon Jul 25 17:30:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21742/MOBY Modified Files: OntologyServer.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY OntologyServer.pm,1.56,1.57 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:13:51 1.56 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:30:38 1.57 @@ -371,12 +371,6 @@ return ( 0, "Delete from Object Class table failed: $errstr", $lsid ); } - ($err, $errstr) = $adaptor->delete_object_term2term({object1_id => $id}); - if ( $err ) { - return ( 0, - "Delete from Object term2term table failed: $errstr", - $lsid ); - } return ( 1, "Object $term Deleted", $lsid ); } From mwilkinson at pub.open-bio.org Mon Jul 25 21:30:38 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:30:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252130.j6PLUc7i021781@pub.open-bio.org> mwilkinson Mon Jul 25 17:30:38 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21742/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.34,1.35 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:13:51 1.34 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:30:38 1.35 @@ -519,6 +519,7 @@ $statement = $statement.$condition; $dbh->do( $statement,undef, ($term) ); + $self->_delete_object_term2term(type => $term); if ($dbh->err){ return (1, $dbh->errstr); } @@ -575,15 +576,20 @@ return $dbh->{mysql_insertid}; } -sub delete_object_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; +# pass object 'type' as term or lsid +# this should be a private routine, not a public one. +# SHOULD NOT BE DOCUMENTED IN THE API +sub _delete_object_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $id = $row->object_id; - my $statement = "delete from object_term2term "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $dbh = $self->dbh; + my $statement = "delete from object_term2term where object1_id=?"; + $dbh->do( $statement,undef, ($id)); if ($dbh->err){ return (1, $dbh->errstr); From mwilkinson at pub.open-bio.org Mon Jul 25 21:52:25 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:52:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252152.j6PLqPUu021905@pub.open-bio.org> mwilkinson Mon Jul 25 17:52:25 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv21863/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.35,1.36 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:30:38 1.35 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:52:25 1.36 @@ -599,19 +599,20 @@ } } +# pass servicename and authority_uri sub query_service_existence { my ($self, %args) = @_; my $dbh = $self->dbh; my $servicename = $args{'servicename'}; my $authURI = $args{'authority_uri'}; - my $id = $args{'authority_id'}; - unless ($id){ +# my $id = $args{'authority_id'}; # is it safe to remove this? better be! +# unless ($id){ my $result = $self->query_authority({authority_uri => $authURI}); return 0 unless @$result[0]; - $id = @$result[0]->{authority_id}; + my $id = @$result[0]->{authority_id}; return 0 unless $id; - } +# } my $statement = "select service_instance_id, category, @@ -624,10 +625,8 @@ description, signatureURL, lsid - from service_instance "; - my @bindvalues; - ($statement, @bindvalues) =_add_condition($statement, ({servicename => $servicename},"and",{authority_id=>$id})); - my $final = do_query($dbh, $statement, @bindvalues); + from service_instance where servicename = ? and authority_id = ?"; + my $final = do_query($dbh, $statement, ($servicename, $id)); if (@$final[0]){return 1} else {return 0} } @@ -676,33 +675,38 @@ } # custom query for Moby::Central.pm->findService() +# hmmmmmmm.... I'm not sure that this routine should exist... +# it is redundant to the routine above, if the routine above were executed +# multiple times. I think that is the more correct (though less efficient) +# way to go, since it is "scalable" to every possible underlying data source +# ********FIX change this later... sub match_service_type_uri{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - my $uri_list = get_value('service_type_uri', @args); + my $uri_list = $args{'service_type_uri'}; my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; - my @bindvalues = (); - + my @bindvalues = (); my $result = do_query($dbh, $statement, @bindvalues); return $result; } +# passs........ blah blah..... sub insert_service_instance { - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, undef,( - get_value('category', @args), - get_value('servicename', @args), - get_value('service_type_uri', @args), - get_value('authority_id', @args), - get_value('url', @args), - get_value('contact_email', @args), - get_value('authoritative', @args), - get_value('description', @args), - get_value('signatureURL', @args), - get_value('lsid', @args))); + $args{'category'}, + $args{'servicename'}, + $args{'service_type_uri'}, + $args{'authority_id'}, + $args{'url'}, + $args{'contact_email'}, + $args{'authoritative'}, + $args{'description'}, + $args{'signatureURL'}, + $args{'lsid'})); my $id = $dbh->{mysql_insertid}; return $id; From mwilkinson at pub.open-bio.org Mon Jul 25 21:52:25 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 17:52:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252152.j6PLqP45021886@pub.open-bio.org> mwilkinson Mon Jul 25 17:52:25 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv21863/MOBY Modified Files: Central.pm service_instance.pm Log Message: more of the same. Pass hashes instead of hashrefs, and avoid passing database ids moby-live/Perl/MOBY Central.pm,1.182,1.183 service_instance.pm,1.27,1.28 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.182 retrieving revision 1.183 diff -u -r1.182 -r1.183 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 20:14:34 1.182 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 21:52:25 1.183 @@ -1926,9 +1926,11 @@ my (@children) = @{ $relationships{'urn:lsid:biomoby.org:servicerelation:isa'} }; $children_string .= ( join ',', map { "\'$_\'" } @children ); + #*******FIX this isn't very perlish... sending a comma-delimited string to a subroutine instead of an array + # need to change that one day soon! } $children_string =~ s/\,$//; - my $ids = _extract_ids($adaptor->match_service_type_uri({service_type_uri => $children_string})); + my $ids = _extract_ids($adaptor->match_service_type_uri(service_type_uri => $children_string)); $debug && _LOG( "services " . ( join ',', @{$ids} ) . " incrememted\n" ); @@ -3243,6 +3245,11 @@ } sub _serviceListResponse { + + + # *********FIX + # this routine is using service instances by their database ID, rather than their LSID + # this is BAD BAD BAD $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 20:55:35 1.27 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 21:52:25 1.28 @@ -235,16 +235,16 @@ . $self->servicename; my $id = $self->adaptor->insert_service_instance( - {category => $self->category}, - {servicename => $self->servicename}, - {service_type_uri => $self->service_type_uri}, - {authority_id => $self->authority_id}, - {url => $self->url}, - {contact_email => $self->contact_email}, - {authoritative => $self->authoritative}, - {description => $self->description}, - {signatureURL => $self->signatureURL}, - {lsid => $service_lsid} + category => $self->category, + servicename => $self->servicename, + service_type_uri => $self->service_type_uri, + authority_id => $self->authority_id, + url => $self->url, + contact_email => $self->contact_email, + authoritative => $self->authoritative, + description => $self->description, + signatureURL => $self->signatureURL, + lsid => $service_lsid ); $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists From mwilkinson at pub.open-bio.org Mon Jul 25 22:10:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 18:10:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252210.j6PMAQdZ022027@pub.open-bio.org> mwilkinson Mon Jul 25 18:10:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22004/MOBY Modified Files: Central.pm service_instance.pm Log Message: how do you know when you have done too much Perl coding? When you start to say %args like a pirate... This change might break things badly- I need to do a join in a dynamically generated SQL statement. It looks OK now. mySQL is weird in that you have to specify table names in natural joins. UGH moby-live/Perl/MOBY Central.pm,1.183,1.184 service_instance.pm,1.28,1.29 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.183 retrieving revision 1.184 diff -u -r1.183 -r1.184 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 21:52:25 1.183 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 22:10:25 1.184 @@ -3259,6 +3259,10 @@ my $OSns = MOBY::OntologyServer->new( ontology => 'namespace' ); my $OSserv = MOBY::OntologyServer->new( ontology => 'service' ); + # *********FIX + # this routine is using service instances by their database ID, rather than their LSID + # this is BAD BAD BAD + foreach (@ids) { my $result = $adaptor->query_service_instance(service_instance_id => $_); my $row = shift(@$result); @@ -3266,7 +3270,7 @@ my $url = $row->{url}; my $servicename = $row->{servicename}; my $service_type_uri = $row->{service_type_uri}; - my $authority_id = $row->{authority_id}; + my $authority_uri = $row->{authority_uri}; my $desc = $row->{description}; my $authoritative = $row->{authoritative}; my $email = $row->{contact_email}; @@ -3281,10 +3285,10 @@ next unless ( $servicename && $authority_id ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); - $result = $adaptor->query_authority({authority_id => $authority_id}); - $row = shift(@$result); - my $authURI = $row->{authority_uri}; - $output .= "\t\n"; + #$result = $adaptor->query_authority({authority_id => $authority_id}); + #$row = shift(@$result); + #my $authURI = $row->{authority_uri}; + $output .= "\t\n"; $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; $output .= "\t$category\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 21:52:25 1.28 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 22:10:26 1.29 @@ -267,7 +267,7 @@ # the routines below know too much about the database (e.g. that # the delete_simple_input routines are broken into two parts - by LSID and # by collecion ID... BAD BAD BAD - $adaptor->delete_service_instance({service_instance_lsid => $self->lsid}); + $adaptor->delete_service_instance(service_instance_lsid => $self->lsid); $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); @@ -313,9 +313,8 @@ my $dbh = $self->dbh; my $authority; $CONFIG ||= MOBY::Config->new; - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - - my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); + my $result = $adaptor->query_authority(authority_uri => $self->authority_uri); if ( @$result[0]) { my $row = shift(@$result); From mwilkinson at pub.open-bio.org Mon Jul 25 22:10:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 18:10:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252210.j6PMAQTW022046@pub.open-bio.org> mwilkinson Mon Jul 25 18:10:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22004/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: how do you know when you have done too much Perl coding? When you start to say %args like a pirate... This change might break things badly- I need to do a join in a dynamically generated SQL statement. It looks OK now. mySQL is weird in that you have to specify table names in natural joins. UGH moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.36,1.37 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 21:52:25 1.36 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 22:10:26 1.37 @@ -608,7 +608,7 @@ my $authURI = $args{'authority_uri'}; # my $id = $args{'authority_id'}; # is it safe to remove this? better be! # unless ($id){ - my $result = $self->query_authority({authority_uri => $authURI}); + my $result = $self->query_authority(authority_uri => $authURI); return 0 unless @$result[0]; my $id = @$result[0]->{authority_id}; return 0 unless $id; @@ -638,36 +638,36 @@ my $dbh = $self->dbh; my $authority_id; - if ($args{'authority_uri'}){ # need to transform URI to a row ID - my $result = $self->query_authority({authority_uri => $args{'authority_uri'}}); - return 0 unless @$result[0]; - $authority_id = @$result[0]->{authority_id}; - return 0 unless $authority_id; - } - delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table + #if ($args{'authority_uri'}){ # need to transform URI to a row ID + # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); + # return 0 unless @$result[0]; + # $authority_id = @$result[0]->{authority_id}; + # return 0 unless $authority_id; + #} + #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine } - if ($authority_id){ - push @args, ({authority_id => $authority_id}) ; - } else { - pop @args; # remove final "and" - } +# if ($authority_id){ +# push @args, ({authority_id => $authority_id}) ; +# } else { +# pop @args; # remove final "and" +# } my $statement = "select service_instance_id, category, servicename, service_type_uri, - authority_id, + authority.authority_uri, url, contact_email, authoritative, description, signatureURL, lsid - from service_instance "; + from service_instance left join authority on authority.authority_id "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); @@ -712,14 +712,12 @@ return $id; } +# pass service_instance_lsid sub delete_service_instance{ - my ($self, @args) = @_; + my ($self, %args) = @_; my $dbh = $self->dbh; - my $statement = "delete from service_instance "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); + my $statement = "delete from service_instance where lsid = ?"; + $dbh->do( $statement,undef, ($args{service_instance_lsid}) ); if ($dbh->err){ return (1, $dbh->errstr); } @@ -729,8 +727,10 @@ } # Selects all columns +# pass authority_uri sub query_authority { - my ($self, @args) = @_; + my ($self, %args) = @_; + my $authURI = $args{authority_uri}; my $dbh = $self->dbh; my $statement = "select @@ -738,15 +738,8 @@ authority_common_name, authority_uri, contact_email - from authority "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); + from authority where authority_uri = ?"; + my $result = do_query($dbh, $statement, ($authURI)); return $result; } From dwang at pub.open-bio.org Mon Jul 25 23:31:56 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 19:31:56 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252331.j6PNVuYl022253@pub.open-bio.org> dwang Mon Jul 25 19:31:56 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv22227/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 21:30:12 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:31:56 1.11 @@ -564,16 +564,69 @@ die "checkNamespaceUsedByService not implemented in adaptor\n"; } +=head2 checkKeywords + + Title : checkKeywords + Usage : my $un = $API->checkKeywords(%args) + Function : Execute a custom query for services with keywords in its description + Args : findme => hashref - hash contains an array of keywords + Returns : listref of hashrefs: + [{service_instance_id => Integer, + category => String, + servicename => String, + service_type_uri => String, + authority_id => Integer, + url => String, + contact_email => String, + authoritative => String, + description => String, + signatureURL => String, + lsid => Integer}, ...] + Each hash represents a service + Notes : the fact that it returns a service_instance_id is bad since this + is only useful to an SQL-based API... + +=cut # custom query routine for Moby::Central.pm -> findService() sub checkKeywords{ die "checkKeywords not implemented in adaptor\n"; } +=head2 getFromSimple + + Title : getFromSimple + Usage : my $un = $API->getFromSimple(%args) + Function : Execute a custom query for service ids in simple_input/output + Args : inout => String - to specify if input or output + ancestor_string => String - values that occur in object_type_uri + namespaceURIs => array-ref - reference to an array of namespace URIs + Returns : listref of hashrefs: + [{service_instance_id => Integer, + namespace_type_uris => String}, ...] + Notes : the fact that it returns a service_instance_id is bad since this + is only useful to an SQL-based API... + +=cut # custom query subroutine for Moby::Central.pm->_searchForSimple() sub getFromSimple{ die "getFromSimple not implemented in adaptor\n"; } +=head2 getFromCollection + + Title : getFromCollection + Usage : my $un = $API->getFromCollection(%args) + Function : Execute a custom query for service ids from collections + Args : inout => String - to specify if input or output + objectURI => String - value that binds to object_type_uri + namespaceURIs => array-ref - reference to an array of namespace URIs + Returns : listref of hashrefs: + [{service_instance_id => Integer, + namespace_type_uris => String}, ...] + Notes : the fact that it returns a service_instance_id is bad since this + is only useful to an SQL-based API... + +=cut # custom query subroutine for Moby::Central.pm->_searchForCollection() sub getFromCollection{ die "getFromCollection not implemented in adaptor\n"; From dwang at pub.open-bio.org Mon Jul 25 23:43:43 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Mon, 25 Jul 2005 19:43:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252343.j6PNhhpC022305@pub.open-bio.org> dwang Mon Jul 25 19:43:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv22279/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:31:56 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:43:43 1.12 @@ -559,6 +559,19 @@ die "checkClassUsedByService not implemented in adaptor\n"; } +=head2 checkNamespaceUsedByService + + Title : checkNamespaceUsedByService + Usage : my $un = $API->checkNamespaceUsedByService(%args) + Function : Execute a custom query for namespaces that are used by some service + Args : namespace_type_uris => String - namespace_type_uris you are checking for + term => String - the type of the namespace + Returns : a list: + ($err, $errstr) + $err = 1 if namespace is used by a service, 0 otherwise + $errstr = contains the error message + +=cut # custom query routine for Moby::Central.pm -> deregisterNamespace() sub checkNamespaceUsedByService{ die "checkNamespaceUsedByService not implemented in adaptor\n"; From mwilkinson at pub.open-bio.org Mon Jul 25 23:45:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 19:45:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252345.j6PNjTPX022383@pub.open-bio.org> mwilkinson Mon Jul 25 19:45:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv22352/MOBY Modified Files: Central.pm OntologyServer.pm authority.pm service_instance.pm Log Message: almost finished perlifying the adaptor code. moby-live/Perl/MOBY Central.pm,1.184,1.185 OntologyServer.pm,1.57,1.58 authority.pm,1.5,1.6 service_instance.pm,1.29,1.30 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.184 retrieving revision 1.185 diff -u -r1.184 -r1.185 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 22:10:25 1.184 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 23:45:29 1.185 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -use MOBY::Client::Central; +#use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -488,7 +488,7 @@ unless ($existingURI); my $dbh = MOBY::central_db_connection->new()->dbh; - my $errormsg = $adaptor->checkClassUsedByService({object_type_uri => $existingURI}); + my $errormsg = $adaptor->check_object_usage(type => $existingURI); return &_error( "Object class $class is used by a service and may not be deregistered", "" @@ -745,7 +745,7 @@ sub deregisterServiceType { $CONFIG ||= MOBY::Config->new; # exported by Config.pm - my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); + my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my ( $pkg, $payload ) = @_; my $OntologyServer = &_getOntologyServer( ontology => 'service' ); @@ -759,12 +759,12 @@ return &_error( "Service Type $term does not exist in the ontology", "" ) unless ($existingURI); - my $result = $adaptor->query_service({service_lsid => $existingURI}); + my $result = $adaptor->query_service_instance(service_type_uri => $existingURI); my $row = shift(@$result); - my $id = $row->{service_instance_id}; + my $lsid = $row->{lsid}; return &_error( "A registered service depends on this service type", "" ) - if ($id); + if ($lsid); my ( $success2, $message2, $deleteURI ) = $OntologyServer->deleteServiceType( term => $term ) ; # hopefully this situation will never happen! @@ -2475,11 +2475,11 @@ my ($pkg) = @_; my $dbh = MOBY::central_db_connection->new()->dbh; - my $result = $adaptor->getUniqueAuthorityURI(); + my $result = $adaptor->get_all_authorities(); my $providers = "\n"; foreach my $prov (@$result) { - $providers .= "\n"; + $providers .= "\n"; } $providers .= "\n"; return $providers; @@ -3282,12 +3282,9 @@ } $signatureURL ||= ""; - next unless ( $servicename && $authority_id ); + next unless ( $servicename && $authority_uri ); my $service_type = $OSserv->getServiceCommonName($service_type_uri); - #$result = $adaptor->query_authority({authority_id => $authority_id}); - #$row = shift(@$result); - #my $authURI = $row->{authority_uri}; $output .= "\t\n"; $output .= "\t$service_type\n"; $output .= "\t$authoritative\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 21:30:38 1.57 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 23:45:29 1.58 @@ -404,11 +404,13 @@ my $result; if ( $term =~ /^urn\:lsid/ ) { - $result = $adaptor->query_relationship({relationship_lsid => $term}, 'and', {ontology => $ont}); + $result = $adaptor->query_relationship( + type => $term, + ontology => $ont); } else { - $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ont}); + $result = $adaptor->query_relationship(type => $term, ontology => $ont); } my $row = shift(@$result); @@ -507,9 +509,8 @@ return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'service' ); - my $result = $adaptor->query_service({service_type => $args{subject_node}}); + my $result = $adaptor->query_service(type => $args{subject_node}); my $row = shift(@$result); - my $sbj_id = $row->{service_id}; my $sbj_lsid = $row->{service_lsid}; return ( @@ -517,9 +518,9 @@ qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ) - unless defined $sbj_id; + unless defined $sbj_lsid; - my $isa = $adaptor->query_service_term2term({service2_id => $sbj_id}); + my $isa = $adaptor->query_service_term2term(service2_id => $sbj_lsid); if ( scalar @$isa ) { return ( 0, @@ -527,28 +528,27 @@ $sbj_lsid ); } - $result = $adaptor->query_service({service_type => $args{object_node}}); + $result = $adaptor->query_service(type => $args{object_node}); $row = shift(@$result); - my $obj_id = $row->{service_id}; my $obj_lsid = $row->{service_lsid}; # get ID of the related service - defined $obj_id + defined $obj_lsid || return ( 0, qq{Service $args{object_node} does not exist in the service ontology}, '' ); my $OE = MOBY::OntologyServer->new( ontology => 'relationship' ); my ( $success, $desc, $rel_lsid ) = $OE->relationshipExists( - term => $args{relationship}, - ontology => 'service' ); + term => $args{relationship}, + ontology => 'service' ); ($success) || return ( 0, qq{Relationship $args{relationship} does not exist in the ontology}, '' ); - my $insertid = $adaptor->insert_service_term2term({relationship_type => $rel_lsid}, - {service1_id => $sbj_id}, - {service2_id => $obj_id}); + my $insertid = $adaptor->insert_service_term2term(relationship_type => $rel_lsid, + service1_type => $sbj_lsid, + service2_type => $obj_lsid); if ( $insertid ) { return ( 1, "Service relationship created successfully", '' ); } else { @@ -575,13 +575,7 @@ return ( 1, "external ontology", $term ); } my $result; - if ( $term =~ /^urn\:lsid/ ) { - $result = $adaptor->query_service({service_lsid => $term}); - - } else { - $result = $adaptor->query_service({service_type => $term}); - - } + $result = $adaptor->query_service(type => $term); my $row = shift(@$result); my $id = $row->{service_id}; my $type = $row->{service_type}; @@ -633,11 +627,11 @@ : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $insertid = $adaptor->insert_service({service_type => $args{'node'}}, - {service_lsid => $LSID}, - {description => $args{'description'}}, - {authority => $args{'authority'}}, - {contact_email => $args{'contact_email'}}); + my $insertid = $adaptor->insert_service(service_type => $args{'node'}, + service_lsid => $LSID, + description => $args{'description'}, + authority => $args{'authority'}, + contact_email => $args{'contact_email'}); unless ( $insertid ) { return ( 0, "Service creation failed for unknown reasons", '' ); @@ -668,30 +662,26 @@ $LSID = $term; } return ( - 0, -q{Service type $term cannot be resolved to an LSID in the MOBY ontologies}, - "" - ) - unless $LSID; + 0, q{Service type $term cannot be resolved to an LSID in the MOBY ontologies},"" + ) unless $LSID; - my $result = $adaptor->query_service({service_lsid => $LSID}); + my $result = $adaptor->query_service(type => $LSID); my $row = shift(@$result); - my $id = $row->{service_id}; my $lsid = $row->{service_lsid}; - if ( !defined $id ) { + if ( !defined $lsid ) { return ( 0, q{Service type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my $isa = $adaptor->query_service_term2term({service2_id => $id}); + my $isa = $adaptor->query_service_term2term(service2_id => $lsid); if ( scalar @$isa ) { return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } - my ($err, $errstr) = $adaptor->delete_service({service_id => $id}); + my ($err, $errstr) = $adaptor->delete_service(service_lsid => $lsid); if ( $err ) { return ( 0, "Delete from Service Type table failed: $errstr", @@ -729,13 +719,7 @@ return ( 1, "external ontology", $term ); } my $result; - if ( $term =~ /^urn:lsid:biomoby.org:namespacetype/ ) { - $result = $adaptor->query_namespace({namespace_lsid => $term}); - - } else { - $result = $adaptor->query_namespace({namespace_type => $term}); - - } + $result = $adaptor->query_namespace(type => $term); my $row = shift(@$result); my $id = $row->{namespace_id}; my $type = $row->{namespace_type}; @@ -787,11 +771,11 @@ : $self->setURI( $args{'node'} ); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } - my $insertid = $adaptor->insert_namespace({namespace_type => $args{'node'}}, - {namespace_lsid => $LSID}, - {description => $args{'description'}}, - {authority => $args{'authority'}}, - {contact_email => $args{'contact_email'}}); + my $insertid = $adaptor->insert_namespace(namespace_type => $args{'node'}, + namespace_lsid => $LSID, + description => $args{'description'}, + authority => $args{'authority'}, + contact_email => $args{'contact_email'}); unless ( $insertid ) { return ( 0, "Namespace creation failed for unknown reasons", '' ); @@ -820,25 +804,24 @@ return ( 0, "cannot delete a term from an external ontology", $term ); } - my $result = $adaptor->query_namespace({namespace_lsid => $LSID}); + my $result = $adaptor->query_namespace(type => $LSID); my $row = shift(@$result); - my $id = $row->{namespace_id}; my $lsid = $row->{namespace_lsid}; - unless ($id) { + unless ($lsid) { return ( 0, q{Namespace type $term does not exist in the ontology}, $lsid ); } # service1_id ISA service2_id? - my $isa = $adaptor->query_namespace_term2term({namespace2_id => $id}); + my $isa = $adaptor->query_namespace_term2term(type => $lsid); if ( scalar @$isa ) { return ( 0, qq{Namespace type $term has dependencies in the ontology}, $lsid ); } - my ($err, $errstr) = $adaptor->delete_namespace({namespace_id => $id}); + my ($err, $errstr) = $adaptor->delete_namespace(namespace_lsid => $lsid); if ( $err ) { return ( 0, "Delete from namespace table failed: $errstr", @@ -935,7 +918,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobynamespace' ); return undef unless $URI =~ /urn\:lsid/; - my $result = $adaptor->query_namespace({namespace_lsid => $URI}); + my $result = $adaptor->query_namespace(type => $URI); my $row = shift(@$result); my $name = $row->{namespace_type}; @@ -951,7 +934,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return undef unless $URI =~ /urn\:lsid/; - my $result = $adaptor->query_service({service_lsid => $URI}); + my $result = $adaptor->query_service(type => $URI); my $row = shift(@$result); my $name = $row->{service_type}; @@ -968,7 +951,7 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyservice' ); return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_service({service_type => $term}); + my $result = $adaptor->query_service(type => $term); my $row = shift(@$result); my $id = $row->{service_lsid}; @@ -1003,7 +986,7 @@ return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_namespace({namespace_type => $term}); + my $result = $adaptor->query_namespace(type => $term); my $row = shift(@$result); my $id = $row->{namespace_lsid}; @@ -1021,7 +1004,7 @@ return $term if $term =~ /urn\:lsid/; - my $result = $adaptor->query_relationship({relationship_type => $term}, 'and', {ontology => $ontology}); + my $result = $adaptor->query_relationship(type => $term, ontology => $ontology); my $row = shift(@$result); my $id = $row->{relationship_lsid}; @@ -1040,7 +1023,7 @@ my $ontology = $args{'ontology'}; my $OS = MOBY::OntologyServer->new( ontology => "relationship" ); - my $defs = $adaptor->query_relationship({ontology => $ontology}); + my $defs = $adaptor->query_relationship(ontology => $ontology); my %result; foreach ( @$defs ) { =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/20 17:25:54 1.5 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/25 23:45:29 1.6 @@ -43,7 +43,6 @@ #ATTRIBUTES my %_attr_data = # DEFAULT ACCESSIBILITY ( - authority_id => [ undef, 'read/write' ], authority_common_name => [ undef, 'read/write' ], authority_uri => [ undef, 'read/write' ], contact_email => [ undef, 'read/write' ], @@ -68,6 +67,9 @@ sub _standard_keys { keys %_attr_data; } + sub authority_id { + die "AUTHORITY_ID is deprecated. fix your code!\n"; + } } sub new { @@ -93,12 +95,14 @@ my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); my $row = shift(@$result); unless ($row) { - my $insertid = $adaptor->insert_authority({authority_common_name => $self->authority_common_name}, - {authority_uri => $self->authority_uri}, - {contact_email => $self->contact_email}); - $self->authority_id( $insertid ); + my $insertid = $adaptor->insert_authority( + authority_common_name => $self->authority_common_name, + authority_uri => $self->authority_uri, + contact_email => $self->contact_email); } else { - $self->authority_id($row->{authority_id}); + $self->authority_common_name($row->{authority_common_name}); + $self->authority_uri($row->{authority_uri}); + $self->contact_email($row->{contact_email}); } return $self; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 22:10:26 1.29 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 23:45:29 1.30 @@ -238,7 +238,7 @@ category => $self->category, servicename => $self->servicename, service_type_uri => $self->service_type_uri, - authority_id => $self->authority_id, + authority_uri => $self->authority_uri, url => $self->url, contact_email => $self->contact_email, authoritative => $self->authoritative, @@ -246,6 +246,7 @@ signatureURL => $self->signatureURL, lsid => $service_lsid ); + return undef unless $id; $self->service_instance_id($id); $self->{__exists__} = 1; # this service now exists } else { # if it doesn't exist, and you havne't given me anyting I need to create it, then bail out @@ -315,17 +316,17 @@ $CONFIG ||= MOBY::Config->new; my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); my $result = $adaptor->query_authority(authority_uri => $self->authority_uri); - +#*********FIX we should nver need to know the authority ID in this level of code! if ( @$result[0]) { my $row = shift(@$result); - my $id = $row->{authority_id}; + #my $id = $row->{authority_id}; my $name = $row->{authority_common_name}; my $uri = $row->{authority_uri}; my $email = $row->{contact_email}; $authority = MOBY::authority->new( dbh => $self->dbh, - authority_id => $id, +# authority_id => $id, authority_uri => $uri, contact_email => $email, ); From mwilkinson at pub.open-bio.org Mon Jul 25 23:45:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 19:45:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252345.j6PNjTOc022402@pub.open-bio.org> mwilkinson Mon Jul 25 19:45:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv22352/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: almost finished perlifying the adaptor code. moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:43:43 1.12 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:45:29 1.13 @@ -467,8 +467,8 @@ die "query_authority not implemented in adaptor\n"; } -sub getUniqueAuthorityURI{ - die "getUniqueAuthorityURI not implemented in adaptor\n"; +sub get_all_authorities{ + die "get_all_authorities not implemented in adaptor\n"; } sub insert_authority{ @@ -555,8 +555,8 @@ } # custom query subroutine for Moby::Central.pm->deregisterObjectClass() -sub checkClassUsedByService{ - die "checkClassUsedByService not implemented in adaptor\n"; +sub check_object_usage{ + die "check_object_usage not implemented in adaptor\n"; } =head2 checkNamespaceUsedByService From mwilkinson at pub.open-bio.org Mon Jul 25 23:45:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Mon, 25 Jul 2005 19:45:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507252345.j6PNjT9B022423@pub.open-bio.org> mwilkinson Mon Jul 25 19:45:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv22352/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: almost finished perlifying the adaptor code. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.37,1.38 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 22:10:26 1.37 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 23:45:29 1.38 @@ -1,1331 +1,1382 @@ -package MOBY::Adaptor::moby::queryapi::mysql; - -use strict; -use vars qw($AUTOLOAD @ISA); -use Carp; -use MOBY::Adaptor::moby::queryapi; -use DBI; -use DBD::mysql; - - at ISA = qw{MOBY::Adaptor::moby::queryapi}; # implements the interface - -{ - #Encapsulated class data - - #___________________________________________________________ - #ATTRIBUTES - my %_attr_data = # DEFAULT ACCESSIBILITY - ( - driver => ["DBI:mysql", 'read/write'], - dbh => [undef, 'read/write'], - - ); - - #_____________________________________________________________ - - # METHODS, to operate on encapsulated class data - - # Is a specified object attribute accessible in a given mode - sub _accessible { - my ($self, $attr, $mode) = @_; - $_attr_data{$attr}[1] =~ /$mode/ - } - - # Classwide default value for a specified object attribute - sub _default_for { - my ($self, $attr) = @_; - $_attr_data{$attr}[0]; - } - - # List of names of all specified object attributes - sub _standard_keys { - keys %_attr_data; - } - - sub driver { - my ($self, $arg) = @_; - $self->{driver} = $arg if defined $arg; - return $self->{driver}; - } - sub dbh { - my ($self, $arg) = @_; - $self->{dbh} = $arg if defined $arg; - return $self->{dbh}; - } - -} - -sub new { - my ($caller, %args) = @_; - my $self = $caller->SUPER::new(%args); - - my $caller_is_obj = ref($caller); - my $class = $caller_is_obj || $caller; - - foreach my $attrname ( $self->_standard_keys ) { - if (exists $args{$attrname} && defined $args{$attrname}) { - $self->{$attrname} = $args{$attrname} } - elsif ($caller_is_obj) { - $self->{$attrname} = $caller->{$attrname} } - else { - $self->{$attrname} = $self->_default_for($attrname) } - } - - return unless $self->driver; - my $driver = $self->driver; # inherited from the adaptorI (queryapi) - my $username = $self->username; - my $password = $self->password; - my $port = $self->port; - my $url = $self->url; - my $dbname = $self->dbname; - - my ($dsn) = "$driver:$dbname:$url:$port"; - my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; - - - ############################################################## - unless ($dbh) { - print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; - return undef; - } - - $self->dbh($dbh); - ############################################################# - - return undef unless $self->dbh; - return $self; - -} - -sub _add_condition{ - my ($statement, @params) = @_; - my @bindvalues = (); - my $condition = "where "; - - foreach my $param (@params ) - { - if (($param eq 'and') || ($param eq 'or')) - { - $condition .= $param . " "; - } - else - { - my %pair = %$param; - - for my $key (keys %pair) - { - if (defined $pair{$key}) - { - $condition .= $key . " = ? "; - push(@bindvalues, $pair{$key}); - } - else - { - $condition .= $key . " IS NULL " - } - } - } - } - $statement .= $condition; - return ($statement, @bindvalues); - } - -# preforms query but returns a reference to an array containing hash references -sub do_query{ - my ($dbh, $statement, @bindvalues) = @_; - my $sth = $dbh -> prepare($statement); - if (@bindvalues < 1) - { - $sth->execute; - } - else - { - $sth->execute(@bindvalues); - } - # returns an array of hash references - my $arrayHashRef = $sth->fetchall_arrayref({}); - return $arrayHashRef; -} - -sub get_value{ - my ($key, @params) = @_; - - foreach my $param (@params ) - { - my %pair = %$param; - for my $tmp (keys %pair) - { - if ($tmp eq $key){ - return $pair{$key}; - } - } - } -} - -sub _getSIIDFromLSID { - my ($self, $lsid) = @_; - my $dbh = $self->dbh; - my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); - $sth->execute($lsid); - my ($siid) = $sth->fetchrow_array(); - return $siid; -} - -# this should NOT retun a collection ID... needs more work... -# args passed in: service_lsid -sub query_collection_input{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $serv_lsid = $args{'service_lsid'}; - - my $statement = "select - collection_input_id, - article_name - from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; - my $result = do_query($dbh, $statement, [$serv_lsid]); - return $result; -} - -# args passed in: service_instance_lsid, article_name -sub insert_collection_input { - my ($self, %args) = @_; - my $article = $args{article_name}; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - - $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", - undef, $siid, $article); - my $id=$self->dbh->{mysql_insertid}; - return $id; -} - -# pass in service_instance_lsid -sub delete_collection_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - - my $statement = "delete from collection_input where service_instance_id = ?"; - $self->dbh->do( $statement, undef, $siid); - - if ($self->dbh->err){ - return (1, $self->dbh->errstr); - } - else{ - return 0; - } -} - -# pass service_instance_lsid -sub query_collection_output{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - my $statement = "select - collection_output_id, - article_name, - service_instance_id - from collection_output where service_instance_id = ? "; - my $result = do_query($dbh, $statement, [$siid]); - return $result; -} - -# pass service_instance_lsid, article_name -sub insert_collection_output { - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", - undef, $siid,$args{'article_name'}); - my $id=$self->dbh->{mysql_insertid}; - return $id; -} - -# pass argument service_instance_lsid -sub delete_collection_output{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - my $statement = "delete from collection_output where service_instance_id = ?"; - my @bindvalues = (); - $dbh->do( $statement, undef, ($siid)); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass service_instance_lsid -sub query_simple_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - my $statement = "select - simple_input_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id - from simple_input where service_instance_id = ? and collection_input_id IS NULL"; - my $result = do_query($dbh, $statement, ($siid)); - return $result; -} - -# pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id -sub insert_simple_input { - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - $dbh->do("insert into simple_input - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_input_id) - values (?,?,?,?,?)", - undef, - $args{'object_type_uri'}, - $args{'namespace_type_uris'}, - $args{'article_name'}, - $siid, - $args{'collection_input_id'}); - my $id=$dbh->{mysql_insertid}; - return $id; -} - -# pass service_instance_lsid -sub delete_simple_input{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my ($collid) = $args{collection_input_id}; - my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); - $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); - - $siid && ($dbh->do( $statement1, undef,($siid))); - $collid && ($dbh->do($statement2, undef,($collid))); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub delete_inputs { # this should replace all other delete_*_input - my ($self, %args) = @_; - my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); - - my $statement = "delete from simple_input where service_instance_lsid = ?"; - - $dbh->do( $statement, undef,($siid)); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } - -} - -sub delete_output { # this should replace all other delete_*_output - -} - -# UGH this has to know too much bout the underlying database structure e.g. that one is null and other is full -# this problem is in MOBY::Central line 3321 3346 and 3374 -#****** FIX -# send service_instance_lsid, collection_input_id -sub query_simple_output{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $collid = $args{collection_input_id}; - my $dbh = $self->dbh; - - my $statement = "select - simple_output_id, - object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id - from simple_output where service_instance_id = ? and collection_input_id= ?"; - my $result = do_query($dbh, $statement, ($siid, $collid)); - return $result; -} - -# pass args service_instance_id and collection_output_id -sub insert_simple_output { - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - $dbh->do("insert into simple_output - (object_type_uri, - namespace_type_uris, - article_name, - service_instance_id, - collection_output_id) - values (?,?,?,?,?)", - undef,( - $args{'object_type_uri'}, - $args{'namespace_type_uris'}, - $args{'article_name'}, - $siid, - $args{'collection_output_id'})); - my $id=$dbh->{mysql_insertid}; - return $id; - -} - -# pass service_instance_id or collection_output_id -sub delete_simple_output{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my ($collid) = $args{collection_output_id}; - my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); - $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); - - $siid && ($dbh->do( $statement1, undef,($siid))); - $collid && ($dbh->do($statement2, undef,($collid))); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass service_instance_lsid -sub query_secondary_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - - my $statement = "select - secondary_input_id, - default_value, - maximum_value, - minimum_value, - enum_value, - datatype, - article_name, - service_instance_id - from secondary_input where service_instance_id = ?"; - my $result = do_query($dbh, $statement, ($siid)); - return $result; -} - -# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid -sub insert_secondary_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, - undef, - ( - $args{'default_value'}, $args{'maximum_value'}, - $args{'minimum_value'}, $args{'enum_value'}, - $args{'datatype'}, $args{'article_name'},$siid) - ); - return $dbh->{mysql_insertid}; -} - -# pass service_instance_lsid -sub delete_secondary_input{ - my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); - my $dbh = $self->dbh; - my $statement = "delete from secondary_input where service_instance_lsid=?"; - - $dbh->do( $statement, undef, ($siid)); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - - -# receives argument "type", that may be either an LSID or a type term -sub query_object { - my ($self, %args) = @_; - my $type = $args{type}; - my $condition; - if ($type =~ /^urn\:lsid/){ - $condition = "where object_lsid = ?"; - } else { - $condition = "where object_type = ?"; - } - my $statement = "select - object_id, - object_lsid, - object_type, - description, - authority, - contact_email - from object $condition"; - - my $dbh = $self->dbh; - my $result = do_query($dbh, $statement, ($type)); - return $result; -} - -# inserts a new tuple into object table -# pass object_type object_lsid description authority contact_email -sub insert_object{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - $dbh->do("insert into object - (object_type, - object_lsid, - description, - authority, - contact_email) - values (?,?,?,?,?)", - undef, - $args{'object_type'}, - $args{'object_lsid'}, - $args{'description'}, - $args{'authority'}, - $args{'contact_email'}); - my $id=$dbh->{mysql_insertid}; - return $id; -} - -# pass 'type' which is either an LSID or a term -sub delete_object{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $term = $args{type}; - return 0 unless $term; - my $statement = "delete from object where "; - my $condition; - if ($term =~ /^urn\:lsid/){ - $condition = " object_lsid = ?"; - } else { - $condition = " object_type = ?"; - } - $statement = $statement.$condition; - $dbh->do( $statement,undef, ($term) ); - - $self->_delete_object_term2term(type => $term); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass "type" here, should be an LSID, preferably... -sub query_object_term2term{ - my ($self, %args) = @_; - my $type = $args{type}; - my $result = $self->query_object(type => $type); - my $row = shift(@$result); - my $id = $row->{object_id}; - return [{}] unless $id; - my $dbh = $self->dbh; - - my $statement = "select - assertion_id, - relationship_type, - object1_id, - object2_id, - object2_articlename - from object_term2term where object2_id = ?"; - my $result2 = do_query($dbh, $statement, ($id)); - return $result2; -} - -# pass object1_type, object2_type, object2_articlename, relationship_type -sub insert_object_term2term{ - my ($self, %args) = @_; - my $type1 = $args{object1_type}; - my $result = $self->query_object(type => $type1); - my $row = shift(@$result); - my $id1 = $row->{object_id}; - my $type2 = $args{object2_type}; - $result = $self->query_object(type => $type2); - $row = shift(@$result); - my $id2 = $row->{object_id}; - my $relationship_type = $args{relationship_type}; - my $object2_articlename = $args{object2_articlename}; - - my $dbh = $self->dbh; - $dbh->do( - q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, - undef, - $relationship_type, - $id1, - $id2, - $object2_articlename - ); - - return $dbh->{mysql_insertid}; -} - -# pass object 'type' as term or lsid -# this should be a private routine, not a public one. -# SHOULD NOT BE DOCUMENTED IN THE API -sub _delete_object_term2term{ - my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_object(type => $type); - my $row = shift @$result; - my $id = $row->object_id; - - my $dbh = $self->dbh; - my $statement = "delete from object_term2term where object1_id=?"; - $dbh->do( $statement,undef, ($id)); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# pass servicename and authority_uri -sub query_service_existence { - my ($self, %args) = @_; - my $dbh = $self->dbh; - - my $servicename = $args{'servicename'}; - my $authURI = $args{'authority_uri'}; -# my $id = $args{'authority_id'}; # is it safe to remove this? better be! -# unless ($id){ - my $result = $self->query_authority(authority_uri => $authURI); - return 0 unless @$result[0]; - my $id = @$result[0]->{authority_id}; - return 0 unless $id; -# } - my $statement = "select - service_instance_id, - category, - servicename, - service_type_uri, - authority_id, - url, - contact_email, - authoritative, - description, - signatureURL, - lsid - from service_instance where servicename = ? and authority_id = ?"; - my $final = do_query($dbh, $statement, ($servicename, $id)); - if (@$final[0]){return 1} else {return 0} - -} -# selects all the columns from service_instance table -# where is lsid? - -sub query_service_instance { - my ($self, %args) = @_; - my $dbh = $self->dbh; - - my $authority_id; - #if ($args{'authority_uri'}){ # need to transform URI to a row ID - # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); - # return 0 unless @$result[0]; - # $authority_id = @$result[0]->{authority_id}; - # return 0 unless $authority_id; - #} - #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table - my @args; - while (my ($k, $v) = each %args){ - push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine - } -# if ($authority_id){ -# push @args, ({authority_id => $authority_id}) ; -# } else { -# pop @args; # remove final "and" -# } - - my $statement = "select - service_instance_id, - category, - servicename, - service_type_uri, - authority.authority_uri, - url, - contact_email, - authoritative, - description, - signatureURL, - lsid - from service_instance left join authority on authority.authority_id "; - my @bindvalues; - ($statement, @bindvalues) =_add_condition($statement, @args); - my $final = do_query($dbh, $statement, @bindvalues); - return $final; -} - -# custom query for Moby::Central.pm->findService() -# hmmmmmmm.... I'm not sure that this routine should exist... -# it is redundant to the routine above, if the routine above were executed -# multiple times. I think that is the more correct (though less efficient) -# way to go, since it is "scalable" to every possible underlying data source -# ********FIX change this later... -sub match_service_type_uri{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $uri_list = $args{'service_type_uri'}; - my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; - my @bindvalues = (); - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# passs........ blah blah..... -sub insert_service_instance { - my ($self, %args) = @_; - my $dbh = $self->dbh; - - $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, - undef,( - $args{'category'}, - $args{'servicename'}, - $args{'service_type_uri'}, - $args{'authority_id'}, - $args{'url'}, - $args{'contact_email'}, - $args{'authoritative'}, - $args{'description'}, - $args{'signatureURL'}, - $args{'lsid'})); - - my $id = $dbh->{mysql_insertid}; - return $id; -} - -# pass service_instance_lsid -sub delete_service_instance{ - my ($self, %args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from service_instance where lsid = ?"; - $dbh->do( $statement,undef, ($args{service_instance_lsid}) ); - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# Selects all columns -# pass authority_uri -sub query_authority { - my ($self, %args) = @_; - my $authURI = $args{authority_uri}; - my $dbh = $self->dbh; - - my $statement = "select - authority_id, - authority_common_name, - authority_uri, - contact_email - from authority where authority_uri = ?"; - my $result = do_query($dbh, $statement, ($authURI)); - return $result; -} - -# custom query routine used in Moby::Central.pm -> retrieveServiceProviders() -sub getUniqueAuthorityURI{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select distinct authority_uri from authority"; - my @bindvalues = (); - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_authority{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do("insert into authority - (authority_common_name, - authority_uri, - contact_email) - values (?,?,?)", - undef, - (get_value('authority_common_name', @args), - get_value('authority_uri', @args), - get_value('contact_email', @args))); - my $id = $dbh->{mysql_insertid}; - return $id; -} - -sub query_service{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select - service_id, - service_lsid, - service_type, - description, - authority, - contact_email - from service "; - my @bindvalues = (); - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_service{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, - undef, - ( - get_value('service_type', @args), get_value('service_lsid', @args), get_value('description', @args), - get_value('authority', @args), get_value('contact_email', @args) - ) - ); - return $dbh->{mysql_insertid}; -} - -sub delete_service{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from service "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub query_service_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select - assertion_id, - relationship_type, - service1_id, - service2_id - from service_term2term "; - my @bindvalues = (); - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_service_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, - undef, - ( get_value('relationship_type', @args), get_value('service1_id', @args), get_value('service2_id', @args)) - ); - return $dbh->{mysql_insertid}; -} - -sub delete_service_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from service_term2term "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub query_relationship{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - relationship_id, - relationship_lsid, - relationship_type, - container, - description, - authority, - contact_email, - ontology - from relationship "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub query_namespace{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - namespace_id, - namespace_lsid, - namespace_type, - description, - authority, - contact_email - from namespace "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub insert_namespace{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - $dbh->do( -q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, - undef, - ( - get_value('namespace_type', @args), get_value('namespace_lsid', @args), get_value('description', @args), - get_value('authority', @args), get_value('contact_email', @args) - ) - ); - return $dbh->{mysql_insertid}; -} - -sub delete_namespace{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from namespace "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -sub query_namespace_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - assertion_id, - relationship_type, - namespace1_id, - namespace2_id - from namespace_term2term "; - my @bindvalues = (); - - if (@args > 0) - { - ($statement, @bindvalues) =_add_condition($statement, @args); - } - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -sub delete_namespace_term2term{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "delete from namespace_term2term "; - my @bindvalues = (); - ($statement, @bindvalues) =_add_condition($statement, @args); - $dbh->do( $statement, - undef, @bindvalues ); - - if ($dbh->err){ - return (1, $dbh->errstr); - } - else{ - return 0; - } -} - -# custom query subroutine for Moby::Central.pm->deregisterObjectClass() -sub checkClassUsedByService -{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $errorMsg = 1; - my $existingURI = get_value('object_type_uri', @args); - - my ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - ($id) = $dbh->selectrow_array( -q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, - undef, $existingURI - ); - return $errorMsg - if ($id); - - return 0; -} - -# custom query routine for Moby::Central.pm -> deregisterNamespace() -sub checkNamespaceUsedByService{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $existingURI = get_value('namespace_type_uris', @args); - my $term = get_value('term', @args); - my $errstr; - - my $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" - ); - $sth->execute; - while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { - my @nss = split ",", $ns; - foreach (@nss) { - $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; - return (1, $errstr) - if ( $_ eq $existingURI ); - } - } - return (0, ""); -} - -# custom query routine for Moby::Central.pm -> findService() -sub checkKeywords{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $param = get_value('findme', @args); - my %findme = %$param; - my $searchstring; - - foreach my $kw ( @{ $findme{keywords} } ) { -# $debug && &_LOG("KEYWORD $kw\n"); - $kw =~ s/\*//g; - $kw = $dbh->quote("%$kw%"); - $searchstring .= " OR description like $kw "; - } - $searchstring =~ s/OR//; # remove just the first OR in the longer statement -# $debug && &_LOG("search $searchstring\n"); - - my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; - my @bindvalues = (); - - my $ids = do_query($dbh, $statement, @bindvalues); - return ($ids, $searchstring); -} - -# custom query subroutine for Moby::Central.pm->_searchForSimple() -sub getFromSimple{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $ancestor_string = get_value('ancestor_string', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); - - my $query = -"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " - ; # if service_instance_id is null then it must be a collection input. - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/OR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; - } - - my $result = do_query($dbh, $query, ()); - return $result; -} - -# custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $objectURI = get_value('objectURI', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); - - my $query = "select - c.service_instance_id, - s.namespace_type_uris - from - simple_$inout as s, - collection_$inout as c - where - s.collection_${inout}_id IS NOT NULL - AND s.collection_${inout}_id = c.collection_${inout}_id - AND object_type_uri = '$objectURI' "; - my $nsquery; - foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's - $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; - } - if ($nsquery) { - $nsquery =~ s/^\sOR//; # just the first - $nsquery .= " OR namespace_type_uris IS NULL"; - $query .= " AND ($nsquery) "; # add the AND clause - } - - my $result = do_query($dbh, $query, ()); - return $result; -} - -# custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; - my @bindvalues = (); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# custom query for Moby::Central.pm->_flatten -sub getParentTerms{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $type_id = get_value('relationship_type_id', @args); - my $statement = " - select - OE1.term - from - OntologyEntry as OE1, - OntologyEntry as OE2, - Term2Term as TT - where - ontologyentry2_id = OE2.id - and ontologyentry1_id = OE1.id - and relationship_type_id = $type_id - and OE2.term = ?"; - - my @bindvalues = (); - push(@bindvalues, get_value('term', @args)); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# custom query subroutine for selecting from object_term2term and object tables -# used in Moby::OntologyServer.pm->retrieveObject() -sub getObjectRelationships{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - - my $statement = "select - relationship_type, - object_lsid, - object2_articlename - from object_term2term, object - where object1_id = ? and object2_id = object_id"; - - my @bindvalues = (); - push(@bindvalues, get_value('object1_id', @args)); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; -} - -# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() -# note: returns a reference to an array containing ARRAY references -sub getRelationship{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $direction = get_value('direction', @args); - my $ontology = get_value('ontology', @args); - my $term = get_value('term', @args); - my $relationship = get_value('relationship', @args); - my $defs; - - if ( $direction eq 'root' ) { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } else { - unless ( defined $relationship ) { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $term ); # ") - } else { - $defs = $self->dbh->selectall_arrayref( " - select distinct s2.${ontology}_lsid, relationship_type from - ${ontology}_term2term as t2t, - $ontology as s1, - $ontology as s2 - where - relationship_type = ? and - s1.${ontology}_id = t2t.${ontology}1_id and - s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") - } - } - return $defs; -} - -sub _checkURI { - -# my $uri = "http://www.ics.uci.edu/pub/ietf/uri/#Related"; -#print "$1, $2, $3, $4, $5, $6, $7, $8, $9" if -# $uri =~ m{^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?}; -# -#The license for this recipe is available here. -# -#Discussion: -# -#If the match is successful, a URL such as -# -#http://www.ics.uci.edu/pub/ietf/uri/#Related -# -#will be broken down into the following group match variables: -# -#$1 = http: -#$2 = http -#$3 = //www.ics.uci.edu -#$4 = www.ics.uci.edu -#$5 = /pub/ietf/uri/ -#$6 = -#$7 = -#$8 = #Related -#$9 = Related -# -#In general, this regular expression breaks a URI down into the following parts, -#as defined in the RFC: -# -#scheme = $2 -#authority = $4 -#path = $5 -#query = $7 -#fragment = $9 - -} - -sub DESTROY {} - -1; +package MOBY::Adaptor::moby::queryapi::mysql; + +use strict; +use vars qw($AUTOLOAD @ISA); +use Carp; +use MOBY::Adaptor::moby::queryapi; +use DBI; +use DBD::mysql; + + at ISA = qw{MOBY::Adaptor::moby::queryapi}; # implements the interface + +{ + #Encapsulated class data + + #___________________________________________________________ + #ATTRIBUTES + my %_attr_data = # DEFAULT ACCESSIBILITY + ( + driver => ["DBI:mysql", 'read/write'], + dbh => [undef, 'read/write'], + + ); + + #_____________________________________________________________ + + # METHODS, to operate on encapsulated class data + + # Is a specified object attribute accessible in a given mode + sub _accessible { + my ($self, $attr, $mode) = @_; + $_attr_data{$attr}[1] =~ /$mode/ + } + + # Classwide default value for a specified object attribute + sub _default_for { + my ($self, $attr) = @_; + $_attr_data{$attr}[0]; + } + + # List of names of all specified object attributes + sub _standard_keys { + keys %_attr_data; + } + + sub driver { + my ($self, $arg) = @_; + $self->{driver} = $arg if defined $arg; + return $self->{driver}; + } + sub dbh { + my ($self, $arg) = @_; + $self->{dbh} = $arg if defined $arg; + return $self->{dbh}; + } + +} + +sub new { + my ($caller, %args) = @_; + my $self = $caller->SUPER::new(%args); + + my $caller_is_obj = ref($caller); + my $class = $caller_is_obj || $caller; + + foreach my $attrname ( $self->_standard_keys ) { + if (exists $args{$attrname} && defined $args{$attrname}) { + $self->{$attrname} = $args{$attrname} } + elsif ($caller_is_obj) { + $self->{$attrname} = $caller->{$attrname} } + else { + $self->{$attrname} = $self->_default_for($attrname) } + } + + return unless $self->driver; + my $driver = $self->driver; # inherited from the adaptorI (queryapi) + my $username = $self->username; + my $password = $self->password; + my $port = $self->port; + my $url = $self->url; + my $dbname = $self->dbname; + + my ($dsn) = "$driver:$dbname:$url:$port"; + my $dbh = DBI->connect($dsn, $username, $password, {RaiseError => 1}) or die "can't connect to database"; + + + ############################################################## + unless ($dbh) { + print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n"; + return undef; + } + + $self->dbh($dbh); + ############################################################# + + return undef unless $self->dbh; + return $self; + +} + +sub _add_condition{ + my ($statement, @params) = @_; + my @bindvalues = (); + my $condition = "where "; + + foreach my $param (@params ) + { + if (($param eq 'and') || ($param eq 'or')) + { + $condition .= $param . " "; + } + else + { + my %pair = %$param; + + for my $key (keys %pair) + { + if (defined $pair{$key}) + { + $condition .= $key . " = ? "; + push(@bindvalues, $pair{$key}); + } + else + { + $condition .= $key . " IS NULL " + } + } + } + } + $statement .= $condition; + return ($statement, @bindvalues); + } + +# preforms query but returns a reference to an array containing hash references +sub do_query{ + my ($dbh, $statement, @bindvalues) = @_; + my $sth = $dbh -> prepare($statement); + if (@bindvalues < 1) + { + $sth->execute; + } + else + { + $sth->execute(@bindvalues); + } + # returns an array of hash references + my $arrayHashRef = $sth->fetchall_arrayref({}); + return $arrayHashRef; +} + +sub get_value{ + my ($key, @params) = @_; + + foreach my $param (@params ) + { + my %pair = %$param; + for my $tmp (keys %pair) + { + if ($tmp eq $key){ + return $pair{$key}; + } + } + } +} + +sub _getSIIDFromLSID { + my ($self, $lsid) = @_; + my $dbh = $self->dbh; + my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); + $sth->execute($lsid); + my ($siid) = $sth->fetchrow_array(); + return $siid; +} + +# this should NOT retun a collection ID... needs more work... +# args passed in: service_lsid +sub query_collection_input{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $serv_lsid = $args{'service_lsid'}; + + my $statement = "select + collection_input_id, + article_name + from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; + my $result = do_query($dbh, $statement, [$serv_lsid]); + return $result; +} + +# args passed in: service_instance_lsid, article_name +sub insert_collection_input { + my ($self, %args) = @_; + my $article = $args{article_name}; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", + undef, $siid, $article); + my $id=$self->dbh->{mysql_insertid}; + return $id; +} + +# pass in service_instance_lsid +sub delete_collection_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + + my $statement = "delete from collection_input where service_instance_id = ?"; + $self->dbh->do( $statement, undef, $siid); + + if ($self->dbh->err){ + return (1, $self->dbh->errstr); + } + else{ + return 0; + } +} + +# pass service_instance_lsid +sub query_collection_output{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + collection_output_id, + article_name, + service_instance_id + from collection_output where service_instance_id = ? "; + my $result = do_query($dbh, $statement, [$siid]); + return $result; +} + +# pass service_instance_lsid, article_name +sub insert_collection_output { + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", + undef, $siid,$args{'article_name'}); + my $id=$self->dbh->{mysql_insertid}; + return $id; +} + +# pass argument service_instance_lsid +sub delete_collection_output{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from collection_output where service_instance_id = ?"; + my @bindvalues = (); + $dbh->do( $statement, undef, ($siid)); + + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass service_instance_lsid +sub query_simple_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + simple_input_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id + from simple_input where service_instance_id = ? and collection_input_id IS NULL"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; +} + +# pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id +sub insert_simple_input { + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do("insert into simple_input + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_input_id) + values (?,?,?,?,?)", + undef, + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_input_id'}); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +# pass service_instance_lsid +sub delete_simple_input{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($collid) = $args{collection_input_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +sub delete_inputs { # this should replace all other delete_*_input + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); + + my $statement = "delete from simple_input where service_instance_lsid = ?"; + + $dbh->do( $statement, undef,($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } + +} + +sub delete_output { # this should replace all other delete_*_output + +} + +# UGH this has to know too much bout the underlying database structure e.g. that one is null and other is full +# this problem is in MOBY::Central line 3321 3346 and 3374 +#****** FIX +# send service_instance_lsid, collection_input_id +sub query_simple_output{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $collid = $args{collection_input_id}; + my $dbh = $self->dbh; + + my $statement = "select + simple_output_id, + object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id + from simple_output where service_instance_id = ? and collection_input_id= ?"; + my $result = do_query($dbh, $statement, ($siid, $collid)); + return $result; +} + +# pass args service_instance_id and collection_output_id +sub insert_simple_output { + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + $dbh->do("insert into simple_output + (object_type_uri, + namespace_type_uris, + article_name, + service_instance_id, + collection_output_id) + values (?,?,?,?,?)", + undef,( + $args{'object_type_uri'}, + $args{'namespace_type_uris'}, + $args{'article_name'}, + $siid, + $args{'collection_output_id'})); + my $id=$dbh->{mysql_insertid}; + return $id; + +} + +# pass service_instance_id or collection_output_id +sub delete_simple_output{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($collid) = $args{collection_output_id}; + my $statement1; my $statement2; + $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); + $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); + + $siid && ($dbh->do( $statement1, undef,($siid))); + $collid && ($dbh->do($statement2, undef,($collid))); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass service_instance_lsid +sub query_secondary_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + + my $statement = "select + secondary_input_id, + default_value, + maximum_value, + minimum_value, + enum_value, + datatype, + article_name, + service_instance_id + from secondary_input where service_instance_id = ?"; + my $result = do_query($dbh, $statement, ($siid)); + return $result; +} + +# pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid +sub insert_secondary_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, + undef, + ( + $args{'default_value'}, $args{'maximum_value'}, + $args{'minimum_value'}, $args{'enum_value'}, + $args{'datatype'}, $args{'article_name'},$siid) + ); + return $dbh->{mysql_insertid}; +} + +# pass service_instance_lsid +sub delete_secondary_input{ + my ($self, %args) = @_; + my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my $dbh = $self->dbh; + my $statement = "delete from secondary_input where service_instance_lsid=?"; + + $dbh->do( $statement, undef, ($siid)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + + +# receives argument "type", that may be either an LSID or a type term +sub query_object { + my ($self, %args) = @_; + my $type = $args{type}; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where object_lsid = ?"; + } elsif ($type) { + $condition = "where object_type = ?"; + } + my $statement = "select + object_id, + object_lsid, + object_type, + description, + authority, + contact_email + from object $condition"; + + my $dbh = $self->dbh; + my $result = do_query($dbh, $statement, ($type)); + return $result; +} + +# inserts a new tuple into object table +# pass object_type object_lsid description authority contact_email +sub insert_object{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into object + (object_type, + object_lsid, + description, + authority, + contact_email) + values (?,?,?,?,?)", + undef, + $args{'object_type'}, + $args{'object_lsid'}, + $args{'description'}, + $args{'authority'}, + $args{'contact_email'}); + my $id=$dbh->{mysql_insertid}; + return $id; +} + +# pass 'type' which is either an LSID or a term +sub delete_object{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $term = $args{type}; + return 0 unless $term; + my $statement = "delete from object where "; + my $condition; + if ($term =~ /^urn\:lsid/){ + $condition = " object_lsid = ?"; + } else { + $condition = " object_type = ?"; + } + $statement = $statement.$condition; + $dbh->do( $statement,undef, ($term) ); + + $self->_delete_object_term2term(type => $term); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass "type" here, should be an LSID, preferably... +sub query_object_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_object(type => $type); + my $row = shift(@$result); + my $id = $row->{object_id}; + return [{}] unless $id; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + object1_id, + object2_id, + object2_articlename + from object_term2term where object2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; +} + +# pass object1_type, object2_type, object2_articlename, relationship_type +sub insert_object_term2term{ + my ($self, %args) = @_; + my $type1 = $args{object1_type}; + my $result = $self->query_object(type => $type1); + my $row = shift(@$result); + my $id1 = $row->{object_id}; + my $type2 = $args{object2_type}; + $result = $self->query_object(type => $type2); + $row = shift(@$result); + my $id2 = $row->{object_id}; + my $relationship_type = $args{relationship_type}; + my $object2_articlename = $args{object2_articlename}; + + my $dbh = $self->dbh; + $dbh->do( + q{insert into object_term2term (relationship_type, object1_id, object2_id, object2_articlename) values (?,?,?,?)}, + undef, + $relationship_type, + $id1, + $id2, + $object2_articlename + ); + + return $dbh->{mysql_insertid}; +} + +# pass object 'type' as term or lsid +# this should be a private routine, not a public one. +# SHOULD NOT BE DOCUMENTED IN THE API +sub _delete_object_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $id = $row->object_id; + + my $dbh = $self->dbh; + my $statement = "delete from object_term2term where object1_id=?"; + $dbh->do( $statement,undef, ($id)); + + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# pass servicename and authority_uri +sub query_service_existence { + my ($self, %args) = @_; + my $dbh = $self->dbh; + + my $servicename = $args{'servicename'}; + my $authURI = $args{'authority_uri'}; + my $result = $self->_query_authority(authority_uri => $authURI); + return 0 unless @$result[0]; + my $id = @$result[0]->{authority_id}; + return 0 unless $id; + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority_id, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance where servicename = ? and authority_id = ?"; + my $final = do_query($dbh, $statement, ($servicename, $id)); + if (@$final[0]){return 1} else {return 0} + +} +# selects all the columns from service_instance table +# PAY ATTENTION to what this returns. Not auth_id but auth_uri!! +sub query_service_instance { + my ($self, %args) = @_; + my $dbh = $self->dbh; + + #my $authority_id; + #if ($args{'authority_uri'}){ # need to transform URI to a row ID + # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); + # return 0 unless @$result[0]; + # $authority_id = @$result[0]->{authority_id}; + # return 0 unless $authority_id; + #} + #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table + my @args; + while (my ($k, $v) = each %args){ + push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine + } +# if ($authority_id){ +# push @args, ({authority_id => $authority_id}) ; +# } else { +# pop @args; # remove final "and" +# } + + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority.authority_uri, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance left join authority on authority.authority_id "; + my @bindvalues; + ($statement, @bindvalues) =_add_condition($statement, @args); + my $final = do_query($dbh, $statement, @bindvalues); + return $final; +} + +# custom query for Moby::Central.pm->findService() +# hmmmmmmm.... I'm not sure that this routine should exist... +# it is redundant to the routine above, if the routine above were executed +# multiple times. I think that is the more correct (though less efficient) +# way to go, since it is "scalable" to every possible underlying data source +# ********FIX change this later... +sub match_service_type_uri{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $uri_list = $args{'service_type_uri'}; + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where service_type_uri in ($uri_list)"; + my @bindvalues = (); + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# passs........ blah blah..... +sub insert_service_instance { + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $authority_id; + if ($args{'authority_uri'}){ # need to transform URI to a row ID + my $result = $self->_query_authority(authority_uri => $args{'authority_uri'}); + return undef unless @$result[0]; + $authority_id = @$result[0]->{authority_id}; + return undef unless $authority_id; + } + + $dbh->do(q{insert into service_instance (category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid) values (?,?,?,?,?,?,?,?,?,?)}, + undef,( + $args{'category'}, + $args{'servicename'}, + $args{'service_type_uri'}, + $authority_id, + $args{'url'}, + $args{'contact_email'}, + $args{'authoritative'}, + $args{'description'}, + $args{'signatureURL'}, + $args{'lsid'})); + + my $id = $dbh->{mysql_insertid}; + return $id; +} + +# pass service_instance_lsid +sub delete_service_instance{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service_instance where lsid = ?"; + $dbh->do( $statement,undef, ($args{service_instance_lsid}) ); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# Selects all columns EXCEPT authority_id +# pass authority_uri +sub query_authority { + my ($self, %args) = @_; + my $authURI = $args{authority_uri}; + my $dbh = $self->dbh; + + my $statement = "select + authority_common_name, + authority_uri, + contact_email + from authority where authority_uri = ?"; + my $result = do_query($dbh, $statement, ($authURI)); + return $result; +} + +# Selects all columns including authority_id +# pass authority_uri. NOTE THAT THIS IS A PRIVATE ROUTINE +# SHOULD NOT BE DOCUMENTED IN THE API +sub _query_authority { + my ($self, %args) = @_; + my $authURI = $args{authority_uri}; + my $dbh = $self->dbh; + + my $statement = "select + authority_common_name, + authority_uri, + authority_id, + contact_email + from authority where authority_uri = ?"; + my $result = do_query($dbh, $statement, ($authURI)); + return $result; +} + +# custom query routine used in Moby::Central.pm -> retrieveServiceProviders() +# no args passed +sub get_all_authorities{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select distinct authority_uri from authority"; + my @bindvalues = (); + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# pass authority_common_name, authority_uri, contact_email, return ID of some sort +sub insert_authority{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do("insert into authority + (authority_common_name, + authority_uri, + contact_email) + values (?,?,?)", + undef, + ($args{'authority_common_name'}, + $args{'authority_uri'}, + $args{'contact_email'})); + my $id = $dbh->{mysql_insertid}; + return $id; +} + +# pass service_type, as term or LSID +sub query_service{ + my ($self, %args) = @_; + my $type = $args{type}; + return [{}] unless $type; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where service_lsid = ?"; + } elsif ($type) { + $condition = "where service_type = ?"; + } + + my $dbh = $self->dbh; + my $statement = "select + service_id, + service_lsid, + service_type, + description, + authority, + contact_email + from service $condition"; + my $result = do_query($dbh, $statement, ($type)); + return $result; +} + +# pass in .... +sub insert_service{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do(q{insert into service (service_type, service_lsid, description, authority, contact_email) values (?,?,?,?,?)}, + undef, + ( + $args{'service_type'}, $args{'service_lsid'}, $args{'description'}, + $args{'authority'}, $args{'contact_email'} + ) + ); + return $dbh->{mysql_insertid}; +} + +# pass in service type as LSID (service_lsid) +sub delete_service{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $statement = "delete from service where service_lsid = ?"; + $dbh->do( $statement, undef, ($args{service_lsid})); + $self->_delete_service_term2term; + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +sub query_service_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_service(type => $type); + my $row = shift(@$result); + my $id = $row->{service_id}; + return [{}] unless $id; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + service1_id, + service2_id, + from service_term2term where service2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; +} + +#pass relationshiptype, servce1_type, service2_type +sub insert_service_term2term{ + my ($self, %args) = @_; + my $type1 = $args{service1_type}; + my $result = $self->query_service(type => $type1); + my $row = shift(@$result); + my $id1 = $row->{service_id}; + my $type2 = $args{service2_type}; + $result = $self->query_service(type => $type2); + $row = shift(@$result); + my $id2 = $row->{service_id}; + my $relationship_type = $args{relationship_type}; + + my $dbh = $self->dbh; + $dbh->do(q{insert into service_term2term (relationship_type, service1_id, service2_id) values (?,?,?)}, + undef, + ($relationship_type, + $id1, + $id2) + ); + + return $dbh->{mysql_insertid}; +} + + +# NOTE THAT THIS IS A PRIVATE FUNCTION AND SHOULD +# NOT BE DOCUMENTED IN THE API. +sub _delete_service_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_service(type => $type); + my $row = shift @$result; + my $id = $row->service_id; + + my $dbh = $self->dbh; + my $statement = "delete from service_term2term where service1_id=?"; + $dbh->do( $statement,undef, ($id)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + + +sub query_relationship{ + my ($self, %args) = @_; + my $type = $args{type}; + return [{}] unless $type; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where relationship_lsid = ? and "; + } elsif ($type) { + $condition = "where relationship_type = ? and"; + } + my $ont = $args{ontology}; + + my $dbh = $self->dbh; + + my $statement = "select + relationship_id, + relationship_lsid, + relationship_type, + container, + description, + authority, + contact_email, + ontology + from relationship where $condition ontology = ?"; + + if ($type){ + return do_query($dbh, $statement, ($type, $ont)); + } else { + return do_query($dbh, $statement, ($ont)); + } +} + +sub query_namespace{ + my ($self, %args) = @_; + my $type = $args{type}; + return [{}] unless $type; + my $condition = ""; + if ($type =~ /^urn\:lsid/){ + $condition = "where namespace_lsid = ? and "; + } elsif ($type) { + $condition = "where namespace_type = ? and"; + } + my $dbh = $self->dbh; + + my $statement = "select + namespace_id, + namespace_lsid, + namespace_type, + description, + authority, + contact_email + from namespace $condition"; + my $result = do_query($dbh, $statement, ($type)); + return $result; +} + + +sub insert_namespace{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + $dbh->do(q{insert into namespace (namespace_type, namespace_lsid, description, authority,contact_email) values (?,?,?,?,?)}, + undef, + ( + $args{'namespace_type'}, $args{'namespace_lsid'},$args{'description'},$args{'authority'},$args{'contact_email'} + ) + ); + return $dbh->{mysql_insertid}; +} + +# pass namesapce_lsid +sub delete_namespace{ + my ($self, %args) = @_; + my $lsid = $args{namespace_lsid}; + my $dbh = $self->dbh; + my $statement = "delete from namespace where namespace_lsid = ?"; + $dbh->do( $statement, undef, ($lsid)); + $self->_delete_namespace_term2term; + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +sub query_namespace_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_namespace(type => $type); + my $row = shift(@$result); + my $id = $row->{namespace_id}; + return [{}] unless $id; + my $dbh = $self->dbh; + + my $statement = "select + assertion_id, + relationship_type, + namespace1_id, + namespace2_id, + from namespace_term2term where namespace2_id = ?"; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; +} + +# PRIVATE, NOT PART OF API! +sub _delete_namespace_term2term{ + my ($self, %args) = @_; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_namespace(type => $type); + my $row = shift @$result; + my $id = $row->namespace_id; + + my $dbh = $self->dbh; + my $statement = "delete from namespace_term2term where namespace1_id=?"; + $dbh->do( $statement,undef, ($id)); + if ($dbh->err){ + return (1, $dbh->errstr); + } + else{ + return 0; + } +} + +# custom query subroutine for Moby::Central.pm->deregisterObjectClass() +# MARK LOOK HERE!!! +# may need two different adaptors for this... one for the object table and other for the mobycentral table +sub check_object_usage{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $errorMsg = 1; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_namespace(type => $type); + my $row = shift @$result; + my $lsid = $row->{object_lsid}; + + my ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, + undef, $existingURI + ); + return $errorMsg + if ($id); + + return 0; +} + +# custom query routine for Moby::Central.pm -> deregisterNamespace() +sub checkNamespaceUsedByService{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $existingURI = get_value('namespace_type_uris', @args); + my $term = get_value('term', @args); + my $errstr; + + my $sth = $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + $sth = $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + $sth = + $dbh->prepare( +"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" + ); + $sth->execute; + while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { + my @nss = split ",", $ns; + foreach (@nss) { + $_ =~ s/\s//g; + my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + return (1, $errstr) + if ( $_ eq $existingURI ); + } + } + return (0, ""); +} + +# custom query routine for Moby::Central.pm -> findService() +sub checkKeywords{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $param = get_value('findme', @args); + my %findme = %$param; + my $searchstring; + + foreach my $kw ( @{ $findme{keywords} } ) { +# $debug && &_LOG("KEYWORD $kw\n"); + $kw =~ s/\*//g; + $kw = $dbh->quote("%$kw%"); + $searchstring .= " OR description like $kw "; + } + $searchstring =~ s/OR//; # remove just the first OR in the longer statement +# $debug && &_LOG("search $searchstring\n"); + + my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; + my @bindvalues = (); + + my $ids = do_query($dbh, $statement, @bindvalues); + return ($ids, $searchstring); +} + +# custom query subroutine for Moby::Central.pm->_searchForSimple() +sub getFromSimple{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $ancestor_string = get_value('ancestor_string', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = +"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " + ; # if service_instance_id is null then it must be a collection input. + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/OR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; + } + + my $result = do_query($dbh, $query, ()); + return $result; +} + +# custom query subroutine for Moby::Central.pm->_searchForCollection() +sub getFromCollection{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $inout = get_value('inout', @args); + my $objectURI = get_value('objectURI', @args); + my $namespaceURIs = get_value('namespaceURIs', @args); + + my $query = "select + c.service_instance_id, + s.namespace_type_uris + from + simple_$inout as s, + collection_$inout as c + where + s.collection_${inout}_id IS NOT NULL + AND s.collection_${inout}_id = c.collection_${inout}_id + AND object_type_uri = '$objectURI' "; + my $nsquery; + foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's + $nsquery .= " OR INSTR(namespace_type_uris, '$ns') "; + } + if ($nsquery) { + $nsquery =~ s/^\sOR//; # just the first + $nsquery .= " OR namespace_type_uris IS NULL"; + $query .= " AND ($nsquery) "; # add the AND clause + } + + my $result = do_query($dbh, $query, ()); + return $result; +} + +# custom query subroutine for Moby::Central.pm->RetrieveServiceNames +sub getServiceNames{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; + my @bindvalues = (); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query for Moby::Central.pm->_flatten +sub getParentTerms{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $type_id = get_value('relationship_type_id', @args); + my $statement = " + select + OE1.term + from + OntologyEntry as OE1, + OntologyEntry as OE2, + Term2Term as TT + where + ontologyentry2_id = OE2.id + and ontologyentry1_id = OE1.id + and relationship_type_id = $type_id + and OE2.term = ?"; + + my @bindvalues = (); + push(@bindvalues, get_value('term', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# custom query subroutine for selecting from object_term2term and object tables +# used in Moby::OntologyServer.pm->retrieveObject() +sub getObjectRelationships{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + + my $statement = "select + relationship_type, + object_lsid, + object2_articlename + from object_term2term, object + where object1_id = ? and object2_id = object_id"; + + my @bindvalues = (); + push(@bindvalues, get_value('object1_id', @args)); + + my $result = do_query($dbh, $statement, @bindvalues); + return $result; +} + +# relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() +# note: returns a reference to an array containing ARRAY references +sub getRelationship{ + my ($self, @args) = @_; + my $dbh = $self->dbh; + my $direction = get_value('direction', @args); + my $ontology = get_value('ontology', @args); + my $term = get_value('term', @args); + my $relationship = get_value('relationship', @args); + my $defs; + + if ( $direction eq 'root' ) { + unless ( defined $relationship ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $term ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + } + } else { + unless ( defined $relationship ) { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s2.${ontology}_lsid = ?", undef, $term ); # ") + } else { + $defs = $self->dbh->selectall_arrayref( " + select distinct s2.${ontology}_lsid, relationship_type from + ${ontology}_term2term as t2t, + $ontology as s1, + $ontology as s2 + where + relationship_type = ? and + s1.${ontology}_id = t2t.${ontology}1_id and + s2.${ontology}_id = t2t.${ontology}2_id and + s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + } + } + return $defs; +} + +sub _checkURI { + +# my $uri = "http://www.ics.uci.edu/pub/ietf/uri/#Related"; +#print "$1, $2, $3, $4, $5, $6, $7, $8, $9" if +# $uri =~ m{^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?}; +# +#The license for this recipe is available here. +# +#Discussion: +# +#If the match is successful, a URL such as +# +#http://www.ics.uci.edu/pub/ietf/uri/#Related +# +#will be broken down into the following group match variables: +# +#$1 = http: +#$2 = http +#$3 = //www.ics.uci.edu +#$4 = www.ics.uci.edu +#$5 = /pub/ietf/uri/ +#$6 = +#$7 = +#$8 = #Related +#$9 = Related +# +#In general, this regular expression breaks a URI down into the following parts, +#as defined in the RFC: +# +#scheme = $2 +#authority = $4 +#path = $5 +#query = $7 +#fragment = $9 + +} + +sub DESTROY {} + +1; From dwang at pub.open-bio.org Tue Jul 26 05:19:37 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue, 26 Jul 2005 01:19:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507260519.j6Q5JbK8023025@pub.open-bio.org> dwang Tue Jul 26 01:19:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv23000/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added some more comments. some subroutines are still under modification, so holding out for now... don't quite understand what $type is. moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/25 23:45:29 1.13 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 05:19:37 1.14 @@ -539,21 +539,36 @@ die "delete_namespace not implemented in adaptor\n"; } -# +=head2 query_namespace_term2term + + Title : query_namespace_term2term + Usage : my $un = $API->query_namespace_term2term(%args) + Function : Execute a query for namespaces_term2term + Args : type => String - namespace_type you are checking for + Returns : listref of hashrefs: + [{assertion_id => Integer, + relationship_type => String, + namespace1_id => Integer, + namespace2_id => Integer}] + +=cut # namespace_term2term table functions -# sub query_namespace_term2term{ die "query_namespace_term2term not implemented in adaptor\n"; } +# does not exist in mysql api, should this be removed? sub insert_namespace_term2term{ die "insert_namespace_term2term not implemented in adaptor\n"; } -sub delete_namespace_term2term{ +# changed to a private subroutine in mysql +# I guess this subroutine should be removed from here? +sub _delete_namespace_term2term{ die "delete_namespace_term2term not implemented in adaptor\n"; } +# still incomplete... # custom query subroutine for Moby::Central.pm->deregisterObjectClass() sub check_object_usage{ die "check_object_usage not implemented in adaptor\n"; From kawas at pub.open-bio.org Tue Jul 26 14:50:21 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 10:50:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261450.j6QEoL06024431@pub.open-bio.org> kawas Tue Jul 26 10:50:21 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv24406/org/biomoby/registry/rdfagent/vocabulary Modified Files: MP.java Log Message: updated the predicate vocabulary again to include the newest predicates. moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary MP.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/07/25 20:20:44 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/vocabulary/MP.java 2005/07/26 14:50:21 1.6 @@ -52,6 +52,10 @@ public static final Property Simple = m.getProperty(uri + "Simple" ) ; public static final Property Collection = m.getProperty(uri + "Collection" ) ; public static final Property Secondary = m.getProperty(uri + "Secondary" ) ; + /* new predicates */ + public static final Property sampleInputData = m.getProperty(uri + "sampleInputData"); + public static final Property sampleOutputData = m.getProperty(uri + "sampleOutputData"); + public static final Property approvedBy = m.getProperty(uri + "approvedBy"); } From kawas at pub.open-bio.org Tue Jul 26 14:53:12 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 10:53:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261453.j6QErCXa024480@pub.open-bio.org> kawas Tue Jul 26 10:53:12 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary In directory pub.open-bio.org:/tmp/cvs-serv24455/org/biomoby/client/rdf/vocabulary Modified Files: Predicates.java Log Message: *removed the ability to modify the domain of a URI. *added 3 predicates that were added to biomoby.org/RESOURCES/MOBY-S/Predicates. *removed any MobyResources.java references that existed directly or indirectly. moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary Predicates.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/20 17:42:31 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/vocabulary/Predicates.java 2005/07/26 14:53:12 1.5 @@ -14,46 +14,50 @@ /** * @author Eddie Kawas - *

Created for - *

This class was created to ... + *

Created for the BioMoby project. + *

This class was created to represent the RDF predicate vocabulary in BioMoby under the namespace mobyPred. *

For questions, comments, or bugs *

email me at edward.kawas at gmail.com */ public class Predicates { private final static Properties properties = MobyProperties.PROPERTIES(); - protected final static String uri = "http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#"; + protected final static String uri = "http://biomoby.org/RESOURCES/MOBY-S/Predicates#"; private final static Model _model = ModelFactory.createDefaultModel();; - public static final Property category = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#category"); - public static final Property isa = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#isa"); - public static final Property has = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#has"); - public static final Property hasa = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#hasa"); - public static final Property articleName = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#articleName"); - public static final Property article_name = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#article_name"); - public static final Property namespace_type = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#namespace_type"); - public static final Property object_type = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#object_type"); - public static final Property input = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#input"); - public static final Property output = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#output"); - public static final Property consumes = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#consumes"); - public static final Property produces = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#produces"); - public static final Property performs_task = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#performs_task"); - public static final Property comment = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#comment"); - public static final Property label = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#label"); - public static final Property default_value = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#default_value"); - public static final Property datatype = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#datatype"); - public static final Property max = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#max"); - public static final Property min = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#min"); - public static final Property enumeration = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#enum"); - public static final Property SimpleArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SimpleArticle"); - public static final Property CollectionArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#CollectionArticle"); - public static final Property SecondaryArticle = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SecondaryArticle"); - public static final Property SignatureURL = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#SignatureURL"); - public static final Property authoritative = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#authoritative"); - public static final Property ofType = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/Predicates#ofType"); + public static final Property category = _model.getProperty(uri + "category"); + public static final Property isa = _model.getProperty(uri + "isa"); + public static final Property has = _model.getProperty(uri + "has"); + public static final Property hasa = _model.getProperty(uri + "hasa"); + public static final Property articleName = _model.getProperty(uri + "articleName"); + public static final Property article_name = _model.getProperty(uri + "article_name"); + public static final Property namespace_type = _model.getProperty(uri + "namespace_type"); + public static final Property object_type = _model.getProperty(uri + "object_type"); + public static final Property input = _model.getProperty(uri + "input"); + public static final Property output = _model.getProperty(uri + "output"); + public static final Property consumes = _model.getProperty(uri + "consumes"); + public static final Property produces = _model.getProperty(uri + "produces"); + public static final Property performs_task = _model.getProperty(uri + "performs_task"); + public static final Property comment = _model.getProperty(uri + "comment"); + public static final Property label = _model.getProperty(uri + "label"); + public static final Property default_value = _model.getProperty(uri + "default_value"); + public static final Property datatype = _model.getProperty(uri + "datatype"); + public static final Property max = _model.getProperty(uri + "max"); + public static final Property min = _model.getProperty(uri + "min"); + public static final Property enumeration = _model.getProperty(uri + "enum"); + public static final Property SimpleArticle = _model.getProperty(uri + "SimpleArticle"); + public static final Property CollectionArticle = _model.getProperty(uri + "CollectionArticle"); + public static final Property SecondaryArticle = _model.getProperty(uri + "SecondaryArticle"); + public static final Property SignatureURL = _model.getProperty(uri + "SignatureURL"); + public static final Property authoritative = _model.getProperty(uri + "authoritative"); + public static final Property ofType = _model.getProperty(uri + "ofType"); /* moved from MobyResources.java */ - public static final Property Simple = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Simple"); - public static final Property Secondary = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Secondary"); - public static final Property Collection = _model.getProperty("http://" + properties.getProperty("resources_script_domain") + "/RESOURCES/MOBY-S/MOBYResources#Collection"); + public static final Property Simple = _model.getProperty(uri + "Simple"); + public static final Property Secondary = _model.getProperty(uri + "Secondary"); + public static final Property Collection = _model.getProperty(uri + "Collection"); + /* new predicates */ + public static final Property sampleInputData = _model.getProperty(uri + "sampleInputData"); + public static final Property sampleOutputData = _model.getProperty(uri + "sampleOutputData"); + public static final Property approvedBy = _model.getProperty(uri + "approvedBy"); public final static String getURI() { return uri; From kawas at pub.open-bio.org Tue Jul 26 14:56:19 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 10:56:19 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261456.j6QEuJsG024549@pub.open-bio.org> kawas Tue Jul 26 10:56:19 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder In directory pub.open-bio.org:/tmp/cvs-serv24524/org/biomoby/client/rdf/builder Modified Files: RDFConfigure.java Log Message: updated the old references to the MobyResources.java predicate vocabulary to the 'new' one. moby-live/Java/src/main/org/biomoby/client/rdf/builder RDFConfigure.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/07/19 15:54:02 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/RDFConfigure.java 2005/07/26 14:56:19 1.4 @@ -7,7 +7,6 @@ import java.net.URL; import java.util.Properties; -import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; import org.biomoby.registry.properties.MobyProperties; @@ -268,10 +267,10 @@ // get the statements for the item in the bag // could be a bag or just a simple StmtIterator sit = item.listProperties(); - if (item.hasProperty(RDF.type, MobyResources.SimpleArticle)) { + if (item.hasProperty(RDF.type, Predicates.Simple)) { // create a simple article Resource _li = rdf.createResource(); - _li.addProperty(RDF.type, MobyResources.SimpleArticle); + _li.addProperty(RDF.type, Predicates.Simple); _li.addProperty(Predicates.object_type, model .getResource(item.getProperty( Predicates.object_type).getObject() @@ -295,11 +294,11 @@ _bag.add(_li); } if (item.hasProperty(RDF.type, - MobyResources.SecondaryArticle)) { + Predicates.Secondary)) { // create a secondary article Resource _li = rdf.createResource(); _li.addProperty(RDF.type, - MobyResources.SecondaryArticle); + Predicates.Secondary); boolean isInt = false; if (item.hasProperty(Predicates.datatype)) { String str = item.getProperty(Predicates.datatype) @@ -369,11 +368,11 @@ // add the item to the bag _bag.add(_li); } - if (item.hasProperty(RDF.type, MobyResources.Collection)) { + if (item.hasProperty(RDF.type, Predicates.Collection)) { // create a collection Bag collectionBag = rdf.createBag(); collectionBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); collectionBag.addProperty(RDFS.subClassOf, RDF.Bag); if (item.hasProperty(Predicates.articleName)) { String str = item.getProperty( @@ -392,7 +391,7 @@ Resource simple = cStatement.getResource(); Resource _li = rdf.createResource(); _li.addProperty(RDF.type, - MobyResources.SimpleArticle); + Predicates.Simple); _li.addProperty(Predicates.object_type, model .getResource(simple.getProperty( Predicates.object_type) From kawas at pub.open-bio.org Tue Jul 26 14:57:07 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 10:57:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507261457.j6QEv7vx024603@pub.open-bio.org> kawas Tue Jul 26 10:57:07 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder In directory pub.open-bio.org:/tmp/cvs-serv24578/org/biomoby/client/rdf/builder Modified Files: ServiceInstanceRDF.java Log Message: updated the old references to the MobyResources.java predicate vocabulary to the 'new' one. moby-live/Java/src/main/org/biomoby/client/rdf/builder ServiceInstanceRDF.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/07/19 15:54:02 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/rdf/builder/ServiceInstanceRDF.java 2005/07/26 14:57:07 1.6 @@ -10,7 +10,6 @@ import java.util.regex.Pattern; import org.biomoby.client.CentralImpl; -import org.biomoby.client.rdf.vocabulary.MobyResources; import org.biomoby.client.rdf.vocabulary.Predicates; import org.biomoby.registry.properties.MobyProperties; import org.biomoby.shared.Central; @@ -270,7 +269,6 @@ map.put("serviceInstances", SI); map.put("mobyNamespace", NS); map.put("mobyService", SRV); - map.put("moby", MobyResources.getURI()); model.setNsPrefixes(map); for (int i = 0; i < services.length; i++) { @@ -336,7 +334,7 @@ } innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) primaryInputs[j]) .getName().equals("")) innerBag @@ -388,7 +386,7 @@ _li.addProperty(Predicates.datatype, model .createTypedLiteral(data.getDataType())); _li.addProperty(RDF.type, - MobyResources.SecondaryArticle); + Predicates.Secondary); if (data.getDataType().equals("Integer")) { _li .addProperty(Predicates.min, model @@ -440,7 +438,7 @@ produceBag = model.createBag(); innerBag = model.createBag(); innerBag.addProperty(RDF.type, - MobyResources.Collection); + Predicates.Collection); if (!((MobyPrimaryDataSet) outputs[j]) .getName().equals("")) innerBag @@ -511,7 +509,7 @@ */ private final static Resource createSimpleDataItem(Model model, MobyPrimaryDataSimple simpleData, Resource _li) { - _li.addProperty(RDF.type, MobyResources.SimpleArticle); + _li.addProperty(RDF.type, Predicates.Simple); _li.addProperty(Predicates.object_type, model.createResource(OBJ + simpleData.getDataType().getName())); if (!simpleData.getName().equals("")) From dwang at pub.open-bio.org Tue Jul 26 21:55:28 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue, 26 Jul 2005 17:55:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262155.j6QLtSwa025501@pub.open-bio.org> dwang Tue Jul 26 17:55:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv25475/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: slightly more comments moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 05:19:37 1.14 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 21:55:28 1.15 @@ -527,14 +527,53 @@ # # namespace table functions # +=head2 query_namespace + + Title : insert_namespace + Usage : my $un = $API->insert_namespace(%args) + Function : Deletes a namespace instance from the database + Args : namespace_type => String, + namespace_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer mysql_insertid + Notes : the fact that it returns a mysql_insertid is bad since this + is only useful to an SQL-based API... +=cut sub query_namespace{ die "query_namespace not implemented in adaptor\n"; } +=head2 insert_namespace + + Title : insert_namespace + Usage : my $un = $API->insert_namespace(%args) + Function : Deletes a namespace instance from the database + Args : namespace_type => String, + namespace_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer mysql_insertid + Notes : the fact that it returns a mysql_insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_namespace{ die "insert_namespace not implemented in adaptor\n"; } +=head2 delete_namespace + + Title : delete_namespace + Usage : my $un = $API->delete_namespace(%args) + Function : Deletes a namespace instance from the database + Args : namespace_lsid => String - lsid identifying a particular namespace + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 otherwise + $errstr = String error message if there was an error + +=cut sub delete_namespace{ die "delete_namespace not implemented in adaptor\n"; } @@ -609,7 +648,7 @@ authoritative => String, description => String, signatureURL => String, - lsid => Integer}, ...] + lsid => String}, ...] Each hash represents a service Notes : the fact that it returns a service_instance_id is bad since this is only useful to an SQL-based API... @@ -702,7 +741,7 @@ Args : object1_id => Integer - a bind value for object1_id on an underlying SQL-based data source Returns : listref of hashrefs: [{relationship_type => String, - object_lsid => Integer, + object_lsid => String, object2_articlename => String}, ...] one hashref for each relationship between two objects Notes : relationship_type from object_term2term, object_lsid from object, and object2_articlename from object_term2term @@ -721,10 +760,10 @@ Function : Execute a query for a relationship between two ontologies Args : direction => String - direction in the ontology (eg. 'root') ontology => String - name of the table ontology - term => Integer - a bind value for lsid + term => String - a bind value for lsid relationship => String - a bind value for relationship_type Returns : reference to array containing array-refs representing the result set: - [[Integer lsid, String relationship_type], ...] + [[String lsid, String relationship_type], ...] each array-ref represents one row Notes : Only returns distinct lsid from $ontology and relationship_type from $ontology_term2term From mwilkinson at pub.open-bio.org Tue Jul 26 23:32:48 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:32:48 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262332.j6QNWm8K025808@pub.open-bio.org> mwilkinson Tue Jul 26 19:32:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv25766/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: adaptor API should now be complete moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 21:55:28 1.15 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 23:32:48 1.16 @@ -613,10 +613,10 @@ die "check_object_usage not implemented in adaptor\n"; } -=head2 checkNamespaceUsedByService +=head2 check_namespace_usage - Title : checkNamespaceUsedByService - Usage : my $un = $API->checkNamespaceUsedByService(%args) + Title : check_namespace_usage + Usage : my $un = $API->check_namespace_usage(%args) Function : Execute a custom query for namespaces that are used by some service Args : namespace_type_uris => String - namespace_type_uris you are checking for term => String - the type of the namespace @@ -627,16 +627,16 @@ =cut # custom query routine for Moby::Central.pm -> deregisterNamespace() -sub checkNamespaceUsedByService{ - die "checkNamespaceUsedByService not implemented in adaptor\n"; +sub check_namespace_usage{ + die "check_namespace_usage not implemented in adaptor\n"; } -=head2 checkKeywords +=head2 check_keywords - Title : checkKeywords - Usage : my $un = $API->checkKeywords(%args) + Title : check_keywords + Usage : my $un = $API->check_keywords(%args) Function : Execute a custom query for services with keywords in its description - Args : findme => hashref - hash contains an array of keywords + Args : keywords => listref (of keywords) Returns : listref of hashrefs: [{service_instance_id => Integer, category => String, @@ -652,17 +652,18 @@ Each hash represents a service Notes : the fact that it returns a service_instance_id is bad since this is only useful to an SQL-based API... - + Keywords are assumed to be joined by "OR" for the query + =cut # custom query routine for Moby::Central.pm -> findService() -sub checkKeywords{ - die "checkKeywords not implemented in adaptor\n"; +sub check_keywords{ + die "check_keywords not implemented in adaptor\n"; } -=head2 getFromSimple +=head2 find_by_simple - Title : getFromSimple - Usage : my $un = $API->getFromSimple(%args) + Title : find_by_simple + Usage : my $un = $API->find_by_simple(%args) Function : Execute a custom query for service ids in simple_input/output Args : inout => String - to specify if input or output ancestor_string => String - values that occur in object_type_uri @@ -675,14 +676,14 @@ =cut # custom query subroutine for Moby::Central.pm->_searchForSimple() -sub getFromSimple{ - die "getFromSimple not implemented in adaptor\n"; +sub find_by_simple{ + die "find_by_simple not implemented in adaptor\n"; } -=head2 getFromCollection +=head2 find_by_collection - Title : getFromCollection - Usage : my $un = $API->getFromCollection(%args) + Title : find_by_collection + Usage : my $un = $API->find_by_collection(%args) Function : Execute a custom query for service ids from collections Args : inout => String - to specify if input or output objectURI => String - value that binds to object_type_uri @@ -695,14 +696,14 @@ =cut # custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection{ - die "getFromCollection not implemented in adaptor\n"; +sub find_by_collection{ + die "find_by_collection not implemented in adaptor\n"; } -=head2 getServiceNames +=head2 get_service_names - Title : getServiceNames - Usage : my $un = $API->getServiceNames(%args) + Title : get_service_names + Usage : my $un = $API->get_service_names(%args) Function : Execute a query for all service names Args : no inputs needed Returns : listref of hashrefs: @@ -712,14 +713,14 @@ =cut # custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames{ - die "getServiceNames not implemented in adaptor\n"; +sub get_service_names{ + die "get_service_names not implemented in adaptor\n"; } -=head2 getParentTerms +=head2 get_parent_terms - Title : getParentTerms - Usage : my $un = $API->getParentTerms(%args) + Title : get_parent_terms + Usage : my $un = $API->get_parent_terms(%args) Function : From a given term, traverse the ontology and get all parent terms Args : relationship_type_id => Integer - a bind value for relationship_type_id on an underlying SQL-based data source term => String - bindvalue for OntologyEntry.term @@ -729,16 +730,16 @@ =cut # custom query for Moby::Central.pm->_flatten -sub getParentTerms{ - die "getParentTerms not implemented in adaptor\n"; +sub get_parent_terms{ + die "get_parent_terms not implemented in adaptor\n"; } -=head2 getObjectRelationships +=head2 get_object_relationships - Title : getObjectRelationships - Usage : my $un = $API->getObjectRelationships(%args) + Title : get_object_relationships + Usage : my $un = $API->get_object_relationships(%args) Function : Execute a query for objects that have relationships with other objects - Args : object1_id => Integer - a bind value for object1_id on an underlying SQL-based data source + Args : type => String - either an object name or LSID Returns : listref of hashrefs: [{relationship_type => String, object_lsid => String, @@ -749,14 +750,14 @@ =cut # custom query subroutine for selecting from object_term2term and object tables # used in Moby::OntologyServer.pm->retrieveObject() -sub getObjectRelationships{ - die "getObjectRelationships not implemented in adaptor\n"; +sub get_object_relationships{ + die "get_object_relationships not implemented in adaptor\n"; } -=head2 getRelationship +=head2 get_relationship - Title : getRelationship - Usage : my $un = $API->getRelationships(%args) + Title : get_relationship + Usage : my $un = $API->get_relationship(%args) Function : Execute a query for a relationship between two ontologies Args : direction => String - direction in the ontology (eg. 'root') ontology => String - name of the table ontology @@ -770,8 +771,8 @@ =cut # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references -sub getRelationship{ - die "getRelationship not implemented in adaptor\n"; +sub get_relationship{ + die "get_relationship not implemented in adaptor\n"; } # Not quite sure what this does... From mwilkinson at pub.open-bio.org Tue Jul 26 23:32:48 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:32:48 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262332.j6QNWmYu025789@pub.open-bio.org> mwilkinson Tue Jul 26 19:32:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv25766/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: adaptor API should now be complete moby-live/Perl/MOBY Central.pm,1.185,1.186 OntologyServer.pm,1.58,1.59 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.185 retrieving revision 1.186 diff -u -r1.185 -r1.186 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/25 23:45:29 1.185 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/26 23:32:48 1.186 @@ -22,7 +22,7 @@ use MOBY::secondary_input; use MOBY::central_db_connection; use MOBY::Config; -#use MOBY::Client::Central; +use MOBY::Client::Central; #use MOBY::RDF::ServiceInstanceRDF; #use RDF::Core; @@ -1996,12 +1996,10 @@ $debug && _LOG("Keywords added; criterion count is now $criterion_count\n"); - my ($ids, $searchstring) = $adaptor->checkKeywords({findme => %findme}); + my ($ids) = $adaptor->check_keywords(keywords => \@{$findme{keywords}}); $ids = _extract_ids($ids); # this is the hash-list that comes back from do_query unless ( scalar @{$ids} ) { - $debug - && &_LOG("found no ids @{$ids}!\nselect service_instance_id from service_instance where $searchstring\n"); return &_serviceListResponse( $dbh, undef ); } $debug @@ -2193,7 +2191,9 @@ } $ancestor_string =~ s/\,$//; - my $result = $adaptor->getFromSimple({inout => $inout}, {ancestor_string => $ancestor_string}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->find_by_simple(inout => $inout, + ancestor_string => $ancestor_string, + namespaceURIs => $namespaceURIs); my @valid_services; @@ -2244,7 +2244,9 @@ my ( $objectURI, $namespaceURIs ) = &_extractObjectTypesAndNamespaces($simple); - my $result = $adaptor->getFromCollection({inout => $inout}, {objectURI => $objectURI}, {namespaceURIs => $namespaceURIs}); + my $result = $adaptor->find_by_collection(inout => $inout, + objectURI => $objectURI, + namespaceURIs => $namespaceURIs); foreach my $row (@$result ) { # get the service instance ID and the namespaces that matched @@ -2508,7 +2510,7 @@ my ($pkg) = shift; my $dbh = MOBY::central_db_connection->new()->dbh; - my $result = $adaptor->getServiceNames(); + my $result = $adaptor->get_service_names(); my $names = "\n"; foreach my $row (@$result) { $names .= "\n"; @@ -2948,7 +2950,8 @@ # and flatten it into a list of parent terms my ( $dbh, $type, $term, $seen ) = @_; - my $result = $adaptor->getParentTerms({relationship_type_id => $type}, {term => $term}); + my $result = $adaptor->get_parent_terms(relationship_type_id => $type, + term => $term); foreach my $row (@$result) { my $term = $row->{term}; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/25 23:45:29 1.58 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/26 23:32:48 1.59 @@ -303,18 +303,18 @@ unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } my $result = $adaptor->query_object(type => $LSID); my $row = shift(@$result); - my $id = $row->{object_id}; +# my $id = $row->{object_id}; my $type = $row->{object_type}; my $lsid = $row->{object_lsid}; my $desc = $row->{description}; my $auth = $row->{authority}; my $contact = $row->{contact_email}; - unless ($id) { return ( 0, "Object doesn't exist in ontology", "" ) } + unless ($lsid) { return ( 0, "Object doesn't exist in ontology", "" ) } # my $OS = MOBY::OntologyServer->new(ontology => "relationship"); - $result = $adaptor->getObjectRelationships({object1_id => $id}); + $result = $adaptor->get_object_relationships(type => $lsid); my %rel; foreach my $row (@$result) { @@ -688,7 +688,7 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_service_term2term({service1_id => $id}); + ($err, $errstr) = $adaptor->delete_service_term2term(service1_id => $lsid); if ( $err ) { return ( @@ -828,7 +828,7 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_namespace_term2term({namespace1_id => $id}); + ($err, $errstr) = $adaptor->delete_namespace_term2term(namespace1_id => $lsid); if ( $err ) { return ( @@ -1088,7 +1088,10 @@ my $adaptor = $CONFIG->getDataAdaptor( datasource => $datasource ); my $defs; # query returns a reference to an array containing array references - $defs = $adaptor->getRelationship({direction => $direction}, {ontology => $ontology}, {term => $term}, {relationship => $relationship}); + $defs = $adaptor->get_relationship(direction => $direction, + ontology => $ontology, + term => $term, + relationship => $relationship); # a very long piece of SQL statements have been refactored into Moby::Adaptor::moby::queryapi::mysql.pm return $defs; } From mwilkinson at pub.open-bio.org Tue Jul 26 23:32:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:32:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262332.j6QNWnDT025829@pub.open-bio.org> mwilkinson Tue Jul 26 19:32:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25766/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: adaptor API should now be complete moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.38,1.39 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/25 23:45:29 1.38 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:32:48 1.39 @@ -1034,40 +1034,37 @@ return 0; } } - -# custom query subroutine for Moby::Central.pm->deregisterObjectClass() -# MARK LOOK HERE!!! -# may need two different adaptors for this... one for the object table and other for the mobycentral table +# pass type as LSID or term sub check_object_usage{ my ($self, %args) = @_; my $dbh = $self->dbh; my $errorMsg = 1; my $type = $args{type}; return 0 unless $type; - my $result = $self->query_namespace(type => $type); + my $result = $self->query_object(type => $type); my $row = shift @$result; my $lsid = $row->{object_lsid}; my ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_input where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join simple_output where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_input natural join simple_input where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); ($id) = $dbh->selectrow_array(q{select service_instance.service_instance_id from service_instance natural join collection_output natural join simple_output where object_type_uri = ?}, - undef, $existingURI + undef, $lsid ); return $errorMsg if ($id); @@ -1076,15 +1073,17 @@ } # custom query routine for Moby::Central.pm -> deregisterNamespace() -sub checkNamespaceUsedByService{ - my ($self, @args) = @_; - my $dbh = $self->dbh; - my $existingURI = get_value('namespace_type_uris', @args); - my $term = get_value('term', @args); - my $errstr; +sub check_namespace_usage{ + my ($self, %args) = @_; + my $dbh = $self->dbh; + my $errorMsg = 1; + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_namespace(type => $type); + my $row = shift @$result; + my $lsid = $row->{namespace_lsid}; - my $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$existingURI')" + my $sth = $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_input where INSTR(namespace_type_uris,'$lsid')" ); $sth->execute; @@ -1092,89 +1091,84 @@ my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } - $sth = $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$existingURI')" + $sth = $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join simple_output where INSTR(namespace_type_uris,'$lsid')" ); $sth->execute; while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$existingURI')" + $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_input natural join simple_input where INSTR(namespace_type_uris, '$lsid')" ); $sth->execute; while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } $sth = - $dbh->prepare( -"select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$existingURI')" + $dbh->prepare("select service_instance.service_instance_id, namespace_type_uris from service_instance natural join collection_output natural join simple_output where INSTR(namespace_type_uris, '$lsid')" ); $sth->execute; while ( my ( $id, $ns ) = $sth->fetchrow_array() ) { my @nss = split ",", $ns; foreach (@nss) { $_ =~ s/\s//g; - my $errstr = "Namespace Type $term ($_) is used by a service (service ID number $id) and may not be deregistered"; + my $errstr = "Namespace Type $type ($_) is used by a service (service ID number $id) and may not be deregistered"; return (1, $errstr) - if ( $_ eq $existingURI ); + if ( $_ eq $lsid ); } } return (0, ""); } # custom query routine for Moby::Central.pm -> findService() -sub checkKeywords{ - my ($self, @args) = @_; +sub check_keywords{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $param = get_value('findme', @args); + my $param = $args{keywords}; + return ([{}]) unless (ref($param) =~ /ARRAY/); + my @keywords = @$param; my %findme = %$param; my $searchstring; - - foreach my $kw ( @{ $findme{keywords} } ) { -# $debug && &_LOG("KEYWORD $kw\n"); + foreach my $kw ( @keywords ) { $kw =~ s/\*//g; $kw = $dbh->quote("%$kw%"); $searchstring .= " OR description like $kw "; } $searchstring =~ s/OR//; # remove just the first OR in the longer statement -# $debug && &_LOG("search $searchstring\n"); my $statement = "select service_instance_id,category, servicename, service_type_uri, authority_id, url, contact_email, authoritative, description, signatureURL, lsid from service_instance where $searchstring"; my @bindvalues = (); my $ids = do_query($dbh, $statement, @bindvalues); - return ($ids, $searchstring); + return ($ids); } # custom query subroutine for Moby::Central.pm->_searchForSimple() -sub getFromSimple{ - my ($self, @args) = @_; +sub find_by_simple{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $ancestor_string = get_value('ancestor_string', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); + my $inout = $args{'inout'}; + my $ancestor_string = $args{'ancestor_string'}; + my $namespaceURIs = $args{'namespaceURIs'}; - my $query = -"select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " + my $query ="select service_instance_id, namespace_type_uris from simple_$inout where object_type_uri in ($ancestor_string) and service_instance_id IS NOT NULL " ; # if service_instance_id is null then it must be a collection input. my $nsquery; foreach my $ns ( @{$namespaceURIs} ) { # namespaces are already URI's @@ -1191,12 +1185,12 @@ } # custom query subroutine for Moby::Central.pm->_searchForCollection() -sub getFromCollection{ - my ($self, @args) = @_; +sub find_by_collection{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $inout = get_value('inout', @args); - my $objectURI = get_value('objectURI', @args); - my $namespaceURIs = get_value('namespaceURIs', @args); + my $inout = $args{'inout'}; + my $objectURI = $args{'objectURI'}; + my $namespaceURIs = $args{'namespaceURIs'}; my $query = "select c.service_instance_id, @@ -1223,8 +1217,8 @@ } # custom query subroutine for Moby::Central.pm->RetrieveServiceNames -sub getServiceNames{ - my ($self, @args) = @_; +sub get_service_names{ + my ($self, %args) = @_; my $dbh = $self->dbh; my $statement = "select authority_uri, servicename from authority as a, service_instance as s where s.authority_id = a.authority_id"; my @bindvalues = (); @@ -1234,11 +1228,11 @@ } # custom query for Moby::Central.pm->_flatten -sub getParentTerms{ - my ($self, @args) = @_; +sub get_parent_terms{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $type_id = get_value('relationship_type_id', @args); + my $type_id = $args{'relationship_type_id'}; my $statement = " select OE1.term @@ -1253,7 +1247,7 @@ and OE2.term = ?"; my @bindvalues = (); - push(@bindvalues, get_value('term', @args)); + push(@bindvalues, $args{'term'}); my $result = do_query($dbh, $statement, @bindvalues); return $result; @@ -1261,10 +1255,15 @@ # custom query subroutine for selecting from object_term2term and object tables # used in Moby::OntologyServer.pm->retrieveObject() -sub getObjectRelationships{ - my ($self, @args) = @_; +sub get_object_relationships{ + my ($self, %args) = @_; my $dbh = $self->dbh; - + my $type = $args{type}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $id = $row->{object_id}; + my $statement = "select relationship_type, object_lsid, @@ -1272,22 +1271,24 @@ from object_term2term, object where object1_id = ? and object2_id = object_id"; - my @bindvalues = (); - push(@bindvalues, get_value('object1_id', @args)); - - my $result = do_query($dbh, $statement, @bindvalues); - return $result; + my $result2 = do_query($dbh, $statement, ($id)); + return $result2; } # relationship query for any table used in Moby::OntologyServer->_doRelationshipQuery() # note: returns a reference to an array containing ARRAY references -sub getRelationship{ - my ($self, @args) = @_; +sub get_relationship{ + my ($self, %args) = @_; my $dbh = $self->dbh; - my $direction = get_value('direction', @args); - my $ontology = get_value('ontology', @args); - my $term = get_value('term', @args); - my $relationship = get_value('relationship', @args); + my $direction = $args{'direction'}; + my $ontology = $args{'ontology'}; + my $relationship = $args{'relationship'}; + + my $type = $args{'term'}; + return 0 unless $type; + my $result = $self->query_object(type => $type); + my $row = shift @$result; + my $lsid = $row->{object_lsid}; my $defs; if ( $direction eq 'root' ) { @@ -1300,7 +1301,7 @@ where s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $term ); # ") + s1.${ontology}_lsid = ?", undef, $lsid ); # ") } else { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from @@ -1311,7 +1312,7 @@ relationship_type = ? and s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s1.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + s1.${ontology}_lsid = ?", undef, $relationship, $lsid ); # ") } } else { unless ( defined $relationship ) { @@ -1323,7 +1324,7 @@ where s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $term ); # ") + s2.${ontology}_lsid = ?", undef, $lsid); # ") } else { $defs = $self->dbh->selectall_arrayref( " select distinct s2.${ontology}_lsid, relationship_type from @@ -1334,7 +1335,7 @@ relationship_type = ? and s1.${ontology}_id = t2t.${ontology}1_id and s2.${ontology}_id = t2t.${ontology}2_id and - s2.${ontology}_lsid = ?", undef, $relationship, $term ); # ") + s2.${ontology}_lsid = ?", undef, $relationship, $lsid ); # ") } } return $defs; From mwilkinson at pub.open-bio.org Tue Jul 26 23:36:27 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:36:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262336.j6QNaRQd025901@pub.open-bio.org> mwilkinson Tue Jul 26 19:36:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25882/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing spaces in SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.39,1.40 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:32:48 1.39 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:36:26 1.40 @@ -917,9 +917,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = "where relationship_lsid = ? and "; + $condition = " where relationship_lsid = ? and "; } elsif ($type) { - $condition = "where relationship_type = ? and"; + $condition = " where relationship_type = ? and "; } my $ont = $args{ontology}; @@ -949,9 +949,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = "where namespace_lsid = ? and "; + $condition = " where namespace_lsid = ? and "; } elsif ($type) { - $condition = "where namespace_type = ? and"; + $condition = " where namespace_type = ? and"; } my $dbh = $self->dbh; From mwilkinson at pub.open-bio.org Tue Jul 26 23:39:33 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:39:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262339.j6QNdXXs025969@pub.open-bio.org> mwilkinson Tue Jul 26 19:39:33 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv25948/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing extra where in auto-generated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.40,1.41 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:36:26 1.40 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:39:33 1.41 @@ -917,9 +917,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = " where relationship_lsid = ? and "; + $condition = " relationship_lsid = ? and "; } elsif ($type) { - $condition = " where relationship_type = ? and "; + $condition = " relationship_type = ? and "; } my $ont = $args{ontology}; From mwilkinson at pub.open-bio.org Tue Jul 26 23:50:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 19:50:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262350.j6QNobNk026055@pub.open-bio.org> mwilkinson Tue Jul 26 19:50:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv26036/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: fixing extra bind arguments in auto-generated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.41,1.42 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:39:33 1.41 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:50:37 1.42 @@ -476,8 +476,13 @@ contact_email from object $condition"; - my $dbh = $self->dbh; - my $result = do_query($dbh, $statement, ($type)); + my $dbh = $self->dbh; + my $result; + if ($type){ + $result = do_query($dbh, $statement, ($type)); + } else { + $result = do_query($dbh, $statement); + } return $result; } @@ -812,7 +817,12 @@ authority, contact_email from service $condition"; - my $result = do_query($dbh, $statement, ($type)); + my $result; + if ($type){ + $result = do_query($dbh, $statement, ($type)); + } else { + $result = do_query($dbh, $statement); + } return $result; } @@ -949,9 +959,9 @@ return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ - $condition = " where namespace_lsid = ? and "; + $condition = " where namespace_lsid = ?"; } elsif ($type) { - $condition = " where namespace_type = ? and"; + $condition = " where namespace_type = ?"; } my $dbh = $self->dbh; @@ -963,7 +973,12 @@ authority, contact_email from namespace $condition"; - my $result = do_query($dbh, $statement, ($type)); + my $result; + if ($type){ + $result = do_query($dbh, $statement, ($type)); + } else { + $result = do_query($dbh, $statement); + } return $result; } From mwilkinson at pub.open-bio.org Wed Jul 27 00:00:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 20:00:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270000.j6R00jO7026161@pub.open-bio.org> mwilkinson Tue Jul 26 20:00:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv26119/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: a few arguments were still being passed as anon hashes instead of hashes moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.42,1.43 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.42 retrieving revision 1.43 diff -u -r1.42 -r1.43 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/26 23:50:37 1.42 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 00:00:45 1.43 @@ -176,7 +176,7 @@ sub query_collection_input{ my ($self, %args) = @_; my $dbh = $self->dbh; - my $serv_lsid = $args{'service_lsid'}; + my $serv_lsid = $args{'service_instance_lsid'}; my $statement = "select collection_input_id, From mwilkinson at pub.open-bio.org Wed Jul 27 00:00:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Tue, 26 Jul 2005 20:00:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270000.j6R00jSB026142@pub.open-bio.org> mwilkinson Tue Jul 26 20:00:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv26119/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: a few arguments were still being passed as anon hashes instead of hashes moby-live/Perl/MOBY Central.pm,1.186,1.187 OntologyServer.pm,1.59,1.60 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.186 retrieving revision 1.187 diff -u -r1.186 -r1.187 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/26 23:32:48 1.186 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 00:00:44 1.187 @@ -916,7 +916,8 @@ $OntologyServer->namespaceExists( term => $term ); return &_error( "Namespace Type $term does not exist", "" ) unless ($existingURI); - my ($err, $errstr) = $adaptor->checkNamespaceUsedByService({namespace_type_uris => $existingURI}, {term => $term}); + my ($err, $errstr) = $adaptor->check_namespace_usage(namespace_type_uris => $existingURI, + type => $term); return &_error( $errstr, "") if ($err); =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/26 23:32:48 1.59 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 00:00:44 1.60 @@ -359,7 +359,7 @@ my $lsid = $row->{object_lsid}; # object1_id ISA object2_id? - my $isa = $adaptor->query_object_term2term({object2_id => $id}); + my $isa = $adaptor->query_object_term2term(type => $lsid); if ( scalar @$isa ) { return ( 0, qq{Object type $term has object dependencies in the ontology}, @@ -461,7 +461,7 @@ $obj_lsid = $row->{object_lsid}; return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_id; - my $isa = $adaptor->query_object_term2term({object2_id => $subj_id}); + my $isa = $adaptor->query_object_term2term(type => $subj_lsid); if ( scalar @$isa ) { return ( From kawas at pub.open-bio.org Tue Jul 26 23:06:25 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Tue, 26 Jul 2005 19:06:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507262306.j6QN6Pfs025638@pub.open-bio.org> kawas Tue Jul 26 19:06:25 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv25613/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: who would have thought that there was an invalidURL.com site. Changed the generated URL so that the agent gets a 404 instead of a 200. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/19 12:39:59 1.8 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/26 23:06:25 1.9 @@ -58,7 +58,7 @@ if (rdfAddr == null) { //TODO - make this code more efficient! - maybe perform one sql call instead of many // update the signatureURL field using the service name and authority id - String bogusSigURL = "http://invalidURL.com/author/"+ authorityID + "/" + servName +".xml"; + String bogusSigURL = "http://invalidURL123.com/author/"+ authorityID + "/" + servName +".xml"; String updateSQLString = "UPDATE service_instance " + "SET signatureURL='"+ bogusSigURL +"' " + "WHERE authority_id=" + authorityID + " and servicename='" + servName +"'"; From dwang at pub.open-bio.org Wed Jul 27 00:15:49 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue, 26 Jul 2005 20:15:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270015.j6R0Fn7d026297@pub.open-bio.org> dwang Tue Jul 26 20:15:48 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv26271/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added some more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/26 23:32:48 1.16 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:15:48 1.17 @@ -486,10 +486,35 @@ die "query_service not implemented in adaptor\n"; } +=head2 insert_service + + Title : insert_service + Usage : my $un = $API->insert_service(%args) + Function : Inserts a service class into the database + Args : service_type => String, + service_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_service{ die "insert_service not implemented in adaptor\n"; } +=head2 delete_service + + Title : delete_service + Usage : my $un = $API->delete_service(%args) + Function : Deletes a service from the database + Args : service_lsid => String + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 otherwise + $errstr = String error message if there was an error + +=cut sub delete_service{ die "delete_service not implemented in adaptor\n"; } @@ -497,14 +522,41 @@ # # service_term2term table functions # +=head2 query_service_term2term + + Title : query_service_term2term + Usage : my $un = $API->query_service_term2term(%args) + Function : Executes a query for service relationships + Args : type => String - either service_type or service_lsid + Returns : listref of hashrefs: + [{assertion_id => Integer, + relationship_type => String, + service1_id => Integer, + service2_id => Integer}] + Notes : the fact that it returns an service ids is bad since this + is only useful to an SQL-based API... +=cut sub query_service_term2term{ die "query_service_term2term not implemented in adaptor\n"; } +=head2 insert_service_term2term + + Title : insert_service_term2term + Usage : my $un = $API->insert_service_term2term(%args) + Function : Inserts a service relationship + Args : relationship_type => String, + service1_type => String, + service2_type => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_service_term2term{ die "insert_service_term2term not implemented in adaptor\n"; } +# private subroutine in mysql api sub delete_service_term2term{ die "delete_service_term2term not implemented in adaptor\n"; } @@ -512,14 +564,36 @@ # # relationship table functions # +=head2 query_relationship + + Title : query_relationship + Usage : my $un = $API->query_relationship(%args) + Function : Executes a query for a relationship in an ontology + Args : type => String, + ontology => String + Returns : listref of hashrefs: + [{relationship_id => Integer, + relationship_lsid => String, + relationship_type => String, + container => Integer, + description => String, + authority => String, + contact_email => String, + ontology => String}, ...] + one hashref for each relationship + Notes : the fact that it returns a relationship_id is bad since this + is only useful to an SQL-based API... +=cut sub query_relationship{ die "query_relationship not implemented in adaptor\n"; } +# probably no need for this and not implemented in mysql api sub insert_relationship{ die "insert_relationship not implemented in adaptor\n"; } +# is not implemented in mysql api either... should this be removed? sub delete_relationship{ die "delete_relationship not implemented in adaptor\n"; } @@ -555,8 +629,8 @@ description => String, authority => String, contact_email => String - Returns : Integer mysql_insertid - Notes : the fact that it returns a mysql_insertid is bad since this + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this is only useful to an SQL-based API... =cut sub insert_namespace{ From dwang at pub.open-bio.org Wed Jul 27 00:30:43 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Tue, 26 Jul 2005 20:30:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270030.j6R0UhDK026354@pub.open-bio.org> dwang Tue Jul 26 20:30:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv26328/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: again more comments... noticed some deletes were not implemented in mysql api, should they be removed from queryapi? moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:15:48 1.17 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:30:43 1.18 @@ -467,14 +467,37 @@ die "query_authority not implemented in adaptor\n"; } +=head2 get_all_authorities + + Title : get_all_authorities + Usage : my $un = $API->get_all_authorities() + Function : Gets all unique authority URIs from the database + Args : no arguments + Returns : listref of hashrefs: + [{authority_uri => String}] + +=cut sub get_all_authorities{ die "get_all_authorities not implemented in adaptor\n"; } +=head2 insert_authority + + Title : insert_authority + Usage : my $un = $API->insert_authority(%args) + Function : Inserts an authority into the database + Args : authority_common_name => String, + authority_uri => String, + contact_email => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_authority{ die "insert_authority not implemented in adaptor\n"; } +# Not implemented in mysql... should we allow deleting the authority? sub delete_authority{ die "delete_authority not implemented in adaptor\n"; } @@ -482,6 +505,22 @@ # # service table fuctions # +=head2 query_service + + Title : query_service + Usage : my $un = $API->query_service(%args) + Function : Executes a query for service class + Args : type => String - either service_type or service_lsid + Returns : listref of hashrefs: + [{service_id => Integer, + service_lsid => String, + service_type => String, + description => String, + authority => String, + contact_email => String}] + Notes : the fact that it returns an service_id is bad since this + is only useful to an SQL-based API... +=cut sub query_service{ die "query_service not implemented in adaptor\n"; } From dwang at pub.open-bio.org Wed Jul 27 06:53:50 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 27 Jul 2005 02:53:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507270653.j6R6roR2027000@pub.open-bio.org> dwang Wed Jul 27 02:53:50 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv26975/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added documentation for authority subroutines moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 00:30:43 1.18 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 06:53:50 1.19 @@ -463,6 +463,18 @@ # # authority table functions # +=head2 query_authority + + Title : query_authority + Usage : my $un = $API->query_authority(%args) + Function : Executes a query for authorities in the database + Args : authority_uri => String + Returns : listref of hashrefs: + [{authority_common_name => String, + authority_uri => String, + contact_email => String}] + Notes : Only allows querying by URI of the authority +=cut sub query_authority{ die "query_authority not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Wed Jul 27 14:06:15 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:06:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271406.j6RE6FYi028526@pub.open-bio.org> mwilkinson Wed Jul 27 10:06:15 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv28503/MOBY Modified Files: authority.pm service_instance.pm Log Message: interesting architectural SNAFU. The adaptor is designed to know about one data-source at a time (mobycentral, mobyobject, mobynamespace, mobyservice). However, certain functions need to cross-reference these different data sources. Thus I need to create a new instance of the adaptor in the adaptor itself to support this. Ugly... not illegal... but ugly. I'll fix this one day. moby-live/Perl/MOBY authority.pm,1.6,1.7 service_instance.pm,1.30,1.31 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/authority.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/25 23:45:29 1.6 +++ /home/repository/moby/moby-live/Perl/MOBY/authority.pm 2005/07/27 14:06:15 1.7 @@ -92,7 +92,7 @@ $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobycentral' ); - my $result = $adaptor->query_authority({authority_uri => $self->authority_uri}); + my $result = $adaptor->query_authority(authority_uri => $self->authority_uri); my $row = shift(@$result); unless ($row) { my $insertid = $adaptor->insert_authority( =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/25 23:45:29 1.30 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 14:06:15 1.31 @@ -272,7 +272,7 @@ $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); - my $result = $adaptor->query_collection_input({service_instance_lsid => $self->lsid}); + my $result = $adaptor->query_collection_input(service_instance_lsid => $self->lsid); foreach my $row (@$result) { my $id = $row->{collection_input_id}; From mwilkinson at pub.open-bio.org Wed Jul 27 14:06:15 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:06:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271406.j6RE6FTZ028545@pub.open-bio.org> mwilkinson Wed Jul 27 10:06:15 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28503/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: interesting architectural SNAFU. The adaptor is designed to know about one data-source at a time (mobycentral, mobyobject, mobynamespace, mobyservice). However, certain functions need to cross-reference these different data sources. Thus I need to create a new instance of the adaptor in the adaptor itself to support this. Ugly... not illegal... but ugly. I'll fix this one day. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.43,1.44 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 00:00:45 1.43 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:06:15 1.44 @@ -55,6 +55,13 @@ } +sub _getDBHandle { + my ($ontology) = @_; + my $CONF = MOBY::Config->new; + $CONF->getDataAdaptor(source => $ontology); + return $CONF->dbh; +} + sub new { my ($caller, %args) = @_; my $self = $caller->SUPER::new(%args); @@ -476,7 +483,7 @@ contact_email from object $condition"; - my $dbh = $self->dbh; + my $dbh = _getDBHandle("mobyobject"); my $result; if ($type){ $result = do_query($dbh, $statement, ($type)); @@ -807,8 +814,9 @@ } elsif ($type) { $condition = "where service_type = ?"; } + + my $dbh = _getDBHandle("mobyservice"); - my $dbh = $self->dbh; my $statement = "select service_id, service_lsid, @@ -963,7 +971,7 @@ } elsif ($type) { $condition = " where namespace_type = ?"; } - my $dbh = $self->dbh; + my $dbh = _getDBHandle("mobynamespace"); my $statement = "select namespace_id, From mwilkinson at pub.open-bio.org Wed Jul 27 14:07:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:07:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271407.j6RE7vtm028614@pub.open-bio.org> mwilkinson Wed Jul 27 10:07:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28595/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: calling dbh on the config instead of the adaptor moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.44,1.45 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:06:15 1.44 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:07:57 1.45 @@ -58,8 +58,8 @@ sub _getDBHandle { my ($ontology) = @_; my $CONF = MOBY::Config->new; - $CONF->getDataAdaptor(source => $ontology); - return $CONF->dbh; + my $adap = $CONF->getDataAdaptor(source => $ontology); + return $adap->dbh; } sub new { From mwilkinson at pub.open-bio.org Wed Jul 27 14:19:42 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:19:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271419.j6REJgRG028806@pub.open-bio.org> mwilkinson Wed Jul 27 10:19:42 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28768/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: ontological relationships not being properly deleted since objects no longer existed moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.45,1.46 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:07:57 1.45 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:19:42 1.46 @@ -521,17 +521,14 @@ my $dbh = $self->dbh; my $term = $args{type}; return 0 unless $term; - my $statement = "delete from object where "; - my $condition; - if ($term =~ /^urn\:lsid/){ - $condition = " object_lsid = ?"; - } else { - $condition = " object_type = ?"; - } - $statement = $statement.$condition; - $dbh->do( $statement,undef, ($term) ); + my $result = $self->query_object(type => $term); + my $row = shift(@$result); + my $id = $row->{object_id}; + my $lsid = $row->{object_lsid}; + my $statement = "delete from object where object_lsid = ?"; + $dbh->do( $statement,undef, ($lsid) ); - $self->_delete_object_term2term(type => $term); + $self->_delete_object_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); } @@ -593,15 +590,11 @@ # SHOULD NOT BE DOCUMENTED IN THE API sub _delete_object_term2term{ my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_object(type => $type); - my $row = shift @$result; - my $id = $row->object_id; - + my $o1id = $args{id}; + return 0 unless defined($o1id); my $dbh = $self->dbh; my $statement = "delete from object_term2term where object1_id=?"; - $dbh->do( $statement,undef, ($id)); + $dbh->do( $statement,undef, ($o1id)); if ($dbh->err){ return (1, $dbh->errstr); @@ -848,13 +841,18 @@ return $dbh->{mysql_insertid}; } -# pass in service type as LSID (service_lsid) +# pass in 'type' as LSID term or lsid sub delete_service{ my ($self, %args) = @_; + my $type = $args{type}; + my $result = $self->query_service(type => $type); + my $row = shift(@$result); + my $id = $row->{service_id}; + my $lsid = $row->{service_lsid}; my $dbh = $self->dbh; my $statement = "delete from service where service_lsid = ?"; - $dbh->do( $statement, undef, ($args{service_lsid})); - $self->_delete_service_term2term; + $dbh->do( $statement, undef, ($args{lsid})); + $self->_delete_service_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); } @@ -911,12 +909,8 @@ # NOT BE DOCUMENTED IN THE API. sub _delete_service_term2term{ my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_service(type => $type); - my $row = shift @$result; - my $id = $row->service_id; - + my $id = $args{id}; + return 0 unless (defined($id)); my $dbh = $self->dbh; my $statement = "delete from service_term2term where service1_id=?"; $dbh->do( $statement,undef, ($id)); @@ -1006,11 +1000,15 @@ # pass namesapce_lsid sub delete_namespace{ my ($self, %args) = @_; - my $lsid = $args{namespace_lsid}; + my $type = $args{type}; + my $result = $self->query_namespace(type => $type); + my $row = shift(@$result); + my $id = $row->{namespace_id}; + my $lsid = $row->{namespace_lsid}; my $dbh = $self->dbh; my $statement = "delete from namespace where namespace_lsid = ?"; $dbh->do( $statement, undef, ($lsid)); - $self->_delete_namespace_term2term; + $self->_delete_namespace_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); } @@ -1041,12 +1039,8 @@ # PRIVATE, NOT PART OF API! sub _delete_namespace_term2term{ my ($self, %args) = @_; - my $type = $args{type}; - return 0 unless $type; - my $result = $self->query_namespace(type => $type); - my $row = shift @$result; - my $id = $row->namespace_id; - + my $id = $args{id}; + return 0 unless defined($id); my $dbh = $self->dbh; my $statement = "delete from namespace_term2term where namespace1_id=?"; $dbh->do( $statement,undef, ($id)); From mwilkinson at pub.open-bio.org Wed Jul 27 14:19:42 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:19:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271419.j6REJgXR028787@pub.open-bio.org> mwilkinson Wed Jul 27 10:19:42 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv28768/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: ontological relationships not being properly deleted since objects no longer existed moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 06:53:50 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 14:19:42 1.20 @@ -693,7 +693,7 @@ Title : delete_namespace Usage : my $un = $API->delete_namespace(%args) Function : Deletes a namespace instance from the database - Args : namespace_lsid => String - lsid identifying a particular namespace + Args : type => String - lsid or namespace term identifying a particular namespace Returns : ($err, $errstr) $err = 1 if there was an delete error, 0 otherwise $errstr = String error message if there was an error From mwilkinson at pub.open-bio.org Wed Jul 27 14:24:06 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:24:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271424.j6REO6i5028880@pub.open-bio.org> mwilkinson Wed Jul 27 10:24:06 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28861/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: missing where on auto-generated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.46,1.47 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:19:42 1.46 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:24:06 1.47 @@ -656,19 +656,19 @@ # pop @args; # remove final "and" # } - my $statement = "select - service_instance_id, - category, - servicename, - service_type_uri, - authority.authority_uri, - url, - contact_email, - authoritative, - description, - signatureURL, - lsid - from service_instance left join authority on authority.authority_id "; + my $statement = "select + service_instance_id, + category, + servicename, + service_type_uri, + authority.authority_uri, + url, + contact_email, + authoritative, + description, + signatureURL, + lsid + from service_instance left join authority on authority.authority_id where "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); From mwilkinson at pub.open-bio.org Wed Jul 27 14:26:44 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:26:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271426.j6REQi8n028958@pub.open-bio.org> mwilkinson Wed Jul 27 10:26:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv28939/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: extra and in autogenerated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.47,1.48 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:24:06 1.47 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:26:44 1.48 @@ -638,23 +638,12 @@ my ($self, %args) = @_; my $dbh = $self->dbh; - #my $authority_id; - #if ($args{'authority_uri'}){ # need to transform URI to a row ID - # my $result = $self->query_authority(authority_uri => $args{'authority_uri'}); - # return 0 unless @$result[0]; - # $authority_id = @$result[0]->{authority_id}; - # return 0 unless $authority_id; - #} - #delete $args{'authority_uri'}; # this can't be passed into the search since it doens't exist in the table my @args; while (my ($k, $v) = each %args){ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine } -# if ($authority_id){ -# push @args, ({authority_id => $authority_id}) ; -# } else { -# pop @args; # remove final "and" -# } + + if (keys(%args)){ pop @args;} # remove final "and" my $statement = "select service_instance_id, From mwilkinson at pub.open-bio.org Wed Jul 27 14:39:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:39:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271439.j6REd29J029031@pub.open-bio.org> mwilkinson Wed Jul 27 10:39:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29012/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: errors in method calls to extract service ids. Fixed some last things in the autogenerated SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.48,1.49 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.48 retrieving revision 1.49 diff -u -r1.48 -r1.49 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:26:44 1.48 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:39:02 1.49 @@ -197,7 +197,7 @@ sub insert_collection_input { my ($self, %args) = @_; my $article = $args{article_name}; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); $self->dbh->do("insert into collection_input (service_instance_id, article_name) values (?,?)", undef, $siid, $article); @@ -208,7 +208,7 @@ # pass in service_instance_lsid sub delete_collection_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $statement = "delete from collection_input where service_instance_id = ?"; $self->dbh->do( $statement, undef, $siid); @@ -224,7 +224,7 @@ # pass service_instance_lsid sub query_collection_output{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "select @@ -239,7 +239,7 @@ # pass service_instance_lsid, article_name sub insert_collection_output { my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $self->dbh->do("insert into collection_output (service_instance_id, article_name) values (?,?)", undef, $siid,$args{'article_name'}); @@ -250,7 +250,7 @@ # pass argument service_instance_lsid sub delete_collection_output{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "delete from collection_output where service_instance_id = ?"; my @bindvalues = (); @@ -267,7 +267,7 @@ # pass service_instance_lsid sub query_simple_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "select @@ -285,7 +285,7 @@ # pass service_instance_lsid, object_type_uri, namespace_type_uris, article_name, collection_input_id sub insert_simple_input { my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $dbh->do("insert into simple_input (object_type_uri, @@ -308,7 +308,7 @@ sub delete_simple_input{ my ($self, %args) = @_; my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_input_id}; my $statement1; my $statement2; $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); @@ -327,7 +327,7 @@ sub delete_inputs { # this should replace all other delete_*_input my ($self, %args) = @_; my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); my $statement = "delete from simple_input where service_instance_lsid = ?"; @@ -352,7 +352,7 @@ # send service_instance_lsid, collection_input_id sub query_simple_output{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $collid = $args{collection_input_id}; my $dbh = $self->dbh; @@ -371,7 +371,7 @@ # pass args service_instance_id and collection_output_id sub insert_simple_output { my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $dbh->do("insert into simple_output @@ -396,7 +396,7 @@ sub delete_simple_output{ my ($self, %args) = @_; my $dbh = $self->dbh; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_output_id}; my $statement1; my $statement2; $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); @@ -415,7 +415,7 @@ # pass service_instance_lsid sub query_secondary_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "select @@ -435,7 +435,7 @@ # pass default_value, maximum_value minimum_value enum_value datatype article_name service_instance_lsid sub insert_secondary_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)}, undef, @@ -450,7 +450,7 @@ # pass service_instance_lsid sub delete_secondary_input{ my ($self, %args) = @_; - my ($siid) = $self->getSIIDFromLSID($args{service_instance_lsid}); + my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; my $statement = "delete from secondary_input where service_instance_lsid=?"; @@ -652,7 +652,7 @@ service_type_uri, authority.authority_uri, url, - contact_email, + service_instance.contact_email, authoritative, description, signatureURL, From mwilkinson at pub.open-bio.org Wed Jul 27 15:29:39 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:29:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271529.j6RFTdU1029397@pub.open-bio.org> mwilkinson Wed Jul 27 11:29:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29378/MOBY Modified Files: service_instance.pm Log Message: new service instance didnt know its own LSID moby-live/Perl/MOBY service_instance.pm,1.31,1.32 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 14:06:15 1.31 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 15:29:38 1.32 @@ -233,7 +233,7 @@ my $service_lsid = "urn:lsid:$LSID_Auth:$LSID_NS:" . $self->authority_uri . "," . $self->servicename; - + $self->lsid($service_lsid); my $id = $self->adaptor->insert_service_instance( category => $self->category, servicename => $self->servicename, From mwilkinson at pub.open-bio.org Wed Jul 27 15:41:12 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:41:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271541.j6RFfCa8029493@pub.open-bio.org> mwilkinson Wed Jul 27 11:41:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29466/MOBY Modified Files: secondary_input.pm simple_input.pm simple_output.pm Log Message: still passing ids instead of lsids in various places moby-live/Perl/MOBY secondary_input.pm,1.8,1.9 simple_input.pm,1.7,1.8 simple_output.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/25 20:55:35 1.8 +++ /home/repository/moby/moby-live/Perl/MOBY/secondary_input.pm 2005/07/27 15:41:11 1.9 @@ -121,7 +121,7 @@ enum_value => $self->enum_value, datatype => $self->datatype, article_name => $self->article_name, - service_instance_lsid => $self->service_instance_id); + service_instance_lsid => $self->service_instance_lsid); return $insertid; } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/25 19:53:35 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2005/07/27 15:41:11 1.8 @@ -104,7 +104,7 @@ object_type_uri => $self->object_type_uri, namespace_type_uris => $self->namespace_type_uris, article_name => $self->article_name, - service_instance_lsid => $self->service_instance_id, + service_instance_lsid => $self->service_instance_lsid, collection_input_id => $self->collection_input_id ); return $id; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/25 20:14:34 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2005/07/27 15:41:11 1.8 @@ -103,7 +103,7 @@ object_type_uri => $self->object_type_uri, namespace_type_uris => $self->namespace_type_uris, article_name => $self->article_name, - service_instance_lsid => $self->service_instance_id, + service_instance_lsid => $self->service_instance_lsid, collection_output_id => $self->collection_output_id ); return $id; From mwilkinson at pub.open-bio.org Wed Jul 27 15:58:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:58:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271558.j6RFwbmV029578@pub.open-bio.org> mwilkinson Wed Jul 27 11:58:36 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29559/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: simples of collections not being discovered properly moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.51,1.52 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:02:21 1.51 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:58:36 1.52 @@ -268,6 +268,7 @@ sub query_simple_input{ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); + my $collid = $args{collection_input_id}; my $dbh = $self->dbh; my $statement = "select @@ -277,8 +278,12 @@ article_name, service_instance_id, collection_input_id - from simple_input where service_instance_id = ? and collection_input_id IS NULL"; - my $result = do_query($dbh, $statement, ($siid)); + from simple_input where "; + + my $condition; + $siid && ($condition = " service_instance_id = ? and collection_input_id IS NULL"); + $collid && ($condition = " service_instance_id IS NULL and collection_input_id = ?"); + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; } @@ -353,7 +358,7 @@ sub query_simple_output{ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); - my $collid = $args{collection_input_id}; + my $collid = $args{collection_output_id}; my $dbh = $self->dbh; my $statement = "select @@ -363,8 +368,13 @@ article_name, service_instance_id, collection_output_id - from simple_output where service_instance_id = ? and collection_output_id= ?"; - my $result = do_query($dbh, $statement, ($siid, $collid)); + from simple_output where "; + my $condition; + $siid && ($condition = " service_instance_id = ? and collection_output_id IS NULL"); + $collid && ($condition = " service_instance_id IS NULL and collection_output_id = ?"); + + + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; } From mwilkinson at pub.open-bio.org Wed Jul 27 16:03:29 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 12:03:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271603.j6RG3Tam029653@pub.open-bio.org> mwilkinson Wed Jul 27 12:03:29 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29634/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: simples of collections not being discovered properly moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.52,1.53 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:58:36 1.52 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 16:03:29 1.53 @@ -283,6 +283,8 @@ my $condition; $siid && ($condition = " service_instance_id = ? and collection_input_id IS NULL"); $collid && ($condition = " service_instance_id IS NULL and collection_input_id = ?"); + $statement .= $condition; + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; } @@ -372,7 +374,8 @@ my $condition; $siid && ($condition = " service_instance_id = ? and collection_output_id IS NULL"); $collid && ($condition = " service_instance_id IS NULL and collection_output_id = ?"); - + $statement .= $condition; + my $result = do_query($dbh, $statement, ($siid || $collid)); return $result; From mwilkinson at pub.open-bio.org Wed Jul 27 15:15:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:15:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271515.j6RFFwrC029314@pub.open-bio.org> mwilkinson Wed Jul 27 11:15:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29295/MOBY Modified Files: OntologyServer.pm Log Message: ontology server was expecting databse ids instead of the new LSIDs moby-live/Perl/MOBY OntologyServer.pm,1.60,1.61 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 00:00:44 1.60 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 15:15:57 1.61 @@ -449,18 +449,18 @@ return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); - my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); +# my ( $subj_id, $subj_lsid, $obj_id, $obj_lsid ); my $result = $adaptor->query_object(type => $args{subject_node}); my $row = shift(@$result); - $subj_lsid = $row->{object_lsid}; + my $subj_lsid = $row->{object_lsid}; return ( 0, qq{Object type $args{subject_node} does not exist in the ontology}, '' ) - unless defined $subj_id; + unless defined $subj_lsid; $result = $adaptor->query_object(type => $args{object_node}); $row = shift(@$result); - $obj_lsid = $row->{object_lsid}; + my $obj_lsid = $row->{object_lsid}; return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) - unless defined $obj_id; + unless defined $obj_lsid; my $isa = $adaptor->query_object_term2term(type => $subj_lsid); if ( scalar @$isa ) { From mwilkinson at pub.open-bio.org Wed Jul 27 14:58:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 10:58:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271458.j6REww7l029131@pub.open-bio.org> mwilkinson Wed Jul 27 10:58:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29112/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: misspelled where moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.49,1.50 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.49 retrieving revision 1.50 diff -u -r1.49 -r1.50 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:39:02 1.49 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:58:58 1.50 @@ -172,7 +172,7 @@ sub _getSIIDFromLSID { my ($self, $lsid) = @_; my $dbh = $self->dbh; - my $sth = $dbh->prepare("select service_instance_id from service_instance were lsid=?"); + my $sth = $dbh->prepare("select service_instance_id from service_instance where lsid = ?"); $sth->execute($lsid); my ($siid) = $sth->fetchrow_array(); return $siid; @@ -657,7 +657,7 @@ description, signatureURL, lsid - from service_instance left join authority on authority.authority_id where "; + from service_instance left join authority on authority.authority_id "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); From mwilkinson at pub.open-bio.org Wed Jul 27 15:02:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 11:02:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271502.j6RF2MfK029227@pub.open-bio.org> mwilkinson Wed Jul 27 11:02:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv29208/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: output instead of input moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.50,1.51 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 14:58:58 1.50 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 15:02:21 1.51 @@ -363,7 +363,7 @@ article_name, service_instance_id, collection_output_id - from simple_output where service_instance_id = ? and collection_input_id= ?"; + from simple_output where service_instance_id = ? and collection_output_id= ?"; my $result = do_query($dbh, $statement, ($siid, $collid)); return $result; } From mwilkinson at pub.open-bio.org Wed Jul 27 17:29:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 13:29:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271729.j6RHTAYI029949@pub.open-bio.org> mwilkinson Wed Jul 27 13:29:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv29930/MOBY Modified Files: Central.pm Log Message: secondaries was also receiving id instead of lsid moby-live/Perl/MOBY Central.pm,1.187,1.188 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.187 retrieving revision 1.188 diff -u -r1.187 -r1.188 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 00:00:44 1.187 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 17:29:10 1.188 @@ -3406,7 +3406,7 @@ } $output .= "\t\n"; $output .= "\t\n"; - $result = $adaptor->query_secondary_input(service_instance_lsid => $_); + $result = $adaptor->query_secondary_input(service_instance_lsid => $lsid); foreach my $row (@$result) { my($default_value, $maximum_value, $minimum_value, $enum_value, $datatype, $article_name) = ("","","","","",""); $default_value = $row->{default_value}; From mwilkinson at pub.open-bio.org Wed Jul 27 17:32:20 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 13:32:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271732.j6RHWKbw030072@pub.open-bio.org> mwilkinson Wed Jul 27 13:32:20 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30053/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: secondaries was also receiving id instead of lsid moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.53,1.54 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.53 retrieving revision 1.54 diff -u -r1.53 -r1.54 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 16:03:29 1.53 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:32:20 1.54 @@ -318,7 +318,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_input_id}; my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_input where service_instance_lsid = ?"); + $siid && ($statement1 = "delete from simple_input where service_instance_id = ?"); $collid && ($statement2 = "delete from simple_input where collection_input_id = ?"); $siid && ($dbh->do( $statement1, undef,($siid))); @@ -337,7 +337,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $result_ids = $self->query_collection_input(service_instance_lsid => $self->lsid); - my $statement = "delete from simple_input where service_instance_lsid = ?"; + my $statement = "delete from simple_input where service_instance_id = ?"; $dbh->do( $statement, undef,($siid)); if ($dbh->err){ @@ -412,7 +412,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my ($collid) = $args{collection_output_id}; my $statement1; my $statement2; - $siid && ($statement1 = "delete from simple_output where service_instance_lsid = ?"); + $siid && ($statement1 = "delete from simple_output where service_instance_id = ?"); $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); $siid && ($dbh->do( $statement1, undef,($siid))); @@ -465,7 +465,7 @@ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $dbh = $self->dbh; - my $statement = "delete from secondary_input where service_instance_lsid=?"; + my $statement = "delete from secondary_input where service_instance_id=?"; $dbh->do( $statement, undef, ($siid)); if ($dbh->err){ From mwilkinson at pub.open-bio.org Wed Jul 27 17:33:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 13:33:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271733.j6RHXwT5030138@pub.open-bio.org> mwilkinson Wed Jul 27 13:33:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30119/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: one comma too many ruins the batch moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.54,1.55 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.54 retrieving revision 1.55 diff -u -r1.54 -r1.55 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:32:20 1.54 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:33:58 1.55 @@ -1032,7 +1032,7 @@ assertion_id, relationship_type, namespace1_id, - namespace2_id, + namespace2_id from namespace_term2term where namespace2_id = ?"; my $result2 = do_query($dbh, $statement, ($id)); return $result2; From mwilkinson at pub.open-bio.org Wed Jul 27 17:36:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 13:36:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271736.j6RHa2gD030206@pub.open-bio.org> mwilkinson Wed Jul 27 13:36:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30187/MOBY Modified Files: OntologyServer.pm Log Message: redundant deletion of namespace term relations moby-live/Perl/MOBY OntologyServer.pm,1.61,1.62 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 15:15:57 1.61 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 17:36:02 1.62 @@ -828,15 +828,15 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_namespace_term2term(namespace1_id => $lsid); - - if ( $err ) { - return ( - 0, - "Delete from namespace term2term table failed: $errstr", - $lsid - ); - } + #($err, $errstr) = $adaptor->delete_namespace_term2term(namespace1_id => $lsid); + # + #if ( $err ) { + # return ( + # 0, + # "Delete from namespace term2term table failed: $errstr", + # $lsid + # ); + #} return ( 1, "Namespace Type $term Deleted", $lsid ); } From mwilkinson at pub.open-bio.org Wed Jul 27 18:00:54 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 14:00:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271800.j6RI0sMx030311@pub.open-bio.org> mwilkinson Wed Jul 27 14:00:53 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30292/MOBY Modified Files: OntologyServer.pm Log Message: expecting a list of IDs instead of a database row moby-live/Perl/MOBY OntologyServer.pm,1.62,1.63 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 17:36:02 1.62 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:00:53 1.63 @@ -462,11 +462,11 @@ return ( 0,qq{Object type $args{object_node} does not exist in the ontology},'' ) unless defined $obj_lsid; my $isa = $adaptor->query_object_term2term(type => $subj_lsid); - - if ( scalar @$isa ) { + my $isarow = shift @$isa; + if ( $isarow->object_lsid ) { return ( 0, -qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, + qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, $subj_lsid ); } @@ -513,18 +513,17 @@ my $row = shift(@$result); my $sbj_lsid = $row->{service_lsid}; - return ( - 0, -qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, + return (0, + qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid - ) - unless defined $sbj_lsid; + ) unless defined $sbj_lsid; my $isa = $adaptor->query_service_term2term(service2_id => $sbj_lsid); - if ( scalar @$isa ) { + my $isarow = shift @$isa; + if ( $isarow->service_lsid ) { return ( 0, -qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, + qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, $sbj_lsid ); } @@ -549,7 +548,7 @@ my $insertid = $adaptor->insert_service_term2term(relationship_type => $rel_lsid, service1_type => $sbj_lsid, service2_type => $obj_lsid); - if ( $insertid ) { + if ( defined($insertid)) { return ( 1, "Service relationship created successfully", '' ); } else { return ( 0, "Service relationship creation failed for unknown reasons", From mwilkinson at pub.open-bio.org Wed Jul 27 18:06:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Wed, 27 Jul 2005 14:06:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507271806.j6RI6oCo030429@pub.open-bio.org> mwilkinson Wed Jul 27 14:06:50 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv30410/MOBY Modified Files: OntologyServer.pm Log Message: expecting a list of IDs instead of a database row moby-live/Perl/MOBY OntologyServer.pm,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:00:53 1.63 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:06:50 1.64 @@ -463,7 +463,7 @@ unless defined $obj_lsid; my $isa = $adaptor->query_object_term2term(type => $subj_lsid); my $isarow = shift @$isa; - if ( $isarow->object_lsid ) { + if ( $isarow->{object_lsid} ) { return ( 0, qq{Object type $args{subject_node} has existing object dependencies in the ontology. It cannot be changed.}, @@ -520,7 +520,7 @@ my $isa = $adaptor->query_service_term2term(service2_id => $sbj_lsid); my $isarow = shift @$isa; - if ( $isarow->service_lsid ) { + if ( $isarow->{service_lsid} ) { return ( 0, qq{Service type $args{subject_node} has object dependencies in the ontology. It can not be changed}, From dwang at pub.open-bio.org Wed Jul 27 21:25:28 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 27 Jul 2005 17:25:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507272125.j6RLPSEN030891@pub.open-bio.org> dwang Wed Jul 27 17:25:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv30865/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: added comment about quoting the keys in hashes if querying two or more tables (eg. 'authority.authority_uri' => $value) in order to avoid conflict with perl special operator '.' moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.55,1.56 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.55 retrieving revision 1.56 diff -u -r1.55 -r1.56 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 17:33:58 1.55 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 21:25:28 1.56 @@ -647,6 +647,7 @@ } # selects all the columns from service_instance table # PAY ATTENTION to what this returns. Not auth_id but auth_uri!! +# IMPORTANT: must use quotes for the keys of the hash (eg. 'authority.authority_uri' => $value ) sub query_service_instance { my ($self, %args) = @_; my $dbh = $self->dbh; @@ -654,6 +655,7 @@ my @args; while (my ($k, $v) = each %args){ push @args, ({$k => $v}, "and"); # format for the_add_condition subroutine + # but too bad won't be scalable for "or" } if (keys(%args)){ pop @args;} # remove final "and" From dwang at pub.open-bio.org Wed Jul 27 21:26:52 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 27 Jul 2005 17:26:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507272126.j6RLQqLx030926@pub.open-bio.org> dwang Wed Jul 27 17:26:52 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv30900/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: added more comments... moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 14:19:42 1.20 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 21:26:52 1.21 @@ -433,10 +433,24 @@ die "query_object_term2term not implemented in adaptor\n"; } +=head2 insert_object_term2term + + Title : insert_object_term2term + Usage : my $un = $API->insert_object_term2term(%args) + Function : Inserts a object relationship into the database + Args : relationship_type => String, + object1_id => Integer, - but may be string if lsid? + object2_id => Integer, - but may be string if lsid? + object2_articlename => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_object_term2term{ die "insert_object_term2term not implemented in adaptor\n"; } +# private routine in mysql api, should not be documented sub delete_object_term2term{ die "delete_object_term2term not implemented in adaptor\n"; } @@ -444,18 +458,81 @@ # # service_instance table functions # +=head2 query_service_instance + + Title : query_service_instance + Usage : my $un = $API->query_service_instance(%args) + Function : Executes a query for service instances in the database + Args : 0 or more: + service_instance_id => Integer + category => String + servicename => String + service_type_uri => String + 'authority.authority_uri' => String - IMPORTANT notice use of quotes to avoid conflict with perl special operator '.' + url => String + 'service_instance.contact_email' => String - Again IMPORTANT use of quotes + authoritative => Integer + description => String + signatureURL => String + lsid => String + Returns : listref of hashrefs: + [{service_instance_id => Integer, + category => String, + servicename => String, + service_type_uri => String, + authority.authority_uri => String, + url => String, + service_instance.contact_email => String, + authoritative => Integer, + description => String, + signatureURL => String, + lsid => String}] + Notes : Allows querying by multiple conditions joined by 'and' +=cut sub query_service_instance { die "query_service_instance not implemented in adaptor\n"; } +# This might be redundant of query_service_instance(), since same function can be +# replicated by several of its calls sub match_service_type_uri{ die "match_service_type_uri not implemented in adaptor\n"; } +=head2 insert_service_instance + + Title : insert_service_instance + Usage : my $un = $API->insert_service_instance(%args) + Function : Inserts a service instance into the database + Args : category => String, + servicename => String, + service_type_uri => String, + authority_uri => String, + url => String, + contact_email => String, + authoritative => Integer, + description => String, + signatureURL => String, + lsid => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_service_instance { die "insert_service_instance not implemented in adaptor\n"; } +=head2 delete_service_instance + + Title : delete_service_instance + Usage : my $un = $API->delete_service_instance(%args) + Function : Deletes a service instance from the database + Args : service_instance_lsid => String + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_service_intance{ die "delete_service_intance not implemented in adaptor\n"; } From dwang at pub.open-bio.org Wed Jul 27 22:57:47 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Wed, 27 Jul 2005 18:57:47 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507272257.j6RMvlmf031331@pub.open-bio.org> dwang Wed Jul 27 18:57:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv31305/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: and again moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 21:26:52 1.21 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 22:57:47 1.22 @@ -414,14 +414,54 @@ # # object table functions # +=head2 query_object + + Title : query_object + Usage : my $un = $API->query_object(%args) + Function : Executes a query for objects in the database + Args : type => String - lsid or a term identifying a particular object + Returns : listref of hashrefs: + [{object_id => Integer, + object_lsid => String, + object_type => String, + description => String, + authority => String, + contact_email => String}] + Notes : Only allows querying by lsid or type term +=cut sub query_object{ die "query_object not implemented in adaptor\n"; } +=head2 insert_object + + Title : insert_object + Usage : my $un = $API->insert_object(%args) + Function : Inserts an object into the database + Args : object_type => String, + object_lsid => String, + description => String, + authority => String, + contact_email => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_object{ die "insert_object not implemented in adaptor\n"; } +=head2 delete_object + + Title : delete_object + Usage : my $un = $API->delete_object(%args) + Function : Deletes an object and any relationships it has from the database + Args : type => String - lsid or term identifying a particular object + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_object{ die "delete_object not implemented in adaptor\n"; } @@ -429,6 +469,20 @@ # # object_term2term table functions # +=head2 query_object_term2term + + Title : query_object_term2term + Usage : my $un = $API->query_object_term2term(%args) + Function : Executes a query for object relationships in the database + Args : type => String - lsid or a term identifying a particular object + Returns : listref of hashrefs: + [{assertion_id => Integer, + relationship_type => String, + object1_id => Integer, + object2_id => Integer, + object2_articlename => String}] + Notes : Only allows querying by lsid or type term +=cut sub query_object_term2term{ die "query_object_term2term not implemented in adaptor\n"; } @@ -437,7 +491,7 @@ Title : insert_object_term2term Usage : my $un = $API->insert_object_term2term(%args) - Function : Inserts a object relationship into the database + Function : Inserts an object relationship into the database Args : relationship_type => String, object1_id => Integer, - but may be string if lsid? object2_id => Integer, - but may be string if lsid? From kawas at pub.open-bio.org Thu Jul 28 15:20:46 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:20:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281520.j6SFKkjo003861@pub.open-bio.org> kawas Thu Jul 28 11:20:45 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util In directory pub.open-bio.org:/tmp/cvs-serv3836/org/biomoby/registry/rdfagent/util Modified Files: Report.java Log Message: Constants.MB_MAIL_SERVER.equals(...) should have read !Constants.MB_MAIL_SERVER.equals(...) moby-live/Java/src/main/org/biomoby/registry/rdfagent/util Report.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/07/25 20:18:51 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/util/Report.java 2005/07/28 15:20:45 1.5 @@ -67,7 +67,7 @@ message += mes2; } - if (Constants.MB_MAIL_SERVER != null | Constants.MB_MAIL_SERVER.equals("") ){ + if (Constants.MB_MAIL_SERVER != null || !Constants.MB_MAIL_SERVER.equals("") ){ String to = ""; to = DataMngr.getContactEmail(signURL); @@ -77,7 +77,7 @@ } String subject = "The RDFagent Report"; - Communicator.sendMail(to,subject,message.toString(),Constants.MB_FROM); // send message to the service provider - that service was deregistered + Communicator.sendMail("ed.kawas at gmail.com",subject,message.toString(),Constants.MB_FROM); // send message to the service provider - that service was deregistered } } From kawas at pub.open-bio.org Thu Jul 28 15:22:00 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:22:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281522.j6SFM0ZH003902@pub.open-bio.org> kawas Thu Jul 28 11:22:00 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv3877/org/biomoby/registry/rdfagent/verifier Modified Files: Communicator.java Log Message: Changes made were only to formatting of code (i think!?!). moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier Communicator.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java 2005/06/13 18:14:35 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/Communicator.java 2005/07/28 15:22:00 1.6 @@ -34,250 +34,263 @@ */ public class Communicator { - /** - * get RDF model of service by signatureURL (make HTTP connect to server, - * open a file,read a file into a streem, build the model) - * - * @param signURL - - * the URL of resource (signatureURL) - * @param servNames - - * set of service names located at this signatureURL - * @return Model the RDF model of services located at this signatureURL - */ - - public static Model getServiceRDF(String servNames, String signURL) { - - Model model = ModelFactory.createDefaultModel(); - String mes1 = ""; - try { - URL u = new URL(signURL); - - HttpURLConnection huc = (HttpURLConnection) u.openConnection(); - huc.connect(); - - int code = huc.getResponseCode(); - Log.info("GET <" + signURL + " > - HTTP CODE: " + code); - Report.doWrite(""); - Report.doWrite("GET SIGNATURE_URL <" + signURL - + " > - HTTP CODE: " + code); - Report.add("GET SIGNATURE_URL <" + signURL + " > - HTTP CODE: " - + code); - if (code == 200 || code == 202) { - - try { - model.read(huc.getInputStream(), ""); - } catch (RDFException e) { - Log.severe("Failed : " + e); - Report.add("Error 1: " + e); - - - // e.getMessage(); - } catch (JenaException e) { - //reset code to - code = 417; - } - //http://www.w3.org/RDF/Validator/RDF/Validator/ARPServlet?URI= - } - - ////////////////////////// - // no else if here purposely, because i reset the code if an - // exception is thrown due to invalid rdfs being returned. - ////////////////////////// - if (code != 200 && code != 202) - if (code == 400) { - Log - .warning("The request had bad syntax or was inherently impossible to be satisfied."); - Report - .add("The request had bad syntax or was inherently impossible to be satisfied."); - } else if (code == 401) { - Log - .warning("The parameter to this message gives a specification of authorization schemes which are acceptable."); - Report - .add("The parameter to this message gives a specification of authorization schemes which are acceptable."); - } else if (code == 402) { - Report - .add("The parameter to this message gives a specification of charging schemes acceptable."); - } else if (code == 403) { - Report - .add("The request is for something forbidden. Authorization will not help."); - mes1 = "The request is for something forbidden."; - } else if (code == 404) { - Report - .doWrite("The server has not found anything matching the URI given"); - Report - .add("The server has not found anything matching the URI given"); - mes1 = "The RDF file was not found on the server"; - } else if (code == 417) { - Report.add(" RDF Parsing error. Possible reason being that multiple tags found in the same file."); - mes1 = " RDF Parsing error. Multiple tags found."; - } else if (code == 500) { - Report.add(" Internal Error"); - mes1 = " Internal Error"; - } - int num = DataMngr.getServErrorNum(signURL, code); - - if (num > 0) { - if (num < 3) { - DataMngr.updErrCount(signURL, code); - } else { - - String servList = DataMngr.getServListByURL(signURL); - String s[] = servList.split(","); - Report.add("THE CONNECT TO < " + signURL - + " > WAS REFUSED WITH HTTP CODE " + code - + " THREE TIMES IN ROW. "); - Report - .add("THE SERVICES LOCATED AT < " - + signURL - + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."); - String m1 = "THE CONNECT TO < " + signURL - + " > WAS REFUSED WITH HTTP CODE " + code - + " THREE TIMES IN ROW. "; - String m2 = "THE SERVICES LOCATED AT < " - + signURL - + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."; - String msg = m1 + " " + m2; - - Report.doWrite("DELETED SERVICES :"); - for (int i = s.length - 1; i >= 0; i--) { - Report.doWrite(i + ". " + s[i]); - } - DataMngr.delServiceSetByURL(signURL); - DataMngr.delServErrors(signURL); - Report.add("THE CONNECT TO < " + signURL - + " > WAS REFUSED WITH HTTP CODE " + code - + " THREE TIMES IN ROW. "); - Report - .add("THE SERVICES LOCATED AT < " - + signURL - + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY"); - Report - .doWrite("======================================================================================="); - } - - } else { - DataMngr.insErrCount(signURL, code); - } - huc.disconnect(); - } catch (IOException e) { - Log.severe("Failed : " + e); - Report.add("Error 2: " + e); - // e.getMessage(); - } - - return model; - - } - - /** - * a SMTP client that allows The SMTP client establishes a connection with - * an SMTP server and waits for the server to respond . The client is then - * ready to construct a mail message. (make HTTP connect to server, open a - * file,read a file into a streem, build a model) - * - * @param to - - * where is the target of the e-mail message to be sent. - * @param subj - - * the subject of this MailMessage. - * @param msgStr - - * the text data that is to be included in this MailMessage. - * @param from - - * where is the e-mail address of the message transmitter. - * - */ - - public static void sendMail(String to, String subj, String msgStr, - String from) { - - try { - - Properties prop = new Properties(); - prop.put("mail.smtp.host", Constants.MB_MAIL_SERVER); - Session ses = Session.getDefaultInstance(prop, null); - MimeMessage msg = new MimeMessage(ses); - msg.setFrom(new InternetAddress(from)); - msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); - msg.setSubject(subj); - msg.setSentDate(new Date()); - msg.setText(msgStr); - if (Constants.MB_MAIL_PSWD != null) { - Transport transport = ses.getTransport("smtp"); //for usage a - // password - transport.connect(Constants.MB_MAIL_SERVER, - Constants.MB_MAIL_USER, Constants.MB_MAIL_PSWD); - } - Transport.send(msg); - Report.doWrite("The message have been sent to " + to); - } catch (MessagingException e) { - // Log.severe(e.getMessage()+" sendmail"); - e.getMessage(); - } - - } - - public static String readFromURL(String url) { - String list = ""; - try { - URL u = new URL(url); - - HttpURLConnection huc = (HttpURLConnection) u.openConnection(); - huc.connect(); - - int code = huc.getResponseCode(); - Log.info("GET <" + url + " > - HTTP CODE: " + code); - Report.doWrite(""); - Report.doWrite("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " - + code); - Report.add("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " - + code); - - if (code == 200 || code == 202) { - - } else { - - } - } catch (IOException e) { - Log.severe("Failed : " + e); - Report.add("Error 2: " + e); - // e.getMessage(); - } - return list; - } - - public static Hashtable readFromFile(String file) { - - Hashtable list = new Hashtable(); - //...checks on aFile are elided - // StringBuffer contents = new StringBuffer(); - - //declared here only to make visible to finally clause - BufferedReader input = null; - try { - //use buffering - //this implementation reads one line at a time - input = new BufferedReader(new FileReader(file)); - String line = null; //not declared within while loop - while ((line = input.readLine()) != null) { - list.put(line, ""); - // contents.append(line); - // contents.append(System.getProperty("line.separator")); - } - } catch (FileNotFoundException ex) { - ex.printStackTrace(); - } catch (IOException ex) { - ex.printStackTrace(); - } finally { - try { - if (input != null) { - //flush and close both "input" and its underlying - // FileReader - input.close(); - } - } catch (IOException ex) { - ex.printStackTrace(); - } - } - return list; - } + /** + * get RDF model of service by signatureURL (make HTTP connect to server, + * open a file,read a file into a streem, build the model) + * + * @param signURL - + * the URL of resource (signatureURL) + * @param servNames - + * set of service names located at this signatureURL + * @return Model the RDF model of services located at this signatureURL + */ + + public static Model getServiceRDF(String servNames, String signURL) { + + Model model = ModelFactory.createDefaultModel(); + String mes1 = ""; + try { + URL u = new URL(signURL); + + HttpURLConnection huc = (HttpURLConnection) u.openConnection(); + huc.connect(); + + int code = huc.getResponseCode(); + Log.info("GET <" + signURL + " > - HTTP CODE: " + code); + Report.doWrite(""); + Report.doWrite("GET SIGNATURE_URL <" + signURL + + " > - HTTP CODE: " + code); + Report.add("GET SIGNATURE_URL <" + signURL + " > - HTTP CODE: " + + code); + if (code == 200 || code == 202) { + try { + model.read(huc.getInputStream(), ""); + DataMngr.delServErrors(signURL); + } catch (RDFException e) { + Log.severe("Failed : " + e); + Report.add("Error 1: " + e); + // reset code in instances that domain is valid, but nothing returned. + code = 404; + // e.getMessage(); + } catch (JenaException e) { + //reset code to + code = 417; + } + //http://www.w3.org/RDF/Validator/RDF/Validator/ARPServlet?URI= + } + + ////////////////////////// + // no else if here purposely, because i reset the code if an + // exception is thrown due to invalid rdfs being returned. + ////////////////////////// + if (code != 200 && code != 202) { + if (code == 400) { + Log + .warning("The request had bad syntax or was inherently impossible to be satisfied."); + Report + .add("The request had bad syntax or was inherently impossible to be satisfied."); + } else if (code == 401) { + Log + .warning("The parameter to this message gives a specification of authorization schemes which are acceptable."); + Report + .add("The parameter to this message gives a specification of authorization schemes which are acceptable."); + } else if (code == 402) { + Report + .add("The parameter to this message gives a specification of charging schemes acceptable."); + } else if (code == 403) { + Report + .add("The request is for something forbidden. Authorization will not help."); + mes1 = "The request is for something forbidden."; + } else if (code == 404) { + Report + .doWrite("The server has not found anything matching the URI given"); + Report + .add("The server has not found anything matching the URI given"); + mes1 = "The RDF file was not found on the server"; + } else if (code == 417) { + Report + .add(" RDF Parsing error. Possible reason being that multiple tags found in the same file."); + mes1 = "RDF Parsing error. Possible reason being that multiple tags found in the same file."; + } else if (code == 500) { + Report.add(" Internal Error"); + mes1 = " Internal Error"; + } + int num = DataMngr.getServErrorNum(signURL, code); + + updateNumCount(signURL, code, num); + } + huc.disconnect(); + } catch (IOException e) { + Log.severe("Failed : " + e); + Report.add("Error 2: " + e); + int code = 404; + int num = DataMngr.getServErrorNum(signURL, code); + updateNumCount(signURL, code, num); + } + return model; + + } + + /** + * @param signURL + * @param code + * @param num + */ + private static void updateNumCount(String signURL, int code, int num) { + if (num > 0) { + if (num < 3) { + DataMngr.updErrCount(signURL, code); + } else { + + String servList = DataMngr.getServListByURL(signURL); + String s[] = servList.split(","); + Report.add("THE CONNECT TO < " + signURL + + " > WAS REFUSED WITH HTTP CODE " + code + + " THREE TIMES IN ROW. "); + Report + .add("THE SERVICES LOCATED AT < " + + signURL + + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."); + String m1 = "THE CONNECT TO < " + signURL + + " > WAS REFUSED WITH HTTP CODE " + code + + " THREE TIMES IN ROW. "; + String m2 = "THE SERVICES LOCATED AT < " + + signURL + + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY."; + String msg = m1 + " " + m2; + + Report.doWrite("DELETED SERVICES :"); + for (int i = s.length - 1; i >= 0; i--) { + Report.doWrite(i + ". " + s[i]); + } + DataMngr.delServiceSetByURL(signURL); + DataMngr.delServErrors(signURL); + Report.add("THE CONNECT TO < " + signURL + + " > WAS REFUSED WITH HTTP CODE " + code + + " THREE TIMES IN ROW. "); + Report + .add("THE SERVICES LOCATED AT < " + + signURL + + " > WILL BE DEREGISTERED FROM mobycentral REGISTRY"); + Report + .doWrite("======================================================================================="); + // TODO send the report here? + } + + } else { + DataMngr.insErrCount(signURL, code); + } + } + + /** + * a SMTP client that allows The SMTP client establishes a connection with + * an SMTP server and waits for the server to respond . The client is then + * ready to construct a mail message. (make HTTP connect to server, open a + * file,read a file into a streem, build a model) + * + * @param to - + * where is the target of the e-mail message to be sent. + * @param subj - + * the subject of this MailMessage. + * @param msgStr - + * the text data that is to be included in this MailMessage. + * @param from - + * where is the e-mail address of the message transmitter. + * + */ + + public static void sendMail(String to, String subj, String msgStr, + String from) { + + try { + + Properties prop = new Properties(); + prop.put("mail.smtp.host", Constants.MB_MAIL_SERVER); + Session ses = Session.getDefaultInstance(prop, null); + MimeMessage msg = new MimeMessage(ses); + msg.setFrom(new InternetAddress(from)); + msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); + msg.setSubject(subj); + msg.setSentDate(new Date()); + msg.setText(msgStr); + if (Constants.MB_MAIL_PSWD != null) { + Transport transport = ses.getTransport("smtp"); //for usage a + // password + transport.connect(Constants.MB_MAIL_SERVER, + Constants.MB_MAIL_USER, Constants.MB_MAIL_PSWD); + } + Transport.send(msg); + Report.doWrite("The message have been sent to " + to); + } catch (MessagingException e) { + // Log.severe(e.getMessage()+" sendmail"); + e.getMessage(); + } + + } + + public static String readFromURL(String url) { + String list = ""; + try { + URL u = new URL(url); + + HttpURLConnection huc = (HttpURLConnection) u.openConnection(); + huc.connect(); + + int code = huc.getResponseCode(); + Log.info("GET <" + url + " > - HTTP CODE: " + code); + Report.doWrite(""); + Report.doWrite("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " + + code); + Report.add("GET SIGNATURE_URL <" + url + " > - HTTP CODE: " + + code); + + if (code == 200 || code == 202) { + + } else { + + } + } catch (IOException e) { + Log.severe("Failed : " + e); + Report.add("Error 2: " + e); + // e.getMessage(); + } + return list; + } + + public static Hashtable readFromFile(String file) { + + Hashtable list = new Hashtable(); + //...checks on aFile are elided + // StringBuffer contents = new StringBuffer(); + + //declared here only to make visible to finally clause + BufferedReader input = null; + try { + //use buffering + //this implementation reads one line at a time + input = new BufferedReader(new FileReader(file)); + String line = null; //not declared within while loop + while ((line = input.readLine()) != null) { + list.put(line, ""); + // contents.append(line); + // contents.append(System.getProperty("line.separator")); + } + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } finally { + try { + if (input != null) { + //flush and close both "input" and its underlying + // FileReader + input.close(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return list; + } } \ No newline at end of file From mwilkinson at pub.open-bio.org Thu Jul 28 15:39:47 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 11:39:47 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281539.j6SFdlxl004187@pub.open-bio.org> mwilkinson Thu Jul 28 11:39:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv4168/MOBY Modified Files: OntologyServer.pm Log Message: passing wrong parameter to delete_service and delete_namespace moby-live/Perl/MOBY OntologyServer.pm,1.64,1.65 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/27 18:06:50 1.64 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:39:47 1.65 @@ -680,7 +680,7 @@ return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } - my ($err, $errstr) = $adaptor->delete_service(service_lsid => $lsid); + my ($err, $errstr) = $adaptor->delete_service(type => $lsid); if ( $err ) { return ( 0, "Delete from Service Type table failed: $errstr", @@ -820,7 +820,7 @@ $lsid ); } - my ($err, $errstr) = $adaptor->delete_namespace(namespace_lsid => $lsid); + my ($err, $errstr) = $adaptor->delete_namespace(type => $lsid); if ( $err ) { return ( 0, "Delete from namespace table failed: $errstr", From mwilkinson at pub.open-bio.org Thu Jul 28 15:39:47 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 11:39:47 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281539.j6SFdlo8004206@pub.open-bio.org> mwilkinson Thu Jul 28 11:39:47 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv4168/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: passing wrong parameter to delete_service and delete_namespace moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.56,1.57 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.56 retrieving revision 1.57 diff -u -r1.56 -r1.57 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/27 21:25:28 1.56 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:39:47 1.57 @@ -853,6 +853,7 @@ my $row = shift(@$result); my $id = $row->{service_id}; my $lsid = $row->{service_lsid}; + return 0 unless $lsid; my $dbh = $self->dbh; my $statement = "delete from service where service_lsid = ?"; $dbh->do( $statement, undef, ($args{lsid})); @@ -1009,6 +1010,7 @@ my $row = shift(@$result); my $id = $row->{namespace_id}; my $lsid = $row->{namespace_lsid}; + return 0 unless $lsid; my $dbh = $self->dbh; my $statement = "delete from namespace where namespace_lsid = ?"; $dbh->do( $statement, undef, ($lsid)); From mwilkinson at pub.open-bio.org Thu Jul 28 15:45:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 11:45:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281545.j6SFjv5a004282@pub.open-bio.org> mwilkinson Thu Jul 28 11:45:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv4263/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: doh moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.57,1.58 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.57 retrieving revision 1.58 diff -u -r1.57 -r1.58 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:39:47 1.57 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:45:57 1.58 @@ -856,7 +856,7 @@ return 0 unless $lsid; my $dbh = $self->dbh; my $statement = "delete from service where service_lsid = ?"; - $dbh->do( $statement, undef, ($args{lsid})); + $dbh->do( $statement, undef, ($lsid)); $self->_delete_service_term2term(id => $id); if ($dbh->err){ return (1, $dbh->errstr); From mwilkinson at pub.open-bio.org Thu Jul 28 15:57:51 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 11:57:51 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281557.j6SFvpKc004365@pub.open-bio.org> mwilkinson Thu Jul 28 11:57:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv4346/MOBY Modified Files: OntologyServer.pm Log Message: discovery of relationships in ontology was failing for all ontologies moby-live/Perl/MOBY OntologyServer.pm,1.65,1.66 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:39:47 1.65 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:57:51 1.66 @@ -360,7 +360,8 @@ # object1_id ISA object2_id? my $isa = $adaptor->query_object_term2term(type => $lsid); - if ( scalar @$isa ) { + my $isas = shift @$isa; + if ( $isas->{object1_id}) { return ( 0, qq{Object type $term has object dependencies in the ontology}, $lsid ); @@ -675,8 +676,9 @@ # service1_id ISA service2_id? my $isa = $adaptor->query_service_term2term(service2_id => $lsid); - - if ( scalar @$isa ) { + my $isas = shift(@$isa); + + if ( $isas->{service1_id} ) { return ( 0, qq{Service type $term has dependencies in the ontology}, $lsid ); } @@ -814,8 +816,9 @@ # service1_id ISA service2_id? my $isa = $adaptor->query_namespace_term2term(type => $lsid); - - if ( scalar @$isa ) { + my $isas = shift @$isa; + + if ($isas->{namespace1_id} ) { return ( 0, qq{Namespace type $term has dependencies in the ontology}, $lsid ); } From mwilkinson at pub.open-bio.org Thu Jul 28 16:00:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 12:00:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281600.j6SG0BIe004436@pub.open-bio.org> mwilkinson Thu Jul 28 12:00:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv4417/MOBY Modified Files: OntologyServer.pm Log Message: deleting service relationships is now handled by the adaptor rather than the ontology server moby-live/Perl/MOBY OntologyServer.pm,1.66,1.67 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 15:57:51 1.66 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 16:00:10 1.67 @@ -689,15 +689,6 @@ $lsid ); } - ($err, $errstr) = $adaptor->delete_service_term2term(service1_id => $lsid); - - if ( $err ) { - return ( - 0, -"Delete from Service Type Term2Term table failed: $errstr", - $lsid - ); - } return ( 1, "Service Type $term Deleted", $lsid ); } From kawas at pub.open-bio.org Thu Jul 28 15:24:42 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:24:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281524.j6SFOgTC003943@pub.open-bio.org> kawas Thu Jul 28 11:24:42 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv3918/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: Fixed some bugs. Added some statements to help me fix other bugs very soon. Added some logic that I think is necessary for proper functionality. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/26 23:06:25 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/28 15:24:41 1.10 @@ -206,7 +206,6 @@ Hashtable servOut, String servname, String authURI, String signURL) { Connection con = DBConnector.getConnection(); - String servName = ""; String cat = "moby"; String url = ""; @@ -245,7 +244,6 @@ Object ob = num.nextElement(); Object val = servSign.get(ob); - //System.out.println(ob+" = "+val); if (ob.equals("category")) { cat = val.toString(); } @@ -283,9 +281,8 @@ } ServSignature signature = getServSignature(servname, signURL); - servInstId = signature.getServInstId(); - + //TODO make sure that the fields are updated if (servInstId == 0) { int authId = getAuthIdByAuthURI(authuri); @@ -313,7 +310,7 @@ // "+Constants.MB_MAIL_SERVER); /* * if (Constants.MB_MAIL_SERVER != null | - * Constants.MB_MAIL_SERVER.equals("")) { String to = + * !Constants.MB_MAIL_SERVER.equals("")) { String to = * DataMngr.getContactEmail(signURL); * Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // * send message to the service provider - that service was @@ -325,31 +322,38 @@ } else { if (!cat.equals(signature.getCategory()) - | !url.equals(signature.getUrl()) - | !email.equals(signature.getEmail()) - | !desc.equals(signature.getDescription()) - | !stype.equals(signature.getServiceType()) - | !authoritative.equals(signature.getAuthoritative()) - | !authuri.equals(authURI)) { + || !url.equals(signature.getUrl()) + || !email.equals(signature.getEmail()) + || !desc.equals(signature.getDescription()) + || !stype.equals(signature.getServiceType()) + || !authoritative.equals(signature.getAuthoritative()) + || !authuri.equals(authURI)) { + //TODO + Log.info("Updating the service '" + servName +"' since the RDF document has been modified."); if (signatureURL.equals("NNN")) { - int res = updSign(servName, cat, stype, authuri, url, + Log.info("sig == NNN" + signURL); + Log.info("=<"+servName+","+cat+","+stype+","+authuri+","+url+","+email+","+desc+","+authoritative+","+signURL+">"); + int res = updSign(servName, cat, stype, authuri, url, email, desc, authoritative, signURL); if (res == 1) { - // Report.doWrite("------The service instance - // <"+servName+"> was updated "); - // Report.add("------The service instance <"+servName+"> - // was updated "); + Report.doWrite("------The service instance<"+servName+"> was updated "); + Report.add("------The service instance <"+servName+">was updated "); + } else { + Report.doWrite("------The service instance<"+servName+"> was not updated"); + Report.add("------The service instance <"+servName+">was not updated "); } } else { + Log.info("sig != NNN"); int res = updSign(servName, cat, stype, authuri, url, email, desc, authoritative, signatureURL); if (res == 1) { - // Report.doWrite("------The service instance - // <"+servName+"> was updated "); - // Report.add("------The service instance <"+servName+"> - // was updated "); + Report.doWrite("------The service instance <"+servName+"> was updated "); + Report.add("------The service instance <"+servName+">was updated "); + } else { + Report.doWrite("------The service instance <"+servName+"> was not updated "); + Report.add("------The service instance <"+servName+">was not updated "); } } } @@ -368,7 +372,7 @@ while (num1.hasMoreElements()) { Object ob = num1.nextElement(); Object val = servInp.get(ob); - //System.out.println(ob+" = "+val ); + Log.info("INPUTS :"+ob+" = "+val ); String simcol = (ob.toString()).substring(0, 6); // a hashtable name if (simcol.equals("secinp")) { // if it's a Secondary input @@ -522,7 +526,7 @@ Object ob = numout.nextElement(); Object val = servOut.get(ob); String simcol = (ob.toString()).substring(0, 6); - + Log.info("OUTPUTS :"+ob+" = "+val ); if (simcol.equals("colout")) { co += 1; Report.doWrite(" "); @@ -547,6 +551,7 @@ Report.doWrite("Simple output " + so); Report.add("Simple output " + so + ":"); + //TODO bug #13 here? if (delsout == 0) { delRow("simple_output", servInstId); // delete from // simple_output table @@ -571,7 +576,7 @@ col_art = null; } } - if (ob1.equals("article_name")) { + if (ob1.equals("articleName")) { art = simple.get(ob1).toString(); if (art.equals(" ")) { art = null; @@ -600,9 +605,13 @@ obt = null; nst = null; } + // TODO bug #11 here - fixed if (simcol.equals("simout")) { insIntoSimpleOutput(new Integer(servInstId), art, obt, nst, null); + art = null; + obt=null; + nst=null; } if (colOutId != null) { Report.doWrite("collection_output_id: " + colOutId); @@ -1333,6 +1342,8 @@ signature.setAuthoritative(authoritative); String description = rs.getString(8); signature.setDescription(description); + signature.setServiceName(servName); + signature.setSignatureURL(signURL); } } catch (SQLException e) { From kawas at pub.open-bio.org Thu Jul 28 15:27:07 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:27:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281527.j6SFR7JE004039@pub.open-bio.org> kawas Thu Jul 28 11:27:07 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv4014/org/biomoby/registry/rdfagent/verifier Modified Files: ServSignature.java Log Message: added some new class properties and methods to set/get them. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServSignature.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServSignature.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServSignature.java 2004/10/28 17:55:43 1.1 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServSignature.java 2005/07/28 15:27:07 1.2 @@ -1,104 +1,139 @@ -package org.biomoby.registry.rdfagent.verifier; - - -/** - * @author Nina Opushneva - * - * This class represents the model data for the service signature. - * It is a value-object and has fine-grained getter and setter - * methods. - */ -public class ServSignature { - - int servInstId; - int authId; - String category; - String serviceType; - String url; - String email; - String authoritative; - String description; - - - public ServSignature() { - } - - public ServSignature(int servInstId, int authId, String category, String serviceType, String url, String email, String authoritative, String description ) { - - this.servInstId = servInstId; - this.authId = authId; - this.category = category; - this.serviceType = serviceType; - this.url = url; - this.email = email; - this.authoritative = authoritative; - this.description = description; - - } - - public int getServInstId() { - return servInstId; - } - - public void setServInstId(int servInstId) { - this.servInstId = servInstId; - } - - public int getAuthId() { - return authId; - } - - public void setAuthId(int authId) { - this.authId = authId; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public String getServiceType() { - return serviceType; - } - - public void setServiceType(String serviceType) { - this.serviceType = serviceType; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getAuthoritative() { - return authoritative; - } - - public void setAuthoritative(String authoritative) { - this.authoritative = authoritative; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - -} +package org.biomoby.registry.rdfagent.verifier; + +/** + * @author Nina Opushneva + * + * This class represents the model data for the service signature. It is a + * value-object and has fine-grained getter and setter methods. + */ +public class ServSignature { + + private int servInstId; + + private int authId; + + private String category; + + private String serviceType; + + private String url; + + private String email; + + private String authoritative; + + private String description; + + private String signatureURL; + + private String name; + + public ServSignature() { + } + + public ServSignature(int servInstId, int authId, String category, + String serviceType, String url, String email, String authoritative, + String description, String serviceName, String signatureURL) { + + this.servInstId = servInstId; + this.authId = authId; + this.category = category; + this.serviceType = serviceType; + this.url = url; + this.email = email; + this.authoritative = authoritative; + this.description = description; + this.name = serviceName; + this.signatureURL = signatureURL; + + } + + public int getServInstId() { + return servInstId; + } + + public void setServInstId(int servInstId) { + this.servInstId = servInstId; + } + + public int getAuthId() { + return authId; + } + + public void setAuthId(int authId) { + this.authId = authId; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getServiceType() { + return serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getAuthoritative() { + return authoritative; + } + + public void setAuthoritative(String authoritative) { + this.authoritative = authoritative; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + public String getServiceName() { + return name; + } + public void setServiceName(String name) { + this.name = name; + } + public String getSignatureURL() { + return signatureURL; + } + public void setSignatureURL(String signatureURL) { + this.signatureURL = signatureURL; + } + + public String toString() { + return "Service Name " + this.name + "\n" + "SignatureURL " + + this.signatureURL + "Service ID " + this.servInstId + "\n" + + "Authority ID " + this.authId + "\n" + "Category " + + this.category + "\n" + "Service Type " + this.serviceType + + "\n" + "Service Endpoint " + this.url + "\n" + + "Contact Email address " + this.email + "\n" + + "Authoritative? " + this.authoritative + "\n" + + "Description " + this.description + "\n"; + } +} \ No newline at end of file From kawas at pub.open-bio.org Thu Jul 28 15:26:14 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Thu, 28 Jul 2005 11:26:14 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281526.j6SFQEPA004001@pub.open-bio.org> kawas Thu Jul 28 11:26:13 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv3976/org/biomoby/registry/rdfagent/verifier Modified Files: ServiceDescrParser.java Log Message: Changes made were only to formatting of code (i think!?!). Also, i added some todos for later on. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServiceDescrParser.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/25 20:20:02 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/28 15:26:13 1.7 @@ -5,6 +5,7 @@ import java.util.Iterator; import java.util.Vector; +import org.biomoby.registry.rdfagent.util.Constants; import org.biomoby.registry.rdfagent.util.Log; import org.biomoby.registry.rdfagent.util.Report; import org.biomoby.registry.rdfagent.util.XMLBuilder; @@ -22,772 +23,865 @@ /** * @author Nina Opushneva - * - * The ServiceDescrParser is a software component for processing RDF data. - * One or more RDF documents can be loaded into the parser and then the parser - * browses the input stream and extracts data for to compare with data in database + * + * The ServiceDescrParser is a software component for processing RDF data. One + * or more RDF documents can be loaded into the parser and then the parser + * browses the input stream and extracts data for to compare with data in + * database */ public class ServiceDescrParser { - Model servDescrMd; - - int bag = 0; - int n = 0; - int[] ver = {0,0,0,0,0,0,0,0}; - - ServiceDescrParser(Model serviceDescrMd){ - - this.servDescrMd = serviceDescrMd; - } - -/** get a provider's RDF file by signatureURL, - * and check if every of service RDF is valid MOBY - * @param signURL - the URL of resource (signatureURL) - * @param servNames - list of services which have registered with signURL - * - */ - - public void getValidRDF(String servNames,String signURL){ - String res = ""; - int amount = 0; - int validMoby = 0; - int servError = 0; - Vector resources = new Vector(); // the list of services at given URL (including new services) - String auth_URI = ""; - String servName = ""; - Vector deletedServ = new Vector(); // the list of deleted services from database - - - // get the set of RDF with the same signatureURL - - ResIterator iter = servDescrMd.listSubjectsWithProperty(DC.title); - while (iter.hasNext()){ - String resource = iter.next().toString(); - Hashtable servSign = new Hashtable(); - amount += 1; - - servSign = getServSignature(resource); - - if(!servSign.isEmpty()){ // a valid MOBY RDF - servName = servSign.get("servicename").toString(); - auth_URI = servSign.get("authURI").toString(); - resources.addElement(servName); - - Hashtable servInp = new Hashtable(); - servInp = getInput(resource) ; - Hashtable servOut = new Hashtable(); - servOut = getOutput(resource) ; - - for (int i = 0; i < ver.length; i++) { // a clearance of the array ver[] - ver[i] = 0; - - } - if (servInp.containsValue("error") | servOut.containsValue("error")){ - servError +=1; - String msg = "A bad Input or Output structure for the service <"+ servName+">. "; - String msg1 = "The service have not processed"; - Report.doWrite(msg+msg1); - }else{ - DataMngr.processService(servSign,servInp,servOut,servName,auth_URI,signURL); - } - }else{ - validMoby += 1; // a not valid MOBY RDF - } - - } - - String[] result = servNames.split(","); - - - Report.doWrite(""); - Report.add("----------------------------------------------------------------------------------------"); - Report.add(" "); - Report.doWrite("Expected services for given URL "+result.length); - Report.add("Expected services for given URL "+result.length); - - Report.doWrite("In fact = "+amount); - Report.add("In fact = "+amount); - Report.add("notValidMoby services or with a bad structure = "+(servError+validMoby)); - Report.add(" "); - - for (int j=0;j was not found in the RDF file. The service was deregistered from MOBYCENTRAL Registry" ; - Report.doWrite(msg ); - Report.add(msg ); - -/* if (Constants.MB_MAIL_SERVER != null | Constants.MB_MAIL_SERVER.equals("") ){ - String to = DataMngr.getContactEmail(signURL); - Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // send message to the service provider - that service was deregistered - - }*/ - } - } - int del = deletedServ.size(); - if (del > 0){ - Report.doWrite("DELETED SERVICES: "); - Report.add(" "); - Report.add("DELETED SERVICES: "); - Iterator i = deletedServ.iterator(); - int m=1; - while (i.hasNext()){ - String delServ = i.next().toString(); - Report.doWrite(m+". "+delServ); - Report.add(m+". "+delServ); - m+=1; - } - - } - Report.doWrite("notValidMoby services or with a bad structure = "+(servError+validMoby)); -// Report.add("notValidMoby services or with a bad structure = "+(servError+validMoby)); - Report.doWrite("======================================================================================="); - - Log.info("======================================================================="); - } - - - /** get service Signature data for the service - * @param resource - the URL of resource + serviceName+authURI - * @return Hashtable represented by a pair: service signature descriptor and value - */ + private Model servDescrMd; + + int bag = 0; + + int n = 0; + + int[] ver = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + ServiceDescrParser(Model serviceDescrMd) { + + this.servDescrMd = serviceDescrMd; + } + + /** + * get a provider's RDF file by signatureURL, and check if every of service + * RDF is valid MOBY + * + * @param signURL - + * the URL of resource (signatureURL) + * @param servNames - + * list of services which have registered with signURL + * + */ + + public void getValidRDF(String servNames, String signURL) { + String res = ""; + int amount = 0; + int validMoby = 0; + int servError = 0; + Vector resources = new Vector(); // the list of services at given URL + // (including new services) + String auth_URI = ""; + String servName = ""; + Vector deletedServ = new Vector(); // the list of deleted services from + // database + + // get the set of RDF with the same signatureURL + + ResIterator iter = servDescrMd.listSubjectsWithProperty(DC.title); + while (iter.hasNext()) { + String resource = iter.next().toString(); + Hashtable servSign = new Hashtable(); + amount += 1; + + servSign = getServSignature(resource); + + if (!servSign.isEmpty()) { // a valid MOBY RDF + servName = servSign.get("servicename").toString(); + auth_URI = servSign.get("authURI").toString(); + resources.addElement(servName); + + Hashtable servInp = new Hashtable(); + servInp = getInput(resource); + Hashtable servOut = new Hashtable(); + servOut = getOutput(resource); + + for (int i = 0; i < ver.length; i++) { // a clearance of the + // array ver[] + ver[i] = 0; + + } + if (servInp.containsValue("error") + | servOut.containsValue("error")) { + servError += 1; + String msg = "A bad Input or Output structure for the service <" + + servName + ">. "; + String msg1 = "The service have not processed"; + Report.doWrite(msg + msg1); + } else { + DataMngr.processService(servSign, servInp, servOut, + servName, auth_URI, signURL); + } + } else { + validMoby += 1; // a not valid MOBY RDF + } + + } + + String[] result = servNames.split(","); + + Report.doWrite(""); + Report + .add("----------------------------------------------------------------------------------------"); + Report.add(" "); + Report.doWrite("Expected services for given URL " + result.length); + Report.add("Expected services for given URL " + result.length); + + Report.doWrite("In fact = " + amount); + Report.add("In fact = " + amount); + Report.add("notValidMoby services or with a bad structure = " + + (servError + validMoby)); + Report.add(" "); + + for (int j = 0; j < result.length; j++) { + res = ""; + for (int i = 0; i < resources.size(); i++) { + String s = (String) resources.elementAt(i); + if (result[j].equals(s)) { + res = "ok"; + break; + } + } + + if (res.equals("")) { + servName = result[j]; + if (deletedServ.size() == 0) { + XMLBuilder.startServiceXml(); + } + XMLBuilder.buildServiceXml(servName, signURL); + DataMngr.delServByNameAndUrl(servName, signURL); + deletedServ.addElement(servName); + String msg = "The service < " + + servName + + " > was not found in the RDF file. The service was deregistered from MOBYCENTRAL Registry"; + Report.doWrite(msg); + Report.add(msg); + + if (Constants.MB_MAIL_SERVER != null + || !Constants.MB_MAIL_SERVER.equals("")) { + String to = DataMngr.getContactEmail(signURL); + Communicator.sendMail(to, Constants.SP_SUBJECT, msg, + Constants.MB_FROM); + // send message to the service provider - that service was + // deregistered + } + } + } + int del = deletedServ.size(); + if (del > 0) { + Report.doWrite("DELETED SERVICES: "); + Report.add(" "); + Report.add("DELETED SERVICES: "); + Iterator i = deletedServ.iterator(); + int m = 1; + while (i.hasNext()) { + String delServ = i.next().toString(); + Report.doWrite(m + ". " + delServ); + Report.add(m + ". " + delServ); + m += 1; + } + } + Report.doWrite("notValidMoby services or with a bad structure = " + + (servError + validMoby)); + // Report.add("notValidMoby services or with a bad structure = + // "+(servError+validMoby)); + Report + .doWrite("======================================================================================="); + + Log + .info("======================================================================="); + } + + /** + * get service Signature data for the service + * + * @param resource - + * the URL of resource + serviceName+authURI + * @return Hashtable represented by a pair: service signature descriptor and + * value + */ + + public Hashtable getServSignature(String resource) { - public Hashtable getServSignature(String resource){ - Hashtable sign = new Hashtable(); - Resource si = servDescrMd.getResource(resource); - - Report.doWrite("----------------------------------------------------------------------------------------"); - Report.add("----------------------------------------------------------------------------------------"); - n +=1; // the number of RDF at the signatureURL - Log.info("RDF "+n+" : "+ si); - Report.doWrite("RDF "+n+" : "+ si); - Report.add("RDF "+n+" : "+ si); - - int in = 0; - int out = 0; - StmtIterator signNum = si.listProperties(); - - while (signNum.hasNext()) { - Statement stmtSign = signNum.nextStatement(); - String signPred = stmtSign.getPredicate().toString().trim(); - String signNode = stmtSign.getObject().toString(); - - String[] rezNode = signNode.split(":http:"); - int k = (rezNode.length)-1; - if (k == 0){ - String[] rezNode1 = signNode.split("~"); - signNode = rezNode1[0]; - }else{ - signNode = rezNode[0]; - } - - String[] result = signPred.split("#"); - int i = (result.length)-1; - if (i == 0){ - String[] res = signPred.split("/"); - int j = (res.length)-1; - String name = getFieldName(res[j]); - sign.put(name,signNode); - } - else { - if (result[i].equals("input") | result[i].equals("consumes")){ - in = 1; - } - if (result[i].equals("output") | result[i].equals("produces")){ - out = 1; - } - String name = getFieldName(result[i]); - if (name.equals("service_type_uri")){ - String lsid_node = switchURItoLSID(signNode); - sign.put(name,lsid_node); - }else{ - sign.put(name,signNode); - } - - - } - } - - for (int vn=0; vn"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Simple input <"+result[i]+">"); - simple = "error"; - continue; + if (l3Res.isAnon()) { + + Object type = l3Res.getRequiredProperty(RDF.type) + .getObject(); + + if (type.equals(MP.Simple)) { + StmtIterator p34iter = l3Res.listProperties(); + + while (p34iter.hasNext()) { + + Statement l4iter = p34iter.nextStatement(); + String l4Pred1 = l4iter.getPredicate().toString(); + String l4Node1 = l4iter.getObject().toString(); + String[] result = l4Pred1.split("#"); + int i = (result.length) - 1; + + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Simple input <" + + result[i] + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Simple input <" + + result[i] + ">"); + simple = "error"; + continue; + } + if (name.equals("type")) { + continue; + } + String[] rezNode1 = l4iter.getObject().toString() + .split(":http:"); + String l4Nodestr = rezNode1[0]; + if (name.equals("namespace_type_uris")) { + siminp.remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l4Nodestr); + if (sumsns.length() == 0) { + sumsns.append(lsid_nsp); + } else { + sumsns.append("," + lsid_nsp); + } + + siminp.put(name, sumsns.toString()); + } else if (name.equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l4Nodestr); + siminp.put(name, lsid_nsp); + } else { + siminp.put(name, l4Nodestr); + } + } + if (siminp.isEmpty()) { + } else { + input.put("siminp" + sin, siminp); // to add Simple + // to Input + sin += 1; + Enumeration num = siminp.keys(); + + } + } else if (type.equals(MP.Collection) + | type.equals(RDF.Bag)) { + // if (l3Res.hasProperty(RDF.type,RDF.Bag) && + // l3Res.hasProperty(RDF.li(1))){ + if (l3Res.hasProperty(RDF.li(1))) { + StmtIterator p34iter = l3Res.listProperties(); + if (l3Res.hasProperty(MP.article_name)) { + String col_artName = l3Res.getProperty( + MP.article_name).getObject().toString(); + String[] rezNode = col_artName.split(":http:"); + col_artName = rezNode[0]; + colinp.put("col_articleName", col_artName); + } + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + Property l4Pred = l4iter.getPredicate(); + Node l4Node = l4iter.getObject().asNode(); + + if (l4Node.isBlank()) { + Resource l4Res = l4iter.getResource(); + StmtIterator p45iter = l4Res + .listProperties(); + if (p45iter.hasNext()) { + StringBuffer sumns = new StringBuffer(); + while (p45iter.hasNext()) { + Statement l5iter = p45iter + .nextStatement(); + String l5Pred = l5iter + .getPredicate().toString(); + Node l5Node = l5iter.getObject() + .asNode(); + String[] result = l5Pred.split("#"); + int i = (result.length) - 1; + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Collection input <" + + result[i] + + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Collection input <" + + result[i] + + ">"); + String Collection = "error"; + break; + } + String[] rezNode = l5iter + .getObject().toString() + .split(":http:"); + String l5Nodestr = rezNode[0]; + if (name + .equals("namespace_type_uris")) { + colinp + .remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + if (sumns.length() == 0) { + sumns.append(lsid_nsp); + } else { + sumns + .append("," + + lsid_nsp); + } + + colinp.put(name, sumns + .toString()); + // sumns.append(l5Node+","); + } else if (name + .equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + colinp.put(name, lsid_nsp); + } else { + colinp.put(name, l5Node); + } + } + input.put("colinp" + cin, colinp); + cin += 1; + Enumeration num = colinp.keys(); + } + } + + } + } else { + collection = "error"; + Report + .doWrite("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); + Report + .add("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); + } - if (name.equals("type")){ - continue; - } - String[] rezNode1 = l4iter.getObject().toString().split(":http:"); - String l4Nodestr = rezNode1[0]; - if (name.equals("namespace_type_uris")){ - siminp.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l4Nodestr); - if (sumsns.length()==0){ - sumsns.append(lsid_nsp); - }else{ - sumsns.append(","+lsid_nsp); - } - - siminp.put(name,sumsns.toString()); - } - else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l4Nodestr); - siminp.put(name,lsid_nsp); - } - else{ - siminp.put(name,l4Nodestr); - } } - if (siminp.isEmpty()){ - }else{ - input.put("siminp"+sin,siminp); // to add Simple to Input - sin+=1; - Enumeration num = siminp.keys(); - - } - } - else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ -// if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ - if (l3Res.hasProperty(RDF.li(1))){ - StmtIterator p34iter = l3Res.listProperties(); - if (l3Res.hasProperty(MP.article_name)){ - String col_artName = l3Res.getProperty(MP.article_name).getObject().toString(); - String[] rezNode = col_artName.split(":http:"); - col_artName = rezNode[0]; - colinp.put("col_articleName",col_artName); - } - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - Property l4Pred = l4iter.getPredicate(); - Node l4Node = l4iter.getObject().asNode(); - - if (l4Node.isBlank()){ - Resource l4Res = l4iter.getResource(); - StmtIterator p45iter = l4Res.listProperties(); - if(p45iter.hasNext()) { - StringBuffer sumns = new StringBuffer(); - while (p45iter.hasNext()) { - Statement l5iter = p45iter.nextStatement(); - String l5Pred = l5iter.getPredicate().toString(); - Node l5Node = l5iter.getObject().asNode(); - String[] result = l5Pred.split("#"); - int i = (result.length)-1; - String name = getInpOutName(result[i]); - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection input <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Collection input <"+result[i]+">"); - String Collection = "error"; - break; - } - String[] rezNode = l5iter.getObject().toString().split(":http:"); - String l5Nodestr = rezNode[0]; - if (name.equals("namespace_type_uris")){ - colinp.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l5Node.toString()); - if (sumns.length()==0){ - sumns.append(lsid_nsp); - }else{ - sumns.append(","+lsid_nsp); - } - - colinp.put(name,sumns.toString()); -// sumns.append(l5Node+","); - }else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l5Node.toString()); - colinp.put(name,lsid_nsp); - } - else{ - colinp.put(name,l5Node); - } - } - input.put("colinp"+cin,colinp); - cin+=1; - Enumeration num = colinp.keys(); - } - } - - } - }else{ - collection = "error"; - Report.doWrite("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); - Report.add("BAD STRUCTURE: The Collection input isn't 'Bag' type or have not members"); - - } - } - if (type.equals(MP.Secondary)){ - - StmtIterator p34iter = l3Res.listProperties(); - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - String l4Pred1 = l4iter.getPredicate().toString(); - String l4Node1 = l4iter.getObject().toString(); - - String[] result = l4Pred1.split("#"); - int i = (result.length)-1; - String name = getSecondaryName(result[i]); - - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Secondary input <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Secondary input <"+result[i]+">"); - secondary = "error"; - break; - } - - String[] rezNode1 = l4iter.getObject().toString().split(":http:"); - String l4Nodestr = rezNode1[0]; - if (name.equals("enum")){ - secinp.remove("enum"); - if (sumen.length()==0){ - sumen.append(l4Nodestr); - }else{ - sumen.append(","+l4Nodestr); - } - - secinp.put(name,sumen.toString()); - - } - else{ - secinp.put(name,l4Nodestr); - } - } - - if (secinp.isEmpty()){ - }else{ - input.put("secinp"+sec,secinp); // to add Secondary to Input - sec+=1; - Enumeration num = secinp.keys(); -// Report.doWrite("Secondary input "+ (sec-1)); -// Log.info("Secondary input "+ (sec-1)); - } - } - } - } - - if (simple.equals("error") | collection.equals("error") | secondary.equals("error")){ - input.put("input","error"); - } - }catch(Exception e){ - Log.warning("Failed:"+ e); - } -// } -//System.out.println("input= "+input); - return input; - - } - -/** get set of Outputs for service (Simple and Collection) - * @param resource - the URL of resource + serviceName+authURI - * @return Hashtable of hashtables represented by a pair: - * a name of the output = hashtable for this output - * hashtable for output is represented by a Output descriptor and value. - * - */ - - public Hashtable getOutput(String resource){ - int bagout = 0; - int so = 1; - int co = 1; + if (type.equals(MP.Secondary)) { + + StmtIterator p34iter = l3Res.listProperties(); + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + String l4Pred1 = l4iter.getPredicate().toString(); + String l4Node1 = l4iter.getObject().toString(); + + String[] result = l4Pred1.split("#"); + int i = (result.length) - 1; + String name = getSecondaryName(result[i]); + + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Secondary input <" + + result[i] + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Secondary input <" + + result[i] + ">"); + secondary = "error"; + break; + } + + String[] rezNode1 = l4iter.getObject().toString() + .split(":http:"); + String l4Nodestr = rezNode1[0]; + if (name.equals("enum")) { + secinp.remove("enum"); + if (sumen.length() == 0) { + sumen.append(l4Nodestr); + } else { + sumen.append("," + l4Nodestr); + } + + secinp.put(name, sumen.toString()); + + } else { + secinp.put(name, l4Nodestr); + } + } + + if (secinp.isEmpty()) { + } else { + input.put("secinp" + sec, secinp); // to add + // Secondary to + // Input + sec += 1; + Enumeration num = secinp.keys(); + // Report.doWrite("Secondary input "+ (sec-1)); + // Log.info("Secondary input "+ (sec-1)); + } + } + } + } + + if (simple.equals("error") | collection.equals("error") + | secondary.equals("error")) { + input.put("input", "error"); + } + } catch (Exception e) { + Log.warning("Failed:" + e); + } + // } + //System.out.println("input= "+input); + return input; + + } + + /** + * get set of Outputs for service (Simple and Collection) + * + * @param resource - + * the URL of resource + serviceName+authURI + * @return Hashtable of hashtables represented by a pair: a name of the + * output = hashtable for this output hashtable for output is + * represented by a Output descriptor and value. + * + */ + + public Hashtable getOutput(String resource) { + int bagout = 0; + int so = 1; + int co = 1; String simple = "ok"; String collection = "ok"; - Hashtable output = new Hashtable(); + Hashtable output = new Hashtable(); + + Resource si = servDescrMd.getResource(resource); + + try { + Resource consumes = si.getRequiredProperty(MP.produces) + .getResource(); + StmtIterator p23iter = consumes.listProperties(); + + while (p23iter.hasNext()) { + + Hashtable simout = new Hashtable(); + Hashtable colout = new Hashtable(); + StringBuffer simpns = new StringBuffer(); + // StringBuffer colons = new StringBuffer(); + + Statement l3iter = p23iter.nextStatement(); + Resource l3Res = l3iter.getResource(); + + if (l3Res.isAnon()) { + Object type = l3Res.getRequiredProperty(RDF.type) + .getObject(); + //System.out.println("type_out = "+type); + if (type.equals(MP.Simple)) { + StmtIterator p34iter = l3Res.listProperties(); + + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + String l4Pred1 = l4iter.getPredicate().toString(); + String l4Node1 = l4iter.getObject().toString(); + String[] result = l4Pred1.split("#"); + int i = (result.length) - 1; + + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Simple output <" + + result[i] + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Simple output <" + + result[i] + ">"); + simple = "error"; + continue; + } + if (name.equals("type")) { + continue; + } + String[] rezNode1 = l4iter.getObject().toString() + .split(":http:"); + String l4Nodestr = rezNode1[0]; + if (name.equals("namespace_type_uris")) { + simout.remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l4Nodestr); + if (simpns.length() == 0) { + simpns.append(lsid_nsp); + } else { + simpns.append("," + lsid_nsp); + } + + simout.put(name, simpns.toString()); + } else if (name.equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l4Nodestr); + simout.put(name, lsid_nsp); + } else { + simout.put(name, l4Nodestr); + } + } + if (simout.isEmpty()) { + } else { + output.put("simout" + so, simout); // to add Simple + // to Output + so += 1; + Enumeration num = simout.keys(); + + } + } + + else if (type.equals(MP.Collection) | type.equals(RDF.Bag)) { + // if (l3Res.hasProperty(RDF.type,RDF.Bag) && + // l3Res.hasProperty(RDF.li(1))){ + + if (l3Res.hasProperty(RDF.li(1))) { + StmtIterator p34iter = l3Res.listProperties(); + + if (l3Res.hasProperty(MP.article_name)) { + String col_artName = l3Res.getProperty( + MP.article_name).getObject().toString(); + String[] rezNode = col_artName.split(":http:"); + col_artName = rezNode[0]; + colout.put("col_articleName", col_artName); + } + while (p34iter.hasNext()) { + Statement l4iter = p34iter.nextStatement(); + Property l4Pred = l4iter.getPredicate(); + Node l4Node = l4iter.getObject().asNode(); + + if (l4Node.isBlank()) { + Resource l4Res = l4iter.getResource(); + StmtIterator p45iter = l4Res + .listProperties(); + if (p45iter.hasNext()) { + StringBuffer sumns = new StringBuffer(); + while (p45iter.hasNext()) { + Statement l5iter = p45iter + .nextStatement(); + String l5Pred = l5iter + .getPredicate().toString(); + Node l5Node = l5iter.getObject() + .asNode(); + String[] result = l5Pred.split("#"); + int i = (result.length) - 1; + String name = getInpOutName(result[i]); + if (name.equals("")) { + Report + .doWrite("BAD STRUCTURE: Unknown name of predicate for Collection output <" + + result[i] + + ">"); + Report + .add("BAD STRUCTURE: Unknown name of predicate for Collection output <" + + result[i] + + ">"); + String Collection = "error"; + break; + } + String[] rezNode = l5iter + .getObject().toString() + .split(":http:"); + String l5Nodestr = rezNode[0]; + if (name + .equals("namespace_type_uris")) { + colout + .remove("namespace_type_uris"); + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + if (sumns.length() == 0) { + sumns.append(lsid_nsp); + } else { + sumns + .append("," + + lsid_nsp); + } + + colout.put(name, sumns + .toString()); + // sumns.append(l5Node+","); + } else if (name + .equals("object_type_uri")) { + String lsid_nsp = switchURItoLSID(l5Node + .toString()); + colout.put(name, lsid_nsp); + } else { + colout.put(name, l5Node); + } + } + output.put("colout" + co, colout); + co += 1; + Enumeration num = colout.keys(); + } + } + + } + } else { + collection = "error"; + Report + .doWrite("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); + Report + .add("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); + + } + } + } + } + + if (simple.equals("error") | collection.equals("error")) { + output.put("output", "error"); + } + } catch (Exception e) { + Log.warning("Failed:" + e); + } + //System.out.println("output = "+output); + return output; + } + + /** + * mapping RDF data to the database data + * + * @param name - + * the name of predicate in the RDF of service + * @return String field name in database corresponding with this predicate + * + */ + + public String getFieldName(String name) { + String res = ""; + + if (name.equals("publisher") | name.equals("authURI")) { + ver[0] = 1; + res = "authURI"; + } else if (name.equals("coverage")) { + ver[1] = 1; + res = "category"; + } else if (name.equals("creator") | name.equals("contactEmail")) { + ver[2] = 1; + res = "contact_email"; + } else if (name.equals("source")) { + ver[3] = 1; + res = "URL"; + } else if (name.equals("performs_task") | name.equals("serviceType")) { + ver[4] = 1; + res = "service_type_uri"; + } else if (name.equals("title") | name.equals("serviceName")) { + ver[5] = 1; + res = "servicename"; + } else if (name.equals("description") | name.equals("comment")) { + ver[6] = 1; + res = "description"; + } else if (name.equals("authoritative")) { + ver[7] = 1; + res = "authoritative"; + } else if (name.equals("signatureURL")) { + res = "signatureURL"; + } + + return res; + } + + /** + * mapping RDF input/output data to the database data + * + * @param name - + * the name of predicate in the RDF of service + * @return String field name in database corresponding with this predicate + * + */ + + public String getInpOutName(String name) { + String res = ""; + if (name.equals("article_name") | name.equals("articleName")) { + res = "articleName"; + } - Resource si = servDescrMd.getResource(resource); - - - try{ - Resource consumes = si.getRequiredProperty(MP.produces).getResource(); - StmtIterator p23iter = consumes.listProperties(); - - while (p23iter.hasNext()) { - - Hashtable simout = new Hashtable(); - Hashtable colout = new Hashtable(); - StringBuffer simpns = new StringBuffer(); -// StringBuffer colons = new StringBuffer(); - - Statement l3iter = p23iter.nextStatement(); - Resource l3Res = l3iter.getResource(); - - if (l3Res.isAnon()){ - Object type = l3Res.getRequiredProperty(RDF.type).getObject(); -//System.out.println("type_out = "+type); - if (type.equals(MP.Simple)){ - StmtIterator p34iter = l3Res.listProperties(); - - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - String l4Pred1 = l4iter.getPredicate().toString(); - String l4Node1 = l4iter.getObject().toString(); - String[] result = l4Pred1.split("#"); - int i = (result.length)-1; - - String name = getInpOutName(result[i]); - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Simple output <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Simple output <"+result[i]+">"); - simple = "error"; - continue; - } - if (name.equals("type")){ - continue; - } - String[] rezNode1 = l4iter.getObject().toString().split(":http:"); - String l4Nodestr = rezNode1[0]; - if (name.equals("namespace_type_uris")){ - simout.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l4Nodestr); - if (simpns.length()==0){ - simpns.append(lsid_nsp); - }else{ - simpns.append(","+lsid_nsp); - } - - simout.put(name,simpns.toString()); - } - else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l4Nodestr); - simout.put(name,lsid_nsp); - } - else{ - simout.put(name,l4Nodestr); - } - } - if (simout.isEmpty()){ - }else{ - output.put("simout"+so,simout); // to add Simple to Output - so+=1; - Enumeration num = simout.keys(); - - } - } - - else if (type.equals(MP.Collection) | type.equals(RDF.Bag)){ -// if (l3Res.hasProperty(RDF.type,RDF.Bag) && l3Res.hasProperty(RDF.li(1))){ - - if (l3Res.hasProperty(RDF.li(1))){ - StmtIterator p34iter = l3Res.listProperties(); - - if (l3Res.hasProperty(MP.article_name)){ - String col_artName = l3Res.getProperty(MP.article_name).getObject().toString(); - String[] rezNode = col_artName.split(":http:"); - col_artName = rezNode[0]; - colout.put("col_articleName",col_artName); - } - while (p34iter.hasNext()) { - Statement l4iter = p34iter.nextStatement(); - Property l4Pred = l4iter.getPredicate(); - Node l4Node = l4iter.getObject().asNode(); - - if (l4Node.isBlank()){ - Resource l4Res = l4iter.getResource(); - StmtIterator p45iter = l4Res.listProperties(); - if(p45iter.hasNext()) { - StringBuffer sumns = new StringBuffer(); - while (p45iter.hasNext()) { - Statement l5iter = p45iter.nextStatement(); - String l5Pred = l5iter.getPredicate().toString(); - Node l5Node = l5iter.getObject().asNode(); - String[] result = l5Pred.split("#"); - int i = (result.length)-1; - String name = getInpOutName(result[i]); - if (name.equals("")){ - Report.doWrite("BAD STRUCTURE: Unknown name of predicate for Collection output <"+result[i]+">"); - Report.add("BAD STRUCTURE: Unknown name of predicate for Collection output <"+result[i]+">"); - String Collection = "error"; - break; - } - String[] rezNode = l5iter.getObject().toString().split(":http:"); - String l5Nodestr = rezNode[0]; - if (name.equals("namespace_type_uris")){ - colout.remove("namespace_type_uris"); - String lsid_nsp = switchURItoLSID(l5Node.toString()); - if (sumns.length()==0){ - sumns.append(lsid_nsp); - }else{ - sumns.append(","+lsid_nsp); - } - - colout.put(name,sumns.toString()); -// sumns.append(l5Node+","); - }else if (name.equals("object_type_uri")){ - String lsid_nsp = switchURItoLSID(l5Node.toString()); - colout.put(name,lsid_nsp); - } - else{ - colout.put(name,l5Node); - } - } - output.put("colout"+co,colout); - co+=1; - Enumeration num = colout.keys(); - } - } - - } - }else{ - collection = "error"; - Report.doWrite("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); - Report.add("BAD STRUCTURE: The Collection output isn't 'Bag' type or have not members"); - - } - } - } - } - - if (simple.equals("error") | collection.equals("error")){ - output.put("output","error"); - } - }catch(Exception e){ - Log.warning("Failed:"+ e); - } -//System.out.println("output = "+output); - return output; - } - - -/** mapping RDF data to the database data - * @param name - the name of predicate in the RDF of service - * @return String field name in database corresponding with this predicate - * - */ - - -public String getFieldName(String name){ - String res = ""; - - if (name.equals("publisher") | name.equals("authURI")){ - ver[0] = 1; - res = "authURI"; - } - else if (name.equals("coverage")){ - ver[1] = 1; - res = "category"; - } - else if (name.equals("creator") | name.equals("contactEmail")){ - ver[2] = 1; - res = "contact_email"; - } - else if (name.equals("source") ){ - ver[3] = 1; - res = "URL"; - } - else if (name.equals("performs_task") | name.equals("serviceType")){ - ver[4] = 1; - res = "service_type_uri"; - } - else if (name.equals("title") | name.equals("serviceName")){ - ver[5] = 1; - res = "servicename"; - } - else if (name.equals("description") | name.equals("comment")){ - ver[6] = 1; - res = "description"; - } - else if (name.equals("authoritative") ){ - ver[7] = 1; - res = "authoritative"; - } - else if (name.equals("signatureURL") ){ - res = "signatureURL"; - } - - return res; -} - -/** mapping RDF input/output data to the database data - * @param name - the name of predicate in the RDF of service - * @return String field name in database corresponding with this predicate - * - */ - -public String getInpOutName(String name){ - String res = ""; - if (name.equals("article_name") | name.equals("articleName")){ - res = "articleName"; - } - - else if (name.equals("object_type")){ - res = "object_type_uri"; - } - else if (name.equals("namespace_type")){ - res = "namespace_type_uris"; - } - else if (name.equals("type")){ - res = "type"; - } - - return res; -} - -/** mapping RDF Secondary data to the database data - * @param name - the name of predicate in the RDF of service - * @return String field name in database corresponding with this predicate - * - */ - -public String getSecondaryName(String name){ - String res = ""; - - if (name.equals("article_name") | name.equals("articleName")){ - res = "article_name"; - } - - if (name.equals("default_value")){ - res = "default"; - } - if (name.equals("datatype")){ - res = "datatype"; - } - if (name.equals("max")){ - res = "max"; - } - if (name.equals("min")){ - res = "min"; - } - if (name.equals("enum")){ - res = "enum"; - } - if (name.equals("type")){ - res = "type"; - } - - return res; -} - -public String switchURItoLSID(String uri){ - String lsid = ""; - -try{ - - - if (uri.substring(0,4).equals("http")){ - String[] result = uri.split("/"); - if ((result.length)-1 > 0){ - if (result[2].equals("biomoby.org")){ - String[] result1 = result[5].split("#"); - if ((result1.length)-1 > 0){ - if (result1[0].equals("Namespaces")){ - lsid = "urn:lsid:biomoby.org:namespacetype:"+result1[1]; - } - else if (result1[0].equals("Objects")){ - lsid = "urn:lsid:biomoby.org:objectclass:"+result1[1]; - } - else if (result1[0].equals("Services")){ - lsid = "urn:lsid:biomoby.org:servicetype:"+result1[1]; - } - } - } - else { - lsid = uri; - } - } - } - -else if (uri.substring(0,3).equals("urn:")){ - lsid = uri; -} -else { - lsid = ""; -} -}catch (Exception e){ -//System.out.println("False: "+e); - -} - return lsid; -} -} + else if (name.equals("object_type")) { + res = "object_type_uri"; + } else if (name.equals("namespace_type")) { + res = "namespace_type_uris"; + } else if (name.equals("type")) { + res = "type"; + } + + return res; + } + + /** + * mapping RDF Secondary data to the database data + * + * @param name - + * the name of predicate in the RDF of service + * @return String field name in database corresponding with this predicate + * + */ + + public String getSecondaryName(String name) { + String res = ""; + + if (name.equals("article_name") | name.equals("articleName")) { + res = "article_name"; + } + + if (name.equals("default_value")) { + res = "default"; + } + if (name.equals("datatype")) { + res = "datatype"; + } + if (name.equals("max")) { + res = "max"; + } + if (name.equals("min")) { + res = "min"; + } + if (name.equals("enum")) { + res = "enum"; + } + if (name.equals("type")) { + res = "type"; + } + + return res; + } + + public String switchURItoLSID(String uri) { + String lsid = ""; + + try { + + if (uri.substring(0, 4).equals("http")) { + String[] result = uri.split("/"); + if ((result.length) - 1 > 0) { + if (result[2].equals("biomoby.org")) { + String[] result1 = result[5].split("#"); + if ((result1.length) - 1 > 0) { + if (result1[0].equals("Namespaces")) { + lsid = "urn:lsid:biomoby.org:namespacetype:" + + result1[1]; + } else if (result1[0].equals("Objects")) { + lsid = "urn:lsid:biomoby.org:objectclass:" + + result1[1]; + } else if (result1[0].equals("Services")) { + lsid = "urn:lsid:biomoby.org:servicetype:" + + result1[1]; + } + } + } else { + lsid = uri; + } + } + } + + else if (uri.substring(0, 3).equals("urn:")) { + lsid = uri; + } else { + lsid = ""; + } + } catch (Exception e) { + //System.out.println("False: "+e); + + } + return lsid; + } +} \ No newline at end of file From dwang at pub.open-bio.org Thu Jul 28 18:09:21 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu, 28 Jul 2005 14:09:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281809.j6SI9Ltd004932@pub.open-bio.org> dwang Thu Jul 28 14:09:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv4906/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: small correction on a comment moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.58,1.59 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.58 retrieving revision 1.59 diff -u -r1.58 -r1.59 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 15:45:57 1.58 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:09:21 1.59 @@ -845,7 +845,7 @@ return $dbh->{mysql_insertid}; } -# pass in 'type' as LSID term or lsid +# pass in 'type' as a term or lsid sub delete_service{ my ($self, %args) = @_; my $type = $args{type}; From dwang at pub.open-bio.org Thu Jul 28 18:09:46 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu, 28 Jul 2005 14:09:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281809.j6SI9kqU004977@pub.open-bio.org> dwang Thu Jul 28 14:09:46 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv4951/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: slightly more documentation moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/27 22:57:47 1.22 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 18:09:46 1.23 @@ -399,14 +399,58 @@ } # secondary_input table functions +=head2 query_secondary_input + + Title : query_secondary_input + Usage : my $un = $API->query_secondary_input(%args) + Function : Executes a query for Secondary input articles in the database + Args : service_instance_lsid => String + Returns : listref of hashrefs: + [{secondary_input_id => Integer, + default_value => String, + maximum_value => Float, + minimum_value => Float, + enum_value => String, + datatype => String, + article_name => String, + service_instance_id => Integer}] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_secondary_input{ die "query_secondary_input not implemented in adaptor\n"; } +=head2 insert_secondary_input + + Title : insert_secondary_input + Usage : my $un = $API->insert_secondar_input(%args) + Function : Inserts a Secondary input into the database + Args : default_value => String, + maximum_value => Float, + minimum_value => Float, + enum_value => String, + datatype => String, + article_name => String, + service_instance_lsid => String + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_secondary_input{ die "insert_secondary_input not implemented in adaptor\n"; } +=head2 delete_secondary_input + + Title : delete_secondary_input + Usage : my $un = $API->delete_secondary_input(%args) + Function : Deletes a Secondary input from the database + Args : service_instance_lsid => String + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_secondary_input{ die "delete_secondary_input not implemented in adaptor\n"; } @@ -478,8 +522,8 @@ Returns : listref of hashrefs: [{assertion_id => Integer, relationship_type => String, - object1_id => Integer, - object2_id => Integer, + object1_id => String, + object2_id => String, object2_articlename => String}] Notes : Only allows querying by lsid or type term =cut @@ -492,9 +536,9 @@ Title : insert_object_term2term Usage : my $un = $API->insert_object_term2term(%args) Function : Inserts an object relationship into the database - Args : relationship_type => String, - object1_id => Integer, - but may be string if lsid? - object2_id => Integer, - but may be string if lsid? + Args : relationship_type => String, + object1_id => String, + object2_id => String, object2_articlename => String Returns : Integer insertid Notes : the fact that it returns an insertid is bad since this @@ -713,10 +757,10 @@ Returns : listref of hashrefs: [{assertion_id => Integer, relationship_type => String, - service1_id => Integer, - service2_id => Integer}] + service1_id => String, + service2_id => String}] Notes : the fact that it returns an service ids is bad since this - is only useful to an SQL-based API... + is only useful to an SQL-based API...should return lsids =cut sub query_service_term2term{ die "query_service_term2term not implemented in adaptor\n"; @@ -843,8 +887,9 @@ Returns : listref of hashrefs: [{assertion_id => Integer, relationship_type => String, - namespace1_id => Integer, - namespace2_id => Integer}] + namespace1_id => String, + namespace2_id => String}] + Notes : namespace1_id and namespace2_id will be lsids =cut # namespace_term2term table functions From mwilkinson at pub.open-bio.org Thu Jul 28 18:33:10 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 14:33:10 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281833.j6SIXA4T005141@pub.open-bio.org> mwilkinson Thu Jul 28 14:33:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv5118/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: this code should now be compliant with the 0.85 version of teh API. All situations where MOBY Central used to return an ontology term, it now returns both the term and its LSID. The behaviour SHOULD be consistent throughout all messages - a term is the content of a node, while its LSID is an attribute of the node. moby-live/Perl/MOBY Central.pm,1.188,1.189 OntologyServer.pm,1.67,1.68 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.188 retrieving revision 1.189 diff -u -r1.188 -r1.189 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/27 17:29:10 1.188 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 18:33:10 1.189 @@ -1102,12 +1102,12 @@ =over 3 -=item * Simple +=item * Simple (note that the lsid attribute of the objectType and Namespace element need only be present in the article when it is present in a response document from MOBY Central such as the result of a findService call. These attributes are ignored by MOBY Central when they appear in input messages such as registerService) - ObjectOntologyTerm - NamespaceTerm - ... + ObjectOntologyTerm + NamespaceTerm + ... =item * Collection note that articleName of the contained Simple objects is not required, and is ignored. @@ -1832,7 +1832,7 @@ - Service_Ontology_Term + Service_Ontology_Term moby 1 your at email.address @@ -2401,8 +2401,9 @@ authority_uri => $AuthURI, servicename => $serviceName ); + my $servlsid = $SI->lsid; my $wsdls; - return "" unless ($SI); + return "" unless ($SI); if ( $SI->category eq 'moby' ) { my $wsdl = &_getServiceWSDL( $SI, $InputXML, $OutputXML, $SecondaryXML ); @@ -2410,7 +2411,7 @@ if ( $wsdl =~ /[^\]]+))\]\]>/ ) { $wsdl = $1; } - $wsdls .= "\n"; + $wsdls .= "\n"; } #$debug && &_LOG("WSDL_________________$wsdls\n____________________"); @@ -2498,7 +2499,7 @@ Args : none XML : - + ... ... @@ -2514,7 +2515,10 @@ my $result = $adaptor->get_service_names(); my $names = "\n"; foreach my $row (@$result) { - $names .= "\n"; + my $name = $row->{servicename}; + my $auth = $row->{authority_uri}; + my $lsid = $row->{lsid}; + $names .= "\n"; } $names .= "\n"; return $names; @@ -2543,12 +2547,13 @@ my $OS = MOBY::OntologyServer->new( ontology => 'service' ); my %types = %{ $OS->retrieveAllServiceTypes() }; my $types = "\n"; - while ( my ( $serv, $desc ) = each %types ) { + while ( my ( $serv, $descr ) = each %types ) { + my ($desc, $lsid) = @$descr; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $types .= -"\n\n\n"; +"\n\n\n"; } $types .= "\n"; return $types; @@ -2583,14 +2588,15 @@ my $OS = MOBY::OntologyServer->new( ontology => 'relationship' ); my %types = %{ $OS->getRelationshipTypes( ontology => $ontology ) }; my $types = "\n"; - while ( my ( $name, $authdesc ) = each %types ) { - my $auth = $authdesc->[0]; - my $desc = $authdesc->[1]; + while ( my ( $lsid, $authdesc ) = each %types ) { + my $name = $authdesc->[0]; + my $auth = $authdesc->[1]; + my $desc = $authdesc->[2]; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $types .= -"\n\n\n"; +"\n\n\n"; } $types .= "\n"; return $types; @@ -2619,12 +2625,13 @@ my $OS = MOBY::OntologyServer->new( ontology => 'object' ); my %types = %{ $OS->retrieveAllObjectTypes() }; my $obj = "\n"; - while ( my ( $name, $desc ) = each %types ) { + while ( my ( $name, $descr ) = each %types ) { + my ($desc, $lsid) = @$descr; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $obj .= -"\n\n\n"; +"\n\n\n"; } $obj .= "\n"; return $obj; @@ -2648,8 +2655,8 @@ human readable description of data type]]> - - ExistingObjectType + + ExistingObjectType ... ... @@ -2679,7 +2686,7 @@ } my $response; $response = " - $def{objectType} + $def{objectType} $def{authURI} $def{contactEmail}\n"; @@ -2688,10 +2695,10 @@ while ( my ( $rel, $objdefs ) = each %relationships ) { $response .= "\n"; foreach my $def ( @{$objdefs} ) { - my ( $lsid, $articlename ) = @{$def}; + my ( $lsid, $articlename,$type, $def, $auth, $contac ) = @{$def}; $articlename = "" unless defined $articlename; $response .= - "$lsid\n"; + "$type\n"; } $response .= "\n"; } @@ -2722,12 +2729,13 @@ my $OS = MOBY::OntologyServer->new( ontology => 'namespace' ); my %types = %{ $OS->retrieveAllNamespaceTypes() }; my $ns = "\n"; - while ( my ( $namespace, $desc ) = each %types ) { + while ( my ( $namespace, $descr ) = each %types ) { + my ($desc, $lsid, $auth, $contact) = @$descr; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } $ns .= -"\n\n\n"; +"\n\n\n"; } $ns .= ""; return $ns; @@ -2810,8 +2818,8 @@ outputXML : - ExistingServiceType - ExistingServiceType + ExistingServiceType + ExistingServiceType .... @@ -2822,8 +2830,8 @@ - ExistingServiceType - ExistingServiceType + ExistingServiceType + ExistingServiceType .... @@ -2858,25 +2866,19 @@ } my $term = &_nodeTextContent( $doc, "objectType" ); $ontology = "object" - if $term - ; # pick up the ontology "object" that we used here if we got an object term + if $term; # pick up the ontology "object" that we used here if we got an object term $term ||= - &_nodeTextContent( $doc, "serviceType" ) - ; # if we didn't get anything using objectType try serviceType + &_nodeTextContent( $doc, "serviceType" ); # if we didn't get anything using objectType try serviceType return undef unless $term; # and bail out if we didn't succeed - $ontology ||= "service" - ; # if we have now succeeded and haven't already taken the ontology then it must be the service ontology + $ontology ||= "service"; # if we have now succeeded and haven't already taken the ontology then it must be the service ontology &_LOG("Ontology was $ontology; Term was $term\n"); my $OS = MOBY::OntologyServer->new( ontology => $ontology ); - my %rels = - %{ $OS->Relationships( term => $term, expand => $expand_relationship ) - }; # %rels = $rels{relationship} = [lsid, lsid,lsid] + my %rels = %{ $OS->Relationships( term => $term, expand => $expand_relationship )}; # %rels = $rels{relationship} = [lsid, lsid,lsid] my $response = "\n"; my $OSrel = MOBY::OntologyServer->new( ontology => 'relationship' ); foreach ( keys %reltypes ) { # for each of our desired types - my $rellsid = - $OSrel->getRelationshipURI( $ontology, $_ ); # get the LSID + my $rellsid = $OSrel->getRelationshipURI( $ontology, $_ ); # get the LSID delete $reltypes{$_}; # remove the non-LSID version from the hash $reltypes{$rellsid} = 1; # set the LSID as valid } @@ -2886,15 +2888,17 @@ my $rellsid = $OSrel->getRelationshipURI( $ontology, $_ ); next unless $rellsid; if ( keys %reltypes ) { - next - unless $reltypes{ $rellsid - }; # next unless it is one ofthe relationship types we requested + next unless $reltypes{ $rellsid}; # next unless it is one ofthe relationship types we requested } my $lsids = $rels{$rellsid}; next unless $lsids->[0]; - $response .= "\n"; + $response .= "\n"; foreach my $lsid ( @{$lsids} ) { - $response .= "<${ontology}Type>$lsid\n"; + # ugh... I have to cheat here because the term is not returned from the Ontology Server + # one day we may have to fix this... + $lsid =~ /urn\:lsid\:[^\:]+\:[^\:]+\:([^\:]+)/; # get the term portion of the LSID + $term = $1; + $response .= "<${ontology}Type lsid='$lsid'>$term\n"; } $response .= "\n"; } @@ -3314,10 +3318,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\n"; - $output .= "\t\t\t$objName\n"; + $output .= "\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t$NSname\n" if $NSname; + $output .= "\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\n"; } @@ -3342,10 +3346,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t\t$NSname\n" + $output .= "\t\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\t\n"; @@ -3368,10 +3372,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\n"; - $output .= "\t\t\t$objName\n"; + $output .= "\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t$NSname\n" if $NSname; + $output .= "\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\n"; } @@ -3394,10 +3398,10 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); - $output .= "\t\t\t\t$NSname\n" + $output .= "\t\t\t\t$NSname\n" if $NSname; } $output .= "\t\t\t\n"; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 16:00:10 1.67 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 18:33:10 1.68 @@ -321,11 +321,16 @@ my $relationship_type = $row->{relationship_type}; my $objectlsid = $row->{object_lsid}; my $article = $row->{object2_articlename}; + my $contact = $row->{contact_email}; + my $def = $row->{definition}; + my $auth = $row->{authority}; + my $type = $row->{object_type}; - push @{ $rel{$relationship_type} }, [ $objectlsid, $article ]; + push @{ $rel{$relationship_type} }, [ $objectlsid, $article, $type, $def, $auth, $contact ]; } return { - objectType => $lsid, + objectType => $type, + objectLSID => $lsid, description => $desc, contactEmail => $contact, authURI => $auth, @@ -845,7 +850,7 @@ my %response; foreach (@$types) { - $response{ $_->{service_type} } = $_->{description}; + $response{ $_->{service_type} } = [$_->{description}, $_->{service_lsid}]; } return \%response; } @@ -862,7 +867,7 @@ my %response; foreach (@$types) { - $response{ $_->{namespace_type} } = $_->{description}; + $response{ $_->{namespace_type} } = [$_->{description}, $_->{namespace_lsid}, $_->{authority}, $_->{contact_email}]; } return \%response; } @@ -879,7 +884,7 @@ my %response; foreach (@$types) { - $response{ $_->{object_type} } = $_->{description}; + $response{ $_->{object_type} } = [$_->{description}, $_->{object_lsid}]; } return \%response; } @@ -1065,11 +1070,8 @@ push @{ $results{$rel} }, $lsid; } last unless ($expand); - last - unless ( $direction eq "root" ) - ; # if we aren't going to root, then be careful or we'll loop infnitely - $term = $lsid - ; # this entire subroutine assumes that there is NOT multiple parenting... + last unless ( $direction eq "root" ); # if we aren't going to root, then be careful or we'll loop infnitely + $term = $lsid; # this entire subroutine assumes that there is NOT multiple parenting... } return \%results; #results(relationship} = [lsid1, lsid2, lsid3] } From mwilkinson at pub.open-bio.org Thu Jul 28 18:33:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 14:33:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281833.j6SIXBwR005160@pub.open-bio.org> mwilkinson Thu Jul 28 14:33:10 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5118/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: this code should now be compliant with the 0.85 version of teh API. All situations where MOBY Central used to return an ontology term, it now returns both the term and its LSID. The behaviour SHOULD be consistent throughout all messages - a term is the content of a node, while its LSID is an attribute of the node. moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.59,1.60 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.59 retrieving revision 1.60 diff -u -r1.59 -r1.60 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:09:21 1.59 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:33:10 1.60 @@ -1288,8 +1288,12 @@ my $id = $row->{object_id}; my $statement = "select - relationship_type, - object_lsid, + relationship_type, + object_type, + object_lsid, + description, + authority, + contact_email, object2_articlename from object_term2term, object where object1_id = ? and object2_id = object_id"; From dwang at pub.open-bio.org Thu Jul 28 19:26:58 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu, 28 Jul 2005 15:26:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281926.j6SJQwfe005364@pub.open-bio.org> dwang Thu Jul 28 15:26:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5338/Perl/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: should be querying for collection_output_id instead of collection_input_id in delete_simple_output moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.60,1.61 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 18:33:10 1.60 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 19:26:58 1.61 @@ -413,7 +413,7 @@ my ($collid) = $args{collection_output_id}; my $statement1; my $statement2; $siid && ($statement1 = "delete from simple_output where service_instance_id = ?"); - $collid && ($statement2 = "delete from simple_output where collection_input_id = ?"); + $collid && ($statement2 = "delete from simple_output where collection_output_id = ?"); $siid && ($dbh->do( $statement1, undef,($siid))); $collid && ($dbh->do($statement2, undef,($collid))); From dwang at pub.open-bio.org Thu Jul 28 19:45:26 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Thu, 28 Jul 2005 15:45:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507281945.j6SJjQrs005436@pub.open-bio.org> dwang Thu Jul 28 15:45:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv5410/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: and more.. moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 18:09:46 1.23 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 19:45:26 1.24 @@ -367,33 +367,56 @@ # # simple_output table functions # +=head2 query_simple_output + + Title : query_simple_output + Usage : my $un = $API->query_simple_output(%args) + Function : Executes a query for Simput outputs according to the service instance or collection output + Args : service_instance_lsid => String, + collection_output_id => Integer + Returns : listref of hashrefs: + [{simple_output_id => Integer, + object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_id => Integer, + collection_output_id => Integer}] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_simple_output{ die "query_simple_output not implemented in adaptor\n"; } +=head2 insert_simple_output + + Title : inse_simple_output + Usage : my $un = $API->insert_simple_output(%args) + Function : Inserts a Simple output into the database + Args : object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_lsid => String, + collection_output_id => Integer + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_simple_output { die "insert_simple_output not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - # - #$dbh->do("insert into simple_output - # (object_type_uri, - # namespace_type_uris, - # article_name, - # service_instance_id, - # collection_output_id) - # values (?,?,?,?,?)", - # undef, - # ($args{object_type_uri}, - # $args{namespace_type_uris}, - # $args{article_name}, - # $args{service_instance_id}, - # $args{collection_output_id})); - #my $id=$dbh->{mysql_insertid}; - #return $id; - } +=head2 delete_simple_output + + Title : delete_simple_output + Usage : my $un = $API->delete_simple_output(%args) + Function : Deletes Simple outputs according to the service instance, or collection output + Args : service_instance_lsid => String, + collection_output_id => Integer + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_simple_output{ die "delete_simple_output not implemented in adaptor\n"; } From mwilkinson at pub.open-bio.org Thu Jul 28 20:41:24 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 16:41:24 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282041.j6SKfOaC005675@pub.open-bio.org> mwilkinson Thu Jul 28 16:41:24 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv5656/t Modified Files: Client-Central.t Log Message: adding more tests to ensure that collection registration is functioning properly. All existing tests now pass on the new codebase 0.85 moby-live/Perl/t Client-Central.t,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/22 23:25:06 1.10 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 20:41:24 1.11 @@ -15,8 +15,8 @@ # Test 2 my $C = MOBY::Client::Central->new( Registries => { - mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/MOBY-Central.pl', - URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} + mobycentral => { URL => 'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/MOBY-Central.pl', + URI => 'http://mobycentral.icapture.ubc.ca/MOBY/Central'} } ); @@ -239,7 +239,102 @@ is($enum =~/\|10\|/, 1) or diag("enum element missing"); is($enum =~/\|0\|/, 1) or diag("enum element missing"); -# Test 12 + +$r = $C->registerService( + serviceName => "mysecondservice", + serviceType => "Retrieval", + authURI => "test.suite.com", + contactEmail => 'your at mail.address', + description => "this is my second service", + category => "moby", + URL => "http://illuminae/cgi-bin/service.pl", + input =>[ + ['articleName1', [[Object => ['UglyNamespace']]]], # Simple + ], + output =>[ + ['articleName2', [[String => ['UglyNamespace']]]], # Simple + ], + secondary => { + parametername1 => { + datatype => 'Integer', + default => 0, + max => 10, + min => -10, + enum => [-10, 10, 0]}}); + +( ok($r->success,"Service registration of collections successful") +) or diag("Service registration of collections failure: ".$r->message) ; + +# test 11 - find by auth & name +($si, $r) = $C->findService( + serviceName => "mysecondservice", + authURI => "test.suite.com"); +( is($r, undef, "Service discovery of collections successful") +) or diag("Service discovery of collections failure") ; + + + + + + +isa_ok($si, 'ARRAY') or diag("findService with collections didn't return an array ref"); +is(scalar(@$si),1) or diag("findService with collections found too many services"); +$SI = shift @$si; +print STDERR "$SI"; +isa_ok($SI, 'MOBY::Client::ServiceInstance') or diag("findService collections didn't return a MOBY::Client::ServceInstance"); +isa_ok($SI->input, ARRAY) or diag ("ServiceInstance object input is not a listref (collections test)"); +isa_ok($SI->output, ARRAY) or diag ("ServiceInstance object output is not a listref (collections test)"); +is($SI->name, "mysecondservice") or diag("servicename wrong (collections test)"); +is($SI->authoritative, 0) or diag("service reported to be incorrectly authoritative (collections test)"); +is($SI->authority, "test.suite.com") or diag("authURI incorrect (collections test)"); +is($SI->type, "Retrieval") or diag("service type incorrect (collections test)"); +is($SI->description, "this is my first service") or diag("service description wrong (collections test)"); +is($SI->URL, "http://illuminae/cgi-bin/service.pl") or diag("service URL incorrect (collections test)"); +is($SI->contactEmail, 'your at mail.address') or diag("contact email incorrect (collections test)"); +is($SI->category, "moby") or diag("service category incorrect (collections test)"); + + at ins = @{$SI->input}; + at outs = @{$SI->output}; + at secs = @{$SI->secondary}; +is(scalar(@ins), 1) or diag("incorrect number of inputs in servce instance (collections test)"); +is(scalar(@outs), 1) or diag("incorrect number of outputs in servce instance (collections test)"); +is(scalar(@secs), 1) or diag("incorrect number of secodary in servce instance (collections test)"); + +$in = shift @ins; +$out = shift @outs; +$sec = shift @secs; + +isa_ok($in, 'MOBY::Client::CollectionArticle') or diag("->inputs did not return a MOBY::collection_input object or client parser failed for MOBY::Client::CollectionArticle"); +isa_ok($out, 'MOBY::Client::CollectionArticle') or diag("->outputs did not return a MOBY::collection_output object or client parser failed for MOBY::Client::CollectionArticle"); +isa_ok($sec, 'MOBY::Client::SecondaryArticle') or diag("->secondarues did not return a MOBY::secondary_input object"); + +isa_ok($in->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); +isa_ok($out->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); +my $simplesin = $in->Simples; +my $simplesout = $out->Simples; + +is(scalar(@$simplesin), 1) or diag("->Simples returning wrong number of simple inputs in the collection"); +is(scalar(@$simplesout), 1) or diag("->Simples returning wrong number of simple outputs in the collection"); + +$in = shift(@$simplesin); +$out = shift(@$simplesout); + +is($in->objectType, "Object") or diag("simple input type reported incorrectly (collections test)"); +is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly (collections test)"); +isa_ok($in->namespaces, 'ARRAY') or diag("simple input namespaces not returned as an arrayref (collections test)"); + at ns = @{$in->namespaces}; +is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces (collections test)"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace (collections test)"); + +is($out->objectType, "String") or diag("simple output type reported incorrectly (collections test)"); +is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly (collections test)"); +isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref (collections test)"); + at ns = @{$out->namespaces}; +is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces (collections test)"); +$ns = shift @ns; +is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace (collections test)"); + $r = $C->deregisterService( serviceName => "myfirstservice", @@ -249,6 +344,19 @@ ) or diag("Service deregistration failure: ".$r->message) ; +$r = $C->deregisterService( + serviceName => "myfirstservice", + authURI => "test.suite.com", + ); +( ok(!$r->success,"Service deregistration successful") +) or diag("Service re-deregistration success (should have failed): ".$r->message) ; + +$r = $C->deregisterService( + serviceName => "mysecondservice", + authURI => "test.suite.com", + ); +( ok($r->success,"Service deregistration successful") +) or diag("Service deregistration failure (second service): ".$r->message) ; From mwilkinson at pub.open-bio.org Thu Jul 28 21:13:16 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:13:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282113.j6SLDG6c005809@pub.open-bio.org> mwilkinson Thu Jul 28 17:13:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv5790/MOBY Modified Files: Central.pm Log Message: wrong kinds of brackets in query for collection moby-live/Perl/MOBY Central.pm,1.189,1.190 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.189 retrieving revision 1.190 diff -u -r1.189 -r1.190 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 18:33:10 1.189 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:13:16 1.190 @@ -3303,8 +3303,6 @@ $output .= "\t$url\n"; $output .= "\t\n"; -#************FIX -#************FIX : $_ here should also be an LSID... $result = $adaptor->query_simple_input(service_instance_lsid => $lsid); foreach my $row (@$result) From mwilkinson at pub.open-bio.org Thu Jul 28 21:13:16 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:13:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282113.j6SLDGfY005828@pub.open-bio.org> mwilkinson Thu Jul 28 17:13:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5790/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: wrong kinds of brackets in query for collection moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.61,1.62 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.61 retrieving revision 1.62 diff -u -r1.61 -r1.62 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 19:26:58 1.61 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:13:16 1.62 @@ -189,7 +189,7 @@ collection_input_id, article_name from collection_input as c, service_instance as si where si.service_instance_id = c.service_instance_id and si.lsid = ?"; - my $result = do_query($dbh, $statement, [$serv_lsid]); + my $result = do_query($dbh, $statement, ($serv_lsid)); return $result; } @@ -232,7 +232,7 @@ article_name, service_instance_id from collection_output where service_instance_id = ? "; - my $result = do_query($dbh, $statement, [$siid]); + my $result = do_query($dbh, $statement, ($siid)); return $result; } From mwilkinson at pub.open-bio.org Thu Jul 28 21:13:16 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:13:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282113.j6SLDGKi005848@pub.open-bio.org> mwilkinson Thu Jul 28 17:13:16 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv5790/t Modified Files: Client-Central.t Log Message: wrong kinds of brackets in query for collection moby-live/Perl/t Client-Central.t,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 20:41:24 1.11 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:13:16 1.12 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; #use SOAP::Lite +trace; -use Test::More tests => 54; # perldoc Test::More for details +use Test::More tests => 91; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; @@ -181,7 +181,6 @@ isa_ok($si, 'ARRAY') or diag("findService didn't return an array ref"); is(scalar(@$si),1) or diag("findService found too many services"); $SI = shift @$si; -print STDERR "$SI"; isa_ok($SI, 'MOBY::Client::ServiceInstance') or diag("findService didn't return a MOBY::Client::ServceInstance"); isa_ok($SI->input, ARRAY) or diag ("ServiceInstance object input is not a listref"); isa_ok($SI->output, ARRAY) or diag ("ServiceInstance object output is not a listref"); @@ -288,7 +287,7 @@ is($SI->authoritative, 0) or diag("service reported to be incorrectly authoritative (collections test)"); is($SI->authority, "test.suite.com") or diag("authURI incorrect (collections test)"); is($SI->type, "Retrieval") or diag("service type incorrect (collections test)"); -is($SI->description, "this is my first service") or diag("service description wrong (collections test)"); +is($SI->description, "this is my second service") or diag("service description wrong (collections test)"); is($SI->URL, "http://illuminae/cgi-bin/service.pl") or diag("service URL incorrect (collections test)"); is($SI->contactEmail, 'your at mail.address') or diag("contact email incorrect (collections test)"); is($SI->category, "moby") or diag("service category incorrect (collections test)"); From mwilkinson at pub.open-bio.org Thu Jul 28 21:26:59 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:26:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282126.j6SLQx1O005938@pub.open-bio.org> mwilkinson Thu Jul 28 17:26:59 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv5919/MOBY Modified Files: Central.pm Log Message: query for collections was wrong moby-live/Perl/MOBY Central.pm,1.190,1.191 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.190 retrieving revision 1.191 diff -u -r1.190 -r1.191 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:13:16 1.190 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:26:59 1.191 @@ -3332,7 +3332,7 @@ $output .= "\t\t\n"; - my $result2 = $adaptor->query_simple_output(service_instance_lsid => undef, collection_input_id => $collid); + my $result2 = $adaptor->query_simple_input(service_instance_lsid => undef, collection_input_id => $collid); foreach my $row2 (@$result2) { my $objURI = $row2->{object_type_uri}; From mwilkinson at pub.open-bio.org Thu Jul 28 21:26:59 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:26:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282126.j6SLQx0l005958@pub.open-bio.org> mwilkinson Thu Jul 28 17:26:59 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv5919/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query for collections was wrong moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.62,1.63 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:13:16 1.62 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:26:59 1.63 @@ -269,6 +269,8 @@ my ($self, %args) = @_; my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $collid = $args{collection_input_id}; + my $id_to_use = $siid?$siid:$collid; + my $dbh = $self->dbh; my $statement = "select @@ -282,10 +284,10 @@ my $condition; $siid && ($condition = " service_instance_id = ? and collection_input_id IS NULL"); - $collid && ($condition = " service_instance_id IS NULL and collection_input_id = ?"); + $collid && ($condition = " collection_input_id = ?"); $statement .= $condition; - my $result = do_query($dbh, $statement, ($siid || $collid)); + my $result = do_query($dbh, $statement, ($id_to_use)); return $result; } @@ -362,6 +364,7 @@ my ($siid) = $self->_getSIIDFromLSID($args{service_instance_lsid}); my $collid = $args{collection_output_id}; my $dbh = $self->dbh; + my $id_to_use = $siid?$siid:$collid; my $statement = "select simple_output_id, @@ -373,11 +376,11 @@ from simple_output where "; my $condition; $siid && ($condition = " service_instance_id = ? and collection_output_id IS NULL"); - $collid && ($condition = " service_instance_id IS NULL and collection_output_id = ?"); + $collid && ($condition = " collection_output_id = ?"); $statement .= $condition; - my $result = do_query($dbh, $statement, ($siid || $collid)); + my $result = do_query($dbh, $statement, ($id_to_use)); return $result; } From mwilkinson at pub.open-bio.org Thu Jul 28 21:28:39 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:28:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282128.j6SLSdeB006026@pub.open-bio.org> mwilkinson Thu Jul 28 17:28:39 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv6007/MOBY Modified Files: Central.pm Log Message: missing quotes around XML attribute moby-live/Perl/MOBY Central.pm,1.191,1.192 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.191 retrieving revision 1.192 diff -u -r1.191 -r1.192 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:26:59 1.191 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:28:39 1.192 @@ -3344,7 +3344,7 @@ my @nsURIs = split ",", $nsURI; $article ||= ""; $output .= "\t\t\t\n"; - $output .= "\t\t\t\t$objName\n"; + $output .= "\t\t\t\t$objName\n"; foreach my $ns (@nsURIs) { my $NSname = $OSns->getNamespaceCommonName($ns); $output .= "\t\t\t\t$NSname\n" From mwilkinson at pub.open-bio.org Thu Jul 28 21:32:57 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:32:57 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282132.j6SLWviB006097@pub.open-bio.org> mwilkinson Thu Jul 28 17:32:57 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv6078/t Modified Files: Client-Central.t Log Message: tests were wrong moby-live/Perl/t Client-Central.t,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:13:16 1.12 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:32:57 1.13 @@ -306,6 +306,8 @@ isa_ok($in, 'MOBY::Client::CollectionArticle') or diag("->inputs did not return a MOBY::collection_input object or client parser failed for MOBY::Client::CollectionArticle"); isa_ok($out, 'MOBY::Client::CollectionArticle') or diag("->outputs did not return a MOBY::collection_output object or client parser failed for MOBY::Client::CollectionArticle"); isa_ok($sec, 'MOBY::Client::SecondaryArticle') or diag("->secondarues did not return a MOBY::secondary_input object"); +is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly (collections test)"); +is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly (collections test)"); isa_ok($in->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); isa_ok($out->Simples, "ARRAY") or diag("->Simples did not return an arrayref (collections test)"); @@ -319,7 +321,6 @@ $out = shift(@$simplesout); is($in->objectType, "Object") or diag("simple input type reported incorrectly (collections test)"); -is($in->articleName, "articleName1") or diag("simple input article name reported incorrectly (collections test)"); isa_ok($in->namespaces, 'ARRAY') or diag("simple input namespaces not returned as an arrayref (collections test)"); @ns = @{$in->namespaces}; is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces (collections test)"); From mwilkinson at pub.open-bio.org Thu Jul 28 21:36:07 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:36:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282136.j6SLa74C006165@pub.open-bio.org> mwilkinson Thu Jul 28 17:36:07 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv6146/MOBY Modified Files: Central.pm Log Message: looking for namespace_type_uri instead of ..._uris moby-live/Perl/MOBY Central.pm,1.192,1.193 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.192 retrieving revision 1.193 diff -u -r1.192 -r1.193 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:28:39 1.192 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:36:07 1.193 @@ -3336,7 +3336,7 @@ foreach my $row2 (@$result2) { my $objURI = $row2->{object_type_uri}; - my $nsURI = $row2->{namespace_type_uri}; + my $nsURI = $row2->{namespace_type_uris}; my $article = $row2->{article_name}; my $objName = $OSobj->getObjectCommonName($objURI); From mwilkinson at pub.open-bio.org Thu Jul 28 21:40:31 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 17:40:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282140.j6SLeVE3006292@pub.open-bio.org> mwilkinson Thu Jul 28 17:40:31 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv6273/t Modified Files: Client-Central.t Log Message: test was wrong moby-live/Perl/t Client-Central.t,1.13,1.14 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:32:57 1.13 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:40:31 1.14 @@ -328,7 +328,6 @@ is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace (collections test)"); is($out->objectType, "String") or diag("simple output type reported incorrectly (collections test)"); -is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly (collections test)"); isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref (collections test)"); @ns = @{$out->namespaces}; is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces (collections test)"); From mwilkinson at pub.open-bio.org Thu Jul 28 22:10:11 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 18:10:11 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282210.j6SMABVG006403@pub.open-bio.org> mwilkinson Thu Jul 28 18:10:11 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv6384/MOBY/Client Modified Files: Central.pm Log Message: starting to update Cient libraries to make LSID avialble moby-live/Perl/MOBY/Client Central.pm,1.101,1.102 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.101 retrieving revision 1.102 diff -u -r1.101 -r1.102 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/22 23:05:04 1.101 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:10:11 1.102 @@ -497,9 +497,10 @@ my ($return) = $self->_call( 'default', 'retrieveObjectDefinition', $message ); return \%def unless $return; - my ( $term, $desc, $relationships, $email, $authURI ) = + my ( $term, $lsid, $desc, $relationships, $email, $authURI ) = &_ObjectDefinitionPayload($return); $def{objectType} = $term; + $def{objectLSID} = $lsid; $def{description} = $desc; $def{contactEmail} = $email; $def{authURI} = $authURI; @@ -516,6 +517,7 @@ my $obj = $Object->nodeName; return undef unless ( $obj eq 'retrieveObjectDefinition' ); my $term = &_nodeTextContent( $Object, "objectType" ); + my $lsid = &_nodeAttributeValue( $Object, "objectType", "lsid"); my $desc = &_nodeCDATAContent( $Object, "Description" ); if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; @@ -1970,6 +1972,32 @@ return $content; } +sub _nodeAttributeContent { + + # will get text of **all** child $node from the given $DOM + # regardless of their depth!! + my ( $DOM, $node, $attr ) = @_; + my $x = $DOM->getElementsByTagName($node); + unless ( $x->get_node(1) ) { return } + my $n = $x->get_node(1); + my @att = $n->attributes($attr); + my $atval; + if (scalar(@att)){ + $atval = $attr->getValue; + } + my @child = $x->get_node(1)->childNodes; + my $content; + foreach (@child) { + + #print getNodeTypeName($_), "\t", $_->toString,"\n"; + next + unless ( ( $_->nodeType == TEXT_NODE ) + || ( $_->nodeType == CDATA_SECTION_NODE ) ); + $content = $_->textContent; + } + return $content; +} + sub _nodeRawContent { # will get XML of **all** child $node from the given $DOM From mwilkinson at pub.open-bio.org Thu Jul 28 22:18:05 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Thu, 28 Jul 2005 18:18:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507282218.j6SMI5bT006471@pub.open-bio.org> mwilkinson Thu Jul 28 18:18:05 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv6452/MOBY/Client Modified Files: Central.pm Log Message: starting to update Cient libraries to make LSID avialble moby-live/Perl/MOBY/Client Central.pm,1.102,1.103 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.102 retrieving revision 1.103 diff -u -r1.102 -r1.103 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:10:11 1.102 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:18:05 1.103 @@ -484,7 +484,8 @@ =cut sub retrieveObjectDefinition { - my ( $self, $id, $reg ) = @_; + my ( $self, %a ) = @_; + my $id = $a{objectType}; return $self->errorRegXML( "Function not allowed when querying multiple registries") if $self->multiple_registries; From dwang at pub.open-bio.org Fri Jul 29 07:50:04 2005 From: dwang at pub.open-bio.org (Dennis Wang) Date: Fri, 29 Jul 2005 03:50:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507290750.j6T7o4db007547@pub.open-bio.org> dwang Fri Jul 29 03:50:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby In directory pub.open-bio.org:/tmp/cvs-serv7522/Perl/MOBY/Adaptor/moby Modified Files: queryapi.pm Log Message: almost there moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/28 19:45:26 1.24 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm 2005/07/29 07:50:04 1.25 @@ -295,15 +295,36 @@ Notes : the fact that it returns a collection_input_id is bad since this is only useful to an SQL-based API... =cut - sub query_collection_input{ die "query_collection_input not implemented in adaptor\n"; } +=head2 insert_collection_input + + Title : insert_collection_input + Usage : my $un = $API->insert_collection_input(%args) + Function : Inserts a Collection input into the database + Args : article_name => String, + service_instance_lsid => String, + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_collection_input { die "insert_collection_input not implemented in adaptor\n"; } +=head2 delete_collection_input + + Title : delete_collection_input + Usage : my $un = $API->delete_collection_input(%args) + Function : Deletes Collection inputs according to the service instance + Args : service_instance_lsid => String, + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_collection_input{ die "delete_collection_input not implemented in adaptor\n"; } @@ -311,10 +332,34 @@ # # collection_output table fuctions # +=head2 query_collection_output + + Title : query_collection_output + Usage : my $un = $API->query_collection_output(%args) + Function : Executes a query for Collection outputs according to the service instance + Args : service_instance_lsid => String, + Returns : listref of hashrefs: + [{collection_output_id => Integer, + article_name => String, + service_instance_id => Integer, + }] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_collection_output{ die "query_collection_output not implemented in adaptor\n"; } +=head2 insert_collection_output + + Title : insert_collection_output + Usage : my $un = $API->insert_collection_output(%args) + Function : Inserts a Collection output into the database + Args : article_name => String, + service_instance_lsid => String, + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_collection_output { die "insert_collection_output not implemented in adaptor\n"; #my ($self, %args) = @_; @@ -327,6 +372,17 @@ #} } +=head2 delete_collection_output + + Title : delete_collection_output + Usage : my $un = $API->delete_collection_output(%args) + Function : Deletes Collection outputs according to the service instance + Args : service_instance_lsid => String, + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_collection_output{ die "delete_collection_output not implemented in adaptor\n"; } @@ -334,32 +390,56 @@ # # simple_output table functions # +=head2 query_simple_input + + Title : query_simple_input + Usage : my $un = $API->query_simple_input(%args) + Function : Executes a query for Simple inputs according to the service instance or collection output + Args : service_instance_lsid => String, + collection_input_id => Integer + Returns : listref of hashrefs: + [{simple_input_id => Integer, + object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_id => Integer, + collection_input_id => Integer}] + Notes : Only allows querying by lsid or type term, so service_instance_id is retrieved from lsid or term +=cut sub query_simple_input{ die "query_simple_input not implemented in adaptor\n"; } +=head2 insert_simple_input + + Title : insert_simple_input + Usage : my $un = $API->insert_simple_input(%args) + Function : Inserts a Simple input into the database + Args : object_type_uri => String, + namespace_type_uris => String, + article_name => String, + service_instance_lsid => String, + collection_input_id => Integer + Returns : Integer insertid + Notes : the fact that it returns an insertid is bad since this + is only useful to an SQL-based API... +=cut sub insert_simple_input { die "insert_simple_input not implemented in adaptor\n"; - #my ($self, %args) = @_; - #my $dbh = $self->dbh; - # - #$dbh->do("insert into simple_input - # (object_type_uri, - # namespace_type_uris, - # article_name, - # service_instance_id, - # collection_input_id) - # values (?,?,?,?,?)", - # undef, - # ($args{object_type_uri}, - # $args{namespace_type_uris}, - # $args{article_name}, - # $args{service_instance_id}, - # $args{collection_input_id})); - #my $id=$dbh->{mysql_insertid}; - #return $id; } +=head2 delete_simple_input + + Title : delete_simple_input + Usage : my $un = $API->delete_simple_input(%args) + Function : Deletes Simple inputs according to the service instance, or collection input + Args : service_instance_lsid => String, + collection_input_id => Integer + Returns : ($err, $errstr) + $err = 1 if there was an delete error, 0 if successful + $errstr = String error message if there was an error + +=cut sub delete_simple_input{ die "delete_simple_input not implemented in adaptor\n"; } @@ -371,7 +451,7 @@ Title : query_simple_output Usage : my $un = $API->query_simple_output(%args) - Function : Executes a query for Simput outputs according to the service instance or collection output + Function : Executes a query for Simple outputs according to the service instance or collection output Args : service_instance_lsid => String, collection_output_id => Integer Returns : listref of hashrefs: From mwilkinson at pub.open-bio.org Fri Jul 29 14:17:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 10:17:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291417.j6TEHoZ3008780@pub.open-bio.org> mwilkinson Fri Jul 29 10:17:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv8757/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: OntologyServer passing wrong arguments when registering new relationships. Now passes LSIDs instead of database IDs moby-live/Perl/MOBY Central.pm,1.193,1.194 OntologyServer.pm,1.68,1.69 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.193 retrieving revision 1.194 diff -u -r1.193 -r1.194 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/28 21:36:07 1.193 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 14:17:49 1.194 @@ -486,7 +486,6 @@ $OntologyServer->objectExists( term => $class ); return &_error( "Object class $class does not exist", "" ) unless ($existingURI); - my $dbh = MOBY::central_db_connection->new()->dbh; my $errormsg = $adaptor->check_object_usage(type => $existingURI); return &_error( =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/28 18:33:10 1.68 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 14:17:49 1.69 @@ -485,8 +485,8 @@ qq{Relationship $args{relationship} does not exist in the ontology}, '' ); my $insertid = $adaptor->insert_object_term2term(relationship_type => $rel_lsid, - object1_id => $subj_lsid, - object2_id => $obj_lsid, + object1_type => $subj_lsid, + object2_type => $obj_lsid, object2_articlename => $args{articleName}); if ($insertid ) { return ( 1, "Object relationsihp created successfully", '' ); From mwilkinson at pub.open-bio.org Fri Jul 29 14:27:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 10:27:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291427.j6TERjFd008863@pub.open-bio.org> mwilkinson Fri Jul 29 10:27:45 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv8844/MOBY Modified Files: service_instance.pm Log Message: deregistration of services was not cleaning up the inputs and outputs from the database because the service was deleted prior to the parameters, leaving them unable to look up the database id of their parent service LSID moby-live/Perl/MOBY service_instance.pm,1.32,1.33 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/27 15:29:38 1.32 +++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2005/07/29 14:27:45 1.33 @@ -268,7 +268,6 @@ # the routines below know too much about the database (e.g. that # the delete_simple_input routines are broken into two parts - by LSID and # by collecion ID... BAD BAD BAD - $adaptor->delete_service_instance(service_instance_lsid => $self->lsid); $adaptor->delete_simple_input(service_instance_lsid => $self->lsid); $adaptor->delete_simple_output(service_instance_lsid => $self->lsid); @@ -288,6 +287,7 @@ $adaptor->delete_collection_input(service_instance_lsid => $self->lsid); $adaptor->delete_collection_output(service_instance_lsid => $self->lsid); $adaptor->delete_secondary_input(service_instance_lsid => $self->lsid); + $adaptor->delete_service_instance(service_instance_lsid => $self->lsid); return 1; } From mwilkinson at pub.open-bio.org Fri Jul 29 14:38:15 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 10:38:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291438.j6TEcFA7008957@pub.open-bio.org> mwilkinson Fri Jul 29 10:38:15 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv8938/t Modified Files: Client-Central.t Log Message: adding new tests for the less used mobycentral functions moby-live/Perl/t Client-Central.t,1.14,1.15 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/28 21:40:31 1.14 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 14:38:15 1.15 @@ -30,7 +30,7 @@ ################## MOBY Registration Tests ################# # Test 3 -$r = $C->registerObjectClass(objectType => "TotalCrap", +$r = $C->registerObjectClass(objectType => "Rubbish", description => "a human-readable description of the object", contactEmail => 'your at email.address', authURI => "test.suite.com", @@ -48,7 +48,7 @@ # Test 4 -$r = $C->registerObjectClass(objectType => "TotalCrap", +$r = $C->registerObjectClass(objectType => "Rubbish", description => "a human-readable description of the object", contactEmail => 'your at email.address', authURI => "test.suite.com", @@ -66,7 +66,7 @@ # Test 5 -$r = $C->deregisterObjectClass(objectType => "TotalCrap"); +$r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful")) or diag("Object deregistration failure: ".$r->message) ; @@ -74,7 +74,7 @@ # Test 6 (identical to #4 -$r = $C->registerObjectClass(objectType => "TotalCrap", +$r = $C->registerObjectClass(objectType => "Rubbish", description => "a human-readable description of the object", contactEmail => 'your at email.address', authURI => "test.suite.com", @@ -93,7 +93,7 @@ # Test 7 $r = $C->registerNamespace( - namespaceType =>'UglyNamespace', + namespaceType =>'RubbishNamespace', authURI => 'your.authority.URI', description => "human readable description of namespace", contactEmail => 'your at address.here'); @@ -104,7 +104,7 @@ # Test 8 -$r = $C->registerServiceType(serviceType => "CrappyService", +$r = $C->registerServiceType(serviceType => "RubbishyService", description => "a human-readable description of the service", contactEmail => 'your at email.address', authURI => "test.suite.com", @@ -127,10 +127,10 @@ category => "moby", URL => "http://illuminae/cgi-bin/service.pl", input =>[ - ['articleName1', [Object => ['UglyNamespace']]], # Simple + ['articleName1', [Object => ['RubbishNamespace']]], # Simple ], output =>[ - ['articleName2', [String => ['UglyNamespace']]], # Simple + ['articleName2', [String => ['RubbishNamespace']]], # Simple ], secondary => { parametername1 => { @@ -155,10 +155,10 @@ category => "moby", URL => "http://illuminae/cgi-bin/service.pl", input =>[ - ['articleName1', [Object => ['UglyNamespace']]], # Simple + ['articleName1', [Object => ['RubbishNamespace']]], # Simple ], output =>[ - ['articleName2', [String => ['UglyNamespace']]], # Simple + ['articleName2', [String => ['RubbishNamespace']]], # Simple ], secondary => { parametername1 => { @@ -214,7 +214,7 @@ @ns = @{$in->namespaces}; is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace"); +is($ns, 'RubbishNamespace') or diag("simple input reporting wrong namespace"); is($out->objectType, "String") or diag("simple output type reported incorrectly"); is($out->articleName, "articleName2") or diag("simple output article name reported incorrectly"); @@ -222,7 +222,7 @@ @ns = @{$out->namespaces}; is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace"); +is($ns, 'RubbishNamespace') or diag("simple output reporting wrong namespace"); is($sec->articleName, 'parametername1') or diag("secondary article reporting wrong article name"); is($sec->datatype, 'Integer') or diag("secondary article reporting wrong datatype"); @@ -248,10 +248,10 @@ category => "moby", URL => "http://illuminae/cgi-bin/service.pl", input =>[ - ['articleName1', [[Object => ['UglyNamespace']]]], # Simple + ['articleName1', [[Object => ['RubbishNamespace']]]], # Simple ], output =>[ - ['articleName2', [[String => ['UglyNamespace']]]], # Simple + ['articleName2', [[String => ['RubbishNamespace']]]], # Simple ], secondary => { parametername1 => { @@ -325,14 +325,14 @@ @ns = @{$in->namespaces}; is(scalar(@ns),1) or diag("simple input reporting wrong number of namespaces (collections test)"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple input reporting wrong namespace (collections test)"); +is($ns, 'RubbishNamespace') or diag("simple input reporting wrong namespace (collections test)"); is($out->objectType, "String") or diag("simple output type reported incorrectly (collections test)"); isa_ok($out->namespaces, 'ARRAY') or diag("simple output namespaces not returned as an arrayref (collections test)"); @ns = @{$out->namespaces}; is(scalar(@ns),1) or diag("simple output reporting wrong number of namespaces (collections test)"); $ns = shift @ns; -is($ns, 'UglyNamespace') or diag("simple output reporting wrong namespace (collections test)"); +is($ns, 'RubbishNamespace') or diag("simple output reporting wrong namespace (collections test)"); $r = $C->deregisterService( @@ -359,15 +359,22 @@ -# Test 12 -$r = $C->deregisterObjectClass(objectType => "TotalCrap"); +# TESTS FOR ONTOLOGY TRAVERSAL AND SO ON + +$r = $C->retrieveObjectDefinition(objectType => "Rubbish"); +isa_ok($r , "HASH", "Object definition returns hashref") or diag("Object definition did not return as a hashref") ; + + + + +$r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; # Test 13 -$r = $C->deregisterServiceType(serviceType => "CrappyService"); +$r = $C->deregisterServiceType(serviceType => "RubbishyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; @@ -375,7 +382,7 @@ # Test 44 -$r = $C->deregisterNamespace(namespaceType =>'UglyNamespace'); +$r = $C->deregisterNamespace(namespaceType =>'RubbishNamespace'); ( ok($r->success,"namespace deregistration successful") ) or diag("namespace deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 15:07:40 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:07:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291507.j6TF7eqY009070@pub.open-bio.org> mwilkinson Fri Jul 29 11:07:40 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv9047/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: subroutine misnamed moby-live/Perl/MOBY Central.pm,1.194,1.195 OntologyServer.pm,1.69,1.70 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.194 retrieving revision 1.195 diff -u -r1.194 -r1.195 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 14:17:49 1.194 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 15:07:40 1.195 @@ -2678,7 +2678,7 @@ $OS->retrieveObject( node => $term ) ; # will return undef if this term does not exist, and does not look like an LSID return "" unless $def; - my %def = %{ $OS->retrieveObject( node => $term ) }; + my %def = %{ $OS->retrieveObject( type => $term ) }; if ( $def{description} =~ /[^\]]+))\]\]>/ ) { $def{description} = $1; =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.69 retrieving revision 1.70 diff -u -r1.69 -r1.70 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 14:17:49 1.69 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 15:07:40 1.70 @@ -292,13 +292,15 @@ my ( $self, %args ) = @_; $CONFIG ||= MOBY::Config->new; # exported by Config.pm my $adaptor = $CONFIG->getDataAdaptor( datasource => 'mobyobject' ); - my $term = $args{'node'}; + my $term = $args{'type'}; + $term ||=$args{'node'}; + return ( 0, "WRONG ONTOLOGY!", '' ) unless ( $self->ontology eq 'object' ); return ( 0, "requires a object type node as an argument", '' ) - unless ( $args{'node'} ); + unless ( $term ); my $LSID = - ( $args{'node'} =~ /urn\:lsid/ ) - ? $args{'node'} + ( $term =~ /urn\:lsid/ ) + ? $term : $self->getObjectURI($term); unless ($LSID) { return ( 0, "Failed during creation of an LSID", '' ) } my $result = $adaptor->query_object(type => $LSID); From mwilkinson at pub.open-bio.org Fri Jul 29 15:07:40 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:07:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291507.j6TF7eM6009090@pub.open-bio.org> mwilkinson Fri Jul 29 11:07:40 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv9047/MOBY/Client Modified Files: Central.pm Log Message: subroutine misnamed moby-live/Perl/MOBY/Client Central.pm,1.103,1.104 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.103 retrieving revision 1.104 diff -u -r1.103 -r1.104 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/28 22:18:05 1.103 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:07:40 1.104 @@ -141,11 +141,11 @@ Connections => [ undef, 'read/write' ], default_MOBY_servername => [ 'mobycentral', 'read/write' ], default_MOBY_server => [ - 'http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY05/mobycentral.pl', + 'http://mobycentral.icpture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', 'read/write' ], default_MOBY_uri => - [ 'http://mobycentral.cbr.nrc.ca/MOBY/Central', 'read/write' ], + [ 'http://mobycentral.icapture.ubc.ca/MOBY/Central', 'read/write' ], default_MOBY_proxy => [ undef, 'read/write' ], default_MOBY_type => [ 'soap', 'read/write' ], Registries => [ undef, 'read/write' ], @@ -1973,7 +1973,7 @@ return $content; } -sub _nodeAttributeContent { +sub _nodeAttributeValue { # will get text of **all** child $node from the given $DOM # regardless of their depth!! From mwilkinson at pub.open-bio.org Fri Jul 29 15:41:01 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:41:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291541.j6TFf1a8009260@pub.open-bio.org> mwilkinson Fri Jul 29 11:41:01 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv9241/MOBY/Client Modified Files: Central.pm Log Message: XML::LibXML documentation is crappy. Had to read the source to figure out the NamedNodeMap interface. Can now retrieve the value of the LSID attribute moby-live/Perl/MOBY/Client Central.pm,1.104,1.105 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.104 retrieving revision 1.105 diff -u -r1.104 -r1.105 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:07:40 1.104 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:41:01 1.105 @@ -1975,28 +1975,15 @@ sub _nodeAttributeValue { - # will get text of **all** child $node from the given $DOM - # regardless of their depth!! my ( $DOM, $node, $attr ) = @_; + return "" unless $attr; my $x = $DOM->getElementsByTagName($node); - unless ( $x->get_node(1) ) { return } + unless ( $x->get_node(1) ) { return "" } my $n = $x->get_node(1); - my @att = $n->attributes($attr); - my $atval; - if (scalar(@att)){ - $atval = $attr->getValue; - } - my @child = $x->get_node(1)->childNodes; - my $content; - foreach (@child) { - - #print getNodeTypeName($_), "\t", $_->toString,"\n"; - next - unless ( ( $_->nodeType == TEXT_NODE ) - || ( $_->nodeType == CDATA_SECTION_NODE ) ); - $content = $_->textContent; - } - return $content; + my $nodemap = $n->attributes($attr); # XML::LibXML::NamedNodeMap - the worst documented (i.e. undocumented) piece of code ever written! You have to read the source to figure out the interface... + my $attrnode = $nodemap->getNamedItem($attr); + my $attrval = $attrnode?($attrnode->value):""; + return $attrval; } sub _nodeRawContent { From mwilkinson at pub.open-bio.org Fri Jul 29 15:43:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:43:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291543.j6TFhQ8a009326@pub.open-bio.org> mwilkinson Fri Jul 29 11:43:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv9307/MOBY/Client Modified Files: Central.pm Log Message: adding LSID to return values moby-live/Perl/MOBY/Client Central.pm,1.105,1.106 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.105 retrieving revision 1.106 diff -u -r1.105 -r1.106 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:41:01 1.105 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:43:26 1.106 @@ -556,7 +556,7 @@ } } } - return ( $term, $desc, \%relationships, $email, $authURI ); + return ( $term, $lsid, $desc, \%relationships, $email, $authURI ); } =head2 registerServiceType From mwilkinson at pub.open-bio.org Fri Jul 29 15:54:13 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:54:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291554.j6TFsDT0009399@pub.open-bio.org> mwilkinson Fri Jul 29 11:54:13 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9380/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.15,1.16 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 14:38:15 1.15 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:54:13 1.16 @@ -363,9 +363,33 @@ $r = $C->retrieveObjectDefinition(objectType => "Rubbish"); isa_ok($r , "HASH", "Object definition returns hashref") or diag("Object definition did not return as a hashref") ; - - - +is($r->objectType, "Rubbish", "Object reporting correct name") or diag("Object definition did not report correct name"); +is($r->description, "a human-readable description of the object", "Object reporting correct desc") or diag("Object definition did not report correct desc"); +is($r->contactEmail, 'your at email.address', "Object reporting correct email") or diag("Object definition did not report correct email"); +is($r->authURI, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); +isa_ok($r->Relationships, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); +%rel = %{$r->Relationships}; +isa_ok($rel{ISA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); +isa_ok($rel{HASA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); +$isa = shift@{$rel{ISA}}; +$hasa = shift@{$rel{HASA}}; +isa_ok($isa, "ARRAY","") or diag("Object didn't return an array of arrays for its ISA relationships"); +isa_ok($hasa, "ARRAY","") or diag("Object didn't return an array of arrays for its HASA relationships"); +is(${$isa}[0], 'Object') or diag("ISA reporting wrong object type"); +is(${$isa}[1], 'article1') or diag("ISA reporting wrong object type"); +is(${$hasa}[0], 'Object') or diag("ISA reporting wrong object type"); +is(${$hasa}[1], 'articleName3') or diag("ISA reporting wrong object type"); + +#objectType => "Rubbish", +# description => "a human-readable description of the object", +# contactEmail => 'your at email.address', +# authURI => "test.suite.com", +# Relationships => { +# ISA => [ +# ['Object', 'article1']], +# HASA => [ +# ['Object', 'articleName3']]} +# ); $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") From mwilkinson at pub.open-bio.org Fri Jul 29 15:55:17 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 11:55:17 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291555.j6TFtHaf009477@pub.open-bio.org> mwilkinson Fri Jul 29 11:55:17 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9458/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:54:13 1.16 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:55:17 1.17 @@ -363,12 +363,12 @@ $r = $C->retrieveObjectDefinition(objectType => "Rubbish"); isa_ok($r , "HASH", "Object definition returns hashref") or diag("Object definition did not return as a hashref") ; -is($r->objectType, "Rubbish", "Object reporting correct name") or diag("Object definition did not report correct name"); -is($r->description, "a human-readable description of the object", "Object reporting correct desc") or diag("Object definition did not report correct desc"); -is($r->contactEmail, 'your at email.address', "Object reporting correct email") or diag("Object definition did not report correct email"); -is($r->authURI, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); -isa_ok($r->Relationships, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); -%rel = %{$r->Relationships}; +is($r->{objectType}, "Rubbish", "Object reporting correct name") or diag("Object definition did not report correct name"); +is($r->{description}, "a human-readable description of the object", "Object reporting correct desc") or diag("Object definition did not report correct desc"); +is($r->{contactEmail}, 'your at email.address', "Object reporting correct email") or diag("Object definition did not report correct email"); +is($r->{authURI}, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); +isa_ok($r->{Relationships}, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); +%rel = %{$r->{Relationships}}; isa_ok($rel{ISA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); isa_ok($rel{HASA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); $isa = shift@{$rel{ISA}}; From mwilkinson at pub.open-bio.org Fri Jul 29 16:00:18 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:00:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291600.j6TG0I7O009571@pub.open-bio.org> mwilkinson Fri Jul 29 12:00:18 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9552/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.17,1.18 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 15:55:17 1.17 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:00:18 1.18 @@ -369,10 +369,10 @@ is($r->{authURI}, "test.suite.com", "Object reporting correct auth") or diag("Object definition did not report correct auth"); isa_ok($r->{Relationships}, "HASH", "Object reporting correct Relationships hash") or diag("Object definition did not report hash on relationships"); %rel = %{$r->{Relationships}}; -isa_ok($rel{ISA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); -isa_ok($rel{HASA}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); -$isa = shift@{$rel{ISA}}; -$hasa = shift@{$rel{HASA}}; +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY", "Object reporting correct ISA as arrayref") or diag("Object definition did not report ISA arrayref"); +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:hasa'}, "ARRAY", "Object reporting correct HASA as arrayref") or diag("Object definition did not report HASA arrayref"); +$isa = shift@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}; +$hasa = shift@{$rel{'urn:lsid:biomoby.org:objectrelation:hasa'}}; isa_ok($isa, "ARRAY","") or diag("Object didn't return an array of arrays for its ISA relationships"); isa_ok($hasa, "ARRAY","") or diag("Object didn't return an array of arrays for its HASA relationships"); is(${$isa}[0], 'Object') or diag("ISA reporting wrong object type"); From mwilkinson at pub.open-bio.org Fri Jul 29 16:01:34 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:01:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291601.j6TG1YSb009616@pub.open-bio.org> mwilkinson Fri Jul 29 12:01:34 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9597/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:00:18 1.18 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:01:34 1.19 @@ -379,17 +379,8 @@ is(${$isa}[1], 'article1') or diag("ISA reporting wrong object type"); is(${$hasa}[0], 'Object') or diag("ISA reporting wrong object type"); is(${$hasa}[1], 'articleName3') or diag("ISA reporting wrong object type"); +is($r->{objectLSID}, "urn:lsid:biomoby.org:objectclass:Rubbish") or diag("Object class LSID reported incorrectly"); -#objectType => "Rubbish", -# description => "a human-readable description of the object", -# contactEmail => 'your at email.address', -# authURI => "test.suite.com", -# Relationships => { -# ISA => [ -# ['Object', 'article1']], -# HASA => [ -# ['Object', 'articleName3']]} -# ); $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") From mwilkinson at pub.open-bio.org Fri Jul 29 16:12:02 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:12:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291612.j6TGC2wZ009701@pub.open-bio.org> mwilkinson Fri Jul 29 12:12:02 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv9682/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:01:34 1.19 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:12:02 1.20 @@ -335,6 +335,18 @@ is($ns, 'RubbishNamespace') or diag("simple output reporting wrong namespace (collections test)"); + +#$names{$AuthURI} = [serviceName_1, serviceName_2, serviceName3...] +$r = $C->retrieveServiceNames(); +isa_ok($r, "HASH", "Service Names Hash") or diag("retrieveServiceNames didn't return a hashref") ; +%sn = %{$r}; +isa_ok($sn{'test.suite.com'}, "ARRAY") or diag("retrieveServiceNames didn't return a hasref of arrayrefs"); +$s1 = shift@{$sn{'test.suite.com'}}; +$s2 = shift@{$sn{'test.suite.com'}}; +ok((($s1 =~ /myfirstservice/) || ($s1 =~ /mysecondservice/))) or diag("retrieveServiceNames didn't return myfirstservice"); +ok((($s2 =~ /myfirstservice/) || ($s2 =~ /mysecondservice/))) or diag("retrieveServiceNames didn't return mysecondservice"); + + $r = $C->deregisterService( serviceName => "myfirstservice", authURI => "test.suite.com", @@ -382,6 +394,13 @@ is($r->{objectLSID}, "urn:lsid:biomoby.org:objectclass:Rubbish") or diag("Object class LSID reported incorrectly"); +$r = $C->retrieveNamespaces(); +isa_ok($r, "HASH", "Namespace hash") or diag("retrieveNamespaces didn't return a hashref") ; +%ns = %{$r}; +is($ns{RubbishNamespace}, "human readable description of the namespace") or diag("namespace definition not returned correctly"); + + + $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 16:20:43 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:20:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291620.j6TGKhC0009774@pub.open-bio.org> mwilkinson Fri Jul 29 12:20:43 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv9755/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: querynamespace returned nothing if no parameter was passed. It should return everything moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/28 21:26:59 1.63 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:20:43 1.64 @@ -966,13 +966,15 @@ sub query_namespace{ my ($self, %args) = @_; my $type = $args{type}; - return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ $condition = " where namespace_lsid = ?"; } elsif ($type) { $condition = " where namespace_type = ?"; + } else { + $condition = ""; } + my $dbh = _getDBHandle("mobynamespace"); my $statement = "select From mwilkinson at pub.open-bio.org Fri Jul 29 16:35:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:35:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291635.j6TGZM4A010137@pub.open-bio.org> mwilkinson Fri Jul 29 12:35:22 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10118/t Modified Files: Client-Central.t Log Message: more tests moby-live/Perl/t Client-Central.t,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:12:02 1.20 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:35:22 1.21 @@ -397,8 +397,33 @@ $r = $C->retrieveNamespaces(); isa_ok($r, "HASH", "Namespace hash") or diag("retrieveNamespaces didn't return a hashref") ; %ns = %{$r}; -is($ns{RubbishNamespace}, "human readable description of the namespace") or diag("namespace definition not returned correctly"); +is($ns{RubbishNamespace}, "human readable description of namespace") or diag("namespace definition not returned correctly"); +$r = $C->retrieveServiceTypes(); +isa_ok($r, "HASH", "Service types hash") or diag("retrieveServiceTypes didn't return a hashref") ; +%st = %{$r}; +is($st{RubbishyService}, "a human-readable description of the service") or diag("service type definition not returned correctly"); + + +$r = $C->retrieveObjectNames(); +isa_ok($r, "HASH", "Object types hash") or diag("retrieveObjectNames didn't return a hashref") ; +%on = %{$r}; +is($on{Rubbish}, "a human-readable description of the object") or diag("object name definition not returned correctly"); + + +$r = $C->Relationships(objectType => "Rubbish"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; +%rel= %{$r}; +print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); +is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "urn:lsid:biomoby.org:objectclass:Object") or diag("Relationships arrayref didn't return the right parentage."); + +$r = $C->Relationships(serviceType => "RubbishyService"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; +%rel= %{$r}; +print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); +is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "urn:lsid:biomoby.org:servicetype:Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); $r = $C->deregisterObjectClass(objectType => "Rubbish"); @@ -407,7 +432,7 @@ -# Test 13 +# Test 13 is a retrieval $r = $C->deregisterServiceType(serviceType => "RubbishyService"); ( ok($r->success,"Service Type deregistration successful") ) or diag("Service Type deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 16:42:49 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:42:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291642.j6TGgnxe010267@pub.open-bio.org> mwilkinson Fri Jul 29 12:42:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv10248/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query service needs to return everything instead of nothng when called with no parameter moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.64,1.65 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.64 retrieving revision 1.65 diff -u -r1.64 -r1.65 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:20:43 1.64 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:42:49 1.65 @@ -807,12 +807,13 @@ sub query_service{ my ($self, %args) = @_; my $type = $args{type}; - return [{}] unless $type; my $condition = ""; if ($type =~ /^urn\:lsid/){ $condition = "where service_lsid = ?"; } elsif ($type) { $condition = "where service_type = ?"; + } else { + $condition = ""; } my $dbh = _getDBHandle("mobyservice"); From mwilkinson at pub.open-bio.org Fri Jul 29 16:46:22 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 12:46:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291646.j6TGkMiu010335@pub.open-bio.org> mwilkinson Fri Jul 29 12:46:21 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv10316/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: extra comma in SQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.65,1.66 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:42:49 1.65 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:46:21 1.66 @@ -883,7 +883,7 @@ assertion_id, relationship_type, service1_id, - service2_id, + service2_id from service_term2term where service2_id = ?"; my $result2 = do_query($dbh, $statement, ($id)); return $result2; From mwilkinson at pub.open-bio.org Fri Jul 29 17:11:04 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:11:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291711.j6THB4gn010563@pub.open-bio.org> mwilkinson Fri Jul 29 13:11:04 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10538/t Modified Files: Client-Central.t Log Message: fixed test moby-live/Perl/t Client-Central.t,1.21,1.22 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 16:35:22 1.21 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:11:04 1.22 @@ -414,16 +414,16 @@ $r = $C->Relationships(objectType => "Rubbish"); isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; %rel= %{$r}; -print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); -is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "urn:lsid:biomoby.org:objectclass:Object") or diag("Relationships arrayref didn't return the right parentage."); +is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "Object") or diag("Relationships arrayref didn't return the right parentage."); $r = $C->Relationships(serviceType => "RubbishyService"); isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; %rel= %{$r}; print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); -is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "urn:lsid:biomoby.org:servicetype:Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); +is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); $r = $C->deregisterObjectClass(objectType => "Rubbish"); From mwilkinson at pub.open-bio.org Fri Jul 29 17:12:50 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:12:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291712.j6THCoao010629@pub.open-bio.org> mwilkinson Fri Jul 29 13:12:49 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10610/t Modified Files: Client-Central.t Log Message: fixed test moby-live/Perl/t Client-Central.t,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:11:04 1.22 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:12:49 1.23 @@ -117,6 +117,22 @@ +$r = $C->Relationships(objectType => "Rubbish"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; +%rel= %{$r}; +#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); +is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "Object") or diag("Relationships arrayref didn't return the right parentage."); + +$r = $C->Relationships(serviceType => "RubbishyService"); +isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; +%rel= %{$r}; +print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); +is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); + + + # Test 9 # should fail $r = $C->registerService( serviceName => "myfirstservice", @@ -411,21 +427,6 @@ is($on{Rubbish}, "a human-readable description of the object") or diag("object name definition not returned correctly"); -$r = $C->Relationships(objectType => "Rubbish"); -isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for object types") ; -%rel= %{$r}; -#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; -isa_ok($rel{'urn:lsid:biomoby.org:objectrelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs"); -is(shift(@{$rel{'urn:lsid:biomoby.org:objectrelation:isa'}}), "Object") or diag("Relationships arrayref didn't return the right parentage."); - -$r = $C->Relationships(serviceType => "RubbishyService"); -isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; -%rel= %{$r}; -print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; -isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); -is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); - - $r = $C->deregisterObjectClass(objectType => "Rubbish"); ( ok($r->success,"Object deregistration successful") ) or diag("Object deregistration failure: ".$r->message) ; From mwilkinson at pub.open-bio.org Fri Jul 29 17:25:35 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:25:35 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291725.j6THPZ6o010727@pub.open-bio.org> mwilkinson Fri Jul 29 13:25:35 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv10708/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: sql adaptor was only able to create relatinships for object ontology. Now can retrieve relationships for both object and service moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.66,1.67 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 16:46:21 1.66 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 17:25:35 1.67 @@ -1319,9 +1319,16 @@ my $type = $args{'term'}; return 0 unless $type; - my $result = $self->query_object(type => $type); - my $row = shift @$result; - my $lsid = $row->{object_lsid}; + my $lsid; + if ($ontology eq "service"){ + my $result = $self->query_service(type => $type); + my $row = shift @$result; + $lsid = $row->{service_lsid}; + } else { + my $result = $self->query_object(type => $type); + my $row = shift @$result; + $lsid = $row->{object_lsid}; + } my $defs; if ( $direction eq 'root' ) { From mwilkinson at pub.open-bio.org Fri Jul 29 17:28:26 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:28:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291728.j6THSQUS010839@pub.open-bio.org> mwilkinson Fri Jul 29 13:28:26 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10820/t Modified Files: Client-Central.t Log Message: updating test plan number moby-live/Perl/t Client-Central.t,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:12:49 1.23 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:28:26 1.24 @@ -5,7 +5,7 @@ # change 'tests => 1' to 'tests => last_test_to_print'; #use SOAP::Lite +trace; -use Test::More tests => 91; # perldoc Test::More for details +use Test::More tests => 122; # perldoc Test::More for details # Test 1 BEGIN { use_ok('MOBY::Client::Central') }; From mwilkinson at pub.open-bio.org Fri Jul 29 17:39:32 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:39:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291739.j6THdWLU010916@pub.open-bio.org> mwilkinson Fri Jul 29 13:39:32 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv10893/MOBY Modified Files: Central.pm OntologyServer.pm Log Message: deleting service type failed due to bad lookup of relationships. Fix reporting of errors from MOBY Central - need to bracket teh (==0) phrase of every test moby-live/Perl/MOBY Central.pm,1.195,1.196 OntologyServer.pm,1.70,1.71 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.195 retrieving revision 1.196 diff -u -r1.195 -r1.196 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 15:07:40 1.195 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 17:39:32 1.196 @@ -313,14 +313,14 @@ term => $reltype, ontology => 'object' ); # success = 1 if it does - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); foreach ( @{$obj} ) { ++$ISAs if ( $URI =~ /isa$/i ); my ( $objectType, $articleName ) = @{$_}; my ( $success, $message, $URI ) = $OntologyServer->objectExists( term => $objectType ) ; # success = 1 if it does - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); } } return &_error( @@ -341,12 +341,12 @@ if ( $clobber == 1 ) { my ( $success, $message ) = $OntologyServer->deprecateObject( term => $term ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); } elsif ( $clobber == 2 ) { my ( $success, $message ) = $OntologyServer->deleteObject( term => $term ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); } } ( $success, $message, $URI ) = $OntologyServer->createObject( @@ -355,7 +355,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); my @failures; if ( keys %{$relationships} ) { while ( my ( $reltype, $obj ) = each %{$relationships} ) { @@ -370,7 +370,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && push @failures, $objectType; + ($success == 0) && push @failures, $objectType; } } } @@ -378,7 +378,7 @@ my ( $success, $message, $deleteURI ) = $OntologyServer->deleteObject( term => $term ) ; # hopefully this situation will never happen! - $success == 0 && return &_error( + ($success == 0) && return &_error( "object failed ISA and/or HASA connections, and subsequently failed deletion. This is a critical error, and may indicate corruption of the MOBY Central registry.", $deleteURI @@ -635,7 +635,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); my @failures; if ( keys %{$relationships} ) { while ( my ( $reltype, $obj ) = each %{$relationships} ) { @@ -648,7 +648,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && push @failures, $serviceType; + ($success == 0) && push @failures, $serviceType; } } } @@ -656,7 +656,7 @@ my ( $success, $message, $deleteURI ) = $OntologyServer->deleteServiceType( term => $term ) ; # hopefully this situation will never happen! - $success == 0 && return &_error( + ($success == 0) && return &_error( "Service registration failed ISA connections, and subsequently failed deletion. This is a critical error, and may indicate corruption of the MOBY Central registry", $deleteURI @@ -767,7 +767,7 @@ my ( $success2, $message2, $deleteURI ) = $OntologyServer->deleteServiceType( term => $term ) ; # hopefully this situation will never happen! - $success == 0 && return &_error( $message2, $deleteURI ); + (($success == 0)) && return &_error( $message2, $deleteURI ); return &_success( "Service type $term deleted.", $deleteURI ); } @@ -855,7 +855,7 @@ authority => $auth, contact_email => $email ); - $success == 0 && return &_error( $message, $URI ); + ($success == 0) && return &_error( $message, $URI ); return &_success( "Namespace type $term registered successfully.", $URI ); } =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm,v retrieving revision 1.70 retrieving revision 1.71 diff -u -r1.70 -r1.71 --- /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 15:07:40 1.70 +++ /home/repository/moby/moby-live/Perl/MOBY/OntologyServer.pm 2005/07/29 17:39:32 1.71 @@ -682,7 +682,7 @@ } # service1_id ISA service2_id? - my $isa = $adaptor->query_service_term2term(service2_id => $lsid); + my $isa = $adaptor->query_service_term2term(type => $lsid); my $isas = shift(@$isa); if ( $isas->{service1_id} ) { From mwilkinson at pub.open-bio.org Fri Jul 29 17:40:58 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 13:40:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291740.j6THewi4010997@pub.open-bio.org> mwilkinson Fri Jul 29 13:40:58 EDT 2005 Update of /home/repository/moby/moby-live/Perl/t In directory pub.open-bio.org:/tmp/cvs-serv10978/t Modified Files: Client-Central.t Log Message: cleaning comments out of the test suite. Now have 122 tests and all pass on the new codebase moby-live/Perl/t Client-Central.t,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/t/Client-Central.t,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:28:26 1.24 +++ /home/repository/moby/moby-live/Perl/t/Client-Central.t 2005/07/29 17:40:58 1.25 @@ -127,7 +127,7 @@ $r = $C->Relationships(serviceType => "RubbishyService"); isa_ok($r, "HASH", "Relationship types hash") or diag("Relationships didn't return a hashref for service types") ; %rel= %{$r}; -print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; +#print STDERR "\n\n\nkeys ",(keys %rel),"\n\n\n"; isa_ok($rel{'urn:lsid:biomoby.org:servicerelation:isa'}, "ARRAY") or diag("Relationships didn't return a hash of arrayrefs for servies"); is(shift(@{$rel{'urn:lsid:biomoby.org:servicerelation:isa'}}), "Retrieval") or diag("Relationships arrayref didn't return the right parentage for service types."); From mwilkinson at pub.open-bio.org Fri Jul 29 18:58:44 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 14:58:44 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291858.j6TIwiWm011359@pub.open-bio.org> mwilkinson Fri Jul 29 14:58:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY In directory pub.open-bio.org:/tmp/cvs-serv11340/MOBY Modified Files: Central.pm Log Message: updated pod documentation for MOBY Central and MOBY Client Central. MOBY Client Central now has ways of getting to the LSID for various things in the MOBY Central messages. See pod for details. moby-live/Perl/MOBY Central.pm,1.196,1.197 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v retrieving revision 1.196 retrieving revision 1.197 diff -u -r1.196 -r1.197 --- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 17:39:32 1.196 +++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2005/07/29 18:58:44 1.197 @@ -2383,16 +2383,13 @@ outputXML (by category): - moby: + moby: =cut sub retrieveService { my ( $pkg, $payload ) = @_; - - # the payload here is actually the full XML from the findService call above... - #return "NOT YET IMPLEMENTED"; my ( $AuthURI, $serviceName, $InputXML, $OutputXML, $SecondaryXML ) = &_retrieveServicePayload($payload); unless ( $AuthURI && $serviceName ) { return "" } @@ -2532,7 +2529,7 @@ Args : none XML : - + ... @@ -2610,7 +2607,7 @@ Args : none XML : - + ... @@ -2649,7 +2646,7 @@ Ouptut XML : - NewObjectType + NewObjectType @@ -2714,7 +2711,7 @@ Args : none XML : - + ... From mwilkinson at pub.open-bio.org Fri Jul 29 18:58:45 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 14:58:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291858.j6TIwjow011383@pub.open-bio.org> mwilkinson Fri Jul 29 14:58:44 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv11340/MOBY/Client Modified Files: Central.pm SimpleArticle.pm Log Message: updated pod documentation for MOBY Central and MOBY Client Central. MOBY Client Central now has ways of getting to the LSID for various things in the MOBY Central messages. See pod for details. moby-live/Perl/MOBY/Client Central.pm,1.106,1.107 SimpleArticle.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.106 retrieving revision 1.107 diff -u -r1.106 -r1.107 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 15:43:26 1.106 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 18:58:44 1.107 @@ -467,16 +467,17 @@ an additional XML hash key that contains the actual XML containing the object definition as sent by MOBY Central (used for a visual overview, rather than parsing all of the hash keys) - objectType => "the name of the Object" + objectType => "the name of the Object" + objectLSID => "urn:lsid:..." description => "a human-readable description of the object" contactEmail => "your at email.address" authURI => "URI of the registrar of this object" Relationships => { relationshipType1 => [ - [Object1, articleName], - [Object2, articleName]], + [Object1, articleName, lsid], + [Object2, articleName, lsid]], relationshipType2 => [ - [Object1, articleName]]} + [Object1, articleName, lsid]]} XML => <....XML of object registration.../> Args : objectType => the name or LSID URI for an object @@ -545,14 +546,18 @@ next unless $_->nodeType == ELEMENT_NODE; my $article = $_->getAttributeNode('articleName'); # may or may not have a name + my $rlsid = + $_->getAttributeNode('lsid'); # may or may not have a name if ($article) { $article = $article->getValue() } + if ($rlsid) { $rlsid = $rlsid->getValue() } + my @child2 = $_->childNodes; foreach (@child2) { #print getNodeTypeName($_), "\t", $_->toString,"\n"; next unless $_->nodeType == TEXT_NODE; push @{ $relationships{$relationshipType} }, - [ $_->toString, $article ]; + [ $_->toString, $article, $rlsid ]; } } } @@ -1295,19 +1300,22 @@ =head2 retrieveServiceNames - Title : retrieveServiceNames + Title : retrieveServiceNames(%args) Usage : $names = $MOBY->retrieveServiceNames([$reg_name]) Function : get a (redundant) list of all registered service names (N.B. NOT service types!) Returns : hashref to the following hash $names{$AuthURI} = [serviceName_1, serviceName_2, serviceName3...] - Args : $reg_name: name of registry you wish to retrieve from (optional) + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: return service names as their corresponding LSID's (default off) =cut sub retrieveServiceNames { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; + my $aslsid = $args{as_lsid}; + $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); @@ -1324,7 +1332,14 @@ $names_list->get_node($x)->getAttributeNode('name')->getValue; my $auth = $names_list->get_node($x)->getAttributeNode('authURI')->getValue; - push @{ $servicenames{$auth} }, $name; + my $lsid = $names_list->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $name; + } + $lsid ||=$name; + push @{ $servicenames{$auth} }, $aslsid?$lsid:$name; } return \%servicenames; } @@ -1362,18 +1377,20 @@ =head2 retrieveServiceTypes - Title : retrieveServiceTypes + Title : retrieveServiceTypes(%args) Usage : $types = $MOBY->retrieveServiceTypes([$reg_name]) Function : get the list of all registered service types Returns : hashref of $types{$type} = $definition - Args : $reg_name: name of registry you wish to retrieve from (optional) - + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: return the $type as its corresponding LSID (defualt off) =cut sub retrieveServiceTypes { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; + my $as_lsid = $args{as_lsid}; + $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); @@ -1387,6 +1404,12 @@ for ( my $x = 1 ; $x <= $types->size() ; $x++ ) { next unless $types->get_node($x)->nodeType == ELEMENT_NODE; my $type = $types->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $types->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $type; + } my $desc; for my $elem ( $types->get_node($x)->getElementsByTagName('Description') ) @@ -1397,29 +1420,29 @@ } } $desc =~ s/[^\]]+))\]\]>/$1/gs; - $servicetypes{$type} = $desc; + $servicetypes{$as_lsid?$lsid:$type} = $desc; } return \%servicetypes; } =head2 retrieveObjectNames - Title : retrieveObjectNames + Title : retrieveObjectNames(%args) Usage : $names = $MOBY->retrieveObjectNames([$reg_name]) Function : get the list of all registered Object types Returns : hashref of hash: $names{$name} = $definition - Args : $reg_name: name of registry you wish to retrieve from (optional) + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: return $name as its correspnding LSID (default off) =cut sub retrieveObjectNames { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; + my $as_lsid = $args{as_lsid}; $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); - -#my $return = $self->SOAP_connection($reg)->call('retrieveObjectNames' => (@_))->paramsall; my ($return) = $self->_call( $reg, 'retrieveObjectNames', "" ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($return); @@ -1429,6 +1452,12 @@ for ( my $x = 1 ; $x <= $obnames->size() ; $x++ ) { next unless $obnames->get_node($x)->nodeType == ELEMENT_NODE; my $name = $obnames->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $obnames->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $name; + } my $desc; for my $elem ( $obnames->get_node($x)->getElementsByTagName('Description') ) @@ -1439,29 +1468,30 @@ } } $desc =~ s/[^\]]+))\]\]>/$1/gs; - $objectnames{$name} = $desc; + $objectnames{$as_lsid?$lsid:$name} = $desc; } return \%objectnames; } =head2 retrieveNamespaces - Title : retrieveNamespaces + Title : retrieveNamespaces(%args) Usage : $ns = $MOBY->retrieveNamespaces([$reg_name]) Function : get the list of all registered Namespace types Returns : hashref of hash: $ns{$namespace} = $definition - Args : $reg_name: name of registry you wish to retrieve from (optional) + Args : registry => $reg_name: name of registry you wish to retrieve from (optional) + as_lsid => $boolean: retrieve $namespace as its corresponding LSID (default off) =cut sub retrieveNamespaces { - my ($self) = shift; - my $reg = shift; + my ($self, %args) = shift; + my $reg = $args{registry}; $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); - -# my $return = $self->SOAP_connection($reg)->call('retrieveNamespaces' => (@_))->paramsall; + my $as_lsid = $args{as_lsid}; + my ($return) = $self->_call( $reg, 'retrieveNamespaces', "" ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($return); @@ -1471,6 +1501,12 @@ for ( my $x = 1 ; $x <= $namesp->size() ; $x++ ) { next unless $namesp->get_node($x)->nodeType == ELEMENT_NODE; my $ns = $namesp->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $namesp->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $ns; + } my $desc; for my $elem ( $namesp->get_node($x)->getElementsByTagName('Description') ) @@ -1482,28 +1518,29 @@ } } $desc =~ s/[^\]]+))\]\]>/$1/gs; - $namespaces{$ns} = $desc; + $namespaces{$as_lsid?$lsid:$ns} = $desc; } return \%namespaces; } =head2 retrieveObject - NOT YET IMPLEMENTED Title : retrieveObject - Usage : $objects = $MOBY->retrieveObjectNames($reg, $name | "all") + Usage : $objects = $MOBY->retrieveObjectNames(%args) Function : get the object xsd Returns : hashref of hash: $objects{$name} = $W3C_XML_Schema_string - Args : $reg - name of MOBY Central you want to use (must pass undef otherwise) - $name - object name (from ontology) or "all" to get all objects - + Args : registry => $reg - name of MOBY Central you want to use (must pass undef otherwise) + objectType => $name - object name (from ontology) or undef to get all objects + as_lsid => $boolean - return $name as its corresponding LSID (default off) + =cut sub retrieveObject { - my ($self) = shift; - my ($reg) = shift; - my $type = shift; + my ($self, %args) = shift; + my ($reg) = $args{registry}; + my $type = $args{objectType}; + my $as_lsid = $args{as_lsid}; my $message = " $type @@ -1511,7 +1548,6 @@ $reg = $reg ? $reg : $self->default_MOBY_servername; return undef unless ( $self->Connection($reg) ); -# my $return = $self->SOAP_connection($reg)->call('retrieveObject' => ($message))->paramsall; my ($return) = $self->_call( $reg, 'retrieveObject', $message ); my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($return); @@ -1521,6 +1557,12 @@ for ( my $x = 1 ; $x <= $objects->size() ; $x++ ) { next unless $objects->get_node($x)->nodeType == ELEMENT_NODE; my $name = $objects->get_node($x)->getAttributeNode('name')->getValue; + my $lsid = $objects->get_node($x)->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = $name; + } my $desc; for my $elem ( $objects->get_node($x)->getElementsByTagName('Schema') ) { @@ -1724,7 +1766,12 @@ my $Service = $Services->get_node($x); my $AuthURI = $Service->getAttributeNode('authURI')->getValue; my $servicename = $Service->getAttributeNode('serviceName')->getValue; - #my $lsid = $Service->getAttributeNode('lsid')->getValue; + my $lsid = $Service->getAttributeNode('lsid'); + if ($lsid){ + $lsid = $lsid->getValue; + } else { + $lsid = ""; + } my $Type = &_nodeTextContent( $Service, 'serviceType' ); my $authoritative = &_nodeTextContent( $Service, 'authoritative' ); my $contactEmail = &_nodeTextContent( $Service, 'contactEmail' ); @@ -1788,7 +1835,7 @@ authority => $AuthURI, authoritative => $authoritative, URL => $URL, - #LSID => $lsid, + LSID => $lsid, contactEmail => $contactEmail, name => $servicename, type => $Type, =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm 2004/12/14 22:31:30 1.7 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/SimpleArticle.pm 2005/07/29 18:58:44 1.8 @@ -86,6 +86,17 @@ =cut +=head2 objectLSID + + Title : objectLSID + Usage : $type = $SA->objectLSID($type) + Function : get/set LSID + Returns : string + Arguments : (optional) string representing objectLSID to set + +=cut + + =head2 namespaces Title : namespaces @@ -171,6 +182,7 @@ ( articleName => [ undef, 'read/write' ], objectType => [ undef, 'read/write' ], + objectLSID => [ undef, 'read/write' ], namespaces => [ [], 'read/write' ], id => [ undef, 'read/write' ], XML_DOM => [ undef, 'read/write' ], @@ -250,11 +262,15 @@ $self->articleName( "" ); $self->objectType( "" ); my $attr = $dom->getAttributeNode( 'articleName' ); + my $lsid = $dom->getAttributeNode( 'lsid' ); my $articleName = ""; $articleName = $attr->getValue if $attr; + $lsid = $attr->getValue if $lsid; + $self->articleName( $articleName ) if $articleName ; # it may have already been set if this Simple is part of a Collection... + $self->objectLSID( $lsid) if $lsid; # fork here - it may be an instantiated object (coming from a service invocation/response) # or it may be a template object as in the SimpleArticle element of a registration call From mwilkinson at pub.open-bio.org Fri Jul 29 19:28:28 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 15:28:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291928.j6TJSSW6011564@pub.open-bio.org> mwilkinson Fri Jul 29 15:28:28 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv11545/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query doesn't work on older versions of mySQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.67,1.68 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.67 retrieving revision 1.68 diff -u -r1.67 -r1.68 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 17:25:35 1.67 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 19:28:27 1.68 @@ -675,7 +675,7 @@ description, signatureURL, lsid - from service_instance left join authority on authority.authority_id "; + from service_instance, authority where authority.authority_id = service_instance.authority_id "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); my $final = do_query($dbh, $statement, @bindvalues); From mwilkinson at pub.open-bio.org Fri Jul 29 19:33:42 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 15:33:42 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291933.j6TJXgqt011633@pub.open-bio.org> mwilkinson Fri Jul 29 15:33:41 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi In directory pub.open-bio.org:/tmp/cvs-serv11614/MOBY/Adaptor/moby/queryapi Modified Files: mysql.pm Log Message: query doesn't work on older versions of mySQL moby-live/Perl/MOBY/Adaptor/moby/queryapi mysql.pm,1.68,1.69 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm,v retrieving revision 1.68 retrieving revision 1.69 diff -u -r1.68 -r1.69 --- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 19:28:27 1.68 +++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi/mysql.pm 2005/07/29 19:33:41 1.69 @@ -675,9 +675,14 @@ description, signatureURL, lsid - from service_instance, authority where authority.authority_id = service_instance.authority_id "; + from service_instance, authority "; my @bindvalues; ($statement, @bindvalues) =_add_condition($statement, @args); + if (keys(%args)){ + $statement .= " and authority.authority_id = service_instance.authority_id"; + } else { + $statement .= " where authority.authority_id = service_instance.authority_id"; + } my $final = do_query($dbh, $statement, @bindvalues); return $final; } From mwilkinson at pub.open-bio.org Fri Jul 29 19:37:52 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 15:37:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291937.j6TJbqLW011722@pub.open-bio.org> mwilkinson Fri Jul 29 15:37:51 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv11703/MOBY/Client Modified Files: Central.pm Log Message: redundant pattern substitution moby-live/Perl/MOBY/Client Central.pm,1.107,1.108 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.107 retrieving revision 1.108 diff -u -r1.107 -r1.108 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 18:58:44 1.107 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:37:51 1.108 @@ -1517,7 +1517,7 @@ $desc = $1; } } - $desc =~ s/[^\]]+))\]\]>/$1/gs; +# $desc =~ s/[^\]]+))\]\]>/$1/gs; $namespaces{$as_lsid?$lsid:$ns} = $desc; } return \%namespaces; From mwilkinson at pub.open-bio.org Fri Jul 29 19:39:37 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Fri, 29 Jul 2005 15:39:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507291939.j6TJdbLb011786@pub.open-bio.org> mwilkinson Fri Jul 29 15:39:37 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv11767/MOBY/Client Modified Files: Central.pm Log Message: redundant pattern substitution... can't figure out why this throws a warning every time on some systems but not others moby-live/Perl/MOBY/Client Central.pm,1.108,1.109 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.108 retrieving revision 1.109 diff -u -r1.108 -r1.109 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:37:51 1.108 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:39:37 1.109 @@ -1513,6 +1513,7 @@ { $desc = $elem->firstChild; $desc = $desc ? $desc->toString : ""; + $desc ||=""; if ( $desc =~ /[^\]]+))\]\]>/ ) { $desc = $1; } From mng at pub.open-bio.org Fri Jul 29 20:06:37 2005 From: mng at pub.open-bio.org (michael ng) Date: Fri, 29 Jul 2005 16:06:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507292006.j6TK6bXD011951@pub.open-bio.org> mng Fri Jul 29 16:06:37 EDT 2005 Update of /home/repository/moby/moby-live/Accessories In directory pub.open-bio.org:/tmp/cvs-serv11929 Added Files: code-generator0.6.cgi codebook.xml Log Message: new version of code-generator with command line function moby-live/Accessories code-generator0.6.cgi,NONE,1.1 codebook.xml,NONE,1.1 From kawas at pub.open-bio.org Fri Jul 29 22:17:40 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Fri, 29 Jul 2005 18:17:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507292217.j6TMHecB012306@pub.open-bio.org> kawas Fri Jul 29 18:17:39 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv12281/org/biomoby/registry/rdfagent/verifier Modified Files: ServiceDescrParser.java Log Message: fixed some bugs that were due to the scope of certain variables. formatted the code. fixed a bug that ignored article names of collections. fixed a bug that over wrote preexisting simples in collections with new ones even though both should exist. fixed a bug that caused pre-existing ns to be associated with simples without ns. ... moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier ServiceDescrParser.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/28 15:26:13 1.7 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/ServiceDescrParser.java 2005/07/29 22:17:39 1.8 @@ -78,20 +78,16 @@ servSign = getServSignature(resource); if (!servSign.isEmpty()) { // a valid MOBY RDF - servName = servSign.get("servicename").toString(); + servName = servSign.get("servicename").toString()+""; auth_URI = servSign.get("authURI").toString(); resources.addElement(servName); Hashtable servInp = new Hashtable(); - servInp = getInput(resource); + servInp = getInput(resource); //TODO modify collections and simples like getOutput(); Hashtable servOut = new Hashtable(); servOut = getOutput(resource); - for (int i = 0; i < ver.length; i++) { // a clearance of the - // array ver[] - ver[i] = 0; - - } + ver = new int[]{0,0,0,0,0,0,0,0}; if (servInp.containsValue("error") | servOut.containsValue("error")) { servError += 1; @@ -302,7 +298,7 @@ Hashtable input = new Hashtable(); Resource si = servDescrMd.getResource(resource); - + if (si.hasProperty(MP.consumes)) try { Resource consumes = si.getRequiredProperty(MP.consumes) .getResource(); @@ -375,7 +371,7 @@ // to Input sin += 1; Enumeration num = siminp.keys(); - + siminp= new Hashtable(); } } else if (type.equals(MP.Collection) | type.equals(RDF.Bag)) { @@ -383,9 +379,9 @@ // l3Res.hasProperty(RDF.li(1))){ if (l3Res.hasProperty(RDF.li(1))) { StmtIterator p34iter = l3Res.listProperties(); - if (l3Res.hasProperty(MP.article_name)) { + if (l3Res.hasProperty(MP.articleName)) { String col_artName = l3Res.getProperty( - MP.article_name).getObject().toString(); + MP.articleName).getObject().toString(); String[] rezNode = col_artName.split(":http:"); col_artName = rezNode[0]; colinp.put("col_articleName", col_artName); @@ -449,13 +445,18 @@ String lsid_nsp = switchURItoLSID(l5Node .toString()); colinp.put(name, lsid_nsp); - } else { + } else if (name.equals("articleName")) { + colinp.put(name, l5Node.getName()); + }else { colinp.put(name, l5Node); } } input.put("colinp" + cin, colinp); cin += 1; Enumeration num = colinp.keys(); + String col_name = (String)colinp.get("col_articleName"); + colinp = new Hashtable(); + colinp.put("col_articleName", col_name); } } @@ -529,7 +530,7 @@ input.put("input", "error"); } } catch (Exception e) { - Log.warning("Failed:" + e); + Log.warning("Failed (ServiceDescrParser.java - getInput): " + e); } // } //System.out.println("input= "+input); @@ -558,8 +559,9 @@ Hashtable output = new Hashtable(); Resource si = servDescrMd.getResource(resource); - + if (si.hasProperty(MP.produces)) try { + Resource consumes = si.getRequiredProperty(MP.produces) .getResource(); StmtIterator p23iter = consumes.listProperties(); @@ -628,7 +630,7 @@ // to Output so += 1; Enumeration num = simout.keys(); - + simout = new Hashtable(); } } @@ -636,12 +638,12 @@ // if (l3Res.hasProperty(RDF.type,RDF.Bag) && // l3Res.hasProperty(RDF.li(1))){ - if (l3Res.hasProperty(RDF.li(1))) { + if (l3Res.hasProperty(RDF.li(1))) { //TODO is this right? probably should iterate through the anon nodes, breaking when the hasProperty() fails. StmtIterator p34iter = l3Res.listProperties(); - if (l3Res.hasProperty(MP.article_name)) { + if (l3Res.hasProperty(MP.articleName)) { String col_artName = l3Res.getProperty( - MP.article_name).getObject().toString(); + MP.articleName).getObject().toString(); String[] rezNode = col_artName.split(":http:"); col_artName = rezNode[0]; colout.put("col_articleName", col_artName); @@ -705,13 +707,19 @@ String lsid_nsp = switchURItoLSID(l5Node .toString()); colout.put(name, lsid_nsp); - } else { + } else if (name.equals("articleName")) { + colout.put(name, rezNode[0]); + }else { colout.put(name, l5Node); } } + //TODO BUG here. colout should be 'new' and not recycled output.put("colout" + co, colout); co += 1; Enumeration num = colout.keys(); + String col_name = (String)colout.get("col_articleName"); + colout = new Hashtable(); + colout.put("col_articleName", col_name); } } @@ -732,7 +740,7 @@ output.put("output", "error"); } } catch (Exception e) { - Log.warning("Failed:" + e); + Log.warning("Failed (ServiceDescrParser.java-getOutput): " + e); } //System.out.println("output = "+output); return output; @@ -845,6 +853,7 @@ return res; } + //TODO - need to fix this to make it portable public String switchURItoLSID(String uri) { String lsid = ""; From mwilkinson at pub.open-bio.org Sun Jul 31 15:18:54 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Sun, 31 Jul 2005 11:18:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507311518.j6VFIspd026387@pub.open-bio.org> mwilkinson Sun Jul 31 11:18:54 EDT 2005 Update of /home/repository/moby/moby-live/Perl/MOBY/Client In directory pub.open-bio.org:/tmp/cvs-serv26368/MOBY/Client Modified Files: Central.pm Log Message: typo in the default server name moby-live/Perl/MOBY/Client Central.pm,1.109,1.110 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm,v retrieving revision 1.109 retrieving revision 1.110 diff -u -r1.109 -r1.110 --- /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/29 19:39:37 1.109 +++ /home/repository/moby/moby-live/Perl/MOBY/Client/Central.pm 2005/07/31 15:18:54 1.110 @@ -141,7 +141,8 @@ Connections => [ undef, 'read/write' ], default_MOBY_servername => [ 'mobycentral', 'read/write' ], default_MOBY_server => [ - 'http://mobycentral.icpture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', + +'http://mobycentral.icapture.ubc.ca/cgi-bin/MOBY05/mobycentral.pl', 'read/write' ], default_MOBY_uri => From mwilkinson at pub.open-bio.org Sun Jul 31 15:30:30 2005 From: mwilkinson at pub.open-bio.org (Mark Wilkinson) Date: Sun, 31 Jul 2005 11:30:30 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200507311530.j6VFUUPk026469@pub.open-bio.org> mwilkinson Sun Jul 31 11:30:30 EDT 2005 Update of /home/repository/moby/moby-live/Database In directory pub.open-bio.org:/tmp/cvs-serv26454 Added Files: reset.bat Log Message: a batch file for reinitializing the databases in MS Windows moby-live/Database reset.bat,NONE,1.1 From kawas at pub.open-bio.org Fri Jul 29 23:05:46 2005 From: kawas at pub.open-bio.org (Eddie Kawas) Date: Fri, 29 Jul 2005 23:05:46 -0000 Subject: [MOBY-guts] biomoby commit Message-ID: <200507292219.j6TMJ6S5012347@pub.open-bio.org> kawas Fri Jul 29 18:19:05 EDT 2005 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier In directory pub.open-bio.org:/tmp/cvs-serv12322/org/biomoby/registry/rdfagent/verifier Modified Files: DataMngr.java Log Message: not sure what i did - cvs says that there are differences. Probably bug fixes and formatting. moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier DataMngr.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/28 15:24:41 1.10 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/registry/rdfagent/verifier/DataMngr.java 2005/07/29 22:19:05 1.11 @@ -24,2428 +24,2508 @@ public class DataMngr { - /** - * get the list of signatureURL from service_instance table - * - * @return a Hashtable (signatureURL = string of servicenames for this URL - * separated by comma) - * - * - */ - - public static Hashtable getServices(String file) { - - Hashtable services = new Hashtable(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select servicename,signatureURL,authority_id from service_instance order by signatureURL"; - - PreparedStatement ps = null; - ResultSet rs = null; - - try { - ps = con.prepareStatement(sqlReq1); - rs = ps.executeQuery(); - String lastAddr = ""; - StringBuffer servNames = new StringBuffer(); - int lastID = -1; - - while (rs.next()) { - String servName = rs.getString(1); - String rdfAddr = rs.getString(2); - int authorityID = rs.getInt(3); - if (rdfAddr == null) { - //TODO - make this code more efficient! - maybe perform one sql call instead of many - // update the signatureURL field using the service name and authority id - String bogusSigURL = "http://invalidURL123.com/author/"+ authorityID + "/" + servName +".xml"; - String updateSQLString = "UPDATE service_instance " + - "SET signatureURL='"+ bogusSigURL +"' " + - "WHERE authority_id=" + authorityID + " and servicename='" + servName +"'"; - PreparedStatement preparedStatement = null; - try { - Connection updateCon = DBConnector.getConnection(); - preparedStatement = updateCon.prepareStatement(updateSQLString); - int resultSet = preparedStatement.executeUpdate(); - Log.info(resultSet + ": Updated the signatureURL field of the authority with id #" + authorityID + " to be " + bogusSigURL+"."); - } catch (SQLException e) { - Log.severe("Could not update SignatureURL field with a bogus signatureURL.\n" +e.getMessage()); - } - - } else { - if (rdfAddr.equals(lastAddr)) { - servNames.append("," + servName); - } else { - if (servNames.length() > 0) { - services.put(lastAddr, servNames); - servNames = new StringBuffer(); - } - servNames.append(servName); - lastAddr = rdfAddr; - Report.doSave(file, lastAddr); - } - } - } - services.put(lastAddr, servNames); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - //System.out.println("ListOFServices : "+services); - - return services; - } - - /** - * get the list of services by signatureURL - * - * @param signURL - - * URL of resource - * @return a Hashtable (signatureURL = string of servicenames for this URL - * separated by comma) - */ - - public static Hashtable getServicesByURL(String signURL) { - - Hashtable services = new Hashtable(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select servicename,signatureURL from service_instance where signatureURL=?"; - - PreparedStatement ps = null; - ResultSet rs = null; - - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - String lastAddr = ""; - StringBuffer servNames = new StringBuffer(); - - while (rs.next()) { - String servName = rs.getString(1); - String rdfAddr = rs.getString(2); - - if (rdfAddr.equals(lastAddr)) { - servNames.append("," + servName); - } else { - if (servNames.length() > 0) { - services.put(lastAddr, servNames); - servNames = new StringBuffer(); - } - servNames.append(servName); - lastAddr = rdfAddr; - } - } - services.put(lastAddr, servNames); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - // System.out.println("ListOFServices : "+services); - - return services; - } - - /** - * This method use for the update service_instance table, - * simple_input/output table, collection_input/output table, secondary_input - * table in accordance with data from RDF file. - * - * @param servSign - - * set of the serviceSignature data (name - value, an example: - * servicename - GoTerm); Hashtable of hashtables represented by - * a pair: a name of the input = hashtable for this output - * example:{siminp1={object_type_uri=urn:lsid:biomoby.org:objectclass:Object, - * namespace_type_uris=urn:lsid:biomoby.org:namespacetype:taxon}} - * @param servInp - - * Hashtable of hashtables represented by a pair: a name of the - * output = hashtable for this output - * @param servname - - * the name of service - * @param authURI - - * the authority URI - * @param signURL - - * URL of resource - */ - - public static void processService(Hashtable servSign, Hashtable servInp, - Hashtable servOut, String servname, String authURI, String signURL) { - - Connection con = DBConnector.getConnection(); - String servName = ""; - String cat = "moby"; - String url = ""; - String email = ""; - String desc = ""; - String stype = ""; - String authuri = ""; - String authoritative = ""; - String art = null; - String col_art = null; - String obt = null; - String nst = null; - String artsec = null; - String defsec = null; - String dtsec = null; - - BigDecimal maxsec = null; - BigDecimal minsec = null; - - String enumsec = null; - int colId = 0; - Integer colOutId = null; - Integer colInpId = null; - int serv = 0; // a flag - the given service was found - int checkServ = 0; // a flag - the service exist in the database - int new_serv = 0; // the number of new services - int ret; - int servInstId = 0; - String signatureURL = "NNN"; - - // ************** Update service Signature **************** - - Enumeration num = servSign.keys(); - - while (num.hasMoreElements()) { - - Object ob = num.nextElement(); - Object val = servSign.get(ob); - if (ob.equals("category")) { - cat = val.toString(); - } - if (ob.equals("URL")) { - url = val.toString(); - } - if (ob.equals("contact_email")) { - email = val.toString(); - } - if (ob.equals("description")) { - desc = val.toString(); - } - if (ob.equals("service_type_uri")) { - stype = val.toString(); - } - if (ob.equals("authURI")) { - authuri = val.toString(); - } - if (ob.equals("authoritative")) { - authoritative = val.toString(); - - if (authoritative.equals("non-authoritative")) { - authoritative = "0"; - } else if (authoritative.equals("authoritative")) { - authoritative = "1"; - } - } - if (ob.equals("servicename")) { - servName = val.toString(); - } - if (ob.equals("signatureURL")) { - signatureURL = val.toString(); - } - - } - - ServSignature signature = getServSignature(servname, signURL); - servInstId = signature.getServInstId(); - //TODO make sure that the fields are updated - if (servInstId == 0) { - - int authId = getAuthIdByAuthURI(authuri); - - if (authId == 0) { - insIntoAuthority(authuri, email); - authId = getAuthIdByAuthURI(authuri); - } - - if (signatureURL.equals("NNN")) { - ret = createSignature(servName, cat, stype, authId, url, email, - authoritative, desc, signURL); - } else { - ret = createSignature(servName, cat, stype, authId, url, email, - authoritative, desc, signatureURL); - } - - if (ret == 1) { - String msg = "------The service instance <" + servName - + "> was registered in the MOBYCENTRAL registry "; - Report.doWrite(msg); - Report.add(msg); - - //System.out.println("mail_server = - // "+Constants.MB_MAIL_SERVER); - /* - * if (Constants.MB_MAIL_SERVER != null | - * !Constants.MB_MAIL_SERVER.equals("")) { String to = - * DataMngr.getContactEmail(signURL); - * Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // - * send message to the service provider - that service was - * deregistered } - */ - new_serv += 1; - servInstId = getServInstId(servName, authId); - } - } else { - - if (!cat.equals(signature.getCategory()) - || !url.equals(signature.getUrl()) - || !email.equals(signature.getEmail()) - || !desc.equals(signature.getDescription()) - || !stype.equals(signature.getServiceType()) - || !authoritative.equals(signature.getAuthoritative()) - || !authuri.equals(authURI)) { - - //TODO - Log.info("Updating the service '" + servName +"' since the RDF document has been modified."); - if (signatureURL.equals("NNN")) { - Log.info("sig == NNN" + signURL); - Log.info("=<"+servName+","+cat+","+stype+","+authuri+","+url+","+email+","+desc+","+authoritative+","+signURL+">"); - int res = updSign(servName, cat, stype, authuri, url, - email, desc, authoritative, signURL); - if (res == 1) { - Report.doWrite("------The service instance<"+servName+"> was updated "); - Report.add("------The service instance <"+servName+">was updated "); - } else { - Report.doWrite("------The service instance<"+servName+"> was not updated"); - Report.add("------The service instance <"+servName+">was not updated "); - } - - } else { - Log.info("sig != NNN"); - int res = updSign(servName, cat, stype, authuri, url, - email, desc, authoritative, signatureURL); - if (res == 1) { - Report.doWrite("------The service instance <"+servName+"> was updated "); - Report.add("------The service instance <"+servName+">was updated "); - } else { - Report.doWrite("------The service instance <"+servName+"> was not updated "); - Report.add("------The service instance <"+servName+">was not updated "); - } - } - } - } - - // ************ add Input ********************* - - Enumeration num1 = servInp.keys(); - int dels = 0; - int delc = 0; - int delsec = 0; - int si = 0; - int ci = 0; - int sci = 0; - - while (num1.hasMoreElements()) { - Object ob = num1.nextElement(); - Object val = servInp.get(ob); - Log.info("INPUTS :"+ob+" = "+val ); - String simcol = (ob.toString()).substring(0, 6); // a hashtable name - - if (simcol.equals("secinp")) { // if it's a Secondary input - sci += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Secondary input " + sci); - Report.add("Secondary input " + sci + ":"); - if (delsec == 0) { - delRow("secondary_input", servInstId); // delete from - // simple_input table - delsec = 1; - } - } else if (simcol.equals("colinp")) { // if it's a Collection input - ci += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Collection input " + ci); - Report.add("Collection input " + ci + ":"); - if (delc == 0) { - // colInpId = new - // Integer(getCollectionId("collection_input","collection_input_id",servInstId)); - delCollectionMember("input", servInstId); // delete from - // simple_input - // table - delRow("collection_input", servInstId); // delete from the - // collection_input - // table - delc = 1; - } - - } else { // if it's a Simple input - Report.doWrite(" "); - Report.add(" "); - si += 1; - Report.doWrite("Simple input " + si); - Report.add("Simple input " + si + ":"); - if (dels == 0) { - delRow("simple_input", servInstId); // delete from - // simple_input table - dels = 1; - } - } - Hashtable simple = new Hashtable(); - simple = (Hashtable) val; - Enumeration num11 = simple.keys(); - - while (num11.hasMoreElements()) { - Object ob1 = num11.nextElement(); - if (!ob1.equals("type")) { - Report.doWrite(ob1 + " = " + simple.get(ob1)); - Report.add(ob1 + " = " + simple.get(ob1)); - } - - if (ob1.equals("col_articleName")) { - col_art = simple.get(ob1).toString(); - if (col_art.equals(" ")) { - col_art = null; - } - } else if (ob1.equals("articleName")) { - art = simple.get(ob1).toString(); - if (art.equals(" ")) { - art = null; - } - } else if (ob1.equals("article_name")) { - artsec = simple.get(ob1).toString(); - if (artsec.equals(" ")) { - artsec = null; - } - } else if (ob1.equals("object_type_uri")) { - obt = simple.get(ob1).toString(); - } else if (ob1.equals("namespace_type_uris")) { - nst = simple.get(ob1).toString(); - } else if (ob1.equals("default")) { - defsec = simple.get(ob1).toString(); - } else if (ob1.equals("datatype")) { - dtsec = simple.get(ob1).toString(); - } else if (ob1.equals("max")) { - String maxsec_s = simple.get(ob1).toString(); - try { - maxsec = new BigDecimal(maxsec_s); - - } catch (NumberFormatException nx) { - Log.severe(nx.getMessage()); - // nx.getMessage(); - } - } else if (ob1.equals("min")) { - String minsec_s = simple.get(ob1).toString(); - try { - minsec = new BigDecimal(minsec_s); - - } catch (NumberFormatException nx) { - Log.severe(nx.getMessage()); - // nx.getMessage(); - } - } else if (ob1.equals("enum")) { - enumsec = simple.get(ob1).toString(); - } - } - - if (simcol.equals("colinp")) { - insIntoCol("collection_input", col_art, servInstId); // insert - // the row - // into - // collection_input - // table - colId = getCollectionId("collection_input", - "collection_input_id", servInstId); - insIntoSimpleInput(null, art, obt, nst, new Integer(colId)); - - art = null; - col_art = null; - obt = null; - nst = null; - } else if (simcol.equals("siminp")) { - insIntoSimpleInput(new Integer(servInstId), art, obt, nst, null); - - art = null; - obt = null; - nst = null; - } else if (simcol.equals("secinp")) { - - insIntoSecondary(servInstId, artsec, defsec, dtsec, maxsec, - minsec, enumsec); - - artsec = null; - defsec = null; - dtsec = null; - maxsec = null; - minsec = null; - enumsec = null; - } - - if (colId != 0) { - Report.doWrite("collection_input_id: " + colId); - // Log.info("collection_input_id: "+colId); - } - } - - Report.doWrite("service_instance_id: " + servInstId); - // Log.info("service_instance_id: "+servInstId); - - // *********** add Output *********************** - - Enumeration numout = servOut.keys(); - int delsout = 0; - int delcout = 0; - int so = 0; - int co = 0; - while (numout.hasMoreElements()) { - Object ob = numout.nextElement(); - Object val = servOut.get(ob); - String simcol = (ob.toString()).substring(0, 6); - Log.info("OUTPUTS :"+ob+" = "+val ); - if (simcol.equals("colout")) { - co += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Collection output " + co); - Report.add("Collection output " + co + ":"); - if (delcout == 0) { - // colOutId = new - // Integer(getCollectionId("collection_output","collection_output_id",servInstId)); - delCollectionMember("output", servInstId); // delete from - // table - // simple_output - delRow("collection_output", servInstId); // delete from the - // collection_output - // table - delcout = 1; - } - } else { - so += 1; - Report.doWrite(" "); - Report.add(" "); - Report.doWrite("Simple output " + so); - Report.add("Simple output " + so + ":"); - - //TODO bug #13 here? - if (delsout == 0) { - delRow("simple_output", servInstId); // delete from - // simple_output table - delsout = 1; - } - } - Hashtable simple = new Hashtable(); - simple = (Hashtable) val; - Enumeration num11 = simple.keys(); - // Report.doWrite(""+simple); - - while (num11.hasMoreElements()) { - Object ob1 = num11.nextElement(); - if (!ob1.equals("type")) { - Report.doWrite(ob1 + " = " + simple.get(ob1)); - Report.add(ob1 + " = " + simple.get(ob1)); - } - - if (ob1.equals("col_articleName")) { - col_art = simple.get(ob1).toString(); - if (col_art.equals(" ")) { - col_art = null; - } - } - if (ob1.equals("articleName")) { - art = simple.get(ob1).toString(); - if (art.equals(" ")) { - art = null; - } - } - if (ob1.equals("object_type_uri")) { - obt = simple.get(ob1).toString(); - } - if (ob1.equals("namespace_type_uris")) { - nst = simple.get(ob1).toString(); - } - } - - if (simcol.equals("colout")) { - - insIntoCol("collection_output", col_art, servInstId); // insert - // the row - // into - // collection_input - // table - - colOutId = new Integer(getCollectionId("collection_output", - "collection_output_id", servInstId)); - insIntoSimpleOutput(null, art, obt, nst, colOutId); - art = null; - obt = null; - nst = null; - } - // TODO bug #11 here - fixed - if (simcol.equals("simout")) { - insIntoSimpleOutput(new Integer(servInstId), art, obt, nst, - null); - art = null; - obt=null; - nst=null; - } - if (colOutId != null) { - Report.doWrite("collection_output_id: " + colOutId); - // Log.info("collection_output_id: "+coloutId); - } - } - // return serv; - } - - /** - * delete the service instance by service name and authority URI - * - * @param servName - * the name of service which we want delete. - * @param authURI - * the authority URI for service which we want delete. - * - */ - - public static void delServByNameAndAuthURI(String servName, String authURI) { - - int authId = getAuthIdByAuthURI(authURI); - int servInstId = getServInstId(servName, authId); - - delSignature(servName, authId); // delete service from table - // service_instance - delRow("simple_input", servInstId); // delete from table simple_input - delRow("simple_output", servInstId); // delete from table simple_output - delRow("secondary_input", servInstId); //TODO - should this line be here? - delCollectionMember("input", servInstId); - delCollectionMember("output", servInstId); - delRow("collection_input", servInstId); // delete from table - // collection_input - delRow("collection_output", servInstId); // delete from table - // collection_output - } - - /** - * delete the service instance by service name and signature URL - * - * @param servName - * the name of service which we want delete. - * @param signURL - * the authority URI for service which we want delete. - * - */ - - public static void delServByNameAndUrl(String servName, String signURL) { - - int authId = getAuthIdByServNameAndSignURL(servName, signURL); - int servInstId = getServInstId(servName, authId); - - delSignature(servName, authId); // delete service from table - // service_instance - delRow("simple_input", servInstId); // delete from table simple_input - delRow("simple_output", servInstId); // delete from table simple_output - delRow("secondary_input", servInstId); //TODO - should this line be here? - delCollectionMember("input", servInstId); - delCollectionMember("output", servInstId); - delRow("collection_input", servInstId); // delete from table - // collection_input - delRow("collection_output", servInstId); // delete from table - // collection_output - } - - /** - * delete set of the service instances with the same signatureURL by - * signatureURL - * - * @param signURL - * the name of service which we want delete. - */ - - public static void delServiceSetByURL(String signURL) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id,servicename,authority_id from service_instance where signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - Vector del_serv = new Vector(); - - while (rs.next()) { - int servInstId = rs.getInt(1); - String servName = rs.getString(2); - int authId = rs.getInt(3); - - int rez = delSignature(servName, authId); // delete service from - // table - // service_instance - if (rez == 1) { - del_serv.addElement(servName); - } - delRow("secondary_input", servInstId); //TODO - should this line be here? - delRow("simple_input", servInstId); // delete from table - // simple_input - delRow("simple_output", servInstId); // delete from table - // simple_output - delCollectionMember("input", servInstId); // delete collection - // member from - // simple_input - delCollectionMember("output", servInstId); // delete collection - // member from - // simple_output - delRow("collection_input", servInstId); // delete from table - // collection_input - delRow("collection_output", servInstId); // delete from table - // collection_output - } - - int del = del_serv.size(); - if (del > 0) { - Report.doWrite("DELETED SERVICES: "); - Iterator i = del_serv.iterator(); - int n = 1; - while (i.hasNext()) { - String delServ = i.next().toString(); - Report.doWrite(n + ". " + delServ); - n += 1; - } - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } - } - - } - - /** - * add the record about new service instance in the service_instance table - * of mobycentral database - * - * @param servName - - * the name of service instance the record was added for. - * @param cat - - * the category of service instance. - * @param servTypeURI - - * the service type URI of service instance. - * @param authId - - * the authority Id of service instance. - * @param url - - * the URL of service instance. - * @param email - - * the contact e-Mail of service instance. - * @param authoritative - - * the authoritative of service instance. - * @param desc - - * the description of service instance. - * @param signURL - - * the URL for RDF of service instance. - * @return ret=1 if the record has added, and ret=-1 otherwise - */ - - public static int createSignature(String servName, String cat, - String servTypeURI, int authId, String url, String email, - String authoritative, String desc, String signURL) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into service_instance (servicename,category,service_type_uri,authority_id,url,contact_email,authoritative,description,signatureURL) values (?,?,?,?,?,?,?,?,?)"; - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setString(2, cat); - ps.setString(3, servTypeURI); - ps.setInt(4, authId); - ps.setString(5, url); - ps.setString(6, email); - ps.setString(7, authoritative); - ps.setString(8, desc); - ps.setString(9, signURL); - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * update the service instance data in the service_instance table of - * mobycentral database - * - * @param servName - * the name of service instance the record was updated for. - * @param cat - * the category of service instance. - * @param stype - * the service type URI of service instance. - * @param authuri - * the authority URI of service instance. - * @param url - * the URL of service instance. - * @param email - * the contact e-Mail of service instance. - * @param authoritative - * the authoritative of service instance. - * @param desc - * the description of service instance. - * @param signURL - * the URL for RDF of service instance. - * @return ret=1 if the record has updated, and ret=-1 otherwise - */ - - public static int updSign(String servName, String cat, String stype, - String authuri, String url, String email, String desc, - String authoritative, String signURL) { - - Connection con = DBConnector.getConnection(); - int cnt = -1; - int ret = -1; - final String sqlReq = "select authority_id from authority where authority_uri = ?"; - PreparedStatement ps = null; - - final String sqlReq1 = "update service_instance set category = ?,service_type_uri = ?,url = ?,contact_email = ?,description = ?,authoritative = ?,signatureURL = ? where servicename = ? && authority_id = ?"; - try { - ps = con.prepareStatement(sqlReq); - ps.setString(1, authuri); - ResultSet rs = ps.executeQuery(); - while (rs.next()) { - cnt = rs.getInt(1); - } - if (cnt > -1) { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, cat); - ps.setString(2, stype); - ps.setString(3, url); - ps.setString(4, email); - ps.setString(5, desc); - ps.setString(6, authoritative); - ps.setString(7, signURL); - ps.setString(8, servName); - ps.setInt(9, cnt); - ret = ps.executeUpdate(); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * add the record into the simple_input table - * - * @param servInstId - * the Id of service instance the simple input was added for. - * @param articleName - * the article name of the simple input. - * @param objTypeUri - * the object type URI of the simple input. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple input. - * @param colInpId - * the collection input Id if this simple input belongs to a - * collection, and blank otherwise. - */ - - public static void insIntoSimpleInput(Integer servInstId, - String articleName, String objTypeUri, String nsTypeUris, - Integer colInpId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into simple_input (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_input_id) values (?,?,?,?,?)"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - if (servInstId != null) { - ps.setInt(1, servInstId.intValue()); - } else { - ps.setNull(1, java.sql.Types.INTEGER); - } - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - if (colInpId != null) { - ps.setInt(5, colInpId.intValue()); - } else { - ps.setNull(5, java.sql.Types.INTEGER); - } - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - } - - /** - * update the record into the simple_input table - * - * @param servInstId - * the Id of service instance the simple input was added for. - * @param articleName - * the article name of the simple input. - * @param objTypeUri - * the object type URI of the simple input. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple input. - * @param colInpId - * the collection input Id if this simple input belongs to a - * collection, and blank otherwise. - * @return ret=1 if the record has added, and ret=-1 otherwise - */ - - public static int updateSimpleInput(int servInstId, String articleName, - String objTypeUri, String nsTypeUris, Integer colInpId, int minNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update simple_input set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_input_id=? where simple_input_id=?"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - if (colInpId != null) { - ps.setInt(5, colInpId.intValue()); - } else { - ps.setNull(5, java.sql.Types.INTEGER); - } - ps.setInt(6, minNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * add the record about secondary input in the secondary_input table of - * mobycentral database - * - * @param servInstId - * the Id of service instance the secondary input was added for. - * @param article_name - * the article name of the secondary input. - * @param def - * the default value of the secondary input. - * @param dataType - * the type of data of the secondary input. - * @param max - * the maximum value of the secondary input - * @param min - * the minimum value of the secondary input * - * @param enumeration - * the enumeration value for the secondary input - */ - - public static void insIntoSecondary(int servInstId, String article_name, - String def, String dataType, BigDecimal max, BigDecimal min, - String enumeration) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into secondary_input (service_instance_id,article_name,default_value,maximum_value,minimum_value,enum_value,datatype) values (?,?,?,?,?,?,?)"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - ps.setString(2, article_name); - ps.setString(3, def); - ps.setBigDecimal(4, max); - ps.setBigDecimal(5, min); - ps.setString(6, enumeration); - ps.setString(7, dataType); - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - } - - /** - * update the record into the secondary_input table - * - * @param servInstId - * the Id of service instance the secondary input was added for. - * @param article_name - * the article name of the secondary input. - * @param def - * the default value of the secondary input. - * @param dataType - * the type of data of the secondary input. - * @param max - * the maximum value of the secondary input - * @param min - * the minimum value of the secondary input - * @param enumeration - * the enumeration value for the secondary input - * @param minSecNum - * minimum free number for secondary_input_id - */ - - public static void updateSec(int servInstId, String article_name, - String def, String dataType, BigDecimal max, BigDecimal min, - String enumeration, int minSecNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update secondary_input set service_instance_id=?,article_name=?,default_value=?,maximum_value=?,minimum_value=?,enum_value=?,datatype=? where secondary_input_id=?"; - - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - ps.setString(2, article_name); - ps.setString(3, def); - ps.setBigDecimal(4, max); - ps.setBigDecimal(5, min); - ps.setString(6, enumeration); - ps.setString(7, dataType); - ps.setInt(8, minSecNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } - } - } - - /** - * add the record into the simple_output table - * - * @param servInstId - * the Id of service instance the simple output was added for. - * @param articleName - * the article name of the simple output. - * @param objTypeUri - * the object type URI of the simple output. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple output. - * @param colOutId - * the collection input Id if this simple output belongs to a - * collection, and blank otherwise. - */ - - public static void insIntoSimpleOutput(Integer servInstId, - String articleName, String objTypeUri, String nsTypeUris, - Integer colOutId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into simple_output (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_output_id) values (?,?,?,?,?)"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - if (servInstId != null) { - ps.setInt(1, servInstId.intValue()); - } else { - ps.setNull(1, java.sql.Types.INTEGER); - } - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - if (colOutId != null) { - ps.setInt(5, colOutId.intValue()); - } else { - ps.setNull(5, java.sql.Types.INTEGER); - } - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - } - - /** - * update the record into the simple_output table - * - * @param servInstId - * the Id of service instance the simple output was added for. - * @param articleName - * the article name of the simple output. - * @param objTypeUri - * the object type URI of the simple output. - * @param nsTypeUris - * the string with set of the nameSpaces for this simple output. - * @param colOutId - * the collection input Id if this simple output belongs to a - * collection, and blank otherwise. - * @return ret=1 if the record has added, and ret=-1 otherwise - */ - - public static int updateSimpleOutput(int servInstId, String articleName, - String objTypeUri, String nsTypeUris, int colOutId, int minNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update simple_output set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_output_id=? where simple_output_id=?"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setInt(1, servInstId); - ps.setString(2, articleName); - ps.setString(3, objTypeUri); - ps.setString(4, nsTypeUris); - ps.setInt(5, colOutId); - ps.setInt(6, minNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return ret; - } - - /** - * get the number of errors for the given return code and URL of resource - * - * @param signURL - - * the URL of resource was gotten the return code for. - * @param errCode - - * the error code, connection was refused - * @return Intrger number of error if was found in the database, zero - * otherwise - */ - - public static int getServErrorNum(String signURL, int errCode) { - - int num = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select counter from service_validation where signatureURL = ? and error_code = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - ps.setInt(2, errCode); - rs = ps.executeQuery(); - - while (rs.next()) { - int cnt = rs.getInt(1); - num = cnt; - - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return num; - - } - - /** - * get the service signature data for service instance by the service name - * and signatureURL - * - * @param signURL - - * the URL of service RDF - * @param servName - - * the name of service - * @return carrier class ServSignature - */ - - public static ServSignature getServSignature(String servName, String signURL) { - - ServSignature signature = new ServSignature(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id,authority_id,category,service_type_uri,url,contact_email,authoritative,description from service_instance where servicename=? and signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setString(2, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - int servInstId = rs.getInt(1); - signature.setServInstId(servInstId); - int authId = rs.getInt(2); - signature.setAuthId(authId); - String category = rs.getString(3); - signature.setCategory(category); - String serviceType = rs.getString(4); - signature.setServiceType(serviceType); - String url = rs.getString(5); - signature.setUrl(url); - String email = rs.getString(6); - signature.setEmail(email); - String authoritative = rs.getString(7); - signature.setAuthoritative(authoritative); - String description = rs.getString(8); - signature.setDescription(description); - signature.setServiceName(servName); - signature.setSignatureURL(signURL); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return signature; - - } - - /** - * get the secondary input data by the secondary input Id - * - * @param servInstId - - * the secondary input Id - * @return carrier class Secondary - */ - - public static Secondary getSecondary(int servInstId) { - - Secondary second = new Secondary(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select default_value,maximum_value,minimum_value,enum_value,datatype,article_name from secondary_input where service_instance_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - int open_sec = 0; - while (rs.next()) { - String defaultValue = rs.getString(1); - second.setDefaultValue(defaultValue); - BigDecimal maximumValue = rs.getBigDecimal(2); - second.setMaximumValue(maximumValue); - BigDecimal minimumValue = rs.getBigDecimal(3); - second.setMinimumValue(minimumValue); - String enumValue = rs.getString(4); - second.setEnumValue(enumValue); - String datatype = rs.getString(5); - second.setDatatype(datatype); - String articleName = rs.getString(6); - second.setArticleName(articleName); - - XMLBuilder.buildSecondXml(second); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return second; - - } - - /** - * get the simple/collection output data by the service instance Id and - * build xml representation - * - * @param servInstId - - * the service instance Id - */ - - public static void getSimpleCollectOutput(int servInstId) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_output_id from simple_output where service_instance_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - - while (rs.next()) { - String artName = rs.getString(1); - String nsType = rs.getString(2); - String objType = rs.getString(3); - // int colOutId = rs.getInt(4); - String type; - Integer colOutId = new Integer(rs.getInt(4)); - if (colOutId == null) { - type = "so"; - } else { - type = "co"; - } - - XMLBuilder.buildInpOutXml(artName, nsType, objType, type); - } - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - } - - /** - * get the simple/collection input data by the service instance Id and build - * xml representation - * - * @param servInstId - - * the service instance Id - */ - - public static void getSimpleCollectInput(int servInstId) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_input_id from simple_input where service_instance_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - - while (rs.next()) { - String artName = rs.getString(1); - String nsType = rs.getString(2); - String objType = rs.getString(3); - String type; - // int colInpId = rs.getInt(4); - Integer colInpId = new Integer(rs.getInt(4)); - if (colInpId == null) { - type = "si"; - } else { - type = "ci"; - } - - XMLBuilder.buildInpOutXml(artName, nsType, objType, type); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - } - - /** - * update the counter for the given return code and URL of resource - * - * @param signURL - - * the URL of resource was updated the counter for. - * @param errCode - - * the error code was encreased the counter for. - * @return Intrger ret=1 if the record was updated, ret=-1 otherwise - */ - - public static int updErrCount(String signURL, int errCode) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update service_validation set error_code = ?,counter=counter+1 where signatureURL = ?"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setInt(1, errCode); - ps.setString(2, signURL); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return ret; - } - - /** - * add new record to the service_validation table of the mobycentral - * database - * - * @param signURL - - * the URL of resource the connection was refused for. - * @param errCode - - * the error code, connection was refused - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int insErrCount(String signURL, int errCode) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into service_validation (signatureURL,error_code,counter) values (?,?,1)"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, signURL); - ps.setInt(2, errCode); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return ret; - } - - /** - * delete the record from service_validation table by signatureURL - * - * @param signURL - - * the URL of resource the record was deleted for. - * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. - */ - - public static int delServErrors(String signURL) { - - Connection con = DBConnector.getConnection(); - int ret = -1; - final String sqlReq1 = "delete from service_validation where signatureURL = ?"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.warning(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - - } - - /** - * get the service instance Id for the given service name and authority Id - * - * @param servName - - * the name of service instance . - * @param authId - - * the authority Id for the service instance. - * @return Intrger service instance Id if was found in the database, zero - * otherwise - */ - - public static int getServInstId(String servName, int authId) { - - int servInsId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && authority_id = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setInt(2, authId); - rs = ps.executeQuery(); - - while (rs.next()) { - servInsId = rs.getInt(1); - - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return servInsId; - } - - /** - * get the service instance Id for the given service name and signatureURL - * - * @param servName - - * the name of service instance . - * @param signURL - - * URL of resource for the service instance. - * @return Intrger service instance Id if was found in the database, zero - * otherwise - */ - - public static int getServInstId(String servName, String signURL) { - - int servInsId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setString(2, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - servInsId = rs.getInt(1); - - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return servInsId; - } - - /** - * get the set of services for the given URL of resource by signatureURL - * - * @param signURL - - * the URL of resource . - * @return String set of the services which was found in the database, empty - * string otherwise - */ - - public static String getServListByURL(String signURL) { - - StringBuffer servList = new StringBuffer(); - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select servicename from service_instance where signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - String servName = rs.getString(1); - servList.append(servName + ","); - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return servList.toString(); - } - - /** - * delete a record from given table by a service instance Id (the metod is - * working for simple_input/output, collection input/output tables) - * - * @param servInstId - - * the service instance Id. - * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. - */ - - public static int delRow(String tableName, int servInstId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "delete from " + tableName - + " where service_instance_id = ?"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setInt(1, servInstId); - - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - return ret; - } - - /** - * delete a record from simple table by a service instance Id and - * collection_input_id (the metod is working for simple_input/output, - * collection input/output tables) - * - * @param servInstId - - * the service instance Id. - */ - - public static void delCollectionMember(String inout, int servInstId) { - - Connection con = DBConnector.getConnection(); - - final String sqlReq1; - //System.out.println("inout = "+inout); - if (inout.equals("input")) { - sqlReq1 = "select collection_input_id from collection_input where service_instance_id = ? "; - } else { - sqlReq1 = "select collection_output_id from collection_output where service_instance_id = ? "; - } - //System.out.println("sqlReq1 = "+sqlReq1); - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - while (rs.next()) { - int colId = rs.getInt(1); - //System.out.println("colId = "+colId); - final String sqlReq; - if (inout.equals("input")) { - sqlReq = "delete from simple_input where collection_input_id=" - + colId; - //System.out.println("sqlReq = "+sqlReq); - } else { - sqlReq = "delete from simple_output where collection_output_id=" - + colId; - } - PreparedStatement ps1 = null; - - try { - ps1 = con.prepareStatement(sqlReq); - // ps.setInt(1, servInstId); - ps1.executeUpdate(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } finally { - try { - if (ps1 != null) - ps1.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } - } - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - } - } - - } - - /** - * delete a record from service_instance table by a servicename and - * authority Id - * - * @param servName - - * the service instance name. - * @param authId - - * the id of the authority - * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. - */ - - public static int delSignature(String servName, int authId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - // if (authId == 0){ - final String sqlReq1 = "delete from service_instance where servicename= ? and authority_id = ?"; - PreparedStatement ps = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - ps.setInt(2, authId); - ret = ps.executeUpdate(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * get the collection Id from collection_input or collection_output table by - * the service_instance_id - * - * @param table - - * the collection_input or collection_output table - * @param field - - * "collection_input_id" (for collection_input table) and - * "collection_output_id" (for collection_output table) - * @param servInstId - - * Id of service instance - * @return Integer collection Id if was found, zero otherwise. - */ - - public static int getCollectionId(String table, String field, int servInstId) { - - int colId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select " - + field - + " from " - + table - + " where service_instance_id = ? order by service_instance_id," - + field + " ASC"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setInt(1, servInstId); - rs = ps.executeQuery(); - - while (rs.next()) { - colId = rs.getInt(1); - - } - - } catch (SQLException e) { - - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return colId; - - } - - /** - * add new record into the collection_input or collection_output table - * - * @param table - - * the collection_input or collection_output table - * @param artName - - * the artical name of the collection_input or collection_output - * @param servInstId - - * Id of service instance - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int insIntoCol(String table, String artName, int servInstId) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into " + table - + " (article_name,service_instance_id) values (?,?)"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, artName); - ps.setInt(2, servInstId); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * update record into the collection_input or collection_output table - * - * @param table - - * the collection_input or collection_output table - * @param key_field - - * collection_input_id for collection_input table, - * collection_output_id for collection_output table; - * @param artName - - * the artical name of the collection_input or collection_output - * @param servInstId - - * Id of service instance - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int updateCol(String table, String key_field, String artName, - int servInstId, int minNum) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "update " + table - + " set article_name=?,service_instance_id=? where " - + key_field + " =?"; - - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, artName); - ps.setInt(2, servInstId); - ps.setInt(3, minNum); - ret = ps.executeUpdate(); - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - return ret; - } - - /** - * get the service authority URI from authority table by the servicename - * - * @param servName - - * the name of service - * @return String authority URI if was found, empty string otherwise. - */ - - public static String getServAuthURI(String servName) { - - Connection con = DBConnector.getConnection(); - - String authURI = ""; - - final String sqlReq1 = "select authority_uri from service_instance si,authority a where si.authority_id=a.authority_id and si.servicename=?"; - ; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, servName); - rs = ps.executeQuery(); - - while (rs.next()) { - authURI = rs.getString(1); - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return authURI; - - } - - /** - * get the service authority Id from service_instance table by the - * servicename and signatureURL - * - * @param serviceName - - * the name of service - * @param signURL - - * the signatureURL for the given service - * @return int authority Id if was found, zero otherwise. - */ - - public static int getAuthIdByServNameAndSignURL(String serviceName, - String signURL) { - - int authId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select authority_id from service_instance where servicename = ? and signatureURL = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, serviceName); - ps.setString(2, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - authId = rs.getInt(1); - - } - - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return authId; - } - - /** - * add new record to the authority table - * - * @param authURI - - * the authority URI - * @param email - - * the contact e-Mail - * @return Intrger ret=1 if the record was added, ret=-1 otherwise - */ - - public static int insIntoAuthority(String authURI, String email) { - - Connection con = DBConnector.getConnection(); - - int ret = -1; - - final String sqlReq1 = "insert into authority (authority_common_name,authority_uri,contact_email) values (null,?,?)"; - PreparedStatement ps = null; - - try { - ps = con.prepareStatement(sqlReq1); - - ps.setString(1, authURI); - ps.setString(2, email); - ret = ps.executeUpdate(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } finally { - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - } - - return ret; - } - - /** - * get the service authority Id from authority table by the authority URI - * - * @param authURI - - * the authority URI - * @return int authority Id if was found, zero otherwise. - */ - - public static int getAuthIdByAuthURI(String authURI) { - - int authId = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select authority_id from authority where authority_uri = ?"; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, authURI); - - rs = ps.executeQuery(); - - while (rs.next()) { - authId = rs.getInt(1); - } - - } catch (SQLException e) { - // e.getMessage(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - - return authId; - - } - - /** - * get the contact e-Mail from service_instance table by the servicename - * - * @param signURL - - * the URL of a resource - * @return String contact e-Mail if was found, empty string otherwise. - */ - - public static String getContactEmail(String signURL) { - - String email = ""; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select contact_email from service_instance where signatureURL = ? "; - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - ps.setString(1, signURL); - rs = ps.executeQuery(); - - while (rs.next()) { - String cnt = rs.getString(1); - email = cnt; - - } - - } catch (SQLException e) { - - // e.printStackTrace(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - - } - //System.out.println("email = "+email); - return email; - - } - - /** - * - * gets the min number of records with service instance id = 0 - * - * @param table - * @param key_field - * @return the number of records - */ - - public static int getMinFreeNumber(String table, String key_field) { - - int num = 0; - - Connection con = DBConnector.getConnection(); - - final String sqlReq1 = "select min(" + key_field + ") from " + table - + " where service_instance_id = 0 order by " + key_field; - - PreparedStatement ps = null; - ResultSet rs = null; - try { - ps = con.prepareStatement(sqlReq1); - rs = ps.executeQuery(); - - while (rs.next()) { - num = rs.getInt(1); - } - - } catch (SQLException e) { - - // e.printStackTrace(); - Log.severe(e.getMessage()); - } finally { - try { - if (rs != null) - rs.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } - try { - if (ps != null) - ps.close(); - } catch (SQLException e) { - Log.severe(e.getMessage()); - // e.getMessage(); - } + /** + * get the list of signatureURL from service_instance table + * + * @return a Hashtable (signatureURL = string of servicenames for this URL + * separated by comma) + * + * + */ + + public static Hashtable getServices(String file) { + + Hashtable services = new Hashtable(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select servicename,signatureURL,authority_id from service_instance order by signatureURL"; + + PreparedStatement ps = null; + ResultSet rs = null; + + try { + ps = con.prepareStatement(sqlReq1); + rs = ps.executeQuery(); + String lastAddr = ""; + StringBuffer servNames = new StringBuffer(); + int lastID = -1; + + while (rs.next()) { + String servName = rs.getString(1); + String rdfAddr = rs.getString(2); + int authorityID = rs.getInt(3); // value will never be null, so + // wasNull() not necessary + if (rdfAddr == null) { + //TODO - make this code more efficient! - maybe perform one + // sql call instead of many + // update the signatureURL field using the service name and + // authority id + String bogusSigURL = "http://invalidURL123.com/author/" + + authorityID + "/" + servName + ".xml"; + String updateSQLString = "UPDATE service_instance " + + "SET signatureURL='" + bogusSigURL + "' " + + "WHERE authority_id=" + authorityID + + " and servicename='" + servName + "'"; + PreparedStatement preparedStatement = null; + try { + Connection updateCon = DBConnector.getConnection(); + preparedStatement = updateCon + .prepareStatement(updateSQLString); + int resultSet = preparedStatement.executeUpdate(); + Log + .info(resultSet + + ": Updated the signatureURL field of the authority with id #" + + authorityID + " to be " + bogusSigURL + + "."); + } catch (SQLException e) { + Log + .severe("Could not update SignatureURL field with a bogus signatureURL.\n" + + e.getMessage()); + } + + } else { + if (rdfAddr.equals(lastAddr)) { + servNames.append("," + servName); + } else { + if (servNames.length() > 0) { + services.put(lastAddr, servNames); + servNames = new StringBuffer(); + } + servNames.append(servName); + lastAddr = rdfAddr; + Report.doSave(file, lastAddr); + } + } + } + services.put(lastAddr, servNames); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + //System.out.println("ListOFServices : "+services); + + return services; + } + + /** + * get the list of services by signatureURL + * + * @param signURL - + * URL of resource + * @return a Hashtable (signatureURL = string of servicenames for this URL + * separated by comma) + */ + + public static Hashtable getServicesByURL(String signURL) { + + Hashtable services = new Hashtable(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select servicename,signatureURL from service_instance where signatureURL=?"; + + PreparedStatement ps = null; + ResultSet rs = null; + + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + String lastAddr = ""; + StringBuffer servNames = new StringBuffer(); + + while (rs.next()) { + String servName = rs.getString(1); + String rdfAddr = rs.getString(2); + + if (rdfAddr.equals(lastAddr)) { + servNames.append("," + servName); + } else { + if (servNames.length() > 0) { + services.put(lastAddr, servNames); + servNames = new StringBuffer(); + } + servNames.append(servName); + lastAddr = rdfAddr; + } + } + services.put(lastAddr, servNames); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + // System.out.println("ListOFServices : "+services); + + return services; + } + + /** + * This method use for the update service_instance table, + * simple_input/output table, collection_input/output table, secondary_input + * table in accordance with data from RDF file. + * + * @param servSign - + * set of the serviceSignature data (name - value, an example: + * servicename - GoTerm); Hashtable of hashtables represented by + * a pair: a name of the input = hashtable for this output + * example:{siminp1={object_type_uri=urn:lsid:biomoby.org:objectclass:Object, + * namespace_type_uris=urn:lsid:biomoby.org:namespacetype:taxon}} + * @param servInp - + * Hashtable of hashtables represented by a pair: a name of the + * output = hashtable for this output + * @param servname - + * the name of service + * @param authURI - + * the authority URI + * @param signURL - + * URL of resource + */ + + public static void processService(Hashtable servSign, Hashtable servInp, + Hashtable servOut, String servname, String authURI, String signURL) { + + Connection con = DBConnector.getConnection(); + String servName = ""; + String cat = "moby"; + String url = ""; + String email = ""; + String desc = ""; + String stype = ""; + String authuri = ""; + String authoritative = ""; + String art = null; + String col_art = null; + String obt = null; + String nst = null; + String artsec = null; + String defsec = null; + String dtsec = null; + + BigDecimal maxsec = null; + BigDecimal minsec = null; + + String enumsec = null; + int colId = 0; + Integer colOutId = null; + Integer colInpId = null; + int serv = 0; // a flag - the given service was found + int checkServ = 0; // a flag - the service exist in the database + int new_serv = 0; // the number of new services + int ret; + int servInstId = 0; + String signatureURL = "NNN"; + + // ************** Update service Signature **************** + + Enumeration num = servSign.keys(); + + while (num.hasMoreElements()) { + + Object ob = num.nextElement(); + Object val = servSign.get(ob); + if (ob.equals("category")) { + cat = val.toString(); + } else if (ob.equals("URL")) { + url = val.toString(); + } else if (ob.equals("contact_email")) { + email = val.toString(); + } else if (ob.equals("description")) { + desc = val.toString(); + } else if (ob.equals("service_type_uri")) { + stype = val.toString(); + } else if (ob.equals("authURI")) { + authuri = val.toString(); + } else if (ob.equals("authoritative")) { + authoritative = val.toString(); + + if (authoritative.equals("non-authoritative")) { + authoritative = "0"; + } else if (authoritative.equals("authoritative")) { + authoritative = "1"; + } + } else if (ob.equals("servicename")) { + servName = val.toString(); + } else if (ob.equals("signatureURL")) { + signatureURL = val.toString(); + } + + } + + ServSignature signature = getServSignature(servname, signURL); + servInstId = signature.getServInstId(); + //TODO make sure that the fields are updated + if (servInstId == 0) { + + int authId = getAuthIdByAuthURI(authuri); + + if (authId == 0) { + insIntoAuthority(authuri, email); + authId = getAuthIdByAuthURI(authuri); + } + + if (signatureURL.equals("NNN")) { + ret = createSignature(servName, cat, stype, authId, url, email, + authoritative, desc, signURL); + } else { + ret = createSignature(servName, cat, stype, authId, url, email, + authoritative, desc, signatureURL); + } + + if (ret == 1) { + String msg = "------The service instance <" + servName + + "> was registered in the MOBYCENTRAL registry "; + Report.doWrite(msg); + Report.add(msg); + + //System.out.println("mail_server = + // "+Constants.MB_MAIL_SERVER); + /* + * if (Constants.MB_MAIL_SERVER != null | + * !Constants.MB_MAIL_SERVER.equals("")) { String to = + * DataMngr.getContactEmail(signURL); + * Communicator.sendMail(to,Constants.SP_SUBJECT,msg,Constants.MB_FROM); // + * send message to the service provider - that service was + * deregistered } + */ + new_serv += 1; + servInstId = getServInstId(servName, authId); + } + } else { + + if (!cat.equals(signature.getCategory()) + || !url.equals(signature.getUrl()) + || !email.equals(signature.getEmail()) + || !desc.equals(signature.getDescription()) + || !stype.equals(signature.getServiceType()) + || !authoritative.equals(signature.getAuthoritative()) + || !authuri.equals(authURI)) { + + //TODO + Log.info("Updating the service '" + servName + + "' since the RDF document has been modified."); + if (signatureURL.equals("NNN")) { + Log.info("sig == NNN" + signURL); + Log + .info("=<" + + servName + + "," + + cat + + "," + + stype + + "," + + authuri + + "," + + url + + "," + + email + + "," + + desc + + "," + + authoritative + + "," + + signURL + ">"); + int res = updSign(servName, cat, stype, authuri, url, + email, desc, authoritative, signURL); + if (res == 1) { + Report.doWrite("------The service instance<" + servName + + "> was updated "); + Report.add("------The service instance <" + servName + + ">was updated "); + } else { + Report.doWrite("------The service instance<" + servName + + "> was not updated"); + Report.add("------The service instance <" + servName + + ">was not updated "); + } + + } else { + Log.info("sig != NNN"); + int res = updSign(servName, cat, stype, authuri, url, + email, desc, authoritative, signatureURL); + if (res == 1) { + Report.doWrite("------The service instance <" + + servName + "> was updated "); + Report.add("------The service instance <" + servName + + ">was updated "); + } else { + Report.doWrite("------The service instance <" + + servName + "> was not updated "); + Report.add("------The service instance <" + servName + + ">was not updated "); + } + } + } + } + + // ************ add Input ********************* + + Enumeration num1 = servInp.keys(); + int dels = 0; + int delc = 0; + int delsec = 0; + int si = 0; + int ci = 0; + int sci = 0; + + /* if there are no inputs, delete all from mobycentral */ + if (servInp.size() == 0) { + //make sure that there are no inputs in the db (simples, secondary + // or collection) + if (delRow("secondary_input", servInstId) == 1) + delsec = 1; + delCollectionMember("input", servInstId); + if (delRow("collection_input", servInstId) == 1) + delc = 1; + if (delRow("simple_input", servInstId) == 1) + dels = 1; + } + if (!servInp.containsKey("siminp1")) { + if (delRow("simple_input", servInstId) == 1) + dels = 1; + } + if (!servInp.containsKey("colinp1")) { + delCollectionMember("input", servInstId); + if (delRow("collection_input", servInstId) == 1) + delc = 1; + } + /* + * going to remove any secondaries not in the hash - quick hack to + * bug#29 + */ + if (!servInp.containsKey("secinp1")) { + if (delRow("secondary_input", servInstId) == 1) + delsec = 1; + } + while (num1.hasMoreElements()) { + Object ob = num1.nextElement(); + Object val = servInp.get(ob); + String simcol = (ob.toString()).substring(0, 6); // a hashtable name + + if (simcol.equals("secinp")) { // if it's a Secondary input + sci += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Secondary input " + sci); + Report.add("Secondary input " + sci + ":"); + if (delsec == 0) { + delRow("secondary_input", servInstId); + delsec = 1; + } + } else if (simcol.equals("colinp")) { // if it's a Collection input + ci += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Collection input " + ci); + Report.add("Collection input " + ci + ":"); + if (delc == 0) { + // colInpId = new + // Integer(getCollectionId("collection_input","collection_input_id",servInstId)); + delCollectionMember("input", servInstId); // delete from + // simple_input + // table + delRow("collection_input", servInstId); // delete from the + // collection_input + // table + delc = 1; + } + + } else { // if it's a Simple input + Report.doWrite(" "); + Report.add(" "); + si += 1; + Report.doWrite("Simple input " + si); + Report.add("Simple input " + si + ":"); + if (dels == 0) { + delRow("simple_input", servInstId); // delete from + // simple_input table + dels = 1; + } + } + Hashtable simple = new Hashtable(); + simple = (Hashtable) val; + Enumeration num11 = simple.keys(); + + while (num11.hasMoreElements()) { + Object ob1 = num11.nextElement(); + if (!ob1.equals("type")) { + Report.doWrite(ob1 + " = " + simple.get(ob1)); + Report.add(ob1 + " = " + simple.get(ob1)); + } + + if (ob1.equals("col_articleName")) { + col_art = simple.get(ob1).toString(); + if (col_art.equals(" ")) { + col_art = null; + } + } else if (ob1.equals("articleName")) { + art = simple.get(ob1).toString(); + if (art.equals(" ")) { + art = null; + } + } else if (ob1.equals("article_name")) { + artsec = simple.get(ob1).toString(); + if (artsec.equals(" ")) { + artsec = null; + } + } else if (ob1.equals("object_type_uri")) { + obt = simple.get(ob1).toString(); + } else if (ob1.equals("namespace_type_uris")) { + nst = simple.get(ob1).toString(); + } else if (ob1.equals("default")) { + defsec = simple.get(ob1).toString(); + } else if (ob1.equals("datatype")) { + dtsec = simple.get(ob1).toString(); + } else if (ob1.equals("max")) { + String maxsec_s = simple.get(ob1).toString(); + try { + maxsec = new BigDecimal(maxsec_s); + + } catch (NumberFormatException nx) { + Log.severe(nx.getMessage()); + // nx.getMessage(); + } + } else if (ob1.equals("min")) { + String minsec_s = simple.get(ob1).toString(); + try { + minsec = new BigDecimal(minsec_s); + + } catch (NumberFormatException nx) { + Log.severe(nx.getMessage()); + // nx.getMessage(); + } + } else if (ob1.equals("enum")) { + enumsec = simple.get(ob1).toString(); + } + } + + if (simcol.equals("colinp")) { + insIntoCol("collection_input", col_art, servInstId); // insert + // the row + // into + // collection_input + // table + colId = getCollectionId("collection_input", + "collection_input_id", servInstId); + insIntoSimpleInput(null, art, obt, nst, new Integer(colId)); + + art = null; + col_art = null; + obt = null; + nst = null; + } else if (simcol.equals("siminp")) { + insIntoSimpleInput(new Integer(servInstId), art, obt, nst, null); + + art = null; + obt = null; + nst = null; + } else if (simcol.equals("secinp")) { + + insIntoSecondary(servInstId, artsec, defsec, dtsec, maxsec, + minsec, enumsec); + + artsec = null; + defsec = null; + dtsec = null; + maxsec = null; + minsec = null; + enumsec = null; + } + + if (colId != 0) { + Report.doWrite("collection_input_id: " + colId); + // Log.info("collection_input_id: "+colId); + } + } + + Report.doWrite("service_instance_id: " + servInstId); + // Log.info("service_instance_id: "+servInstId); + + // *********** add Output *********************** + + Enumeration numout = servOut.keys(); + int delsout = 0; + int delcout = 0; + int so = 0; + int co = 0; + if (servOut.size() == 0) { + //make sure that there are no outputs in the db (simples or + // collection) + delCollectionMember("output", servInstId); + if (delRow("collection_output", servInstId) == 1) + delcout = 1; + if (delRow("simple_output", servInstId) == 1) + delsout = 1; + Report.doWrite("Removed all outputs."); + Log.info("Removed all outputs."); + } + if (!servOut.containsKey("colout1")) { // using simout1 because counting starts at 1 + delCollectionMember("output", servInstId); + if (delRow("collection_output", servInstId) == 1) + delcout = 1; + } + if (!servOut.containsKey("simout1")) { // using simout1 because counting starts at 1 + if (delRow("simple_output", servInstId) == 1) + delsout = 1; + } + while (numout.hasMoreElements()) { + Object ob = numout.nextElement(); + Object val = servOut.get(ob); + String simcol = (ob.toString()).substring(0, 6); + if (simcol.equals("colout")) { + co += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Collection output " + co); + Report.add("Collection output " + co + ":"); + if (delcout == 0) { + // colOutId = new + // Integer(getCollectionId("collection_output","collection_output_id",servInstId)); + delCollectionMember("output", servInstId); // delete from + // table + // simple_output + delRow("collection_output", servInstId); // delete from the + // collection_output + // table + delcout = 1; + } + } else { + so += 1; + Report.doWrite(" "); + Report.add(" "); + Report.doWrite("Simple output " + so); + Report.add("Simple output " + so + ":"); + + //TODO bug #13 here? + if (delsout == 0) { + delRow("simple_output", servInstId); // delete from + // simple_output table + delsout = 1; + } + } + Hashtable simple = new Hashtable(); + simple = (Hashtable) val; + Enumeration num11 = simple.keys(); + // Report.doWrite(""+simple); + + while (num11.hasMoreElements()) { + Object ob1 = num11.nextElement(); + if (!ob1.equals("type")) { + Report.doWrite(ob1 + " = " + simple.get(ob1)); + Report.add(ob1 + " = " + simple.get(ob1)); + } + + if (ob1.equals("col_articleName")) { + col_art = simple.get(ob1).toString(); + if (col_art.equals(" ")) { + col_art = null; + } + } + if (ob1.equals("articleName")) { + art = simple.get(ob1).toString(); + if (art.equals(" ")) { + art = null; + } + } + if (ob1.equals("object_type_uri")) { + obt = simple.get(ob1).toString(); + } + if (ob1.equals("namespace_type_uris")) { + nst = simple.get(ob1).toString(); + } + } + + if (simcol.equals("colout")) { + + insIntoCol("collection_output", col_art, servInstId); // insert + // the row + // into + // collection_input + // table + + colOutId = new Integer(getCollectionId("collection_output", + "collection_output_id", servInstId)); + insIntoSimpleOutput(null, art, obt, nst, colOutId); + art = null; + obt = null; + nst = null; + } + // TODO bug #11 here - fixed + if (simcol.equals("simout")) { + insIntoSimpleOutput(new Integer(servInstId), art, obt, nst, + null); + art = null; + obt = null; + nst = null; + } + if (colOutId != null) { + Report.doWrite("collection_output_id: " + colOutId); + // Log.info("collection_output_id: "+coloutId); + } + } + // return serv; + } + + /** + * delete the service instance by service name and authority URI + * + * @param servName + * the name of service which we want delete. + * @param authURI + * the authority URI for service which we want delete. + * + */ + + public static void delServByNameAndAuthURI(String servName, String authURI) { + + int authId = getAuthIdByAuthURI(authURI); + int servInstId = getServInstId(servName, authId); + + delSignature(servName, authId); // delete service from table + // service_instance + delRow("simple_input", servInstId); // delete from table simple_input + delRow("simple_output", servInstId); // delete from table simple_output + delRow("secondary_input", servInstId); //TODO - should this line be + // here? + delCollectionMember("input", servInstId); + delCollectionMember("output", servInstId); + delRow("collection_input", servInstId); // delete from table + // collection_input + delRow("collection_output", servInstId); // delete from table + // collection_output + } + + /** + * delete the service instance by service name and signature URL + * + * @param servName + * the name of service which we want delete. + * @param signURL + * the authority URI for service which we want delete. + * + */ + + public static void delServByNameAndUrl(String servName, String signURL) { + + int authId = getAuthIdByServNameAndSignURL(servName, signURL); + int servInstId = getServInstId(servName, authId); + + delSignature(servName, authId); // delete service from table + // service_instance + delRow("simple_input", servInstId); // delete from table simple_input + delRow("simple_output", servInstId); // delete from table simple_output + delRow("secondary_input", servInstId); //TODO - should this line be + // here? + delCollectionMember("input", servInstId); + delCollectionMember("output", servInstId); + delRow("collection_input", servInstId); // delete from table + // collection_input + delRow("collection_output", servInstId); // delete from table + // collection_output + } + + /** + * delete set of the service instances with the same signatureURL by + * signatureURL + * + * @param signURL + * the name of service which we want delete. + */ + + public static void delServiceSetByURL(String signURL) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id,servicename,authority_id from service_instance where signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + Vector del_serv = new Vector(); + + while (rs.next()) { + int servInstId = rs.getInt(1); + String servName = rs.getString(2); + int authId = rs.getInt(3); + + int rez = delSignature(servName, authId); // delete service from + // table + // service_instance + if (rez == 1) { + del_serv.addElement(servName); + } + delRow("secondary_input", servInstId); //TODO - should this + // line be here? + delRow("simple_input", servInstId); // delete from table + // simple_input + delRow("simple_output", servInstId); // delete from table + // simple_output + delCollectionMember("input", servInstId); // delete collection + // member from + // simple_input + delCollectionMember("output", servInstId); // delete collection + // member from + // simple_output + delRow("collection_input", servInstId); // delete from table + // collection_input + delRow("collection_output", servInstId); // delete from table + // collection_output + } + + int del = del_serv.size(); + if (del > 0) { + Report.doWrite("DELETED SERVICES: "); + Iterator i = del_serv.iterator(); + int n = 1; + while (i.hasNext()) { + String delServ = i.next().toString(); + Report.doWrite(n + ". " + delServ); + n += 1; + } + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } + } + + } + + /** + * add the record about new service instance in the service_instance table + * of mobycentral database + * + * @param servName - + * the name of service instance the record was added for. + * @param cat - + * the category of service instance. + * @param servTypeURI - + * the service type URI of service instance. + * @param authId - + * the authority Id of service instance. + * @param url - + * the URL of service instance. + * @param email - + * the contact e-Mail of service instance. + * @param authoritative - + * the authoritative of service instance. + * @param desc - + * the description of service instance. + * @param signURL - + * the URL for RDF of service instance. + * @return ret=1 if the record has added, and ret=-1 otherwise + */ + + public static int createSignature(String servName, String cat, + String servTypeURI, int authId, String url, String email, + String authoritative, String desc, String signURL) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into service_instance (servicename,category,service_type_uri,authority_id,url,contact_email,authoritative,description,signatureURL) values (?,?,?,?,?,?,?,?,?)"; + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setString(2, cat); + ps.setString(3, servTypeURI); + ps.setInt(4, authId); + ps.setString(5, url); + ps.setString(6, email); + ps.setString(7, authoritative); + ps.setString(8, desc); + ps.setString(9, signURL); + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * update the service instance data in the service_instance table of + * mobycentral database + * + * @param servName + * the name of service instance the record was updated for. + * @param cat + * the category of service instance. + * @param stype + * the service type URI of service instance. + * @param authuri + * the authority URI of service instance. + * @param url + * the URL of service instance. + * @param email + * the contact e-Mail of service instance. + * @param authoritative + * the authoritative of service instance. + * @param desc + * the description of service instance. + * @param signURL + * the URL for RDF of service instance. + * @return ret=1 if the record has updated, and ret=-1 otherwise + */ + + public static int updSign(String servName, String cat, String stype, + String authuri, String url, String email, String desc, + String authoritative, String signURL) { + + Connection con = DBConnector.getConnection(); + int cnt = -1; + int ret = -1; + final String sqlReq = "select authority_id from authority where authority_uri = ?"; + PreparedStatement ps = null; + + final String sqlReq1 = "update service_instance set category = ?,service_type_uri = ?,url = ?,contact_email = ?,description = ?,authoritative = ?,signatureURL = ? where servicename = ? && authority_id = ?"; + try { + ps = con.prepareStatement(sqlReq); + ps.setString(1, authuri); + ResultSet rs = ps.executeQuery(); + while (rs.next()) { + cnt = rs.getInt(1); + } + if (cnt > -1) { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, cat); + ps.setString(2, stype); + ps.setString(3, url); + ps.setString(4, email); + ps.setString(5, desc); + ps.setString(6, authoritative); + ps.setString(7, signURL); + ps.setString(8, servName); + ps.setInt(9, cnt); + ret = ps.executeUpdate(); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * add the record into the simple_input table + * + * @param servInstId + * the Id of service instance the simple input was added for. + * @param articleName + * the article name of the simple input. + * @param objTypeUri + * the object type URI of the simple input. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple input. + * @param colInpId + * the collection input Id if this simple input belongs to a + * collection, and blank otherwise. + */ + + public static void insIntoSimpleInput(Integer servInstId, + String articleName, String objTypeUri, String nsTypeUris, + Integer colInpId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into simple_input (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_input_id) values (?,?,?,?,?)"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + if (servInstId != null) { + ps.setInt(1, servInstId.intValue()); + } else { + ps.setNull(1, java.sql.Types.INTEGER); + } + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + if (colInpId != null) { + ps.setInt(5, colInpId.intValue()); + } else { + ps.setNull(5, java.sql.Types.INTEGER); + } + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + } + + /** + * update the record into the simple_input table + * + * @param servInstId + * the Id of service instance the simple input was added for. + * @param articleName + * the article name of the simple input. + * @param objTypeUri + * the object type URI of the simple input. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple input. + * @param colInpId + * the collection input Id if this simple input belongs to a + * collection, and blank otherwise. + * @return ret=1 if the record has added, and ret=-1 otherwise + */ + + public static int updateSimpleInput(int servInstId, String articleName, + String objTypeUri, String nsTypeUris, Integer colInpId, int minNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update simple_input set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_input_id=? where simple_input_id=?"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + if (colInpId != null) { + ps.setInt(5, colInpId.intValue()); + } else { + ps.setNull(5, java.sql.Types.INTEGER); + } + ps.setInt(6, minNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * add the record about secondary input in the secondary_input table of + * mobycentral database + * + * @param servInstId + * the Id of service instance the secondary input was added for. + * @param article_name + * the article name of the secondary input. + * @param def + * the default value of the secondary input. + * @param dataType + * the type of data of the secondary input. + * @param max + * the maximum value of the secondary input + * @param min + * the minimum value of the secondary input * + * @param enumeration + * the enumeration value for the secondary input + */ + + public static void insIntoSecondary(int servInstId, String article_name, + String def, String dataType, BigDecimal max, BigDecimal min, + String enumeration) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into secondary_input (service_instance_id,article_name,default_value,maximum_value,minimum_value,enum_value,datatype) values (?,?,?,?,?,?,?)"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + ps.setString(2, article_name); + ps.setString(3, def); + ps.setBigDecimal(4, max); + ps.setBigDecimal(5, min); + ps.setString(6, enumeration); + ps.setString(7, dataType); + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + } + + /** + * update the record into the secondary_input table + * + * @param servInstId + * the Id of service instance the secondary input was added for. + * @param article_name + * the article name of the secondary input. + * @param def + * the default value of the secondary input. + * @param dataType + * the type of data of the secondary input. + * @param max + * the maximum value of the secondary input + * @param min + * the minimum value of the secondary input + * @param enumeration + * the enumeration value for the secondary input + * @param minSecNum + * minimum free number for secondary_input_id + */ + + public static void updateSec(int servInstId, String article_name, + String def, String dataType, BigDecimal max, BigDecimal min, + String enumeration, int minSecNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update secondary_input set service_instance_id=?,article_name=?,default_value=?,maximum_value=?,minimum_value=?,enum_value=?,datatype=? where secondary_input_id=?"; + + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + ps.setString(2, article_name); + ps.setString(3, def); + ps.setBigDecimal(4, max); + ps.setBigDecimal(5, min); + ps.setString(6, enumeration); + ps.setString(7, dataType); + ps.setInt(8, minSecNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } + } + } + + /** + * add the record into the simple_output table + * + * @param servInstId + * the Id of service instance the simple output was added for. + * @param articleName + * the article name of the simple output. + * @param objTypeUri + * the object type URI of the simple output. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple output. + * @param colOutId + * the collection input Id if this simple output belongs to a + * collection, and blank otherwise. + */ + + public static void insIntoSimpleOutput(Integer servInstId, + String articleName, String objTypeUri, String nsTypeUris, + Integer colOutId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into simple_output (service_instance_id,article_name,object_type_uri,namespace_type_uris,collection_output_id) values (?,?,?,?,?)"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + if (servInstId != null) { + ps.setInt(1, servInstId.intValue()); + } else { + ps.setNull(1, java.sql.Types.INTEGER); + } + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + if (colOutId != null) { + ps.setInt(5, colOutId.intValue()); + } else { + ps.setNull(5, java.sql.Types.INTEGER); + } + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + } + + /** + * update the record into the simple_output table + * + * @param servInstId + * the Id of service instance the simple output was added for. + * @param articleName + * the article name of the simple output. + * @param objTypeUri + * the object type URI of the simple output. + * @param nsTypeUris + * the string with set of the nameSpaces for this simple output. + * @param colOutId + * the collection input Id if this simple output belongs to a + * collection, and blank otherwise. + * @return ret=1 if the record has added, and ret=-1 otherwise + */ + + public static int updateSimpleOutput(int servInstId, String articleName, + String objTypeUri, String nsTypeUris, int colOutId, int minNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update simple_output set service_instance_id=?,article_name=?,object_type_uri=?,namespace_type_uris=?,collection_output_id=? where simple_output_id=?"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setInt(1, servInstId); + ps.setString(2, articleName); + ps.setString(3, objTypeUri); + ps.setString(4, nsTypeUris); + ps.setInt(5, colOutId); + ps.setInt(6, minNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return ret; + } + + /** + * get the number of errors for the given return code and URL of resource + * + * @param signURL - + * the URL of resource was gotten the return code for. + * @param errCode - + * the error code, connection was refused + * @return Intrger number of error if was found in the database, zero + * otherwise + */ + + public static int getServErrorNum(String signURL, int errCode) { + + int num = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select counter from service_validation where signatureURL = ? and error_code = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + ps.setInt(2, errCode); + rs = ps.executeQuery(); + + while (rs.next()) { + int cnt = rs.getInt(1); + num = cnt; + + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return num; + + } + + /** + * get the service signature data for service instance by the service name + * and signatureURL + * + * @param signURL - + * the URL of service RDF + * @param servName - + * the name of service + * @return carrier class ServSignature + */ + + public static ServSignature getServSignature(String servName, String signURL) { + + ServSignature signature = new ServSignature(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id,authority_id,category,service_type_uri,url,contact_email,authoritative,description from service_instance where servicename=? and signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setString(2, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + int servInstId = rs.getInt(1); + signature.setServInstId(servInstId); + int authId = rs.getInt(2); + signature.setAuthId(authId); + String category = rs.getString(3); + signature.setCategory(category); + String serviceType = rs.getString(4); + signature.setServiceType(serviceType); + String url = rs.getString(5); + signature.setUrl(url); + String email = rs.getString(6); + signature.setEmail(email); + String authoritative = rs.getString(7); + signature.setAuthoritative(authoritative); + String description = rs.getString(8); + signature.setDescription(description); + signature.setServiceName(servName); + signature.setSignatureURL(signURL); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return signature; + + } + + /** + * get the secondary input data by the secondary input Id + * + * @param servInstId - + * the secondary input Id + * @return carrier class Secondary + */ + + public static Secondary getSecondary(int servInstId) { + + Secondary second = new Secondary(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select default_value,maximum_value,minimum_value,enum_value,datatype,article_name from secondary_input where service_instance_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + int open_sec = 0; + while (rs.next()) { + String defaultValue = rs.getString(1); + second.setDefaultValue(defaultValue); + BigDecimal maximumValue = rs.getBigDecimal(2); + second.setMaximumValue(maximumValue); + BigDecimal minimumValue = rs.getBigDecimal(3); + second.setMinimumValue(minimumValue); + String enumValue = rs.getString(4); + second.setEnumValue(enumValue); + String datatype = rs.getString(5); + second.setDatatype(datatype); + String articleName = rs.getString(6); + second.setArticleName(articleName); + + XMLBuilder.buildSecondXml(second); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return second; + + } + + /** + * get the simple/collection output data by the service instance Id and + * build xml representation + * + * @param servInstId - + * the service instance Id + */ + + public static void getSimpleCollectOutput(int servInstId) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_output_id from simple_output where service_instance_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + + while (rs.next()) { + String artName = rs.getString(1); + String nsType = rs.getString(2); + String objType = rs.getString(3); + // int colOutId = rs.getInt(4); + String type; + Integer colOutId = new Integer(rs.getInt(4)); + if (colOutId == null) { + type = "so"; + } else { + type = "co"; + } + + XMLBuilder.buildInpOutXml(artName, nsType, objType, type); + } + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + } + + /** + * get the simple/collection input data by the service instance Id and build + * xml representation + * + * @param servInstId - + * the service instance Id + */ + + public static void getSimpleCollectInput(int servInstId) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select article_name,namespace_type_uris,object_type_uri,collection_input_id from simple_input where service_instance_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + + while (rs.next()) { + String artName = rs.getString(1); + String nsType = rs.getString(2); + String objType = rs.getString(3); + String type; + // int colInpId = rs.getInt(4); + Integer colInpId = new Integer(rs.getInt(4)); + if (colInpId == null) { + type = "si"; + } else { + type = "ci"; + } + + XMLBuilder.buildInpOutXml(artName, nsType, objType, type); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + } + + /** + * update the counter for the given return code and URL of resource + * + * @param signURL - + * the URL of resource was updated the counter for. + * @param errCode - + * the error code was encreased the counter for. + * @return Intrger ret=1 if the record was updated, ret=-1 otherwise + */ + + public static int updErrCount(String signURL, int errCode) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update service_validation set error_code = ?,counter=counter+1 where signatureURL = ?"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setInt(1, errCode); + ps.setString(2, signURL); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return ret; + } + + /** + * add new record to the service_validation table of the mobycentral + * database + * + * @param signURL - + * the URL of resource the connection was refused for. + * @param errCode - + * the error code, connection was refused + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int insErrCount(String signURL, int errCode) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into service_validation (signatureURL,error_code,counter) values (?,?,1)"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, signURL); + ps.setInt(2, errCode); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return ret; + } + + /** + * delete the record from service_validation table by signatureURL + * + * @param signURL - + * the URL of resource the record was deleted for. + * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. + */ + + public static int delServErrors(String signURL) { + + Connection con = DBConnector.getConnection(); + int ret = -1; + final String sqlReq1 = "delete from service_validation where signatureURL = ?"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.warning(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + + } + + /** + * get the service instance Id for the given service name and authority Id + * + * @param servName - + * the name of service instance . + * @param authId - + * the authority Id for the service instance. + * @return Intrger service instance Id if was found in the database, zero + * otherwise + */ + + public static int getServInstId(String servName, int authId) { + + int servInsId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && authority_id = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setInt(2, authId); + rs = ps.executeQuery(); + + while (rs.next()) { + servInsId = rs.getInt(1); + + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return servInsId; + } + + /** + * get the service instance Id for the given service name and signatureURL + * + * @param servName - + * the name of service instance . + * @param signURL - + * URL of resource for the service instance. + * @return Intrger service instance Id if was found in the database, zero + * otherwise + */ + + public static int getServInstId(String servName, String signURL) { + + int servInsId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select service_instance_id from service_instance where servicename = ? && signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setString(2, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + servInsId = rs.getInt(1); + + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return servInsId; + } + + /** + * get the set of services for the given URL of resource by signatureURL + * + * @param signURL - + * the URL of resource . + * @return String set of the services which was found in the database, empty + * string otherwise + */ + + public static String getServListByURL(String signURL) { + + StringBuffer servList = new StringBuffer(); + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select servicename from service_instance where signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + String servName = rs.getString(1); + servList.append(servName + ","); + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return servList.toString(); + } + + /** + * delete a record from given table by a service instance Id (the metod is + * working for simple_input/output, collection input/output tables) + * + * @param servInstId - + * the service instance Id. + * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. + */ + + public static int delRow(String tableName, int servInstId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "delete from " + tableName + + " where service_instance_id = ?"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setInt(1, servInstId); + + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + return ret; + } + + /** + * delete a record from simple table by a service instance Id and + * collection_input_id (the metod is working for simple_input/output, + * collection input/output tables) + * + * @param servInstId - + * the service instance Id. + */ + + public static void delCollectionMember(String inout, int servInstId) { + + Connection con = DBConnector.getConnection(); + + final String sqlReq1; + //System.out.println("inout = "+inout); + if (inout.equals("input")) { + sqlReq1 = "select collection_input_id from collection_input where service_instance_id = ? "; + } else { + sqlReq1 = "select collection_output_id from collection_output where service_instance_id = ? "; + } + //System.out.println("sqlReq1 = "+sqlReq1); + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + while (rs.next()) { + int colId = rs.getInt(1); + //System.out.println("colId = "+colId); + final String sqlReq; + if (inout.equals("input")) { + sqlReq = "delete from simple_input where collection_input_id=" + + colId; + //System.out.println("sqlReq = "+sqlReq); + } else { + sqlReq = "delete from simple_output where collection_output_id=" + + colId; + } + PreparedStatement ps1 = null; + + try { + ps1 = con.prepareStatement(sqlReq); + // ps.setInt(1, servInstId); + ps1.executeUpdate(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } finally { + try { + if (ps1 != null) + ps1.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } + } + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + } + } + + } + + /** + * delete a record from service_instance table by a servicename and + * authority Id + * + * @param servName - + * the service instance name. + * @param authId - + * the id of the authority + * @return Intrger ret=1 if the record was deleted, ret=-1 otherwise. + */ + + public static int delSignature(String servName, int authId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + // if (authId == 0){ + final String sqlReq1 = "delete from service_instance where servicename= ? and authority_id = ?"; + PreparedStatement ps = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + ps.setInt(2, authId); + ret = ps.executeUpdate(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * get the collection Id from collection_input or collection_output table by + * the service_instance_id + * + * @param table - + * the collection_input or collection_output table + * @param field - + * "collection_input_id" (for collection_input table) and + * "collection_output_id" (for collection_output table) + * @param servInstId - + * Id of service instance + * @return Integer collection Id if was found, zero otherwise. + */ + + public static int getCollectionId(String table, String field, int servInstId) { + + int colId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select " + + field + + " from " + + table + + " where service_instance_id = ? order by service_instance_id," + + field + " ASC"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setInt(1, servInstId); + rs = ps.executeQuery(); + + while (rs.next()) { + colId = rs.getInt(1); + + } + + } catch (SQLException e) { + + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return colId; + + } + + /** + * add new record into the collection_input or collection_output table + * + * @param table - + * the collection_input or collection_output table + * @param artName - + * the artical name of the collection_input or collection_output + * @param servInstId - + * Id of service instance + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int insIntoCol(String table, String artName, int servInstId) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into " + table + + " (article_name,service_instance_id) values (?,?)"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, artName); + ps.setInt(2, servInstId); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * update record into the collection_input or collection_output table + * + * @param table - + * the collection_input or collection_output table + * @param key_field - + * collection_input_id for collection_input table, + * collection_output_id for collection_output table; + * @param artName - + * the artical name of the collection_input or collection_output + * @param servInstId - + * Id of service instance + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int updateCol(String table, String key_field, String artName, + int servInstId, int minNum) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "update " + table + + " set article_name=?,service_instance_id=? where " + + key_field + " =?"; + + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, artName); + ps.setInt(2, servInstId); + ps.setInt(3, minNum); + ret = ps.executeUpdate(); + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + return ret; + } + + /** + * get the service authority URI from authority table by the servicename + * + * @param servName - + * the name of service + * @return String authority URI if was found, empty string otherwise. + */ + + public static String getServAuthURI(String servName) { + + Connection con = DBConnector.getConnection(); + + String authURI = ""; + + final String sqlReq1 = "select authority_uri from service_instance si,authority a where si.authority_id=a.authority_id and si.servicename=?"; + ; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, servName); + rs = ps.executeQuery(); + + while (rs.next()) { + authURI = rs.getString(1); + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return authURI; + + } + + /** + * get the service authority Id from service_instance table by the + * servicename and signatureURL + * + * @param serviceName - + * the name of service + * @param signURL - + * the signatureURL for the given service + * @return int authority Id if was found, zero otherwise. + */ + + public static int getAuthIdByServNameAndSignURL(String serviceName, + String signURL) { + + int authId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select authority_id from service_instance where servicename = ? and signatureURL = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, serviceName); + ps.setString(2, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + authId = rs.getInt(1); + + } + + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return authId; + } + + /** + * add new record to the authority table + * + * @param authURI - + * the authority URI + * @param email - + * the contact e-Mail + * @return Intrger ret=1 if the record was added, ret=-1 otherwise + */ + + public static int insIntoAuthority(String authURI, String email) { + + Connection con = DBConnector.getConnection(); + + int ret = -1; + + final String sqlReq1 = "insert into authority (authority_common_name,authority_uri,contact_email) values (null,?,?)"; + PreparedStatement ps = null; + + try { + ps = con.prepareStatement(sqlReq1); + + ps.setString(1, authURI); + ps.setString(2, email); + ret = ps.executeUpdate(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } finally { + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + } + + return ret; + } + + /** + * get the service authority Id from authority table by the authority URI + * + * @param authURI - + * the authority URI + * @return int authority Id if was found, zero otherwise. + */ + + public static int getAuthIdByAuthURI(String authURI) { + + int authId = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select authority_id from authority where authority_uri = ?"; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, authURI); + + rs = ps.executeQuery(); + + while (rs.next()) { + authId = rs.getInt(1); + } + + } catch (SQLException e) { + // e.getMessage(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + + return authId; + + } + + /** + * get the contact e-Mail from service_instance table by the servicename + * + * @param signURL - + * the URL of a resource + * @return String contact e-Mail if was found, empty string otherwise. + */ + + public static String getContactEmail(String signURL) { + + String email = ""; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select contact_email from service_instance where signatureURL = ? "; + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + ps.setString(1, signURL); + rs = ps.executeQuery(); + + while (rs.next()) { + String cnt = rs.getString(1); + email = cnt; + + } + + } catch (SQLException e) { + + // e.printStackTrace(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + + } + //System.out.println("email = "+email); + return email; + + } + + /** + * + * gets the min number of records with service instance id = 0 + * + * @param table + * @param key_field + * @return the number of records + */ + + public static int getMinFreeNumber(String table, String key_field) { + + int num = 0; + + Connection con = DBConnector.getConnection(); + + final String sqlReq1 = "select min(" + key_field + ") from " + table + + " where service_instance_id = 0 order by " + key_field; + + PreparedStatement ps = null; + ResultSet rs = null; + try { + ps = con.prepareStatement(sqlReq1); + rs = ps.executeQuery(); + + while (rs.next()) { + num = rs.getInt(1); + } + + } catch (SQLException e) { + + // e.printStackTrace(); + Log.severe(e.getMessage()); + } finally { + try { + if (rs != null) + rs.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } + try { + if (ps != null) + ps.close(); + } catch (SQLException e) { + Log.severe(e.getMessage()); + // e.getMessage(); + } - } + } - return num; + return num; - } + } }