Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
96aa117
implement computation result filters uuid
ghazwarhili Nov 24, 2025
da16f38
clean code
ghazwarhili Nov 29, 2025
c2c5efd
merge main into branch
ghazwarhili Dec 10, 2025
beb30da
resolve conflicts
ghazwarhili Jan 8, 2026
fb3ecee
add TU
ghazwarhili Jan 14, 2026
1865754
Merge branch 'main' into implement-computation-result-filters-uuid
ghazwarhili Jan 14, 2026
1cc78e2
add TU
ghazwarhili Jan 15, 2026
87532f1
code review remarks
ghazwarhili Jan 16, 2026
d0de69b
Merge branch 'main' into implement-computation-result-filters-uuid
ghazwarhili Jan 16, 2026
d119f17
use WireMock for TU
ghazwarhili Jan 16, 2026
df1bdc5
unused import
ghazwarhili Jan 16, 2026
f7fd1be
fix TU
ghazwarhili Jan 16, 2026
73d3e41
fix to send computationType and computationSubType
ghazwarhili Jan 21, 2026
79d4156
use only computationSubType
ghazwarhili Jan 21, 2026
8a79ec3
update ComputationResultFiltersController
ghazwarhili Jan 22, 2026
4806432
resolve conflicts
ghazwarhili Jan 22, 2026
0b12f16
clean code
ghazwarhili Jan 22, 2026
c8b6328
Merge branch 'main' into implement-computation-result-filters-uuid
Meklo Jan 26, 2026
bce1a37
update controller computation result filters
ghazwarhili Jan 30, 2026
ad57b14
Merge remote-tracking branch 'origin/implement-computation-result-fil…
ghazwarhili Jan 30, 2026
059e7d2
resolve conflicts
ghazwarhili Jan 30, 2026
8cd1419
fix checkstyle
ghazwarhili Jan 30, 2026
81a7076
resolve conflicts
ghazwarhili Jan 30, 2026
ff14529
update endpoint
ghazwarhili Jan 30, 2026
f2167e5
Merge branch 'main' into implement-computation-result-filters-uuid
ghazwarhili Jan 30, 2026
9acb6f5
enhance coverage code
ghazwarhili Feb 1, 2026
f048f19
refacto TU
ghazwarhili Feb 2, 2026
c73f48f
Merge branch 'main' into implement-computation-result-filters-uuid
ghazwarhili Feb 2, 2026
381bf77
code review remarks
ghazwarhili Feb 4, 2026
20df8b0
Merge remote-tracking branch 'origin/implement-computation-result-fil…
ghazwarhili Feb 4, 2026
d74cad8
rename to omputationResultsFiltersId
ghazwarhili Feb 5, 2026
7f7f670
Merge branch 'main' into implement-computation-result-filters-uuid
ghazwarhili Feb 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
@@ -0,0 +1,82 @@
/*
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.study.server.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.gridsuite.study.server.StudyApi;
import org.gridsuite.study.server.service.StudyService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.Optional;
import java.util.UUID;
/**
* @author Rehili Ghazwa <ghazwa.rehili at rte-france.com>
*/

@RestController
@RequestMapping(value = "/" + StudyApi.API_VERSION + "/studies/{studyUuid}/computation-result-filters")
@Tag(name = "Study server - Computation result filters")
public class ComputationResultFiltersController {
private final StudyService studyService;

public ComputationResultFiltersController(StudyService studyService) {
this.studyService = studyService;
}

@GetMapping("/{computationType}")
@Operation(summary = "Get study's computation result global filters")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The computation result global filters")})
public ResponseEntity<String> getComputationResultGlobalFilters(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("computationType") String computationType) {
return Optional.ofNullable(studyService.getComputationResultGlobalFilters(studyUuid, computationType))
.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.noContent().build());
}

@GetMapping("/{computationType}/{computationSubType}")
@Operation(summary = "Get study's computation result column filters")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The computation result column filters")})
public ResponseEntity<String> getComputationResultColumnFilters(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("computationType") String computationType,
@PathVariable("computationSubType") String computationSubType) {
return Optional.ofNullable(studyService.getComputationResultColumnFilters(studyUuid, computationType, computationSubType))
.map(ResponseEntity::ok)
.orElseGet(() -> ResponseEntity.noContent().build());
}

@PostMapping("/{computationType}/global-filters")
@Operation(summary = "Set global filters",
description = "Replaces all existing global filters with the provided list for a computation result")
@ApiResponse(responseCode = "204", description = "Global filters set successfully")
@ApiResponse(responseCode = "404", description = "computation result global filters not found")
public ResponseEntity<Void> setGlobalFiltersForComputationResult(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable String computationType,
@RequestBody String globalFilters) {
studyService.setGlobalFiltersForComputationResult(studyUuid, computationType, globalFilters);
return ResponseEntity.noContent().build();
}

@PutMapping("/{computationType}/{computationSubType}/columns")
@Operation(summary = "Update a column", description = "Updates a column")
@ApiResponse(responseCode = "204", description = "Column updated")
public ResponseEntity<Void> updateColumns(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable String computationType,
@PathVariable String computationSubType,
@Valid @RequestBody String columnInfos) {
studyService.updateColumns(studyUuid, computationType, computationSubType, columnInfos);
return ResponseEntity.noContent().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public class StudyEntity extends AbstractManuallyAssignedIdentifierEntity<UUID>
@Column(name = "workspacesConfigUuid")
private UUID workspacesConfigUuid;

@Column(name = "computationResultFiltersUuid")
private UUID computationResultFiltersUuid;

@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "study_voltage_init_parameters_id",
foreignKey = @ForeignKey(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
import org.gridsuite.study.server.repository.StudyEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;

import static org.gridsuite.study.server.StudyConstants.DELIMITER;
import static org.gridsuite.study.server.StudyConstants.STUDY_CONFIG_API_VERSION;
Expand Down Expand Up @@ -49,6 +48,10 @@ public class StudyConfigService {
private static final String NAME_URI = "/name";
private static final String WORKSPACE_PANELS_URI = "/panels";
private static final String DEFAULT_URI = "/default";
private static final String COMPUTATION_RESULT_FILTERS_URI = "/computation-result-filters";
private static final String COMPUTATION_TYPE = "computationType";
private static final String COMPUTATION_SUB_TYPE = "computationSubType";
private static final String COMPUTATION_RESULT_FILTERS_ID = "computationResultFiltersId";

private final RestTemplate restTemplate;

Expand Down Expand Up @@ -423,4 +426,46 @@ public void deleteWorkspacePanelNadConfig(UUID configId, UUID workspaceId, UUID
.buildAndExpand(configId, workspaceId, panelId).toUriString();
restTemplate.delete(studyConfigServerBaseUri + path);
}

public String getComputationResultGlobalFilters(UUID computationResultFiltersId, String computationType) {
Objects.requireNonNull(computationResultFiltersId);
Map<String, Object> uriVariables = Map.of(COMPUTATION_RESULT_FILTERS_ID, computationResultFiltersId, COMPUTATION_TYPE, computationType);
String path = UriComponentsBuilder.fromPath(DELIMITER + STUDY_CONFIG_API_VERSION + COMPUTATION_RESULT_FILTERS_URI +
"/{computationResultFiltersId}/{computationType}").buildAndExpand(uriVariables).toUriString();
return restTemplate.getForObject(studyConfigServerBaseUri + path, String.class);
}

public String getComputationResultColumnFilters(UUID computationResultFiltersId, String computationType, String computationSubType) {
Objects.requireNonNull(computationResultFiltersId);
Map<String, Object> uriVariables = Map.of(COMPUTATION_RESULT_FILTERS_ID, computationResultFiltersId, COMPUTATION_TYPE, computationType, COMPUTATION_SUB_TYPE, computationSubType);
String path = UriComponentsBuilder.fromPath(DELIMITER + STUDY_CONFIG_API_VERSION + COMPUTATION_RESULT_FILTERS_URI +
"/{computationResultFiltersId}/{computationType}/{computationSubType}").buildAndExpand(uriVariables).toUriString();
return restTemplate.getForObject(studyConfigServerBaseUri + path, String.class);
}

public void setGlobalFiltersForComputationResult(UUID computationResultFiltersUuid, String computationType, String globalFilters) {
Map<String, Object> uriVariables = Map.of(COMPUTATION_RESULT_FILTERS_ID, computationResultFiltersUuid, COMPUTATION_TYPE, computationType);
String path = UriComponentsBuilder.fromPath(DELIMITER + STUDY_CONFIG_API_VERSION + COMPUTATION_RESULT_FILTERS_URI +
"/{computationResultFiltersId}/{computationType}/global-filters").buildAndExpand(uriVariables).toUriString();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> httpEntity = new HttpEntity<>(globalFilters, headers);
restTemplate.exchange(studyConfigServerBaseUri + path, HttpMethod.POST, httpEntity, Void.class);
}

public void updateColumns(UUID computationResultFiltersId, String computationType, String computationSubType, String columnInfos) {
Map<String, Object> uriVariables = Map.of(COMPUTATION_RESULT_FILTERS_ID, computationResultFiltersId, COMPUTATION_TYPE, computationType, COMPUTATION_SUB_TYPE, computationSubType);
String path = UriComponentsBuilder.fromPath(DELIMITER + STUDY_CONFIG_API_VERSION + COMPUTATION_RESULT_FILTERS_URI +
"/{computationResultFiltersId}/{computationType}/{computationSubType}/columns").buildAndExpand(uriVariables).toUriString();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> httpEntity = new HttpEntity<>(columnInfos, headers);
restTemplate.put(studyConfigServerBaseUri + path, httpEntity);
}

public UUID createComputationResultsFiltersId() {
var path = UriComponentsBuilder.fromPath(DELIMITER + STUDY_CONFIG_API_VERSION + COMPUTATION_RESULT_FILTERS_URI + DEFAULT_URI)
.buildAndExpand().toUriString();
return restTemplate.exchange(studyConfigServerBaseUri + path, HttpMethod.POST, null, UUID.class).getBody();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
import org.gridsuite.study.server.elasticsearch.StudyInfosService;
import org.gridsuite.study.server.error.StudyException;
import org.gridsuite.study.server.networkmodificationtree.dto.*;
import org.gridsuite.study.server.networkmodificationtree.entities.*;
import org.gridsuite.study.server.networkmodificationtree.entities.NetworkModificationNodeInfoEntity;
import org.gridsuite.study.server.networkmodificationtree.entities.NodeEntity;
import org.gridsuite.study.server.networkmodificationtree.entities.NodeType;
import org.gridsuite.study.server.networkmodificationtree.entities.RootNetworkNodeInfoEntity;
import org.gridsuite.study.server.notification.NotificationService;
import org.gridsuite.study.server.notification.dto.NetworkImpactsInfos;
import org.gridsuite.study.server.repository.*;
Expand Down Expand Up @@ -2788,6 +2791,26 @@ public String getSpreadsheetConfigCollection(UUID studyUuid) {
return studyConfigService.getSpreadsheetConfigCollection(studyConfigService.getSpreadsheetConfigCollectionUuidOrElseCreateDefaults(studyEntity));
}

@Transactional
public String getComputationResultGlobalFilters(UUID studyUuid, String computationType) {
StudyEntity studyEntity = getStudy(studyUuid);
UUID computationResultFiltersId = studyEntity.getComputationResultFiltersUuid();
if (Objects.isNull(computationResultFiltersId)) {
return null;
}
return studyConfigService.getComputationResultGlobalFilters(computationResultFiltersId, computationType);
}

@Transactional
public String getComputationResultColumnFilters(UUID studyUuid, String computationType, String computationSubType) {
StudyEntity studyEntity = getStudy(studyUuid);
UUID computationResultFiltersId = studyEntity.getComputationResultFiltersUuid();
if (Objects.isNull(computationResultFiltersId)) {
return null;
}
return studyConfigService.getComputationResultColumnFilters(computationResultFiltersId, computationType, computationSubType);
}

/**
* Set spreadsheet config collection on study or reset to default one if empty body.
* Default is the user profile one, or system default if no profile is available.
Expand Down Expand Up @@ -3662,6 +3685,28 @@ public void setGlobalFilters(UUID studyUuid, UUID configUuid, String globalFilte
notificationService.emitSpreadsheetConfigChanged(studyUuid, configUuid);
}

@Transactional
public void setGlobalFiltersForComputationResult(UUID studyUuid, String computationType, String globalFilters) {
UUID computationResultFiltersId = getComputationResultFiltersId(studyUuid);
studyConfigService.setGlobalFiltersForComputationResult(computationResultFiltersId, computationType, globalFilters);
}

@Transactional
public void updateColumns(UUID studyUuid, String computationType, String computationSubType, String columnInfos) {
UUID computationResultFiltersId = getComputationResultFiltersId(studyUuid);
studyConfigService.updateColumns(computationResultFiltersId, computationType, computationSubType, columnInfos);
}

public UUID getComputationResultFiltersId(UUID studyUuid) {
StudyEntity studyEntity = getStudy(studyUuid);
UUID computationResultFiltersId = studyEntity.getComputationResultFiltersUuid();
if (Objects.isNull(computationResultFiltersId)) {
computationResultFiltersId = studyConfigService.createComputationResultsFiltersId();
studyEntity.setComputationResultFiltersUuid(computationResultFiltersId);
}
return computationResultFiltersId;
}

public void renameSpreadsheetConfig(UUID studyUuid, UUID configUuid, String newName) {
studyConfigService.renameSpreadsheetConfig(configUuid, newName);
notificationService.emitSpreadsheetConfigChanged(studyUuid, configUuid);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="rehiligha (generated)" id="1763373405443-18">
<addColumn tableName="study">
<column name="computation_result_filters_uuid" type="uuid"/>
</addColumn>
</changeSet>
</databaseChangeLog>
3 changes: 3 additions & 0 deletions src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,6 @@ databaseChangeLog:
- include:
file: changesets/changelog_20260123T095727Z.xml
relativeToChangelogFile: true
- include:
file: changesets/changelog_20251117T095627Z.xml
relativeToChangelogFile: true
Loading