From 025723e5e7b4b205f9af2a2a96a332c3c24fe890 Mon Sep 17 00:00:00 2001 From: Russ Poetker Date: Mon, 18 Mar 2024 14:07:08 -0400 Subject: [PATCH] Add nihmsId to logging --- .../pass/loader/nihms/NihmsCsvProcessor.java | 10 +++---- .../nihms/NihmsPublicationToSubmission.java | 27 +++++++++---------- .../nihms/NihmsTransformLoadService.java | 27 +++++++++---------- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsCsvProcessor.java b/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsCsvProcessor.java index 2fae0a9f3..ac0bdb960 100644 --- a/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsCsvProcessor.java +++ b/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsCsvProcessor.java @@ -163,15 +163,15 @@ private void consumeRow(CSVRecord row, Consumer pubConsumer) { row.get(TAGGINGCOMPLETE_COLNUM), row.get(FINALAPPROVAL_COLNUM), row.get(ARTICLETITLE_COLNUM)); - LOG.info("NIHMS record pmid={} is being processed", pub.getPmid()); + LOG.info("NIHMS record PMID={} and NIHMS ID={} is being processed", pub.getPmid(), pub.getRawNihmsId()); pubConsumer.accept(pub); - LOG.info("NIHMS record pmid={} was processed successfully", pub.getPmid()); + LOG.info("NIHMS record PMID={} and NIHMS ID={} was processed successfully", pub.getPmid(), + pub.getRawNihmsId()); } catch (Exception ex) { failCount = failCount + 1; LOG.error( - "A problem occurred while processing csv row {} with pmid {}. The record was not imported " + - "successfully.", - recCount + 1, pub.getPmid(), ex); + "A problem occurred while processing csv row {} with PMID {} and NIHMS ID {}. The record was not " + + "imported successfully.", recCount + 1, pub.getPmid(), pub.getRawNihmsId(), ex); } } diff --git a/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsPublicationToSubmission.java b/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsPublicationToSubmission.java index ee6f61ba0..29bf1678d 100644 --- a/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsPublicationToSubmission.java +++ b/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsPublicationToSubmission.java @@ -94,8 +94,8 @@ public SubmissionDTO transform(NihmsPublication pub) throws IOException { Grant grant = clientService.findMostRecentGrantByAwardNumber(pub.getGrantNumber()); if (grant == null) { throw new RuntimeException( - String.format("No Grant matching award number \"%s\" was found. Cannot process submission with pmid %s", - pub.getGrantNumber(), pub.getPmid())); + String.format("No Grant matching award number \"%s\" was found. Cannot process submission with " + + "PMID %s and NIHMS ID %s", pub.getGrantNumber(), pub.getPmid(), pub.getRawNihmsId())); } //this stage will be all about building up the DTO @@ -135,6 +135,8 @@ private Publication retrieveOrCreatePublication(NihmsPublication nihmsPub, Submi Deposit deposit = clientService.findNihmsDepositbyNihmsId(nihmsPub.getRawNihmsId()); if (deposit != null) { + LOG.info("Deposit found for PMID {} using NIHMS ID {} lookup.", nihmsPub.getPmid(), + nihmsPub.getRawNihmsId()); submissionDTO.setUpdateDeposoit(true); submissionDTO.setDeposit(deposit); @@ -198,8 +200,8 @@ private Publication retrieveOrCreatePublication(NihmsPublication nihmsPub, Submi * @return the Publication, never {@code null} */ private Publication initiateNewPublication(NihmsPublication nihmsPub, PubMedEntrezRecord pmr) throws IOException { - LOG.info("No existing publication found for PMID \"{}\", initiating new Publication record", - nihmsPub.getPmid()); + LOG.info("No existing publication found for PMID {} and NIHMS ID {}, initiating new Publication record", + nihmsPub.getPmid(), nihmsPub.getRawNihmsId()); Publication publication = new Publication(); publication.setPmid(nihmsPub.getPmid()); @@ -265,8 +267,8 @@ private RepositoryCopy retrieveOrCreateRepositoryCopy(NihmsPublication pub, Stri private RepositoryCopy initiateNewRepositoryCopy(NihmsPublication pub, String publicationId) throws IOException { RepositoryCopy repositoryCopy = new RepositoryCopy(); - LOG.info("NIHMS RepositoryCopy record needed for PMID \"{}\", initiating new RepositoryCopy record", - pub.getPmid()); + LOG.info("NIHMS RepositoryCopy record needed for PMID {} and NIHMS ID {}, initiating new RepositoryCopy record", + pub.getPmid(), pub.getRawNihmsId()); repositoryCopy.setPublication((clientService.readPublication(publicationId))); repositoryCopy.setCopyStatus(calcRepoCopyStatus(pub, null)); repositoryCopy.setRepository(clientService.readRepository(nihmsRepositoryId)); @@ -435,11 +437,9 @@ public static CopyStatus calcRepoCopyStatus(NihmsPublication pub, CopyStatus cur // probably bad data if (currCopyStatus != null && currCopyStatus.equals(CopyStatus.COMPLETE)) { LOG.warn( - "A NIHMS record for a publication with PMID {} is attempting to change the status of a COMPLETED " + - "Repository Copy. " - + "This may be due to two PMIDs being assigned to a single DOI, so the data should be checked. The " + - "status will not " - + "be changed.", pub.getPmid()); + "A NIHMS record for a publication with PMID {} and NIHMS ID {} is attempting to change the status " + + "of a COMPLETED Repository Copy. This may be due to two PMIDs being assigned to a single DOI, " + + "so the data should be checked. The status will not be changed.", pub.getPmid(), pub.getRawNihmsId()); return CopyStatus.COMPLETE; } @@ -460,9 +460,8 @@ public static CopyStatus calcRepoCopyStatus(NihmsPublication pub, CopyStatus cur || (currCopyStatus.equals(CopyStatus.IN_PROGRESS) && newStatus.equals(CopyStatus.ACCEPTED))) { LOG.warn( "The status of the RepositoryCopy in PASS was at a later stage than the current NIHMS status " + - "would imply. " - + "Rolled back from \"{}\" to \"{}\" for pmid {}", currCopyStatus.toString(), - (newStatus == null ? "(null)" : newStatus.toString()), pub.getPmid()); + "would imply. Rolled back from \"{}\" to \"{}\" for PMID {} and NIHMS ID {}", currCopyStatus, + (newStatus == null ? "(null)" : newStatus.toString()), pub.getPmid(), pub.getRawNihmsId()); } } diff --git a/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsTransformLoadService.java b/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsTransformLoadService.java index 454344e52..7111b70e1 100644 --- a/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsTransformLoadService.java +++ b/pass-nihms-loader/nihms-data-transform-load/src/main/java/org/eclipse/pass/loader/nihms/NihmsTransformLoadService.java @@ -83,7 +83,7 @@ public void transformAndLoadFiles(Set statusesToProcess) { try { transformAndLoadNihmsPub(pub); } catch (IOException e) { - LOG.error("Error transforming and loading NIHMS publication for NihmsId {}", pub.getNihmsId(), e); + LOG.error("Error transforming and loading NIHMS publication for NIHMS ID {}", pub.getRawNihmsId(), e); throw new RuntimeException(e); } }; @@ -111,9 +111,8 @@ void transformAndLoadNihmsPub(NihmsPublication pub) throws IOException { // if the record is compliant, let's check the cache to see if it has been processed previously if (pub.getNihmsStatus().equals(NihmsStatus.COMPLIANT) && completedPublicationsCache.contains(pub.getPmid(), pub.getGrantNumber())) { - LOG.info( - "Compliant NIHMS record with pmid {} and award number \"{}\" has been processed in a previous load", - pub.getPmid(), pub.getGrantNumber()); + LOG.info("Compliant NIHMS record with PMID {}, NIHMS ID {}, and award number {} has been processed " + + "in a previous load", pub.getPmid(), pub.getRawNihmsId(), pub.getGrantNumber()); return; } @@ -124,24 +123,24 @@ void transformAndLoadNihmsPub(NihmsPublication pub) throws IOException { if (transformedRecord.doUpdate()) { submissionLoader.load(transformedRecord); } else { - LOG.info("No update required for PMID {} with award number {}", pub.getPmid(), - pub.getGrantNumber()); + LOG.info("No update required for PMID {}, NIHMS ID {}, and award number {}", pub.getPmid(), + pub.getRawNihmsId(), pub.getGrantNumber()); } break; } catch (IllegalStateException | ConcurrentModificationException | IllegalArgumentException ex) { if (attempt < MAX_ATTEMPTS) { - LOG.warn("Update failed for PMID %s due to database conflict, attempting retry # %d", pub.getPmid(), - attempt); + LOG.warn("Update failed for PMID {} and NIHMS ID {} due to database conflict, " + + "attempting retry # {}", pub.getPmid(), pub.getRawNihmsId(), attempt); LOG.warn("Error message: {}", ex.getMessage()); } else { throw new RuntimeException( - String.format("Update could not be applied for PMID %s after %d attempts ", pub.getPmid(), - MAX_ATTEMPTS), ex); + String.format("Update could not be applied for PMID %s and NIHMS ID %s after %d attempts ", + pub.getPmid(), pub.getRawNihmsId(), MAX_ATTEMPTS), ex); } } catch (IOException e) { - LOG.error("Error transforming or loading record for PMID {} with award number {}", pub.getPmid(), - pub.getGrantNumber(), e); + LOG.error("Error transforming or loading record for PMID {} and NIHMS ID {} with award number {}", + pub.getPmid(), pub.getRawNihmsId(), pub.getGrantNumber(), e); throw new IOException(e); } } @@ -150,7 +149,7 @@ void transformAndLoadNihmsPub(NihmsPublication pub) throws IOException { && StringUtils.isNotEmpty(pub.getPmcId())) { //add to cache so it doesn't check it again once it has been processed and has a pmcid assigned completedPublicationsCache.add(pub.getPmid(), pub.getGrantNumber()); - LOG.debug("Added pmid {} and grant \"{}\" to cache", pub.getPmid(), pub.getGrantNumber()); + LOG.debug("Added PMID {} and grant \"{}\" to cache", pub.getPmid(), pub.getGrantNumber()); } } @@ -169,7 +168,7 @@ private List loadFiles(File downloadDirectory) { } if (CollectionUtils.isEmpty(filepaths)) { throw new RuntimeException( - String.format("No file found to process at path %s", downloadDirectory.toString())); + String.format("No file found to process at path %s", downloadDirectory)); } return filepaths; }