-
Notifications
You must be signed in to change notification settings - Fork 0
Add visibility management for spreadsheet columns #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
029b3ee
Add visibility management for spreadsheet columns
achour94 888a429
Merge remote-tracking branch 'origin/main' into spreadsheet/persist-c…
achour94 524a531
Add visibility management for spreadsheet columns
achour94 497666b
Refactor column visibility handling to use primitive boolean type
achour94 e30f074
Merge branch 'main' into spreadsheet/persist-column-visibility
achour94 9f2ec23
Merge remote-tracking branch 'origin/main' into spreadsheet/persist-c…
achour94 7982f3f
Refactor column visibility handling to use Boolean type and improve c…
achour94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -51,5 +51,14 @@ public record ColumnInfos( | |||||
String filterValue, | ||||||
|
||||||
@Schema(description = "Filter tolerance for numeric comparisons") | ||||||
Double filterTolerance | ||||||
) { } | ||||||
Double filterTolerance, | ||||||
|
||||||
@Schema(description = "Column visibility", defaultValue = "true") | ||||||
Boolean visible | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not using the primitive type if null isn't a value we support?
Suggested change
|
||||||
) { | ||||||
public ColumnInfos { | ||||||
if (visible == null) { | ||||||
visible = true; | ||||||
} | ||||||
} | ||||||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/org/gridsuite/studyconfig/server/dto/ColumnStateUpdateInfos.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* 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.studyconfig.server.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* DTO for updating column state (visibility and order) | ||
* @author Achour BERRAHMA <achour.berrahma at rte-france.com> | ||
*/ | ||
@Schema(name = "ColumnStateUpdateDto", description = "Column state update information") | ||
public record ColumnStateUpdateInfos( | ||
|
||
@NotNull(message = "Column UUID is mandatory") | ||
@Schema(description = "Column UUID") | ||
UUID columnId, | ||
|
||
@NotNull(message = "Visible state is mandatory") | ||
@Schema(description = "Column visibility state") | ||
Boolean visible, | ||
|
||
@NotNull(message = "Order is mandatory") | ||
@Schema(description = "New position in the column order (0-based index)") | ||
Integer order | ||
|
||
) { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,6 +333,7 @@ public void updateColumn(UUID id, UUID columnId, ColumnInfos dto) { | |
columnEntity.setFilterType(dto.filterType()); | ||
columnEntity.setFilterValue(dto.filterValue()); | ||
columnEntity.setFilterTolerance(dto.filterTolerance()); | ||
columnEntity.setVisible(dto.visible()); | ||
|
||
spreadsheetConfigRepository.save(entity); | ||
} | ||
|
@@ -352,11 +353,35 @@ public void reorderColumns(UUID id, List<UUID> columnOrder) { | |
SpreadsheetConfigEntity entity = findEntityById(id); | ||
List<ColumnEntity> columns = entity.getColumns(); | ||
|
||
columns.sort((c1, c2) -> { | ||
int idx1 = columnOrder.indexOf(c1.getUuid()); | ||
int idx2 = columnOrder.indexOf(c2.getUuid()); | ||
return Integer.compare(idx1, idx2); | ||
}); | ||
reorderColumns(columnOrder, columns); | ||
} | ||
|
||
private static void reorderColumns(List<UUID> columnOrder, List<ColumnEntity> columns) { | ||
columns.sort(Comparator.comparingInt(column -> columnOrder.indexOf(column.getUuid()))); | ||
} | ||
|
||
@Transactional | ||
public void updateColumnStates(UUID id, List<ColumnStateUpdateInfos> columnStates) { | ||
SpreadsheetConfigEntity entity = findEntityById(id); | ||
List<ColumnEntity> columns = entity.getColumns(); | ||
|
||
Map<UUID, ColumnEntity> columnMap = columns.stream() | ||
.collect(Collectors.toMap(ColumnEntity::getUuid, column -> column)); | ||
|
||
for (ColumnStateUpdateInfos state : columnStates) { | ||
ColumnEntity column = columnMap.get(state.columnId()); | ||
if (column == null) { | ||
throw new EntityNotFoundException(COLUMN_NOT_FOUND + state.columnId()); | ||
} | ||
column.setVisible(state.visible()); | ||
} | ||
|
||
// Reorder columns based on the provided states | ||
List<UUID> orderedColumnIds = columnStates.stream() | ||
.sorted(Comparator.comparingInt(ColumnStateUpdateInfos::order)) | ||
.map(ColumnStateUpdateInfos::columnId) | ||
.toList(); | ||
reorderColumns(orderedColumnIds, columns); | ||
Comment on lines
+380
to
+384
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of creating an intermediate list, you can order directly in one step. |
||
} | ||
|
||
private SpreadsheetConfigCollectionInfos readDefaultSpreadsheetConfigCollection() throws IOException { | ||
|
10 changes: 10 additions & 0 deletions
10
src/main/resources/db/changelog/changesets/changelog_20250606T123216Z.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?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="berrahmaach (generated)" id="1749213150568-4"> | ||
<addColumn tableName="spreadsheet_column"> | ||
<column name="visible" type="boolean" defaultValueBoolean="true" valueBoolean="true"> | ||
<constraints nullable="false"/> | ||
</column> | ||
</addColumn> | ||
</changeSet> | ||
</databaseChangeLog> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultValue
withoutnullable=true
?