Project

General

Profile

« Previous | Next » 

Revision 52897

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

View differences:

modules/uoa-admin-tools/deployments.txt
1
!!!!Check the following for the override properties port
2

  
3
    src/main/java/eu/dnetlib/uoaadmintools/UoaAdminToolsApplication.java
4

  
5

  
6
!! properties here cannot be overwritten in dnet-override.properties
7
    src/main/resources/application.properties
8

  
9
!!Check dnet-override.properties that have override the properties from:
10

  
11
    src/main/resources/admintools.properties
12

  
13

  
14

  
15

  
16

  
17
***BETA***
18
 PORT: 8380
19
 logs: /var/log/dnet/uoa-admin-tools/
20

  
21
 #spring.data.mongodb.host=beta.services.openaire.eu
22
 #spring.data.mongodb.port=27017
23
 #spring.data.mongodb.database=openaireconnect
24

  
25

  
26
***Production***
27

  
28
 PORT: 8480
29
 logs: /var/log/dnet/uoa-admin-tools/
30

  
31
 #spring.data.mongodb.host=services.openaire.eu
32
 #spring.data.mongodb.port=27017
33
 #spring.data.mongodb.database=openaireconnect
34
 #spring.data.mongodb.username=dnet8480
35
 #spring.data.mongodb.password=...
36

  
modules/uoa-admin-tools/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">&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

  
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();
modules/uoa-admin-tools/init_db.js
77 77
	db.page.save({"name" : "Claims Project Manager", "route" : "/claims-project-manager", "type" : "link", "connect":false,"openaire":true,"entities" : []})
78 78

  
79 79
	db.page.save({"name" : "Monitor", "route" : "/monitor", "type" : "other", "connect":true,"openaire":false,"entities" : []})
80
	db.page.save({"name" : "Content", "route" : "/content", "type" : "other", "connect":true,"openaire":false,"entities" : []})
81 80

  
82 81
	db.page.save({"name" : "About", "route" : "/about", "type" : "html", "connect":true,"openaire":false,"entities" : []})
83 82
	db.page.save({"name" : "Organizations", "route" : "/organizations", "type" : "html", "connect":true,"openaire":false,"entities" : []})
......
145 144
	claimsProjectManager = db.page.find( { route: "/claims-project-manager" }).map( function(page) { return page._id.str; } ).toString()
146 145

  
147 146
	monitor = db.page.find( { route: "/monitor" }).map( function(page) { return page._id.str; } ).toString()
148
	content = db.page.find( { route: "/content" }).map( function(page) { return page._id.str; } ).toString()
149 147

  
150 148
	about = db.page.find( { route: "/about" }).map( function(page) { return page._id.str; } ).toString()
151 149
	organizations = db.page.find( { route: "/organizations" }).map( function(page) { return page._id.str; } ).toString()
......
188 186
	community_pages[administratorClaims] = true;
189 187
	community_pages[claimsProjectManager] = true;
190 188
	community_pages[monitor] = true;
191
	community_pages[content] = true;
192
	community_pages[about] = true;
193
	community_pages[organizations] = true;
189
	community_pages[about] = false;
190
	community_pages[organizations] = false;
194 191

  
195 192
	publicationId = db.entity.find( { pid: "publication" }).map( function(entity) { return entity._id.str; } ).toString()
196 193
	datasetId = db.entity.find( { pid: "dataset" }).map( function(entity) { return entity._id.str; } ).toString()
197 194
	softwareId = db.entity.find( { pid: "software" }).map( function(entity) { return entity._id.str; } ).toString()
198 195
	projectId = db.entity.find( { pid: "project" }).map( function(entity) { return entity._id.str; } ).toString()
199 196
	organizationId = db.entity.find( { pid: "organization" }).map( function(entity) { return entity._id.str; } ).toString()
200
	datasourceId = db.entity.find( { pid: "datasource" }).map( function(entity) { return entity._id.str; } ).toString()
197
	datasourceId = db.entity.find( { pid: "datasource" }).map( function(entity) { return entity._id.str; } ).toString();
198
	print("PAges:"+publicationId);
201 199
	var community_entities = {}
202 200
	community_entities[publicationId] = true;
203 201
	community_entities[datasetId] = true;
......
264 262
function createAllCommunities(){
265 263
    createCommunity("OpenAIRE","openaire");
266 264
    createCommunity("EGI Federation","egi");
267
    createCommunity("Environment and Economy","ee");
265
    createCommunity("SDSN - Greece ","ee");
268 266
    createCommunity("Fisheries and Aquaculture Management","fam");
269 267
    createCommunity("Instruct-ERIC","instruct");
270 268
    createCommunity("Elixir","elixir-gr");
271
    createCommunity("Marine Environmental Science","mes");
269
    createCommunity("European Marine Science","mes");
272 270
    createCommunity("EC post-grant Open Access Pilot","oa-pg");
273 271
    createCommunity("Neuroinformatics","ni");
274 272
    createCommunity("Research Data Alliance","rda");
275 273
    createCommunity("Digital Humanities and Cultural Heritage","dh-ch");
276
	createCommunity("AGINFRA+","aginfra");
274
	createCommunity("AGINFRA","aginfra");
277 275
	createCommunity("Clarin","clarin");
278 276
}
279 277

  
......
284 282
	communities = db.community.find().map( function(community) { return community._id.str.toString(); } );
285 283

  
286 284
	for (var i = 0; i < communities.length; i++) {
287
 		db.htmlPageContent.save({"page" : about, "community" : communities[i], "content" : "<div>Build your html page: About</div>"})
288
 		db.htmlPageContent.save({"page" : organizations, "community" : communities[i], "content" : "<div>Build your html page: Organizations</div>"})
285
 		db.htmlPageContent.save({"page" : about, "community" : communities[i], "content" : '<div><div class="uk-article-title custom-article-title"> About the community </div> <p> This is an introductory text. To be updated... </p> </div>'})
286
 		db.htmlPageContent.save({"page" : organizations, "community" : communities[i], "content" : '<div><div class="uk-article-title custom-article-title"> Organizations related to the community </div> <p> This is an introductory text. Here follows the list of organizations... </p> <div class="uk-child-width-1-3@m uk-text-center uk-grid-match " uk-grid > <div class="uk-card uk-card-default uk-margin-bottom uk-padding-remove"> <div class="uk-card-media-top"> <img src="https://upload.wikimedia.org/wikipedia/el/2/2b/Logo_uoa_blue.png" alt="" class="uk-height-small uk-responsive-height "> </div> <div class="uk-card-body"> <h3 class="uk-card-title"> <a class="wk-link-reset" href="https://www.uoa.gr/">University of Athens</a> </h3> </div> </div> <div class="uk-card uk-card-default uk-margin-bottom uk-padding-remove"> <div class="uk-card-media-top"> <img src="https://pbs.twimg.com/profile_images/631127495933165569/ElbqhHK0_400x400.jpg" alt="" class="uk-height-small uk-responsive-height "> </div> <div class="uk-card-body"> <h3 class="uk-card-title"> <a class="wk-link-reset" href="https://www.athena-innovation.gr/en">Athena Research & Innovation center</a> </h3> </div> </div> <div class="uk-card uk-card-default uk-margin-bottom uk-padding-remove"> <div class="uk-card-media-top"> <img src="" alt="Logo 1" class="uk-height-small uk-responsive-height "> </div> <div class="uk-card-body"> <h3 class="uk-card-title"> <a class="wk-link-reset" href="">Organization 1</a> </h3> </div> </div> <div class="uk-card uk-card-default uk-margin-bottom uk-padding-remove"> <div class="uk-card-media-top"> <img src="" alt="Logo 2" class="uk-height-small uk-responsive-height "> </div> <div class="uk-card-body"> <h3 class="uk-card-title"> <a class="wk-link-reset" href="">Organization 2</a> </h3> </div> </div> <div class="uk-card uk-card-default uk-margin-bottom uk-padding-remove"> <div class="uk-card-media-top"> <img src="" alt="Logo 3" class="uk-height-small uk-responsive-height "> </div> <div class="uk-card-body"> <h3 class="uk-card-title"> <a class="wk-link-reset" href="">Organization 3</a> </h3> </div> </div> </div></div>'})
289 287
	}
290 288
}
291 289

  
......
294 292
dropDB();
295 293
createCollections();
296 294
initializeEntitiesPagesDivIds();
297
//createCommunity("OpenAIRE","openaire");
298 295
createAllCommunities();
299 296
addDefaultHtmlToHtmlPages();
modules/uoa-admin-tools/src/test/java/eu/dnetlib/uoaadmintools/NotificationsTests.java
1
package eu.dnetlib.uoaadmintools;
2

  
3
import eu.dnetlib.uoaadmintools.dao.*;
4
import eu.dnetlib.uoaadmintools.entities.Notifications;
5
import eu.dnetlib.uoaadmintools.entities.Page;
6
import org.junit.Test;
7
import org.junit.runner.RunWith;
8
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.boot.test.context.SpringBootTest;
10
import org.springframework.test.context.junit4.SpringRunner;
11

  
12
import java.util.List;
13

  
14
@RunWith(SpringRunner.class)
15
@SpringBootTest
16
public class NotificationsTests {
17

  
18
	@Autowired
19
	private CommunityDAO communityDAO;
20

  
21

  
22
	@Autowired
23
	private NotificationsDAO notificationsDAO;
24

  
25

  
26
	@Test
27
	public void test() {
28
		String mail = "argirokokogiannaki@gmail.com";
29
		String id="rda";
30
			System.out.println(notificationsDAO.findByCommunityPid(id));
31

  
32
		Notifications notifications = notificationsDAO.findByManagerEmailAndCommunityPid(mail	, id);
33
		if(notifications == null){
34
			notifications = new Notifications();
35
			notifications.setCommunityPid(id);
36
			notifications.setManagerEmail(mail);
37
		}
38
		notifications.setNotifyForNewManagers(false);
39
		notifications.setNotifyForNewSubscribers(false);
40

  
41
		notificationsDAO.save(notifications);
42
		System.out.println(notificationsDAO.findByCommunityPid(id));
43

  
44

  
45

  
46

  
47
	}
48

  
49
}
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/UoaAdminToolsApplication.java
11 11
        @PropertySource("classpath:admintools.properties"),
12 12
        @PropertySource(value = "file:/usr/share/tomcat7/lib/dnet-override.properties", ignoreResourceNotFound = true),
13 13
        @PropertySource(value = "file:/var/lib/tomcat_dnet/8380/lib/dnet-override.properties", ignoreResourceNotFound = true)
14

  
14 15
})
15 16
public class UoaAdminToolsApplication {
16 17

  
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/dao/MongoDBNotificationsDAO.java
1
package eu.dnetlib.uoaadmintools.dao;
2

  
3
import eu.dnetlib.uoaadmintools.entities.Notifications;
4
import org.springframework.data.mongodb.repository.MongoRepository;
5

  
6
import java.util.List;
7

  
8
/**
9
 * Created by argirok on 6/7/2018.
10
 */
11
public interface MongoDBNotificationsDAO extends NotificationsDAO, MongoRepository<Notifications, String> {
12
    List<Notifications> findAll();
13

  
14
    Notifications findById(String Id);
15

  
16
    Notifications findByManagerEmailAndCommunityPid(String managerEmail, String communityPid);
17
    List<Notifications> findByCommunityPid(String communityPid);
18

  
19
    Notifications save(Notifications entity);
20

  
21
    void deleteAll();
22

  
23
    void delete(String id);
24
}
25

  
26

  
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/dao/NotificationsDAO.java
1
package eu.dnetlib.uoaadmintools.dao;
2

  
3
import eu.dnetlib.uoaadmintools.entities.Notifications;
4

  
5
import java.util.List;
6

  
7
/**
8
 * Created by argirok on 6/7/2018.
9
 */
10
public interface NotificationsDAO {
11
    List<Notifications> findAll();
12

  
13
    Notifications findById(String Id);
14

  
15
    Notifications findByManagerEmailAndCommunityPid(String managerEmail, String communityPid);
16
    List<Notifications> findByCommunityPid(String communityPid);
17

  
18
    Notifications save(Notifications entity);
19

  
20
    void deleteAll();
21

  
22
    void delete(String id);
23
}
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/entities/Notifications.java
1
package eu.dnetlib.uoaadmintools.entities;
2

  
3
import com.fasterxml.jackson.annotation.JsonProperty;
4
import org.springframework.data.annotation.Id;
5

  
6
/**
7
 * Created by argirok on 6/7/2018.
8
 */
9
public class Notifications {
10
    @Id
11
    @JsonProperty("_id")
12
    private String id;
13
    Boolean notifyForNewManagers = true;
14
    Boolean notifyForNewSubscribers = true;
15
    String managerEmail;
16
    String communityPid;
17
    public Notifications(){
18

  
19
    }
20
    public Notifications(String managerEmail, String communityPid){
21
        this();
22
        this.communityPid = communityPid;
23
        this.managerEmail = managerEmail;
24
    }
25
    public String getId() {
26
        return id;
27
    }
28

  
29
    public void setId(String id) {
30
        this.id = id;
31
    }
32

  
33
    public Boolean getNotifyForNewManagers() {
34
        return notifyForNewManagers;
35
    }
36

  
37
    public void setNotifyForNewManagers(Boolean notifyForNewManagers) {
38
        this.notifyForNewManagers = notifyForNewManagers;
39
    }
40

  
41
    public Boolean getNotifyForNewSubscribers() {
42
        return notifyForNewSubscribers;
43
    }
44

  
45
    public void setNotifyForNewSubscribers(Boolean notifyForNewSubscribers) {
46
        this.notifyForNewSubscribers = notifyForNewSubscribers;
47
    }
48

  
49
    public String getManagerEmail() {
50
        return managerEmail;
51
    }
52

  
53
    public void setManagerEmail(String managerEmail) {
54
        this.managerEmail = managerEmail;
55
    }
56

  
57
    public String getCommunityPid() {
58
        return communityPid;
59
    }
60

  
61
    public void setCommunityPid(String communityPid) {
62
        this.communityPid = communityPid;
63
    }
64

  
65
    @Override
66
    public String toString() {
67
        return "Notifications{" +
68
                "id='" + id + '\'' +
69
                ", notifyForNewManagers=" + notifyForNewManagers +
70
                ", notifyForNewSubscribers=" + notifyForNewSubscribers +
71
                ", managerEmail='" + managerEmail + '\'' +
72
                ", communityPid='" + communityPid + '\'' +
73
                '}';
74
    }
75
}
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/entities/Email.java
1
package eu.dnetlib.uoaadmintools.entities;
2

  
3
import java.util.List;
4

  
5
/**
6
 * Created by argirok on 6/7/2018.
7
 */
8
public class Email {
9
    String subject;
10
    List<String> recipients;
11
    String body;
12

  
13
    public String getSubject() {
14
        return subject;
15
    }
16

  
17
    public void setSubject(String subject) {
18
        this.subject = subject;
19
    }
20

  
21
    public List<String> getRecipients() {
22
        return recipients;
23
    }
24

  
25
    public void setRecipients(List<String> recipients) {
26
        this.recipients = recipients;
27
    }
28

  
29
    public String getBody() {
30
        return body;
31
    }
32

  
33
    public void setBody(String body) {
34
        this.body = body;
35
    }
36
}
37

  
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/CommunitySubscribersController.java
54 54
        if(savedSubscriber==null){
55 55
            savedSubscriber = subscriberDAO.save(subscriber);
56 56
        }
57
        for(Subscriber sub:communitySubscribers.getSubscribers()){
58
            if(sub.getEmail().equals(subscriber.getEmail())){
59
                //already subscribed
60
                return communitySubscribers;
61
            }
62
        }
63
        //not subscribed yet
57 64
        communitySubscribers.getSubscribers().add(savedSubscriber);
58 65
        return communitySubscriberDAO.save(communitySubscribers);
59 66

  
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/EmailController.java
1 1
package eu.dnetlib.uoaadmintools.controllers;
2 2

  
3
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
4
import eu.dnetlib.uoaadmintools.dao.NotificationsDAO;
3 5
import eu.dnetlib.uoaadmintools.emailSender.EmailSender;
6
import eu.dnetlib.uoaadmintools.entities.Email;
7
import eu.dnetlib.uoaadmintools.entities.Notifications;
8
import eu.dnetlib.uoaadmintools.handlers.NotFoundException;
4 9
import org.apache.log4j.Logger;
5 10
import org.springframework.beans.factory.annotation.Autowired;
6 11
import org.springframework.web.bind.annotation.*;
7 12

  
13
import java.util.ArrayList;
8 14
import java.util.List;
9 15

  
10 16
@RestController
......
14 20

  
15 21
    @Autowired
16 22
    private EmailSender emailSender;
23
    @Autowired
24
    private NotificationsDAO notificationsDAO;
25
    @Autowired
26
    private CommunityDAO communityDAO;
27
    //invitation // no check
28
    //welcome new manager - no check
29
    //notify about new manager - check manager option
30
    //notify about new subscribers - check manager option
31
    //notify for claims - check manager option --> claim API
32
    @RequestMapping(value = "/email", method = RequestMethod.POST)
33
    public Boolean sendEmail(@RequestBody Email email ) throws Exception {
34
        for(String userMail:email.getRecipients()){
35
            ArrayList<String> sendTo = new ArrayList<>();
36
            sendTo.add(userMail);
37
            emailSender.send(sendTo,email.getSubject(),email.getBody());
38
        }
17 39

  
18
    @RequestMapping(value = "/invite", method = RequestMethod.POST)
19
    public Boolean inviteReciptients(@RequestBody List<String> reciptients) throws Exception {
20
        emailSender.send(reciptients);
21 40
        return true;
22 41
    }
42

  
43
    @RequestMapping(value = "/notifyNewManagers/{pid}", method = RequestMethod.POST)
44
    public Boolean notifyNewManagers(@PathVariable(value = "pid") String pid,@RequestBody Email email ) throws Exception {
45
        List<String> notifyrecipients = new ArrayList<String>();
46
        if(communityDAO.findByPid(pid) == null){
47
            throw new NotFoundException("Community not found");
48
        }
49
        for(String user:email.getRecipients()){
50
            Notifications userNotifications = notificationsDAO.findByManagerEmailAndCommunityPid(user,pid);
51

  
52
            if(userNotifications == null || userNotifications.getNotifyForNewManagers()){
53
                notifyrecipients.add(user);
54
            }
55
        }
56
        if(notifyrecipients.size() > 0){
57
            emailSender.send(notifyrecipients,email.getSubject(),email.getBody());
58
        }else{
59
            log.debug("There are no users to notify ");
60
        }
61

  
62
        return true;
63
    }
64
    @RequestMapping(value = "/notifyNewSubscribers/{pid}", method = RequestMethod.POST)
65
    public Boolean notifyNewSubscribers(@PathVariable(value = "pid") String pid,@RequestBody Email email ) throws Exception {
66
        List<String> notifyrecipients = new ArrayList<String>();
67
        if(communityDAO.findByPid(pid) == null){
68
            throw new NotFoundException("Community not found");
69
        }
70
        for(String user:email.getRecipients()){
71
            Notifications userNotifications = notificationsDAO.findByManagerEmailAndCommunityPid(user,pid);
72

  
73
            if(userNotifications == null || userNotifications.getNotifyForNewSubscribers()){
74
                notifyrecipients.add(user);
75
            }
76
        }
77
        if(notifyrecipients.size() > 0){
78
            emailSender.send(notifyrecipients,email.getSubject(),email.getBody());
79
        }else{
80
            log.debug("There are no users to notify ");
81
        }
82

  
83
        return true;
84
    }
85

  
23 86
}
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/NotificationsController.java
1
package eu.dnetlib.uoaadmintools.controllers;
2

  
3
import eu.dnetlib.uoaadmintools.dao.CommunityDAO;
4
import eu.dnetlib.uoaadmintools.dao.NotificationsDAO;
5
import eu.dnetlib.uoaadmintools.entities.Notifications;
6
import eu.dnetlib.uoaadmintools.handlers.NotFoundException;
7
import org.springframework.beans.factory.annotation.Autowired;
8
import org.springframework.web.bind.annotation.*;
9

  
10
import java.util.List;
11

  
12
/**
13
 * Created by argirok on 6/7/2018.
14
 */
15
@RestController
16
@CrossOrigin(origins = "*")
17
public class NotificationsController {
18
    @Autowired
19
    private NotificationsDAO notificationsDAO;
20
    @Autowired
21
    private CommunityDAO communityDAO;
22

  
23
    @RequestMapping(value = "/community/{pid}/notifications", method = RequestMethod.GET)
24
    public List<Notifications> getNotifications(@PathVariable(value = "pid") String pid ) throws NotFoundException {
25
        if(communityDAO.findByPid(pid) == null){
26
            throw new NotFoundException("Community not found");
27
        }
28
        List<Notifications> notifications = notificationsDAO.findByCommunityPid(pid);
29
        if(notifications == null || notifications.size() == 0){
30
            throw new NotFoundException("Notifications settings not found");
31
        }
32
        return notifications;
33
    }
34
    @RequestMapping(value = "/community/{pid}/notifications", method = RequestMethod.DELETE)
35
    public void deleteEntity(@PathVariable(value = "pid") String pid, @RequestBody String email) throws NotFoundException {
36
        Notifications notifications = notificationsDAO.findByManagerEmailAndCommunityPid(email,pid);
37
        if(notifications!= null){
38
            notificationsDAO.delete(notifications.getId());
39
        }else{
40
            throw new NotFoundException("Notifications not found");
41
        }
42

  
43
    }
44

  
45
    @RequestMapping(value = "/community/{pid}/notifications", method = RequestMethod.POST)
46
    public Notifications saveEntity(@PathVariable(value = "pid") String pid, @RequestBody Notifications notifications) throws NotFoundException {
47
        if(communityDAO.findByPid(pid) == null){
48
            throw new NotFoundException("Community not found");
49
        }
50
        notifications.setCommunityPid(pid);
51
        Notifications savedNotifications = notificationsDAO.save(notifications);
52
        return savedNotifications;
53

  
54
    }
55

  
56
}
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/emailSender/EmailSender.java
35 35
    @Value( "${admintool.from}" )
36 36
    private String from = null;
37 37

  
38
    public void send(List<String> recipients) {
38
    public void send(List<String> recipients, String subject, String body) {
39 39
        // Get system properties
40 40
        Properties properties = System.getProperties();
41 41
        properties.setProperty("mail.smtp.host", host);
......
51 51
                });
52 52

  
53 53
        try {
54
            logger.debug("Try to sent e-mail to "+recipients.toString()+
55
            "\nSubject: "+subject+
56
            "\nBody:"+body);
57

  
54 58
            // Create a default MimeMessage object.
55 59
            MimeMessage message = new MimeMessage(session);
56 60

  
......
59 63

  
60 64
            // Set To: header field of the header.
61 65
            for(String to : recipients) {
62
                message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
66
                message.addRecipient(Message.RecipientType.BCC, new InternetAddress(to));
63 67
            }
64

  
65 68
            // Set Subject: header field
66
            message.setSubject("Join Openaire!");
69
            message.setSubject(subject);
67 70

  
68 71
            // For simple text setText() can be used instead of setContent()
69 72

  
70 73
            // Send the actual HTML message, as big as you like
71
            message.setContent("Test email", "text/html");
74
            message.setContent(body, "text/html");
72 75

  
73 76
            // Send message
74 77
            Transport.send(message);
modules/uoa-admin-tools/src/main/resources/admintools.properties
1 1
#dev
2
admintool.userInfoUrl = http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=
3
admintool.originServer = .di.uoa.gr
2
#admintool.userInfoUrl = http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/api/users/getUserInfo?accessToken=
3
#admintool.originServer = .di.uoa.gr
4 4
#beta
5 5
#admintool.userInfoUrl =  https://beta.services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=
6 6
#admintool.originServer = .openaire.eu
7 7

  
8
#production
9
#admintool.userInfoUrl =  https://services.openaire.eu/uoa-user-management/api/users/getUserInfo?accessToken=
10
#admintool.originServer = .openaire.eu
11

  
8 12
admintool.host = smtp.gmail.com
9 13
admintool.port = 587
10 14
admintool.from = invalid_email@email.com
modules/uoa-admin-tools/src/main/resources/application.properties
3 3
#spring.data.mongodb.host=beta.services.openaire.eu
4 4
#spring.data.mongodb.port=27017
5 5
#spring.data.mongodb.database=openaireconnect
6
#production
7
#spring.data.mongodb.host=localhost
8
#spring.data.mongodb.port=27017
9
#spring.data.mongodb.database=openaireconnect
10
#spring.data.mongodb.authentication-database=openaireconnect
11
#spring.data.mongodb.username=dnet8480
12
#spring.data.mongodb.password=...
13

  
14

  
6 15
#dev
7 16
spring.data.mongodb.host=localhost
8 17
spring.data.mongodb.port=27017

Also available in: Unified diff