Skip to content

Commit 845bc0d

Browse files
committed
Merge branch 'add-locationId-to-sa-result' of https://github.com/gridsuite/security-analysis-server into add-locationId-to-sa-result
2 parents 45db592 + 1ee3328 commit 845bc0d

File tree

8 files changed

+34
-9
lines changed

8 files changed

+34
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
build:
11-
uses: powsybl/github-ci/.github/workflows/build-generic.yml@07ff8aa16a298b7d735d50883f6f723d84d87a55
11+
uses: powsybl/github-ci/.github/workflows/build-backend-app-generic.yml@8e3547c7f6d98c23095896b6097294f22100b122
1212
with:
1313
sonarOrganization: gridsuite
1414
sonarProjectKey: org.gridsuite:security-analysis-server

.github/workflows/patch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
run-patch:
12-
uses: powsybl/github-ci/.github/workflows/patch-generic.yml@07ff8aa16a298b7d735d50883f6f723d84d87a55
12+
uses: powsybl/github-ci/.github/workflows/patch-backend-app-generic.yml@8e3547c7f6d98c23095896b6097294f22100b122
1313
with:
1414
githubappId: ${{ vars.GRIDSUITE_ACTIONS_APPID }}
1515
sonarOrganization: gridsuite

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212

1313
jobs:
1414
run-release:
15-
uses: powsybl/github-ci/.github/workflows/release-generic.yml@07ff8aa16a298b7d735d50883f6f723d84d87a55
15+
uses: powsybl/github-ci/.github/workflows/release-backend-app-generic.yml@8e3547c7f6d98c23095896b6097294f22100b122
1616
with:
1717
githubappId: ${{ vars.GRIDSUITE_ACTIONS_APPID }}
1818
sonarOrganization: gridsuite

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@
8686
<dependencyManagement>
8787
<dependencies>
8888
<!-- overrides of imports -->
89-
<dependency><!-- To remove when integrate in next release of gridsuite-dependencies or powsybl-ws-dependencies -->
90-
<groupId>com.powsybl</groupId>
91-
<artifactId>powsybl-ws-commons</artifactId>
92-
<version>1.19.0</version>
93-
</dependency>
9489
<dependency><!-- To remove when integrate in next release of gridsuite-dependencies or powsybl-ws-dependencies -->
9590
<groupId>com.squareup.okhttp3</groupId>
9691
<artifactId>okhttp-bom</artifactId>

src/main/java/org/gridsuite/securityanalysis/server/SecurityAnalysisParametersController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@
1111
import io.swagger.v3.oas.annotations.responses.ApiResponse;
1212
import io.swagger.v3.oas.annotations.responses.ApiResponses;
1313
import io.swagger.v3.oas.annotations.tags.Tag;
14+
import org.gridsuite.securityanalysis.server.dto.LimitReductionsByVoltageLevel;
1415
import org.gridsuite.securityanalysis.server.dto.SecurityAnalysisParametersValues;
1516
import org.gridsuite.securityanalysis.server.service.SecurityAnalysisParametersService;
1617
import org.springframework.http.MediaType;
1718
import org.springframework.http.ResponseEntity;
1819
import org.springframework.web.bind.annotation.*;
1920

21+
import java.util.List;
2022
import java.util.UUID;
2123

2224
/**
@@ -103,4 +105,13 @@ public ResponseEntity<Void> updateProvider(
103105
parametersService.updateProvider(parametersUuid, provider);
104106
return ResponseEntity.ok().build();
105107
}
108+
109+
@GetMapping(value = "/default-limit-reductions", produces = MediaType.APPLICATION_JSON_VALUE)
110+
@Operation(summary = "Get default limit reductions")
111+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The default limit reductions")})
112+
public ResponseEntity<List<LimitReductionsByVoltageLevel>> getDefaultLimitReductions() {
113+
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON)
114+
.body(parametersService.getDefaultLimitReductions());
115+
}
116+
106117
}

src/main/java/org/gridsuite/securityanalysis/server/entities/AbstractLimitViolationEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public abstract class AbstractLimitViolationEntity {
6363

6464
public static Double computeLoading(LimitViolation limitViolation) {
6565
return LimitViolationType.CURRENT.equals(limitViolation.getLimitType())
66-
? (100 * limitViolation.getValue()) / (limitViolation.getLimit() * limitViolation.getLimitReduction())
66+
? 100 * limitViolation.getValue() / limitViolation.getLimit()
6767
: null;
6868
}
6969
}

src/main/java/org/gridsuite/securityanalysis/server/service/SecurityAnalysisParametersService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,8 @@ public void updateProvider(UUID parametersUuid, String provider) {
176176
.orElseThrow()
177177
.updateProvider(provider != null ? provider : defaultProvider);
178178
}
179+
180+
public List<LimitReductionsByVoltageLevel> getDefaultLimitReductions() {
181+
return limitReductionService.createDefaultLimitReductions();
182+
}
179183
}

src/test/java/org/gridsuite/securityanalysis/server/SecurityAnalysisParametersControllerTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package org.gridsuite.securityanalysis.server;
88

9+
import com.fasterxml.jackson.core.type.TypeReference;
910
import com.fasterxml.jackson.databind.ObjectMapper;
1011
import org.gridsuite.securityanalysis.server.dto.LimitReductionsByVoltageLevel;
1112
import org.gridsuite.securityanalysis.server.dto.SecurityAnalysisParametersValues;
@@ -341,6 +342,20 @@ void testRemoveParameters() throws Exception {
341342
assertNull(securityAnalysisParametersRepository.findById(createdParametersUuid).orElse(null));
342343
}
343344

345+
@Test
346+
void testGetDefaultLimitReductions() throws Exception {
347+
MvcResult mvcResult = mockMvc.perform(get("/v1/parameters/default-limit-reductions")
348+
.contentType(MediaType.APPLICATION_JSON))
349+
.andExpect(status().isOk())
350+
.andReturn();
351+
352+
String responseContent = mvcResult.getResponse().getContentAsString();
353+
List<LimitReductionsByVoltageLevel> limitReductions = objectMapper.readValue(responseContent, new TypeReference<>() { });
354+
355+
assertNotNull(limitReductions);
356+
assertFalse(limitReductions.isEmpty());
357+
}
358+
344359
private void assertSecurityAnalysisParametersEntityAreEquals(UUID parametersUuid, double lowVoltageAbsoluteThreshold, double lowVoltageProportionalThreshold, double highVoltageAbsoluteThreshold, double highVoltageProportionalThreshold, double flowProportionalThreshold) {
345360
SecurityAnalysisParametersEntity securityAnalysisParametersEntity = securityAnalysisParametersRepository.findById(parametersUuid).orElseThrow();
346361
assertEquals(lowVoltageAbsoluteThreshold, securityAnalysisParametersEntity.getLowVoltageAbsoluteThreshold(), 0.001);

0 commit comments

Comments
 (0)