initAttr initializes the given mapped attribute with the given service attribute.
(ma *MappedAttributeExpr, svcAtt *AttributeExpr)
| 1110 | // initAttr initializes the given mapped attribute with the given service |
| 1111 | // attribute. |
| 1112 | func initAttr(ma *MappedAttributeExpr, svcAtt *AttributeExpr) { |
| 1113 | svcObj := AsObject(svcAtt.Type) |
| 1114 | for _, nat := range *AsObject(ma.Type) { |
| 1115 | var patt *AttributeExpr |
| 1116 | var required bool |
| 1117 | if svcObj != nil { |
| 1118 | patt = svcObj.Attribute(nat.Name) |
| 1119 | required = svcAtt.IsRequired(nat.Name) |
| 1120 | } else { |
| 1121 | patt = svcAtt |
| 1122 | required = true |
| 1123 | } |
| 1124 | initAttrFromDesign(nat.Attribute, patt) |
| 1125 | if required { |
| 1126 | if ma.Validation == nil { |
| 1127 | ma.Validation = &ValidationExpr{} |
| 1128 | } |
| 1129 | ma.Validation.AddRequired(nat.Name) |
| 1130 | } |
| 1131 | } |
| 1132 | } |
| 1133 | |
| 1134 | // initAttrFromDesign overrides the type of att with the one of patt and |
| 1135 | // initializes other non-initialized fields of att with the one of patt except |
no test coverage detected