-
Notifications
You must be signed in to change notification settings - Fork 168
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 interfaces for CRUD services #20743
Conversation
b433077
to
83ece96
Compare
These were previously in Hilla but are equally useful in Flow applications
83ece96
to
8ebca25
Compare
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/CrudRepositoryService.java
Outdated
Show resolved
Hide resolved
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/JpaFilterConverter.java
Outdated
Show resolved
Hide resolved
...-spring/src/main/java/com/vaadin/flow/spring/data/jpa/PropertyStringFilterSpecification.java
Outdated
Show resolved
Hide resolved
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/JpaFilterConverter.java
Outdated
Show resolved
Hide resolved
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.
Since this is a breaking change anyway, I took the liberty of being extra picky with the review.
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/FormService.java
Show resolved
Hide resolved
@@ -0,0 +1,2 @@ | |||
@org.springframework.lang.NonNullApi | |||
package com.vaadin.flow.spring.data.jpa; |
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.
Maybe also add @NullMarked
from JSpecify?
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.
Why would we need both?
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 removing @NonNullApi
does not break anything, then by all means remove it.
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.
On the contrary, Hilla only supports @NonNullApi
@@ -0,0 +1,2 @@ | |||
@org.springframework.lang.NonNullApi | |||
package com.vaadin.flow.spring.data; |
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.
Same thing here?
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/ListService.java
Outdated
Show resolved
Hide resolved
@JsonSubTypes({ @Type(value = OrFilter.class, name = "or"), | ||
@Type(value = AndFilter.class, name = "and"), | ||
@Type(value = PropertyStringFilter.class, name = "propertyString") }) | ||
public class Filter implements Serializable { |
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.
Are the Filter classes meant to mainly be created by Jackson, or is there a situation where a developer may want to create them in Java as well? Also why are the Filter classes mutable and not immutable?
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 need to create some examples to show usage before this is merged. I think they should be public and ok to create by hand but they don't need to be mutable
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.
Added convenience constructors. Some usage examples in https://github.com/Artur-/flow-crud-demo/tree/main/src/main/java/com/example/demo
@@ -0,0 +1,2 @@ | |||
@org.springframework.lang.NonNullApi |
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.
Consider adding @NullMarked
here.
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/CrudRepositoryService.java
Show resolved
Hide resolved
...-spring/src/main/java/com/vaadin/flow/spring/data/jpa/PropertyStringFilterSpecification.java
Show resolved
Hide resolved
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/CountService.java
Outdated
Show resolved
Hide resolved
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/CountService.java
Outdated
Show resolved
Hide resolved
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/FormService.java
Outdated
Show resolved
Hide resolved
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/filter/PropertyStringFilter.java
Show resolved
Hide resolved
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/ListRepositoryService.java
Show resolved
Hide resolved
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/jpa/JpaFilterConverter.java
Show resolved
Hide resolved
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/CrudService.java
Show resolved
Hide resolved
* @return | ||
*/ | ||
@Override | ||
public long count(@Nullable Filter 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.
Can we have shorthand count()
method ?
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 could. Should we? :D
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 should, minor thing but IMO makes the code reading a bit clearer when count has no null
in the project.
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.
Added
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.
However, now count and list works differently.
Also, it is impossible to do something like
grid.setItemsPageable(pageable -> productService.list(pageable, filter),
pageable -> productService.count(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.
Reverted count()
again. Let's start without it and see?
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, okay 👍
vaadin-spring/src/main/java/com/vaadin/flow/spring/data/filter/PropertyStringFilter.java
Show resolved
Hide resolved
Made a quick example of how a CRUD service may look like with/without these classes vaadin/flow-crm-tutorial@crud-services...without-crud-services. |
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.
Overall looks good and has many benefits of being available in Flow.
LGTM.
This reverts commit c16124f.
Fixes #20834. |
Quality Gate passedIssues Measures |
These were previously in Hilla but are equally useful in Flow applications