Revision 58394
Added by Konstantina Galouni about 4 years ago
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/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/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/dao/MongoDBDivIdDAO.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.dao; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaadmintools.entities.DivId; |
|
4 |
import org.springframework.data.mongodb.repository.MongoRepository; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
public interface MongoDBDivIdDAO extends DivIdDAO, MongoRepository<DivId, String> { |
|
9 |
List<DivId> findAll(); |
|
10 |
|
|
11 |
List<DivId> findByPagesContaining(String page); |
|
12 |
|
|
13 |
DivId findByPagesContainingAndName(String page, String name); |
|
14 |
DivId findByName(String name); |
|
15 |
|
|
16 |
DivId findById(String Id); |
|
17 |
|
|
18 |
List<DivId> findByConnect(boolean connect); |
|
19 |
List<DivId> findByCommunities(boolean communities); |
|
20 |
List<DivId> findByOpenaire(boolean openaire); |
|
21 |
|
|
22 |
DivId save(DivId divId); |
|
23 |
|
|
24 |
void deleteAll(); |
|
25 |
|
|
26 |
void delete(String id); |
|
27 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/dao/MongoDBCuratorDAO.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.dao; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaadmintools.entities.Curator; |
|
4 |
import org.springframework.data.mongodb.repository.MongoRepository; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
public interface MongoDBCuratorDAO extends CuratorDAO, MongoRepository<Curator, String> { |
|
9 |
|
|
10 |
List<Curator> findAll(); |
|
11 |
|
|
12 |
Curator findById(String Id); |
|
13 |
|
|
14 |
Curator findByEmail(String email); |
|
15 |
|
|
16 |
Curator save(Curator curator); |
|
17 |
|
|
18 |
void deleteAll(); |
|
19 |
|
|
20 |
void delete(String id); |
|
21 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/dao/MongoDBSubscriberDAO.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.dao; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaadmintools.entities.Subscriber; |
|
4 |
import org.springframework.data.mongodb.repository.MongoRepository; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
public interface MongoDBSubscriberDAO extends SubscriberDAO, MongoRepository<Subscriber, String> { |
|
9 |
|
|
10 |
List<Subscriber> findAll(); |
|
11 |
|
|
12 |
Subscriber findById(String Id); |
|
13 |
|
|
14 |
Subscriber findByEmail(String email); |
|
15 |
|
|
16 |
Subscriber save(Subscriber subscriber); |
|
17 |
|
|
18 |
void deleteAll(); |
|
19 |
|
|
20 |
void delete(String id); |
|
21 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/dao/MongoDBCommunitySubscribersDAO.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.dao; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaadmintools.entities.CommunitySubscribers; |
|
4 |
import org.springframework.data.mongodb.repository.MongoRepository; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
public interface MongoDBCommunitySubscribersDAO extends CommunitySubscribersDAO, MongoRepository<CommunitySubscribers, String> { |
|
9 |
|
|
10 |
List<CommunitySubscribers> findAll(); |
|
11 |
|
|
12 |
CommunitySubscribers findById(String Id); |
|
13 |
|
|
14 |
CommunitySubscribers findByPid(String Pid); |
|
15 |
|
|
16 |
CommunitySubscribers save(CommunitySubscribers communitySubscribers); |
|
17 |
|
|
18 |
void deleteAll(); |
|
19 |
|
|
20 |
void delete(String id); |
|
21 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/dao/MongoDBStatisticsDAO.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.dao; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics; |
|
4 |
import org.springframework.data.mongodb.repository.MongoRepository; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
public interface MongoDBStatisticsDAO extends StatisticsDAO, MongoRepository<Statistics, String> { |
|
9 |
List<Statistics> findAll(); |
|
10 |
|
|
11 |
Statistics findById(String Id); |
|
12 |
|
|
13 |
Statistics findByPid(String Pid); |
|
14 |
|
|
15 |
Statistics save(Statistics statistic); |
|
16 |
|
|
17 |
void deleteAll(); |
|
18 |
|
|
19 |
void delete(String id); |
|
20 |
} |
|
21 |
|
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/dao/CommunitySubscribersDAO.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.dao; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaadmintools.entities.CommunitySubscribers; |
|
4 |
|
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
public interface CommunitySubscribersDAO { |
|
9 |
|
|
10 |
List<CommunitySubscribers> findAll(); |
|
11 |
|
|
12 |
CommunitySubscribers findById(String Id); |
|
13 |
|
|
14 |
CommunitySubscribers findByPid(String Pid); |
|
15 |
|
|
16 |
CommunitySubscribers save(CommunitySubscribers communitySubscribers); |
|
17 |
|
|
18 |
void deleteAll(); |
|
19 |
|
|
20 |
void delete(String id); |
|
21 |
} |
|
22 |
|
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/dao/MongoDBLayoutDAO.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.dao; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaadmintools.entities.Layout; |
|
4 |
import org.springframework.data.mongodb.repository.MongoRepository; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
public interface MongoDBLayoutDAO extends LayoutDAO, MongoRepository<Layout, String> { |
|
9 |
|
|
10 |
List<Layout> findAll(); |
|
11 |
|
|
12 |
Layout findById(String Id); |
|
13 |
|
|
14 |
Layout save(Layout entity); |
|
15 |
|
|
16 |
void deleteAll(); |
|
17 |
|
|
18 |
void delete(String id); |
|
19 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/entities/CommunitySubscribers.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.entities; |
|
2 |
|
|
3 |
import com.fasterxml.jackson.annotation.JsonProperty; |
|
4 |
import org.springframework.data.annotation.Id; |
|
5 |
|
|
6 |
import java.util.ArrayList; |
|
7 |
import java.util.List; |
|
8 |
|
|
9 |
/** |
|
10 |
* Created by argirok on 2/3/2018. |
|
11 |
*/ |
|
12 |
public class CommunitySubscribers { |
|
13 |
@Id |
|
14 |
@JsonProperty("_id") |
|
15 |
private String id; |
|
16 |
private String pid; |
|
17 |
private List<Subscriber> subscribers = new ArrayList<Subscriber>(); |
|
18 |
private List<Subscriber> pendingSubscribers = new ArrayList<Subscriber>(); |
|
19 |
public CommunitySubscribers(String pid){ |
|
20 |
this.pid=pid; |
|
21 |
} |
|
22 |
public String getId() { |
|
23 |
return id; |
|
24 |
} |
|
25 |
|
|
26 |
public void setId(String id) { |
|
27 |
this.id = id; |
|
28 |
} |
|
29 |
|
|
30 |
public String getPid() { |
|
31 |
return pid; |
|
32 |
} |
|
33 |
|
|
34 |
public void setPid(String pid) { |
|
35 |
this.pid = pid; |
|
36 |
} |
|
37 |
|
|
38 |
public List<Subscriber> getSubscribers() { |
|
39 |
return subscribers; |
|
40 |
} |
|
41 |
|
|
42 |
public void setSubscribers(List<Subscriber> subscribers) { |
|
43 |
this.subscribers = subscribers; |
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public String toString() { |
|
48 |
return "CommunitySubscribers{" + |
|
49 |
"id='" + id + '\'' + |
|
50 |
", pid='" + pid + '\'' + |
|
51 |
", subscribers=" + subscribers + |
|
52 |
'}'; |
|
53 |
} |
|
54 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/entities/CuratorResponse.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.entities; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
public class CuratorResponse { |
|
6 |
|
|
7 |
private String email; |
|
8 |
private String name; |
|
9 |
private List<Affiliation> affiliations; |
|
10 |
private String photo; |
|
11 |
private String bio; |
|
12 |
|
|
13 |
public CuratorResponse() { |
|
14 |
} |
|
15 |
|
|
16 |
public CuratorResponse(Curator curator) { |
|
17 |
this.email = curator.getEmail(); |
|
18 |
this.name = curator.getName(); |
|
19 |
this.affiliations = curator.getAffiliations(); |
|
20 |
this.photo = curator.getPhoto(); |
|
21 |
this.bio = curator.getBio(); |
|
22 |
} |
|
23 |
|
|
24 |
public String getEmail() { |
|
25 |
return email; |
|
26 |
} |
|
27 |
|
|
28 |
public void setEmail(String email) { |
|
29 |
this.email = email; |
|
30 |
} |
|
31 |
|
|
32 |
public String getName() { |
|
33 |
return name; |
|
34 |
} |
|
35 |
|
|
36 |
public void setName(String name) { |
|
37 |
this.name = name; |
|
38 |
} |
|
39 |
|
|
40 |
public List<Affiliation> getAffiliations() { |
|
41 |
return affiliations; |
|
42 |
} |
|
43 |
|
|
44 |
public void setAffiliation(List<Affiliation> affiliations) { |
|
45 |
this.affiliations = affiliations; |
|
46 |
} |
|
47 |
|
|
48 |
public String getPhoto() { |
|
49 |
return photo; |
|
50 |
} |
|
51 |
|
|
52 |
public void setPhoto(String photo) { |
|
53 |
this.photo = photo; |
|
54 |
} |
|
55 |
|
|
56 |
public String getBio() { |
|
57 |
return bio; |
|
58 |
} |
|
59 |
|
|
60 |
public void setBio(String bio) { |
|
61 |
this.bio = bio; |
|
62 |
} |
|
63 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/entities/Curator.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.entities; |
|
2 |
|
|
3 |
import com.fasterxml.jackson.annotation.JsonProperty; |
|
4 |
import org.springframework.data.annotation.Id; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
public class Curator { |
|
9 |
|
|
10 |
@Id |
|
11 |
@JsonProperty("_id") |
|
12 |
private String id; |
|
13 |
private String email; |
|
14 |
private String name; |
|
15 |
private List<Affiliation> affiliations; |
|
16 |
private String photo; |
|
17 |
private String bio; |
|
18 |
|
|
19 |
public Curator() { |
|
20 |
} |
|
21 |
|
|
22 |
public String getId() { |
|
23 |
return id; |
|
24 |
} |
|
25 |
|
|
26 |
public void setId(String id) { |
|
27 |
this.id = id; |
|
28 |
} |
|
29 |
|
|
30 |
public String getEmail() { |
|
31 |
return email; |
|
32 |
} |
|
33 |
|
|
34 |
public void setEmail(String email) { |
|
35 |
this.email = email; |
|
36 |
} |
|
37 |
|
|
38 |
public String getName() { |
|
39 |
return name; |
|
40 |
} |
|
41 |
|
|
42 |
public void setName(String name) { |
|
43 |
this.name = name; |
|
44 |
} |
|
45 |
|
|
46 |
public List<Affiliation> getAffiliations() { |
|
47 |
return affiliations; |
|
48 |
} |
|
49 |
|
|
50 |
public void setAffiliation(List<Affiliation> affiliations) { |
|
51 |
this.affiliations = affiliations; |
|
52 |
} |
|
53 |
|
|
54 |
public String getPhoto() { |
|
55 |
return photo; |
|
56 |
} |
|
57 |
|
|
58 |
public void setPhoto(String photo) { |
|
59 |
this.photo = photo; |
|
60 |
} |
|
61 |
|
|
62 |
public String getBio() { |
|
63 |
return bio; |
|
64 |
} |
|
65 |
|
|
66 |
public void setBio(String bio) { |
|
67 |
this.bio = bio; |
|
68 |
} |
|
69 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/entities/Subscriber.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.entities; |
|
2 |
|
|
3 |
import com.fasterxml.jackson.annotation.JsonProperty; |
|
4 |
import org.springframework.data.annotation.Id; |
|
5 |
|
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
/** |
|
9 |
* Created by argirok on 2/3/2018. |
|
10 |
*/ |
|
11 |
public class Subscriber { |
|
12 |
@Id |
|
13 |
@JsonProperty("_id") |
|
14 |
private String id; |
|
15 |
|
|
16 |
private String email; |
|
17 |
|
|
18 |
public String getId() { |
|
19 |
return id; |
|
20 |
} |
|
21 |
|
|
22 |
public void setId(String id) { |
|
23 |
this.id = id; |
|
24 |
} |
|
25 |
|
|
26 |
public String getEmail() { |
|
27 |
return email; |
|
28 |
} |
|
29 |
|
|
30 |
public void setEmail(String email) { |
|
31 |
this.email = email; |
|
32 |
} |
|
33 |
|
|
34 |
@Override |
|
35 |
public String toString() { |
|
36 |
return "Subscriber{" + |
|
37 |
"id='" + id + '\'' + |
|
38 |
", email='" + email + '\'' + |
|
39 |
'}'; |
|
40 |
} |
|
41 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/controllers/CommunitySubscribersController.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.controllers; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaadmintools.dao.CommunityDAO; |
|
4 |
import eu.dnetlib.uoaadmintools.dao.CommunitySubscribersDAO; |
|
5 |
import eu.dnetlib.uoaadmintools.dao.SubscriberDAO; |
|
6 |
import eu.dnetlib.uoaadmintools.entities.Community; |
|
7 |
import eu.dnetlib.uoaadmintools.entities.CommunitySubscribers; |
|
8 |
import eu.dnetlib.uoaadmintools.entities.Subscriber; |
|
9 |
import eu.dnetlib.uoaadmintools.handlers.ContentNotFoundException; |
|
10 |
import org.apache.log4j.Logger; |
|
11 |
import org.springframework.beans.factory.annotation.Autowired; |
|
12 |
import org.springframework.web.bind.annotation.*; |
|
13 |
|
|
14 |
import java.util.ArrayList; |
|
15 |
import java.util.List; |
|
16 |
|
|
17 |
/** |
|
18 |
* Created by argirok on 2/3/2018. |
|
19 |
*/ |
|
20 |
@RestController |
|
21 |
@CrossOrigin(origins = "*") |
|
22 |
public class CommunitySubscribersController { |
|
23 |
@Autowired |
|
24 |
CommunitySubscribersDAO communitySubscriberDAO; |
|
25 |
@Autowired |
|
26 |
SubscriberDAO subscriberDAO; |
|
27 |
@Autowired |
|
28 |
CommunityDAO communityDAO; |
|
29 |
|
|
30 |
private final Logger log = Logger.getLogger(this.getClass()); |
|
31 |
@RequestMapping(value = "/community/subscribers", method = RequestMethod.GET) |
|
32 |
public List<CommunitySubscribers> getAllCommunitySubscribers(){ |
|
33 |
return communitySubscriberDAO.findAll(); |
|
34 |
} |
|
35 |
@RequestMapping(value = "/community/{pid}/subscribers", method = RequestMethod.GET) |
|
36 |
public CommunitySubscribers getSubscribersPerCommunity(@PathVariable(value="pid", required = true) String pid) throws ContentNotFoundException { |
|
37 |
CommunitySubscribers communitySubscribers = communitySubscriberDAO.findByPid(pid); |
|
38 |
if(communitySubscribers != null){ |
|
39 |
return communitySubscribers; |
|
40 |
}else{ |
|
41 |
throw new ContentNotFoundException("Community Subscribers not found"); |
|
42 |
|
|
43 |
} |
|
44 |
|
|
45 |
} |
|
46 |
@RequestMapping(value = "/community/{pid}/subscribers", method = RequestMethod.POST) |
|
47 |
public CommunitySubscribers addSubscriberInCommunity(@PathVariable(value="pid", required = true) String pid, @RequestBody Subscriber subscriber) throws ContentNotFoundException { |
|
48 |
CommunitySubscribers communitySubscribers = communitySubscriberDAO.findByPid(pid); |
|
49 |
if(communitySubscribers == null){ |
|
50 |
throw new ContentNotFoundException("Community Subscribers not found"); |
|
51 |
} |
|
52 |
|
|
53 |
Subscriber savedSubscriber = subscriberDAO.findByEmail(subscriber.getEmail()); |
|
54 |
if(savedSubscriber==null){ |
|
55 |
savedSubscriber = subscriberDAO.save(subscriber); |
|
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 |
|
64 |
communitySubscribers.getSubscribers().add(savedSubscriber); |
|
65 |
return communitySubscriberDAO.save(communitySubscribers); |
|
66 |
|
|
67 |
} |
|
68 |
@RequestMapping(value = "/community/{pid}/subscribers/delete", method = RequestMethod.POST) |
|
69 |
public CommunitySubscribers deleteSubscriberFromCommunity(@PathVariable(value="pid", required = true) String pid, @RequestBody List<String> emails) throws ContentNotFoundException { |
|
70 |
CommunitySubscribers communitySubscribers = communitySubscriberDAO.findByPid(pid); |
|
71 |
if(communitySubscribers == null){ |
|
72 |
throw new ContentNotFoundException("Community Subscribers not found"); |
|
73 |
} |
|
74 |
List<Subscriber> list = new ArrayList<>(); |
|
75 |
for(Subscriber s:communitySubscribers.getSubscribers()){ |
|
76 |
if(emails.indexOf(s.getEmail())==-1){ |
|
77 |
list.add(s); |
|
78 |
} |
|
79 |
} |
|
80 |
communitySubscribers.setSubscribers(list); |
|
81 |
return communitySubscriberDAO.save(communitySubscribers); |
|
82 |
} |
|
83 |
|
|
84 |
@RequestMapping(value = "/subscriber/communities", method = RequestMethod.GET) |
|
85 |
public List<String> getCommunitiesPerSubcriber(@RequestParam(value="email", required = true) String email) { |
|
86 |
List<CommunitySubscribers> communitySubscribers = communitySubscriberDAO.findAll(); |
|
87 |
List<String> list = new ArrayList<>(); |
|
88 |
for(CommunitySubscribers s:communitySubscribers){ |
|
89 |
for(Subscriber sub:s.getSubscribers()) { |
|
90 |
if (sub.getEmail().equals(email)) { |
|
91 |
list.add(s.getPid()); |
|
92 |
break; |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
96 |
return list; |
|
97 |
} |
|
98 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/controllers/DivIdController.java | ||
---|---|---|
1 |
package eu.dnetlib.uoaadmintools.controllers; |
|
2 |
|
|
3 |
import eu.dnetlib.uoaadmintools.dao.CommunityDAO; |
|
4 |
import eu.dnetlib.uoaadmintools.dao.DivIdDAO; |
|
5 |
import eu.dnetlib.uoaadmintools.dao.MongoDBCommunityDAO; |
|
6 |
import eu.dnetlib.uoaadmintools.dao.PageDAO; |
|
7 |
import eu.dnetlib.uoaadmintools.entities.*; |
|
8 |
import org.apache.log4j.Logger; |
|
9 |
import org.springframework.beans.factory.annotation.Autowired; |
|
10 |
import org.springframework.web.bind.annotation.*; |
|
11 |
|
|
12 |
import java.util.*; |
|
13 |
|
|
14 |
@RestController |
|
15 |
@CrossOrigin(origins = "*") |
|
16 |
public class DivIdController { |
|
17 |
private final Logger log = Logger.getLogger(this.getClass()); |
|
18 |
|
|
19 |
@Autowired |
|
20 |
private DivIdDAO divIdDAO; |
|
21 |
|
|
22 |
@Autowired |
|
23 |
private PageDAO pageDAO; |
|
24 |
|
|
25 |
@Autowired |
|
26 |
private CommunityController communityController; |
|
27 |
|
|
28 |
@Autowired |
|
29 |
private DivHelpContentController divHelpContentController; |
|
30 |
|
|
31 |
DivIdController() {} |
|
32 |
|
|
33 |
@RequestMapping(value = "/div", method = RequestMethod.GET) |
|
34 |
public List<DivId> getDivIds(@RequestParam(required = false) String page, |
|
35 |
@RequestParam(required = false) String name, |
|
36 |
@RequestParam(value = "communityId", required = false) String pid) { |
|
37 |
List<DivId> divIds = null; |
|
38 |
|
|
39 |
if(page != null && name != null) { |
|
40 |
DivId divId = divIdDAO.findByPagesContainingAndName(page, name); |
|
41 |
if(divId != null) { |
|
42 |
divIds = new ArrayList<>(); |
|
43 |
divIds.add(divId); |
|
44 |
} |
|
45 |
} else if(page != null) { |
|
46 |
divIds = divIdDAO.findByPagesContaining(page); |
|
47 |
} else if(name != null) { |
|
48 |
DivId divId = divIdDAO.findByName(name); |
|
49 |
if(divId != null) { |
|
50 |
divIds = new ArrayList<>(); |
|
51 |
divIds.add(divId); |
|
52 |
} |
|
53 |
} else { |
|
54 |
divIds = divIdDAO.findAll(); |
|
55 |
} |
|
56 |
|
|
57 |
if(pid != null) { |
|
58 |
Iterator<DivId> iteratorDivIds = divIds.iterator(); |
|
59 |
while(iteratorDivIds.hasNext()) { |
|
60 |
DivId divId = iteratorDivIds.next(); |
|
61 |
if (pid.equals("openaire") && !divId.getOpenaire()) { |
|
62 |
iteratorDivIds.remove(); |
|
63 |
} else if (pid.equals("connect") && !divId.getConnect()) { |
|
64 |
iteratorDivIds.remove(); |
|
65 |
} else if(!pid.equals("openaire") && !pid.equals("connect") && !divId.getCommunities()){ |
|
66 |
iteratorDivIds.remove(); |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
return divIds; |
|
72 |
} |
|
73 |
|
|
74 |
@RequestMapping(value = "/divFull", method = RequestMethod.GET) |
|
75 |
public List<DivIdResponse> getDivIdsFull(@RequestParam(required = false) String page, |
|
76 |
@RequestParam(required = false) String name, |
|
77 |
@RequestParam(value="communityId", required = false) String pid) { |
|
78 |
|
|
79 |
List<DivId> divIds = this.getDivIds(page, name, pid); |
|
80 |
|
|
81 |
List<DivIdResponse> divIdResponses = new ArrayList<>(); |
|
82 |
for(DivId divId : divIds) { |
|
83 |
DivIdResponse divIdResponse = new DivIdResponse(divId); |
|
84 |
List<Page> pages = new ArrayList<>(); |
|
85 |
for(String pageId : divId.getPages()) { |
|
86 |
pages.add(pageDAO.findById(pageId)); |
|
87 |
} |
|
88 |
divIdResponse.setPages(pages); |
|
89 |
|
|
90 |
divIdResponses.add(divIdResponse); |
|
91 |
} |
|
92 |
|
|
93 |
return divIdResponses; |
|
94 |
} |
|
95 |
|
|
96 |
@RequestMapping(value = "/div/{id}", method = RequestMethod.GET) |
|
97 |
public DivId getDivId(@PathVariable(value = "id") String id) { |
|
98 |
return divIdDAO.findById(id); |
|
99 |
} |
|
100 |
|
|
101 |
@RequestMapping(value = "/divFull/{id}", method = RequestMethod.GET) |
|
102 |
public DivIdResponse getDivIdFull(@PathVariable(value = "id") String id) { |
|
103 |
DivId divId = divIdDAO.findById(id); |
|
104 |
return divIdResponseFromDivId(divId); |
|
105 |
} |
|
106 |
|
|
107 |
public DivIdResponse divIdResponseFromDivId(DivId divId) { |
|
108 |
DivIdResponse divIdResponse = new DivIdResponse(divId); |
|
109 |
List<Page> pages = new ArrayList<>(); |
|
110 |
for(String pageId : divId.getPages()) { |
|
111 |
pages.add(pageDAO.findById(pageId)); |
|
112 |
} |
|
113 |
divIdResponse.setPages(pages); |
|
114 |
return divIdResponse; |
|
115 |
} |
|
116 |
|
|
117 |
@RequestMapping(value = "/div", method = RequestMethod.DELETE) |
|
118 |
public void deleteAllDivIds() { |
|
119 |
divIdDAO.deleteAll(); |
|
120 |
} |
|
121 |
|
|
122 |
@RequestMapping(value = "/div/save", method = RequestMethod.POST) |
|
123 |
public DivIdResponse insertDivId(@RequestBody DivIdResponse divIdResponse) { |
|
124 |
DivId divId = this.getDivIdByDivIdResponse(divIdResponse); |
|
125 |
|
|
126 |
DivId savedDivId = divIdDAO.save(divId); |
|
127 |
divIdResponse.setId(savedDivId.getId()); |
|
128 |
|
|
129 |
return this.getDivIdFull(divId.getId()); |
|
130 |
} |
|
131 |
|
|
132 |
private DivId getDivIdByDivIdResponse(DivIdResponse divIdResponse) { |
|
133 |
DivId divId = new DivId(); |
|
134 |
divId.setId(divIdResponse.getId()); |
|
135 |
divId.setName(divIdResponse.getName()); |
|
136 |
divId.setOpenaire(divIdResponse.getOpenaire()); |
|
137 |
divId.setConnect(divIdResponse.getConnect()); |
|
138 |
divId.setCommunities(divIdResponse.getCommunities()); |
|
139 |
|
|
140 |
List<Page> fullPages = divIdResponse.getPages(); |
|
141 |
List<String> pages = new ArrayList<String>(); |
|
142 |
for(Page page : fullPages) { |
|
143 |
pages.add(page.getId()); |
|
144 |
} |
|
145 |
divId.setPages(pages); |
|
146 |
|
|
147 |
return divId; |
|
148 |
} |
|
149 |
|
|
150 |
@RequestMapping(value = "/div/update", method = RequestMethod.POST) |
|
151 |
public DivIdResponse updateDivId(@RequestBody DivIdResponse divIdResponse) { |
|
152 |
/* |
|
153 |
DivId divId = divIdDAO.findById(_divId.getId()); |
|
154 |
divId.setName(_divId.getName()); |
|
155 |
divId.setPages(_divId.getPages()); |
|
156 |
divIdDAO.save(divId); |
|
157 |
return this.getDivIdFull(divId.getId()); |
|
158 |
*/ |
|
159 |
DivId divIdOld = divIdDAO.findById(divIdResponse.getId()); |
|
160 |
DivId divId = this.getDivIdByDivIdResponse(divIdResponse); |
|
161 |
divIdDAO.save(divId); |
|
162 |
|
|
163 |
boolean openaireEnabled = divId.getOpenaire(); |
|
164 |
boolean connectEnabled = divId.getConnect(); |
|
165 |
|
|
166 |
if(divId.getCommunities() && !divIdOld.getCommunities()) { |
|
167 |
List<Community> communities = communityController.getAllCommunities(); |
|
168 |
for( Community community : communities ) { |
|
169 |
if(!community.getPid().equals("openaire") && !community.getPid().equals("connect")) { |
|
170 |
divHelpContentController.addDivHelpContentsInCommunity(community.getPid(), community.getId(), divId.getName()); |
|
171 |
} |
|
172 |
} |
|
173 |
} |
|
174 |
if(openaireEnabled && !divIdOld.getOpenaire()) { |
|
175 |
Community community = communityController.getCommunity("openaire"); |
|
176 |
divHelpContentController.addDivHelpContentsInCommunity(community.getPid(), community.getId(), divId.getName()); |
|
177 |
} |
|
178 |
|
|
179 |
if(connectEnabled && !divIdOld.getConnect()) { |
|
180 |
Community community = communityController.getCommunity("connect"); |
|
181 |
divHelpContentController.addDivHelpContentsInCommunity(community.getPid(), community.getId(), divId.getName()); |
|
182 |
} |
|
183 |
|
|
184 |
if(!divId.getCommunities()) { |
|
185 |
List<Community> communities = communityController.getAllCommunities(); |
|
186 |
for( Community community : communities ) { |
|
187 |
if(!community.getPid().equals("openaire") && !community.getPid().equals("connect")) { |
|
188 |
// delete div contents related to this divId |
|
189 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(community.getPid(), null, divId.getName(), null); |
|
190 |
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) { |
|
191 |
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId()); |
|
192 |
} |
|
193 |
} |
|
194 |
} |
|
195 |
} |
|
196 |
|
|
197 |
if(!openaireEnabled) { |
|
198 |
Community community = communityController.getCommunity("openaire"); |
|
199 |
|
|
200 |
// delete div contents related to this divId |
|
201 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents("openaire", null, divId.getName(), null); |
|
202 |
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) { |
|
203 |
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId()); |
|
204 |
} |
|
205 |
} |
|
206 |
|
|
207 |
if(!connectEnabled) { |
|
208 |
Community community = communityController.getCommunity("connect"); |
|
209 |
|
|
210 |
// delete div contents related to this divId |
|
211 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents("connect", null, divId.getName(), null); |
|
212 |
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) { |
|
213 |
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId()); |
|
214 |
} |
|
215 |
} |
|
216 |
|
|
217 |
return divIdResponse; |
|
218 |
} |
|
219 |
|
|
220 |
@RequestMapping(value = "/div/delete", method = RequestMethod.POST) |
|
221 |
public Boolean deleteDivIds(@RequestBody List<String> divIds) throws Exception { |
|
222 |
for (String id: divIds) { |
|
223 |
DivId divId = divIdDAO.findById(id); |
|
224 |
|
|
225 |
// delete div contents related to this divId |
|
226 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(null, null, divId.getName(), null); |
|
227 |
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) { |
|
228 |
divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId()); |
|
229 |
} |
|
230 |
|
|
231 |
divIdDAO.delete(id); |
|
232 |
} |
|
233 |
return true; |
|
234 |
} |
|
235 |
|
|
236 |
@RequestMapping(value = "/div/{id}", method = RequestMethod.DELETE) |
|
237 |
public void deleteDivId(@PathVariable(value = "id") String id) { |
|
238 |
divIdDAO.delete(id); |
|
239 |
} |
|
240 |
|
|
241 |
@RequestMapping(value = "/div/pages", method = RequestMethod.GET) |
|
242 |
public Set<String> getDivIdsPages(@RequestParam(value="communityId", required = false) String pid) { |
|
243 |
List<DivId> divIds = null; |
|
244 |
Set<String> hasCommunityPageDivIds = new HashSet<>(); |
|
245 |
|
|
246 |
if(pid != null) { |
|
247 |
if(pid.equals("openaire")) { |
|
248 |
divIds = divIdDAO.findByOpenaire(true); |
|
249 |
} else if(pid.equals("connect")) { |
|
250 |
divIds = divIdDAO.findByConnect(true); |
|
251 |
} else { |
|
252 |
divIds = divIdDAO.findByCommunities(true); |
|
253 |
} |
|
254 |
} else { |
|
255 |
divIds = divIdDAO.findAll(); |
|
256 |
} |
|
257 |
|
|
258 |
for(DivId divId : divIds) { |
|
259 |
for(String pageId : divId.getPages()) { |
|
260 |
hasCommunityPageDivIds.add(pageId); |
|
261 |
} |
|
262 |
} |
|
263 |
return hasCommunityPageDivIds; |
|
264 |
} |
|
265 |
|
|
266 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/update_db.js | ||
---|---|---|
1429 | 1429 |
softwareId = db.entity.find( { pid: "software" }).map( function(entity) { return entity._id.str; } ).toString() |
1430 | 1430 |
orpId = db.entity.find( { pid: "orp" }).map( function(entity) { return entity._id.str; } ).toString(); |
1431 | 1431 |
|
1432 |
searchResearchOutcomesId = db.page.insertOne({"name" : "Search Research Outcomes", "route" : "/search/find/research-outcomes", "type" : "search", "connect":false,"openaire":true, "communities": true, "entities" : [publicationId, datasetId, softwareId, orpId]}).insertedId.str; |
|
1433 |
avancedSearchResearchOutcomesId = db.page.insertOne({"name" : "Advanced Search Research Outcomes", "route" : "/search/advanced/research-outcomes", "type" : "search", "connect":false,"openaire":true, "communities": true, "entities" : [publicationId, datasetId, softwareId, orpId]}).insertedId.str; |
|
1432 |
searchResearchOutcomesId = db.page.insertOne({"name" : "Search Research Outcomes", "route" : "/search/find/research-outcomes", "type" : "search", "connect":false,"openaire":true, "communities": true, "entities" : [publicationId, datasetId, softwareId, orpId], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str;
|
|
1433 |
avancedSearchResearchOutcomesId = db.page.insertOne({"name" : "Advanced Search Research Outcomes", "route" : "/search/advanced/research-outcomes", "type" : "search", "connect":false,"openaire":true, "communities": true, "entities" : [publicationId, datasetId, softwareId, orpId], "top":true,"bottom":false,"right":false,"left":false}).insertedId.str;
|
|
1434 | 1434 |
|
1435 | 1435 |
print("Creating Search Research Outcomes page with id " + searchResearchOutcomesId); |
1436 | 1436 |
print("Creating Advanced Search Research Outcomes page with id " + avancedSearchResearchOutcomesId); |
1437 | 1437 |
|
1438 | 1438 |
communities = db.community.find().map( function(community) { return community; } ); |
1439 | 1439 |
for (var i = 0; i < communities.length; i++) { |
1440 |
community_pages = communities[i].pages;
|
|
1440 |
community_pages = communities[i].pages; |
|
1441 | 1441 |
|
1442 |
community_pages[searchResearchOutcomesId] = true;
|
|
1443 |
community_pages[avancedSearchResearchOutcomesId] = true;
|
|
1442 |
community_pages[searchResearchOutcomesId] = true; |
|
1443 |
community_pages[avancedSearchResearchOutcomesId] = true; |
|
1444 | 1444 |
|
1445 |
community_pid = communities[i].pid;
|
|
1446 |
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}});
|
|
1447 |
print("Add Search Research Outcomes page with id " + searchResearchOutcomesId + " on community " + community_pid);
|
|
1448 |
print("Add Advanced Search Research Outcomes page with id " + avancedSearchResearchOutcomesId + " on community " + community_pid);
|
|
1445 |
community_pid = communities[i].pid; |
|
1446 |
db.community.update({ "pid" : community_pid },{$set: { "pages": community_pages}}); |
|
1447 |
print("Add Search Research Outcomes page with id " + searchResearchOutcomesId + " on community " + community_pid); |
|
1448 |
print("Add Advanced Search Research Outcomes page with id " + avancedSearchResearchOutcomesId + " on community " + community_pid); |
|
1449 | 1449 |
} |
1450 | 1450 |
} |
1451 | 1451 |
|
1452 |
use openaire_admin; |
|
1452 |
function addPortalType() { |
|
1453 |
communities = db.community.find().map( function(community) { return community; } ); |
|
1454 |
for (var i = 0; i < communities.length; i++) { |
|
1455 |
community = communities[i]; |
|
1456 |
if(community.pid == "openaire") { |
|
1457 |
community['type'] = "explore"; |
|
1458 |
} else if(community.pid == "connect") { |
|
1459 |
community['type'] = "connect"; |
|
1460 |
} else { |
|
1461 |
community['type'] = "community"; |
|
1462 |
} |
|
1463 |
db.community.save(community); |
|
1464 |
} |
|
1465 |
} |
|
1453 | 1466 |
|
1467 |
function createPagesForEachPortalType() { |
|
1468 |
pages = db.page.find().map( function(page) { return page; } ); |
|
1469 |
for (var i = 0; i < pages.length; i++) { |
|
1470 |
page = pages[i]; |
|
1471 |
|
|
1472 |
print("createPagesForEachPortalType: page["+i+"] = "+page.name + " ( "+page._id.str+" ) -> openaire: "+page.openaire+" - connect: "+page.connect + " - communities: "+page.communities); |
|
1473 |
|
|
1474 |
if(page.openaire == false) { // do not include this page in portal profile |
|
1475 |
communityOpenaire = db.community.findOne({pid: "openaire"}); |
|
1476 |
removePageFromPortal(communityOpenaire, page._id, communityOpenaire.pages); |
|
1477 |
} |
|
1478 |
if(page.connect == false) { // do not include this page in portal profile |
|
1479 |
communityConnect = db.community.findOne({pid: "connect"}); |
|
1480 |
removePageFromPortal(communityConnect, page._id, communityConnect.pages); |
|
1481 |
} |
|
1482 |
if(page.communities == false) { |
|
1483 |
communities = db.community.find({ "type" : "community" }).map( function(community) { return community; } ); |
|
1484 |
for (var j = 0; j < communities.length; j++) { |
|
1485 |
removePageFromPortal(communities[j], page._id, communities[j].pages); |
|
1486 |
} |
|
1487 |
} |
|
1488 |
|
|
1489 |
if(page.openaire == true && page.connect == true && page.communities == true) { |
|
1490 |
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "community", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left}); |
|
1491 |
print("Keep for communities"); |
|
1492 |
|
|
1493 |
createAndUpdatePageAndContentsForPortal(page, "openaire", "explore"); |
|
1494 |
//print("Delete and create other for explore"); |
|
1495 |
|
|
1496 |
createAndUpdatePageAndContentsForPortal(page, "connect", "connect"); |
|
1497 |
//print("Delete and create other for connect"); |
|
1498 |
|
|
1499 |
} else if(page.openaire == true && page.connect == true) { |
|
1500 |
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "connect", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left}); |
|
1501 |
print("Keep for connect"); |
|
1502 |
|
|
1503 |
createAndUpdatePageAndContentsForPortal(page, "openaire", "explore"); |
|
1504 |
//print("Delete and create other for explore"); |
|
1505 |
|
|
1506 |
} else if(page.openaire == true && page.communities == true) { |
|
1507 |
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "community", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left}); |
|
1508 |
print("Keep for community"); |
|
1509 |
|
|
1510 |
createAndUpdatePageAndContentsForPortal(page, "openaire", "explore"); |
|
1511 |
//print("Delete and create other for explore"); |
|
1512 |
|
|
1513 |
} else if(page.connect == true && page.communities == true) { |
|
1514 |
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "community", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left}); |
|
1515 |
print("Keep for community"); |
|
1516 |
|
|
1517 |
createAndUpdatePageAndContentsForPortal(page, "connect", "connect"); |
|
1518 |
//print("Delete and create other for connect"); |
|
1519 |
|
|
1520 |
} else if(page.openaire == true) { |
|
1521 |
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "explore", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left}); |
|
1522 |
print("Keep for explore"); |
|
1523 |
|
|
1524 |
} else if(page.connect == true) { |
|
1525 |
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "connect", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left}); |
|
1526 |
print("Keep for connect"); |
|
1527 |
|
|
1528 |
} else if(page.communities == true) { |
|
1529 |
db.page.save({"_id": page._id, "name" : page.name, "route" : page.route, "type" : page.type, "portalType": "community", "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left}); |
|
1530 |
print("Keep for community"); |
|
1531 |
|
|
1532 |
} |
|
1533 |
} |
|
1534 |
} |
|
1535 |
|
|
1536 |
function createAndUpdatePageAndContentsForPortal(page, pid, portalType) { |
|
1537 |
db.page.save({"name" : page.name, "route" : page.route, "type" : page.type, "portalType": portalType, "entities" : page.entities, "top":page.top, "bottom":page.bottom, "right":page.right,"left":page.left}); |
|
1538 |
pageIdForPortalType = db.page.find({portalType: portalType, "route" : page.route}).map(function (page) { return page._id.str; }).toString(); |
|
1539 |
print("portalType: "+ portalType + " --> new page id: "+ pageIdForPortalType); |
|
1540 |
|
|
1541 |
community = db.community.findOne({pid: pid}); |
|
1542 |
|
|
1543 |
community_pages = community.pages; |
|
1544 |
community_pages[pageIdForPortalType] = community_pages[page._id.str]; |
|
1545 |
removePageFromPortal(community, page._id, community_pages); |
|
1546 |
if(portalType == "explore") { |
|
1547 |
print(" Delete page: "+page._id.str + " = (should be null) "+community.pages[page._id.str] |
|
1548 |
+ " - new page: "+pageIdForPortalType+" = "+community.pages[pageIdForPortalType]); |
|
1549 |
} |
|
1550 |
|
|
1551 |
updatePageHelpContentsForPortalPage(page._id.str, pageIdForPortalType, community._id.str); |
|
1552 |
} |
|
1553 |
|
|
1554 |
function removePageFromPortal(community, pageId, community_pages) { |
|
1555 |
//community_pages = community.pages; |
|
1556 |
//print(community.name+": Delete page: "+pageId.str); |
|
1557 |
delete community_pages[pageId.str]; |
|
1558 |
db.community.update({"pid": community.pid}, {$set: {"pages": community_pages}}); |
|
1559 |
} |
|
1560 |
|
|
1561 |
function updatePageHelpContentsForPortalPage(pageId, newPageId, communityId) { |
|
1562 |
pageHelpContents = db.pageHelpContent.find({"page" : pageId, "community" : communityId,}).map( function(pageHelpContent) { return pageHelpContent; } ); |
|
1563 |
for (var i = 0; i < pageHelpContents.length; i++) { |
|
1564 |
pageHelpContent = pageHelpContents[i]; |
|
1565 |
db.pageHelpContent.save({ |
|
1566 |
"_id": pageHelpContent._id, |
|
1567 |
"page": newPageId, |
|
1568 |
"community": communityId, |
|
1569 |
"placement": pageHelpContent.placement, |
|
1570 |
"order": pageHelpContent.order, |
|
1571 |
"content": pageHelpContent.content, |
|
1572 |
"isActive": pageHelpContent.isActive, |
|
1573 |
"isPriorTo": pageHelpContent.isPriorTo |
|
1574 |
}); |
|
1575 |
} |
|
1576 |
} |
|
1577 |
|
|
1578 |
function createDivIdsForEachPortalType() { |
|
1579 |
divIds = db.divId.find().map( function(divId) { return divId; } ); |
|
1580 |
for (var i = 0; i < divIds.length; i++) { |
|
1581 |
divId = divIds[i]; |
|
1582 |
|
|
1583 |
print("createDivIdsForEachPortalType: divId["+i+"] = "+divId.name + " -> openaire: "+divId.openaire+" - connect: "+divId.connect + " - communities: "+divId.communities); |
|
1584 |
|
|
1585 |
if(divId.openaire == true && divId.connect == true && divId.communities == true) { |
|
1586 |
//var pages = updateDivIdPages(divId.pages, "community"); |
|
1587 |
//db.divId.save({"_id": divId._id, "name": divId.name, "pages": pages, "portalType": "community"}); |
|
1588 |
//createAndUpdateDivId(divId, "community", false); |
|
1589 |
createAndUpdateDivIdAndContentsForPortal(divId, null, "community", false); |
|
1590 |
|
|
1591 |
createAndUpdateDivIdAndContentsForPortal(divId, "openaire", "explore", true); |
|
1592 |
createAndUpdateDivIdAndContentsForPortal(divId, "connect", "connect", true); |
|
1593 |
|
|
1594 |
} else if(divId.openaire == true && divId.connect == true) { |
|
1595 |
//var pages = updateDivIdPages(divId.pages, "connect"); |
|
1596 |
//db.divId.save({"_id": divId._id, "name": divId.name, "pages": pages, "portalType": "connect"}); |
|
1597 |
//createAndUpdateDivId(divId, "connect", false); |
|
1598 |
createAndUpdateDivIdAndContentsForPortal(divId, null, "connect", false); |
|
1599 |
|
|
1600 |
createAndUpdateDivIdAndContentsForPortal(divId, "openaire", "explore", true); |
|
1601 |
|
|
1602 |
} else if(divId.openaire == true && divId.communities == true) { |
|
1603 |
//var pages = updateDivIdPages(divId.pages, "community"); |
|
1604 |
//db.divId.save({ "_id": divId._id, "name" : divId.name, "pages" : pages, "portalType": "community"}); |
|
1605 |
//createAndUpdateDivId(divId, "community", false); |
|
1606 |
createAndUpdateDivIdAndContentsForPortal(divId, null, "community", false); |
|
1607 |
|
|
1608 |
createAndUpdateDivIdAndContentsForPortal(divId, "openaire", "explore", true); |
|
1609 |
|
|
1610 |
} else if(divId.connect == true && divId.communities == true) { |
|
1611 |
//var pages = updateDivIdPages(divId.pages, "community"); |
|
1612 |
//db.divId.save({ "_id": divId._id, "name" : divId.name, "pages" : pages, "portalType": "community"}); |
|
1613 |
//createAndUpdateDivId(divId, "community", false); |
|
1614 |
createAndUpdateDivIdAndContentsForPortal(divId, null, "community", false); |
|
1615 |
|
|
1616 |
createAndUpdateDivIdAndContentsForPortal(divId, "connect", "connect", true); |
|
1617 |
|
|
1618 |
} else if(divId.openaire == true) { |
|
1619 |
//var pages = updateDivIdPages(divId.pages, "explore"); |
|
1620 |
//db.divId.save({ "_id": divId._id, "name" : divId.name, "pages" : pages, "portalType": "explore"}); |
|
1621 |
//createAndUpdateDivId(divId, "explore", false); |
|
1622 |
createAndUpdateDivIdAndContentsForPortal(divId, null, "explore", false); |
|
1623 |
|
|
1624 |
} else if(divId.connect == true) { |
|
1625 |
//var pages = updateDivIdPages(divId.pages, "connect"); |
|
1626 |
//db.divId.save({ "_id": divId._id, "name" : divId.name, "pages" : pages, "portalType": "connect"}); |
|
1627 |
//createAndUpdateDivId(divId, "connect", false); |
|
1628 |
createAndUpdateDivIdAndContentsForPortal(divId, null, "connect", false); |
|
1629 |
|
|
1630 |
} else if(divId.communities == true) { |
|
1631 |
//var pages = updateDivIdPages(divId.pages, "community"); |
|
1632 |
//db.divId.save({ "_id": divId._id, "name" : divId.name, "pages" : pages, "portalType": "community"}); |
|
1633 |
//createAndUpdateDivId(divId, "community", false); |
|
1634 |
createAndUpdateDivIdAndContentsForPortal(divId, null, "community", false); |
|
1635 |
} |
|
1636 |
} |
|
1637 |
} |
|
1638 |
|
|
1639 |
function updateDivIdPages(pages, portalType) { |
|
1640 |
var newPages = []; |
|
1641 |
for (var i = 0; i < pages.length; i++) { |
|
1642 |
page = db.page.findOne({"_id": ObjectId(pages[i])}); |
|
1643 |
pageForPortalType = db.page.findOne({portalType: portalType, "route" : page.route}); |
|
1644 |
if(pageForPortalType) { |
|
1645 |
print("page in divId: "+pages[i] + " will be replaced with "+pageForPortalType._id.str); |
|
1646 |
newPages.push(pageForPortalType._id.str); |
|
1647 |
} else { |
|
1648 |
print("page in divId: "+pages[i] + " will be not be replaced. pageForPortalType: "+pageForPortalType); |
|
1649 |
} |
|
1650 |
} |
|
1651 |
return newPages; |
|
1652 |
} |
|
1653 |
|
|
1654 |
// function createAndUpdateDivId(divId, portalType, create) { |
|
1655 |
// var pages = updateDivIdPages(divId.pages, portalType); |
|
1656 |
// if(pages.length == 0) { |
|
1657 |
// db.divId.remove({"_id": divId._id}); |
|
1658 |
// communities = db.community.find({ "type" : portalType }).map( function(community) { return community; } ); |
|
1659 |
// for (var j = 0; j < communities.length; j++) { |
|
1660 |
// db.divHelpContent.remove({"divId": divId._id.str, "community": communities[j]._id.str}); |
|
1661 |
// } |
|
1662 |
// } else { |
|
1663 |
// if (create) { |
|
1664 |
// db.divId.save({"name": divId.name, "pages": pages, "portalType": portalType}); |
|
1665 |
// } else { |
|
1666 |
// db.divId.save({"_id": divId._id, "name": divId.name, "pages": pages, "portalType": portalType}); |
|
1667 |
// } |
|
1668 |
// } |
|
1669 |
// } |
|
1670 |
|
|
1671 |
function createAndUpdateDivIdAndContentsForPortal(divId, pid, portalType, create) { |
|
1672 |
//var pages = updateDivIdPages(divId.pages, portalType); |
|
1673 |
//db.divId.save({ "name" : divId.name, "pages" : pages, "portalType": portalType}); |
|
1674 |
|
|
1675 |
var pages = updateDivIdPages(divId.pages, portalType); |
|
1676 |
if(pages.length == 0) { |
|
1677 |
db.divId.remove({"_id": divId._id}); |
|
1678 |
communities = db.community.find({ "type" : portalType }).map( function(community) { return community; } ); |
|
1679 |
for (var j = 0; j < communities.length; j++) { |
|
1680 |
db.divHelpContent.remove({"divId": divId._id.str, "community": communities[j]._id.str}); |
|
1681 |
} |
|
1682 |
} else { |
|
1683 |
if (create) { |
|
1684 |
db.divId.save({"name": divId.name, "pages": pages, "portalType": portalType}); |
|
1685 |
|
|
1686 |
divIdForPortalType = db.divId.find({portalType: portalType, "name" : divId.name}).map(function (divId) { return divId._id.str; }).toString(); |
|
1687 |
|
|
1688 |
communityId = db.community.find({pid: pid}).map(function (community) { return community._id.str; }).toString(); |
|
1689 |
|
|
1690 |
updateDivIdHelpContentsForPortalPage(divId._id.str, divIdForPortalType, communityId); |
|
1691 |
} else { |
|
1692 |
db.divId.save({"_id": divId._id, "name": divId.name, "pages": pages, "portalType": portalType}); |
|
1693 |
} |
|
1694 |
} |
|
1695 |
} |
|
1696 |
|
|
1697 |
function updateDivIdHelpContentsForPortalPage(divIdId, newDivIdId, communityId) { |
|
1698 |
divHelpContents = db.divHelpContent.find({"divId" : divIdId, "community" : communityId,}).map( function(divHelpContent) { return divHelpContent; } ); |
|
1699 |
for (var i = 0; i < divHelpContents.length; i++) { |
|
1700 |
divHelpContent = divHelpContents[i]; |
|
1701 |
|
|
1702 |
db.divHelpContent.save({ |
|
1703 |
"_id": divHelpContent._id, |
|
1704 |
"divId" : newDivIdId, |
|
1705 |
"community" : communityId, |
|
1706 |
"content" : divHelpContent.content, |
|
1707 |
"isActive" : divHelpContent.isActive |
|
1708 |
}); |
|
1709 |
} |
|
1710 |
} |
|
1711 |
|
|
1712 |
function renameCollectionAndFields() { |
|
1713 |
db.community.renameCollection("portal"); |
|
1714 |
db.communitySubscribers.renameCollection("portalSubscribers"); |
|
1715 |
|
|
1716 |
db.divHelpContent.update({"community": {$exists: true}}, {$rename:{"community":"portal"}}, false, true); |
|
1717 |
db.pageHelpContent.update({"community": {$exists: true}}, {$rename:{"community":"portal"}}, false, true); |
|
1718 |
db.notifications.update({"communityPid": {$exists: true}}, {$rename:{"communityPid":"portalPid"}}, false, true); |
|
1719 |
} |
|
1720 |
|
|
1721 |
function addPortalPidInLayoutRecords() { |
|
1722 |
communities = db.portal.find().map( function(community) { return community; } ); |
|
1723 |
for (var j = 0; j < communities.length; j++) { |
|
1724 |
community = communities[j]; |
|
1725 |
if(community.layout) { |
|
1726 |
layout = db.layout.findOne({"_id": ObjectId(community.layout)}); |
|
1727 |
db.layout.save({ |
|
1728 |
"_id": layout._id, |
|
1729 |
"mainColor": layout.mainColor, |
|
1730 |
"secondaryColor": layout.secondaryColor, |
|
1731 |
"panel": layout.panel, |
|
1732 |
"box": layout.box, |
|
1733 |
"links": layout.links, |
|
1734 |
"buttons": layout.buttons, |
|
1735 |
"portalPid": community.pid |
|
1736 |
}) |
|
1737 |
|
|
1738 |
db.portal.update({"_id": community._id}, {$unset: {layout:""}}); |
|
1739 |
} |
|
1740 |
} |
|
1741 |
} |
|
1742 |
|
|
1743 |
use openaire_admin_beta_20191105; |
|
1744 |
|
|
1454 | 1745 |
//updatePages(); |
1455 | 1746 |
|
1456 | 1747 |
//updateTypeOfLandingPages(); |
... | ... | |
1513 | 1804 |
// removeOldLayouts(); |
1514 | 1805 |
|
1515 | 1806 |
// 13-03-2020 |
1516 |
addSearchResearchOutcomesPages(); |
|
1807 |
//addSearchResearchOutcomesPages(); |
|
1808 |
|
|
1809 |
// 02-02-2020 - 19-03-2020 |
|
1810 |
addPortalType(); |
|
1811 |
createPagesForEachPortalType(); |
|
1812 |
createDivIdsForEachPortalType(); |
|
1813 |
renameCollectionAndFields(); |
|
1814 |
addPortalPidInLayoutRecords(); |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/test/java/eu/dnetlib/uoaadmintools/UoaAdminToolsApplicationTests.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.uoaadmintools; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.uoaadmintools.dao.*; |
4 |
import eu.dnetlib.uoaadmintools.entities.*;
|
|
5 |
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
|
|
4 |
import eu.dnetlib.uoaadmintoolslibrary.dao.*;
|
|
5 |
import eu.dnetlib.uoaadmintoolslibrary.entities.Page;
|
|
6 | 6 |
import org.junit.Test; |
7 | 7 |
import org.junit.runner.RunWith; |
8 | 8 |
import org.springframework.beans.factory.annotation.Autowired; |
9 | 9 |
import org.springframework.boot.test.context.SpringBootTest; |
10 | 10 |
import org.springframework.test.context.junit4.SpringRunner; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.HashMap; |
|
14 |
import java.util.List; |
|
15 |
import java.util.Map; |
|
16 |
|
|
17 | 12 |
@RunWith(SpringRunner.class) |
18 | 13 |
@SpringBootTest |
19 | 14 |
public class UoaAdminToolsApplicationTests { |
20 | 15 |
|
21 | 16 |
@Autowired |
22 |
private CommunityDAO communityDAO;
|
|
17 |
private PortalDAO communityDAO;
|
|
23 | 18 |
|
24 | 19 |
@Autowired |
25 | 20 |
private EntityDAO entityDAO; |
... | ... | |
40 | 35 |
private SubscriberDAO subscriberDAO; |
41 | 36 |
|
42 | 37 |
@Autowired |
43 |
private CommunitySubscribersDAO communitySubscribersDAO;
|
|
38 |
private PortalSubscribersDAO portalSubscribersDAO;
|
|
44 | 39 |
|
45 | 40 |
/* |
46 | 41 |
|
... | ... | |
205 | 200 |
// for(Community c:communities){ |
206 | 201 |
// String pid = c.getPid(); |
207 | 202 |
// System.out.println("Community :" +pid); |
208 |
// CommunitySubscribers communitySubscribers= communitySubscribersDAO.findByPid(pid);
|
|
203 |
// PortalSubscribers communitySubscribers= portalSubscribersDAO.findByPid(pid);
|
|
209 | 204 |
// if(communitySubscribers == null){ |
210 |
// communitySubscribers = new CommunitySubscribers(pid);
|
|
211 |
// communitySubscribersDAO.save(communitySubscribers);
|
|
205 |
// communitySubscribers = new PortalSubscribers(pid);
|
|
206 |
// portalSubscribersDAO.save(communitySubscribers);
|
|
212 | 207 |
// System.out.println("Saved community subscribers for :" +pid); |
213 | 208 |
// } |
214 | 209 |
// } |
215 | 210 |
} |
216 | 211 |
|
217 |
@Test |
|
218 |
public void testPages() { |
|
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 |
// } |
|
219 | 220 |
|
220 |
System.out.println( pageDAO.findByConnect(false).size()); |
|
221 |
for (Page p: pageDAO.findByConnect(false) ){ |
|
222 |
System.out.println(p.getRoute()+" Con: "+p.getConnect()+" Op: "+p.getOpenaire()); |
|
223 |
} |
|
224 |
} |
|
225 |
|
|
226 | 221 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/test/java/eu/dnetlib/uoaadmintools/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 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/handlers/ExceptionsHandler.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import eu.dnetlib.uoaadmintools.responses.ExceptionResponse; |
4 | 4 |
|
5 |
import eu.dnetlib.uoaadmintoolslibrary.handlers.InvalidReCaptchaException; |
|
5 | 6 |
import org.apache.log4j.Logger; |
6 | 7 |
import org.springframework.http.HttpStatus; |
7 | 8 |
import org.springframework.http.ResponseEntity; |
... | ... | |
26 | 27 |
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.BAD_REQUEST); |
27 | 28 |
} |
28 | 29 |
@ExceptionHandler(ContentNotFoundException.class) |
29 |
public ResponseEntity<ErrorDetails> contentNotFound(Exception ex) {
|
|
30 |
public ResponseEntity<ExceptionResponse> contentNotFound(Exception ex) {
|
|
30 | 31 |
ExceptionResponse response = new ExceptionResponse(); |
31 | 32 |
response.setErrorCode("No content found"); |
32 | 33 |
response.setErrorMessage(ex.getMessage()); |
33 | 34 |
response.setErrors(ex.getMessage()); |
34 |
ErrorDetails errorDetails = new ErrorDetails(new Date(),ex.getMessage(),ex.getMessage()); |
|
35 | 35 |
log.debug("contentNotFound exception" + response.getErrorCode()+ " "+response.getErrorMessage()); |
36 |
|
|
37 |
return new ResponseEntity<ErrorDetails>(errorDetails, HttpStatus.NOT_FOUND); |
|
36 |
return new ResponseEntity<ExceptionResponse>(response, HttpStatus.NOT_FOUND); |
|
38 | 37 |
} |
39 | 38 |
@ExceptionHandler(NullPointerException.class) |
40 | 39 |
public ResponseEntity<ExceptionResponse> nullPointerException(Exception ex) { |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/UoaAdminToolsApplication.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.uoaadmintools; |
2 | 2 |
|
3 |
import eu.dnetlib.uoaadmintools.configuration.properties.GoogleConfig; |
|
4 |
import eu.dnetlib.uoaadmintools.configuration.properties.MailConfig; |
|
5 | 3 |
import eu.dnetlib.uoaadmintools.configuration.properties.MongoConfig; |
6 | 4 |
import eu.dnetlib.uoaadmintools.configuration.properties.SecurityConfig; |
7 | 5 |
import org.springframework.boot.SpringApplication; |
... | ... | |
10 | 8 |
import org.springframework.context.annotation.PropertySource; |
11 | 9 |
import org.springframework.context.annotation.PropertySources; |
12 | 10 |
|
13 |
@SpringBootApplication |
|
11 |
@SpringBootApplication(scanBasePackages = {"eu.dnetlib.uoaadmintools", "eu.dnetlib.uoaadmintoolslibrary"})
|
|
14 | 12 |
@PropertySources({ |
15 | 13 |
@PropertySource("classpath:admintools.properties"), |
16 | 14 |
@PropertySource("classpath:dnet-override.properties") |
17 | 15 |
}) |
18 |
@EnableConfigurationProperties({SecurityConfig.class, MailConfig.class, GoogleConfig.class, MongoConfig.class})
|
|
16 |
@EnableConfigurationProperties({SecurityConfig.class, MongoConfig.class}) |
|
19 | 17 |
public class UoaAdminToolsApplication { |
20 | 18 |
|
21 | 19 |
public static void main(String[] args) { |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/dao/LayoutDAO.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
Layout findById(String Id); |
11 | 11 |
|
12 |
Layout save(Layout entity);
|
|
12 |
Layout findByPortalPid(String portalPid);
|
|
13 | 13 |
|
14 |
Layout save(Layout layout); |
|
15 |
|
|
14 | 16 |
void deleteAll(); |
15 | 17 |
|
16 | 18 |
void delete(String id); |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/entities/Layout.java | ||
---|---|---|
19 | 19 |
private Links links; |
20 | 20 |
private Buttons buttons; |
21 | 21 |
|
22 |
private String portalPid; |
|
22 | 23 |
|
23 | 24 |
public Layout() { } |
24 | 25 |
|
25 |
public Layout(String id, String mainColor, String secondaryColor, Panel panel, Box box, Links links, Buttons buttons) { |
|
26 |
public Layout(String id, String mainColor, String secondaryColor, Panel panel, Box box, Links links, Buttons buttons, String portalPid) {
|
|
26 | 27 |
this.id = id; |
27 | 28 |
this.mainColor = mainColor; |
28 | 29 |
this.secondaryColor = secondaryColor; |
... | ... | |
30 | 31 |
this.box = box; |
31 | 32 |
this.links = links; |
32 | 33 |
this.buttons = buttons; |
34 |
|
|
35 |
this.portalPid = portalPid; |
|
33 | 36 |
} |
34 | 37 |
|
35 | 38 |
public String getId() { |
... | ... | |
87 | 90 |
public void setButtons(Buttons buttons) { |
88 | 91 |
this.buttons = buttons; |
89 | 92 |
} |
93 |
|
|
94 |
public String getPortalPid() { |
|
95 |
return portalPid; |
|
96 |
} |
|
97 |
|
|
98 |
public void setPortalPid(String portalPid) { |
|
99 |
this.portalPid = portalPid; |
|
100 |
} |
|
90 | 101 |
} |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/controllers/CuratorController.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.uoaadmintools.controllers; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.uoaadmintools.dao.CuratorDAO; |
4 |
import eu.dnetlib.uoaadmintools.entities.Curator; |
|
5 |
import eu.dnetlib.uoaadmintools.entities.CuratorResponse; |
|
4 |
import eu.dnetlib.uoaadmintools.entities.curator.Curator;
|
|
5 |
import eu.dnetlib.uoaadmintools.entities.curator.CuratorResponse;
|
|
6 | 6 |
import org.apache.log4j.Logger; |
7 | 7 |
import org.springframework.beans.factory.annotation.Autowired; |
8 | 8 |
import org.springframework.web.bind.annotation.*; |
modules/uoa-admin-tools/branches/use-UoaAdminToolsLibrary/src/main/java/eu/dnetlib/uoaadmintools/controllers/CommunityController.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.uoaadmintools.controllers; |
2 | 2 |
|
3 |
import eu.dnetlib.uoaadmintools.dao.*; |
|
4 |
import eu.dnetlib.uoaadmintools.entities.*; |
|
5 |
|
|
6 |
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics; |
|
3 |
import eu.dnetlib.uoaadmintools.entities.Layout; |
|
4 |
import eu.dnetlib.uoaadmintools.services.LayoutService; |
|
5 |
import eu.dnetlib.uoaadmintools.services.StatisticsService; |
|
6 |
import eu.dnetlib.uoaadmintools.services.SubscriberService; |
|
7 |
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal; |
|
8 |
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.PortalResponse; |
|
9 |
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService; |
|
7 | 10 |
import org.apache.log4j.Logger; |
8 |
import org.springframework.beans.factory.annotation.Value; |
|
9 | 11 |
import org.springframework.web.bind.annotation.*; |
10 | 12 |
import org.springframework.beans.factory.annotation.Autowired; |
11 | 13 |
|
... | ... | |
17 | 19 |
private final Logger log = Logger.getLogger(this.getClass()); |
18 | 20 |
|
19 | 21 |
@Autowired |
20 |
private CommunityDAO communityDAO;
|
|
22 |
private LayoutService layoutService;
|
|
21 | 23 |
|
22 | 24 |
@Autowired |
23 |
private LayoutDAO layoutDAO;
|
|
25 |
private StatisticsService statisticsService;
|
|
24 | 26 |
|
25 | 27 |
@Autowired |
26 |
private PageDAO pageDAO;
|
|
28 |
private SubscriberService subscriberService;
|
|
27 | 29 |
|
28 | 30 |
@Autowired |
29 |
private EntityDAO entityDAO;
|
|
31 |
private PortalService portalService;
|
|
30 | 32 |
|
31 |
@Autowired |
|
32 |
private DivIdDAO divIdDAO; |
|
33 |
@RequestMapping(value = "/community/update", method = RequestMethod.POST) |
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.