-
Notifications
You must be signed in to change notification settings - Fork 0
Add Filter Based Contingency List #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: basseche <[email protected]>
Signed-off-by: basseche <[email protected]>
85727fe
to
e775fd4
Compare
|
@OneToMany(cascade = CascadeType.ALL) | ||
private List<FilterMetaDataEntity> filtersListEntities; |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Table(name = "filter_based_contingency_list") | |
@Table(name = ""filter_based_contingency"") |
There was a problem hiding this comment.
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.
src/main/java/org/gridsuite/actions/server/entities/FilterBasedContingencyListEntity.java
Outdated
Show resolved
Hide resolved
<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"/> |
There was a problem hiding this comment.
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"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constrantName not yet managed
src/main/java/org/gridsuite/actions/server/ContingencyListController.java
Outdated
Show resolved
Hide resolved
@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(); | ||
} | ||
} |
There was a problem hiding this comment.
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
@Schema(description = "filter name") | ||
private String name; | ||
|
||
@Schema(description = "equipment type") | ||
private String equipmentType; |
There was a problem hiding this comment.
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
Co-authored-by: Thang PHAM <[email protected]>
} | ||
|
||
@PostMapping(value = "/filters-contingency-lists", params = "duplicateFrom") | ||
@Operation(summary = "Create a filter based contingency list from another existing one") |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ApiResponse(responseCode = "404", description = "Source form contingency list not found")}) | |
@ApiResponse(responseCode = "404", description = "Source from contingency list not found")}) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
record?
There was a problem hiding this comment.
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
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; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes done
needs filter lib version : gridsuite/filter#84