Skip to content
Closed
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
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<sonar.coverage.exclusions>**/migration/**/*</sonar.coverage.exclusions>
<sonar.organization>gridsuite</sonar.organization>
<sonar.projectKey>org.gridsuite:network-modification-server</sonar.projectKey>
<network-modification.version>0.59.0</network-modification.version>
<network-modification.version>0.60.0-SNAPSHOT</network-modification.version>
</properties>

<build>
Expand Down Expand Up @@ -99,7 +99,7 @@
<type>pom</type>
<scope>import</scope>
</dependency>

<!-- imports -->
<dependency>
<groupId>org.gridsuite</groupId>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static Set<VoltageLevel> getVoltageLevels(@NonNull Identifiable<?> identi
).collect(Collectors.toSet());
}

throw NetworkModificationException.createEquipmentTypeUnknown(identifiable.getClass().getSimpleName());
throw new NetworkModificationException("The equipment type : " + identifiable.getClass().getSimpleName() + " is unknown");
}

public static String getEquipmentTypeName(@NonNull Identifiable<?> identifiable) {
Expand All @@ -98,11 +98,10 @@ public static String getEquipmentTypeName(@NonNull Identifiable<?> identifiable)
/**
* @param hvdcLine The hvdc line to get hvdc type name
* @return The hvdc type name string
* @throws NetworkModificationException if converter station types don't match
*/
private static String getHvdcLineTypeName(HvdcLine hvdcLine) {
if (hvdcLine.getConverterStation1().getHvdcType() != hvdcLine.getConverterStation2().getHvdcType()) {
throw NetworkModificationException.createHybridHvdcUnsupported(hvdcLine.getId());
throw new NetworkModificationException(String.format("The hybrid Hvdc line %s is unsupported", hvdcLine.getId()));
}

return String.format("%s_%s", hvdcLine.getType().name(), hvdcLine.getConverterStation1().getHvdcType().name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
import org.gridsuite.modification.dto.EquipmentAttributeModificationInfos;
import org.gridsuite.modification.dto.ModificationInfos;
import org.gridsuite.modification.server.entities.equipment.modification.attribute.EquipmentAttributeModificationEntity;
import org.gridsuite.modification.server.error.NetworkModificationServerException;

import java.lang.reflect.Constructor;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.UUID;

import static org.gridsuite.modification.NetworkModificationException.Type.MISSING_MODIFICATION_DESCRIPTION;

/**
* @author Slimane Amar <slimane.amar at rte-france.com>
*/
Expand Down Expand Up @@ -86,7 +85,7 @@ public ModificationEntity(UUID id, String type) {

protected ModificationEntity(ModificationInfos modificationInfos) {
if (modificationInfos == null) {
throw new NetworkModificationException(MISSING_MODIFICATION_DESCRIPTION, "Missing network modification description");
throw new NetworkModificationException("Missing network modification description");
}
//We need to limit the precision to avoid database precision storage limit issue (postgres has a precision of 6 digits while h2 can go to 9)
this.date = Instant.now().truncatedTo(ChronoUnit.MICROS);
Expand Down Expand Up @@ -138,7 +137,7 @@ public static ModificationEntity fromDTO(ModificationInfos dto) {
Constructor<? extends ModificationEntity> constructor = entityClass.getConstructor(dto.getClass());
return constructor.newInstance(dto);
} catch (Exception e) {
throw new RuntimeException("Failed to map DTO to Entity", e);
throw new NetworkModificationServerException("Failed to map DTO to Entity: " + e.getCause().getMessage(), e);
}
} else {
throw new IllegalArgumentException("No entity class registered for DTO class: " + dto.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

import jakarta.persistence.*;

import static org.gridsuite.modification.NetworkModificationException.Type.LINE_ATTACH_DESCRIPTION_ERROR;

/**
* @author Nicolas NOIR <nicolas.noir at rte-france.com>
*/
Expand Down Expand Up @@ -98,7 +96,7 @@ private void assignAttributes(LineAttachToVoltageLevelInfos lineAttachToVoltageL
existingVoltageLevelId = lineAttachToVoltageLevelInfos.getExistingVoltageLevelId();
bbsOrBusId = lineAttachToVoltageLevelInfos.getBbsOrBusId();
if (lineAttachToVoltageLevelInfos.getAttachmentLine() == null) {
throw new NetworkModificationException(LINE_ATTACH_DESCRIPTION_ERROR, "Missing required attachment line description");
throw new NetworkModificationException("Missing required attachment line description");
}
lineCreation = new LineCreationEntity(lineAttachToVoltageLevelInfos.getAttachmentLine());
newLine1Id = lineAttachToVoltageLevelInfos.getNewLine1Id();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.MappedSuperclass;
import org.gridsuite.modification.server.error.NetworkModificationServerException;


/**
Expand Down Expand Up @@ -95,7 +96,7 @@ public static EquipmentAttributeModificationEntity<?> createAttributeEntity(Equi
Constructor<? extends EquipmentAttributeModificationEntity<?>> constructor = entityClass.getConstructor(EquipmentAttributeModificationInfos.class);
return constructor.newInstance(dto);
} catch (Exception e) {
throw new RuntimeException("Failed to map DTO to Entity", e);
throw new NetworkModificationServerException("Failed to map DTO to Entity: " + e.getCause().getMessage(), e);
}
} else {
throw new IllegalArgumentException("No entity class registered for attribute value class: " + attributeValueClass);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
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.error;

/**
* @author Mohamed Benrejeb <mohamed.benrejeb at rte-france.com>
*/
public class NetworkModificationGroupNotFoundException extends RuntimeException {

public NetworkModificationGroupNotFoundException(String message) {
super(message);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
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.error;

/**
* @author Mohamed Benrejeb <mohamed.benrejeb at rte-france.com>
*/
public class NetworkModificationServerException extends RuntimeException {

public NetworkModificationServerException(String message) {
super(message);
}

public NetworkModificationServerException(String message, Throwable cause) {
super(message, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.powsybl.iidm.network.*;
import com.powsybl.network.store.client.NetworkStoreService;
import lombok.Getter;
import org.gridsuite.modification.NetworkModificationException;
import org.gridsuite.modification.dto.ModificationInfos;
import org.gridsuite.modification.server.dto.elasticsearch.EquipmentInfos;
import org.gridsuite.modification.server.dto.elasticsearch.ModificationApplicationInfos;
Expand All @@ -26,7 +25,6 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;

import static org.gridsuite.modification.NetworkModificationException.Type.MODIFICATION_ERROR;
import static org.gridsuite.modification.server.elasticsearch.EquipmentInfosService.getIndexedEquipmentTypes;
import static org.gridsuite.modification.server.elasticsearch.EquipmentInfosService.getIndexedEquipmentTypesInModification;

Expand Down Expand Up @@ -196,13 +194,8 @@ public void initModificationApplication(UUID groupUuid, ModificationInfos modifi
}

public List<AbstractBaseImpact> flushModificationApplications() {
try {
networkStoreService.flush(network); // At first
flushImpactedEquipments();
} catch (Exception e) {
throw new NetworkModificationException(MODIFICATION_ERROR, e);
}

networkStoreService.flush(network); // At first
flushImpactedEquipments();
return reduceNetworkImpacts();
}

Expand Down
Loading
Loading