Skip to content

Commit 36c6835

Browse files
supervision controller for filters
1 parent d9e1248 commit 36c6835

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package org.gridsuite.mapping.server.controller;
8+
9+
import io.swagger.v3.oas.annotations.Operation;
10+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
11+
import io.swagger.v3.oas.annotations.responses.ApiResponses;
12+
import io.swagger.v3.oas.annotations.tags.Tag;
13+
import lombok.AllArgsConstructor;
14+
import org.gridsuite.mapping.server.service.SupervisionService;
15+
import org.springframework.http.MediaType;
16+
import org.springframework.http.ResponseEntity;
17+
import org.springframework.web.bind.annotation.GetMapping;
18+
import org.springframework.web.bind.annotation.RequestMapping;
19+
import org.springframework.web.bind.annotation.RestController;
20+
21+
import java.util.List;
22+
import java.util.UUID;
23+
24+
/**
25+
* @author Mathieu Deharbe <mathieu.deharbe at rte-france.com>
26+
*
27+
* endpoints only used for supervision from the admins, should never be used by any other users
28+
*/
29+
@RestController
30+
@RequestMapping(value = "/supervision")
31+
@Tag(name = "Mapping server - Supervision")
32+
@AllArgsConstructor
33+
public class SupervisionController {
34+
private final SupervisionService supervisionService;
35+
36+
@GetMapping(value = "/filters")
37+
@Operation(summary = "Get all the uuids of the filters used by the mapping server")
38+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "List of all the filters uuids")})
39+
public ResponseEntity<List<UUID>> getAllRootNetworks() {
40+
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(supervisionService.getAllFiltersUuids());
41+
}
42+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package org.gridsuite.mapping.server.service;
8+
9+
import lombok.AllArgsConstructor;
10+
import org.gridsuite.mapping.server.model.RuleEntity;
11+
import org.gridsuite.mapping.server.repository.RuleRepository;
12+
import org.springframework.stereotype.Service;
13+
import org.springframework.transaction.annotation.Transactional;
14+
15+
import java.util.List;
16+
import java.util.Objects;
17+
import java.util.UUID;
18+
19+
/**
20+
* @author Mathieu Deharbe <mathieu.deharbe at rte-france.com>
21+
*/
22+
@Service
23+
@AllArgsConstructor
24+
public class SupervisionService {
25+
private final RuleRepository ruleRepository;
26+
27+
@Transactional(readOnly = true)
28+
public List<UUID> getAllFiltersUuids() {
29+
return ruleRepository.findAll().stream()
30+
.map(RuleEntity::getFilterUuid)
31+
.filter(Objects::nonNull)
32+
.toList();
33+
}
34+
}

0 commit comments

Comments
 (0)