Search in sources :

Example 1 with DataAccessFeasibility

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();
}
Also used : DataAccessFeasibility(org.obiba.mica.access.domain.DataAccessFeasibility)

Example 2 with DataAccessFeasibility

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();
}
Also used : DataAccessFeasibility(org.obiba.mica.access.domain.DataAccessFeasibility) DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest)

Example 3 with DataAccessFeasibility

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();
}
Also used : DataAccessFeasibility(org.obiba.mica.access.domain.DataAccessFeasibility) DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest) Timed(com.codahale.metrics.annotation.Timed)

Example 4 with DataAccessFeasibility

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;
}
Also used : DataAccessFeasibility(org.obiba.mica.access.domain.DataAccessFeasibility) DataAccessFeasibilityUpdatedEvent(org.obiba.mica.access.event.DataAccessFeasibilityUpdatedEvent) DataAccessEntityStatus(org.obiba.mica.access.domain.DataAccessEntityStatus)

Example 5 with DataAccessFeasibility

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);
}
Also used : DataAccessFeasibility(org.obiba.mica.access.domain.DataAccessFeasibility)

Aggregations

DataAccessFeasibility (org.obiba.mica.access.domain.DataAccessFeasibility)7 Timed (com.codahale.metrics.annotation.Timed)2 DataAccessRequest (org.obiba.mica.access.domain.DataAccessRequest)2 DataAccessEntityStatus (org.obiba.mica.access.domain.DataAccessEntityStatus)1 DataAccessFeasibilityUpdatedEvent (org.obiba.mica.access.event.DataAccessFeasibilityUpdatedEvent)1