Skip to content

Commit f94fbe2

Browse files
authored
feat: Add Segment.is_on_uebertragungsdatei_level to AHB(esser) View (the aggregated instead of only the bare data model) (#134)
1 parent 46650c2 commit f94fbe2

File tree

6 files changed

+500
-12
lines changed

6 files changed

+500
-12
lines changed

src/fundamend/sqlmodels/ahbtabellen_view.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class AhbTabellenLine(SQLModel, table=True):
5252
segment_code: str | None = Field()
5353
data_element: str | None = Field()
5454
qualifier: str | None = Field()
55+
is_on_uebertragungsdatei_level: bool | None = Field() #: !=null as soon as at least one segment is part of the path
5556
line_ahb_status: str | None = Field()
5657
line_name: str | None = Field()
5758
line_type: str | None = Field() # 'code' or 'dataelement' or 'segment' or 'segmentgroup' or 'dataelementgroup'

src/fundamend/sqlmodels/ahbview.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ class AhbHierarchyMaterialized(SQLModel, table=True):
212212
segment_number: Optional[str] = Field(default=None, index=True)
213213
segment_ahb_status: Optional[str] = Field(default=None)
214214
segment_position: Optional[int] = Field(default=None, index=True)
215+
is_on_uebertragungsdatei_level: Optional[bool] = Field(default=None, index=False) #: null for SG only (no segment)
215216

216217
# Data Element Group
217218
dataelementgroup_id: Optional[str] = Field(default=None, index=True)

src/fundamend/sqlmodels/create_ahbtabellen_view.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ WITH consolidated_ahm AS (SELECT id,
1616
beschreibung,
1717
segmentgroup_id,
1818
segment_id,
19+
is_on_uebertragungsdatei_level,
1920
dataelement_id,
2021
code_value,
2122
sort_path,
@@ -39,12 +40,13 @@ SELECT c.id as id,
3940
c.segmentgroup_id as segmentgroup_key, -- eg 'SG6'
4041
c.segment_id as segment_code, -- e.g 'NAD'
4142
c.dataelement_id as data_element, -- e.g 'D_3035'
43+
c.is_on_uebertragungsdatei_level as is_on_uebertragungsdatei_level, -- true for UNA/UNB+UNZ, not for UNH
4244
--CASE
4345
-- WHEN dataelement_id IS NOT NULL THEN SUBSTR(dataelement_id, 3)
4446
-- END AS dataelement_without_leading_d_, -- e.g '3035'
4547
c.code_value as qualifier,
46-
c.line_ahb_status as line_ahb_status, -- e.g. 'Muss [28] ∧ [64]'
47-
c.line_name as line_name, -- e.g. 'Datums- oder Uhrzeit- oder Zeitspannen-Format, Code' or 'Produkt-Daten für Lieferant relevant'
48+
c.line_ahb_status as line_ahb_status, -- e.g. 'Muss [28] ∧ [64]'
49+
c.line_name as line_name, -- e.g. 'Datums- oder Uhrzeit- oder Zeitspannen-Format, Code' or 'Produkt-Daten für Lieferant relevant'
4850
c.line_type as line_type,
4951
c.sort_path as sort_path,
5052
NULLIF(ahe.node_texts, '') as bedingung,

src/fundamend/sqlmodels/materialize_ahb_view.sql

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ WITH RECURSIVE
2525
af.beschreibung,
2626
af.kommunikation_von,
2727
ah.edifact_format_version,
28-
af.anwendungshandbuch_primary_key
28+
af.anwendungshandbuch_primary_key,
29+
null as is_on_uebertragungsdatei_level
2930
FROM segmentgroup sg
3031
JOIN anwendungsfall af ON sg.anwendungsfall_primary_key = af.primary_key
3132
JOIN anwendungshandbuch ah ON af.anwendungshandbuch_primary_key = ah.primary_key
@@ -34,8 +35,8 @@ WITH RECURSIVE
3435

3536
SELECT s.primary_key,
3637
s.position,
37-
'segment' AS type,
38-
s.id AS root_id_text,
38+
'segment' AS type,
39+
s.id AS root_id_text,
3940
s.name,
4041
s.ahb_status,
4142
s.anwendungsfall_primary_key,
@@ -48,7 +49,8 @@ WITH RECURSIVE
4849
af.beschreibung,
4950
af.kommunikation_von,
5051
ah.edifact_format_version,
51-
af.anwendungshandbuch_primary_key
52+
af.anwendungshandbuch_primary_key,
53+
s.is_on_uebertragungsdatei_level as is_on_uebertragungsdatei_level
5254
FROM segment s
5355
JOIN anwendungsfall af ON s.anwendungsfall_primary_key = af.primary_key
5456
JOIN anwendungshandbuch ah ON af.anwendungshandbuch_primary_key = ah.primary_key
@@ -83,7 +85,7 @@ WITH RECURSIVE
8385
o.kommunikation_von,
8486
o.edifact_format_version,
8587
o.anwendungshandbuch_primary_key,
86-
88+
o.is_on_uebertragungsdatei_level,
8789
CASE WHEN o.type = 'segment_group' THEN o.root_id_text ELSE NULL END AS segmentgroup_id,
8890
CASE WHEN o.type = 'segment_group' THEN o.name ELSE NULL END AS segmentgroup_name,
8991
CASE WHEN o.type = 'segment_group' THEN o.ahb_status ELSE NULL END AS segmentgroup_ahb_status,
@@ -142,6 +144,7 @@ WITH RECURSIVE
142144
h.kommunikation_von,
143145
h.edifact_format_version,
144146
h.anwendungshandbuch_primary_key,
147+
h.is_on_uebertragungsdatei_level,
145148

146149
'SG' || child.id,
147150
child.name,
@@ -199,7 +202,7 @@ WITH RECURSIVE
199202
h.kommunikation_von,
200203
h.edifact_format_version,
201204
h.anwendungshandbuch_primary_key,
202-
205+
s.is_on_uebertragungsdatei_level,
203206
h.segmentgroup_id,
204207
h.segmentgroup_name,
205208
h.segmentgroup_ahb_status,
@@ -255,7 +258,7 @@ WITH RECURSIVE
255258
h.kommunikation_von,
256259
h.edifact_format_version,
257260
h.anwendungshandbuch_primary_key,
258-
261+
h.is_on_uebertragungsdatei_level,
259262
h.segmentgroup_id,
260263
h.segmentgroup_name,
261264
h.segmentgroup_ahb_status,
@@ -311,7 +314,7 @@ WITH RECURSIVE
311314
h.kommunikation_von,
312315
h.edifact_format_version,
313316
h.anwendungshandbuch_primary_key,
314-
317+
h.is_on_uebertragungsdatei_level,
315318
h.segmentgroup_id,
316319
h.segmentgroup_name,
317320
h.segmentgroup_ahb_status,
@@ -368,7 +371,7 @@ WITH RECURSIVE
368371
h.kommunikation_von,
369372
h.edifact_format_version,
370373
h.anwendungshandbuch_primary_key,
371-
374+
h.is_on_uebertragungsdatei_level,
372375
h.segmentgroup_id,
373376
h.segmentgroup_name,
374377
h.segmentgroup_ahb_status,
@@ -424,7 +427,7 @@ WITH RECURSIVE
424427
h.kommunikation_von,
425428
h.edifact_format_version,
426429
h.anwendungshandbuch_primary_key,
427-
430+
h.is_on_uebertragungsdatei_level,
428431
h.segmentgroup_id,
429432
h.segmentgroup_name,
430433
h.segmentgroup_ahb_status,

0 commit comments

Comments
 (0)