diff --git a/monitor-admin/utils/indicator-utils.ts b/monitor-admin/utils/indicator-utils.ts index fe994f5d..5a17a189 100644 --- a/monitor-admin/utils/indicator-utils.ts +++ b/monitor-admin/utils/indicator-utils.ts @@ -772,45 +772,6 @@ export class IndicatorUtils { } private extractStakeHolders(obj, stakeholder: Stakeholder) { - this.extractFunder(obj, stakeholder); - this.extractRI(obj, stakeholder); - this.extractOrganization(obj, stakeholder); - this.extractDatasource(obj, stakeholder); - this.extractResearcher(obj, stakeholder); - this.extractPublisher(obj, stakeholder); - } - - private extractFunder(obj, stakeholder: Stakeholder) { - if (stakeholder.type != 'funder') { - 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"]) { - //ignore field No Of Funders - let replacedValue = this.replaceIndexValues(gfilter["values"][0], stakeholder); - if (replacedValue) { // don't proceed in replacement if no replaced value matches - if ((gfilter["field"].indexOf(" funder") != -1 && gfilter["field"].indexOf(" funders") == -1) || - (gfilter["field"].indexOf(".funder") != -1) || - (gfilter["field"].indexOf(".funder.id") != -1)) { - gfilter["values"][0] = replacedValue; - } - } - } - } - } - } - - private extractRI(obj, stakeholder: Stakeholder) { - if (stakeholder.type != 'ri') { - 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; @@ -822,116 +783,7 @@ export class IndicatorUtils { for (let gfilter of filter["groupFilters"]) { let replacedValue = this.replaceIndexValues(gfilter["values"][0], stakeholder); if (replacedValue) { // don't proceed in replacement if no replaced value matches - if ((gfilter["field"].indexOf(".context.name") != -1) - || (gfilter["field"].indexOf(".context.id") != -1)) { gfilter["values"][0] = replacedValue; - } - } - } - } - } - } - - private extractOrganization(obj, stakeholder: Stakeholder) { - // works for publication.project.organization.name - // and publication.organization.name - if (stakeholder.type != 'organization') { - 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"]) { - let replacedValue = this.replaceIndexValues(gfilter["values"][0], stakeholder); - if (replacedValue) { // don't proceed in replacement if no replaced value matches - if ((gfilter["field"].indexOf(".organization.name") != -1) || - (gfilter["field"].indexOf(".organization.id") != -1)) { - gfilter["values"][0] = replacedValue; - } - } - } - } - } - } - - private extractPublisher(obj, stakeholder: Stakeholder) { - // works for .publisher - if (stakeholder.type != 'publisher') { - 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"]) { - let replacedValue = this.replaceIndexValues(gfilter["values"][0], stakeholder); - console.log(replacedValue) - if (replacedValue) { // don't proceed in replacement if no replaced value matches - if (gfilter["field"].indexOf(".publisher") != -1) { - console.log(gfilter["values"][0]) - gfilter["values"][0] = replacedValue; - } - } - } - } - } - } - - private extractDatasource(obj, stakeholder: Stakeholder) { - // works for .datasource.name and .HostedBy datasource - // and .datasource.id - if (stakeholder.type != 'datasource' && stakeholder.type != 'journal') { - 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"]) { - let replacedValue = this.replaceIndexValues(gfilter["values"][0], stakeholder); - if (replacedValue) { // don't proceed in replacement if no replaced value matches - if ((gfilter["field"].indexOf(".datasource.name") != -1 || gfilter["field"].indexOf(".HostedBy datasource") != -1) || - (gfilter["field"].indexOf(".datasource.id") != -1) || (gfilter["field"].indexOf(".hostedby") != -1)) { - gfilter["values"][0] = replacedValue; - } - } - } - } - } - } - - private extractResearcher(obj, stakeholder: Stakeholder) { - // works for .orcid - if (stakeholder.type != "researcher") { - 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"]) { - let replacedValue = this.replaceIndexValues(gfilter["values"][0], stakeholder); - if (replacedValue) { // don't proceed in replacement if no replaced value matches - if ((gfilter["field"].indexOf(".orcid") != -1)) { - gfilter["values"][0] = replacedValue; - } } } }