-
Notifications
You must be signed in to change notification settings - Fork 0
Implement global filter #120
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
#120 (review) |
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.
} catch (JsonProcessingException e) { | ||
SensitivityRunQueryResult result = service.getRunResult(resultUuid, networkUuid, variantId, selector, resourceFilters, globalFilter); | ||
return result != null ? ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(result) : ResponseEntity.notFound().build(); | ||
} catch (Exception e) { | ||
return ResponseEntity.badRequest().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.
If you change JsonProcessingException to Exception doesn't it mean that any throw will be considered a bad request error ?
If you want to catch everything maybe : ?
} catch (JsonProcessingException e) {
return ResponseEntity.badRequest().build();
} catch (Exception e) {
return ResponseEntity.internalServerError().build();
}
But if you think that we can consider any error in the controller to be a badRequest, then fine.
Specification<SensitivityResultEntity> baseSpec = buildSpecification(resultUuid, Collections.emptyList(), false); | ||
Specification<SensitivityResultEntity> resourceFilterSpec = buildCustomResourceFilterSpecification(resourceFilters); |
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.
This is this change that breaks the filter by column (cf request change). Probably because you don't use the specification functions anymore (like appendTextFilterToSpecification...)
return columnSpec; | ||
} | ||
|
||
private Specification<SensitivityResultEntity> createSingleFilterSpecification(ResourceFilterDTO filter) { |
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 think you forgot to take into account the DataType of the Filter. The behavior is different between text and numbers.
if (filter.value() instanceof List<?> valueList && !valueList.isEmpty()) { | ||
Path<Object> fieldPath = getFieldPathForFilter(root, filter.column()); | ||
|
||
switch (filter.type()) { |
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.
There are a lot more type that should be handled I think : NOT_EQUAL, CONTAINS... (like in appendTextFilterToSpecification
).
Actually why don't you use appendTextFilterToSpecification
and appendNumberFilterToSpecification
?
@@ -90,4 +208,170 @@ public Map<String, Long> getIdentifiablesCount(SensitivityFactorsIdsByGroup fact | |||
return restTemplate.exchange(filterServerBaseUri + path, HttpMethod.GET, null, new ParameterizedTypeReference<Map<String, Long>>() { | |||
}).getBody(); | |||
} | |||
|
|||
public List<ResourceFilterDTO> getResourceFiltersForSensitivity(UUID networkUuid, String variantId, GlobalFilter globalFilter) { |
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.
We are in sensi Filter service, I don't think this is useful to precise ForSensitivity here. (I took the function declaration from loadflow).
public List<ResourceFilterDTO> getResourceFiltersForSensitivity(UUID networkUuid, String variantId, GlobalFilter globalFilter) { | |
public List<ResourceFilterDTO> getResourceFilters(@NonNull UUID networkUuid, @NonNull String variantId, @NonNull GlobalFilter globalFilter) { |
ResourceFilterDTO.DataType.TEXT, | ||
ResourceFilterDTO.Type.IN, | ||
allSubjectIds, | ||
"functionId" |
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.
"functionId" | |
SensitivityResultEntity.Fields.functionId |
)); | ||
} | ||
|
||
private Map<EquipmentType, List<String>> processEquipmentTypes( |
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 naming doesn't explain the function.
return result; | ||
} | ||
|
||
private List<String> processEquipmentType( |
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 naming doesn't explain the function.
new ArrayList<>(genericFilterResults); | ||
} | ||
|
||
private List<String> processGenericFilter(AbstractFilter filter, EquipmentType equipmentType, Network network) { |
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 naming doesn't explain the function.
//when(networkStoreService.getNetwork(UUID.fromString(eq(network.getId())), any(PreloadingStrategy.class))).thenReturn(network); | ||
//when(network.getVariantManager()).thenReturn(variantManager); |
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 description provided.