MCPcopy Create free account
hub / github.com/DanWahlin/CustomerManagerStandard / checkForDups

Function checkForDups

CustomerManager/Scripts/breeze.debug.js:4918–4950  ·  view source on GitHub ↗
(relationArray, adds)

Source from the content-addressed store, hash-verified

4916 }
4917
4918 function checkForDups(relationArray, adds) {
4919 // don't allow dups in this array. - also prevents recursion
4920 var parentEntity = relationArray.parentEntity;
4921 var navProp = relationArray.navigationProperty;
4922 var inverseProp = navProp.inverse;
4923 var goodAdds;
4924 if (inverseProp) {
4925 goodAdds = adds.filter(function (a) {
4926 if (relationArray._addsInProcess.indexOf(a) >= 0) {
4927 return false;
4928 }
4929 var inverseValue = a.getProperty(inverseProp.name);
4930 return inverseValue !== parentEntity;
4931 });
4932 } else {
4933 // This occurs with a unidirectional 1->N relation ( where there is no n -> 1)
4934 // in this case we compare fks.
4935 var fkPropNames = navProp.invForeignKeyNames;
4936 var keyProps = parentEntity.entityType.keyProperties;
4937 goodAdds = adds.filter(function (a) {
4938 if (relationArray._addsInProcess.indexOf(a) >= 0) {
4939 return false;
4940 }
4941 return fkPropNames.some(function (fk, i) {
4942 var keyProp = keyProps[i].name;
4943 var keyVal = parentEntity.getProperty(keyProp);
4944 var fkVal = a.getProperty(fk);
4945 return keyVal !== fkVal;
4946 });
4947 });
4948 }
4949 return goodAdds;
4950 }
4951
4952 function makeRelationArray(arr, parentEntity, navigationProperty) {
4953 arr.parentEntity = parentEntity;

Callers 1

getGoodAddsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected