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
7 changed files with 38 additions and 0 deletions
Showing only changes of commit cda62bd5e4 - Show all commits

View File

@ -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)

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -13,4 +13,6 @@ public interface DbOrganizationRepository extends JpaRepository<DbOrganization,
List<DbOrganization> findByCommunity(String community);
void deleteByCommunity(String id);
}

View File

@ -13,4 +13,6 @@ public interface DbProjectRepository extends JpaRepository<DbProject, DbProjectP
Page<DbProject> findByCommunity(String community, Pageable page);
void deleteByCommunity(String id);
}

View File

@ -14,4 +14,6 @@ public interface DbSubCommunityRepository extends JpaRepository<DbSubCommunity,
List<DbSubCommunity> findByCommunityAndParent(String community, String parent);
void deleteByCommunity(String id);
}

View File

@ -13,4 +13,6 @@ public interface DbSupportOrgRepository extends JpaRepository<DbSupportOrg, DbSu
List<DbSupportOrg> findByCommunity(String community);
void deleteByCommunity(String id);
}