use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.
the class DataAccessRequestResource method get.
@PUT
@Timed
public Response get(@PathParam("id") String id, Mica.DataAccessRequestDto dto) {
subjectAclService.checkPermission("/data-access-request", "EDIT", id);
if (!id.equals(dto.getId()))
throw new BadRequestException();
DataAccessRequest request = dtos.fromDto(dto);
dataAccessRequestService.save(request);
return Response.noContent().build();
}
use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.
the class DataAccessRequestResource method review.
private Response review(@PathParam("id") String id) {
DataAccessRequest request = dataAccessRequestService.findById(id);
boolean fromConditionallyApproved = request.getStatus() == DataAccessRequest.Status.CONDITIONALLY_APPROVED;
if (fromConditionallyApproved) {
// remove applicant permissions
subjectAclService.removePermission("/data-access-request", "EDIT,DELETE", id);
subjectAclService.removePermission("/data-access-request/" + id, "EDIT", "_status");
// data access officers can change the status of the request
subjectAclService.addGroupPermission(Roles.MICA_DAO, "/data-access-request/" + id, "EDIT", "_status");
}
return updateStatus(id, DataAccessRequest.Status.REVIEWED);
}
use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.
the class DataAccessRequestResource method get.
@GET
@Timed
public Mica.DataAccessRequestDto get(@PathParam("id") String id) {
subjectAclService.checkPermission("/data-access-request", "VIEW", id);
DataAccessRequest request = dataAccessRequestService.findById(id);
return dtos.asDto(request);
}
use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.
the class ProjectService method dataAccessRequestUpdated.
//
// Event handling
//
@Async
@Subscribe
public void dataAccessRequestUpdated(DataAccessRequestUpdatedEvent event) {
DataAccessRequest request = event.getPersistable();
if (!projectRepository.exists(request.getId()) && request.getStatus() == DataAccessRequest.Status.APPROVED) {
Project project = new Project();
project.setId(event.getPersistable().getId());
project.setDataAccessRequestId(event.getPersistable().getId());
String title = dataAccessRequestUtilService.getRequestTitle(request);
if (!Strings.isNullOrEmpty(title)) {
project.setTitle(LocalizedString.from(micaConfigService.getConfig().getLocales(), title));
}
String summary = dataAccessRequestUtilService.getRequestSummary(request);
if (!Strings.isNullOrEmpty(summary)) {
project.setSummary(LocalizedString.from(micaConfigService.getConfig().getLocales(), summary));
}
save(project, "Created from Data Access Request");
}
}
use of org.obiba.mica.access.domain.DataAccessRequest 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);
}
Aggregations