Skip to content
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

feat: Add filtering capabilities in events change log [DHIS2-18012] #19268

Merged
merged 5 commits into from
Nov 25, 2024

Conversation

muilpp
Copy link
Contributor

@muilpp muilpp commented Nov 22, 2024

This PR introduces filtering for change logs. These filters differ slightly from the ones we currently use:

  • They accept only one field at a time.
  • They support only the equals operator.
  • Filtering is limited to username, data element, or property.

Another key difference is that while our current filters are UID based, these new filters are string based.

Although the only supported operator is eq, I’ve retained the filter format [field]:[operator]:[filter] used in other endpoints. This way, if we need to support additional operators in the future, it won’t require a breaking change.

validateFilter(String, Set<String>) is used only for event change logs, but it will be used for attributes as soon as we refactor those change logs, that's why I added it to RequestParamsValidator

Note: ACL validation for data elements is not yet implemented. I will address this in a separate ticket once we decide how data sharing validation on data elements should be handled.

@muilpp muilpp marked this pull request as ready for review November 22, 2024 15:36
@muilpp muilpp requested a review from a team as a code owner November 22, 2024 15:36
@@ -40,20 +42,30 @@
public class EventChangeLogOperationParams {

private Order order;
private Map.Entry<String, QueryFilter> filterEntry;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it makes sense to make this field a Pair?
Right now I don't understand why we have a Map.Entry here but in the builder we have a filterMap method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I just didn't want to use an external library, but I agree conceptually probably makes more sense to use Pair instead of Map.Entry.

private EventChangeLogOperationParamsBuilder order(Order order) {
return this;
}

private EventChangeLogOperationParamsBuilder filterMap(Pair<String, QueryFilter> filterMap) {
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
private EventChangeLogOperationParamsBuilder filterMap(Pair<String, QueryFilter> filterMap) {
private EventChangeLogOperationParamsBuilder filter(Pair<String, QueryFilter> filter) {

@muilpp muilpp enabled auto-merge (squash) November 25, 2024 15:33
Copy link

sonarqubecloud bot commented Nov 25, 2024

@muilpp muilpp merged commit 2313c47 into master Nov 25, 2024
14 checks passed
@muilpp muilpp deleted the DHIS2-18012-filter-change-logs branch November 25, 2024 15:46
private EventChangeLogOperationParamsBuilder order(Order order) {
return this;
}

private EventChangeLogOperationParamsBuilder filter(Pair<String, QueryFilter> filter) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'filter' is never used.
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