diff --git a/src/main/java/org/gridsuite/modification/server/NetworkModificationController.java b/src/main/java/org/gridsuite/modification/server/NetworkModificationController.java index 313a7570a..d23ce8cff 100644 --- a/src/main/java/org/gridsuite/modification/server/NetworkModificationController.java +++ b/src/main/java/org/gridsuite/modification/server/NetworkModificationController.java @@ -225,10 +225,11 @@ public ResponseEntity createNetworkCompositeModification(@RequestBody List @GetMapping(value = "/network-composite-modification/{uuid}/network-modifications", produces = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Get the list of the network modifications inside a composite modification") @ApiResponse(responseCode = "200", description = "List of the modifications inside the composite modification") - public ResponseEntity> getNetworkModificationsFromComposite(@PathVariable("uuid") UUID compositeModificationUuid) { + public ResponseEntity> getNetworkModificationsFromComposite(@PathVariable("uuid") UUID compositeModificationUuid, + @Parameter(description = "Only metadata") @RequestParam(name = "onlyMetadata", required = false, defaultValue = "true") Boolean onlyMetadata) { return ResponseEntity.ok() .contentType(MediaType.APPLICATION_JSON) - .body(networkModificationService.getNetworkModificationsFromComposite(compositeModificationUuid) + .body(networkModificationService.getNetworkModificationsFromComposite(compositeModificationUuid, onlyMetadata) ); } diff --git a/src/main/java/org/gridsuite/modification/server/service/NetworkModificationService.java b/src/main/java/org/gridsuite/modification/server/service/NetworkModificationService.java index 79813d0de..ebcd687af 100644 --- a/src/main/java/org/gridsuite/modification/server/service/NetworkModificationService.java +++ b/src/main/java/org/gridsuite/modification/server/service/NetworkModificationService.java @@ -78,8 +78,12 @@ public List getNetworkModifications(UUID groupUuid, boolean o } @Transactional(readOnly = true) - public List getNetworkModificationsFromComposite(UUID compositeModificationUuid) { - return networkModificationRepository.getBasicNetworkModificationsFromComposite(compositeModificationUuid); + public List getNetworkModificationsFromComposite(UUID compositeModificationUuid, boolean onlyMetadata) { + if (onlyMetadata) { + return networkModificationRepository.getBasicNetworkModificationsFromComposite(compositeModificationUuid); + } else { + return networkModificationRepository.getCompositeModificationsInfos(List.of(compositeModificationUuid)); + } } @Transactional(readOnly = true) diff --git a/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java b/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java index eecc990c0..46f00237f 100644 --- a/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java +++ b/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java @@ -717,11 +717,26 @@ void testNetworkCompositeModification() throws Exception { assertThat(modificationRepository.getModificationInfo(compositeModificationUuid)).recursivelyEquals(compositeModificationInfos); assertEquals(modificationsNumber, modificationRepository.getModifications(TEST_GROUP_ID, true, true).size()); - // get the composite modification metadata + // get the composite modification (metadata only) mvcResult = mockMvc.perform(get(URI_GET_COMPOSITE_NETWORK_MODIF_CONTENT + compositeModificationUuid + "/network-modifications")) .andExpect(status().isOk()).andReturn(); List compositeModificationContent = mapper.readValue(mvcResult.getResponse().getContentAsString(), new TypeReference<>() { }); assertEquals(modificationsNumber, compositeModificationContent.size()); + assertNotNull(compositeModificationContent.get(0).getMessageType()); + assertNotNull(compositeModificationContent.get(0).getMessageValues()); + assertNull(((EquipmentAttributeModificationInfos) compositeModificationContent.get(0)).getEquipmentAttributeName()); + assertNull(((EquipmentAttributeModificationInfos) compositeModificationContent.get(0)).getEquipmentAttributeValue()); + assertNull(((EquipmentAttributeModificationInfos) compositeModificationContent.get(0)).getEquipmentType()); + assertNull(((EquipmentAttributeModificationInfos) compositeModificationContent.get(0)).getEquipmentId()); + + // get the composite modification (complete data) + mvcResult = mockMvc.perform(get(URI_GET_COMPOSITE_NETWORK_MODIF_CONTENT + compositeModificationUuid + "/network-modifications?onlyMetadata=false")) + .andExpect(status().isOk()).andReturn(); + compositeModificationContent = mapper.readValue(mvcResult.getResponse().getContentAsString(), new TypeReference<>() { }); + assertEquals("open", ((EquipmentAttributeModificationInfos) compositeModificationContent.get(0)).getEquipmentAttributeName()); + assertEquals(Boolean.TRUE, ((EquipmentAttributeModificationInfos) compositeModificationContent.get(0)).getEquipmentAttributeValue()); + assertEquals(IdentifiableType.SWITCH, ((EquipmentAttributeModificationInfos) compositeModificationContent.get(0)).getEquipmentType()); + assertEquals("v1b1", ((EquipmentAttributeModificationInfos) compositeModificationContent.get(0)).getEquipmentId()); // Insert the composite modification in the group mvcResult = mockMvc.perform(