2022-02-04 10:12:15 +01:00
package eu.dnetlib.openaire.community ;
2022-08-19 15:21:40 +02:00
import static eu.dnetlib.openaire.common.ExporterConstants.C ;
import static eu.dnetlib.openaire.common.ExporterConstants.C_CP ;
import static eu.dnetlib.openaire.common.ExporterConstants.C_O ;
import static eu.dnetlib.openaire.common.ExporterConstants.C_PJ ;
import static eu.dnetlib.openaire.common.ExporterConstants.C_ZC ;
import static eu.dnetlib.openaire.common.ExporterConstants.R ;
import static eu.dnetlib.openaire.common.ExporterConstants.W ;
2022-02-04 10:12:15 +01:00
import java.util.List ;
2023-06-28 12:29:59 +02:00
import java.util.Map ;
import java.util.Set ;
2022-02-04 10:12:15 +01:00
2023-06-12 14:47:27 +02:00
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty ;
2023-06-20 09:10:14 +02:00
import org.springframework.data.domain.Page ;
2023-06-12 14:47:27 +02:00
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 ;
2023-06-20 09:10:14 +02:00
import org.springframework.web.bind.annotation.RequestParam ;
2023-06-12 14:47:27 +02:00
import org.springframework.web.bind.annotation.RestController ;
2023-03-31 14:53:52 +02:00
import eu.dnetlib.openaire.exporter.exceptions.CommunityException ;
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.selectioncriteria.SelectionCriteria ;
2022-08-19 15:21:40 +02:00
import io.swagger.v3.oas.annotations.Operation ;
import io.swagger.v3.oas.annotations.responses.ApiResponse ;
import io.swagger.v3.oas.annotations.responses.ApiResponses ;
import io.swagger.v3.oas.annotations.tags.Tag ;
2022-02-04 10:12:15 +01:00
@RestController
2022-08-19 15:21:40 +02:00
@CrossOrigin ( origins = {
" * "
} )
2022-02-04 10:12:15 +01:00
@ConditionalOnProperty ( value = " openaire.exporter.enable.community " , havingValue = " true " )
2022-08-19 15:21:40 +02:00
@Tag ( name = " OpenAIRE Communities API " , description = " the OpenAIRE Community API " )
2022-02-04 10:12:15 +01:00
public class CommunityApiController {
@Autowired
2023-06-12 14:47:27 +02:00
private CommunityService communityService ;
2022-02-04 10:12:15 +01:00
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/communities " , produces = {
" application/json "
} , method = RequestMethod . GET )
@Operation ( summary = " get all community profiles " , description = " get all community profiles " , tags = {
C , R
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public List < CommunitySummary > listCommunities ( ) throws CommunityException {
2023-06-12 14:47:27 +02:00
return communityService . listCommunities ( ) ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id} " , produces = {
" application/json "
} , method = RequestMethod . GET )
@Operation ( summary = " get community profile " , description = " get community profile " , tags = {
C , R
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-07-04 11:36:44 +02:00
public CommunityDetails getCommunity ( @PathVariable final String id ) throws CommunityException {
2023-06-12 14:47:27 +02:00
return communityService . getCommunity ( id ) ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id} " , produces = {
" application/json "
} , method = RequestMethod . POST )
@Operation ( summary = " update community details " , description = " update community details " , tags = {
2023-06-30 10:46:20 +02:00
C , W
2022-08-19 15:21:40 +02:00
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public void setCommunity (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final CommunityWritableProperties properties ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-06-12 14:47:27 +02:00
communityService . setCommunity ( id , properties ) ;
2022-02-04 10:12:15 +01:00
}
2023-06-20 09:10:14 +02:00
@RequestMapping ( value = " /community/{id}/projects/{page}/{size} " , produces = {
2022-08-19 15:21:40 +02:00
" application/json "
} , method = RequestMethod . GET )
@Operation ( summary = " get community projects " , description = " get community projects " , tags = {
C_PJ , R
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-06-30 10:46:20 +02:00
public Page < CommunityProject > getCommunityProjects ( @PathVariable final String id , @PathVariable final Integer page , @PathVariable final Integer size )
2023-07-04 11:36:44 +02:00
throws CommunityException {
2023-06-20 09:10:14 +02:00
return communityService . getCommunityProjects ( id , page , size ) ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/projects " , produces = {
" application/json "
} , method = RequestMethod . POST )
@Operation ( summary = " associate a project to the community " , description = " associate a project to the community " , tags = {
C_PJ , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public CommunityProject addCommunityProject (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final CommunityProject project ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-06-12 14:47:27 +02:00
return communityService . addCommunityProject ( id , project ) ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/projects " , produces = {
" application/json "
} , method = RequestMethod . DELETE )
@Operation ( summary = " remove a project from the community " , description = " remove a project from the community " , tags = {
C_PJ , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public void deleteCommunityProject (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-07-05 10:56:11 +02:00
@RequestParam final String projectId ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-07-04 11:36:44 +02:00
communityService . removeCommunityProjects ( id , projectId ) ;
2022-02-04 10:12:15 +01:00
}
2022-09-26 12:15:39 +02:00
@RequestMapping ( value = " /community/{id}/projectList " , produces = {
2023-06-12 14:47:27 +02:00
" application/json "
2022-09-26 12:15:39 +02:00
} , method = RequestMethod . POST )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " associate a list of project to the community " , description = " associate a list of project to the community " , tags = {
C_PJ , W
2022-09-26 12:15:39 +02:00
} )
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-09-26 12:15:39 +02:00
} )
2023-07-04 11:36:44 +02:00
public CommunityProject [ ] addCommunityProjectList (
2023-06-12 14:47:27 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final CommunityProject [ ] projects ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-07-04 11:36:44 +02:00
communityService . addCommunityProjects ( id , projects ) ;
return projects ;
2022-09-26 12:15:39 +02:00
}
@RequestMapping ( value = " /community/{id}/projectList " , produces = {
2023-06-12 14:47:27 +02:00
" application/json "
2022-09-26 12:15:39 +02:00
} , method = RequestMethod . DELETE )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " remove a list of projects from the community " , description = " remove a list of projects from the community " , tags = {
C_PJ , W
2022-09-26 12:15:39 +02:00
} )
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-09-26 12:15:39 +02:00
} )
public void deleteCommunityProjectList (
2023-06-12 14:47:27 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final String [ ] projectIdList ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-07-04 11:36:44 +02:00
communityService . removeCommunityProjects ( id , projectIdList ) ;
2022-09-26 12:15:39 +02:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/contentproviders " , produces = {
" application/json "
} , method = RequestMethod . GET )
@Operation ( summary = " get the list of content providers associated to a given community " , description = " get the list of content providers associated to a given community " , tags = {
C_CP , R
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-07-04 11:36:44 +02:00
public List < CommunityContentprovider > getCommunityContentproviders ( @PathVariable final String id ) throws CommunityException {
2023-06-12 14:47:27 +02:00
return communityService . getCommunityContentproviders ( id ) ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/contentproviders " , produces = {
" application/json "
} , method = RequestMethod . POST )
@Operation ( summary = " associate a content provider to the community " , description = " associate a content provider to the community " , tags = {
C_CP , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public CommunityContentprovider addCommunityContentprovider (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final CommunityContentprovider contentprovider ) throws CommunityException {
communityService . addCommunityContentProviders ( id , contentprovider ) ;
2022-02-04 10:12:15 +01:00
2023-07-04 11:36:44 +02:00
return contentprovider ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/contentproviders " , produces = {
" application/json "
} , method = RequestMethod . DELETE )
@Operation ( summary = " remove the association between a content provider and the community " , description = " remove the association between a content provider and the community " , tags = {
C_CP , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public void removeCommunityContentprovider (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-07-05 10:56:11 +02:00
@RequestParam final String contentproviderId ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-07-04 11:36:44 +02:00
communityService . removeCommunityContentProviders ( id , contentproviderId ) ;
2022-02-04 10:12:15 +01:00
}
2022-09-27 16:06:31 +02:00
@RequestMapping ( value = " /community/{id}/contentprovidersList " , produces = {
2023-06-12 14:47:27 +02:00
" application/json "
2022-09-27 16:06:31 +02:00
} , method = RequestMethod . POST )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " associate a list of content providers to the community " , description = " associate a list of content providers to the community " , tags = {
2023-07-04 11:36:44 +02:00
C_CP , W
2022-09-27 16:06:31 +02:00
} )
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-09-27 16:06:31 +02:00
} )
2023-07-04 11:36:44 +02:00
public CommunityContentprovider [ ] addCommunityContentProvidersList (
2023-06-12 14:47:27 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final CommunityContentprovider [ ] contentprovidersList ) throws CommunityException {
communityService . addCommunityContentProviders ( id , contentprovidersList ) ;
2022-09-27 16:06:31 +02:00
2023-07-04 11:36:44 +02:00
return contentprovidersList ;
2022-09-27 16:06:31 +02:00
}
2022-12-19 12:45:13 +01:00
@RequestMapping ( value = " /community/{id}/contentprovidersList " , produces = {
2023-06-12 14:47:27 +02:00
" application/json "
2022-09-27 16:06:31 +02:00
} , method = RequestMethod . DELETE )
2023-06-12 14:47:27 +02:00
@Operation ( summary = " remove a list of content providers from the community " , description = " remove a list of content providers from the community " , tags = {
2023-07-04 11:36:44 +02:00
C_CP , W
2022-09-27 16:06:31 +02:00
} )
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
2022-09-27 16:06:31 +02:00
} )
public void deleteCommunityContentProvidersList (
2023-06-12 14:47:27 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final String [ ] contentProviderIdList ) throws CommunityException {
2022-09-27 16:06:31 +02:00
2023-07-04 11:36:44 +02:00
communityService . removeCommunityContentProviders ( id , contentProviderIdList ) ;
2022-09-27 16:06:31 +02:00
}
2022-08-19 15:21:40 +02:00
// ADDING CODE FOR COMMUNITY ORGANIZATIONS
2022-02-04 10:12:15 +01:00
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/organizations " , produces = {
" application/json "
} , method = RequestMethod . GET )
@Operation ( summary = " get the list of organizations for a given community " , description = " get the list of organizations for a given community " , tags = {
C_O , R
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-07-04 11:36:44 +02:00
public List < CommunityOrganization > getCommunityOrganizations ( @PathVariable final String id ) throws CommunityException {
2023-06-12 14:47:27 +02:00
return communityService . getCommunityOrganizations ( id ) ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/organizations " , produces = {
" application/json "
} , method = RequestMethod . POST )
@Operation ( summary = " associate an organization to the community " , description = " associate an organization to the community " , tags = {
C_O , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public CommunityOrganization addCommunityOrganization (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final CommunityOrganization organization ) throws CommunityException {
communityService . addCommunityOrganizations ( id , organization ) ;
return organization ;
}
@RequestMapping ( value = " /community/{id}/organizationList " , produces = {
" application/json "
} , method = RequestMethod . POST )
@Operation ( summary = " associate a list of organizations to the community " , description = " associate a list of organizations to the community " , tags = {
C_O , W
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
public CommunityOrganization [ ] addCommunityOrganizationList (
@PathVariable final String id ,
@RequestBody final CommunityOrganization [ ] orgs ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-07-04 11:36:44 +02:00
communityService . addCommunityOrganizations ( id , orgs ) ;
return orgs ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/organizations " , produces = {
" application/json "
} , method = RequestMethod . DELETE )
@Operation ( summary = " remove the association between an organization and the community " , description = " remove the association between an organization and the community " , tags = {
C_O , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public void removeCommunityOrganization (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-07-05 11:20:53 +02:00
@RequestParam final String organizationId ) throws CommunityException {
2023-07-04 11:36:44 +02:00
communityService . removeCommunityOrganizations ( id , organizationId ) ;
}
@RequestMapping ( value = " /community/{id}/organizationList " , produces = {
" application/json "
} , method = RequestMethod . DELETE )
@Operation ( summary = " remove a list of associations between some organizations and the community " , description = " remove a list of associations between some organizations and the community " , tags = {
C_O , W
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
public void removeCommunityOrganizationList (
@PathVariable final String id ,
@RequestBody final String [ ] orgsIdList ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-07-04 11:36:44 +02:00
communityService . removeCommunityOrganizations ( id , orgsIdList ) ;
2022-02-04 10:12:15 +01:00
}
2023-07-04 11:36:44 +02:00
2022-08-19 15:21:40 +02:00
// **********************
@RequestMapping ( value = " /community/{id}/subjects " , produces = {
" application/json "
} , method = RequestMethod . POST )
@Operation ( summary = " associate a subject to the community " , description = " associate a subject to the community " , tags = {
C , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public CommunityDetails addCommunitySubjects (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-06-12 14:47:27 +02:00
return communityService . addCommunitySubjects ( id , subjects ) ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/subjects " , produces = {
" application/json "
} , method = RequestMethod . DELETE )
@Operation ( summary = " remove subjects from a community " , description = " remove subjects from a community " , tags = {
C , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public CommunityDetails removeCommunitySubjects (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-06-12 14:47:27 +02:00
return communityService . removeCommunitySubjects ( id , subjects ) ;
2022-02-04 10:12:15 +01:00
}
2023-06-12 14:47:27 +02:00
@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
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails addCommunityFOS (
2023-06-12 14:47:27 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-06-12 14:47:27 +02:00
return communityService . addCommunityFOS ( id , subjects ) ;
2022-09-26 12:15:39 +02:00
}
2023-06-12 14:47:27 +02:00
@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
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails removeCommunityFOS (
2023-06-12 14:47:27 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-06-12 14:47:27 +02:00
return communityService . removeCommunityFOS ( id , subjects ) ;
2022-09-26 12:15:39 +02:00
}
2023-06-12 14:47:27 +02:00
@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
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails addCommunitySDG (
2023-06-12 14:47:27 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-06-12 14:47:27 +02:00
return communityService . addCommunitySDG ( id , subjects ) ;
2022-09-26 12:15:39 +02:00
}
2023-06-12 14:47:27 +02:00
@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
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails removeCommunitySDG (
2023-06-12 14:47:27 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final String [ ] subjects ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-06-12 14:47:27 +02:00
return communityService . removeCommunitySDG ( id , subjects ) ;
2022-09-26 12:15:39 +02:00
}
2023-06-12 14:47:27 +02:00
@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
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails addAdvancedConstraint (
2023-06-12 14:47:27 +02:00
@PathVariable final String id ,
2023-07-04 11:36:44 +02:00
@RequestBody final SelectionCriteria advancedConstraint ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-06-12 14:47:27 +02:00
return communityService . addCommunityAdvancedConstraint ( id , advancedConstraint ) ;
2022-09-26 12:15:39 +02:00
}
2023-06-12 14:47:27 +02:00
@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
} )
2022-09-26 12:15:39 +02:00
@ApiResponses ( value = {
2023-06-12 14:47:27 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-09-26 12:15:39 +02:00
public CommunityDetails removeAdvancedConstraint (
2023-07-04 11:36:44 +02:00
@PathVariable final String id ) throws CommunityException {
2022-09-26 12:15:39 +02:00
2023-06-12 14:47:27 +02:00
return communityService . removeCommunityAdvancedConstraint ( id ) ;
2022-09-26 12:15:39 +02:00
}
2022-02-04 10:12:15 +01:00
2023-07-05 11:20:53 +02:00
@RequestMapping ( value = " /community/{id}/removeConstraint " , produces = {
" application/json "
} , method = RequestMethod . POST )
@Operation ( summary = " the set of constraints to be used to remove the association between result and community " , description = " the set of constraints to be used to remove 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 addRemoveConstraint (
@PathVariable final String id ,
@RequestBody final SelectionCriteria removeConstraint ) throws CommunityException {
return communityService . addCommunityRemoveConstraint ( id , removeConstraint ) ;
}
@RequestMapping ( value = " /community/{id}/removeConstraint " , produces = {
" application/json "
} , method = RequestMethod . DELETE )
@Operation ( summary = " remove the constraints to remove the association beetween result and community " , description = " remove the constraints to remove the association beetween 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 removeRemoveConstraint ( @PathVariable final String id ) throws CommunityException {
return communityService . removeCommunityRemoveConstraint ( id ) ;
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/zenodocommunities " , produces = {
" application/json "
} , method = RequestMethod . POST )
@Operation ( summary = " associate a Zenodo community to the community " , description = " associate a Zenodo community to the community " , tags = {
C_ZC , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-06-19 15:47:48 +02:00
public CommunityDetails addCommunityZenodoCommunity (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-06-20 09:10:14 +02:00
@RequestParam ( required = false , defaultValue = " false " ) final boolean main ,
2023-07-05 10:49:07 +02:00
@RequestParam final String zenodocommunity ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-06-20 09:10:14 +02:00
return communityService . addCommunityZenodoCommunity ( id , zenodocommunity , main ) ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{id}/zenodocommunities " , produces = {
" application/json "
} , method = RequestMethod . DELETE )
@Operation ( summary = " remove a Zenodo community from a community " , description = " remove a Zenodo community from a community " , tags = {
C_ZC , W
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2022-02-04 10:12:15 +01:00
public void removeCommunityZenodoCommunity (
2022-08-19 15:21:40 +02:00
@PathVariable final String id ,
2023-06-20 09:10:14 +02:00
@RequestParam ( required = false , defaultValue = " false " ) final boolean main ,
2023-07-05 10:49:07 +02:00
@RequestParam final String zenodocommunity ) throws CommunityException {
2022-02-04 10:12:15 +01:00
2023-07-05 10:49:07 +02:00
communityService . removeCommunityZenodoCommunity ( id , zenodocommunity , main ) ;
2022-02-04 10:12:15 +01:00
}
2022-08-19 15:21:40 +02:00
@RequestMapping ( value = " /community/{zenodoId}/openairecommunities " , produces = {
" application/json "
} , method = RequestMethod . GET )
@Operation ( summary = " get the list of OpenAIRE communities associated to a given Zenodo community " , description = " get the list of OpenAIRE communities associated to a given Zenodo community " , tags = {
C_ZC , R
} )
2022-02-04 10:12:15 +01:00
@ApiResponses ( value = {
2022-08-19 15:21:40 +02:00
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-07-04 11:36:44 +02:00
public CommunityOpenAIRECommunities getOpenAireCommunities ( @PathVariable final String zenodoId ) throws CommunityException {
2023-06-19 15:47:48 +02:00
final CommunityOpenAIRECommunities res = new CommunityOpenAIRECommunities ( ) ;
res . setZenodoid ( zenodoId ) ;
2023-06-30 10:55:48 +02:00
res . setOpenAirecommunitylist ( communityService . getOpenAIRECommunitiesByZenodoId ( zenodoId ) ) ;
2023-06-19 15:47:48 +02:00
return res ;
2022-02-04 10:12:15 +01:00
}
2023-06-28 12:29:59 +02:00
// APIs to manage the propagationOrganizationCommunityMap
@RequestMapping ( value = " /propagationOrganizationCommunityMap " , produces = {
" application/json "
} , method = RequestMethod . GET )
@Operation ( summary = " Get the propagationOrganizationCommunityMap " , description = " propagationOrganizationCommunityMap " , tags = {
C_O , R
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-06-30 10:46:20 +02:00
public Map < String , Set < String > > getPropagationOrganizationCommunityMap ( ) throws CommunityException {
2023-06-28 12:29:59 +02:00
return communityService . getPropagationOrganizationCommunityMap ( ) ;
}
2023-06-30 11:27:14 +02:00
@RequestMapping ( value = " /community/{id}/propagationOrganizations " , produces = {
2023-06-28 12:29:59 +02:00
" application/json "
} , method = RequestMethod . GET )
@Operation ( summary = " return the propagation organizations of a community " , description = " return the propagation organizations of a community " , tags = {
C_O , R
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-06-30 11:27:14 +02:00
public Set < String > getPropagationOrganizationsForCommunity ( @PathVariable final String id ) throws CommunityException {
return communityService . getPropagationOrganizationsForCommunity ( id ) ;
2023-06-28 12:29:59 +02:00
}
2023-06-30 11:27:14 +02:00
@RequestMapping ( value = " /community/{id}/propagationOrganizations " , produces = {
2023-06-28 12:29:59 +02:00
" application/json "
} , method = RequestMethod . POST )
@Operation ( summary = " add an organization to the propagationOrganizationCommunityMap " , description = " add an organization to the propagationOrganizationCommunityMap " , tags = {
C_O , W
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-06-30 11:27:14 +02:00
public Set < String > addPropagationOrganizationForCommunity ( @PathVariable final String id ,
2023-06-30 10:46:20 +02:00
@RequestParam final String organizationId ) throws CommunityException {
2023-06-30 11:27:14 +02:00
return communityService . addPropagationOrganizationForCommunity ( id , organizationId ) ;
2023-06-28 12:29:59 +02:00
}
2023-06-30 11:27:14 +02:00
@RequestMapping ( value = " /community/{id}/propagationOrganizations " , produces = {
2023-06-28 12:29:59 +02:00
" application/json "
} , method = RequestMethod . DELETE )
@Operation ( summary = " delete an organization to the propagationOrganizationCommunityMap " , description = " delete an organization to the propagationOrganizationCommunityMap " , tags = {
C_O , W
} )
@ApiResponses ( value = {
@ApiResponse ( responseCode = " 200 " , description = " OK " ) ,
@ApiResponse ( responseCode = " 404 " , description = " not found " ) ,
@ApiResponse ( responseCode = " 500 " , description = " unexpected error " )
} )
2023-06-30 11:27:14 +02:00
public Set < String > removePropagationOrganizationForCommunity ( @PathVariable final String id ,
2023-06-30 10:46:20 +02:00
@RequestParam final String organizationId ) throws CommunityException {
2023-06-30 11:27:14 +02:00
return communityService . removePropagationOrganizationForCommunity ( id , organizationId ) ;
2023-06-28 12:29:59 +02:00
}
2022-02-04 10:12:15 +01:00
}