@Test public void getByQuery_DOIexists_WithPostvalidation_shouldReturnJSONFromTitleFirstAuthor() { final String myDOI = "myDOI"; final boolean postValidate = true; final String atitle = "atitle"; final String firstAuthor = "firstAuthor"; final String jsonOutput = "{\"DOI\":\"" + myDOI + "\",\"title\":[\"" + atitle + "12312312313\"],\"author\":[{\"given\":\"Alexander Yu\",\"family\":\"" + firstAuthor + "\",\"sequence\":\"first\",\"affiliation\":[]}]}"; final MatchingDocument response = new MatchingDocument(myDOI, jsonOutput); expect(mockMetadataLookup.retrieveByMetadata(myDOI)).andReturn(new MatchingDocument()); mockMetadataMatching.retrieveByMetadataAsync(eq(atitle), eq(firstAuthor), anyObject()); replay(mockMetadataLookup, mockedAsyncResponse, mockPmidsLookup, mockOALookup, mockIstexLookup, mockMetadataMatching); target.getByQuery(myDOI, null, null, null, null, firstAuthor, atitle, postValidate, null, null, null, null, null, mockedAsyncResponse); verify(mockMetadataLookup, mockedAsyncResponse, mockPmidsLookup, mockOALookup, mockIstexLookup, mockMetadataMatching); }
protected void getByQuery( String doi, String pmid, String pmc, String pii, String istexid, String firstAuthor, String atitle, final Boolean postValidate, String jtitle, String volume, String firstPage, String biblio, final Boolean parseReference, AsyncResponse asyncResponse ) { boolean areParametersEnoughToLookup = false; StringBuilder messagesSb = new StringBuilder(); if (isNotBlank(doi)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByDoi(doi, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { messagesSb.append(e.getMessage()); LOGGER.warn("DOI did not matched, move to additional metadata"); } } if (isNotBlank(pmid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmid(pmid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMID did not matched, move to additional metadata"); } } if (isNotBlank(pmc)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmc(pmc, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMC ID did not matched, move to additional metadata"); } } if (isNotBlank(pii)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPii(pii, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PII ID did not matched, move to additional metadata"); } } if (isNotBlank(istexid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByIstexid(istexid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("ISTEX ID did not matched, move to additional metadata"); } } if (isNotBlank(atitle) && isNotBlank(firstAuthor)) { LOGGER.debug("Match with metadata"); lookupEngine.retrieveByArticleMetadataAsync(atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { LOGGER.debug("Error with title/first author, trying to match with journal infos (no first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal title, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, MatchingDocumentBiblio -> { if (MatchingDocumentBiblio.isException()) { asyncResponse.resume(MatchingDocumentBiblio.getException()); } else { asyncResponse.resume(MatchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with journal infos (with first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal info, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(firstAuthor) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title and first page"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title without first author"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(biblio)) { LOGGER.debug("Match with biblio string"); lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } if (areParametersEnoughToLookup) { throw new ServiceException(404, messagesSb.toString()); } else { throw new ServiceException(400, "The supplied parameters were not sufficient to select the query"); } }
LookupController { protected void getByQuery( String doi, String pmid, String pmc, String pii, String istexid, String firstAuthor, String atitle, final Boolean postValidate, String jtitle, String volume, String firstPage, String biblio, final Boolean parseReference, AsyncResponse asyncResponse ) { boolean areParametersEnoughToLookup = false; StringBuilder messagesSb = new StringBuilder(); if (isNotBlank(doi)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByDoi(doi, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { messagesSb.append(e.getMessage()); LOGGER.warn("DOI did not matched, move to additional metadata"); } } if (isNotBlank(pmid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmid(pmid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMID did not matched, move to additional metadata"); } } if (isNotBlank(pmc)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmc(pmc, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMC ID did not matched, move to additional metadata"); } } if (isNotBlank(pii)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPii(pii, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PII ID did not matched, move to additional metadata"); } } if (isNotBlank(istexid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByIstexid(istexid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("ISTEX ID did not matched, move to additional metadata"); } } if (isNotBlank(atitle) && isNotBlank(firstAuthor)) { LOGGER.debug("Match with metadata"); lookupEngine.retrieveByArticleMetadataAsync(atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { LOGGER.debug("Error with title/first author, trying to match with journal infos (no first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal title, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, MatchingDocumentBiblio -> { if (MatchingDocumentBiblio.isException()) { asyncResponse.resume(MatchingDocumentBiblio.getException()); } else { asyncResponse.resume(MatchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with journal infos (with first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal info, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(firstAuthor) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title and first page"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title without first author"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(biblio)) { LOGGER.debug("Match with biblio string"); lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } if (areParametersEnoughToLookup) { throw new ServiceException(404, messagesSb.toString()); } else { throw new ServiceException(400, "The supplied parameters were not sufficient to select the query"); } } }
LookupController { protected void getByQuery( String doi, String pmid, String pmc, String pii, String istexid, String firstAuthor, String atitle, final Boolean postValidate, String jtitle, String volume, String firstPage, String biblio, final Boolean parseReference, AsyncResponse asyncResponse ) { boolean areParametersEnoughToLookup = false; StringBuilder messagesSb = new StringBuilder(); if (isNotBlank(doi)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByDoi(doi, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { messagesSb.append(e.getMessage()); LOGGER.warn("DOI did not matched, move to additional metadata"); } } if (isNotBlank(pmid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmid(pmid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMID did not matched, move to additional metadata"); } } if (isNotBlank(pmc)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmc(pmc, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMC ID did not matched, move to additional metadata"); } } if (isNotBlank(pii)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPii(pii, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PII ID did not matched, move to additional metadata"); } } if (isNotBlank(istexid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByIstexid(istexid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("ISTEX ID did not matched, move to additional metadata"); } } if (isNotBlank(atitle) && isNotBlank(firstAuthor)) { LOGGER.debug("Match with metadata"); lookupEngine.retrieveByArticleMetadataAsync(atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { LOGGER.debug("Error with title/first author, trying to match with journal infos (no first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal title, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, MatchingDocumentBiblio -> { if (MatchingDocumentBiblio.isException()) { asyncResponse.resume(MatchingDocumentBiblio.getException()); } else { asyncResponse.resume(MatchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with journal infos (with first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal info, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(firstAuthor) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title and first page"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title without first author"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(biblio)) { LOGGER.debug("Match with biblio string"); lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } if (areParametersEnoughToLookup) { throw new ServiceException(404, messagesSb.toString()); } else { throw new ServiceException(400, "The supplied parameters were not sufficient to select the query"); } } protected  LookupController(); @Inject  LookupController(LookupConfiguration configuration, StorageEnvFactory storageEnvFactory); }
LookupController { protected void getByQuery( String doi, String pmid, String pmc, String pii, String istexid, String firstAuthor, String atitle, final Boolean postValidate, String jtitle, String volume, String firstPage, String biblio, final Boolean parseReference, AsyncResponse asyncResponse ) { boolean areParametersEnoughToLookup = false; StringBuilder messagesSb = new StringBuilder(); if (isNotBlank(doi)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByDoi(doi, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { messagesSb.append(e.getMessage()); LOGGER.warn("DOI did not matched, move to additional metadata"); } } if (isNotBlank(pmid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmid(pmid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMID did not matched, move to additional metadata"); } } if (isNotBlank(pmc)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmc(pmc, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMC ID did not matched, move to additional metadata"); } } if (isNotBlank(pii)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPii(pii, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PII ID did not matched, move to additional metadata"); } } if (isNotBlank(istexid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByIstexid(istexid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("ISTEX ID did not matched, move to additional metadata"); } } if (isNotBlank(atitle) && isNotBlank(firstAuthor)) { LOGGER.debug("Match with metadata"); lookupEngine.retrieveByArticleMetadataAsync(atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { LOGGER.debug("Error with title/first author, trying to match with journal infos (no first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal title, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, MatchingDocumentBiblio -> { if (MatchingDocumentBiblio.isException()) { asyncResponse.resume(MatchingDocumentBiblio.getException()); } else { asyncResponse.resume(MatchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with journal infos (with first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal info, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(firstAuthor) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title and first page"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title without first author"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(biblio)) { LOGGER.debug("Match with biblio string"); lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } if (areParametersEnoughToLookup) { throw new ServiceException(404, messagesSb.toString()); } else { throw new ServiceException(400, "The supplied parameters were not sufficient to select the query"); } } protected  LookupController(); @Inject  LookupController(LookupConfiguration configuration, StorageEnvFactory storageEnvFactory); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/") void getByQueryAsync(
            @QueryParam("doi") String doi,
            @QueryParam("pmid") String pmid,
            @QueryParam("pmc") String pmc,
            @QueryParam("pii") String pii,
            @QueryParam("istexid") String istexid,
            @QueryParam("firstAuthor") String firstAuthor,
            @QueryParam("atitle") String atitle,
            @QueryParam("postValidate") Boolean postValidate,
            @QueryParam("jtitle") String jtitle,
            @QueryParam("volume") String volume,
            @QueryParam("firstPage") String firstPage,
            @QueryParam("biblio") String biblio,
            @QueryParam("parseReference") Boolean parseReference,
            @Suspended final AsyncResponse asyncResponse); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/doi/{doi}") String getByDoi(@PathParam("doi") String doi); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/pmid/{pmid}") String getByPmid(@PathParam("pmid") String pmid); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/pii/{pii}") String getByPii(@PathParam("pii") String pii); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/pmc/{pmc}") String getByPmc(@PathParam("pmc") String pmc); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/istexid/{istexid}") String getByIstexid(@PathParam("istexid") String istexid); @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.TEXT_PLAIN) @Path("/") void getByBiblioStringWithPost(String biblio, @Suspended final AsyncResponse asyncResponse); }
LookupController { protected void getByQuery( String doi, String pmid, String pmc, String pii, String istexid, String firstAuthor, String atitle, final Boolean postValidate, String jtitle, String volume, String firstPage, String biblio, final Boolean parseReference, AsyncResponse asyncResponse ) { boolean areParametersEnoughToLookup = false; StringBuilder messagesSb = new StringBuilder(); if (isNotBlank(doi)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByDoi(doi, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { messagesSb.append(e.getMessage()); LOGGER.warn("DOI did not matched, move to additional metadata"); } } if (isNotBlank(pmid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmid(pmid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMID did not matched, move to additional metadata"); } } if (isNotBlank(pmc)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPmc(pmc, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PMC ID did not matched, move to additional metadata"); } } if (isNotBlank(pii)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByPii(pii, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("PII ID did not matched, move to additional metadata"); } } if (isNotBlank(istexid)) { areParametersEnoughToLookup = true; try { final String response = lookupEngine.retrieveByIstexid(istexid, postValidate, firstAuthor, atitle); if (isNotBlank(response)) { asyncResponse.resume(response); return; } } catch (NotFoundException e) { LOGGER.warn("ISTEX ID did not matched, move to additional metadata"); } } if (isNotBlank(atitle) && isNotBlank(firstAuthor)) { LOGGER.debug("Match with metadata"); lookupEngine.retrieveByArticleMetadataAsync(atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { LOGGER.debug("Error with title/first author, trying to match with journal infos (no first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal title, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, MatchingDocumentBiblio -> { if (MatchingDocumentBiblio.isException()) { asyncResponse.resume(MatchingDocumentBiblio.getException()); } else { asyncResponse.resume(MatchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with journal infos (with first author)"); if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocumentJournal -> { if (matchingDocumentJournal.isException()) { LOGGER.debug("Error with journal info, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocumentJournal.getFinalJsonObject()); } }); return; } LOGGER.debug("Error with title/first author, trying to match with biblio string"); if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(firstAuthor) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title and first page"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(jtitle) && isNotBlank(volume) && isNotBlank(firstPage)) { LOGGER.debug("Match with journal title without first author"); lookupEngine.retrieveByJournalMetadataAsync(jtitle, volume, firstPage, atitle, firstAuthor, postValidate, matchingDocument -> { if (matchingDocument.isException()) { if (isNotBlank(biblio)) { lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } else { asyncResponse.resume(matchingDocument.getException()); } } else { asyncResponse.resume(matchingDocument.getFinalJsonObject()); } }); return; } if (isNotBlank(biblio)) { LOGGER.debug("Match with biblio string"); lookupEngine.retrieveByBiblioAsync(biblio, postValidate, firstAuthor, atitle, parseReference, matchingDocumentBiblio -> { if (matchingDocumentBiblio.isException()) { asyncResponse.resume(matchingDocumentBiblio.getException()); } else { asyncResponse.resume(matchingDocumentBiblio.getFinalJsonObject()); } }); return; } if (areParametersEnoughToLookup) { throw new ServiceException(404, messagesSb.toString()); } else { throw new ServiceException(400, "The supplied parameters were not sufficient to select the query"); } } protected  LookupController(); @Inject  LookupController(LookupConfiguration configuration, StorageEnvFactory storageEnvFactory); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/") void getByQueryAsync(
            @QueryParam("doi") String doi,
            @QueryParam("pmid") String pmid,
            @QueryParam("pmc") String pmc,
            @QueryParam("pii") String pii,
            @QueryParam("istexid") String istexid,
            @QueryParam("firstAuthor") String firstAuthor,
            @QueryParam("atitle") String atitle,
            @QueryParam("postValidate") Boolean postValidate,
            @QueryParam("jtitle") String jtitle,
            @QueryParam("volume") String volume,
            @QueryParam("firstPage") String firstPage,
            @QueryParam("biblio") String biblio,
            @QueryParam("parseReference") Boolean parseReference,
            @Suspended final AsyncResponse asyncResponse); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/doi/{doi}") String getByDoi(@PathParam("doi") String doi); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/pmid/{pmid}") String getByPmid(@PathParam("pmid") String pmid); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/pii/{pii}") String getByPii(@PathParam("pii") String pii); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/pmc/{pmc}") String getByPmc(@PathParam("pmc") String pmc); @GET @Produces(MediaType.APPLICATION_JSON) @Path("/istexid/{istexid}") String getByIstexid(@PathParam("istexid") String istexid); @POST @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.TEXT_PLAIN) @Path("/") void getByBiblioStringWithPost(String biblio, @Suspended final AsyncResponse asyncResponse);  }