UNPKG

@easyquery/core

Version:

EasyQuery.JS core modules

92 lines 3.51 kB
import { Expression } from "../dm/expression"; import { LinkType } from "../types/link_type"; import { CondTag } from "../types/cond_tag"; var Condition = /** @class */ (function () { function Condition(tag) { this.linkType = LinkType.All; //only for predicates console.log("Creating condition...", tag); this.justAdded = false; this.tag = tag || CondTag.Unknown; this.enabled = true; this.readOnly = false; this.parameterized = false; this.inJoin = false; this.operatorID = ""; this.blockId = ""; this.expressions = new Array(); this.conditions = new Array(); } Condition.prototype.loadFromData = function (model, data) { console.log("Loading condition...", data); if (data) { this.tag = data.tag; if (this.tag == CondTag.Simple) { if (typeof data.enabled !== "undefined") { this.enabled = data.enabled; } if (typeof data.readOnly !== "undefined") { this.readOnly = data.readOnly; } if (typeof data.inJoin !== "undefined") { this.inJoin = data.inJoin; } if (typeof data.parameterized !== "undefined") { this.parameterized = data.parameterized; } this.operatorID = data.op; ///!!!!!!!!!!!TODO: read ReadOnly and other condition properties if (data.exprs) { for (var i = 0; i < data.exprs.length; i++) { var newExpr = new Expression(); newExpr.loadFromData(model, data.exprs[i]); this.expressions.push(newExpr); } } } else { //if predicate this.linkType = data.linking; if (data.conds) { for (var i = 0; i < data.conds.length; i++) { var newCond = new Condition(); newCond.loadFromData(model, data.conds[i]); this.conditions.push(newCond); } } } } }; Condition.prototype.saveToData = function () { var obj = {}; obj.tag = this.tag; if (this.tag == CondTag.Simple) { if (this.enabled == false) { obj.enabled = this.enabled; } if (this.parameterized) { obj.parameterized = this.parameterized; } if (this.inJoin) { obj.inJoin = this.inJoin; } obj.op = this.operatorID; ///!!!!!!!!!!!TODO: read ReadOnly and other condition properties obj.exprs = []; for (var i = 0; i < this.expressions.length; i++) { obj.exprs.push(this.expressions[i].saveToData()); } } else { //if predicate obj.linking = this.linkType; obj.conds = []; for (var i = 0; i < this.conditions.length; i++) { obj.conds.push(this.conditions[i].saveToData()); } } return obj; }; return Condition; }()); export { Condition }; //# sourceMappingURL=condition.js.map