Skip to content

Commit

Permalink
Allow null award_status in ingest record
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoet-jh committed Mar 1, 2024
1 parent 75fa83b commit 11799ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ private void updateGrants(Collection<GrantIngestRecord> results) {
&& (endDate != null && (grant.getEndDate() == null || !endDate.isBefore(grant.getEndDate())))) {
grant.setEndDate(endDate);
//status should be the latest one
AwardStatus awardStatus = AwardStatus.of(grantIngestRecord.getAwardStatus().toLowerCase());
AwardStatus awardStatus = StringUtils.isNotBlank(grantIngestRecord.getAwardStatus())
? AwardStatus.of(grantIngestRecord.getAwardStatus().toLowerCase())
: null;
grant.setAwardStatus(awardStatus);

//we want the PI to be the one listed on the most recent grant iteration
Expand Down Expand Up @@ -312,7 +314,6 @@ private void validate(GrantIngestRecord grantIngestRecord) throws GrantDataExcep

required(grantIngestRecord.getGrantNumber(), "grantNumber");
required(grantIngestRecord.getGrantTitle(), "grantTitle");
required(grantIngestRecord.getAwardStatus(), "awardStatus");
required(grantIngestRecord.getAwardStart(), "awardStart");
required(grantIngestRecord.getAwardEnd(), "awardEnd");
required(grantIngestRecord.getDirectFunderCode(), "directFunderCode");
Expand All @@ -333,11 +334,13 @@ private void validate(GrantIngestRecord grantIngestRecord) throws GrantDataExcep
createZonedDateTime(grantIngestRecord.getAwardEnd());
createZonedDateTime(grantIngestRecord.getUpdateTimeStamp());

try {
AwardStatus.of(grantIngestRecord.getAwardStatus().toLowerCase());
} catch (IllegalArgumentException e) {
throw new GrantDataException("Invalid Award Status: " + grantIngestRecord.getAwardStatus() +
". Valid " + Arrays.asList(AwardStatus.values()));
if (StringUtils.isNotBlank(grantIngestRecord.getAwardStatus())) {
try {
AwardStatus.of(grantIngestRecord.getAwardStatus().toLowerCase());
} catch (IllegalArgumentException e) {
throw new GrantDataException("Invalid Award Status: " + grantIngestRecord.getAwardStatus() +
". Valid " + Arrays.asList(AwardStatus.values()));
}
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private void verifyGrantThree() throws IOException {
assertEquals("johnshopkins.edu:grant:333333", passGrant.getLocalKey());
assertEquals("323453", passGrant.getAwardNumber());
assertEquals("Test Grant 3", passGrant.getProjectName());
assertEquals(AwardStatus.ACTIVE, passGrant.getAwardStatus());
assertNull(passGrant.getAwardStatus());
assertEquals("2021-10-01T00:00Z", passGrant.getAwardDate().toString());
assertEquals("2021-05-01T00:00Z", passGrant.getStartDate().toString());
assertEquals("2026-04-30T00:00Z", passGrant.getEndDate().toString());
Expand Down
2 changes: 1 addition & 1 deletion pass-grant-loader/src/test/resources/test-load.csv
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GRANT_NUMBER,GRANT_TITLE,AWARD_NUMBER,AWARD_STATUS,AWARD_DATE,AWARD_START,AWARD_
130823,The Subclinical Vascular Contributions to Alzheimer's Disease: The Multi-Ethnic Study of Atherosclerosis (MESA) ,107-33664-1000055108,active,12/14/2018,2018-08-15 10:00:00,2025-05-31 00:00:00,NATIONAL INSTITUTES OF HEALTH,300865,WAKE FOREST UNIV,304106,UserFourFn,UserFourMn,UserFourLn,[email protected],userfour,,C,2023-03-10 15:15:20.234
130823,The Subclinical Vascular Contributions to Alzheimer's Disease: The Multi-Ethnic Study of Atherosclerosis (MESA) ,107-33664-1000055108,active,12/14/2018,2018-08-15 10:00:00,2025-05-31 00:00:00,NATIONAL INSTITUTES OF HEALTH,300865,WAKE FOREST UNIV,304106,UserFiveFn,,UserFiveLn,[email protected],,,C,2023-03-10 15:15:20.234
130823,The Subclinical Vascular Contributions to Alzheimer's Disease: The Multi-Ethnic Study of Atherosclerosis (MESA) ,107-33664-1000055108,active,12/14/2018,2018-08-15 10:00:00,2025-05-31 00:00:00,NATIONAL INSTITUTES OF HEALTH,300865,WAKE FOREST UNIV,304106,UserSixFn,,UserSixLn,[email protected],,,C,2023-03-10 15:15:20.234
333333,Test Grant 3,323453,active,2021-10-01,2021-05-01,2026-04-30,NATIONAL INSTITUTES OF HEALTH,300865,NATIONAL INSTITUTES OF HEALTH,300865,UserOneFn,UserOneMn,UserOneLn,[email protected],,123456,P,2023-02-01
333333,Test Grant 3,323453,,2021-10-01,2021-05-01,2026-04-30,NATIONAL INSTITUTES OF HEALTH,300865,NATIONAL INSTITUTES OF HEALTH,300865,UserOneFn,UserOneMn,UserOneLn,[email protected],,123456,P,2023-02-01
444444,Test Grant 4 - invalid award date,423454,active,10-01-2021,2021-05-01,2026-04-30,NATIONAL INSTITUTES OF HEALTH,300865,NATIONAL INSTITUTES OF HEALTH,300865,UserOneFn,UserOneMn,UserOneLn,[email protected],,123456,P,2023-02-01
555555,Test Grant 5 - missing required funder,423454,active,2021-10-01,2021-05-01,2026-04-30,,,,,UserOneFn,UserOneMn,UserOneLn,[email protected],,123456,P,2023-02-01
666666,Test Grant 6 - invalid award status,423454,foobar,2021-10-01,2021-05-01,2026-04-30,NATIONAL INSTITUTES OF HEALTH,300865,NATIONAL INSTITUTES OF HEALTH,300865,UserOneFn,UserOneMn,UserOneLn,[email protected],,123456,P,2023-02-01
Expand Down

0 comments on commit 11799ba

Please sign in to comment.