-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into dbraquart/add-network…
…-visualizations-params-controller # Conflicts: # src/main/resources/db/changelog/db.changelog-master.yaml
- Loading branch information
Showing
10 changed files
with
461 additions
and
2 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
.../gridsuite/spreadsheetconfig/server/controller/SpreadsheetConfigCollectionController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* Copyright (c) 2024, 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.spreadsheetconfig.server.controller; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.Parameter; | ||
import io.swagger.v3.oas.annotations.media.Content; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.gridsuite.spreadsheetconfig.server.SpreadsheetConfigApi; | ||
import org.gridsuite.spreadsheetconfig.server.dto.SpreadsheetConfigCollectionInfos; | ||
import org.gridsuite.spreadsheetconfig.server.service.SpreadsheetConfigService; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.UUID; | ||
|
||
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; | ||
|
||
/** | ||
* @author Ayoub LABIDI <ayoub.labidi at rte-france.com> | ||
*/ | ||
@RestController | ||
@RequestMapping(value = "/" + SpreadsheetConfigApi.API_VERSION + "/spreadsheet-config-collections") | ||
@RequiredArgsConstructor | ||
@Tag(name = "Spreadsheet Config Collection", description = "Spreadsheet Configuration Collection API") | ||
public class SpreadsheetConfigCollectionController { | ||
|
||
private final SpreadsheetConfigService spreadsheetConfigService; | ||
|
||
@PostMapping(consumes = APPLICATION_JSON_VALUE) | ||
@Operation(summary = "Create a new spreadsheet configuration collection", | ||
description = "Creates a new spreadsheet configuration collection and returns its ID") | ||
@ApiResponse(responseCode = "201", description = "Configuration collection created", | ||
content = @Content(schema = @Schema(implementation = UUID.class))) | ||
public ResponseEntity<UUID> createSpreadsheetConfigCollection(@Parameter(description = "Configuration collection to save") @Valid @RequestBody SpreadsheetConfigCollectionInfos dto) { | ||
UUID id = spreadsheetConfigService.createSpreadsheetConfigCollection(dto); | ||
return ResponseEntity.status(HttpStatus.CREATED).body(id); | ||
} | ||
|
||
@GetMapping("/{id}") | ||
@Operation(summary = "Get a spreadsheet configuration collection", | ||
description = "Retrieves a spreadsheet configuration collection by its ID") | ||
@ApiResponse(responseCode = "200", description = "Configuration collection found", | ||
content = @Content(schema = @Schema(implementation = SpreadsheetConfigCollectionInfos.class))) | ||
@ApiResponse(responseCode = "404", description = "Configuration collection not found") | ||
public ResponseEntity<SpreadsheetConfigCollectionInfos> getSpreadsheetConfigCollection( | ||
@Parameter(description = "ID of the configuration collection to retrieve") @PathVariable UUID id) { | ||
return ResponseEntity.ok(spreadsheetConfigService.getSpreadsheetConfigCollection(id)); | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
@Operation(summary = "Delete a spreadsheet configuration collection", | ||
description = "Deletes an existing spreadsheet configuration collection") | ||
@ApiResponse(responseCode = "204", description = "Configuration collection deleted") | ||
@ApiResponse(responseCode = "404", description = "Configuration collection not found") | ||
public ResponseEntity<Void> deleteSpreadsheetConfigCollection( | ||
@Parameter(description = "ID of the configuration collection to delete") @PathVariable UUID id) { | ||
spreadsheetConfigService.deleteSpreadsheetConfigCollection(id); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@PutMapping("/{id}") | ||
@Operation(summary = "Update a spreadsheet configuration collection", | ||
description = "Updates an existing spreadsheet configuration collection") | ||
@ApiResponse(responseCode = "204", description = "Configuration collection updated") | ||
@ApiResponse(responseCode = "404", description = "Configuration collection not found") | ||
public ResponseEntity<Void> updateSpreadsheetConfigCollection( | ||
@Parameter(description = "ID of the configuration collection to update") @PathVariable UUID id, | ||
@Valid @RequestBody SpreadsheetConfigCollectionInfos dto) { | ||
spreadsheetConfigService.updateSpreadsheetConfigCollection(id, dto); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@PostMapping(value = "/duplicate", params = { "duplicateFrom" }) | ||
@Operation(summary = "Duplicate a spreadsheet configuration collection", | ||
description = "Creates a copy of an existing spreadsheet configuration collection") | ||
@ApiResponse(responseCode = "201", description = "Configuration collection duplicated", | ||
content = @Content(schema = @Schema(implementation = UUID.class))) | ||
@ApiResponse(responseCode = "404", description = "Configuration collection not found") | ||
public ResponseEntity<UUID> duplicateSpreadsheetConfigCollection(@Parameter(description = "UUID of the configuration collection to duplicate") @RequestParam(name = "duplicateFrom") UUID id) { | ||
UUID newId = spreadsheetConfigService.duplicateSpreadsheetConfigCollection(id); | ||
return ResponseEntity.status(HttpStatus.CREATED).body(newId); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...ain/java/org/gridsuite/spreadsheetconfig/server/dto/SpreadsheetConfigCollectionInfos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) 2024, 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.spreadsheetconfig.server.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
/** | ||
* @author Ayoub LABIDI <ayoub.labidi at rte-france.com> | ||
*/ | ||
@Schema(name = "SpreadsheetConfigCollectionDto", description = "Spreadsheet configuration collection") | ||
public record SpreadsheetConfigCollectionInfos( | ||
|
||
@Schema(description = "Spreadsheet configuration collection ID") | ||
UUID id, | ||
|
||
@Schema(description = "List of spreadsheet configurations") | ||
List<SpreadsheetConfigInfos> spreadsheetConfigs | ||
) { | ||
} |
37 changes: 37 additions & 0 deletions
37
...va/org/gridsuite/spreadsheetconfig/server/entities/SpreadsheetConfigCollectionEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright (c) 2024, 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.spreadsheetconfig.server.entities; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
/** | ||
* @author Ayoub LABIDI <ayoub.labidi at rte-france.com> | ||
*/ | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Setter | ||
@Entity | ||
@Table(name = "spreadsheet_config_collection") | ||
public class SpreadsheetConfigCollectionEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.AUTO) | ||
@Column(name = "id") | ||
private UUID id; | ||
|
||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) | ||
@JoinColumn(name = "collection_id", foreignKey = @ForeignKey(name = "fk_spreadsheet_config_collection")) | ||
@Builder.Default | ||
private List<SpreadsheetConfigEntity> spreadsheetConfigs = new ArrayList<>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ridsuite/spreadsheetconfig/server/repositories/SpreadsheetConfigCollectionRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright (c) 2024, 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.spreadsheetconfig.server.repositories; | ||
|
||
import org.gridsuite.spreadsheetconfig.server.entities.SpreadsheetConfigCollectionEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* @author Ayoub LABIDI <ayoub.labidi at rte-france.com> | ||
*/ | ||
@Repository | ||
public interface SpreadsheetConfigCollectionRepository extends JpaRepository<SpreadsheetConfigCollectionEntity, UUID> { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/resources/db/changelog/changesets/changelog_20241216T144619Z.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.1" encoding="UTF-8" standalone="no"?> | ||
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd"> | ||
<changeSet author="labidiayo (generated)" id="1734360388052-1"> | ||
<createTable tableName="spreadsheet_config_collection"> | ||
<column name="id" type="UUID"> | ||
<constraints nullable="false" primaryKey="true" primaryKeyName="spreadsheet_config_collectionPK"/> | ||
</column> | ||
</createTable> | ||
</changeSet> | ||
<changeSet author="labidiayo (generated)" id="1734360388052-2"> | ||
<addColumn tableName="spreadsheet_config"> | ||
<column name="collection_id" type="uuid"/> | ||
</addColumn> | ||
</changeSet> | ||
<changeSet author="labidiayo (generated)" id="1734360388052-3"> | ||
<addForeignKeyConstraint baseColumnNames="collection_id" baseTableName="spreadsheet_config" constraintName="fk_spreadsheet_config_collection" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="spreadsheet_config_collection" validate="true"/> | ||
</changeSet> | ||
</databaseChangeLog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.