new_model_for_communities #15

Merged
michele.artini merged 81 commits from new_model_for_communities into master 2023-10-24 08:12:26 +02:00
3 changed files with 16 additions and 9 deletions
Showing only changes of commit dde8e1c564 - Show all commits

View File

@ -346,9 +346,9 @@ public class CommunityApiController {
}) })
public void removeCommunityOrganization( public void removeCommunityOrganization(
@PathVariable final String id, @PathVariable final String id,
@RequestParam final String organizationId) throws CommunityException { @RequestParam final String organizationName) throws CommunityException {
communityService.removeCommunityOrganizations(id, organizationId); communityService.removeCommunityOrganizations(id, organizationName);
} }
@RequestMapping(value = "/community/{id}/organizationList", produces = { @RequestMapping(value = "/community/{id}/organizationList", produces = {
@ -364,9 +364,9 @@ public class CommunityApiController {
}) })
public void removeCommunityOrganizationList( public void removeCommunityOrganizationList(
@PathVariable final String id, @PathVariable final String id,
@RequestBody final String[] orgsIdList) throws CommunityException { @RequestBody final String[] orgNames) throws CommunityException {
communityService.removeCommunityOrganizations(id, orgsIdList); communityService.removeCommunityOrganizations(id, orgNames);
} }
// ********************** // **********************

View File

@ -23,11 +23,11 @@ import eu.dnetlib.openaire.community.model.DbCommunity;
import eu.dnetlib.openaire.community.model.DbDatasource; import eu.dnetlib.openaire.community.model.DbDatasource;
import eu.dnetlib.openaire.community.model.DbDatasourcePK; import eu.dnetlib.openaire.community.model.DbDatasourcePK;
import eu.dnetlib.openaire.community.model.DbOrganization; import eu.dnetlib.openaire.community.model.DbOrganization;
import eu.dnetlib.openaire.community.model.DbOrganizationPK;
import eu.dnetlib.openaire.community.model.DbProject; import eu.dnetlib.openaire.community.model.DbProject;
import eu.dnetlib.openaire.community.model.DbProjectPK; import eu.dnetlib.openaire.community.model.DbProjectPK;
import eu.dnetlib.openaire.community.model.DbSubCommunity; import eu.dnetlib.openaire.community.model.DbSubCommunity;
import eu.dnetlib.openaire.community.model.DbSupportOrg; import eu.dnetlib.openaire.community.model.DbSupportOrg;
import eu.dnetlib.openaire.community.model.DbSupportOrgPK;
import eu.dnetlib.openaire.community.repository.DbCommunityRepository; import eu.dnetlib.openaire.community.repository.DbCommunityRepository;
import eu.dnetlib.openaire.community.repository.DbDatasourceRepository; import eu.dnetlib.openaire.community.repository.DbDatasourceRepository;
import eu.dnetlib.openaire.community.repository.DbOrganizationRepository; import eu.dnetlib.openaire.community.repository.DbOrganizationRepository;
@ -206,12 +206,12 @@ public class CommunityService {
} }
@Transactional @Transactional
public void removeCommunityOrganizations(final String id, final String... ids) throws CommunityException { public void removeCommunityOrganizations(final String id, final String... orgNames) throws CommunityException {
try { try {
final List<DbOrganizationPK> list = Arrays.stream(ids) final List<DbSupportOrgPK> list = Arrays.stream(orgNames)
.map(orgId -> new DbOrganizationPK(id, orgId)) .map(name -> new DbSupportOrgPK(id, name))
.collect(Collectors.toList()); .collect(Collectors.toList());
dbOrganizationRepository.deleteAllById(list); dbSupportOrgRepository.deleteAllById(list);
} catch (final Throwable e) { } catch (final Throwable e) {
log.error(e); log.error(e);
throw new CommunityException(e); throw new CommunityException(e);

View File

@ -11,6 +11,13 @@ public class DbSupportOrgPK implements Serializable {
private String orgName; private String orgName;
public DbSupportOrgPK() {}
public DbSupportOrgPK(final String community, final String orgName) {
this.community = community;
this.orgName = orgName;
}
public String getCommunity() { public String getCommunity() {
return community; return community;
} }