use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class LinkedDataFragmentsApi method ttl.
private static String ttl(Request request, Response response) {
Schema schema = getSchema(request);
StringWriter sw = new StringWriter();
LinkedDataService.getTtlForSchema(schema, new PrintWriter(sw));
return sw.getBuffer().toString();
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class BootstrapThemeService method getParams.
@NotNull
private static Map<String, String> getParams(Request request) {
Schema schema = getSchema(request);
Map<String, String> params = new LinkedHashMap<>();
if (schema != null) {
String cssUrl = schema.getMetadata().getSetting("cssURL");
if (cssUrl != null) {
params.putAll(splitQuery(cssUrl.split("\\?")[1]));
}
}
return params;
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class ExcelApi method getExcel.
static String getExcel(Request request, Response response) throws IOException {
Schema schema = getSchema(request);
Path tempDir = Files.createTempDirectory(MolgenisWebservice.TEMPFILES_DELETE_ON_EXIT);
tempDir.toFile().deleteOnExit();
try (OutputStream outputStream = response.raw().getOutputStream()) {
Path excelFile = tempDir.resolve("download.xlsx");
if (request.queryParams("emx1") != null) {
MolgenisIO.toEmx1ExcelFile(excelFile, schema);
} else {
MolgenisIO.toExcelFile(excelFile, schema);
}
response.type("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.header("Content-Disposition", "attachment; filename=" + schema.getMetadata().getName() + System.currentTimeMillis() + ".xlsx");
outputStream.write(Files.readAllBytes(excelFile));
return "Export success";
}
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class TestQueryJsonGraph method testGroupBy.
// todo @Test
// we want to refactor this
public void testGroupBy() throws JsonProcessingException {
Schema schema = db.dropCreateSchema(TestQueryJsonGraph.class.getSimpleName() + "_testGroupBy");
schema.create(table("Test", column("id").setPkey(), column("tag"), column("tag_array").setType(STRING_ARRAY), column("tag_array2").setType(STRING_ARRAY)));
schema.getTable("Test").insert(row("id", 1, "tag", "blue", "tag_array", new String[] { "blue", "green" }, "tag_array2", new String[] { "yellow", "red" }), row("id", 2, "tag", "blue", "tag_array", new String[] { "green", "blue" }, "tag_array2", new String[] { "yellow", "red" }), row("id", 3, "tag", "green", "tag_array", new String[] { "blue" }, "tag_array2", new String[] { "yellow", "red" }));
ObjectMapper mapper = new ObjectMapper();
Map<String, Map<String, List<Map<String, Object>>>> result = mapper.readValue(schema.agg("Test").select(s("groupBy", s("count"), s("tag"))).retrieveJSON(), Map.class);
assertEquals(2, result.get("Test_agg").get("groupBy").get(1).get("count"));
result = mapper.readValue(schema.agg("Test").select(s("groupBy", s("count"), s("tag_array"))).retrieveJSON(), Map.class);
assertEquals(2, result.get("Test_agg").get("groupBy").get(0).get("count"));
result = mapper.readValue(schema.agg("Test").select(s("groupBy", s("count"), s("tag_array"), s("tag_array2"))).retrieveJSON(), Map.class);
assertEquals(3, result.get("Test_agg").get("groupBy").get(0).get("count"));
}
use of com.reprezen.kaizen.oasparser.model3.Schema in project molgenis-emx2 by molgenis.
the class TestQueryJsonGraph method testAgg.
@Test
public void testAgg() {
Schema schema = db.dropCreateSchema(TestQueryJsonGraph.class.getSimpleName() + "_testAgg");
new PetStoreLoader().load(schema, true);
String json = schema.query("Order_agg", s("max", s("quantity"))).retrieveJSON();
assertTrue(json.contains("{\"Order_agg\": {\"max\": {\"quantity\": 7}}}"));
}
Aggregations