use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessFormService method find.
public Optional<DataAccessForm> find() {
DataAccessForm form = dataAccessFormRepository.findOne(DataAccessForm.DEFAULT_ID);
if (form == null) {
createOrUpdate(createDefaultDataAccessForm());
form = dataAccessFormRepository.findOne(DataAccessForm.DEFAULT_ID);
}
if (StringUtils.isEmpty(form.getCsvExportFormat())) {
form.setCsvExportFormat(getDefaultDataAccessFormResourceAsString("export-csv-schema.json"));
form = createOrUpdate(form);
}
return Optional.ofNullable(form);
}
use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessResource method getDataAccessPdf.
@GET
@Path("/pdf")
public FileResource getDataAccessPdf(@QueryParam("lang") String lang) {
Optional<DataAccessForm> d = dataAccessFormService.find();
if (!d.isPresent())
throw NoSuchDataAccessFormException.withDefaultMessage();
DataAccessForm dataAccessForm = d.get();
Locale locale = Locale.forLanguageTag(!Strings.isNullOrEmpty(lang) ? Locale.forLanguageTag(lang).toLanguageTag() : LanguageTag.UNDETERMINED);
if (!dataAccessForm.getPdfTemplates().containsKey(locale))
throw NoSuchDataAccessFormException.withDefaultMessage();
fileResource.setAttachment(dataAccessForm.getPdfTemplates().get(locale));
return fileResource;
}
use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessRequestCommentMailNotification method send.
@Override
public void send(Comment comment) {
if (comment == null)
return;
DataAccessForm dataAccessForm = dataAccessFormService.find().get();
if (!dataAccessForm.isNotifyCommented())
return;
DataAccessRequest request = dataAccessRequestService.findById(comment.getInstanceId());
Map<String, String> ctx = Maps.newHashMap();
String organization = micaConfigService.getConfig().getName();
String id = request.getId();
String title = dataAccessRequestUtilService.getRequestTitle(request);
ctx.put("organization", organization);
ctx.put("publicUrl", micaConfigService.getPublicUrl());
ctx.put("id", id);
if (Strings.isNullOrEmpty(title))
title = id;
ctx.put("title", title);
ctx.put("applicant", request.getApplicant());
ctx.put("status", request.getStatus().name());
mailService.sendEmailToUsers(mailService.getSubject(dataAccessForm.getCommentedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestCommentAdded", ctx, request.getApplicant());
mailService.sendEmailToGroups(mailService.getSubject(dataAccessForm.getCommentedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestCommentAdded", ctx, Roles.MICA_DAO);
}
use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessRequestService method sendApprovedNotificationEmail.
private void sendApprovedNotificationEmail(DataAccessRequest request) {
DataAccessForm dataAccessForm = dataAccessFormService.find().get();
if (dataAccessForm.isNotifyApproved()) {
Map<String, String> ctx = getNotificationEmailContext(request);
mailService.sendEmailToUsers(mailService.getSubject(dataAccessForm.getApprovedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestApprovedApplicantEmail", ctx, request.getApplicant());
}
}
use of org.obiba.mica.micaConfig.domain.DataAccessForm in project mica2 by obiba.
the class DataAccessRequestService method sendSubmittedNotificationEmail.
private void sendSubmittedNotificationEmail(DataAccessRequest request) {
DataAccessForm dataAccessForm = dataAccessFormService.find().get();
if (dataAccessForm.isNotifySubmitted()) {
Map<String, String> ctx = getNotificationEmailContext(request);
mailService.sendEmailToUsers(mailService.getSubject(dataAccessForm.getSubmittedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestSubmittedApplicantEmail", ctx, request.getApplicant());
mailService.sendEmailToGroups(mailService.getSubject(dataAccessForm.getSubmittedSubject(), ctx, DataAccessRequestUtilService.DEFAULT_NOTIFICATION_SUBJECT), "dataAccessRequestSubmittedDAOEmail", ctx, Roles.MICA_DAO);
}
}
Aggregations