[DT-3063, DT-3065] Store relationship between DARs/Progress Reports and DAAs, Flag DARs/PRs for SO approval when user not pre authorized for DAAs#2859
Conversation
…after closeouts or DMIs are SO approved.
…se where system is configured without DAAs for DACs.
rushtong
left a comment
There was a problem hiding this comment.
Still reviewing functionally, but wanted to get this first pass of feedback out in the meantime.
| } | ||
|
|
||
| @Override | ||
| public Stream<Entry<Integer, Set<Integer>>> stream(Map<Integer, Set<Integer>> container) { |
There was a problem hiding this comment.
This looks super useful 👍🏽
| Integer darId = | ||
| dataAccessRequestDAO.insertDataAccessRequest( | ||
| collectionId, | ||
| referenceId, | ||
| user.getUserId(), | ||
| now, | ||
| now, | ||
| now, | ||
| darData, | ||
| user.getEraCommonsId()); |
There was a problem hiding this comment.
It would be nice if these were both in a single transaction. I have some WITH examples that might serve as a template for this in one of my open PRs.
There was a problem hiding this comment.
I might go with a slightly different approach to see how we like it, but it will be in one transaction.
There was a problem hiding this comment.
Coming back to this one. It looks like there were already multiple database updates in this method that should effectively unwind if there's an error here, but because of the number of elements involved, I'm wondering if we should make a ticket for this and come back to it later. Would that be acceptable? There are also other methods in this class (and related services) that need to be linked as well, hence my hesitation to add this to the scope of this ticket.
There was a problem hiding this comment.
Sure thing - it would be nice to tighten this up separately
There was a problem hiding this comment.
DT-3176 created.
| // We need to set the new DAAs that were in place on the DAR because the DAAs may have been | ||
| // updated | ||
| // from the original DAR. | ||
| originalDataCopy.setDaaIds(newData.getDaaIds()); |
There was a problem hiding this comment.
Just clarifying that I think we're planning on the FE to populate these values on submission. If not, these will be empty.
There was a problem hiding this comment.
Exactly. It's the next ticket I'm grabbing. :-)
| """ | ||
| INSERT INTO dar_daa (dar_id, daa_id) VALUES (:darId, :daaId) | ||
| """) | ||
| void insertDarDAARelationship(@Bind("darId") Integer darId, @Bind("daaId") Set<Integer> daaIds); |
There was a problem hiding this comment.
Copilot caught this for me - I was unaware of this detail. See current jdbi doc for reference.
In JDBI 3, all @SqlBatch parameters are expected to be iterable. A non-iterable scalar must be annotated with @SingleValue to be held constant per row. Without it, behavior is undefined across JDBI point-releases and the batch will fail if the set has more than one element.
Fix:
void insertDarDAARelationship(@Bind("darId") @SingleValue Integer darId,
@Bind("daaId") Set<Integer> daaIds);
There was a problem hiding this comment.
I want to spend some time looking at this because I think I wrote a test that ends up proving this works. See testStoreDarDAARelationshipForPR in DaaDAOTest.java
There was a problem hiding this comment.
I've updated the method and added the @SingleValue decoration. No change in the test result. Looking at the docs, they all are using the @SingleValue decoration on Collection parameters. That's different than what I've got in the code. darId is a single integer value. I've added an assertion to the testStoreDarDAARelationshipForPR to confirm multiple rows are being inserted as expected.
rushtong
left a comment
There was a problem hiding this comment.
Thank you for the updates 👍🏽
…lationships and record new ones based on the object submitted.
|



Addresses
https://broadworkbench.atlassian.net/browse/DT-3063
https://broadworkbench.atlassian.net/browse/DT-3065
Summary
Have you read CONTRIBUTING.md lately? If not, do that first.