use of org.orcid.core.manager.LoadOptions in project ORCID-Source by ORCID.
the class ProfileEventManager method callOnceOnAll.
private void callOnceOnAll(final String classStr) throws InterruptedException {
ProfileEvent dummyPe = (ProfileEvent) context.getBean(classStr, (ProfileEvent) null);
long startTime = System.currentTimeMillis();
@SuppressWarnings("unchecked") List<String> orcids = Collections.EMPTY_LIST;
int doneCount = 0;
do {
orcids = getProfileDao().findByMissingEventTypes(CHUNK_SIZE, dummyPe.outcomes(), null, true);
Set<ProfileEvent> callables = new HashSet<ProfileEvent>();
for (final String orcid : orcids) {
LOG.info("Calling bean " + classStr + " for " + orcid);
// TODO: parameterize load options.
OrcidProfile orcidProfile = getOrcidProfileManager().retrieveOrcidProfile(orcid, new LoadOptions(true, false, true));
callables.add((ProfileEvent) context.getBean(classStr, orcidProfile));
doneCount++;
}
List<Future<ProfileEventResult>> futures = pool.invokeAll(callables);
for (Future<ProfileEventResult> future : futures) {
ProfileEventResult per = null;
try {
per = future.get();
} catch (ExecutionException e) {
LOG.error("failed calling task ", e);
}
getProfileEventDao().persist(new ProfileEventEntity(per.getOrcidId(), per.getOutcome()));
}
LOG.info("Current done count: {}", doneCount);
} while (!orcids.isEmpty());
long endTime = System.currentTimeMillis();
String timeTaken = DurationFormatUtils.formatDurationHMS(endTime - startTime);
LOG.info("Profile Event " + classStr + ": doneCount={}, timeTaken={} (H:m:s.S)", doneCount, timeTaken);
}
Aggregations