[CommunityAPIExtention] adding FOS , SDG and advancedCriteria to the summary. Adding the possibility to add and remove list of projects from the profiles
This commit is contained in:
parent
1271f9cf43
commit
e751759de9
|
@ -133,6 +133,44 @@ public class CommunityApiController {
|
||||||
communityApiCore.removeCommunityProject(id, projectId);
|
communityApiCore.removeCommunityProject(id, projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/community/{id}/projectList", produces = {
|
||||||
|
"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
|
||||||
|
})
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@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, CommunityNotFoundException {
|
||||||
|
|
||||||
|
return communityApiCore.addCommunityProjectList(id, projectList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/community/{id}/projectList", produces = {
|
||||||
|
"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
|
||||||
|
})
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@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, CommunityNotFoundException {
|
||||||
|
|
||||||
|
communityApiCore.removeCommunityProjectList(id, projectIdList);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/community/{id}/contentproviders", produces = {
|
@RequestMapping(value = "/community/{id}/contentproviders", produces = {
|
||||||
"application/json"
|
"application/json"
|
||||||
}, method = RequestMethod.GET)
|
}, method = RequestMethod.GET)
|
||||||
|
@ -273,6 +311,101 @@ public class CommunityApiController {
|
||||||
|
|
||||||
return communityApiCore.removeCommunitySubjects(id, subjects);
|
return communityApiCore.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 })
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@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, CommunityNotFoundException {
|
||||||
|
|
||||||
|
return communityApiCore.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 })
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@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, CommunityNotFoundException {
|
||||||
|
|
||||||
|
return communityApiCore.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 })
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@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, CommunityNotFoundException {
|
||||||
|
|
||||||
|
return communityApiCore.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 })
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@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, CommunityNotFoundException {
|
||||||
|
|
||||||
|
return communityApiCore.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 })
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@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 String advancedConstraint) throws CommunityException, CommunityNotFoundException {
|
||||||
|
|
||||||
|
return communityApiCore.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 })
|
||||||
|
@ApiResponses(value = {
|
||||||
|
@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, CommunityNotFoundException {
|
||||||
|
|
||||||
|
return communityApiCore.removeCommunityAdvancedConstraint(id);
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
|
@RequestMapping(value = "/community/{id}/zenodocommunities", produces = {
|
||||||
"application/json"
|
"application/json"
|
||||||
|
|
|
@ -1,35 +1,6 @@
|
||||||
package eu.dnetlib.openaire.community;
|
package eu.dnetlib.openaire.community;
|
||||||
|
|
||||||
import static eu.dnetlib.openaire.community.CommunityConstants.CCONTENTPROVIDER_NAME;
|
import java.util.*;
|
||||||
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_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.Base64;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -47,6 +18,8 @@ import com.google.common.collect.Sets;
|
||||||
|
|
||||||
import eu.dnetlib.openaire.common.ISClient;
|
import eu.dnetlib.openaire.common.ISClient;
|
||||||
|
|
||||||
|
import static eu.dnetlib.openaire.community.CommunityConstants.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
|
@ConditionalOnProperty(value = "openaire.exporter.enable.community", havingValue = "true")
|
||||||
public class CommunityApiCore {// implements CommunityClient{
|
public class CommunityApiCore {// implements CommunityClient{
|
||||||
|
@ -99,6 +72,18 @@ public class CommunityApiCore {// implements CommunityClient{
|
||||||
if (details.getSubjects() != null) {
|
if (details.getSubjects() != null) {
|
||||||
isClient.updateContextParam(id, CPROFILE_SUBJECT, Joiner.on(CSV_DELIMITER).join(details.getSubjects()));
|
isClient.updateContextParam(id, CPROFILE_SUBJECT, Joiner.on(CSV_DELIMITER).join(details.getSubjects()));
|
||||||
|
|
||||||
|
}
|
||||||
|
if (details.getFos() != null) {
|
||||||
|
isClient.updateContextParam(id, CPROFILE_FOS, Joiner.on(CSV_DELIMITER).join(details.getFos()));
|
||||||
|
|
||||||
|
}
|
||||||
|
if (details.getSdg() != null) {
|
||||||
|
isClient.updateContextParam(id, CPROFILE_SDG, Joiner.on(CSV_DELIMITER).join(details.getSdg()));
|
||||||
|
|
||||||
|
}
|
||||||
|
if (details.getAdvancedConstraint() != null) {
|
||||||
|
isClient.updateContextParam(id, CPROFILE_ADVANCED_CONSTRAINT, details.getAdvancedConstraint());
|
||||||
|
|
||||||
}
|
}
|
||||||
if (details.getMainZenodoCommunity() != null) {
|
if (details.getMainZenodoCommunity() != null) {
|
||||||
isClient.updateContextParam(id, CSUMMARY_ZENODOC, details.getMainZenodoCommunity());
|
isClient.updateContextParam(id, CSUMMARY_ZENODOC, details.getMainZenodoCommunity());
|
||||||
|
@ -117,40 +102,63 @@ public class CommunityApiCore {// implements CommunityClient{
|
||||||
throw new CommunityException("parameters 'id' and project.communityId must be coherent");
|
throw new CommunityException("parameters 'id' and project.communityId must be coherent");
|
||||||
}
|
}
|
||||||
|
|
||||||
final TreeMap<Integer, CommunityProject> projects = getCommunityProjectMap(id);
|
return updateProject(id, project);
|
||||||
final String project_id = project.getId();
|
|
||||||
|
|
||||||
if (project_id != null && projects.keySet().contains(Integer.valueOf(project_id))) {
|
}
|
||||||
|
|
||||||
|
private CommunityProject updateProject(String id, CommunityProject project) throws CommunityException, CommunityNotFoundException {
|
||||||
|
final TreeMap<Integer, CommunityProject> projects = getCommunityProjectMap(id);
|
||||||
|
String project_id = project.getId();
|
||||||
|
|
||||||
|
if (project_id != null && projects.keySet().contains(Integer.valueOf(project_id))){
|
||||||
if (project.getName() != null) {
|
if (project.getName() != null) {
|
||||||
isClient.updateConceptParam(id + PROJECTS_ID_SUFFIX + ID_SEPARATOR + project_id, CPROJECT_FULLNAME, project.getName());
|
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());
|
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());
|
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());
|
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());
|
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));
|
project.setId(nextId(projects != null && !projects.isEmpty() ? projects.lastKey() : 0));
|
||||||
|
|
||||||
isClient.addConcept(id, id + PROJECTS_ID_SUFFIX, CommunityMappingUtils.asProjectXML(id, project));
|
isClient.addConcept(id, id + PROJECTS_ID_SUFFIX, CommunityMappingUtils.asProjectXML(id, project));
|
||||||
|
|
||||||
}
|
}
|
||||||
cc.updateProject(id, project);
|
cc.updateProject(id, project );
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CommunityProject> addCommunityProjectList(final String id, final List<CommunityProject> projectList) throws CommunityException, CommunityNotFoundException {
|
||||||
|
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();
|
||||||
|
|
||||||
|
for(CommunityProject project : projectList){
|
||||||
|
projects.add(updateProject(id, project));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return projects;
|
||||||
|
}
|
||||||
|
|
||||||
private String nextId(final Integer id) {
|
private String nextId(final Integer id) {
|
||||||
return String.valueOf(id + 1);
|
return String.valueOf(id + 1);
|
||||||
}
|
}
|
||||||
|
@ -164,6 +172,12 @@ public class CommunityApiCore {// implements CommunityClient{
|
||||||
cc.removeFromCategory(id, PROJECTS_ID_SUFFIX, String.valueOf(projectId));
|
cc.removeFromCategory(id, PROJECTS_ID_SUFFIX, String.valueOf(projectId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeCommunityProjectList(final String id, final List<Integer> projectIdList) throws CommunityException, CommunityNotFoundException {
|
||||||
|
for(Integer projectId: projectIdList){
|
||||||
|
removeCommunityProject(id, projectId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<CommunityContentprovider> getCommunityContentproviders(final String id) throws CommunityException, CommunityNotFoundException {
|
public List<CommunityContentprovider> getCommunityContentproviders(final String id) throws CommunityException, CommunityNotFoundException {
|
||||||
cc.getCommunity(id); // ensure the community exists.
|
cc.getCommunity(id); // ensure the community exists.
|
||||||
return cc.getCommunityInfo(id, CONTENTPROVIDERS_ID_SUFFIX, c -> CommunityMappingUtils.asCommunityDataprovider(id, c));
|
return cc.getCommunityInfo(id, CONTENTPROVIDERS_ID_SUFFIX, c -> CommunityMappingUtils.asCommunityDataprovider(id, c));
|
||||||
|
@ -258,6 +272,88 @@ public class CommunityApiCore {// implements CommunityClient{
|
||||||
return cd;
|
return cd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommunityDetails addCommunityFOS(final String id, final List<String> foss) throws CommunityException, CommunityNotFoundException {
|
||||||
|
|
||||||
|
final CommunityDetails cd = new CommunityDetails();
|
||||||
|
|
||||||
|
final Set<String> current = Sets.newHashSet(cc.getCommunity(id).getFos());
|
||||||
|
|
||||||
|
current.addAll(foss);
|
||||||
|
|
||||||
|
cd.setFos(Lists.newArrayList(current));
|
||||||
|
|
||||||
|
setCommunity(id, CommunityWritableProperties.fromDetails(cd));
|
||||||
|
|
||||||
|
return cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommunityDetails removeCommunityFOS(final String id, final List<String> foss) throws CommunityException, CommunityNotFoundException {
|
||||||
|
|
||||||
|
final CommunityDetails cd = new CommunityDetails();
|
||||||
|
|
||||||
|
final Set<String> current = Sets.newHashSet(cc.getCommunity(id).getFos());
|
||||||
|
|
||||||
|
current.removeAll(foss);
|
||||||
|
|
||||||
|
cd.setFos(Lists.newArrayList(current));
|
||||||
|
|
||||||
|
setCommunity(id, CommunityWritableProperties.fromDetails(cd));
|
||||||
|
|
||||||
|
return cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommunityDetails addCommunitySDG(final String id, final List<String> sdgs) throws CommunityException, CommunityNotFoundException {
|
||||||
|
|
||||||
|
final CommunityDetails cd = new CommunityDetails();
|
||||||
|
|
||||||
|
final Set<String> current = Sets.newHashSet(cc.getCommunity(id).getSdg());
|
||||||
|
|
||||||
|
current.addAll(sdgs);
|
||||||
|
|
||||||
|
cd.setFos(Lists.newArrayList(current));
|
||||||
|
|
||||||
|
setCommunity(id, CommunityWritableProperties.fromDetails(cd));
|
||||||
|
|
||||||
|
return cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommunityDetails removeCommunitySDG(final String id, final List<String> sdgs) throws CommunityException, CommunityNotFoundException {
|
||||||
|
|
||||||
|
final CommunityDetails cd = new CommunityDetails();
|
||||||
|
|
||||||
|
final Set<String> current = Sets.newHashSet(cc.getCommunity(id).getSdg());
|
||||||
|
|
||||||
|
current.removeAll(sdgs);
|
||||||
|
|
||||||
|
cd.setFos(Lists.newArrayList(current));
|
||||||
|
|
||||||
|
setCommunity(id, CommunityWritableProperties.fromDetails(cd));
|
||||||
|
|
||||||
|
return cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommunityDetails addCommunityAdvancedConstraint(final String id, final String advancedCosntraint) throws CommunityException, CommunityNotFoundException {
|
||||||
|
|
||||||
|
final CommunityDetails cd = cc.getCommunity(id);
|
||||||
|
|
||||||
|
cd.setAdvancedConstraint(advancedCosntraint);
|
||||||
|
|
||||||
|
setCommunity(id, CommunityWritableProperties.fromDetails(cd));
|
||||||
|
|
||||||
|
return cd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommunityDetails removeCommunityAdvancedConstraint(final String id) throws CommunityException, CommunityNotFoundException {
|
||||||
|
|
||||||
|
final CommunityDetails cd = cc.getCommunity(id);
|
||||||
|
|
||||||
|
cd.setAdvancedConstraint(null);
|
||||||
|
|
||||||
|
setCommunity(id, CommunityWritableProperties.fromDetails(cd));
|
||||||
|
|
||||||
|
return cd;
|
||||||
|
}
|
||||||
|
|
||||||
@CacheEvict(value = "community-cache", allEntries = true)
|
@CacheEvict(value = "community-cache", allEntries = true)
|
||||||
public void removeCommunityZenodoCommunity(final String id, final Integer zenodoCommId) throws CommunityException, CommunityNotFoundException {
|
public void removeCommunityZenodoCommunity(final String id, final Integer zenodoCommId) throws CommunityException, CommunityNotFoundException {
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,9 @@ public class CommunityConstants {
|
||||||
// community profile
|
// community profile
|
||||||
public final static String CPROFILE_SUBJECT = "subject";
|
public final static String CPROFILE_SUBJECT = "subject";
|
||||||
public final static String CPROFILE_CREATIONDATE = "creationdate";
|
public final static String CPROFILE_CREATIONDATE = "creationdate";
|
||||||
|
public final static String CPROFILE_FOS = "fos";
|
||||||
|
public final static String CPROFILE_SDG = "sdg";
|
||||||
|
public final static String CPROFILE_ADVANCED_CONSTRAINT = "advancedConstraint";
|
||||||
|
|
||||||
// community project
|
// community project
|
||||||
public final static String CPROJECT_FUNDER = "funder";
|
public final static String CPROJECT_FUNDER = "funder";
|
||||||
|
|
|
@ -19,6 +19,16 @@ public class CommunityDetails extends CommunitySummary {
|
||||||
@Schema(description = "list of subjects (keywords) that characterise this community")
|
@Schema(description = "list of subjects (keywords) that characterise this community")
|
||||||
private List<String> subjects;
|
private List<String> subjects;
|
||||||
|
|
||||||
|
@Schema(description = "list of fos that characterise this community")
|
||||||
|
private List<String> fos;
|
||||||
|
|
||||||
|
@Schema(description = "list of sdg that characterise this community")
|
||||||
|
private List<String> sdg;
|
||||||
|
|
||||||
|
@Schema(description = "list of advanced criteria to associate results to this community")
|
||||||
|
private String advancedConstraint;
|
||||||
|
|
||||||
|
|
||||||
public CommunityDetails() {}
|
public CommunityDetails() {}
|
||||||
|
|
||||||
public CommunityDetails(final CommunitySummary summary) {
|
public CommunityDetails(final CommunitySummary summary) {
|
||||||
|
@ -52,4 +62,28 @@ public class CommunityDetails extends CommunitySummary {
|
||||||
public void setLastUpdateDate(final Date lastUpdateDate) {
|
public void setLastUpdateDate(final Date lastUpdateDate) {
|
||||||
this.lastUpdateDate = lastUpdateDate;
|
this.lastUpdateDate = lastUpdateDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getFos() {
|
||||||
|
return fos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFos(List<String> fos) {
|
||||||
|
this.fos = fos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getSdg() {
|
||||||
|
return sdg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSdg(List<String> sdg) {
|
||||||
|
this.sdg = sdg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdvancedConstraint() {
|
||||||
|
return advancedConstraint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdvancedConstraint(String advancedConstraint) {
|
||||||
|
this.advancedConstraint = advancedConstraint;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,15 @@ public class CommunityMappingUtils {
|
||||||
if (params.containsKey(CPROFILE_SUBJECT)) {
|
if (params.containsKey(CPROFILE_SUBJECT)) {
|
||||||
p.setSubjects(splitValues(asValues(params.get(CPROFILE_SUBJECT)), CSV_DELIMITER));
|
p.setSubjects(splitValues(asValues(params.get(CPROFILE_SUBJECT)), CSV_DELIMITER));
|
||||||
}
|
}
|
||||||
|
if (params.containsKey(CPROFILE_FOS)) {
|
||||||
|
p.setFos(splitValues(asValues(params.get(CPROFILE_FOS)), CSV_DELIMITER));
|
||||||
|
}
|
||||||
|
if (params.containsKey(CPROFILE_SDG)) {
|
||||||
|
p.setSdg(splitValues(asValues(params.get(CPROFILE_SDG)), CSV_DELIMITER));
|
||||||
|
}
|
||||||
|
if (params.containsKey(CPROFILE_ADVANCED_CONSTRAINT)) {
|
||||||
|
p.setAdvancedConstraint(asCsv(params.get(CPROFILE_ADVANCED_CONSTRAINT)));
|
||||||
|
}
|
||||||
if (params.containsKey(CPROFILE_CREATIONDATE)){
|
if (params.containsKey(CPROFILE_CREATIONDATE)){
|
||||||
try {
|
try {
|
||||||
p.setCreationDate(org.apache.commons.lang3.time.DateUtils.parseDate(asCsv(params.get(CPROFILE_CREATIONDATE)), pattern));
|
p.setCreationDate(org.apache.commons.lang3.time.DateUtils.parseDate(asCsv(params.get(CPROFILE_CREATIONDATE)), pattern));
|
||||||
|
|
|
@ -24,6 +24,16 @@ public class CommunityWritableProperties {
|
||||||
@Schema(description = "list of subjects (keywords) that characterise this community")
|
@Schema(description = "list of subjects (keywords) that characterise this community")
|
||||||
private List<String> subjects;
|
private List<String> subjects;
|
||||||
|
|
||||||
|
@Schema(description = "list of fos that characterise this community")
|
||||||
|
private List<String> fos;
|
||||||
|
|
||||||
|
@Schema(description = "list of sdg that characterise this community")
|
||||||
|
private List<String> sdg;
|
||||||
|
|
||||||
|
@Schema(description = "Advanced constraint for the association of results to the community")
|
||||||
|
private String advancedConstraint;
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "status of the community, drives its visibility")
|
@Schema(description = "status of the community, drives its visibility")
|
||||||
private CommunityStatus status;
|
private CommunityStatus status;
|
||||||
|
|
||||||
|
@ -39,9 +49,36 @@ public class CommunityWritableProperties {
|
||||||
p.setSubjects(details.getSubjects());
|
p.setSubjects(details.getSubjects());
|
||||||
p.setStatus(details.getStatus());
|
p.setStatus(details.getStatus());
|
||||||
p.setMainZenodoCommunity(details.getZenodoCommunity());
|
p.setMainZenodoCommunity(details.getZenodoCommunity());
|
||||||
|
p.setFos(details.getFos());
|
||||||
|
p.setSdg(details.getSdg());
|
||||||
|
p.setAdvancedConstraint(details.getAdvancedConstraint());
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getFos() {
|
||||||
|
return fos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFos(List<String> fos) {
|
||||||
|
this.fos = fos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getSdg() {
|
||||||
|
return sdg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSdg(List<String> sdg) {
|
||||||
|
this.sdg = sdg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdvancedConstraint() {
|
||||||
|
return advancedConstraint;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdvancedConstraint(String advancedConstraint) {
|
||||||
|
this.advancedConstraint = advancedConstraint;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue