Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -54,5 +54,5 @@ public record ColumnInfos(
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")

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

) { }
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ public class ColumnEntity {

@Column(name = "visible", nullable = false)
@Builder.Default
private Boolean visible = true;
private boolean visible = true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public static ColumnInfos toColumnDto(ColumnEntity entity) {
entity.getFilterType(),
entity.getFilterValue(),
entity.getFilterTolerance(),
entity.getVisible()
entity.isVisible()
);
}

Expand All @@ -90,7 +90,7 @@ public static ColumnEntity toColumnEntity(ColumnInfos dto) {
.filterType(dto.filterType())
.filterValue(dto.filterValue())
.filterTolerance(dto.filterTolerance())
.visible(dto.visible() != null ? dto.visible() : true)
.visible(dto.visible())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +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() != null ? dto.visible() : true);
columnEntity.setVisible(dto.visible());

spreadsheetConfigRepository.save(entity);
}
Expand Down Expand Up @@ -381,11 +381,13 @@ public void updateColumnStates(UUID id, List<ColumnStateUpdateInfos> columnState
}

// Reorder columns based on the provided states
List<UUID> orderedColumnIds = columnStates.stream()
.sorted(Comparator.comparingInt(ColumnStateUpdateInfos::order))
.map(ColumnStateUpdateInfos::columnId)
.toList();
reorderColumns(orderedColumnIds, columns);
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.

}

private SpreadsheetConfigCollectionInfos readDefaultSpreadsheetConfigCollection() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@
<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">
<column name="visible" type="boolean" defaultValueBoolean="true" valueBoolean="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>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void testConversionToEntityOfSpreadsheetConfig() {
assertThat(e.getColumns().get(0).getFilterType()).isEqualTo("greaterThan");
assertThat(e.getColumns().get(0).getFilterValue()).isEqualTo("100");
assertThat(e.getColumns().get(0).getFilterTolerance()).isEqualTo(0.5);
assertThat(e.getColumns().get(0).getVisible()).isTrue();
assertThat(e.getColumns().get(0).isVisible()).isTrue();

assertThat(e.getColumns().get(1).getName()).isEqualTo("Column2");
assertThat(e.getColumns().get(1).getFormula()).isEqualTo("Z*W");
Expand All @@ -143,7 +143,7 @@ void testConversionToEntityOfSpreadsheetConfig() {
assertThat(e.getColumns().get(1).getFilterType()).isNull();
assertThat(e.getColumns().get(1).getFilterValue()).isNull();
assertThat(e.getColumns().get(1).getFilterTolerance()).isNull();
assertThat(e.getColumns().get(1).getVisible()).isTrue();
assertThat(e.getColumns().get(1).isVisible()).isTrue();

// Global filter assertions
assertThat(e.getGlobalFilters()).hasSize(1);
Expand Down Expand Up @@ -212,7 +212,7 @@ void testConversionToEntityOfColumnWithFilter() {
assertThat(e.getFilterType()).isEqualTo("lessThan");
assertThat(e.getFilterValue()).isEqualTo("50.5");
assertThat(e.getFilterTolerance()).isEqualTo(0.1);
assertThat(e.getVisible()).isTrue();
assertThat(e.isVisible()).isTrue();
});
}

Expand Down