templates.data-delivery-data-records.record.field.enum.py.vm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of foundation-mda Show documentation
Show all versions of foundation-mda Show documentation
Model driven architecture artifacts for aiSSEMBLE
The newest version!
from __future__ import annotations
from enum import Enum
from typing import List
#foreach ($import in $record.enumImports)
${import}
#end
class ${record.capitalizedName}Field(Enum):
"""
Enum to represent the fields of a ${record.capitalizedName} record.
GENERATED CODE - DO NOT MODIFY
Originally generated from: ${templateName}
"""
#foreach ($field in $record.fields)
${field.upperSnakecaseName} = ${foreach.index}, ${field.driftPolicyEnumValue}, ${field.ethicsPolicyEnumValue}, ${field.protectionPolicyEnumValue}
#end
def __new__(cls, index: int, drift_policy: str, ethics_policy: str, protection_policy: str):
field = object.__new__(cls)
field.index = index
field._drift_policy = drift_policy
field._ethics_policy = ethics_policy
field._protection_policy = protection_policy
return field
@property
def drift_policy(self) -> str:
return self._drift_policy
def has_drift_policy(self) -> bool:
return True if self._drift_policy and self._drift_policy.strip() else False
@property
def ethics_policy(self) -> str:
return self._ethics_policy
def has_ethics_policy(self) -> bool:
return True if self._ethics_policy and self._ethics_policy.strip() else False
@property
def protection_policy(self) -> str:
return self._protection_policy
def has_protection_policy(self) -> bool:
return True if self._protection_policy and self._protection_policy.strip() else False
@classmethod
def get_fields_with_drift_policy(cls) -> List[${record.capitalizedName}Field]:
"""
Returns the list of fields that have a drift policy.
"""
fields_with_drift_policy = []
for field in ${record.capitalizedName}Field:
if field.has_drift_policy():
fields_with_drift_policy.append(field)
return fields_with_drift_policy
@classmethod
def get_fields_with_ethics_policy(cls) -> List[${record.capitalizedName}Field]:
"""
Returns the list of fields that have an ethics policy.
"""
fields_with_ethics_policy = []
for field in ${record.capitalizedName}Field:
if field.has_ethics_policy():
fields_with_ethics_policy.append(field)
return fields_with_ethics_policy
@classmethod
def get_fields_with_protection_policy(cls) -> List[${record.capitalizedName}Field]:
"""
Returns the list of fields that have a protection policy.
"""
fields_with_protection_policy = []
for field in ${record.capitalizedName}Field:
if field.has_protection_policy():
fields_with_protection_policy.append(field)
return fields_with_protection_policy
© 2015 - 2025 Weber Informatics LLC | Privacy Policy