Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | 1x 1x 1x 60x 60x 60x 4x 60x 8x 60x 6x 60x 1x 60x 5x 60x 1x 2x 2x 2x 2x 3x 2x 1x 1x 2x 1x 1x 1x 1x | "use strict";
const _ = require("lodash");
const AnnotationTarget = require("../annotations/AnnotationTarget");
const NavigationPropertyBinding = require("../schema/NavigationPropertyBinding");
/**
* Envelops an entity set.
*
* http://docs.oasis-open.org/odata/odata-csdl-xml/v4.01/cs01/odata-csdl-xml-v4.01-cs01.html#sec_EntitySet
*
* @class EntitySet
* @extends {AnnotationTarget}
*/
class EntitySet extends AnnotationTarget {
/**
* Creates an instance of EntitySet.
* @param {Object} rawMetadata raw metadata object for the entity set
* @param {CsdlSchema} schema to resolve entity type reference
* @memberof EntitySet
*/
constructor(rawMetadata, schema) {
super(rawMetadata);
let entityType = schema.resolveModelPath(rawMetadata.$.EntityType);
let navigationPropertyBindings = (
rawMetadata.NavigationPropertyBinding || []
).map((npb) => new NavigationPropertyBinding(npb));
let actions = _.filter(
schema.actions,
(action) => action.entityType === rawMetadata.$.EntityType
);
Object.defineProperty(this, "entityType", {
get: () => entityType,
});
Object.defineProperty(this, "includeInServiceDocument", {
get: () => rawMetadata.$.IncludeInServiceDocument !== "false",
});
Object.defineProperty(this, "navigationPropertyBindings", {
get: () => navigationPropertyBindings,
});
Object.defineProperty(this, "actions", {
get: () => actions,
});
}
/**
* Gets info on parameterization of the entity set
*
* @returns {Object} info with {Bool} isParameterized and {NavigationProperty} valuesAssociation, if isParameterized is true
* @memberof EntitySet
*/
getParameterizationInfo() {
var info = {
isParameterized: false,
};
var paramsNavProp = this.entityType.navigationProperties.find(
(np) =>
np.name === "Set" && np.containsTarget && np.partner === "Parameters"
);
var paramsNavPropBinding = this.navigationPropertyBindings.find(
(npb) => npb.target === this.name && npb.path === "Set/Parameters"
);
if (paramsNavProp && paramsNavPropBinding) {
info.isParameterized = true;
info.valuesAssociation = paramsNavProp;
}
return info;
}
/**
* Gets legacy api object. (XML casing, maybe some other changes.)
*
* @returns {Object} legacy api object
* @memberof EntityType
*/
getLegacyApiObject() {
let api = super.getLegacyApiObject();
api.EntityType = this.entityType.name;
return api;
}
}
module.exports = EntitySet;
|