kodexa 7.0.11355436841__py3-none-any.whl → 7.0.11483003156__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/model.py CHANGED
@@ -14,7 +14,7 @@ import deepdiff
14
14
  import msgpack
15
15
  from pydantic import BaseModel, ConfigDict, Field
16
16
 
17
- from kodexa.model.objects import ContentObject, FeatureSet
17
+ from kodexa.model.objects import ContentObject, FeatureSet, DocumentTaxonValidation
18
18
 
19
19
 
20
20
  class Ref:
@@ -299,6 +299,12 @@ class ContentNode(object):
299
299
  def set_content_parts(self, content_parts):
300
300
  self.document.get_persistence().update_content_parts(self, content_parts)
301
301
 
302
+ def get_validations(self) -> list[DocumentTaxonValidation]:
303
+ return self.document.get_persistence().get_validations()
304
+
305
+ def set_validations(self, validations: list[DocumentTaxonValidation]):
306
+ self.document.get_persistence().set_validations(validations)
307
+
302
308
  def update(self):
303
309
  """
304
310
  Update this node in the document persistence
kodexa/model/objects.py CHANGED
@@ -2591,13 +2591,28 @@ class TaxonConditionalFormat(BaseModel):
2591
2591
  properties: Dict[str, Any] = Field(default_factory=dict)
2592
2592
 
2593
2593
 
2594
- class TaxonRule(BaseModel):
2595
- name: Optional[str] = None
2596
- description: Optional[str] = None
2597
- rule_formula: Optional[str] = None
2598
- message_formula: Optional[str] = None
2599
- detail_formula: Optional[str] = None
2600
- exception_id: Optional[str] = None
2594
+
2595
+ class TaxonValidation(BaseModel):
2596
+
2597
+ model_config = ConfigDict(
2598
+ populate_by_name=True,
2599
+ use_enum_values=True,
2600
+ arbitrary_types_allowed=True,
2601
+ protected_namespaces=("model_config",),
2602
+ )
2603
+
2604
+ name: Optional[str] = Field(None)
2605
+ description: Optional[str] = Field(None)
2606
+ rule_formula: Optional[str] = Field(None, alias="ruleFormula")
2607
+ message_formula: Optional[str] = Field(None, alias="messageFormula")
2608
+ detail_formula: Optional[str] = Field(None, alias="detailFormula")
2609
+ exception_id: Optional[str] = Field(None, alias="exceptionId")
2610
+
2611
+
2612
+ class DocumentTaxonValidation:
2613
+ taxonomy_ref: Optional[str] = Field(None, alias="taxonomyRef")
2614
+ taxon_path: Optional[str] = Field(None, alias="taxonPath")
2615
+ rule: Optional[TaxonValidation] = None
2601
2616
 
2602
2617
 
2603
2618
  class Taxon(BaseModel):
@@ -2643,7 +2658,11 @@ class Taxon(BaseModel):
2643
2658
  properties: Optional[Dict[str, Any]] = Field(default_factory=dict)
2644
2659
  conditional_formats: Optional[List[TaxonConditionalFormat]] = Field(default_factory=list,
2645
2660
  alias="conditionalFormats")
2646
- rules: Optional[List[TaxonRule]] = Field(default_factory=list)
2661
+ validation_rules: List[TaxonValidation] = Field(
2662
+ default_factory=list,
2663
+ description="The validation rules for the taxon"
2664
+ )
2665
+
2647
2666
  cardinality: Optional[TaxonCardinality] = None
2648
2667
  path: Optional[str] = None
2649
2668
  multi_value: Optional[bool] = Field(True, alias="multiValue")
@@ -15,6 +15,7 @@ from kodexa.model.model import (
15
15
  ContentException,
16
16
  ModelInsight, ProcessingStep,
17
17
  )
18
+ from kodexa.model.objects import DocumentTaxonValidation
18
19
 
19
20
  logger = logging.getLogger()
20
21
 
@@ -1138,6 +1139,47 @@ class SqliteDocumentPersistence(object):
1138
1139
  if result[0] == 0:
1139
1140
  self.cursor.execute("INSERT INTO ed (obj) VALUES (?)", [sqlite3.Binary(msgpack.packb({}))])
1140
1141
 
1142
+ def __ensure_validations_table_exists(self):
1143
+ """
1144
+ Ensure the 'validations' table exists in the database.
1145
+ Creates the table if it does not exist and initializes it with an empty list.
1146
+ """
1147
+ self.cursor.execute("""
1148
+ CREATE TABLE IF NOT EXISTS validations (
1149
+ obj BLOB
1150
+ )
1151
+ """)
1152
+
1153
+ # Check if the table has any rows, if not, insert an initial empty row
1154
+ result = self.cursor.execute("SELECT COUNT(*) FROM validations").fetchone()
1155
+ if result[0] == 0:
1156
+ self.cursor.execute("INSERT INTO validations (obj) VALUES (?)", [sqlite3.Binary(msgpack.packb([]))])
1157
+
1158
+ def set_validations(self, validations: List[DocumentTaxonValidation]):
1159
+ """
1160
+ Sets the validations for the document.
1161
+
1162
+ Args:
1163
+ validations (List[DocumentTaxonValidation]): The validations to store.
1164
+ """
1165
+ self.__ensure_validations_table_exists()
1166
+ serialized_data = sqlite3.Binary(msgpack.packb([v.to_dict() for v in validations]))
1167
+ self.cursor.execute("UPDATE validations SET obj = ? WHERE rowid = 1", [serialized_data])
1168
+ self.connection.commit()
1169
+
1170
+ def get_validations(self) -> List[DocumentTaxonValidation]:
1171
+ """
1172
+ Gets the validations associated with this document.
1173
+
1174
+ Returns:
1175
+ List[DocumentTaxonValidation]: The list of validations stored in the validations table.
1176
+ """
1177
+ self.__ensure_validations_table_exists()
1178
+ result = self.cursor.execute("SELECT obj FROM validations WHERE rowid = 1").fetchone()
1179
+ if result and result[0]:
1180
+ return [DocumentTaxonValidation(**v) for v in msgpack.unpackb(result[0])]
1181
+ return []
1182
+
1141
1183
  def set_external_data(self, external_data: dict):
1142
1184
  """
1143
1185
  Sets the external data for the document.
@@ -1355,6 +1397,12 @@ class PersistenceManager(object):
1355
1397
  def set_steps(self, steps: list[ProcessingStep]):
1356
1398
  self._underlying_persistence.set_steps(steps)
1357
1399
 
1400
+ def set_validations(self, validations: list[DocumentTaxonValidation]):
1401
+ self._underlying_persistence.set_validations(validations)
1402
+
1403
+ def get_validations(self) -> list[DocumentTaxonValidation]:
1404
+ return self._underlying_persistence.get_validations()
1405
+
1358
1406
  def get_external_data(self) -> dict:
1359
1407
  """
1360
1408
  Gets the external data object associated with this document
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kodexa
3
- Version: 7.0.11355436841
3
+ Version: 7.0.11483003156
4
4
  Summary: Python SDK for the Kodexa Platform
5
5
  Author: Austin Redenbaugh
6
6
  Author-email: austin@kodexa.com
@@ -11,9 +11,9 @@ kodexa/model/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3h
11
11
  kodexa/model/entities/check_response.py,sha256=eqBHxO6G2OAziL3p9bHGI-oiPkAG82H6Choc8wyvtM4,3949
12
12
  kodexa/model/entities/product.py,sha256=ZDpHuBE_9FJ-klnkyBvTfPwYOqBkM1wraZMtHqNA8FQ,3526
13
13
  kodexa/model/entities/product_subscription.py,sha256=UcmWR-qgLfdV7VCtJNwzgkanoS8nBSL6ngVuxQUK1M8,3810
14
- kodexa/model/model.py,sha256=Ay3X9rsoJaUdG51WysSDPp2iy_cnz4eEYJgWdC25uio,118058
15
- kodexa/model/objects.py,sha256=7xXLv9QFmXSzWQ64B-UZMd_2kI7D-y2k0hh2ZZRuj2Y,184223
16
- kodexa/model/persistence.py,sha256=w4WGS_qH1iowH8-ZMawZBZ2RFW3bNvmFy5fgSwr6VmQ,66198
14
+ kodexa/model/model.py,sha256=nNnsZK2plgr6f13F85JNms3V0en8APCpmrPwZFAJ_2I,118358
15
+ kodexa/model/objects.py,sha256=YkEQmL85JTNdZwTOBfTBgddk_65UJrPkxzvo7AFiMuk,184833
16
+ kodexa/model/persistence.py,sha256=_k3KCcJReoWkwcelcoiXaMDKsVhnH7A6o68Fv9kzVAU,68252
17
17
  kodexa/pipeline/__init__.py,sha256=sA7f5D6qkdMrpp2xTIeefnrUBI6xxEEWostvxfX_1Cs,236
18
18
  kodexa/pipeline/pipeline.py,sha256=ZYpJAWcwV4YRK589DUhU0vXGQlkNSj4J2TsGbYqTLjo,25221
19
19
  kodexa/platform/__init__.py,sha256=1O3oiWMg292NPL_NacKDnK1T3_R6cMorrPRue_9e-O4,216
@@ -42,7 +42,7 @@ kodexa/testing/test_utils.py,sha256=DrLCkHxdb6AbZ-X3WmTMbQmnVIm55VEBL8MjtUK9POs,
42
42
  kodexa/training/__init__.py,sha256=xs2L62YpRkIRfslQwtQZ5Yxjhm7sLzX2TrVX6EuBnZQ,52
43
43
  kodexa/training/train_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  kodexa/utils/__init__.py,sha256=Pnim1o9_db5YEnNvDTxpM7HG-qTlL6n8JwFwOafU9wo,5928
45
- kodexa-7.0.11355436841.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
46
- kodexa-7.0.11355436841.dist-info/METADATA,sha256=P6j63TyN8tRep2Aqe1sNJxXY6Cdhm1JpsQ6FFe-yWzw,3529
47
- kodexa-7.0.11355436841.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
48
- kodexa-7.0.11355436841.dist-info/RECORD,,
45
+ kodexa-7.0.11483003156.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
46
+ kodexa-7.0.11483003156.dist-info/METADATA,sha256=K-bMtUDxtNUUNbj5kAX4JnkVqFXSTLTZX2cWIImwMbM,3529
47
+ kodexa-7.0.11483003156.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
48
+ kodexa-7.0.11483003156.dist-info/RECORD,,