@easyquery/core 7.2.3 → 7.2.4-beta03

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/bundles/easyquery.core.js +9353 -9336
  2. package/dist/bundles/easyquery.core.js.map +1 -1
  3. package/dist/bundles/easyquery.core.min.js +1 -1
  4. package/dist/bundles/easyquery.core.min.js.map +1 -1
  5. package/dist/lib/common/eq_services.d.ts +56 -56
  6. package/dist/lib/common/eq_services.js +159 -159
  7. package/dist/lib/common/query_param.d.ts +25 -25
  8. package/dist/lib/common/query_param.js +1 -0
  9. package/dist/lib/common/tree.d.ts +10 -10
  10. package/dist/lib/common/tree.js +57 -57
  11. package/dist/lib/data/eq_aggr_container.d.ts +24 -24
  12. package/dist/lib/data/eq_aggr_container.js +108 -108
  13. package/dist/lib/data/eq_aggr_container.js.map +1 -1
  14. package/dist/lib/data/eq_data_loader.d.ts +8 -8
  15. package/dist/lib/data/eq_data_loader.js +49 -49
  16. package/dist/lib/data/eq_data_loader.js.map +1 -1
  17. package/dist/lib/data/google_data_converter.d.ts +82 -82
  18. package/dist/lib/data/google_data_converter.js +173 -173
  19. package/dist/lib/data/google_data_converter.js.map +1 -1
  20. package/dist/lib/dm/aggr_function.d.ts +27 -27
  21. package/dist/lib/dm/aggr_function.js +42 -42
  22. package/dist/lib/dm/data_model.d.ts +330 -330
  23. package/dist/lib/dm/data_model.js +934 -932
  24. package/dist/lib/dm/data_model.js.map +1 -1
  25. package/dist/lib/dm/dto/af_data.d.ts +16 -16
  26. package/dist/lib/dm/dto/af_data.js +1 -0
  27. package/dist/lib/dm/dto/dm_data.d.ts +34 -34
  28. package/dist/lib/dm/dto/dm_data.js +1 -0
  29. package/dist/lib/dm/dto/entity_data.d.ts +37 -37
  30. package/dist/lib/dm/dto/entity_data.js +1 -0
  31. package/dist/lib/dm/dto/operator_data.d.ts +44 -44
  32. package/dist/lib/dm/dto/operator_data.js +1 -0
  33. package/dist/lib/dm/dto/ve_data.d.ts +10 -10
  34. package/dist/lib/dm/dto/ve_data.js +1 -0
  35. package/dist/lib/dm/entity.d.ts +71 -71
  36. package/dist/lib/dm/entity.js +90 -88
  37. package/dist/lib/dm/entity.js.map +1 -1
  38. package/dist/lib/dm/link.d.ts +7 -7
  39. package/dist/lib/dm/link.js +1 -0
  40. package/dist/lib/dm/operator.d.ts +80 -80
  41. package/dist/lib/dm/operator.js +93 -93
  42. package/dist/lib/dm/value_editor.d.ts +16 -16
  43. package/dist/lib/dm/value_editor.js +43 -41
  44. package/dist/lib/dm/value_editor.js.map +1 -1
  45. package/dist/lib/eqs/eqs_data_fetcher.d.ts +7 -7
  46. package/dist/lib/eqs/eqs_data_fetcher.js +36 -36
  47. package/dist/lib/eqs/eqs_exporter.d.ts +10 -10
  48. package/dist/lib/eqs/eqs_exporter.js +57 -54
  49. package/dist/lib/eqs/eqs_exporter.js.map +1 -1
  50. package/dist/lib/eqs/eqs_model_loader.d.ts +7 -7
  51. package/dist/lib/eqs/eqs_model_loader.js +42 -40
  52. package/dist/lib/eqs/eqs_model_loader.js.map +1 -1
  53. package/dist/lib/eqs/eqs_query_file_loader.d.ts +9 -9
  54. package/dist/lib/eqs/eqs_query_file_loader.js +54 -54
  55. package/dist/lib/eqs/eqs_query_file_loader.js.map +1 -1
  56. package/dist/lib/eqs/eqs_query_synchronizer.d.ts +7 -7
  57. package/dist/lib/eqs/eqs_query_synchronizer.js +23 -23
  58. package/dist/lib/eqs/eqs_value_list_resolver.d.ts +7 -7
  59. package/dist/lib/eqs/eqs_value_list_resolver.js +28 -28
  60. package/dist/lib/export/exporter.d.ts +16 -16
  61. package/dist/lib/export/exporter.js +1 -0
  62. package/dist/lib/i18n/text_resources.d.ts +1 -1
  63. package/dist/lib/i18n/text_resources.js +26 -26
  64. package/dist/lib/i18n/text_resources.js.map +1 -1
  65. package/dist/lib/main/action.d.ts +13 -13
  66. package/dist/lib/main/action.js +5 -5
  67. package/dist/lib/main/context.d.ts +342 -342
  68. package/dist/lib/main/context.js +1439 -1439
  69. package/dist/lib/main/context.js.map +1 -1
  70. package/dist/lib/main/context_options.d.ts +145 -145
  71. package/dist/lib/main/context_options.js +1 -0
  72. package/dist/lib/main/data_fetcher.d.ts +46 -46
  73. package/dist/lib/main/data_fetcher.js +1 -0
  74. package/dist/lib/main/eq_actions.d.ts +14 -14
  75. package/dist/lib/main/eq_actions.js +15 -15
  76. package/dist/lib/main/list_cache.d.ts +8 -8
  77. package/dist/lib/main/list_cache.js +1 -0
  78. package/dist/lib/main/model_loader.d.ts +21 -21
  79. package/dist/lib/main/model_loader.js +32 -32
  80. package/dist/lib/main/model_storage.d.ts +13 -13
  81. package/dist/lib/main/model_storage.js +17 -17
  82. package/dist/lib/main/query_file_loader.d.ts +15 -15
  83. package/dist/lib/main/query_file_loader.js +1 -0
  84. package/dist/lib/main/query_storage.d.ts +58 -58
  85. package/dist/lib/main/query_storage.js +124 -124
  86. package/dist/lib/main/query_synchronizer.d.ts +9 -9
  87. package/dist/lib/main/query_synchronizer.js +1 -0
  88. package/dist/lib/main/value_list_resolver.d.ts +18 -18
  89. package/dist/lib/main/value_list_resolver.js +1 -0
  90. package/dist/lib/main/widget.d.ts +74 -74
  91. package/dist/lib/main/widget.js +101 -101
  92. package/dist/lib/public_api.d.ts +58 -58
  93. package/dist/lib/public_api.js +59 -42
  94. package/dist/lib/public_api.js.map +1 -1
  95. package/dist/lib/query/condition.d.ts +97 -97
  96. package/dist/lib/query/condition.js +331 -331
  97. package/dist/lib/query/descriptors.d.ts +36 -36
  98. package/dist/lib/query/descriptors.js +1 -0
  99. package/dist/lib/query/dto/condition_data.d.ts +38 -38
  100. package/dist/lib/query/dto/condition_data.js +1 -0
  101. package/dist/lib/query/dto/expression_data.d.ts +32 -32
  102. package/dist/lib/query/dto/expression_data.js +1 -0
  103. package/dist/lib/query/dto/query_column_data.d.ts +28 -28
  104. package/dist/lib/query/dto/query_column_data.js +1 -0
  105. package/dist/lib/query/dto/query_data.d.ts +27 -27
  106. package/dist/lib/query/dto/query_data.js +1 -0
  107. package/dist/lib/query/expression.d.ts +69 -69
  108. package/dist/lib/query/expression.js +202 -202
  109. package/dist/lib/query/query.d.ts +410 -410
  110. package/dist/lib/query/query.js +1393 -1391
  111. package/dist/lib/query/query.js.map +1 -1
  112. package/dist/lib/query/query_column.d.ts +70 -70
  113. package/dist/lib/query/query_column.js +157 -157
  114. package/dist/lib/query/query_events.d.ts +29 -29
  115. package/dist/lib/query/query_events.js +19 -19
  116. package/dist/lib/types/cond_part.d.ts +6 -6
  117. package/dist/lib/types/cond_part.js +7 -7
  118. package/dist/lib/types/cond_tag.d.ts +12 -12
  119. package/dist/lib/types/cond_tag.js +13 -13
  120. package/dist/lib/types/data_kind.d.ts +15 -15
  121. package/dist/lib/types/data_kind.js +16 -16
  122. package/dist/lib/types/eq_editor_tag.d.ts +17 -17
  123. package/dist/lib/types/eq_editor_tag.js +20 -20
  124. package/dist/lib/types/expr_tag.d.ts +19 -19
  125. package/dist/lib/types/expr_tag.js +20 -20
  126. package/dist/lib/types/link_type.d.ts +17 -17
  127. package/dist/lib/types/link_type.js +18 -18
  128. package/dist/lib/types/widget_group.d.ts +17 -17
  129. package/dist/lib/types/widget_group.js +18 -18
  130. package/dist/lib/utils/constants.d.ts +36 -36
  131. package/dist/lib/utils/constants.js +50 -50
  132. package/dist/lib/utils/format_parser.d.ts +40 -40
  133. package/dist/lib/utils/format_parser.js +87 -87
  134. package/dist/lib/utils/utils.d.ts +34 -34
  135. package/dist/lib/utils/utils.js +102 -102
  136. package/dist/lib/utils/version_info.d.ts +9 -9
  137. package/dist/lib/utils/version_info.js +12 -12
  138. package/dist/lib/utils/version_info.js.map +1 -1
  139. package/package.json +16 -16
  140. package/webpack.config.js +6 -5
@@ -1,332 +1,332 @@
1
- import { DataType, EditorTag, utils as dataUtils } from '@easydata/core';
2
- import { Expression } from './expression';
3
- import { DataKind } from '../types/data_kind';
4
- import { LinkType } from '../types/link_type';
5
- import { CondTag } from '../types/cond_tag';
6
- import { ExprTag } from '../types/expr_tag';
7
- import { QueryChangePart, QueryChangeAction } from './query_events';
8
- import { EqValueEditor } from '../dm/value_editor';
9
- import { EqEditorTag } from '../types/eq_editor_tag';
10
- import { ConditionPart } from '../types/cond_part';
11
- /**
12
- * Represents some condition.
13
- */
14
- var Condition = /** @class */ (function () {
15
- /**
16
- * The default constructor.
17
- * @param tag The condition tag
18
- */
19
- function Condition(query, tag) {
20
- this.query = query;
21
- /**
22
- * The linking type.
23
- */
24
- this.linkType = LinkType.All; //only for predicates
25
- this.parent = null;
26
- this._id = dataUtils.generateId('cond');
27
- this.justAdded = false;
28
- this.tag = tag || CondTag.Unknown;
29
- this.enabled = true;
30
- this.operatorId = '';
31
- this.blockId = '';
32
- this.expressions = new Array();
33
- this.conditions = new Array();
34
- }
35
- Object.defineProperty(Condition.prototype, "id", {
36
- get: function () {
37
- return this._id;
38
- },
39
- enumerable: true,
40
- configurable: true
41
- });
42
- Object.defineProperty(Condition.prototype, "enabled", {
43
- get: function () {
44
- return this._enabled && (!this.getParent() || this.getParent().enabled);
45
- },
46
- set: function (value) {
47
- this._enabled = value && (!this.getParent() || this.getParent().enabled);
48
- this.conditions && this.conditions.forEach(function (cond) {
49
- cond.enabled = value;
50
- });
51
- },
52
- enumerable: true,
53
- configurable: true
54
- });
55
- Condition.prototype.getQuery = function () {
56
- return this.query;
57
- };
58
- Condition.prototype.getModel = function () {
59
- return this.query.getModel();
60
- };
61
- Condition.prototype.getParent = function () {
62
- return this.parent;
63
- };
64
- Condition.prototype.setParent = function (parent) {
65
- this.parent = parent;
66
- };
67
- Condition.prototype.getConditions = function () {
68
- return this.conditions;
69
- };
70
- Condition.prototype.isEmpty = function () {
71
- return this.conditions.length === 0;
72
- };
73
- Condition.prototype.isGroup = function () {
74
- return (this.tag == CondTag.Group) || (this.parent == null);
75
- };
76
- Condition.prototype.getLevel = function () {
77
- var parent = this.getParent();
78
- return parent ? parent.getLevel() + 1 : 0;
79
- };
80
- /**
81
- * Indicates whether this condition is read-only.
82
- */
83
- Condition.prototype.isReadOnly = function () {
84
- return false;
85
- };
86
- Condition.prototype.setReadOnly = function (value) {
87
- };
88
- /**
89
- * The value indicating whether this condition is parameterized.
90
- */
91
- Condition.prototype.isParameterized = function () {
92
- return false;
93
- };
94
- Condition.prototype.setParameterized = function (value) {
95
- };
96
- /**
97
- * Indicates whether this condition must be placed into `JOIN` clause in result `SQL`.
98
- */
99
- Condition.prototype.isInJoin = function () {
100
- return false;
101
- };
102
- Condition.prototype.setInJoin = function (value) {
103
- };
104
- Condition.prototype.clearConditions = function () {
105
- this.conditions = [];
106
- };
107
- Condition.prototype.addCondition = function (cond) {
108
- cond.setParent(this);
109
- return this.conditions.push(cond);
110
- };
111
- Condition.prototype.removeConditionAt = function (index) {
112
- this.conditions.splice(index, 1);
113
- };
114
- /**
115
- * Loads condtion from its JSON representation object.
116
- * @param model The Data Model.
117
- * @param data The JSON representation object.
118
- */
119
- Condition.prototype.loadFromData = function (model, data) {
120
- if (data) {
121
- this.tag = data.tag;
122
- if (!this.tag) {
123
- this.tag = (!this.parent || this.conditions.length > 0) ? CondTag.Group : CondTag.Simple;
124
- }
125
- if (typeof data.enabled !== 'undefined') {
126
- this.enabled = data.enabled;
127
- }
128
- if (typeof data.disabled !== 'undefined') {
129
- this.enabled = !data.disabled;
130
- }
131
- if (this.tag == CondTag.Simple) {
132
- this.operatorId = data.op;
133
- if (data.exprs) {
134
- for (var i = 0; i < data.exprs.length; i++) {
135
- var newExpr = new Expression(this);
136
- newExpr.loadFromData(model, data.exprs[i]);
137
- this.expressions.push(newExpr);
138
- }
139
- }
140
- }
141
- this.linkType = data.linking;
142
- }
143
- };
144
- /**
145
- * Saves condition to JSON representation object.
146
- * @returns The JSON representation object.
147
- */
148
- Condition.prototype.saveToData = function () {
149
- var obj = {};
150
- obj.tag = this.tag;
151
- if (!this.enabled) {
152
- obj.enabled = this.enabled;
153
- }
154
- if (this.tag == CondTag.Simple) {
155
- obj.op = this.operatorId;
156
- obj.exprs = [];
157
- for (var i = 0; i < this.expressions.length; i++) {
158
- obj.exprs.push(this.expressions[i].saveToData());
159
- }
160
- }
161
- if (this.tag == CondTag.Group) {
162
- //if condition group
163
- obj.linking = this.linkType;
164
- }
165
- return obj;
166
- };
167
- Condition.prototype.fireChangedEvent = function (condPart) {
168
- if (condPart === void 0) { condPart = ConditionPart.All; }
169
- this.query.fireChangedEvent({
170
- part: QueryChangePart.Conditions,
171
- action: QueryChangeAction.Modify,
172
- changee: this,
173
- condPart: condPart
174
- });
175
- };
176
- Condition.prototype.getExpressionIndex = function (expr) {
177
- return this.expressions.indexOf(expr, 0);
178
- };
179
- Condition.prototype.expressionChanged = function (expr, oldValue) {
180
- if (expr.getIndex() == 0 && expr.tag == ExprTag.EntityAttribute) {
181
- //this is a base entity attribute, we need to re-pack the whole condition
182
- this.tuneOperatorForAttr(expr.value);
183
- }
184
- };
185
- Condition.prototype.getOperatorId = function () {
186
- return this.operatorId;
187
- };
188
- Condition.prototype.setOperatorId = function (newOperatorId, silent) {
189
- if (silent === void 0) { silent = false; }
190
- var oldOperatorId = this.operatorId;
191
- this.operatorId = newOperatorId;
192
- if (!silent) {
193
- var model = this.getModel();
194
- var operator = model.getOperatorById(newOperatorId);
195
- var attrId = this.expressions[0].value;
196
- var attr = model.getAttributeById(attrId);
197
- this.tuneValueExpressions(attr, operator, attr.id, oldOperatorId);
198
- }
199
- };
200
- Condition.prototype.tuneOperatorForAttr = function (oldAttrId) {
201
- var model = this.getModel();
202
- var attrId = this.expressions[0].value;
203
- var attr = model.getAttributeById(attrId);
204
- if (attr != null) {
205
- var newOperator = this.getModel().getDefaultOperatorForAttr(attr);
206
- var oldOperatorId = this.operatorId;
207
- this.operatorId = newOperator.id;
208
- this.tuneValueExpressions(attr, newOperator, oldAttrId, oldOperatorId);
209
- }
210
- };
211
- Condition.prototype.tuneValueExpressions = function (attr, operator, oldAttrId, oldOperatorId) {
212
- var model = this.getModel();
213
- if (!operator)
214
- return;
215
- var exprCount = this.expressions.length;
216
- var oldAttr = oldAttrId ? model.getAttributeById(oldAttrId) : null;
217
- var oldOperator = null;
218
- if (oldOperatorId) {
219
- oldOperator = model.getOperatorById(oldOperatorId);
220
- }
221
- if (oldOperator && oldOperator.paramCount == operator.paramCount) {
222
- //add necessary expressions
223
- var i = 1;
224
- while (i < operator.paramCount) {
225
- var oldOperand = model.getOperand(attr, oldOperator, i);
226
- var operand = model.getOperand(attr, operator, i);
227
- if (operand.dataType == DataType.Unknown) {
228
- operand.dataType = attr.dataType;
229
- }
230
- var editor = operand.editor && operand.editor.tag !== EditorTag.Unknown
231
- ? operand.editor
232
- : (attr.defaultEditor && attr.defaultEditor.tag !== EditorTag.Unknown
233
- ? attr.defaultEditor
234
- : new EqValueEditor());
235
- if (i >= exprCount) {
236
- var valExpr = this.createValueExpr(operand);
237
- this.expressions.push(valExpr);
238
- }
239
- else {
240
- var oldExpr = this.expressions[i];
241
- //create new value expression according to the corresponding operand
242
- var newExpr = this.createValueExpr(operand);
243
- if (this.areCompitableEditors(oldOperand.editor, editor)) {
244
- newExpr.tryCopyValueFrom(oldExpr);
245
- }
246
- this.expressions[i] = newExpr;
247
- }
248
- i++;
249
- }
250
- if (exprCount > i) {
251
- //remove all redundant expressions
252
- this.expressions.splice(i, exprCount - i);
253
- }
254
- }
255
- else {
256
- this.expressions.splice(1, this.expressions.length - 1);
257
- for (var i = 1; i < operator.paramCount; i++) {
258
- var operand = model.getOperand(attr, operator, i);
259
- if (operand.dataType == DataType.Unknown) {
260
- operand.dataType = attr.dataType;
261
- }
262
- var valExpr = this.createValueExpr(operand);
263
- this.expressions.push(valExpr);
264
- }
265
- }
266
- };
267
- Condition.prototype.areCompitableEditors = function (oldEditor, newEditor) {
268
- if (newEditor.tag == EqEditorTag.CustomList || newEditor.tag == EqEditorTag.List
269
- || newEditor.tag == EqEditorTag.SqlList || newEditor.tag == EditorTag.Unknown) {
270
- return false;
271
- }
272
- return true;
273
- };
274
- Condition.prototype.addExpressionByOperand = function (operand, val) {
275
- if (val === void 0) { val = null; }
276
- var expr = this.createValueExpr(operand, val);
277
- this.expressions.push(expr);
278
- return expr;
279
- };
280
- Condition.prototype.createValueExpr = function (operand, val) {
281
- if (val === void 0) { val = null; }
282
- var valueNotDefined = val === null || typeof val === 'undefined';
283
- var value = val ? val : operand.defValue;
284
- var text = val ? val : operand.defText;
285
- var result = new Expression(this);
286
- if (operand.kind === DataKind.Query) {
287
- result.tag = ExprTag.Query;
288
- result.dataType = operand.dataType;
289
- result.kind = operand.kind;
290
- result.setContent(value, text, true);
291
- }
292
- else if (operand.kind === DataKind.Attribute) {
293
- if (!valueNotDefined) {
294
- var defAttr = this.getModel().getFirstAttributeByFilter(function (attr) {
295
- return attr.useInConditions == true && (!operand.dataType || attr.dataType == operand.dataType);
296
- });
297
- value = defAttr ? defAttr.id : null;
298
- }
299
- result.tag = ExprTag.EntityAttribute;
300
- result.kind = operand.kind;
301
- result.dataType = operand.dataType;
302
- result.setContent(value, text, true);
303
- }
304
- else {
305
- if (valueNotDefined) {
306
- if (operand.defValue && operand.defValue != "") {
307
- value = operand.defValue;
308
- }
309
- else {
310
- if (operand.editor && operand.editor.defValue) {
311
- value = operand.editor.defValue;
312
- }
313
- else {
314
- value = '';
315
- }
316
- }
317
- if (operand.editor) {
318
- text = operand.editor.getValueText(value);
319
- }
320
- }
321
- result.tag = ExprTag.Constant;
322
- result.dataType = operand.dataType;
323
- result.kind = operand.kind;
324
- result.setContent(value, text, true);
325
- result._isDefaultValue = valueNotDefined;
326
- }
327
- return result;
328
- };
329
- return Condition;
330
- }());
331
- export { Condition };
1
+ import { DataType, EditorTag, utils as dataUtils } from '@easydata/core';
2
+ import { Expression } from './expression';
3
+ import { DataKind } from '../types/data_kind';
4
+ import { LinkType } from '../types/link_type';
5
+ import { CondTag } from '../types/cond_tag';
6
+ import { ExprTag } from '../types/expr_tag';
7
+ import { QueryChangePart, QueryChangeAction } from './query_events';
8
+ import { EqValueEditor } from '../dm/value_editor';
9
+ import { EqEditorTag } from '../types/eq_editor_tag';
10
+ import { ConditionPart } from '../types/cond_part';
11
+ /**
12
+ * Represents some condition.
13
+ */
14
+ var Condition = /** @class */ (function () {
15
+ /**
16
+ * The default constructor.
17
+ * @param tag The condition tag
18
+ */
19
+ function Condition(query, tag) {
20
+ this.query = query;
21
+ /**
22
+ * The linking type.
23
+ */
24
+ this.linkType = LinkType.All; //only for predicates
25
+ this.parent = null;
26
+ this._id = dataUtils.generateId('cond');
27
+ this.justAdded = false;
28
+ this.tag = tag || CondTag.Unknown;
29
+ this.enabled = true;
30
+ this.operatorId = '';
31
+ this.blockId = '';
32
+ this.expressions = new Array();
33
+ this.conditions = new Array();
34
+ }
35
+ Object.defineProperty(Condition.prototype, "id", {
36
+ get: function () {
37
+ return this._id;
38
+ },
39
+ enumerable: false,
40
+ configurable: true
41
+ });
42
+ Object.defineProperty(Condition.prototype, "enabled", {
43
+ get: function () {
44
+ return this._enabled && (!this.getParent() || this.getParent().enabled);
45
+ },
46
+ set: function (value) {
47
+ this._enabled = value && (!this.getParent() || this.getParent().enabled);
48
+ this.conditions && this.conditions.forEach(function (cond) {
49
+ cond.enabled = value;
50
+ });
51
+ },
52
+ enumerable: false,
53
+ configurable: true
54
+ });
55
+ Condition.prototype.getQuery = function () {
56
+ return this.query;
57
+ };
58
+ Condition.prototype.getModel = function () {
59
+ return this.query.getModel();
60
+ };
61
+ Condition.prototype.getParent = function () {
62
+ return this.parent;
63
+ };
64
+ Condition.prototype.setParent = function (parent) {
65
+ this.parent = parent;
66
+ };
67
+ Condition.prototype.getConditions = function () {
68
+ return this.conditions;
69
+ };
70
+ Condition.prototype.isEmpty = function () {
71
+ return this.conditions.length === 0;
72
+ };
73
+ Condition.prototype.isGroup = function () {
74
+ return (this.tag == CondTag.Group) || (this.parent == null);
75
+ };
76
+ Condition.prototype.getLevel = function () {
77
+ var parent = this.getParent();
78
+ return parent ? parent.getLevel() + 1 : 0;
79
+ };
80
+ /**
81
+ * Indicates whether this condition is read-only.
82
+ */
83
+ Condition.prototype.isReadOnly = function () {
84
+ return false;
85
+ };
86
+ Condition.prototype.setReadOnly = function (value) {
87
+ };
88
+ /**
89
+ * The value indicating whether this condition is parameterized.
90
+ */
91
+ Condition.prototype.isParameterized = function () {
92
+ return false;
93
+ };
94
+ Condition.prototype.setParameterized = function (value) {
95
+ };
96
+ /**
97
+ * Indicates whether this condition must be placed into `JOIN` clause in result `SQL`.
98
+ */
99
+ Condition.prototype.isInJoin = function () {
100
+ return false;
101
+ };
102
+ Condition.prototype.setInJoin = function (value) {
103
+ };
104
+ Condition.prototype.clearConditions = function () {
105
+ this.conditions = [];
106
+ };
107
+ Condition.prototype.addCondition = function (cond) {
108
+ cond.setParent(this);
109
+ return this.conditions.push(cond);
110
+ };
111
+ Condition.prototype.removeConditionAt = function (index) {
112
+ this.conditions.splice(index, 1);
113
+ };
114
+ /**
115
+ * Loads condtion from its JSON representation object.
116
+ * @param model The Data Model.
117
+ * @param data The JSON representation object.
118
+ */
119
+ Condition.prototype.loadFromData = function (model, data) {
120
+ if (data) {
121
+ this.tag = data.tag;
122
+ if (!this.tag) {
123
+ this.tag = (!this.parent || this.conditions.length > 0) ? CondTag.Group : CondTag.Simple;
124
+ }
125
+ if (typeof data.enabled !== 'undefined') {
126
+ this.enabled = data.enabled;
127
+ }
128
+ if (typeof data.disabled !== 'undefined') {
129
+ this.enabled = !data.disabled;
130
+ }
131
+ if (this.tag == CondTag.Simple) {
132
+ this.operatorId = data.op;
133
+ if (data.exprs) {
134
+ for (var i = 0; i < data.exprs.length; i++) {
135
+ var newExpr = new Expression(this);
136
+ newExpr.loadFromData(model, data.exprs[i]);
137
+ this.expressions.push(newExpr);
138
+ }
139
+ }
140
+ }
141
+ this.linkType = data.linking;
142
+ }
143
+ };
144
+ /**
145
+ * Saves condition to JSON representation object.
146
+ * @returns The JSON representation object.
147
+ */
148
+ Condition.prototype.saveToData = function () {
149
+ var obj = {};
150
+ obj.tag = this.tag;
151
+ if (!this.enabled) {
152
+ obj.enabled = this.enabled;
153
+ }
154
+ if (this.tag == CondTag.Simple) {
155
+ obj.op = this.operatorId;
156
+ obj.exprs = [];
157
+ for (var i = 0; i < this.expressions.length; i++) {
158
+ obj.exprs.push(this.expressions[i].saveToData());
159
+ }
160
+ }
161
+ if (this.tag == CondTag.Group) {
162
+ //if condition group
163
+ obj.linking = this.linkType;
164
+ }
165
+ return obj;
166
+ };
167
+ Condition.prototype.fireChangedEvent = function (condPart) {
168
+ if (condPart === void 0) { condPart = ConditionPart.All; }
169
+ this.query.fireChangedEvent({
170
+ part: QueryChangePart.Conditions,
171
+ action: QueryChangeAction.Modify,
172
+ changee: this,
173
+ condPart: condPart
174
+ });
175
+ };
176
+ Condition.prototype.getExpressionIndex = function (expr) {
177
+ return this.expressions.indexOf(expr, 0);
178
+ };
179
+ Condition.prototype.expressionChanged = function (expr, oldValue) {
180
+ if (expr.getIndex() == 0 && expr.tag == ExprTag.EntityAttribute) {
181
+ //this is a base entity attribute, we need to re-pack the whole condition
182
+ this.tuneOperatorForAttr(expr.value);
183
+ }
184
+ };
185
+ Condition.prototype.getOperatorId = function () {
186
+ return this.operatorId;
187
+ };
188
+ Condition.prototype.setOperatorId = function (newOperatorId, silent) {
189
+ if (silent === void 0) { silent = false; }
190
+ var oldOperatorId = this.operatorId;
191
+ this.operatorId = newOperatorId;
192
+ if (!silent) {
193
+ var model = this.getModel();
194
+ var operator = model.getOperatorById(newOperatorId);
195
+ var attrId = this.expressions[0].value;
196
+ var attr = model.getAttributeById(attrId);
197
+ this.tuneValueExpressions(attr, operator, attr.id, oldOperatorId);
198
+ }
199
+ };
200
+ Condition.prototype.tuneOperatorForAttr = function (oldAttrId) {
201
+ var model = this.getModel();
202
+ var attrId = this.expressions[0].value;
203
+ var attr = model.getAttributeById(attrId);
204
+ if (attr != null) {
205
+ var newOperator = this.getModel().getDefaultOperatorForAttr(attr);
206
+ var oldOperatorId = this.operatorId;
207
+ this.operatorId = newOperator.id;
208
+ this.tuneValueExpressions(attr, newOperator, oldAttrId, oldOperatorId);
209
+ }
210
+ };
211
+ Condition.prototype.tuneValueExpressions = function (attr, operator, oldAttrId, oldOperatorId) {
212
+ var model = this.getModel();
213
+ if (!operator)
214
+ return;
215
+ var exprCount = this.expressions.length;
216
+ var oldAttr = oldAttrId ? model.getAttributeById(oldAttrId) : null;
217
+ var oldOperator = null;
218
+ if (oldOperatorId) {
219
+ oldOperator = model.getOperatorById(oldOperatorId);
220
+ }
221
+ if (oldOperator && oldOperator.paramCount == operator.paramCount) {
222
+ //add necessary expressions
223
+ var i = 1;
224
+ while (i < operator.paramCount) {
225
+ var oldOperand = model.getOperand(attr, oldOperator, i);
226
+ var operand = model.getOperand(attr, operator, i);
227
+ if (operand.dataType == DataType.Unknown) {
228
+ operand.dataType = attr.dataType;
229
+ }
230
+ var editor = operand.editor && operand.editor.tag !== EditorTag.Unknown
231
+ ? operand.editor
232
+ : (attr.defaultEditor && attr.defaultEditor.tag !== EditorTag.Unknown
233
+ ? attr.defaultEditor
234
+ : new EqValueEditor());
235
+ if (i >= exprCount) {
236
+ var valExpr = this.createValueExpr(operand);
237
+ this.expressions.push(valExpr);
238
+ }
239
+ else {
240
+ var oldExpr = this.expressions[i];
241
+ //create new value expression according to the corresponding operand
242
+ var newExpr = this.createValueExpr(operand);
243
+ if (this.areCompitableEditors(oldOperand.editor, editor)) {
244
+ newExpr.tryCopyValueFrom(oldExpr);
245
+ }
246
+ this.expressions[i] = newExpr;
247
+ }
248
+ i++;
249
+ }
250
+ if (exprCount > i) {
251
+ //remove all redundant expressions
252
+ this.expressions.splice(i, exprCount - i);
253
+ }
254
+ }
255
+ else {
256
+ this.expressions.splice(1, this.expressions.length - 1);
257
+ for (var i = 1; i < operator.paramCount; i++) {
258
+ var operand = model.getOperand(attr, operator, i);
259
+ if (operand.dataType == DataType.Unknown) {
260
+ operand.dataType = attr.dataType;
261
+ }
262
+ var valExpr = this.createValueExpr(operand);
263
+ this.expressions.push(valExpr);
264
+ }
265
+ }
266
+ };
267
+ Condition.prototype.areCompitableEditors = function (oldEditor, newEditor) {
268
+ if (newEditor.tag == EqEditorTag.CustomList || newEditor.tag == EqEditorTag.List
269
+ || newEditor.tag == EqEditorTag.SqlList || newEditor.tag == EditorTag.Unknown) {
270
+ return false;
271
+ }
272
+ return true;
273
+ };
274
+ Condition.prototype.addExpressionByOperand = function (operand, val) {
275
+ if (val === void 0) { val = null; }
276
+ var expr = this.createValueExpr(operand, val);
277
+ this.expressions.push(expr);
278
+ return expr;
279
+ };
280
+ Condition.prototype.createValueExpr = function (operand, val) {
281
+ if (val === void 0) { val = null; }
282
+ var valueNotDefined = val === null || typeof val === 'undefined';
283
+ var value = val ? val : operand.defValue;
284
+ var text = val ? val : operand.defText;
285
+ var result = new Expression(this);
286
+ if (operand.kind === DataKind.Query) {
287
+ result.tag = ExprTag.Query;
288
+ result.dataType = operand.dataType;
289
+ result.kind = operand.kind;
290
+ result.setContent(value, text, true);
291
+ }
292
+ else if (operand.kind === DataKind.Attribute) {
293
+ if (!valueNotDefined) {
294
+ var defAttr = this.getModel().getFirstAttributeByFilter(function (attr) {
295
+ return attr.useInConditions == true && (!operand.dataType || attr.dataType == operand.dataType);
296
+ });
297
+ value = defAttr ? defAttr.id : null;
298
+ }
299
+ result.tag = ExprTag.EntityAttribute;
300
+ result.kind = operand.kind;
301
+ result.dataType = operand.dataType;
302
+ result.setContent(value, text, true);
303
+ }
304
+ else {
305
+ if (valueNotDefined) {
306
+ if (operand.defValue && operand.defValue != "") {
307
+ value = operand.defValue;
308
+ }
309
+ else {
310
+ if (operand.editor && operand.editor.defValue) {
311
+ value = operand.editor.defValue;
312
+ }
313
+ else {
314
+ value = '';
315
+ }
316
+ }
317
+ if (operand.editor) {
318
+ text = operand.editor.getValueText(value);
319
+ }
320
+ }
321
+ result.tag = ExprTag.Constant;
322
+ result.dataType = operand.dataType;
323
+ result.kind = operand.kind;
324
+ result.setContent(value, text, true);
325
+ result._isDefaultValue = valueNotDefined;
326
+ }
327
+ return result;
328
+ };
329
+ return Condition;
330
+ }());
331
+ export { Condition };
332
332
  //# sourceMappingURL=condition.js.map