Search in sources :

Example 11 with DataAccessForm

use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.

the class DataAccessRequestService method generateId.

private String generateId() {
    DataAccessForm dataAccessForm = dataAccessFormService.find().get();
    IdentifierGenerator idGenerator = IdentifierGenerator.newBuilder().prefix(dataAccessForm.getIdPrefix()).size(dataAccessForm.getIdLength()).zeros().build();
    while (true) {
        String id = idGenerator.generateIdentifier();
        if (dataAccessRequestRepository.findOne(id) == null)
            return id;
    }
}
Also used : DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm) IdentifierGenerator(org.obiba.mica.core.support.IdentifierGenerator)

Example 12 with DataAccessForm

use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.

the class DataAccessRequestService method sendReviewedNotificationEmail.

private void sendReviewedNotificationEmail(DataAccessRequest request) {
    DataAccessForm dataAccessForm = dataAccessFormService.find().get();
    if (dataAccessForm.isNotifyReviewed() && dataAccessForm.isWithReview()) {
        Map<String, String> ctx = getNotificationEmailContext(request);
        mailService.sendEmailToUsers(mailService.getSubject(dataAccessForm.getReviewedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestReviewedApplicantEmail", ctx, request.getApplicant());
    }
}
Also used : DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm)

Example 13 with DataAccessForm

use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.

the class DataAccessRequestService method sendRejectedNotificationEmail.

private void sendRejectedNotificationEmail(DataAccessRequest request) {
    DataAccessForm dataAccessForm = dataAccessFormService.find().get();
    if (dataAccessForm.isNotifyRejected()) {
        Map<String, String> ctx = getNotificationEmailContext(request);
        mailService.sendEmailToUsers(mailService.getSubject(dataAccessForm.getRejectedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestRejectedApplicantEmail", ctx, request.getApplicant());
    }
}
Also used : DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm)

Example 14 with DataAccessForm

use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.

the class DataAccessRequestUtilService method addNextSubmittedStatus.

private void addNextSubmittedStatus(List<DataAccessRequest.Status> to) {
    to.add(DataAccessRequest.Status.OPENED);
    DataAccessForm dataAccessForm = dataAccessFormService.find().get();
    if (dataAccessForm.isWithReview()) {
        to.add(DataAccessRequest.Status.REVIEWED);
    } else {
        to.add(DataAccessRequest.Status.APPROVED);
        to.add(DataAccessRequest.Status.REJECTED);
        if (dataAccessForm.isWithConditionalApproval())
            to.add(DataAccessRequest.Status.CONDITIONALLY_APPROVED);
    }
}
Also used : DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm)

Example 15 with DataAccessForm

use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.

the class DataAccessRequestsResource method exportCsv.

@GET
@Timed
@Path("/csv")
@Produces("text/csv")
public Response exportCsv(@QueryParam("lang") String lang) {
    List<DataAccessRequest> dataAccessRequests = listByStatusFilteringPermitted(null);
    DataAccessForm dataAccessForm = dataAccessFormService.find().get();
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    new CsvReportGenerator(dataAccessRequests, dataAccessForm.getCsvExportFormat(), lang).write(byteArrayOutputStream);
    String date = new DateTime().toString("YYYY-MM-dd");
    return Response.ok(byteArrayOutputStream.toByteArray()).header("Content-Disposition", String.format("attachment; filename=\"Access-Requests-Report_%s.csv\"", date)).build();
}
Also used : DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest) ByteArrayOutputStream(org.apache.commons.io.output.ByteArrayOutputStream) DataAccessForm(org.obiba.mica.micaConfig.domain.DataAccessForm) DateTime(org.joda.time.DateTime) Timed(com.codahale.metrics.annotation.Timed)

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