This is a Spring Boot application that manages the admission process of a university. It allows for the creation, retrieval, update, and deletion of admissions. It also provides endpoints to get admissions by program and applicant.
- Java
- Spring Boot
- Maven
- MySQL
- Java 11
- MySQL
- Maven
- Clone the repository to your local machine using
git clone https://github.com/your-repository-url
. - Navigate to the project directory.
Update the src/main/resources/application.properties
file with your MySQL configuration:
spring.datasource.url=jdbc:mysql://localhost:3306/your-database
spring.datasource.username=your-username
spring.datasource.password=your-password
You can run the application using Maven with the following command:
mvn spring-boot:run
The application provides a RESTful API for managing admissions. Here are some example endpoints:
GET /admissions
: Get all admissions.POST /admissions
: Create a new admission.GET /admissions/{id}
: Get an admission by id.PUT /admissions/{id}
: Update an admission.DELETE /admissions/{id}
: Delete an admission.GET /admissions/program/{programId}
: Get all admissions for a specific program.GET /admissions/applicant/{applicantId}
: Get all admissions for a specific applicant.
/admissions
: GET, POST/admissions/{id}
: GET, PUT, DELETE/admissions/program/{programId}
: GET/admissions/applicant/{applicantId}
: GET
The application uses the following models:
id
: Longapplicant
: Applicantprogram
: Programdecision
: Stringdecision_date
: Date
id
: Longname
: Stringemail
: String
id
: Longname
: String
- id : Long
- name : String
This document provides an overview of the controllers in the project.
The AdmissionController is a REST controller that provides endpoints for managing admissions in the university system. It uses the AdmissionService to perform operations related to admissions.
- GET /admissions: Get all admissions.
- POST /admissions: Create a new admission.
- GET /admissions/{id}: Get an admission by id.
- PUT /admissions/{id}: Update an admission.
- DELETE /admissions/{id}: Delete an admission.
- GET /admissions/program/{programId}: Get all admissions for a specific program.
- GET /admissions/applicant/{applicantId}: Get all admissions for a specific applicant.
To get all admissions, send a GET request to /admissions.
To create a new admission, send a POST request to /admissions with the admission data in the request body.
To get an admission by id, send a GET request to /admissions/{id} where {id} is the id of the admission.
To update an admission, send a PUT request to /admissions/{id} where {id} is the id of the admission. Include the updated admission data in the request body.
To delete an admission, send a DELETE request to /admissions/{id} where {id} is the id of the admission.
To get all admissions for a specific program, send a GET request to /admissions/program/{programId} where {programId} is the id of the program.
To get all admissions for a specific applicant, send a GET request to /admissions/applicant/{applicantId} where {applicantId} is the id of the applicant.
The ApplicantController is a REST controller that provides endpoints for managing applicants in the university system. It uses the ApplicantService to perform operations related to applicants.
- GET /applicants: Get all applicants.
- POST /applicants: Create a new applicant.
- GET /applicants/{id}: Get an applicant by id.
- PUT /applicants/{id}: Update an applicant.
- DELETE /applicants/{id}: Delete an applicant.
To get all applicants, send a GET request to /applicants.
To create a new applicant, send a POST request to /applicants with the applicant data in the request body.
To get an applicant by id, send a GET request to /applicants/{id} where {id} is the id of the applicant.
To update an applicant, send a PUT request to /applicants/{id} where {id} is the id of the applicant. Include the updated applicant data in the request body.
To delete an applicant, send a DELETE request to /applicants/{id} where {id} is the id of the applicant.
The DepartmentController is a REST controller that provides endpoints for managing departments in the university system. It uses the DepartmentService to perform operations related to departments.
- GET /departments: Get all departments.
- POST /departments: Create a new department.
- GET /departments/{id}: Get a department by id.
- PUT /departments/{id}: Update a department.
- DELETE /departments/{id}: Delete a department.
To get all departments, send a GET request to /departments.
To create a new department, send a POST request to /departments with the department data in the request body.
To get a department by id, send a GET request to /departments/{id} where {id} is the id of the department.
To update a department, send a PUT request to /departments/{id} where {id} is the id of the department. Include the updated department data in the request body.
To delete a department, send a DELETE request to /departments/{id} where {id} is the id of the department.
The ProgramController is a REST controller that provides endpoints for managing programs in the university system. It uses the ProgramService to perform operations related to programs.
- GET /programs: Get all programs.
- POST /programs: Create a new program.
- GET /programs/{id}: Get a program by id.
- PUT /programs/{id}: Update a program.
- DELETE /programs/{id}: Delete a program.
To get all programs, send a GET request to /programs.
To create a new program, send a POST request to /programs with the program data in the request body.
To get a program by id, send a GET request to /programs/{id} where {id} is the id of the program.
To update a program, send a PUT request to /programs/{id} where {id} is the id of the program. Include the updated program data in the request body.
To delete a program, send a DELETE request to /programs/{id} where {id} is the id of the program.
The GlobalExceptionHandler is a class that handles all exceptions thrown by the application. It uses the @ControllerAdvice annotation to provide global exception handling.
- handleApplicantNotFoundException(ApplicantNotFoundException ex): Handles ApplicantNotFoundException and returns a NOT_FOUND status.
- handleDepartmentNotFoundException(DepartmentNotFoundException ex): Handles DepartmentNotFoundException and returns a NOT_FOUND status.
- handleProgramNotFoundException(ProgramNotFoundException ex): Handles ProgramNotFoundException and returns a NOT_FOUND status.
- handleAdmissionNotFoundException(AdmissionNotFoundException ex): Handles AdmissionNotFoundException and returns a NOT_FOUND status.
- handleInsufficientDataException(InsufficientDataException ex): Handles InsufficientDataException and returns a BAD_REQUEST status.
- handleIllegalArgumentException(IllegalArgumentException ex): Handles IllegalArgumentException and returns a BAD_REQUEST status.
- handleDataIntegrityViolationException(DataIntegrityViolationException ex): Handles DataIntegrityViolationException and returns a CONFLICT status.
- handleGeneralException(Exception ex): Handles all other exceptions and returns an INTERNAL_SERVER_ERROR status.
The GlobalExceptionHandler is automatically used by Spring to handle exceptions thrown by the application. When an exception is thrown, the corresponding handler method in the GlobalExceptionHandler is invoked, and it returns a ResponseEntity with an appropriate HTTP status and error message.
For example, if an ApplicantNotFoundException is thrown, the handleApplicantNotFoundException method is invoked, and it returns a ResponseEntity with a NOT_FOUND status and the message from the exception.
This section provides an overview of the custom exceptions in the project.
This exception is thrown when an applicant with a specified id cannot be found in the database.
This exception is thrown when a department with a specified id cannot be found in the database.
This exception is thrown when a program with a specified id cannot be found in the database.
This exception is thrown when an admission with a specified id cannot be found in the database.
This exception is thrown when the provided data for a certain operation is insufficient or incomplete.
These exceptions are typically thrown by the service classes when a certain condition is not met. For example, if an attempt is made to retrieve an applicant with an id that does not exist in the database, the ApplicantService would throw an ApplicantNotFoundException.
The GlobalExceptionHandler class is responsible for handling these exceptions. When an exception is thrown, the corresponding handler method in the GlobalExceptionHandler is invoked, and it returns a ResponseEntity with an appropriate HTTP status and error message.
For example, if an ApplicantNotFoundException is thrown, the handleApplicantNotFoundException method in the GlobalExceptionHandler is invoked, and it returns a ResponseEntity with a NOT_FOUND status and the message from the exception.
This section provides an overview of the services in the project.
The AdmissionService is a service class that handles the business logic related to admissions. It is used by the AdmissionController to perform operations related to admissions.
- getAllAdmissions(): Returns a list of all admissions.
- getAdmissionById(Long id): Returns the admission with the specified id.
- createAdmission(Admission admission): Creates a new admission and returns it.
- updateAdmission(Long id, Admission admission): Updates the admission with the specified id and returns the updated admission.
- deleteAdmission(Long id): Deletes the admission with the specified id.
- getAdmissionsByProgram(Long programId): Returns a list of all admissions for the specified program.
- getAdmissionsByApplicant(Long applicantId): Returns a list of all admissions for the specified applicant.
The ApplicantService is a service class that handles the business logic related to applicants. It is used by the ApplicantController to perform operations related to applicants.
- getAllApplicants(): Returns a list of all applicants.
- getApplicantById(Long id): Returns the applicant with the specified id.
- createApplicant(Applicant applicant): Creates a new applicant and returns it.
- updateApplicant(Long id, Applicant applicant): Updates the applicant with the specified id and returns the updated applicant.
- deleteApplicant(Long id): Deletes the applicant with the specified id.
The DepartmentService is a service class that handles the business logic related to departments. It is used by the DepartmentController to perform operations related to departments.
- getAllDepartments(): Returns a list of all departments.
- getDepartmentById(Long id): Returns the department with the specified id.
- createDepartment(Department department): Creates a new department and returns it.
- updateDepartment(Long id, Department department): Updates the department with the specified id and returns the updated department.
- deleteDepartment(Long id): Deletes the department with the specified id.
The ProgramService is a service class that handles the business logic related to programs. It is used by the ProgramController to perform operations related to programs.
- getAllPrograms(): Returns a list of all programs.
- getProgramById(Long id): Returns the program with the specified id.
- createProgram(Program program): Creates a new program and returns it.
- updateProgram(Long id, Program program): Updates the program with the specified id and returns the updated program.
- deleteProgram(Long id): Deletes the program with the specified id.
The application uses a MySQL database with tables for Admission
, Applicant
, and Program
. The Admission
table has a composite unique constraint on applicant_id
and program_id
.
To deploy the application to a production environment, you would typically build a deployable artifact such as a JAR file using Maven, and then deploy this artifact to your production environment.
If you would like to contribute to this project, please fork the repository and submit a pull request.
Thanks to all contributors and users of this project.
For any questions or concerns, please contact Om Midya at [email protected] or via GitHub
This updated README.md file includes the information about all the possible endpoints and model implementation.