Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -1535,7 +1535,7 @@
@Parameter(description = "ids of children to remove") @RequestParam("ids") List<UUID> nodeIds,
@Parameter(description = "deleteChildren") @RequestParam(value = "deleteChildren", defaultValue = "false") boolean deleteChildren,
@RequestHeader(HEADER_USER_ID) String userId) {
nodeIds.stream().forEach(nodeId -> studyService.assertNoBlockedNodeInStudy(studyUuid, nodeId));

Check warning on line 1538 in src/main/java/org/gridsuite/study/server/controller/StudyController.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Simplify the code by replacing .stream().forEach() with .forEach().

See more on https://sonarcloud.io/project/issues?id=org.gridsuite%3Astudy-server&issues=AZ3euCfXBWrewn4scNlA&open=AZ3euCfXBWrewn4scNlA&pullRequest=985
studyService.deleteNodes(studyUuid, nodeIds, deleteChildren, userId);
return ResponseEntity.ok().build();
}
Expand Down Expand Up @@ -1735,6 +1735,16 @@
return ResponseEntity.ok().build();
}

@PostMapping(value = "/studies/notification")
@Operation(summary = "Create studies related notification")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The notifications have been sent"),
})
public ResponseEntity<Void> notify(@RequestBody List<UUID> studiesUuid) {
studyService.notify(studiesUuid);
return ResponseEntity.ok().build();
}

@PostMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/sensitivity-analysis/run")
@Operation(summary = "run sensitivity analysis on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The sensitivity analysis has started"), @ApiResponse(responseCode = "403", description = "The study node is not a model node")})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@
@Transactional(readOnly = true)
public void assertNoBlockedNodeInStudy(@NonNull UUID studyUuid, @NonNull UUID nodeUuid) {
List<UUID> nodesUuids = networkModificationTreeService.getNodeTreeUuids(nodeUuid);
getStudyRootNetworks(studyUuid).stream().forEach(rootNetwork ->

Check warning on line 1173 in src/main/java/org/gridsuite/study/server/service/StudyService.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Simplify the code by replacing .stream().forEach() with .forEach().

See more on https://sonarcloud.io/project/issues?id=org.gridsuite%3Astudy-server&issues=AZ3euCc5BWrewn4scNk_&open=AZ3euCc5BWrewn4scNk_&pullRequest=985
rootNetworkNodeInfoService.assertNoBlockedNode(rootNetwork.getId(), nodesUuids)
);
}
Expand Down Expand Up @@ -2661,6 +2661,12 @@
notificationService.emitStudyMetadataChanged(studyUuid);
}

public void notify(List<UUID> studiesUuid) {
for (UUID studyUuid : studiesUuid) {
notify(studyUuid);
}
}

@Transactional
public UUID runSensitivityAnalysis(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid, String userId) {
StudyEntity study = getStudy(studyUuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,17 @@ void testNotifyStudyMetadataUpdated() throws Exception {
checkStudyMetadataUpdatedMessagesReceived();
}

@Test
void testNotifyStudiesMetadataUpdated() throws Exception {
List<UUID> studyUuids = Arrays.asList(UUID.randomUUID(), UUID.randomUUID());
mockMvc.perform(post("/v1/studies/notification")
.header(USER_ID_HEADER, "userId")
.contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(studyUuids)))
.andExpect(status().isOk());
checkStudyMetadataUpdatedMessagesReceived(studyUuids.size());
}

@Test
void testLogsReport() throws Exception {
UUID studyUuid = createStudyWithStubs("userId", CASE_UUID);
Expand Down Expand Up @@ -670,6 +681,12 @@ private void checkNodeAliasUpdateMessageReceived(UUID studyUuid) {
assertEquals(NotificationService.UPDATE_SPREADSHEET_NODE_ALIASES, headersStudyUpdate.get(NotificationService.HEADER_UPDATE_TYPE));
}

private void checkStudyMetadataUpdatedMessagesReceived(int count) {
for (int i = 0; i < count; i++) {
checkStudyMetadataUpdatedMessagesReceived();
}
}

private void checkStudyMetadataUpdatedMessagesReceived() {
// assert that the broker message has been sent for updating study type
Message<byte[]> messageStudyUpdate = output.receive(TIMEOUT, studyUpdateDestination);
Expand Down
Loading