Skip to content
Snippets Groups Projects
Commit bf153f0e authored by Sabine Schröder's avatar Sabine Schröder
Browse files

#3,#25: updated revised data flags in controlled vocabulary; corrected API...

#3,#25: updated revised data flags in controlled vocabulary; corrected API access for controlled vocabulary
parent c988f699
No related branches found
No related tags found
2 merge requests!20@selke1: merging from testing to master; #3,#25: updated revised data flags in controlled vocabulary; corrected API...,!19#3,#25: updated revised data flags in controlled vocabulary; corrected API...
Pipeline #67359 passed
...@@ -291,9 +291,9 @@ ...@@ -291,9 +291,9 @@
[5, 'ResourceProvider', 'resource provider']] [5, 'ResourceProvider', 'resource provider']]
#### Role Status #### #### Role Status ####
* Role Status: [ * Role Status: [
[0, 'active', 'active'], [0, 'Active', 'active'],
[1, 'inactive', 'inactive'], [1, 'Inactive', 'inactive'],
[2, 'unknown', 'unknown']] [2, 'Unkown', 'unknown']]
#### Kind Of Annotation #### #### Kind Of Annotation ####
* Kind Of Annotation: [ * Kind Of Annotation: [
[0, 'User', 'user comment'], [0, 'User', 'user comment'],
...@@ -357,13 +357,6 @@ ...@@ -357,13 +357,6 @@
[10, 'TropicalWet', 'tropical wet'], [10, 'TropicalWet', 'tropical wet'],
[11, 'TropicalMoist', 'tropical moist'], [11, 'TropicalMoist', 'tropical moist'],
[12, 'TropicalDry', 'tropical dry']] [12, 'TropicalDry', 'tropical dry']]
#### Coordinate Validity ####
* Coordinate Validity: [
[0, 'NotChecked', 'not checked'],
[1, 'Verified', 'verified'],
[2, 'Plausible', 'plausible'],
[3, 'Doubtful', 'doubtful'],
[4, 'Unverifyable', 'not verifyable']]
#### Country Code #### #### Country Code ####
* Country Code: [ * Country Code: [
[-1, 'N/A', 'N/A'], [-1, 'N/A', 'N/A'],
...@@ -1212,6 +1205,13 @@ ...@@ -1212,6 +1205,13 @@
[590, 'W-SU', 'W-SU'], [590, 'W-SU', 'W-SU'],
[591, 'WET', 'WET'], [591, 'WET', 'WET'],
[592, 'Zulu', 'Zulu']] [592, 'Zulu', 'Zulu']]
#### Station Coordinate Validity ####
* Station Coordinate Validity: [
[0, 'NotChecked', 'not checked'],
[1, 'Verified', 'verified'],
[2, 'Plausible', 'plausible'],
[3, 'Doubtful', 'doubtful'],
[4, 'Unverifyable', 'not verifyable']]
#### Station Type #### #### Station Type ####
* Station Type: [ * Station Type: [
[0, 'Unknown', 'unknown'], [0, 'Unknown', 'unknown'],
...@@ -1286,18 +1286,23 @@ ...@@ -1286,18 +1286,23 @@
[4, 'OKPreliminaryQCPassed', 'OK preliminary QC passed'], [4, 'OKPreliminaryQCPassed', 'OK preliminary QC passed'],
[5, 'OKPreliminaryModified', 'OK preliminary modified'], [5, 'OKPreliminaryModified', 'OK preliminary modified'],
[6, 'OKEstimated', 'OK estimated'], [6, 'OKEstimated', 'OK estimated'],
[7, 'OKPreliminaryNotChecked', 'OK preliminary not checked'],
[10, 'QuestionnableValidatedConfirmed', 'questionnable validated confirmed'], [10, 'QuestionnableValidatedConfirmed', 'questionnable validated confirmed'],
[11, 'QuestionnableValidatedUnconfirmed', 'questionnable validated unconfirmed'], [11, 'QuestionnableValidatedUnconfirmed', 'questionnable validated unconfirmed'],
[12, 'QuestionnableValidatedFlagged', 'questionnable validated flagged'], [12, 'QuestionnableValidatedFlagged', 'questionnable validated flagged'],
[13, 'QuestionnablePreliminaryConfirmed', 'questionnable preliminary confirmed'], [13, 'QuestionnablePreliminaryConfirmed', 'questionnable preliminary confirmed'],
[14, 'QuestionnablePreliminaryUnconfirmed', 'questionnable preliminary unconfirmed'], [14, 'QuestionnablePreliminaryUnconfirmed', 'questionnable preliminary unconfirmed'],
[15, 'QuestionnablePreliminaryFlagged', 'questionnable preliminary flagged'], [15, 'QuestionnablePreliminaryFlagged', 'questionnable preliminary flagged'],
[16, 'QuestionnablePreliminaryNotChecked', 'questionnable preliminary not checked'],
[20, 'ErroneousValidatedConfirmed', 'erroneous validated confirmed'], [20, 'ErroneousValidatedConfirmed', 'erroneous validated confirmed'],
[21, 'ErroneousValidatedUnconfirmed', 'erroneous validated unconfirmed'], [21, 'ErroneousValidatedUnconfirmed', 'erroneous validated unconfirmed'],
[22, 'ErroneousValidatedFlagged', 'erroneous validated flagged'], [22, 'ErroneousValidatedFlagged1', 'erroneous validated flagged (1)'],
[23, 'ErroneousPreliminaryConfirmed', 'erroneous preliminary confirmed'], [23, 'ErroneousValidatedFlagged2', 'erroneous validated flagged (2)'],
[24, 'ErroneousPreliminaryUnconfirmed', 'erroneous preliminary unconfirmed'], [24, 'ErroneousPreliminaryConfirmed', 'erroneous preliminary confirmed'],
[25, 'ErroneousPreliminaryFlagged', 'erroneous preliminary flagged'], [25, 'ErroneousPreliminaryUnconfirmed', 'erroneous preliminary unconfirmed'],
[26, 'ErroneousPreliminaryFlagged1', 'erroneous preliminary flagged (1)'],
[27, 'ErroneousPreliminaryFlagged2', 'erroneous preliminary flagged (2)'],
[28, 'ErroneousPreliminaryNotChecked', 'erroneous preliminary not checked'],
[90, 'MissingValue', 'missing value'], [90, 'MissingValue', 'missing value'],
[91, 'UnknownQualityStatus', 'unknown quality status']] [91, 'UnknownQualityStatus', 'unknown quality status']]
#### Type Of Change #### #### Type Of Change ####
...@@ -1710,7 +1715,6 @@ Get Stationmeta ...@@ -1710,7 +1715,6 @@ Get Stationmeta
| Name | Located in | Description | Required | Schema | | Name | Located in | Description | Required | Schema |
| ---- | ---------- | ----------- | -------- | ---- | | ---- | ---------- | ----------- | -------- | ---- |
| station_code | path | | Yes | string | | station_code | path | | Yes | string |
| format | query | | No | string |
##### Responses ##### Responses
......
--
-- toardb/extension/toar_controlled_vocabulary/toar_controlled_vocabulary--0.5--0.6.sql
--
-- [Step to install]
--
-- 1.
--
-- INSTALL VERSION: '0.6'
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE/ALTER EXTENSION toar_controlled_vocabulary" to load this file. \quit
-- Update Data
-- ===========
-- Data Flags
-- still to do:
-- How to set convoc_schema to result from SELECT:
-- SELECT table_schema INTO convoc_schema FROM information_schema.tables WHERE table_name='df_vocabulary';
SET SCHEMA 'toar_convoc';
INSERT INTO df_vocabulary (enum_val, enum_str, enum_display_str) VALUES
( 7, 'OKPreliminaryNotChecked', 'OK preliminary not checked'),
(16, 'QuestionnablePreliminaryNotChecked', 'questionnable preliminary not checked'),
(26, 'ErroneousPreliminaryFlagged1', 'erroneous preliminary flagged (1)'),
(27, 'ErroneousPreliminaryFlagged2', 'erroneous preliminary flagged (2)'),
(28, 'ErroneousPreliminaryNotChecked', 'erroneous preliminary not checked');
UPDATE df_vocabulary SET (enum_val, enum_str, enum_display_str) = (22, 'ErroneousValidatedFlagged1', 'erroneous validated flagged (1)') WHERE enum_val=22;
UPDATE df_vocabulary SET (enum_val, enum_str, enum_display_str) = (23, 'ErroneousValidatedFlagged2', 'erroneous validated flagged (2)') WHERE enum_val=23;
UPDATE df_vocabulary SET (enum_val, enum_str, enum_display_str) = (24, 'ErroneousPreliminaryConfirmed', 'erroneous preliminary confirmed') WHERE enum_val=24;
UPDATE df_vocabulary SET (enum_val, enum_str, enum_display_str) = (25, 'ErroneousPreliminaryUnconfirmed', 'erroneous preliminary unconfirmed') WHERE enum_val=25;
-- Roles
-- =====
-- Role Status
UPDATE rs_vocabulary SET enum_str = 'Active' WHERE enum_val=0;
UPDATE rs_vocabulary SET enum_str = 'Inactive' WHERE enum_val=1;
UPDATE rs_vocabulary SET enum_str = 'Unkown' WHERE enum_val=2;
This diff is collapsed.
# toar_controlled_vocabulary extension # toar_controlled_vocabulary extension
comment = 'TOAR controlled vocabulary' comment = 'TOAR controlled vocabulary'
default_version = '0.5' default_version = '0.6'
module_pathname = '$libdir/toar_controlled_vocabulary-0.5' module_pathname = '$libdir/toar_controlled_vocabulary-0.6'
relocatable = false relocatable = false
...@@ -54,54 +54,54 @@ async def read_onto(): ...@@ -54,54 +54,54 @@ async def read_onto():
@app.get("/controlled_vocabulary/") @app.get("/controlled_vocabulary/")
async def info(): async def info():
controlled_vocabulary = { controlled_vocabulary = {
"Role Code": settings.RC_vocab, "Role Code": RC_vocabulary,
"Role Status": settings.RS_vocab, "Role Status": RS_vocabulary,
"Kind Of Annotation": settings.AK_vocab, "Kind Of Annotation": AK_vocabulary,
"Kind Of Organization": settings.OK_vocab, "Kind Of Organization": OK_vocabulary,
"Data Access Right": settings.DA_vocab, "Data Access Right": DA_vocabulary,
"Sampling Frequency": settings.SF_vocab, "Sampling Frequency": SF_vocabulary,
"Aggregation Type": settings.AT_vocab, "Aggregation Type": AT_vocabulary,
"Data Source": settings.DS_vocab, "Data Source": DS_vocabulary,
"Measurement Method": settings.MM_vocab, "Measurement Method": MM_vocabulary,
"Climatic Zone": settings.CZ_vocab, "Climatic Zone": CZ_vocabulary,
"Coordinate Validity": settings.CV_vocab, "Country Code": CN_vocabulary,
"Country Code": settings.CN_vocab, "Timezone": TZ_vocabulary,
"Timezone": settings.TZ_vocab, "Station Coordinate Validity": CV_vocabulary,
"Station Type": settings.ST_vocab, "Station Type": ST_vocabulary,
"Station Type Of Area": settings.TA_vocab, "Station Type Of Area": TA_vocabulary,
"Station TOAR Category": settings.TC_vocab, "Station TOAR Category": TC_vocabulary,
"Station HTAP Region": settings.TR_vocab, "Station HTAP Region": TR_vocabulary,
"Station Dominant Landcover Type": settings.DL_vocab, "Station Dominant Landcover Type": DL_vocabulary,
"Result Type": settings.RT_vocab, "Result Type": RT_vocabulary,
"Data Flag": settings.DF_vocab, "Data Flag": DF_vocabulary,
"Type Of Change": settings.CL_vocab, "Type Of Change": CL_vocabulary,
} }
return controlled_vocabulary return controlled_vocabulary
@app.get("/controlled_vocabulary/{name}") @app.get("/controlled_vocabulary/{name}")
async def info(name: str): async def info(name: str):
controlled_vocabulary = { controlled_vocabulary = {
"role code": settings.RC_vocab, "role code": RC_vocabulary,
"role status": settings.RS_vocab, "role status": RS_vocabulary,
"kind of annotation": settings.AK_vocab, "kind of annotation": AK_vocabulary,
"kind of organization": settings.OK_vocab, "kind of organization": OK_vocabulary,
"data access right": settings.DA_vocab, "data access right": DA_vocabulary,
"sampling frequency": settings.SF_vocab, "sampling frequency": SF_vocabulary,
"aggregation type": settings.AT_vocab, "aggregation type": AT_vocabulary,
"data source": settings.DS_vocab, "data source": DS_vocabulary,
"measurement method": settings.MM_vocab, "measurement method": MM_vocabulary,
"climatic zone": settings.CZ_vocab, "climatic zone": CZ_vocabulary,
"coordinate validity": settings.CV_vocab, "coordinate validity": CV_vocabulary,
"country code": settings.CN_vocab, "country code": CN_vocabulary,
"timezone": settings.TZ_vocab, "timezone": TZ_vocabulary,
"station type": settings.ST_vocab, "station type": ST_vocabulary,
"station type of area": settings.TA_vocab, "station type of area": TA_vocabulary,
"station toar category": settings.TC_vocab, "station toar category": TC_vocabulary,
"station htap region": settings.TR_vocab, "station htap region": TR_vocabulary,
"station dominant landcover type": settings.DL_vocab, "station dominant landcover type": DL_vocabulary,
"result type": settings.RT_vocab, "result type": RT_vocabulary,
"data flag": settings.DF_vocab, "data flag": DF_vocabulary,
"type of change": settings.CL_vocab, "type of change": CL_vocabulary,
} }
if name.lower() in controlled_vocabulary.keys(): if name.lower() in controlled_vocabulary.keys():
return controlled_vocabulary[name.lower()] return controlled_vocabulary[name.lower()]
...@@ -152,14 +152,8 @@ def __get_enum_dict(fake_cur, table_name): ...@@ -152,14 +152,8 @@ def __get_enum_dict(fake_cur, table_name):
# will be executed before application *starts* # will be executed before application *starts*
# ==> again: at this point no database connection available! # ==> again: at this point no database connection available!
# (and also all tables are unknown) # (and also all tables are unknown)
# how can I do pytests with this?!?!
# ==> https://fastapi.tiangolo.com/advanced/testing-events/
# I did not try yet, if test database is created before
# startup_event or after (for the letter, the hint in the link
# will not work)
async def startup_event(): async def startup_event():
fake_conn = engine.raw_connection()
fake_cur = fake_conn.cursor()
global RC_vocabulary global RC_vocabulary
global RS_vocabulary global RS_vocabulary
global AK_vocabulary global AK_vocabulary
...@@ -182,6 +176,8 @@ async def startup_event(): ...@@ -182,6 +176,8 @@ async def startup_event():
global DF_vocabulary global DF_vocabulary
global CL_vocabulary global CL_vocabulary
fake_conn = engine.raw_connection()
fake_cur = fake_conn.cursor()
RC_vocabulary = __get_enum_dict(fake_cur, "rc_vocabulary") RC_vocabulary = __get_enum_dict(fake_cur, "rc_vocabulary")
RS_vocabulary = __get_enum_dict(fake_cur, "rs_vocabulary") RS_vocabulary = __get_enum_dict(fake_cur, "rs_vocabulary")
AK_vocabulary = __get_enum_dict(fake_cur, "ak_vocabulary") AK_vocabulary = __get_enum_dict(fake_cur, "ak_vocabulary")
...@@ -204,29 +200,3 @@ async def startup_event(): ...@@ -204,29 +200,3 @@ async def startup_event():
DF_vocabulary = __get_enum_dict(fake_cur, "df_vocabulary") DF_vocabulary = __get_enum_dict(fake_cur, "df_vocabulary")
CL_vocabulary = __get_enum_dict(fake_cur, "cl_vocabulary") CL_vocabulary = __get_enum_dict(fake_cur, "cl_vocabulary")
class Settings(BaseSettings):
RC_vocab = RC_vocabulary
RS_vocab = RS_vocabulary
AK_vocab = AK_vocabulary
OK_vocab = OK_vocabulary
DA_vocab = DA_vocabulary
SF_vocab = SF_vocabulary
AT_vocab = AT_vocabulary
DS_vocab = DS_vocabulary
MM_vocab = MM_vocabulary
CZ_vocab = CZ_vocabulary
CV_vocab = CV_vocabulary
CN_vocab = CN_vocabulary
TZ_vocab = TZ_vocabulary
ST_vocab = ST_vocabulary
TA_vocab = TA_vocabulary
TC_vocab = TC_vocabulary
TR_vocab = TR_vocabulary
DL_vocab = DL_vocabulary
RT_vocab = RT_vocabulary
DF_vocab = DF_vocabulary
CL_vocab = CL_vocabulary
settings = Settings()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment