kodexa 7.4.416807352183__py3-none-any.whl → 7.4.417022235742__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kodexa/model/objects.py +1 -0
- kodexa/model/persistence.py +39 -2
- {kodexa-7.4.416807352183.dist-info → kodexa-7.4.417022235742.dist-info}/METADATA +1 -1
- {kodexa-7.4.416807352183.dist-info → kodexa-7.4.417022235742.dist-info}/RECORD +6 -6
- {kodexa-7.4.416807352183.dist-info → kodexa-7.4.417022235742.dist-info}/LICENSE +0 -0
- {kodexa-7.4.416807352183.dist-info → kodexa-7.4.417022235742.dist-info}/WHEEL +0 -0
kodexa/model/objects.py
CHANGED
@@ -2625,6 +2625,7 @@ class TaxonValidation(BaseModel):
|
|
2625
2625
|
detail_formula: Optional[str] = Field(None, alias="detailFormula")
|
2626
2626
|
exception_id: Optional[str] = Field(None, alias="exceptionId")
|
2627
2627
|
support_article_id: Optional[str] = Field(None, alias="supportArticleId")
|
2628
|
+
overridable: Optional[bool] = None
|
2628
2629
|
|
2629
2630
|
class DocumentTaxonValidation(BaseModel):
|
2630
2631
|
model_config = ConfigDict(
|
kodexa/model/persistence.py
CHANGED
@@ -1172,6 +1172,36 @@ class SqliteDocumentPersistence(object):
|
|
1172
1172
|
if result[0] == 0:
|
1173
1173
|
self.cursor.execute("INSERT INTO validations (obj) VALUES (?)", [sqlite3.Binary(msgpack.packb([]))])
|
1174
1174
|
|
1175
|
+
def __deduplicate_document_taxon_validations(self, taxon_validations: List[DocumentTaxonValidation]) -> List[DocumentTaxonValidation]:
|
1176
|
+
"""
|
1177
|
+
Deduplicate DocumentTaxonValidation objects based on taxon_path and exception_id.
|
1178
|
+
|
1179
|
+
Args:
|
1180
|
+
taxon_validations: List of DocumentTaxonValidation objects to deduplicate.
|
1181
|
+
|
1182
|
+
Returns:
|
1183
|
+
List of deduplicated DocumentTaxonValidation objects.
|
1184
|
+
"""
|
1185
|
+
if taxon_validations is None or len(taxon_validations) == 0:
|
1186
|
+
return []
|
1187
|
+
|
1188
|
+
seen_keys = set()
|
1189
|
+
deduplicated = []
|
1190
|
+
|
1191
|
+
for tv in taxon_validations:
|
1192
|
+
if tv is None:
|
1193
|
+
continue
|
1194
|
+
|
1195
|
+
taxon_path = tv.taxon_path if tv.taxon_path is not None else ""
|
1196
|
+
exception_id = tv.validation.exception_id if tv.validation and tv.validation.exception_id else ""
|
1197
|
+
key = f"{taxon_path}|{exception_id}"
|
1198
|
+
|
1199
|
+
if key not in seen_keys:
|
1200
|
+
seen_keys.add(key)
|
1201
|
+
deduplicated.append(tv)
|
1202
|
+
|
1203
|
+
return deduplicated
|
1204
|
+
|
1175
1205
|
def set_validations(self, validations: List[DocumentTaxonValidation]):
|
1176
1206
|
"""
|
1177
1207
|
Sets the validations for the document.
|
@@ -1180,7 +1210,12 @@ class SqliteDocumentPersistence(object):
|
|
1180
1210
|
validations (List[DocumentTaxonValidation]): The validations to store.
|
1181
1211
|
"""
|
1182
1212
|
self.__ensure_validations_table_exists()
|
1183
|
-
|
1213
|
+
# Handle None input
|
1214
|
+
if validations is None:
|
1215
|
+
validations = []
|
1216
|
+
# Deduplicate validations before storing
|
1217
|
+
deduplicated_validations = self.__deduplicate_document_taxon_validations(validations)
|
1218
|
+
serialized_data = sqlite3.Binary(msgpack.packb([v.model_dump(by_alias=True) for v in deduplicated_validations]))
|
1184
1219
|
self.cursor.execute("UPDATE validations SET obj = ? WHERE rowid = 1", [serialized_data])
|
1185
1220
|
self.connection.commit()
|
1186
1221
|
|
@@ -1194,7 +1229,9 @@ class SqliteDocumentPersistence(object):
|
|
1194
1229
|
self.__ensure_validations_table_exists()
|
1195
1230
|
result = self.cursor.execute("SELECT obj FROM validations WHERE rowid = 1").fetchone()
|
1196
1231
|
if result and result[0]:
|
1197
|
-
|
1232
|
+
validations = [DocumentTaxonValidation.model_validate(v) for v in msgpack.unpackb(result[0])]
|
1233
|
+
# Deduplicate validations before returning
|
1234
|
+
return self.__deduplicate_document_taxon_validations(validations)
|
1198
1235
|
return []
|
1199
1236
|
|
1200
1237
|
def set_external_data(self, external_data: dict, key: str = "default"):
|
@@ -13,8 +13,8 @@ kodexa/model/entities/product.py,sha256=StUhTEeLXmc05cj6XnZppQfeJsqCPbX1jdhsysHH
|
|
13
13
|
kodexa/model/entities/product_group.py,sha256=540fRGyUf34h1BzAN1DiWu6rGgvaj3xDFhZ2k-RvSFY,3617
|
14
14
|
kodexa/model/entities/product_subscription.py,sha256=UcmWR-qgLfdV7VCtJNwzgkanoS8nBSL6ngVuxQUK1M8,3810
|
15
15
|
kodexa/model/model.py,sha256=o93SDgw8mj28LWbwJB78PF_Oim8qeCTH1a9x_GDc7yg,120895
|
16
|
-
kodexa/model/objects.py,sha256=
|
17
|
-
kodexa/model/persistence.py,sha256=
|
16
|
+
kodexa/model/objects.py,sha256=mPLc1QwVzNuyXLhaHArUMLRf7KTIwgTyY3cu5zb7yyY,204986
|
17
|
+
kodexa/model/persistence.py,sha256=n5KfdyujKmBWc-x_LN0pmRpFCo50VSrTr4_1M98q6tc,73548
|
18
18
|
kodexa/model/utils.py,sha256=YEG3f8YzBil06D0P3_dfx2S9GnHREzyrjnlWwQ7oPlU,3038
|
19
19
|
kodexa/pipeline/__init__.py,sha256=sA7f5D6qkdMrpp2xTIeefnrUBI6xxEEWostvxfX_1Cs,236
|
20
20
|
kodexa/pipeline/pipeline.py,sha256=zyNEpA7KlGhPs_l-vgV6m-OCb16dbxQhl8QezeylugA,25540
|
@@ -45,7 +45,7 @@ kodexa/testing/test_utils.py,sha256=v44p__gE7ia67W7WeHN2HBFCWSCUrCZt7G4xBNCmwf8,
|
|
45
45
|
kodexa/training/__init__.py,sha256=xs2L62YpRkIRfslQwtQZ5Yxjhm7sLzX2TrVX6EuBnZQ,52
|
46
46
|
kodexa/training/train_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
47
|
kodexa/utils/__init__.py,sha256=Pnim1o9_db5YEnNvDTxpM7HG-qTlL6n8JwFwOafU9wo,5928
|
48
|
-
kodexa-7.4.
|
49
|
-
kodexa-7.4.
|
50
|
-
kodexa-7.4.
|
51
|
-
kodexa-7.4.
|
48
|
+
kodexa-7.4.417022235742.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
49
|
+
kodexa-7.4.417022235742.dist-info/METADATA,sha256=Du0Gon9vD5l1DVOD2awarhL2j3uUpEpEZw_smgzEWEA,2916
|
50
|
+
kodexa-7.4.417022235742.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
51
|
+
kodexa-7.4.417022235742.dist-info/RECORD,,
|
File without changes
|
File without changes
|