Revision 50840
Added by Konstantina Galouni about 6 years ago
modules/uoa-admin-tools/src/test/java/eu/dnetlib/uoaadmintools/UoaAdminToolsApplicationTests.java | ||
---|---|---|
35 | 35 |
private PageHelpContentDAO pageHelpContentDAO; |
36 | 36 |
|
37 | 37 |
/* |
38 |
|
|
38 | 39 |
@Test |
40 |
public void createAllEntities() { |
|
41 |
Map<String, String> entities = new HashMap<>(); |
|
42 |
entities.put("Publication", "publication"); |
|
43 |
entities.put("Research Data", "dataset"); |
|
44 |
entiites.put("Software", "software"); |
|
45 |
entities.put("Project", "project"); |
|
46 |
entities.put("Organization", "organization"); |
|
47 |
entities.put("Content Provider", "datasource"); |
|
48 |
|
|
49 |
for(entry<String, String> entr : entities.entrySet()) { |
|
50 |
Entity entity = new Entity(); |
|
51 |
entity.setName(entr.getKey()); |
|
52 |
entity.setPid(entr.getValue()); |
|
53 |
entityDAO.save(entity); |
|
54 |
} |
|
55 |
} |
|
56 |
|
|
57 |
@Test |
|
58 |
public void createAllPages() { |
|
59 |
String publication = entityDAO.findByPid("publication").getId(); |
|
60 |
String dataset = entityDAO.findByPid("dataset").getId(); |
|
61 |
String software = entityDAO.findByPid("software").getId(); |
|
62 |
String project = entityDAO.findByPid("project").getId(); |
|
63 |
String organization = entityDAO.findByPid("organization").getId(); |
|
64 |
String datasource = entityDAO.findByPid("datasource").getId(); |
|
65 |
|
|
66 |
|
|
67 |
Map<String, List<String>> pages = new HashMap<>(); |
|
68 |
pages.put("Search Publications", new ArrayList<>()); |
|
69 |
pages.get("Search Publications").add() |
|
70 |
|
|
71 |
//entities.add("5a300ee4c97a7d2c000b9e9d"); // Publication |
|
72 |
entities.add("5a319f8bc97a7d241ebddf75"); // Research Data |
|
73 |
|
|
74 |
|
|
75 |
Page page = new Page(); |
|
76 |
page.setName("Search Research Data"); |
|
77 |
page.setRoute("/search/find/datasets"); |
|
78 |
page.setType("search"); |
|
79 |
page.setEntities(entities); |
|
80 |
pageDAO.save(page); |
|
81 |
} |
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
@Test |
|
39 | 86 |
public void deleteAllEntities() { |
40 | 87 |
List<Entity> entities = entityDAO.findAll(); |
41 | 88 |
for(Entity entity : entities) { |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/dao/DivIdDAO.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
List<DivId> findByCommunity(String community); |
11 | 11 |
List<DivId> findByCommunityAndPage(String community, String page); |
12 |
List<DivId> findByCommunityAndPageAndName(String community, String page, String name); |
|
13 |
List<DivId> findByCommunityAndName(String community, String name); |
|
14 |
List<DivId> findByPageAndName(String page, String name); |
|
15 |
List<DivId> findByPage(String page); |
|
16 |
List<DivId> findByName(String name); |
|
12 | 17 |
|
13 | 18 |
DivId findById(String Id); |
14 | 19 |
|
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/dao/MongoDBDivIdDAO.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
List<DivId> findByCommunity(String community); |
12 | 12 |
List<DivId> findByCommunityAndPage(String community, String page); |
13 |
List<DivId> findByCommunityAndPageAndName(String community, String page, String name); |
|
14 |
List<DivId> findByCommunityAndName(String community, String name); |
|
15 |
List<DivId> findByPageAndName(String page, String name); |
|
16 |
List<DivId> findByPage(String page); |
|
17 |
List<DivId> findByName(String name); |
|
13 | 18 |
|
14 | 19 |
DivId findById(String Id); |
15 | 20 |
|
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/PageController.java | ||
---|---|---|
60 | 60 |
List<Community> communities = communityDAO.findAll(); |
61 | 61 |
for( Community community : communities ) { |
62 | 62 |
Map<String, Boolean> pages = community.getPages(); |
63 |
pages.put(page.getId(), false);
|
|
63 |
pages.put(page.getId(), true);
|
|
64 | 64 |
community.setPages(pages); |
65 | 65 |
communityDAO.save(community); |
66 | 66 |
} |
... | ... | |
91 | 91 |
pageDAO.delete(id); |
92 | 92 |
|
93 | 93 |
// delete divIds related to this page from all communities |
94 |
List<DivId> divIds = divIdController.getDivIds(null, id); |
|
94 |
List<DivId> divIds = divIdController.getDivIds(null, id, null);
|
|
95 | 95 |
for(DivId divId : divIds) { |
96 | 96 |
divIdController.deleteDivId(divId.getId()); |
97 | 97 |
} |
98 | 98 |
|
99 | 99 |
// delete div contents related to this page from all communities |
100 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(null, id, null); |
|
100 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(null, id, null, null);
|
|
101 | 101 |
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) { |
102 | 102 |
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId()); |
103 | 103 |
} |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/DivIdController.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
@RequestMapping(value = "/div", method = RequestMethod.GET) |
33 | 33 |
public List<DivId> getDivIds(@RequestParam(required = false) String community, |
34 |
@RequestParam(required = false) String page) { |
|
34 |
@RequestParam(required = false) String page, |
|
35 |
@RequestParam(required = false) String name) { |
|
35 | 36 |
List<DivId> divIds = null; |
36 |
if(community != null && page != null) { |
|
37 |
String communityId = communityDAO.findByPid(community).getId(); |
|
37 |
String communityId = null; |
|
38 |
if(community != null) { |
|
39 |
communityId = communityDAO.findByPid(community).getId(); |
|
40 |
} |
|
41 |
|
|
42 |
if(community != null && page != null && name != null) { |
|
43 |
divIds = divIdDAO.findByCommunityAndPageAndName(communityId, page, name); |
|
44 |
} else if(community != null && page != null) { |
|
38 | 45 |
divIds = divIdDAO.findByCommunityAndPage(communityId, page); |
46 |
} else if(community != null && name != null) { |
|
47 |
divIds = divIdDAO.findByCommunityAndName(communityId, name); |
|
48 |
} else if(page != null && name != null) { |
|
49 |
divIds = divIdDAO.findByPageAndName(page, name); |
|
39 | 50 |
} else if(community != null) { |
40 |
String communityId = communityDAO.findByPid(community).getId(); |
|
41 | 51 |
divIds = divIdDAO.findByCommunity(communityId); |
52 |
} else if(page != null) { |
|
53 |
divIds = divIdDAO.findByPage(page); |
|
54 |
} else if(name != null) { |
|
55 |
divIds = divIdDAO.findByName(name); |
|
42 | 56 |
} else { |
43 | 57 |
divIds = divIdDAO.findAll(); |
44 | 58 |
} |
... | ... | |
47 | 61 |
|
48 | 62 |
@RequestMapping(value = "/divFull", method = RequestMethod.GET) |
49 | 63 |
public List<DivIdResponse> getDivIdsFull(@RequestParam(required = false) String community, |
50 |
@RequestParam(required = false) String page) { |
|
64 |
@RequestParam(required = false) String page, |
|
65 |
@RequestParam(required = false) String name) { |
|
51 | 66 |
|
52 |
List<DivId> divIds = this.getDivIds(community, page); |
|
67 |
List<DivId> divIds = this.getDivIds(community, page, name);
|
|
53 | 68 |
|
54 | 69 |
List<DivIdResponse> divIdResponses = new ArrayList<>(); |
55 | 70 |
for(DivId divId : divIds) { |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/CommunityController.java | ||
---|---|---|
232 | 232 |
communityDAO.delete(id); |
233 | 233 |
|
234 | 234 |
// delete divIds related to this page from all communities |
235 |
List<DivId> divIds = divIdController.getDivIds(id, null); |
|
235 |
List<DivId> divIds = divIdController.getDivIds(id, null, null);
|
|
236 | 236 |
for(DivId divId : divIds) { |
237 | 237 |
divIdController.deleteDivId(divId.getId()); |
238 | 238 |
} |
239 | 239 |
|
240 | 240 |
// delete div contents related to this page from all communities |
241 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(null, id, null); |
|
241 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(null, id, null, null);
|
|
242 | 242 |
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) { |
243 | 243 |
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId()); |
244 | 244 |
} |
modules/uoa-admin-tools/src/main/java/eu/dnetlib/uoaadmintools/controllers/DivHelpContentController.java | ||
---|---|---|
35 | 35 |
@RequestMapping(value = "/divhelpcontent", method = RequestMethod.GET) |
36 | 36 |
public List<DivHelpContentResponse> getDivHelpContents(@RequestParam(required = false) String community, |
37 | 37 |
@RequestParam(required = false) String page, |
38 |
@RequestParam(required = false) String div, |
|
38 | 39 |
@RequestParam(required = false) String active) { |
39 | 40 |
List<DivHelpContentResponse> divHelpContentResponses = new ArrayList<>(); |
40 | 41 |
List<DivIdResponse> divIdResponses = null; |
41 | 42 |
|
42 |
if(community != null) { |
|
43 |
divIdResponses = divIdController.getDivIdsFull(community, null); |
|
44 |
} else { |
|
45 |
divIdResponses = divIdController.getDivIdsFull(null, null); |
|
46 |
} |
|
43 |
divIdResponses = divIdController.getDivIdsFull(community, null, div); |
|
47 | 44 |
|
48 | 45 |
for(DivIdResponse divIdResponse : divIdResponses) { |
49 | 46 |
if(page == null || divIdResponse.getPage().getRoute().equals(page)) { |
modules/uoa-admin-tools/src/main/resources/application.properties | ||
---|---|---|
1 |
#mongodb |
|
2 |
spring.data.mongodb.host=localhost |
|
3 |
spring.data.mongodb.port=27017 |
|
4 |
spring.data.mongodb.database=openaire_admin |
Also available in: Unified diff
1. API to find divhelpcontents by div
2. API to find div by name