Revision 56174
Added by Konstantina Galouni almost 5 years ago
modules/uoa-admin-tools/update_db.js | ||
---|---|---|
163 | 163 |
} |
164 | 164 |
} |
165 | 165 |
|
166 |
function pageOptionConnectAsCommunities() { |
|
167 |
pages = db.page.find().map( function(page) { return page; } ); |
|
168 |
for (var i = 0; i < pages.length; i++) { |
|
169 |
page = pages[i]; |
|
170 |
|
|
171 |
db.page.update( |
|
172 |
{ "_id" : page._id }, |
|
173 |
{ $set: {"communities": page.connect, "connect": false}} |
|
174 |
); |
|
175 |
} |
|
176 |
} |
|
177 |
|
|
166 | 178 |
use openaire_admin; |
167 | 179 |
|
168 | 180 |
//updatePages(); |
... | ... | |
188 | 200 |
//addORPInStatistics(); |
189 | 201 |
//createShareInZenodoPage(); |
190 | 202 |
//addCommunityLayout(); |
191 |
addCuratorsPage(); |
|
192 |
removeMonitorPage(); |
|
203 |
//addCuratorsPage(); |
|
204 |
//removeMonitorPage(); |
|
205 |
pageOptionConnectAsCommunities(); |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/dao/PageDAO.java | ||
---|---|---|
7 | 7 |
public interface PageDAO { |
8 | 8 |
List<Page> findAll(); |
9 | 9 |
List<Page> findByConnect(boolean connect); |
10 |
List<Page> findByCommunities(boolean communities); |
|
10 | 11 |
List<Page> findByOpenaire(boolean openaire); |
11 | 12 |
Page findById(String Id); |
12 | 13 |
Page findByRoute(String route); |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/dao/MongoDBPageDAO.java | ||
---|---|---|
9 | 9 |
public interface MongoDBPageDAO extends PageDAO, MongoRepository<Page, String> { |
10 | 10 |
List<Page> findAll(); |
11 | 11 |
List<Page> findByConnect(boolean connect); |
12 |
List<Page> findByCommunities(boolean communities); |
|
12 | 13 |
List<Page> findByOpenaire(boolean openaire); |
13 | 14 |
Page findById(String Id); |
14 | 15 |
|
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/entities/Page.java | ||
---|---|---|
17 | 17 |
private String type; |
18 | 18 |
private List<String> entities; |
19 | 19 |
private Boolean connect; |
20 |
private Boolean communities; |
|
20 | 21 |
private Boolean openaire; |
21 | 22 |
|
22 | 23 |
public Page() { |
... | ... | |
62 | 63 |
return connect; |
63 | 64 |
} |
64 | 65 |
|
65 |
public void setConnect(Boolean connect) { |
|
66 |
this.connect = connect; |
|
66 |
public void setConnect(Boolean connect) { this.connect = connect; } |
|
67 |
|
|
68 |
public Boolean getCommunities() { |
|
69 |
return communities; |
|
67 | 70 |
} |
68 | 71 |
|
72 |
public void setCommunities(Boolean communities) { |
|
73 |
this.communities = communities; |
|
74 |
} |
|
75 |
|
|
69 | 76 |
public Boolean getOpenaire() { |
70 | 77 |
return openaire; |
71 | 78 |
} |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/entities/DivIdResponse.java | ||
---|---|---|
13 | 13 |
private String name; |
14 | 14 |
private List<Page> pages; |
15 | 15 |
|
16 |
public DivIdResponse() {} |
|
17 |
|
|
16 | 18 |
public DivIdResponse(DivId divId) { |
17 | 19 |
this.id = divId.getId(); |
18 | 20 |
this.name = divId.getName(); |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/entities/CommunityPage.java | ||
---|---|---|
19 | 19 |
private List<Entity> entities; |
20 | 20 |
private Boolean isEnabled; |
21 | 21 |
private Boolean connect; |
22 |
private Boolean communities; |
|
22 | 23 |
private Boolean openaire; |
23 | 24 |
|
24 | 25 |
public CommunityPage() {} |
... | ... | |
29 | 30 |
this.setName(page.getName()); |
30 | 31 |
this.setType(page.getType()); |
31 | 32 |
this.setConnect(page.getConnect()); |
33 |
this.setCommunities(page.getCommunities()); |
|
32 | 34 |
this.setOpenaire(page.getOpenaire()); |
33 | 35 |
} |
34 | 36 |
|
... | ... | |
76 | 78 |
return connect; |
77 | 79 |
} |
78 | 80 |
|
79 |
public void setConnect(Boolean connect) { |
|
80 |
this.connect = connect; |
|
81 |
public void setConnect(Boolean connect) { this.connect = connect; } |
|
82 |
|
|
83 |
public Boolean getCommunities() { |
|
84 |
return communities; |
|
81 | 85 |
} |
82 | 86 |
|
87 |
public void setCommunities(Boolean communities) { |
|
88 |
this.communities = communities; |
|
89 |
} |
|
90 |
|
|
83 | 91 |
public Boolean getOpenaire() { |
84 | 92 |
return openaire; |
85 | 93 |
} |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/DivIdController.java | ||
---|---|---|
99 | 99 |
} |
100 | 100 |
|
101 | 101 |
@RequestMapping(value = "/div/save", method = RequestMethod.POST) |
102 |
public DivIdResponse insertDivId(@RequestBody DivId divId) { |
|
103 |
divIdDAO.save(divId); |
|
102 |
public DivIdResponse insertDivId(@RequestBody DivIdResponse divIdResponse) { |
|
103 |
DivId divId = this.getDivIdByDivIdResponse(divIdResponse); |
|
104 |
|
|
105 |
DivId savedDivId = divIdDAO.save(divId); |
|
106 |
divIdResponse.setId(savedDivId.getId()); |
|
107 |
|
|
104 | 108 |
return this.getDivIdFull(divId.getId()); |
105 | 109 |
} |
106 | 110 |
|
111 |
private DivId getDivIdByDivIdResponse(DivIdResponse divIdResponse) { |
|
112 |
DivId divId = new DivId(); |
|
113 |
divId.setId(divIdResponse.getId()); |
|
114 |
divId.setName(divIdResponse.getName()); |
|
115 |
|
|
116 |
List<Page> fullPages = divIdResponse.getPages(); |
|
117 |
List<String> pages = new ArrayList<String>(); |
|
118 |
for(Page page : fullPages) { |
|
119 |
pages.add(page.getId()); |
|
120 |
} |
|
121 |
divId.setPages(pages); |
|
122 |
|
|
123 |
return divId; |
|
124 |
} |
|
125 |
|
|
107 | 126 |
@RequestMapping(value = "/div/update", method = RequestMethod.POST) |
108 |
public DivIdResponse updateDivId(@RequestBody DivId _divId) { |
|
127 |
public DivIdResponse updateDivId(@RequestBody DivIdResponse divIdResponse) { |
|
128 |
/* |
|
109 | 129 |
DivId divId = divIdDAO.findById(_divId.getId()); |
110 | 130 |
divId.setName(_divId.getName()); |
111 |
/*List<String> pageIds = new ArrayList<>(); |
|
112 |
for(Page page : divIdResponse.getPages()) { |
|
113 |
pageIds.add(page.getId()); |
|
114 |
}*/ |
|
115 | 131 |
divId.setPages(_divId.getPages()); |
116 | 132 |
divIdDAO.save(divId); |
117 | 133 |
return this.getDivIdFull(divId.getId()); |
134 |
*/ |
|
135 |
DivId divId = this.getDivIdByDivIdResponse(divIdResponse); |
|
136 |
divIdDAO.save(divId); |
|
137 |
return divIdResponse; |
|
118 | 138 |
} |
119 | 139 |
|
120 | 140 |
@RequestMapping(value = "/div/delete", method = RequestMethod.POST) |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/PageController.java | ||
---|---|---|
38 | 38 |
public List<Page> getAllPages(@RequestParam(required=false) String pid) { |
39 | 39 |
List<Page> pages; |
40 | 40 |
if(pid !=null){ |
41 |
pages = (pid=="openaire")? pageDAO.findByOpenaire(true):pageDAO.findByConnect(true); |
|
41 |
if(pid=="openaire") { |
|
42 |
pages = pageDAO.findByOpenaire(true); |
|
43 |
} else if(pid == "connect") { |
|
44 |
pages = pageDAO.findByConnect(true); |
|
45 |
} else { |
|
46 |
pages = pageDAO.findByCommunities(true); |
|
47 |
} |
|
42 | 48 |
} |
43 | 49 |
else{ |
44 | 50 |
pages = pageDAO.findAll(); |
... | ... | |
84 | 90 |
page.setName(communityPage.getName()); |
85 | 91 |
page.setType(communityPage.getType()); |
86 | 92 |
page.setConnect(communityPage.getConnect()); |
93 |
page.setCommunities(communityPage.getCommunities()); |
|
87 | 94 |
page.setOpenaire(communityPage.getOpenaire()); |
88 | 95 |
|
89 | 96 |
List<Entity> fullEntities = communityPage.getEntities(); |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/CommunityController.java | ||
---|---|---|
385 | 385 |
|
386 | 386 |
Page p = pageDAO.findById(page.getKey()); |
387 | 387 |
|
388 |
if((pid.equals("openaire") && p.getOpenaire()) ||(!pid.equals("openaire") && p.getConnect())) {
|
|
388 |
if((pid.equals("openaire") && p.getOpenaire()) || (pid.equals("connect") && p.getConnect()) ||(!pid.equals("openaire") && !pid.equals("connect") && p.getCommunities())) {
|
|
389 | 389 |
if ((page_type == null && page_route == null) || (page_route == null && p.getType().equals(page_type)) |
390 | 390 |
|| p.getRoute().equals(page_route)) { |
391 | 391 |
CommunityPage communityPage = new CommunityPage(p); |
Also available in: Unified diff
1. CommunityController.java: Add check for pid: "connect"
2. DivIdController.java: Bug fix: Save and Update methods should get parameter DivIdResponse
3. PageController.java: pid == "connect" case - get pages that are enabled in connect
4. CommunityPage.java & Page.java & PageDAO.java & MongoDBPageDAO.java: Rename "connect" field to "communities" and use "connect" field for connect general pages (not community specific)
5. update_db.js: Add function to set "communities" field in each page with value from "connect" field, and make "connect" false.