Revision 52897
Added by Argiro Kokogiannaki over 5 years ago
update_db.js | ||
---|---|---|
1 | 1 |
//version compatibility: 1.1.0-SNAPSHOT |
2 | 2 |
|
3 |
function updateStats(){ |
|
4 |
print("Update Stats...") |
|
5 |
db.statistics.drop(); |
|
6 |
db.createCollection("statistics") |
|
7 |
|
|
8 |
var communities = db.community.find().map( function(entity) { return entity.pid } ); |
|
9 |
print(communities); |
|
10 |
for(var i =0; i < communities.length; i++){ |
|
11 |
print(communities[i]); |
|
12 |
var communityPid = communities[i]; |
|
13 |
var numbers_map = {}; |
|
14 |
numbers_map["total"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
15 |
numbers_map["project"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
16 |
numbers_map["open"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
17 |
numbers_map["closed"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
18 |
numbers_map["embargo"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
19 |
numbers_map["restricted"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
20 |
var numbers = {"map":numbers_map}; |
|
21 |
var charts_map = {}; |
|
22 |
charts_map["timeline"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
23 |
charts_map["graph"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
24 |
charts_map["projectTable"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
25 |
charts_map["projectColumn"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
26 |
charts_map["projectPie"] = { "showInMonitor" : true, "showInDashboard" : false }; |
|
27 |
var charts = {"map":charts_map}; |
|
28 |
var statistics_entities = {"charts":charts,"numbers":numbers} |
|
29 |
var entities = {}; |
|
30 |
entities["publication"]=statistics_entities; |
|
31 |
entities["dataset"]=statistics_entities; |
|
32 |
entities["software"]=statistics_entities; |
|
33 |
var statistics = {"pid" : communityPid, "entities" : entities}; |
|
34 |
db.statistics.save(statistics); |
|
35 |
print("Update stats for " + communityPid) |
|
36 |
} |
|
37 |
} |
|
38 |
function updateDivIds(){ |
|
39 |
print("Update DivIds...") |
|
40 |
|
|
41 |
//db.divId.drop(); |
|
42 |
//db.createCollection("divId") |
|
3 |
//function createOtherResearchProducts() { |
|
4 |
// db.entity.save({"pid" : "orp", "name" : "Other Research Products"}); |
|
5 |
// orpId = db.entity.find( { pid: "orp" }).map( function(entity) { return entity._id.str; } ).toString(); |
|
43 | 6 |
// |
44 |
//link = db.page.find( { route: "/participate/claim" }).map( function(page) { return page._id.str; } ).toString() |
|
45 |
//directLink = db.page.find( { route: "/participate/direct-claim" }).map( function(page) { return page._id.str; } ).toString() |
|
7 |
// db.page.save({"name" : "Other Research Products Landing", "route" : "/search/other", "type" : "landing", "connect":true,"openaire":true,"entities" : [orpId]}); |
|
8 |
// db.page.save({"name" : "Search Other Research Products", "route" : "/search/find/other", "type" : "search", "connect":true,"openaire":true,"entities" : [orpId]}); |
|
9 |
// db.page.save({"name" : "Advanced Search Other Research Products", "route" : "/search/advanced/other", "type" : "search", "connect":true,"openaire":true,"entities" : [orpId]}); |
|
46 | 10 |
// |
47 |
//db.divId.save({ "name" : "link-context-form", "pages" : [link, directLink]}) |
|
48 |
//db.divId.save({ "name" : "link-project-form", "pages" : [link, directLink]}) |
|
49 |
//db.divId.save({ "name" : "link-result-form", "pages" : [link, directLink]}) |
|
50 |
//db.divId.save({ "name" : "link-result-bulk", "pages" : [link]}) |
|
51 |
//db.divId.save({ "name" : "link-metadata", "pages" : [link, directLink]}) |
|
52 |
} |
|
53 |
function updatePages(){ |
|
54 |
print("\n\nUpdate Pages with connect & openaire fields...") |
|
55 |
db.page.update({ "route" : "/search/publication" },{$set: { "connect": true, "openaire":true }}); |
|
56 |
db.page.update({ "route" : "/search/dataset" },{$set: { "connect": true, "openaire":true }}); |
|
57 |
db.page.update({ "route" : "/search/software" },{$set: { "connect": true, "openaire":true }}); |
|
58 |
db.page.update({ "route" : "/search/project" },{$set: { "connect": true, "openaire":true }}); |
|
59 |
db.page.update({ "route" : "/search/organization" },{$set: { "connect": true, "openaire":true }}); |
|
60 |
db.page.update({ "route" : "/search/dataprovider" },{$set: { "connect": true, "openaire":true }}); |
|
61 |
db.page.update({ "route" : "/project-report" },{$set: { "connect": false, "openaire":true }}); |
|
11 |
// orpLanding = db.page.find( { route: "/search/other" }).map( function(page) { return page._id.str; } ).toString(); |
|
12 |
// searchOrp = db.page.find( { route: "/search/find/other" }).map( function(page) { return page._id.str; } ).toString(); |
|
13 |
// advancedSearchOrp = db.page.find( { route: "/search/advanced/other" }).map( function(page) { return page._id.str; } ).toString(); |
|
14 |
// |
|
15 |
// communities = db.community.find().map( function(community) { return community; } ); |
|
16 |
// |
|
17 |
// for (var i = 0; i < communities.length; i++) { |
|
18 |
// community_pages = communities[i].pages; |
|
19 |
// |
|
20 |
// community_pages[orpLanding] = true; |
|
21 |
// community_pages[searchOrp] = true; |
|
22 |
// community_pages[advancedSearchOrp] = true; |
|
23 |
// |
|
24 |
// community_pid = communities[i].pid; |
|
25 |
// db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}}); |
|
26 |
// print("Update pages for " + community_pid); |
|
27 |
// |
|
28 |
// community_entities = communities[i].entities; |
|
29 |
// |
|
30 |
// community_entities[orpId] = true; |
|
31 |
// |
|
32 |
// community_pid = communities[i].pid; |
|
33 |
// db.community.update({ "pid" : community_pid },{$set: { "entities": community_entities}}); |
|
34 |
// print("Update entities for " + community_pid); |
|
35 |
// } |
|
36 |
//} |
|
62 | 37 |
|
63 |
db.page.update({ "route" : "/search/find" },{$set: { "connect": false, "openaire":true }}); |
|
64 |
|
|
65 |
db.page.update({ "route" : "/search/find/publications" },{$set: { "connect": true, "openaire":true }}); |
|
66 |
db.page.update({ "route" : "/search/find/datasets" },{$set: { "connect": true, "openaire":true }}); |
|
67 |
db.page.update({ "route" : "/search/find/software" },{$set: { "connect": true, "openaire":true }}); |
|
68 |
db.page.update({ "route" : "/search/find/projects" },{$set: { "connect": true, "openaire":true }}); |
|
69 |
db.page.update({ "route" : "/search/find/organizations" },{$set: { "connect": false, "openaire":true }}); |
|
70 |
db.page.update({ "route" : "/search/find/dataproviders" },{$set: { "connect": true, "openaire":true }}); |
|
71 |
|
|
72 |
db.page.update({ "route" : "/search/advanced/publications" },{$set: { "connect": true, "openaire":true }}); |
|
73 |
db.page.update({ "route" : "/search/advanced/datasets" },{$set: { "connect": true, "openaire":true }}); |
|
74 |
db.page.update({ "route" : "/search/advanced/software" },{$set: { "connect": true, "openaire":true }}); |
|
75 |
db.page.update({ "route" : "/search/advanced/projects" },{$set: { "connect": false, "openaire":true }}); |
|
76 |
db.page.update({ "route" : "/search/advanced/organizations" },{$set: { "connect": false, "openaire":true }}); |
|
77 |
db.page.update({ "route" : "/search/advanced/dataproviders" },{$set: { "connect": false, "openaire":true }}); |
|
78 |
|
|
79 |
db.page.update({ "route" : "/search/journals" },{$set: { "connect": false, "openaire":true }}); |
|
80 |
db.page.update({ "route" : "/search/entity-registries" },{$set: { "connect": false, "openaire":true }}); |
|
81 |
db.page.update({ "route" : "/search/content-providers" },{$set: { "connect": false, "openaire":true }}); |
|
82 |
db.page.update({ "route" : "/search/journals-table" },{$set: { "connect": false, "openaire":true }}); |
|
83 |
db.page.update({ "route" : "/search/entity-registries-table" },{$set: { "connect": false, "openaire":true }}); |
|
84 |
db.page.update({ "route" : "/search/content-providers-table" },{$set: { "connect": false, "openaire":true }}); |
|
85 |
|
|
86 |
db.page.update({ "route" : "/participate/deposit-publications" },{$set: { "connect": true, "openaire":true }}); |
|
87 |
db.page.update({ "route" : "/participate/deposit-datasets" },{$set: { "connect": true, "openaire":true }}); |
|
88 |
db.page.update({ "route" : "/participate/deposit-publications-result" },{$set: { "connect": true, "openaire":true }}); |
|
89 |
db.page.update({ "route" : "/participate/deposit-datasets-result" },{$set: { "connect": true, "openaire":true }}); |
|
90 |
db.page.update({ "route" : "/participate/deposit-subject-result" },{$set: { "connect": true, "openaire":true }}); |
|
91 |
|
|
92 |
db.page.update({ "route" : "/participate/claim" },{$set: { "connect": true, "openaire":true }}); |
|
93 |
db.page.update({ "route" : "/participate/direct-claim" },{$set: { "connect": true, "openaire":true }}); |
|
94 |
db.page.update({ "route" : "/myclaims" },{$set: { "connect": true, "openaire":true }}); |
|
95 |
db.page.update({ "route" : "/claims" },{$set: { "connect": false, "openaire":true }}); |
|
96 |
db.page.update({ "route" : "/claims-project-manager" },{$set: { "connect": false, "openaire":true }}); |
|
97 |
|
|
98 |
print("Updated\n\n") |
|
99 |
}; |
|
100 |
|
|
101 |
function updateTypeOfLandingPages(){ |
|
102 |
print("\n\nUpdate type of Landing Pages (from 'search' to 'landing')...") |
|
103 |
db.page.update({ "route" : "/search/publication" },{$set: { "type": "landing"}}); |
|
104 |
db.page.update({ "route" : "/search/dataset" },{$set: { "type": "landing"}}); |
|
105 |
db.page.update({ "route" : "/search/software" },{$set: { "type": "landing"}}); |
|
106 |
db.page.update({ "route" : "/search/project" },{$set: { "type": "landing"}}); |
|
107 |
db.page.update({ "route" : "/search/organization" },{$set: { "type": "landing"}}); |
|
108 |
db.page.update({ "route" : "/search/dataprovider" },{$set: { "type": "landing"}}); |
|
109 |
db.page.update({ "route" : "/project-report" },{$set: { "type": "landing"}}); |
|
110 |
|
|
111 |
print("Updated\n\n") |
|
112 |
}; |
|
113 |
|
|
114 |
function removeEntitiesFromSearchFindPage() { |
|
115 |
db.page.update({ "route" : "/search/find" },{$set: {"entities" : []}}); |
|
116 |
} |
|
117 |
|
|
118 |
function initDivHelpContents(){ |
|
119 |
print("Init Div Help Contents for every community...") |
|
120 |
|
|
121 |
link_context_form = db.divId.find( { name: "link-context-form" }).map( function(divId) { return divId._id.str; } ).toString(); |
|
122 |
link_project_form = db.divId.find( { name: "link-project-form" }).map( function(divId) { return divId._id.str; } ).toString(); |
|
123 |
link_result_form = db.divId.find( { name: "link-result-form" }).map( function(divId) { return divId._id.str; } ).toString(); |
|
124 |
link_result_bulk = db.divId.find( { name: "link-result-bulk" }).map( function(divId) { return divId._id.str; } ).toString(); |
|
125 |
link_metadata = db.divId.find( { name: "link-metadata" }).map( function(divId) { return divId._id.str; } ).toString(); |
|
126 |
|
|
127 |
link_context_form_content = '<div> <div><span class="uk-text-bold"><span uk-icon="icon: info"> </span> Information:</span> Select a research community and/or a category and search for a community concept, or browse to the community tree through the categories</div> </div>'; |
|
128 |
link_project_form_content = '<div> <div><span class="uk-text-bold"><span uk-icon="icon: info"> </span> Information:</span> Search for projects using project name or grant id. Limit results filtering by funder.</div> </div>'; |
|
129 |
link_result_form_content = '<div> <div><span class="uk-text-bold"><span uk-icon="icon: info"> </span> Information:</span></div> Search for research results in OpenAIRE information space, Datacite, CrossRef or ORCID. <div class="uk-text-small">Use keywords, DOI (more than one - space separated), author's ORCID</div> </div> '; |
|
130 |
link_result_bulk_content = '<div> <div><span class="uk-text-bold"><span uk-icon="icon: info"> </span> Information:</span> Upload a csv file containing a list of DOIs. For each DOI found in the file, metadata will be fetched from CrossRef or Datacite and will be added to your selected research results.</div> <div class="uk-margin-top uk-text-small"><span class="uk-text-bold">CSV format:</span> <ul class="uk-list"> <li>The format of CSV file should be "DOI","ACCESS_MODE","DATE".</li> <li>The value "DOI" is required</li> <li>Access mode column should have values: "OPEN","CLOSED" or "EMBARGO".</li> <li>Date column valid format is YYYY-MM-DD and is required when access mode has value EMBARGO.</li> <li>In case access mode is not available default value is "OPEN".</li> </ul> </div> </div> '; |
|
131 |
link_metadata_content = '<div> <div><span class="uk-text-bold"><span uk-icon="icon: info"> </span> Information:</span> Manage access mode & type of selected research results. For OpenAIRE this functionality isn't available.</div> </div>'; |
|
132 |
|
|
133 |
communities = db.community.find().map( function(community) { return community._id.str.toString(); } ); |
|
134 |
|
|
135 |
for (var i = 0; i < communities.length; i++) { |
|
136 |
//db.divHelpContent.drop(); |
|
137 |
//db.createCollection("divHelpContent"); |
|
138 |
|
|
139 |
db.divHelpContent.save({ "divId" : link_context_form, "community" : communities[i], "content" : link_context_form_content, "isActive" : false }); |
|
140 |
db.divHelpContent.save({ "divId" : link_project_form, "community" : communities[i], "content" : link_project_form_content, "isActive" : false }); |
|
141 |
db.divHelpContent.save({ "divId" : link_result_form, "community" : communities[i], "content" : link_result_form_content, "isActive" : true }); |
|
142 |
db.divHelpContent.save({ "divId" : link_result_bulk, "community" : communities[i], "content" : link_result_bulk_content, "isActive" : true }); |
|
143 |
db.divHelpContent.save({ "divId" : link_metadata, "community" : communities[i], "content" : link_metadata_content, "isActive" : false }); |
|
144 |
|
|
145 |
print("Div Help Contents for community "+ communities[i] +" were just created"); |
|
146 |
} |
|
147 |
|
|
148 |
} |
|
149 |
|
|
150 |
function createMonitorPageWithTypeOther() { |
|
151 |
db.page.save({"name" : "Monitor", "route" : "/monitor", "type" : "other", "connect":true,"openaire":false,"entities" : []}) |
|
152 |
} |
|
153 |
|
|
154 |
function addMonitorPageToCommunities() { |
|
155 |
communities = db.community.find().map( function(community) { return community; } ); |
|
156 |
|
|
157 |
monitor = db.page.find( { route: "/monitor" }).map( function(page) { return page._id.str; } ).toString() |
|
158 |
|
|
159 |
for (var i = 0; i < communities.length; i++) { |
|
160 |
community_pages = communities[i].pages; |
|
161 |
|
|
162 |
community_pages[monitor] = false;; |
|
163 |
|
|
164 |
community_pid = communities[i].pid; |
|
165 |
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}}); |
|
166 |
print("Update pages for " + community_pid); |
|
167 |
} |
|
168 |
} |
|
169 |
|
|
170 |
function createContentPageWithTypeOther() { |
|
171 |
db.page.save({"name" : "Content", "route" : "/content", "type" : "other", "connect":true,"openaire":false,"entities" : []}); |
|
172 |
} |
|
173 |
|
|
174 |
function createPagesWithTypeHtml() { |
|
175 |
db.page.save({"name" : "About", "route" : "/about", "type" : "html", "connect":true,"openaire":false,"entities" : []}); |
|
176 |
db.page.save({"name" : "Organizations", "route" : "/organizations", "type" : "html", "connect":true,"openaire":false,"entities" : []}); |
|
177 |
} |
|
178 |
|
|
179 |
function addContent_About_Organizations_PagesToCommunities() { |
|
180 |
communities = db.community.find().map( function(community) { return community; } ); |
|
181 |
|
|
182 |
content = db.page.find( { route: "/content" }).map( function(page) { return page._id.str; } ).toString() |
|
183 |
|
|
184 |
about = db.page.find( { route: "/about" }).map( function(page) { return page._id.str; } ).toString() |
|
185 |
organizations = db.page.find( { route: "/organizations" }).map( function(page) { return page._id.str; } ).toString() |
|
186 |
|
|
187 |
for (var i = 0; i < communities.length; i++) { |
|
188 |
community_pages = communities[i].pages; |
|
189 |
|
|
190 |
community_pages[content] = false; |
|
191 |
community_pages[about] = false; |
|
192 |
community_pages[organizations] = false; |
|
193 |
|
|
194 |
community_pid = communities[i].pid; |
|
195 |
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}}); |
|
196 |
print("Update pages for " + community_pid); |
|
197 |
} |
|
198 |
} |
|
199 |
|
|
200 |
function createCollectionForHtmlPageContents() { |
|
201 |
db.createCollection("htmlPageContent"); |
|
202 |
} |
|
203 |
|
|
204 |
function addDefaultHtmlToHtmlPages() { |
|
205 |
about = db.page.find( { route: "/about" }).map( function(page) { return page._id.str; } ).toString() |
|
206 |
organizations = db.page.find( { route: "/organizations" }).map( function(page) { return page._id.str; } ).toString() |
|
207 |
|
|
208 |
communities = db.community.find().map( function(community) { return community._id.str.toString(); } ); |
|
209 |
|
|
210 |
for (var i = 0; i < communities.length; i++) { |
|
211 |
db.htmlPageContent.save({"page" : about, "community" : communities[i], "content" : "<div>Build your html page: About</div>"}) |
|
212 |
db.htmlPageContent.save({"page" : organizations, "community" : communities[i], "content" : "<div>Build your html page: Organizations</div>"}) |
|
213 |
} |
|
214 |
} |
|
215 |
|
|
216 |
function createOtherResearchProducts() { |
|
217 |
db.entity.save({"pid" : "orp", "name" : "Other Research Products"}); |
|
218 |
orpId = db.entity.find( { pid: "orp" }).map( function(entity) { return entity._id.str; } ).toString(); |
|
219 |
|
|
220 |
db.page.save({"name" : "Other Research Products Landing", "route" : "/search/other", "type" : "landing", "connect":true,"openaire":true,"entities" : [orpId]}); |
|
221 |
db.page.save({"name" : "Search Other Research Products", "route" : "/search/find/other", "type" : "search", "connect":true,"openaire":true,"entities" : [orpId]}); |
|
222 |
db.page.save({"name" : "Advanced Search Other Research Products", "route" : "/search/advanced/other", "type" : "search", "connect":true,"openaire":true,"entities" : [orpId]}); |
|
223 |
|
|
224 |
orpLanding = db.page.find( { route: "/search/other" }).map( function(page) { return page._id.str; } ).toString(); |
|
225 |
searchOrp = db.page.find( { route: "/search/find/other" }).map( function(page) { return page._id.str; } ).toString(); |
|
226 |
advancedSearchOrp = db.page.find( { route: "/search/advanced/other" }).map( function(page) { return page._id.str; } ).toString(); |
|
227 |
|
|
228 |
communities = db.community.find().map( function(community) { return community; } ); |
|
229 |
|
|
230 |
for (var i = 0; i < communities.length; i++) { |
|
231 |
community_pages = communities[i].pages; |
|
232 |
|
|
233 |
community_pages[orpLanding] = true; |
|
234 |
community_pages[searchOrp] = true; |
|
235 |
community_pages[advancedSearchOrp] = true; |
|
236 |
|
|
237 |
community_pid = communities[i].pid; |
|
238 |
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}}); |
|
239 |
print("Update pages for " + community_pid); |
|
240 |
|
|
241 |
community_entities = communities[i].entities; |
|
242 |
|
|
243 |
community_entities[orpId] = true; |
|
244 |
|
|
245 |
community_pid = communities[i].pid; |
|
246 |
db.community.update({ "pid" : community_pid },{$set: { "entities": community_entities}}); |
|
247 |
print("Update entities for " + community_pid); |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 | 38 |
use openaire_admin; |
252 | 39 |
|
253 | 40 |
//updatePages(); |
... | ... | |
265 | 52 |
//createMonitorPageWithTypeOther(); |
266 | 53 |
//addMonitorPageToCommunities(); |
267 | 54 |
|
268 |
createOtherResearchProducts(); |
|
55 |
//createOtherResearchProducts(); |
Also available in: Unified diff
add deployments info file
remove content page from init script
update names of communities
update html for pages with htmlPageContent
Subscribers: don't subscribe again if already subscribed
Notifications: add entity, DAO, controller
Add Email entity
Change emailSender to be more generic