Skip to content

Conversation

achour94
Copy link
Collaborator

@achour94 achour94 commented Jun 8, 2025

No description provided.

@achour94 achour94 self-assigned this Jun 8, 2025
achour94 added 2 commits June 8, 2025 18:28
…olumn-visibility

# Conflicts:
#	src/main/resources/db/changelog/db.changelog-master.yaml
#	src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java
@Tristan-WorkGH Tristan-WorkGH self-requested a review June 10, 2025 13:23

@Column(name = "visible", nullable = false)
@Builder.Default
private Boolean visible = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If nullable = false, then use primitive type instead of nullable Object.

Suggested change
private Boolean visible = true;
private boolean visible = true;

You can also set the default value at SQL level:

@ColumnDefault(false)

Double filterTolerance
Double filterTolerance,

@Schema(description = "Column visibility", defaultValue = "true")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultValue without nullable=true?

Suggested change
@Schema(description = "Column visibility", defaultValue = "true")
@Schema(description = "Column visibility", nullable=true, defaultValue = "true")

Double filterTolerance,

@Schema(description = "Column visibility", defaultValue = "true")
Boolean visible
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Boolean visible
boolean visible

Comment on lines +384 to +388
List<UUID> orderedColumnIds = columnStates.stream()
.sorted(Comparator.comparingInt(ColumnStateUpdateInfos::order))
.map(ColumnStateUpdateInfos::columnId)
.toList();
reorderColumns(orderedColumnIds, columns);
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Comment on lines 3 to 17
<changeSet author="berrahmaach (generated)" id="1749213150568-4">
<addColumn tableName="spreadsheet_column">
<column name="visible" type="boolean" defaultValueBoolean="true">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>

<!-- Set default value for existing rows -->
<changeSet author="berrahmaach" id="1749213150568-5">
<update tableName="spreadsheet_column">
<column name="visible" valueBoolean="true"/>
<where>visible IS NULL</where>
</update>
</changeSet>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can simplify it:

Suggested change
<changeSet author="berrahmaach (generated)" id="1749213150568-4">
<addColumn tableName="spreadsheet_column">
<column name="visible" type="boolean" defaultValueBoolean="true">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
<!-- Set default value for existing rows -->
<changeSet author="berrahmaach" id="1749213150568-5">
<update tableName="spreadsheet_column">
<column name="visible" valueBoolean="true"/>
<where>visible IS NULL</where>
</update>
</changeSet>
<changeSet author="berrahmaach (generated)" id="1749213150568-4">
<addColumn tableName="spreadsheet_column">
<column name="visible" type="boolean" defaultValueBoolean="true" valueBoolean="true" remarks="Is the column visible in the table?">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>

ref: addColumn > column

@achour94 achour94 requested a review from Tristan-WorkGH June 11, 2025 14:14
Copy link
Contributor

@Tristan-WorkGH Tristan-WorkGH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review, 2 last remarks and that's good.
I set as "approve" to not block you as I'm on holidays next week.


@Schema(description = "Column visibility", defaultValue = "true")
Boolean visible
boolean visible
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attention: if you do that, you must also set the default value in Java because primitive types have 0/false as implicit value when their container object is initialized!

Suggested change
boolean visible
boolean visible = true

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you cannot assign default values directly in record parameter declarations

Comment on lines 384 to 390
columns.sort(Comparator.comparing(column ->
columnStates.stream()
.filter(state -> state.columnId().equals(column.getUuid()))
.findFirst()
.map(ColumnStateUpdateInfos::order)
.orElse(Integer.MAX_VALUE)
));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My previous review was wrong, I was thinking you could reuse the columnMap, but that isn't the case. You're previous version was good.

Comment on lines 359 to 365
private static void reorderColumns(List<UUID> columnOrder, List<ColumnEntity> columns) {
columns.sort((c1, c2) -> {
int idx1 = columnOrder.indexOf(c1.getUuid());
int idx2 = columnOrder.indexOf(c2.getUuid());
return Integer.compare(idx1, idx2);
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntelliJ simplify as

Suggested change
private static void reorderColumns(List<UUID> columnOrder, List<ColumnEntity> columns) {
columns.sort((c1, c2) -> {
int idx1 = columnOrder.indexOf(c1.getUuid());
int idx2 = columnOrder.indexOf(c2.getUuid());
return Integer.compare(idx1, idx2);
});
}
private static void reorderColumns(List<UUID> columnOrder, List<ColumnEntity> columns) {
columns.sort(Comparator.comparingInt(c -> columnOrder.indexOf(c.getUuid())));
}

Copy link

@achour94 achour94 merged commit 5f55ff9 into main Jun 16, 2025
4 checks passed
@achour94 achour94 deleted the spreadsheet/persist-column-visibility branch June 16, 2025 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants