58
|
1 "use strict";
|
|
2 var result_column_1 = require('./result-column');
|
|
3 var ResultType = (function () {
|
|
4 function ResultType(name, idAttribute, allowedAttributes, deniedAttributes) {
|
|
5 if (allowedAttributes === void 0) { allowedAttributes = []; }
|
|
6 if (deniedAttributes === void 0) { deniedAttributes = []; }
|
|
7 this.name = name;
|
|
8 this.idAttribute = idAttribute;
|
|
9 this.allowedAttributes = allowedAttributes;
|
|
10 this.deniedAttributes = deniedAttributes;
|
|
11 }
|
|
12 /**
|
|
13 * Return columns for the given list of attributes.
|
|
14 */
|
|
15 ResultType.prototype.getColumns = function (attributes, allAttributes) {
|
|
16 var _this = this;
|
|
17 if (allAttributes === void 0) { allAttributes = true; }
|
|
18 var atts = attributes.slice();
|
|
19 var cols = [];
|
|
20 // allowed attributes
|
|
21 this.allowedAttributes.forEach(function (att) {
|
|
22 var idx = atts.indexOf(att);
|
|
23 if (idx > -1) {
|
|
24 cols.push(new result_column_1.ResultColumn(att, att, '', true));
|
|
25 atts[idx] = null;
|
|
26 }
|
|
27 });
|
|
28 // then other attributes
|
|
29 if (allAttributes) {
|
|
30 atts.forEach(function (att) {
|
|
31 if (att != null && att[0] != '_' && _this.deniedAttributes.indexOf(att) < 0) {
|
|
32 cols.push(new result_column_1.ResultColumn(att, att, '', false));
|
|
33 }
|
|
34 });
|
|
35 }
|
|
36 return cols;
|
|
37 };
|
|
38 return ResultType;
|
|
39 }());
|
|
40 exports.ResultType = ResultType;
|
|
41 function getResultType(name, resultTypes) {
|
|
42 var rt = resultTypes[name];
|
|
43 if (rt == null) {
|
|
44 rt = resultTypes['*'];
|
|
45 }
|
|
46 return rt;
|
|
47 }
|
|
48 exports.getResultType = getResultType;
|
|
49 //# sourceMappingURL=result-type.js.map |