From 7d3476c13f577169133992cb1b98c36bae13250c Mon Sep 17 00:00:00 2001 From: Russ Poetker Date: Wed, 26 Jun 2024 11:48:38 -0400 Subject: [PATCH] Add KP role filter in grant sql --- .../pass/support/grant/data/jhu/JhuGrantDbConnector.java | 5 ++--- .../pass/support/grant/data/jhu/JhuGrantDbConnectorTest.java | 5 +++++ pass-grant-loader/src/test/resources/data.sql | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pass-grant-loader/src/main/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnector.java b/pass-grant-loader/src/main/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnector.java index c5eb39cb..10995b50 100644 --- a/pass-grant-loader/src/main/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnector.java +++ b/pass-grant-loader/src/main/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnector.java @@ -105,6 +105,7 @@ public class JhuGrantDbConnector implements GrantConnector { "WHERE A.inst_proposal = B.inst_proposal " + "AND B.employee_id = C.employee_id " + "AND A.AWARD_END_DATE >= '2011-01-01' " + + "AND B.ROLE != 'KP' " + "AND EXISTS (" + " select * from JHU_PASS_AWD_VIEW EA where" + " EA.UPDATE_TIMESTAMP > ?" + @@ -123,7 +124,6 @@ public class JhuGrantDbConnector implements GrantConnector { "FROM JHU_PERSON_VIEW A, " + "JHU_FIBI_IP_INV_VIEW B " + "WHERE A.employee_id = B.employee_id " + - // todo need reply from Bob on this "and A.UPDATE_TIMESTAMP > ?"; private static final String SELECT_FUNDER_SQL = @@ -136,8 +136,7 @@ public class JhuGrantDbConnector implements GrantConnector { private final Map jhuGrantDbRoleMapping = Map.of( "PI", "P", "Co-PI", "C", - "Co-I", "C", - "KP", "C" + "Co-I", "C" ); @Value("${grant.db.url}") diff --git a/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnectorTest.java b/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnectorTest.java index 30f354c3..eb3f7c49 100644 --- a/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnectorTest.java +++ b/pass-grant-loader/src/test/java/org/eclipse/pass/support/grant/data/jhu/JhuGrantDbConnectorTest.java @@ -47,6 +47,11 @@ public void testGrantQuery() throws SQLException { assertEquals(2, actualAwardNums.size()); assertTrue(actualAwardNums.contains("B10000000")); assertTrue(actualAwardNums.contains("B10000003")); + // Verify KP user is not in result set + List actualPiEmails = results.stream().map(GrantIngestRecord::getPiEmail).distinct().toList(); + assertEquals(2, actualPiEmails.size()); + assertTrue(actualPiEmails.contains("arecko1@jhu.edu")); + assertTrue(actualPiEmails.contains("sclass1@jhu.edu")); } @Test diff --git a/pass-grant-loader/src/test/resources/data.sql b/pass-grant-loader/src/test/resources/data.sql index 0096583c..86f1bd7a 100644 --- a/pass-grant-loader/src/test/resources/data.sql +++ b/pass-grant-loader/src/test/resources/data.sql @@ -13,11 +13,15 @@ INSERT INTO JHU_FIBI_IP_INV_VIEW (INST_PROPOSAL, EMPLOYEE_ID, ROLE) VALUES ('1', '31000000', 'PI'); INSERT INTO JHU_FIBI_IP_INV_VIEW (INST_PROPOSAL, EMPLOYEE_ID, ROLE) VALUES ('1', '31000001', 'Co-I'); +INSERT INTO JHU_FIBI_IP_INV_VIEW (INST_PROPOSAL, EMPLOYEE_ID, ROLE) +VALUES ('1', '31000002', 'KP'); INSERT INTO JHU_PERSON_VIEW (EMPLOYEE_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, EMAIL_ADDRESS, JHED_ID, UPDATE_TIMESTAMP) VALUES ('31000000', 'Amanda', 'Bea', 'Reckondwith', 'arecko1@jhu.edu', 'arecko1', '2022-03-11 00:00:00.0'); INSERT INTO JHU_PERSON_VIEW (EMPLOYEE_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, EMAIL_ADDRESS, JHED_ID, UPDATE_TIMESTAMP) VALUES ('31000001', 'Skip', 'Avery', 'Class', 'sclass1@jhu.edu', 'sclass1', '2023-03-11 00:00:00.0'); +INSERT INTO JHU_PERSON_VIEW (EMPLOYEE_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME, EMAIL_ADDRESS, JHED_ID, UPDATE_TIMESTAMP) +VALUES ('31000002', 'John', null, 'Doe', 'jdoe1@jhu.edu', 'jdoe1', '2022-03-11 00:00:00.0'); INSERT INTO JHU_PASS_AWD_VIEW (INST_PROPOSAL, AWARD_ID, AWARD_STATUS, SAP_GRANT_NUMBER, TITLE, AWARD_DATE, AWARD_START_DATE, AWARD_END_DATE, SPONSOR_CODE, SPONSOR_NAME, PRIME_SPONSOR_CODE, PRIME_SPONSOR_NAME,