[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).
This commit is contained in:
Konstantina Galouni 2020-04-03 20:32:32 +00:00
parent 1872dbc4ab
commit 011628562d
14 changed files with 528 additions and 104 deletions

View File

@ -21,10 +21,10 @@ public class DivHelpContentController {
@RequestMapping(value = "/divhelpcontent", method = RequestMethod.GET)
public List<DivHelpContentResponse> getDivHelpContents(@RequestParam(value = "portal", required = false) String pid,
@RequestParam(required = false) String page,
@RequestParam(required = false) String div,
@RequestParam(required = false) String divId,
@RequestParam(required = false) String active) {
return divHelpContentService.getDivHelpContents(pid, page, div, active);
return divHelpContentService.getDivHelpContents(pid, page, divId, active);
}
@RequestMapping(value = "/divhelpcontent/{id}", method = RequestMethod.GET)
@ -52,8 +52,4 @@ public class DivHelpContentController {
return divHelpContentService.toggleDivHelpContent(divHelpContents, status);
}
public void addDivHelpContentsInPortal(String pid, String portalId, String divIdName) {
divHelpContentService.addDivHelpContentsInPortal(pid, portalId, divIdName);
}
}

View File

@ -20,11 +20,12 @@ public class PageHelpContentController {
@RequestMapping(value = "/pagehelpcontent", method = RequestMethod.GET)
public List<PageHelpContentResponse> getPageHelpContents(@RequestParam(value = "portal", required = false) String pid,
@RequestParam(required=false) String portalType,
@RequestParam(required=false) String page,
@RequestParam(required=false) String position,
@RequestParam(required=false) String active,
@RequestParam(required=false) String before) {
return pageHelpContentService.getPageHelpContents(pid, page, position, active, before);
return pageHelpContentService.getPageHelpContents(pid, portalType, page, position, active, before);
}
@RequestMapping(value = "/pagehelpcontent", method = RequestMethod.DELETE)

View File

@ -0,0 +1,330 @@
package eu.dnetlib.uoaadmintoolslibrary.controllers;
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
import eu.dnetlib.uoaadmintoolslibrary.entities.fullEntities.*;
import eu.dnetlib.uoaadmintoolslibrary.services.PortalService;
import org.springframework.web.bind.annotation.*;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Map;
@RestController
@CrossOrigin(origins = "*")
public class PortalController {
private final Logger log = Logger.getLogger(this.getClass());
@Autowired
private PortalService portalService;
@RequestMapping(value = {"/community", "/explore", "/connect"}, method = RequestMethod.GET)
public List<Portal> getAllCommunities() {
List<Portal> communities = portalService.getAllPortals();
return communities;
}
@RequestMapping(value = {"/communityFull", "/exploreFull", "/connectFull"}, method = RequestMethod.GET)
public List<PortalResponse> getAllCommunitiesFull() {
// List<Community> communities = portalDAO.findAll();
// List<CommunityResponse> communitiesResponse = new ArrayList<>();
// for(Community community : communities) {
// CommunityResponse communityResponse = new CommunityResponse(community);
//
// List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
// log.debug("PAGES number="+pages.size());
// Iterator<CommunityPage> iteratorPages = pages.iterator();
// while(iteratorPages.hasNext()) {
// CommunityPage page = iteratorPages.next();
// if(!page.getIsEnabled()) {
// iteratorPages.remove();
// }
// }
// communityResponse.setPages(pages);
// log.debug("PAGES set");
//
// List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
// log.debug("ENTITIES number="+entities.size());
// Iterator<CommunityEntity> iteratorEntities = entities.iterator();
// while(iteratorEntities.hasNext()) {
// CommunityEntity entity = iteratorEntities.next();
// if(!entity.getIsEnabled()) {
// iteratorEntities.remove();
// }
// }
// communityResponse.setEntities(entities);
// Layout layout = layoutDAO.findById(community.getLayout());
// communityResponse.setLayout(layout);
// communitiesResponse.add(communityResponse);
// }
// return communitiesResponse;
// TODO check where is this used? no more layout in response!!
return portalService.getAllPortalsFull();
}
@RequestMapping(value = {"/communityFull/{pid}", "/exploreFull/{pid}", "/connectFull/{pid}"}, method = RequestMethod.GET)
public PortalResponse getCommunityFull(@PathVariable(value = "pid") String pid) {
// Community community = portalDAO.findByPid(pid);
// CommunityResponse communityResponse = new CommunityResponse(community);
//
// List<CommunityPage> pages = this.getPagesForCommunityByType(community.getPid(), null, null, null);
// Iterator<CommunityPage> iteratorPages = pages.iterator();
// while(iteratorPages.hasNext()) {
// CommunityPage page = iteratorPages.next();
// if(!page.getIsEnabled()) {
// iteratorPages.remove();
// }
// }
// communityResponse.setPages(pages);
//
// List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getPid(), null);
// Iterator<CommunityEntity> iteratorEntities = entities.iterator();
// while(iteratorEntities.hasNext()) {
// CommunityEntity entity = iteratorEntities.next();
// if(!entity.getIsEnabled()) {
// iteratorEntities.remove();
// }
// }
// communityResponse.setEntities(entities);
// Layout layout = layoutDAO.findById(community.getLayout());
// communityResponse.setLayout(layout);
//
// return communityResponse;
// TODO check where is this used? no more layout in response!!
return portalService.getPortalFull(pid);
}
/*
@RequestMapping(value = "/communityFullByName/{name}", method = RequestMethod.GET)
public CommunityResponse getCommunityFullByName(@PathVariable(value = "name") String name) {
Community community = portalDAO.findByName(name);
CommunityResponse communityResponse = new CommunityResponse(community);
List<CommunityPage> pages = this.getPagesForCommunityByType(community.getId(), null, null);
Iterator<CommunityPage> iteratorPages = pages.iterator();
while(iteratorPages.hasNext()) {
CommunityPage page = iteratorPages.next();
if(!page.getIsEnabled()) {
iteratorPages.remove();
}
}
communityResponse.setPages(pages);
List<CommunityEntity> entities = this.getEntitiesForCommunity(community.getId(), null);
Iterator<CommunityEntity> iteratorEntities = entities.iterator();
while(iteratorEntities.hasNext()) {
CommunityEntity entity = iteratorEntities.next();
if(!entity.getIsEnabled()) {
iteratorEntities.remove();
}
}
communityResponse.setEntities(entities);
return communityResponse;
}
*/
// @RequestMapping(value = "/community", method = RequestMethod.DELETE)
// public void deleteAllCommunities() {
// portalDAO.deleteAll();
// }
@RequestMapping(value = {"/community", "/explore", "/connect"}, method = RequestMethod.POST)
public Portal insertOrUpdateCommunity(@RequestBody Portal portal) {
return portalService.insertOrUpdatePortal(portal);
}
@RequestMapping(value = {"/community/{pid}", "/explore/{pid}", "/connect/{pid}"}, method = RequestMethod.GET)
public Portal getCommunity(@PathVariable(value = "pid") String pid) {
log.debug("PID: "+ pid);
return portalService.getPortal(pid);
}
@RequestMapping(value = {"/community/{id}", "/explore/{id}", "/connect/{id}"}, method = RequestMethod.DELETE)
public void deleteCommunity(@PathVariable(value = "id") String id) {
portalService.deletePortalId(id);
}
@RequestMapping(value = {"/community/{pid}/pages", "/explore/{pid}/pages", "/connect/{pid}/pages"}, method = RequestMethod.GET)
public List<PortalPage> getPagesForCommunityByType(@PathVariable(value = "pid") String pid,
@RequestParam(value="page_type", required=false) String page_type,
@RequestParam(value="page_route", required=false) String page_route,
@RequestParam(value="div", required = false) String div) {
// List<CommunityPage> return_pages = new ArrayList<CommunityPage>();
// Map<String, Boolean> pages = portalDAO.findByPid(pid).getPages();
//
// if(pages != null) {
// for (Map.Entry<String, Boolean> page : pages.entrySet()) {
// if(div != null && div.equals("true")) {
// Community community = portalDAO.findByPid(pid);
// List<DivId> divIds = divIdDAO.findByPagesContaining(page.getKey());
// Iterator<DivId> divIdIterator = divIds.iterator();
//
// while (divIdIterator.hasNext()) {
// DivId divId = divIdIterator.next();
// if((pid.equals("openaire") && !divId.getOpenaire()) ||
// (pid.equals("connect") && !divId.getConnect()) ||
// (!pid.equals("openaire") && !pid.equals("connect") && !divId.getCommunities())) {
// divIdIterator.remove();
// }
// }
//
// if(divIds.isEmpty()) {
// continue;
// }
// }
//
// Page p = pageDAO.findById(page.getKey());
//
// if((pid.equals("openaire") && p.getOpenaire()) || (pid.equals("connect") && p.getConnect()) ||(!pid.equals("openaire") && !pid.equals("connect") && p.getCommunities())) {
// if ((page_type == null && page_route == null) || (page_route == null && p.getType().equals(page_type))
// || p.getRoute().equals(page_route)) {
// CommunityPage communityPage = new CommunityPage(p);
//
// List<Entity> entities = new ArrayList<>();
// for (String entity : p.getEntities()) {
// entities.add(entityDAO.findById(entity));
// }
// communityPage.setEntities(entities);
// communityPage.setIsEnabled(page.getValue());
//
// return_pages.add(communityPage);
//
// if (page_route != null) {
// break;
// }
// }
// }
// }
// }
// return_pages.sort(Comparator.comparing(CommunityPage::getName));
// return return_pages;
return portalService.getPagesForPortalByType(pid, page_type, page_route, div);
}
@RequestMapping(value = {"/community/{id}/page", "/explore/{id}/page", "/connect/{id}/page"}, method = RequestMethod.POST)
public Portal insertOrUpdatePage(@PathVariable(value = "id") String id, @RequestBody PortalPage page) {
// Community community = portalDAO.findById(id);
// Map<String, Boolean> pages = community.getPages();
//
// String name = page.getName();
// boolean isEnabled = page.getIsEnabled();
//
// pages.put(name, isEnabled);
// community.setPages(pages);
//
// return portalDAO.save(community);
return portalService.insertOrUpdatePage(id, page);
}
@RequestMapping(value = {"/community/{pid}/page/toggle", "/explore/{pid}/page/toggle", "/connect/{pid}/page/toggle"}, method = RequestMethod.POST)
public Portal togglePage(@PathVariable(value = "pid") String pid, @RequestBody List<String> pageIds, @RequestParam String status) throws Exception {
// Community community = portalDAO.findByPid(pid);
// Map<String, Boolean> pages = community.getPages();
//
// for (String pageId: pageIds) {
// log.debug("Toggle community page: " + pageId + " of community: " + pid + " to " + status);
// pages.put(pageId, Boolean.parseBoolean(status));
// }
//
// community.setPages(pages);
// return portalDAO.save(community);
return portalService.togglePage(pid, pageIds, status);
}
@RequestMapping(value = {"/community/{pid}/entity/toggle", "/explore/{pid}/entity/toggle", "/connect/{pid}/entity/toggle"}, method = RequestMethod.POST)
public Portal toggleEntity(@PathVariable(value = "pid") String pid, @RequestBody List<String> entityIds, @RequestParam String status) throws Exception {
// Community community = portalDAO.findByPid(pid);
// Map<String, Boolean> entities = community.getEntities();
// Map<String, Boolean> pages = community.getPages();
//
// for (String entityId: entityIds) {
// log.debug("Toggle community entity: " + entityId + " of community: " + pid + " to " + status);
//
// entities.put(entityId, Boolean.parseBoolean(status));
//
// if(pages != null) {
// for (Map.Entry<String, Boolean> pageEntry : pages.entrySet()) {
// Page page = pageDAO.findById(pageEntry.getKey());
// if (page.getEntities().contains(entityId) && page.getType().equals("search")) {
// pages.put(pageEntry.getKey(), Boolean.parseBoolean(status));
// }
// }
// }
// }
//
// community.setEntities(entities);
// return portalDAO.save(community);
return portalService.toggleEntity(pid, entityIds, status);
}
@RequestMapping(value = {"/community/{pid}/entities", "/explore/{pid}/entities", "/connect/{pid}/entities"}, method = RequestMethod.GET)
public List<PortalEntity> getEntitiesForCommunity(@PathVariable(value = "pid") String pid, @RequestParam(value="entity", required=false) String entity) {
// List<CommunityEntity> return_entities = new ArrayList<CommunityEntity>();
// Map<String, Boolean> entities = portalDAO.findByPid(pid).getEntities();
//
// log.debug("/community/"+pid+"/entities -- entity: "+entity);
// if (entity != null) {
// String entityId = entityDAO.findByPid(entity).getId();
// CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(entityId));
// communityEntity.setIsEnabled(entities.get(entityId));
// return_entities.add(communityEntity);
// } else {
// if(entities != null) {
// for (Map.Entry<String, Boolean> _entity : entities.entrySet()) {
// CommunityEntity communityEntity = new CommunityEntity(entityDAO.findById(_entity.getKey()));
// communityEntity.setIsEnabled(_entity.getValue());
// return_entities.add(communityEntity);
// }
// }
// }
// return return_entities;
return portalService.getEntitiesForPortal(pid, entity);
}
@RequestMapping(value = {"/community/{pid}/pagehelpcontent", "/explore/{pid}/pagehelpcontent", "/connect/{pid}/pagehelpcontent"}, method = RequestMethod.GET)
public Map<String, List<PageHelpContentResponse>> getPageHelpContentsByPosition(@PathVariable(value = "pid") String pid,
@RequestParam(required=false) String page,
@RequestParam(required=false) String active) {
// Map<String, List<PageHelpContentResponse>> pageHelpContentResponses = new HashMap<>();
//
// List<PageHelpContentResponse> pageHelpContents = null;
// pageHelpContents = pageHelpContentService.getPageHelpContents(pid, page, null, active, null);
//
// pageHelpContentResponses.put("top", new ArrayList<>());
// pageHelpContentResponses.put("bottom", new ArrayList<>());
// pageHelpContentResponses.put("left", new ArrayList<>());
// pageHelpContentResponses.put("right", new ArrayList<>());
//
// for (PageHelpContentResponse pageHelpContentResponse : pageHelpContents) {
// pageHelpContentResponses.get(pageHelpContentResponse.getPlacement()).add(pageHelpContentResponse);
// }
//
//
// return pageHelpContentResponses;
return portalService.getPageHelpContentsByPosition(pid, page, active);
}
@RequestMapping(value = {"/community/{pid}/divhelpcontent", "/explore/{pid}/divhelpcontent", "/connect/{pid}/divhelpcontent"}, method = RequestMethod.GET)
public Map<String, List<DivHelpContentResponse>> getDivHelpContentsByPosition(@PathVariable(value = "pid") String pid,
@RequestParam(required=false) String page,
@RequestParam(required=false) String active) {
// Map<String, List<DivHelpContentResponse>> divHelpContentResponses = new HashMap<>();
//
// List<DivHelpContentResponse> divHelpContents = null;
// divHelpContents = divHelpContentService.getDivHelpContents(pid, page, null, active);
//
// for (DivHelpContentResponse divHelpContentResponse : divHelpContents) {
// if(!divHelpContentResponses.containsKey(divHelpContentResponse.getDivId())) {
// divHelpContentResponses.put(divHelpContentResponse.getDivId().getName(), new ArrayList<>());
// }
// divHelpContentResponses.get(divHelpContentResponse.getDivId().getName()).add(divHelpContentResponse);
// }
//
//
// return divHelpContentResponses;
return portalService.getDivHelpContentsByPosition(pid, page, active);
}
}

View File

@ -5,16 +5,16 @@ import java.util.List;
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
public interface DivIdDAO {
List<DivId> findAll();
List<DivId> findByPagesContaining(String page);
DivId findByPagesContainingAndNameAndPortalType(String page, String name, String portalType);
DivId findByPagesContainingAndName(String page, String name);
DivId findByName(String name);
DivId findByNameAndPortalType(String name, String portalType);
DivId findById(String Id);
List<DivId> findAll();
List<DivId> findByPagesContaining(String page);
List<DivId> findByName(String name);
List<DivId> findByPortalType(String portalType);
List<DivId> findByPagesContainingAndPortalType(String page, String portalType);
DivId save(DivId divId);

View File

@ -8,16 +8,16 @@ import eu.dnetlib.uoaadmintoolslibrary.dao.DivIdDAO;
import eu.dnetlib.uoaadmintoolslibrary.entities.DivId;
public interface MongoDBDivIdDAO extends DivIdDAO, MongoRepository<DivId, String> {
List<DivId> findAll();
List<DivId> findByPagesContaining(String page);
DivId findByPagesContainingAndNameAndPortalType(String page, String name, String portalType);
DivId findByPagesContainingAndName(String page, String name);
DivId findByName(String name);
DivId findByNameAndPortalType(String name, String portalType);
DivId findById(String Id);
List<DivId> findAll();
List<DivId> findByPagesContaining(String page);
List<DivId> findByName(String name);
List<DivId> findByPortalType(String portalType);
List<DivId> findByPagesContainingAndPortalType(String page, String portalType);
DivId save(DivId divId);

View File

@ -9,6 +9,7 @@ import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
public interface MongoDBPortalDAO extends PortalDAO, MongoRepository<Portal, String> {
List<Portal> findAll();
List<Portal> findByType(String Type);
Portal findById(String Id);

View File

@ -6,6 +6,7 @@ import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
public interface PortalDAO {
List<Portal> findAll();
List<Portal> findByType(String Type);
Portal findById(String Id);

View File

@ -16,7 +16,6 @@ public class Portal {
private String type; // explore, connect, community, monitor
private Map<String, Boolean> pages;
private Map<String, Boolean> entities;
private String layout;
public Portal() {}
@ -61,12 +60,4 @@ public class Portal {
public void setEntities(Map<String, Boolean> entities) {
this.entities = entities;
}
public String getLayout() {
return layout;
}
public void setLayout(String layout) {
this.layout = layout;
}
}

View File

@ -17,7 +17,6 @@ public class PortalResponse {
private String type; // explore, connect, community, monitor
private List<PortalPage> pages;
private List<PortalEntity> entities;
//private Layout layout;
public PortalResponse() {}
@ -69,12 +68,4 @@ public class PortalResponse {
public void setEntities(List<PortalEntity> entities) {
this.entities = entities;
}
// public Layout getLayout() {
// return layout;
// }
//
// public void setLayout(Layout layout) {
// this.layout = layout;
// }
}

View File

@ -28,7 +28,7 @@ public class DivHelpContentService {
@Autowired
private PortalService portalService;
public List<DivHelpContentResponse> getDivHelpContents(String pid, String page, String div, String active) {
public List<DivHelpContentResponse> getDivHelpContents(String pid, String page, String divIdId, String active) {
Portal _portal = portalService.getPortal(pid);
String portalId = null;
@ -36,26 +36,26 @@ public class DivHelpContentService {
portalId = _portal.getId();
}
DivId divId = divIdService.getDivIdByName(div);
String divIdId = null;
if(divId != null) {
divIdId = divId.getId();
}
// DivId divId = divIdService.getDivIdByName(divId);
// String divIdId = null;
// if(divId != null) {
// divIdId = divId.getId();
// }
List<DivHelpContentResponse> divHelpContentResponses = new ArrayList<>();
List<DivHelpContent> divHelpContents = null;
if(pid != null && div != null && active != null) {
if(pid != null && divIdId != null && active != null) {
divHelpContents = divHelpContentDAO.findByPortalAndDivIdAndIsActive(portalId, divIdId, Boolean.parseBoolean(active));
} else if(pid != null && div != null) {
} else if(pid != null && divIdId != null) {
divHelpContents = divHelpContentDAO.findByPortalAndDivId(portalId, divIdId);
} else if(pid != null && active != null) {
divHelpContents = divHelpContentDAO.findByPortalAndIsActive(portalId, Boolean.parseBoolean(active));
} else if(div != null && active != null) {
} else if(divIdId != null && active != null) {
divHelpContents = divHelpContentDAO.findByDivIdAndIsActive(divIdId, Boolean.parseBoolean(active));
} else if(pid != null) {
divHelpContents = divHelpContentDAO.findByPortal(portalId);
} else if(div != null) {
} else if(divIdId != null) {
divHelpContents = divHelpContentDAO.findByDivId(divIdId);
} else if(active != null){
divHelpContents = divHelpContentDAO.findByIsActive(Boolean.parseBoolean(active));
@ -65,8 +65,11 @@ public class DivHelpContentService {
for (DivHelpContent divHelpContent : divHelpContents) {
DivIdResponse divIdResponse = null;
if(div == null) {
DivId divId;
if(divIdId == null) {
divId = divIdService.getDivId(divHelpContent.getDivId());
} else {
divId = divIdService.getDivId(divIdId);
}
divIdResponse = divIdService.divIdResponseFromDivId(divId);
@ -117,10 +120,7 @@ public class DivHelpContentService {
return divHelpContents;
}
public void addDivHelpContentsInPortal(String pid, String portalId, String divIdName) {
Portal portal = portalService.getPortal(pid);
String portalType = portal.getType();
public void addDivHelpContentsInPortal(String portalId, String portalType) {
//String organizations_class_content = "<div> <p>Here you can write more details about the organizations related to your portal.</p> </div>";
String link_context_form_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\">&nbsp;</span> Information:</span> Select a research portal and/or a category and search for a portal concept, or browse to the portal tree through the categories</div> </div>";
String link_project_form_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\">&nbsp;</span> Information:</span> Search for projects using project name or grant id. Limit results filtering by funder.</div> </div>";
@ -128,10 +128,10 @@ public class DivHelpContentService {
String link_result_bulk_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\">&nbsp;</span> Information:</span> Upload a csv file containing a list of DOIs. For each DOI found in the file, metadata will be fetched from CrossRef or Datacite and will be added to your selected research results.</div> <div class=\"uk-margin-top uk-text-small\"><span class=\"uk-text-bold\">CSV format:</span> <ul class=\"uk-list\"> <li>The format of CSV file should be &quot;DOI&quot;,&quot;ACCESS_MODE&quot;,&quot;DATE&quot;.</li> <li>The value &quot;DOI&quot; is required</li> <li>Access mode column should have values: &quot;OPEN&quot;,&quot;CLOSED&quot; or &quot;EMBARGO&quot;.</li> <li>Date column valid format is YYYY-MM-DD and is required when access mode has value EMBARGO.</li> <li>In case access mode is not available default value is &quot;OPEN&quot;.</li> </ul> </div> </div>";
String link_metadata_content = "<div> <div><span class=\"uk-text-bold\"><span uk-icon=\"icon: info\">&nbsp;</span> Information:</span> Manage access mode &amp; type of selected research results. For OpenAIRE this functionality isn&#39;t available.</div> </div>";
List<DivId> divIds = divIdService.getDivIds(null, divIdName, null);
List<DivId> divIds = divIdService.getDivIdsByPortalType(portalType);
for( DivId div : divIds ) {
if (div != null && div.getPortalType().equals(portalType) ) {
if (div != null) {
// (div.getOpenaire() && pid.equals("openaire")) ||
// (div.getConnect() && pid.equals("connect")) ||
// (div.getCommunities() && !pid.equals("openaire") && !pid.equals("connect"))

View File

@ -30,45 +30,87 @@ public class DivIdService {
private DivHelpContentService divHelpContentService;
public List<DivId> getDivIds(String page, String name, String pid) {
Portal portal = portalService.getPortal(pid);
String portalType = portal.getType();
List<DivId> divIds = null;
if(page != null && name != null) {
if(page != null && name != null && pid != null) {
Portal portal = portalService.getPortal(pid);
if(portal == null) {
return null;
}
String portalType = portal.getType();
DivId divId = divIdDAO.findByPagesContainingAndNameAndPortalType(page, name, portalType);
if(divId != null) {
divIds = new ArrayList<>();
divIds.add(divId);
}
}
else if(page != null && name != null) {
DivId divId = divIdDAO.findByPagesContainingAndName(page, name);
if(divId != null) {
divIds = new ArrayList<>();
divIds.add(divId);
}
} else if(page != null && pid != null) {
Portal portal = portalService.getPortal(pid);
if(portal == null) {
return null;
}
String portalType = portal.getType();
divIds = divIdDAO.findByPagesContainingAndPortalType(page, portalType);
} else if(name != null && pid != null) {
Portal portal = portalService.getPortal(pid);
if(portal == null) {
return null;
}
String portalType = portal.getType();
DivId divId = divIdDAO.findByNameAndPortalType(name, portalType);
if(divId != null) {
divIds = new ArrayList<>();
divIds.add(divId);
}
} else if(page != null) {
divIds = divIdDAO.findByPagesContaining(page);
} else if(name != null) {
DivId divId = divIdDAO.findByName(name);
if(divId != null) {
divIds = new ArrayList<>();
divIds.add(divId);
divIds = divIdDAO.findByName(name);
} else if(pid != null) {
Portal portal = portalService.getPortal(pid);
if(portal == null) {
return null;
}
String portalType = portal.getType();
divIds = divIdDAO.findByPortalType(portalType);
} else {
divIds = divIdDAO.findAll();
}
if(portalType != null) {
Iterator<DivId> iteratorDivIds = divIds.iterator();
while(iteratorDivIds.hasNext()) {
DivId divId = iteratorDivIds.next();
if (!portalType.equals(divId.getPortalType())) {
iteratorDivIds.remove();
}
}
}
// if(portalType != null) {
// Iterator<DivId> iteratorDivIds = divIds.iterator();
// while(iteratorDivIds.hasNext()) {
// DivId divId = iteratorDivIds.next();
// if (!portalType.equals(divId.getPortalType())) {
// iteratorDivIds.remove();
// }
// }
// }
return divIds;
}
public List<DivIdResponse> getDivIdsFull(String page, String name, String pid) {
public List<DivId> getDivIdsByPortalType(String portalType) {
if (portalType == null) {
return null;
}
return divIdDAO.findByPortalType(portalType);
}
public List<DivIdResponse> getDivIdsFull(String page, String name, String pid) {
List<DivId> divIds = this.getDivIds(page, name, pid);
if(divIds == null) {
return null;
}
List<DivIdResponse> divIdResponses = new ArrayList<>();
for(DivId divId : divIds) {
@ -85,9 +127,9 @@ public class DivIdService {
return divIdResponses;
}
public DivId getDivIdByName(String name) {
return divIdDAO.findByName(name);
}
// public DivId getDivIdByName(String name) {
// return divIdDAO.findByName(name);
// }
public DivId getDivId(String id) {
return divIdDAO.findById(id);
@ -208,10 +250,8 @@ public class DivIdService {
public Boolean deleteDivIds(List<String> divIds) throws Exception {
for (String id: divIds) {
DivId divId = divIdDAO.findById(id);
// delete div contents related to this divId
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentService.getDivHelpContents(null, null, divId.getName(), null);
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentService.getDivHelpContents(null, null, id, null);
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
divHelpContentService.deleteDivHelpContent(divHelpContentResponse.getId());
}
@ -226,13 +266,15 @@ public class DivIdService {
}
public Set<String> getDivIdsPages(String pid) {
Portal portal = portalService.getPortal(pid);
String portalType = portal.getType();
List<DivId> divIds = null;
Set<String> hasPortalPageDivIds = new HashSet<>();
if(portalType != null) {
if(pid != null) {
Portal portal = portalService.getPortal(pid);
if(portal == null) {
return null;
}
String portalType = portal.getType();
divIds = divIdDAO.findByPortalType(portalType);
} else {
divIds = divIdDAO.findAll();

View File

@ -26,7 +26,7 @@ public class PageHelpContentService {
@Autowired
private PortalService portalService;
public List<PageHelpContentResponse> getPageHelpContents(String pid, String page, String position, String active, String before) {
public List<PageHelpContentResponse> getPageHelpContents(String pid, String portalType, String page, String position, String active, String before) {
List<PageHelpContent> pageHelpContents = null;
Portal _portal = null;
@ -75,7 +75,7 @@ public class PageHelpContentService {
List<PageHelpContentResponse> pageHelpContentResponses = new ArrayList<>();
for (PageHelpContent pageHelpContent : pageHelpContents) {
Page _page = pageService.getPage(pageHelpContent.getPage());
if(page == null || page.equals(_page.getRoute())) {
if((page == null || page.equals(_page.getRoute())) && (portalType == null || portalType.equals(_page.getPortalType()))) {
PageHelpContentResponse pageHelpContentResponse = new PageHelpContentResponse(pageHelpContent);
pageHelpContentResponse.setPage(_page);
@ -125,14 +125,17 @@ public class PageHelpContentService {
return true;
}
public void addPageHelpContentsInPortal(String pid, String portalId) {
if (pid != "connect" && pid != "openaire") {
public void addPageHelpContentsInPortal(String portalId, String portalType) {
Page organizationsPage = pageService.getPageByPortalTypeAndRoute(portalType, "/organizations");
if(organizationsPage != null) {
String organizations_page_content = "<div> <p>Here you can write more details about the organizations related to your community.</p> </div>";
Page organizationsPage = (pageService.getAllPages(null, "/organizations", null)).get(0);
PageHelpContent organizations_pageHelpContent = new PageHelpContent(organizationsPage.getId(), pid, "top", 1, organizations_page_content, false, false);
PageHelpContent organizations_pageHelpContent = new PageHelpContent(organizationsPage.getId(), portalId, "top", 1, organizations_page_content, false, false);
this.insertPageHelpContent(organizations_pageHelpContent);
}
Page depositLearnHowPage = pageService.getPageByPortalTypeAndRoute(portalType, "/participate/deposit/learn-how");
if(depositLearnHowPage != null) {
String depositLearnHow_page_content = "" +
"<div class=\"uk-width-3-5 uk-align-center\"> " +
" <div class=\"uk-text-bold\">How to comply with funder Open Access policies</div> " +
@ -143,9 +146,8 @@ public class PageHelpContentService {
" <li>All OpenAIRE guides can be found <a class=\"custom-external\" href=\"https://www.openaire.eu/guides\" target=\"_blank\">here</a></li> " +
" </ul> " +
"</div>";
Page depositLearnHowPage = (pageService.getAllPages(null, "/participate/deposit/learn-how", null)).get(0);
PageHelpContent depositLearnHow_pageHelpContent = new PageHelpContent(depositLearnHowPage.getId(), pid, "bottom", 1, depositLearnHow_page_content, true, false);
PageHelpContent depositLearnHow_pageHelpContent = new PageHelpContent(depositLearnHowPage.getId(), portalId, "bottom", 1, depositLearnHow_page_content, true, false);
this.insertPageHelpContent(depositLearnHow_pageHelpContent);
}
}

View File

@ -41,6 +41,9 @@ public class PageService {
public List<PortalPage> getPagesFull(String pid, String page_route) {
List<Page> pages = this.getAllPages(pid, page_route, null);
if(pages == null) {
return null;
}
List<PortalPage> portalPages = new ArrayList<>();
for(Page page : pages) {
@ -58,14 +61,21 @@ public class PageService {
}
public List<Page> getAllPages(String pid, String page_route, String with_positions) {
List<Page> pages;
List<Page> pages = null;
if (pid != null) {
Portal portal = portalService.getPortal(pid);
if(portal == null) {
return null;
}
String portalType = portal.getType();
if (page_route != null) {
pages = new ArrayList<Page>();
pages.add(pageDAO.findByPortalTypeAndRoute(portalType, page_route));
Page page = pageDAO.findByPortalTypeAndRoute(portalType, page_route);
if(page != null) {
pages.add(page);
}
} else {
pages = pageDAO.findByPortalType(portalType);
}
@ -76,6 +86,10 @@ public class PageService {
}
if (with_positions != null) {
if(pages == null) {
return null;
}
boolean at_least_one_position = Boolean.parseBoolean(with_positions);
Iterator<Page> iteratorPages = pages.iterator();
@ -93,10 +107,26 @@ public class PageService {
}
}
}
pages.sort(Comparator.comparing(Page::getName));
if(pages != null) {
pages.sort(Comparator.comparing(Page::getName));
}
return pages;
}
public List<Page> getPagesByPortalType(String portalType) {
if (portalType == null) {
return null;
}
return pageDAO.findByPortalType(portalType);
}
public Page getPageByPortalTypeAndRoutegetPageByPortalTypeAndRoute(String portalType, String page_route) {
if (page_route == null || portalType == null) {
return null;
}
return pageDAO.findByPortalTypeAndRoute(portalType, page_route);
}
public void deleteAllPages() {
pageDAO.deleteAll();
}
@ -155,7 +185,7 @@ public class PageService {
if(!portalPage.getTop()) {
// delete page contents with position "top" related to this page from all portals
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, portalPage.getRoute(), "top", null, null);
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, portalPage.getPortalType(), portalPage.getRoute(), "top", null, null);
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
pageHelpContentService.deletePageHelpContent(pageHelpContentResponse.getId());
}
@ -163,7 +193,7 @@ public class PageService {
if(!portalPage.getBottom()) {
// delete page contents with position "bottom" related to this page from all portals
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, portalPage.getRoute(), "bottom", null, null);
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, portalPage.getPortalType(), portalPage.getRoute(), "bottom", null, null);
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
pageHelpContentService.deletePageHelpContent(pageHelpContentResponse.getId());
}
@ -171,7 +201,7 @@ public class PageService {
if(!portalPage.getLeft()) {
// delete page contents with position "left" related to this page from all portals
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, portalPage.getRoute(), "left", null, null);
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, portalPage.getPortalType(), portalPage.getRoute(), "left", null, null);
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
pageHelpContentService.deletePageHelpContent(pageHelpContentResponse.getId());
}
@ -179,7 +209,7 @@ public class PageService {
if(!portalPage.getRight()) {
// delete page contents with position "right" related to this page from all portals
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, portalPage.getRoute(), "right", null, null);
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, portalPage.getPortalType(), portalPage.getRoute(), "right", null, null);
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
pageHelpContentService.deletePageHelpContent(pageHelpContentResponse.getId());
}
@ -188,6 +218,7 @@ public class PageService {
public Boolean deletePages(List<String> pages) throws Exception {
for (String id: pages) {
Page page = pageDAO.findById(id);
pageDAO.delete(id);
// delete divIds related only to this page from all portals, otherwise remove this page from divIds
@ -211,7 +242,7 @@ public class PageService {
// delete page contents related to this page from all portals
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, id, null, null, null);
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(null, page.getPortalType(), id, null, null, null);
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
pageHelpContentService.deletePageHelpContent(pageHelpContentResponse.getId());
}

View File

@ -88,6 +88,9 @@ public class PortalService {
public PortalResponse getPortalFull(String pid) {
Portal portal = portalDAO.findByPid(pid);
if(pid != null && portal == null) {
return null;
}
PortalResponse portalResponse = new PortalResponse(portal);
setEnabledPagesForPortalByType(portal, portalResponse);
@ -133,7 +136,7 @@ public class PortalService {
portalEntities.add(portalEntity);
}
for(Page page : pageService.getAllPages(null, null, null)) {
for(Page page : pageService.getPagesByPortalType(portal.getType())) {
pages.put(page.getId(), true);
PortalPage portalPage = new PortalPage(page);
@ -159,8 +162,8 @@ public class PortalService {
String id = savedPortal.getId();
divHelpContentService.addDivHelpContentsInPortal(savedPortal.getPid(), id, null);
pageHelpContentService.addPageHelpContentsInPortal(savedPortal.getPid(), id);
divHelpContentService.addDivHelpContentsInPortal(id, savedPortal.getType());
pageHelpContentService.addPageHelpContentsInPortal(id, savedPortal.getType());
return portalResponse;
}
@ -211,7 +214,7 @@ public class PortalService {
}
// delete page contents related to this portal
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(pid, null,null, null, null);
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(pid, null, null,null, null, null);
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
pageHelpContentService.deletePageHelpContent(pageHelpContentResponse.getId());
}
@ -237,6 +240,41 @@ public class PortalService {
return true;
}
public String deletePortal(String id) {
Portal portal = portalDAO.findById(id);
String pid = portal.getPid();
// delete div contents related to this portal
List<DivHelpContentResponse> divHelpContentResponses = divHelpContentService.getDivHelpContents(pid, null, null, null);
for(DivHelpContentResponse divHelpContentResponse : divHelpContentResponses) {
divHelpContentService.deleteDivHelpContent(divHelpContentResponse.getId());
}
// delete page contents related to this portal
List<PageHelpContentResponse> pageHelpContentResponses = pageHelpContentService.getPageHelpContents(pid, null, null,null, null, null);
for(PageHelpContentResponse pageHelpContentResponse : pageHelpContentResponses) {
pageHelpContentService.deletePageHelpContent(pageHelpContentResponse.getId());
}
// if no other portlas with the same type, delete pages and divIds for this portal type
List<Portal> portalsWithSameType = portalDAO.findByType(portal.getType());
if(portalsWithSameType == null || portalsWithSameType.size() == 1) {
// delete pages for this portal type
for(String pageId : portal.getPages().keySet()) {
pageService.deletePage(pageId);
}
// delete divIds for this portal type
List<DivId> divIds = divIdService.getDivIdsByPortalType(portal.getType());
for(DivId divId : divIds) {
divIdService.deleteDivId(divId.getId());
}
}
portalDAO.delete(id);
return pid;
}
public Portal insertOrUpdatePortal(Portal portal) {
return portalDAO.save(portal);
}
@ -251,7 +289,7 @@ public class PortalService {
return portalDAO.findByPid(pid);
}
public void deletePortal(String id) {
public void deletePortalId(String id) {
portalDAO.delete(id);
}
@ -407,7 +445,7 @@ public class PortalService {
Map<String, List<PageHelpContentResponse>> pageHelpContentResponses = new HashMap<>();
List<PageHelpContentResponse> pageHelpContents = null;
pageHelpContents = pageHelpContentService.getPageHelpContents(pid, page, null, active, null);
pageHelpContents = pageHelpContentService.getPageHelpContents(pid, null, page, null, active, null);
pageHelpContentResponses.put("top", new ArrayList<>());
pageHelpContentResponses.put("bottom", new ArrayList<>());