|
|
|
@ -249,7 +249,7 @@ export class IndicatorUtils {
|
|
|
|
|
if (indicatorPath.chartObject) {
|
|
|
|
|
if (fundingL0 && indicatorPath.filters["fundingL0"]) {
|
|
|
|
|
let newJsonObject = JSON.parse(replacedUrl);
|
|
|
|
|
for (let queries of newJsonObject["chartDescription"]["queries"]) {
|
|
|
|
|
for (let queries of newJsonObject[this.getDescriptionObjectName(newJsonObject)]["queries"]) {
|
|
|
|
|
if (!queries["query"]["filters"] || queries["query"]["filters"].length == 0) {
|
|
|
|
|
queries["query"]["filters"] = [];
|
|
|
|
|
}
|
|
|
|
@ -288,7 +288,8 @@ export class IndicatorUtils {
|
|
|
|
|
let chart = JSON.parse(indicatorPath.chartObject);
|
|
|
|
|
// console.debug(indicatorPath);
|
|
|
|
|
if (indicatorPath.url == "chart?json=") {
|
|
|
|
|
if (chart["library"] && (chart["library"] == "HighCharts" || chart["library"] == "eCharts" )) {
|
|
|
|
|
|
|
|
|
|
if (chart["library"] && (chart["library"] == "HighCharts" || chart["library"] == "eCharts" || chart["library"] == "HighMaps" )) {
|
|
|
|
|
indicatorPath.type = this.extractType(chart, indicatorPath);
|
|
|
|
|
} else {
|
|
|
|
|
indicatorPath.type = this.defaultChartType;
|
|
|
|
@ -337,18 +338,27 @@ export class IndicatorUtils {
|
|
|
|
|
return indicatorPath;
|
|
|
|
|
}
|
|
|
|
|
private getQueryObjectName(obj){
|
|
|
|
|
if(obj["library"] && obj["library"] == "GoogleCharts"){
|
|
|
|
|
if((obj[this.getDescriptionObjectName(obj)]).hasOwnProperty("queriesInfo")){
|
|
|
|
|
return "queriesInfo";
|
|
|
|
|
}else if(obj["library"] && ( obj["library"] == "HighCharts" || obj["library"] == "eCharts")) {
|
|
|
|
|
}else if((obj[this.getDescriptionObjectName(obj)]).hasOwnProperty("queries")) {
|
|
|
|
|
return "queries";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private getDescriptionObjectName(obj){
|
|
|
|
|
if(obj.hasOwnProperty("mapDescription")){
|
|
|
|
|
return "mapDescription";
|
|
|
|
|
}else if(obj.hasOwnProperty("chartDescription")) {
|
|
|
|
|
return "chartDescription";
|
|
|
|
|
}else if(obj.hasOwnProperty("tableDescription") ){
|
|
|
|
|
return "tableDescription";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private extractType(obj, indicatorPath: IndicatorPath): IndicatorPathType {
|
|
|
|
|
let type = obj["chartDescription"]["queries"][0]["type"];
|
|
|
|
|
let type = (obj[this.getDescriptionObjectName(obj)] && obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)][0]["type"])?obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)][0]["type"]:"";
|
|
|
|
|
if (this.basicChartTypes.indexOf(type) == -1) {
|
|
|
|
|
type = this.defaultChartType;
|
|
|
|
|
} else {
|
|
|
|
|
obj["chartDescription"]["queries"][0]["type"] = ChartHelper.prefix + "type" + ChartHelper.suffix;
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["queries"][0]["type"] = ChartHelper.prefix + "type" + ChartHelper.suffix;
|
|
|
|
|
indicatorPath.parameters['type'] = type;
|
|
|
|
|
}
|
|
|
|
|
return type;
|
|
|
|
@ -362,7 +372,7 @@ export class IndicatorUtils {
|
|
|
|
|
if(stakeholder.type != "funder"){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) {
|
|
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
|
|
|
|
if (!query["query"]["filters"]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -382,7 +392,7 @@ export class IndicatorUtils {
|
|
|
|
|
if(stakeholder.type != "ri"){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) {
|
|
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
|
|
|
|
if (!query["query"]["filters"]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -404,7 +414,7 @@ export class IndicatorUtils {
|
|
|
|
|
if(stakeholder.type != "organization"){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) {
|
|
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
|
|
|
|
if (!query["query"]["filters"]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -421,7 +431,7 @@ export class IndicatorUtils {
|
|
|
|
|
}
|
|
|
|
|
private extractStartYear(obj, indicatorPath: IndicatorPath) {
|
|
|
|
|
let start_year;
|
|
|
|
|
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) {
|
|
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
|
|
|
|
if (!query["query"]["filters"]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -439,7 +449,7 @@ export class IndicatorUtils {
|
|
|
|
|
|
|
|
|
|
private extractEndYear(obj, indicatorPath: IndicatorPath) {
|
|
|
|
|
let end_year;
|
|
|
|
|
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) {
|
|
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
|
|
|
|
if (!query["query"]["filters"]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -457,8 +467,7 @@ export class IndicatorUtils {
|
|
|
|
|
|
|
|
|
|
private parameterizeDefaultQuery(obj, indicatorPath: IndicatorPath, stakeholder:Stakeholder) {
|
|
|
|
|
let name = "";
|
|
|
|
|
|
|
|
|
|
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) {
|
|
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
|
|
|
|
//monitor.{{stakeholderType}}.{{queryname}}
|
|
|
|
|
//parameters: stakeholderId*, type
|
|
|
|
|
if (query["query"]["name"]) {
|
|
|
|
@ -493,7 +502,10 @@ export class IndicatorUtils {
|
|
|
|
|
}
|
|
|
|
|
private extractDataTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
|
let index = 0;
|
|
|
|
|
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) {
|
|
|
|
|
if(obj[this.getDescriptionObjectName(obj)] && obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
|
|
|
|
if (query["name"]) {
|
|
|
|
|
let name = query["name"];
|
|
|
|
|
query["name"] = ChartHelper.prefix + "data_title_"+index + ChartHelper.suffix;
|
|
|
|
@ -504,55 +516,55 @@ export class IndicatorUtils {
|
|
|
|
|
}
|
|
|
|
|
private extractTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
|
let title = "";
|
|
|
|
|
if (obj["library"] && ( obj["library"] == "HighCharts" || obj["library"] == "eCharts") && obj["chartDescription"]["title"]) {
|
|
|
|
|
title = obj["chartDescription"]["title"]["text"];
|
|
|
|
|
obj["chartDescription"]["title"]["text"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj["library"] && obj["library"] == "GoogleCharts" && obj["chartDescription"]["options"]["title"]) {
|
|
|
|
|
title = obj["chartDescription"]["options"]["title"];
|
|
|
|
|
obj["chartDescription"]["options"]["title"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
|
|
|
|
|
if (obj[this.getDescriptionObjectName(obj)]["title"]) {
|
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["title"]["text"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["title"]["text"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["options"] && obj[this.getDescriptionObjectName(obj)]["options"]["title"]) {
|
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["options"]["title"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["options"]["title"] = ChartHelper.prefix + "title" + ChartHelper.suffix;
|
|
|
|
|
}
|
|
|
|
|
indicatorPath.parameters["title"] = title ? title : "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private extractSubTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
|
let subtitle = "";
|
|
|
|
|
if (obj["chartDescription"]["subtitle"]) {
|
|
|
|
|
subtitle = obj["chartDescription"]["subtitle"]["text"];
|
|
|
|
|
obj["chartDescription"]["subtitle"]["text"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix;
|
|
|
|
|
if (obj[this.getDescriptionObjectName(obj)]["subtitle"]) {
|
|
|
|
|
subtitle = obj[this.getDescriptionObjectName(obj)]["subtitle"]["text"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["subtitle"]["text"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix;
|
|
|
|
|
indicatorPath.parameters["subtitle"] = subtitle ? subtitle : "";
|
|
|
|
|
}else if (obj["chartDescription"]["title"] && obj["chartDescription"]["title"]["subtext"]) {
|
|
|
|
|
subtitle = obj["chartDescription"]["title"]["subtext"];
|
|
|
|
|
obj["chartDescription"]["title"]["subtext"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["title"] && obj[this.getDescriptionObjectName(obj)]["title"] && obj[this.getDescriptionObjectName(obj)]["title"]["subtext"]) {
|
|
|
|
|
subtitle = obj[this.getDescriptionObjectName(obj)]["title"]["subtext"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["title"]["subtext"] = ChartHelper.prefix + "subtitle" + ChartHelper.suffix;
|
|
|
|
|
indicatorPath.parameters["subtitle"] = subtitle ? subtitle : "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private extractXTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
|
let title = "";
|
|
|
|
|
if (obj["library"] && obj["library"] == "HighCharts" && obj["chartDescription"]["xAxis"]["title"]) {
|
|
|
|
|
title = obj["chartDescription"]["xAxis"]["title"]["text"];
|
|
|
|
|
obj["chartDescription"]["xAxis"]["title"]["text"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj["library"] && obj["library"] == "GoogleCharts" && obj["chartDescription"]["options"]["hAxis"]["title"]) {
|
|
|
|
|
title = obj["chartDescription"]["options"]["hAxis"]["title"];
|
|
|
|
|
obj["chartDescription"]["options"]["hAxis"]["title"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj["library"] && obj["library"] == "eCharts" && obj["chartDescription"]["xAxis"]["name"]) {
|
|
|
|
|
title = obj["chartDescription"]["xAxis"]["name"];
|
|
|
|
|
obj["chartDescription"]["xAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
if (obj[this.getDescriptionObjectName(obj)]["xAxis"] && obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]) {
|
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]["text"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["xAxis"]["title"]["text"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["options"] && obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"] && obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"]["title"]) {
|
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"]["title"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["options"]["hAxis"]["title"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["xAxis"] && obj[this.getDescriptionObjectName(obj)]["xAxis"]["name"]) {
|
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["xAxis"]["name"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["xAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}
|
|
|
|
|
indicatorPath.parameters["xAxisTitle"] = title ? title : "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private extractYTitle(obj, indicatorPath: IndicatorPath) {
|
|
|
|
|
let title = "";
|
|
|
|
|
if (obj["library"] && obj["library"] == "HighCharts" && obj["chartDescription"]["yAxis"]["title"]) {
|
|
|
|
|
title = obj["chartDescription"]["yAxis"]["title"]["text"];
|
|
|
|
|
obj["chartDescription"]["yAxis"]["title"]["text"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj["library"] && obj["library"] == "GoogleCharts" && obj["chartDescription"]["options"]["vAxis"]["title"]) {
|
|
|
|
|
title = obj["chartDescription"]["options"]["vAxis"]["title"];
|
|
|
|
|
obj["chartDescription"]["options"]["vAxis"]["title"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj["library"] && obj["library"] == "eCharts" && obj["chartDescription"]["yAxis"]["name"]) {
|
|
|
|
|
title = obj["chartDescription"]["yAxis"]["name"];
|
|
|
|
|
obj["chartDescription"]["yAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
if (obj[this.getDescriptionObjectName(obj)]["yAxis"] && obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"] ) {
|
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"]["text"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["yAxis"]["title"]["text"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["options"]&& obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"] && obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"]["title"]) {
|
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"]["title"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["options"]["vAxis"]["title"] = ChartHelper.prefix + "yAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}else if (obj[this.getDescriptionObjectName(obj)]["yAxis"] && obj[this.getDescriptionObjectName(obj)]["yAxis"]["name"]) {
|
|
|
|
|
title = obj[this.getDescriptionObjectName(obj)]["yAxis"]["name"];
|
|
|
|
|
obj[this.getDescriptionObjectName(obj)]["yAxis"]["name"] = ChartHelper.prefix + "xAxisTitle" + ChartHelper.suffix;
|
|
|
|
|
}
|
|
|
|
|
indicatorPath.parameters["yAxisTitle"] = title ? title : "";
|
|
|
|
|
}
|
|
|
|
@ -560,7 +572,7 @@ export class IndicatorUtils {
|
|
|
|
|
private addResultFilters(obj, indicatorPath: IndicatorPath) {
|
|
|
|
|
let resultTypes = ["publication", "software", "dataset", "other"];
|
|
|
|
|
let index = -1;
|
|
|
|
|
for (let query of obj[(obj["chartDescription"]?"chartDescription":"tableDescription")][this.getQueryObjectName(obj)]) {
|
|
|
|
|
for (let query of obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)]) {
|
|
|
|
|
if (!query["query"]["select"]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|