Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bb758db
extract composite to share description
EtienneLt Sep 11, 2026
81b4eb2
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 14, 2026
0024da5
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 16, 2026
f83c2a3
add userId
EtienneLt Sep 17, 2026
4222783
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 17, 2026
b1ea19c
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 17, 2026
c8c4240
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 23, 2026
a82ef0c
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 24, 2026
8880691
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 25, 2026
5a099e4
review
EtienneLt Sep 25, 2026
58e7561
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 25, 2026
ef493c6
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 25, 2026
108f8d9
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 28, 2026
283b81c
fix encode
EtienneLt Sep 28, 2026
3ec13ac
put description in body request
EtienneLt Sep 28, 2026
f49aee0
clean
EtienneLt Sep 28, 2026
8dd27c9
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Sep 30, 2026
144db76
clean
EtienneLt Oct 1, 2026
25a757c
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Oct 1, 2026
a5d6b0e
clean and add test
EtienneLt Oct 2, 2026
e8a6e50
checkstyle
EtienneLt Oct 2, 2026
168050e
add test
EtienneLt Oct 2, 2026
fa214db
Merge branch 'main' into extract-composite-to-share-description
Mathieu-Deharbe Oct 2, 2026
ef5a535
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Oct 5, 2026
82d713c
Merge branch 'main' into extract-composite-to-share-description
EtienneLt Oct 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ public ResponseEntity<Void> updateNetworkModificationsMetadata(@RequestParam("uu
return ResponseEntity.ok().build();
}

@PutMapping(value = "/network-modifications/name-and-description/{uuid}")
public ResponseEntity<Void> updateModificationNameAndDescription(@PathVariable UUID uuid,
@RequestHeader(HEADER_USER_ID) String userId,
@RequestBody String metadata) {
networkModificationService.updateNetworkModificationNameAndDescription(uuid, metadata, userId);
return ResponseEntity.ok().build();
}

@GetMapping(value = "/containers/references/exists")
public ResponseEntity<Boolean> hasModificationReferences(@RequestParam("uuids") List<UUID> containerUuids) {
return ResponseEntity.ok().body(networkModificationService.hasModificationReferences(containerUuids));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,15 @@ public void updateModificationsMetadata(UUID groupUUid, List<UUID> modifications
restTemplate.exchange(path, HttpMethod.PUT, httpEntity, Void.class);
}

public void updateNetworkModificationNameAndDescription(UUID networkModificationUuid, String metadata, String userId) {
String path = UriComponentsBuilder.fromPath(NETWORK_MODIFICATIONS_PATH + DELIMITER + "name-and-description" + DELIMITER + networkModificationUuid.toString())
.build().toUriString();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set(HEADER_USER_ID, userId);
restTemplate.exchange(getNetworkModificationServerURI(false) + path, HttpMethod.PUT, new HttpEntity<>(metadata, headers), Void.class);
}

public void restoreModifications(UUID groupUUid, List<UUID> modificationsUuids, UUID studyUuid, UUID nodeUuid, String userId) {
Objects.requireNonNull(groupUUid);
Objects.requireNonNull(modificationsUuids);
Expand Down Expand Up @@ -521,7 +530,8 @@ public NetworkModificationsResult insertCompositeModifications(UUID groupUuid,
* @return the reference modification left in place of the composite modification, either in the group of the node
* or in a parent composite
*/
public ModificationReference extractCompositeModificationToShare(@NonNull UUID groupUuid, @NonNull UUID modificationUuid, @NonNull String name) {
public ModificationReference extractCompositeModificationToShare(@NonNull UUID groupUuid, @NonNull UUID modificationUuid, @NonNull String name, String description) {

String path = UriComponentsBuilder.fromPath(COMPOSITE_PATH + "{modificationUuid}" + DELIMITER + "share")
.queryParam(QUERY_PARAM_NAME, name)
.queryParam(QUERY_PARAM_GROUP_UUID, groupUuid)
Expand All @@ -531,7 +541,7 @@ public ModificationReference extractCompositeModificationToShare(@NonNull UUID g
return restTemplate.exchange(
getNetworkModificationServerURI(false) + path,
HttpMethod.POST,
null,
new HttpEntity<>(description),
ModificationReference.class
).getBody();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1987,9 +1987,10 @@ public void shareCompositeNetworkModification(
List<UUID> childrenUuids = networkModificationTreeService.getChildrenUuids(nodeUuid);
try {
// the applied modifications are left unchanged : the node does not need to be rebuilt
ModificationReference newReference = networkModificationService.extractCompositeModificationToShare(groupUuid, modificationUuid, name);
ModificationReference newReference = networkModificationService.extractCompositeModificationToShare(groupUuid, modificationUuid, name, description);
// the composite modification keeps its uuid when extracted, so it is shared under that same uuid
directoryService.createElement(parentDirectoryUuid, description, modificationUuid, name, DirectoryService.MODIFICATION, userId);
// description is null as it is provided by the referenced modification
directoryService.createElement(parentDirectoryUuid, null, modificationUuid, name, DirectoryService.MODIFICATION, userId);
// extraction replaced the local composite by a new reference modification, in the node group or in a parent
// composite: register it on the shared element
directoryService.createElementsReferences(List.of(newReference), studyUuid, nodeUuid, userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
Expand Down Expand Up @@ -163,7 +164,26 @@ void testUpdateNetworkModificationsMetadata() throws Exception {
}

@Test
void testhasModificationReference() throws Exception {
void testUpdateNetworkModificationsNameAndDescription() throws Exception {
UUID modificationUuid = UUID.randomUUID();
String userId = "user";
String metadata = "{\"message\":{\"name\":\"newName\",\"description\":\"newDescription\"}}";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set(HEADER_USER_ID, userId);

mockMvc.perform(put(BASE_URL + "/network-modifications/name-and-description/" + modificationUuid)
.headers(headers)
.content(metadata)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(""));

verify(networkModificationService).updateNetworkModificationNameAndDescription(modificationUuid, metadata, userId);
}

@Test
void testHasModificationReference() throws Exception {
UUID firstUuid = UUID.randomUUID();
UUID secondUuid = UUID.randomUUID();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,14 @@ void testHasModificationReferences() {
networkModificationService.hasModificationReferences(List.of(modificationUuid));
verify(restTemplate).getForObject(eq(expectedUrl), eq(Boolean.class));
}

@Test
void testUpdateNetworkModificationsNameAndDescription() {
UUID modificationUuid = UUID.randomUUID();
String metadata = "";
String expectedUrl = NETWORK_MODIFICATION_SERVER_URI + "/v1/network-modifications/name-and-description/" + modificationUuid;

networkModificationService.updateNetworkModificationNameAndDescription(modificationUuid, metadata, USER_ID);
verify(restTemplate).exchange(eq(expectedUrl), eq(HttpMethod.PUT), org.mockito.ArgumentMatchers.<HttpEntity<String>>any(), eq(Void.class));
}
}
Loading