igniteui-react-core
Version:
Ignite UI React Core.
404 lines (403 loc) • 12.8 kB
JavaScript
/*
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 { 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
*/
export let FinancialDataAdapter = /*@__PURE__*/ (() => {
class FinancialDataAdapter extends Base {
get stockSymbols() {
return this.e;
}
set stockSymbols(a) {
this.a1(this.e, a);
}
get stockPrices() {
return this.c;
}
set stockPrices(a) {
let b = this.c;
this.c = a;
if (b != this.c) {
this.ap("StockPrices", b, this.c);
}
}
get stockPricesMemberPaths() {
return this.d;
}
get stockPositions() {
return this.b;
}
set stockPositions(a) {
let b = this.b;
this.b = a;
if (b != this.b) {
this.ap("StockPositions", b, this.b);
}
}
get stockDetails() {
return this.a;
}
set stockDetails(a) {
let b = this.a;
this.a = a;
if (b != this.a) {
this.ap("StockDetails", b, this.a);
}
}
get ac() {
return this.aa;
}
set ac(a) {
let b = this.aa;
this.aa = a;
if (b != this.aa) {
this.ap("StockPricesTimeRange", b, this.aa);
}
}
get ab() {
return this.z;
}
set ab(a) {
let b = this.z;
this.z = a;
if (b != this.z) {
this.ap("StockPricesTimeInterval", b, this.z);
}
}
get u() {
return this.r;
}
set u(a) {
let b = this.r;
this.r = a;
if (b != this.r) {
this.ap("StockPricesTradeAfterHours", b, this.r);
}
}
ap(a, b, c) {
this.aq(a, b, c);
if (this.propertyChanged != null) {
this.propertyChanged(this, new PropertyChangedEventArgs(a));
}
}
aq(a, b, c) {
switch (a) {
case "StockPricesTimeRange":
case "StockPricesTimeInterval":
case "StockPricesTradeAfterHours":
this.az();
break;
case "StockSymbols":
this.ay(b, c);
break;
}
}
au(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));
}
}
constructor() {
super();
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();
}
log(message_) {
}
clearData() {
this.e = new Array(0);
this.v.clear();
this.x.clear();
arrayClear(this.stockPrices);
arrayClear(this.stockPositions);
}
removeStockPosition(a) {
this.ar(a);
}
removeStockPrices(a) {
this.as(a, 0);
}
ax(a, b = "") {
let e = this.stockSymbols;
for (let d = 0; d < e.length; d++) {
let 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);
}
let f = this.y(String_$type, this.stockSymbols);
if (!f.contains(a)) {
f.add(a);
}
this.stockSymbols = this.f(String_$type, f);
}
a0(a) {
if (this.v.containsKey(a)) {
let b = this.y(String_$type, this.stockSymbols);
if (this.w.containsKey(a)) {
this.w.removeItem(a);
}
let 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));
}
}
ad(a) {
if (stringIsNullOrEmpty(a)) {
return "";
}
if (this.w.containsKey(a)) {
return this.w.item(a);
}
return "";
}
q(a) {
this.o.dateRange = this.ac;
this.o.dateInterval = this.ab;
this.o.skipAfterHours = !this.u;
let b = this.ad(a);
let 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;
}
p(a) {
this.o.dateRange = this.ac;
this.o.dateInterval = this.ab;
this.o.skipAfterHours = !this.u;
let b = this.ad(a);
let 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;
}
an(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);
}
ao(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);
}
as(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);
}
ar(a) {
this.log("OnRemovingPosition " + a);
if (this.x.count > a) {
this.x.removeAt(a);
}
else {
return;
}
for (let b = 0; b < this.x.count; b++) {
this.x._inner[b].index = b;
}
this.stockPositions = this.f(StockPosition.$, this.x);
}
at() {
this.log("OnStockClearing ");
this.a1(this.stockSymbols, new Array(0), true);
}
a1(a, b, c = false) {
if (this.t(a, b)) {
return;
}
let d = this.y(String_$type, a);
for (let f = 0; f < b.length; f++) {
let 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);
}
ay(a, b) {
if (a == b) {
return;
}
this.log("StockGenerate ");
if (a != null && a.length != 0) {
for (let c = a.length - 1; c >= 0; c--) {
let d = a[c];
if (this.v.containsKey(d)) {
this.as(d, c);
}
}
}
if (b != null && b.length != 0) {
for (let e = 0; e < b.length; e++) {
let f = b[e];
if (!this.v.containsKey(f)) {
let g = this.p(f);
let h = this.q(f);
this.ao(f, h);
this.an(f, g);
}
}
}
}
az() {
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 (let a = 0; a < this.stockSymbols.length; a++) {
let b = this.stockSymbols[a];
let c = this.p(b);
let d = this.q(b);
this.ao(b, d);
this.an(b, c);
}
}
}
s(a, b) {
if (a == null || a.length == 0) {
return false;
}
for (let d = 0; d < a.length; d++) {
let c = a[d];
if (b == c) {
return true;
}
}
return false;
}
f($t, a) {
if (a == null || a.count == 0) {
return new Array(0);
}
let b = new Array(a.count);
let c = 0;
for (let d of fromEnum(a)) {
b[c] = d;
c++;
}
return b;
}
y($t, a) {
if (a == null || a.length == 0) {
return new List$1($t, 0);
}
let b = new List$1($t, 0);
for (let c = 0; c < a.length; c++) {
b.add(a[c]);
}
return b;
}
t(a, b) {
if (a == null || b == null) {
return false;
}
if (a.length != b.length) {
return false;
}
for (let c = 0; c < a.length; c++) {
if (a[c] != b[c]) {
return false;
}
}
return true;
}
}
FinancialDataAdapter.$t = /*@__PURE__*/ markType(FinancialDataAdapter, 'FinancialDataAdapter', Base.$, [INotifyPropertyChanged_$type]);
return FinancialDataAdapter;
})();