53 lines
4 KiB
Python
53 lines
4 KiB
Python
# Copyright (c) 2025 Patrick Motsch
|
|
# All rights reserved.
|
|
"""Neutralizer models: DataNeutraliserConfig and DataNeutralizerAttributes."""
|
|
|
|
import uuid
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
from modules.shared.attributeUtils import registerModelLabels
|
|
|
|
|
|
class DataNeutraliserConfig(BaseModel):
|
|
id: str = Field(default_factory=lambda: str(uuid.uuid4()), description="Unique ID of the configuration", json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": False})
|
|
mandateId: str = Field(description="ID of the mandate this configuration belongs to", json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": True})
|
|
userId: str = Field(description="ID of the user who created this configuration", json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": True})
|
|
enabled: bool = Field(default=True, description="Whether data neutralization is enabled", json_schema_extra={"frontend_type": "checkbox", "frontend_readonly": False, "frontend_required": False})
|
|
namesToParse: str = Field(default="", description="Multiline list of names to parse for neutralization", json_schema_extra={"frontend_type": "textarea", "frontend_readonly": False, "frontend_required": False})
|
|
sharepointSourcePath: str = Field(default="", description="SharePoint path to read files for neutralization", json_schema_extra={"frontend_type": "text", "frontend_readonly": False, "frontend_required": False})
|
|
sharepointTargetPath: str = Field(default="", description="SharePoint path to store neutralized files", json_schema_extra={"frontend_type": "text", "frontend_readonly": False, "frontend_required": False})
|
|
registerModelLabels(
|
|
"DataNeutraliserConfig",
|
|
{"en": "Data Neutralization Config", "fr": "Configuration de neutralisation des données"},
|
|
{
|
|
"id": {"en": "ID", "fr": "ID"},
|
|
"mandateId": {"en": "Mandate ID", "fr": "ID de mandat"},
|
|
"userId": {"en": "User ID", "fr": "ID utilisateur"},
|
|
"enabled": {"en": "Enabled", "fr": "Activé"},
|
|
"namesToParse": {"en": "Names to Parse", "fr": "Noms à analyser"},
|
|
"sharepointSourcePath": {"en": "Source Path", "fr": "Chemin source"},
|
|
"sharepointTargetPath": {"en": "Target Path", "fr": "Chemin cible"},
|
|
},
|
|
)
|
|
|
|
class DataNeutralizerAttributes(BaseModel):
|
|
id: str = Field(default_factory=lambda: str(uuid.uuid4()), description="Unique ID of the attribute mapping (used as UID in neutralized files)", json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": False})
|
|
mandateId: str = Field(description="ID of the mandate this attribute belongs to", json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": True})
|
|
userId: str = Field(description="ID of the user who created this attribute", json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": True})
|
|
originalText: str = Field(description="Original text that was neutralized", json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": True})
|
|
fileId: Optional[str] = Field(default=None, description="ID of the file this attribute belongs to", json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": False})
|
|
patternType: str = Field(description="Type of pattern that matched (email, phone, name, etc.)", json_schema_extra={"frontend_type": "text", "frontend_readonly": True, "frontend_required": True})
|
|
registerModelLabels(
|
|
"DataNeutralizerAttributes",
|
|
{"en": "Neutralized Data Attribute", "fr": "Attribut de données neutralisées"},
|
|
{
|
|
"id": {"en": "ID", "fr": "ID"},
|
|
"mandateId": {"en": "Mandate ID", "fr": "ID de mandat"},
|
|
"userId": {"en": "User ID", "fr": "ID utilisateur"},
|
|
"originalText": {"en": "Original Text", "fr": "Texte original"},
|
|
"fileId": {"en": "File ID", "fr": "ID de fichier"},
|
|
"patternType": {"en": "Pattern Type", "fr": "Type de modèle"},
|
|
},
|
|
)
|
|
|
|
|