[MOBY-guts] biomoby commit

Mark Wilkinson mwilkinson at pub.open-bio.org
Mon Jul 25 19:53:36 UTC 2005


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<Service authURI='$authURI' serviceName='$servicename' lsid='$lsid'>\n";
+		$output .= "\t<Service authURI='$authURI' serviceName='$servicename' lsid='$lsid'>\n";
 		$output .= "\t<serviceType>$service_type</serviceType>\n";
 		$output .= "\t<authoritative>$authoritative</authoritative>\n";
 		$output .= "\t<Category>$category</Category>\n";
@@ -3288,8 +3286,10 @@
 		$output .= "\t<signatureURL>$signatureURL</signatureURL>\n";
 		$output .= "\t<URL>$url</URL>\n";
 		$output .= "\t<Input>\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</Simple>\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<Collection articleName='$articlename'>\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</Input>\n";
 		$output .= "\t<Output>\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</Simple>\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<Collection articleName='$articlename'>\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</Output>\n";
 		$output .= "\t<secondaryArticles>\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;




More information about the MOBY-guts mailing list