diff --git a/src/main/java/eu/bbmri_eric/negotiator/governance/resource/ResourceServiceImpl.java b/src/main/java/eu/bbmri_eric/negotiator/governance/resource/ResourceServiceImpl.java index e7d2e8ceb..64ddda4d9 100644 --- a/src/main/java/eu/bbmri_eric/negotiator/governance/resource/ResourceServiceImpl.java +++ b/src/main/java/eu/bbmri_eric/negotiator/governance/resource/ResourceServiceImpl.java @@ -165,19 +165,9 @@ private static void initializeStateForNewResources( } private Negotiation getNegotiation(String negotiationId) { - Negotiation negotiation = - negotiationRepository - .findById(negotiationId) - .orElseThrow(() -> new EntityNotFoundException(negotiationId)); - return negotiation; - } - - private Request getRequest(String negotiationId) { - Request request = - requestRepository - .findByNegotiation_Id(negotiationId) - .orElseThrow(() -> new EntityNotFoundException(negotiationId)); - return request; + return negotiationRepository + .findById(negotiationId) + .orElseThrow(() -> new EntityNotFoundException(negotiationId)); } private boolean userIsntAuthorized(String negotiationId, Long userId) { diff --git a/src/main/java/eu/bbmri_eric/negotiator/negotiation/mappers/RequestModelsMapper.java b/src/main/java/eu/bbmri_eric/negotiator/negotiation/mappers/RequestModelsMapper.java index c7a9f9f8b..2f1962e54 100644 --- a/src/main/java/eu/bbmri_eric/negotiator/negotiation/mappers/RequestModelsMapper.java +++ b/src/main/java/eu/bbmri_eric/negotiator/negotiation/mappers/RequestModelsMapper.java @@ -42,14 +42,6 @@ public void addMappings() { mapper -> mapper.using(requestToRedirectUrl).map(Request::getId, RequestDTO::setRedirectUrl)); - Converter negotiationToNegotiationId = - q -> convertNegotiationToNegotiationId(q.getSource()); - typeMap.addMappings( - mapper -> - mapper - .using(negotiationToNegotiationId) - .map(Request::getNegotiation, RequestDTO::setNegotiationId)); - /////////////////////////////////////////// // Mapper from v2 Request to V3 Request TypeMap v2ToV3Map = diff --git a/src/main/java/eu/bbmri_eric/negotiator/negotiation/request/Request.java b/src/main/java/eu/bbmri_eric/negotiator/negotiation/request/Request.java index cb876f7d6..e2c5f4a06 100644 --- a/src/main/java/eu/bbmri_eric/negotiator/negotiation/request/Request.java +++ b/src/main/java/eu/bbmri_eric/negotiator/negotiation/request/Request.java @@ -64,11 +64,6 @@ public class Request { @NotNull private Set resources; - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "negotiation_id") - @Exclude - private Negotiation negotiation; - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "discovery_service_id") @JsonIgnore diff --git a/src/main/java/eu/bbmri_eric/negotiator/negotiation/request/RequestRepository.java b/src/main/java/eu/bbmri_eric/negotiator/negotiation/request/RequestRepository.java index ef622d588..269bb3fb0 100644 --- a/src/main/java/eu/bbmri_eric/negotiator/negotiation/request/RequestRepository.java +++ b/src/main/java/eu/bbmri_eric/negotiator/negotiation/request/RequestRepository.java @@ -19,6 +19,4 @@ public interface RequestRepository extends JpaRepository { @EntityGraph(value = "request-with-detailed-resources") Optional findDetailedById(String id); - - Optional findByNegotiation_Id(String negotiationId); } diff --git a/src/main/resources/db/migration/V16.0__move_resources_and_human_readable_to_negotiation.sql b/src/main/resources/db/migration/V16.0__move_resources_and_human_readable_to_negotiation.sql index 466ab904e..1edb38f39 100644 --- a/src/main/resources/db/migration/V16.0__move_resources_and_human_readable_to_negotiation.sql +++ b/src/main/resources/db/migration/V16.0__move_resources_and_human_readable_to_negotiation.sql @@ -17,4 +17,6 @@ set human_readable = ( insert into negotiation_resources_link (negotiation_id, resource_id) select r.negotiation_id, rrl.resource_id from request_resources_link rrl join request r on rrl.request_id = r.id; -delete from request where negotiation_id is null; \ No newline at end of file +delete from request where negotiation_id is null; + +alter table request drop column negotiation_id; \ No newline at end of file diff --git a/src/main/resources/db/test/migration/R__Initial_data.sql b/src/main/resources/db/test/migration/R__Initial_data.sql index 3325781b1..641acb60f 100644 --- a/src/main/resources/db/test/migration/R__Initial_data.sql +++ b/src/main/resources/db/test/migration/R__Initial_data.sql @@ -84,14 +84,14 @@ values (101, '2024-03-11', 101, '2024-03-31', 'REPRESENTATIVE_CONTACTED', 'negot (101, '2024-03-11', 101, '2024-03-31', 'REPRESENTATIVE_CONTACTED', 'negotiation-3', 5), (101, '2024-03-11', 101, '2024-03-31', 'RESOURCE_AVAILABLE', 'negotiation-3', 5); -insert into request (id, url, human_readable, discovery_service_id, negotiation_id) -values ('request-1', 'http://discoveryservice.dev', '#1: No filters used', 1, 'negotiation-1'), - ('request-2', 'http://discoveryservice.dev', '#1: DNA Samples', 1, null), - ('request-5', 'http://discoveryservice.dev', '#1: DNA Samples', 1, 'negotiation-5'), - ('request-v2', 'http://discoveryservice.dev', '#1: Blood Samples', 1, 'negotiation-v2'), - ('request-3', 'http://discoveryservice.dev', '#1: Blood Samples', 1, 'negotiation-3'), - ('request-4', 'http://discoveryservice.dev', '#1: Blood Samples', 1, 'negotiation-4'), - ('request-unassigned', 'http://discoveryservice.dev', '#1: Blood Samples', 1, null); +insert into request (id, url, human_readable, discovery_service_id) +values ('request-1', 'http://discoveryservice.dev', '#1: No filters used', 1), + ('request-2', 'http://discoveryservice.dev', '#1: DNA Samples', 1), + ('request-5', 'http://discoveryservice.dev', '#1: DNA Samples', 1), + ('request-v2', 'http://discoveryservice.dev', '#1: Blood Samples', 1), + ('request-3', 'http://discoveryservice.dev', '#1: Blood Samples', 1), + ('request-4', 'http://discoveryservice.dev', '#1: Blood Samples', 1), + ('request-unassigned', 'http://discoveryservice.dev', '#1: Blood Samples', 1); insert into request_resources_link (request_id, resource_id) values ('request-1', 4), diff --git a/src/test/java/eu/bbmri_eric/negotiator/integration/api/v3/RequestControllerTests.java b/src/test/java/eu/bbmri_eric/negotiator/integration/api/v3/RequestControllerTests.java index a81c2863f..0ae98d0ba 100644 --- a/src/test/java/eu/bbmri_eric/negotiator/integration/api/v3/RequestControllerTests.java +++ b/src/test/java/eu/bbmri_eric/negotiator/integration/api/v3/RequestControllerTests.java @@ -205,6 +205,7 @@ public void testGetAll_Ok_whenNoNegotiationIsAssigned() throws Exception { assertEquals(repository.count(), previousCount); } + @Disabled @Test @WithMockUser public void testGetAll_Ok_whenNegotiationIsAssigned() throws Exception { @@ -226,8 +227,6 @@ public void testGetAll_Ok_whenNegotiationIsAssigned() throws Exception { @WithUserDetails("researcher") public void testGetById_Ok_whenNoNegotiationIsAssigned() throws Exception { RequestDTO r = requestService.create(TestUtils.createRequest(false)); - long previousCount = repository.count(); - mockMvc .perform( MockMvcRequestBuilders.get("%s/%s".formatted(ENDPOINT, r.getId())) @@ -236,9 +235,7 @@ public void testGetById_Ok_whenNoNegotiationIsAssigned() throws Exception { .andExpect(jsonPath("$.id").isString()) .andExpect(jsonPath("$.url", is("http://discoveryservice.dev"))) .andExpect(jsonPath("$.redirectUrl", containsString("http://localhost/request"))) - .andExpect(jsonPath("$.negotiationId").doesNotExist()) .andExpect(jsonPath("$.resources[0].id", is("biobank:1:collection:1"))); - assertEquals(repository.count(), previousCount); } // This is no longer possible since when the negotiation is assigned the request is removed diff --git a/src/test/java/eu/bbmri_eric/negotiator/integration/repository/NotificationRepositoryTest.java b/src/test/java/eu/bbmri_eric/negotiator/integration/repository/NotificationRepositoryTest.java index ccb4259e1..212bab4cd 100644 --- a/src/test/java/eu/bbmri_eric/negotiator/integration/repository/NotificationRepositoryTest.java +++ b/src/test/java/eu/bbmri_eric/negotiator/integration/repository/NotificationRepositoryTest.java @@ -106,7 +106,6 @@ private Negotiation saveNegotiation(Person author) { .payload(payload) .build(); negotiation.setCreatedBy(author); - request.setNegotiation(negotiation); negotiationRepository.save(negotiation); return negotiation; }