Skip to content
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] DAC rejects datasets #2216

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ public class DatasetDeniedModel {
private String dataSubmitterName;
private String datasetName;
private String dacName;
private String dacEmail;

public DatasetDeniedModel(String dataSubmitterName, String datasetName, String dacName) {
public DatasetDeniedModel(String dataSubmitterName, String datasetName, String dacName, String dacEmail) {
this.dataSubmitterName = dataSubmitterName;
this.datasetName = datasetName;
this.dacName = dacName;
this.dacEmail = dacEmail;
}

public String getDataSubmitterName() {
Expand All @@ -23,4 +25,9 @@ public String getDatasetName() {
public String getDacName() {
return dacName;
}

public String getDacEmail() {
return dacEmail;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public Writer getDatasetApprovedTemplate(String dataSubmitterName, String datase
}

public Writer getDatasetDeniedTemplate(String dataSubmitterName, String datasetName,
String dacName) throws IOException, TemplateException {
String dacName, String dacEmail) throws IOException, TemplateException {
Template temp = freeMarkerConfig.getTemplate("dataset-denied.html");
return generateDatasetDeniedTemplate(dataSubmitterName, datasetName, dacName, temp);
return generateDatasetDeniedTemplate(dataSubmitterName, datasetName, dacName, dacEmail, temp);
}

public Writer getNewResearcherLibraryRequestTemplate(String researcherName, String serverUrl)
Expand All @@ -90,8 +90,8 @@ private Writer generateDatasetApprovedTemplate(String dataSubmitterName, String
}

private Writer generateDatasetDeniedTemplate(String dataSubmitterName, String datasetName,
String dacName, Template temp) throws IOException, TemplateException {
DatasetDeniedModel model = new DatasetDeniedModel(dataSubmitterName, datasetName, dacName);
String dacName, String dacEmail, Template temp) throws IOException, TemplateException {
DatasetDeniedModel model = new DatasetDeniedModel(dataSubmitterName, datasetName, dacName, dacEmail);
Writer out = new StringWriter();
temp.process(model, out);
return out;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@
import org.broadinstitute.consent.http.models.dto.DatasetDTO;
import org.broadinstitute.consent.http.models.dto.DatasetPropertyDTO;
import org.broadinstitute.consent.http.service.dao.DatasetServiceDAO;
import org.broadinstitute.consent.http.util.ConsentLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class DatasetService {
public class DatasetService implements ConsentLogger {

private final Logger logger = LoggerFactory.getLogger(this.getClass());
public static final String DATASET_NAME_KEY = "Dataset Name";
Expand Down Expand Up @@ -345,10 +346,17 @@ private void sendDatasetApprovalNotificationEmail(Dataset dataset, User user, Bo
dac.getName(),
dataset.getDatasetIdentifier());
} else {
emailService.sendDatasetDeniedMessage(
user,
dac.getName(),
dataset.getDatasetIdentifier());
if (!Objects.isNull(dac.getEmail())) {
String dacEmail = dac.getEmail();
emailService.sendDatasetDeniedMessage(
user,
dac.getName(),
dataset.getDatasetIdentifier(),
dacEmail);
}
else {
logWarn("Unable to send dataset denied email to DAC: " + dac.getDacId());
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,10 @@ public void sendDatasetApprovedMessage(User user,

public void sendDatasetDeniedMessage(User user,
String dacName,
String datasetName) throws Exception {
String datasetName,
String dacEmail) throws Exception {
Writer template = templateHelper.getDatasetDeniedTemplate(user.getDisplayName(), datasetName,
dacName);
dacName, dacEmail);
Optional<Response> response = sendGridAPI.sendDatasetDeniedMessage(user.getEmail(), template);
saveEmailAndResponse(
response.orElse(null),
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/freemarker/dataset-denied.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 your interest in using DUOS to register your dataset(s). Unfortunately, ${dacName} has rejected your ${datasetName} dataset. Based on the feedback your received from this DAC, you can choose to alter your data submission form and re-submit the dataset to ${dacName}. Alternatively, you can submit the dataset to a different DAC for review.
Your dataset, ${datasetName}, submitted to the ${dacName} by ${dataSubmitterName} for management of future data access requests has been <b>rejected</b>. Please contact the DAC directly at ${dacEmail} for questions.
</p>
<p>
Please reach out to <a href="mailto:[email protected]" style="text-decoration: none; font-family: 'Montserrat', sans-serif; color: #00609F;">[email protected]</a> if you have any questions or concerns.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ void testApproveDataset_DenyDataset() throws Exception {
dataset.setDacId(3);
Dac dac = new Dac();
dac.setName("DAC NAME");
dac.setEmail("[email protected]");
initService();
when(dacDAO.findById(3)).thenReturn(dac);

Expand All @@ -767,10 +768,46 @@ void testApproveDataset_DenyDataset() throws Exception {
verify(emailService, times(1)).sendDatasetDeniedMessage(
user,
"DAC NAME",
"DUOS-000001"
"DUOS-000001",
"[email protected]"
);
}

@Test
void testApproveDataset_DenyDataset_WithNoDACEmail() throws Exception {
Dataset dataset = new Dataset();
dataset.setDataSetId(1);
User user = new User();
user.setUserId(1);
user.setEmail("[email protected]");
user.setDisplayName("John Doe");
Boolean payloadBool = false;
Dataset updatedDataset = new Dataset();
updatedDataset.setDataSetId(1);
updatedDataset.setDacApproval(payloadBool);

when(datasetDAO.findDatasetById(any())).thenReturn(updatedDataset);
dataset.setAlias(1);
dataset.setDacId(3);
Dac dac = new Dac();
dac.setName("DAC NAME");
initService();
when(dacDAO.findById(3)).thenReturn(dac);

Dataset returnedDataset = datasetService.approveDataset(dataset, user, payloadBool);
assertEquals(dataset.getDataSetId(), returnedDataset.getDataSetId());
assertFalse(returnedDataset.getDacApproval());

// do not send denied email
verify(emailService, times(0)).sendDatasetDeniedMessage(
user,
"DAC NAME",
"DUOS-000001",
""
);

}

@Test
void testSyncDataUseTranslation() {
Dataset ds = new Dataset();
Expand Down
Loading