Skip to content
Snippets Groups Projects
Commit 1fc02422 authored by Ulrich Loup's avatar Ulrich Loup
Browse files

Merge remote-tracking branch 'origin/main'

# Conflicts:
#	README.md
parents e7770ba6 8cafd6e6
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ pip install -r requirements.txt ...@@ -16,7 +16,7 @@ pip install -r requirements.txt
``` ```
## Run ## Run
``` ```
python odm_importer.py -h python odm2sms.py -h
``` ```
## Reference ## Reference
......
...@@ -20,12 +20,13 @@ ...@@ -20,12 +20,13 @@
[sms] [sms]
# URL of the sensor management system (SMS) # URL of the sensor management system (SMS)
url = "https://sms-dev.ibg3container.ibg.kfa-juelich.de" #url = "https://sms-dev.ibg3container.ibg.kfa-juelich.de"
#url = "https://sms-staging.ibg3container.ibg.kfa-juelich.de" url = "https://sms-staging.ibg3container.ibg.kfa-juelich.de"
#url = "https://ibg3sms.ibg.kfa-juelich.de" #url = "https://ibg3sms.ibg.kfa-juelich.de"
# API KEY for admin access # API KEY for admin access
#apikey = "5cccb692f961964eab336d5c850e3fd57d468d1331ecf24b97633ec23362b74a9ac160fb91a870aef22d642b3e1a6d952393ff6aa5c7fc59ce5ad798e6985532" #apikey = "5cccb692f961964eab336d5c850e3fd57d468d1331ecf24b97633ec23362b74a9ac160fb91a870aef22d642b3e1a6d952393ff6aa5c7fc59ce5ad798e6985532"
apikey = "a623c727ba165027636148fb988e4ade6fcf2f0a98a45ce48df253092d1375f63e25f7301120207b84bec7bb7f87040bd478e4da1cfb4486f6bf415f8c762c80" #apikey = "0099358493094275a535615f09a202ee53a277151ec74d3b5eb964451c7b3c2cd6f42f35ed0678857ff19fda7819644fb1d56796e4cdf5c5650cbdf5c5dcab97"
apikey = "685cb8073df1e6982d3e0ad07bf1191b251d8f491289b0bc20b4078e2699c0e42f1ed823742ca2c2f140e813f2968a2a3154f005d13be0cc7022c5fdf8b2eec1"
# default permission group with admin access # default permission group with admin access
default_permission_group_name = "Tereno : fzj-sms" default_permission_group_name = "Tereno : fzj-sms"
# contact for the configurations of there is no source in the Tereno data # contact for the configurations of there is no source in the Tereno data
...@@ -39,9 +40,11 @@ tsm_endpoint_name = "FZJ" ...@@ -39,9 +40,11 @@ tsm_endpoint_name = "FZJ"
# As given by odm.sqls.sites_clustering_sql, each configuration has exactly one project, i.e., the mapping also provides # As given by odm.sqls.sites_clustering_sql, each configuration has exactly one project, i.e., the mapping also provides
# the one "admin" cfg_permission_group for each configuration. # the one "admin" cfg_permission_group for each configuration.
project_to_permission_groups = """{ project_to_permission_groups = """{
"eifelrur": "Tereno : fzj-sms-eifelrur-admin", "eifelrur": "Tereno : fzj-sms",
"soilcan": "Tereno : fzj-sms-soilcan-admin", "soilcan": "Tereno : fzj-sms",
"eddy": "Tereno : fzj-sms-eifelrur-admin" "cosmicray": "Tereno : fzj-sms",
"wver": "Tereno : fzj-sms",
"eddy": "Tereno : fzj-sms"
}""" }"""
[cv] [cv]
...@@ -111,7 +114,7 @@ when upper(s.code) like 'SY_%' then 'Scheyern' ...@@ -111,7 +114,7 @@ when upper(s.code) like 'SY_%' then 'Scheyern'
--when substring(s.code from '[^_]_([BKYCDR]*)_') is not NULL then substring(s.code from '([^_]*_)') || 'Y' || substring(s.code from '(_[0-9]{1})') --when substring(s.code from '[^_]_([BKYCDR]*)_') is not NULL then substring(s.code from '([^_]*_)') || 'Y' || substring(s.code from '(_[0-9]{1})')
else NULL end as site_label_2, else NULL end as site_label_2,
case when upper(s.code) like 'DD_K%' then substring(s.code from '([^_]*_)') || 'Y_' || substring(s.code from '([0-9]{2}$)') case when upper(s.code) like 'DD_K%' then substring(s.code from '([^_]*_)') || 'Y_' || substring(s.code from '([0-9]{2}$)')
when substring(s.code from '[^_]_([BKYCDR]*)_') is not null then substring(s.code from '([^_]*_)') || 'Y' || substring(s.code from '(_[0-9]{2})') when substring(s.code from '(RO|WU|SE)_(BKY|Y)_') is not null then substring(s.code from '([^_]*_)') || 'Y' || substring(s.code from '(_[0-9]{2})')
else s.code end as configuration_label, else s.code end as configuration_label,
min(ts.schema_name) as project, min(ts.schema_name) as project,
json_agg(s.objectid) as platform_ids, json_agg(s.objectid) as platform_ids,
...@@ -122,7 +125,11 @@ inner join importandpublish.logger l on l.siteid = s.objectid and l.timestampto ...@@ -122,7 +125,11 @@ inner join importandpublish.logger l on l.siteid = s.objectid and l.timestampto
inner join importandpublish.tsm_schemas ts on ts.objectid = l.schemaid inner join importandpublish.tsm_schemas ts on ts.objectid = l.schemaid
where s.active = true where s.active = true
and exists (select 1 from importandpublish.sensorinstances i where i.siteid = s.objectid) and exists (select 1 from importandpublish.sensorinstances i where i.siteid = s.objectid)
and (s.code like 'WU%Y%' or s.code like 'SE%Y%' or s.code like 'WU_AW%' or s.code like 'RO_A%' or s.code like 'RO%Y%' or s.code like 'DD%01%' or s.code like 'DM%Y%' or s.code like 'SY%Y%02%') and (
l.code in ('SE4-V105-Data1MinI','BL1-V105-AlarmG','COMBILOG','cs125','SB-V105-Data1MinI','A80125','WU-V105-Data10MinH','C00127','SE1-V105-Data10MinH','SE1-V105-Data1MinI','DD-V105-Data1MinI','DD2-V105-Data10MinH','A80138','ST-V105-Data1MinI','ST-V105-Data10MinH','SFLX1-Probes','SFLX1-Weight','SE2-V105-Data10MinH','BL2-V105-AlarmG','A80124','D30015','SE2-V105-Data1MinI','SE2-V105-AlarmG','V2020-12-SYSTEM','SE4-V105-Data10MinH','RO-V105-Data10MinH','C00145','DM-V105-Data10MinH','RO-V105-AlarmG','WU-V105-Data1MinI','ST-V105-AlarmG','DM-V105-AlarmG','SE3-V105-Data10MinH','V2020-12-Data1MinI','SE3-V105-AlarmG','A70084','WU-V105-AlarmG','BL2-V105-Data10MinH','SE4-V105-AlarmG','RO-V105-Data1MinI','V2020-12-Data10MinH','A80105','Flowstation','A80131','SE3-V105-Data1MinI','BL1-V105-Data1MinI','BL3-V105-AlarmG','A80098','DD2-V105-AlarmG','SB-V105-AlarmG','SE1-V105-AlarmG','A80121','BL1-V105-Data10MinH','BL2-V105-Data1MinI','SB-V105-Data10MinH','DD2-V105-Data1MinI','BL3-V105-Data10MinH','DD-V105-AlarmG','SFLX1-System','DD-V105-Data10MinH','BL3-V105-Data1MinI','DM-V105-Data1MinI')
or
(s.code like 'WU%Y%' or s.code like 'SE%Y%' or s.code like 'WU_AW%' or s.code like 'RO_A%' or s.code like 'RO%Y%' or s.code like 'DM%Y%' or s.code like 'SY%Y%02%')
)
group by site_label, site_label_2, configuration_label group by site_label, site_label_2, configuration_label
order by site_label, site_label_2, configuration_label order by site_label, site_label_2, configuration_label
) configurations ) configurations
...@@ -163,4 +170,4 @@ sensorcomponents.unit_sms = true ...@@ -163,4 +170,4 @@ sensorcomponents.unit_sms = true
[odm.definitions] [odm.definitions]
# #
datasource.schema = "importandpublish" datasource.schema = "importandpublish"
datasource.table = "tsm_schemas" datasource.table = "tsm_schemas"
\ No newline at end of file
...@@ -146,7 +146,8 @@ def import_configuration(sms_access, sms_site_id, begin_date, label, project, cl ...@@ -146,7 +146,8 @@ def import_configuration(sms_access, sms_site_id, begin_date, label, project, cl
logging.info("SMS seems to know the configuration " + label.__str__() + " already.") logging.info("SMS seems to know the configuration " + label.__str__() + " already.")
else: else:
if not clear: if not clear:
sms_response = sms_access.create_configuration(label, sms_permission_group_id, begin_date, sms_site_id) sms_response = sms_access.create_configuration(label, None, sms_permission_group_id, begin_date,
sms_site_id)
sms_configuration_id = SMSAccess.get_response_entity_id(sms_response) sms_configuration_id = SMSAccess.get_response_entity_id(sms_response)
if clear and sms_site_id is not None: if clear and sms_site_id is not None:
sms_access.delete_entity(SMSAccess.API_ENDPOINT_NAME_SITES, sms_site_id) sms_access.delete_entity(SMSAccess.API_ENDPOINT_NAME_SITES, sms_site_id)
...@@ -400,7 +401,7 @@ def parse_arguments(): ...@@ -400,7 +401,7 @@ def parse_arguments():
"""Configures and executes the argument parser and returns the command-line arguments in a Namespace. """Configures and executes the argument parser and returns the command-line arguments in a Namespace.
Moreover, the logging is configured and set to the respective log level.""" Moreover, the logging is configured and set to the respective log level."""
parser = argparse.ArgumentParser(description='Importer for ODM metadata to the SMS API.\n' parser = argparse.ArgumentParser(description='Importer for ODM metadata to the SMS API.\n'
'Use "odm_importer.py -l debug [options] 2> import.log"' 'Use "odm2sms.py -l debug [options] 2> import.log"'
'to start with an error log file.', 'to start with an error log file.',
formatter_class=argparse.RawTextHelpFormatter) formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('--config-file', dest='config_file', default=DEFAULT_CONFIG_FILE_PATH, parser.add_argument('--config-file', dest='config_file', default=DEFAULT_CONFIG_FILE_PATH,
......
...@@ -540,7 +540,7 @@ class SMSAccess: ...@@ -540,7 +540,7 @@ class SMSAccess:
"attributes": { "attributes": {
"label": label, "label": label,
"geometry": geometry_str, "geometry": geometry_str,
"description": get_migration_info(), "description": None, # get_migration_info(),
"epsg_code": "4326", "epsg_code": "4326",
"is_internal": False, "is_internal": False,
"is_public": True, "is_public": True,
...@@ -616,7 +616,8 @@ class SMSAccess: ...@@ -616,7 +616,8 @@ class SMSAccess:
}) })
return self.create_entity(SMSAccess.API_ENDPOINT_NAME_SITE_CONTACT_ROLES, json_object, True) return self.create_entity(SMSAccess.API_ENDPOINT_NAME_SITE_CONTACT_ROLES, json_object, True)
def create_configuration(self, configuration_label, permission_group_id, begin_date, sms_site_id): def create_configuration(self, configuration_label, configuration_description, permission_group_id, begin_date,
sms_site_id):
"""Posts configurations API endpoint with the given data related to the given site_id.""" """Posts configurations API endpoint with the given data related to the given site_id."""
json_object = json.dumps({ json_object = json.dumps({
"data": { "data": {
...@@ -628,7 +629,7 @@ class SMSAccess: ...@@ -628,7 +629,7 @@ class SMSAccess:
"cfg_permission_group": permission_group_id, "cfg_permission_group": permission_group_id,
"is_public": True, "is_public": True,
"is_internal": False, "is_internal": False,
"description": get_migration_info(), "description": configuration_description, # get_migration_info(),
"project": "", "project": "",
# "persistent_identifier": configuration_label # "persistent_identifier": configuration_label
}, },
...@@ -658,7 +659,7 @@ class SMSAccess: ...@@ -658,7 +659,7 @@ class SMSAccess:
"data": { "data": {
"type": "configuration_static_location_action", "type": "configuration_static_location_action",
"attributes": { "attributes": {
"begin_description": get_migration_info(), # "begin_description": get_migration_info(),
# "end_description": "string", # "end_description": "string",
# "label": "string", # "label": "string",
"x": envelope.x, "x": envelope.x,
......
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