-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
This will explain in more detail where to go in the working tree to change what you want to change.
This is the project structure with a short description with what goes in which folder and a detailed description can be found below
recruitment
├─ .travis.yml
├─ Procfile
├─ pom.xml
├─ src
└─ main
├─ client
│ ├─ static
│ │ └─ css
│ │ └─ standard.css
│ └─ templates
│ ├─ layout
│ │ └─ partials
│ │ └─ navigation.html
│ └─ websites.html
├─ java
│ └─ iv1201
│ └─ group1
│ └─ applications
│ └─ recruitment
│ ├─ Main.java
│ ├─ config
│ │ └─ WebSecurityConfig
│ ├─ controller
│ │ └─ RegistrationController
│ ├─ domain
│ │ └─ Database entities
│ ├─ error
│ │ └─ Custom exceptions
│ ├─ exceptionhandling
│ │ ├─ Exception handlers
│ │ └─ validation
│ │ └─ User validation
│ ├─ model
│ │ └─ JPA Repositories
│ └─ service
│ └─ Using the models to preform actions like database calls
├─ resources
│ └─ application.properties
└─ scripts
└─ SQL scripts
In pom.xml, the Maven project is described. All dependencies for spring and the database are found here.
Store all of the CSS and Javascript here in different folders.
Right now we have no Javascript, so just create a folder called js
if you want one, within this folder.
Here all of the sites that should be accessed by any end user are stored.
We use this subfolder to store templates that are used across the site such as the header and footer.
Since we use Spring MVC, our Main.java
basically only starts the SpringBootApplication and is not more interesting.
Here we store all of the configurations for our webapplication that, for example, constraints pages in our site.
So if you create a new page and store it under templates
you will need to specify the restrictions for it in java/.../config/WebSecurityConfig.java
.
Controllers for the entire project are layed out here. The controllers are a tool within SpringBoot that controls the redirections for the website and controls what models and data are allowed to be sent to the view.
More information about the controllers can be found in springs own documentation: https://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/mvc.html
Stores the Spruing Entities.
The entities are objects that are linked to the database tables. ' For example Person.java is an entity that directly connects to the person table in the database and have the same constraints as the database. So when we try to enter a new user in the register.html form, all of the constraints that the database have for that particular table must be met.
If you want to write custom throwable exceptions, write them here please.
Does precisely as you would think. Handles the exceptions.
The custom repositories that extends the Jpa Repositories. These repositories controls the calls to the database.
For example, if you want to get a user from the database you will write the following:
public interface PersonJpaRepository extends JpaRepository<Person,Long>{
Person findByUsername(String username);
}
The findByUsername
is a function which returns a Person and maps to a select sql statement that finds the table Person (because of this line JpaRepository<Person,Long>
) and returns the username we seek.
This works because of the extension of JpaRepository which controlls the mapping. For more information about implementing new queries, check the documentation for Jpa Repositories linked above
The services serves the program by providing implementation of the Models. If the program want's to find a user for example, it goes through the services which then calls the findByUsername
in the Model (which returns a user) and then can do calculations or provide information to the viewer or what not.
Both the Service interfaces and their implementations are stored here.