Merge remote-tracking branch 'origin/master' into production

This commit is contained in:
Konstantinos Triantafyllou 2023-07-07 11:38:35 +03:00
commit 1ccefb03cf
12 changed files with 350 additions and 104 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.8</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>eu.dnetlib</groupId> <groupId>eu.dnetlib</groupId>
@ -56,6 +56,7 @@
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
<configuration> <configuration>
<mainClass>eu.dnetlib.uoamonitorservice.UoaMonitorServiceApplication</mainClass> <mainClass>eu.dnetlib.uoamonitorservice.UoaMonitorServiceApplication</mainClass>
<executable>true</executable> <executable>true</executable>

View File

@ -77,9 +77,7 @@ public class CategoryController {
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
if(stakeholder != null) { if(stakeholder != null) {
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
List<String> roles = rolesUtils.getRoles();
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Save Category: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("Save Category: You are not authorized to update stakeholder with id: "+stakeholderId);
} }
@ -236,9 +234,7 @@ public class CategoryController {
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
if(stakeholder != null) { if(stakeholder != null) {
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
List<String> roles = rolesUtils.getRoles();
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Delete category: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("Delete category: You are not authorized to update stakeholder with id: "+stakeholderId);
} }
@ -250,7 +246,7 @@ public class CategoryController {
Category<String> category = categoryDAO.findById(categoryId); Category<String> category = categoryDAO.findById(categoryId);
if(category != null) { if(category != null) {
if(category.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(roles, stakeholder.getType())) { if(category.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Delete category: You are not authorized to delete a default Category in stakeholder with id: "+stakeholderId); throw new ForbiddenException("Delete category: You are not authorized to delete a default Category in stakeholder with id: "+stakeholderId);
} }
@ -460,9 +456,7 @@ public class CategoryController {
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
if (stakeholder != null) { if (stakeholder != null) {
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
List<String> roles = rolesUtils.getRoles();
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Toggle category: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("Toggle category: You are not authorized to update stakeholder with id: "+stakeholderId);
} }
@ -525,9 +519,7 @@ public class CategoryController {
// EXCEPTION - Stakeholder not found // EXCEPTION - Stakeholder not found
throw new EntityNotFoundException("checkForExceptions category: Stakeholder with id: " + stakeholderId + " not found"); throw new EntityNotFoundException("checkForExceptions category: Stakeholder with id: " + stakeholderId + " not found");
} }
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
List<String> roles = rolesUtils.getRoles();
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("checkForExceptions category: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("checkForExceptions category: You are not authorized to update stakeholder with id: "+stakeholderId);
} }

View File

@ -65,7 +65,7 @@ public class IndicatorController {
createSectionsAndSaveBulk(date, sections, stakeholder, topicId, categoryId, subcategoryId); createSectionsAndSaveBulk(date, sections, stakeholder, topicId, categoryId, subcategoryId);
// createSectionAndSaveBulk(date, "number", "Numbers imported from file", number_indicators, stakeholder, topicId, categoryId, subcategoryId); // createSectionAndSaveBulk(date, "number", "Numbers imported from file", number_indicators, stakeholder, topicId, categoryId, subcategoryId);
return stakeholderController.setFullEntities(stakeholder, rolesUtils.getRoles()); return stakeholderController.setFullEntities(stakeholder);
} }
private void createSectionsAndSaveBulk(Date date, List<Section<Indicator>> old_sections, private void createSectionsAndSaveBulk(Date date, List<Section<Indicator>> old_sections,
@ -88,10 +88,10 @@ public class IndicatorController {
List<Indicator> indicators = section.getIndicators(); List<Indicator> indicators = section.getIndicators();
for (Indicator indicator : indicators) { for (Indicator indicator : indicators) {
if (indicator.getType().equals("chart")) { if (indicator.getType().equals("chart")) {
saveIndicatorAndAddInSection(indicator, date, stakeholder, chart_section, chart_indicators); saveIndicatorAndAddInSection(indicator, date, stakeholder, subcategoryId, chart_section, chart_indicators);
} else if (indicator.getType().equals("number")) { } else if (indicator.getType().equals("number")) {
saveIndicatorAndAddInSection(indicator, date, stakeholder, number_section, number_indicators); saveIndicatorAndAddInSection(indicator, date, stakeholder, subcategoryId, number_section, number_indicators);
} }
} }
@ -118,14 +118,18 @@ public class IndicatorController {
return section; return section;
} }
private void saveIndicatorAndAddInSection(Indicator indicator, Date date, Stakeholder stakeholder, Section section, List<String> indicators) throws UnsupportedEncodingException { // private void saveIndicatorAndAddInSection(Indicator indicator, Date date, Stakeholder stakeholder, Section section, List<String> indicators) throws UnsupportedEncodingException {
// saveIndicatorAndAddInSection(indicator, date, stakeholder, section, indicators);
// }
private void saveIndicatorAndAddInSection(Indicator indicator, Date date, Stakeholder stakeholder, String subcategoryId, Section section, List<String> indicators) throws UnsupportedEncodingException {
// indicator does not exist in DB // indicator does not exist in DB
indicator.setCreationDate(date); indicator.setCreationDate(date);
indicator.setUpdateDate(date); indicator.setUpdateDate(date);
if (stakeholder.getDefaultId() == null) { // this indicator belongs in default profile and it is new if (stakeholder.getDefaultId() == null) { // this indicator belongs in default profile and it is new
indicatorDAO.save(indicator); indicatorDAO.save(indicator);
onSaveDefaultIndicator(indicator, section.getId()); onSaveDefaultIndicator(indicator, section, subcategoryId);
} else { // this indicator belongs in a stakeholder's profile and it is new } else { // this indicator belongs in a stakeholder's profile and it is new
indicatorDAO.save(indicator); indicatorDAO.save(indicator);
} }
@ -168,7 +172,7 @@ public class IndicatorController {
if(stakeholder.getDefaultId() == null) { if(stakeholder.getDefaultId() == null) {
if(indicatorId == null) { if(indicatorId == null) {
indicatorDAO.save(indicator); indicatorDAO.save(indicator);
onSaveDefaultIndicator(indicator, sectionId); onSaveDefaultIndicator(indicator, section, subcategoryId);
} }
else { else {
onUpdateDefaultIndicator(indicator, stakeholder, oldIndicator); onUpdateDefaultIndicator(indicator, stakeholder, oldIndicator);
@ -190,26 +194,38 @@ public class IndicatorController {
return indicator; return indicator;
} }
public void onSaveDefaultIndicator(Indicator indicator, String defaultSectionId) throws UnsupportedEncodingException { public void onSaveDefaultIndicator(Indicator indicator, Section defaultSection, String defaultSubcategoryId) throws UnsupportedEncodingException {
log.debug("On save default indicator"); log.debug("On save default indicator");
// new indicator in default profile - add it on profiles of the same type // new indicator in default profile - add it on profiles of the same type
List<Section> sections = sectionDAO.findByDefaultId(defaultSectionId); List<SubCategory> subCategories = subCategoryDAO.findByDefaultId(defaultSubcategoryId);
for (SubCategory subCategory : subCategories) {
for (Section section : sections) { List<String> sections = null;
Indicator indicatorNew = new Indicator(); if(defaultSection.getType().equals("chart")) {
indicatorNew.copyFromDefault(indicator); sections = subCategory.getCharts();
for (IndicatorPath indicatorPath : indicatorNew.getIndicatorPaths()) { } else {
Stakeholder stakeholder = stakeholderDAO.findByAlias(section.getStakeholderAlias()); sections = subCategory.getNumbers();
parameterMapping(indicatorPath, stakeholder);
} }
indicatorDAO.save(indicatorNew); for (String sectionId : sections) {
Section section = sectionDAO.findById(sectionId);
if(section.getDefaultId().equals(defaultSection.getId())) {
Indicator indicatorNew = new Indicator();
indicatorNew.copyFromDefault(indicator, subCategory.getVisibility());
for (IndicatorPath indicatorPath : indicatorNew.getIndicatorPaths()) {
Stakeholder stakeholder = stakeholderDAO.findByAlias(section.getStakeholderAlias());
parameterMapping(indicatorPath, stakeholder);
}
List<String> indicators = section.getIndicators(); indicatorDAO.save(indicatorNew);
indicators.add(indicatorNew.getId());
sectionDAO.save(section); List<String> indicators = section.getIndicators();
indicators.add(indicatorNew.getId());
sectionDAO.save(section);
}
}
} }
} }
@ -302,6 +318,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()))) {
@ -534,8 +564,7 @@ public class IndicatorController {
Section<String> section = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId, sectionId, indicator.getType()); Section<String> section = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId, sectionId, indicator.getType());
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
List<String> roles = rolesUtils.getRoles(); if(indicator.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
if(indicator.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(roles, stakeholder.getType())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Delete indicator: You are not authorized to delete a default Indicator in stakeholder with id: "+stakeholderId); throw new ForbiddenException("Delete indicator: You are not authorized to delete a default Indicator in stakeholder with id: "+stakeholderId);
} }
@ -849,9 +878,7 @@ public class IndicatorController {
// EXCEPTION - Stakeholder not found // EXCEPTION - Stakeholder not found
throw new EntityNotFoundException("Save indicator: Stakeholder with id: " + stakeholderId + " not found"); throw new EntityNotFoundException("Save indicator: Stakeholder with id: " + stakeholderId + " not found");
} }
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
List<String> roles = rolesUtils.getRoles();
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("CheckForExceptions Indicator: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("CheckForExceptions Indicator: You are not authorized to update stakeholder with id: "+stakeholderId);
} }

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

@ -237,8 +237,7 @@ public class SectionController {
SubCategory<String> subCategory = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId); SubCategory<String> subCategory = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId);
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
List<String> roles = rolesUtils.getRoles(); if(section.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
if(section.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(roles, stakeholder.getType())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Delete section: You are not authorized to delete a default Section in stakeholder with id: "+stakeholderId); throw new ForbiddenException("Delete section: You are not authorized to delete a default Section in stakeholder with id: "+stakeholderId);
} }
@ -442,9 +441,7 @@ public class SectionController {
// EXCEPTION - Stakeholder not found // EXCEPTION - Stakeholder not found
throw new EntityNotFoundException("Save indicator: Stakeholder with id: " + stakeholderId + " not found"); throw new EntityNotFoundException("Save indicator: Stakeholder with id: " + stakeholderId + " not found");
} }
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
List<String> roles = rolesUtils.getRoles();
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("CheckForExceptions Section: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("CheckForExceptions Section: You are not authorized to update stakeholder with id: "+stakeholderId);
} }

View File

@ -112,7 +112,7 @@ public class StakeholderController {
//return null; //return null;
} }
public Stakeholder setFullEntities(Stakeholder<String> stakeholder, List<String> roles) { public Stakeholder setFullEntities(Stakeholder<String> stakeholder) {
boolean addAll = false; boolean addAll = false;
boolean addPublicAndRestricted = false; boolean addPublicAndRestricted = false;
@ -120,7 +120,7 @@ public class StakeholderController {
// || roles.contains(authorizationService.PORTAL_ADMIN) // || roles.contains(authorizationService.PORTAL_ADMIN)
// || roles.contains(authorizationService.curator(stakeholder.getType())) // || roles.contains(authorizationService.curator(stakeholder.getType()))
// || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) { // || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) {
if(rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) { if(rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
//if(visibility == null || visibility == (Visibility.PRIVATE)) { //if(visibility == null || visibility == (Visibility.PRIVATE)) {
addAll = true; addAll = true;
//} //}
@ -128,7 +128,7 @@ public class StakeholderController {
addPublicAndRestricted = true; addPublicAndRestricted = true;
//} //}
// } else if(roles != null && roles.contains(authorizationService.member(stakeholder.getType(), stakeholder.getAlias()))) { // } else if(roles != null && roles.contains(authorizationService.member(stakeholder.getType(), stakeholder.getAlias()))) {
} else if(rolesUtils.isMember(roles, stakeholder.getType(), stakeholder.getAlias())) { } else if(rolesUtils.isMember(stakeholder.getType(), stakeholder.getAlias())) {
//if(visibility == null || visibility == (Visibility.PRIVATE) || visibility == (Visibility.RESTRICTED)) { //if(visibility == null || visibility == (Visibility.PRIVATE) || visibility == (Visibility.RESTRICTED)) {
addPublicAndRestricted = true; addPublicAndRestricted = true;
//} //}
@ -297,8 +297,7 @@ public class StakeholderController {
List<Stakeholder> stakeholdersFull = new ArrayList<>(); List<Stakeholder> stakeholdersFull = new ArrayList<>();
for(Stakeholder stakeholder : stakeholders) { for(Stakeholder stakeholder : stakeholders) {
List<String> roles = rolesUtils.getRoles(); stakeholdersFull.add(this.setFullEntities(stakeholder));
stakeholdersFull.add(this.setFullEntities(stakeholder, roles));
} }
return stakeholdersFull; return stakeholdersFull;
@ -320,14 +319,13 @@ public class StakeholderController {
// Remove stakeholders for which i do not have authority // Remove stakeholders for which i do not have authority
if(stakeholders != null && stakeholders.size() > 0) { if(stakeholders != null && stakeholders.size() > 0) {
List<String> roles = rolesUtils.getRoles();
// log.debug("ROLES: "); // log.debug("ROLES: ");
// roles.forEach(role -> log.debug(role)); // roles.forEach(role -> log.debug(role));
// //
// if (roles.contains(authorizationService.PORTAL_ADMIN)) { // if (roles.contains(authorizationService.PORTAL_ADMIN)) {
if (rolesUtils.isPortalAdmin(roles)) { if (rolesUtils.isPortalAdmin()) {
for(Stakeholder stakeholder : stakeholders) { for(Stakeholder stakeholder : stakeholders) {
stakeholdersFull.add(this.setFullEntities(stakeholder, roles)); stakeholdersFull.add(this.setFullEntities(stakeholder));
} }
return stakeholdersFull; return stakeholdersFull;
} }
@ -337,8 +335,8 @@ public class StakeholderController {
Stakeholder stakeholder = stakeholderIterator.next(); Stakeholder stakeholder = stakeholderIterator.next();
// if(roles.contains(authorizationService.curator(stakeholder.getType()))) { // if(roles.contains(authorizationService.curator(stakeholder.getType()))) {
if(rolesUtils.isCurator(roles, stakeholder.getType())) { if(rolesUtils.isCurator(stakeholder.getType())) {
stakeholdersFull.add(this.setFullEntities(stakeholder, roles)); stakeholdersFull.add(this.setFullEntities(stakeholder));
continue; continue;
} }
stakeholderIterator.remove(); stakeholderIterator.remove();
@ -368,10 +366,8 @@ public class StakeholderController {
if(stakeholders != null && stakeholders.size() > 0) { if(stakeholders != null && stakeholders.size() > 0) {
// List<String> roles = authorizationService.getRoles(); // List<String> roles = authorizationService.getRoles();
List<String> roles = rolesUtils.getRoles();
// if (roles.contains(authorizationService.PORTAL_ADMIN)) { // if (roles.contains(authorizationService.PORTAL_ADMIN)) {
if (rolesUtils.isPortalAdmin(roles)) { if (rolesUtils.isPortalAdmin()) {
// for(Stakeholder stakeholder : stakeholders) { // for(Stakeholder stakeholder : stakeholders) {
// stakeholdersFull.add(this.setFullEntities(stakeholder)); // stakeholdersFull.add(this.setFullEntities(stakeholder));
// } // }
@ -387,8 +383,8 @@ public class StakeholderController {
// || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias())) // || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))
// || stakeholder.getVisibility() == Visibility.PUBLIC // || stakeholder.getVisibility() == Visibility.PUBLIC
// || (stakeholder.getVisibility() == Visibility.RESTRICTED && roles.contains(authorizationService.member(stakeholder.getType(), stakeholder.getAlias())))) { // || (stakeholder.getVisibility() == Visibility.RESTRICTED && roles.contains(authorizationService.member(stakeholder.getType(), stakeholder.getAlias())))) {
if(rolesUtils.isCurator(roles, stakeholder.getType()) if(rolesUtils.isCurator(stakeholder.getType())
|| rolesUtils.isManager(roles, stakeholder.getType(), stakeholder.getAlias()) || rolesUtils.isManager(stakeholder.getType(), stakeholder.getAlias())
|| stakeholder.getVisibility() == Visibility.PUBLIC || stakeholder.getVisibility() == Visibility.PUBLIC
|| stakeholder.getVisibility() == Visibility.RESTRICTED) { || stakeholder.getVisibility() == Visibility.RESTRICTED) {
// || (stakeholder.getVisibility() == Visibility.RESTRICTED && rolesUtils.isMember(roles, stakeholder.getType(), stakeholder.getAlias()))) { // || (stakeholder.getVisibility() == Visibility.RESTRICTED && rolesUtils.isMember(roles, stakeholder.getType(), stakeholder.getAlias()))) {
@ -420,13 +416,8 @@ public class StakeholderController {
List<Stakeholder> stakeholdersFull = new ArrayList<>(); List<Stakeholder> stakeholdersFull = new ArrayList<>();
if(stakeholders != null && stakeholders.size() > 0) { if(stakeholders != null && stakeholders.size() > 0) {
// List<String> roles = authorizationService.getRoles();
List<String> roles = rolesUtils.getRoles();
// log.debug("ROLES: ");
// roles.forEach(role -> log.debug(role));
// if (roles.contains(authorizationService.PORTAL_ADMIN)) { // if (roles.contains(authorizationService.PORTAL_ADMIN)) {
if (rolesUtils.isPortalAdmin(roles)) { if (rolesUtils.isPortalAdmin()) {
// for(Stakeholder stakeholder : stakeholders) { // for(Stakeholder stakeholder : stakeholders) {
// stakeholdersFull.add(this.setFullEntities(stakeholder, roles)); // stakeholdersFull.add(this.setFullEntities(stakeholder, roles));
// } // }
@ -440,8 +431,8 @@ public class StakeholderController {
// if(roles.contains(authorizationService.curator(stakeholder.getType())) // if(roles.contains(authorizationService.curator(stakeholder.getType()))
// || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) { // || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) {
if(rolesUtils.isCurator(roles, stakeholder.getType()) if(rolesUtils.isCurator(stakeholder.getType())
|| rolesUtils.isManager(roles, stakeholder.getType(), stakeholder.getAlias())) { || rolesUtils.isManager(stakeholder.getType(), stakeholder.getAlias())) {
//stakeholdersFull.add(this.setFullEntities(stakeholder, roles)); //stakeholdersFull.add(this.setFullEntities(stakeholder, roles));
continue; continue;
} else { } else {
@ -466,19 +457,17 @@ public class StakeholderController {
} }
// List<String> roles = authorizationService.getRoles(); // List<String> roles = authorizationService.getRoles();
List<String> roles = rolesUtils.getRoles(); if(stakeholder.getDefaultId() == null && !rolesUtils.isLoggedIn()) {
if(stakeholder.getDefaultId() == null && !rolesUtils.isLoggedIn(roles)) {
// EXCEPTION - Unauthorized // EXCEPTION - Unauthorized
throw new AccessDeniedException("Get stakeholder: You are not authorized (not logged in) to access stakeholder with alias: "+alias); throw new AccessDeniedException("Get stakeholder: You are not authorized (not logged in) to access stakeholder with alias: "+alias);
} }
if(stakeholder.getDefaultId() == null && !rolesUtils.hasCreateAndDeleteAuthority(roles, stakeholder.getType())) { if(stakeholder.getDefaultId() == null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Get stakeholder: You are not authorized to access stakeholder with alias: "+alias); throw new ForbiddenException("Get stakeholder: You are not authorized to access stakeholder with alias: "+alias);
} }
if((stakeholder.getVisibility() == Visibility.PRIVATE && !rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias()) if((stakeholder.getVisibility() == Visibility.PRIVATE && !rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())
|| (stakeholder.getVisibility() == Visibility.RESTRICTED && !rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias()) && !rolesUtils.isMember(roles, stakeholder.getType(), stakeholder.getAlias())))) { || (stakeholder.getVisibility() == Visibility.RESTRICTED && !rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias()) && !rolesUtils.isMember(stakeholder.getType(), stakeholder.getAlias())))) {
// // EXCEPTION - Access denied // // EXCEPTION - Access denied
// throw new ForbiddenException("Get stakeholder: You are not authorized to get stakeholder with alias: "+alias); // throw new ForbiddenException("Get stakeholder: You are not authorized to get stakeholder with alias: "+alias);
List<String> topicsEmpty = stakeholder.getTopics(); List<String> topicsEmpty = stakeholder.getTopics();
@ -488,7 +477,7 @@ public class StakeholderController {
return stakeholder; return stakeholder;
} }
return this.setFullEntities(stakeholder, roles); return this.setFullEntities(stakeholder);
} }
// @PreAuthorize("isAuthenticated()") // @PreAuthorize("isAuthenticated()")
@ -564,12 +553,10 @@ public class StakeholderController {
if(stakeholder != null) { if(stakeholder != null) {
pid = stakeholder.getAlias(); pid = stakeholder.getAlias();
// List<String> roles = authorizationService.getRoles();
List<String> roles = rolesUtils.getRoles();
// if(!roles.contains(authorizationService.PORTAL_ADMIN) // if(!roles.contains(authorizationService.PORTAL_ADMIN)
// && !roles.contains(authorizationService.curator(stakeholder.getType()))) { // && !roles.contains(authorizationService.curator(stakeholder.getType()))) {
if(!rolesUtils.hasCreateAndDeleteAuthority(roles, stakeholder.getType())) { if(!rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Delete stakeholder: You are not authorized to delete stakeholder with id: "+stakeholderId); throw new ForbiddenException("Delete stakeholder: You are not authorized to delete stakeholder with id: "+stakeholderId);
} }
@ -701,12 +688,11 @@ public class StakeholderController {
} }
// List<String> roles = authorizationService.getRoles(); // List<String> roles = authorizationService.getRoles();
List<String> roles = rolesUtils.getRoles();
// if(!roles.contains(authorizationService.PORTAL_ADMIN) // if(!roles.contains(authorizationService.PORTAL_ADMIN)
// && !roles.contains(authorizationService.curator(stakeholder.getType())) // && !roles.contains(authorizationService.curator(stakeholder.getType()))
// && !roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) { // && !roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) {
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) { if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Change stakeholder visibility: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("Change stakeholder visibility: You are not authorized to update stakeholder with id: "+stakeholderId);
} }

View File

@ -254,8 +254,7 @@ public class SubCategoryController {
if(subcategory != null) { if(subcategory != null) {
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
List<String> roles = rolesUtils.getRoles(); if(subcategory.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
if(subcategory.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(roles, stakeholder.getType())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Delete subcategory: You are not authorized to delete a default SubCategory in stakeholder with id: "+stakeholderId); throw new ForbiddenException("Delete subcategory: You are not authorized to delete a default SubCategory in stakeholder with id: "+stakeholderId);
} }
@ -497,9 +496,7 @@ public class SubCategoryController {
// EXCEPTION - Stakeholder not found // EXCEPTION - Stakeholder not found
throw new EntityNotFoundException("Save indicator: Stakeholder with id: " + stakeholderId + " not found"); throw new EntityNotFoundException("Save indicator: Stakeholder with id: " + stakeholderId + " not found");
} }
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
List<String> roles = rolesUtils.getRoles();
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("CheckForExceptions SubCategory: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("CheckForExceptions SubCategory: You are not authorized to update stakeholder with id: "+stakeholderId);
} }

View File

@ -73,8 +73,7 @@ public class TopicController {
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
if(stakeholder != null) { if(stakeholder != null) {
List<String> roles = rolesUtils.getRoles(); if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Save Topic: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("Save Topic: You are not authorized to update stakeholder with id: "+stakeholderId);
} }
@ -210,8 +209,7 @@ public class TopicController {
if(stakeholder != null) { if(stakeholder != null) {
List<String> roles = rolesUtils.getRoles(); if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Delete topic: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("Delete topic: You are not authorized to update stakeholder with id: "+stakeholderId);
} }
@ -219,7 +217,7 @@ public class TopicController {
Topic<String> topic = topicDAO.findById(topicId); Topic<String> topic = topicDAO.findById(topicId);
if(topic != null) { if(topic != null) {
if(topic.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(roles, stakeholder.getType())) { if(topic.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Delete topic: You are not authorized to delete a default Topic in stakeholder with id: "+stakeholderId); throw new ForbiddenException("Delete topic: You are not authorized to delete a default Topic in stakeholder with id: "+stakeholderId);
} }
@ -356,9 +354,7 @@ public class TopicController {
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
if(stakeholder != null) { if(stakeholder != null) {
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
List<String> roles = rolesUtils.getRoles();
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Reorder topics: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("Reorder topics: You are not authorized to update stakeholder with id: "+stakeholderId);
} }
@ -438,9 +434,7 @@ public class TopicController {
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId); Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
if (stakeholder != null) { if (stakeholder != null) {
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
List<String> roles = rolesUtils.getRoles();
if(!rolesUtils.hasUpdateAuthority(roles, stakeholder.getType(), stakeholder.getAlias())) {
// EXCEPTION - Access denied // EXCEPTION - Access denied
throw new ForbiddenException("Toggle topic: You are not authorized to update stakeholder with id: "+stakeholderId); throw new ForbiddenException("Toggle topic: You are not authorized to update stakeholder with id: "+stakeholderId);
} }

View File

@ -36,7 +36,7 @@ public class Indicator {
private String defaultId; private String defaultId;
private List<IndicatorPath> indicatorPaths; private List<IndicatorPath> indicatorPaths;
public void copyFromDefault(Indicator defaultIndicator) { public void copyFromDefault(Indicator defaultIndicator, Visibility visibility) {
setName(defaultIndicator.getName()); setName(defaultIndicator.getName());
setDescription(defaultIndicator.getDescription()); setDescription(defaultIndicator.getDescription());
setAdditionalDescription(defaultIndicator.getAdditionalDescription()); setAdditionalDescription(defaultIndicator.getAdditionalDescription());
@ -44,7 +44,7 @@ public class Indicator {
setWidth(defaultIndicator.getWidth()); setWidth(defaultIndicator.getWidth());
setHeight(defaultIndicator.getHeight()); setHeight(defaultIndicator.getHeight());
setTags(defaultIndicator.getTags()); setTags(defaultIndicator.getTags());
setVisibility(Visibility.RESTRICTED); setVisibility(visibility);
setCreationDate(defaultIndicator.getCreationDate()); setCreationDate(defaultIndicator.getCreationDate());
setUpdateDate(defaultIndicator.getUpdateDate()); setUpdateDate(defaultIndicator.getUpdateDate());
setDefaultId(defaultIndicator.getId()); setDefaultId(defaultIndicator.getId());

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

@ -14,6 +14,16 @@ enum StakeholderType
FUNDER, RI, PROJECT, ORGANIZATION; FUNDER, RI, PROJECT, ORGANIZATION;
} }
enum Locale {
EN("en"), EU("eu");
public final String label;
private Locale(String label) {
this.label = label;
}
}
public class Stakeholder<StringOrTopic> { public class Stakeholder<StringOrTopic> {
@Id @Id
@ -24,12 +34,14 @@ 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;
private String alias; private String alias;
private String description; private String description;
private String defaultId = null; private String defaultId = null;
private Locale locale = Locale.EU;
private Visibility visibility = Visibility.PRIVATE; private Visibility visibility = Visibility.PRIVATE;
private Date creationDate; private Date creationDate;
private Date updateDate; private Date updateDate;
@ -45,12 +57,14 @@ 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();
alias = stakeholder.getAlias(); alias = stakeholder.getAlias();
description = stakeholder.getDescription(); description = stakeholder.getDescription();
defaultId = stakeholder.getDefaultId(); defaultId = stakeholder.getDefaultId();
setLocale(stakeholder.getLocale());
setVisibility(stakeholder.getVisibility()); setVisibility(stakeholder.getVisibility());
creationDate = stakeholder.getCreationDate(); creationDate = stakeholder.getCreationDate();
updateDate = stakeholder.getUpdateDate(); updateDate = stakeholder.getUpdateDate();
@ -112,6 +126,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;
} }
@ -156,6 +178,20 @@ public class Stakeholder<StringOrTopic> {
this.defaultId = defaultId; this.defaultId = defaultId;
} }
public String getLocale() {
return locale.label;
}
public void setLocale(String label) {
Locale locale = null;
for (Locale l : Locale.values()) {
if (l.label.equals(label)) {
locale = l;
}
}
this.locale = locale;
}
public Visibility getVisibility() { public Visibility getVisibility() {
//return visibility.getLabel(); //return visibility.getLabel();
return visibility; return visibility;

View File

@ -294,6 +294,185 @@ 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);
}
}
function addFundingLevelInFilters(filter) {
if(filter.groupFilters && filter.groupFilters.length > 0) {
var index = filter.groupFilters.findIndex(filter => filter.field.includes('project'));
if(index !== -1) {
print('before: ' + JSON.stringify(filter));
var prefix = filter.groupFilters[index].field.substring(0, filter.groupFilters[index].field.indexOf('project'));
if(!filter.groupFilters.find(filter => filter.field === prefix + "project.funding level 1")) {
filter.groupFilters.push({
"field": prefix + "project.funding level 1",
"type": "contains",
"values": [
'((__index_shortName__))'
]
});
print('after: ' + JSON.stringify(filter));
} else {
print('Already added');
}
}
return filter;
}
}
function addFundingStreamInDefaultMSCA() {
print("addFundingStreamInDefaultMSCA")
var stakeholder = db.stakeholder.findOne({"alias": "default-fl1"});
if(stakeholder) {
stakeholder.topics.forEach((topic) => {
var topicObj = db.topic.findOne({"_id": ObjectId(topic)});
topicObj.categories.forEach((category) => {
var categoryObj = db.category.findOne({"_id": ObjectId(category)});
categoryObj.subCategories.forEach((subCategory) => {
var subCategoryObj = db.subCategory.findOne({"_id": ObjectId(subCategory)});
subCategoryObj.numbers.forEach((number) => {
var section = db.section.findOne({"_id": ObjectId(number)});
section.indicators.forEach((indicator) => {
var indicatorObject = db.indicator.findOne({"_id": ObjectId(indicator)});
if(indicatorObject.indicatorPaths[0].parameters) {
indicatorObject.indicatorPaths[0].parameters['index_shortName'] = stakeholder.index_shortName.toLowerCase();
if(indicatorObject.indicatorPaths[0] && indicatorObject.indicatorPaths[0].chartObject) {
var json = JSON.parse(indicatorObject.indicatorPaths[0].chartObject);
if(json.series && json.series.length > 0) {
json.series.forEach(query => {
if(query.query && query.query.filters && query.query.filters.length > 0) {
query.query.filters.forEach(filter => {
filter = addFundingLevelInFilters(filter);
});
}
});
indicatorObject.indicatorPaths[0].chartObject = JSON.stringify(json);
db.indicator.save(indicatorObject);
}
}
}
});
});
subCategoryObj.charts.forEach((chart) => {
var section = db.section.findOne({"_id": ObjectId(chart)});
section.indicators.forEach((indicator) => {
var indicatorObject = db.indicator.findOne({"_id": ObjectId(indicator)});
if(indicatorObject.indicatorPaths[0].parameters) {
indicatorObject.indicatorPaths[0].parameters['index_shortName'] = stakeholder.index_shortName.toLowerCase();
if (indicatorObject.indicatorPaths[0] && indicatorObject.indicatorPaths[0].chartObject) {
var json = JSON.parse(indicatorObject.indicatorPaths[0].chartObject);
if (json.chartDescription && json.chartDescription.queries && json.chartDescription.queries.length > 0) {
json.chartDescription.queries.forEach(query => {
if (query.query && query.query.filters && query.query.filters.length > 0) {
query.query.filters.forEach(filter => {
filter = addFundingLevelInFilters(filter);
});
}
});
indicatorObject.indicatorPaths[0].chartObject = JSON.stringify(json);
db.indicator.save(indicatorObject);
}
}
}
});
});
});
});
});
} else {
print("Profile doesn't exist")
}
}
use monitordb; use monitordb;
// use 1_openaire-mongodb-beta; // dev db // use 1_openaire-mongodb-beta; // dev db
@ -310,12 +489,17 @@ 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();
// 30-05-2023
addFundingStreamInDefaultMSCA();