[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Wed Jun 16 01:15:30 UTC 2004
mwilkinson
Tue Jun 15 21:15:30 EDT 2004
Update of /home/repository/moby/moby-live/Perl/MOBY
In directory pub.open-bio.org:/tmp/cvs-serv16447/MOBY
Modified Files:
Central.pm service_instance.pm simple_input.pm
simple_output.pm
Added Files:
collection_input.pm collection_output.pm secondary_input.pm
Log Message:
all sorts of additions and changes. Secondary parameters now work for me on two systems, so that problem should now be solved. I am starting to rip out the SQL that is in MOBY Central into other modules, and it will eventually end up in a single mysql-specific module with an API to make it easier to code MOBY onto other data back-ends. Various bug fixes here and there as well.
moby-live/Perl/MOBY collection_input.pm,NONE,1.1 collection_output.pm,NONE,1.1 secondary_input.pm,NONE,1.1 Central.pm,1.129,1.130 service_instance.pm,1.3,1.4 simple_input.pm,1.2,1.3 simple_output.pm,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/Central.pm,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -r1.129 -r1.130
--- /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2004/06/15 01:00:26 1.129
+++ /home/repository/moby/moby-live/Perl/MOBY/Central.pm 2004/06/16 01:15:30 1.130
@@ -17,6 +17,11 @@
use MOBY::service_type;
use MOBY::authority;
use MOBY::service_instance;
+use MOBY::simple_input;
+use MOBY::simple_output;
+use MOBY::collection_input;
+use MOBY::collection_output;
+use MOBY::secondary_input;
use MOBY::central_db_connection;
use MOBY::Config;
@@ -1150,7 +1155,7 @@
return &_error("Service with this authority/servicename already exists","") if ($SVC == -1);
$debug && &_LOG("new service instance created\n");
-
+
foreach my $IN(@IN){
my ($success,$msg) = &_registerArticles($SVC, "input", $IN, undef);
return &_error("Registration Failed During INPUT Article Registration: $msg","") unless ($success==1);
@@ -1160,7 +1165,7 @@
return &_error("Registration Failed During OUTPUT Article Registration: $msg","") unless ($success==1);
}
foreach my $SEC(@SECS){
- my ($success,$msg) = &_registerArticles($SVC, "secondary", $SEC, undef);
+ my ($success,$msg) = &_registerArticles($SVC, "secondary", $SEC, undef);
return &_error("Registration Failed During SECONDARY Article Registration: $msg","") unless ($success==1);
}
@@ -1172,7 +1177,7 @@
my $dbh = $SVC->dbh;
return (-1,'Bad node') unless $node->getNodeType == ELEMENT_NODE;
- # this is a Simple or a Collection object
+ # this is a Simple, Collection, or Parameter object
my $simp_coll = $node->getTagName;
$debug && &_LOG("TAGNAME in $inout _registerArticle is $simp_coll");
@@ -1183,9 +1188,20 @@
my ($object_type, @namespaces);
if ($simp_coll eq "Collection"){
- $debug && &_LOG("Collection!\n"); # the following SQl belongs in the service_instance object, but screw it, I'm running out of time!
- $dbh->do("insert into collection_$inout (service_instance_id, article_name) values (?,?)", undef, ($SVC->service_instance_id, $article));
- my $collection_id=$dbh->{mysql_insertid};
+ $debug && &_LOG("Collection!\n");
+ my $collection_id;
+ if ($inout eq 'input'){
+ $collection_id = $SVC->add_collection_input(article_name => $article);
+ } elsif ($inout eq 'output') {
+ $collection_id = $SVC->add_collection_output(article_name => $article);
+ } else {
+ $SVC->DELETE_THYSELF; return (-1,"found article that was neither input nor output");
+ }
+
+ # the following SQl belongs in the service_instance object, but screw it, I'm running out of time!
+ #$dbh->do("insert into collection_$inout (service_instance_id, article_name) values (?,?)", undef, ($SVC->service_instance_id, $article));
+ #my $collection_id=$dbh->{mysql_insertid};
+
my $Simples = $node->getElementsByTagName('Simple');
my $length = $Simples->getLength;
for (my $x=0; $x<$length; ++$x){
@@ -1227,67 +1243,88 @@
chop($namespace_string); # remove trailing comma
my $dbh = $SVC->dbh;
my $service_instance_id;
- unless ($collid) {
+ unless ($collid) { # this SIMPLE is either alone, or is part of a COLLECTION ($collid > 0)
+ # therefore we want either its service instance ID, or its Collection ID.
$service_instance_id = $SVC->service_instance_id;
} # one or the other, but not both
- $dbh->do("insert into simple_".$inout."
- (object_type_uri,
- namespace_type_uris,
- article_name,
- service_instance_id,
- collection_".$inout."_id)
- values (?,?,?,?,?)",
- undef,
- ($typeURI,
- $namespace_string,
- $article,
- $service_instance_id,
- $collid));
-
+
+ if ($inout eq 'input'){
+ my $sinput = $SVC->add_simple_input(
+ object_type_uri => $typeURI,
+ namespace_type_uris => $namespace_string,
+ article_name => $article,
+ collection_input_id => $collid,
+ );
+ unless ($sinput){
+ $SVC->DELETE_THYSELF; return (-1,"registration failed during registration of input object $typeURI. Unknown reasons.");
+ }
+
+ } elsif ($inout eq 'output'){
+ my $soutput = $SVC->add_simple_output(
+ object_type_uri => $typeURI,
+ namespace_type_uris => $namespace_string,
+ article_name => $article,
+ collection_input_id => $collid,
+ );
+ unless ($soutput){
+ $SVC->DELETE_THYSELF; return (-1,"registration failed during registration of output object $typeURI. Unknown reasons.");
+ }
+ }
+
} elsif ($simp_coll eq "Parameter"){
- my $article = $node->getAttributeNode("articleName");
- $article = $article->getValue() if $article;
- my $types = $node->getElementsByTagName('datatype');
- my ($datatype, $def, $max, $min, @enums);
+ my $parameter = $node;
+ my $article = $parameter->getAttributeNode("articleName");
+ $article = $article->getValue() if $article;
+ my ($datatype, $def, $max, $min, @enums);
+ my $types = $parameter->getElementsByTagName('datatype');
if ($types->item(0)){
- foreach ($types->item(0)->getChildNodes){ # should only ever be one!
+ foreach ($types->item(0)->getChildNodes){ # should only ever be one!
($_->getNodeType == TEXT_NODE) && ($datatype = $_->toString);
- }
- }
- my $defs = $node->getElementsByTagName('default');
+ }
+ }
+ my $defs = $parameter->getElementsByTagName('default');
if ($defs->item(0)){
- foreach ($defs->item(0)->getChildNodes){ # should only ever be one!
- ($_->getNodeType == TEXT_NODE) && ($def = $_->toString);
- }
- }
- my $maxs = $node->getElementsByTagName('max');
+ foreach ($defs->item(0)->getChildNodes){ # should only ever be one!
+ ($_->getNodeType == TEXT_NODE) && ($def = $_->toString);
+ }
+ }
+ my $maxs = $parameter->getElementsByTagName('max');
if ($maxs->item(0)){
- foreach ($maxs->item(0)->getChildNodes){ # should only ever be one!
- ($_->getNodeType == TEXT_NODE) && ($max = $_->toString);
- }
- }
- my $mins = $node->getElementsByTagName('min');
+ foreach ($maxs->item(0)->getChildNodes){ # should only ever be one!
+ ($_->getNodeType == TEXT_NODE) && ($max = $_->toString);
+ }
+ }
+ my $mins = $parameter->getElementsByTagName('min');
if ($mins->item(0)){
- foreach ($mins->item(0)->getChildNodes){ # should only ever be one!
- ($_->getNodeType == TEXT_NODE) && ($min = $_->toString);
- }
- }
- my $enums = $node->getElementsByTagName('enum');
- my $numenums = $enums->getLength;
- for (my $n=0;$n<$numenums;++$n){
- foreach ($enums->item($n)->getChildNodes){ # should only ever be one!
- ($_->getNodeType == TEXT_NODE) && (push @enums, $_->toString);
- }
- }
- my $enum_string = join "",(map {$_.","} @enums);
- chop $enum_string; # get rid of trailing comma
- my $dbh = $SVC->dbh;
- $dbh->do(q{insert into secondary_input (default_value,maximum_value,minimum_value,enum_value,datatype,article_name,service_instance_id) values (?,?,?,?,?,?,?)},
- undef,
- ($def, $max, $min, $enum_string, $datatype, $article, $SVC->service_instance_id));
+ foreach ($mins->item(0)->getChildNodes){ # should only ever be one!
+ ($_->getNodeType == TEXT_NODE) && ($min = $_->toString);
+ }
+ }
+ my $enums = $parameter->getElementsByTagName('enum');
+ my $numenums = $enums->getLength;
+ for (my $n=0;$n<$numenums;++$n){
+ foreach ($enums->item($n)->getChildNodes){ # should only ever be one!
+ ($_->getNodeType == TEXT_NODE) && (push @enums, $_->toString);
+ }
+ }
+ my $enum_string = join "",(map {$_.","} @enums);
+ chop $enum_string; # get rid of trailing comma
+ my $sec = $SVC->add_secondary_input(
+ default_value => $def,
+ maximum_value => $max,
+ minimum_value => $min,
+ enum_value => $enum_string,
+ datatype => $datatype,
+ article_name => $article,
+ );
+ unless ($sec){
+ $SVC->DELETE_THYSELF; return (-1,"registration failed during registration of parameter $article. Must be of type Integer, String, DateTime, or Float.");
+ }
}
return 1;
}
+
+
sub _registerServicePayload {
my ($payload) = @_;
my $Parser = new XML::DOM::Parser;
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2003/12/02 00:23:23 1.3
+++ /home/repository/moby/moby-live/Perl/MOBY/service_instance.pm 2004/06/16 01:15:30 1.4
@@ -43,7 +43,7 @@
=head1 AUTHORS
-Mark Wilkinson (mwilkinson at gene.pbi.nrc.ca)
+Mark Wilkinson (mwilkinson at mrl.ubc.ca)
=cut
@@ -321,6 +321,94 @@
return $authority;
}
+sub add_simple_input {
+ my ($self, %a) = @_;
+
+# 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'}
+ );
+
+ push @{$self->{inputs}}, $simple;
+ return $simple->simple_input_id;
+}
+
+
+sub add_simple_output {
+ my ($self, %a) = @_;
+
+# 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_input_id => $a{'collection_output_id'}
+ );
+
+ push @{$self->{outputs}}, $simple;
+ return $simple->simple_output_id;
+}
+
+
+sub add_collection_input {
+ my ($self, %a) = @_;
+
+# validate here... one day...
+
+ my $coll = MOBY::collection_input->new(
+ article_name => $a{'article_name'},
+ service_instance_id => $self->service_instance_id,
+ );
+
+ push @{$self->{inputs}}, $coll;
+ return $coll->collection_input_id;
+}
+
+
+sub add_collection_output {
+ my ($self, %a) = @_;
+
+# validate here... one day...
+
+ my $coll = MOBY::collection_output->new(
+ article_name => $a{'article_name'},
+ service_instance_id => $self->service_instance_id,
+ );
+
+ push @{$self->{outputs}}, $coll;
+ return $coll->collection_output_id;
+}
+
+
+sub add_secondary_input {
+ my ($self, %a) = @_;
+
+# 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,
+ );
+
+ push @{$self->{inputs}}, $sec;
+ return $sec->secondary_input_id;
+
+}
+
+
+
sub AUTOLOAD {
no strict "refs";
my ($self, $newval) = @_;
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2003/12/28 20:41:59 1.2
+++ /home/repository/moby/moby-live/Perl/MOBY/simple_input.pm 2004/06/16 01:15:30 1.3
@@ -9,11 +9,13 @@
=head1 NAME
-MOBY::authority - a lightweight connection to the
+MOBY::simple_input - a lightweight connection to the
simple_input table in the database
=head1 SYNOPSIS
+NON FUNCTIONAL AT THIS TIME
+
use MOBY::simple_input;
my $Instance = MOBY::simple_input->new(
object_type => "Sequence",
@@ -28,7 +30,7 @@
=head1 DESCRIPTION
-representation of the authority table. Can write to the database
+representation of the simple_input table. Can write to the database
=head1 AUTHORS
@@ -46,11 +48,13 @@
#ATTRIBUTES
my %_attr_data = # DEFAULT ACCESSIBILITY
(
- object_type => [undef, 'read/write'],
- namespaces => [undef, 'read/write'],
- article_name => [undef, 'read/write'],
- simple_input_id => [undef, 'read/write'],
- service_instance_id => [undef, 'read/write'],
+ simple_input_id => [undef, 'read/write'],
+ object_type_uri => [undef, 'read/write'],
+ namespace_type_uris => [undef, 'read/write'],
+ article_name => [undef, 'read/write'],
+ service_instance_id => [undef, 'read/write'],
+ collection_input_id => [undef, 'read/write'],
+ dbh => [undef, 'read/write'],
);
#_____________________________________________________________
@@ -76,6 +80,17 @@
}
+
+sub _dbh {
+ my ($self) = @_;
+
+ my $central_connect = MOBY::central_db_connection->new();
+ $self->dbh($central_connect->dbh);
+ return $central_connect->dbh;
+
+}
+
+
sub new {
my ($caller, %args) = @_;
@@ -95,10 +110,33 @@
$self->{$attrname} = $self->_default_for($attrname) }
}
+ my $id = $self->WRITE;
+ $self->simple_input_id($id) if defined $id;
return $self;
}
+sub WRITE {
+ my ($self) = @_;
+ 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,
+ ($self->object_type_uri,
+ $self->namespace_type_uris,
+ $self->article_name,
+ $self->service_instance_id,
+ $self->collection_input_id));
+ my $id=$dbh->{mysql_insertid};
+ return $id;
+}
+
sub AUTOLOAD {
no strict "refs";
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2003/05/07 19:20:27 1.1
+++ /home/repository/moby/moby-live/Perl/MOBY/simple_output.pm 2004/06/16 01:15:30 1.2
@@ -14,6 +14,7 @@
=head1 SYNOPSIS
+NON FUNCTIONAL AT THIS TIME
use MOBY::simple_output;
my $Instance = MOBY::simple_output->new(
object_type => "Sequence",
@@ -28,7 +29,7 @@
=head1 DESCRIPTION
-representation of the authority table. Can write to the database
+representation of the simple_output table. Can write to the database
=head1 AUTHORS
@@ -46,11 +47,13 @@
#ATTRIBUTES
my %_attr_data = # DEFAULT ACCESSIBILITY
(
- object_type => [undef, 'read/write'],
- namespaces => [undef, 'read/write'],
- article_name => [undef, 'read/write'],
- simple_output_id => [undef, 'read/write'],
- service_instance_id => [undef, 'read/write'],
+ simple_output_id => [undef, 'read/write'],
+ object_type_uri => [undef, 'read/write'],
+ namespace_type_uris => [undef, 'read/write'],
+ article_name => [undef, 'read/write'],
+ service_instance_id => [undef, 'read/write'],
+ collection_output_id => [undef, 'read/write'],
+ dbh => [undef, 'read/write'],
);
#_____________________________________________________________
@@ -76,6 +79,18 @@
}
+
+
+sub _dbh {
+ my ($self) = @_;
+
+ my $central_connect = MOBY::central_db_connection->new();
+ $self->dbh($central_connect->dbh);
+ return $central_connect->dbh;
+
+}
+
+
sub new {
my ($caller, %args) = @_;
@@ -95,15 +110,31 @@
$self->{$attrname} = $self->_default_for($attrname) }
}
+ my $id = $self->WRITE;
+ $self->simple_output_id($id) if defined $id;
return $self;
}
-sub object_type
sub WRITE {
- my ($caller, $dbh) = @_;
- my $sth = $dbh->prepare("insert into simple_input (object_type_id, namespace_type_ids, article_name, service_instance_id) values (?,?,?,?)");
-
+ my ($self) = @_;
+ 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,
+ ($self->object_type_uri,
+ $self->namespace_type_uris,
+ $self->article_name,
+ $self->service_instance_id,
+ $self->collection_output_id));
+ my $id=$dbh->{mysql_insertid};
+ return $id;
+
}
sub AUTOLOAD {
More information about the MOBY-guts
mailing list