|
|
@ -222,103 +222,104 @@ export class IndicatorPath {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export type FilterType = "fundingL0"|"start_year" | "end_year" | "co-funded" | "foslvl1" | "foslvl2";
|
|
|
|
export type FilterType = "fundingL0"|"start_year" | "end_year" | "co-funded" | "foslvl1" | "foslvl2" | "publicly-funded";
|
|
|
|
|
|
|
|
|
|
|
|
export class IndicatorFilterUtils {
|
|
|
|
export class IndicatorFilterUtils {
|
|
|
|
|
|
|
|
public static filteredFields = {
|
|
|
|
static getFilter(fieldPath: string, filterType:FilterType, value:string|string[] =null) {
|
|
|
|
"year":{
|
|
|
|
if ((filterType == "start_year" || filterType == "end_year") && (fieldPath.indexOf(".year") != -1 || fieldPath.indexOf(".start year") != -1)
|
|
|
|
"result": "result.year",
|
|
|
|
&& fieldPath.indexOf("indi_pub_downloads_year.year") == -1) {
|
|
|
|
"indi_pub_downloads_year": "indi_pub_downloads_year.year", //exclude indi_pub_downloads_year.year because it throws errors. when there is a solution remove the exclusion
|
|
|
|
// make it work for any table with field year or start year no matter the type or the table name
|
|
|
|
"indi_pub_downloads":"indi_pub_downloads.result.year",
|
|
|
|
//exclude indi_pub_downloads_year.year because it throws errors. when there is a solution remove the exclusion
|
|
|
|
"result_apc":"result_apc.result.year",
|
|
|
|
if (filterType == "start_year") {
|
|
|
|
"result_apc_affiliations":"result_apc_affiliations.result.year",
|
|
|
|
return '{"groupFilters":[{"field":"' + fieldPath + '","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
"result_country":"result_country.result.year",
|
|
|
|
} else if (filterType == "end_year") {
|
|
|
|
"indi_impact_measures": "indi_impact_measures.result.year",
|
|
|
|
return '{"groupFilters":[{"field":"' + fieldPath + '","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
"project": "project.start year"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
"fundingL0":{
|
|
|
|
|
|
|
|
"result": "result.project funding level 0",
|
|
|
|
|
|
|
|
"project": "project.funding level 0",
|
|
|
|
|
|
|
|
"country":"country.organization.project.funding level 0",
|
|
|
|
|
|
|
|
"organization":"organization.project.funding level 0"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"co-funded":{
|
|
|
|
|
|
|
|
"result": "result.No of funders",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"foslvl1":
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
"publication":"publication.topics.result.result_fos.lvl1",
|
|
|
|
|
|
|
|
"result":"result.result_fos.lvl1",
|
|
|
|
|
|
|
|
"indi_pub_downloads":"indi_pub_downloads.result.result_fos.lvl1",
|
|
|
|
|
|
|
|
"indi_pub_downloads_year":"indi_pub_downloads_year.result.result_fos.lvl1",
|
|
|
|
|
|
|
|
"indi_impact_measures":"indi_impact_measures.result.result_fos.lvl1",
|
|
|
|
|
|
|
|
"result_apc":"result_apc.result.result_fos.lvl1",
|
|
|
|
|
|
|
|
"result_apc_affiliations":"result_apc_affiliations.result.result_fos.lvl1",
|
|
|
|
|
|
|
|
"result_country":"result_country.result.result_fos.lvl1",
|
|
|
|
|
|
|
|
"historical_snapshots_irish_fos":"historical_snapshots_irish_fos.lvl1"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"foslvl2":{
|
|
|
|
|
|
|
|
"publication":"publication.topics.result.result_fos.lvl2",
|
|
|
|
|
|
|
|
"result":"result.result_fos.lvl2",
|
|
|
|
|
|
|
|
"indi_pub_downloads":"indi_pub_downloads.result.result_fos.lvl2",
|
|
|
|
|
|
|
|
"indi_pub_downloads_year":"indi_pub_downloads_year.result.result_fos.lvl2",
|
|
|
|
|
|
|
|
"indi_impact_measures":"indi_impact_measures.result.result_fos.lvl2",
|
|
|
|
|
|
|
|
"result_apc":"result_apc.result.result_fos.lvl2",
|
|
|
|
|
|
|
|
"result_apc_affiliations":"result_apc_affiliations.result.result_fos.lvl2",
|
|
|
|
|
|
|
|
"result_country":"result_country.result.result_fos.lvl2",
|
|
|
|
|
|
|
|
"historical_snapshots_irish_fos":"historical_snapshots_irish_fos.lvl2"
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"publicly-funded":{
|
|
|
|
|
|
|
|
"result":"result.indi_pub_publicly_funded.publicly_funded",
|
|
|
|
|
|
|
|
"indi_pub_downloads":"indi_pub_downloads.result.indi_pub_publicly_funded.publicly_funded",
|
|
|
|
|
|
|
|
"indi_pub_downloads_year":"indi_pub_downloads_year.result.indi_pub_publicly_funded.publicly_funded",
|
|
|
|
|
|
|
|
"indi_impact_measures":"indi_impact_measures.result.indi_pub_publicly_funded.publicly_funded",
|
|
|
|
|
|
|
|
"result_apc":"result_apc.result.indi_pub_publicly_funded.publicly_funded",
|
|
|
|
|
|
|
|
"result_apc_affiliations":"result_apc_affiliations.result.indi_pub_publicly_funded.publicly_funded",
|
|
|
|
|
|
|
|
"result_country":"result_country.result.indi_pub_publicly_funded.publicly_funded"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((filterType == "foslvl1" || filterType == "foslvl2") ){
|
|
|
|
|
|
|
|
if (filterType == "foslvl1" && fieldPath.indexOf("result.result_fos.lvl1")!=-1 && value && value.length > 0) {
|
|
|
|
|
|
|
|
let filterString = '{"groupFilters":[' ;
|
|
|
|
|
|
|
|
let filters = [];
|
|
|
|
|
|
|
|
for(let v of value) {
|
|
|
|
|
|
|
|
filters.push('{"field":"' + fieldPath + '","type":"=","values":["' + v + '"]}');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
filterString+=filters.join(", ")
|
|
|
|
|
|
|
|
filterString+='],"op":"OR"}'
|
|
|
|
|
|
|
|
return filterString;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filterType == "foslvl1" && fieldPath.indexOf("result.result_fos.lvl2")!=-1 && value && value.length > 0) {
|
|
|
|
|
|
|
|
let filterString = '{"groupFilters":[' ;
|
|
|
|
|
|
|
|
let filters = [];
|
|
|
|
|
|
|
|
for(let v of value) {
|
|
|
|
|
|
|
|
filters.push('{"field":"' + (fieldPath.replace(".lvl2",".lvl1")) + '","type":"=","values":["' + v + '"]}');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
filterString+=filters.join(", ")
|
|
|
|
|
|
|
|
filterString+='],"op":"OR"}'
|
|
|
|
|
|
|
|
return filterString;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (filterType == "foslvl2" && fieldPath.indexOf("result.result_fos.lvl2")!=-1 && value && value.length > 0) {
|
|
|
|
|
|
|
|
let filterString = '{"groupFilters":[' ;
|
|
|
|
|
|
|
|
let filters = [];
|
|
|
|
|
|
|
|
for(let v of value) {
|
|
|
|
|
|
|
|
filters.push('{"field":"' + fieldPath + '","type":"=","values":["' + v + '"]}');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
filterString+=filters.join(", ")
|
|
|
|
|
|
|
|
filterString+='],"op":"OR"}'
|
|
|
|
|
|
|
|
return filterString;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let table = fieldPath&&fieldPath.length > 0? fieldPath.split(".")[0]:"";
|
|
|
|
static getFieldForTable(field, table){
|
|
|
|
if(["publication", "software", "dataset", "other", "result"].indexOf(table)!=-1){
|
|
|
|
if(["publication", "software", "dataset", "other", "result"].indexOf(table)!=-1){
|
|
|
|
return this.getResultFilter(table,filterType);
|
|
|
|
return IndicatorFilterUtils.filteredFields[field]["result"];
|
|
|
|
}else if (table == "project"){
|
|
|
|
}else{
|
|
|
|
return this.getProjectFilter(filterType);
|
|
|
|
return IndicatorFilterUtils.filteredFields[field][table];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (table == "country"){
|
|
|
|
}
|
|
|
|
return this.getCountryFilter(filterType);
|
|
|
|
static getFilter(fieldPath: string, filterType:FilterType, value:string|string[] =null) {
|
|
|
|
}else if (table == "organization"){
|
|
|
|
let tablename = fieldPath.split(".")[0];
|
|
|
|
return this.getOrganizationFilter(filterType);
|
|
|
|
if ((filterType == "start_year" || filterType == "end_year") && (IndicatorFilterUtils.getFieldForTable("year",tablename))){
|
|
|
|
}
|
|
|
|
if (filterType == "start_year") {
|
|
|
|
|
|
|
|
return '{"groupFilters":[{"field":"' + IndicatorFilterUtils.getFieldForTable("year",tablename) + '","type":">=","values":["' + ChartHelper.prefix + 'start_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
return "";
|
|
|
|
} else if (filterType == "end_year") {
|
|
|
|
}
|
|
|
|
return '{"groupFilters":[{"field":"' + IndicatorFilterUtils.getFieldForTable("year",tablename) + '","type":"<=","values":["' + ChartHelper.prefix + 'end_year' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
static getResultFilter(table: string = null, filterType:FilterType) {
|
|
|
|
|
|
|
|
//works for tables ["publication", "software", "dataset", "other", "result"]
|
|
|
|
|
|
|
|
if (filterType == "fundingL0") {
|
|
|
|
|
|
|
|
if(properties.useOldStatisticsSchema) {
|
|
|
|
|
|
|
|
return '{"groupFilters":[{"field":"' + table + '.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
|
|
|
|
}else{//new statistcs schema
|
|
|
|
|
|
|
|
return '{"groupFilters":[{"field":"' + table + '.project funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else if (filterType == "co-funded") {
|
|
|
|
}
|
|
|
|
return '{"groupFilters":[{"field":"' + table + '.No of funders","type":">","values":["1"]}],"op":"AND"}';
|
|
|
|
if (filterType == "fundingL0" && IndicatorFilterUtils.getFieldForTable("fundingL0",tablename)) {
|
|
|
|
|
|
|
|
return '{"groupFilters":[{"field":"' + IndicatorFilterUtils.getFieldForTable("fundingL0",tablename) + '","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
|
|
|
|
|
|
|
|
}else if (table == "publication" &&(filterType == "foslvl1" || filterType == "foslvl2") ){
|
|
|
|
}else if (filterType == "co-funded" && IndicatorFilterUtils.getFieldForTable("co-funded",tablename)) {
|
|
|
|
return '{"groupFilters":[{"field":"' + (filterType == "foslvl1"?"publication.topics.result.result_fos.lvl1":"publication.topics.result.result_fos.lvl2") + '","type":"=","values":["' + ChartHelper.prefix + filterType + ChartHelper.suffix + '"]}],"op":"OR"}';
|
|
|
|
return '{"groupFilters":[{"field":"' + IndicatorFilterUtils.getFieldForTable("co-funded",tablename) + '","type":">","values":["1"]}],"op":"AND"}';
|
|
|
|
}
|
|
|
|
}else if (filterType == "publicly-funded" && IndicatorFilterUtils.getFieldForTable("publicly-funded",tablename)) {
|
|
|
|
return "";
|
|
|
|
return '{"groupFilters":[{"field":"' + IndicatorFilterUtils.getFieldForTable("publicly-funded",tablename) + '","type":"=","values":["' + (value=="true"?"1":"0") +'"]}],"op":"AND"}';
|
|
|
|
}
|
|
|
|
}else if (filterType == "foslvl1" && IndicatorFilterUtils.getFieldForTable("foslvl1",tablename) && value && value.length > 0) {
|
|
|
|
static getProjectFilter( filterType:FilterType) {
|
|
|
|
let filterString = '{"groupFilters":[' ;
|
|
|
|
//works for table "project"
|
|
|
|
let filters = [];
|
|
|
|
if (filterType == "fundingL0") {
|
|
|
|
for(let v of value) {
|
|
|
|
return '{"groupFilters":[{"field":"project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
filters.push('{"field":"' + IndicatorFilterUtils.getFieldForTable("foslvl1",tablename) + '","type":"=","values":["' + v + '"]}');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
filterString+=filters.join(", ")
|
|
|
|
}
|
|
|
|
filterString+='],"op":"OR"}'
|
|
|
|
static getOrganizationFilter( filterType:FilterType) {
|
|
|
|
return filterString;
|
|
|
|
//works for table "organization"
|
|
|
|
}else if (filterType == "foslvl2" && IndicatorFilterUtils.getFieldForTable("foslvl2",tablename) && value && value.length > 0) {
|
|
|
|
if (filterType == "fundingL0") {
|
|
|
|
let filterString = '{"groupFilters":[' ;
|
|
|
|
return '{"groupFilters":[{"field":"organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
let filters = [];
|
|
|
|
}
|
|
|
|
for(let v of value) {
|
|
|
|
return "";
|
|
|
|
filters.push('{"field":"' + IndicatorFilterUtils.getFieldForTable("foslvl2",tablename) + '","type":"=","values":["' + v + '"]}');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static getCountryFilter( filterType:FilterType) {
|
|
|
|
filterString+=filters.join(", ")
|
|
|
|
//works for table "country"
|
|
|
|
filterString+='],"op":"OR"}'
|
|
|
|
if (filterType == "fundingL0") {
|
|
|
|
return filterString;
|
|
|
|
return '{"groupFilters":[{"field":"country.organization.project.funding level 0","type":"=","values":["' + ChartHelper.prefix + 'fundingL0' + ChartHelper.suffix + '"]}],"op":"AND"}';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|