new_model_for_communities #15
|
@ -111,6 +111,22 @@ public class CommunityApiController extends AbstractDnetController {
|
|||
communityService.setCommunity(id, properties);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{id}", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.DELETE)
|
||||
@Operation(summary = "delete a community", description = "delete 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 void deleteCommunity(@PathVariable final String id, @RequestParam(required = false, defaultValue = "false") final boolean recursive)
|
||||
throws CommunityException {
|
||||
communityService.deleteCommunity(id, recursive);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/community/{id}/projects/{page}/{size}", produces = {
|
||||
"application/json"
|
||||
}, method = RequestMethod.GET)
|
||||
|
|
|
@ -539,4 +539,16 @@ public class CommunityService {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteCommunity(final String id, final boolean recursive) {
|
||||
if (recursive) {
|
||||
dbProjectRepository.deleteByCommunity(id);
|
||||
dbDatasourceRepository.deleteByCommunity(id);
|
||||
dbOrganizationRepository.deleteByCommunity(id);
|
||||
dbSupportOrgRepository.deleteByCommunity(id);
|
||||
dbSubCommunityRepository.deleteByCommunity(id);
|
||||
}
|
||||
dbCommunityRepository.deleteById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,4 +12,6 @@ import eu.dnetlib.openaire.community.model.DbDatasourcePK;
|
|||
public interface DbDatasourceRepository extends JpaRepository<DbDatasource, DbDatasourcePK> {
|
||||
|
||||
List<DbDatasource> findByCommunity(String community);
|
||||
|
||||
void deleteByCommunity(String id);
|
||||
}
|
||||
|
|
|
@ -13,4 +13,6 @@ public interface DbOrganizationRepository extends JpaRepository<DbOrganization,
|
|||
|
||||
List<DbOrganization> findByCommunity(String community);
|
||||
|
||||
void deleteByCommunity(String id);
|
||||
|
||||
}
|
||||
|
|
|
@ -13,4 +13,6 @@ public interface DbProjectRepository extends JpaRepository<DbProject, DbProjectP
|
|||
|
||||
Page<DbProject> findByCommunity(String community, Pageable page);
|
||||
|
||||
void deleteByCommunity(String id);
|
||||
|
||||
}
|
||||
|
|
|
@ -14,4 +14,6 @@ public interface DbSubCommunityRepository extends JpaRepository<DbSubCommunity,
|
|||
|
||||
List<DbSubCommunity> findByCommunityAndParent(String community, String parent);
|
||||
|
||||
void deleteByCommunity(String id);
|
||||
|
||||
}
|
||||
|
|
|
@ -13,4 +13,6 @@ public interface DbSupportOrgRepository extends JpaRepository<DbSupportOrg, DbSu
|
|||
|
||||
List<DbSupportOrg> findByCommunity(String community);
|
||||
|
||||
void deleteByCommunity(String id);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue