public Object getObject() throws Exception { return new OntologyMapping(name, resource.getURL()); }
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { if (ontologiesSolrUrl == null) { throw new NullPointerException("ontologiesSolrUrl is null"); } HttpSolrServer ontologiesSolrServer = createSolrServer(); OntologyIndexer ontologyIndexer = new OntologyIndexer(ontologiesSolrServer); if (taxonomyOntologyMappings != null) { indexUniprotTaxonomy = true; } if (indexUniprotTaxonomy) { if (taxonomyOntologyMappings == null) { ontologyIndexer.indexUniprotTaxonomy(); } else { for (OntologyMapping om : taxonomyOntologyMappings) { ontologyIndexer.indexOntology(new UniprotTaxonomyOntologyIterator(om.getUrl())); } } } ontologyIndexer.indexObo(oboOntologyMappings.toArray(new OntologyMapping[oboOntologyMappings.size()])); long count = countDocs(ontologiesSolrServer); contribution.getExitStatus().addExitDescription("Total docs in index: "+count); ontologiesSolrServer.shutdown(); return RepeatStatus.FINISHED; }
private static void addOboOntologyToIndex( OntologyMapping mapping, OntologyIndexWriter writer ) throws OBOParseException, IOException { final long start = System.currentTimeMillis(); OboOntologyIterator iterator = new OboOntologyIterator( mapping.getName(), mapping.getUrl() ); if ( log.isDebugEnabled() ) log.debug( "Starting to index " + mapping.getName() + " (URL: "+ mapping.getUrl() +")"); int count = 0; while ( iterator.hasNext() ) { count++; if ( log.isTraceEnabled() && ( (count % 1000 ) == 0 ) ) { log.trace( "Processed " + count + " " + mapping.getName() + " terms" ); } final OntologyDocument ontologyDocument = iterator.next(); writer.addDocument( ontologyDocument ); } final long stop = System.currentTimeMillis(); if ( log.isDebugEnabled() ) log.debug( "Completed indexing of " + mapping.getName() + " in " + (stop - start) + "ms" ); } }