GetTypeOfReferenceByNameInEntityDefinition retrieves the type of reference in an `EntityDefinition` by its name. It returns the type of the relational reference if it is found in the `EntityDefinition`. If the relational reference is not found, it returns an error with error code `ERROR_CODE_RELATIO
(entityDefinition *base.EntityDefinition, name string)
| 115 | // It returns the type of the relational reference if it is found in the `EntityDefinition`. |
| 116 | // If the relational reference is not found, it returns an error with error code `ERROR_CODE_RELATION_DEFINITION_NOT_FOUND`. |
| 117 | func GetTypeOfReferenceByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (relationalDefinitionType base.EntityDefinition_Reference, err error) { |
| 118 | // Look up the relational reference in the entity definition's References map |
| 119 | if re, ok := entityDefinition.GetReferences()[name]; ok { |
| 120 | // If the relational reference is found, return its type and a nil error |
| 121 | return re, nil |
| 122 | } |
| 123 | // If the relational reference is not found, return the default type and an error |
| 124 | return base.EntityDefinition_REFERENCE_UNSPECIFIED, errors.New(base.ErrorCode_ERROR_CODE_RELATION_DEFINITION_NOT_FOUND.String()) |
| 125 | } |
| 126 | |
| 127 | // GetPermissionByNameInEntityDefinition retrieves an `PermissionDefinition` from an `EntityDefinition` by its name. |
| 128 | // It returns a pointer to the `PermissionDefinition` if it is found in the `EntityDefinition`. |
no test coverage detected