Revision 61089
Added by Konstantina Galouni almost 3 years ago
modules/uoa-admin-tools/trunk/update_db.js | ||
---|---|---|
1717 | 1717 |
db.portal.update({"pid": "covid-19"}, {$set: {piwik:"267"}}); |
1718 | 1718 |
db.portal.update({"pid": "rural-digital-europe"}, {$set: {piwik:"319"}}); |
1719 | 1719 |
db.portal.update({"pid": "enermaps"}, {$set: {piwik:"318"}}); |
1720 |
|
|
1721 |
db.portal.update({"pid": "galaxy"}, {$set: {piwik:"453"}}); |
|
1722 |
db.portal.update({"pid": "gotriple"}, {$set: {piwik:"490"}}); |
|
1723 |
db.portal.update({"pid": "neanias-underwater"}, {$set: {piwik:"474"}}); |
|
1724 |
// db.portal.update({"pid": "embrc"}, {$set: {piwik:"474"}}); |
|
1720 | 1725 |
} |
1721 | 1726 |
|
1727 |
// 03-06-2021 |
|
1728 |
function addFooterDivIdForConnect() { |
|
1729 |
connectHomePageID = db.page.find({"portalType": "connect", "route": "/"}).map( function(page) { return page._id.str; } ).toString(); |
|
1730 |
db.divId.save({ "name" : "footer", "pages" : [ connectHomePageID ], "portalType" : "connect" }); |
|
1731 |
print("divId 'footer' added for connect (home page id: "+connectHomePageID + ")"); |
|
1732 |
} |
|
1733 |
|
|
1734 |
function addFooterDivIdForCommunities() { |
|
1735 |
// db.page.save({ "route" : "/", "name" : "Home", "type" : "other", "entities" : [ ], "portalType" : "community", "top" : false, "bottom" : false, "left" : false, "right" : false }); |
|
1736 |
// print("page 'Home' added for communities"); |
|
1737 |
addHomePageInCommunities(); |
|
1738 |
|
|
1739 |
communityHomePageID = db.page.find({"portalType": "community", "route": "/"}).map( function(community) { return community._id.str; } ).toString(); |
|
1740 |
db.divId.save({ "name" : "footer", "pages" : [ communityHomePageID ], "portalType" : "community" }); |
|
1741 |
print("divId 'footer' added for communities (home page id: "+communityHomePageID + ")"); |
|
1742 |
} |
|
1743 |
|
|
1744 |
function addHomePageInCommunities() { |
|
1745 |
communityHomePageID = db.page.insertOne({ "route" : "/", "name" : "Home", "type" : "other", "entities" : [ ], "portalType" : "community", "top" : false, "bottom" : false, "left" : false, "right" : false }).insertedId.str; |
|
1746 |
print("Creating Home page with id " + communityHomePageID); |
|
1747 |
communities = db.portal.find({"type": "community"}).map( function(community) { return community; } ); |
|
1748 |
for (var i = 0; i < communities.length; i++) { |
|
1749 |
community_pages = communities[i].pages; |
|
1750 |
|
|
1751 |
community_pages[communityHomePageID] = true; |
|
1752 |
|
|
1753 |
community_pid = communities[i].pid; |
|
1754 |
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}}); |
|
1755 |
print("Add home page with id " + communityHomePageID + " on community " + community_pid); |
|
1756 |
} |
|
1757 |
} |
|
1758 |
|
|
1759 |
function addFooterHelpTextForConnect() { |
|
1760 |
connectID = db.portal.find({ "pid" : "connect"}).map( function(portal) { return portal._id.str; } ).toString(); |
|
1761 |
connectFooterDivIdID = db.divId.find({"portalType": "connect", "name": "footer"}).map( function(divId) { return divId._id.str; } ).toString(); |
|
1762 |
|
|
1763 |
db.divHelpContent.save( |
|
1764 |
{ "divId" : connectFooterDivIdID, |
|
1765 |
"portal" : connectID, |
|
1766 |
"content" : "<p class=\"uk-margin-remove-bottom\"><span style=\"font-size:8pt\">" + |
|
1767 |
"OpenAIRE has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541, 731011 and 101017452" + |
|
1768 |
"</span></p>", |
|
1769 |
"isActive" : true |
|
1770 |
} |
|
1771 |
); |
|
1772 |
|
|
1773 |
print("div help text for divId 'footer' added for connect (connect id: "+ connectID + " - footer divId id: "+connectFooterDivIdID + ")"); |
|
1774 |
} |
|
1775 |
|
|
1776 |
function addFooterHelpTextForCommunities() { |
|
1777 |
communityFooterDivIdID = db.divId.find({"portalType": "community", "name": "footer"}).map( function(divId) { return divId._id.str; } ).toString(); |
|
1778 |
|
|
1779 |
communities = db.portal.find({"type": "community"}).map( function(community) { return community; } ); |
|
1780 |
for (var j = 0; j < communities.length; j++) { |
|
1781 |
community = communities[j]; |
|
1782 |
|
|
1783 |
var content = "OpenAIRE has received funding from the European Union's Horizon 2020 research and innovation programme under grant agreements No. 777541, 731011 and 101017452"; |
|
1784 |
|
|
1785 |
if(community.pid == "aginfra" || community.pid == "rural-digital-europe") { |
|
1786 |
content = "This OpenAIRE gateway 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, 731011 and 101017452"; |
|
1787 |
|
|
1788 |
} else if(community.pid == "clarin" || community.pid == "covid-19" || community.pid == "dariah" |
|
1789 |
|| community.pid == "dh-ch" || community.pid == "egi" || community.pid == "mes" || community.pid == "epos" |
|
1790 |
|| community.pid == "elixir-gr" || community.pid == "fam" || community.pid == "ni" |
|
1791 |
|| community.pid == "sdsn-gr" || community.pid == "instruct" || community.pid == "instruct" |
|
1792 |
|| community.pid == "rda" || community.pid == "gotriple") { |
|
1793 |
|
|
1794 |
content = "This OpenAIRE gateway 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, 731011 and 101017452"; |
|
1795 |
|
|
1796 |
} else if(community.pid == "enermaps") { |
|
1797 |
content = "This OpenAIRE gateway 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, 731011, 101017452 and 884161"; |
|
1798 |
|
|
1799 |
} else if(community.pid == "beopen") { |
|
1800 |
content = "This OpenAIRE gateway 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, 731011, 101017452 and 824323"; |
|
1801 |
|
|
1802 |
} else if(community.pid == "risis" || community.pid == "science-innovation-policy") { |
|
1803 |
content = "This OpenAIRE gateway 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, 731011, 101017452 and 824091"; |
|
1804 |
} |
|
1805 |
|
|
1806 |
db.divHelpContent.save( |
|
1807 |
{ "divId" : communityFooterDivIdID, |
|
1808 |
"portal" : community._id.str, |
|
1809 |
"content" : "<p class=\"uk-margin-remove-bottom\"><span style=\"font-size:8pt\">"+content+"</span></p>", |
|
1810 |
"isActive" : true |
|
1811 |
} |
|
1812 |
); |
|
1813 |
|
|
1814 |
print("div help text for divId 'footer' added for community (community id: "+ community._id + " - community pid: " + community.pid + " - footer divId id: "+communityFooterDivIdID + ")"); |
|
1815 |
} |
|
1816 |
} |
|
1817 |
|
|
1818 |
// 04-06-2021 debug helper function |
|
1819 |
function cleanPagesFromPortals() { |
|
1820 |
portals = db.portal.find().map( function(portal) { return portal; } ); |
|
1821 |
for (var j = 0; j < portals.length; j++) { |
|
1822 |
portal = portals[j]; |
|
1823 |
portal_pages = portal.pages; |
|
1824 |
|
|
1825 |
for (var key in portal_pages) { |
|
1826 |
// print(key); |
|
1827 |
// db.page.findOne({"_id": ObjectId(+'"'+key+'"')}); |
|
1828 |
if(db.page.find({"_id": ObjectId(key)}).map( function(page) { return page; } ).length == 0) { |
|
1829 |
delete portal_pages[key]; |
|
1830 |
print("deleted page: "+key + " from portal: "+portal.pid); |
|
1831 |
} |
|
1832 |
} |
|
1833 |
portal_pid = portal.pid; |
|
1834 |
db.portal.update({ "pid" : portal_pid },{$set: { "pages": portal_pages}}); |
|
1835 |
} |
|
1836 |
} |
|
1837 |
|
|
1722 | 1838 |
use openaireconnect; |
1723 | 1839 |
|
1724 | 1840 |
//updatePages(); |
... | ... | |
1786 | 1902 |
//addSearchResearchOutcomesPages(); |
1787 | 1903 |
|
1788 | 1904 |
// 02-02-2020 - 19-03-2020 |
1789 |
addPortalType(); |
|
1790 |
createPagesForEachPortalType(); |
|
1791 |
createDivIdsForEachPortalType(); |
|
1792 |
renameCollectionAndFields(); |
|
1793 |
addPortalPidInLayoutRecords(); |
|
1905 |
// addPortalType();
|
|
1906 |
// createPagesForEachPortalType();
|
|
1907 |
// createDivIdsForEachPortalType();
|
|
1908 |
// renameCollectionAndFields();
|
|
1909 |
// addPortalPidInLayoutRecords();
|
|
1794 | 1910 |
|
1795 | 1911 |
// 22-10-2020 |
1796 |
// addPiwik(); |
|
1912 |
// addPiwik(); |
|
1913 |
|
|
1914 |
// 03-06-2021 |
|
1915 |
addFooterDivIdForConnect(); |
|
1916 |
addFooterDivIdForCommunities(); |
|
1917 |
addFooterHelpTextForConnect(); |
|
1918 |
addFooterHelpTextForCommunities(); |
|
1919 |
|
|
1920 |
// 04-06-2021 debug helper function |
|
1921 |
// cleanPagesFromPortals(); |
Also available in: Unified diff
[Trunk | Admin Tools]: update_db.js:
a. In function addPiwik(), add new communities (galaxy, gortriple, neanias-underwater, pending piwik: embrc).
b. New functions for footer divId & div helptexts (connect & communities): addFooterDivIdForConnect(), addFooterDivIdForCommunities(), addFooterHelpTextForConnect(), addFooterHelpTextForCommunities().