[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Fri Jul 9 00:21:53 UTC 2004


mwilkinson
Thu Jul  8 20:21:53 EDT 2004
Update of /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby
In directory pub.open-bio.org:/tmp/cvs-serv5633/MOBY/Adaptor/moby

Modified Files:
	queryapi.pm 
Log Message:
more refactoring of code to get SQL out of mobycentral.  Also created two new subroutines for Martin and Ben to add their XSD-generating code such that the WSDL from MOBY Central will be valid

moby-live/Perl/MOBY/Adaptor/moby queryapi.pm,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm	2004/06/24 22:32:39	1.1
+++ /home/repository/moby/moby-live/Perl/MOBY/Adaptor/moby/queryapi.pm	2004/07/09 00:21:53	1.2
@@ -16,12 +16,7 @@
 				   dbname		=>  [undef,			'read/write'],
 				   port			=>  [undef,			'read/write'],
 				   proxy		=>	[undef,			'read/write'],
-				   sourcetype	=> 	["MOBY::Adaptor::moby::queryapi::mysql",			'read/write'],
-				   url			=>	[undef,			'read/write'],
-				   _implementation	=> [undef, 			'read/write'],  # this is the implementation of the API, e.g. mysql
-				   
-                   dbh		     =>  [undef,         'read/write'],  # once all the calls are converttd remove this!  It should not be accessible from outside!!!
-                   
+				   url			=>	[undef,			'read/write'],                   
                     );
 
    #_____________________________________________________________
@@ -41,10 +36,56 @@
     }
 
     # List of names of all specified object attributes
-    sub _standard_keys {
+    sub _standard_keys_a {
 	keys %_attr_data;
     }
 
+	sub username {
+		my ($self, $arg) = @_;
+		$self->{username} = $arg if defined $arg;
+		return $self->{username};
+	}
+	sub password {
+		my ($self, $arg) = @_;
+		$self->{password} = $arg if defined $arg;
+		return $self->{password};
+	}
+	sub dbname {
+		my ($self, $arg) = @_;
+		$self->{dbname} = $arg if defined $arg;
+		return $self->{dbname};
+	}
+	sub port {
+		my ($self, $arg) = @_;
+		$self->{port} = $arg if defined $arg;
+		return $self->{port};
+	}
+	sub proxy {
+		my ($self, $arg) = @_;
+		$self->{proxy} = $arg if defined $arg;
+		return $self->{proxy};
+	}
+	sub sourcetype {
+		my ($self, $arg) = @_;
+		$self->{sourcetype} = $arg if defined $arg;
+		return $self->{sourcetype};
+	}
+	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'};
+	}
+	sub dbh {
+		my ($self, $arg) = @_;
+		$self->{dbh} = $arg if defined $arg;
+		return $self->{dbh};
+	}
+	
 }
 
 sub new {
@@ -54,7 +95,7 @@
 
     my $self = bless {}, $class;
 
-    foreach my $attrname ( $self->_standard_keys ) {
+    foreach my $attrname ( $self->_standard_keys_a ) {
     	if (exists $args{$attrname} && defined $args{$attrname}) {
 		$self->{$attrname} = $args{$attrname} }
     elsif ($caller_is_obj) {
@@ -62,95 +103,88 @@
     else {
 		$self->{$attrname} = $self->_default_for($attrname) }
     }
-
-    my $source = $self->sourcetype;
-    my $datasource = $source->new(adaptor => $self);
-	unless ($datasource) {
-		print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n";
-		return undef;
-	}
-	$self->_implementation($datasource);
-	
-	# the lines below should be removed, since this should be pushed down into the implementation
-	##############################################################
-	unless ($datasource->dbh) {
-		print STDERR "Couldn't connect to the datasource \n",($self->_dump()),"\n\n";
-		return undef;
-	}
-	
-    $self->dbh($datasource->dbh);
-	#############################################################
-
     return $self;
     
 }
 
 sub insert_collection_input {
-	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;
-	}
+	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 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, ($args{service_instance}, $args{article_name}));
-		my $id=$self->dbh->{mysql_insertid};
-		return $id;
-	}
+	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_simple_input {
-	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;
+	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;
 }
 
 
 sub insert_simple_output {
-	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;
+	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;
 
 }
 
+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 _dump {
 	my ($self) = @_;
@@ -160,37 +194,37 @@
 }
 
 sub DESTROY {}
-
-sub AUTOLOAD {
-    no strict "refs";
-    my ($self, $newval) = @_;
-
-    $AUTOLOAD =~ /.*::(\w+)/;
-
-    my $attr=$1;
-    if ($self->_accessible($attr,'write')) {
-
-	*{$AUTOLOAD} = sub {
-	    if (defined $_[1]) { $_[0]->{$attr} = $_[1] }
-	    return $_[0]->{$attr};
-	};    ### end of created subroutine
-
-###  this is called first time only
-	if (defined $newval) {
-	    $self->{$attr} = $newval
-	}
-	return $self->{$attr};
-
-    } elsif ($self->_accessible($attr,'read')) {
-
-	*{$AUTOLOAD} = sub {
-	    return $_[0]->{$attr} }; ### end of created subroutine
-	return $self->{$attr}  }
-
-
-    # Must have been a mistake then...
-    croak "No such method: $AUTOLOAD";
-}
-
+#
+#sub AUTOLOAD {
+#    no strict "refs";
+#    my ($self, $newval) = @_;
+#
+#    $AUTOLOAD =~ /.*::(\w+)/;
+#
+#    my $attr=$1;
+#    if ($self->_accessible($attr,'write')) {
+#
+#	*{$AUTOLOAD} = sub {
+#	    if (defined $_[1]) { $_[0]->{$attr} = $_[1] }
+#	    return $_[0]->{$attr};
+#	};    ### end of created subroutine
+#
+####  this is called first time only
+#	if (defined $newval) {
+#	    $self->{$attr} = $newval
+#	}
+#	return $self->{$attr};
+#
+#    } elsif ($self->_accessible($attr,'read')) {
+#
+#	*{$AUTOLOAD} = sub {
+#	    return $_[0]->{$attr} }; ### end of created subroutine
+#	return $self->{$attr}  }
+#
+#
+#    # Must have been a mistake then...
+#    croak "No such method: $AUTOLOAD";
+#}
+#
 
 1;




More information about the MOBY-guts mailing list