diff --git a/src/model/SchemaConcepts/TOMO_Image.py b/src/model/SchemaConcepts/TOMO_Image.py index bdc62c7..26e9c69 100644 --- a/src/model/SchemaConcepts/TOMO_Image.py +++ b/src/model/SchemaConcepts/TOMO_Image.py @@ -1,7 +1,7 @@ import os from datetime import datetime -from pydantic import BeforeValidator, BaseModel, computed_field +from pydantic import BeforeValidator, BaseModel, computed_field, model_validator from typing_extensions import Annotated from src.config import MappingConfig @@ -57,4 +57,11 @@ def match_by_path(self, other): if not other.localPath: return False if not os.path.exists(self.absolutePath()): return False if not os.path.exists(other.absolutePath()): return False - return os.path.samefile(self.absolutePath(), other.absolutePath()) \ No newline at end of file + return os.path.samefile(self.absolutePath(), other.absolutePath()) + + @model_validator(mode="after") + def set_fileLink(self): + # Automatically populate fileLink from filePath if not set. + if not self.fileLink and self.localPath: + self.fileLink = Identifier(identifierValue=self.filePath) + return self \ No newline at end of file