(metadataStore, schemas, altMetadata)
| 6919 | var CsdlMetadataParser = (function () { |
| 6920 | |
| 6921 | function parse(metadataStore, schemas, altMetadata) { |
| 6922 | |
| 6923 | metadataStore._entityTypeResourceMap = {}; |
| 6924 | __toArray(schemas).forEach(function (schema) { |
| 6925 | if (schema.cSpaceOSpaceMapping) { |
| 6926 | // Web api only - not avail in OData. |
| 6927 | var mappings = JSON.parse(schema.cSpaceOSpaceMapping); |
| 6928 | var newMap = {}; |
| 6929 | mappings.forEach(function (mapping) { |
| 6930 | newMap[mapping[0]] = mapping[1]; |
| 6931 | }); |
| 6932 | schema.cSpaceOSpaceMapping = newMap; |
| 6933 | } |
| 6934 | |
| 6935 | if (schema.entityContainer) { |
| 6936 | __toArray(schema.entityContainer).forEach(function (container) { |
| 6937 | __toArray(container.entitySet).forEach(function (entitySet) { |
| 6938 | var entityTypeName = parseTypeName(entitySet.entityType, schema).typeName; |
| 6939 | metadataStore.setEntityTypeForResourceName(entitySet.name, entityTypeName); |
| 6940 | metadataStore._entityTypeResourceMap[entityTypeName] = entitySet.name; |
| 6941 | }); |
| 6942 | }); |
| 6943 | } |
| 6944 | |
| 6945 | // process complextypes before entity types. |
| 6946 | if (schema.complexType) { |
| 6947 | __toArray(schema.complexType).forEach(function (ct) { |
| 6948 | var complexType = parseCsdlComplexType(ct, schema, metadataStore); |
| 6949 | }); |
| 6950 | } |
| 6951 | if (schema.entityType) { |
| 6952 | __toArray(schema.entityType).forEach(function (et) { |
| 6953 | var entityType = parseCsdlEntityType(et, schema, metadataStore); |
| 6954 | |
| 6955 | }); |
| 6956 | } |
| 6957 | |
| 6958 | }); |
| 6959 | var badNavProps = metadataStore.getIncompleteNavigationProperties(); |
| 6960 | if (badNavProps.length > 0) { |
| 6961 | var msg = badNavProps.map(function (np) { |
| 6962 | return np.parentType.name + ":" + np.name; |
| 6963 | }).join(', '); |
| 6964 | throw new Error("Incomplete navigation properties: " + msg); |
| 6965 | } |
| 6966 | if (altMetadata) { |
| 6967 | metadataStore.importMetadata(altMetadata, true); |
| 6968 | } |
| 6969 | return metadataStore; |
| 6970 | } |
| 6971 | |
| 6972 | function parseCsdlEntityType(csdlEntityType, schema, metadataStore) { |
| 6973 | var shortName = csdlEntityType.name; |
nothing calls this directly
no test coverage detected