-
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
Conversation
Signed-off-by: achour94 <[email protected]>
…olumn-visibility # Conflicts: # src/main/resources/db/changelog/db.changelog-master.yaml # src/test/java/org/gridsuite/studyconfig/server/DtoConverterTest.java
Signed-off-by: achour94 <[email protected]>
|
||
@Column(name = "visible", nullable = false) | ||
@Builder.Default | ||
private Boolean visible = true; |
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.
If nullable = false
, then use primitive type instead of nullable Object.
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") |
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
without nullable=true
?
@Schema(description = "Column visibility", defaultValue = "true") | |
@Schema(description = "Column visibility", nullable=true, defaultValue = "true") |
Double filterTolerance, | ||
|
||
@Schema(description = "Column visibility", defaultValue = "true") | ||
Boolean visible |
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.
why not using the primitive type if null isn't a value we support?
Boolean visible | |
boolean visible |
List<UUID> orderedColumnIds = columnStates.stream() | ||
.sorted(Comparator.comparingInt(ColumnStateUpdateInfos::order)) | ||
.map(ColumnStateUpdateInfos::columnId) | ||
.toList(); | ||
reorderColumns(orderedColumnIds, columns); |
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.
Instead of creating an intermediate list, you can order directly in one step.
<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> |
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.
You can simplify it:
<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> |
Signed-off-by: achour94 <[email protected]>
…olumn-visibility # Conflicts: # src/main/resources/db/changelog/db.changelog-master.yaml
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.
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 |
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.
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!
boolean visible | |
boolean visible = true |
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.
you cannot assign default values directly in record parameter declarations
columns.sort(Comparator.comparing(column -> | ||
columnStates.stream() | ||
.filter(state -> state.columnId().equals(column.getUuid())) | ||
.findFirst() | ||
.map(ColumnStateUpdateInfos::order) | ||
.orElse(Integer.MAX_VALUE) | ||
)); |
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.
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 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); | ||
}); | ||
} |
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.
IntelliJ simplify as
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()))); | |
} |
…olumn sorting logic Signed-off-by: achour94 <[email protected]>
|
No description provided.