Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

Commit

Permalink
Improvements to grant matching, RepositoryCopy status control (#18)
Browse files Browse the repository at this point in the history
* To improve matching of awardNumber to NIHMS data, anything after a "-" is removed
* Ensure you can't switch a RepositoryCopy.copyStatus back from COMPLETE. This showed up when 2 pmids were assigned to the same DOI with one compliant and the non-compliant. It tried to switch the copyStatus to null. There is now a warning and a COMPLETE RepositoryCopy cannot be undone.
* Fix an error message that cites the record number instead of CSV row number
* Increment to version 1.2.3
  • Loading branch information
karenhanson authored Jun 19, 2018
1 parent 8c8fa84 commit a5f2729
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion entrez-pmid-lookup/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>entrez-pmid-lookup</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-data-harvest-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>
<artifactId>nihms-data-harvest-cli</artifactId>
<packaging>jar</packaging>
Expand Down
2 changes: 1 addition & 1 deletion nihms-data-harvest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>nihms-data-harvest</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-data-transform-load-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>
<artifactId>nihms-data-transform-load-cli</artifactId>
<name>NIHMS Data Transform/Load Command Line Interface</name>
Expand Down
2 changes: 1 addition & 1 deletion nihms-data-transform-load/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>
<artifactId>nihms-data-transform-load</artifactId>
<name>NIHMS Data Transform/Load</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private void consumeRow(CSVRecord row, Consumer<NihmsPublication> pubConsumer) {
}
catch (Exception ex) {
failCount = failCount + 1;
LOG.error("A problem occurred while processing csv row {} with pmid {}. The record was not imported successfully.", recCount, pub.getPmid(), ex);
LOG.error("A problem occurred while processing csv row {} with pmid {}. The record was not imported successfully.", recCount+1, pub.getPmid(), ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,13 @@ private RepositoryCopy retrieveOrCreateRepositoryCopy(NihmsPublication pub, URI
}
repoCopy.setExternalIds(externalIds);

//check if copystatus changed
//check if copystatus changed, but do not change from completed to something else, this indicates a data issue.
CopyStatus copyStatus = repoCopy.getCopyStatus();
CopyStatus newCopyStatus = calcRepoCopyStatus(pub, copyStatus);
if (!copyStatus.equals(newCopyStatus)) {

if (copyStatus==null || !copyStatus.equals(newCopyStatus)) {
repoCopy.setCopyStatus(newCopyStatus);
submissionDTO.setUpdateRepositoryCopy(true);
submissionDTO.setUpdateRepositoryCopy(true);
}
}
return repoCopy;
Expand Down Expand Up @@ -420,6 +421,13 @@ public static CopyStatus calcRepoCopyStatus(NihmsPublication pub, CopyStatus cur
if (pub.getNihmsStatus().equals(NihmsStatus.COMPLIANT)) {
return CopyStatus.COMPLETE;
}
//do not let the status go back from COMPLETE - once it is COMPLETE any attempt to change status back is 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());
return CopyStatus.COMPLETE;
}

CopyStatus newStatus = null;

Expand All @@ -435,7 +443,6 @@ public static CopyStatus calcRepoCopyStatus(NihmsPublication pub, CopyStatus cur
// NIHMS but log a warning
if (currCopyStatus!=null) {
if (newStatus==null
|| currCopyStatus.equals(CopyStatus.COMPLETE)
|| (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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public void testCalcCopyStatusAccepted() {
CopyStatus status = NihmsPublicationToSubmission.calcRepoCopyStatus(pub, null);
assertEquals(CopyStatus.ACCEPTED, status);

//status has gone out of alignment with PASS - PASS status is saying complete. This should roll back
//the status to accepted and log a warning.
//status has gone out of alignment with PASS - PASS status is saying complete. This should not roll back
//the status to accepted and it should log a warning that something is attempting to take status out of complete.
status = NihmsPublicationToSubmission.calcRepoCopyStatus(pub, CopyStatus.COMPLETE);
assertEquals(CopyStatus.ACCEPTED, status);
assertEquals(CopyStatus.COMPLETE, status);

//it was accepted, and is still accepted
status = NihmsPublicationToSubmission.calcRepoCopyStatus(pub, CopyStatus.ACCEPTED);
Expand All @@ -104,9 +104,9 @@ public void testCalcCopyStatusStalled() {
CopyStatus status = NihmsPublicationToSubmission.calcRepoCopyStatus(pub, null);
assertEquals(CopyStatus.STALLED, status);

//should be stalled even if was previously complete
//if previous status was complete, should be complete regardless
status = NihmsPublicationToSubmission.calcRepoCopyStatus(pub, CopyStatus.COMPLETE);
assertEquals(CopyStatus.STALLED, status);
assertEquals(CopyStatus.COMPLETE, status);
}


Expand All @@ -129,7 +129,7 @@ public void testCalcCopyStatusInProgress() {
//status has gone out of alignment with PASS - PASS is ahead sometime. This should roll back
//the status to received and log a warning.
status = NihmsPublicationToSubmission.calcRepoCopyStatus(pub, CopyStatus.COMPLETE);
assertEquals(CopyStatus.IN_PROGRESS, status);
assertEquals(CopyStatus.COMPLETE, status);

//this time, the submission has been tagged since it was accepted.
pub = newTestPub();
Expand Down
2 changes: 1 addition & 1 deletion nihms-etl-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>
<artifactId>nihms-etl-integration</artifactId>
<name>NIHMS ELT Integration Tests</name>
Expand Down
2 changes: 1 addition & 1 deletion nihms-etl-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>nihms-etl-model</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion nihms-etl-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>
<artifactId>nihms-etl-util</artifactId>
<name>NIHMS ETL Utilities</name>
Expand Down
2 changes: 1 addition & 1 deletion nihms-pass-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
</parent>

<artifactId>nihms-pass-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ public Grant findMostRecentGrantByAwardNumber(String awardNumber) {
if (!awardNumber.equals(modAwardNum)) {
grantIds.addAll(client.findAllByAttribute(Grant.class, AWARD_NUMBER_FLD, modAwardNum));
}

//if there is a "-##" at the end of the award number, remove it and search again
if (modAwardNum.contains("-") && modAwardNum.indexOf("-") > 9) {
modAwardNum = modAwardNum.substring(0, modAwardNum.indexOf("-"));
grantIds.addAll(client.findAllByAttribute(Grant.class, AWARD_NUMBER_FLD, modAwardNum));
}

List<Grant> grants = new ArrayList<Grant>();
for (URI id : grantIds) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.dataconservancy.pass</groupId>
<artifactId>pass-nihms-submission-etl</artifactId>
<version>1.2.2</version>
<version>1.2.3</version>
<packaging>pom</packaging>

<name>PASS NIHMS Submission Extract-Transform-Load</name>
Expand Down

0 comments on commit a5f2729

Please sign in to comment.