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;
}
}
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());
}
}
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());
}
}
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);
}
}
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();
}
Aggregations