Search in sources :

Example 1 with DataAccessForm

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());
    }
}
Also used : DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm)

Example 2 with DataAccessForm

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);
    }
}
Also used : DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm)

Example 3 with DataAccessForm

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());
}
Also used : Locale(java.util.Locale) Attachment(org.obiba.mica.file.Attachment) DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm)

Example 4 with DataAccessForm

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());
    }
}
Also used : DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm)

Example 5 with DataAccessForm

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);
    }
}
Also used : DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm)

Aggregations

DataAccessForm (org.obiba.mica.micaConfig.domain.DataAccessForm)17 Locale (java.util.Locale)3 Timed (com.codahale.metrics.annotation.Timed)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 DataAccessRequest (org.obiba.mica.access.domain.DataAccessRequest)2 Strings (com.google.common.base.Strings)1 Maps (com.google.common.collect.Maps)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 Inject (javax.inject.Inject)1 QueryParam (javax.ws.rs.QueryParam)1 ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)1 RequiresAuthentication (org.apache.shiro.authz.annotation.RequiresAuthentication)1 DateTime (org.joda.time.DateTime)1 LocalizedString (org.obiba.mica.core.domain.LocalizedString)1 IdentifierGenerator (org.obiba.mica.core.support.IdentifierGenerator)1 Attachment (org.obiba.mica.file.Attachment)1 FileResource (org.obiba.mica.file.rest.FileResource)1