new_model_for_communities #15
|
@ -346,9 +346,9 @@ public class CommunityApiController {
|
|||
})
|
||||
public void removeCommunityOrganization(
|
||||
@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 = {
|
||||
|
@ -364,9 +364,9 @@ public class CommunityApiController {
|
|||
})
|
||||
public void removeCommunityOrganizationList(
|
||||
@PathVariable final String id,
|
||||
@RequestBody final String[] orgsIdList) throws CommunityException {
|
||||
@RequestBody final String[] orgNames) throws CommunityException {
|
||||
|
||||
communityService.removeCommunityOrganizations(id, orgsIdList);
|
||||
communityService.removeCommunityOrganizations(id, orgNames);
|
||||
}
|
||||
|
||||
// **********************
|
||||
|
|
|
@ -23,11 +23,11 @@ import eu.dnetlib.openaire.community.model.DbCommunity;
|
|||
import eu.dnetlib.openaire.community.model.DbDatasource;
|
||||
import eu.dnetlib.openaire.community.model.DbDatasourcePK;
|
||||
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.DbProjectPK;
|
||||
import eu.dnetlib.openaire.community.model.DbSubCommunity;
|
||||
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.DbDatasourceRepository;
|
||||
import eu.dnetlib.openaire.community.repository.DbOrganizationRepository;
|
||||
|
@ -206,12 +206,12 @@ public class CommunityService {
|
|||
}
|
||||
|
||||
@Transactional
|
||||
public void removeCommunityOrganizations(final String id, final String... ids) throws CommunityException {
|
||||
public void removeCommunityOrganizations(final String id, final String... orgNames) throws CommunityException {
|
||||
try {
|
||||
final List<DbOrganizationPK> list = Arrays.stream(ids)
|
||||
.map(orgId -> new DbOrganizationPK(id, orgId))
|
||||
final List<DbSupportOrgPK> list = Arrays.stream(orgNames)
|
||||
.map(name -> new DbSupportOrgPK(id, name))
|
||||
.collect(Collectors.toList());
|
||||
dbOrganizationRepository.deleteAllById(list);
|
||||
dbSupportOrgRepository.deleteAllById(list);
|
||||
} catch (final Throwable e) {
|
||||
log.error(e);
|
||||
throw new CommunityException(e);
|
||||
|
|
|
@ -11,6 +11,13 @@ public class DbSupportOrgPK implements Serializable {
|
|||
|
||||
private String orgName;
|
||||
|
||||
public DbSupportOrgPK() {}
|
||||
|
||||
public DbSupportOrgPK(final String community, final String orgName) {
|
||||
this.community = community;
|
||||
this.orgName = orgName;
|
||||
}
|
||||
|
||||
public String getCommunity() {
|
||||
return community;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue