From d1223e2c15540d5385b1b1d50e7905c359adfed3 Mon Sep 17 00:00:00 2001 From: FyloZ Date: Sun, 16 Feb 2020 14:24:23 -0500 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20du=20refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/configuration/InitialDataLoader.java | 16 ++- .../core/io/file/ImageHandler.java | 2 +- .../core/io/response/ResponseDataType.java | 8 +- .../core/model/BeanModel.java | 5 - .../core/model/Company.java | 12 +-- .../core/model/IModel.java | 5 + .../core/model/Material.java | 13 +-- .../core/model/MaterialType.java | 22 ++--- .../colorrecipesexplorer/core/model/Mix.java | 14 +-- .../core/model/MixQuantity.java | 12 +-- .../core/model/MixType.java | 14 +-- .../core/model/Recipe.java | 30 +++--- .../core/model/RecipeStep.java | 12 +-- .../core/services/GenericService.java | 10 +- .../core/services/IGenericService.java | 8 +- .../core/services/InventoryService.java | 2 +- .../core/services/model/CompanyService.java | 4 +- .../core/services/model/MaterialService.java | 16 +-- .../services/model/MaterialTypeService.java | 13 +-- .../core/services/model/MixService.java | 10 +- .../core/services/model/MixTypeService.java | 2 +- .../core/services/model/RecipeService.java | 16 +-- .../colorrecipesexplorer/dao/CompanyDao.java | 4 +- .../colorrecipesexplorer/dao/MaterialDao.java | 8 +- .../dao/MaterialTypeDao.java | 4 +- .../colorrecipesexplorer/dao/MixDao.java | 5 +- .../dao/MixQuantityDao.java | 2 +- .../colorrecipesexplorer/dao/MixTypeDao.java | 4 +- .../colorrecipesexplorer/dao/RecipeDao.java | 8 +- .../colorrecipesexplorer/dao/StepDao.java | 4 +- .../colorrecipesexplorer/web/PagesPaths.java | 34 +++---- .../colorrecipesexplorer/web/StringBank.java | 2 +- .../web/controller/ImageFilesController.java | 32 +++--- .../web/controller/IndexController.java | 4 +- .../web/controller/InventoryController.java | 10 +- .../web/controller/OthersController.java | 16 +-- .../controller/RecipeExplorerController.java | 32 +++--- .../web/controller/SIMDUTFilesController.java | 12 +-- .../creators/CompanyCreatorController.java | 6 +- .../creators/MaterialCreatorController.java | 6 +- .../MaterialTypeCreatorController.java | 2 +- .../creators/MixCreatorController.java | 14 +-- .../editors/MaterialEditorController.java | 46 ++++----- .../editors/MaterialTypeEditorController.java | 24 ++--- .../editors/MixEditorController.java | 34 +++---- .../editors/RecipeEditorController.java | 16 +-- .../removers/CompanyRemoverController.java | 12 +-- .../removers/MaterialRemoverController.java | 12 +-- .../MaterialTypeRemoverController.java | 10 +- .../removers/RecipeRemoverController.java | 10 +- .../xlsx/XlsxExporter.java | 18 ++-- src/main/resources/application.yml | 1 + .../resources/templates/company/creator.html | 4 +- .../resources/templates/company/remover.html | 10 +- src/main/resources/templates/images/add.html | 2 +- src/main/resources/templates/index.html | 20 ++-- src/main/resources/templates/inventory.html | 20 ++-- .../resources/templates/material/created.html | 2 +- .../resources/templates/material/creator.html | 10 +- .../resources/templates/material/edit.html | 26 ++--- .../resources/templates/material/editor.html | 16 +-- .../resources/templates/material/remover.html | 14 +-- .../resources/templates/material/simdut.html | 2 +- .../templates/materialType/creator.html | 4 +- .../templates/materialType/edit.html | 12 +-- .../templates/materialType/editor.html | 14 +-- .../templates/materialType/remover.html | 12 +-- src/main/resources/templates/mix/creator.html | 8 +- src/main/resources/templates/mix/editor.html | 16 +-- .../resources/templates/mix/selector.html | 6 +- src/main/resources/templates/recipe/bak.html | 30 +++--- .../resources/templates/recipe/created.html | 4 +- .../resources/templates/recipe/creator.html | 12 +-- src/main/resources/templates/recipe/edit.html | 54 +++++----- .../resources/templates/recipe/editor.html | 22 ++--- .../resources/templates/recipe/explore.html | 98 +++++++++---------- .../resources/templates/recipe/remover.html | 18 ++-- .../core/services/CompanyServiceTests.java | 18 ++-- .../core/services/MaterialServiceTests.java | 34 +++---- .../services/MaterialTypeServiceTests.java | 28 +++--- .../services/MixQuantityServiceTests.java | 2 +- .../core/services/MixServiceTests.java | 10 +- .../core/services/MixTypeServiceTests.java | 24 ++--- .../core/services/RecipeServiceTests.java | 10 +- 84 files changed, 572 insertions(+), 628 deletions(-) delete mode 100644 src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/BeanModel.java create mode 100644 src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/IModel.java diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/configuration/InitialDataLoader.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/configuration/InitialDataLoader.java index 2c2be3f..fec3356 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/configuration/InitialDataLoader.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/configuration/InitialDataLoader.java @@ -25,18 +25,16 @@ public class InitialDataLoader implements ApplicationListener optionalSavedMaterialType = materialTypeService.save(defaultMaterialType); + private void createInitialMaterialType(MaterialType materialType) { + Optional optionalSavedMaterialType = materialTypeService.save(materialType); if (!optionalSavedMaterialType.isPresent()) { - ColorRecipesExplorerApplication.LOGGER.warn(String.format("Échec de la création du type de produit par défaut '%s'.", name)); + ColorRecipesExplorerApplication.LOGGER.warn(String.format("Échec de la création du type de produit par défaut '%s'.", materialType.getName())); } } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/io/file/ImageHandler.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/io/file/ImageHandler.java index d53848b..067185f 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/io/file/ImageHandler.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/io/file/ImageHandler.java @@ -16,7 +16,7 @@ public class ImageHandler extends FileHandler { private RecipeService recipeService; public ImageHandler(Recipe recipe, RecipeService recipeService) { - super(String.format("%s_%s", recipe.getRecipeID(), recipe.getRecipeCode()), FileContext.IMAGE, FileExtension.JPEG); + super(String.format("%s_%s", recipe.getId(), recipe.getName()), FileContext.IMAGE, FileExtension.JPEG); this.recipe = recipe; this.recipeService = recipeService; diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/io/response/ResponseDataType.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/io/response/ResponseDataType.java index 19a55c8..44bfbeb 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/io/response/ResponseDataType.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/io/response/ResponseDataType.java @@ -9,7 +9,7 @@ import java.util.stream.Stream; public enum ResponseDataType { MATERIAL("material", Material.class), MATERIALS("materials", ArrayList.class, MATERIAL), - MATERIAL_ID("materialID", Integer.class), + MATERIAL_ID("materialId", Integer.class), MATERIAL_CODE("materialCode", String.class), MATERIAL_TYPE("materialType", MaterialType.class), @@ -18,7 +18,7 @@ public enum ResponseDataType { RECIPE("recipe", Recipe.class), RECIPES("recipes", ArrayList.class, RECIPE), - RECIPE_ID("recipeID", Integer.class), + RECIPE_ID("recipeId", Integer.class), RECIPE_CODE("recipeCode", String.class), RECIPE_MAP("recipeMap", HashMap.class), @@ -27,7 +27,7 @@ public enum ResponseDataType { MIX("mix", Mix.class), MIXES("mixes", ArrayList.class, MIX), - MIX_ID("mixID", Integer.class), + MIX_ID("mixId", Integer.class), MIX_TYPE("mixType", MixType.class), MIX_TYPES("mixTypes", ArrayList.class, MIX_TYPE), @@ -37,7 +37,7 @@ public enum ResponseDataType { COMPANY("company", Company.class), COMPANIES("companies", ArrayList.class, COMPANY), - COMPANY_ID("companyID", Integer.class), + COMPANY_ID("companyId", Integer.class), COMPANY_NAME("companyName", String.class), IMAGE("image", String.class), diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/BeanModel.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/BeanModel.java deleted file mode 100644 index a9a1690..0000000 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/BeanModel.java +++ /dev/null @@ -1,5 +0,0 @@ -package dev.fyloz.trial.colorrecipesexplorer.core.model; - -public abstract class BeanModel { - public abstract Integer getID(); -} diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Company.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Company.java index 2c138ad..5c11cc0 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Company.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Company.java @@ -8,25 +8,19 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; @Entity -@Table(name = "companies") @Data @EqualsAndHashCode(callSuper = false) @RequiredArgsConstructor @NoArgsConstructor -public class Company extends BeanModel implements Serializable { +public class Company implements IModel { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - private int companyID; + private Long id; @NonNull @NotNull @Length(min = 2, max = 50) @Column(unique = true) - private String companyName; - - @Override - public Integer getID() { - return companyID; - } + private String name; } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/IModel.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/IModel.java new file mode 100644 index 0000000..34d753b --- /dev/null +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/IModel.java @@ -0,0 +1,5 @@ +package dev.fyloz.trial.colorrecipesexplorer.core.model; + +public interface IModel { + Long getId(); +} diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Material.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Material.java index 2289522..9c490a2 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Material.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Material.java @@ -6,25 +6,23 @@ import org.hibernate.annotations.ColumnDefault; import javax.persistence.*; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; -import java.io.Serializable; @Entity -@Table(name = "materials") @Data @RequiredArgsConstructor @NoArgsConstructor @EqualsAndHashCode(callSuper = false) -public class Material extends BeanModel implements Serializable { +public class Material implements IModel { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - private Integer materialID = 0; + private Long id; @NonNull @NotNull @NotEmpty @Column(unique = true) - private String materialCode; + private String name; @NonNull @NotNull @@ -41,11 +39,6 @@ public class Material extends BeanModel implements Serializable { @ManyToOne private MaterialType materialType; - @Override - public Integer getID() { - return materialID; - } - public boolean isMixType() { return isMixType; } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MaterialType.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MaterialType.java index 8377236..0de633f 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MaterialType.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MaterialType.java @@ -5,7 +5,6 @@ import org.hibernate.annotations.ColumnDefault; import javax.persistence.*; import javax.validation.constraints.NotNull; -import java.io.Serializable; import java.util.List; @Entity @@ -13,19 +12,24 @@ import java.util.List; @EqualsAndHashCode(callSuper = false) @RequiredArgsConstructor @NoArgsConstructor -public class MaterialType extends BeanModel implements Serializable { +public class MaterialType implements IModel { - public static final String DEFAULT_MATERIAL_TYPE_NAME = "Aucun"; - public static final String BASE_MATERIAL_TYPE_NAME = "Base"; + public static final MaterialType DEFAULT_MATERIAL_TYPE; + public static final MaterialType BASE_MATERIAL_TYPE; + + static { + DEFAULT_MATERIAL_TYPE = new MaterialType("Aucun", "", false); + BASE_MATERIAL_TYPE = new MaterialType("Base", "BAS", false); + } @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - private Integer materialTypeID; + private Long id; @NonNull @NotNull @Column(unique = true) - private String materialTypeName; + private String name; @NonNull @NotNull @@ -38,11 +42,5 @@ public class MaterialType extends BeanModel implements Serializable { private Boolean usePercentages; @OneToMany - @JoinColumn(name = "material_type") private List materials; - - @Override - public Integer getID() { - return materialTypeID; - } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Mix.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Mix.java index 3194bc5..2ef2bcd 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Mix.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Mix.java @@ -4,21 +4,19 @@ import lombok.*; import javax.persistence.*; import javax.validation.constraints.NotNull; -import java.io.Serializable; import java.util.List; @Entity -@Table(name = "mixes") @Data @EqualsAndHashCode(callSuper = false) @RequiredArgsConstructor @NoArgsConstructor -public class Mix extends BeanModel implements Serializable { +public class Mix implements IModel { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) @Basic - private Integer mixID = 0; + private Long id; @NonNull @ToString.Exclude @@ -31,15 +29,9 @@ public class Mix extends BeanModel implements Serializable { @ManyToOne private MixType mixType; - @OneToMany(mappedBy = "mix", cascade = CascadeType.ALL) + @OneToMany(cascade = CascadeType.ALL) private List mixQuantities; // Casier private String location; - - @Override - public Integer getID() { - return mixID; - } - } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixQuantity.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixQuantity.java index dba6b64..6f99d9b 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixQuantity.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixQuantity.java @@ -5,20 +5,17 @@ import lombok.*; import javax.persistence.*; import javax.validation.constraints.NotNull; -import java.io.Serializable; @Entity -@Table(name = "mixQuantities") @Data @EqualsAndHashCode(callSuper = false) @RequiredArgsConstructor @NoArgsConstructor -public class MixQuantity extends BeanModel implements Serializable { +public class MixQuantity implements IModel { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - @Basic - private Integer mixQuantityID = 0; + private Long id; @NonNull @ToString.Exclude @@ -35,9 +32,4 @@ public class MixQuantity extends BeanModel implements Serializable { @NonNull @NotNull private Float quantity; - - @Override - public Integer getID() { - return mixQuantityID; - } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixType.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixType.java index 2fb9e39..a3f5e4e 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixType.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/MixType.java @@ -4,32 +4,24 @@ import lombok.*; import javax.persistence.*; import javax.validation.constraints.NotNull; -import java.io.Serializable; @Entity -@Table(name = "mixTypes") @Data @EqualsAndHashCode(callSuper = false) @RequiredArgsConstructor @NoArgsConstructor -public class MixType extends BeanModel implements Serializable { +public class MixType implements IModel { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - private int typeID; + private Long id; @NonNull @NotNull - private String typeName; + private String name; @NonNull @NotNull @OneToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "materialid") private Material material; - - @Override - public Integer getID() { - return typeID; - } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Recipe.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Recipe.java index eed7c52..7fd55d0 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Recipe.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/Recipe.java @@ -6,25 +6,23 @@ import org.hibernate.validator.constraints.Length; import javax.persistence.*; import javax.validation.constraints.NotNull; -import java.io.Serializable; import java.util.List; @Entity -@Table(name = "recipes") @Data @EqualsAndHashCode(callSuper = false) @RequiredArgsConstructor @NoArgsConstructor -public class Recipe extends BeanModel implements Serializable { +public class Recipe implements IModel { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - private Integer recipeID = 0; + private Long id; @NonNull @NotNull @Length(min = 2) - private String recipeCode; + private String name; @NonNull @NotNull @@ -33,7 +31,7 @@ public class Recipe extends BeanModel implements Serializable { @NonNull @NotNull - private String recipeDescription; + private String description; @NonNull @NotNull @@ -46,29 +44,25 @@ public class Recipe extends BeanModel implements Serializable { private String note; @JsonIgnore - @OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL) - private List recipeMixes; + @OneToMany(cascade = CascadeType.ALL) + private List mixes; - @OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL, fetch = FetchType.LAZY) + @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) private List recipeSteps; - @Override - public Integer getID() { - return recipeID; - } - + // TODO utilisé ? public Material getBase() { - if (recipeMixes.isEmpty() || recipeMixes.stream().allMatch(m -> m.getMixQuantities().isEmpty())) return null; + if (mixes.isEmpty() || mixes.stream().allMatch(m -> m.getMixQuantities().isEmpty())) return null; - Material base = recipeMixes + Material base = mixes .stream() .map(mix -> mix .getMixQuantities() .stream() - .filter(mq -> mq.getMaterial().getMaterialType().getMaterialTypeName().equals(MaterialType.BASE_MATERIAL_TYPE_NAME)) + .filter(mq -> mq.getMaterial().getMaterialType().getName().equals(MaterialType.BASE_MATERIAL_TYPE.getName())) .findFirst().get() ) - .findFirst().orElse(recipeMixes + .findFirst().orElse(mixes .stream() .filter(m -> !m.getMixQuantities().isEmpty()) .findFirst() diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/RecipeStep.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/RecipeStep.java index 4aa6ea4..2a5167e 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/RecipeStep.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/model/RecipeStep.java @@ -8,16 +8,15 @@ import javax.validation.constraints.NotNull; import java.io.Serializable; @Entity -@Table(name = "steps") @Data @EqualsAndHashCode(callSuper = false) @RequiredArgsConstructor @NoArgsConstructor -public class RecipeStep extends BeanModel implements Serializable { +public class RecipeStep implements IModel { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) - private int stepID; + private Long id; @NonNull @ToString.Exclude @@ -27,10 +26,5 @@ public class RecipeStep extends BeanModel implements Serializable { @NonNull @NotNull - private String stepMessage; - - @Override - public Integer getID() { - return stepID; - } + private String message; } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/GenericService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/GenericService.java index 2acc38a..4c3ed5f 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/GenericService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/GenericService.java @@ -3,7 +3,7 @@ package dev.fyloz.trial.colorrecipesexplorer.core.services; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication; -import dev.fyloz.trial.colorrecipesexplorer.core.model.BeanModel; +import dev.fyloz.trial.colorrecipesexplorer.core.model.IModel; import org.slf4j.Logger; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.lang.NonNull; @@ -11,7 +11,7 @@ import org.springframework.lang.NonNull; import java.util.List; import java.util.Optional; -public abstract class GenericService> implements IGenericService { +public abstract class GenericService> implements IGenericService { protected Logger logger = ColorRecipesExplorerApplication.LOGGER; @@ -22,7 +22,7 @@ public abstract class GenericService getByID(int id) { + public Optional getById(Long id) { return dao.findById(id); } @@ -116,11 +116,11 @@ public abstract class GenericService { +public interface IGenericService { /** * Récupère toutes les entités du même type dans la base de données. @@ -21,7 +21,7 @@ public interface IGenericService { * @param id L'identifiant de l'entité * @return L'entité correspondant à l'identifiant. */ - Optional getByID(int id); + Optional getById(Long id); /** * Sauvegarde une entité dans la base de données. @@ -77,5 +77,5 @@ public interface IGenericService { boolean exists(T entity); - boolean existsById(int id); + boolean existsById(Long id); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/InventoryService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/InventoryService.java index 6f4b3c5..b2adbb8 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/InventoryService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/InventoryService.java @@ -24,7 +24,7 @@ public class InventoryService { Float quantity = quantities.get(material); if (quantity > material.getInventoryQuantity()) { - return String.format("%s-%s", mix.getMixID(), material.getMaterialID()); + return String.format("%s-%s", mix.getId(), material.getId()); } } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/CompanyService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/CompanyService.java index bed4aa5..1a963ff 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/CompanyService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/CompanyService.java @@ -20,11 +20,11 @@ public class CompanyService extends GenericService { @Override public boolean isValidForCreation(Company entity) { - return super.isValidForCreation(entity) && !existsByName(entity.getCompanyName()); + return super.isValidForCreation(entity) && !existsByName(entity.getName()); } public boolean existsByName(String name) { - return dao.existsByCompanyName(name); + return dao.existsByName(name); } public boolean isLinkedToRecipes(Company company) { diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialService.java index 1085485..95575b3 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialService.java @@ -28,8 +28,8 @@ public class MaterialService extends GenericService { this.mixQuantityService = mixQuantityService; } - public Optional getByMaterialCode(String materialCode) { - return dao.findByMaterialCode(materialCode); + public Optional getByName(String name) { + return dao.findByName(name); } public List getAllByMaterialType(MaterialType materialType) { @@ -40,7 +40,7 @@ public class MaterialService extends GenericService { public List getAllOrdered() { return getAll().stream() - .sorted(Comparator.comparing(Material::getMaterialCode)) + .sorted(Comparator.comparing(Material::getName)) .collect(Collectors.toList()); } @@ -64,19 +64,19 @@ public class MaterialService extends GenericService { @Override public boolean exists(Material material) { - return material != null && (super.exists(material) || dao.existsByMaterialCode(material.getMaterialCode())); + return material != null && (super.exists(material) || dao.existsByName(material.getName())); } @Override public boolean isValidForUpdate(Material material) { if (material == null) return false; - Optional materialByCode = dao.findByMaterialCode(material.getMaterialCode()); - return super.isValidForUpdate(material) && (!materialByCode.isPresent() || material.getMaterialID().equals(materialByCode.get().getMaterialID())); + Optional materialByCode = dao.findByName(material.getName()); + return super.isValidForUpdate(material) && (!materialByCode.isPresent() || material.getId().equals(materialByCode.get().getId())); } public List getAllBySearchString(String searchString) { - return dao.findAllByMaterialCodeContainingIgnoreCase(searchString).stream().filter(m -> !m.isMixType()).collect(Collectors.toList()); + return dao.findAllByNameContainingIgnoreCase(searchString).stream().filter(m -> !m.isMixType()).collect(Collectors.toList()); } /** @@ -86,7 +86,7 @@ public class MaterialService extends GenericService { * @return Le FileHandler correspondant au produit. */ private FileHandler getFileHandlerForMaterial(Material material) { - String filename = String.format("%s_%s", material.getMaterialID(), material.getMaterialCode()); + String filename = String.format("%s_%s", material.getId(), material.getName()); return new FileHandler(filename, FileHandler.FileContext.SIMDUT, FileHandler.FileExtension.PDF); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialTypeService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialTypeService.java index 99aa914..fc01217 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialTypeService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MaterialTypeService.java @@ -33,7 +33,7 @@ public class MaterialTypeService extends GenericService materialTypeByName = dao.findByMaterialTypeName(materialType.getMaterialTypeName()); + Optional materialTypeByName = dao.findByName(materialType.getName()); - return !materialTypeByName.isPresent() || materialType.getMaterialTypeID().equals(materialTypeByName.get().getMaterialTypeID()); + return !materialTypeByName.isPresent() || materialType.getId().equals(materialTypeByName.get().getId()); } public boolean isValidForUpdatePrefix(MaterialType materialType) { Optional materialTypeByPrefix = dao.findByPrefix(materialType.getPrefix()); - return !materialTypeByPrefix.isPresent() || materialType.getMaterialTypeID().equals(materialTypeByPrefix.get().getMaterialTypeID()); + return !materialTypeByPrefix.isPresent() || materialType.getId().equals(materialTypeByPrefix.get().getId()); } public Optional getByName(String name) { - return dao.findByMaterialTypeName(name); + return dao.findByName(name); } + // TODO Utilisé ? public Optional getDefaultMaterialType() { - return getByName(MaterialType.DEFAULT_MATERIAL_TYPE_NAME); + return getByName(MaterialType.DEFAULT_MATERIAL_TYPE.getName()); } public boolean existsByName(String name) { diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixService.java index 09e05f6..40ff4e1 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixService.java @@ -38,7 +38,7 @@ public class MixService extends GenericService { List materials = new ArrayList<>(); for (String materialCode : formDto.getMaterials()) { - Optional found = materialService.getByMaterialCode(materialCode); + Optional found = materialService.getByName(materialCode); if (!found.isPresent()) { return modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_NOT_FOUND_BY_NAME, materialCode); } @@ -51,7 +51,7 @@ public class MixService extends GenericService { MixType mixType = optionalMixType.get(); if (recipeService.hasMixType(recipe, mixType)) - return modelResponseBuilder.addResponseCode(ResponseCode.MIX_TYPE_ALREADY_USED, mixType.getTypeName()); + return modelResponseBuilder.addResponseCode(ResponseCode.MIX_TYPE_ALREADY_USED, mixType.getName()); // Crée le mélange en premier pour avoir accès à son ID pour les autres éléments Mix mix = new Mix(recipe, mixType); @@ -79,7 +79,7 @@ public class MixService extends GenericService { List materials = new ArrayList<>(); for (String materialCode : formDto.getMaterials()) { - Optional found = materialService.getByMaterialCode(materialCode); + Optional found = materialService.getByName(materialCode); if (!found.isPresent()) { return modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_NOT_FOUND_BY_NAME, materialCode); } @@ -88,8 +88,8 @@ public class MixService extends GenericService { } mix.getMixType().getMaterial().setMaterialType(formDto.getMaterialType()); - mix.getMixType().setTypeName(formDto.getMixTypeName()); - material.setMaterialCode(formDto.getMixTypeName()); + mix.getMixType().setName(formDto.getMixTypeName()); + material.setName(formDto.getMixTypeName()); List mixQuantities = createMixQuantities(mix, materials, formDto.getQuantities()); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixTypeService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixTypeService.java index 751018a..2b42ba9 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixTypeService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/MixTypeService.java @@ -22,7 +22,7 @@ public class MixTypeService extends GenericService { } public Optional getByName(String name) { - return dao.findByTypeName(name); + return dao.findByName(name); } public Optional getByMaterial(Material material) { diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/RecipeService.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/RecipeService.java index 37aaa80..75ef8f7 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/RecipeService.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/core/services/model/RecipeService.java @@ -44,8 +44,8 @@ public class RecipeService extends GenericService { * @return Une liste triée des mélanges. */ public List getSortedMixes(Recipe recipe) { - List mixes = recipe.getRecipeMixes(); - mixes.sort(Comparator.comparing(Mix::getMixID)); + List mixes = recipe.getMixes(); + mixes.sort(Comparator.comparing(Mix::getId)); return mixes; } @@ -59,9 +59,9 @@ public class RecipeService extends GenericService { } public Optional updateRecipe(Recipe newRecipe, Recipe storedRecipe, MultiValueMap form) { - storedRecipe.setRecipeCode(newRecipe.getRecipeCode()); + storedRecipe.setName(newRecipe.getName()); storedRecipe.setCompany(newRecipe.getCompany()); - storedRecipe.setRecipeDescription(newRecipe.getRecipeDescription()); + storedRecipe.setDescription(newRecipe.getDescription()); storedRecipe.setSample(newRecipe.getSample()); storedRecipe.setApprobationDate(newRecipe.getApprobationDate()); storedRecipe.setRemark(newRecipe.getRemark()); @@ -88,9 +88,9 @@ public class RecipeService extends GenericService { * @return Une liste contenant le nom des images liées à la recette. */ public List getImageFiles(Recipe recipe) { - int recipeID = recipe.getRecipeID(); - String recipeCode = recipe.getRecipeCode(); - String fileName = String.format("%s_%s", recipeID, recipeCode); + Long recipeId = recipe.getId(); + String name = recipe.getName(); + String fileName = String.format("%s_%s", recipeId, name); File imageLocation = new File(ImageHandler.IMAGES_LOCATION); File[] result = imageLocation.listFiles((d, n) -> n.startsWith(fileName) && n.endsWith("jpeg")); @@ -108,7 +108,7 @@ public class RecipeService extends GenericService { */ public List getAssociatedMixesTypes(Recipe recipe) { return recipe - .getRecipeMixes() + .getMixes() .stream() .map(Mix::getMixType) .collect(Collectors.toList()); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/CompanyDao.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/CompanyDao.java index 2785ed3..c1e2e85 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/CompanyDao.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/CompanyDao.java @@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @Repository -public interface CompanyDao extends JpaRepository { +public interface CompanyDao extends JpaRepository { - boolean existsByCompanyName(String companyName); + boolean existsByName(String name); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MaterialDao.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MaterialDao.java index 8014e54..7d440a3 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MaterialDao.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MaterialDao.java @@ -9,12 +9,12 @@ import java.util.List; import java.util.Optional; @Repository -public interface MaterialDao extends JpaRepository { - Optional findByMaterialCode(String materialCode); +public interface MaterialDao extends JpaRepository { + Optional findByName(String name); List findAllByMaterialType(MaterialType materialType); - List findAllByMaterialCodeContainingIgnoreCase(String stringSearch); + List findAllByNameContainingIgnoreCase(String stringSearch); - boolean existsByMaterialCode(String materialCode); + boolean existsByName(String name); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MaterialTypeDao.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MaterialTypeDao.java index 96ba4dc..4902a20 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MaterialTypeDao.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MaterialTypeDao.java @@ -5,9 +5,9 @@ import org.springframework.data.jpa.repository.JpaRepository; import java.util.Optional; -public interface MaterialTypeDao extends JpaRepository { +public interface MaterialTypeDao extends JpaRepository { - Optional findByMaterialTypeName(String name); + Optional findByName(String name); Optional findByPrefix(String prefix); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixDao.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixDao.java index 46a2b3c..1e82afa 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixDao.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixDao.java @@ -8,9 +8,8 @@ import org.springframework.stereotype.Repository; import java.util.List; @Repository -public interface MixDao extends JpaRepository { - - Mix findByMixID(int mixID); +public interface MixDao extends JpaRepository { List findAllByRecipe(Recipe recipe); + } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixQuantityDao.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixQuantityDao.java index 1a41d6a..4bcaf07 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixQuantityDao.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixQuantityDao.java @@ -8,7 +8,7 @@ import org.springframework.stereotype.Repository; import java.util.List; @Repository -public interface MixQuantityDao extends JpaRepository { +public interface MixQuantityDao extends JpaRepository { List findAllByMaterial(Material material); boolean existsByMaterial(Material material); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixTypeDao.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixTypeDao.java index 5ae466d..c4422ed 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixTypeDao.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/MixTypeDao.java @@ -8,8 +8,8 @@ import org.springframework.stereotype.Repository; import java.util.Optional; @Repository -public interface MixTypeDao extends JpaRepository { - Optional findByTypeName(String typeName); +public interface MixTypeDao extends JpaRepository { + Optional findByName(String name); Optional findByMaterial(Material material); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/RecipeDao.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/RecipeDao.java index 7ed35d4..88ea1e0 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/RecipeDao.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/RecipeDao.java @@ -9,14 +9,12 @@ import org.springframework.stereotype.Repository; import java.util.List; @Repository -public interface RecipeDao extends JpaRepository { +public interface RecipeDao extends JpaRepository { List findAllByCompany(Company company); - Recipe findByRecipeCode(String recipeCode); + Recipe findByName(String name); - Recipe findByRecipeID(int recipeID); - - @Query("select r from Recipe r where upper(r.recipeCode) like %?1% or upper(r.recipeDescription) like %?1%") + @Query("select r from Recipe r where upper(r.name) like %?1% or upper(r.description) like %?1%") List findAllByRecipeDescriptionContainsOrRecipeCodeContains(String searchWordUpperCase); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/StepDao.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/StepDao.java index 5b998a7..0f32f01 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/StepDao.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/dao/StepDao.java @@ -6,9 +6,7 @@ import org.springframework.data.jpa.repository.JpaRepository; import java.util.List; -public interface StepDao extends JpaRepository { - - RecipeStep findByStepID(int stepID); +public interface StepDao extends JpaRepository { List findAllByRecipe(Recipe recipe); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/PagesPaths.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/PagesPaths.java index 6000b93..0802621 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/PagesPaths.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/PagesPaths.java @@ -5,10 +5,10 @@ public class PagesPaths { public static final String INDEX = "index"; public static final String SEARCH = "search"; public static final String SEARCH_INVENTORY = "inventory/search"; - public static final String SIMDUT_FILES = "simdut/{materialID}"; + public static final String SIMDUT_FILES = "simdut/{id}"; public static final String PASSWORD_VALIDATION = "password/valid"; public static final String TOUCHUP = "touchup"; - public static final String RECIPE_XLS = "recipe/xls/{recipeID}"; + public static final String RECIPE_XLS = "recipe/xls/{id}"; public static final String ALL_RECIPES_XLS = "recipe/xls"; public static final String ERROR = "error"; public static final String CLOSE_TAB = "closeTab"; @@ -18,7 +18,7 @@ public class PagesPaths { // Images public static final String IMAGES_FILES = "images/{image}"; public static final String ADD_IMAGE = "images/add"; - public static final String ADD_IMAGE_SPECIFIC = "images/add/{recipeID}"; + public static final String ADD_IMAGE_SPECIFIC = "images/add/{id}"; public static final String DELETE_IMAGE = "images/delete"; // Inventaire @@ -27,46 +27,46 @@ public class PagesPaths { // Recettes public static final String EXPLORER_RECIPE = "recipe/explore"; - public static final String EXPLORER_RECIPE_SPECIFIC = "recipe/explore/{recipeID}"; + public static final String EXPLORER_RECIPE_SPECIFIC = "recipe/explore/{id}"; public static final String CREATOR_RECIPE = "recipe/creator"; public static final String CREATOR_RECIPE_SUCCESS = "recipe/created"; public static final String EDITOR_RECIPE = "recipe/editor"; - public static final String EDITOR_RECIPE_SPECIFIC = "recipe/editor/{recipeID}"; + public static final String EDITOR_RECIPE_SPECIFIC = "recipe/editor/{id}"; public static final String EDITOR_RECIPE_EDITOR = "recipe/edit"; public static final String REMOVER_RECIPE = "recipe/remover"; - public static final String REMOVER_RECIPE_SPECIFIC = "recipe/remover/{recipeID}"; + public static final String REMOVER_RECIPE_SPECIFIC = "recipe/remover/{id}"; // Compagnies public static final String CREATOR_COMPANY = "company/creator"; public static final String CREATOR_COMPANY_SUCCESS = "company/created"; public static final String REMOVER_COMPANY = "company/remover"; - public static final String REMOVER_COMPANY_SPECIFIC = "company/remover/{companyID}"; + public static final String REMOVER_COMPANY_SPECIFIC = "company/remover/{id}"; // Matériaux public static final String CREATOR_MATERIAL = "material/creator"; public static final String EDIT_MATERIAL_SIMDUT = "material/simdut"; - public static final String EDIT_MATERIAL_SIMDUT_SPECIFIC = "material/simdut/{materialID}"; + public static final String EDIT_MATERIAL_SIMDUT_SPECIFIC = "material/simdut/{id}"; public static final String CREATOR_MATERIAL_SUCCESS = "material/created"; public static final String REMOVER_MATERIAL = "material/remover"; - public static final String REMOVER_MATERIAL_SPECIFIC = "material/remover/{materialID}"; + public static final String REMOVER_MATERIAL_SPECIFIC = "material/remover/{id}"; public static final String EDITOR_MATERIAL = "material/editor"; - public static final String EDITOR_MATERIAL_SPECIFIC = "material/editor/{materialID}"; + public static final String EDITOR_MATERIAL_SPECIFIC = "material/editor/{id}"; public static final String EDITOR_MATERIAL_EDITOR = "material/edit"; // Types de matériaux public static final String CREATOR_MATERIAL_TYPE = "materialType/creator"; public static final String REMOVER_MATERIAL_TYPE = "materialType/remover"; - public static final String REMOVER_MATERIAL_TYPE_SPECIFIC = "materialType/remover/{materialTypeID}"; + public static final String REMOVER_MATERIAL_TYPE_SPECIFIC = "materialType/remover/{id}"; public static final String EDITOR_MATERIAL_TYPE = "materialType/editor"; - public static final String EDITOR_MATERIAL_TYPE_SPECIFIC = "materialType/editor/{materialTypeID}"; + public static final String EDITOR_MATERIAL_TYPE_SPECIFIC = "materialType/editor/{id}"; public static final String EDITOR_MATERIAL_TYPE_EDITOR = "materialType/edit"; - // Mélanges + // Mélanges( public static final String CREATOR_MIX = "mix/creator"; - public static final String CREATOR_MIX_SPECIFIC = "mix/creator/{recipeID}"; + public static final String CREATOR_MIX_SPECIFIC = "mix/creator/{id}"; public static final String EDITOR_MIX = "mix/editor"; - public static final String EDITOR_MIX_SPECIFIC = "mix/editor/{mixID}"; - public static final String REMOVER_MIX_SPECIFIC = "mix/remover/{mixID}"; - public static final String MATERIAL_SELECTOR_MIX = "mix/selector/{recipeID}/{mixID}"; + public static final String EDITOR_MIX_SPECIFIC = "mix/editor/{id}"; + public static final String REMOVER_MIX_SPECIFIC = "mix/remover/{id}"; + public static final String MATERIAL_SELECTOR_MIX = "mix/selector/{recipeId}/{mixId}"; public static final String MATERIAL_SELECTOR_FRAGMENT = "mix/selector.html :: materialSelector"; } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/StringBank.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/StringBank.java index 46c4486..19f9f43 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/StringBank.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/StringBank.java @@ -16,7 +16,7 @@ public class StringBank { public static final String MATERIAL_TYPE = "materialType"; public static final String RECIPES = "recipes"; public static final String RECIPE = "recipe"; - public static final String RECIPE_ID = "recipeID"; + public static final String RECIPE_ID = "recipeId"; public static final String RECIPE_CODE = "recipeCode"; public static final String MIXES = "mixes"; public static final String MIX = "mix"; diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/ImageFilesController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/ImageFilesController.java index 9cef050..ab93d29 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/ImageFilesController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/ImageFilesController.java @@ -60,17 +60,17 @@ public class ImageFilesController { * Cette méthode requiert l'identifiant de la recette dans l'URL. *

* Modèle de la page: - * - recipeID: Contient l'identifiant de la recette + * - id: Contient l'identifiant de la recette * * @param model Le Model injecté par Thymeleaf - * @param recipeID L'identifiant de la recette + * @param id L'identifiant de la recette * @return La page à afficher. */ @GetMapping(ADD_IMAGE_SPECIFIC) - public ModelAndView showPage(ModelAndView model, @PathVariable int recipeID) { + public ModelAndView showPage(ModelAndView model, @PathVariable Long id) { return new ModelResponseBuilder(model) .withView(ADD_IMAGE) - .addResponseData(ResponseDataType.RECIPE_ID, recipeID) + .addResponseData(ResponseDataType.RECIPE_ID, id) .build(); } @@ -86,30 +86,30 @@ public class ImageFilesController { * Modèle de la page: * - error: Contient le message d'erreur, s'il y a lieu * - recipeCode: Contient la couleur de la recette - * - recipeID: Contient l'identifiant de la recette + * - id: Contient l'identifiant de la recette *

* REQUIERT UNE AUTORISATION * - * @param recipeID L'identifiant de la recette + * @param id L'identifiant de la recette * @param image L'image uploadée * @return La page à afficher. */ @PostMapping(ADD_IMAGE) - public ModelAndView addImage(int recipeID, MultipartFile image) throws IOException { - ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(ControllerUtils.redirect(EDITOR_RECIPE_SPECIFIC.replace("{recipeID}", String.valueOf(recipeID)))); + public ModelAndView addImage(Long id, MultipartFile image) throws IOException { + ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(ControllerUtils.redirect(EDITOR_RECIPE_SPECIFIC.replace("{id}", String.valueOf(id)))); // Vérifie que le fichier est bien une image if (ImageIO.read(image.getInputStream()) == null) { return showPage(modelResponseBuilder .addResponseCode(ResponseCode.FILE_NOT_IMAGE) - .build(), recipeID); + .build(), id); } - Optional optionalRecipe = recipeService.getByID(recipeID); + Optional optionalRecipe = recipeService.getById(id); if (!optionalRecipe.isPresent()) { return showPage(modelResponseBuilder - .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeID) - .build(), recipeID); + .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, id) + .build(), id); } Recipe recipe = optionalRecipe.get(); @@ -117,12 +117,12 @@ public class ImageFilesController { if (!imageHandler.createFile()) { return showPage(modelResponseBuilder .addResponseCode(ResponseCode.ERROR_SAVING_IMAGE) - .build(), recipeID); + .build(), id); } modelResponseBuilder - .addResponseData(ResponseDataType.RECIPE_CODE, recipe.getRecipeCode()) - .addResponseData(ResponseDataType.RECIPE_ID, recipe.getRecipeID()); + .addResponseData(ResponseDataType.RECIPE_CODE, recipe.getName()) + .addResponseData(ResponseDataType.RECIPE_ID, recipe.getId()); try { // Si je n'utilise pas le path, il cherche un fichier dans les tmp ? @@ -133,7 +133,7 @@ public class ImageFilesController { ColorRecipesExplorerApplication.LOGGER.error("Erreur inconnue lors de la création d'une image", e); modelResponseBuilder.addResponseCode(ResponseCode.ERROR_SAVING_IMAGE); - return showPage(modelResponseBuilder.build(), recipeID); + return showPage(modelResponseBuilder.build(), id); } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/IndexController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/IndexController.java index cc51792..d125ad2 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/IndexController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/IndexController.java @@ -56,10 +56,10 @@ public class IndexController { @ResponseBody public Map searchWord(@RequestParam String searchString) { Map> searchResult = recipeService.getRecipesForSearchString(searchString); - Map> outputResult = new HashMap<>(); + Map> outputResult = new HashMap<>(); for (Company c : searchResult.keySet()) { - outputResult.put(c.getCompanyID(), searchResult.get(c).stream().map(Recipe::getRecipeID).collect(Collectors.toList())); + outputResult.put(c.getId(), searchResult.get(c).stream().map(Recipe::getId).collect(Collectors.toList())); } return new JSONResponseBuilder() diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/InventoryController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/InventoryController.java index 154be15..9839e77 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/InventoryController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/InventoryController.java @@ -84,9 +84,9 @@ public class InventoryController { Map> quantities = new HashMap<>(); for (String mixIDStr : form.keySet()) { - int mixID = Integer.parseInt(mixIDStr); + Long mixID = Long.parseLong(mixIDStr); - Optional optionalMix = mixService.getByID(mixID); + Optional optionalMix = mixService.getById(mixID); if (!optionalMix.isPresent()) { return responseBuilder .addResponseCode(ResponseCode.MIX_NOT_FOUND, mixID) @@ -100,7 +100,7 @@ public class InventoryController { Map mixQuantities = new HashMap<>(); for (Material material : mix.getMixQuantities().stream().map(MixQuantity::getMaterial).collect(Collectors.toList())) { - String materialIDAsString = String.valueOf(material.getMaterialID()); + String materialIDAsString = String.valueOf(material.getId()); if (formMaterials.containsKey(materialIDAsString)) { mixQuantities.put(material, Float.parseFloat(formMaterials.get(materialIDAsString))); @@ -113,7 +113,7 @@ public class InventoryController { for (Mix mix : mixes) { String errorCode = inventoryService.checkQuantities(mix, quantities.get(mix)); if (errorCode != null) { - String materialCode = materialService.getByID(Integer.parseInt(errorCode.split("-")[1])).orElse(new Material()).getMaterialCode(); + String materialCode = materialService.getById(Long.parseLong(errorCode.split("-")[1])).orElse(new Material()).getName(); return responseBuilder .addResponseCode(ResponseCode.NOT_ENOUGH_MATERIAL, materialCode) @@ -139,7 +139,7 @@ public class InventoryController { @ResponseBody public Map searchWordInventory(@RequestParam String searchString) { List searchResult = materialService.getAllBySearchString(searchString); - List outputResult = searchResult.stream().map(Material::getMaterialID).collect(Collectors.toList()); + List outputResult = searchResult.stream().map(Material::getId).collect(Collectors.toList()); return new JSONResponseBuilder() .addAttribute("result", outputResult) diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/OthersController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/OthersController.java index e675c88..5f922c5 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/OthersController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/OthersController.java @@ -65,17 +65,17 @@ public class OthersController { } @GetMapping(MATERIAL_SELECTOR_MIX) - public ModelAndView getMaterialSelectorFragment(@PathVariable int recipeID, @PathVariable int mixID) { + public ModelAndView getMaterialSelectorFragment(@PathVariable Long recipeId, @PathVariable Long mixId) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(MATERIAL_SELECTOR_FRAGMENT); - Optional optionalRecipe = recipeService.getByID(recipeID); + Optional optionalRecipe = recipeService.getById(recipeId); if (!optionalRecipe.isPresent()) { return modelResponseBuilder .withView("") .build(); } - Optional optionalMix = mixService.getByID(mixID); + Optional optionalMix = mixService.getById(mixId); boolean mixExist = optionalMix.isPresent(); List associatedMixTypes = recipeService.getAssociatedMixesTypes(optionalRecipe.get()); @@ -84,8 +84,8 @@ public class OthersController { .getAll() .stream() .filter(m -> !m.isMixType() || (!mixExist || !m.equals(optionalMix.get().getMixType().getMaterial())) && associatedMixTypes.contains(mixTypeService.getByMaterial(m).get())) - .sorted(Comparator.comparing(Material::getMaterialCode)) - .sorted(Comparator.comparing(m -> m.getMaterialType().getMaterialTypeName())) + .sorted(Comparator.comparing(Material::getName)) + .sorted(Comparator.comparing(m -> m.getMaterialType().getName())) .collect(Collectors.toList()); return modelResponseBuilder @@ -99,10 +99,10 @@ public class OthersController { } @GetMapping(RECIPE_XLS) - public ResponseEntity getXlsForRecipe(HttpServletRequest request, @PathVariable int recipeID) { + public ResponseEntity getXlsForRecipe(HttpServletRequest request, @PathVariable Long id) { HttpHeaders headers = new HttpHeaders(); - Optional optionalRecipe = recipeService.getByID(recipeID); + Optional optionalRecipe = recipeService.getById(id); if (!optionalRecipe.isPresent()) { headers.add(HttpHeaders.LOCATION, request.getHeader("referer")); return new ResponseEntity<>(headers, HttpStatus.FOUND); @@ -132,7 +132,7 @@ public class OthersController { byte[] recipeXLS = new XlsxExporter().generate(recipe); if (recipeXLS.length <= 0) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); - out.putNextEntry(new ZipEntry(String.format("%s_%s.xlsx", recipe.getCompany().getCompanyName(), recipe.getRecipeCode()))); + out.putNextEntry(new ZipEntry(String.format("%s_%s.xlsx", recipe.getCompany().getName(), recipe.getName()))); out.write(recipeXLS, 0, recipeXLS.length); out.closeEntry(); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/RecipeExplorerController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/RecipeExplorerController.java index 5902c18..d221644 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/RecipeExplorerController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/RecipeExplorerController.java @@ -40,24 +40,24 @@ public class RecipeExplorerController { * - mixes: Contient les mélanges associées à la recette * - images: Contient la liste des noms des images associées à la recette * - * @param recipeID L'identifiant de la recette + * @param id L'identifiant de la recette * @return La page à afficher. */ @GetMapping(EXPLORER_RECIPE_SPECIFIC) - public ModelAndView showRecipe(@PathVariable int recipeID) { + public ModelAndView showRecipe(@PathVariable Long id) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(EXPLORER_RECIPE); - Optional optionalRecipe = recipeService.getByID(recipeID); + Optional optionalRecipe = recipeService.getById(id); if (!optionalRecipe.isPresent()) { return modelResponseBuilder .withView(INDEX) - .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeID) + .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, id) .build(); } Recipe recipe = optionalRecipe.get(); - List mixes = new ArrayList<>(recipe.getRecipeMixes()); // Convertit le PersistentBag en ArrayList - mixes.sort(Comparator.comparing(Mix::getMixID)); + List mixes = new ArrayList<>(recipe.getMixes()); // Convertit le PersistentBag en ArrayList + mixes.sort(Comparator.comparing(Mix::getId)); return modelResponseBuilder .addResponseData(ResponseDataType.RECIPE, recipe) @@ -73,13 +73,13 @@ public class RecipeExplorerController { JSONResponseBuilder responseBuilder = new JSONResponseBuilder(); - int recipeID = Integer.parseInt(form.get("recipeID").toString()); + long recipeId = Long.parseLong(form.get("recipeId").toString()); Map location = (Map) form.get("locations"); String note = form.get("note").toString(); - Optional optionalRecipe = recipeService.getByID(recipeID); + Optional optionalRecipe = recipeService.getById(recipeId); if (!optionalRecipe.isPresent()) { - responseBuilder.addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeID); + responseBuilder.addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeId); } else { Recipe recipe = optionalRecipe.get(); @@ -87,19 +87,19 @@ public class RecipeExplorerController { recipeService.save(recipe); } - for (String mixIDStr : location.keySet()) { - int mixID = Integer.parseInt(mixIDStr); + for (String mixIdStr : location.keySet()) { + long mixId = Long.parseLong(mixIdStr); - Optional optionalMix = mixService.getByID(mixID); + Optional optionalMix = mixService.getById(mixId); if (!optionalMix.isPresent()) { - responseBuilder.addResponseCode(ResponseCode.MIX_NOT_FOUND, mixID); + responseBuilder.addResponseCode(ResponseCode.MIX_NOT_FOUND, mixId); } else { Mix mix = optionalMix.get(); - if (mix.getRecipe().getRecipeID() != recipeID) { - responseBuilder.addResponseCode(ResponseCode.MIX_NOT_ASSOCIATED_WITH_RECIPE, mixID, recipeID); + if (mix.getRecipe().getId() != recipeId) { + responseBuilder.addResponseCode(ResponseCode.MIX_NOT_ASSOCIATED_WITH_RECIPE, mixId, recipeId); } else { - mix.setLocation(location.get(mixIDStr)); + mix.setLocation(location.get(mixIdStr)); mixService.update(mix); } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/SIMDUTFilesController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/SIMDUTFilesController.java index 0c2f046..f026eda 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/SIMDUTFilesController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/SIMDUTFilesController.java @@ -30,8 +30,8 @@ public class SIMDUTFilesController { } @GetMapping(SIMDUT_FILES) - public ResponseEntity getFile(HttpServletRequest request, @PathVariable int materialID) { - Optional optionalMaterial = materialService.getByID(materialID); + public ResponseEntity getFile(HttpServletRequest request, @PathVariable Long id) { + Optional optionalMaterial = materialService.getById(id); HttpHeaders headers = new HttpHeaders(); if (!optionalMaterial.isPresent()) { @@ -39,7 +39,7 @@ public class SIMDUTFilesController { return new ResponseEntity<>(headers, HttpStatus.FOUND); } - FileHandler fileHandler = new FileHandler(String.format("%s_%s", materialID, optionalMaterial.get().getMaterialCode()), FileHandler.FileContext.SIMDUT, FileHandler.FileExtension.PDF); + FileHandler fileHandler = new FileHandler(String.format("%s_%s", id, optionalMaterial.get().getName()), FileHandler.FileContext.SIMDUT, FileHandler.FileExtension.PDF); if (!fileHandler.isValid()) { headers.add("Location", "/" + CLOSE_TAB); return new ResponseEntity<>(headers, HttpStatus.FOUND); @@ -51,11 +51,11 @@ public class SIMDUTFilesController { } @PostMapping(SIMDUT_FILES) - public ResponseEntity getFile(@PathVariable int materialID) { - Optional optionalMaterial = materialService.getByID(materialID); + public ResponseEntity getFile(@PathVariable Long id) { + Optional optionalMaterial = materialService.getById(id); if (!optionalMaterial.isPresent()) return ResponseEntity.status(HttpStatus.BAD_REQUEST).build(); - FileHandler fileHandler = new FileHandler(String.format("%s_%s", materialID, optionalMaterial.get().getMaterialCode()), FileHandler.FileContext.SIMDUT, FileHandler.FileExtension.PDF); + FileHandler fileHandler = new FileHandler(String.format("%s_%s", id, optionalMaterial.get().getName()), FileHandler.FileContext.SIMDUT, FileHandler.FileExtension.PDF); if (!fileHandler.isValid()) return ResponseEntity.status(HttpStatus.NOT_FOUND).build(); return ResponseEntity.status(HttpStatus.FOUND).build(); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/CompanyCreatorController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/CompanyCreatorController.java index 15a29ca..75108f6 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/CompanyCreatorController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/CompanyCreatorController.java @@ -47,7 +47,7 @@ public class CompanyCreatorController { *

* Modèle de la page: * - error: Contient le message d'erreur, s'il y a lieu - * - companyName: Contient le nom de la bannière + * - name: Contient le nom de la bannière *

* REQUIERT UNE AUTORISATION * @@ -63,13 +63,13 @@ public class CompanyCreatorController { if (savedCompany.isPresent()) { return modelResponseBuilder - .addResponseData(ResponseDataType.COMPANY_NAME, savedCompany.get().getCompanyName()) + .addResponseData(ResponseDataType.COMPANY_NAME, savedCompany.get().getName()) .build(); } else { modelResponseBuilder.addResponseCode(ResponseCode.ERROR_SAVING); } } else { - modelResponseBuilder.addResponseCode(ResponseCode.COMPANY_ALREADY_EXIST, company.getCompanyName()); + modelResponseBuilder.addResponseCode(ResponseCode.COMPANY_ALREADY_EXIST, company.getName()); } return showCreationPage(modelResponseBuilder.build(), company); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialCreatorController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialCreatorController.java index 556ed6d..d201e65 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialCreatorController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialCreatorController.java @@ -68,20 +68,20 @@ public class MaterialCreatorController { if (savedMaterial.isPresent()) { material = savedMaterial.get(); - modelResponseBuilder.addResponseData(ResponseDataType.MATERIAL_CODE, material.getMaterialCode()); + modelResponseBuilder.addResponseData(ResponseDataType.MATERIAL_CODE, material.getName()); if (simdut.getSize() > 0 && !materialService.addSimdut(simdut, material)) { modelResponseBuilder.addResponseCode(ResponseCode.ERROR_SAVING_SIMDUT); } return showCreationPage(modelResponseBuilder - .addResponseData(ResponseDataType.MATERIAL_CODE, material.getMaterialCode()) + .addResponseData(ResponseDataType.MATERIAL_CODE, material.getName()) .build(), null); } else { modelResponseBuilder.addResponseCode(ResponseCode.ERROR_SAVING); } } else { - modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_ALREADY_EXIST, material.getMaterialCode()); + modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_ALREADY_EXIST, material.getName()); } return showCreationPage(modelResponseBuilder.build(), material); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialTypeCreatorController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialTypeCreatorController.java index 3ffa255..e678aa2 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialTypeCreatorController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MaterialTypeCreatorController.java @@ -46,7 +46,7 @@ public class MaterialTypeCreatorController { modelResponseBuilder.addResponseCode(ResponseCode.ERROR_SAVING); } } else { - modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_ALREADY_EXIST, materialType.getMaterialTypeName()); + modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_ALREADY_EXIST, materialType.getName()); } return showPage(modelResponseBuilder.build(), materialType); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MixCreatorController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MixCreatorController.java index b62498a..f31925f 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MixCreatorController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/creators/MixCreatorController.java @@ -49,15 +49,15 @@ public class MixCreatorController { * Cette méthode requiert l'identifiant d'une recette dans l'URL. * * @param model Le Model injecté par Thymeleaf - * @param recipeID L'identifiant de la recette + * @param id L'identifiant de la recette * @return La page à afficher. */ @GetMapping(CREATOR_MIX_SPECIFIC) - public ModelAndView showCreationPage(ModelAndView model, @PathVariable int recipeID) { + public ModelAndView showCreationPage(ModelAndView model, @PathVariable Long id) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(model) .withView(CREATOR_MIX); - Optional optionalRecipe = recipeService.getByID(recipeID); + Optional optionalRecipe = recipeService.getById(id); if (!optionalRecipe.isPresent()) { return modelResponseBuilder .withView(ControllerUtils.redirect(EDITOR_RECIPE)) @@ -72,8 +72,8 @@ public class MixCreatorController { .getAll() .stream() .filter(m -> !m.isMixType() || associatedMixTypes.contains(mixTypeService.getByMaterial(m).get())) - .sorted(Comparator.comparing(Material::getMaterialCode)) - .sorted(Comparator.comparing(m -> m.getMaterialType().getMaterialTypeName())) + .sorted(Comparator.comparing(Material::getName)) + .sorted(Comparator.comparing(m -> m.getMaterialType().getName())) .collect(Collectors.toList()); ModelResponseBuilder responseBuilder = modelResponseBuilder @@ -119,10 +119,10 @@ public class MixCreatorController { ModelResponseBuilder mixCreationResponse = mixService.create(formDto, recipe); if (mixCreationResponse != null) - return showCreationPage(mixCreationResponse.build(), formDto.getRecipe().getRecipeID()); + return showCreationPage(mixCreationResponse.build(), formDto.getRecipe().getId()); return modelResponseBuilder - .withRedirect(EDITOR_RECIPE_SPECIFIC, recipe.getRecipeID()) + .withRedirect(EDITOR_RECIPE_SPECIFIC, recipe.getId()) .build(); } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MaterialEditorController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MaterialEditorController.java index 17ca51f..2a88c07 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MaterialEditorController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MaterialEditorController.java @@ -51,17 +51,17 @@ public class MaterialEditorController { } @GetMapping(EDITOR_MATERIAL_SPECIFIC) - public ModelAndView showEditPage(ModelAndView model, @PathVariable int materialID, Material material) { + public ModelAndView showEditPage(ModelAndView model, @PathVariable Long id, Material material) { ModelResponseBuilder responseBuilder = new ModelResponseBuilder(model) .withView(EDITOR_MATERIAL_EDITOR); - if (material.getMaterialCode() == null) { - Optional optionalMaterial = materialService.getByID(materialID); + if (material.getName() == null) { + Optional optionalMaterial = materialService.getById(id); if (!optionalMaterial.isPresent()) { return listMaterials( responseBuilder - .addResponseCode(ResponseCode.MATERIAL_NOT_FOUND, materialID) + .addResponseCode(ResponseCode.MATERIAL_NOT_FOUND, id) .build() ); } @@ -95,28 +95,28 @@ public class MaterialEditorController { @PostMapping(value = EDITOR_MATERIAL, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public ModelAndView saveEditedMaterial(Material material) { ModelResponseBuilder responseBuilder = new ModelResponseBuilder(""); - int materialID = material.getMaterialID(); + Long id = material.getId(); - if (!materialService.existsById(materialID)) { - responseBuilder.addResponseCode(ResponseCode.MATERIAL_NOT_FOUND, materialID); + if (!materialService.existsById(id)) { + responseBuilder.addResponseCode(ResponseCode.MATERIAL_NOT_FOUND, id); } else if (!materialService.isValidForUpdate(material)) { - responseBuilder.addResponseCode(ResponseCode.MATERIAL_ALREADY_EXIST, material.getMaterialCode()); + responseBuilder.addResponseCode(ResponseCode.MATERIAL_ALREADY_EXIST, material.getName()); return showEditPage( responseBuilder - .addResponseCode(ResponseCode.MATERIAL_ALREADY_EXIST, material.getMaterialCode()) + .addResponseCode(ResponseCode.MATERIAL_ALREADY_EXIST, material.getName()) .build(), - materialID, material); + id, material); } else { Optional updatedMaterial = materialService.update(material); if (updatedMaterial.isPresent()) { - responseBuilder.addResponseData(ResponseDataType.MATERIAL_CODE, updatedMaterial.get().getMaterialCode()); + responseBuilder.addResponseData(ResponseDataType.MATERIAL_CODE, updatedMaterial.get().getName()); } else { return showEditPage( responseBuilder .addResponseCode(ResponseCode.ERROR_SAVING) .build(), - materialID, null); + id, null); } } @@ -128,17 +128,17 @@ public class MaterialEditorController { * Cette méthode requiert l'identifiant du produit dans l'URL *

* Modèle de la page: - * - materialID: Contient l'identifiant du produit + * - id: Contient l'identifiant du produit * * @param model Le Model injecté par Thymeleaf - * @param materialID L'identifiant du produit à modifier le SIMDUT + * @param id L'identifiant du produit à modifier le SIMDUT * @return La page à afficher. */ @GetMapping(value = EDIT_MATERIAL_SIMDUT_SPECIFIC) - public ModelAndView chooseSIMDUTFile(ModelAndView model, @PathVariable int materialID) { + public ModelAndView chooseSIMDUTFile(ModelAndView model, @PathVariable Long id) { return new ModelResponseBuilder(model) .withView(EDIT_MATERIAL_SIMDUT) - .addResponseData(ResponseDataType.MATERIAL_ID, materialID) + .addResponseData(ResponseDataType.MATERIAL_ID, id) .build(); } @@ -150,27 +150,27 @@ public class MaterialEditorController { *

* REQUIERT UNE AUTORISATION * - * @param materialID L'identifiant du produit + * @param id L'identifiant du produit * @param simdut Le fichier SIMDUT uploadé * @return La page à afficher. */ @PostMapping(value = EDIT_MATERIAL_SIMDUT, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ModelAndView saveSIMDUT(int materialID, MultipartFile simdut) { - ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(ControllerUtils.redirect("material/editor/" + materialID)); + public ModelAndView saveSIMDUT(Long id, MultipartFile simdut) { + ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(ControllerUtils.redirect("material/editor/" + id)); - Optional optionalMaterial = materialService.getByID(materialID); + Optional optionalMaterial = materialService.getById(id); if (!optionalMaterial.isPresent()) { return chooseSIMDUTFile(modelResponseBuilder - .addResponseCode(ResponseCode.MATERIAL_NOT_FOUND, materialID) + .addResponseCode(ResponseCode.MATERIAL_NOT_FOUND, id) .build(), - materialID); + id); } Material material = optionalMaterial.get(); if (!materialService.removeSimdut(material) || !materialService.addSimdut(simdut, material)) { modelResponseBuilder.addResponseCode(ResponseCode.ERROR_SAVING_SIMDUT); - return chooseSIMDUTFile(modelResponseBuilder.build(), materialID); + return chooseSIMDUTFile(modelResponseBuilder.build(), id); } return modelResponseBuilder.build(); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MaterialTypeEditorController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MaterialTypeEditorController.java index 60e572d..cfac48e 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MaterialTypeEditorController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MaterialTypeEditorController.java @@ -36,17 +36,17 @@ public class MaterialTypeEditorController { } @GetMapping(EDITOR_MATERIAL_TYPE_SPECIFIC) - public ModelAndView showEditPage(ModelAndView model, @PathVariable int materialTypeID, MaterialType materialType) { + public ModelAndView showEditPage(ModelAndView model, @PathVariable Long id, MaterialType materialType) { ModelResponseBuilder responseBuilder = new ModelResponseBuilder(model) .withView(EDITOR_MATERIAL_TYPE_EDITOR); - if (materialType.getMaterialTypeName() == null) { - Optional optionalMaterialType = materialTypeService.getByID(materialTypeID); + if (materialType.getName() == null) { + Optional optionalMaterialType = materialTypeService.getById(id); if (!optionalMaterialType.isPresent()) { return listMaterialTypes( responseBuilder - .addResponseCode(ResponseCode.MATERIAL_TYPE_NOT_FOUND, materialTypeID) + .addResponseCode(ResponseCode.MATERIAL_TYPE_NOT_FOUND, id) .build() ); } @@ -62,32 +62,32 @@ public class MaterialTypeEditorController { @PostMapping(value = EDITOR_MATERIAL_TYPE, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public ModelAndView saveEditedMaterialType(MaterialType materialType) { ModelResponseBuilder responseBuilder = new ModelResponseBuilder(""); - int materialTypeID = materialType.getMaterialTypeID(); + long id = materialType.getId(); - if (!materialTypeService.getByID(materialTypeID).isPresent()) { - responseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_NOT_FOUND, materialTypeID); + if (!materialTypeService.getById(id).isPresent()) { + responseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_NOT_FOUND, id); } else if (!materialTypeService.isValidForUpdateName(materialType)) { return showEditPage( responseBuilder - .addResponseCode(ResponseCode.MATERIAL_TYPE_ALREADY_EXIST, materialType.getMaterialTypeName()) + .addResponseCode(ResponseCode.MATERIAL_TYPE_ALREADY_EXIST, materialType.getName()) .build(), - materialTypeID, materialType); + id, materialType); } else if (!materialTypeService.isValidForUpdatePrefix(materialType)) { return showEditPage( responseBuilder .addResponseCode(ResponseCode.MATERIAL_TYPE_ALREADY_EXIST_PREFIX, materialType.getPrefix()) .build(), - materialTypeID, materialType); + id, materialType); } else { Optional updatedMaterialType = materialTypeService.update(materialType); if (updatedMaterialType.isPresent()) { - responseBuilder.addResponseData(ResponseDataType.MATERIAL_TYPE_NAME, updatedMaterialType.get().getMaterialTypeName()); + responseBuilder.addResponseData(ResponseDataType.MATERIAL_TYPE_NAME, updatedMaterialType.get().getName()); } else { return showEditPage( responseBuilder .addResponseCode(ResponseCode.ERROR_SAVING) .build(), - materialTypeID, null); + id, null); } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MixEditorController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MixEditorController.java index ce347a2..b669584 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MixEditorController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/MixEditorController.java @@ -50,15 +50,15 @@ public class MixEditorController { * Cette méthode requiert l'identifiant du mélange à modifier dans l'URL. * * @param model Le Model injecté par Thymeleaf - * @param mixID L'identifiant du mélange à modifier + * @param id L'identifiant du mélange à modifier * @return La page à afficher. */ @GetMapping(EDITOR_MIX_SPECIFIC) - public ModelAndView showPage(ModelAndView model, @PathVariable int mixID) { + public ModelAndView showPage(ModelAndView model, @PathVariable Long id) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(model) .withView(EDITOR_MIX_SPECIFIC.replaceAll("/\\{" + MIX_ID + "}", "")); - Optional optionalMix = mixService.getByID(mixID); + Optional optionalMix = mixService.getById(id); if (!optionalMix.isPresent()) { return modelResponseBuilder .withView(ControllerUtils.redirect(EDITOR_RECIPE)) @@ -72,8 +72,8 @@ public class MixEditorController { .getAll() .stream() .filter(m -> !m.isMixType() || (!m.equals(mix.getMixType().getMaterial()) && associatedMixTypes.contains(mixTypeService.getByMaterial(m).get()))) - .sorted(Comparator.comparing(Material::getMaterialCode)) - .sorted(Comparator.comparing(m -> m.getMaterialType().getMaterialTypeName())) + .sorted(Comparator.comparing(Material::getName)) + .sorted(Comparator.comparing(m -> m.getMaterialType().getName())) .collect(Collectors.toList()); return modelResponseBuilder @@ -104,18 +104,18 @@ public class MixEditorController { * @return La page à afficher. */ @PostMapping(value = EDITOR_MIX, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) - public ModelAndView saveMix(@ModelAttribute @Valid MixCreationFormDto formDto, int mixID) { + public ModelAndView saveMix(@ModelAttribute @Valid MixCreationFormDto formDto, Long id) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(); - Optional optionalMix = mixService.getByID(mixID); + Optional optionalMix = mixService.getById(id); if (!optionalMix.isPresent()) { - modelResponseBuilder.addResponseCode(ResponseCode.MIX_NOT_FOUND, mixID); + modelResponseBuilder.addResponseCode(ResponseCode.MIX_NOT_FOUND, id); - return showPage(modelResponseBuilder.build(), mixID); + return showPage(modelResponseBuilder.build(), id); } Mix mix = optionalMix.get(); - modelResponseBuilder.withRedirect(EDITOR_RECIPE_SPECIFIC, mix.getRecipe().getRecipeID()); + modelResponseBuilder.withRedirect(EDITOR_RECIPE_SPECIFIC, mix.getRecipe().getId()); ModelResponseBuilder editResult = mixService.edit(mix, formDto); if (editResult != null) { @@ -123,31 +123,31 @@ public class MixEditorController { modelResponseBuilder .addResponseCode(ResponseCode.ERROR_SAVING) .build(), - mixID); + id); } return modelResponseBuilder.build(); } @GetMapping(REMOVER_MIX_SPECIFIC) - public ModelAndView deleteMix(@PathVariable int mixID) { + public ModelAndView deleteMix(@PathVariable Long id) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(""); - Optional optionalMix = mixService.getByID(mixID); + Optional optionalMix = mixService.getById(id); if (!optionalMix.isPresent()) { return showPage(modelResponseBuilder - .addResponseCode(ResponseCode.MIX_NOT_FOUND, mixID) + .addResponseCode(ResponseCode.MIX_NOT_FOUND, id) .build(), - mixID); + id); } Mix mix = optionalMix.get(); - modelResponseBuilder.withView(ControllerUtils.redirect(EDITOR_RECIPE_SPECIFIC.replace("{recipeID}", String.valueOf(mix.getRecipe().getRecipeID())))); + modelResponseBuilder.withView(ControllerUtils.redirect(EDITOR_RECIPE_SPECIFIC.replace("{recipeID}", String.valueOf(mix.getRecipe().getId())))); if (!mixService.deleteMix(mix)) { modelResponseBuilder.addResponseCode(ResponseCode.ERROR_SAVING); - return showPage(modelResponseBuilder.build(), mixID); + return showPage(modelResponseBuilder.build(), id); } return modelResponseBuilder.build(); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/RecipeEditorController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/RecipeEditorController.java index d26afc9..f9d39a7 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/RecipeEditorController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/editors/RecipeEditorController.java @@ -52,17 +52,17 @@ public class RecipeEditorController { } @GetMapping(EDITOR_RECIPE_SPECIFIC) - public ModelAndView showEditPage(ModelAndView model, @PathVariable int recipeID, Recipe recipe) { + public ModelAndView showEditPage(ModelAndView model, @PathVariable Long id, Recipe recipe) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(model) .withView(EDITOR_RECIPE_EDITOR); - if (recipe.getRecipeCode() == null || recipe.getCompany() == null) { - Optional optionalRecipe = recipeService.getByID(recipeID); + if (recipe.getName() == null || recipe.getCompany() == null) { + Optional optionalRecipe = recipeService.getById(id); if (!optionalRecipe.isPresent()) { return listRecipes( modelResponseBuilder - .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeID) + .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, id) .build() ); } @@ -101,19 +101,19 @@ public class RecipeEditorController { @Transactional public ModelAndView saveRecipe(Recipe recipe, @RequestBody MultiValueMap form) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(""); - int recipeID = recipe.getRecipeID(); + Long recipeId = recipe.getId(); - Optional optionalStoredRecipe = recipeService.getByID(recipeID); + Optional optionalStoredRecipe = recipeService.getById(recipeId); if (!optionalStoredRecipe.isPresent()) { return listRecipes( modelResponseBuilder - .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeID) + .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeId) .build()); } Optional optionalRecipe = recipeService.updateRecipe(recipe, optionalStoredRecipe.get(), form); if (optionalRecipe.isPresent()) { - modelResponseBuilder.addResponseData(ResponseDataType.RECIPE_CODE, optionalRecipe.get().getRecipeCode()); + modelResponseBuilder.addResponseData(ResponseDataType.RECIPE_CODE, optionalRecipe.get().getName()); return listRecipes(modelResponseBuilder.build()); } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/CompanyRemoverController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/CompanyRemoverController.java index 09bef80..88935eb 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/CompanyRemoverController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/CompanyRemoverController.java @@ -59,23 +59,23 @@ public class CompanyRemoverController { *

* REQUIERT UNE AUTORISATION * - * @param companyID L'identifiant de la bannière + * @param id L'identifiant de la bannière * @return La page à afficher */ @PostMapping(REMOVER_COMPANY_SPECIFIC) - public ModelAndView removeCompany(@PathVariable int companyID) { + public ModelAndView removeCompany(@PathVariable Long id) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(""); - Optional optionalCompany = companyService.getByID(companyID); + Optional optionalCompany = companyService.getById(id); if (optionalCompany.isPresent()) { Company company = optionalCompany.get(); if (companyService.deleteIfNotLinked(company)) - modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_COMPANY, company.getCompanyName()); - else modelResponseBuilder.addResponseCode(ResponseCode.COMPANY_LINKED, company.getCompanyName()); + modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_DELETING_COMPANY, company.getName()); + else modelResponseBuilder.addResponseCode(ResponseCode.COMPANY_LINKED, company.getName()); } else { - modelResponseBuilder.addResponseCode(ResponseCode.COMPANY_NOT_FOUND, companyID); + modelResponseBuilder.addResponseCode(ResponseCode.COMPANY_NOT_FOUND, id); } return showPage(modelResponseBuilder.build()); diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/MaterialRemoverController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/MaterialRemoverController.java index 8e8f581..530b964 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/MaterialRemoverController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/MaterialRemoverController.java @@ -57,27 +57,27 @@ public class MaterialRemoverController { *

* REQUIERT UNE AUTORISATION * - * @param materialID L'identifiant du produit à supprimer + * @param id L'identifiant du produit à supprimer * @return La page à afficher. */ @PostMapping(REMOVER_MATERIAL_SPECIFIC) - public ModelAndView removeMaterial(@PathVariable int materialID) { + public ModelAndView removeMaterial(@PathVariable Long id) { ModelResponseBuilder responseBuilder = new ModelResponseBuilder(""); - Optional optionalMaterial = materialService.getByID(materialID); + Optional optionalMaterial = materialService.getById(id); if (!optionalMaterial.isPresent()) { - responseBuilder.addResponseCode(ResponseCode.MATERIAL_NOT_FOUND, materialID); + responseBuilder.addResponseCode(ResponseCode.MATERIAL_NOT_FOUND, id); } else { Material material = optionalMaterial.get(); if (materialService.deleteIfNotLinked(material)) { - responseBuilder.addResponseData(ResponseDataType.MATERIAL_CODE, material.getMaterialCode()); + responseBuilder.addResponseData(ResponseDataType.MATERIAL_CODE, material.getName()); if (!materialService.removeSimdut(material)) { responseBuilder.addResponseCode(ResponseCode.ERROR_SAVING_SIMDUT); } } else { - responseBuilder.addResponseCode(ResponseCode.MATERIAL_LINKED, material.getMaterialCode()); + responseBuilder.addResponseCode(ResponseCode.MATERIAL_LINKED, material.getName()); } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/MaterialTypeRemoverController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/MaterialTypeRemoverController.java index facf9eb..534a716 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/MaterialTypeRemoverController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/MaterialTypeRemoverController.java @@ -37,19 +37,19 @@ public class MaterialTypeRemoverController { } @PostMapping(REMOVER_MATERIAL_TYPE_SPECIFIC) - public ModelAndView removeMaterialType(@PathVariable int materialTypeID) { + public ModelAndView removeMaterialType(@PathVariable Long id) { ModelResponseBuilder responseBuilder = new ModelResponseBuilder(""); - Optional optionalMaterialType = materialTypeService.getByID(materialTypeID); + Optional optionalMaterialType = materialTypeService.getById(id); if (!optionalMaterialType.isPresent()) { - responseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_NOT_FOUND, materialTypeID); + responseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_NOT_FOUND, id); } else { MaterialType materialType = optionalMaterialType.get(); if (materialTypeService.deleteIfNotLinked(materialType)) { - responseBuilder.addResponseData(ResponseDataType.MATERIAL_TYPE_NAME, materialType.getMaterialTypeName()); + responseBuilder.addResponseData(ResponseDataType.MATERIAL_TYPE_NAME, materialType.getName()); } else { - responseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_LINKED, materialType.getMaterialTypeName()); + responseBuilder.addResponseCode(ResponseCode.MATERIAL_TYPE_LINKED, materialType.getName()); } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/RecipeRemoverController.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/RecipeRemoverController.java index 2bbc64c..0722154 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/RecipeRemoverController.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/web/controller/removers/RecipeRemoverController.java @@ -54,18 +54,18 @@ public class RecipeRemoverController { *

* REQUIERT UNE AUTORISATION * - * @param recipeID L'identifiant de la recette + * @param id L'identifiant de la recette * @return La page à afficher. */ @PostMapping(REMOVER_RECIPE_SPECIFIC) - public ModelAndView removeRecipe(@PathVariable int recipeID) { + public ModelAndView removeRecipe(@PathVariable Long id) { ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder(""); - Optional optionalRecipe = recipeService.getByID(recipeID); + Optional optionalRecipe = recipeService.getById(id); if (!optionalRecipe.isPresent()) { return listRecipes( modelResponseBuilder - .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeID) + .addResponseCode(ResponseCode.RECIPE_NOT_FOUND, id) .build()); } @@ -77,7 +77,7 @@ public class RecipeRemoverController { .build()); } - modelResponseBuilder.addResponseData(ResponseDataType.RECIPE_CODE, recipe.getRecipeCode()); + modelResponseBuilder.addResponseData(ResponseDataType.RECIPE_CODE, recipe.getName()); return listRecipes(modelResponseBuilder.build()); } } diff --git a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/xlsx/XlsxExporter.java b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/xlsx/XlsxExporter.java index 3743cd0..71cbe20 100644 --- a/src/main/java/dev/fyloz/trial/colorrecipesexplorer/xlsx/XlsxExporter.java +++ b/src/main/java/dev/fyloz/trial/colorrecipesexplorer/xlsx/XlsxExporter.java @@ -22,9 +22,9 @@ import java.util.Collection; public class XlsxExporter { public byte[] generate(Recipe recipe) { - ColorRecipesExplorerApplication.LOGGER.info(String.format("Génération du XLS de la couleur %s (%s)", recipe.getRecipeCode(), recipe.getRecipeID())); + ColorRecipesExplorerApplication.LOGGER.info(String.format("Génération du XLS de la couleur %s (%s)", recipe.getName(), recipe.getId())); - Document document = new Document(recipe.getRecipeCode()); + Document document = new Document(recipe.getName()); Sheet sheet = document.getSheet(); registerCells(recipe, sheet); @@ -44,11 +44,11 @@ public class XlsxExporter { private void registerCells(Recipe recipe, Sheet sheet) { // Header - sheet.registerCell(new TitleCell(recipe.getRecipeCode())); + sheet.registerCell(new TitleCell(recipe.getName())); sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.NAME, "Bannière")); - sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.VALUE_STR, recipe.getCompany().getCompanyName())); + sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.VALUE_STR, recipe.getCompany().getName())); sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.NAME, "Description")); - sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.VALUE_STR, recipe.getRecipeDescription())); + sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.VALUE_STR, recipe.getDescription())); sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.NAME, "Échantillon")); sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.VALUE_NUM, recipe.getSample())); sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.NAME, "Date d'approbation")); @@ -57,18 +57,18 @@ public class XlsxExporter { sheet.registerCell(new DescriptionCell(DescriptionCell.DescriptionCellType.VALUE_STR, recipe.getRemark())); // Mélanges - Collection recipeMixes = recipe.getRecipeMixes(); + Collection recipeMixes = recipe.getMixes(); if (recipeMixes.size() > 0) { sheet.registerCell(new SectionTitleCell("Recette")); for (Mix mix : recipeMixes) { - Table mixTable = new Table(4, mix.getMixQuantities().size() + 1, mix.getMixType().getTypeName()); + Table mixTable = new Table(4, mix.getMixQuantities().size() + 1, mix.getMixType().getName()); mixTable.setColumnName(0, "Quantité"); mixTable.setColumnName(2, "Unités"); int row = 0; for (MixQuantity mixQuantity : mix.getMixQuantities()) { - mixTable.setRowName(row, mixQuantity.getMaterial().getMaterialCode()); + mixTable.setRowName(row, mixQuantity.getMaterial().getName()); mixTable.setContent(new Position(1, row + 1), mixQuantity.getQuantity()); mixTable.setContent(new Position(3, row + 1), mixQuantity.getMaterial().getMaterialType().getUsePercentages() ? "%" : "mL"); @@ -85,7 +85,7 @@ public class XlsxExporter { sheet.registerCell(new SectionTitleCell("Étapes")); Catalog stepsCatalog = new Catalog(); - for (RecipeStep step : recipe.getRecipeSteps()) stepsCatalog.addContent(step.getStepMessage()); + for (RecipeStep step : recipe.getRecipeSteps()) stepsCatalog.addContent(step.getMessage()); sheet.registerAllCells(stepsCatalog.getCells()); } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 05c2ad6..cf04904 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -15,6 +15,7 @@ spring: jpa: hibernate: ddl-auto: update + show-sql: true h2: console: enabled: true diff --git a/src/main/resources/templates/company/creator.html b/src/main/resources/templates/company/creator.html index 0c0a50f..20da887 100644 --- a/src/main/resources/templates/company/creator.html +++ b/src/main/resources/templates/company/creator.html @@ -19,13 +19,13 @@

-
diff --git a/src/main/resources/templates/company/remover.html b/src/main/resources/templates/company/remover.html index ef05ef3..259fec0 100644 --- a/src/main/resources/templates/company/remover.html +++ b/src/main/resources/templates/company/remover.html @@ -24,8 +24,8 @@
-

+

@@ -38,10 +38,10 @@ - + - diff --git a/src/main/resources/templates/images/add.html b/src/main/resources/templates/images/add.html index 2819e2b..2528a0a 100644 --- a/src/main/resources/templates/images/add.html +++ b/src/main/resources/templates/images/add.html @@ -12,7 +12,7 @@
- +
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 40958e0..485ce9d 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -19,11 +19,11 @@
-

+ th:data-companyId="${company.id}"> +

- @@ -32,12 +32,12 @@ - - + th:data-approbationDate="${recipe.approbationDate}" th:data-recipeId="${recipe.id}"> + + @@ -55,9 +55,9 @@ (() => { document.querySelectorAll(".gotoRecipe").forEach(e => { e.addEventListener("click", () => { - const recipeID = e.getAttribute("data-recipeID"); + const recipeId = e.getAttribute("data-recipeId"); - document.location.href = "/recipe/explore/" + recipeID; + document.location.href = "/recipe/explore/" + recipeId; }); }); })(); diff --git a/src/main/resources/templates/inventory.html b/src/main/resources/templates/inventory.html index 07ca00a..388a555 100644 --- a/src/main/resources/templates/inventory.html +++ b/src/main/resources/templates/inventory.html @@ -61,8 +61,8 @@
- + th:if="${materialType.name.equalsIgnoreCase('aucun')}"> +

@@ -92,16 +92,16 @@
- + th:data-materialType="${material.materialType.id}" + th:data-materialId="${material.materialId}"> + - + @@ -123,8 +123,8 @@ diff --git a/src/main/resources/templates/material/created.html b/src/main/resources/templates/material/created.html index 03ab0d0..9dc2b84 100644 --- a/src/main/resources/templates/material/created.html +++ b/src/main/resources/templates/material/created.html @@ -11,7 +11,7 @@
-

+

diff --git a/src/main/resources/templates/material/creator.html b/src/main/resources/templates/material/creator.html index e759a45..71717e5 100644 --- a/src/main/resources/templates/material/creator.html +++ b/src/main/resources/templates/material/creator.html @@ -9,7 +9,7 @@
-

+

@@ -20,7 +20,7 @@
- +
@@ -36,7 +36,7 @@
@@ -66,8 +66,8 @@
diff --git a/src/main/resources/templates/material/edit.html b/src/main/resources/templates/material/edit.html index ae04b3b..ff62571 100644 --- a/src/main/resources/templates/material/edit.html +++ b/src/main/resources/templates/material/edit.html @@ -2,7 +2,7 @@ + th:include="fragments.html :: head(#{material.editing.title(${material.name})}, 'form')"> @@ -14,19 +14,19 @@
-

+

- +
- +
- +
@@ -37,10 +37,10 @@
- +
- +
@@ -83,14 +83,14 @@