-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
797 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...idsuite/modification/server/entities/equipment/creation/OperationalLimitsGroupEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Copyright (c) 2025, RTE (http://www.rte-france.com) | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.gridsuite.modification.server.entities.equipment.creation; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import org.gridsuite.modification.dto.OperationalLimitsGroupInfos; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.UUID; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* @author Mathieu Deharbe <mathieu.deharbe_externe at rte-france.com> | ||
*/ | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Entity | ||
@Table(name = "operational_limits_group") | ||
public class OperationalLimitsGroupEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
@Column(name = "uuid") | ||
private UUID uuid; | ||
|
||
@Column(name = "id") | ||
private String id; | ||
|
||
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) | ||
@JoinColumn(name = "current_limits_id", | ||
referencedColumnName = "id", | ||
foreignKey = @ForeignKey( | ||
name = "current_limits_id_fk" | ||
)) | ||
private CurrentLimitsEntity currentLimits; | ||
|
||
public static List<OperationalLimitsGroupEntity> toOperationalLimitsGroupsEntities(@NonNull List<OperationalLimitsGroupInfos> limitsGroups) { | ||
return limitsGroups.stream() | ||
.filter(Objects::nonNull) | ||
.map(limitsGroup -> | ||
new OperationalLimitsGroupEntity( | ||
null, | ||
limitsGroup.getId(), | ||
new CurrentLimitsEntity(limitsGroup.getCurrentLimits()) | ||
) | ||
) | ||
.toList(); | ||
} | ||
|
||
public static List<OperationalLimitsGroupInfos> fromOperationalLimitsGroupsEntities(List<OperationalLimitsGroupEntity> limitsGroupsEntities) { | ||
return CollectionUtils.isEmpty(limitsGroupsEntities) ? null : | ||
limitsGroupsEntities.stream() | ||
.map(limitsGroupEntity -> | ||
OperationalLimitsGroupInfos.builder() | ||
.id(limitsGroupEntity.getId()) | ||
.currentLimits(limitsGroupEntity.getCurrentLimits().toCurrentLimitsInfos()) | ||
.build() | ||
) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.