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(""));
});
}
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));
}
}
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();
}
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();
}
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);
}
Aggregations