Commit 7e83cb00 authored by Grand Francois's avatar Grand Francois
Browse files

refactor: MultiDimensionResults class: add childrenResults,extraResult getters

refs #517
parent bac18767
......@@ -39,7 +39,7 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
this._logHelper = undefined;
if (rs.length > 0 && rs[0] instanceof MacrorugoCompoundResults) {
this._mrcResults = rs[0] as MacrorugoCompoundResults;
this._logHelper = new LogHelper(this._mrcResults, this._mrcResults.childrenResults);
this._logHelper = new LogHelper(this._mrcResults);
}
}
......
......@@ -35,7 +35,7 @@ export class PabResultsComponent extends ResultsComponentDirective {
this._pabResults = rs[0] as PabResults;
// log helper
this._logHelper = new LogHelper(this._pabResults, this._pabResults.cloisonsResults, this._pabResults.cloisonAvalResults);
this._logHelper = new LogHelper(this._pabResults);
}
}
......
......@@ -33,19 +33,8 @@ export class PbResultsComponent {
for (const r of rs) {
if (r instanceof PrebarrageResults) {
this._pbResults = r as PrebarrageResults;
// log helper
const childResults: Result[] = [];
const sn = this._pbResults.result?.sourceNub as PreBarrage;
if (sn?.children) {
for (const cr of sn.children) {
if (cr.result) {
childResults.push(cr.result);
}
}
}
this._logHelper = new LogHelper(this._pbResults, childResults);
this._logHelper = new LogHelper(this._pbResults);
}
}
}
......
......@@ -5,7 +5,12 @@ import { MultiDimensionResults } from "./multidimension-results";
* calculation log helpers
*/
export class LogHelper {
constructor(private _mdr: MultiDimensionResults, private _childrenResults: Result[], private _extraResult?: Result) {
private _childrenResults: Result[];
private _extraResult?: Result;
constructor(private _mdr: MultiDimensionResults) {
this._childrenResults = this._mdr.childrenResults;
this._extraResult = this._mdr.extraResult;
}
private mergeGlobalLog(result: Result, log: cLog) {
......
......@@ -8,7 +8,7 @@ import { ChartType } from "./chart-type";
export class MacrorugoCompoundResults extends MultiDimensionResults implements PlottableData {
/** résultats des modules MacroRugo enfants */
public childrenResults: Result[];
private _childrenResults: Result[];
/** symboles des colonnes de résultat */
protected _columns: string[];
......@@ -70,7 +70,7 @@ export class MacrorugoCompoundResults extends MultiDimensionResults implements P
public reset() {
super.reset();
this.childrenResults = [];
this._childrenResults = [];
}
/**
......@@ -224,4 +224,12 @@ export class MacrorugoCompoundResults extends MultiDimensionResults implements P
return data;
}
public get childrenResults(): Result[] {
return this._childrenResults;
}
public set childrenResults(cr: Result[]) {
this._childrenResults = cr;
}
}
import { CalculatedParamResults } from "./param-calc-results";
import { VariatedDetails } from "jalhyd";
import { Result, VariatedDetails } from "jalhyd";
export class MultiDimensionResults extends CalculatedParamResults {
......@@ -19,4 +18,12 @@ export class MultiDimensionResults extends CalculatedParamResults {
public set variableIndex(v: number) {
this._variableIndex = v;
}
public get childrenResults(): Result[] {
return [];
}
public get extraResult(): Result {
return undefined;
}
}
......@@ -256,4 +256,12 @@ export class PabResults extends MultiDimensionResults implements PlottableData {
return data;
}
public get childrenResults(): Result[] {
return this.cloisonsResults;
}
public get extraResult(): Result {
return this.cloisonAvalResults;
}
}
......@@ -24,6 +24,9 @@ export class PrebarrageResults extends MultiDimensionResults implements IObserva
/** Implémentation par délégation */
private _observable: Observable;
/** résultats enfants */
private _childrenResults: Result[];
public constructor() {
super();
this._observable = new Observable();
......@@ -83,6 +86,7 @@ export class PrebarrageResults extends MultiDimensionResults implements IObserva
this.cloisonResults.variableIndex = this._variableIndex;
this.cloisonResults.size = this.size;
this.result = undefined;
this._childrenResults = undefined;
}
/**
......@@ -163,6 +167,22 @@ export class PrebarrageResults extends MultiDimensionResults implements IObserva
return err;
}
/** liste des résultats enfants */
public get childrenResults(): Result[] {
if (this._childrenResults === undefined) {
this._childrenResults = [];
const sn = this.result?.sourceNub as PreBarrage;
if (sn?.children) {
for (const cr of sn.children) {
if (cr.result) {
this._childrenResults.push(cr.result);
}
}
}
}
return this._childrenResults;
}
// interface IObservable
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment