[MOBY-guts] biomoby commit

Ambrose Ng ambrose at pub.open-bio.org
Fri May 28 20:54:08 UTC 2004


ambrose
Fri May 28 16:54:08 EDT 2004
Update of /home/repository/moby/moby-live/Perl/Accessories
In directory pub.open-bio.org:/tmp/cvs-serv13964

Modified Files:
	NamespaceMaintenance.cgi 
Log Message:
fixed mysql duplicate entry problem caused by updating form field error

moby-live/Perl/Accessories NamespaceMaintenance.cgi,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Perl/Accessories/NamespaceMaintenance.cgi,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Perl/Accessories/NamespaceMaintenance.cgi	2004/04/29 18:03:52	1.2
+++ /home/repository/moby/moby-live/Perl/Accessories/NamespaceMaintenance.cgi	2004/05/28 20:54:08	1.3
@@ -6,18 +6,31 @@
 my $namespace_id;
 my $authabvr;
 my $namespacetype;
-    if (param('ns')) { #ns param specified; user intends to load from database so open database and load up parameters
-        my @ns = split (/\_/,param('ns'));
-        param('authabvr'=>$ns[0]);
-        param('namespacetype'=>$ns[1]);
-        $authabvr=$ns[0];
-        $namespacetype=$ns[1];
-        my $retrieve = 'urn:lsid:biomoby.org:namespacetype:'.param('ns');
-        my $dbh1 = open_dbi();
-        my $sth1 = $dbh1->prepare(qq{SELECT * FROM namespace WHERE namespace_lsid = ?});
-        $sth1->execute($retrieve);
+    if (param('ns') or param('id')) { #ns or id param specified; user intends to load from database so open database and load up parameters
+        my $sth1;
+        if (param('ns')) {
+            my @ns = split (/\_/,param('ns'));
+            param('authabvr'=>$ns[0]);
+            param('namespacetype'=>$ns[1]);
+            $authabvr=$ns[0];
+            $namespacetype=$ns[1];
+            my $retrieve = 'urn:lsid:biomoby.org:namespacetype:'.param('ns');
+            my $dbh1 = open_dbi();
+            $sth1 = $dbh1->prepare(qq{SELECT * FROM namespace WHERE namespace_lsid = ?});
+            $sth1->execute($retrieve);
+        }
+        else {
+            my $retrieve = param('id');
+            my $dbh1 = open_dbi();
+            $sth1 = $dbh1->prepare(qq{SELECT * FROM namespace WHERE namespace_id = ?});
+            $sth1->execute($retrieve);
+        }
         my ($id, $namespace_lsid,  $namespace_type, $desc, $auth, $contactemail, $object,  $generic_url,  $synonym,  $urlsyntax,  $urlexample,  $shorthandname, $example_id, $note) = $sth1->fetchrow_array();
         $namespace_id = $id;
+        my @split = split(/\:/, $namespace_lsid);
+        ($authabvr, $namespacetype) = split(/\_/,$split[4]);
+        param('authabvr'=>$authabvr);
+        param('namespacetype'=>$namespacetype);
         param('desc'=>$desc);
         param('auth'=>$auth);
         param('object'=>$object);
@@ -58,20 +71,22 @@
         param('shorthand_name'=>$shorthandname);
         param('example_id'=>$example_id);
         param('note'=>$note);
+        param('continue'=>1);
+        param('nsid'=>$id);
     }
 
     print header,
-        start_html(-title => 'Namespace Form', -style => {-src => 'http://mobycentral.cbr.nrc.ca/stylesheets/ambrose.css'}),
-        
-        h1('Namespace Form');
+        start_html(-title => 'Namespace Update Form', -style => {-src => 'http://mobycentral.cbr.nrc.ca/stylesheets/ambrose.css'}, -class => "update"),
+        h1('Namespace Update Form');
+        print "Database search page is located here: ",a({href=>'http://mobycentral.cbr.nrc.ca/cgi-bin/search.cgi'}, "Search Page"),p,; 
         if (!$namespace_id) {
             print
-        "* = required fields",p,
+        "* = required fields (highlighted)",p,
         " --------",p,
         "Full abbreviation will be \"authority abbreviation_identifier abbreviation\" e.g. \"GeneDB_Tbrucei\"",
         start_form,
         table(
-        Tr(td("authority abbreviation* "),td(textfield(-name => 'authabvr', -class => "require"),"e.g.: GeneDB")),
+        Tr(td("authority abbreviation* "),td(textfield(-name => 'authabvr', -class => "require"),"e.g.: GeneDB"),(hidden('continue')),(hidden('nsid'))),
         Tr(td("identifier abbreviation* "),td(textfield(-name =>'namespacetype', -class => "require"),"e.g.: Tbrucei")),
         Tr(td"--------"),
         Tr(td("description* "),td(textarea(-name => 'desc', -class => "require"),"Type a short description here about the entry.")),
@@ -105,11 +120,11 @@
         else {
             param('namespace_id'=>$namespace_id);
             print
-        "* = required fields",p,
+        "* = required fields (highlighted)",p,
         " --------",p,
         start_form,
         table(
-        Tr(td("authority abbreviation: "),td($authabvr),(hidden('authabvr')),(hidden('namespace_id'))),
+        Tr(td("authority abbreviation: "),td($authabvr),(hidden('authabvr')),(hidden('namespace_id')),(hidden('continue')),(hidden('nsid'))),
         Tr(td("identifier abbreviation: "),td($namespacetype),(hidden('namespacetype'))),
         Tr(td"--------"),
         Tr(td("description* "),td(textarea(-name =>'desc', -class => "require"),"Type a short description here about the entry.")),
@@ -135,7 +150,7 @@
         Tr(td("url_example "),td(textfield('url_iec'),"e.g.: http\:\/\/www.genedb.org\/genedb\/Search\?organism=tryp&name=Tb927.1.5250")),
         Tr(td("shorthand_names "),td(textarea('shorthand_name'),"e.g.: Tbrucei. one entry per line")),
         Tr(td("note "),td(textarea('note'))),
-    Tr(td(submit)),
+    Tr(td(submit -name => 'submit values', -class => 'submit')),
     Tr(td(reset)),
     end_form,),p,
         $namespace_id,p,
@@ -168,31 +183,29 @@
         if (param('note')) {$Param{note}=param('note');}
         if (param('syn')) {$Param{syn} = param('syn');}
         
-if (param() and !param('ns')) {
-        my $error = chkerrors(%Param);
-        my %variables;
-        if ($error == 0){
-            %variables = setvariables(%Param);
-
-        
+if (param() and !param('ns') and !param('id')) {
+    my $error = chkerrors(%Param);
+    my %variables;
+    if ($error == 0){
+        %variables = setvariables(%Param);
         my $dbh = open_dbi();
-        my $sth;
- 
-        if (!param('namespace_id')) {
+        my $sth; 
+        if (!param('namespace_id') and param('continue') != 1) {
             adddata ($dbh, $sth, %variables);
         }
         else {
-            my $nsid = (param('namespace_id'));
+            my $nsid;
+            if (param('namespace_id')) {
+            $nsid = (param('namespace_id')); }
+            elsif (param('nsid')) { $nsid= param('nsid'); }
             updatedata ($dbh, $sth, $nsid, %variables);
         }
         $variables{authabvr} = param('authabvr');
         finalprinttoscreen (%variables);
-        param('namespace_id')=>undef;
-        }
+    }
+    #elsif ($error == 1) { print hidden('continue'=>1); }
 }
 
-elsif (param('ns')){ param('ns')=>undef;
-                    }
 #########
 
 
@@ -267,11 +280,7 @@
         print "invalid url_synonym header",hr;
         return 1;
     }
-    #elsif ($Param{example_id} =~ /\W/)  {
-     #   print "invalid characters in example_id",hr;
-      #  return 1;
-    #}
-    
+   
     else { return 0; }
 }
 sub setvariables {
@@ -358,7 +367,7 @@
         }
 sub finalprinttoscreen { #final printing to screen after updating database
     my (%variables) = @_;
-            print pre(
+            print pre(p,"successful!",p
         "namespace_type = ",$variables{namespacetype},p,
         "lsid = ",$variables{lsid},p,
         "description = ",$variables{desc},p,




More information about the MOBY-guts mailing list