[Library | develop]: helper.class.ts: Added return false in method "isCurator()" as fallback | stakeholder.ts: Added return "" in methods "getFilter()", "getResultFilter()", "getProjectFilter()", "getOrganizationFilter()", "getCountryFilter()" as fallback | string-utils.class.ts: Added return null in method "getPIDFromIdentifiers()" as fallback.

This commit is contained in:
Konstantina Galouni 2023-07-25 13:24:24 +03:00
parent 27f644aad1
commit 52fc9ce22a
3 changed files with 15 additions and 8 deletions

View File

@ -131,6 +131,7 @@ export class Session {
} else if (type == 'project') { } else if (type == 'project') {
return user && this.isProjectCurator(user); return user && this.isProjectCurator(user);
} }
return false;
} }
public static isPortalAdministrator(user: User): boolean { public static isPortalAdministrator(user: User): boolean {

View File

@ -246,6 +246,8 @@ export class IndicatorFilterUtils {
}else if (table == "organization"){ }else if (table == "organization"){
return this.getOrganizationFilter(filterType); return this.getOrganizationFilter(filterType);
} }
return "";
} }
static getResultFilter(table: string = null, filterType:FilterType) { static getResultFilter(table: string = null, filterType:FilterType) {
//works for tables ["publication", "software", "dataset", "other", "result"] //works for tables ["publication", "software", "dataset", "other", "result"]
@ -258,24 +260,28 @@ export class IndicatorFilterUtils {
}else if (filterType == "co-funded") { }else if (filterType == "co-funded") {
return '{"groupFilters":[{"field":"' + table + '.No of funders","type":">","values":["1"]}],"op":"AND"}'; return '{"groupFilters":[{"field":"' + table + '.No of funders","type":">","values":["1"]}],"op":"AND"}';
} }
return "";
} }
static getProjectFilter( filterType:FilterType) { static getProjectFilter( filterType:FilterType) {
//works for table "project" //works for table "project"
if (filterType == "fundingL0") { if (filterType == "fundingL0") {
return '{"groupFilters":[{"field":"project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}'; return '{"groupFilters":[{"field":"project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
} }
return "";
} }
static getOrganizationFilter( filterType:FilterType) { static getOrganizationFilter( filterType:FilterType) {
//works for table "organization" //works for table "organization"
if (filterType == "fundingL0") { if (filterType == "fundingL0") {
return '{"groupFilters":[{"field":"organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}'; return '{"groupFilters":[{"field":"organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
} }
return "";
} }
static getCountryFilter( filterType:FilterType) { static getCountryFilter( filterType:FilterType) {
//works for table "country" //works for table "country"
if (filterType == "fundingL0") { if (filterType == "fundingL0") {
return '{"groupFilters":[{"field":"country.organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}'; return '{"groupFilters":[{"field":"country.organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
} }
return "";
} }
static filterIndexOf(filterToAdd, currentFilters):any{ static filterIndexOf(filterToAdd, currentFilters):any{

View File

@ -209,16 +209,16 @@ export class Identifier {
public static getPIDFromIdentifiers(identifiers: Map<string, string[]>): Identifier { public static getPIDFromIdentifiers(identifiers: Map<string, string[]>): Identifier {
let classes:string [] = ["doi", "handle", "pmc", "pmid", "re3data"]; let classes:string [] = ["doi", "handle", "pmc", "pmid", "re3data"];
if(identifiers) { if(identifiers) {
for (let cl of classes){ for (let cl of classes) {
if(identifiers.get(cl)){ if (identifiers.get(cl)) {
for (let pid of identifiers.get(cl)) { for (let pid of identifiers.get(cl)) {
let identifier = Identifier.getIdentifierFromString(pid); let identifier = Identifier.getIdentifierFromString(pid);
if (identifier){ if (identifier) {
return identifier; return identifier;
}
} }
} }
}
} }
return null; return null;
} }