[MOBY-guts] biomoby commit
Mark Wilkinson
mwilkinson at pub.open-bio.org
Mon Jul 25 23:45:29 UTC 2005
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 = "<serviceProviders>\n";
foreach my $prov (@$result) {
- $providers .= "<serviceProvider name='$prov->{authority_uri}'/>\n";
+ $providers .= "<serviceProvider name='".($prov->{authority_uri})."'/>\n";
}
$providers .= "</serviceProviders>\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<Service authURI='$authority_uri' serviceName='$servicename' lsid='$lsid'>\n";
$output .= "\t<serviceType>$service_type</serviceType>\n";
$output .= "\t<authoritative>$authoritative</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,
);
More information about the MOBY-guts
mailing list