[pkg-bioc] svn commit r347 r347 - /branches/tools-ng/storage.pm

psychedelys-guest at users.alioth.debian.org psychedelys-guest at users.alioth.debian.org
Sat Oct 13 14:36:02 UTC 2007


Author: psychedelys-guest
Date: Sat Oct 13 14:36:02 2007
New Revision: 347

URL: http://svn.debian.org/wsvn/pkg-bioc/?sc=1&rev=347
Log:
updated the sql routine

Modified:
    branches/tools-ng/storage.pm

Modified: branches/tools-ng/storage.pm
URL: http://svn.debian.org/wsvn/pkg-bioc/branches/tools-ng/storage.pm?rev=347&op=diff
==============================================================================
--- branches/tools-ng/storage.pm (original)
+++ branches/tools-ng/storage.pm Sat Oct 13 14:36:02 2007
@@ -22,6 +22,11 @@ our @EXPORT = qw(
   insert_update_cannotbuild
   clean_cannotbuild_since_last_updated
   finish_store_source
+  prepare_store_description
+  get_package_id
+  get_package_repo
+  get_repo_name
+  finish_store_description
   close_storage
 );
 
@@ -164,24 +169,25 @@ sub init_storage($$$) {
 
 # updated during r_pkg_ordering.
 # parsing all the Descriptions file.
-# status:  'error'|'clean'|'unclean'
+# status:  'unknow'|'error'|'clean'|'unclean'
+#            unknown : just inserted the package, status is unknown
 #            error : something happen before which block the package from being buildable.
 #            clean : everything goes without problem, parsed dependencies,....
 #            unclean: something happen during the parsing, check the log to see what
 #
     $sql = qq{ CREATE TABLE IF NOT EXISTS packages (
 				  id INTEGER PRIMARY KEY NOT NULL,
-				  Author TEXT,
-				  Package TEXT,
-				  Date TEXT,
-				  Description TEXT,
-				  License TEXT, 
-				  Title TEXT,
+				  Author TEXT NOT NULL,
+				  Package TEXT NOT NULL,
+				  Date TEXT NOT NULL,
+				  Description TEXT NOT NULL,
+				  License TEXT NOT NULL, 
+				  Title TEXT NOT NULL,
 				  Imports TEXT,
-				  URL TEXT,
+				  URL TEXT NOT NULL,
 				  biocViews TEXT,
-				  isBinary BOOLEAN,
-				  status ENUM('error','clean','unclean'),
+				  isBinary BOOLEAN NOT NULL,
+				  status ENUM('unknown','error','clean','unclean'),
 				  FOREIGN KEY (id) REFERENCES packagesupdate(id)
 			) };
     $dbh->do($sql)
@@ -626,6 +632,94 @@ sub finish_store_source($) {
 
 }
 
+sub prepare_store_description($) {
+    my ($hash) = @_;
+    if ( !$dbh ) {
+        print "Cannot work, I am not connected\n";
+    }
+
+    $hash->{getid} =
+      $dbh->prepare(
+"SELECT packagesupdate.id from packagesupdate, packagesname where packagesupdate.packagesname_id = packagesname.id AND packagesname.name = ?"
+      );
+    $hash->{getrepoid} =
+      $dbh->prepare(
+"SELECT packagesupdate.repository_id from packagesupdate where packagesupdate.id = ?"
+      );
+    $hash->{getreponame} =
+      $dbh->prepare("SELECT name from repository where id = ?");
+
+}
+
+sub get_package_id($$) {
+    my ( $sth, $name ) = @_;
+    my $pkg_id = -1;
+    if ( !$dbh ) {
+        print "Cannot work, I am not connected\n";
+    }
+    $sth->{getid}->execute($name)
+      or die "Couldn't execute statement: " . $sth->{getid}->errstr;
+    my $l = $sth->{getid}->rows();
+    if ( $l == 0 ) {
+        print
+" ERROR, THIS SHOULD NEVER APPEND. I DO NO KNOW THE ID OF THIS PACKAGE";
+    }
+    else {
+        ($pkg_id) = @{ $sth->{getid}->fetchrow_arrayref() };
+    }
+    return $pkg_id;
+}
+
+sub get_package_repo($$) {
+    my ( $sth, $nameid ) = @_;
+    my $pkg_repoid = -1;
+    if ( !$dbh ) {
+        print "Cannot work, I am not connected\n";
+    }
+    $sth->{getrepoid}->execute($nameid)
+      or die "Couldn't execute statement: " . $sth->{getrepoid}->errstr;
+    my $l = $sth->{getrepoid}->rows();
+    if ( $l == 0 ) {
+        print
+" ERROR, THIS SHOULD NEVER APPEND. I DO NO KNOW THE REPO OF THIS PACKAGE";
+    }
+    else {
+        my ($pkg_repoid) = @{ $sth->{getrepoid}->fetchrow_arrayref() };
+    }
+    return $pkg_repoid;
+}
+
+sub get_repo_name($$) {
+    my ( $sth, $repoid ) = @_;
+    my $pkg_repo = "";
+    if ( !$dbh ) {
+        print "Cannot work, I am not connected\n";
+    }
+    $sth->{getreponame}->execute($repoid)
+      or die "Couldn't execute statement: " . $sth->{getreponame}->errstr;
+    my $l = $sth->{getreponame}->rows();
+    if ( $l == 0 ) {
+        print
+" ERROR, THIS SHOULD NEVER APPEND. I DO NO KNOW THE REPONAME OF THIS PACKAGE";
+    }
+    else {
+        my ($pkg_reponame) = @{ $sth->{getreponame}->fetchrow_arrayref() };
+    }
+    return $pkg_reponame;
+}
+
+sub finish_store_description($) {
+    my ($hash) = @_;
+    if ( !$dbh ) {
+        print "Cannot work, I am not connected\n";
+    }
+
+    $hash->{getid}->finish();
+    $hash->{getrepoid}->finish();
+    $hash->{getreponame}->finish();
+
+}
+
 sub clean_cannotbuild_since_last_updated($) {
     my ($name) = @_;
     if ( !$dbh ) {




More information about the pkg-bioc-devel mailing list