2020-11-11 13:50:44 +01:00
//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 } ) ;
}
2021-06-23 17:19:20 +02:00
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 + ")" ) ;
}
}
2020-11-11 13:50:44 +01:00
use monitordb ;
2021-06-23 17:19:20 +02:00
// use 1_openaire-mongodb-beta; // dev db
2020-11-11 13:50:44 +01:00
// 29-09-2020 - 22-10-2020
//upperCaseEnumValues();
2021-06-23 17:19:20 +02:00
// addHeightInIndicators();
// addVisibility();
// removeIsActiveAndIsPublic();
//
// addAdminToolsCollections();
// // addPortals();
//
// uniqueIndexes();
2021-09-16 00:17:52 +02:00
// 04-06-2021 - 24-06-2021
2021-06-23 17:19:20 +02:00
addHomePageInPortalType ( "funder" ) ;
addFooterDivIdForPortalType ( "funder" ) ;
addFooterHelpTextForPortalType ( "funder" ) ;
addHomePageInPortalType ( "ri" ) ;
addFooterDivIdForPortalType ( "ri" ) ;
addFooterHelpTextForPortalType ( "ri" ) ;
addHomePageInPortalType ( "organization" ) ;
addFooterDivIdForPortalType ( "organization" ) ;
addFooterHelpTextForPortalType ( "organization" ) ;