add multiple propagation orgs (comma separeted)

This commit is contained in:
Michele Artini 2023-07-11 13:33:12 +02:00
parent 14e54a5140
commit 096b229c5a
2 changed files with 14 additions and 8 deletions

View File

@ -664,7 +664,8 @@ public class CommunityApiController {
}) })
public Set<String> addPropagationOrganizationForCommunity(@PathVariable final String id, public Set<String> addPropagationOrganizationForCommunity(@PathVariable final String id,
@RequestParam final String organizationId) throws CommunityException { @RequestParam final String organizationId) throws CommunityException {
return communityService.addPropagationOrganizationForCommunity(id, organizationId);
return communityService.addPropagationOrganizationForCommunity(id, organizationId.split(","));
} }
@RequestMapping(value = "/community/{id}/propagationOrganizations", produces = { @RequestMapping(value = "/community/{id}/propagationOrganizations", produces = {
@ -680,7 +681,8 @@ public class CommunityApiController {
}) })
public Set<String> removePropagationOrganizationForCommunity(@PathVariable final String id, public Set<String> removePropagationOrganizationForCommunity(@PathVariable final String id,
@RequestParam final String organizationId) throws CommunityException { @RequestParam final String organizationId) throws CommunityException {
return communityService.removePropagationOrganizationForCommunity(id, organizationId);
return communityService.removePropagationOrganizationForCommunity(id, organizationId.split(","));
} }
} }

View File

@ -512,10 +512,12 @@ public class CommunityService {
} }
@Transactional @Transactional
public Set<String> addPropagationOrganizationForCommunity(final String communityId, final String organizationId) throws CommunityException { public Set<String> addPropagationOrganizationForCommunity(final String communityId, final String... organizationIds) throws CommunityException {
try { try {
final DbOrganization o = new DbOrganization(communityId, organizationId); for (final String orgId : organizationIds) {
dbOrganizationRepository.save(o); final DbOrganization o = new DbOrganization(communityId.trim(), orgId.trim());
dbOrganizationRepository.save(o);
}
return getPropagationOrganizationsForCommunity(communityId); return getPropagationOrganizationsForCommunity(communityId);
} catch (final Throwable e) { } catch (final Throwable e) {
log.error(e); log.error(e);
@ -524,10 +526,12 @@ public class CommunityService {
} }
@Transactional @Transactional
public Set<String> removePropagationOrganizationForCommunity(final String communityId, final String organizationId) throws CommunityException { public Set<String> removePropagationOrganizationForCommunity(final String communityId, final String... organizationIds) throws CommunityException {
try { try {
final DbOrganization o = new DbOrganization(communityId, organizationId); for (final String orgId : organizationIds) {
dbOrganizationRepository.delete(o); final DbOrganization o = new DbOrganization(communityId.trim(), orgId.trim());
dbOrganizationRepository.delete(o);
}
return getPropagationOrganizationsForCommunity(communityId); return getPropagationOrganizationsForCommunity(communityId);
} catch (final Throwable e) { } catch (final Throwable e) {
log.error(e); log.error(e);