Project

General

Profile

1
package eu.dnetlib.uoaadmintools.controllers;
2

    
3
import eu.dnetlib.uoaadmintools.dao.*;
4
import eu.dnetlib.uoaadmintools.entities.*;
5

    
6
import eu.dnetlib.uoaadmintools.entities.statistics.Statistics;
7
import org.apache.log4j.Logger;
8
import org.springframework.beans.factory.annotation.Value;
9
import org.springframework.web.bind.annotation.*;
10
import org.springframework.beans.factory.annotation.Autowired;
11

    
12
import java.util.*;
13

    
14
@RestController
15
@CrossOrigin(origins = "*")
16
public class CommunityController {
17
    private final Logger log = Logger.getLogger(this.getClass());
18

    
19
    @Autowired
20
    private CommunityDAO communityDAO;
21

    
22
    @Autowired
23
    private LayoutDAO layoutDAO;
24

    
25
    @Autowired
26
    private PageDAO pageDAO;
27

    
28
    @Autowired
29
    private EntityDAO entityDAO;
30

    
31
    @Autowired
32
    private DivIdDAO divIdDAO;
33

    
34
    @Autowired
35
    private PageHelpContentController pageHelpContentController;
36

    
37
    @Autowired
38
    private DivHelpContentController divHelpContentController;
39

    
40
    @Autowired
41
    private HtmlPageContentController htmlPageContentController;
42

    
43
    @Autowired
44
    private DivIdController divIdController;
45

    
46
    @Autowired
47
    private StatisticsDAO statisticsDAO;
48
    @Autowired
49
    private CommunitySubscribersDAO  communitySubscribersDAO;
50

    
51

    
52
    @RequestMapping(value = "/community", method = RequestMethod.GET)
53
    public List<Community> getAllCommunities() {
54
        List<Community> communities = communityDAO.findAll();
55

    
56
        return communities;
57
    }
58

    
59
    @RequestMapping(value = "/communityFull", method = RequestMethod.GET)
60
    public List<CommunityResponse> getAllCommunitiesFull() {
61
        List<Community> communities = communityDAO.findAll();
62
        List<CommunityResponse> communitiesResponse = new ArrayList<>();
63
        for(Community community : communities) {
64
            CommunityResponse communityResponse = new CommunityResponse(community);
65

    
66
            List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
67
            log.debug("PAGES number="+pages.size());
68
            Iterator<CommunityPage> iteratorPages = pages.iterator();
69
            while(iteratorPages.hasNext()) {
70
                CommunityPage page = iteratorPages.next();
71
                if(!page.getIsEnabled()) {
72
                    iteratorPages.remove();
73
                }
74
            }
75
            communityResponse.setPages(pages);
76
            log.debug("PAGES set");
77

    
78
            List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
79
            log.debug("ENTITIES number="+entities.size());
80
            Iterator<CommunityEntity> iteratorEntities = entities.iterator();
81
            while(iteratorEntities.hasNext()) {
82
                CommunityEntity entity = iteratorEntities.next();
83
                if(!entity.getIsEnabled()) {
84
                    iteratorEntities.remove();
85
                }
86
            }
87
            communityResponse.setEntities(entities);
88
            Layout layout = layoutDAO.findById(community.getLayout());
89
            communityResponse.setLayout(layout);
90
            communitiesResponse.add(communityResponse);
91
        }
92
        return communitiesResponse;
93
    }
94

    
95
    @RequestMapping(value = "/communityFull/{pid}", method = RequestMethod.GET)
96
    public CommunityResponse getCommunityFull(@PathVariable(value = "pid") String pid) {
97
        Community community = communityDAO.findByPid(pid);
98
        CommunityResponse communityResponse = new CommunityResponse(community);
99

    
100
        List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
101
        Iterator<CommunityPage> iteratorPages = pages.iterator();
102
        while(iteratorPages.hasNext()) {
103
            CommunityPage page = iteratorPages.next();
104
            if(!page.getIsEnabled()) {
105
                iteratorPages.remove();
106
            }
107
        }
108
        communityResponse.setPages(pages);
109

    
110
        List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
111
        Iterator<CommunityEntity> iteratorEntities = entities.iterator();
112
        while(iteratorEntities.hasNext()) {
113
            CommunityEntity entity = iteratorEntities.next();
114
            if(!entity.getIsEnabled()) {
115
                iteratorEntities.remove();
116
            }
117
        }
118
        communityResponse.setEntities(entities);
119
        Layout layout = layoutDAO.findById(community.getLayout());
120
        communityResponse.setLayout(layout);
121
//        communityResponse.setPages(this.getPagesForCommunityByType(community.getId(), null));
122
//        communityResponse.setEntities(this.getEntitiesForCommunity(community.getId()));
123

    
124
        return communityResponse;
125
    }
126
/*
127

    
128
    @RequestMapping(value = "/communityFullByName/{name}", method = RequestMethod.GET)
129
    public CommunityResponse getCommunityFullByName(@PathVariable(value = "name") String name) {
130
        Community community = communityDAO.findByName(name);
131
        CommunityResponse communityResponse = new CommunityResponse(community);
132

    
133
        List<CommunityPage> pages = this.getPagesForCommunityByType(community.getId(), null, null);
134
        Iterator<CommunityPage> iteratorPages = pages.iterator();
135
        while(iteratorPages.hasNext()) {
136
            CommunityPage page = iteratorPages.next();
137
            if(!page.getIsEnabled()) {
138
                iteratorPages.remove();
139
            }
140
        }
141
        communityResponse.setPages(pages);
142

    
143
        List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getId(), null);
144
        Iterator<CommunityEntity> iteratorEntities = entities.iterator();
145
        while(iteratorEntities.hasNext()) {
146
            CommunityEntity entity = iteratorEntities.next();
147
            if(!entity.getIsEnabled()) {
148
                iteratorEntities.remove();
149
            }
150
        }
151
        communityResponse.setEntities(entities);
152

    
153
        return communityResponse;
154
    }
155
*/
156

    
157
    @RequestMapping(value = "/community/update", method = RequestMethod.POST)
158
    public CommunityResponse updateCommunity(@RequestBody Community community) {
159
        Community com = communityDAO.findById(community.getId());
160
        com.setName(community.getName());
161
        com.setPid(community.getPid());
162
        // = this.getCommunityByCommunityResponse(communityResponse);
163
        communityDAO.save(com);
164
        CommunityResponse communityResponse = this.getCommunityFull(community.getPid());
165

    
166
        return communityResponse;
167
    }
168

    
169
    @RequestMapping(value = "/community/save", method = RequestMethod.POST)
170
    public CommunityResponse insertCommunity(@RequestBody Community community) {
171
        //Community community = this.getCommunityByCommunityResponse(communityResponse);
172

    
173
        List<CommunityEntity> communityEntities = new ArrayList<>();
174
        List<CommunityPage> communityPages = new ArrayList<>();
175
        Map<String, Boolean> entities = new HashMap<>();
176
        Map<String, Boolean> pages = new HashMap<>();
177

    
178
        for(Entity entity : entityDAO.findAll()) {
179
            entities.put(entity.getId(), true);
180

    
181
            CommunityEntity communityEntity = new CommunityEntity(entity);
182
            communityEntity.setIsEnabled(true);
183
            communityEntities.add(communityEntity);
184
        }
185

    
186
        for(Page page : pageDAO.findAll()) {
187
            pages.put(page.getId(), true);
188

    
189
            CommunityPage communityPage = new CommunityPage(page);
190
            if(page.getRoute().equals("/curators") || page.getRoute().equals("/organizations")) {
191
                communityPage.setIsEnabled(false);
192
            } else {
193
                communityPage.setIsEnabled(true);
194
            }
195

    
196
            communityPages.add(communityPage);
197
        }
198

    
199
        community.setEntities(entities);
200
        community.setPages(pages);
201
        Statistics statistics =  new Statistics(community.getPid());
202
        statisticsDAO.save(statistics);
203
        CommunitySubscribers communitySubscribers =  new CommunitySubscribers(community.getPid());
204
        communitySubscribersDAO.save(communitySubscribers);
205
        Community savedCommunity = communityDAO.save(community);
206
        CommunityResponse communityResponse = this.getCommunityFull(savedCommunity.getPid());
207

    
208
        log.debug("pid of saved community: "+savedCommunity.getPid());
209

    
210
        String id = savedCommunity.getId();
211

    
212
        divHelpContentController.addDivHelpContentsInCommunity(savedCommunity.getPid(), id, null);
213
        pageHelpContentController.addPageHelpContentsInCommunity(savedCommunity.getPid(), id);
214
        /*
215
        Page page = null;
216
        page = pageDAO.findByRoute("/about" );
217
        if(page != null) {
218
            String htmlContent = "<div><div class=\"uk-article-title custom-article-title\"> About the community </div> <p> This is an introductory text. To be updated... </p> </div>";
219
            HtmlPageContent htmlPageContent = new HtmlPageContent(page.getId(), id, htmlContent);
220
            htmlPageContentController.updateHtmlPageContent(htmlPageContent);
221
        }
222
        */
223

    
224
        /*
225
        page = pageDAO.findByRoute("/organizations");
226
        if(page != null) {
227
            String htmlContent = "<div><div class=\"uk-article-title custom-article-title\"> Organizations related to the community </div> <p> This is an introductory text. Here follows the list of organizations... </p> <div class=\"uk-child-width-1-3@m uk-text-center uk-grid-match \" uk-grid > <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"https://upload.wikimedia.org/wikipedia/el/2/2b/Logo_uoa_blue.png\" alt=\"\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"https://www.uoa.gr/\">University of Athens</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"https://pbs.twimg.com/profile_images/631127495933165569/ElbqhHK0_400x400.jpg\" alt=\"\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"https://www.athena-innovation.gr/en\">Athena Research & Innovation center</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"\" alt=\"Logo 1\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"\">Organization 1</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"\" alt=\"Logo 2\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"\">Organization 2</a> </h3> </div> </div> <div class=\"uk-card uk-card-default uk-margin-bottom uk-padding-remove\"> <div class=\"uk-card-media-top\"> <img src=\"\" alt=\"Logo 3\" class=\"uk-height-small uk-responsive-height \"> </div> <div class=\"uk-card-body\"> <h3 class=\"uk-card-title\"> <a class=\"wk-link-reset\" href=\"\">Organization 3</a> </h3> </div> </div> </div></div>";
228
            HtmlPageContent htmlPageContent = new HtmlPageContent(page.getId(), id, htmlContent);
229
            htmlPageContentController.updateHtmlPageContent(htmlPageContent);
230
        }
231
        */
232

    
233
        return communityResponse;
234
    }
235

    
236
    private Community getCommunityByCommunityResponse(CommunityResponse communityResponse) {
237
        Community community = new Community();
238
        community.setId(communityResponse.getId());
239
        community.setName(communityResponse.getName());
240

    
241
        List<CommunityEntity> fullEntities = communityResponse.getEntities();
242
        Map<String, Boolean> entities = new HashMap<String, Boolean>();
243
        for(CommunityEntity entity : fullEntities) {
244
            entities.put(entity.getId(), true);
245
        }
246
        for(Entity entity : entityDAO.findAll()) {
247
            if(!entities.containsKey(entity.getId())) {
248
                entities.put(entity.getId(), false);
249
            }
250
        }
251
        community.setEntities(entities);
252

    
253
        List<CommunityPage> fullPages = communityResponse.getPages();
254
        Map<String, Boolean> pages = new HashMap<String, Boolean>();
255
        for(CommunityPage page : fullPages) {
256
            pages.put(page.getId(), true);
257
        }
258
        for(Page page : pageDAO.findAll()) {
259
            if(!pages.containsKey(page.getId())) {
260
                pages.put(page.getId(), false);
261
            }
262
        }
263
        community.setPages(pages);
264
        Layout layout = communityResponse.getLayout();
265
        community.setLayout(layout.getId());
266

    
267
        return community;
268
    }
269

    
270
    @RequestMapping(value = "/community/delete", method = RequestMethod.POST)
271
    public Boolean deleteCommunities(@RequestBody List<String> communities) throws Exception {
272
        for (String id: communities) {
273
            Community community = communityDAO.findById(id);
274
            String pid = community.getPid();
275

    
276
            // delete div contents related to this community
277
            List<DivHelpContentResponse> divHelpContentResponses = divHelpContentController.getDivHelpContents(pid, null, null, null);
278
            for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
279
                divHelpContentController.deleteDivHelpContent(divHelpContentResponse.getId());
280
            }
281

    
282
            // delete page contents related to this community
283
            List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentController.getPageHelpContents(pid, null, null, null, null);
284
            for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
285
                pageHelpContentController.deletePageHelpContent(pageHelpContentResponse.getId());
286
            }
287

    
288
            List<HtmlPageContent> htmlPageContents = htmlPageContentController.getHtmlPageContents(pid, null);
289
            for(HtmlPageContent htmlPageContent : htmlPageContents) {
290
                htmlPageContentController.deleteHtmlPageContent(htmlPageContent.getId());
291
            }
292

    
293
            Statistics stats = statisticsDAO.findByPid(pid);
294
            if(stats != null) {
295
                statisticsDAO.delete(stats.getId());
296
            }
297

    
298
            CommunitySubscribers communitySubscribers = communitySubscribersDAO.findByPid(pid);
299
            if(communitySubscribers != null) {
300
                communitySubscribersDAO.delete(communitySubscribers.getId());
301
            }
302

    
303
            Layout layout = layoutDAO.findById(community.getLayout());
304
            if(layout != null) {
305
                layoutDAO.delete(layout.getId());
306
            }
307

    
308
            communityDAO.delete(id);
309
        }
310

    
311
        return true;
312
    }
313

    
314
//    @RequestMapping(value = "/community", method = RequestMethod.DELETE)
315
//    public void deleteAllCommunities() {
316
//        communityDAO.deleteAll();
317
//    }
318

    
319
    @RequestMapping(value = "/community", method = RequestMethod.POST)
320
    public Community insertOrUpdateCommunity(@RequestBody Community community) {
321
        return communityDAO.save(community);
322
    }
323

    
324
    @RequestMapping(value = "/community/{pid}", method = RequestMethod.GET)
325
    public Community getCommunity(@PathVariable(value = "pid") String pid) {
326
        log.debug("PID: "+ pid);
327
        return communityDAO.findByPid(pid);
328
    }
329

    
330
    @RequestMapping(value = "/community/{id}", method = RequestMethod.DELETE)
331
    public void deleteCommunity(@PathVariable(value = "id") String id) {
332
        communityDAO.delete(id);
333
    }
334

    
335
    @RequestMapping(value = "/community/{pid}/pages", method = RequestMethod.GET)
336
    public List<CommunityPage> getPagesForCommunityByType(@PathVariable(value = "pid") String pid,
337
                                                          @RequestParam(value="page_type", required=false) String page_type,
338
                                                          @RequestParam(value="page_route", required=false) String page_route,
339
                                                          @RequestParam(value="div", required = false) String div) {
340
        List<CommunityPage> return_pages = new ArrayList<CommunityPage>();
341
        Map<String, Boolean> pages = communityDAO.findByPid(pid).getPages();
342

    
343
        if(pages != null) {
344
            for (Map.Entry<String, Boolean> page : pages.entrySet()) {
345
                if(div != null && div.equals("true")) {
346
                    Community community = communityDAO.findByPid(pid);
347
                    List<DivId> divIds = divIdDAO.findByPagesContaining(page.getKey());
348
                    Iterator<DivId> divIdIterator = divIds.iterator();
349

    
350
                    while (divIdIterator.hasNext()) {
351
                        DivId divId = divIdIterator.next();
352
                        if((pid.equals("openaire") && !divId.getOpenaire()) ||
353
                                (pid.equals("connect") && !divId.getConnect()) ||
354
                                (!pid.equals("openaire") && !pid.equals("connect") && !divId.getCommunities())) {
355
                            divIdIterator.remove();
356
                        }
357
                    }
358

    
359
                    if(divIds.isEmpty()) {
360
                        continue;
361
                    }
362
                }
363

    
364
                Page p = pageDAO.findById(page.getKey());
365

    
366
                if((pid.equals("openaire") && p.getOpenaire()) || (pid.equals("connect") && p.getConnect()) ||(!pid.equals("openaire") && !pid.equals("connect") && p.getCommunities())) {
367
                    if ((page_type == null && page_route == null) || (page_route == null && p.getType().equals(page_type))
368
                            || p.getRoute().equals(page_route)) {
369
                        CommunityPage communityPage = new CommunityPage(p);
370

    
371
                        List<Entity> entities = new ArrayList<>();
372
                        for (String entity : p.getEntities()) {
373
                            entities.add(entityDAO.findById(entity));
374
                        }
375
                        communityPage.setEntities(entities);
376
                        communityPage.setIsEnabled(page.getValue());
377

    
378
                        return_pages.add(communityPage);
379

    
380
                        if (page_route != null) {
381
                            break;
382
                        }
383
                    }
384
                }
385
            }
386
        }
387
        return_pages.sort(Comparator.comparing(CommunityPage::getName));
388
        return return_pages;
389
    }
390

    
391
    @RequestMapping(value = "/community/{id}/page", method = RequestMethod.POST)
392
    public Community insertOrUpdatePage(@PathVariable(value = "id") String id, @RequestBody CommunityPage page) {
393
        Community community = communityDAO.findById(id);
394
        Map<String, Boolean> pages = community.getPages();
395

    
396
        String name = page.getName();
397
        boolean isEnabled = page.getIsEnabled();
398

    
399
        pages.put(name, isEnabled);
400
        community.setPages(pages);
401

    
402
        return communityDAO.save(community);
403
    }
404

    
405
    @RequestMapping(value = "community/{pid}/page/toggle", method = RequestMethod.POST)
406
    public Community togglePage(@PathVariable(value = "pid") String pid, @RequestBody List<String> pageIds, @RequestParam String status) throws Exception {
407
        Community community = communityDAO.findByPid(pid);
408
        Map<String, Boolean> pages = community.getPages();
409

    
410
        for (String pageId: pageIds) {
411
            log.debug("Toggle community page: " + pageId + " of community: " + pid + " to " + status);
412
            pages.put(pageId, Boolean.parseBoolean(status));
413
        }
414

    
415
        community.setPages(pages);
416
        return communityDAO.save(community);
417
    }
418

    
419
    @RequestMapping(value = "community/{pid}/entity/toggle", method = RequestMethod.POST)
420
    public Community toggleEntity(@PathVariable(value = "pid") String pid, @RequestBody List<String> entityIds, @RequestParam String status) throws Exception {
421
        Community community = communityDAO.findByPid(pid);
422
        Map<String, Boolean> entities = community.getEntities();
423
        Map<String, Boolean> pages = community.getPages();
424

    
425
        for (String entityId: entityIds) {
426
            log.debug("Toggle community entity: " + entityId + " of community: " + pid + " to " + status);
427

    
428
            entities.put(entityId, Boolean.parseBoolean(status));
429

    
430
            if(pages != null) {
431
                for (Map.Entry<String, Boolean> pageEntry : pages.entrySet()) {
432
                    Page page = pageDAO.findById(pageEntry.getKey());
433
                    if (page.getEntities().contains(entityId) && page.getType().equals("search")) {
434
                        pages.put(pageEntry.getKey(), Boolean.parseBoolean(status));
435
                    }
436
                }
437
            }
438
        }
439

    
440
        community.setEntities(entities);
441
        return communityDAO.save(community);
442
    }
443

    
444
    @RequestMapping(value = "/community/{pid}/entities", method = RequestMethod.GET)
445
    public List<CommunityEntity> getEntitiesForCommunity(@PathVariable(value = "pid") String pid, @RequestParam(value="entity", required=false) String entity) {
446
        List<CommunityEntity> return_entities = new ArrayList<CommunityEntity>();
447
        Map<String, Boolean> entities = communityDAO.findByPid(pid).getEntities();
448

    
449
        log.debug("/community/"+pid+"/entities -- entity: "+entity);
450
        if (entity != null) {
451
            String entityId = entityDAO.findByPid(entity).getId();
452
            CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(entityId));
453
            communityEntity.setIsEnabled(entities.get(entityId));
454
            return_entities.add(communityEntity);
455
        } else {
456
            if(entities != null) {
457
                for (Map.Entry<String, Boolean> _entity : entities.entrySet()) {
458
                    CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(_entity.getKey()));
459
                    communityEntity.setIsEnabled(_entity.getValue());
460
                    return_entities.add(communityEntity);
461
                }
462
            }
463
        }
464
        return return_entities;
465
    }
466

    
467
    @RequestMapping(value = "/community/{pid}/layout", method = RequestMethod.GET)
468
    public Layout getLayoutForCommunity(@PathVariable(value = "pid") String pid) {
469
        Community community = communityDAO.findByPid(pid);
470
        if(community.getLayout() != null) {
471
            return layoutDAO.findById(community.getLayout());
472
        } else {
473
            return null;
474
        }
475
    }
476

    
477
    @RequestMapping(value = "/community/{pid}/layout", method = RequestMethod.POST)
478
    public Layout updateLayoutForCommunity(@PathVariable(value = "pid") String pid, @RequestBody Layout layout) {
479
        Community community = communityDAO.findByPid(pid);
480
        if(community.getLayout() != null) {
481
            layout.setId(community.getLayout());
482
            layout = layoutDAO.save(layout);
483
        } else {
484
            layout = layoutDAO.save(layout);
485
            community.setLayout(layout.getId());
486
            communityDAO.save(community);
487
        }
488
        return layout;
489
    }
490

    
491

    
492
    @RequestMapping(value = "/community/{pid}/pagehelpcontent", method = RequestMethod.GET)
493
    public Map<String, List<PageHelpContentResponse>> getPageHelpContentsByPosition(@PathVariable(value = "pid") String pid,
494
                                                                       @RequestParam(required=false) String page,
495
                                                                       @RequestParam(required=false) String active) {
496
        Map<String, List<PageHelpContentResponse>> pageHelpContentResponses = new HashMap<>();
497

    
498
        List<PageHelpContentResponse> pageHelpContents = null;
499
        pageHelpContents = pageHelpContentController.getPageHelpContents(pid, page, null, active, null);
500

    
501
        pageHelpContentResponses.put("top", new ArrayList<>());
502
        pageHelpContentResponses.put("bottom", new ArrayList<>());
503
        pageHelpContentResponses.put("left", new ArrayList<>());
504
        pageHelpContentResponses.put("right", new ArrayList<>());
505

    
506
        for (PageHelpContentResponse pageHelpContentResponse : pageHelpContents) {
507
            pageHelpContentResponses.get(pageHelpContentResponse.getPlacement()).add(pageHelpContentResponse);
508
        }
509

    
510

    
511
        return pageHelpContentResponses;
512
    }
513

    
514
    @RequestMapping(value = "/community/{pid}/divhelpcontent", method = RequestMethod.GET)
515
    public Map<String, List<DivHelpContentResponse>> getDivHelpContentsByPosition(@PathVariable(value = "pid") String pid,
516
                                                                                    @RequestParam(required=false) String page,
517
                                                                                    @RequestParam(required=false) String active) {
518
        Map<String, List<DivHelpContentResponse>> divHelpContentResponses = new HashMap<>();
519

    
520
        List<DivHelpContentResponse> divHelpContents = null;
521
        divHelpContents = divHelpContentController.getDivHelpContents(pid, page, null, active);
522

    
523
        for (DivHelpContentResponse divHelpContentResponse : divHelpContents) {
524
            if(!divHelpContentResponses.containsKey(divHelpContentResponse.getDivId())) {
525
                divHelpContentResponses.put(divHelpContentResponse.getDivId().getName(), new ArrayList<>());
526
            }
527
            divHelpContentResponses.get(divHelpContentResponse.getDivId().getName()).add(divHelpContentResponse);
528
        }
529

    
530

    
531
        return divHelpContentResponses;
532
    }
533
}
534

    
(1-1/16)