use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessRequestService method sendOpenedNotificationEmail.
private void sendOpenedNotificationEmail(DataAccessRequest request) {
DataAccessForm dataAccessForm = dataAccessFormService.find().get();
if (dataAccessForm.isNotifyReopened()) {
Map<String, String> ctx = getNotificationEmailContext(request);
mailService.sendEmailToUsers(mailService.getSubject(dataAccessForm.getReopenedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestReopenedApplicantEmail", ctx, request.getApplicant());
}
}
use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessRequestService method sendAttachmentsUpdatedNotificationEmail.
private void sendAttachmentsUpdatedNotificationEmail(DataAccessRequest request) {
DataAccessForm dataAccessForm = dataAccessFormService.find().get();
if (dataAccessForm.isNotifyAttachment()) {
Map<String, String> ctx = getNotificationEmailContext(request);
mailService.sendEmailToUsers(mailService.getSubject(dataAccessForm.getAttachmentSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestAttachmentsUpdated", ctx, request.getApplicant());
mailService.sendEmailToGroups(mailService.getSubject(dataAccessForm.getAttachmentSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestAttachmentsUpdated", ctx, Roles.MICA_DAO);
}
}
use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessRequestService method getTemplate.
private byte[] getTemplate(Locale locale) throws IOException {
DataAccessForm dataAccessForm = dataAccessFormService.find().get();
Attachment pdfTemplate = dataAccessForm.getPdfTemplates().get(locale);
if (pdfTemplate == null) {
Map<Locale, Attachment> pdfTemplates = dataAccessForm.getPdfTemplates();
if (!pdfTemplates.isEmpty()) {
pdfTemplate = dataAccessForm.getPdfTemplates().get(Locale.ENGLISH);
if (pdfTemplate == null)
pdfTemplate = dataAccessForm.getPdfTemplates().values().stream().findFirst().get();
}
}
return pdfTemplate != null ? ByteStreams.toByteArray(fileStoreService.getFile(pdfTemplate.getFileReference())) : ByteStreams.toByteArray(defaultTemplateResource.getInputStream());
}
use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessRequestService method sendConditionallyApprovedEmail.
private void sendConditionallyApprovedEmail(DataAccessRequest request) {
DataAccessForm dataAccessForm = dataAccessFormService.find().get();
if (dataAccessForm.isNotifyConditionallyApproved()) {
Map<String, String> ctx = getNotificationEmailContext(request);
mailService.sendEmailToUsers(mailService.getSubject(dataAccessForm.getConditionallyApprovedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestConditionallyApprovedApplicantEmail", ctx, request.getApplicant());
}
}
use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessRequestUtilService method addNextReviewedStatus.
private void addNextReviewedStatus(List<DataAccessRequest.Status> to) {
to.add(DataAccessRequest.Status.APPROVED);
to.add(DataAccessRequest.Status.REJECTED);
DataAccessForm dataAccessForm = dataAccessFormService.find().get();
if (dataAccessForm.isWithConditionalApproval())
to.add(DataAccessRequest.Status.CONDITIONALLY_APPROVED);
else
to.add(DataAccessRequest.Status.OPENED);
// check if current user role is admin to add DataAccessRequest.Status.SUBMITTED
if (userProfileService.currentUserIs(Roles.MICA_ADMIN)) {
to.add(DataAccessRequest.Status.SUBMITTED);
}
}
Aggregations