Remove comments. Add getAliases method in stakeholderService. Remove parametersMapping
This commit is contained in:
parent
a7a3970c79
commit
8918826766
10
pom.xml
10
pom.xml
|
@ -61,10 +61,6 @@
|
|||
<configuration>
|
||||
<mainClass>eu.dnetlib.uoamonitorservice.application.UoaMonitorServiceApplication</mainClass>
|
||||
<executable>true</executable>
|
||||
<excludes>
|
||||
<!-- <packagingExcludes>**/eu/dnetlib/uoamonitorservice/controllers/MonitorLibraryCheckDeployController.class</packagingExcludes>-->
|
||||
<!-- <exclude>**/eu/dnetlib/uoamonitorservice/controllers/MonitorLibraryCheckDeployController.class</exclude>-->
|
||||
</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -73,12 +69,6 @@
|
|||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<!-- <packagingExcludes>**/eu/dnetlib/uoamonitorservice/controllers/MonitorLibraryCheckDeployController.class</packagingExcludes>-->
|
||||
<!-- <exclude>**/eu/dnetlib/uoamonitorservice/controllers/MonitorLibraryCheckDeployController.class</exclude>-->
|
||||
</excludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,245 @@
|
|||
function upperCaseEnumValues() {
|
||||
stakeholders = db.stakeholder.find().map(function (stakeholders) {
|
||||
return stakeholders;
|
||||
});
|
||||
for(var i=0; i<stakeholders.length; i++) {
|
||||
stakeholder = stakeholders[i];
|
||||
|
||||
stakeholderType = stakeholder.type;
|
||||
stakeholder.type = stakeholderType.toUpperCase();
|
||||
db.stakeholder.save(stakeholder);
|
||||
}
|
||||
print("Uppercase enum values for Stakeholder types");
|
||||
|
||||
sections = db.section.find().map(function (sections) {
|
||||
return sections;
|
||||
});
|
||||
for(var i=0; i<sections.length; i++) {
|
||||
section = sections[i];
|
||||
|
||||
sectionType = section.type;
|
||||
section.type = sectionType.toUpperCase();
|
||||
db.section.save(section);
|
||||
}
|
||||
print("Uppercase enum values for Section types");
|
||||
|
||||
indicators = db.indicator.find().map(function (indicators) {
|
||||
return indicators;
|
||||
});
|
||||
for(var i=0; i<indicators.length; i++) {
|
||||
indicator = indicators[i];
|
||||
|
||||
indicatorType = indicator.type;
|
||||
indicator.type = indicatorType.toUpperCase();
|
||||
indicatorWidth = indicator.width;
|
||||
indicator.width = indicatorWidth.toUpperCase();
|
||||
|
||||
indicatorPaths = indicator.indicatorPaths;
|
||||
for(var j=0; j<indicatorPaths.lenght; j++) {
|
||||
indicatorPath = indicatorPaths[j];
|
||||
|
||||
indicatorPathType = indicatorPath.type;
|
||||
indicatorPath.type = indicatorPathType.toUpperCase();
|
||||
indicatorPathSource = indicatorPath.source;
|
||||
indicatorPath.source = indicatorPathSource.toUpperCase();
|
||||
}
|
||||
|
||||
db.indicator.save(indicator);
|
||||
}
|
||||
print("Uppercase enum values for Indicator types and width");
|
||||
print("Uppercase enum values for Indicator path types and source");
|
||||
}
|
||||
|
||||
function addHeightInIndicators() {
|
||||
indicators = db.indicator.find().map(function (indicators) {
|
||||
return indicators;
|
||||
});
|
||||
for(var i=0; i<indicators.length; i++) {
|
||||
indicator = indicators[i];
|
||||
|
||||
if(indicator.type == "chart" || indicator.type == "CHART") {
|
||||
indicator['height'] = "MEDIUM";
|
||||
} else {
|
||||
indicator['height'] = "SMALL";
|
||||
}
|
||||
db.indicator.save(indicator);
|
||||
}
|
||||
print("Height field added in Indicators");
|
||||
}
|
||||
|
||||
function addVisibility() {
|
||||
stakeholders = db.stakeholder.find().map(function (stakeholders) {
|
||||
return stakeholders;
|
||||
});
|
||||
for (var i = 0; i < stakeholders.length; i++) {
|
||||
stakeholder = stakeholders[i];
|
||||
|
||||
if (stakeholder.isActive) {
|
||||
if (stakeholder.isPublic) {
|
||||
stakeholder['visibility'] = "PUBLIC";
|
||||
} else {
|
||||
stakeholder['visibility'] = "RESTRICTED";
|
||||
}
|
||||
} else {
|
||||
stakeholder['visibility'] = "PRIVATE";
|
||||
}
|
||||
|
||||
db.stakeholder.save(stakeholder);
|
||||
}
|
||||
print("Add visibility field for Stakeholders");
|
||||
|
||||
topics = db.topic.find().map(function (topics) {
|
||||
return topics;
|
||||
});
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
topic = topics[i];
|
||||
|
||||
topicVisibility = "PRIVATE";
|
||||
if (topic.isActive) {
|
||||
if (topic.isPublic) {
|
||||
topicVisibility = "PUBLIC";
|
||||
} else {
|
||||
topicVisibility = "RESTRICTED";
|
||||
}
|
||||
}
|
||||
|
||||
topic['visibility'] = topicVisibility;
|
||||
db.topic.save(topic);
|
||||
}
|
||||
print("Add visibility field for Topics");
|
||||
|
||||
categories = db.category.find().map(function (categories) {
|
||||
return categories;
|
||||
});
|
||||
for (var i = 0; i < categories.length; i++) {
|
||||
category = categories[i];
|
||||
|
||||
if (category.isActive) {
|
||||
if (category.isPublic) {
|
||||
category['visibility'] = "PUBLIC";
|
||||
} else {
|
||||
category['visibility'] = "RESTRICTED";
|
||||
}
|
||||
} else {
|
||||
category['visibility'] = "PRIVATE";
|
||||
}
|
||||
|
||||
db.category.save(category);
|
||||
}
|
||||
print("Add visibility field for Categories");
|
||||
|
||||
subCategories = db.subCategory.find().map(function (subCategories) {
|
||||
return subCategories;
|
||||
});
|
||||
for (var i = 0; i < subCategories.length; i++) {
|
||||
subCategory = subCategories[i];
|
||||
|
||||
if (subCategory.isActive) {
|
||||
if (subCategory.isPublic) {
|
||||
subCategory['visibility'] = "PUBLIC";
|
||||
} else {
|
||||
subCategory['visibility'] = "RESTRICTED";
|
||||
}
|
||||
} else {
|
||||
subCategory['visibility'] = "PRIVATE";
|
||||
}
|
||||
|
||||
db.subCategory.save(subCategory);
|
||||
}
|
||||
print("Add visibility field for SubCategories");
|
||||
|
||||
indicators = db.indicator.find().map(function (indicators) {
|
||||
return indicators;
|
||||
});
|
||||
for (var i = 0; i < indicators.length; i++) {
|
||||
indicator = indicators[i];
|
||||
|
||||
if (indicator.isActive) {
|
||||
if (indicator.isPublic) {
|
||||
indicator['visibility'] = "PUBLIC";
|
||||
} else {
|
||||
indicator['visibility'] = "RESTRICTED";
|
||||
}
|
||||
} else {
|
||||
indicator['visibility'] = "PRIVATE";
|
||||
}
|
||||
|
||||
db.indicator.save(indicator);
|
||||
}
|
||||
print("Add visibility field for Indicators");
|
||||
}
|
||||
|
||||
function removeIsActiveAndIsPublic() {
|
||||
stakeholders = db.stakeholder.find().map(function (stakeholders) {
|
||||
return stakeholders;
|
||||
});
|
||||
for(var i=0; i<stakeholders.length; i++) {
|
||||
stakeholder = stakeholders[i];
|
||||
|
||||
db.stakeholder.update({"_id": stakeholder._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
|
||||
topics = db.topic.find().map(function (topics) {
|
||||
return topics;
|
||||
});
|
||||
for(var i=0; i<topics.length; i++) {
|
||||
topic = topics[i];
|
||||
|
||||
db.topic.update({"_id": topic._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
|
||||
categories = db.category.find().map(function (categories) {
|
||||
return categories;
|
||||
});
|
||||
for(var i=0; i<categories.length; i++) {
|
||||
category = categories[i];
|
||||
|
||||
db.category.update({"_id": category._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
|
||||
subCategories = db.subCategory.find().map(function (subCategories) {
|
||||
return subCategories;
|
||||
});
|
||||
for(var i=0; i<subCategories.length; i++) {
|
||||
subCategory = subCategories[i];
|
||||
|
||||
db.subCategory.update({"_id": subCategory._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
|
||||
indicators = db.indicator.find().map(function (indicators) {
|
||||
return indicators;
|
||||
});
|
||||
for(var i=0; i<indicators.length; i++) {
|
||||
indicator = indicators[i];
|
||||
|
||||
db.indicator.update({"_id": indicator._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
}
|
||||
|
||||
function addAdminToolsCollections () {
|
||||
db.createCollection("portal");
|
||||
db.createCollection("entity");
|
||||
db.createCollection("page");
|
||||
db.createCollection("pageHelpContent");
|
||||
db.createCollection("divId");
|
||||
db.createCollection("divHelpContent");
|
||||
}
|
||||
|
||||
function addPortals() {
|
||||
db.portal.save({"pid": "monitor", "name": "Monitor", "type": "monitor", "piwik": null, "pages": {}, "entities": {}});
|
||||
}
|
||||
|
||||
function uniqueIndexes() {
|
||||
db.portal.createIndex( { "pid": 1 }, { unique: true } );
|
||||
db.stakeholder.createIndex( { "alias": 1 }, { unique: true } );
|
||||
}
|
||||
|
||||
use monitordb;
|
||||
|
||||
upperCaseEnumValues();
|
||||
addHeightInIndicators();
|
||||
addVisibility();
|
||||
removeIsActiveAndIsPublic();
|
||||
addAdminToolsCollections();
|
||||
addPortals();
|
||||
uniqueIndexes();
|
|
@ -0,0 +1,65 @@
|
|||
function addHomePageInPortalType(portalType) {
|
||||
homePageID = db.page.insertOne({ "route" : "/", "name" : "Home", "type" : "other", "entities" : [ ], "portalType" : portalType, "top" : false, "bottom" : false, "left" : false, "right" : false }).insertedId.str;
|
||||
print("Creating Home page with id " + homePageID);
|
||||
portals = db.portal.find({"type": portalType}).map( function(portal) { return portal; } );
|
||||
for (var i = 0; i < portals.length; i++) {
|
||||
portal_pages = portals[i].pages;
|
||||
|
||||
portal_pages[homePageID] = true;
|
||||
|
||||
portal_pid = portals[i].pid;
|
||||
db.portal.update({ "pid" : portal_pid },{$set: { "pages": portal_pages}});
|
||||
print("Add home page with id " + homePageID + " on " + portalType + " " + portal_pid);
|
||||
}
|
||||
}
|
||||
|
||||
function addFooterDivIdForPortalType(portalType) {
|
||||
homePageID = db.page.find({"portalType": portalType, "route": "/"}).map( function(portal) { return portal._id.str; } ).toString();
|
||||
db.divId.save({ "name" : "footer", "pages" : [ homePageID ], "portalType" : portalType });
|
||||
print("divId 'footer' added for "+portalType+" (home page id: "+homePageID + ")");
|
||||
}
|
||||
|
||||
function addFooterHelpTextForPortalType(portalType) {
|
||||
footerDivIdID = db.divId.find({"portalType": portalType, "name": "footer"}).map( function(divId) { return divId._id.str; } ).toString();
|
||||
|
||||
portals = db.portal.find({"type": portalType}).map( function(portal) { return portal; } );
|
||||
for (var j = 0; j < portals.length; j++) {
|
||||
portal = portals[j];
|
||||
|
||||
var content = "This OpenAIRE MONITOR dashboard is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452";
|
||||
|
||||
if(portal.pid == "egi") {
|
||||
content = "This OpenAIRE MONITOR dashboard is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452";
|
||||
|
||||
} else if(portal.pid == "risis") {
|
||||
|
||||
content = "This OpenAIRE MONITOR dashboard is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452 and 824091";
|
||||
|
||||
} else if(portal.pid == "sobigdata") {
|
||||
|
||||
content = "This OpenAIRE MONITOR dashboard is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452 and 871042";
|
||||
}
|
||||
|
||||
db.divHelpContent.save(
|
||||
{ "divId" : footerDivIdID,
|
||||
"portal" : portal._id.str,
|
||||
"content" : "<p class=\"uk-margin-remove-bottom\"><span style=\"font-size:8pt\">"+content+"</span></p>",
|
||||
"isActive" : true
|
||||
}
|
||||
);
|
||||
|
||||
print("div help text for divId 'footer' added for "+portalType +" (id: "+ portal._id + " - pid: " + portal.pid + " - footer divId id: "+footerDivIdID + ")");
|
||||
}
|
||||
}
|
||||
|
||||
use monitordb;
|
||||
|
||||
addHomePageInPortalType("funder");
|
||||
addFooterDivIdForPortalType("funder");
|
||||
addFooterHelpTextForPortalType("funder");
|
||||
addHomePageInPortalType("ri");
|
||||
addFooterDivIdForPortalType("ri");
|
||||
addFooterHelpTextForPortalType("ri");
|
||||
addHomePageInPortalType("organization");
|
||||
addFooterDivIdForPortalType("organization");
|
||||
addFooterHelpTextForPortalType("organization");
|
|
@ -0,0 +1,182 @@
|
|||
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;
|
||||
|
||||
statsProfileOfIndicatorsAsVariable();
|
||||
addFundingStreamInDefaultMSCA();
|
|
@ -0,0 +1,16 @@
|
|||
function deleteIndexParameters() {
|
||||
var indicators = db.indicator.find();
|
||||
indicators.forEach(indicator => {
|
||||
indicator.indicatorPaths.forEach(path => {
|
||||
if(path.parameters) {
|
||||
delete path.parameters['index_id'];
|
||||
delete path.parameters['index_name'];
|
||||
delete path.parameters['index_shortName'];
|
||||
}
|
||||
db.indicator.save(indicator);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
use irish-prod;
|
||||
deleteIndexParameters();
|
|
@ -41,7 +41,6 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter {
|
|||
@Bean
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
// .globalOperationParameters(globalParameterList())
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.uoamonitorservice.controllers"))
|
||||
|
|
|
@ -14,7 +14,6 @@ import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
|
|||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
import java.util.Collections;
|
||||
//"uoahelptexts"
|
||||
@Configuration
|
||||
@EnableMongoRepositories(basePackages = {"eu.dnetlib.uoamonitorservice.dao", "eu.dnetlib.uoaadmintoolslibrary.dao"})
|
||||
public class MongoConnection {
|
||||
|
|
|
@ -259,51 +259,10 @@ public class CategoryController {
|
|||
if(topic.getDefaultId() == null && children != null) {
|
||||
onDeleteDefaultCategory(categoryId, topicId, children);
|
||||
}
|
||||
|
||||
// for(String subCategoryId : category.getSubCategories()) {
|
||||
// SubCategory<String> subcategory = subCategoryDAO.findById(subCategoryId);
|
||||
// if(subcategory == null) {
|
||||
// // EXCEPTION - SubCategory not found
|
||||
// throw new EntityNotFoundException("Delete category: SubCategory with id: "+subCategoryId+" not found (subcategory exists in category: "+categoryId+")");
|
||||
// }
|
||||
//
|
||||
// for(String chartSectionId : subcategory.getCharts()) {
|
||||
// Section<String> chartSection = sectionDAO.findById(chartSectionId);
|
||||
// if (chartSection == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Delete topic: Section with id: "+chartSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
|
||||
// }
|
||||
//
|
||||
// for (String chartId : chartSection.getIndicators()) {
|
||||
// indicatorDAO.delete(chartId);
|
||||
// }
|
||||
// subcategory.setCharts(null);
|
||||
// sectionDAO.delete(chartSectionId);
|
||||
// }
|
||||
//
|
||||
// for(String numberSectionId : subcategory.getNumbers()) {
|
||||
// Section<String> numberSection = sectionDAO.findById(numberSectionId);
|
||||
// if (numberSection == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Delete topic: Section with id: "+numberSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
|
||||
// }
|
||||
//
|
||||
// for (String numberId : numberSection.getIndicators()) {
|
||||
// indicatorDAO.delete(numberId);
|
||||
// }
|
||||
// subcategory.setNumbers(null);
|
||||
// sectionDAO.delete(numberSectionId);
|
||||
// }
|
||||
//
|
||||
// subCategoryDAO.delete(subCategoryId);
|
||||
// }
|
||||
subCategoryController.deleteTree(category);
|
||||
|
||||
category.setSubCategories(null);
|
||||
|
||||
categories.remove(index);
|
||||
topicDAO.save(topic);
|
||||
|
||||
categoryDAO.delete(categoryId);
|
||||
log.debug("Category deleted!");
|
||||
} else {
|
||||
|
@ -406,44 +365,6 @@ public class CategoryController {
|
|||
return categoriesFull;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/toggle-status", method = RequestMethod.POST)
|
||||
// public Boolean toggleCategoryStatus(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId,
|
||||
// @PathVariable("categoryId") String categoryId) {
|
||||
// log.debug("toggle category status (isActive)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId);
|
||||
//
|
||||
// Category category = categoryDAO.findById(categoryId);
|
||||
// if (category == null) {
|
||||
// // EXCEPTION - Category not found
|
||||
// throw new EntityNotFoundException("Toggle category status: Category with id: "+categoryId+" not found");
|
||||
// }
|
||||
// category.setIsActive(!category.getIsActive());
|
||||
//
|
||||
// this.toggleCategory(stakeholderId, topicId, category);
|
||||
//
|
||||
// return category.getIsActive();
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/toggle-access", method = RequestMethod.POST)
|
||||
// public Boolean toggleCategoryAccess(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId,
|
||||
// @PathVariable("categoryId") String categoryId) {
|
||||
// log.debug("toggle category access (isPublic)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId);
|
||||
//
|
||||
// Category category = categoryDAO.findById(categoryId);
|
||||
// if (category == null) {
|
||||
// // EXCEPTION - Category not found
|
||||
// throw new EntityNotFoundException("Toggle category access: Category with id: "+categoryId+" not found");
|
||||
// }
|
||||
// category.setIsPublic(!category.getIsPublic());
|
||||
//
|
||||
// this.toggleCategory(stakeholderId, topicId, category);
|
||||
//
|
||||
// return category.getIsPublic();
|
||||
// }
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/change-visibility", method = RequestMethod.POST)
|
||||
public Category changeCategoryVisibility(@PathVariable("stakeholderId") String stakeholderId,
|
||||
|
|
|
@ -221,16 +221,9 @@ public class IndicatorController {
|
|||
if(section.getDefaultId() != null && 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);
|
||||
}
|
||||
|
||||
indicatorDAO.save(indicatorNew);
|
||||
|
||||
List<String> indicators = section.getIndicators();
|
||||
indicators.add(indicatorNew.getId());
|
||||
|
||||
sectionDAO.save(section);
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +293,6 @@ public class IndicatorController {
|
|||
if(indicatorPathBasedOnDefault == null) {
|
||||
// Add new indicator path in existing indicators
|
||||
IndicatorPath indicatorPathNew = new IndicatorPath(indicatorPath);
|
||||
parameterMapping(indicatorPathNew, stakeholder);
|
||||
indicatorPaths.add(indicatorPathNew);
|
||||
changed = true;
|
||||
} else {
|
||||
|
@ -407,10 +399,6 @@ public class IndicatorController {
|
|||
indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue());
|
||||
changed = true;
|
||||
}
|
||||
// else if(parameter.getKey().equals("type")) {
|
||||
// indicatorPathBasedOnDefault.getParameters().put(parameter.getKey(), parameter.getValue());
|
||||
// changed = true;
|
||||
// }
|
||||
}
|
||||
|
||||
// When deleting indicator path parameters in a default profile, delete them also from all children profiles
|
||||
|
@ -421,8 +409,6 @@ public class IndicatorController {
|
|||
}
|
||||
}
|
||||
}
|
||||
parameterMapping(indicatorPathBasedOnDefault, stakeholder);
|
||||
//}
|
||||
}
|
||||
log.debug("After parameters check: " + changed);
|
||||
|
||||
|
@ -500,65 +486,6 @@ public class IndicatorController {
|
|||
}
|
||||
}
|
||||
|
||||
public void parameterMapping(IndicatorPath indicatorPath, Stakeholder stakeholder) throws UnsupportedEncodingException {
|
||||
if (indicatorPath.getParameters() != null) {
|
||||
if (indicatorPath.getParameters().containsKey("index_name")) {
|
||||
indicatorPath.getParameters().put("index_name", stakeholder.getIndex_name());
|
||||
} else if (indicatorPath.getParameters().containsKey("index_shortName")) {
|
||||
if(stakeholder.getIndex_shortName() != null) {
|
||||
indicatorPath.getParameters().put("index_shortName", stakeholder.getIndex_shortName().toLowerCase());
|
||||
} else {
|
||||
indicatorPath.getParameters().remove("index_shortName");
|
||||
}
|
||||
} else if (indicatorPath.getParameters().containsKey("index_id")) {
|
||||
indicatorPath.getParameters().put("index_id", stakeholder.getIndex_id());
|
||||
}
|
||||
}
|
||||
|
||||
// // url encoding for number indicators
|
||||
// String url = indicatorPath.getUrl();
|
||||
// String encoded_index_id = urlEncode(URLEncoder.encode(stakeholder.getIndex_id(), "UTF-8"));
|
||||
// url = url.replace("index_id", encoded_index_id);
|
||||
// String encoded_index_name = urlEncode(URLEncoder.encode(stakeholder.getIndex_name(), "UTF-8"));
|
||||
// url = url.replace("index_name", encoded_index_name);
|
||||
// String encoded_index_shortName = urlEncode(URLEncoder.encode(stakeholder.getIndex_shortName(), "UTF-8"));
|
||||
// url = url.replace("index_shortName", encoded_index_shortName);
|
||||
// indicatorPath.setUrl(url);
|
||||
}
|
||||
|
||||
public String urlEncode(String encodedIndicatorPathField) {
|
||||
String indicatorPathField = "";
|
||||
|
||||
for( int i=0; i<encodedIndicatorPathField.length(); i++ ){
|
||||
String character = encodedIndicatorPathField.substring(i, i+1);
|
||||
|
||||
if(character.equals("+")) {
|
||||
indicatorPathField = indicatorPathField.concat("%20");
|
||||
} else if(character.equals("%")) {
|
||||
//grab the hex in pairs
|
||||
String output = encodedIndicatorPathField.substring(i+1, (i + 3));
|
||||
|
||||
if(output.equals("7E") || output.equals("27") || output.equals("28") || output.equals("29") || output.equals("21")) {
|
||||
//convert hex to decimal
|
||||
int decimal = Integer.parseInt(output, 16);
|
||||
//convert the decimal to character
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append((char) decimal);
|
||||
|
||||
indicatorPathField = indicatorPathField.concat(sb.toString());
|
||||
} else {
|
||||
indicatorPathField = indicatorPathField.concat(character + output);
|
||||
}
|
||||
|
||||
i += 2;
|
||||
} else {
|
||||
indicatorPathField = indicatorPathField.concat(character);
|
||||
}
|
||||
}
|
||||
|
||||
return indicatorPathField;
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{sectionId}/{indicatorId}/delete", method = RequestMethod.DELETE)
|
||||
public boolean deleteIndicator(@PathVariable("stakeholderId") String stakeholderId,
|
||||
|
@ -610,29 +537,6 @@ public class IndicatorController {
|
|||
|
||||
public boolean onDeleteDefaultIndicator(String defaultIndicatorId, String defaultSectionId, String children) {
|
||||
if(children.equals("delete")) {
|
||||
// // 1st way
|
||||
// List<Section> sections = sectionDAO.findByDefaultId(defaultSectionId);
|
||||
//
|
||||
// for(Section section : sections) {
|
||||
// List<String> indicators = section.getIndicators();
|
||||
//
|
||||
// Iterator<String> indicatorsIterator = indicators.iterator();
|
||||
// while(indicatorsIterator.hasNext()) {
|
||||
// String indicatorId = indicatorsIterator.next();
|
||||
//
|
||||
// Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
// if (indicator.getDefaultId().equals(defaultIndicatorId)) {
|
||||
// indicatorsIterator.remove();
|
||||
// sectionDAO.save(section);
|
||||
//
|
||||
// indicatorDAO.delete(indicatorId);
|
||||
// log.debug("Indicator deleted!");
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// 2nd way
|
||||
List<Section> sections = sectionDAO.findByDefaultId(defaultSectionId);
|
||||
List<Indicator> indicators = indicatorDAO.findByDefaultId(defaultIndicatorId);
|
||||
|
@ -654,19 +558,6 @@ public class IndicatorController {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// // 3rd way - parentId
|
||||
// List<Indicator> indicators = indicatorDAO.findByDefaultId(defaultIndicatorId);
|
||||
// for(Indicator indicator : indicators) {
|
||||
// Section section = sectionDAO.findById(indicator.getParent());
|
||||
// List<String> sectionIndicators = section.getIndicators();
|
||||
//
|
||||
// sectionIndicators.remove(indicator.getId());
|
||||
// sectionDAO.save(section);
|
||||
//
|
||||
// indicatorDAO.delete(indicator.getId());
|
||||
// log.debug("Indicator deleted!");
|
||||
// }
|
||||
} else if(children.equals("disconnect")) {
|
||||
List<Indicator> indicators = indicatorDAO.findByDefaultId(defaultIndicatorId);
|
||||
for(Indicator indicator : indicators) {
|
||||
|
@ -678,79 +569,6 @@ public class IndicatorController {
|
|||
return true;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/{stakeholderId}/charts/delete", method = RequestMethod.DELETE)
|
||||
// public boolean deleteAllChartIndicators(@PathVariable("stakeholderId") String stakeholderId) {
|
||||
// log.debug("delete all chart indicators of stakeholder");
|
||||
// log.debug("Stakeholder: "+stakeholderId);
|
||||
//
|
||||
// Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
// if(stakeholder != null) {
|
||||
//
|
||||
// for(String topicId : stakeholder.getTopics()) {
|
||||
// Topic<String> topic = topicDAO.findById(topicId);
|
||||
// if(topic != null) {
|
||||
// for(String categoryId : topic.getCategories()) {
|
||||
// Category<String> category = categoryDAO.findById(categoryId);
|
||||
// if(category != null) {
|
||||
// for(String subcategoryId : category.getSubCategories()) {
|
||||
// SubCategory<String> subcategory = subCategoryDAO.findById(subcategoryId);
|
||||
// if(subcategory != null) {
|
||||
//
|
||||
// for(String sectionId : subcategory.getCharts()) {
|
||||
// Section<String> section = sectionDAO.findById(sectionId);
|
||||
// if (section != null) {
|
||||
//
|
||||
// List<String> indicators = section.getIndicators();
|
||||
// Iterator<String> indicatorsIterator = section.getIndicators().iterator();
|
||||
//
|
||||
// while (indicatorsIterator.hasNext()) {
|
||||
// String indicatorId = indicatorsIterator.next();
|
||||
// Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
// if (indicator != null) {
|
||||
// int index = indicators.indexOf(indicatorId);
|
||||
// if (index != -1) {
|
||||
// indicatorsIterator.remove();
|
||||
// //indicators.remove(index);
|
||||
//
|
||||
// indicatorDAO.delete(indicatorId);
|
||||
// log.debug("Indicator deleted!");
|
||||
// } else {
|
||||
// // EXCEPTION - Indicator not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); -> SubCategory: subcategory.getAlias(); -> Section: section.getTitle();
|
||||
// throw new PathNotValidException("Delete indicator: Indicator with id: " + indicatorId + " not found in Section: " + sectionId);
|
||||
// }
|
||||
// } else {
|
||||
// // EXCEPTION - Indicator not found
|
||||
// throw new EntityNotFoundException("Delete indicator: Indicator with id: " + indicatorId + " not found");
|
||||
// }
|
||||
// }
|
||||
// sectionDAO.save(section);
|
||||
// } else {
|
||||
// // EXCEPTION - Section not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); -> SubCategory: subcategory.getAlias();
|
||||
// throw new PathNotValidException("Delete indicator: Section with id: " + sectionId + " not found in SubCategory: " + subcategoryId);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // EXCEPTION - SubCategory not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias();
|
||||
// throw new PathNotValidException("Delete indicator: SubCategory with id: "+subcategoryId+" not found in Category: "+categoryId);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // EXCEPTION - Category not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias();
|
||||
// throw new PathNotValidException("Delete indicator: Category with id: "+categoryId+" not found in Topic: "+topicId);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // EXCEPTION - Topic not found in Stakeholder: stakeholder.getAlias();
|
||||
// throw new PathNotValidException("Delete indicator: Topic with id: "+topicId+" not found in Stakeholder: "+stakeholderId);
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // EXCEPTION - Stakeholder not found
|
||||
// throw new EntityNotFoundException("Delete indicator: Stakeholder with id: "+stakeholderId+" not found");
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{sectionId}/{type}/reorder", method = RequestMethod.POST)
|
||||
public List<Indicator> reorderIndicators(@PathVariable("stakeholderId") String stakeholderId,
|
||||
|
@ -793,50 +611,6 @@ public class IndicatorController {
|
|||
return indicatorsFull;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{sectionId}/{indicatorId}/toggle-status", method = RequestMethod.POST)
|
||||
// public Boolean toggleIndicatorStatus(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId,
|
||||
// @PathVariable("categoryId") String categoryId,
|
||||
// @PathVariable("subcategoryId") String subcategoryId,
|
||||
// @PathVariable("sectionId") String sectionId,
|
||||
// @PathVariable("indicatorId") String indicatorId) {
|
||||
// log.debug("toggle indicator status (isActive)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId + " - Section: "+sectionId+ " - Indicator: "+indicatorId);
|
||||
//
|
||||
// Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
// if (indicator == null) {
|
||||
// // EXCEPTION - Indicator not found
|
||||
// throw new EntityNotFoundException("Toggle indicator status: Indicator with id: "+indicatorId+" not found");
|
||||
// }
|
||||
// indicator.setIsActive(!indicator.getIsActive());
|
||||
//
|
||||
// this.toggleIndicator(stakeholderId, topicId, categoryId, subcategoryId, sectionId, indicator);
|
||||
//
|
||||
// return indicator.getIsActive();
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{sectionId}/{indicatorId}/toggle-access", method = RequestMethod.POST)
|
||||
// public Boolean toggleIndicatorAccess(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId,
|
||||
// @PathVariable("categoryId") String categoryId,
|
||||
// @PathVariable("subcategoryId") String subcategoryId,
|
||||
// @PathVariable("sectionId") String sectionId,
|
||||
// @PathVariable("indicatorId") String indicatorId) {
|
||||
// log.debug("toggle indicator access (isPublic)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId + " - Section: "+sectionId+ " - Indicator: "+indicatorId);
|
||||
//
|
||||
// Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
// if (indicator == null) {
|
||||
// // EXCEPTION - Indicator not found
|
||||
// throw new EntityNotFoundException("Toggle indicator access: Indicator with id: "+indicatorId+" not found");
|
||||
// }
|
||||
// indicator.setIsPublic(!indicator.getIsPublic());
|
||||
//
|
||||
// this.toggleIndicator(stakeholderId, topicId, categoryId, subcategoryId, sectionId, indicator);
|
||||
//
|
||||
// return indicator.getIsPublic();
|
||||
// }
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{sectionId}/{indicatorId}/change-visibility", method = RequestMethod.POST)
|
||||
public Indicator changeIndicatorVisibility(@PathVariable("stakeholderId") String stakeholderId,
|
||||
|
|
|
@ -16,9 +16,6 @@ import java.util.*;
|
|||
@CrossOrigin(origins = "*")
|
||||
public class MonitorController {
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
//
|
||||
// @Autowired
|
||||
// private LayoutService layoutService;
|
||||
|
||||
@Autowired
|
||||
private PortalService portalService;
|
||||
|
@ -36,11 +33,6 @@ public class MonitorController {
|
|||
if (!old_pid.equals(new_pid)) {
|
||||
pageService.updatePid(old_pid, new_pid, portal.getType());
|
||||
}
|
||||
// String old_pid = portalResponse.getPid();
|
||||
// String new_pid = portal.getPid();
|
||||
// if(!old_pid.equals(new_pid)) {
|
||||
// layoutService.updatePid(old_pid, new_pid);
|
||||
// }
|
||||
|
||||
return portalResponse;
|
||||
}
|
||||
|
@ -60,16 +52,5 @@ public class MonitorController {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/{pid}/layout", method = RequestMethod.GET)
|
||||
// public Layout getLayoutForCommunity(@PathVariable(value = "pid") String pid) {
|
||||
// return layoutService.findByPid(pid);
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/{pid}/layout", method = RequestMethod.POST)
|
||||
// public Layout updateLayoutForCommunity(@PathVariable(value = "pid") String pid, @RequestBody Layout layout) {
|
||||
// return layoutService.save(layout);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Map;
|
|||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
@RequestMapping("/monitor-library")
|
||||
//@ConditionalOnBean(UoaMonitorServiceApplication.class)
|
||||
public class MonitorLibraryCheckDeployController {
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
|
@ -63,7 +62,6 @@ public class MonitorLibraryCheckDeployController {
|
|||
response.put("monitorservice.mongodb.port", mongoConfig.getPort()+"");
|
||||
response.put("monitorservice.mongodb.username", mongoConfig.getUsername() == null ? null : "[unexposed value]");
|
||||
response.put("monitorservice.mongodb.password", mongoConfig.getPassword() == null ? null : "[unexposed value]");
|
||||
// response.put("Define also", "monitorservice.mongodb.username, monitorservice.mongodb.password");
|
||||
|
||||
if(globalVars.date != null) {
|
||||
response.put("Date of deploy", globalVars.date.toString());
|
||||
|
|
|
@ -58,7 +58,6 @@ public class MonitorServiceCheckDeployController {
|
|||
response.put("monitorservice.mongodb.port", mongoConfig.getPort()+"");
|
||||
response.put("monitorservice.mongodb.username", mongoConfig.getUsername() == null ? null : "[unexposed value]");
|
||||
response.put("monitorservice.mongodb.password", mongoConfig.getPassword() == null ? null : "[unexposed value]");
|
||||
// response.put("Define also", "monitorservice.mongodb.username, monitorservice.mongodb.password");
|
||||
|
||||
if(globalVars.date != null) {
|
||||
response.put("Date of deploy", globalVars.date.toString());
|
||||
|
|
|
@ -196,241 +196,6 @@ public class SectionController {
|
|||
|
||||
public void onUpdateDefaultSection(Section section, Stakeholder stakeholder, Section oldSection) {
|
||||
log.debug("On update default section");
|
||||
|
||||
// section already exists - check if changed and update all sections based on it
|
||||
|
||||
boolean changed = false;
|
||||
List<Section> sections = sectionDAO.findByDefaultId(section.getId());
|
||||
|
||||
for(Section sectionBasedOnDefault : sections) {
|
||||
if(section.getTitle() != null && !section.getTitle().equals(sectionBasedOnDefault.getTitle())
|
||||
&& (oldSection.getTitle() == null || oldSection.getTitle().equals(sectionBasedOnDefault.getTitle()))) {
|
||||
|
||||
sectionBasedOnDefault.setTitle(section.getTitle());
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if(!changed) {
|
||||
// break;
|
||||
continue;
|
||||
}
|
||||
|
||||
// sectionBasedOnDefault.setTitle(section.getTitle());
|
||||
sectionBasedOnDefault.setUpdateDate(section.getUpdateDate());
|
||||
sectionDAO.save(sectionBasedOnDefault);
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{sectionId}/delete", method = RequestMethod.DELETE)
|
||||
public boolean deleteSection(@PathVariable("stakeholderId") String stakeholderId,
|
||||
@PathVariable("topicId") String topicId,
|
||||
@PathVariable("categoryId") String categoryId,
|
||||
@PathVariable("subcategoryId") String subcategoryId,
|
||||
@PathVariable("sectionId") String sectionId,
|
||||
@RequestParam(required = false) String children) {
|
||||
log.debug("delete section");
|
||||
log.debug("Id: "+sectionId + " - Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId);
|
||||
|
||||
Section section = sectionDAO.findById(sectionId);
|
||||
if(section != null) {
|
||||
SubCategory<String> subCategory = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId);
|
||||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
if(section.getDefaultId() != null && !rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("Delete section: You are not authorized to delete a default Section in stakeholder with id: "+stakeholderId);
|
||||
}
|
||||
|
||||
String type = "";
|
||||
List<String> sections = null;
|
||||
if (section.getType().equals("chart")) {
|
||||
sections = subCategory.getCharts();
|
||||
type = "chart";
|
||||
} else if (section.getType().equals("number")) {
|
||||
sections = subCategory.getNumbers();
|
||||
type = "number";
|
||||
}
|
||||
|
||||
int index = sections.indexOf(sectionId);
|
||||
if (index != -1) {
|
||||
// this section belongs in default profile
|
||||
if(subCategory.getDefaultId() == null && children != null) {
|
||||
onDeleteDefaultSection(sectionId, subcategoryId, children, type);
|
||||
}
|
||||
|
||||
indicatorController.deleteTree(section);
|
||||
|
||||
sections.remove(index);
|
||||
subCategoryDAO.save(subCategory);
|
||||
|
||||
sectionDAO.delete(sectionId);
|
||||
log.debug("Section deleted!");
|
||||
} else {
|
||||
// EXCEPTION - Section not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); -> SubCategory: subcategory.getAlias();
|
||||
throw new PathNotValidException("Delete section: Section with id: "+sectionId+" not found in SubCategory: "+subcategoryId);
|
||||
}
|
||||
} else {
|
||||
// EXCEPTION - Section not found
|
||||
throw new EntityNotFoundException("Delete section: Section with id: "+sectionId+" not found");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean onDeleteDefaultSection(String defaultSectionId, String defaultSubCategoryId, String children, String type) {
|
||||
if(children.equals("delete")) {
|
||||
List<SubCategory> subCategories = subCategoryDAO.findByDefaultId(defaultSubCategoryId);
|
||||
List<Section> sections = sectionDAO.findByDefaultId(defaultSectionId);
|
||||
|
||||
for(SubCategory subCategory : subCategories) {
|
||||
Iterator<Section> sectionsIterator = sections.iterator();
|
||||
while(sectionsIterator.hasNext()) {
|
||||
Section section = sectionsIterator.next();
|
||||
|
||||
String sectionId = section.getId();
|
||||
List<String> subCategorySections = null;
|
||||
if(type.equals("chart")) {
|
||||
subCategorySections = subCategory.getCharts();
|
||||
} else if(type.equals("number")) {
|
||||
subCategorySections = subCategory.getNumbers();
|
||||
}
|
||||
if(subCategorySections != null && subCategorySections.contains(sectionId)) {
|
||||
sectionsIterator.remove();
|
||||
|
||||
subCategorySections.remove(sectionId);
|
||||
subCategoryDAO.save(subCategory);
|
||||
|
||||
indicatorController.deleteTree(section);
|
||||
|
||||
sectionDAO.delete(sectionId);
|
||||
log.debug("Section with id: "+sectionId+" deleted!");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(children.equals("disconnect")) {
|
||||
List<Section> sections = sectionDAO.findByDefaultId(defaultSectionId);
|
||||
for(Section section : sections) {
|
||||
indicatorController.disConnectTree(section);
|
||||
|
||||
section.setDefaultId(null);
|
||||
sectionDAO.save(section);
|
||||
|
||||
log.debug("DefaultId for Section with id: "+section.getId()+" empty!");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{type}/reorder", method = RequestMethod.POST)
|
||||
public List<Section> reorderSections(@PathVariable("stakeholderId") String stakeholderId,
|
||||
@PathVariable("topicId") String topicId,
|
||||
@PathVariable("categoryId") String categoryId,
|
||||
@PathVariable("subcategoryId") String subcategoryId,
|
||||
@PathVariable("type") String type,
|
||||
@RequestBody List<String> sections) {
|
||||
log.debug("reorder sections of type: "+type);
|
||||
log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId);
|
||||
|
||||
SubCategory<String> subCategory = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId);
|
||||
|
||||
if (type.equals("chart")) {
|
||||
List<String> oldSections = subCategory.getCharts();
|
||||
for (String sectionId : oldSections) {
|
||||
if (!sections.contains(sectionId)) {
|
||||
sections.add(sectionId);
|
||||
}
|
||||
}
|
||||
subCategory.setCharts(sections);
|
||||
} else if (type.equals("number")) {
|
||||
List<String> oldSections = subCategory.getNumbers();
|
||||
for (String sectionId : oldSections) {
|
||||
if (!sections.contains(sectionId)) {
|
||||
sections.add(sectionId);
|
||||
}
|
||||
}
|
||||
subCategory.setNumbers(sections);
|
||||
}
|
||||
|
||||
List<Section> sectionsFull = new ArrayList<>();
|
||||
for(String sectionId : sections) {
|
||||
Section section = sectionDAO.findById(sectionId);
|
||||
if(section == null) {
|
||||
// EXCEPTION - Section not found
|
||||
throw new EntityNotFoundException("Reorder sections: Section with id: " + sectionId + " not found");
|
||||
}
|
||||
sectionsFull.add(section);
|
||||
}
|
||||
|
||||
subCategoryDAO.save(subCategory);
|
||||
log.debug("Sections reordered!");
|
||||
|
||||
return sectionsFull;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{sectionId}/toggle-status", method = RequestMethod.POST)
|
||||
// public Boolean toggleSectionStatus(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId,
|
||||
// @PathVariable("categoryId") String categoryId,
|
||||
// @PathVariable("subcategoryId") String subcategoryId,
|
||||
// @PathVariable("sectionId") String sectionId) {
|
||||
// log.debug("toggle section status (isActive)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId+ " - Section: "+sectionId);
|
||||
//
|
||||
// Section section = sectionDAO.findById(sectionId);
|
||||
// if (section == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Toggle section status: Section with id: "+sectionId+" not found");
|
||||
// }
|
||||
// section.setIsActive(!section.getIsActive());
|
||||
//
|
||||
// this.toggleSection(stakeholderId, topicId, categoryId, subcategoryId, section);
|
||||
//
|
||||
// return section.getIsActive();
|
||||
// }
|
||||
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/{sectionId}/toggle-access", method = RequestMethod.POST)
|
||||
// public Boolean toggleSectionAccess(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId,
|
||||
// @PathVariable("categoryId") String categoryId,
|
||||
// @PathVariable("subcategoryId") String subcategoryId,
|
||||
// @PathVariable("sectionId") String sectionId) {
|
||||
// log.debug("toggle section access (isPublic)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId);
|
||||
//
|
||||
// Section section = sectionDAO.findById(sectionId);
|
||||
// if (section == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Toggle section access: Section with id: "+sectionId+" not found");
|
||||
// }
|
||||
// section.setIsPublic(!section.getIsPublic());
|
||||
//
|
||||
// this.toggleSection(stakeholderId, topicId, categoryId, subcategoryId);
|
||||
//
|
||||
// return section.getIsPublic();
|
||||
// }
|
||||
|
||||
|
||||
public void toggleSection(String stakeholderId, String topicId, String categoryId, String subcategoryId, Section section) {
|
||||
SubCategory<String> subCategory = checkForExceptions(stakeholderId, topicId, categoryId, subcategoryId);
|
||||
|
||||
List<String> sections = null;
|
||||
if (section.getType().equals("chart")) {
|
||||
sections = subCategory.getCharts();
|
||||
} else if (section.getType().equals("number")) {
|
||||
sections = subCategory.getNumbers();
|
||||
}
|
||||
|
||||
if(sections.contains(section.getId())) {
|
||||
sectionDAO.save(section);
|
||||
log.debug("Section toggled!");
|
||||
} else {
|
||||
// EXCEPTION - Section not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias(); -> SubCategory: subCategory.getAlias();
|
||||
throw new PathNotValidException("Toggle section: Section with id: "+section.getId()+" not found in SubCategory: "+subcategoryId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private SubCategory checkForExceptions(String stakeholderId, String topicId, String categoryId, String subcategoryId) {
|
||||
|
|
|
@ -56,19 +56,10 @@ public class StakeholderController {
|
|||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/stakeholder/alias", method = RequestMethod.GET)
|
||||
public List<String> getAllReservedStakeholderAlias() {
|
||||
// log.debug("get all stakeholder reserved alias-es");
|
||||
List<String> stakeholderAlias = new ArrayList<>();
|
||||
|
||||
List<Stakeholder> stakeholders = stakeholderDAO.findAll();
|
||||
if(stakeholders != null) {
|
||||
stakeholders.forEach(stakeholder -> {
|
||||
stakeholderAlias.add(stakeholder.getAlias());
|
||||
});
|
||||
}
|
||||
stakeholderAlias.add( "all");
|
||||
List<String> stakeholderAlias = this.stakeholderService.getAllAliases();
|
||||
stakeholderAlias.add("all");
|
||||
stakeholderAlias.add("default");
|
||||
stakeholderAlias.add("alias");
|
||||
|
||||
return stakeholderAlias;
|
||||
}
|
||||
|
||||
|
@ -120,22 +111,11 @@ public class StakeholderController {
|
|||
boolean addAll = false;
|
||||
boolean addPublicAndRestricted = false;
|
||||
|
||||
// if(roles == null
|
||||
// || roles.contains(authorizationService.PORTAL_ADMIN)
|
||||
// || roles.contains(authorizationService.curator(stakeholder.getType()))
|
||||
// || roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) {
|
||||
if(rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
//if(visibility == null || visibility == (Visibility.PRIVATE)) {
|
||||
addAll = true;
|
||||
//}
|
||||
//if(visibility == null || visibility == (Visibility.PRIVATE) || visibility == (Visibility.RESTRICTED)) {
|
||||
addPublicAndRestricted = true;
|
||||
//}
|
||||
// } else if(roles != null && roles.contains(authorizationService.member(stakeholder.getType(), stakeholder.getAlias()))) {
|
||||
} else if(rolesUtils.isMember(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
//if(visibility == null || visibility == (Visibility.PRIVATE) || visibility == (Visibility.RESTRICTED)) {
|
||||
addPublicAndRestricted = true;
|
||||
//}
|
||||
}
|
||||
|
||||
Stakeholder<Topic> stakeholderFull = new Stakeholder<>(stakeholder);
|
||||
|
@ -201,62 +181,18 @@ public class StakeholderController {
|
|||
sectionsNumbers.add(getSectionFull(sectionId, subCategoryId, addAll, addPublicAndRestricted));
|
||||
}
|
||||
subCategoryFull.setNumbers(sectionsNumbers);
|
||||
|
||||
// List<Indicator> charts = new ArrayList<>();
|
||||
// for(String indicatorId : subCategory.getCharts()) {
|
||||
// Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
// if(indicator == null) {
|
||||
// // EXCEPTION - Indicator not found
|
||||
// throw new EntityNotFoundException("Get stakeholder: Indicator with id: "+indicatorId+" not found (indicator exists in subCategory: "+subCategoryId+")");
|
||||
// }
|
||||
// charts.add(indicator);
|
||||
// }
|
||||
// subCategoryFull.setCharts(charts);
|
||||
//
|
||||
// List<Indicator> numbers = new ArrayList<>();
|
||||
// for (String indicatorId : subCategory.getNumbers()) {
|
||||
// Indicator indicator = indicatorDAO.findById(indicatorId);
|
||||
// if (indicator == null) {
|
||||
// // EXCEPTION - Indicator not found
|
||||
// throw new EntityNotFoundException("Get stakeholder: Indicator with id: " + indicatorId + " not found (indicator exists in subCategory: " + subCategoryId + ")");
|
||||
// }
|
||||
// numbers.add(indicator);
|
||||
// }
|
||||
// subCategoryFull.setNumbers(numbers);
|
||||
|
||||
subCategories.add(subCategoryFull);
|
||||
}
|
||||
|
||||
categoryFull.setSubCategories(subCategories);
|
||||
categories.add(categoryFull);
|
||||
}
|
||||
|
||||
topicFull.setCategories(categories);
|
||||
topics.add(topicFull);
|
||||
}
|
||||
|
||||
stakeholderFull.setTopics(topics);
|
||||
return stakeholderFull;
|
||||
}
|
||||
|
||||
// private SubCategory setFullSubcategory(SubCategory subCategory) {
|
||||
// SubCategory subCategoryFull = new SubCategory<Section<Indicator>>(subCategory);
|
||||
//
|
||||
// List<Section> sectionsCharts = new ArrayList<>();
|
||||
//
|
||||
// for(String sectionId : subCategory.getCharts()) {
|
||||
// sectionsCharts.add(getSectionFull(sectionId, subCategoryId, addAll, addPublicAndRestricted));
|
||||
// }
|
||||
// subCategoryFull.setCharts(sectionsCharts);
|
||||
//
|
||||
// List<Section> sectionsNumbers = new ArrayList<>();
|
||||
//
|
||||
// for(String sectionId : subCategory.getNumbers()) {
|
||||
// sectionsNumbers.add(getSectionFull(sectionId, subCategoryId, addAll, addPublicAndRestricted));
|
||||
// }
|
||||
// subCategoryFull.setNumbers(sectionsNumbers);
|
||||
// }
|
||||
|
||||
private Section getSectionFull(String sectionId, String subCategoryId, boolean addAll, boolean addPublicAndRestricted) {
|
||||
Section<String> section = sectionDAO.findById(sectionId);
|
||||
if (section == null) {
|
||||
|
@ -323,10 +259,6 @@ public class StakeholderController {
|
|||
|
||||
// Remove stakeholders for which i do not have authority
|
||||
if(stakeholders != null && stakeholders.size() > 0) {
|
||||
// log.debug("ROLES: ");
|
||||
// roles.forEach(role -> log.debug(role));
|
||||
//
|
||||
// if (roles.contains(authorizationService.PORTAL_ADMIN)) {
|
||||
if (rolesUtils.isPortalAdmin()) {
|
||||
for(Stakeholder stakeholder : stakeholders) {
|
||||
stakeholdersFull.add(this.setFullEntities(stakeholder));
|
||||
|
@ -337,8 +269,6 @@ public class StakeholderController {
|
|||
Iterator<Stakeholder> stakeholderIterator = stakeholders.iterator();
|
||||
while(stakeholderIterator.hasNext()) {
|
||||
Stakeholder stakeholder = stakeholderIterator.next();
|
||||
|
||||
// if(roles.contains(authorizationService.curator(stakeholder.getType()))) {
|
||||
if(rolesUtils.isCurator(stakeholder.getType())) {
|
||||
stakeholdersFull.add(this.setFullEntities(stakeholder));
|
||||
continue;
|
||||
|
@ -359,13 +289,11 @@ public class StakeholderController {
|
|||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/my-stakeholder", method = RequestMethod.GET)
|
||||
public List<Stakeholder> getMyRealStakeholders(@RequestParam(required = false) String type) {
|
||||
// log.debug("get my NOT default stakeholders" + (type != null ? " with type: "+type : ""));
|
||||
return stakeholderService.getStakeholdersByTypeAndRole(type, null, true);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/stakeholder/{alias:.+}", method = RequestMethod.GET)
|
||||
public Stakeholder getStakeholder(@PathVariable("alias") String alias) {
|
||||
// log.debug("get stakeholder: "+alias);
|
||||
|
||||
Stakeholder<String> stakeholder = stakeholderDAO.findByAlias(alias);
|
||||
if(stakeholder == null) {
|
||||
|
@ -373,7 +301,6 @@ public class StakeholderController {
|
|||
throw new EntityNotFoundException("Get stakeholder: Stakeholder with alias: "+alias+" not found");
|
||||
}
|
||||
|
||||
// List<String> roles = authorizationService.getRoles();
|
||||
if(stakeholder.getDefaultId() == null && !rolesUtils.isLoggedIn()) {
|
||||
// EXCEPTION - Unauthorized
|
||||
throw new AccessDeniedException("Get stakeholder: You are not authorized (not logged in) to access stakeholder with alias: "+alias);
|
||||
|
@ -386,7 +313,6 @@ public class StakeholderController {
|
|||
if((stakeholder.getVisibility() == Visibility.PRIVATE && !rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())
|
||||
|| (stakeholder.getVisibility() == Visibility.RESTRICTED && !rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias()) && !rolesUtils.isMember(stakeholder.getType(), stakeholder.getAlias())))) {
|
||||
// // EXCEPTION - Access denied
|
||||
// throw new ForbiddenException("Get stakeholder: You are not authorized to get stakeholder with alias: "+alias);
|
||||
List<String> topicsEmpty = stakeholder.getTopics();
|
||||
topicsEmpty.clear();
|
||||
stakeholder.setTopics(topicsEmpty);
|
||||
|
@ -397,7 +323,6 @@ public class StakeholderController {
|
|||
return this.setFullEntities(stakeholder);
|
||||
}
|
||||
|
||||
// @PreAuthorize("isAuthenticated()")
|
||||
@PreAuthorize("hasAnyAuthority("
|
||||
+ "@AuthorizationService.PORTAL_ADMIN, "
|
||||
+ "@AuthorizationService.curator(#_stakeholder.getType()), "
|
||||
|
@ -407,26 +332,13 @@ public class StakeholderController {
|
|||
public Stakeholder saveStakeholder(@RequestBody Stakeholder _stakeholder) {
|
||||
log.debug("save stakeholder");
|
||||
log.debug("Alias: "+_stakeholder.getAlias() + " - Id: "+_stakeholder.getId());
|
||||
|
||||
// if(_stakeholder == null) {
|
||||
// log.debug("stakeholder null");
|
||||
// // EXCEPTION - Parameter for Stakeholder is not accepted
|
||||
// }
|
||||
|
||||
Stakeholder<String> stakeholder = new Stakeholder<>(_stakeholder);
|
||||
|
||||
Date date = new Date();
|
||||
stakeholder.setUpdateDate(date);
|
||||
|
||||
List<String> topics = new ArrayList<>();
|
||||
|
||||
// stakeholder does not exist in DB
|
||||
if(_stakeholder.getId() == null) {
|
||||
stakeholder.setCreationDate(date);
|
||||
|
||||
// for(Topic topic : _stakeholder.getTopics()) {
|
||||
// topics.add(topic.getId());
|
||||
// }
|
||||
} else {
|
||||
Stakeholder<String> oldStakeholder = stakeholderDAO.findById(_stakeholder.getId());
|
||||
if(oldStakeholder == null) {
|
||||
|
@ -441,21 +353,12 @@ public class StakeholderController {
|
|||
}
|
||||
topics.add(topic.getId());
|
||||
}
|
||||
// stakeholder.setTopics(topics);
|
||||
// _stakeholder = this.setFullEntities(stakeholder, rolesUtils.getRoles());
|
||||
}
|
||||
|
||||
stakeholder.setTopics(topics);
|
||||
|
||||
Stakeholder<String> stakeholderSaved = stakeholderDAO.save(stakeholder);
|
||||
_stakeholder.setId(stakeholderSaved.getId());
|
||||
_stakeholder.setCreationDate(stakeholderSaved.getCreationDate());
|
||||
_stakeholder.setUpdateDate(stakeholderSaved.getUpdateDate());
|
||||
|
||||
topics = null;
|
||||
stakeholder = null;
|
||||
stakeholderSaved = null;
|
||||
|
||||
return _stakeholder;
|
||||
}
|
||||
|
||||
|
@ -470,78 +373,14 @@ public class StakeholderController {
|
|||
|
||||
if(stakeholder != null) {
|
||||
pid = stakeholder.getAlias();
|
||||
|
||||
// if(!roles.contains(authorizationService.PORTAL_ADMIN)
|
||||
// && !roles.contains(authorizationService.curator(stakeholder.getType()))) {
|
||||
if(!rolesUtils.hasCreateAndDeleteAuthority(stakeholder.getType())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("Delete stakeholder: You are not authorized to delete stakeholder with id: "+stakeholderId);
|
||||
}
|
||||
|
||||
// for(String topicId : stakeholder.getTopics()) {
|
||||
// Topic<String> topic = topicDAO.findById(topicId);
|
||||
// if (topic == null) {
|
||||
// // EXCEPTION - Topic not found
|
||||
// throw new EntityNotFoundException("Delete stakeholder: Topic with id: "+topicId+" not found (topic exists in stakeholder: "+stakeholderId+")");
|
||||
// }
|
||||
//
|
||||
// for (String categoryId : topic.getCategories()) {
|
||||
// Category<String> category = categoryDAO.findById(categoryId);
|
||||
// if (category == null) {
|
||||
// // EXCEPTION - Category not found
|
||||
// throw new EntityNotFoundException("Delete stakeholder: Category with id: "+categoryId+" not found (category exists in topic: "+topicId+")");
|
||||
// }
|
||||
//
|
||||
// for (String subCategoryId : category.getSubCategories()) {
|
||||
// SubCategory<String> subcategory = subCategoryDAO.findById(subCategoryId);
|
||||
// if (subcategory == null) {
|
||||
// // EXCEPTION - SubCategory not found
|
||||
// throw new EntityNotFoundException("Delete stakeholder: SubCategory with id: "+subCategoryId+" not found (subcategory exists in category: "+categoryId+")");
|
||||
// }
|
||||
//
|
||||
// for(String chartSectionId : subcategory.getCharts()) {
|
||||
// Section<String> chartSection = sectionDAO.findById(chartSectionId);
|
||||
// if (chartSection == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Delete topic: Section with id: "+chartSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
|
||||
// }
|
||||
//
|
||||
// for (String chartId : chartSection.getIndicators()) {
|
||||
// indicatorDAO.delete(chartId);
|
||||
// }
|
||||
// subcategory.setCharts(null);
|
||||
// sectionDAO.delete(chartSectionId);
|
||||
// }
|
||||
//
|
||||
// for(String numberSectionId : subcategory.getNumbers()) {
|
||||
// Section<String> numberSection = sectionDAO.findById(numberSectionId);
|
||||
// if (numberSection == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Delete topic: Section with id: "+numberSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
|
||||
// }
|
||||
//
|
||||
// for (String numberId : numberSection.getIndicators()) {
|
||||
// indicatorDAO.delete(numberId);
|
||||
// }
|
||||
// subcategory.setNumbers(null);
|
||||
// sectionDAO.delete(numberSectionId);
|
||||
// }
|
||||
//
|
||||
// subCategoryDAO.delete(subCategoryId);
|
||||
// }
|
||||
// category.setSubCategories(null);
|
||||
// categoryDAO.delete(categoryId);
|
||||
// }
|
||||
// topic.setCategories(null);
|
||||
// topicDAO.delete(topicId);
|
||||
// }
|
||||
|
||||
topicController.deleteTree(stakeholder);
|
||||
|
||||
stakeholder.setTopics(null);
|
||||
stakeholderDAO.delete(stakeholderId);
|
||||
log.debug("Stakeholder deleted!");
|
||||
|
||||
Portal portal = portalService.getPortal(pid);
|
||||
if(portal != null) {
|
||||
portalService.deletePortal(portal.getId());
|
||||
|
@ -553,44 +392,6 @@ public class StakeholderController {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
// @RequestMapping(value = "/{stakeholderId}/toggle-status", method = RequestMethod.POST)
|
||||
// public Boolean toggleStakeholderStatus(@PathVariable("stakeholderId") String stakeholderId) {
|
||||
// log.debug("toggle stakeholder status (isActive)");
|
||||
// log.debug("Stakeholder: "+stakeholderId);
|
||||
//
|
||||
// Stakeholder stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
// if (stakeholder == null) {
|
||||
// // EXCEPTION - Stakeholder not found
|
||||
// throw new EntityNotFoundException("Toggle stakeholder status: Stakeholder with id: "+stakeholderId+" not found");
|
||||
// }
|
||||
// stakeholder.setIsActive(!stakeholder.getIsActive());
|
||||
//
|
||||
// stakeholderDAO.save(stakeholder);
|
||||
// log.debug("Stakeholder toggled!");
|
||||
//
|
||||
// return stakeholder.getIsActive();
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/{stakeholderId}/toggle-access", method = RequestMethod.POST)
|
||||
// public Boolean toggleStakeholderAccess(@PathVariable("stakeholderId") String stakeholderId) {
|
||||
// log.debug("toggle stakeholder access (isPublic)");
|
||||
// log.debug("Stakeholder: "+stakeholderId);
|
||||
//
|
||||
// Stakeholder stakeholder = stakeholderDAO.findById(stakeholderId);
|
||||
// if (stakeholder == null) {
|
||||
// // EXCEPTION - Stakeholder not found
|
||||
// throw new EntityNotFoundException("Toggle stakeholder access: Stakeholder with id: "+stakeholderId+" not found");
|
||||
// }
|
||||
// stakeholder.setIsPublic(!stakeholder.getIsPublic());
|
||||
//
|
||||
// stakeholderDAO.save(stakeholder);
|
||||
// log.debug("Stakeholder toggled!");
|
||||
//
|
||||
// return stakeholder.getIsPublic();
|
||||
// }
|
||||
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/{stakeholderId}/change-visibility", method = RequestMethod.POST)
|
||||
public Stakeholder changeStakeholderVisibility(@PathVariable("stakeholderId") String stakeholderId,
|
||||
|
@ -603,12 +404,6 @@ public class StakeholderController {
|
|||
// EXCEPTION - Stakeholder not found
|
||||
throw new EntityNotFoundException("Change stakeholder visibility: Stakeholder with id: "+stakeholderId+" not found");
|
||||
}
|
||||
|
||||
// List<String> roles = authorizationService.getRoles();
|
||||
|
||||
// if(!roles.contains(authorizationService.PORTAL_ADMIN)
|
||||
// && !roles.contains(authorizationService.curator(stakeholder.getType()))
|
||||
// && !roles.contains(authorizationService.manager(stakeholder.getType(), stakeholder.getAlias()))) {
|
||||
if(!rolesUtils.hasUpdateAuthority(stakeholder.getType(), stakeholder.getAlias())) {
|
||||
// EXCEPTION - Access denied
|
||||
throw new ForbiddenException("Change stakeholder visibility: You are not authorized to update stakeholder with id: "+stakeholderId);
|
||||
|
@ -621,7 +416,7 @@ public class StakeholderController {
|
|||
Stakeholder<Topic> stakeholderFull = new Stakeholder<>(stakeholder);
|
||||
List<Topic> topicsFull = new ArrayList<>();
|
||||
|
||||
if(propagate != null && propagate) {
|
||||
if (propagate != null && propagate) {
|
||||
for (String topicId : stakeholder.getTopics()) {
|
||||
topicsFull.add(topicController.changeVisibilityTree(topicId, visibility, propagate));
|
||||
}
|
||||
|
@ -636,45 +431,4 @@ public class StakeholderController {
|
|||
|
||||
return stakeholder;
|
||||
}
|
||||
|
||||
// The following are not supposed to be used
|
||||
// @RequestMapping(value = "/stakeholder/dates", method = RequestMethod.GET)
|
||||
// public List<Date> getAllStakeholderDates() {
|
||||
// List<Stakeholder> profiles = stakeholderDAO.findAll();
|
||||
// List<Date> profileDates = new ArrayList<>();
|
||||
//
|
||||
// int i=0;
|
||||
// for(Stakeholder profile : profiles) {
|
||||
// log.debug(profile.getCreationDate());
|
||||
// profileDates.add(profile.getCreationDate());
|
||||
// log.debug(profileDates.get(i));
|
||||
// i++;
|
||||
// }
|
||||
// return profileDates;
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/stakeholder/dates1", method = RequestMethod.GET)
|
||||
// public List<String> getAllStakeholderDates1() {
|
||||
// List<Stakeholder> profiles = stakeholderDAO.findAll();
|
||||
// List<String> profileDates = new ArrayList<>();
|
||||
//
|
||||
// for(Stakeholder profile : profiles) {
|
||||
// log.debug(profile.getCreationDate().toString());
|
||||
// profileDates.add(profile.getCreationDate().toString());
|
||||
// }
|
||||
// return profileDates;
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/stakeholder/dates2", method = RequestMethod.GET)
|
||||
// public List<String> getAllStakeholderDates2() {
|
||||
// List<Stakeholder> profiles = stakeholderDAO.findAll();
|
||||
// List<String> profileDates = new ArrayList<>();
|
||||
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
//
|
||||
// for(Stakeholder profile : profiles) {
|
||||
// log.debug(format.format(profile.getCreationDate()));
|
||||
// profileDates.add(format.format(profile.getCreationDate()));
|
||||
// }
|
||||
// return profileDates;
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -142,20 +142,6 @@ public class SubCategoryController {
|
|||
numberSections.add(numberSection.getId());
|
||||
}
|
||||
}
|
||||
|
||||
// List<String> charts = new ArrayList<>();
|
||||
// for(Indicator chart : subcategoryFull.getCharts()) {
|
||||
// charts.add(chart.getId());
|
||||
// }
|
||||
// subCategory.setCharts(charts);
|
||||
//
|
||||
// List<String> numbers = new ArrayList<>();
|
||||
// for(Indicator numbr : subcategoryFull.getNumbers()) {
|
||||
// numbers.add(numbr.getId());
|
||||
// }
|
||||
// subCategory.setNumbers(numbers);
|
||||
|
||||
|
||||
subCategory.setCharts(chartSections);
|
||||
subCategory.setNumbers(numberSections);
|
||||
|
||||
|
@ -181,11 +167,6 @@ public class SubCategoryController {
|
|||
|
||||
subcategoryFull.setId(subCategory.getId());
|
||||
}
|
||||
|
||||
chartSections = null;
|
||||
numberSections = null;
|
||||
subCategory = null;
|
||||
|
||||
return subcategoryFull;
|
||||
}
|
||||
|
||||
|
@ -227,12 +208,8 @@ public class SubCategoryController {
|
|||
}
|
||||
|
||||
if(!changed) {
|
||||
// break;
|
||||
continue;
|
||||
}
|
||||
|
||||
// subCategoryBasedOnDefault.setName(subCategory.getName());
|
||||
// subCategoryBasedOnDefault.setDescription(subCategory.getDescription());
|
||||
subCategoryBasedOnDefault.setUpdateDate(subCategory.getUpdateDate());
|
||||
subCategoryDAO.save(subCategoryBasedOnDefault);
|
||||
}
|
||||
|
@ -266,35 +243,6 @@ public class SubCategoryController {
|
|||
if(category.getDefaultId() == null && children != null) {
|
||||
onDeleteDefaultSubCategory(subcategoryId, categoryId, children);
|
||||
}
|
||||
|
||||
// for(String chartSectionId : subcategory.getCharts()) {
|
||||
// Section<String> chartSection = sectionDAO.findById(chartSectionId);
|
||||
// if (chartSection == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Delete SubCategory: Section with id: "+chartSectionId+" not found (section exists in subcategory: "+subcategoryId+")");
|
||||
// }
|
||||
//
|
||||
// for (String chartId : chartSection.getIndicators()) {
|
||||
// indicatorDAO.delete(chartId);
|
||||
// }
|
||||
// subcategory.setCharts(null);
|
||||
// sectionDAO.delete(chartSectionId);
|
||||
// }
|
||||
//
|
||||
// for(String numberSectionId : subcategory.getNumbers()) {
|
||||
// Section<String> numberSection = sectionDAO.findById(numberSectionId);
|
||||
// if (numberSection == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Delete SubCategory: Section with id: "+numberSectionId+" not found (section exists in subcategory: "+subcategoryId+")");
|
||||
// }
|
||||
//
|
||||
// for (String numberId : numberSection.getIndicators()) {
|
||||
// indicatorDAO.delete(numberId);
|
||||
// }
|
||||
// subcategory.setNumbers(null);
|
||||
// sectionDAO.delete(numberSectionId);
|
||||
// }
|
||||
|
||||
sectionController.deleteTree(subcategory);
|
||||
|
||||
subcategory.setCharts(null);
|
||||
|
@ -393,46 +341,6 @@ public class SubCategoryController {
|
|||
return subCategoriesFull;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/toggle-status", method = RequestMethod.POST)
|
||||
// public Boolean toggleSubCategoryStatus(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId,
|
||||
// @PathVariable("categoryId") String categoryId,
|
||||
// @PathVariable("subcategoryId") String subcategoryId) {
|
||||
// log.debug("toggle subCategory status (isActive)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId);
|
||||
//
|
||||
// SubCategory subCategory = subCategoryDAO.findById(subcategoryId);
|
||||
// if (subCategory == null) {
|
||||
// // EXCEPTION - SubCategory not found
|
||||
// throw new EntityNotFoundException("Toggle subCategory status: SubCategory with id: "+subcategoryId+" not found");
|
||||
// }
|
||||
// subCategory.setIsActive(!subCategory.getIsActive());
|
||||
//
|
||||
// this.toggleSubCategory(stakeholderId, topicId, categoryId, subCategory);
|
||||
//
|
||||
// return subCategory.getIsActive();
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/toggle-access", method = RequestMethod.POST)
|
||||
// public Boolean toggleSubCategoryAccess(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId,
|
||||
// @PathVariable("categoryId") String categoryId,
|
||||
// @PathVariable("subcategoryId") String subcategoryId) {
|
||||
// log.debug("toggle subCategory access (isPublic)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId + " - Category: "+categoryId+ " - SubCategory: "+subcategoryId);
|
||||
//
|
||||
// SubCategory subCategory = subCategoryDAO.findById(subcategoryId);
|
||||
// if (subCategory == null) {
|
||||
// // EXCEPTION - SubCategory not found
|
||||
// throw new EntityNotFoundException("Toggle subCategory access: SubCategory with id: "+subcategoryId+" not found");
|
||||
// }
|
||||
// subCategory.setIsPublic(!subCategory.getIsPublic());
|
||||
//
|
||||
// this.toggleSubCategory(stakeholderId, topicId, categoryId, subCategory);
|
||||
//
|
||||
// return subCategory.getIsPublic();
|
||||
// }
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/{stakeholderId}/{topicId}/{categoryId}/{subcategoryId}/change-visibility", method = RequestMethod.POST)
|
||||
public SubCategory changeSubCategoryVisibility(@PathVariable("stakeholderId") String stakeholderId,
|
||||
|
@ -522,18 +430,6 @@ public class SubCategoryController {
|
|||
// EXCEPTION - Category not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias();
|
||||
throw new PathNotValidException("Save indicator: Category with id: "+categoryId+" not found in Topic: "+topicId);
|
||||
}
|
||||
|
||||
// SubCategory<String> subcategory = subCategoryDAO.findById(subcategoryId);
|
||||
// if(subcategory == null) {
|
||||
// // EXCEPTION - SubCategory not found
|
||||
// throw new EntityNotFoundException("Save indicator: SubCategory with id: "+subcategoryId+" not found");
|
||||
// }
|
||||
//
|
||||
// if (!category.getSubCategories().contains(subcategoryId)) {
|
||||
// // EXCEPTION - SubCategory not found in Stakeholder: stakeholder.getAlias(); -> Topic: topic.getAlias(); -> Category: category.getAlias();
|
||||
// throw new PathNotValidException("Save indicator: SubCategory with id: "+subcategoryId+" not found in Category: "+categoryId);
|
||||
// }
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
package eu.dnetlib.uoamonitorservice.controllers;
|
||||
|
||||
import eu.dnetlib.uoamonitorservice.dao.StakeholderDAO;
|
||||
import eu.dnetlib.uoamonitorservice.entities.Stakeholder;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin(origins = "*")
|
||||
public class TestController {
|
||||
private final Logger log = LogManager.getLogger(this.getClass());
|
||||
|
||||
@Autowired
|
||||
private StakeholderDAO stakeholderDAO;
|
||||
|
||||
// @RequestMapping("/")
|
||||
// public String index() {
|
||||
// return "Greetings from Spring Boot!";
|
||||
// }
|
||||
|
||||
// Check ExceptionHandler
|
||||
@RequestMapping(value = "/test-error1", method = RequestMethod.GET)
|
||||
public Stakeholder getFirstStakeholder() {
|
||||
List<Stakeholder> stakeholders;
|
||||
stakeholders = stakeholderDAO.findAll();
|
||||
|
||||
return stakeholders.get(0);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/test-error2", method = RequestMethod.GET)
|
||||
public String getParam(@RequestParam String param) {
|
||||
return param;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/test-error3", method = RequestMethod.GET)
|
||||
public String getSubstringOfNull() {
|
||||
String str = null;
|
||||
return str.substring(2);
|
||||
}
|
||||
}
|
|
@ -132,9 +132,6 @@ public class TopicController {
|
|||
|
||||
topicFull.setId(topic.getId());
|
||||
}
|
||||
|
||||
categories = null;
|
||||
topic = null;
|
||||
} else {
|
||||
// EXCEPTION - Stakeholder not found
|
||||
throw new EntityNotFoundException("Save topic: Stakeholder with id: "+stakeholderId+" not found");
|
||||
|
@ -186,12 +183,8 @@ public class TopicController {
|
|||
}
|
||||
|
||||
if(!changed) {
|
||||
// break;
|
||||
continue;
|
||||
}
|
||||
|
||||
// topicBasedOnDefault.setName(topic.getName());
|
||||
// topicBasedOnDefault.setDescription(topic.getDescription());
|
||||
topicBasedOnDefault.setUpdateDate(topic.getUpdateDate());
|
||||
topicDAO.save(topicBasedOnDefault);
|
||||
}
|
||||
|
@ -229,54 +222,6 @@ public class TopicController {
|
|||
if(stakeholder.getDefaultId() == null && children != null) {
|
||||
onDeleteDefaultTopic(topicId, stakeholderId, children);
|
||||
}
|
||||
|
||||
// for(String categoryId : topic.getCategories()) {
|
||||
// Category<String> category = categoryDAO.findById(categoryId);
|
||||
// if(category == null) {
|
||||
// // EXCEPTION - Category not found
|
||||
// throw new EntityNotFoundException("Delete topic: Category with id: "+categoryId+" not found (category exists in topic: "+topicId+")");
|
||||
// }
|
||||
//
|
||||
// for(String subCategoryId : category.getSubCategories()) {
|
||||
// SubCategory<String> subcategory = subCategoryDAO.findById(subCategoryId);
|
||||
// if (subcategory == null) {
|
||||
// // EXCEPTION - SubCategory not found
|
||||
// throw new EntityNotFoundException("Delete topic: SubCategory with id: "+subCategoryId+" not found (subcategory exists in category: "+categoryId+")");
|
||||
// }
|
||||
//
|
||||
// for(String chartSectionId : subcategory.getCharts()) {
|
||||
// Section<String> chartSection = sectionDAO.findById(chartSectionId);
|
||||
// if (chartSection == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Delete topic: Section with id: "+chartSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
|
||||
// }
|
||||
//
|
||||
// for (String chartId : chartSection.getIndicators()) {
|
||||
// indicatorDAO.delete(chartId);
|
||||
// }
|
||||
// subcategory.setCharts(null);
|
||||
// sectionDAO.delete(chartSectionId);
|
||||
// }
|
||||
//
|
||||
// for(String numberSectionId : subcategory.getNumbers()) {
|
||||
// Section<String> numberSection = sectionDAO.findById(numberSectionId);
|
||||
// if (numberSection == null) {
|
||||
// // EXCEPTION - Section not found
|
||||
// throw new EntityNotFoundException("Delete topic: Section with id: "+numberSectionId+" not found (section exists in subcategory: "+subCategoryId+")");
|
||||
// }
|
||||
//
|
||||
// for (String numberId : numberSection.getIndicators()) {
|
||||
// indicatorDAO.delete(numberId);
|
||||
// }
|
||||
// subcategory.setNumbers(null);
|
||||
// sectionDAO.delete(numberSectionId);
|
||||
// }
|
||||
//
|
||||
// subCategoryDAO.delete(subCategoryId);
|
||||
// }
|
||||
// category.setSubCategories(null);
|
||||
// categoryDAO.delete(categoryId);
|
||||
// }
|
||||
categoryController.deleteTree(topic);
|
||||
|
||||
topic.setCategories(null);
|
||||
|
@ -387,42 +332,6 @@ public class TopicController {
|
|||
}
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/toggle-status", method = RequestMethod.POST)
|
||||
// public Boolean toggleTopicStatus(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId) {
|
||||
// log.debug("toggle topic status (isActive)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId);
|
||||
//
|
||||
// Topic topic = topicDAO.findById(topicId);
|
||||
// if (topic == null) {
|
||||
// // EXCEPTION - Topic not found
|
||||
// throw new EntityNotFoundException("Toggle topic status: Topic with id: "+topicId+" not found");
|
||||
// }
|
||||
// topic.setIsActive(!topic.getIsActive());
|
||||
//
|
||||
// this.toggleTopic(stakeholderId, topic);
|
||||
//
|
||||
// return topic.getIsActive();
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(value = "/{stakeholderId}/{topicId}/toggle-access", method = RequestMethod.POST)
|
||||
// public Boolean toggleTopicAccess(@PathVariable("stakeholderId") String stakeholderId,
|
||||
// @PathVariable("topicId") String topicId) {
|
||||
// log.debug("toggle topic access (isPublic)");
|
||||
// log.debug("Stakeholder: "+stakeholderId + " - Topic: "+topicId);
|
||||
//
|
||||
// Topic topic = topicDAO.findById(topicId);
|
||||
// if (topic == null) {
|
||||
// // EXCEPTION - Topic not found
|
||||
// throw new EntityNotFoundException("Toggle topic access: Topic with id: "+topicId+" not found");
|
||||
// }
|
||||
// topic.setIsPublic(!topic.getIsPublic());
|
||||
//
|
||||
// this.toggleTopic(stakeholderId, topic);
|
||||
//
|
||||
// return topic.getIsPublic();
|
||||
// }
|
||||
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@RequestMapping(value = "/{stakeholderId}/{topicId}/change-visibility", method = RequestMethod.POST)
|
||||
public Topic changeTopicVisibility(@PathVariable("stakeholderId") String stakeholderId,
|
||||
|
@ -449,10 +358,6 @@ public class TopicController {
|
|||
// EXCEPTION - Stakeholder not found
|
||||
throw new EntityNotFoundException("Toggle topic: Stakeholder with id: "+stakeholderId+" not found");
|
||||
}
|
||||
|
||||
|
||||
// this.toggleTopic(stakeholderId, topic);
|
||||
|
||||
}
|
||||
|
||||
public Topic changeVisibilityTree(String topicId, Visibility visibility, Boolean propagate) {
|
||||
|
@ -489,9 +394,7 @@ public class TopicController {
|
|||
// EXCEPTION - Topic not found
|
||||
throw new EntityNotFoundException("Topic delete tree: Topic with id: "+topicId+" not found (topic exists in stakeholder: "+stakeholder.getId()+")");
|
||||
}
|
||||
|
||||
categoryController.deleteTree(topic);
|
||||
|
||||
topicDAO.delete(topicId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,10 @@ public class StakeholderService {
|
|||
@Autowired
|
||||
RolesUtils rolesUtils;
|
||||
|
||||
public List<String> getAllAliases() {
|
||||
return this.dao.findAll().stream().map(Stakeholder::getAlias).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<Stakeholder> getStakeholdersByTypeAndRole(String type, String defaultId, boolean manage) {
|
||||
List<Stakeholder> stakeholders;
|
||||
if(type != null && defaultId != null) {
|
||||
|
|
|
@ -26,3 +26,30 @@ monitorservice.globalVars.version=@version@
|
|||
#monitorservice.userInfoUrl = https://services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=
|
||||
#monitorservice.originServer = .openaire.eu
|
||||
|
||||
# Monitor
|
||||
monitorservice.mongodb.host=localhost
|
||||
monitorservice.mongodb.port=27017
|
||||
monitorservice.mongodb.database=production
|
||||
|
||||
# Notification
|
||||
notification.mongodb.host = localhost
|
||||
notification.mongodb.port = 27017
|
||||
notification.mongodb.database = openaire_notification
|
||||
|
||||
# Admin Tools Library
|
||||
admintoolslibrary.mail.from = openaire.test@gmail.com
|
||||
admintoolslibrary.mail.username = openaire.test@gmail.com
|
||||
admintoolslibrary.mail.password = koujreltgjduicjp
|
||||
admintoolslibrary.mail.host = smtp.gmail.com
|
||||
admintoolslibrary.mail.port = 587
|
||||
admintoolslibrary.mail.auth = true
|
||||
admintoolslibrary.mail.sslProtocols = TLSv1.2
|
||||
admintoolslibrary.mail.defaultEncoding=UTF-8
|
||||
admintoolslibrary.mail.protocol=smtp
|
||||
admintoolslibrary.mail.testConnection=false
|
||||
admintoolslibrary.google.secret = 6LcVtFIUAAAAAIlEaz6Am2PBC3j5lHG7vBo6uW4_
|
||||
|
||||
# Authorization
|
||||
authorization.security.userInfoUrl = http://mpagasas.di.uoa.gr:19080/login-service/userInfo
|
||||
|
||||
server.port=8888
|
505
update_db.js
505
update_db.js
|
@ -1,505 +0,0 @@
|
|||
//version compatibility: 1.0.0-SNAPSHOT
|
||||
|
||||
//use openaire_monitor;
|
||||
|
||||
function upperCaseEnumValues() {
|
||||
stakeholders = db.stakeholder.find().map(function (stakeholders) {
|
||||
return stakeholders;
|
||||
});
|
||||
for(var i=0; i<stakeholders.length; i++) {
|
||||
stakeholder = stakeholders[i];
|
||||
|
||||
stakeholderType = stakeholder.type;
|
||||
stakeholder.type = stakeholderType.toUpperCase();
|
||||
db.stakeholder.save(stakeholder);
|
||||
}
|
||||
print("Uppercase enum values for Stakeholder types");
|
||||
|
||||
sections = db.section.find().map(function (sections) {
|
||||
return sections;
|
||||
});
|
||||
for(var i=0; i<sections.length; i++) {
|
||||
section = sections[i];
|
||||
|
||||
sectionType = section.type;
|
||||
section.type = sectionType.toUpperCase();
|
||||
db.section.save(section);
|
||||
}
|
||||
print("Uppercase enum values for Section types");
|
||||
|
||||
indicators = db.indicator.find().map(function (indicators) {
|
||||
return indicators;
|
||||
});
|
||||
for(var i=0; i<indicators.length; i++) {
|
||||
indicator = indicators[i];
|
||||
|
||||
indicatorType = indicator.type;
|
||||
indicator.type = indicatorType.toUpperCase();
|
||||
indicatorWidth = indicator.width;
|
||||
indicator.width = indicatorWidth.toUpperCase();
|
||||
|
||||
indicatorPaths = indicator.indicatorPaths;
|
||||
for(var j=0; j<indicatorPaths.lenght; j++) {
|
||||
indicatorPath = indicatorPaths[j];
|
||||
|
||||
indicatorPathType = indicatorPath.type;
|
||||
indicatorPath.type = indicatorPathType.toUpperCase();
|
||||
indicatorPathSource = indicatorPath.source;
|
||||
indicatorPath.source = indicatorPathSource.toUpperCase();
|
||||
}
|
||||
|
||||
db.indicator.save(indicator);
|
||||
}
|
||||
print("Uppercase enum values for Indicator types and width");
|
||||
print("Uppercase enum values for Indicator path types and source");
|
||||
}
|
||||
|
||||
function addHeightInIndicators() {
|
||||
indicators = db.indicator.find().map(function (indicators) {
|
||||
return indicators;
|
||||
});
|
||||
for(var i=0; i<indicators.length; i++) {
|
||||
indicator = indicators[i];
|
||||
|
||||
if(indicator.type == "chart" || indicator.type == "CHART") {
|
||||
indicator['height'] = "MEDIUM";
|
||||
} else {
|
||||
indicator['height'] = "SMALL";
|
||||
}
|
||||
db.indicator.save(indicator);
|
||||
}
|
||||
print("Height field added in Indicators");
|
||||
}
|
||||
|
||||
|
||||
function addVisibility() {
|
||||
stakeholders = db.stakeholder.find().map(function (stakeholders) {
|
||||
return stakeholders;
|
||||
});
|
||||
for (var i = 0; i < stakeholders.length; i++) {
|
||||
stakeholder = stakeholders[i];
|
||||
|
||||
if (stakeholder.isActive) {
|
||||
if (stakeholder.isPublic) {
|
||||
stakeholder['visibility'] = "PUBLIC";
|
||||
} else {
|
||||
stakeholder['visibility'] = "RESTRICTED";
|
||||
}
|
||||
} else {
|
||||
stakeholder['visibility'] = "PRIVATE";
|
||||
}
|
||||
|
||||
db.stakeholder.save(stakeholder);
|
||||
}
|
||||
print("Add visibility field for Stakeholders");
|
||||
|
||||
topics = db.topic.find().map(function (topics) {
|
||||
return topics;
|
||||
});
|
||||
for (var i = 0; i < topics.length; i++) {
|
||||
topic = topics[i];
|
||||
|
||||
topicVisibility = "PRIVATE";
|
||||
if (topic.isActive) {
|
||||
if (topic.isPublic) {
|
||||
topicVisibility = "PUBLIC";
|
||||
} else {
|
||||
topicVisibility = "RESTRICTED";
|
||||
}
|
||||
}
|
||||
|
||||
topic['visibility'] = topicVisibility;
|
||||
db.topic.save(topic);
|
||||
}
|
||||
print("Add visibility field for Topics");
|
||||
|
||||
categories = db.category.find().map(function (categories) {
|
||||
return categories;
|
||||
});
|
||||
for (var i = 0; i < categories.length; i++) {
|
||||
category = categories[i];
|
||||
|
||||
if (category.isActive) {
|
||||
if (category.isPublic) {
|
||||
category['visibility'] = "PUBLIC";
|
||||
} else {
|
||||
category['visibility'] = "RESTRICTED";
|
||||
}
|
||||
} else {
|
||||
category['visibility'] = "PRIVATE";
|
||||
}
|
||||
|
||||
db.category.save(category);
|
||||
}
|
||||
print("Add visibility field for Categories");
|
||||
|
||||
subCategories = db.subCategory.find().map(function (subCategories) {
|
||||
return subCategories;
|
||||
});
|
||||
for (var i = 0; i < subCategories.length; i++) {
|
||||
subCategory = subCategories[i];
|
||||
|
||||
if (subCategory.isActive) {
|
||||
if (subCategory.isPublic) {
|
||||
subCategory['visibility'] = "PUBLIC";
|
||||
} else {
|
||||
subCategory['visibility'] = "RESTRICTED";
|
||||
}
|
||||
} else {
|
||||
subCategory['visibility'] = "PRIVATE";
|
||||
}
|
||||
|
||||
db.subCategory.save(subCategory);
|
||||
}
|
||||
print("Add visibility field for SubCategories");
|
||||
|
||||
indicators = db.indicator.find().map(function (indicators) {
|
||||
return indicators;
|
||||
});
|
||||
for (var i = 0; i < indicators.length; i++) {
|
||||
indicator = indicators[i];
|
||||
|
||||
if (indicator.isActive) {
|
||||
if (indicator.isPublic) {
|
||||
indicator['visibility'] = "PUBLIC";
|
||||
} else {
|
||||
indicator['visibility'] = "RESTRICTED";
|
||||
}
|
||||
} else {
|
||||
indicator['visibility'] = "PRIVATE";
|
||||
}
|
||||
|
||||
db.indicator.save(indicator);
|
||||
}
|
||||
print("Add visibility field for Indicators");
|
||||
}
|
||||
|
||||
function removeIsActiveAndIsPublic() {
|
||||
stakeholders = db.stakeholder.find().map(function (stakeholders) {
|
||||
return stakeholders;
|
||||
});
|
||||
for(var i=0; i<stakeholders.length; i++) {
|
||||
stakeholder = stakeholders[i];
|
||||
|
||||
db.stakeholder.update({"_id": stakeholder._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
|
||||
topics = db.topic.find().map(function (topics) {
|
||||
return topics;
|
||||
});
|
||||
for(var i=0; i<topics.length; i++) {
|
||||
topic = topics[i];
|
||||
|
||||
db.topic.update({"_id": topic._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
|
||||
categories = db.category.find().map(function (categories) {
|
||||
return categories;
|
||||
});
|
||||
for(var i=0; i<categories.length; i++) {
|
||||
category = categories[i];
|
||||
|
||||
db.category.update({"_id": category._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
|
||||
subCategories = db.subCategory.find().map(function (subCategories) {
|
||||
return subCategories;
|
||||
});
|
||||
for(var i=0; i<subCategories.length; i++) {
|
||||
subCategory = subCategories[i];
|
||||
|
||||
db.subCategory.update({"_id": subCategory._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
|
||||
indicators = db.indicator.find().map(function (indicators) {
|
||||
return indicators;
|
||||
});
|
||||
for(var i=0; i<indicators.length; i++) {
|
||||
indicator = indicators[i];
|
||||
|
||||
db.indicator.update({"_id": indicator._id}, {$unset: {isPublic: "", isActive: ""}});
|
||||
}
|
||||
}
|
||||
|
||||
function addAdminToolsCollections () {
|
||||
db.createCollection("portal");
|
||||
db.createCollection("entity");
|
||||
db.createCollection("page");
|
||||
db.createCollection("pageHelpContent");
|
||||
db.createCollection("divId");
|
||||
db.createCollection("divHelpContent");
|
||||
}
|
||||
|
||||
function addPortals() {
|
||||
db.portal.save({"pid": "monitor", "name": "Monitor", "type": "monitor", "piwik": null, "pages": {}, "entities": {}});
|
||||
}
|
||||
|
||||
function uniqueIndexes() {
|
||||
db.portal.createIndex( { "pid": 1 }, { unique: true } );
|
||||
db.stakeholder.createIndex( { "alias": 1 }, { unique: true } );
|
||||
}
|
||||
|
||||
|
||||
function addFooterDivIdForPortalType(portalType) {
|
||||
homePageID = db.page.find({"portalType": portalType, "route": "/"}).map( function(portal) { return portal._id.str; } ).toString();
|
||||
db.divId.save({ "name" : "footer", "pages" : [ homePageID ], "portalType" : portalType });
|
||||
print("divId 'footer' added for "+portalType+" (home page id: "+homePageID + ")");
|
||||
}
|
||||
|
||||
function addHomePageInPortalType(portalType) {
|
||||
homePageID = db.page.insertOne({ "route" : "/", "name" : "Home", "type" : "other", "entities" : [ ], "portalType" : portalType, "top" : false, "bottom" : false, "left" : false, "right" : false }).insertedId.str;
|
||||
print("Creating Home page with id " + homePageID);
|
||||
portals = db.portal.find({"type": portalType}).map( function(portal) { return portal; } );
|
||||
for (var i = 0; i < portals.length; i++) {
|
||||
portal_pages = portals[i].pages;
|
||||
|
||||
portal_pages[homePageID] = true;
|
||||
|
||||
portal_pid = portals[i].pid;
|
||||
db.portal.update({ "pid" : portal_pid },{$set: { "pages": portal_pages}});
|
||||
print("Add home page with id " + homePageID + " on " + portalType + " " + portal_pid);
|
||||
}
|
||||
}
|
||||
|
||||
function addFooterHelpTextForPortalType(portalType) {
|
||||
footerDivIdID = db.divId.find({"portalType": portalType, "name": "footer"}).map( function(divId) { return divId._id.str; } ).toString();
|
||||
|
||||
portals = db.portal.find({"type": portalType}).map( function(portal) { return portal; } );
|
||||
for (var j = 0; j < portals.length; j++) {
|
||||
portal = portals[j];
|
||||
|
||||
var content = "This OpenAIRE MONITOR dashboard is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452";
|
||||
|
||||
if(portal.pid == "egi") {
|
||||
content = "This OpenAIRE MONITOR dashboard is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452";
|
||||
|
||||
} else if(portal.pid == "risis") {
|
||||
|
||||
content = "This OpenAIRE MONITOR dashboard is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452 and 824091";
|
||||
|
||||
} else if(portal.pid == "sobigdata") {
|
||||
|
||||
content = "This OpenAIRE MONITOR dashboard is part of a project that has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541 and 101017452 and 871042";
|
||||
}
|
||||
|
||||
db.divHelpContent.save(
|
||||
{ "divId" : footerDivIdID,
|
||||
"portal" : portal._id.str,
|
||||
"content" : "<p class=\"uk-margin-remove-bottom\"><span style=\"font-size:8pt\">"+content+"</span></p>",
|
||||
"isActive" : true
|
||||
}
|
||||
);
|
||||
|
||||
print("div help text for divId 'footer' added for "+portalType +" (id: "+ portal._id + " - pid: " + portal.pid + " - footer divId id: "+footerDivIdID + ")");
|
||||
}
|
||||
}
|
||||
|
||||
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 1_openaire-mongodb-beta; // dev db
|
||||
|
||||
// 29-09-2020 - 22-10-2020
|
||||
//upperCaseEnumValues();
|
||||
// addHeightInIndicators();
|
||||
// addVisibility();
|
||||
// removeIsActiveAndIsPublic();
|
||||
//
|
||||
// addAdminToolsCollections();
|
||||
// // addPortals();
|
||||
//
|
||||
// uniqueIndexes();
|
||||
|
||||
// 04-06-2021 - 24-06-2021
|
||||
// addHomePageInPortalType("funder");
|
||||
// addFooterDivIdForPortalType("funder");
|
||||
// addFooterHelpTextForPortalType("funder");
|
||||
// addHomePageInPortalType("ri");
|
||||
// addFooterDivIdForPortalType("ri");
|
||||
// addFooterHelpTextForPortalType("ri");
|
||||
// addHomePageInPortalType("organization");
|
||||
// addFooterDivIdForPortalType("organization");
|
||||
// addFooterHelpTextForPortalType("organization");
|
||||
|
||||
// 11-04-2023
|
||||
statsProfileOfIndicatorsAsVariable();
|
||||
// 30-05-2023
|
||||
addFundingStreamInDefaultMSCA();
|
Loading…
Reference in New Issue