[angular-16-irish-monitor | DONE | ADDED] Indicator utils: add method extractDatasource

This commit is contained in:
argirok 2023-12-21 10:30:07 +02:00
parent 1853b1cf57
commit 0707914088
1 changed files with 25 additions and 1 deletions

View File

@ -764,6 +764,7 @@ export class IndicatorUtils {
this.extractFunder(obj, indicatorPath, stakeholder);
this.extractRI(obj, indicatorPath, stakeholder);
this.extractOrganization(obj, indicatorPath, stakeholder);
this.extractDatasource(obj, indicatorPath, stakeholder);
}
private extractFunder(obj, indicatorPath: IndicatorPath, stakeholder: Stakeholder) {
@ -839,7 +840,30 @@ export class IndicatorUtils {
}
}
}
private extractDatasource(obj, indicatorPath: IndicatorPath, stakeholder: Stakeholder) {
// works for publication.project.organization.name
// and publication.organization.name
if (stakeholder.type != "datasource") {
return;
}
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
if (query["query"]["profile"]) {
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
}
if (!query["query"]["filters"]) {
return;
}
for (let filter of query["query"]["filters"]) {
for (let gfilter of filter["groupFilters"]) {
if (gfilter["field"].indexOf(".datasource.name") != -1 || gfilter["field"].indexOf(".HostedBy datasource") != -1) {
gfilter["values"][0] = this.replaceIndexValues(gfilter["values"][0], stakeholder, indicatorPath.parameters)
} else if (gfilter["field"].indexOf(".datasource.id") != -1) {
gfilter["values"][0] = this.replaceIndexValues(gfilter["values"][0], stakeholder, indicatorPath.parameters)
}
}
}
}
}
private replaceIndexValues(currentValue, stakeholder, parameters ){
if(currentValue == stakeholder.index_name){
parameters["index_name"] = stakeholder.index_name;