Search in sources :

Example 71 with Schema

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();
}
Also used : StringWriter(java.io.StringWriter) MolgenisWebservice.getSchema(org.molgenis.emx2.web.MolgenisWebservice.getSchema) Schema(org.molgenis.emx2.Schema) PrintWriter(java.io.PrintWriter)

Example 72 with Schema

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;
}
Also used : Schema(org.molgenis.emx2.Schema) MolgenisWebservice.getSchema(org.molgenis.emx2.web.MolgenisWebservice.getSchema) NotNull(org.jetbrains.annotations.NotNull)

Example 73 with Schema

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";
    }
}
Also used : Path(java.nio.file.Path) MolgenisWebservice.getSchema(org.molgenis.emx2.web.MolgenisWebservice.getSchema) Schema(org.molgenis.emx2.Schema) OutputStream(java.io.OutputStream)

Example 74 with Schema

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"));
}
Also used : Schema(org.molgenis.emx2.Schema) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 75 with Schema

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}}}"));
}
Also used : Schema(org.molgenis.emx2.Schema) PetStoreLoader(org.molgenis.emx2.datamodels.PetStoreLoader) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)57 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 AbstractMessage (com.google.protobuf.AbstractMessage)16 ByteString (com.google.protobuf.ByteString)16 QName (javax.xml.namespace.QName)16 File (java.io.File)15 URL (java.net.URL)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)14 ProjectName (com.google.pubsub.v1.ProjectName)14 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)14 IOException (java.io.IOException)13 StringWriter (java.io.StringWriter)13 Schema (org.oasisopen.odata.csdl.v4.Schema)13 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 JAXBElement (javax.xml.bind.JAXBElement)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 List (java.util.List)8