diff --git a/.vscode/settings.json b/.vscode/settings.json index 944e5ab..06083a4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -57,7 +57,7 @@ "cwd": "${workspaceFolder}", "program": "${workspaceFolder}/.venv/bin/bam_masterdata", "justMyCode": false, - "args": ["export-entities-to-json"] + "args": ["export_to_json"] }, { "name": "BM export-to-excel", @@ -66,7 +66,7 @@ "cwd": "${workspaceFolder}", "program": "${workspaceFolder}/.venv/bin/bam_masterdata", "justMyCode": false, - "args": ["export-entities-to-excel"] + "args": ["export_to_excel"] }, ] }, diff --git a/bam_masterdata/cli/entities_to_excel.py b/bam_masterdata/cli/entities_to_excel.py index dff1eaf..36a176e 100644 --- a/bam_masterdata/cli/entities_to_excel.py +++ b/bam_masterdata/cli/entities_to_excel.py @@ -45,6 +45,7 @@ def entities_to_excel( val = getattr(obj, f_set) row.append(val) worksheet.append(row) + worksheet.append([""]) # empty row after entity definitions return None # All other datamodel modules @@ -69,8 +70,8 @@ def entities_to_excel( ] worksheet.append(header_values) - # Properties assignment for ObjectType - if obj_instance.cls_name == "ObjectType": + # Properties assignment for ObjectType, DatasetType, and CollectionType + if obj_instance.cls_name in ["ObjectType", "DatasetType", "CollectionType"]: if not obj_instance.properties: continue worksheet.append(obj_instance.properties[0].excel_headers) diff --git a/bam_masterdata/datamodel/collection_types.py b/bam_masterdata/datamodel/collection_types.py index 9b5ca4d..fd95c03 100644 --- a/bam_masterdata/datamodel/collection_types.py +++ b/bam_masterdata/datamodel/collection_types.py @@ -1,4 +1,7 @@ -from bam_masterdata.metadata.definitions import CollectionTypeDef, PropertyTypeAssignment +from bam_masterdata.metadata.definitions import ( + CollectionTypeDef, + PropertyTypeAssignment, +) from bam_masterdata.metadata.entities import CollectionType diff --git a/bam_masterdata/metadata/entities.py b/bam_masterdata/metadata/entities.py index 6de4774..7970b6e 100644 --- a/bam_masterdata/metadata/entities.py +++ b/bam_masterdata/metadata/entities.py @@ -55,7 +55,8 @@ def to_dict(self) -> dict: @property def cls_name(self) -> str: """ - Returns the entity name of the class as a string to speed up checks. + Returns the entity name of the class as a string to speed up checks. This is a property + to be overwritten by each of the abstract entity types. """ return self.__class__.__name__ @@ -108,6 +109,13 @@ def model_validator_after_init(cls, data: Any) -> Any: return data + @property + def cls_name(self) -> str: + """ + Returns the entity name of the class as a string. + """ + return "ObjectType" + class VocabularyType(BaseEntity): """ @@ -147,10 +155,27 @@ def model_validator_after_init(cls, data: Any) -> Any: return data + @property + def cls_name(self) -> str: + """ + Returns the entity name of the class as a string. + """ + return "VocabularyType" + class CollectionType(ObjectType): - pass + @property + def cls_name(self) -> str: + """ + Returns the entity name of the class as a string. + """ + return "CollectionType" class DatasetType(ObjectType): - pass + @property + def cls_name(self) -> str: + """ + Returns the entity name of the class as a string. + """ + return "DatasetType"