-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStudyController.java
More file actions
1954 lines (1774 loc) · 145 KB
/
StudyController.java
File metadata and controls
1954 lines (1774 loc) · 145 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2021, 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.study.server;
import com.fasterxml.jackson.databind.JsonNode;
import com.powsybl.commons.report.ReportNode;
import com.powsybl.timeseries.DoubleTimeSeries;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.gridsuite.study.server.StudyException.Type;
import org.gridsuite.study.server.dto.*;
import org.gridsuite.study.server.dto.dynamicmapping.MappingInfos;
import org.gridsuite.study.server.dto.dynamicmapping.ModelInfos;
import org.gridsuite.study.server.dto.dynamicsimulation.DynamicSimulationParametersInfos;
import org.gridsuite.study.server.dto.dynamicsimulation.DynamicSimulationStatus;
import org.gridsuite.study.server.dto.dynamicsimulation.event.EventInfos;
import org.gridsuite.study.server.dto.elasticsearch.EquipmentInfos;
import org.gridsuite.study.server.dto.modification.ModificationType;
import org.gridsuite.study.server.dto.nonevacuatedenergy.NonEvacuatedEnergyParametersInfos;
import org.gridsuite.study.server.dto.sensianalysis.SensitivityAnalysisCsvFileInfos;
import org.gridsuite.study.server.dto.sensianalysis.SensitivityFactorsIdsByGroup;
import org.gridsuite.study.server.dto.timeseries.TimeSeriesMetadataInfos;
import org.gridsuite.study.server.dto.timeseries.TimelineEventInfos;
import org.gridsuite.study.server.dto.voltageinit.parameters.StudyVoltageInitParameters;
import org.gridsuite.study.server.elasticsearch.EquipmentInfosService;
import org.gridsuite.study.server.exception.PartialResultException;
import org.gridsuite.study.server.networkmodificationtree.dto.AbstractNode;
import org.gridsuite.study.server.networkmodificationtree.dto.InsertMode;
import org.gridsuite.study.server.networkmodificationtree.dto.NetworkModificationNode;
import org.gridsuite.study.server.networkmodificationtree.dto.RootNode;
import org.gridsuite.study.server.service.*;
import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisResultType;
import org.gridsuite.study.server.service.shortcircuit.FaultResultsMode;
import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService;
import org.gridsuite.study.server.service.shortcircuit.ShortcircuitAnalysisType;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.util.Pair;
import org.springframework.http.*;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Nullable;
import java.beans.PropertyEditorSupport;
import java.nio.charset.StandardCharsets;
import java.util.*;
import static org.gridsuite.study.server.StudyConstants.CASE_FORMAT;
import static org.gridsuite.study.server.StudyConstants.HEADER_USER_ID;
/**
* @author Abdelsalem Hedhili <abdelsalem.hedhili at rte-france.com>
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
@RestController
@RequestMapping(value = "/" + StudyApi.API_VERSION)
@Tag(name = "Study server")
public class StudyController {
private final StudyService studyService;
private final NetworkService networkStoreService;
private final NetworkModificationTreeService networkModificationTreeService;
private final SingleLineDiagramService singleLineDiagramService;
private final NetworkConversionService networkConversionService;
private final SecurityAnalysisService securityAnalysisService;
private final SensitivityAnalysisService sensitivityAnalysisService;
private final NonEvacuatedEnergyService nonEvacuatedEnergyService;
private final ShortCircuitService shortCircuitService;
private final VoltageInitService voltageInitService;
private final LoadFlowService loadflowService;
private final CaseService caseService;
private final RemoteServicesInspector remoteServicesInspector;
private final StateEstimationService stateEstimationService;
public StudyController(StudyService studyService,
NetworkService networkStoreService,
NetworkModificationTreeService networkModificationTreeService,
SingleLineDiagramService singleLineDiagramService,
NetworkConversionService networkConversionService,
SecurityAnalysisService securityAnalysisService,
SensitivityAnalysisService sensitivityAnalysisService,
NonEvacuatedEnergyService nonEvacuatedEnergyService,
ShortCircuitService shortCircuitService,
VoltageInitService voltageInitService,
LoadFlowService loadflowService,
CaseService caseService,
RemoteServicesInspector remoteServicesInspector,
StateEstimationService stateEstimationService) {
this.studyService = studyService;
this.networkModificationTreeService = networkModificationTreeService;
this.networkStoreService = networkStoreService;
this.singleLineDiagramService = singleLineDiagramService;
this.networkConversionService = networkConversionService;
this.securityAnalysisService = securityAnalysisService;
this.sensitivityAnalysisService = sensitivityAnalysisService;
this.nonEvacuatedEnergyService = nonEvacuatedEnergyService;
this.shortCircuitService = shortCircuitService;
this.voltageInitService = voltageInitService;
this.loadflowService = loadflowService;
this.caseService = caseService;
this.remoteServicesInspector = remoteServicesInspector;
this.stateEstimationService = stateEstimationService;
}
@InitBinder
public void initBinder(WebDataBinder webdataBinder) {
webdataBinder.registerCustomEditor(EquipmentInfosService.FieldSelector.class,
new MyEnumConverter<>(EquipmentInfosService.FieldSelector.class));
webdataBinder.registerCustomEditor(ModificationType.class, new MyModificationTypeConverter());
}
@GetMapping(value = "/studies")
@Operation(summary = "Get all studies")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of studies")})
public ResponseEntity<List<CreatedStudyBasicInfos>> getStudyList() {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getStudies());
}
@GetMapping(value = "/studies/{studyUuid}/case/name")
@Operation(summary = "Get study case name")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The study case name"),
@ApiResponse(responseCode = "204", description = "The study has no case name attached")})
public ResponseEntity<String> getStudyCaseName(@PathVariable("studyUuid") UUID studyUuid) {
String studyCaseName = studyService.getStudyCaseName(studyUuid);
return StringUtils.isEmpty(studyCaseName) ? ResponseEntity.noContent().build() : ResponseEntity.ok().body(studyCaseName);
}
@GetMapping(value = "/study_creation_requests")
@Operation(summary = "Get all study creation requests for a user")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of study creation requests")})
public ResponseEntity<List<BasicStudyInfos>> getStudyCreationRequestList() {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getStudiesCreationRequests());
}
@GetMapping(value = "/studies/metadata")
@Operation(summary = "Get studies metadata")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of studies metadata")})
public ResponseEntity<List<BasicStudyInfos>> getStudyListMetadata(@RequestParam("ids") List<UUID> uuids) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getStudiesMetadata(uuids));
}
@PostMapping(value = "/studies/cases/{caseUuid}")
@Operation(summary = "create a study from an existing case")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The id of the network imported"),
@ApiResponse(responseCode = "409", description = "The study already exists or the case doesn't exist")})
public ResponseEntity<BasicStudyInfos> createStudy(@PathVariable("caseUuid") UUID caseUuid,
@RequestParam(value = CASE_FORMAT) String caseFormat,
@RequestParam(required = false, value = "studyUuid") UUID studyUuid,
@RequestParam(required = false, value = "duplicateCase", defaultValue = "false") Boolean duplicateCase,
@RequestBody(required = false) Map<String, Object> importParameters,
@RequestHeader(HEADER_USER_ID) String userId) {
caseService.assertCaseExists(caseUuid);
BasicStudyInfos createStudy = studyService.createStudy(caseUuid, userId, studyUuid, importParameters, duplicateCase, caseFormat);
return ResponseEntity.ok().body(createStudy);
}
@PostMapping(value = "/studies", params = "duplicateFrom")
@Operation(summary = "create a study from an existing one")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The study was successfully created"),
@ApiResponse(responseCode = "404", description = "The source study doesn't exist")})
public ResponseEntity<UUID> duplicateStudy(@RequestParam("duplicateFrom") UUID studyId,
@RequestHeader(HEADER_USER_ID) String userId) {
UUID newStudyId = studyService.duplicateStudy(studyId, userId);
return newStudyId != null ? ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(newStudyId) :
ResponseEntity.notFound().build();
}
@GetMapping(value = "/studies/{studyUuid}")
@Operation(summary = "get a study")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The study information"),
@ApiResponse(responseCode = "404", description = "The study doesn't exist")})
public ResponseEntity<StudyInfos> getStudy(@PathVariable("studyUuid") UUID studyUuid) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getStudyInfos(studyUuid));
}
@DeleteMapping(value = "/studies/{studyUuid}")
@Operation(summary = "delete the study")
@ApiResponse(responseCode = "200", description = "Study deleted")
public ResponseEntity<Void> deleteStudy(@PathVariable("studyUuid") UUID studyUuid,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.deleteStudyIfNotCreationInProgress(studyUuid, userId);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/studies/{targetStudyUuid}/tree/nodes", params = {"nodeToCopyUuid", "referenceNodeUuid", "insertMode"})
@Operation(summary = "duplicate a node")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The node was successfully created"),
@ApiResponse(responseCode = "403", description = "The node can't be copied above the root node"),
@ApiResponse(responseCode = "404", description = "The source study or node doesn't exist")})
public ResponseEntity<Void> duplicateNode(@Parameter(description = "The study where we want to copy the node") @PathVariable("targetStudyUuid") UUID targetStudyUuid,
@Parameter(description = "The copied node original study") @RequestParam(value = "sourceStudyUuid", required = false) UUID sourceStudyUuid,
@Parameter(description = "The node we want to copy") @RequestParam("nodeToCopyUuid") UUID nodeToCopyUuid,
@Parameter(description = "The reference node to where we want to paste") @RequestParam("referenceNodeUuid") UUID referenceNodeUuid,
@Parameter(description = "the position where the node will be pasted relative to the reference node") @RequestParam(name = "insertMode") InsertMode insertMode,
@RequestHeader(HEADER_USER_ID) String userId) {
//if the source study is not set we assume it's the same as the target study
studyService.duplicateStudyNode(sourceStudyUuid == null ? targetStudyUuid : sourceStudyUuid, targetStudyUuid, nodeToCopyUuid, referenceNodeUuid, insertMode, userId);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/studies/{studyUuid}/tree/nodes", params = {"nodeToCutUuid", "referenceNodeUuid", "insertMode"})
@Operation(summary = "cut and paste a node")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The node was successfully created"),
@ApiResponse(responseCode = "403", description = "The node can't be copied above the root node nor around itself"),
@ApiResponse(responseCode = "404", description = "The source study or node doesn't exist")})
public ResponseEntity<Void> cutAndPasteNode(@PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "The node we want to cut") @RequestParam("nodeToCutUuid") UUID nodeToCutUuid,
@Parameter(description = "The reference node to where we want to paste") @RequestParam("referenceNodeUuid") UUID referenceNodeUuid,
@Parameter(description = "the position where the node will be pasted relative to the reference node") @RequestParam(name = "insertMode") InsertMode insertMode,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.moveStudyNode(studyUuid, nodeToCutUuid, referenceNodeUuid, insertMode, userId);
return ResponseEntity.ok().build();
}
@RequestMapping(value = "/studies/{studyUuid}/network", method = RequestMethod.HEAD)
@Operation(summary = "check study root network existence")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The network does exist"),
@ApiResponse(responseCode = "204", description = "The network doesn't exist")})
public ResponseEntity<Void> checkNetworkExistence(@PathVariable("studyUuid") UUID studyUuid) {
UUID networkUUID = networkStoreService.getNetworkUuid(studyUuid);
return networkStoreService.doesNetworkExist(networkUUID)
? ResponseEntity.ok().build()
: ResponseEntity.noContent().build();
}
@PostMapping(value = "/studies/{studyUuid}/network", params = {"caseUuid"})
@Operation(summary = "recreate study network of a study from an existing case")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Study network recreation has started"),
@ApiResponse(responseCode = "424", description = "The case doesn't exist")})
public ResponseEntity<BasicStudyInfos> recreateStudyNetworkFromCase(@PathVariable("studyUuid") UUID studyUuid,
@RequestBody(required = false) Map<String, Object> importParameters,
@RequestParam(value = "caseUuid") UUID caseUuid,
@Parameter(description = "case format") @RequestParam(name = "caseFormat", required = false) String caseFormat,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.recreateStudyRootNetwork(caseUuid, userId, studyUuid, caseFormat, importParameters);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/studies/{studyUuid}/network")
@Operation(summary = "recreate study network of a study from its case")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Study network recreation has started"),
@ApiResponse(responseCode = "424", description = "The study's case doesn't exist")})
public ResponseEntity<BasicStudyInfos> recreateStudyNetwork(@PathVariable("studyUuid") UUID studyUuid,
@RequestHeader(HEADER_USER_ID) String userId,
@Parameter(description = "case format") @RequestParam(name = "caseFormat", required = false) String caseFormat
) {
studyService.recreateStudyRootNetwork(userId, studyUuid, caseFormat);
return ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/indexation/status")
@Operation(summary = "check study indexation")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The study indexation status"),
@ApiResponse(responseCode = "204", description = "The study indexation status doesn't exist"),
@ApiResponse(responseCode = "404", description = "The study or network doesn't exist")})
public ResponseEntity<String> checkStudyIndexationStatus(@PathVariable("studyUuid") UUID studyUuid) {
String result = studyService.getStudyIndexationStatus(studyUuid).name();
return result != null ? ResponseEntity.ok().body(result) :
ResponseEntity.noContent().build();
}
@PostMapping(value = "/studies/{studyUuid}/tree/subtrees", params = {"subtreeToCutParentNodeUuid", "referenceNodeUuid"})
@Operation(summary = "cut and paste a subtree")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The subtree was successfully created"),
@ApiResponse(responseCode = "403", description = "The subtree can't be copied above the root node nor around itself"),
@ApiResponse(responseCode = "404", description = "The source study or subtree doesn't exist")})
public ResponseEntity<Void> cutAndPasteNodeSubtree(@PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "The parent node of the subtree we want to cut") @RequestParam("subtreeToCutParentNodeUuid") UUID subtreeToCutParentNodeUuid,
@Parameter(description = "The reference node to where we want to paste") @RequestParam("referenceNodeUuid") UUID referenceNodeUuid,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.moveStudySubtree(studyUuid, subtreeToCutParentNodeUuid, referenceNodeUuid, userId);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/studies/{studyUuid}/tree/subtrees", params = {"subtreeToCopyParentNodeUuid", "referenceNodeUuid"})
@Operation(summary = "duplicate a subtree")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The subtree was successfully created"),
@ApiResponse(responseCode = "403", description = "The subtree can't be copied above the root node nor around itself"),
@ApiResponse(responseCode = "404", description = "The source study or subtree doesn't exist")})
public ResponseEntity<Void> duplicateSubtree(@Parameter(description = "The study where we want to copy the node") @PathVariable("studyUuid") UUID targetStudyUuid,
@Parameter(description = "The copied node original study") @RequestParam(value = "sourceStudyUuid") UUID sourceStudyUuid,
@Parameter(description = "The parent node of the subtree we want to cut") @RequestParam("subtreeToCopyParentNodeUuid") UUID subtreeToCopyParentNodeUuid,
@Parameter(description = "The reference node to where we want to paste") @RequestParam("referenceNodeUuid") UUID referenceNodeUuid,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.duplicateStudySubtree(sourceStudyUuid, targetStudyUuid, subtreeToCopyParentNodeUuid, referenceNodeUuid, userId);
return ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network/voltage-levels/{voltageLevelId}/svg")
@Operation(summary = "get the voltage level diagram for the given network and voltage level")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The svg"),
@ApiResponse(responseCode = "404", description = "The voltage level has not been found")})
public ResponseEntity<byte[]> getVoltageLevelDiagram(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@PathVariable("voltageLevelId") String voltageLevelId,
@Parameter(description = "useName") @RequestParam(name = "useName", defaultValue = "false") boolean useName,
@Parameter(description = "centerLabel") @RequestParam(name = "centerLabel", defaultValue = "false") boolean centerLabel,
@Parameter(description = "diagonalLabel") @RequestParam(name = "diagonalLabel", defaultValue = "false") boolean diagonalLabel,
@Parameter(description = "topologicalColoring") @RequestParam(name = "topologicalColoring", defaultValue = "false") boolean topologicalColoring,
@Parameter(description = "component library name") @RequestParam(name = "componentLibrary", required = false) String componentLibrary,
@Parameter(description = "Sld display mode") @RequestParam(name = "sldDisplayMode", defaultValue = "STATE_VARIABLE") StudyConstants.SldDisplayMode sldDisplayMode,
@Parameter(description = "language") @RequestParam(name = "language", defaultValue = "en") String language) {
DiagramParameters diagramParameters = DiagramParameters.builder()
.useName(useName)
.labelCentered(centerLabel)
.diagonalLabel(diagonalLabel)
.topologicalColoring(topologicalColoring)
.componentLibrary(componentLibrary)
.sldDisplayMode(sldDisplayMode)
.language(language)
.build();
byte[] result = studyService.getVoltageLevelSvg(
studyUuid,
voltageLevelId,
diagramParameters,
nodeUuid);
return result != null ? ResponseEntity.ok().contentType(MediaType.APPLICATION_XML).body(result) :
ResponseEntity.noContent().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network/voltage-levels/{voltageLevelId}/svg-and-metadata")
@Operation(summary = "get the voltage level diagram for the given network and voltage level")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The svg and metadata"),
@ApiResponse(responseCode = "404", description = "The voltage level has not been found")})
public ResponseEntity<String> getVoltageLevelDiagramAndMetadata(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@PathVariable("voltageLevelId") String voltageLevelId,
@Parameter(description = "useName") @RequestParam(name = "useName", defaultValue = "false") boolean useName,
@Parameter(description = "centerLabel") @RequestParam(name = "centerLabel", defaultValue = "false") boolean centerLabel,
@Parameter(description = "diagonalLabel") @RequestParam(name = "diagonalLabel", defaultValue = "false") boolean diagonalLabel,
@Parameter(description = "topologicalColoring") @RequestParam(name = "topologicalColoring", defaultValue = "false") boolean topologicalColoring,
@Parameter(description = "component library name") @RequestParam(name = "componentLibrary", required = false) String componentLibrary,
@Parameter(description = "Sld display mode") @RequestParam(name = "sldDisplayMode", defaultValue = "STATE_VARIABLE") StudyConstants.SldDisplayMode sldDisplayMode,
@Parameter(description = "language") @RequestParam(name = "language", defaultValue = "en") String language) {
DiagramParameters diagramParameters = DiagramParameters.builder()
.useName(useName)
.labelCentered(centerLabel)
.diagonalLabel(diagonalLabel)
.topologicalColoring(topologicalColoring)
.componentLibrary(componentLibrary)
.sldDisplayMode(sldDisplayMode)
.language(language)
.build();
String result = studyService.getVoltageLevelSvgAndMetadata(
studyUuid,
voltageLevelId,
diagramParameters,
nodeUuid);
return result != null ? ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(result) :
ResponseEntity.noContent().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network/voltage-levels/{voltageLevelId}/buses")
@Operation(summary = "get buses the for a given network and a given voltage level")
@ApiResponse(responseCode = "200", description = "The buses list of the network for given voltage level")
public ResponseEntity<List<IdentifiableInfos>> getVoltageLevelBuses(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@PathVariable("voltageLevelId") String voltageLevelId,
@Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getVoltageLevelBuses(studyUuid, nodeUuid, voltageLevelId, inUpstreamBuiltParentNode));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network/voltage-levels/{voltageLevelId}/busbar-sections")
@Operation(summary = "get the busbar sections for a given network and a given voltage level")
@ApiResponse(responseCode = "200", description = "The busbar sections list of the network for given voltage level")
public ResponseEntity<List<IdentifiableInfos>> getVoltageLevelBusbarSections(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@PathVariable("voltageLevelId") String voltageLevelId,
@Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getVoltageLevelBusbarSections(studyUuid, nodeUuid, voltageLevelId, inUpstreamBuiltParentNode));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-map/hvdc-lines/{hvdcId}/shunt-compensators")
@Operation(summary = "For a given hvdc line, get its related Shunt compensators in case of LCC converter station")
@ApiResponse(responseCode = "200", description = "Hvdc line type and its shunt compensators on each side")
public ResponseEntity<String> getHvdcLineShuntCompensators(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@PathVariable("hvdcId") String hvdcId,
@Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode) {
String hvdcInfos = studyService.getHvdcLineShuntCompensators(studyUuid, nodeUuid, inUpstreamBuiltParentNode, hvdcId);
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(hvdcInfos);
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/geo-data/lines")
@Operation(summary = "Get Network lines graphics")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of line graphics with the given ids, all otherwise")})
public ResponseEntity<String> getLineGraphics(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Lines ids") @RequestParam(name = "lineId", required = false) List<String> linesIds) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getLinesGraphics(networkStoreService.getNetworkUuid(studyUuid), nodeUuid, linesIds));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/geo-data/substations")
@Operation(summary = "Get Network substations graphics")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of substation graphics with the given ids, all otherwise")})
public ResponseEntity<String> getSubstationGraphics(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Substations id") @RequestParam(name = "substationId", required = false) List<String> substationsIds) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getSubstationsGraphics(networkStoreService.getNetworkUuid(studyUuid), nodeUuid, substationsIds));
}
@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-map/equipments-ids")
@Operation(summary = "Get equipment ids ")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of equipment ids")})
public ResponseEntity<String> getNetworkElementsIds(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@RequestBody(required = false) List<String> substationsIds,
@Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode,
@Parameter(description = "equipment type") @RequestParam(name = "equipmentType") String equipmentType,
@Parameter(description = "Nominal Voltages") @RequestParam(name = "nominalVoltages", required = false) List<Double> nominalVoltages) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getNetworkElementsIds(studyUuid, nodeUuid, substationsIds, inUpstreamBuiltParentNode, equipmentType, nominalVoltages));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-map/substations/{substationId}")
@Operation(summary = "Get specific substation description")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The substation data")})
public ResponseEntity<String> getSubstationMapData(
@Parameter(description = "study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "node uuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "substation Id") @PathVariable("substationId") String substationId,
@Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getSubstationMapData(studyUuid, nodeUuid, substationId, inUpstreamBuiltParentNode));
}
@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network/elements")
@Operation(summary = "Get network elements infos")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of network elements infos")})
public ResponseEntity<String> getNetworkElementsInfos(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@RequestBody(required = false) List<String> substationsIds,
@Parameter(description = "Info type") @RequestParam(name = "infoType") String infoType,
@Parameter(description = "element type") @RequestParam(name = "elementType") String elementType,
@Parameter(description = "Should get in upstream built node ?")
@RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode,
@Parameter(description = "Nominal Voltages") @RequestParam(name = "nominalVoltages", required = false) List<Double> nominalVoltages) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getNetworkElementsInfos(studyUuid, nodeUuid, substationsIds, infoType, elementType, inUpstreamBuiltParentNode, nominalVoltages));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network/elements/{elementId}")
@Operation(summary = "Get network elements infos")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of network elements infos")})
public ResponseEntity<String> getNetworkElementInfos(
@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "Node uuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Element id") @PathVariable("elementId") String elementId,
@Parameter(description = "Element type") @RequestParam(name = "elementType") String elementType,
@Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode,
@Parameter(description = "Info type parameters") InfoTypeParameters infoTypeParameters) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getNetworkElementInfos(studyUuid, nodeUuid, elementType, infoTypeParameters, elementId, inUpstreamBuiltParentNode));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-map/countries")
@Operation(summary = "Get network countries")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of countries")})
public ResponseEntity<String> getNetworkCountries(
@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "Node uuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getNetworkCountries(studyUuid, nodeUuid, inUpstreamBuiltParentNode));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-map/nominal-voltages")
@Operation(summary = "Get network nominal voltages")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of nominal voltages")})
public ResponseEntity<String> getNetworkNominalVoltages(
@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "Node uuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getNetworkNominalVoltages(studyUuid, nodeUuid, inUpstreamBuiltParentNode));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-map/branch-or-3wt/{equipmentId}")
@Operation(summary = "Get specific line or 2WT or 3WT description")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "The line or 2WT or 3WT data"),
@ApiResponse(responseCode = "204", description = "No element found")
})
public ResponseEntity<String> getBranchOrThreeWindingsTransformer(
@Parameter(description = "study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "node uuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "equipment id") @PathVariable("equipmentId") String equipmentId) {
String elementInfos = studyService.getBranchOrThreeWindingsTransformer(studyUuid, nodeUuid, equipmentId);
return StringUtils.isEmpty(elementInfos) ? ResponseEntity.noContent().build() : ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(elementInfos);
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-map/voltage-levels/{voltageLevelId}/equipments")
@Operation(summary = "Get voltage level equipments")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Voltage level equipments")})
public ResponseEntity<String> getVoltageLevelEquipments(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "voltage level id") @PathVariable("voltageLevelId") String voltageLevelId,
@Parameter(description = "Substations id") @RequestParam(name = "substationId", required = false) List<String> substationsIds,
@Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getVoltageLevelEquipments(studyUuid, nodeUuid, substationsIds, inUpstreamBuiltParentNode, voltageLevelId));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-map/all")
@Operation(summary = "Get Network equipments description")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The list of equipments data")})
public ResponseEntity<String> getAllMapData(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Substations id") @RequestParam(name = "substationId", required = false) List<String> substationsIds) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getAllMapData(studyUuid, nodeUuid, substationsIds));
}
@PutMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-modification/{modificationUuid}")
@Operation(summary = "move network modification before another")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The modification order is updated")})
public ResponseEntity<Void> moveModification(@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@PathVariable("modificationUuid") UUID modificationUuid,
@Nullable @Parameter(description = "move before, if no value move to end") @RequestParam(value = "beforeUuid") UUID beforeUuid,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.assertCanModifyNode(studyUuid, nodeUuid);
studyService.moveModifications(studyUuid, nodeUuid, nodeUuid, List.of(modificationUuid), beforeUuid, userId);
return ResponseEntity.ok().build();
}
@PutMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "For a list of network modifications passed in body, copy or cut, then append them to target node")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The modification list has been updated.")})
public ResponseEntity<Void> moveOrCopyModifications(@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@RequestParam("action") StudyConstants.ModificationsActionType action,
@Nullable @RequestParam("originNodeUuid") UUID originNodeUuid,
@RequestBody List<UUID> modificationsToCopyUuidList,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.assertIsStudyAndNodeExist(studyUuid, nodeUuid);
studyService.assertCanModifyNode(studyUuid, nodeUuid);
if (originNodeUuid != null) {
studyService.assertIsNodeExist(studyUuid, originNodeUuid);
studyService.assertCanModifyNode(studyUuid, originNodeUuid);
}
switch (action) {
case COPY, INSERT:
studyService.createModifications(studyUuid, nodeUuid, modificationsToCopyUuidList, userId, action);
break;
case MOVE:
studyService.moveModifications(studyUuid, nodeUuid, originNodeUuid, modificationsToCopyUuidList, null, userId);
break;
default:
throw new StudyException(Type.UNKNOWN_ACTION_TYPE);
}
return ResponseEntity.ok().build();
}
@PutMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/run")
@Operation(summary = "run loadflow on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The loadflow has started")})
public ResponseEntity<Void> runLoadFlow(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "The limit reduction") @RequestParam(name = "limitReduction", required = false) Float limitReduction,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.assertIsNodeNotReadOnly(nodeUuid);
studyService.runLoadFlow(studyUuid, nodeUuid, userId, limitReduction);
return ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/result")
@Operation(summary = "Get a loadflow result on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The loadflow result"),
@ApiResponse(responseCode = "204", description = "No loadflow has been done yet"),
@ApiResponse(responseCode = "404", description = "The loadflow result has not been found")})
public ResponseEntity<String> getLoadflowResult(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "JSON array of filters") @RequestParam(name = "filters", required = false) String filters,
Sort sort) {
String result = loadflowService.getLoadFlowResult(nodeUuid, filters, sort);
return result != null ? ResponseEntity.ok().body(result) :
ResponseEntity.noContent().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/status")
@Operation(summary = "Get the loadflow status on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The loadflow status"),
@ApiResponse(responseCode = "204", description = "No loadflow has been done yet"),
@ApiResponse(responseCode = "404", description = "The loadflow status has not been found")})
public ResponseEntity<String> getLoadFlowStatus(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
String result = loadflowService.getLoadFlowStatus(nodeUuid);
return result != null ? ResponseEntity.ok().body(result) :
ResponseEntity.noContent().build();
}
@PutMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/loadflow/stop")
@Operation(summary = "stop loadflow on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The loadflow has been stopped")})
public ResponseEntity<Void> stopLoadFlow(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
loadflowService.stopLoadFlow(studyUuid, nodeUuid);
return ResponseEntity.ok().build();
}
@PutMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/run")
@Operation(summary = "run short circuit analysis on study")
@ApiResponse(responseCode = "200", description = "The short circuit analysis has started")
public ResponseEntity<Void> runShortCircuit(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@RequestParam(value = "busId", required = false) Optional<String> busId,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.assertIsNodeNotReadOnly(nodeUuid);
studyService.runShortCircuit(studyUuid, nodeUuid, busId, userId);
return ResponseEntity.ok().build();
}
@PutMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/stop")
@Operation(summary = "stop security analysis on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The short circuit analysis has been stopped")})
public ResponseEntity<Void> stopShortCircuitAnalysis(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
shortCircuitService.stopShortCircuitAnalysis(studyUuid, nodeUuid);
return ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/result")
@Operation(summary = "Get a short circuit analysis result on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The short circuit analysis result"),
@ApiResponse(responseCode = "204", description = "No short circuit analysis has been done yet"),
@ApiResponse(responseCode = "404", description = "The short circuit analysis has not been found")})
public ResponseEntity<String> getShortCircuitResult(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "BASIC (faults without limits and feeders), " +
"FULL (faults with both), " +
"WITH_LIMIT_VIOLATIONS (like FULL but only those with limit violations) or " +
"NONE (no fault)") @RequestParam(name = "mode", required = false, defaultValue = "FULL") FaultResultsMode mode,
@Parameter(description = "type") @RequestParam(value = "type", required = false, defaultValue = "ALL_BUSES") ShortcircuitAnalysisType type,
@Parameter(description = "JSON array of filters") @RequestParam(name = "filters", required = false) String filters,
@Parameter(description = "If we wanted the paged version of the results or not") @RequestParam(name = "paged", required = false, defaultValue = "false") boolean paged,
Pageable pageable) {
String result = shortCircuitService.getShortCircuitAnalysisResult(nodeUuid, mode, type, filters, paged, pageable);
return result != null ? ResponseEntity.ok().body(result) :
ResponseEntity.noContent().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/status")
@Operation(summary = "Get the short circuit analysis status on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The short circuit analysis status"),
@ApiResponse(responseCode = "204", description = "No short circuit analysis has been done yet"),
@ApiResponse(responseCode = "404", description = "The short circuit analysis status has not been found")})
public ResponseEntity<String> getShortCircuitAnalysisStatus(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "type") @RequestParam(value = "type", required = false, defaultValue = "ALL_BUSES") ShortcircuitAnalysisType type) {
String result = shortCircuitService.getShortCircuitAnalysisStatus(nodeUuid, type);
return result != null ? ResponseEntity.ok().body(result) :
ResponseEntity.noContent().build();
}
@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/shortcircuit/result/csv")
@Operation(summary = "Get a short circuit analysis csv result")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The short circuit analysis csv export"),
@ApiResponse(responseCode = "204", description = "No short circuit analysis has been done yet"),
@ApiResponse(responseCode = "404", description = "The short circuit analysis has not been found")})
public ResponseEntity<byte[]> getShortCircuitAnalysisCsvResult(
@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "type") @RequestParam(value = "type") ShortcircuitAnalysisType type,
@Parameter(description = "headersCsv") @RequestBody String headersCsv) {
return ResponseEntity.ok().body(shortCircuitService.getShortCircuitAnalysisCsvResult(nodeUuid, type, headersCsv));
}
@PutMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/run")
@Operation(summary = "run voltage init on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The voltage init has started"),
@ApiResponse(responseCode = "403", description = "The study node is not a model node")})
public ResponseEntity<Void> runVoltageInit(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.assertIsNodeNotReadOnly(nodeUuid);
studyService.runVoltageInit(studyUuid, nodeUuid, userId);
return ResponseEntity.ok().build();
}
@PutMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/stop")
@Operation(summary = "stop security analysis on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The voltage init has been stopped")})
public ResponseEntity<Void> stopVoltageInit(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
voltageInitService.stopVoltageInit(studyUuid, nodeUuid);
return ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/result")
@Operation(summary = "Get a voltage init result on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The voltage init result"),
@ApiResponse(responseCode = "204", description = "No voltage init has been done yet"),
@ApiResponse(responseCode = "404", description = "The voltage init has not been found")})
public ResponseEntity<String> getVoltageInitResult(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
String result = voltageInitService.getVoltageInitResult(nodeUuid);
return result != null ? ResponseEntity.ok().body(result) :
ResponseEntity.noContent().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/voltage-init/status")
@Operation(summary = "Get the voltage init status on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The voltage init status"),
@ApiResponse(responseCode = "204", description = "No voltage init has been done yet"),
@ApiResponse(responseCode = "404", description = "The voltage init status has not been found")})
public ResponseEntity<String> getVoltageInitStatus(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) {
String result = voltageInitService.getVoltageInitStatus(nodeUuid);
return result != null ? ResponseEntity.ok().body(result) :
ResponseEntity.noContent().build();
}
@PostMapping(value = "/studies/{studyUuid}/voltage-init/parameters")
@Operation(summary = "Set voltage init parameters on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The voltage init parameters are set")})
public ResponseEntity<Void> setVoltageInitParameters(
@PathVariable("studyUuid") UUID studyUuid,
@RequestBody(required = false) StudyVoltageInitParameters voltageInitParameters,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.setVoltageInitParameters(studyUuid, voltageInitParameters, userId);
return ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/voltage-init/parameters")
@Operation(summary = "Get voltage init parameters on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The voltage init parameters")})
public ResponseEntity<StudyVoltageInitParameters> getVoltageInitParameters(
@PathVariable("studyUuid") UUID studyUuid) {
return ResponseEntity.ok().body(studyService.getVoltageInitParameters(studyUuid));
}
@GetMapping(value = "/export-network-formats")
@Operation(summary = "get the available export format")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The available export format")})
public ResponseEntity<String> getExportFormats() {
String formatsJson = networkConversionService.getExportFormats();
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(formatsJson);
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/export-network/{format}")
@Operation(summary = "export the study's network in the given format")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The network in the given format")})
public ResponseEntity<byte[]> exportNetwork(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@PathVariable("format") String format,
@RequestParam(value = "formatParameters", required = false) String parametersJson) {
studyService.assertRootNodeOrBuiltNode(studyUuid, nodeUuid);
ExportNetworkInfos exportNetworkInfos = studyService.exportNetwork(studyUuid, nodeUuid, format, parametersJson);
HttpHeaders header = new HttpHeaders();
header.setContentDisposition(ContentDisposition.builder("attachment").filename(exportNetworkInfos.getFileName(), StandardCharsets.UTF_8).build());
return ResponseEntity.ok().headers(header).contentType(MediaType.APPLICATION_OCTET_STREAM).body(exportNetworkInfos.getNetworkData());
}
@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/run")
@Operation(summary = "run security analysis on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The security analysis has started")})
public ResponseEntity<Void> runSecurityAnalysis(@Parameter(description = "studyUuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Contingency list names") @RequestParam(name = "contingencyListName", required = false) List<String> contingencyListNames,
@RequestHeader(HEADER_USER_ID) String userId) {
List<String> nonNullcontingencyListNames = contingencyListNames != null ? contingencyListNames : Collections.emptyList();
studyService.assertIsNodeNotReadOnly(nodeUuid);
studyService.runSecurityAnalysis(studyUuid, nonNullcontingencyListNames, nodeUuid, userId);
return ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result")
@Operation(summary = "Get a security analysis result on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The security analysis result"),
@ApiResponse(responseCode = "204", description = "No security analysis has been done yet"),
@ApiResponse(responseCode = "404", description = "The security analysis has not been found")})
public ResponseEntity<String> getSecurityAnalysisResult(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "result type") @RequestParam(name = "resultType") SecurityAnalysisResultType resultType,
@Parameter(description = "JSON array of filters") @RequestParam(name = "filters", required = false) String filters,
Pageable pageable) {
String result = securityAnalysisService.getSecurityAnalysisResult(nodeUuid, resultType, filters, pageable);
return result != null ? ResponseEntity.ok().body(result) :
ResponseEntity.noContent().build();
}
@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/security-analysis/result/csv")
@Operation(summary = "Get a security analysis result on study - CSV export")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The security analysis result csv export"),
@ApiResponse(responseCode = "204", description = "No security analysis has been done yet"),
@ApiResponse(responseCode = "404", description = "The security analysis has not been found")})
public byte[] getSecurityAnalysisResult(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "result type") @RequestParam(name = "resultType") SecurityAnalysisResultType resultType,
@Parameter(description = "Csv translation (JSON)") @RequestBody String csvTranslations) {
return securityAnalysisService.getSecurityAnalysisResultCsv(nodeUuid, resultType, csvTranslations);
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/contingency-count")
@Operation(summary = "Get contingency count for a list of contingency list on a study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The contingency count")})
public ResponseEntity<Integer> getContingencyCount(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "Node UUID") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Contingency list names") @RequestParam(name = "contingencyListName", required = false) List<String> contingencyListNames) {
return ResponseEntity.ok().body(CollectionUtils.isEmpty(contingencyListNames) ? 0 : studyService.getContingencyCount(studyUuid, contingencyListNames, nodeUuid));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/limit-violations")
@Operation(summary = "Get limit violations.")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The limit violations")})
public ResponseEntity<List<LimitViolationInfos>> getLimitViolations(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "Node UUID") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "JSON array of filters") @RequestParam(name = "filters", required = false) String filters,
@Parameter(description = "JSON array of global filters") @RequestParam(name = "globalFilters", required = false) String globalFilters,
Sort sort) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getLimitViolations(studyUuid, nodeUuid, filters, globalFilters, sort));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/computation/result/enum-values")
@Operation(summary = "Get Enum values")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The Enum values")})
public ResponseEntity<List<String>> getResultEnumValues(@Parameter(description = "Study UUID") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "Node UUID") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "Computing Type") @RequestParam(name = "computingType") ComputationType computingType,
@Parameter(description = "Enum name") @RequestParam(name = "enumName") String enumName) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getResultEnumValues(studyUuid, nodeUuid, computingType, enumName));
}
@PostMapping(value = "/studies/{studyUuid}/loadflow/parameters")
@Operation(summary = "set loadflow parameters on study, reset to default ones if empty body")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The loadflow parameters are set"),
@ApiResponse(responseCode = "204", description = "Reset with user profile cannot be done")})
public ResponseEntity<Void> setLoadflowParameters(
@PathVariable("studyUuid") UUID studyUuid,
@RequestBody(required = false) String lfParameter,
@RequestHeader(HEADER_USER_ID) String userId) {
return studyService.setLoadFlowParameters(studyUuid, lfParameter, userId) ? ResponseEntity.noContent().build() : ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/loadflow/parameters")
@Operation(summary = "Get loadflow parameters on study")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The loadflow parameters")})
public ResponseEntity<LoadFlowParametersInfos> getLoadflowParameters(
@PathVariable("studyUuid") UUID studyUuid) {
return ResponseEntity.ok().body(studyService.getLoadFlowParametersInfos(studyUuid));
}
@PostMapping(value = "/studies/{studyUuid}/loadflow/provider")
@Operation(summary = "set load flow provider for the specified study, no body means reset to default provider")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The load flow provider is set")})
public ResponseEntity<Void> setLoadflowProvider(@PathVariable("studyUuid") UUID studyUuid,
@RequestBody(required = false) String provider,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.updateLoadFlowProvider(studyUuid, provider, userId);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/studies/{studyUuid}/security-analysis/provider")
@Operation(summary = "set security analysis provider for the specified study, no body means reset to default provider")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The security analysis provider is set")})
public ResponseEntity<Void> setSecurityAnalysisProvider(@PathVariable("studyUuid") UUID studyUuid,
@RequestBody(required = false) String provider,
@RequestHeader("userId") String userId) {
studyService.updateSecurityAnalysisProvider(studyUuid, provider, userId);
return ResponseEntity.ok().build();
}
@PostMapping(value = "/studies/{studyUuid}/dynamic-simulation/provider")
@Operation(summary = "Set dynamic simulation provider for the specified study, no body means reset to default provider")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The dynamic simulation provider is set")})
public ResponseEntity<Void> setDynamicSimulationProvider(@PathVariable("studyUuid") UUID studyUuid,
@RequestBody(required = false) String provider,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.updateDynamicSimulationProvider(studyUuid, provider, userId);
return ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/dynamic-simulation/provider")
@Operation(summary = "Get dynamic simulation provider for a specified study, empty string means default provider")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The dynamic simulation provider is returned")})
public ResponseEntity<String> getDynamicSimulationProvider(@PathVariable("studyUuid") UUID studyUuid) {
return ResponseEntity.ok().body(studyService.getDynamicSimulationProvider(studyUuid));
}
@PostMapping(value = "/studies/{studyUuid}/short-circuit-analysis/parameters", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "set short-circuit analysis parameters on study, reset to default ones if empty body")
@ApiResponse(responseCode = "200", description = "The short-circuit analysis parameters are set")
public ResponseEntity<Void> setShortCircuitParameters(
@PathVariable("studyUuid") UUID studyUuid,
@RequestBody(required = false) String shortCircuitParametersInfos,
@RequestHeader(HEADER_USER_ID) String userId) {
studyService.setShortCircuitParameters(studyUuid, shortCircuitParametersInfos, userId);
return ResponseEntity.ok().build();
}
@GetMapping(value = "/studies/{studyUuid}/short-circuit-analysis/parameters", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get short-circuit analysis parameters on study")
@ApiResponse(responseCode = "200", description = "The short-circuit analysis parameters return by shortcircuit-server")
public ResponseEntity<String> getShortCircuitParameters(@PathVariable("studyUuid") UUID studyUuid) {
return ResponseEntity.ok().body(studyService.getShortCircuitParametersInfo(studyUuid));
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network/substations/{substationId}/svg")
@Operation(summary = "get the substation diagram for the given network and substation")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The svg"),
@ApiResponse(responseCode = "404", description = "The substation has not been found")})
public ResponseEntity<byte[]> getSubstationDiagram(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@PathVariable("substationId") String substationId,
@Parameter(description = "useName") @RequestParam(name = "useName", defaultValue = "false") boolean useName,
@Parameter(description = "centerLabel") @RequestParam(name = "centerLabel", defaultValue = "false") boolean centerLabel,
@Parameter(description = "diagonalLabel") @RequestParam(name = "diagonalLabel", defaultValue = "false") boolean diagonalLabel,
@Parameter(description = "topologicalColoring") @RequestParam(name = "topologicalColoring", defaultValue = "false") boolean topologicalColoring,
@Parameter(description = "substationLayout") @RequestParam(name = "substationLayout", defaultValue = "horizontal") String substationLayout,
@Parameter(description = "component library name") @RequestParam(name = "componentLibrary", required = false) String componentLibrary,
@Parameter(description = "language") @RequestParam(name = "language", defaultValue = "en") String language) {
DiagramParameters diagramParameters = DiagramParameters.builder()
.useName(useName)
.labelCentered(centerLabel)
.diagonalLabel(diagonalLabel)
.topologicalColoring(topologicalColoring)
.componentLibrary(componentLibrary)
.language(language)
.build();
byte[] result = studyService.getSubstationSvg(studyUuid, substationId,
diagramParameters, substationLayout, nodeUuid);
return result != null ? ResponseEntity.ok().contentType(MediaType.APPLICATION_XML).body(result) :
ResponseEntity.noContent().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network/substations/{substationId}/svg-and-metadata")
@Operation(summary = "get the substation diagram for the given network and substation")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The svg and metadata"),
@ApiResponse(responseCode = "404", description = "The substation has not been found")})
public ResponseEntity<String> getSubstationDiagramAndMetadata(
@PathVariable("studyUuid") UUID studyUuid,
@PathVariable("nodeUuid") UUID nodeUuid,
@PathVariable("substationId") String substationId,
@Parameter(description = "useName") @RequestParam(name = "useName", defaultValue = "false") boolean useName,
@Parameter(description = "centerLabel") @RequestParam(name = "centerLabel", defaultValue = "false") boolean centerLabel,
@Parameter(description = "diagonalLabel") @RequestParam(name = "diagonalLabel", defaultValue = "false") boolean diagonalLabel,
@Parameter(description = "topologicalColoring") @RequestParam(name = "topologicalColoring", defaultValue = "false") boolean topologicalColoring,
@Parameter(description = "substationLayout") @RequestParam(name = "substationLayout", defaultValue = "horizontal") String substationLayout,
@Parameter(description = "component library name") @RequestParam(name = "componentLibrary", required = false) String componentLibrary,
@Parameter(description = "language") @RequestParam(name = "language", defaultValue = "en") String language) {
DiagramParameters diagramParameters = DiagramParameters.builder()
.useName(useName)
.labelCentered(centerLabel)
.diagonalLabel(diagonalLabel)
.topologicalColoring(topologicalColoring)
.componentLibrary(componentLibrary)
.language(language)
.build();
String result = studyService.getSubstationSvgAndMetadata(
studyUuid,
substationId,
diagramParameters,
substationLayout,
nodeUuid);
return result != null ? ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(result) :
ResponseEntity.noContent().build();
}
@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-area-diagram")
@Operation(summary = "get the network area diagram for the given network and voltage levels")