Skip to content

Commit 1335bbd

Browse files
committed
Add limits properties modification
Signed-off-by: basseche <[email protected]>
1 parent a61637b commit 1335bbd

File tree

4 files changed

+82
-1
lines changed

4 files changed

+82
-1
lines changed

src/main/java/org/gridsuite/modification/server/entities/equipment/creation/OperationalLimitsGroupEntity.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import jakarta.persistence.*;
1010
import lombok.*;
1111
import org.gridsuite.modification.dto.OperationalLimitsGroupInfos;
12+
import org.gridsuite.modification.server.entities.equipment.modification.LimitsPropertyEntity;
1213
import org.springframework.util.CollectionUtils;
1314

1415
import java.util.List;
@@ -38,6 +39,13 @@ public class OperationalLimitsGroupEntity {
3839
@Enumerated(EnumType.STRING)
3940
private OperationalLimitsGroupInfos.Applicability applicability;
4041

42+
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
43+
@JoinTable(
44+
name = "operational_limits_group_properties",
45+
joinColumns = @JoinColumn(name = "op_limits_group_id"), foreignKey = @ForeignKey(name = "operationalLimitsGroups_id_fk"),
46+
inverseJoinColumns = @JoinColumn(name = "limits_property_id"), inverseForeignKey = @ForeignKey(name = "limits_property_fk"))
47+
private List<LimitsPropertyEntity> limitsProperties;
48+
4149
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
4250
@JoinColumn(name = "current_limits_id",
4351
referencedColumnName = "id",
@@ -54,6 +62,7 @@ public static List<OperationalLimitsGroupEntity> toOperationalLimitsGroupsEntiti
5462
null,
5563
limitsGroup.getId(),
5664
limitsGroup.getApplicability(),
65+
limitsGroup.getLimitsPropertiesInfos().stream().map(LimitsPropertyEntity::fromLimitsPropertyInfos).toList(),
5766
new CurrentLimitsEntity(limitsGroup.getCurrentLimits())
5867
)
5968
)
@@ -68,6 +77,8 @@ public static List<OperationalLimitsGroupInfos> fromOperationalLimitsGroupsEntit
6877
.id(limitsGroupEntity.getId())
6978
.applicability(limitsGroupEntity.getApplicability())
7079
.currentLimits(limitsGroupEntity.getCurrentLimits().toCurrentLimitsInfos())
80+
.limitsPropertiesInfos(limitsGroupEntity.getLimitsProperties()
81+
.stream().map(LimitsPropertyEntity::toCurrentLimitsInfos).toList())
7182
.build()
7283
)
7384
.collect(Collectors.toList());
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.gridsuite.modification.server.entities.equipment.modification;
2+
3+
import jakarta.persistence.*;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Getter;
6+
import lombok.NoArgsConstructor;
7+
import org.gridsuite.modification.dto.LimitsPropertyInfos;
8+
9+
import java.util.UUID;
10+
11+
@Getter
12+
@NoArgsConstructor
13+
@AllArgsConstructor
14+
@Entity
15+
@Table(name = "limits_property")
16+
public class LimitsPropertyEntity {
17+
@Id
18+
@GeneratedValue(strategy = GenerationType.AUTO)
19+
@Column(name = "id")
20+
private UUID id;
21+
22+
@Column(name = "name", nullable = false)
23+
private String name;
24+
25+
@Column(name = "value", nullable = false)
26+
private String value;
27+
28+
public static LimitsPropertyEntity fromLimitsPropertyInfos(LimitsPropertyInfos propertyInfos) {
29+
return new LimitsPropertyEntity(UUID.randomUUID(), propertyInfos.name(), propertyInfos.value());
30+
}
31+
32+
public LimitsPropertyInfos toCurrentLimitsInfos() {
33+
return new LimitsPropertyInfos(name, value);
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
2+
<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">
3+
<changeSet author="elcheikhbas (generated)" id="1759761318366-35">
4+
<createTable tableName="limits_property">
5+
<column name="id" type="UUID">
6+
<constraints nullable="false" primaryKey="true" primaryKeyName="limits_propertyPK"/>
7+
</column>
8+
<column name="name" type="VARCHAR(255)">
9+
<constraints nullable="false"/>
10+
</column>
11+
<column name="value" type="VARCHAR(255)">
12+
<constraints nullable="false"/>
13+
</column>
14+
</createTable>
15+
</changeSet>
16+
<changeSet author="elcheikhbas (generated)" id="1759761318366-36">
17+
<createTable tableName="operational_limits_group_properties">
18+
<column name="op_limits_group_id" type="UUID">
19+
<constraints nullable="false"/>
20+
</column>
21+
<column name="limits_property_id" type="UUID">
22+
<constraints nullable="false"/>
23+
</column>
24+
</createTable>
25+
</changeSet>
26+
<changeSet author="elcheikhbas (generated)" id="1759761318366-41">
27+
<addUniqueConstraint columnNames="limits_property_id" constraintName="operational_limits_group_properties_id_uc" tableName="operational_limits_group_properties"/>
28+
</changeSet>
29+
<changeSet author="elcheikhbas (generated)" id="1759761318366-51">
30+
<addForeignKeyConstraint baseColumnNames="limits_property_id" baseTableName="operational_limits_group_properties" constraintName="limits_property_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="limits_property" validate="true"/>
31+
</changeSet>
32+
<changeSet author="elcheikhbas (generated)" id="1759761318366-52">
33+
<addForeignKeyConstraint baseColumnNames="op_limits_group_id" baseTableName="operational_limits_group_properties" constraintName="operationalLimitsGroups_id_fk" deferrable="false" initiallyDeferred="false" referencedColumnNames="uuid" referencedTableName="operational_limits_group" validate="true"/>
34+
</changeSet>
35+
</databaseChangeLog>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ databaseChangeLog:
409409
file: changesets/changelog_20250822T115310Z.xml
410410
relativeToChangelogFile: true
411411
- include:
412-
file: changesets/changelog_20250921T151431Z.xml
412+
file: changesets/changelog_20251006T143445Z.xml
413413
relativeToChangelogFile: true
414414
- include:
415415
file: changesets/changelog_20251003T070056Z.xml

0 commit comments

Comments
 (0)