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

Updated Javadoc.

parent d103cf6c
2 merge requests!28Category and doc update to Master.,!27Doc update
Showing
with 176 additions and 14 deletions
......@@ -80,6 +80,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
*/
public static final String WEB_MAPPING_ITEMS = "/products";
/**
* @param env
*/
public WebMvcConfig(Environment env) {
this.env = env;
}
......@@ -105,6 +108,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
*/
private Connection conn;
/**
* @return
*/
@Bean
public Connection connection() {
if (this.conn == null) {
......
......@@ -30,13 +30,28 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class ApiPostCategoryController {
/**
* Category repository.
*/
private ICategoriesRepository repository;
/**
* Constructor.
* @param repo the category repository.
*/
public ApiPostCategoryController(ICategoriesRepository repo)
{
this.repository = repo;
}
/**
* Creates a category.
* @param request Spring request
* @param response Spring response
* @return the created category
* @throws fr.unistra.sil.erp.back.controller.api.ApiServerErrorException
* @throws fr.unistra.sil.erp.back.controller.api.ApiBadRequestException
*/
@RequestMapping(value = MAPPING_CATEGORY, method = RequestMethod.POST)
public ResponseEntity<Object> postCategory(HttpServletRequest request,
HttpServletResponse response)
......@@ -48,7 +63,7 @@ public class ApiPostCategoryController {
body = request.getReader().lines()
.collect(Collectors.joining(System.lineSeparator()));
} catch (IOException ex) {
Logger.getLogger(ApiSubmitTransactionController.class.getName())
Logger.getLogger(ApiPostCategoryController.class.getName())
.log(Level.SEVERE, "Unparseable body.", ex);
throw new ApiBadRequestException("Unparseable body.");
}
......
......@@ -15,11 +15,21 @@ import javax.validation.Valid;
import static fr.unistra.sil.erp.back.WebMvcConfig.MAPPING_ITEMS;
/**
* REST API to create a new item.
*/
@Controller
public class ApiPostItemController {
/**
* Service for storing POJO items.
*/
private final StoreItemService service;
/**
* Constructor.
* @param service the service to store POJO items with.
*/
public ApiPostItemController(StoreItemService service) {
this.service = service;
}
......
......@@ -27,6 +27,10 @@ public class ApiRetrieveCategoriesController implements IRetrieveCategoriesContr
private final ICategoriesRepository repository;
/**
* Class constructor.
* @param repository the category repository.
*/
public ApiRetrieveCategoriesController(ICategoriesRepository repository) {
this.repository = repository;
}
......
......@@ -28,6 +28,10 @@ public class ApiRetrieveItemsController implements IRetrieveInfoController {
private final IItemsRepository repository;
/**
* Class constructor.
* @param repository the item repository.
*/
public ApiRetrieveItemsController(IItemsRepository repository) {
this.repository = repository;
}
......
......@@ -27,8 +27,15 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class ApiRetrieveStocks implements IRetrieveStocks {
/**
* Stock repository.
*/
private final IStocksRepository repository;
/**
*
* @param repository
*/
public ApiRetrieveStocks(IStocksRepository repository) {
this.repository = repository;
}
......
......@@ -13,10 +13,18 @@ import org.springframework.web.bind.annotation.RequestBody;
import static fr.unistra.sil.erp.back.WebMvcConfig.MAPPING_STOCKS;
/**
*
* @author antoine.beauvais
*/
@Controller
public class ApiUpdateStockController {
private final UpdateStockService service;
/**
*
* @param service
*/
public ApiUpdateStockController(UpdateStockService service) {
this.service = service;
}
......
......@@ -8,6 +8,10 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import java.math.BigDecimal;
/**
*
* @author antoine.beauvais
*/
public class PostItemDTO {
/**
* The product's name.
......@@ -36,6 +40,13 @@ public class PostItemDTO {
@Positive
private final int category;
/**
*
* @param name
* @param price
* @param subscriberPrice
* @param category
*/
public PostItemDTO(
@JsonProperty("name") String name,
@JsonProperty("price") BigDecimal price,
......@@ -48,19 +59,35 @@ public class PostItemDTO {
this.category = category;
}
/**
*
* @return
*/
public String getName() {
return name;
}
/**
*
* @return
*/
public BigDecimal getPrice() {
return price;
}
/**
*
* @return
*/
@JsonProperty("subscriber_price")
public BigDecimal getSubscriberPrice() {
return subscriberPrice;
}
/**
*
* @return
*/
public int getCategory() {
return category;
}
......
......@@ -5,6 +5,10 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
/**
*
* @author antoine.beauvais
*/
public class PutStockDTO {
/**
* This product's category identifier.
......@@ -19,15 +23,28 @@ public class PutStockDTO {
@NotNull
private final int quantity;
/**
*
* @param itemId
* @param quantity
*/
public PutStockDTO(@JsonProperty("item_id") int itemId, @JsonProperty("quantity") int quantity) {
this.itemId = itemId;
this.quantity = quantity;
}
/**
*
* @return
*/
public int getItemId() {
return itemId;
}
/**
*
* @return
*/
public int getQuantity() {
return quantity;
}
......
......@@ -12,8 +12,21 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExcep
import java.util.HashMap;
import java.util.Map;
/**
*
* @author antoine.beauvais
*/
@ControllerAdvice
public class ValidationHandler extends ResponseEntityExceptionHandler {
/**
*
* @param ex
* @param headers
* @param status
* @param request
* @return
*/
@Override
protected ResponseEntity<Object> handleMethodArgumentNotValid(
MethodArgumentNotValidException ex,
......
......@@ -8,8 +8,18 @@ import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
/**
*
* @author antoine.beauvais
*/
@Controller
public class WebErrorController implements ErrorController {
/**
*
* @param request
* @return
*/
@RequestMapping("/error")
public String handleError(HttpServletRequest request) {
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
......
......@@ -26,6 +26,10 @@ public class WebProductsController {
private final IItemsRepository repository;
/**
*
* @param repository
*/
public WebProductsController(IItemsRepository repository) {
this.repository = repository;
}
......
......@@ -26,6 +26,10 @@ public class WebRegistryController {
private final IRegistryRepository repository;
/**
*
* @param repository
*/
public WebRegistryController(IRegistryRepository repository) {
this.repository = repository;
}
......
......@@ -24,8 +24,8 @@ public class Category {
/**
* Class constructor.
* @param id the category's identifier.
* @param name the category's name.
* @param id Category ID.
* @param name Category name.
*/
public Category(int id, String name)
{
......
......@@ -50,11 +50,11 @@ public class Item {
/**
* Class constructor.
* @param id The item's reference number.
* @param name The item's name.
* @param price The item's price.
* @param subscriberPrice The item's price for subscribers.
* @param category The item's category.
* @param id Item ID.
* @param name Item name.
* @param price Item price.
* @param subscriberPrice The item's price.
* @param category Item category.
*/
public Item(Integer id, String name, BigDecimal price,
BigDecimal subscriberPrice, int category)
......
......@@ -55,11 +55,11 @@ public class RegistryEntry {
/**
* Class constructor.
* @param id the entry's ID.
* @param transactionType the transaction type.
* @param dt the date and time.
* @param transactionType transaction type.
* @param dt the transaction's date.
* @param accountId the associated account's ID.
* @param debit money for the debit.
* @param credit money for the credit.
* @param debit
* @param credit
* @param remarks arbitrary remarks.
*/
public RegistryEntry(Integer id, int transactionType, Date dt,
......
......@@ -90,6 +90,10 @@ public class Stock {
return this.quantity;
}
/**
*
* @param quantity
*/
public void addQuantity(int quantity) {
this.quantity += quantity;
if (this.quantity < 0) {
......
......@@ -4,6 +4,10 @@ import fr.unistra.sil.erp.back.model.Category;
import java.util.List;
/**
*
* @author antoine.beauvais
*/
public interface ICategoriesRepository {
/**
......@@ -22,7 +26,7 @@ public interface ICategoriesRepository {
/**
* Creates a new category in the database.
*
* @param name the name for the new Category.
* @param c
* @return the created Category.
* @throws fr.unistra.sil.erp.back.repository.DatabaseConnectionException
* @throws fr.unistra.sil.erp.back.repository.DatabaseUpdateException
......
......@@ -4,6 +4,10 @@ import fr.unistra.sil.erp.back.model.Item;
import java.util.List;
/**
*
* @author antoine.beauvais
*/
public interface IItemsRepository {
/**
......@@ -19,7 +23,17 @@ public interface IItemsRepository {
*/
List<Item> getItemsFromCategory(int category);
/**
*
* @param item
* @return
*/
Item store(Item item);
/**
*
* @param id
* @return
*/
Item findById(int id);
}
......@@ -4,11 +4,22 @@ import fr.unistra.sil.erp.back.model.RegistryEntry;
import java.util.List;
/**
*
* @author antoine.beauvais
*/
public interface IRegistryRepository {
/**
* Returns all registry entries.
* @return
* @throws fr.unistra.sil.erp.back.repository.DatabaseConnectionException
*/
List<RegistryEntry> getRegistry() throws DatabaseConnectionException;
/**
*
* @param entry
* @return
*/
RegistryEntry store(RegistryEntry entry);
}
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