Skip to content

Commit cac9e11

Browse files
Add entity to database
1 parent f725637 commit cac9e11

File tree

5 files changed

+53
-8
lines changed

5 files changed

+53
-8
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
@Getter
2525
@Setter
2626
@Entity
27-
@Table(name = "shortCircuitParameters")
28-
public class ShortCircuitParametersEntity {
27+
@Table(name = "shortcircuit_parameters")
28+
public class AnalysisParametersEntity {
2929

30-
public ShortCircuitParametersEntity(boolean withLimitViolations, boolean withVoltageResult, boolean withFortescueResult, boolean withFeederResult, StudyType studyType, double minVoltageDropProportionalThreshold, boolean withLoads, boolean withShuntCompensators, boolean withVscConverterStations, boolean withNeutralPosition, InitialVoltageProfileMode initialVoltageProfileMode, ShortCircuitPredefinedConfiguration predefinedParameters) {
30+
public AnalysisParametersEntity(boolean withLimitViolations, boolean withVoltageResult, boolean withFortescueResult, boolean withFeederResult, StudyType studyType, double minVoltageDropProportionalThreshold, boolean withLoads, boolean withShuntCompensators, boolean withVscConverterStations, boolean withNeutralPosition, InitialVoltageProfileMode initialVoltageProfileMode, ShortCircuitPredefinedConfiguration predefinedParameters) {
3131
this(null, withLimitViolations, withVoltageResult, withFortescueResult, withFeederResult, studyType, minVoltageDropProportionalThreshold, predefinedParameters, withLoads, withShuntCompensators, withVscConverterStations, withNeutralPosition, initialVoltageProfileMode);
3232
}
3333

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package org.gridsuite.shortcircuit.server.repositories;
8+
9+
import org.gridsuite.shortcircuit.server.entities.AnalysisParametersEntity;
10+
import org.springframework.data.jpa.repository.JpaRepository;
11+
import org.springframework.stereotype.Repository;
12+
13+
import java.util.UUID;
14+
15+
@Repository
16+
public interface ParametersRepository extends JpaRepository<AnalysisParametersEntity, UUID> {
17+
}

src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ private static FeederResult fromEntity(FeederResultEntity feederResultEntity) {
125125
}
126126

127127
//TODO tmp migration
128-
public static ShortCircuitParametersEntity toEntity(ShortCircuitParameters parameters, ShortCircuitPredefinedConfiguration shortCircuitPredefinedConfiguration) {
128+
public static AnalysisParametersEntity toEntity(ShortCircuitParameters parameters, ShortCircuitPredefinedConfiguration shortCircuitPredefinedConfiguration) {
129129
Objects.requireNonNull(parameters);
130-
return new ShortCircuitParametersEntity(parameters.isWithLimitViolations(),
130+
return new AnalysisParametersEntity(parameters.isWithLimitViolations(),
131131
parameters.isWithVoltageResult(),
132132
parameters.isWithFortescueResult(),
133133
parameters.isWithFeederResult(),
@@ -142,7 +142,7 @@ public static ShortCircuitParametersEntity toEntity(ShortCircuitParameters param
142142
}
143143

144144
//TODO tmp migration
145-
public static ShortCircuitParameters fromEntity(ShortCircuitParametersEntity entity) {
145+
public static ShortCircuitParameters fromEntity(AnalysisParametersEntity entity) {
146146
Objects.requireNonNull(entity);
147147
List<VoltageRange> voltageRanges = InitialVoltageProfileMode.CONFIGURED.equals(entity.getInitialVoltageProfileMode()) ? CEI909_VOLTAGE_PROFILE : null;
148148
return new ShortCircuitParameters()
@@ -179,7 +179,7 @@ public static ShortCircuitParameters getDefaultShortCircuitParameters() {
179179
}
180180

181181
//TODO tmp migration
182-
public static ShortCircuitParametersInfos toShortCircuitParametersInfo(ShortCircuitParametersEntity entity) {
182+
public static ShortCircuitParametersInfos toShortCircuitParametersInfo(AnalysisParametersEntity entity) {
183183
Objects.requireNonNull(entity);
184184
return ShortCircuitParametersInfos.builder()
185185
.predefinedParameters(entity.getPredefinedParameters())
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
2+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
3+
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
4+
xmlns:pro="http://www.liquibase.org/xml/ns/pro"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
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">
7+
<changeSet author="chuinetri (generated)" id="1715735535615-1">
8+
<createTable tableName="shortcircuit_parameters">
9+
<column name="id" type="UUID">
10+
<constraints nullable="false" primaryKey="true" primaryKeyName="shortcircuit_parametersPK"/>
11+
</column>
12+
<column name="initial_voltage_profile_mode" type="VARCHAR(255)"/>
13+
<column name="min_voltage_drop_proportional_threshold" type="FLOAT(53)"/>
14+
<column name="predefined_parameters" type="VARCHAR(255)"/>
15+
<column name="study_type" type="VARCHAR(255)"/>
16+
<column defaultValueBoolean="true" name="with_feeder_result" type="BOOLEAN"/>
17+
<column defaultValueBoolean="true" name="with_fortescue_result" type="BOOLEAN"/>
18+
<column defaultValueBoolean="true" name="with_limit_violations" type="BOOLEAN"/>
19+
<column defaultValueBoolean="false" name="with_loads" type="BOOLEAN"/>
20+
<column defaultValueBoolean="true" name="with_neutral_position" type="BOOLEAN"/>
21+
<column defaultValueBoolean="false" name="with_shunt_compensators" type="BOOLEAN"/>
22+
<column defaultValueBoolean="true" name="with_voltage_result" type="BOOLEAN"/>
23+
<column defaultValueBoolean="true" name="with_vsc_converter_stations" type="BOOLEAN"/>
24+
</createTable>
25+
</changeSet>
26+
</databaseChangeLog>

src/main/resources/db/changelog/db.changelog-master.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
databaseChangeLog:
2-
32
- include:
43
file: changesets/changelog_20221003T150015Z.xml
54
relativeToChangelogFile: true
@@ -33,3 +32,6 @@ databaseChangeLog:
3332
- include:
3433
file: changesets/changelog_20240403T090341Z.xml
3534
relativeToChangelogFile: true
35+
- include:
36+
file: changesets/changelog_20240515T001122Z.xml
37+
relativeToChangelogFile: true

0 commit comments

Comments
 (0)