Skip to content

Commit

Permalink
Add KP role filter in grant sql
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoet-jh committed Jul 23, 2024
1 parent 3005d0f commit ec83b0c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 > ?" +
Expand All @@ -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 =
Expand All @@ -136,8 +136,7 @@ public class JhuGrantDbConnector implements GrantConnector {
private final Map<String, String> jhuGrantDbRoleMapping = Map.of(
"PI", "P",
"Co-PI", "C",
"Co-I", "C",
"KP", "C"
"Co-I", "C"
);

@Value("${grant.db.url}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> actualPiEmails = results.stream().map(GrantIngestRecord::getPiEmail).distinct().toList();
assertEquals(2, actualPiEmails.size());
assertTrue(actualPiEmails.contains("[email protected]"));
assertTrue(actualPiEmails.contains("[email protected]"));
}

@Test
Expand Down
4 changes: 4 additions & 0 deletions pass-grant-loader/src/test/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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', '[email protected]', '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', '[email protected]', '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', '[email protected]', '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,
Expand Down

0 comments on commit ec83b0c

Please sign in to comment.