Skip to content

Commit

Permalink
Generator option to expose t_ili_tid in project
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Nov 12, 2023
1 parent dc192f5 commit 55fcc27
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
14 changes: 0 additions & 14 deletions modelbaker/dataobjects/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,20 +341,6 @@ def real_id(self):
else:
return None

@property
def oid_domain(self):
t_ili_tid_field = self.t_ili_tid_field
if t_ili_tid_field:
return t_ili_tid_field.oid_domain
return None

@property
def t_ili_tid_field(self):
for field in self.fields:
if field.name.lower() == "t_ili_tid":
return field
return None

def isPureLinkTable(self, project):
"""
Returns True if the layer is a pure link table in a n:m relation.
Expand Down
11 changes: 7 additions & 4 deletions modelbaker/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(
mgmt_uri=None,
consider_basket_handling=False,
optimize_strategy=OptimizeStrategy.NONE,
expose_t_ili_tid=False,
):
"""
Creates a new Generator objects.
Expand All @@ -71,6 +72,7 @@ def __init__(
self._db_connector.new_message.connect(self.append_print_message)
self.basket_handling = consider_basket_handling and self.get_basket_handling()
self.optimize_strategy = optimize_strategy
self.expose_t_ili_tid = expose_t_ili_tid

self._additional_ignored_layers = (
[]
Expand Down Expand Up @@ -308,15 +310,17 @@ def layers(self, filter_layer_list=[]):
break

if column_name in IGNORED_FIELDNAMES:
hide_attribute = True
if not self.expose_t_ili_tid and column_name.lower() == "t_ili_tid":
hide_attribute = True

if not self.basket_handling and column_name in BASKET_FIELDNAMES:
hide_attribute = True

field.hidden = hide_attribute

if column_name in READONLY_FIELDNAMES:
field.read_only = True
if not self.expose_t_ili_tid and column_name.lower() == "t_ili_tid":
field.read_only = True

if column_name in min_max_info:
field.widget = "Range"
Expand Down Expand Up @@ -392,8 +396,7 @@ def layers(self, filter_layer_list=[]):
# when there is a t_ili_tid it should be filled up when there is no OID defined in the model
if "oid_domain" not in fielddef or fielddef["oid_domain"] is None:
field.default_value_expression = "substr(uuid(), 2, 36)"
else:
field.oid_domain = fielddef["oid_domain"]

if "enum_domain" in fielddef and fielddef["enum_domain"]:
field.enum_domain = fielddef["enum_domain"]

Expand Down

0 comments on commit 55fcc27

Please sign in to comment.