Skip to content

Conversation

basseche
Copy link

@basseche basseche commented Sep 1, 2025

needs filter lib version : gridsuite/filter#84

@basseche basseche self-assigned this Sep 1, 2025
@basseche basseche changed the title Add Filter Based Contingency List WIP : Add Filter Based Contingency List Sep 1, 2025
@basseche basseche force-pushed the filterBasedContingencyList branch from 85727fe to e775fd4 Compare September 4, 2025 12:58
@basseche basseche changed the title WIP : Add Filter Based Contingency List Add Filter Based Contingency List Sep 11, 2025
Copy link

Comment on lines 30 to 31
@OneToMany(cascade = CascadeType.ALL)
private List<FilterMetaDataEntity> filtersListEntities;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should declare all annotations for this relation, ex; table name, column names, constraint name

@Getter
@Setter
@Entity
@Table(name = "filter_based_contingency_list")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Table(name = "filter_based_contingency_list")
@Table(name = ""filter_based_contingency"")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No contingency list is on element in this table. We should stay coherent with the other contingency list names.

<addForeignKeyConstraint baseColumnNames="filter_based_contingency_list_entity_id" baseTableName="filter_based_contingency_list_filters_list_entities" constraintName="FK9edqyxdc33w1i725puwjjfhf5" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="filter_based_contingency_list" validate="true"/>
</changeSet>
<changeSet author="elcheikhbas (generated)" id="1756734757338-15">
<addForeignKeyConstraint baseColumnNames="filters_list_entities_id" baseTableName="filter_based_contingency_list_filters_list_entities" constraintName="FKgvj11ba8of2teiuumbgfho6c8" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="filter_metadata" validate="true"/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constrantName not yet managed

<addUniqueConstraint columnNames="filters_list_entities_id" constraintName="UC_FILTER_BASED_CONTINGENCY_LIST_FILTERS_LIST_ENTITIESFILTERS_L" tableName="filter_based_contingency_list_filters_list_entities"/>
</changeSet>
<changeSet author="elcheikhbas (generated)" id="1756734757338-14">
<addForeignKeyConstraint baseColumnNames="filter_based_contingency_list_entity_id" baseTableName="filter_based_contingency_list_filters_list_entities" constraintName="FK9edqyxdc33w1i725puwjjfhf5" deferrable="false" initiallyDeferred="false" referencedColumnNames="id" referencedTableName="filter_based_contingency_list" validate="true"/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constrantName not yet managed

Comment on lines +162 to +175
@PutMapping(value = "/filters-contingency-lists/{id}", consumes = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Modify a filter based contingency list")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The filter based contingency list have been modified successfully")})
public ResponseEntity<Void> modifyFilterBasedContingencyList(
@PathVariable UUID id,
@RequestBody FilterBasedContingencyList contingencyList,
@RequestHeader("userId") String userId) {
try {
service.modifyFilterBasedContingencyList(id, contingencyList, userId);
return ResponseEntity.ok().build();
} catch (EntityNotFoundException ignored) {
return ResponseEntity.notFound().build();
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PUT insert new lines in filter_metadata but not clean old lines, to verify annotation orphanRemoval option of OneToMany.
However, I see lines in relation table are removed

Comment on lines 24 to 28
@Schema(description = "filter name")
private String name;

@Schema(description = "equipment type")
private String equipmentType;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, storing filter metadata on the actions server creates a risk: if a filter’s name or equipment type is updated, this information won’t stay synchronized.

These metadata should be enriched at service level when GET filter's info

}

@PostMapping(value = "/filters-contingency-lists", params = "duplicateFrom")
@Operation(summary = "Create a filter based contingency list from another existing one")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the correct sentence is from an existing one or another one

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok changed

@PostMapping(value = "/filters-contingency-lists", params = "duplicateFrom")
@Operation(summary = "Create a filter based contingency list from another existing one")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The filter based contingency list have been duplicated successfully"),
@ApiResponse(responseCode = "404", description = "Source form contingency list not found")})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@ApiResponse(responseCode = "404", description = "Source form contingency list not found")})
@ApiResponse(responseCode = "404", description = "Source from contingency list not found")})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's a mistake

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes i should replace by filter based contingency list

@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "Metadata on filters composing filter based contingency list")
public class FilterMetaData {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

record?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok changed the class was renamed to FilterAttributes

Comment on lines +376 to +378
String jsonData = "{\"filters\":[{\"equipmentType\":\"LINE\",\"id\":\"b45df471-ada2-4422-975b-d89b62192191\",\"name\":\"Filter1\"}";
jsonData += ",{\"equipmentType\":\"TWO_WINDINGS_TRANSFORMER\",\"id\":\"2da834f8-6ab7-4781-b3ba-83f6f4a2f509\",\"name\":\"Filter3\"}]}";
return jsonData;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these kind of strings are very annoying to read and maintain can you make it an object or a json ?

import org.springframework.web.client.RestTemplate;

@Configuration
public class RestTemplateConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you took it from another service, maybe we can mutualize this bean?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants