Study07 README Contents

Research the Spring Data REST application with the H2 database


The flowchart with the SpringBoot application and the H2 database.

Spring Data REST

The controllers for the Department and the Employee are generated by Spring Data REST .
The relevant MVC context hierarchy diagram is on page Spring Web MVC.
The generation process uses customizations from the DepartmentRepository and the EmployeeRepository.
The helper controller SampleDatasetLoaderController is used only for loading the sample dataset.

The sections of this project:

  1. SpringBoot Server
  2. Web Browser Client
  3. Curl Client

Java source code. Packages:

application sources :  kp
test sources :  kp


The domain objects class diagram.


Java API Documentation ●  Java Test API Documentation


❶ SpringBoot Server

Action:

1. With batch file "01 MVN clean install run.bat" build and start the SpringBoot Server.

Back to the top of the page


❷ Web Browser Client

Action:

1. With the URL http://localhost:8080 open in the web browser the 'home page'.
2. Loading standard dataset with 2 departments. On this 'home page' select
'Load sample dataset : 2 departments' http://localhost:8080/loadSampleDataset.
3. Two endpoints need to load a bigger dataset with 15 departments. On this 'home page' select
'Load sample dataset : 15 departments' http://localhost:8080/loadSampleDataset?depIndex=15.

2.1. The 'home page' file index.html: HTML code, HTML preview


The screenshot of the home page.

2.2. The endpoints generated for Department and selected from the default set.

2.2.1. Get all departments: /departments


The result from the endpoint 'Get all departments'.

2.2.2. Get all departments on 3rd page: /departments?page=2&size=3&sort=name,asc
This endpoint requires loading a bigger dataset with 15 departments.


The result from the endpoint 'Get all departments on 3rd page'.

2.2.3. Get the department: /departments/1


The result from the endpoint 'Get the department'.

2.2.4. Get the employees of the department: /departments/1/employees


The result from the endpoint 'Get the employees of the department'.

2.3. The endpoints generated for Department and based on the interface DepartmentRepository.
The screenshot of the result from the _links endpoint /departments/search

2.3.1. Find all departments on 3rd slice:
/departments/search/findAllByOrderByName?page=2&size=3&sort=name,asc
This endpoint requires loading a bigger dataset with 15 departments.
The method exposed on the repository: kp.company.repository.DepartmentRepository::findAllByOrderByName.


The result from the endpoint 'Find all departments on 3rd slice'.

2.3.2. Find departments by name: /departments/search/findByName?name=D-Name-01
The method exposed on the repository: kp.company.repository.DepartmentRepository::findByName.


The result from the endpoint 'Find departments by name'.

2.3.3. Count departments by name: /departments/search/countByName?name=D-Name-01
The method exposed on the repository: kp.company.repository.DepartmentRepository::countByName.


The result from the endpoint 'Count departments by name'.

2.3.4. Count employees in the department with id: /departments/search/countByCustomQuery?id=1
The method exposed on the repository: kp.company.repository.DepartmentRepository::countByCustomQuery.
This method has the annotation with SQL query, and it returns DepartmentDto object.


The result from the endpoint 'Count employees in the department with id'.

2.3.5. Delete departments by name: /departments/search/deleteByName?name=D-Name-01
The method exposed on the repository: kp.company.repository.DepartmentRepository::deleteByName.


The result from the endpoint 'Delete departments by name'.

2.4. The endpoints generated for Employee and selected from the default set.

2.4.1. Get all employees: /employees


The result from the endpoint 'Get all employees'.

2.4.2. Get the employee: /employees/101


The result from the endpoint 'Get the employee'.

2.4.3. Get the department of the employee: /employees/101/department


The result from the endpoint 'Get the department of the employee'.

2.5. The endpoints generated for Employee and based on interface EmployeeRepository
The screenshot of the result from the _links endpoint /employees/search

2.5.1. Find employees by first name and last name:
/employees/search/findByFirstNameAndLastNameOrderByLastName?firstName=EF-Name-101&lastName=EL-Name-101
The method exposed on the repository: kp.company.repository.EmployeeRepository::findByFirstNameAndLastNameOrderByLastName.


The result from the endpoint 'Find employees by first name and last name'.

2.5.2. Find employees by first name and last name using 'LIKE' pattern:
/employees/search/findByFirstNameLikeAndLastNameLikeOrderByLastName?firstName=%01&lastName=%01
The method exposed on the repository: kp.company.repository.EmployeeRepository::findByFirstNameLikeAndLastNameLikeOrderByLastName.


The result from the endpoint 'Find employees by first name and last name using 'LIKE' pattern'.

2.5.3. Find employees by department name:
/employees/search/findByDepartmentNameOrderByLastNameDesc?name=D-Name-01
The method exposed on the repository: kp.company.repository.EmployeeRepository::findByDepartmentNameOrderByLastNameDesc.


The result from the endpoint 'Find employees by department name'.

2.6. The Application-Level Profile Semantics (ALPS) links

2.7. The Spring Boot Actuator creates the endpoints for monitoring and managing the application.
The screenshot of "List of actuator endpoints" link.

Back to the top of the page


❸ Curl Client

Action:

1. With batch file "02 CURL CRUD.bat" create, read, update, and delete departments and employees.
2. With batch file "03 CURL load and read.bat" load the sample dataset and get departments and employees.

3.1. The console log screenshots from the run of the batch file "02 CURL CRUD.bat".
3.1.1. The screenshot of "CREATE" and "READ by id - after CREATE" steps.
3.1.2. The screenshot of "UPDATE with PUT by id" and "READ by id - after UPDATE with PUT" steps.
The 'PUT' replaces an entire record. Fields not supplied are replaced with null.
3.1.3. The screenshot of "UPDATE with PATCH by id" and "READ by id - after UPDATE with PATCH" steps.
The 'PATCH' updates a subset of items.
3.1.4. The screenshot of "DELETE by id" and "READ by id - after DELETE" steps.

3.2. The console log screenshots from the run of the batch file "03 CURL load and read.bat".
3.2.1. The screenshot of "Load sample dataset" step.
3.2.2. The screenshot of "GET one department" and "GET one employee" steps.
3.2.3. The screenshot of "GET all departments" and "GET all employees" step.

Back to the top of the page


Dictionary

ALPSApplication-Level Profile Semantics
HALHypertext Application Language
HATEOASHypermedia As The Engine Of Application State
RESTRepresentational State Transfer
Back to the top of the page