You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Spring Boot generic paging, sorting and filtering for PrimeNg tables
5
+
6
+
## Goal of the project
7
+
8
+
PrimeNg tables have a 'lazy' mode when displaying data, it sends all the requests of paging, sorting and filtering to the server to be processed.
9
+
The goal of the this project is to make this server side processing the most generic possible (Spring boot).
10
+
11
+
## Structure of the project
12
+
13
+
- The 'ng' folder contains the sample front-end Angular 8 project
14
+
- The Spring Boot project is a minimal showcase and can be used as a base for other projects, it contains : a sample entity, dao, controller and service and two core classes responsible of building queries
15
+
16
+
## How it works
17
+
18
+
The idea is to make an utility class that parse and convert a PrimeNg json request to a paging and sorting query and build an **RSQL** query for the columns and general filters, this rsql query will then converted to Jpa specification with **[rsql-jpa-specification](https://github.com/perplexhub/rsql-jpa-specification)** and executed against the dao.
19
+
20
+
## Core classes and initial setup
21
+
The two most important java classes in this project are :
22
+
23
+
-**org.nd.primeng.search.PrimengRequestData** : a bean to hold the data parsed from the PrimeNg table request
24
+
-**org.nd.primeng.search.SearchBuilder** : responsible for parsing the PrimeNg table json request, generating the paging and sorting jpa query and building an Rsql query from the filters
25
+
- Please refer to the class **org.nd.primeng.services.UserService** for an example to how to use those classes
26
+
27
+
This project uses **[rsql-jpa-specification](https://github.com/perplexhub/rsql-jpa-specification)** to work, please refer to its documentation to see how the intial setup is done.
28
+
29
+
## <fontcolor="red">Very important notes about dates filtering</font>
30
+
In order to properly filter against date columns, you need to do two things :
31
+
32
+
- Never use java.util.Date or any other java date types as type in your entity classes, use only **java.time.LocalDateTime**
33
+
- You need to properly setup your timezone in the jvm with the parameter **-Duser.timezone**, example :
34
+
35
+
-Duser.timezone=Europe/Paris
36
+
37
+
## Run the project
38
+
39
+
- Create a database in mysql with name : **app_db**
40
+
- Execute the sample data sql file **/db/sample-data.sql** againt the database
41
+
- Set your timezone in pom.xml in order to the date filtering to work properly :
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.3.4.
4
+
5
+
## Development server
6
+
7
+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8
+
9
+
## Code scaffolding
10
+
11
+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12
+
13
+
## Build
14
+
15
+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
16
+
17
+
## Running unit tests
18
+
19
+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20
+
21
+
## Running end-to-end tests
22
+
23
+
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
24
+
25
+
## Further help
26
+
27
+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
0 commit comments