Revision 58395
Added by Konstantina Galouni almost 4 years ago
DivIdService.java | ||
---|---|---|
30 | 30 |
private DivHelpContentService divHelpContentService; |
31 | 31 |
|
32 | 32 |
public List<DivId> getDivIds(String page, String name, String pid) { |
33 |
Portal portal = portalService.getPortal(pid); |
|
34 |
String portalType = portal.getType(); |
|
35 |
|
|
36 | 33 |
List<DivId> divIds = null; |
37 | 34 |
|
38 |
if(page != null && name != null) { |
|
35 |
if(page != null && name != null && pid != null) { |
|
36 |
Portal portal = portalService.getPortal(pid); |
|
37 |
if(portal == null) { |
|
38 |
return null; |
|
39 |
} |
|
40 |
String portalType = portal.getType(); |
|
41 |
|
|
42 |
DivId divId = divIdDAO.findByPagesContainingAndNameAndPortalType(page, name, portalType); |
|
43 |
if(divId != null) { |
|
44 |
divIds = new ArrayList<>(); |
|
45 |
divIds.add(divId); |
|
46 |
} |
|
47 |
} |
|
48 |
else if(page != null && name != null) { |
|
39 | 49 |
DivId divId = divIdDAO.findByPagesContainingAndName(page, name); |
40 | 50 |
if(divId != null) { |
41 | 51 |
divIds = new ArrayList<>(); |
42 | 52 |
divIds.add(divId); |
43 | 53 |
} |
44 |
} else if(page != null) { |
|
45 |
divIds = divIdDAO.findByPagesContaining(page); |
|
46 |
} else if(name != null) { |
|
47 |
DivId divId = divIdDAO.findByName(name); |
|
54 |
} else if(page != null && pid != null) { |
|
55 |
Portal portal = portalService.getPortal(pid); |
|
56 |
if(portal == null) { |
|
57 |
return null; |
|
58 |
} |
|
59 |
String portalType = portal.getType(); |
|
60 |
divIds = divIdDAO.findByPagesContainingAndPortalType(page, portalType); |
|
61 |
} else if(name != null && pid != null) { |
|
62 |
Portal portal = portalService.getPortal(pid); |
|
63 |
if(portal == null) { |
|
64 |
return null; |
|
65 |
} |
|
66 |
|
|
67 |
String portalType = portal.getType(); |
|
68 |
|
|
69 |
DivId divId = divIdDAO.findByNameAndPortalType(name, portalType); |
|
48 | 70 |
if(divId != null) { |
49 | 71 |
divIds = new ArrayList<>(); |
50 | 72 |
divIds.add(divId); |
51 | 73 |
} |
74 |
} else if(page != null) { |
|
75 |
divIds = divIdDAO.findByPagesContaining(page); |
|
76 |
} else if(name != null) { |
|
77 |
divIds = divIdDAO.findByName(name); |
|
78 |
} else if(pid != null) { |
|
79 |
Portal portal = portalService.getPortal(pid); |
|
80 |
if(portal == null) { |
|
81 |
return null; |
|
82 |
} |
|
83 |
String portalType = portal.getType(); |
|
84 |
divIds = divIdDAO.findByPortalType(portalType); |
|
52 | 85 |
} else { |
53 | 86 |
divIds = divIdDAO.findAll(); |
54 | 87 |
} |
55 | 88 |
|
56 |
if(portalType != null) { |
|
57 |
Iterator<DivId> iteratorDivIds = divIds.iterator(); |
|
58 |
while(iteratorDivIds.hasNext()) { |
|
59 |
DivId divId = iteratorDivIds.next(); |
|
60 |
if (!portalType.equals(divId.getPortalType())) { |
|
61 |
iteratorDivIds.remove(); |
|
62 |
} |
|
63 |
} |
|
64 |
} |
|
89 |
// if(portalType != null) {
|
|
90 |
// Iterator<DivId> iteratorDivIds = divIds.iterator();
|
|
91 |
// while(iteratorDivIds.hasNext()) {
|
|
92 |
// DivId divId = iteratorDivIds.next();
|
|
93 |
// if (!portalType.equals(divId.getPortalType())) {
|
|
94 |
// iteratorDivIds.remove();
|
|
95 |
// }
|
|
96 |
// }
|
|
97 |
// }
|
|
65 | 98 |
|
66 | 99 |
return divIds; |
67 | 100 |
} |
68 | 101 |
|
102 |
public List<DivId> getDivIdsByPortalType(String portalType) { |
|
103 |
if (portalType == null) { |
|
104 |
return null; |
|
105 |
} |
|
106 |
return divIdDAO.findByPortalType(portalType); |
|
107 |
} |
|
108 |
|
|
69 | 109 |
public List<DivIdResponse> getDivIdsFull(String page, String name, String pid) { |
70 |
|
|
71 | 110 |
List<DivId> divIds = this.getDivIds(page, name, pid); |
111 |
if(divIds == null) { |
|
112 |
return null; |
|
113 |
} |
|
72 | 114 |
|
73 | 115 |
List<DivIdResponse> divIdResponses = new ArrayList<>(); |
74 | 116 |
for(DivId divId : divIds) { |
... | ... | |
85 | 127 |
return divIdResponses; |
86 | 128 |
} |
87 | 129 |
|
88 |
public DivId getDivIdByName(String name) { |
|
89 |
return divIdDAO.findByName(name); |
|
90 |
} |
|
130 |
// public DivId getDivIdByName(String name) {
|
|
131 |
// return divIdDAO.findByName(name);
|
|
132 |
// }
|
|
91 | 133 |
|
92 | 134 |
public DivId getDivId(String id) { |
93 | 135 |
return divIdDAO.findById(id); |
... | ... | |
208 | 250 |
|
209 | 251 |
public Boolean deleteDivIds(List<String> divIds) throws Exception { |
210 | 252 |
for (String id: divIds) { |
211 |
DivId divId = divIdDAO.findById(id); |
|
212 |
|
|
213 | 253 |
// delete div contents related to this divId |
214 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentService.getDivHelpContents(null, null, divId.getName(), null);
|
|
254 |
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentService.getDivHelpContents(null, null, id, null);
|
|
215 | 255 |
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) { |
216 | 256 |
divHelpContentService.deleteDivHelpContent(divHelpContentResponse.getId()); |
217 | 257 |
} |
... | ... | |
226 | 266 |
} |
227 | 267 |
|
228 | 268 |
public Set<String> getDivIdsPages(String pid) { |
229 |
Portal portal = portalService.getPortal(pid); |
|
230 |
String portalType = portal.getType(); |
|
231 |
|
|
232 | 269 |
List<DivId> divIds = null; |
233 | 270 |
Set<String> hasPortalPageDivIds = new HashSet<>(); |
234 | 271 |
|
235 |
if(portalType != null) { |
|
272 |
if(pid != null) { |
|
273 |
Portal portal = portalService.getPortal(pid); |
|
274 |
if(portal == null) { |
|
275 |
return null; |
|
276 |
} |
|
277 |
String portalType = portal.getType(); |
|
236 | 278 |
divIds = divIdDAO.findByPortalType(portalType); |
237 | 279 |
} else { |
238 | 280 |
divIds = divIdDAO.findAll(); |
Also available in: Unified diff
[Trunk | Admin Tools Library Service]:
1. DivHelpContentController.java: In "getDivHelpContents()" (/divhelpcontent) method rename parameter "div" to "divId" | Delete unnecessary method "addDivHelpContentsInPortal()".
2. PageHelpContentController.java: In "getPageHelpContents()" (/pagehelpconent) method add request parameter "portalType".
3. PortalController.java: Controller added for common methods of "ExploreController", "ConnectController" and "CommunityController" in "Admin Tools Service" - @RequestMapping with multiple paths.
4. DivIdDAO.java & MongoDBDivIdDAO.java:
a. Method "findByName()" returns List with new schema.
b. Added methods: "List<DivId> findByPagesContainingAndPortalType()", "DivId findByPagesContainingAndNameAndPortalType()", "DivId findByNameAndPortalType()".
5. PortalDAO.java & MongoDBPortalDAO.java: Added method "findByType()".
6. Portal.java & PortalResponse.java: Removed "layout" field and its methods.
7. DivHelpContentService.java:
a. In "getDivHelpContents()" (/divhelpcontent) method rename parameter "div" to "divId"
b. public void addDivHelpContentsInPortal(String pid, String portalId, String divIdName) --> public void addDivHelpContentsInPortal(String portalId, String portalType)
8. DivIdService.java:
a. [Bug fix] "getDivIds()", "getDivIdsFull()", "deleteDivIds()", "getDivIdsPages()" methods
b. Added method "getDivIdsByPortalType()"
c. Commented "getDivIdByName()" method.
9. PageHelpContentService.java:
a. In "getPageHelpContents()" method add parameter "portalType" and do bug fixes.
b. public void addPageHelpContentsInPortal(String pid, String portalId) --> public void addPageHelpContentsInPortal(String portalId, String portalType).
10. PageService.java:
a. [Bug fix] "getPagesFull()", "getAllPages()", "deletePageHelpContentsForPositionsIfDisabled()" methods.
b. Added methods "getPagesByPortalType()" and "getPageByPortalTypeAndRoute()".
11. PortalService.java:
a. [Bug fix] "getPortalFull()".
b. Method "deletePortal()" renamed to "deletePortalId()" and added NEW "deletePortal()" which deletes related page and div contents (and if no portal with the same type, also pages and divIds).