UNPKG

igniteui-angular-core

Version:

Ignite UI Angular Core logic used in multiple UI components.

461 lines (460 loc) 14.9 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import { __extends, __values } from "tslib"; import { Base, INotifyPropertyChanged_$type, PropertyChangedEventArgs, String_$type, fromEnum, markType } from "./type"; import { StockPriceHistory } from "./StockPriceHistory"; import { StockPosition } from "./StockPosition"; import { StockChangedEventArgs } from "./StockChangedEventArgs"; import { Dictionary$2 } from "./Dictionary$2"; import { List$1 } from "./List$1"; import { StockDataGenerator } from "./StockDataGenerator"; import { arrayClear } from "./array"; import { stringIsNullOrEmpty } from "./string"; /** * @hidden */ var FinancialDataAdapter = /** @class */ /*@__PURE__*/ (function (_super) { __extends(FinancialDataAdapter, _super); function FinancialDataAdapter() { var _this = _super.call(this) || this; _this.e = new Array(0); _this.c = new Array(0); _this.d = ["*.open", "*.high", "*.low", "*.close", "*.volume", "*.date"]; _this.b = new Array(0); _this.a = null; _this.aa = 6; _this.z = 10; _this.r = true; _this.propertyChanged = null; _this.populateStockPosition = null; _this.populateStockPrices = null; _this.stockSymbolsChanged = null; _this.v = new Dictionary$2(String_$type, StockPriceHistory.$, 0); _this.x = new List$1(StockPosition.$, 0); _this.w = new Dictionary$2(String_$type, String_$type, 0); _this.o = new StockDataGenerator(); _this.o = new StockDataGenerator(); _this.a = _this.o.generateDetails(); return _this; } Object.defineProperty(FinancialDataAdapter.prototype, "stockSymbols", { get: function () { return this.e; }, set: function (a) { this.a1(this.e, a); }, enumerable: false, configurable: true }); Object.defineProperty(FinancialDataAdapter.prototype, "stockPrices", { get: function () { return this.c; }, set: function (a) { var b = this.c; this.c = a; if (b != this.c) { this.ap("StockPrices", b, this.c); } }, enumerable: false, configurable: true }); Object.defineProperty(FinancialDataAdapter.prototype, "stockPricesMemberPaths", { get: function () { return this.d; }, enumerable: false, configurable: true }); Object.defineProperty(FinancialDataAdapter.prototype, "stockPositions", { get: function () { return this.b; }, set: function (a) { var b = this.b; this.b = a; if (b != this.b) { this.ap("StockPositions", b, this.b); } }, enumerable: false, configurable: true }); Object.defineProperty(FinancialDataAdapter.prototype, "stockDetails", { get: function () { return this.a; }, set: function (a) { var b = this.a; this.a = a; if (b != this.a) { this.ap("StockDetails", b, this.a); } }, enumerable: false, configurable: true }); Object.defineProperty(FinancialDataAdapter.prototype, "ac", { get: function () { return this.aa; }, set: function (a) { var b = this.aa; this.aa = a; if (b != this.aa) { this.ap("StockPricesTimeRange", b, this.aa); } }, enumerable: false, configurable: true }); Object.defineProperty(FinancialDataAdapter.prototype, "ab", { get: function () { return this.z; }, set: function (a) { var b = this.z; this.z = a; if (b != this.z) { this.ap("StockPricesTimeInterval", b, this.z); } }, enumerable: false, configurable: true }); Object.defineProperty(FinancialDataAdapter.prototype, "u", { get: function () { return this.r; }, set: function (a) { var b = this.r; this.r = a; if (b != this.r) { this.ap("StockPricesTradeAfterHours", b, this.r); } }, enumerable: false, configurable: true }); FinancialDataAdapter.prototype.ap = function (a, b, c) { this.aq(a, b, c); if (this.propertyChanged != null) { this.propertyChanged(this, new PropertyChangedEventArgs(a)); } }; FinancialDataAdapter.prototype.aq = function (a, b, c) { switch (a) { case "StockPricesTimeRange": case "StockPricesTimeInterval": case "StockPricesTradeAfterHours": this.az(); break; case "StockSymbols": this.ay(b, c); break; } }; FinancialDataAdapter.prototype.au = function (a, b) { if (a == null) { a = new Array(0); } if (b == null) { b = new Array(0); } this.log("OnStockChanged " + a.length + " -> " + b.length); if (this.stockSymbolsChanged != null) { this.stockSymbolsChanged(this, new StockChangedEventArgs(a, b)); } }; FinancialDataAdapter.prototype.log = function (message_) { }; FinancialDataAdapter.prototype.clearData = function () { this.e = new Array(0); this.v.clear(); this.x.clear(); arrayClear(this.stockPrices); arrayClear(this.stockPositions); }; FinancialDataAdapter.prototype.removeStockPosition = function (a) { this.ar(a); }; FinancialDataAdapter.prototype.removeStockPrices = function (a) { this.as(a, 0); }; FinancialDataAdapter.prototype.ax = function (a, b) { if (b === void 0) { b = ""; } var e = this.stockSymbols; for (var d = 0; d < e.length; d++) { var c = e[d]; if (!this.w.containsKey(c)) { this.w.addItem(c, ""); } } if (this.w.containsKey(a)) { this.w.item(a, b); } else { this.w.addItem(a, b); } var f = this.y(String_$type, this.stockSymbols); if (!f.contains(a)) { f.add(a); } this.stockSymbols = this.f(String_$type, f); }; FinancialDataAdapter.prototype.a0 = function (a) { if (this.v.containsKey(a)) { var b = this.y(String_$type, this.stockSymbols); if (this.w.containsKey(a)) { this.w.removeItem(a); } var c = this.y(String_$type, this.stockSymbols); if (c.contains(a)) { c.remove(a); } this.e = this.f(String_$type, c); this.ay(this.f(String_$type, b), this.f(String_$type, c)); } }; FinancialDataAdapter.prototype.ad = function (a) { if (stringIsNullOrEmpty(a)) { return ""; } if (this.w.containsKey(a)) { return this.w.item(a); } return ""; }; FinancialDataAdapter.prototype.q = function (a) { this.o.dateRange = this.ac; this.o.dateInterval = this.ab; this.o.skipAfterHours = !this.u; var b = this.ad(a); var c; if (this.populateStockPrices == null) { this.log("OnGeneratingPrices " + a); c = this.o.generateStockPrices(a, b); } else { this.log("OnPopulatePrices " + a); c = this.populateStockPrices(a); } return c; }; FinancialDataAdapter.prototype.p = function (a) { this.o.dateRange = this.ac; this.o.dateInterval = this.ab; this.o.skipAfterHours = !this.u; var b = this.ad(a); var c; if (this.populateStockPosition == null) { this.log("OnGeneratingPosition " + a); c = this.o.generatePosition(a, b); } else { this.log("OnPopulatePosition " + a); c = this.populateStockPosition(a); } return c; }; FinancialDataAdapter.prototype.an = function (a, b) { if (stringIsNullOrEmpty(a)) { return; } if (b == null) { return; } b.index = this.x.count; this.x.add(b); this.stockPositions = this.f(StockPosition.$, this.x); }; FinancialDataAdapter.prototype.ao = function (a, b) { if (stringIsNullOrEmpty(a)) { return; } if (b == null) { return; } this.log("OnAddingPrices " + a); if (!this.v.containsKey(a)) { this.v.addItem(a, b); } else { return; } this.stockPrices = this.f(StockPriceHistory.$, this.v.values); }; FinancialDataAdapter.prototype.as = function (a, b) { if (stringIsNullOrEmpty(a)) { return; } this.log("OnRemovingPrices " + a); if (this.v.containsKey(a)) { this.v.removeItem(a); } else { return; } this.stockPrices = this.f(StockPriceHistory.$, this.v.values); }; FinancialDataAdapter.prototype.ar = function (a) { this.log("OnRemovingPosition " + a); if (this.x.count > a) { this.x.removeAt(a); } else { return; } for (var b = 0; b < this.x.count; b++) { this.x._inner[b].index = b; } this.stockPositions = this.f(StockPosition.$, this.x); }; FinancialDataAdapter.prototype.at = function () { this.log("OnStockClearing "); this.a1(this.stockSymbols, new Array(0), true); }; FinancialDataAdapter.prototype.a1 = function (a, b, c) { if (c === void 0) { c = false; } if (this.t(a, b)) { return; } var d = this.y(String_$type, a); for (var f = 0; f < b.length; f++) { var e = b[f]; if (!d.contains(e)) { d.add(e); } } this.e = this.f(String_$type, d); this.ap("StockSymbols", null, this.e); this.au(a, this.e); }; FinancialDataAdapter.prototype.ay = function (a, b) { if (a == b) { return; } this.log("StockGenerate "); if (a != null && a.length != 0) { for (var c = a.length - 1; c >= 0; c--) { var d = a[c]; if (this.v.containsKey(d)) { this.as(d, c); } } } if (b != null && b.length != 0) { for (var e = 0; e < b.length; e++) { var f = b[e]; if (!this.v.containsKey(f)) { var g = this.p(f); var h = this.q(f); this.ao(f, h); this.an(f, g); } } } }; FinancialDataAdapter.prototype.az = function () { this.o.dateRange = this.ac; this.o.dateInterval = this.ab; this.o.skipAfterHours = !this.u; if (this.stockSymbols == null || this.stockSymbols.length == 0) { this.v.clear(); this.x.clear(); arrayClear(this.stockPrices); arrayClear(this.stockPositions); } else { this.v.clear(); this.x.clear(); arrayClear(this.stockPrices); arrayClear(this.stockPositions); for (var a = 0; a < this.stockSymbols.length; a++) { var b = this.stockSymbols[a]; var c = this.p(b); var d = this.q(b); this.ao(b, d); this.an(b, c); } } }; FinancialDataAdapter.prototype.s = function (a, b) { if (a == null || a.length == 0) { return false; } for (var d = 0; d < a.length; d++) { var c = a[d]; if (b == c) { return true; } } return false; }; FinancialDataAdapter.prototype.f = function ($t, a) { var e_1, _a; if (a == null || a.count == 0) { return new Array(0); } var b = new Array(a.count); var c = 0; try { for (var _b = __values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) { var d = _c.value; b[c] = d; c++; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (_c && !_c.done && (_a = _b.return)) _a.call(_b); } finally { if (e_1) throw e_1.error; } } return b; }; FinancialDataAdapter.prototype.y = function ($t, a) { if (a == null || a.length == 0) { return new List$1($t, 0); } var b = new List$1($t, 0); for (var c = 0; c < a.length; c++) { b.add(a[c]); } return b; }; FinancialDataAdapter.prototype.t = function (a, b) { if (a == null || b == null) { return false; } if (a.length != b.length) { return false; } for (var c = 0; c < a.length; c++) { if (a[c] != b[c]) { return false; } } return true; }; FinancialDataAdapter.$t = markType(FinancialDataAdapter, 'FinancialDataAdapter', Base.$, [INotifyPropertyChanged_$type]); return FinancialDataAdapter; }(Base)); export { FinancialDataAdapter };