Merge pull request 'master' (#1) from master into beta

Reviewed-on: #1
This commit is contained in:
Konstantina Galouni 2023-05-03 12:07:48 +02:00
commit 6cbda6babc
6 changed files with 157 additions and 10 deletions

View File

@ -29,7 +29,7 @@
<dependency> <!-- this dependency includes dependency to uoa-authorization-library --> <dependency> <!-- this dependency includes dependency to uoa-authorization-library -->
<groupId>eu.dnetlib</groupId> <groupId>eu.dnetlib</groupId>
<artifactId>uoa-admin-tools-library</artifactId> <artifactId>uoa-admin-tools-library</artifactId>
<version>1.0.6</version> <version>1.0.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>eu.dnetlib</groupId> <groupId>eu.dnetlib</groupId>

View File

@ -302,6 +302,20 @@ public class IndicatorController {
} }
log.debug("After type check: "+changed); log.debug("After type check: "+changed);
if((
(indicatorPath.getFormat() == null && oldIndicatorPath.getFormat() != null)
||
(indicatorPath.getFormat() != null && !indicatorPath.getFormat().equals(indicatorPathBasedOnDefault.getFormat()))
) && (
(oldIndicatorPath.getFormat() == null && indicatorPathBasedOnDefault.getFormat() == null)
||
(oldIndicatorPath.getFormat() != null && oldIndicatorPath.getFormat().equals(indicatorPathBasedOnDefault.getFormat()))
)) {
indicatorPathBasedOnDefault.setFormat(indicatorPath.getFormat());
changed = true;
}
log.debug("After type check: "+changed);
// if(indicatorPath.getSource() != null // if(indicatorPath.getSource() != null
// && !indicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()) // && !indicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource())
// && (oldIndicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()))) { // && (oldIndicatorPath.getSource().equals(indicatorPathBasedOnDefault.getSource()))) {

View File

@ -2,6 +2,7 @@ package eu.dnetlib.uoamonitorservice.controllers;
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal; import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*; import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
import eu.dnetlib.uoaadmintoolslibrary.services.PageService;
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService; import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -22,10 +23,19 @@ public class MonitorController {
@Autowired @Autowired
private PortalService portalService; private PortalService portalService;
@Autowired
private PageService pageService;
@RequestMapping(value = "/update", method = RequestMethod.POST) @RequestMapping(value = "/update", method = RequestMethod.POST)
public PortalResponse updatePortal(@RequestBody Portal portal) { public PortalResponse updatePortal(@RequestBody Portal portal) {
String old_pid = portalService.getPortalById(portal.getId()).getPid();
String new_pid = portal.getPid();
PortalResponse portalResponse = portalService.updatePortal(portal); PortalResponse portalResponse = portalService.updatePortal(portal);
if (!old_pid.equals(new_pid)) {
pageService.updatePid(old_pid, new_pid, portal.getType());
}
// String old_pid = portalResponse.getPid(); // String old_pid = portalResponse.getPid();
// String new_pid = portal.getPid(); // String new_pid = portal.getPid();
// if(!old_pid.equals(new_pid)) { // if(!old_pid.equals(new_pid)) {

View File

@ -13,8 +13,13 @@ enum IndicatorPathType {
// STATISTICS, SEARCH, METRICS, STATS_TOOL,OLD,IMAGE; // STATISTICS, SEARCH, METRICS, STATS_TOOL,OLD,IMAGE;
//} //}
enum Format {
NUMBER, PERCENTAGE
}
public class IndicatorPath { public class IndicatorPath {
private IndicatorPathType type; // for charts is type of chart {table, bar, column, etc} private IndicatorPathType type; // for charts is type of chart {table, bar, column, etc}
private Format format = Format.NUMBER; // for numbers is if number is percentage or not
private String source; // for numbers is the service {statistics, search, metrics} for charts is the tool {stats-tool,old,metrics, image} private String source; // for numbers is the service {statistics, search, metrics} for charts is the tool {stats-tool,old,metrics, image}
private String url; private String url;
private List<String> jsonPath; private List<String> jsonPath;
@ -27,6 +32,7 @@ public class IndicatorPath {
public IndicatorPath(IndicatorPath indicatorPath) { public IndicatorPath(IndicatorPath indicatorPath) {
setType(indicatorPath.getType()); setType(indicatorPath.getType());
setFormat(indicatorPath.getFormat());
source = indicatorPath.getSource(); source = indicatorPath.getSource();
url = indicatorPath.getUrl(); url = indicatorPath.getUrl();
jsonPath = indicatorPath.getJsonPath(); jsonPath = indicatorPath.getJsonPath();
@ -55,6 +61,22 @@ public class IndicatorPath {
} }
} }
public String getFormat() {
if(format == null) {
return null;
}
return format.name();
}
public void setFormat(String format) {
if(format == null) {
this.format = null;
} else {
Format _format = Format.valueOf(format);
this.format = _format;
}
}
public String getSource() { public String getSource() {
return source; return source;
} }

View File

@ -24,6 +24,7 @@ public class Stakeholder<StringOrTopic> {
private String index_id; private String index_id;
private String index_name; private String index_name;
private String index_shortName; private String index_shortName;
private String statsProfile = "monitor";
private String logoUrl; private String logoUrl;
private boolean isUpload = false; private boolean isUpload = false;
private String name; private String name;
@ -45,6 +46,7 @@ public class Stakeholder<StringOrTopic> {
index_id = stakeholder.getIndex_id(); index_id = stakeholder.getIndex_id();
index_name = stakeholder.getIndex_name(); index_name = stakeholder.getIndex_name();
index_shortName = stakeholder.getIndex_shortName(); index_shortName = stakeholder.getIndex_shortName();
statsProfile = stakeholder.getStatsProfile();
logoUrl = stakeholder.getLogoUrl(); logoUrl = stakeholder.getLogoUrl();
isUpload = stakeholder.getIsUpload(); isUpload = stakeholder.getIsUpload();
name = stakeholder.getName(); name = stakeholder.getName();
@ -112,6 +114,14 @@ public class Stakeholder<StringOrTopic> {
this.index_shortName = index_shortName; this.index_shortName = index_shortName;
} }
public String getStatsProfile() {
return statsProfile;
}
public void setStatsProfile(String statsProfile) {
this.statsProfile = statsProfile;
}
public String getLogoUrl() { public String getLogoUrl() {
return logoUrl; return logoUrl;
} }

View File

@ -294,6 +294,94 @@ function addFooterHelpTextForPortalType(portalType) {
} }
} }
function statsProfileOfIndicatorsAsVariable() {
print("statsProfileOfIndicatorsAsVariable");
numOfNumbers = 0;
numOfCharts = 0;
numOfNonMonitorProfiles = 0;
numOfMonitorProfiles = 0;
numOfNoProfiles = 0;
differentProfiles = new Set();
// indicators = db.indicator.find({"type": "chart"}).map(function (indicator) {
// indicators = db.indicator.find({"type": "number"}).map(function (indicator) {
indicators = db.indicator.find().map(function (indicator) {
return indicator;
});
print(indicators.length);
for (var i = 0; i < indicators.length; i++) {
indicator = indicators[i];
indicatorPaths = indicator.indicatorPaths;
if(indicatorPaths) {
for (var j = 0; j < indicatorPaths.length; j++) {
indicatorPath = indicatorPaths[j];
chartObjectStr = "";
// if(indicator.type == "chart") {
chartObjectStr = indicatorPath.chartObject;
// chartObject = JSON.parse(chartObjectStr);
if(indicator.type == "chart") {
numOfCharts++;
} else {
numOfNumbers++;
}
// if(i==0) {
// if(chartObject.chartDescription != null && chartObject.chartDescription.queries != null) {
// print(chartObject.chartDescription.queries.length);
// for(var z = 0; z < chartObject.chartDescription.queries.length; z++) {
// query = chartObject.chartDescription.queries[z].query;
// print(query.profile);
// query.profile = "((__statsProfile__))";
// }
// }
// indicatorPath.chartObject = JSON.stringify(chartObject);
if(chartObjectStr != null) {
var included = chartObjectStr.includes('"profile":"monitor"');
if (!included) {
numOfNonMonitorProfiles++;
print("Indicator with id: " + indicator._id + " has not monitor profile.");
} else {
numOfMonitorProfiles++;
}
splitted = chartObjectStr.split('"profile":"');
if (splitted.length == 1) {
numOfNoProfiles++;
}
for (var z = 1; z < splitted.length; z = z + 2) {
prof = splitted[z].split('"')[0];
differentProfiles.add(prof);
}
chartObjectStr = chartObjectStr.split('"profile":"monitor"').join('"profile":"((__profile__))"');
chartObjectStr = chartObjectStr.split('"profile":"OpenAIRE All-inclusive"').join('"profile":"((__profile__))"');
chartObjectStr = chartObjectStr.split('"profile":"OpenAIRE Monitor"').join('"profile":"((__profile__))"');
indicatorPath.chartObject = chartObjectStr;
} else {
print("Indicator with id: " + indicator._id + " has no chartObject");
}
}
}
// save indicator
// db.indicator.save(indicator);
}
print("\n");
print("numOfNumbers: "+numOfNumbers);
print("numOfCharts: "+numOfCharts);
print("numOfMonitorProfiles: "+numOfMonitorProfiles);
print("numOfNonMonitorProfiles: "+numOfNonMonitorProfiles);
print("numOfNoProfiles: "+numOfNoProfiles);
print("Different profiles are: ");
for (var item of differentProfiles) {
print(item);
}
}
use monitordb; use monitordb;
// use 1_openaire-mongodb-beta; // dev db // use 1_openaire-mongodb-beta; // dev db
@ -310,12 +398,15 @@ use monitordb;
// uniqueIndexes(); // uniqueIndexes();
// 04-06-2021 - 24-06-2021 // 04-06-2021 - 24-06-2021
addHomePageInPortalType("funder"); // addHomePageInPortalType("funder");
addFooterDivIdForPortalType("funder"); // addFooterDivIdForPortalType("funder");
addFooterHelpTextForPortalType("funder"); // addFooterHelpTextForPortalType("funder");
addHomePageInPortalType("ri"); // addHomePageInPortalType("ri");
addFooterDivIdForPortalType("ri"); // addFooterDivIdForPortalType("ri");
addFooterHelpTextForPortalType("ri"); // addFooterHelpTextForPortalType("ri");
addHomePageInPortalType("organization"); // addHomePageInPortalType("organization");
addFooterDivIdForPortalType("organization"); // addFooterDivIdForPortalType("organization");
addFooterHelpTextForPortalType("organization"); // addFooterHelpTextForPortalType("organization");
// 11-04-2023
statsProfileOfIndicatorsAsVariable();