Skip to content

Commit

Permalink
refactor stash / restore api
Browse files Browse the repository at this point in the history
  • Loading branch information
jamal KHEYYAD authored and jamal-khey committed Sep 29, 2023
1 parent d807f4c commit a40111d
Showing 1 changed file with 11 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,20 @@ public ResponseEntity<ModificationInfos> getNetworkModification(
}

@DeleteMapping(value = "/network-modifications", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Delete network modifications")
@Operation(summary = "Delete stash or restore network modifications")
@ApiResponse(responseCode = "200", description = "The network modifications were deleted")
public ResponseEntity<Void> deleteNetworkModifications(
@Parameter(description = "Network modification UUIDs") @RequestParam("uuids") List<UUID> networkModificationUuids,
@Parameter(description = "Group UUID") @RequestParam("groupUuid") UUID groupUuid) {
networkModificationService.deleteNetworkModifications(groupUuid, networkModificationUuids);
@Parameter(description = "Group UUID") @RequestParam("groupUuid") UUID groupUuid,
@Parameter(description = "Whether to stash the modifications") @RequestParam(value = "stash") Boolean stash) {
if (stash == null) {
networkModificationService.deleteNetworkModifications(groupUuid, networkModificationUuids);
} else if (Boolean.TRUE.equals(stash)) {
networkModificationService.stashNetworkModifications(networkModificationUuids);
} else if (Boolean.FALSE.equals(stash)) {
networkModificationService.restoreNetworkModifications(networkModificationUuids);
}

return ResponseEntity.ok().build();
}

Expand Down Expand Up @@ -202,25 +210,6 @@ public ResponseEntity<UUID> createModificationInGroup(@RequestBody ModificationI
return ResponseEntity.ok().body(networkModificationService.createModificationInGroup(modificationsInfos));
}

@PostMapping(value = "/network-modifications/stash", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "stash network modifications")
@ApiResponse(responseCode = "200", description = "The network modifications were stashed")
public ResponseEntity<Void> stashNetworkModifications(
@Parameter(description = "Network modification UUIDs") @RequestParam("uuids") List<UUID> networkModificationUuids,
@Parameter(description = "Group UUID") @RequestParam("groupUuid") UUID groupUuid) {
networkModificationService.stashNetworkModifications(networkModificationUuids);
return ResponseEntity.ok().build();
}

@PostMapping(value = "/network-modifications/restore", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "restore network modifications")
@ApiResponse(responseCode = "200", description = "The network modifications were restored")
public ResponseEntity<Void> restoreNetworkModifications(
@Parameter(description = "Network modification UUIDs") @RequestParam("uuids") List<UUID> networkModificationUuids,
@Parameter(description = "Group UUID") @RequestParam("groupUuid") UUID groupUuid) {
networkModificationService.restoreNetworkModifications(networkModificationUuids);
return ResponseEntity.ok().build();
}

@PutMapping(value = "/groups/{groupUuid}/duplications", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Duplicate all modifications in a group and append them at the end of another modifications group")
Expand Down

0 comments on commit a40111d

Please sign in to comment.