-
Notifications
You must be signed in to change notification settings - Fork 357
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: adds sortable schema property [DHIS2-18749] #19612
Conversation
|
||
/** Object sharing (JSONB). */ | ||
protected Sharing sharing = new Sharing(); | ||
@Setter protected Sharing sharing = new Sharing(); |
Check notice
Code scanning / CodeQL
Missing Override annotation Note
IdentifiableObject.setSharing
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.
can a test be added to check for the new field present?
@JacksonXmlProperty(namespace = DxfNamespaces.DXF_2_0) | ||
public boolean isSortable() { | ||
Sortable sortable = getterMethod == null ? null : getterMethod.getAnnotation(Sortable.class); | ||
return sortable != null ? sortable.value() : !isCollection() && isSimple(); |
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 we need to check if the property is persisted
, meaning it is mapped to a database column.
For example: a class may not have the property shortName
but it is still inherit the property from base class.
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.
Good point, but I will have to find a way to not exclude a computed property like displayName
that way since it isn't persisted but still possible to sort by.
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 use persisted
now where the default is that it has to be persisted. To make properties like displayName
still be sortable they must be annotated with @Sortable(whenPersisted=false)
. This is not perfect but covers most of the cases.
Added a test now |
Quality Gate passedIssues Measures |
Summary
Adds a
sortable
property to schemaProperty
that indicates if a property can be used in theorder
parameter.By default only simple non-collections properties are sortable. Exceptions can be made by annotating the property getter with
@Sortable(true)
or@Sortable(false)
.As far as I could tell we do not have any actual validation for the
order
parameter apart from simply ignoring collections and non-simple properties should they be present. Therefore that logic was used as the fall-back if no@Sortable
annotation is present.Cleanup
IDE supported refactoring to
@Setter
and some@Getter
instead of explicitly stating the methodfinal
Manual changes
access = READ_ONLY
for jacksonManual Testing
check for example
/api/schemas/dataElement
and look at theproperties
arrayProperties now have a
sortable
attribute, for examplename
looks like