ReadEntityDefinition - Reads a Entity Definition from repository
(_ context.Context, tenantID, entityName, version string)
| 70 | |
| 71 | // ReadEntityDefinition - Reads a Entity Definition from repository |
| 72 | func (r *SchemaReader) ReadEntityDefinition(_ context.Context, tenantID, entityName, version string) (definition *base.EntityDefinition, v string, err error) { |
| 73 | txn := r.database.DB.Txn(false) |
| 74 | defer txn.Abort() |
| 75 | var raw interface{} |
| 76 | raw, err = txn.First(constants.SchemaDefinitionsTable, "id", tenantID, entityName, version) // Query entity definition |
| 77 | if err != nil { |
| 78 | return nil, "", errors.New(base.ErrorCode_ERROR_CODE_EXECUTION.String()) |
| 79 | } |
| 80 | |
| 81 | def, ok := raw.(storage.SchemaDefinition) |
| 82 | if ok { |
| 83 | var sch *base.SchemaDefinition |
| 84 | sch, err = schema.NewSchemaFromStringDefinitions(false, def.Serialized()) |
| 85 | if err != nil { |
| 86 | return nil, "", err |
| 87 | } |
| 88 | definition, err = schema.GetEntityByName(sch, entityName) |
| 89 | if err != nil { |
| 90 | return nil, "", err |
| 91 | } |
| 92 | return definition, def.Version, err |
| 93 | } |
| 94 | |
| 95 | return nil, "", errors.New(base.ErrorCode_ERROR_CODE_SCHEMA_NOT_FOUND.String()) |
| 96 | } |
| 97 | |
| 98 | // ReadRuleDefinition - Reads a Rule Definition from repository |
| 99 | func (r *SchemaReader) ReadRuleDefinition(_ context.Context, tenantID, ruleName, version string) (definition *base.RuleDefinition, v string, err error) { |
nothing calls this directly
no test coverage detected