From: <rbr...@us...> - 2008-04-28 23:04:45
|
Revision: 1767 http://obo.svn.sourceforge.net/obo/?rev=1767&view=rev Author: rbruggne Date: 2008-04-28 16:03:45 -0700 (Mon, 28 Apr 2008) Log Message: ----------- Rest of the annotation importer init. Modified Paths: -------------- phenote/trunk/src/java/phenote/main/Phenote.java Added Paths: ----------- phenote/trunk/src/java/phenote/main/AnnotationImporterCLI.java Added: phenote/trunk/src/java/phenote/main/AnnotationImporterCLI.java =================================================================== --- phenote/trunk/src/java/phenote/main/AnnotationImporterCLI.java (rev 0) +++ phenote/trunk/src/java/phenote/main/AnnotationImporterCLI.java 2008-04-28 23:03:45 UTC (rev 1767) @@ -0,0 +1,83 @@ +package phenote.main; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.CommandLineParser; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Option; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.PosixParser; +import phenote.dataadapter.importer.AnnotationImporterGeneric; + + + + +public class AnnotationImporterCLI{ + + public static void main(String[] args){ + + Options options = new Options(); + + Option dbnameOption = new Option("d", "databaseName", true, "Specify the target database name (Required)."); + dbnameOption.setRequired(true); + options.addOption(dbnameOption); + + Option inputFileOption = new Option("i","input_file",true,"Specify the input file (Required)."); + inputFileOption.setRequired(true); + options.addOption(inputFileOption); + + Option configurationFileOption = new Option("c","configuration_file",true,"Specify the configuration file to be used (Required)"); + configurationFileOption.setRequired(true); + options.addOption(configurationFileOption); + + options.addOption("h","hostname", true, "Specify the target hostname.\nDefault: localhost."); + options.addOption("u","db_username",true,"Specify the target database username.\nDefault: Environmental username."); + options.addOption("p","password",true,"Specify the target database user password.\nDefault: NULL"); + options.addOption("P","port",true,"Specify the target database port.\nDefault: 5432."); + + CommandLineParser parser = new PosixParser(); + CommandLine cmd = null; + try { + cmd = parser.parse( options, args); + } catch (Exception e) { + System.out.println("Usage Error: " + e.getMessage()); + showUsage(options); + } + + try { + importAnnotation(cmd); + } catch (Exception e){ + System.out.println("Annotation Import Error: " + e.getMessage()); + e.printStackTrace(); + System.exit(-1); + } + + } + + private static void showUsage(Options options){ + HelpFormatter formatter = new HelpFormatter(); + formatter.printHelp( "AnnotationImporter", options ); + } + + + private static void importAnnotation(CommandLine cmd) throws Exception{ + + AnnotationImporterGeneric aig = new AnnotationImporterGeneric(); + aig.configureShard(getJDBCConnectionString(cmd), cmd.getOptionValue("u", null), cmd.getOptionValue("p", null)); + aig.importAnnotation(cmd.getOptionValue("c"),cmd.getOptionValue("i")); + System.out.println("DONE!"); + + } + + + private static String getJDBCConnectionString(CommandLine cmd){ + String jdbcPath = "jdbc:postgresql://"; + jdbcPath += cmd.getOptionValue("h","localhost"); + jdbcPath +=":"; + jdbcPath += cmd.getOptionValue("P","5432"); + jdbcPath += "/"; + jdbcPath += cmd.getOptionValue("d"); + return jdbcPath; + } + + +} \ No newline at end of file Modified: phenote/trunk/src/java/phenote/main/Phenote.java =================================================================== --- phenote/trunk/src/java/phenote/main/Phenote.java 2008-04-28 21:55:11 UTC (rev 1766) +++ phenote/trunk/src/java/phenote/main/Phenote.java 2008-04-28 23:03:45 UTC (rev 1767) @@ -190,16 +190,19 @@ public void initOntologies() { //set up new interface here. + String m = "Loading configuration: "+Config.inst().getConfigName(); logInfo(m); - + if (Config.inst().getTerminologyDefs()!=null) { //only do this if defined + try { OntologyDataAdapter2.getInstance().initOntologies(); } catch (Exception e) { e.printStackTrace(); } } else { //the old-school config style + setProgress(m, 10); setProgress(5); // 5?? from 10??? nicole? setProgress("Initializing Ontologies...", 20); @@ -216,6 +219,38 @@ //setMessageText("Ontologies Initialized"); } } + + public void simpleInitOntologies() { + //set up new interface here. + + String m = "Loading configuration: "+Config.inst().getConfigName(); + logInfo(m); + + if (Config.inst().getTerminologyDefs()!=null) { //only do this if defined + + try { + OntologyDataAdapter2.getInstance().initOntologies(false); + } catch (Exception e) { + e.printStackTrace(); + } + } else { //the old-school config style + + setProgress(m, 10); + setProgress(5); // 5?? from 10??? nicole? + setProgress("Initializing Ontologies...", 20); + setProgressMsg("Initializing Ontologies"); + setProgress(10); + LOG.debug("Initializing ontologies"); + //OntologyDataAdapter oda = new OntologyDataAdapter(); // singleton? + // loads up OntologyManager - non intuitive? + OntologyDataAdapter.initialize(); // this sometimes hangs!!! + LOG.debug("Ontologies initialized"); + // if (config.useShrimpDagViewer()) + // ShrimpDag.inst().initOntologies(); + setProgress("Ontologies Initialized", 70); + //setMessageText("Ontologies Initialized"); + } + } private void loadFromCommandLine() { //LOG.debug("read spec "+commandLine.readIsSpecified()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |