1
|
package eu.dnetlib.uoaadmintools;
|
2
|
|
3
|
import eu.dnetlib.uoaadmintools.dao.*;
|
4
|
import eu.dnetlib.uoaadmintoolslibrary.dao.*;
|
5
|
import eu.dnetlib.uoaadmintoolslibrary.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
|
@RunWith(SpringRunner.class)
|
13
|
@SpringBootTest
|
14
|
public class UoaAdminToolsApplicationTests {
|
15
|
|
16
|
@Autowired
|
17
|
private PortalDAO communityDAO;
|
18
|
|
19
|
@Autowired
|
20
|
private EntityDAO entityDAO;
|
21
|
|
22
|
@Autowired
|
23
|
private PageDAO pageDAO;
|
24
|
|
25
|
@Autowired
|
26
|
private PageHelpContentDAO pageHelpContentDAO;
|
27
|
|
28
|
@Autowired
|
29
|
private DivIdDAO divIdDAO;
|
30
|
|
31
|
@Autowired
|
32
|
private StatisticsDAO statisticsDAO;
|
33
|
|
34
|
@Autowired
|
35
|
private SubscriberDAO subscriberDAO;
|
36
|
|
37
|
@Autowired
|
38
|
private PortalSubscribersDAO portalSubscribersDAO;
|
39
|
|
40
|
/*
|
41
|
|
42
|
@Test
|
43
|
public void createAllEntities() {
|
44
|
Map<String, String> entities = new HashMap<>();
|
45
|
entities.put("Publication", "publication");
|
46
|
entities.put("Research Data", "dataset");
|
47
|
entiites.put("Software", "software");
|
48
|
entities.put("Project", "project");
|
49
|
entities.put("Organization", "organization");
|
50
|
entities.put("Content Provider", "datasource");
|
51
|
|
52
|
for(entry<String, String> entr : entities.entrySet()) {
|
53
|
Entity entity = new Entity();
|
54
|
entity.setName(entr.getKey());
|
55
|
entity.setPid(entr.getValue());
|
56
|
entityDAO.save(entity);
|
57
|
}
|
58
|
}
|
59
|
|
60
|
@Test
|
61
|
public void createAllPages() {
|
62
|
String publication = entityDAO.findByPid("publication").getId();
|
63
|
String dataset = entityDAO.findByPid("dataset").getId();
|
64
|
String software = entityDAO.findByPid("software").getId();
|
65
|
String project = entityDAO.findByPid("project").getId();
|
66
|
String organization = entityDAO.findByPid("organization").getId();
|
67
|
String datasource = entityDAO.findByPid("datasource").getId();
|
68
|
|
69
|
|
70
|
Map<String, List<String>> pages = new HashMap<>();
|
71
|
pages.put("Search Publications", new ArrayList<>());
|
72
|
pages.get("Search Publications").add()
|
73
|
|
74
|
//entities.add("5a300ee4c97a7d2c000b9e9d"); // Publication
|
75
|
entities.add("5a319f8bc97a7d241ebddf75"); // Research Data
|
76
|
|
77
|
|
78
|
Page page = new Page();
|
79
|
page.setName("Search Research Data");
|
80
|
page.setRoute("/search/find/datasets");
|
81
|
page.setType("search");
|
82
|
page.setEntities(entities);
|
83
|
pageDAO.save(page);
|
84
|
}
|
85
|
|
86
|
|
87
|
|
88
|
@Test
|
89
|
public void deleteAllEntities() {
|
90
|
List<Entity> entities = entityDAO.findAll();
|
91
|
for(Entity entity : entities) {
|
92
|
entityDAO.delete(entity.getId());
|
93
|
}
|
94
|
}
|
95
|
|
96
|
@Test
|
97
|
public void deleteAllCommunities() {
|
98
|
List<Community> communities = communityDAO.findAll();
|
99
|
for(Community community : communities) {
|
100
|
communityDAO.delete(community.getId());
|
101
|
}
|
102
|
}
|
103
|
|
104
|
@Test
|
105
|
public void deleteAllPages() {
|
106
|
List<Page> pages = pageDAO.findAll();
|
107
|
for(Page page : pages) {
|
108
|
pageDAO.delete(page.getId());
|
109
|
}
|
110
|
}
|
111
|
|
112
|
@Test
|
113
|
public void deleteAllPageContents() {
|
114
|
List<PageHelpContent> pageHelpContents = pageHelpContentDAO.findAll();
|
115
|
for(PageHelpContent pageHelpContent : pageHelpContents) {
|
116
|
pageHelpContentDAO.delete(pageHelpContent.getId());
|
117
|
}
|
118
|
}
|
119
|
|
120
|
@Test
|
121
|
public void createEntity() {
|
122
|
Entity entity = new Entity();
|
123
|
entity.setName("Publication");
|
124
|
entityDAO.save(entity);
|
125
|
}
|
126
|
|
127
|
@Test
|
128
|
public void createPage() {
|
129
|
List<String> entities = new ArrayList<String>();
|
130
|
//entities.add("5a300ee4c97a7d2c000b9e9d"); // Publication
|
131
|
entities.add("5a319f8bc97a7d241ebddf75"); // Research Data
|
132
|
|
133
|
|
134
|
Page page = new Page();
|
135
|
page.setName("Search Research Data");
|
136
|
page.setRoute("/search/find/datasets");
|
137
|
page.setType("search");
|
138
|
page.setEntities(entities);
|
139
|
pageDAO.save(page);
|
140
|
}
|
141
|
|
142
|
@Test
|
143
|
public void createCommunity() {
|
144
|
Map<String, Boolean> entities = new HashMap<String, Boolean>();
|
145
|
//entities.put("5a300ee4c97a7d2c000b9e9d", true); // Publication
|
146
|
entities.put("5a319f8bc97a7d241ebddf75", false); // Research Data
|
147
|
//entities.put("5a3064f9c97a7d4964408ee0", false); // Software
|
148
|
//entities.put("5a30652ec97a7d4964408ee1", false); // Organization
|
149
|
//entities.put("5a306539c97a7d4964408ee2", false); // Project
|
150
|
//entities.put("5a30654dc97a7d4964408ee3", false); // Content Provider
|
151
|
|
152
|
Map<String, Boolean> pages = new HashMap<String, Boolean>();
|
153
|
//pages.put("5a30191ac97a7d3a7fa77362", true); // Search Publications
|
154
|
pages.put("5a31a4cac97a7d28468f0f5c", false); // Search Research Data
|
155
|
//pages.put("5a30657ac97a7d4964408ee4", false); // Search Software
|
156
|
//pages.put("5a30eeffc97a7d74234434ad", false); // Search Organizations
|
157
|
//pages.put("5a30efd9c97a7d7609b77ca5", false); // Search Projects
|
158
|
//pages.put("5a30f08bc97a7d7609b77ca7", false); // Search Content Providers
|
159
|
|
160
|
//pages.put("5a300f19c97a7d2c6e084b9f", false); // Test
|
161
|
|
162
|
Community community = new Community();
|
163
|
community.setName("Test Community");
|
164
|
community.setEntities(entities);
|
165
|
community.setPages(pages);
|
166
|
communityDAO.save(community);
|
167
|
}
|
168
|
*/
|
169
|
|
170
|
@Test
|
171
|
public void contextLoads() {
|
172
|
}
|
173
|
|
174
|
// @Test
|
175
|
// public void createStatistics() {
|
176
|
// statisticsDAO.deleteAll();
|
177
|
// List<Community> communities = communityDAO.findAll();
|
178
|
// for(Community c:communities){
|
179
|
//
|
180
|
// String pid = c.getPid();
|
181
|
// System.out.println("Community :" +pid);
|
182
|
// Statistics stats = statisticsDAO.findByPid(pid);
|
183
|
// if(stats == null){
|
184
|
// Statistics statistics = new Statistics(pid);
|
185
|
// statisticsDAO.save(statistics);
|
186
|
// System.out.println("Saved stats for :" +pid);
|
187
|
// }
|
188
|
// }
|
189
|
//
|
190
|
// }
|
191
|
|
192
|
// @Test
|
193
|
// public void deleteStatistics() {
|
194
|
// statisticsDAO.deleteAll();
|
195
|
// }
|
196
|
@Test
|
197
|
public void createCommunitySubscribers() {
|
198
|
|
199
|
// List<Community> communities = communityDAO.findAll();
|
200
|
// for(Community c:communities){
|
201
|
// String pid = c.getPid();
|
202
|
// System.out.println("Community :" +pid);
|
203
|
// PortalSubscribers communitySubscribers= portalSubscribersDAO.findByPid(pid);
|
204
|
// if(communitySubscribers == null){
|
205
|
// communitySubscribers = new PortalSubscribers(pid);
|
206
|
// portalSubscribersDAO.save(communitySubscribers);
|
207
|
// System.out.println("Saved community subscribers for :" +pid);
|
208
|
// }
|
209
|
// }
|
210
|
}
|
211
|
|
212
|
// @Test
|
213
|
// public void testPages() {
|
214
|
//
|
215
|
// System.out.println( pageDAO.findByConnect(false).size());
|
216
|
// for (Page p: pageDAO.findByConnect(false) ){
|
217
|
// System.out.println(p.getRoute()+" Con: "+p.getConnect()+" Op: "+p.getOpenaire());
|
218
|
// }
|
219
|
// }
|
220
|
|
221
|
}
|