Search in sources :

Example 81 with Schema

use of com.google.pubsub.v1.Schema in project ets-ogcapi-edr10 by opengeospatial.

the class CollectionsTime method coordsParameterDefinition.

/**
 * <pre>
 * Abstract Test 38: Validate that the coords query parameters are constructed correctly. (position)
 * Abstract Test 54: Validate that the coords query parameters are constructed correctly. (area)
 * Abstract Test 70: Validate that the coords query parameters are constructed correctly. (cube)
 * Abstract Test 92: Validate that the coords query parameters are constructed correctly. (trajectory)
 * Abstract Test 116: Validate that the coords query parameters are constructed correctly. (corridor)
 * </pre>
 *
 * @param testPoint the testPoint under test, never <code>null</code>
 * @param model api definition, never <code>null</code>
 */
public void coordsParameterDefinition(TestPoint testPoint, OpenApi3 model) {
    Parameter coords = null;
    String paramName = "coords";
    boolean hasCoordsParameter = false;
    for (Path path : model.getPaths().values()) {
        if (path.getPathString().endsWith(testPoint.getPath())) {
            for (Operation op : path.getOperations().values()) {
                for (Parameter param : op.getParameters()) {
                    if (hasName(param)) {
                        if (param.getName().equals(paramName)) {
                            coords = param;
                        }
                    }
                }
            }
        }
    }
    if (!testPoint.getPath().endsWith("/locations")) {
        assertNotNull(coords, "Required " + paramName + " parameter for collections with path '" + testPoint.getPath() + "'  in OpenAPI document is missing");
        if (coords != null) {
            String msg = "Expected property '%s' with value '%s' but was '%s'";
            assertEquals(coords.getName(), paramName, String.format(msg, "name", paramName, coords.getName()));
            assertEquals(coords.getIn(), "query", String.format(msg, "in", "query", coords.getIn()));
            assertTrue(isRequired(coords), String.format(msg, "required", "true", coords.getRequired()));
            // assertEquals( coords.getStyle(), "form", String.format( msg, "style","form",
            // coords.getStyle() ) ); //TODO SHOULD BE Enabled
            assertFalse(isExplode(coords), String.format(msg, "explode", "false", coords.getExplode()));
            Schema schema = coords.getSchema();
            assertEquals(schema.getType(), "string", String.format(msg, "schema -> type", "string", schema.getType()));
        }
    }
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) Schema(com.reprezen.kaizen.oasparser.model3.Schema) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) Operation(com.reprezen.kaizen.oasparser.model3.Operation)

Example 82 with Schema

use of com.google.pubsub.v1.Schema in project molgenis-emx2 by molgenis.

the class ZipApi method getZip.

static String getZip(Request request, Response response) throws IOException {
    Path tempDir = Files.createTempDirectory(MolgenisWebservice.TEMPFILES_DELETE_ON_EXIT);
    tempDir.toFile().deleteOnExit();
    try (OutputStream outputStream = response.raw().getOutputStream()) {
        Schema schema = getSchema(request);
        Path zipFile = tempDir.resolve("download.zip");
        MolgenisIO.toZipFile(zipFile, schema);
        outputStream.write(Files.readAllBytes(zipFile));
        response.type("application/zip");
        response.header("Content-Disposition", "attachment; filename=" + schema.getMetadata().getName() + System.currentTimeMillis() + ".zip");
        return "Export success";
    } finally {
        try (Stream<Path> files = Files.walk(tempDir)) {
            files.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
        }
    }
}
Also used : Path(java.nio.file.Path) OutputStream(java.io.OutputStream) MolgenisWebservice.getSchema(org.molgenis.emx2.web.MolgenisWebservice.getSchema) Schema(org.molgenis.emx2.Schema) File(java.io.File)

Example 83 with Schema

use of com.google.pubsub.v1.Schema in project molgenis-emx2 by molgenis.

the class CatalogueSiteMap method getResourcePids.

private List<String> getResourcePids(Schema schema, String resourceName) {
    Table table = schema.getTable(resourceName);
    if (table == null) {
        return Collections.emptyList();
    }
    List<Row> rows = table.select(s("pid")).retrieveRows();
    return rows.stream().map(row -> row.getString("pid")).toList();
}
Also used : Arrays(java.util.Arrays) Logger(org.slf4j.Logger) MalformedURLException(java.net.MalformedURLException) MolgenisException(org.molgenis.emx2.MolgenisException) LoggerFactory(org.slf4j.LoggerFactory) SelectColumn.s(org.molgenis.emx2.SelectColumn.s) List(java.util.List) Table(org.molgenis.emx2.Table) WebSitemapUrl(com.redfin.sitemapgenerator.WebSitemapUrl) Schema(org.molgenis.emx2.Schema) Collections(java.util.Collections) Row(org.molgenis.emx2.Row) WebSitemapGenerator(com.redfin.sitemapgenerator.WebSitemapGenerator) Table(org.molgenis.emx2.Table) Row(org.molgenis.emx2.Row)

Example 84 with Schema

use of com.google.pubsub.v1.Schema in project molgenis-emx2 by molgenis.

the class LinkedDataFragmentsApi method jsonld.

private static String jsonld(Request request, Response response) {
    Schema schema = getSchema(request);
    StringWriter sw = new StringWriter();
    LinkedDataService.getJsonLdForSchema(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 85 with Schema

use of com.google.pubsub.v1.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)

Aggregations

Test (org.junit.Test)65 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 ByteString (com.google.protobuf.ByteString)19 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)18 AbstractMessage (com.google.protobuf.AbstractMessage)18 QName (javax.xml.namespace.QName)16 SchemaName (com.google.pubsub.v1.SchemaName)15 File (java.io.File)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 ProjectName (com.google.pubsub.v1.ProjectName)14 IOException (java.io.IOException)14 URL (java.net.URL)14 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)14 StringWriter (java.io.StringWriter)13 Schema (org.oasisopen.odata.csdl.v4.Schema)13 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)12 StatusRuntimeException (io.grpc.StatusRuntimeException)12 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 JAXBElement (javax.xml.bind.JAXBElement)10