Project

General

Profile

1
//version compatibility: 1.0.1-SNAPSHOT
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")
43
//
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()
46
//
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 }});
62

    
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">&nbsp;</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">&nbsp;</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">&nbsp;</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&#39;s ORCID</div> </div> ';
130
 link_result_bulk_content = '<div> <div><span class="uk-text-bold"><span uk-icon="icon: info">&nbsp;</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 &quot;DOI&quot;,&quot;ACCESS_MODE&quot;,&quot;DATE&quot;.</li> <li>The value &quot;DOI&quot; is required</li> <li>Access mode column should have values: &quot;OPEN&quot;,&quot;CLOSED&quot; or &quot;EMBARGO&quot;.</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 &quot;OPEN&quot;.</li> </ul> </div> </div> ';
131
 link_metadata_content = '<div> <div><span class="uk-text-bold"><span uk-icon="icon: info">&nbsp;</span> Information:</span> Manage access mode &amp; type of selected research results. For OpenAIRE this functionality isn&#39;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
 use openaire_admin;
150

    
151

    
152
//updateTypeOfLandingPages();
153
//removeEntitiesFromSearchFindPage();
154
initDivHelpContents();
(3-3/3)