-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DUOS-2781][DUOS-2782] DAC rejects + accepts datasets #2215
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏽
src/main/java/org/broadinstitute/consent/http/mail/freemarker/DatasetApprovedModel.java
Show resolved
Hide resolved
src/main/java/org/broadinstitute/consent/http/service/DatasetService.java
Show resolved
Hide resolved
src/test/java/org/broadinstitute/consent/http/service/DatasetServiceTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I have a question about the test but not a blocker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments, looks OK overall
@@ -5,11 +5,13 @@ public class DatasetDeniedModel { | |||
private String dataSubmitterName; | |||
private String datasetName; | |||
private String dacName; | |||
private String dacEmail; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like these fields can be declared as final
, since they're not modified once the object is constructed. If they were, then this could become a record
:
public record DatasetDeniedModel(String dataSubmitterName, String datasetName, String dacName) {
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of moving to record classes, this is a pretty old part of the code base.
user, | ||
dac.getName(), | ||
dataset.getDatasetIdentifier()); | ||
if (!Objects.isNull(dac.getEmail())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks this use of Objects.isNull()
is common in this codebase, and it works, but it wasn't intended for this use. It was intended to be used as a predicate, such as for a streaming operation. See https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Objects.html#isNull(java.lang.Object). Personally I would compare against null
directly instead:
if (!Objects.isNull(dac.getEmail())) { | |
if (dac.getEmail() != null) { |
If you do want to use an Objects
method, I would use nonNull()
instead as then you don't have to negate the result:
if (!Objects.isNull(dac.getEmail())) { | |
if (Objects.nonNull(dac.getEmail())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the link to the doc, don't think I've ever read that. I've been suggesting the Objects
methods for some time now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you'd rather not compare against null
directly, a lot of people like using Optional.ofNullable()
instead. So you'd write something like:
Optional.ofNullable(dac.getEmail()).ifPresentOrElse(dacEmail ->
emailService.sendDatasetDeniedMessage(
user,
dac.getName(),
dataset.getDatasetIdentifier(),
dacEmail)).orElse(),
() -> logWarn("Unable to send dataset denied email to DAC: " + dac.getDacId());
@@ -22,7 +22,7 @@ | |||
<tr> | |||
<td style="padding: 15px 15px 0px; font-family: 'Montserrat', sans-serif; font-size: 16px; color: #1F3B50; text-align: justify; line-height: 25px;"> | |||
<p id="content" style="margin: 0;"> | |||
Thank you for using DUOS to register your dataset(s). We’re happy to inform you that ${dacName} has accepted your dataset. The ${datasetName} dataset should now be visible in the DUOS dataset catalog. Researchers will now be able to submit data access requests through DUOS for access to your dataset. | |||
Your dataset, ${datasetName}, submitted to the ${dacName} by ${dataSubmitterName} for management of future data access requests has been <b>accepted</b> and can be found in the DUOS Data Library with DUOS ID: ${datasetName} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the phrase submitted to the ${dacName} by ${dataSubmitterName} for management of future data access requests
is an appositive clause so it also should have commas around it, in addition to datasetName
since it's also an appositive for Your dataset
. Also maybe it should be split into two sentences with a period at the end.
Your dataset, ${datasetName}, submitted to the ${dacName} by ${dataSubmitterName} for management of future data access requests has been <b>accepted</b> and can be found in the DUOS Data Library with DUOS ID: ${datasetName} | |
Your dataset, ${datasetName}, submitted to the ${dacName} by ${dataSubmitterName} for management of future data access requests, has been <b>accepted</b>. It can be found in the DUOS Data Library with DUOS ID: ${datasetName}. |
As I understand it, the rationale for separating the appositive clause like this is to make it easer for a reader to find the verb and direct object of a sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The language is specified by product - I'd prefer to leave this decision to @solideoglori for language choice in these cases.
User user = new User(); | ||
user.setUserId(1); | ||
user.setEmail("[email protected]"); | ||
user.setDisplayName("John Doe"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User
has a constructor that can be used here
User user = new User(); | |
user.setUserId(1); | |
user.setEmail("[email protected]"); | |
user.setDisplayName("John Doe"); | |
User user = new User(1, "[email protected], "John Doe", null); |
assertFalse(returnedDataset.getDacApproval()); | ||
|
||
// do not send denied email | ||
verify(emailService, times(0)).sendDatasetDeniedMessage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nice alias for times(0)
is never()
verify(emailService, times(0)).sendDatasetDeniedMessage( | |
verify(emailService, never()).sendDatasetDeniedMessage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
Addresses
https://broadworkbench.atlassian.net/browse/DUOS-2781
https://broadworkbench.atlassian.net/browse/DUOS-2782
Summary
Have you read CONTRIBUTING.md lately? If not, do that first.