deprecated previous core class

This commit is contained in:
Michele Artini 2023-06-12 14:47:27 +02:00
parent cdc8084cb6
commit cb7f5eb52c
8 changed files with 386 additions and 182 deletions

View File

@ -10,6 +10,16 @@ import static eu.dnetlib.openaire.common.ExporterConstants.W;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import eu.dnetlib.openaire.community.db.CommunityService;
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException;
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
@ -21,16 +31,6 @@ import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties;
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
@ -45,7 +45,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
public class CommunityApiController {
@Autowired
private CommunityApiCore communityApiCore;
private CommunityService communityService;
@RequestMapping(value = "/community/communities", produces = {
"application/json"
@ -58,7 +58,7 @@ public class CommunityApiController {
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunitySummary> listCommunities() throws CommunityException {
return communityApiCore.listCommunities();
return communityService.listCommunities();
}
@RequestMapping(value = "/community/{id}", produces = {
@ -73,7 +73,7 @@ public class CommunityApiController {
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails getCommunity(@PathVariable final String id) throws CommunityException, ResourceNotFoundException {
return communityApiCore.getCommunity(id);
return communityService.getCommunity(id);
}
@RequestMapping(value = "/community/{id}", produces = {
@ -91,7 +91,7 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final CommunityWritableProperties properties) throws CommunityException, ResourceNotFoundException {
communityApiCore.setCommunity(id, properties);
communityService.setCommunity(id, properties);
}
@RequestMapping(value = "/community/{id}/projects", produces = {
@ -106,7 +106,7 @@ public class CommunityApiController {
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityProject> getCommunityProjects(@PathVariable final String id) throws CommunityException, ResourceNotFoundException {
return communityApiCore.getCommunityProjects(id);
return communityService.getCommunityProjects(id);
}
@RequestMapping(value = "/community/{id}/projects", produces = {
@ -124,7 +124,7 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final CommunityProject project) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunityProject(id, project);
return communityService.addCommunityProject(id, project);
}
@RequestMapping(value = "/community/{id}/projects", produces = {
@ -142,45 +142,43 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final Integer projectId) throws CommunityException, ResourceNotFoundException {
communityApiCore.removeCommunityProject(id, projectId);
communityService.removeCommunityProject(id, projectId);
}
@RequestMapping(value = "/community/{id}/projectList", produces = {
"application/json"
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "associate a list of project to the community",
description = "associate a list of project to the community", tags = {
C_PJ, W
@Operation(summary = "associate a list of project to the community", description = "associate a list of project to the community", tags = {
C_PJ, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityProject> addCommunityProjectList(
@PathVariable final String id,
@RequestBody final List<CommunityProject> projectList) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id,
@RequestBody final List<CommunityProject> projectList) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunityProjectList(id, projectList);
return communityService.addCommunityProjectList(id, projectList);
}
@RequestMapping(value = "/community/{id}/projectList", produces = {
"application/json"
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove a list of projects from the community",
description = "remove a list of projects from the community", tags = {
C_PJ, W
@Operation(summary = "remove a list of projects from the community", description = "remove a list of projects from the community", tags = {
C_PJ, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void deleteCommunityProjectList(
@PathVariable final String id,
@RequestBody final List<Integer> projectIdList) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id,
@RequestBody final List<Integer> projectIdList) throws CommunityException, ResourceNotFoundException {
communityApiCore.removeCommunityProjectList(id, projectIdList);
communityService.removeCommunityProjectList(id, projectIdList);
}
@RequestMapping(value = "/community/{id}/contentproviders", produces = {
@ -195,7 +193,7 @@ public class CommunityApiController {
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityContentprovider> getCommunityContentproviders(@PathVariable final String id) throws CommunityException, ResourceNotFoundException {
return communityApiCore.getCommunityContentproviders(id);
return communityService.getCommunityContentproviders(id);
}
@RequestMapping(value = "/community/{id}/contentproviders", produces = {
@ -213,7 +211,7 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final CommunityContentprovider contentprovider) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunityContentprovider(id, contentprovider);
return communityService.addCommunityContentprovider(id, contentprovider);
}
@RequestMapping(value = "/community/{id}/contentproviders", produces = {
@ -231,45 +229,43 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final Integer contentproviderId) throws CommunityException, ResourceNotFoundException {
communityApiCore.removeCommunityContentProvider(id, contentproviderId);
communityService.removeCommunityContentProvider(id, contentproviderId);
}
@RequestMapping(value = "/community/{id}/contentprovidersList", produces = {
"application/json"
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "associate a list of content providers to the community",
description = "associate a list of content providers to the community", tags = {
C_PJ, W
@Operation(summary = "associate a list of content providers to the community", description = "associate a list of content providers to the community", tags = {
C_PJ, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityContentprovider> addCommunityContentProvidersList(
@PathVariable final String id,
@RequestBody final List<CommunityContentprovider> contentprovidersList) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id,
@RequestBody final List<CommunityContentprovider> contentprovidersList) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunityContentProvidersList(id, contentprovidersList);
return communityService.addCommunityContentProvidersList(id, contentprovidersList);
}
@RequestMapping(value = "/community/{id}/contentprovidersList", produces = {
"application/json"
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove a list of content providers from the community",
description = "remove a list of content providers from the community", tags = {
C_PJ, W
@Operation(summary = "remove a list of content providers from the community", description = "remove a list of content providers from the community", tags = {
C_PJ, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public void deleteCommunityContentProvidersList(
@PathVariable final String id,
@RequestBody final List<Integer> contentProviderIdList) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id,
@RequestBody final List<Integer> contentProviderIdList) throws CommunityException, ResourceNotFoundException {
communityApiCore.removeCommunityContentProviderList(id, contentProviderIdList);
communityService.removeCommunityContentProviderList(id, contentProviderIdList);
}
// ADDING CODE FOR COMMUNITY ORGANIZATIONS
@ -286,7 +282,7 @@ public class CommunityApiController {
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityOrganization> getCommunityOrganizations(@PathVariable final String id) throws CommunityException, ResourceNotFoundException {
return communityApiCore.getCommunityOrganizations(id);
return communityService.getCommunityOrganizations(id);
}
@RequestMapping(value = "/community/{id}/organizations", produces = {
@ -304,7 +300,7 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final CommunityOrganization organization) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunityOrganization(id, organization);
return communityService.addCommunityOrganization(id, organization);
}
@RequestMapping(value = "/community/{id}/organizations", produces = {
@ -322,7 +318,7 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final Integer organizationId) throws CommunityException, ResourceNotFoundException {
communityApiCore.removeCommunityOrganization(id, organizationId);
communityService.removeCommunityOrganization(id, organizationId);
}
// **********************
@ -341,7 +337,7 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunitySubjects(id, subjects);
return communityService.addCommunitySubjects(id, subjects);
}
@RequestMapping(value = "/community/{id}/subjects", produces = {
@ -359,102 +355,114 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
return communityApiCore.removeCommunitySubjects(id, subjects);
return communityService.removeCommunitySubjects(id, subjects);
}
@RequestMapping(value = "/community/{id}/fos", produces = { "application/json" }, method = RequestMethod.POST)
@Operation(
summary = "associate a fos to the community",
description = "associate a fos to the community",
tags = { C, W })
@RequestMapping(value = "/community/{id}/fos", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "associate a fos to the community", description = "associate a fos to the community", tags = {
C, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error") })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails addCommunityFOS(
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunityFOS(id, subjects);
return communityService.addCommunityFOS(id, subjects);
}
@RequestMapping(value = "/community/{id}/fos", produces = { "application/json" }, method = RequestMethod.DELETE)
@Operation(
summary = "remove fos from a community",
description = "remove fos from a community",
tags = { C, W })
@RequestMapping(value = "/community/{id}/fos", produces = {
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove fos from a community", description = "remove fos from a community", tags = {
C, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error") })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails removeCommunityFOS(
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
return communityApiCore.removeCommunityFOS(id, subjects);
return communityService.removeCommunityFOS(id, subjects);
}
@RequestMapping(value = "/community/{id}/sdg", produces = { "application/json" }, method = RequestMethod.POST)
@Operation(
summary = "associate a sdg to the community",
description = "associate a sdg to the community",
tags = { C, W })
@RequestMapping(value = "/community/{id}/sdg", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "associate a sdg to the community", description = "associate a sdg to the community", tags = {
C, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error") })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails addCommunitySDG(
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunitySDG(id, subjects);
return communityService.addCommunitySDG(id, subjects);
}
@RequestMapping(value = "/community/{id}/sdg", produces = { "application/json" }, method = RequestMethod.DELETE)
@Operation(
summary = "remove sdg from a community",
description = "remove sdg from a community",
tags = { C, W })
@RequestMapping(value = "/community/{id}/sdg", produces = {
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove sdg from a community", description = "remove sdg from a community", tags = {
C, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error") })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails removeCommunitySDG(
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id,
@RequestBody final List<String> subjects) throws CommunityException, ResourceNotFoundException {
return communityApiCore.removeCommunitySDG(id, subjects);
return communityService.removeCommunitySDG(id, subjects);
}
@RequestMapping(value = "/community/{id}/advancedConstraint", produces = { "application/json" }, method = RequestMethod.POST)
@Operation(
summary = "the set of constraints to be used to extend the association between result and community",
description = "the set of constraints to be used to extend the association between result and community",
tags = { C, W })
@RequestMapping(value = "/community/{id}/advancedConstraint", produces = {
"application/json"
}, method = RequestMethod.POST)
@Operation(summary = "the set of constraints to be used to extend the association between result and community", description = "the set of constraints to be used to extend the association between result and community", tags = {
C, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error") })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails addAdvancedConstraint(
@PathVariable final String id,
@RequestBody final SelectionCriteria advancedConstraint) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id,
@RequestBody final SelectionCriteria advancedConstraint) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunityAdvancedConstraint(id, advancedConstraint);
return communityService.addCommunityAdvancedConstraint(id, advancedConstraint);
}
@RequestMapping(value = "/community/{id}/advancedConstraint", produces = { "application/json" }, method = RequestMethod.DELETE)
@Operation(
summary = "remove the constraints to extend the association result community from a community",
description = "remove the constraints to extend the association result community from a community",
tags = { C, W })
@RequestMapping(value = "/community/{id}/advancedConstraint", produces = {
"application/json"
}, method = RequestMethod.DELETE)
@Operation(summary = "remove the constraints to extend the association result community from a community", description = "remove the constraints to extend the association result community from a community", tags = {
C, W
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error") })
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "not found"),
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public CommunityDetails removeAdvancedConstraint(
@PathVariable final String id) throws CommunityException, ResourceNotFoundException {
@PathVariable final String id) throws CommunityException, ResourceNotFoundException {
return communityApiCore.removeCommunityAdvancedConstraint(id);
return communityService.removeCommunityAdvancedConstraint(id);
}
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
@ -469,7 +477,7 @@ public class CommunityApiController {
@ApiResponse(responseCode = "500", description = "unexpected error")
})
public List<CommunityZenodoCommunity> getCommunityZenodoCommunities(@PathVariable final String id) throws CommunityException, ResourceNotFoundException {
return communityApiCore.getCommunityZenodoCommunities(id);
return communityService.getCommunityZenodoCommunities(id);
}
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
@ -487,7 +495,7 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final CommunityZenodoCommunity zenodocommunity) throws CommunityException, ResourceNotFoundException {
return communityApiCore.addCommunityZenodoCommunity(id, zenodocommunity);
return communityService.addCommunityZenodoCommunity(id, zenodocommunity);
}
@ -506,7 +514,7 @@ public class CommunityApiController {
@PathVariable final String id,
@RequestBody final Integer zenodoCommId) throws CommunityException, ResourceNotFoundException {
communityApiCore.removeCommunityZenodoCommunity(id, zenodoCommId);
communityService.removeCommunityZenodoCommunity(id, zenodoCommId);
}
@ -524,7 +532,7 @@ public class CommunityApiController {
public CommunityOpenAIRECommunities getOpenAireCommunities(
@PathVariable final String zenodoId) throws CommunityException, ResourceNotFoundException {
return communityApiCore.getOpenAIRECommunities(zenodoId);
return communityService.getOpenAIRECommunities(zenodoId);
}
}

View File

@ -1,22 +1,42 @@
package eu.dnetlib.openaire.community;
import java.util.*;
import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_NAME;
import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_OFFICIALNAME;
import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_SELCRITERIA;
import static eu.dnetlib.openaire.community.CommunityConstants.CLABEL;
import static eu.dnetlib.openaire.community.CommunityConstants.CONTENTPROVIDERS_ID_SUFFIX;
import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_LOGOURL;
import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_NAME;
import static eu.dnetlib.openaire.community.CommunityConstants.CORGANIZATION_WEBSITEURL;
import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_ADVANCED_CONSTRAINT;
import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_FOS;
import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_SDG;
import static eu.dnetlib.openaire.community.CommunityConstants.CPROFILE_SUBJECT;
import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_ACRONYM;
import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_FULLNAME;
import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_FUNDER;
import static eu.dnetlib.openaire.community.CommunityConstants.CPROJECT_NUMBER;
import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_DESCRIPTION;
import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_LOGOURL;
import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_NAME;
import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_STATUS;
import static eu.dnetlib.openaire.community.CommunityConstants.CSUMMARY_ZENODOC;
import static eu.dnetlib.openaire.community.CommunityConstants.CSV_DELIMITER;
import static eu.dnetlib.openaire.community.CommunityConstants.ID_SEPARATOR;
import static eu.dnetlib.openaire.community.CommunityConstants.OPENAIRE_ID;
import static eu.dnetlib.openaire.community.CommunityConstants.ORGANIZATION_ID_SUFFIX;
import static eu.dnetlib.openaire.community.CommunityConstants.PROJECTS_ID_SUFFIX;
import static eu.dnetlib.openaire.community.CommunityConstants.ZENODOCOMMUNITY_ID_SUFFIX;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException;
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails;
import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities;
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties;
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -29,13 +49,24 @@ import com.google.common.base.Functions;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import eu.dnetlib.openaire.common.ISClient;
import static eu.dnetlib.openaire.community.CommunityConstants.*;
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException;
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails;
import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities;
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties;
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
@Component
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
@Deprecated
public class CommunityApiCore {// implements CommunityClient{
private static final Log log = LogFactory.getLog(CommunityApiCore.class);
@ -59,7 +90,7 @@ public class CommunityApiCore {// implements CommunityClient{
}
private void removeAdvancedConstraint(String id) throws ResourceNotFoundException, CommunityException {
private void removeAdvancedConstraint(final String id) throws ResourceNotFoundException, CommunityException {
cc.getCommunity(id);
isClient.updateContextParam(id, CPROFILE_ADVANCED_CONSTRAINT, "", false);
cc.removeAdvancedConstraint(id);
@ -127,56 +158,56 @@ public class CommunityApiCore {// implements CommunityClient{
}
private CommunityProject updateProject(String id, CommunityProject project) throws CommunityException, ResourceNotFoundException {
private CommunityProject updateProject(final String id, final CommunityProject project) throws CommunityException, ResourceNotFoundException {
final TreeMap<Integer, CommunityProject> projects = getCommunityProjectMap(id);
String project_id = project.getId();
final String project_id = project.getId();
if (project_id != null && projects.keySet().contains(Integer.valueOf(project_id))){
if (project_id != null && projects.keySet().contains(Integer.valueOf(project_id))) {
if (project.getName() != null) {
isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, CPROJECT_FULLNAME, project.getName());
}
if(project.getAcronym()!= null){
if (project.getAcronym() != null) {
isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, CPROJECT_ACRONYM, project.getAcronym());
}
if (project.getOpenaireId() != null){
if (project.getOpenaireId() != null) {
isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, OPENAIRE_ID, project.getOpenaireId());
}
if (project.getFunder() != null){
if (project.getFunder() != null) {
isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, CPROJECT_FUNDER, project.getFunder());
}
if(project.getGrantId() != null){
if (project.getGrantId() != null) {
isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, CPROJECT_NUMBER, project.getGrantId());
}
}else {
} else {
project.setId(nextId(projects != null && !projects.isEmpty() ? projects.lastKey() : 0));
isClient.addConcept(id, id + PROJECTS_ID_SUFFIX, CommunityMappingUtils.asProjectXML(id, project));
}
cc.updateProject(id, project );
cc.updateProject(id, project);
return project;
}
public List<CommunityProject> addCommunityProjectList(final String id, final List<CommunityProject> projectList) throws CommunityException, ResourceNotFoundException {
if(projectList == null || projectList.size() == 0){
public List<CommunityProject> addCommunityProjectList(final String id, final List<CommunityProject> projectList)
throws CommunityException, ResourceNotFoundException {
if (projectList == null || projectList.size() == 0) {
throw new CommunityException("parameter 'projectList' must be present and should contain at least one project");
}
if (!StringUtils.equalsIgnoreCase(id, projectList.get(0).getCommunityId())) {
throw new CommunityException("parameters 'id' and project.communityId must be coherent");
}
List<CommunityProject> projects = new ArrayList();
final List<CommunityProject> projects = new ArrayList();
for(CommunityProject project : projectList){
for (final CommunityProject project : projectList) {
projects.add(updateProject(id, project));
}
return projects;
}
@ -194,7 +225,7 @@ public class CommunityApiCore {// implements CommunityClient{
}
public void removeCommunityProjectList(final String id, final List<Integer> projectIdList) throws CommunityException, ResourceNotFoundException {
for(Integer projectId: projectIdList){
for (final Integer projectId : projectIdList) {
removeCommunityProject(id, projectId);
}
}
@ -212,7 +243,8 @@ public class CommunityApiCore {// implements CommunityClient{
return updateContentprovider(id, cp);
}
private CommunityContentprovider updateContentprovider(String id, CommunityContentprovider cp) throws CommunityException, ResourceNotFoundException {
private CommunityContentprovider updateContentprovider(final String id, final CommunityContentprovider cp)
throws CommunityException, ResourceNotFoundException {
final TreeMap<Integer, CommunityContentprovider> cps = getCommunityContentproviderMap(id);
final String concept_id = cp.getId();
if (concept_id != null && cps.keySet().contains(Integer.valueOf(concept_id))) {
@ -248,26 +280,27 @@ public class CommunityApiCore {// implements CommunityClient{
cc.removeFromCategory(id, CONTENTPROVIDERS_ID_SUFFIX, String.valueOf(contentproviderId));
}
public List<CommunityContentprovider> addCommunityContentProvidersList(String id, List<CommunityContentprovider> contentprovidersList) throws CommunityException, ResourceNotFoundException {
if(contentprovidersList == null || contentprovidersList.size() == 0){
public List<CommunityContentprovider> addCommunityContentProvidersList(final String id, final List<CommunityContentprovider> contentprovidersList)
throws CommunityException, ResourceNotFoundException {
if (contentprovidersList == null || contentprovidersList.size() == 0) {
throw new CommunityException("parameter 'contentprovidersList' must be present and should contain at least one content provider");
}
if (!StringUtils.equalsIgnoreCase(id, contentprovidersList.get(0).getCommunityId())) {
throw new CommunityException("parameters 'id' and contentprovider.communityId must be coherent");
}
List<CommunityContentprovider> contentproviders = new ArrayList();
final List<CommunityContentprovider> contentproviders = new ArrayList();
for(CommunityContentprovider contentProvider : contentprovidersList){
for (final CommunityContentprovider contentProvider : contentprovidersList) {
contentproviders.add(updateContentprovider(id, contentProvider));
}
return contentproviders;
}
public void removeCommunityContentProviderList(final String id, final List<Integer> contentProviderIdList) throws CommunityException, ResourceNotFoundException {
for(Integer contentProviderId: contentProviderIdList){
public void removeCommunityContentProviderList(final String id, final List<Integer> contentProviderIdList)
throws CommunityException, ResourceNotFoundException {
for (final Integer contentProviderId : contentProviderIdList) {
removeCommunityContentProvider(id, contentProviderId);
}
}
@ -326,7 +359,7 @@ public class CommunityApiCore {// implements CommunityClient{
final CommunityDetails cd = new CommunityDetails();
final Set<String> current = Sets.newHashSet();
if(Optional.ofNullable(cc.getCommunity(id).getFos()).isPresent()){
if (Optional.ofNullable(cc.getCommunity(id).getFos()).isPresent()) {
current.addAll(cc.getCommunity(id).getFos());
}
@ -358,7 +391,7 @@ public class CommunityApiCore {// implements CommunityClient{
final CommunityDetails cd = new CommunityDetails();
final Set<String> current = Sets.newHashSet();
if(Optional.ofNullable(cc.getCommunity(id).getSdg()).isPresent()){
if (Optional.ofNullable(cc.getCommunity(id).getSdg()).isPresent()) {
current.addAll(cc.getCommunity(id).getSdg());
}
@ -386,7 +419,8 @@ public class CommunityApiCore {// implements CommunityClient{
return cd;
}
public CommunityDetails addCommunityAdvancedConstraint(final String id, final SelectionCriteria advancedCosntraint) throws CommunityException, ResourceNotFoundException {
public CommunityDetails addCommunityAdvancedConstraint(final String id, final SelectionCriteria advancedCosntraint)
throws CommunityException, ResourceNotFoundException {
final CommunityDetails cd = new CommunityDetails();
@ -404,8 +438,6 @@ public class CommunityApiCore {// implements CommunityClient{
return new CommunityDetails();
}
@CacheEvict(value = "community-cache", allEntries = true)
public void removeCommunityZenodoCommunity(final String id, final Integer zenodoCommId) throws CommunityException, ResourceNotFoundException {
@ -513,5 +545,4 @@ public class CommunityApiCore {// implements CommunityClient{
return organization;
}
}

View File

@ -1,6 +1,9 @@
package eu.dnetlib.openaire.community.db;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Service;
import eu.dnetlib.openaire.community.db.repository.CommunityDatasourceRepository;
@ -8,8 +11,20 @@ import eu.dnetlib.openaire.community.db.repository.CommunityOrgRepository;
import eu.dnetlib.openaire.community.db.repository.CommunityProjectRepository;
import eu.dnetlib.openaire.community.db.repository.CommunityRepository;
import eu.dnetlib.openaire.community.db.repository.CommunitySupportOrgRepository;
import eu.dnetlib.openaire.exporter.exceptions.CommunityException;
import eu.dnetlib.openaire.exporter.exceptions.ResourceNotFoundException;
import eu.dnetlib.openaire.exporter.model.community.CommunityContentprovider;
import eu.dnetlib.openaire.exporter.model.community.CommunityDetails;
import eu.dnetlib.openaire.exporter.model.community.CommunityOpenAIRECommunities;
import eu.dnetlib.openaire.exporter.model.community.CommunityOrganization;
import eu.dnetlib.openaire.exporter.model.community.CommunityProject;
import eu.dnetlib.openaire.exporter.model.community.CommunitySummary;
import eu.dnetlib.openaire.exporter.model.community.CommunityWritableProperties;
import eu.dnetlib.openaire.exporter.model.community.CommunityZenodoCommunity;
import eu.dnetlib.openaire.exporter.model.community.selectioncriteria.SelectionCriteria;
@Service
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
public class CommunityService {
@Autowired
@ -22,4 +37,144 @@ public class CommunityService {
private CommunityOrgRepository communityOrgRepository;
@Autowired
private CommunitySupportOrgRepository communitySupportOrgRepository;
public List<CommunitySummary> listCommunities() throws CommunityException {
// TODO Auto-generated method stub
return null;
}
public CommunityDetails getCommunity(final String id) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public void setCommunity(final String id, final CommunityWritableProperties details) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
}
public List<CommunityProject> getCommunityProjects(final String id) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityProject addCommunityProject(final String id, final CommunityProject project) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public List<CommunityProject> addCommunityProjectList(final String id, final List<CommunityProject> projectList)
throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public void removeCommunityProject(final String id, final Integer projectId) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
}
public void removeCommunityProjectList(final String id, final List<Integer> projectIdList) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
}
public List<CommunityContentprovider> getCommunityContentproviders(final String id) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityContentprovider addCommunityContentprovider(final String id, final CommunityContentprovider cp)
throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public void removeCommunityContentProvider(final String id, final Integer contentproviderId) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
}
public List<CommunityContentprovider> addCommunityContentProvidersList(final String id, final List<CommunityContentprovider> contentprovidersList)
throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public void removeCommunityContentProviderList(final String id, final List<Integer> contentProviderIdList)
throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
}
public void removeCommunityOrganization(final String id, final Integer organizationId) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
}
public List<CommunityZenodoCommunity> getCommunityZenodoCommunities(final String id) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public List<CommunityOrganization> getCommunityOrganizations(final String id) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityDetails addCommunitySubjects(final String id, final List<String> subjects) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityDetails removeCommunitySubjects(final String id, final List<String> subjects) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityDetails addCommunityFOS(final String id, final List<String> foss) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityDetails removeCommunityFOS(final String id, final List<String> foss) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityDetails addCommunitySDG(final String id, final List<String> sdgs) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityDetails removeCommunitySDG(final String id, final List<String> sdgs) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityDetails addCommunityAdvancedConstraint(final String id, final SelectionCriteria advancedCosntraint)
throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityDetails removeCommunityAdvancedConstraint(final String id) throws ResourceNotFoundException, CommunityException {
// TODO Auto-generated method stub
return null;
}
public void removeCommunityZenodoCommunity(final String id, final Integer zenodoCommId) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
}
public CommunityZenodoCommunity addCommunityZenodoCommunity(final String id, final CommunityZenodoCommunity zc)
throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityOpenAIRECommunities getOpenAIRECommunities(final String zenodoId) throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
public CommunityOrganization addCommunityOrganization(final String id, final CommunityOrganization organization)
throws CommunityException, ResourceNotFoundException {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -1,9 +1,11 @@
package eu.dnetlib.openaire.community.db.repository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.jpa.repository.JpaRepository;
import eu.dnetlib.openaire.community.db.model.Community;
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
public interface CommunityDatasourceRepository extends JpaRepository<Community, String> {
}

View File

@ -1,10 +1,12 @@
package eu.dnetlib.openaire.community.db.repository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.jpa.repository.JpaRepository;
import eu.dnetlib.openaire.community.db.model.CommunityOrg;
import eu.dnetlib.openaire.community.db.model.CommunityOrgPK;
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
public interface CommunityOrgRepository extends JpaRepository<CommunityOrg, CommunityOrgPK> {
}

View File

@ -1,10 +1,12 @@
package eu.dnetlib.openaire.community.db.repository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.jpa.repository.JpaRepository;
import eu.dnetlib.openaire.community.db.model.CommunityProject;
import eu.dnetlib.openaire.community.db.model.CommunityProjectPK;
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
public interface CommunityProjectRepository extends JpaRepository<CommunityProject, CommunityProjectPK> {
}

View File

@ -1,9 +1,11 @@
package eu.dnetlib.openaire.community.db.repository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.jpa.repository.JpaRepository;
import eu.dnetlib.openaire.community.db.model.Community;
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
public interface CommunityRepository extends JpaRepository<Community, String> {
}

View File

@ -1,10 +1,12 @@
package eu.dnetlib.openaire.community.db.repository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.data.jpa.repository.JpaRepository;
import eu.dnetlib.openaire.community.db.model.CommunitySupportOrg;
import eu.dnetlib.openaire.community.db.model.CommunitySupportOrgPK;
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
public interface CommunitySupportOrgRepository extends JpaRepository<CommunitySupportOrg, CommunitySupportOrgPK> {
}