processResponse(data, ds, query, xhr, request, changes) {
var metaCheck = 'odata.metadata';
if ((request && request.type === 'GET') && !this.rootUrl && data[metaCheck]) {
var dataUrls = data[metaCheck].split('/$metadata#');
this.rootUrl = dataUrls[0];
this.resourceTableName = dataUrls[1];
}
var pvtData = 'pvtData';
if (!isNullOrUndefined(data.d)) {
var dataCopy = ((query && query.isCountRequired) ? data.d.results : data.d);
var metaData = '__metadata';
if (!isNullOrUndefined(dataCopy)) {
for (var i = 0; i < dataCopy.length; i++) {
if (!isNullOrUndefined(dataCopy[i][metaData])) {
delete dataCopy[i][metaData];
}
}
}
}
var pvt = request && request[pvtData];
var emptyAndBatch = this.processBatchResponse(data, query, xhr, request, changes);
if (emptyAndBatch) {
return emptyAndBatch;
}
var versionCheck = xhr && request.getResponseHeader('DataServiceVersion');
var count = null;
var version = (versionCheck && parseInt(versionCheck, 10)) || 2;
if (query && query.isCountRequired) {
var oDataCount = '__count';
if (data[oDataCount] || data['odata.count']) {
count = data[oDataCount] || data['odata.count'];
}
if (data.d) {
data = data.d;
}
if (data[oDataCount] || data['odata.count']) {
count = data[oDataCount] || data['odata.count'];
}
}
if (version === 3 && data.value) {
data = data.value;
}
if (data.d) {
data = data.d;
}
if (version <= 3 && data.results) {
data = data.results;
}
var args = {};
args.count = count;
args.result = data;
this.getAggregateResult(pvt, data, args, null, query);
return DataUtil.isNull(count) ? args.result : { result: args.result, count: args.count, aggregates: args.aggregates };
} |