Search in sources :

Example 6 with DataAccessAmendment

use of org.obiba.mica.access.domain.DataAccessAmendment in project mica2 by obiba.

the class CsvReportGenerator method writeEachDataAccessRequest.

private void writeEachDataAccessRequest(CSVWriter writer) {
    writer.writeNext(toArray(extractTranslatedField(darSchema, GENERIC_TANSLATION_PREFIX + ".detailedOverview")));
    Set<String> tableKeys = darSchema.read("table", Map.class).keySet();
    dataAccessRequestDtos.entrySet().forEach(entry -> {
        writer.writeNext(tableKeys.stream().map(key -> extractTranslatedField(darSchema, "table.['" + key + "']")).toArray(String[]::new));
        DataAccessRequest dataAccessRequestDto = entry.getKey();
        DocumentContext dataAccessRequestContent = JsonPath.parse(dataAccessRequestDto.getContent());
        addGenericVariablesInDocumentContext(dataAccessRequestDto, darSchema, dataAccessRequestContent);
        writer.writeNext(tableKeys.stream().map(key -> extractValueFromDataAccessRequest(dataAccessRequestContent, key)).toArray(String[]::new));
        writer.writeNext(toArray(""));
        List<DataAccessAmendment> amendments = entry.getValue();
        if (amendments != null && !amendments.isEmpty()) {
            writeEachAmendment(amendments, writer);
        }
        writer.writeNext(toArray(""));
        writer.writeNext(toArray(""));
        writer.writeNext(toArray(""));
    });
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment) DataAccessRequest(org.obiba.mica.access.domain.DataAccessRequest) DocumentContext(com.jayway.jsonpath.DocumentContext) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with DataAccessAmendment

use of org.obiba.mica.access.domain.DataAccessAmendment in project mica2 by obiba.

the class CsvReportGenerator method writeEachAmendment.

private void writeEachAmendment(List<DataAccessAmendment> amendments, CSVWriter writer) {
    Set<String> tableKeys = amdSchema.read("table", Map.class).keySet();
    writer.writeNext(tableKeys.stream().map(key -> extractTranslatedField(amdSchema, "table.['" + key + "']")).toArray(String[]::new));
    for (DataAccessAmendment amendment : amendments) {
        DocumentContext amendmentContent = JsonPath.parse(amendment.getContent());
        addGenericVariablesInDocumentContext(amendment, amdSchema, amendmentContent);
        writer.writeNext(tableKeys.stream().map(key -> extractValueFromDataAccessRequest(amendmentContent, key)).toArray(String[]::new));
    }
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment) DocumentContext(com.jayway.jsonpath.DocumentContext) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with DataAccessAmendment

use of org.obiba.mica.access.domain.DataAccessAmendment in project mica2 by obiba.

the class DataAccessAmendmentResource method deleteVariablesSet.

@DELETE
@Path("/variables")
public Response deleteVariablesSet() {
    subjectAclService.checkPermission(getResourcePath(), "EDIT", id);
    DataAccessAmendment amendment = getService().findById(id);
    if (amendment.hasVariablesSet())
        variableSetService.delete(amendment.getVariablesSet());
    return Response.noContent().build();
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment)

Example 9 with DataAccessAmendment

use of org.obiba.mica.access.domain.DataAccessAmendment in project mica2 by obiba.

the class DataAccessAmendmentResource method setVariablesSet.

@PUT
@Path("/variables")
public Response setVariablesSet() {
    subjectAclService.checkPermission(getResourcePath(), "EDIT", id);
    DataAccessAmendment amendment = getService().findById(id);
    amendment.setVariablesSet(createOrUpdateVariablesSet(amendment));
    dataAccessAmendmentService.save(amendment);
    return Response.noContent().build();
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment)

Example 10 with DataAccessAmendment

use of org.obiba.mica.access.domain.DataAccessAmendment in project mica2 by obiba.

the class DataAccessAmendmentResource method getAmendment.

@GET
@Timed
public Mica.DataAccessRequestDto getAmendment() {
    subjectAclService.checkPermission(getParentResourcePath(), "VIEW", parentId);
    DataAccessAmendment amendment = dataAccessAmendmentService.findById(id);
    return dtos.asAmendmentDto(amendment);
}
Also used : DataAccessAmendment(org.obiba.mica.access.domain.DataAccessAmendment) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

DataAccessAmendment (org.obiba.mica.access.domain.DataAccessAmendment)10 DataAccessRequest (org.obiba.mica.access.domain.DataAccessRequest)3 Timed (com.codahale.metrics.annotation.Timed)2 DocumentContext (com.jayway.jsonpath.DocumentContext)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Subscribe (com.google.common.eventbus.Subscribe)1 DataAccessEntityStatus (org.obiba.mica.access.domain.DataAccessEntityStatus)1 DataAccessAmendmentUpdatedEvent (org.obiba.mica.access.event.DataAccessAmendmentUpdatedEvent)1 Async (org.springframework.scheduling.annotation.Async)1