Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -9,21 +9,24 @@
/**
* @author Achour BERRAHMA <achour.berrahma at rte-france.com>
*/

// Must be in-sync with EQUIPMENT_TYPES in spreadsheet front component
public enum SheetType {
SUBSTATIONS,
VOLTAGE_LEVELS,
LINES,
TWO_WINDINGS_TRANSFORMERS,
THREE_WINDINGS_TRANSFORMERS,
GENERATORS,
LOADS,
SHUNT_COMPENSATORS,
STATIC_VAR_COMPENSATORS,
BATTERIES,
HVDC_LINES,
LCC_CONVERTER_STATIONS,
VSC_CONVERTER_STATIONS,
DANGLING_LINES,
BUSES,
TIE_LINES
SUBSTATION,
VOLTAGE_LEVEL,
LINE,
TWO_WINDINGS_TRANSFORMER,
THREE_WINDINGS_TRANSFORMER,
GENERATOR,
LOAD,
SHUNT_COMPENSATOR,
STATIC_VAR_COMPENSATOR,
BATTERY,
HVDC_LINE,
LCC_CONVERTER_STATION,
VSC_CONVERTER_STATION,
DANGLING_LINE,
BUS,
TIE_LINE
}

Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ public class SpreadsheetConfigEntity {
@ElementCollection
@CollectionTable(
name = "spreadsheet_custom_column",
joinColumns = @JoinColumn(name = "spreadsheet_config_id")
joinColumns = @JoinColumn(name = "spreadsheet_config_id"),
uniqueConstraints = {
@UniqueConstraint(name = "UK_config_id_name", columnNames = {"spreadsheet_config_id", "name"})
}
)
@OrderColumn(name = "column_order")
@Builder.Default
private List<CustomColumnEmbeddable> customColumns = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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="braquartdav (generated)" id="1729252344073-1">
<dropPrimaryKey tableName="spreadsheet_custom_column"/>
</changeSet>
<changeSet author="braquartdav (generated)" id="1729252344073-3">
<addColumn tableName="spreadsheet_custom_column">
<column name="column_order" type="integer">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
<changeSet author="braquartdav (generated)" id="1729252344073-4">
<addUniqueConstraint columnNames="spreadsheet_config_id, name" constraintName="UK_config_id_name" tableName="spreadsheet_custom_column"/>
</changeSet>
<changeSet author="braquartdav (generated)" id="1729252344073-5">
<createIndex indexName="IX_spreadsheet_custom_columnPK" tableName="spreadsheet_custom_column" unique="true">
<column name="spreadsheet_config_id"/>
<column name="column_order"/>
</createIndex>
</changeSet>
<changeSet author="braquartdav (generated)" id="1729252344073-2">
<addPrimaryKey columnNames="spreadsheet_config_id, column_order" constraintName="spreadsheet_custom_columnPK" tableName="spreadsheet_custom_column"/>
</changeSet>
</databaseChangeLog>
5 changes: 4 additions & 1 deletion src/main/resources/db/changelog/db.changelog-master.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
databaseChangeLog:
- include:
file: changesets/create-spreadsheet-config-table.xml
relativeToChangelogFile: true
relativeToChangelogFile: true
- include:
file: changesets/changelog_20241018T115212Z.xml
relativeToChangelogFile: true
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void testConversionToDtoOfSpreadsheetConfig() {
UUID id = UUID.randomUUID();
SpreadsheetConfigEntity entity = SpreadsheetConfigEntity.builder()
.id(id)
.sheetType(SheetType.BATTERIES)
.sheetType(SheetType.BATTERY)
.customColumns(Arrays.asList(
CustomColumnEmbeddable.builder().name("Column1").formula("A+B").build(),
CustomColumnEmbeddable.builder().name("Column2").formula("C*D").build()
Expand All @@ -45,7 +45,7 @@ void testConversionToDtoOfSpreadsheetConfig() {
.as("DTO conversion result")
.satisfies(d -> {
assertThat(d.id()).isEqualTo(id);
assertThat(d.sheetType()).isEqualTo(SheetType.BATTERIES);
assertThat(d.sheetType()).isEqualTo(SheetType.BATTERY);
assertThat(d.customColumns()).hasSize(2);
assertThat(d.customColumns().get(0).name()).isEqualTo("Column1");
assertThat(d.customColumns().get(0).formula()).isEqualTo("A+B");
Expand All @@ -59,7 +59,7 @@ void testConversionToEntityOfSpreadsheetConfig() {
UUID id = UUID.randomUUID();
SpreadsheetConfigInfos dto = new SpreadsheetConfigInfos(
id,
SheetType.BUSES,
SheetType.BUS,
Arrays.asList(
new CustomColumnInfos("Column1", "X+Y"),
new CustomColumnInfos("Column2", "Z*W")
Expand All @@ -72,7 +72,7 @@ void testConversionToEntityOfSpreadsheetConfig() {
.as("Entity conversion result")
.satisfies(e -> {
assertThat(e.getId()).isEqualTo(id);
assertThat(e.getSheetType()).isEqualTo(SheetType.BUSES);
assertThat(e.getSheetType()).isEqualTo(SheetType.BUS);
assertThat(e.getCustomColumns()).hasSize(2);
assertThat(e.getCustomColumns().get(0).getName()).isEqualTo("Column1");
assertThat(e.getCustomColumns().get(0).getFormula()).isEqualTo("X+Y");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void tearDown() {

@Test
void testCreate() throws Exception {
SpreadsheetConfigInfos configToCreate = new SpreadsheetConfigInfos(null, SheetType.BATTERIES, createCustomColumns());
SpreadsheetConfigInfos configToCreate = new SpreadsheetConfigInfos(null, SheetType.BATTERY, createCustomColumns());

UUID configUuid = postSpreadsheetConfig(configToCreate);
SpreadsheetConfigInfos createdConfig = getSpreadsheetConfig(configUuid);
Expand All @@ -86,7 +86,7 @@ void testCreateWithInvalidData() throws Exception {

@Test
void testRead() throws Exception {
SpreadsheetConfigInfos configToRead = new SpreadsheetConfigInfos(null, SheetType.BUSES, createCustomColumns());
SpreadsheetConfigInfos configToRead = new SpreadsheetConfigInfos(null, SheetType.BUS, createCustomColumns());

UUID configUuid = saveAndReturnId(configToRead);

Expand All @@ -101,15 +101,15 @@ void testRead() throws Exception {

@Test
void testGetMetadata() throws Exception {
SpreadsheetConfigInfos configToRead = new SpreadsheetConfigInfos(null, SheetType.BUSES, createCustomColumns());
SpreadsheetConfigInfos configToRead = new SpreadsheetConfigInfos(null, SheetType.BUS, createCustomColumns());

UUID configUuid = saveAndReturnId(configToRead);

List<MetadataInfos> metadata = getMetadataInfos(configUuid);

assertThat(metadata).hasSize(1);
assertThat(metadata.get(0).id()).isEqualTo(configUuid);
assertThat(metadata.get(0).sheetType()).isEqualTo(SheetType.BUSES);
assertThat(metadata.get(0).sheetType()).isEqualTo(SheetType.BUS);

}

Expand All @@ -121,7 +121,7 @@ private List<MetadataInfos> getMetadataInfos(UUID configUuid) throws Exception {

return mapper.readValue(
receivedMetadata.getResponse().getContentAsString(),
new TypeReference<List<MetadataInfos>>() { });
new TypeReference<>() { });
}

@Test
Expand All @@ -134,7 +134,7 @@ void testReadNonExistent() throws Exception {

@Test
void testUpdateWithInvalidData() throws Exception {
SpreadsheetConfigInfos configToUpdate = new SpreadsheetConfigInfos(null, SheetType.BATTERIES, createCustomColumns());
SpreadsheetConfigInfos configToUpdate = new SpreadsheetConfigInfos(null, SheetType.BATTERY, createCustomColumns());

UUID configUuid = saveAndReturnId(configToUpdate);

Expand All @@ -150,11 +150,11 @@ void testUpdateWithInvalidData() throws Exception {

@Test
void testUpdate() throws Exception {
SpreadsheetConfigInfos configToUpdate = new SpreadsheetConfigInfos(null, SheetType.BATTERIES, createCustomColumns());
SpreadsheetConfigInfos configToUpdate = new SpreadsheetConfigInfos(null, SheetType.BATTERY, createCustomColumns());

UUID configUuid = saveAndReturnId(configToUpdate);

SpreadsheetConfigInfos updatedConfig = new SpreadsheetConfigInfos(configUuid, SheetType.BUSES, createUpdatedCustomColumns());
SpreadsheetConfigInfos updatedConfig = new SpreadsheetConfigInfos(configUuid, SheetType.BUS, createUpdatedCustomColumns());

String updatedConfigJson = mapper.writeValueAsString(updatedConfig);

Expand All @@ -173,7 +173,7 @@ void testUpdate() throws Exception {

@Test
void testDelete() throws Exception {
SpreadsheetConfigInfos configToDelete = new SpreadsheetConfigInfos(null, SheetType.BATTERIES, createCustomColumns());
SpreadsheetConfigInfos configToDelete = new SpreadsheetConfigInfos(null, SheetType.BATTERY, createCustomColumns());

UUID configUuid = saveAndReturnId(configToDelete);

Expand All @@ -195,8 +195,8 @@ void testDeleteNonExistent() throws Exception {

@Test
void testGetAll() throws Exception {
SpreadsheetConfigInfos config1 = new SpreadsheetConfigInfos(null, SheetType.BATTERIES, createCustomColumns());
SpreadsheetConfigInfos config2 = new SpreadsheetConfigInfos(null, SheetType.BUSES, createUpdatedCustomColumns());
SpreadsheetConfigInfos config1 = new SpreadsheetConfigInfos(null, SheetType.BATTERY, createCustomColumns());
SpreadsheetConfigInfos config2 = new SpreadsheetConfigInfos(null, SheetType.BUS, createUpdatedCustomColumns());

saveAndReturnId(config1);
saveAndReturnId(config2);
Expand All @@ -208,7 +208,7 @@ void testGetAll() throws Exception {

@Test
void testDuplicate() throws Exception {
SpreadsheetConfigInfos configToCreate = new SpreadsheetConfigInfos(null, SheetType.BATTERIES, createCustomColumns());
SpreadsheetConfigInfos configToCreate = new SpreadsheetConfigInfos(null, SheetType.BATTERY, createCustomColumns());
UUID configUuid = postSpreadsheetConfig(configToCreate);

UUID duplicatedConfigUuid = duplicateSpreadsheetConfig(configUuid);
Expand Down Expand Up @@ -285,7 +285,7 @@ private List<SpreadsheetConfigInfos> getAllSpreadsheetConfigs() throws Exception

return mapper.readValue(
mvcResult.getResponse().getContentAsString(),
new TypeReference<List<SpreadsheetConfigInfos>>() { });
new TypeReference<>() { });
}

private UUID saveAndReturnId(SpreadsheetConfigInfos config) {
Expand Down
Loading