Skip to content

Commit

Permalink
fix: add toEntity method
Browse files Browse the repository at this point in the history
Signed-off-by: Joris Mancini <joris.mancini_externe@rte-france.com>
  • Loading branch information
TheMaskedTurtle committed Jan 11, 2024
1 parent fe3eeaf commit e70c13f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.gridsuite.modification.server.entities.equipment.modification.FreePropertyEntity;

/**
* @author Joris Mancini <joris.mancini_externe at rte-france.com>
Expand All @@ -33,4 +34,13 @@ public class FreePropertyInfos {

@Schema(description = "property added in current modification")
private boolean added = false;

public FreePropertyEntity toEntity() {
return FreePropertyEntity.builder()
.name(getName())
.value(getValue())
.deletionMark(isDeletionMark())
.added(isAdded())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.gridsuite.modification.server.dto.EquipmentModificationInfos;
import org.gridsuite.modification.server.dto.FreePropertyInfos;
import org.gridsuite.modification.server.dto.ModificationInfos;
import org.gridsuite.modification.server.entities.ModificationEntity;

Expand Down Expand Up @@ -45,12 +46,7 @@ private void assignAttributes(EquipmentModificationInfos equipmentModificationIn
equipmentId = equipmentModificationInfos.getEquipmentId();
List<FreePropertyEntity> newProperties = equipmentModificationInfos.getProperties() == null ? null :
equipmentModificationInfos.getProperties().stream()
.map(prop -> (FreePropertyEntity) FreePropertyEntity.builder()
.name(prop.getName())
.value(prop.getValue())
.deletionMark(prop.isDeletionMark())
.added(prop.isAdded())
.build())
.map(FreePropertyInfos::toEntity)
.toList();
if (this.properties != null) {
// update using the same reference with clear/add (to avoid JPA exception)
Expand Down

0 comments on commit e70c13f

Please sign in to comment.