From: Scott C. <sco...@us...> - 2005-12-22 04:31:04
|
Update of /cvsroot/gmod/schema/chado/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8165/bin Modified Files: chado-build-schema.pl Log Message: UI can now handle translations to oracle, mysql, html, GD diagram and graphviz Index: chado-build-schema.pl =================================================================== RCS file: /cvsroot/gmod/schema/chado/bin/chado-build-schema.pl,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** chado-build-schema.pl 21 Dec 2005 22:20:19 -0000 1.9 --- chado-build-schema.pl 22 Dec 2005 04:30:54 -0000 1.10 *************** *** 56,59 **** --- 56,60 ---- } + my $translate_to; $mframe->Checkbutton(-text=>"SQL only", *************** *** 66,73 **** $mframe->Button(-text=>"Create Pg Schema", -command=>\&create_schema)->grid(-column=>3,-row=>$rows_of_stuff+2); ! $mframe->Button(-text=>"Create Oracle Schema", ! -command=>\&create_oracle_schema)->grid(-column=>4,-row=>$rows_of_stuff+2); ! $mframe->Button(-text=>"Create MySQL Schema", ! -command=>\&create_mysql_schema)->grid(-column=>5,-row=>$rows_of_stuff+2); --- 67,77 ---- $mframe->Button(-text=>"Create Pg Schema", -command=>\&create_schema)->grid(-column=>3,-row=>$rows_of_stuff+2); ! ! my @optionlist = ('Oracle','MySQL','Diagram','GraphViz','HTML'); ! $mframe->Label( -text=>"Translate to:")->grid(-column=>4,-row=>$rows_of_stuff+2); ! $mframe->Optionmenu (-options => \@optionlist, ! -variable => \$translate_to)->grid(-column=>5,-row=>$rows_of_stuff+2); ! $mframe->Button(-text=>"Translate Schema", ! -command=>\&translate_schema)->grid(-column=>6,-row=>$rows_of_stuff+2); *************** *** 212,216 **** } ! sub create_oracle_schema { $ONLY_SQL = 1; create_schema(); --- 216,220 ---- } ! sub translate_schema { $ONLY_SQL = 1; create_schema(); *************** *** 218,222 **** $mw->messageBox(-message=>"Please wait for the translation (it can take several minutes)"); ! my $ORACLE_FILE = $SCHEMA_FILE."_oracle"; my $translator = SQL::Translator->new( show_warnings => 1, --- 222,226 ---- $mw->messageBox(-message=>"Please wait for the translation (it can take several minutes)"); ! my $TRANS_FILE = $SCHEMA_FILE."_$translate_to"; my $translator = SQL::Translator->new( show_warnings => 1, *************** *** 225,270 **** my $output = $translator->translate( from => 'PostgreSQL', ! to => 'Oracle', filename => $SCHEMA_FILE, ) or warn $translator->error; ! my $fh = FileHandle->new(">$ORACLE_FILE"); ! if ($fh) { ! print $fh $output; ! $fh->close; ! $mw->messageBox(-message=>"Oracle schema created in file $ORACLE_FILE"); ! } else { ! $mw->messageBox(-message=>"cannot write to $ORACLE_FILE"); ! } ! } ! ! sub create_mysql_schema { ! $ONLY_SQL = 1; ! create_schema(); ! ! $mw->messageBox(-message=>"Please wait for the translation (it can take several minutes)"); ! ! my $MYSQL_FILE = $SCHEMA_FILE."_mysql"; ! my $translator = SQL::Translator->new( ! show_warnings => 1, ! ); ! ! my $output = $translator->translate( ! from => 'PostgreSQL', ! to => 'MySQL', ! filename => $SCHEMA_FILE, ! ) or warn $translator->error; ! ! my $fh = FileHandle->new(">$MYSQL_FILE"); if ($fh) { print $fh $output; $fh->close; ! $mw->messageBox(-message=>"MySQL schema created in file $MYSQL_FILE"); } else { ! $mw->messageBox(-message=>"cannot write to $MYSQL_FILE"); } } - sub read_source { my $mod = shift; --- 229,246 ---- my $output = $translator->translate( from => 'PostgreSQL', ! to => $translate_to, filename => $SCHEMA_FILE, ) or warn $translator->error; ! my $fh = FileHandle->new(">$TRANS_FILE"); if ($fh) { print $fh $output; $fh->close; ! $mw->messageBox(-message=>"$translate_to schema created in file $TRANS_FILE"); } else { ! $mw->messageBox(-message=>"cannot write to $TRANS_FILE"); } } sub read_source { my $mod = shift; |