Revision 58394
Added by Konstantina Galouni almost 4 years ago
NotificationsTests.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.uoaadmintools; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.uoaadmintools.dao.*; |
4 |
import eu.dnetlib.uoaadmintools.entities.Community; |
|
5 | 4 |
import eu.dnetlib.uoaadmintools.entities.Notifications; |
6 |
import eu.dnetlib.uoaadmintools.entities.Page; |
|
5 |
import eu.dnetlib.uoaadmintoolslibrary.dao.PortalDAO; |
|
6 |
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal; |
|
7 | 7 |
import org.junit.Test; |
8 | 8 |
import org.junit.runner.RunWith; |
9 | 9 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
17 | 17 |
public class NotificationsTests { |
18 | 18 |
|
19 | 19 |
@Autowired |
20 |
private CommunityDAO communityDAO;
|
|
20 |
private PortalDAO communityDAO;
|
|
21 | 21 |
|
22 | 22 |
|
23 | 23 |
@Autowired |
... | ... | |
27 | 27 |
public void test() { |
28 | 28 |
String mail = "sofie.mpl@gmail.com"; |
29 | 29 |
String id="ni"; |
30 |
System.out.println(notificationsDAO.findByCommunityPid(id));
|
|
30 |
System.out.println(notificationsDAO.findByPortalPid(id));
|
|
31 | 31 |
|
32 |
Notifications notifications = notificationsDAO.findByManagerEmailAndCommunityPid(mail , id);
|
|
32 |
Notifications notifications = notificationsDAO.findByManagerEmailAndPortalPid(mail , id);
|
|
33 | 33 |
if(notifications == null){ |
34 | 34 |
notifications = new Notifications(); |
35 |
notifications.setCommunityPid(id);
|
|
35 |
notifications.setPortalPid(id);
|
|
36 | 36 |
notifications.setManagerEmail(mail); |
37 | 37 |
} |
38 | 38 |
notifications.setNotifyForNewManagers(false); |
39 | 39 |
notifications.setNotifyForNewSubscribers(false); |
40 | 40 |
|
41 | 41 |
notificationsDAO.save(notifications); |
42 |
System.out.println(notificationsDAO.findByCommunityPid(id));
|
|
42 |
System.out.println(notificationsDAO.findByPortalPid(id));
|
|
43 | 43 |
|
44 | 44 |
|
45 | 45 |
|
... | ... | |
48 | 48 |
|
49 | 49 |
@Test |
50 | 50 |
public void remove() { |
51 |
List <Community> communities = communityDAO.findAll();
|
|
52 |
for(Community com : communities){
|
|
53 |
List <Notifications> notificationsList = notificationsDAO.findByCommunityPid(com.getPid());
|
|
51 |
List <Portal> communities = communityDAO.findAll();
|
|
52 |
for(Portal com : communities){
|
|
53 |
List <Notifications> notificationsList = notificationsDAO.findByPortalPid(com.getPid());
|
|
54 | 54 |
for(Notifications notifications:notificationsList){ |
55 | 55 |
// notificationsDAO.delete(notifications.getId()); |
56 | 56 |
} |
Also available in: Unified diff
[use-UoaAdminToolsLibrary | Admin Tools Service]:
REMINDER NOTE: change war name and properties (e.g. in MongoConfig.java) when merging to trunk.
1. Move MongoDBDAOs to folder /dao/MongoDBDAOs.
2. Move entities for Subscriber to folder /entities/subscriber.
3. Move entities for Curator to folder /entities/curator.
4. Add services for Layout, Statistics and Subscribers (to be called by controllers).
5. Rename "CommunitySubscribers" to "PortalSubscribers", "CommunitySubscribersController" to "PortalSubscribersController" and "CommunitySubscribersDAO" to "PortalSubscribersDAO".
6. Update all files to import appropriate files (from library or locally).
7. Create "ConnectController", "ExploreController" and update "CommunityController".
8. UoaAdminToolsApplication.java: scanBasePackages = {"eu.dnetlib.uoaadmintools", "eu.dnetlib.uoaadmintoolslibrary"}
9. MongoConnection.java: basePackages = {"eu.dnetlib.uoaadmintools.dao", "eu.dnetlib.uoaadmintoolslibrary.dao"}
10. Update update_db.js for changing db collections and entries according to new schema.