From 11799ba39bbaaaf2d32424e467ab5af1159fbf72 Mon Sep 17 00:00:00 2001 From: Russ Poetker Date: Fri, 1 Mar 2024 10:28:22 -0500 Subject: [PATCH] Allow null award_status in ingest record --- .../grant/data/AbstractDefaultPassUpdater.java | 17 ++++++++++------- .../support/grant/GrantLoaderLoadFileIT.java | 2 +- .../src/test/resources/test-load.csv | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pass-grant-loader/src/main/java/org/eclipse/pass/support/grant/data/AbstractDefaultPassUpdater.java b/pass-grant-loader/src/main/java/org/eclipse/pass/support/grant/data/AbstractDefaultPassUpdater.java index 381e46b4..bbbbd555 100644 --- a/pass-grant-loader/src/main/java/org/eclipse/pass/support/grant/data/AbstractDefaultPassUpdater.java +++ b/pass-grant-loader/src/main/java/org/eclipse/pass/support/grant/data/AbstractDefaultPassUpdater.java @@ -248,7 +248,9 @@ private void updateGrants(Collection 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 @@ -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"); @@ -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 { diff --git a/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/GrantLoaderLoadFileIT.java b/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/GrantLoaderLoadFileIT.java index 6a53a620..4e41f95f 100644 --- a/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/GrantLoaderLoadFileIT.java +++ b/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/GrantLoaderLoadFileIT.java @@ -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()); diff --git a/pass-grant-loader/src/test/resources/test-load.csv b/pass-grant-loader/src/test/resources/test-load.csv index 3d5d67e4..7c00d160 100644 --- a/pass-grant-loader/src/test/resources/test-load.csv +++ b/pass-grant-loader/src/test/resources/test-load.csv @@ -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,userfour@jhu.edu,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,userfive@jhu.edu,,,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,usersix@jhu.edu,,,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,userone@jhu.edu,,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,userone@jhu.edu,,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,userone@jhu.edu,,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,userone@jhu.edu,,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,userone@jhu.edu,,123456,P,2023-02-01