GetAttributeByNameInEntityDefinition retrieves an `AttributeDefinition` from an `EntityDefinition` by its name. It returns a pointer to the `AttributeDefinition` if it is found in the `EntityDefinition`. If the `AttributeDefinition` is not found, it returns an error with error code `ERROR_CODE_ATTRI
(entityDefinition *base.EntityDefinition, name string)
| 154 | // It returns a pointer to the `AttributeDefinition` if it is found in the `EntityDefinition`. |
| 155 | // If the `AttributeDefinition` is not found, it returns an error with error code `ERROR_CODE_ATTRIBUTE_DEFINITION_NOT_FOUND`. |
| 156 | func GetAttributeByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (attributeDefinition *base.AttributeDefinition, err error) { |
| 157 | // Look up the attribute definition in the entity definition's Attributes map |
| 158 | if ad, ok := entityDefinition.GetAttributes()[name]; ok { |
| 159 | // If the attribute definition is found, return it and a nil error |
| 160 | return ad, nil |
| 161 | } |
| 162 | // If the attribute definition is not found, return a nil attribute definition and an error |
| 163 | return nil, errors.New(base.ErrorCode_ERROR_CODE_ATTRIBUTE_DEFINITION_NOT_FOUND.String()) |
| 164 | } |
| 165 | |
| 166 | // IsDirectlyRelated checks if a source `RelationReference` is directly related to a target `RelationDefinition`. |
| 167 | // It returns true if the source and target have the same type and relation, false otherwise. |
no test coverage detected