Skip to content
Snippets Groups Projects
Commit 8a083a30 authored by BEAUVAIS ANTOINE's avatar BEAUVAIS ANTOINE
Browse files

Merge branch 'develop' into 'master'

Javadoc updates.

See merge request !12
parents 3558507f ef29e55f
Branches
1 merge request!12Javadoc updates.
Showing
with 98 additions and 27 deletions
......@@ -13,6 +13,15 @@ responsable de la gestion des stocks pour les articles à vendre.
L'application fournit également aux autres services les informations
sur les produits disponibles tels que les prix de chaque article.
### Documentation
L'API REST est documentée à travers un document OpenAPI qui peut être visionné
sur l'éditeur en ligne [SwaggerHub](https://editor.swagger.io/).
La documentation Java (Javadoc) du projet est généré automatiquement par
le système d'intégration continue (CI) pour chaque révision de la branche `master`
et peut être consultée [ici](https://erp-sil.pages.unistra.fr/back/) (en anglais).
### Exécution
BACK est une application Web [Java Spring](https://spring.io/) utilisant
......@@ -76,7 +85,8 @@ ou, sur Microsoft Windows,
### Appel de l'API
TODO: Ajouter la spécification OpenAPI.
Passez par [SwaggerHub](https://editor.swagger.io/) pour ouvrir le fichier `back-openapi.yaml`,
qui est un document OpenAPI.
Utilisez [Postman](https://www.postman.com/) ou [Advanced REST Client](https://install.advancedrestclient.com/install) pour l'appeler l'API REST.
......
......@@ -14,6 +14,14 @@ It also provides other components information about the available
products such as the number of each article in stock as well as their
price.
### Documentation
The RESTful API is documented through an OpenAPI specification file that you can
open through [SwaggerHub](https://editor.swagger.io/).
The project's Javadoc is automatically generated through CI for each commit
on the `master` branch and can be found [here](https://erp-sil.pages.unistra.fr/back/).
### Running
BACK is a [Java Spring](https://spring.io/) Web application built using
......@@ -73,7 +81,8 @@ or, on Microsoft Windows,
### Calling the API
TODO: Add OpenAPI specification.
Go to [SwaggerHub](https://editor.swagger.io/) to open the `back-openapi.yaml` file, which is
an OpenAPI specification document.
Use [Postman](https://www.postman.com/) or [Advanced REST Client](https://install.advancedrestclient.com/install) to make calls to the RESTful API.
......
......@@ -24,6 +24,11 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
javadoc {
title = "SIL ERP BACK 0.0.1 API Specification"
options.overview = "src/main/java/overview.html"
}
test {
useJUnitPlatform()
}
......@@ -2,3 +2,5 @@ version=1.0
license=https://cecill.info/licences/Licence_CeCILL-B_V1-fr.html
netbeans.license=cecill-b
org.gradle.warning.mode=all
\ No newline at end of file
rootProject.name = 'erp.back'
rootProject.name = 'SIL ERP BACK'
......@@ -5,8 +5,8 @@
package fr.unistra.sil.erp.back;
import fr.unistra.sil.erp.back.db.DatabaseConnectionException;
import fr.unistra.sil.erp.back.db.DatabaseInterface;
import fr.unistra.sil.erp.back.db.DatabaseSQLiteImpl;
import fr.unistra.sil.erp.back.db.IDatabase;
/**
* Manages the database implementation to use.
......@@ -17,7 +17,7 @@ public class DatabaseSystem {
/**
* The database implementation object.
*/
private static DatabaseInterface instance;
private static IDatabase instance;
/**
* Returns the database implementation in use.In order to change the
......@@ -27,7 +27,7 @@ public class DatabaseSystem {
* @return the instance of the database implementation.
* @throws DatabaseConnectionException if the connection to the DB failed.
*/
public static DatabaseInterface getInstance() throws DatabaseConnectionException
public static IDatabase getInstance() throws DatabaseConnectionException
{
if(DatabaseSystem.instance == null)
DatabaseSystem.instance = new DatabaseSQLiteImpl();
......
......@@ -3,9 +3,20 @@ package fr.unistra.sil.erp.back;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Java Spring entry class.
*
* This is where the Spring application boots.
*
* @author BEAUVAIS ANTOINE
*/
@SpringBootApplication
public class ErpBackApplication {
/**
* Application's main method.
* @param args command-line arguments.
*/
public static void main(String[] args) {
SpringApplication.run(ErpBackApplication.class, args);
}
......
......@@ -3,8 +3,17 @@ package fr.unistra.sil.erp.back;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* Servlet initialization class.
* @author BEAUVAIS ANTOINE
*/
public class ServletInitializer extends SpringBootServletInitializer {
/**
* Configures the Spring application through its builder.
* @param application the application's builder.
* @return the Spring builder for this application.
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ErpBackApplication.class);
......
......@@ -26,6 +26,9 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
)
public class WebMvcConfig implements WebMvcConfigurer {
/**
* Autowired environment for retrieving properties.
*/
@Autowired
private Environment env;
......@@ -77,6 +80,17 @@ public class WebMvcConfig implements WebMvcConfigurer {
configurer.enable();
}*/
/**
* Adds interceptors to the application.
*
* Interceptors process HTTP requests before they reach their
* attributed methods.
*
* Currently, interceptors are only used for authentication in this
* application.
*
* @param registry the Interceptor Registry to use for additions.
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
......
......@@ -23,11 +23,11 @@ public class ApiBadRequestException extends Exception {
/**
* Class constructor.
* @param errMsg the error message.
* @param string the error message.
*/
public ApiBadRequestException(String errMsg)
public ApiBadRequestException(String string)
{
super(errMsg);
super(string);
}
}
......@@ -9,7 +9,6 @@ import fr.unistra.sil.erp.back.DatabaseSystem;
import fr.unistra.sil.erp.back.controller.IRetrieveCategoriesController;
import fr.unistra.sil.erp.back.model.Category;
import fr.unistra.sil.erp.back.db.DatabaseConnectionException;
import fr.unistra.sil.erp.back.db.DatabaseInterface;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -17,6 +16,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import fr.unistra.sil.erp.back.db.IDatabase;
/**
* REST controller for the category list.
......@@ -35,7 +35,7 @@ public class ApiRetrieveCategoriesController
@Override
public ResponseEntity<Object> getCategories() throws ApiServerErrorException
{
DatabaseInterface db;
IDatabase db;
try {
db = DatabaseSystem.getInstance();
} catch (DatabaseConnectionException ex) {
......
......@@ -9,7 +9,6 @@ import fr.unistra.sil.erp.back.DatabaseSystem;
import fr.unistra.sil.erp.back.controller.IRetrieveInfoController;
import fr.unistra.sil.erp.back.model.Item;
import fr.unistra.sil.erp.back.db.DatabaseConnectionException;
import fr.unistra.sil.erp.back.db.DatabaseInterface;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -18,6 +17,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import fr.unistra.sil.erp.back.db.IDatabase;
/**
* REST controller for the item list.
......@@ -38,7 +38,7 @@ public class ApiRetrieveItemsController implements IRetrieveInfoController {
@RequestParam(value = "category", defaultValue = "") String cat
) throws ApiServerErrorException, ApiBadRequestException
{
DatabaseInterface db;
IDatabase db;
try {
db = DatabaseSystem.getInstance();
} catch (DatabaseConnectionException ex) {
......
......@@ -8,7 +8,6 @@ import static fr.unistra.sil.erp.back.WebMvcConfig.MAPPING_GETSTOCKS;
import fr.unistra.sil.erp.back.DatabaseSystem;
import fr.unistra.sil.erp.back.controller.IRetrieveStocks;
import fr.unistra.sil.erp.back.db.DatabaseConnectionException;
import fr.unistra.sil.erp.back.db.DatabaseInterface;
import fr.unistra.sil.erp.back.model.Stock;
import java.util.List;
import java.util.logging.Level;
......@@ -19,6 +18,7 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import fr.unistra.sil.erp.back.db.IDatabase;
/**
* Retrieves stocks in JSON format.
......@@ -38,7 +38,7 @@ public class ApiRetrieveStocks implements IRetrieveStocks {
@Override
public ResponseEntity<Object> retrieveStocks(HttpServletRequest request,
HttpServletResponse response) throws ApiServerErrorException {
DatabaseInterface db;
IDatabase db;
try {
db = DatabaseSystem.getInstance();
} catch (DatabaseConnectionException ex) {
......
......@@ -18,10 +18,10 @@ public class ApiServerErrorException extends Exception {
/**
* Class constructor.
* @param errMsg the error message to display to the end-user.
* @param string the error message to display to the end-user.
*/
public ApiServerErrorException(String errMsg)
public ApiServerErrorException(String string)
{
super(errMsg);
super(string);
}
}
......@@ -10,7 +10,6 @@ import static fr.unistra.sil.erp.back.WebMvcConfig.MAPPING_SUBTRANSAC;
import fr.unistra.sil.erp.back.DatabaseSystem;
import fr.unistra.sil.erp.back.controller.ISubmitTransactionController;
import fr.unistra.sil.erp.back.db.DatabaseConnectionException;
import fr.unistra.sil.erp.back.db.DatabaseInterface;
import fr.unistra.sil.erp.back.db.DatabaseResourceNotFoundException;
import fr.unistra.sil.erp.back.db.DatabaseUpdateException;
import fr.unistra.sil.erp.back.model.Stock;
......@@ -26,6 +25,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import fr.unistra.sil.erp.back.db.IDatabase;
/**
* REST Controller for submitting transactions.
......@@ -80,7 +80,7 @@ public class ApiSubmitTransactionController
if(!t.checkIfValid())
throw new ApiBadRequestException("Invalid JSON schema.");
DatabaseInterface db;
IDatabase db;
Stock s;
try {
db = DatabaseSystem.getInstance();
......
/**
* API implementations of the HTTP controllers.
*/
package fr.unistra.sil.erp.back.controller.api;
\ No newline at end of file
/**
* Controller interfaces to handle HTTP requests.
*
* Controllers are responsible for processing requests once they have
* been approved by interceptors.
*/
package fr.unistra.sil.erp.back.controller;
\ No newline at end of file
......@@ -18,11 +18,11 @@ public class DatabaseConnectionException extends Exception {
/**
* Class constructor.
* @param errMsg the error message.
* @param string the error message.
*/
public DatabaseConnectionException(String errMsg)
public DatabaseConnectionException(String string)
{
super(errMsg);
super(string);
}
}
......@@ -16,11 +16,11 @@ public class DatabaseResourceNotFoundException extends Exception {
/**
* Class constructor.
* @param errMsg the error message.
* @param string the error message.
*/
public DatabaseResourceNotFoundException(String errMsg)
public DatabaseResourceNotFoundException(String string)
{
super(errMsg);
super(string);
}
}
......@@ -26,7 +26,7 @@ import java.util.logging.Logger;
*
* @author BEAUVAIS ANTOINE
*/
public class DatabaseSQLiteImpl implements DatabaseInterface {
public class DatabaseSQLiteImpl implements IDatabase {
/**
* SQLite's connection string for the JDBC driver.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment