use of com.fasterxml.jackson.dataformat.csv.CsvGenerator in project dhis2-core by dhis2.
the class SystemController method getUidCsv.
@GetMapping(value = { "/uid", "/id" }, produces = "application/csv")
public void getUidCsv(@RequestParam(required = false, defaultValue = "1") Integer limit, HttpServletResponse response) throws IOException {
CodeList codeList = generateCodeList(Math.min(limit, 10000), CodeGenerator::generateUid);
CsvSchema schema = CsvSchema.builder().addColumn("uid").setUseHeader(true).build();
CsvGenerator csvGenerator = CSV_FACTORY.createGenerator(response.getOutputStream());
csvGenerator.setSchema(schema);
for (String code : codeList.getCodes()) {
csvGenerator.writeStartObject();
csvGenerator.writeStringField("uid", code);
csvGenerator.writeEndObject();
}
csvGenerator.flush();
}
Aggregations