Skip to content

Commit

Permalink
Merge 21dc59c into 99831f7
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed Aug 19, 2020
2 parents 99831f7 + 21dc59c commit f3e2e26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Expand Up @@ -36,6 +36,8 @@
import com.rockymadden.stringmetric.similarity.RatcliffObershelpMetric;
import scala.Option;

import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;

/**
* Singleton class for managing the extraction of bibliographical information from pdf documents.
* When consolidation operations are realized, be sure to call the close() method
Expand Down Expand Up @@ -200,7 +202,7 @@ public BiblioItem consolidate(BiblioItem bib, String rawCitation) throws Excepti
arguments = new HashMap<String,String>();
if ( (GrobidProperties.getInstance().getConsolidationService() != GrobidConsolidationService.CROSSREF) ||
(StringUtils.isBlank(rawCitation) && StringUtils.isBlank(doi)) )
arguments.put("query.title", title);
arguments.put("query.bibliographic", title);
}
if (StringUtils.isNotBlank(journalTitle)) {
// call based on partial metadata
Expand Down Expand Up @@ -262,11 +264,11 @@ public BiblioItem consolidate(BiblioItem bib, String rawCitation) throws Excepti
doiQuery = false;
}

client.<BiblioItem>pushRequest("works", arguments, workDeserializer, threadId, new CrossrefRequestListener<BiblioItem>(0) {
client.pushRequest("works", arguments, workDeserializer, threadId, new CrossrefRequestListener<BiblioItem>(0) {

@Override
public void onSuccess(List<BiblioItem> res) {
if ((res != null) && (res.size() > 0) ) {
if (isNotEmpty(res)) {
// we need here to post-check that the found item corresponds
// correctly to the one requested in order to avoid false positive
for(BiblioItem oneRes : res) {
Expand Down
Expand Up @@ -120,11 +120,11 @@ public <T extends Object> void pushRequest(CrossrefRequest<T> request, CrossrefR
request.addListener(listener);
synchronized(this) {
Future<?> f = executorService.submit(new CrossrefRequestTask<T>(this, request));
List<Future<?>> localFutures = this.futures.get(new Long(threadId));
List<Future<?>> localFutures = this.futures.get(threadId);
if (localFutures == null)
localFutures = new ArrayList<Future<?>>();
localFutures = new ArrayList<>();
localFutures.add(f);
this.futures.put(new Long(threadId), localFutures);
this.futures.put(threadId, localFutures);
//System.out.println("add request to thread " + threadId + " / current total for the thread: " + localFutures.size());
}
}
Expand Down Expand Up @@ -152,7 +152,7 @@ public <T extends Object> void pushRequest(String model, Map<String, String> par
public void finish(long threadId) {
synchronized(this.futures) {
try {
List<Future<?>> threadFutures = this.futures.get(new Long(threadId));
List<Future<?>> threadFutures = this.futures.get(threadId);
if (threadFutures != null) {
//System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< thread: " + threadId + " / waiting for " + threadFutures.size() + " requests to finish...");
for(Future<?> future : threadFutures) {
Expand Down

0 comments on commit f3e2e26

Please sign in to comment.