Search in sources :

Example 1 with SampleImporter

use of gov.nih.nci.ctd2.dashboard.importer.internal.SampleImporter in project nci-ctd2-dashboard by CBIIT.

the class DashboardAdminMain method main.

@Transactional
public static void main(String[] args) {
    final CommandLineParser parser = new GnuParser();
    Options gnuOptions = new Options();
    gnuOptions.addOption("h", "help", false, "shows this help document and quits.").addOption("am", "animal-model-data", false, "imports animal model data.").addOption("cl", "cell-line-data", false, "imports cell line data.").addOption("cp", "compound-data", false, "imports compound data.").addOption("e", "eco-term", false, "import ECO terms.").addOption("g", "gene-data", false, "imports gene data.").addOption("p", "protein-data", false, "imports protein data.").addOption("r", "rank-subjects", false, "prioritize and rank the subjects according to the observation data.").addOption("sh", "shrna-data", false, "imports shrna data.").addOption("si", "sirna-data", false, "imports sirna data.").addOption("ts", "tissue-sample-data", false, "imports tissue sample data.").addOption("cv", "controlled-vocabulary", false, "imports the dashboard controlled vocabulary.").addOption("o", "observation-data", false, "imports dashboard observation data.").addOption("s", "sample-data", false, "imports sample data.").addOption("t", "taxonomy-data", false, "imports organism data.").addOption("i", "index", false, "creates lucene index.");
    // Here goes the parsing attempt
    try {
        CommandLine commandLine = parser.parse(gnuOptions, args);
        if (commandLine.getOptions().length == 0) {
            // Here goes help message about running admin
            throw new ParseException("Nothing to do!");
        }
        if (commandLine.hasOption("h")) {
            printHelpAndExit(gnuOptions, 0);
        }
        if (commandLine.hasOption("am")) {
            launchJob("animalModelImporterJob");
        }
        if (commandLine.hasOption("cl")) {
            launchJob("cellLineDataImporterJob");
        }
        if (commandLine.hasOption("cp")) {
            launchJob("compoundDataImporterJob");
        }
        if (commandLine.hasOption("g")) {
            launchJob("geneDataImporterJob");
        }
        if (commandLine.hasOption("p")) {
            launchJob("proteinDataImporterJob");
        }
        if (commandLine.hasOption("sh")) {
            launchJob("TRCshRNADataImporterJob");
        }
        if (commandLine.hasOption("si")) {
            launchJob("siRNADataImporterJob");
        }
        if (commandLine.hasOption("ts")) {
            launchJob("tissueSampleDataImporterJob");
        }
        if (commandLine.hasOption("cv")) {
            launchJob("controlledVocabularyImporterJob");
        }
        if (commandLine.hasOption("o")) {
            launchJob("observationDataImporterJob");
            String dataURL = (String) appContext.getBean("dataURL");
            APIDataBuilder b = (APIDataBuilder) appContext.getBean("apiDataBuilder");
            b.prepareData(dataURL);
        }
        if (commandLine.hasOption("s")) {
            log.info("Running sample importer...");
            // This is just for demonstration purposes
            SampleImporter sampleImporter = (SampleImporter) appContext.getBean("sampleImporter");
            sampleImporter.run();
        }
        if (commandLine.hasOption("t")) {
            launchJob("taxonomyDataImporterJob");
        }
        if (commandLine.hasOption("e")) {
            launchJob("ecotermDataImporterJob");
        }
        if (commandLine.hasOption("r")) {
            SubjectScorer subjectScorer = (SubjectScorer) appContext.getBean("subjectScorer");
            subjectScorer.scoreAllRoles();
            OverallSummary overallSummary = (OverallSummary) appContext.getBean("overallSummary");
            overallSummary.summarize();
        }
        if (commandLine.hasOption("i")) {
            DashboardDao dashboardDao = (DashboardDao) appContext.getBean("dashboardDao");
            dashboardDao.cleanIndex((Integer) appContext.getBean("indexBatchSize"));
        }
        log.info("All done.");
        System.exit(0);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        printHelpAndExit(gnuOptions, -1);
    }
}
Also used : Options(org.apache.commons.cli.Options) CommandLine(org.apache.commons.cli.CommandLine) SampleImporter(gov.nih.nci.ctd2.dashboard.importer.internal.SampleImporter) GnuParser(org.apache.commons.cli.GnuParser) APIDataBuilder(gov.nih.nci.ctd2.dashboard.util.APIDataBuilder) DashboardDao(gov.nih.nci.ctd2.dashboard.dao.DashboardDao) CommandLineParser(org.apache.commons.cli.CommandLineParser) ParseException(org.apache.commons.cli.ParseException) SubjectScorer(gov.nih.nci.ctd2.dashboard.util.SubjectScorer) OverallSummary(gov.nih.nci.ctd2.dashboard.util.OverallSummary) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

DashboardDao (gov.nih.nci.ctd2.dashboard.dao.DashboardDao)1 SampleImporter (gov.nih.nci.ctd2.dashboard.importer.internal.SampleImporter)1 APIDataBuilder (gov.nih.nci.ctd2.dashboard.util.APIDataBuilder)1 OverallSummary (gov.nih.nci.ctd2.dashboard.util.OverallSummary)1 SubjectScorer (gov.nih.nci.ctd2.dashboard.util.SubjectScorer)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 GnuParser (org.apache.commons.cli.GnuParser)1 Options (org.apache.commons.cli.Options)1 ParseException (org.apache.commons.cli.ParseException)1 Transactional (org.springframework.transaction.annotation.Transactional)1