use of ubic.gemma.core.annotation.reference.BibliographicReferenceService in project Gemma by PavlidisLab.
the class BibRefUpdaterCli method doWork.
@Override
protected Exception doWork(String[] args) {
Exception ex = super.processCommandLine(args);
if (ex != null)
return ex;
BibliographicReferenceService bibliographicReferenceService = this.getBean(BibliographicReferenceService.class);
Collection<Long> bibrefIds = new ArrayList<>();
if (this.hasOption("pmids")) {
for (String s : StringUtils.split(this.getOptionValue("pmids"), ",")) {
BibliographicReference found = bibliographicReferenceService.findByExternalId(s);
if (found == null) {
log.warn("Did not find " + s);
continue;
}
bibrefIds.add(found.getId());
}
} else {
log.info("Updating all bibrefs in the system ...");
bibrefIds = bibliographicReferenceService.listAll();
}
log.info("There are " + bibrefIds.size() + " to update");
for (Long id : bibrefIds) {
BibliographicReference bibref = bibliographicReferenceService.load(id);
if (bibref == null) {
log.info("No reference with id=" + id);
continue;
}
bibref = bibliographicReferenceService.thaw(bibref);
try {
BibliographicReference updated = bibliographicReferenceService.refresh(bibref.getPubAccession().getAccession());
log.info(updated);
} catch (Exception e) {
log.info("Failed to update: " + bibref + " (" + e.getMessage() + ")");
}
try {
Thread.sleep(RandomUtils.nextInt(1000));
} catch (InterruptedException e) {
return e;
}
}
return null;
}
Aggregations