Search in sources :

Example 26 with Schema

use of com.google.pubsub.v1.Schema in project divolte-collector by divolte.

the class GoogleCloudPubSubFlusherTest method testMessagesHaveSchemaFingerprint.

@Test
public void testMessagesHaveSchemaFingerprint() {
    processSingleMessage();
    // Reminder: fingerprint is the SHA-256 hash of the normalized schema,
    // base-64 encoded using the URL-safe encoding,
    // with trailing padding stripped.
    final String expectedFingerPrint = BaseEncoding.base64Url().encode(Hashing.sha256().hashString(SchemaNormalization.toParsingForm(MINIMAL_SCHEMA), StandardCharsets.UTF_8).asBytes()).replace("=", "");
    final PubsubMessage deliveredMessage = getFirstPublishedMessage();
    assertEquals(expectedFingerPrint, deliveredMessage.getAttributesOrThrow("schemaFingerprint"));
}
Also used : ByteString(com.google.protobuf.ByteString) PubsubMessage(com.google.pubsub.v1.PubsubMessage) Test(org.junit.Test)

Example 27 with Schema

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

the class OpenApiUtils method collectTemplateReplacements.

private static List<Map<String, String>> collectTemplateReplacements(PathItemAndServer pathItemAndServer, UriTemplate uriTemplate) {
    List<Map<String, String>> templateReplacements = new ArrayList<>();
    Collection<Parameter> parameters = pathItemAndServer.operationObject.getParameters();
    for (String templateVariable : uriTemplate.getTemplateVariables()) {
        for (Parameter parameter : parameters) {
            if (templateVariable.equals(parameter.getName())) {
                Schema schema = parameter.getSchema();
                if (schema.hasEnums()) {
                    addEnumTemplateValues(templateReplacements, templateVariable, schema);
                } else if (schema.getDefault() != null) {
                    addDefaultTemplateValue(templateReplacements, templateVariable, schema);
                } else {
                // TODO: What should be done if the parameter does not have a default value and
                // no
                // enumerated set of valid values?
                }
            }
        }
    }
    return templateReplacements;
}
Also used : Schema(com.reprezen.kaizen.oasparser.model3.Schema) ArrayList(java.util.ArrayList) Parameter(com.reprezen.kaizen.oasparser.model3.Parameter) HashMap(java.util.HashMap) Map(java.util.Map)

Example 28 with Schema

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

the class DataCatalogueLoader method load.

@Override
public void load(Schema schema, boolean includeDemoData) {
    // create ontology schema
    Database db = schema.getDatabase();
    Schema ontologySchema = db.getSchema(CATALOGUE_ONTOLOGIES);
    if (ontologySchema == null) {
        ontologySchema = db.createSchema(CATALOGUE_ONTOLOGIES);
    }
    // create catalogue schema (which will create tables in ontology schema)
    createSchema(schema, "datacatalogue/molgenis.csv");
    // load data into ontology schema
    MolgenisIO.fromClasspathDirectory("datacatalogue/CatalogueOntologies", ontologySchema, false);
    // optionally, load demo data
    if (includeDemoData) {
        MolgenisIO.fromClasspathDirectory("datacatalogue/Cohorts", schema, false);
    }
}
Also used : Schema(org.molgenis.emx2.Schema) Database(org.molgenis.emx2.Database)

Example 29 with Schema

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

the class DataCatalogueStagingLoader method load.

@Override
public void load(Schema schema, boolean includeDemoData) {
    // create ontology schema
    Database db = schema.getDatabase();
    Schema ontologySchema = db.getSchema(CATALOGUE_ONTOLOGIES);
    if (ontologySchema == null) {
        ontologySchema = db.createSchema(CATALOGUE_ONTOLOGIES);
    }
    // create the schema
    createSchema(schema, "datacatalogue/Catalogue_cdm/molgenis.csv");
    // load data into ontology schema
    MolgenisIO.fromClasspathDirectory("datacatalogue/CatalogueOntologies", ontologySchema, false);
}
Also used : Schema(org.molgenis.emx2.Schema) Database(org.molgenis.emx2.Database)

Example 30 with Schema

use of com.google.pubsub.v1.Schema in project geo-platform by geosdi.

the class WFSDescribeFeatureTest method c_describeSiteTrTest.

@Ignore(value = "Geoserver is Down")
@Test
public void c_describeSiteTrTest() throws Exception {
    WFSDescribeFeatureTypeRequest<Schema> request = newConnector().withServerUrl(new URL("http://150.145.141.241/geoserver/wfs")).build().createDescribeFeatureTypeRequest();
    String localPart = siteTRCom.getLocalPart();
    request.setTypeName(Arrays.asList(siteTRCom));
    logger.debug("#########################SCHEMA_AS_STRING : \n{}\n", request.formatResponseAsString(2));
    Schema s = request.getResponse();
    String name = localPart.substring(localPart.indexOf(":") + 1);
    StringWriter writer = new StringWriter();
    gpJAXBContextBuilder.marshal(schemaReader.getFeature(s, name), writer);
    logger.info("######################LAYER_SCHEMA_SITE_COM_XML : \n{}\n", writer);
}
Also used : StringWriter(java.io.StringWriter) Schema(org.geosdi.geoplatform.xml.xsd.v2001.Schema) URL(java.net.URL) Ignore(org.junit.Ignore) Test(org.junit.Test)

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