diff --git a/datastore/protobuf/datastore.proto b/datastore/protobuf/datastore.proto index 98ab8e7..eb920dc 100644 --- a/datastore/protobuf/datastore.proto +++ b/datastore/protobuf/datastore.proto @@ -72,37 +72,38 @@ message Link { } message TSMetadata { - // --- BEGIN metadata of type 'single string' ----------------- - string version = 1; - string type = 2; - string title = 3; - string summary = 4; - string keywords = 5; - string keywords_vocabulary = 6 [json_name = "keywords_vocabulary"]; - string license = 7; - string conventions = 8; - string naming_authority = 9 [json_name = "naming_authority"]; - string creator_type = 10 [json_name = "creator_type"]; - string creator_name = 11 [json_name = "creator_name"]; - string creator_email = 12 [json_name = "creator_email"]; - string creator_url = 13 [json_name = "creator_url"]; - string institution = 14; - string project = 15; - string source = 16; - string platform = 17; - string platform_vocabulary = 18 [json_name = "platform_vocabulary"]; - string standard_name = 19 [json_name = "standard_name"]; - string unit = 20; - string instrument = 21; - string instrument_vocabulary = 22 [json_name = "instrument_vocabulary"]; - // --- END metadata of type 'single string' ----------------- - - // --- BEGIN metadata of other type ----------------- - repeated Link links = 23; - // --- END metadata of other type ----------------- + // --- BEGIN non-string metadata ----------------- + repeated Link links = 1; + // --- END non-string metadata ----------------- + + // --- BEGIN string metadata ----------------- + string version = 2; + string type = 3; + string title = 4; + string summary = 5; + string keywords = 6; + string keywords_vocabulary = 7 [json_name = "keywords_vocabulary"]; + string license = 8; + string conventions = 9; + string naming_authority = 10 [json_name = "naming_authority"]; + string creator_type = 101 [json_name = "creator_type"]; + string creator_name = 12 [json_name = "creator_name"]; + string creator_email = 13 [json_name = "creator_email"]; + string creator_url = 14 [json_name = "creator_url"]; + string institution = 15; + string project = 16; + string source = 17; + string platform = 18; + string platform_vocabulary = 19 [json_name = "platform_vocabulary"]; + string standard_name = 20 [json_name = "standard_name"]; + string unit = 21; + string instrument = 22; + string instrument_vocabulary = 23 [json_name = "instrument_vocabulary"]; + // --- END string metadata ----------------- } message ObsMetadata { + // --- BEGIN non-string metadata ----------------- oneof geometry { Point geo_point = 1 [json_name = "geo_point"]; Polygon geo_polygon = 2 [json_name = "geo_polygon"]; @@ -112,16 +113,17 @@ message ObsMetadata { //TimeInterval obstime_interval = 4 [json_name = "obstime_interval"]; -- unsupported for now } google.protobuf.Timestamp pubtime = 5; + // --- END non-string metadata ----------------- - // --- BEGIN metadata of type 'single string' ----------------- + // --- BEGIN string metadata ----------------- string id = 6; string data_id = 7 [json_name = "data_id"]; string history = 8; string metadata_id = 9 [json_name = "metadata_id"]; string processing_level = 10 [json_name = "processing_level"]; - // --- END metadata of type 'single string' ----------------- + // --- END string metadata ----------------- - string value = 11; // obs value + string value = 11; // obs value (not metadata in a strict sense) } //--------------------------------------------------------------------------- diff --git a/datastore/storagebackend/postgresql/postgresql.go b/datastore/storagebackend/postgresql/postgresql.go index 4b7bdb5..78f1049 100644 --- a/datastore/storagebackend/postgresql/postgresql.go +++ b/datastore/storagebackend/postgresql/postgresql.go @@ -94,13 +94,15 @@ func NewPostgreSQL() (*PostgreSQL, error) { func getTSMdataCols() []string { // ### TODO: modify to use reflection instead of explicit field referrals return []string{ - // links section (aka. non-string metadata ...) + // --- BEGIN non-string metadata --------------------------- "link_href", "link_rel", "link_type", "link_hreflang", "link_title", - // main section (aka. string metadata ...) + // --- END non-string metadata --------------------------- + + // --- BEGIN string metadata --------------------------- "version", "type", "title", @@ -123,6 +125,7 @@ func getTSMdataCols() []string { "unit", "instrument", "instrument_vocabulary", + // --- END string metadata --------------------------- } } diff --git a/datastore/storagebackend/postgresql/putobservations.go b/datastore/storagebackend/postgresql/putobservations.go index 474c315..8225a11 100644 --- a/datastore/storagebackend/postgresql/putobservations.go +++ b/datastore/storagebackend/postgresql/putobservations.go @@ -44,7 +44,7 @@ func getTSColVals(tsMdata *datastore.TSMetadata) ([]interface{}, error) { colVals := []interface{}{} - // links section (aka. non-string metadata ...) + // --- BEGIN non-string metadata --------------------------- getLinkVals := func(key string) ([]string, error) { linkVals := []string{} @@ -77,7 +77,9 @@ func getTSColVals(tsMdata *datastore.TSMetadata) ([]interface{}, error) { } } - // main section (aka. string metadata ...) + // --- END non-string metadata --------------------------- + + // --- BEGIN string metadata --------------------------- // ### TODO: modify to use reflection instead of explicit field referrals @@ -106,6 +108,8 @@ func getTSColVals(tsMdata *datastore.TSMetadata) ([]interface{}, error) { tsMdata.GetInstrumentVocabulary(), }...) + // --- END string metadata --------------------------- + return colVals, nil } diff --git a/datastore/ts-init.sql b/datastore/ts-init.sql index 68f3cb6..063ce61 100644 --- a/datastore/ts-init.sql +++ b/datastore/ts-init.sql @@ -5,7 +5,15 @@ CREATE TABLE time_series ( -- --- BEGIN metadata fields that usually don't vary with obs time --- - -- --- BEGIN metadata of type 'single string' ----------------- + -- --- BEGIN non-string metadata ----------------- + link_href TEXT[], + link_rel TEXT[], + link_type TEXT[], + link_hreflang TEXT[], + link_title TEXT[], + -- --- END non-string metadata ----------------- + + -- --- BEGIN string metadata ----------------- version TEXT NOT NULL, -- required type TEXT NOT NULL, -- required title TEXT, @@ -28,15 +36,8 @@ CREATE TABLE time_series ( unit TEXT, instrument TEXT NOT NULL, instrument_vocabulary TEXT NOT NULL, - -- --- END metadata of type 'single string' ----------------- + -- --- END string metadata ----------------- - -- --- BEGIN metadata of other type ----------------- - link_href TEXT[], - link_rel TEXT[], - link_type TEXT[], - link_hreflang TEXT[], - link_title TEXT[], - -- --- END metadata of other type ----------------- -- --- END metadata fields that usually don't vary with obs time --- CONSTRAINT unique_main UNIQUE NULLS NOT DISTINCT (version, type, title, summary, keywords,