use of org.hisp.dhis.webapi.webdomain.CodeList in project dhis2-core by dhis2.
the class SystemController method getUuid.
@GetMapping(value = "/uuid", produces = { APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ResponseBody
public CodeList getUuid(@RequestParam(required = false, defaultValue = "1") Integer limit, HttpServletResponse response) {
CodeList codeList = generateCodeList(Math.min(limit, 10000), () -> UUID.randomUUID().toString());
setNoStore(response);
return codeList;
}
use of org.hisp.dhis.webapi.webdomain.CodeList 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