use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.
the class DataAccessRequestService method updateContent.
/**
* Update the content of the {@link DataAccessRequest} matching the identifier.
*
* @param id
* @param content
*/
public void updateContent(@NotNull String id, String content) {
DataAccessRequest request = findById(id);
if (request.getStatus() != DataAccessRequest.Status.OPENED)
throw new IllegalArgumentException("Data access request content can only be modified when status is draft");
request.setContent(content);
save(request);
}
use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.
the class DataAccessRequestService method delete.
/**
* Delete the {@link DataAccessRequest} matching the identifier.
*
* @param id
* @throws NoSuchDataAccessRequestException
*/
public void delete(@NotNull String id) throws NoSuchDataAccessRequestException {
DataAccessRequest dataAccessRequest = findById(id);
List<Attachment> attachments = dataAccessRequest.getAttachments();
dataAccessRequestRepository.deleteWithReferences(dataAccessRequest);
schemaFormContentFileService.deleteFiles(dataAccessRequest);
attachments.forEach(a -> fileStoreService.delete(a.getId()));
eventBus.post(new DataAccessRequestDeletedEvent(dataAccessRequest));
}
use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.
the class DataAccessRequestService method getRequestPdf.
public byte[] getRequestPdf(String id, String lang) {
DataAccessRequest dataAccessRequest = findById(id);
ByteArrayOutputStream ba = new ByteArrayOutputStream();
Object content = defaultConfiguration().jsonProvider().parse(dataAccessRequest.getContent());
try {
fillPdfTemplateFromRequest(getTemplate(Locale.forLanguageTag(lang)), ba, content);
} catch (IOException | DocumentException e) {
throw Throwables.propagate(e);
}
return ba.toByteArray();
}
use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.
the class CsvReportGeneratorTest method approvedDataAccessRequest.
private DataAccessRequest approvedDataAccessRequest() {
DataAccessRequest dataAccessRequest = DataAccessRequest.newBuilder().status(Status.APPROVED.toString()).content("{'title':'Approved request title', 'isWaiting':false}").build();
dataAccessRequest.setId("approved id");
dataAccessRequest.setCreatedDate(new DateTime(2016, 8, 20, 14, 36));
dataAccessRequest.setLastModifiedDate(new DateTime(2015, 8, 25, 14, 36));
dataAccessRequest.setStatusChangeHistory(asList(StatusChange.newBuilder().changedOn(new DateTime(2017, 1, 1, 1, 1)).current(Status.APPROVED).build(), StatusChange.newBuilder().changedOn(new DateTime(2016, 6, 1, 1, 1)).current(Status.SUBMITTED).build()));
return dataAccessRequest;
}
use of org.obiba.mica.access.domain.DataAccessRequest in project mica2 by obiba.
the class DataAccessRequestResource method updateAttachments.
@PUT
@Timed
@Path("/_attachments")
public Response updateAttachments(@PathParam("id") String id, Mica.DataAccessRequestDto dto) {
subjectAclService.checkPermission("/data-access-request", "VIEW", id);
if (!id.equals(dto.getId()))
throw new BadRequestException();
DataAccessRequest request = dtos.fromDto(dto);
dataAccessRequestService.saveAttachments(request);
return Response.noContent().build();
}
Aggregations