use of org.obiba.mica.access.domain.DataAccessFeasibility in project mica2 by obiba.
the class DataAccessFeasibilityResource method deleteVariablesSet.
@DELETE
@Path("/variables")
public Response deleteVariablesSet() {
subjectAclService.checkPermission(getResourcePath(), "EDIT", id);
DataAccessFeasibility feasibility = getService().findById(id);
if (feasibility.hasVariablesSet())
variableSetService.delete(feasibility.getVariablesSet());
return Response.noContent().build();
}
use of org.obiba.mica.access.domain.DataAccessFeasibility in project mica2 by obiba.
the class DataAccessFeasibilityResource method setModel.
@PUT
@Path("/model")
@Consumes("application/json")
public Response setModel(String content) {
subjectAclService.checkPermission(getResourcePath(), "EDIT", id);
DataAccessRequest request = dataAccessRequestService.findById(parentId);
if (request.isArchived())
throw new BadRequestException("Data access request is archived");
DataAccessFeasibility feasibility = dataAccessFeasibilityService.findById(id);
feasibility.setContent(content);
dataAccessFeasibilityService.save(feasibility);
return Response.ok().build();
}
use of org.obiba.mica.access.domain.DataAccessFeasibility in project mica2 by obiba.
the class DataAccessFeasibilityResource method update.
@PUT
@Timed
public Response update(Mica.DataAccessRequestDto dto) {
subjectAclService.checkPermission(getResourcePath(), "EDIT", id);
if (!id.equals(dto.getId()))
throw new BadRequestException();
DataAccessRequest request = dataAccessRequestService.findById(parentId);
if (request.isArchived())
throw new BadRequestException("Data access request is archived");
DataAccessFeasibility feasibility = dtos.fromFeasibilityDto(dto);
dataAccessFeasibilityService.save(feasibility);
return Response.noContent().build();
}
use of org.obiba.mica.access.domain.DataAccessFeasibility in project mica2 by obiba.
the class DataAccessFeasibilityService method save.
@Override
public DataAccessFeasibility save(@NotNull DataAccessFeasibility feasibility) {
DataAccessFeasibility saved = feasibility;
DataAccessEntityStatus from = null;
if (feasibility.isNew()) {
setAndLogStatus(saved, DataAccessEntityStatus.OPENED);
int count = findByParentId(saved.getParentId()).size();
saved.setId(saved.getParentId() + "-F" + (count + 1));
} else {
saved = dataFeasibilityRequestRepository.findOne(feasibility.getId());
if (saved != null) {
from = saved.getStatus();
// validate the status
dataAccessRequestUtilService.checkStatusTransition(saved, feasibility.getStatus());
saved.setStatus(feasibility.getStatus());
if (feasibility.hasStatusChangeHistory())
saved.setStatusChangeHistory(feasibility.getStatusChangeHistory());
// merge beans
BeanUtils.copyProperties(feasibility, saved, "id", "version", "createdBy", "createdDate", "lastModifiedBy", "lastModifiedDate", "statusChangeHistory");
} else {
saved = feasibility;
setAndLogStatus(saved, DataAccessEntityStatus.OPENED);
}
}
schemaFormContentFileService.save(saved, dataFeasibilityRequestRepository.findOne(feasibility.getId()), String.format("/data-access-request/%s/feasibility/%s", saved.getParentId(), feasibility.getId()));
saved.setLastModifiedDate(DateTime.now());
dataFeasibilityRequestRepository.save(saved);
eventBus.post(new DataAccessFeasibilityUpdatedEvent(saved));
sendNotificationEmails(saved, from);
return saved;
}
use of org.obiba.mica.access.domain.DataAccessFeasibility in project mica2 by obiba.
the class DataAccessFeasibilitiesResource method create.
@POST
@Path("/_empty")
public Response create(@Context UriInfo uriInfo) {
DataAccessFeasibility feasibility = new DataAccessFeasibility();
feasibility.setContent("{}");
return saveNew(feasibility, uriInfo);
}
Aggregations