[develop]: Change extract stakeholders by removing condition for field name.

This commit is contained in:
Konstantinos Triantafyllou 2024-07-02 15:55:42 +03:00
parent 1401a68256
commit c97c54208f
1 changed files with 0 additions and 148 deletions

View File

@ -772,45 +772,6 @@ export class IndicatorUtils {
} }
private extractStakeHolders(obj, stakeholder: Stakeholder) { 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)]) { for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
if (query["query"]["profile"]) { if (query["query"]["profile"]) {
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix; query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
@ -822,121 +783,12 @@ export class IndicatorUtils {
for (let gfilter of filter["groupFilters"]) { for (let gfilter of filter["groupFilters"]) {
let replacedValue = this.replaceIndexValues(gfilter["values"][0], stakeholder); let replacedValue = this.replaceIndexValues(gfilter["values"][0], stakeholder);
if (replacedValue) { // don't proceed in replacement if no replaced value matches 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; 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;
}
}
}
}
}
}
private replaceIndexValues(currentValue, stakeholder) { private replaceIndexValues(currentValue, stakeholder) {
if (currentValue == stakeholder.index_name) { if (currentValue == stakeholder.index_name) {