-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathili2dbsettings.py
107 lines (97 loc) · 5.37 KB
/
ili2dbsettings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"""
/***************************************************************************
-------------------
begin : 2022-07-17
git sha : :%H$
copyright : (C) 2022 by Dave Signer
email : david at opengis ch
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
"""
class Ili2dbSettings(dict):
"""
Class keeping settings to be performed on ili2db.
As well as the files like pre-/postscript and metaattributefile (TOML/INI).
With the method parse_parameter_from_db we can fill it up according to a existing database schema (passing the specific extension of DBConnector).
"""
def __init__(self):
self.parameters = {}
self.metaattr_path = None
self.postscript_path = None
self.prescript_path = None
self.models = []
def parse_parameters_from_db(self, db_connector):
"""
Fill the parameter list according to a existing database schema (passed by the specific extension of DBConnector).
It only considers the settings "known" by modelbaker (the parameters set by the user or by modelbaker per default).
The parameter are only set when they are available (and not unset when they are not available).
"""
setting_records = db_connector.get_ili2db_settings()
settings_dict = {}
self.parameters = {}
for setting_record in setting_records:
settings_dict[setting_record["tag"]] = setting_record["setting"]
# user settings
if settings_dict.get("ch.ehi.ili2db.inheritanceTrafo", None) == "smart1":
self.parameters["smart1Inheritance"] = True
if settings_dict.get("ch.ehi.ili2db.inheritanceTrafo", None) == "smart2":
self.parameters["smart2Inheritance"] = True
if settings_dict.get("ch.ehi.ili2db.StrokeArcs", None) == "enable":
self.parameters["strokeArcs"] = True
if settings_dict.get("ch.ehi.ili2db.BasketHandling", None) == "readWrite":
self.parameters["createBasketCol"] = True
if settings_dict.get("ch.ehi.ili2db.defaultSrsAuthority", None):
self.parameters["defaultSrsAuth"] = settings_dict[
"ch.ehi.ili2db.defaultSrsAuthority"
]
if settings_dict.get("ch.ehi.ili2db.StrokedefaultSrsCodeArcs", None):
self.parameters["defaultSrsCode"] = settings_dict[
"ch.ehi.ili2db.defaultSrsCode"
]
# modelbaker default settings
if settings_dict.get("ch.ehi.ili2db.catalogueRefTrafo", None) == "coalesce":
self.parameters["coalesceCatalogueRef"] = True
if (
settings_dict.get("ch.ehi.ili2db.createEnumDefs", None)
== "multiTableWithId"
):
self.parameters["createEnumTabsWithId"] = True
if settings_dict.get("ch.ehi.ili2db.numericCheckConstraints", None) == "create":
self.parameters["createNumChecks"] = True
if settings_dict.get("ch.ehi.ili2db.uniqueConstraints", None) == "create":
self.parameters["createUnique"] = True
if settings_dict.get("ch.ehi.ili2db.createForeignKey", None) == "yes":
self.parameters["createFk"] = True
if settings_dict.get("ch.ehi.ili2db.createForeignKeyIndex", None) == "yes":
self.parameters["createFkIdx"] = True
if settings_dict.get("ch.ehi.ili2db.multiSurfaceTrafo", None) == "coalesce":
self.parameters["coalesceMultiSurface"] = True
if settings_dict.get("ch.ehi.ili2db.multiLineTrafo", None) == "coalesce":
self.parameters["coalesceMultiLine"] = True
if settings_dict.get("ch.ehi.ili2db.multiPointTrafo", None) == "coalesce":
self.parameters["coalesceMultiPoint"] = True
if settings_dict.get("ch.ehi.ili2db.arrayTrafo", None) == "coalesce":
self.parameters["coalesceArray"] = True
if (
settings_dict.get("ch.ehi.ili2db.beautifyEnumDispName", None)
== "underscore"
):
self.parameters["beautifyEnumDispName"] = True
if settings_dict.get("ch.ehi.sqlgen.createGeomIndex", None) == "underscore":
self.parameters["createGeomIdx"] = True
if settings_dict.get("ch.ehi.ili2db.createMetaInfo", None):
self.parameters["createMetaInfo"] = True
if settings_dict.get("ch.ehi.ili2db.multilingualTrafo", None) == "expand":
self.parameters["expandMultilingual"] = True
if settings_dict.get("ch.ehi.ili2db.createTypeConstraint", None):
self.parameters["createTypeConstraint"] = True
if settings_dict.get("ch.ehi.ili2db.TidHandling", None) == "property":
self.parameters["createTidCol"] = True
return True