Début du refactoring

This commit is contained in:
FyloZ 2020-02-16 14:24:23 -05:00
parent 4f7336e982
commit d1223e2c15
84 changed files with 572 additions and 628 deletions

View File

@ -25,18 +25,16 @@ public class InitialDataLoader implements ApplicationListener<ApplicationReadyEv
@Override
public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) {
if (!materialTypeService.getByName(MaterialType.DEFAULT_MATERIAL_TYPE_NAME).isPresent())
createInitialMaterialType(MaterialType.DEFAULT_MATERIAL_TYPE_NAME);
if (!materialTypeService.getByName(MaterialType.BASE_MATERIAL_TYPE_NAME).isPresent())
createInitialMaterialType(MaterialType.BASE_MATERIAL_TYPE_NAME);
if (!materialTypeService.getByName(MaterialType.DEFAULT_MATERIAL_TYPE.getName()).isPresent())
createInitialMaterialType(MaterialType.DEFAULT_MATERIAL_TYPE);
if (!materialTypeService.getByName(MaterialType.BASE_MATERIAL_TYPE.getName()).isPresent())
createInitialMaterialType(MaterialType.BASE_MATERIAL_TYPE);
}
private void createInitialMaterialType(String name) {
MaterialType defaultMaterialType = new MaterialType(name, "", false);
Optional<MaterialType> optionalSavedMaterialType = materialTypeService.save(defaultMaterialType);
private void createInitialMaterialType(MaterialType materialType) {
Optional<MaterialType> 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()));
}
}
}

View File

@ -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;

View File

@ -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),

View File

@ -1,5 +0,0 @@
package dev.fyloz.trial.colorrecipesexplorer.core.model;
public abstract class BeanModel {
public abstract Integer getID();
}

View File

@ -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;
}

View File

@ -0,0 +1,5 @@
package dev.fyloz.trial.colorrecipesexplorer.core.model;
public interface IModel {
Long getId();
}

View File

@ -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;
}

View File

@ -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<Material> materials;
@Override
public Integer getID() {
return materialTypeID;
}
}

View File

@ -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<MixQuantity> mixQuantities;
// Casier
private String location;
@Override
public Integer getID() {
return mixID;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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<Mix> recipeMixes;
@OneToMany(cascade = CascadeType.ALL)
private List<Mix> mixes;
@OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<RecipeStep> 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()

View File

@ -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;
}

View File

@ -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<T extends BeanModel, R extends JpaRepository<T, Integer>> implements IGenericService<T> {
public abstract class GenericService<T extends IModel, R extends JpaRepository<T, Long>> implements IGenericService<T> {
protected Logger logger = ColorRecipesExplorerApplication.LOGGER;
@ -22,7 +22,7 @@ public abstract class GenericService<T extends BeanModel, R extends JpaRepositor
}
@Override
public Optional<T> getByID(int id) {
public Optional<T> getById(Long id) {
return dao.findById(id);
}
@ -116,11 +116,11 @@ public abstract class GenericService<T extends BeanModel, R extends JpaRepositor
*/
@Override
public boolean exists(T entity) {
return entity != null && existsById(entity.getID());
return entity != null && existsById(entity.getId());
}
@Override
public boolean existsById(int id) {
public boolean existsById(Long id) {
return dao.existsById(id);
}

View File

@ -1,12 +1,12 @@
package dev.fyloz.trial.colorrecipesexplorer.core.services;
import dev.fyloz.trial.colorrecipesexplorer.core.model.BeanModel;
import dev.fyloz.trial.colorrecipesexplorer.core.model.IModel;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
public interface IGenericService<T extends BeanModel> {
public interface IGenericService<T extends IModel> {
/**
* Récupère toutes les entités du même type dans la base de données.
@ -21,7 +21,7 @@ public interface IGenericService<T extends BeanModel> {
* @param id L'identifiant de l'entité
* @return L'entité correspondant à l'identifiant.
*/
Optional<T> getByID(int id);
Optional<T> getById(Long id);
/**
* Sauvegarde une entité dans la base de données.
@ -77,5 +77,5 @@ public interface IGenericService<T extends BeanModel> {
boolean exists(T entity);
boolean existsById(int id);
boolean existsById(Long id);
}

View File

@ -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());
}
}
}

View File

@ -20,11 +20,11 @@ public class CompanyService extends GenericService<Company, CompanyDao> {
@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) {

View File

@ -28,8 +28,8 @@ public class MaterialService extends GenericService<Material, MaterialDao> {
this.mixQuantityService = mixQuantityService;
}
public Optional<Material> getByMaterialCode(String materialCode) {
return dao.findByMaterialCode(materialCode);
public Optional<Material> getByName(String name) {
return dao.findByName(name);
}
public List<Material> getAllByMaterialType(MaterialType materialType) {
@ -40,7 +40,7 @@ public class MaterialService extends GenericService<Material, MaterialDao> {
public List<Material> 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<Material, MaterialDao> {
@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<Material> materialByCode = dao.findByMaterialCode(material.getMaterialCode());
return super.isValidForUpdate(material) && (!materialByCode.isPresent() || material.getMaterialID().equals(materialByCode.get().getMaterialID()));
Optional<Material> materialByCode = dao.findByName(material.getName());
return super.isValidForUpdate(material) && (!materialByCode.isPresent() || material.getId().equals(materialByCode.get().getId()));
}
public List<Material> 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<Material, MaterialDao> {
* @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);
}

View File

@ -33,7 +33,7 @@ public class MaterialTypeService extends GenericService<MaterialType, MaterialTy
@Override
public boolean isValidForCreation(MaterialType entity) {
return entity != null && !existsByName(entity.getMaterialTypeName());
return entity != null && !existsByName(entity.getName());
}
@Override
@ -44,23 +44,24 @@ public class MaterialTypeService extends GenericService<MaterialType, MaterialTy
}
public boolean isValidForUpdateName(MaterialType materialType) {
Optional<MaterialType> materialTypeByName = dao.findByMaterialTypeName(materialType.getMaterialTypeName());
Optional<MaterialType> 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<MaterialType> 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<MaterialType> getByName(String name) {
return dao.findByMaterialTypeName(name);
return dao.findByName(name);
}
// TODO Utilisé ?
public Optional<MaterialType> getDefaultMaterialType() {
return getByName(MaterialType.DEFAULT_MATERIAL_TYPE_NAME);
return getByName(MaterialType.DEFAULT_MATERIAL_TYPE.getName());
}
public boolean existsByName(String name) {

View File

@ -38,7 +38,7 @@ public class MixService extends GenericService<Mix, MixDao> {
List<Material> materials = new ArrayList<>();
for (String materialCode : formDto.getMaterials()) {
Optional<Material> found = materialService.getByMaterialCode(materialCode);
Optional<Material> 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<Mix, MixDao> {
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<Mix, MixDao> {
List<Material> materials = new ArrayList<>();
for (String materialCode : formDto.getMaterials()) {
Optional<Material> found = materialService.getByMaterialCode(materialCode);
Optional<Material> 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, MixDao> {
}
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<MixQuantity> mixQuantities = createMixQuantities(mix, materials, formDto.getQuantities());

View File

@ -22,7 +22,7 @@ public class MixTypeService extends GenericService<MixType, MixTypeDao> {
}
public Optional<MixType> getByName(String name) {
return dao.findByTypeName(name);
return dao.findByName(name);
}
public Optional<MixType> getByMaterial(Material material) {

View File

@ -44,8 +44,8 @@ public class RecipeService extends GenericService<Recipe, RecipeDao> {
* @return Une liste triée des mélanges.
*/
public List<Mix> getSortedMixes(Recipe recipe) {
List<Mix> mixes = recipe.getRecipeMixes();
mixes.sort(Comparator.comparing(Mix::getMixID));
List<Mix> mixes = recipe.getMixes();
mixes.sort(Comparator.comparing(Mix::getId));
return mixes;
}
@ -59,9 +59,9 @@ public class RecipeService extends GenericService<Recipe, RecipeDao> {
}
public Optional<Recipe> updateRecipe(Recipe newRecipe, Recipe storedRecipe, MultiValueMap<String, Object> 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<Recipe, RecipeDao> {
* @return Une liste contenant le nom des images liées à la recette.
*/
public List<String> 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<Recipe, RecipeDao> {
*/
public List<MixType> getAssociatedMixesTypes(Recipe recipe) {
return recipe
.getRecipeMixes()
.getMixes()
.stream()
.map(Mix::getMixType)
.collect(Collectors.toList());

View File

@ -5,7 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface CompanyDao extends JpaRepository<Company, Integer> {
public interface CompanyDao extends JpaRepository<Company, Long> {
boolean existsByCompanyName(String companyName);
boolean existsByName(String name);
}

View File

@ -9,12 +9,12 @@ import java.util.List;
import java.util.Optional;
@Repository
public interface MaterialDao extends JpaRepository<Material, Integer> {
Optional<Material> findByMaterialCode(String materialCode);
public interface MaterialDao extends JpaRepository<Material, Long> {
Optional<Material> findByName(String name);
List<Material> findAllByMaterialType(MaterialType materialType);
List<Material> findAllByMaterialCodeContainingIgnoreCase(String stringSearch);
List<Material> findAllByNameContainingIgnoreCase(String stringSearch);
boolean existsByMaterialCode(String materialCode);
boolean existsByName(String name);
}

View File

@ -5,9 +5,9 @@ import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface MaterialTypeDao extends JpaRepository<MaterialType, Integer> {
public interface MaterialTypeDao extends JpaRepository<MaterialType, Long> {
Optional<MaterialType> findByMaterialTypeName(String name);
Optional<MaterialType> findByName(String name);
Optional<MaterialType> findByPrefix(String prefix);

View File

@ -8,9 +8,8 @@ import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MixDao extends JpaRepository<Mix, Integer> {
Mix findByMixID(int mixID);
public interface MixDao extends JpaRepository<Mix, Long> {
List<Mix> findAllByRecipe(Recipe recipe);
}

View File

@ -8,7 +8,7 @@ import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MixQuantityDao extends JpaRepository<MixQuantity, Integer> {
public interface MixQuantityDao extends JpaRepository<MixQuantity, Long> {
List<MixQuantity> findAllByMaterial(Material material);
boolean existsByMaterial(Material material);

View File

@ -8,8 +8,8 @@ import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface MixTypeDao extends JpaRepository<MixType, Integer> {
Optional<MixType> findByTypeName(String typeName);
public interface MixTypeDao extends JpaRepository<MixType, Long> {
Optional<MixType> findByName(String name);
Optional<MixType> findByMaterial(Material material);
}

View File

@ -9,14 +9,12 @@ import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface RecipeDao extends JpaRepository<Recipe, Integer> {
public interface RecipeDao extends JpaRepository<Recipe, Long> {
List<Recipe> 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<Recipe> findAllByRecipeDescriptionContainsOrRecipeCodeContains(String searchWordUpperCase);
}

View File

@ -6,9 +6,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface StepDao extends JpaRepository<RecipeStep, Integer> {
RecipeStep findByStepID(int stepID);
public interface StepDao extends JpaRepository<RecipeStep, Long> {
List<RecipeStep> findAllByRecipe(Recipe recipe);

View File

@ -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";
}

View File

@ -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";

View File

@ -60,17 +60,17 @@ public class ImageFilesController {
* Cette méthode requiert l'identifiant de la recette dans l'URL.
* <p>
* 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
* <p>
* 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<Recipe> optionalRecipe = recipeService.getByID(recipeID);
Optional<Recipe> 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);
}
}

View File

@ -56,10 +56,10 @@ public class IndexController {
@ResponseBody
public Map<String, Object> searchWord(@RequestParam String searchString) {
Map<Company, List<Recipe>> searchResult = recipeService.getRecipesForSearchString(searchString);
Map<Integer, List<Integer>> outputResult = new HashMap<>();
Map<Long, List<Long>> 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()

View File

@ -84,9 +84,9 @@ public class InventoryController {
Map<Mix, Map<Material, Float>> quantities = new HashMap<>();
for (String mixIDStr : form.keySet()) {
int mixID = Integer.parseInt(mixIDStr);
Long mixID = Long.parseLong(mixIDStr);
Optional<Mix> optionalMix = mixService.getByID(mixID);
Optional<Mix> optionalMix = mixService.getById(mixID);
if (!optionalMix.isPresent()) {
return responseBuilder
.addResponseCode(ResponseCode.MIX_NOT_FOUND, mixID)
@ -100,7 +100,7 @@ public class InventoryController {
Map<Material, Float> 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<String, Object> searchWordInventory(@RequestParam String searchString) {
List<Material> searchResult = materialService.getAllBySearchString(searchString);
List<Integer> outputResult = searchResult.stream().map(Material::getMaterialID).collect(Collectors.toList());
List<Long> outputResult = searchResult.stream().map(Material::getId).collect(Collectors.toList());
return new JSONResponseBuilder()
.addAttribute("result", outputResult)

View File

@ -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<Recipe> optionalRecipe = recipeService.getByID(recipeID);
Optional<Recipe> optionalRecipe = recipeService.getById(recipeId);
if (!optionalRecipe.isPresent()) {
return modelResponseBuilder
.withView("")
.build();
}
Optional<Mix> optionalMix = mixService.getByID(mixID);
Optional<Mix> optionalMix = mixService.getById(mixId);
boolean mixExist = optionalMix.isPresent();
List<MixType> 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<byte[]> getXlsForRecipe(HttpServletRequest request, @PathVariable int recipeID) {
public ResponseEntity<byte[]> getXlsForRecipe(HttpServletRequest request, @PathVariable Long id) {
HttpHeaders headers = new HttpHeaders();
Optional<Recipe> optionalRecipe = recipeService.getByID(recipeID);
Optional<Recipe> 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();
}

View File

@ -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<Recipe> optionalRecipe = recipeService.getByID(recipeID);
Optional<Recipe> 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<Mix> mixes = new ArrayList<>(recipe.getRecipeMixes()); // Convertit le PersistentBag en ArrayList
mixes.sort(Comparator.comparing(Mix::getMixID));
List<Mix> 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<String, String> location = (Map<String, String>) form.get("locations");
String note = form.get("note").toString();
Optional<Recipe> optionalRecipe = recipeService.getByID(recipeID);
Optional<Recipe> 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<Mix> optionalMix = mixService.getByID(mixID);
Optional<Mix> 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);
}
}

View File

@ -30,8 +30,8 @@ public class SIMDUTFilesController {
}
@GetMapping(SIMDUT_FILES)
public ResponseEntity<byte[]> getFile(HttpServletRequest request, @PathVariable int materialID) {
Optional<Material> optionalMaterial = materialService.getByID(materialID);
public ResponseEntity<byte[]> getFile(HttpServletRequest request, @PathVariable Long id) {
Optional<Material> 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<Void> getFile(@PathVariable int materialID) {
Optional<Material> optionalMaterial = materialService.getByID(materialID);
public ResponseEntity<Void> getFile(@PathVariable Long id) {
Optional<Material> 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();
}

View File

@ -47,7 +47,7 @@ public class CompanyCreatorController {
* <p>
* 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
* <p>
* 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);

View File

@ -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);

View File

@ -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);

View File

@ -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<Recipe> optionalRecipe = recipeService.getByID(recipeID);
Optional<Recipe> 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();
}
}

View File

@ -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<Material> optionalMaterial = materialService.getByID(materialID);
if (material.getName() == null) {
Optional<Material> 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<Material> 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
* <p>
* 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 {
* <p>
* 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<Material> optionalMaterial = materialService.getByID(materialID);
Optional<Material> 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();

View File

@ -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<MaterialType> optionalMaterialType = materialTypeService.getByID(materialTypeID);
if (materialType.getName() == null) {
Optional<MaterialType> 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<MaterialType> 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);
}
}

View File

@ -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<Mix> optionalMix = mixService.getByID(mixID);
Optional<Mix> 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<Mix> optionalMix = mixService.getByID(mixID);
Optional<Mix> 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<Mix> optionalMix = mixService.getByID(mixID);
Optional<Mix> 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();

View File

@ -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<Recipe> optionalRecipe = recipeService.getByID(recipeID);
if (recipe.getName() == null || recipe.getCompany() == null) {
Optional<Recipe> 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<String, Object> form) {
ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder("");
int recipeID = recipe.getRecipeID();
Long recipeId = recipe.getId();
Optional<Recipe> optionalStoredRecipe = recipeService.getByID(recipeID);
Optional<Recipe> optionalStoredRecipe = recipeService.getById(recipeId);
if (!optionalStoredRecipe.isPresent()) {
return listRecipes(
modelResponseBuilder
.addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeID)
.addResponseCode(ResponseCode.RECIPE_NOT_FOUND, recipeId)
.build());
}
Optional<Recipe> 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());
}

View File

@ -59,23 +59,23 @@ public class CompanyRemoverController {
* <p>
* 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<Company> optionalCompany = companyService.getByID(companyID);
Optional<Company> 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());

View File

@ -57,27 +57,27 @@ public class MaterialRemoverController {
* <p>
* 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<Material> optionalMaterial = materialService.getByID(materialID);
Optional<Material> 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());
}
}

View File

@ -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<MaterialType> optionalMaterialType = materialTypeService.getByID(materialTypeID);
Optional<MaterialType> 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());
}
}

View File

@ -54,18 +54,18 @@ public class RecipeRemoverController {
* <p>
* 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<Recipe> optionalRecipe = recipeService.getByID(recipeID);
Optional<Recipe> 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());
}
}

View File

@ -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<Mix> recipeMixes = recipe.getRecipeMixes();
Collection<Mix> 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());
}

View File

@ -15,6 +15,7 @@ spring:
jpa:
hibernate:
ddl-auto: update
show-sql: true
h2:
console:
enabled: true

View File

@ -19,13 +19,13 @@
<div class="content">
<div class="formWrap">
<div class="formColumn">
<label th:for="${#ids.next('companyName')}"
<label th:for="${#ids.next('name')}"
th:text="#{company.form.companyName} + ':'"></label>
</div>
<div class="formColumn">
<input class="rawInput"
required
th:field="*{companyName}"
th:field="*{name}"
type="text">
</div>
</div>

View File

@ -24,8 +24,8 @@
<!-- Corps de la page -->
<section>
<div th:include="fragments.html :: messages"></div>
<p class="success" th:if="${companyName != null}"
th:text="#{company.success.deleted(${companyName})}"></b>
<p class="success" th:if="${name != null}"
th:text="#{company.success.deleted(${name})}"></b>
</p>
<h1 th:text="#{company.delete.title}"></h1>
@ -38,10 +38,10 @@
</tr>
<th:block th:each="company : ${companies}">
<tr>
<td th:text="${company.companyName}"></td>
<td th:text="${company.name}"></td>
<td>
<button class="remover" th:data-code="${company.companyName}"
th:data-entityID="${company.companyID}"
<button class="remover" th:data-code="${company.name}"
th:data-entityId="${company.id}"
type="button" th:text="#{keyword.delete}"></button>
</td>
</tr>

View File

@ -12,7 +12,7 @@
<div th:include="fragments.html :: messages"></div>
<form th:action="@{/images/add}" class="requireAuth" enctype="multipart/form-data" method="POST">
<input name="recipeID" th:value="${recipeID}" type="hidden"/>
<input name="recipeId" th:value="${recipeId}" type="hidden"/>
<input type="file" id="image" name="image" required/>
<br/>

View File

@ -19,11 +19,11 @@
<div class="content recipesContainer">
<div class="companyTab" th:if="${!recipeMap.empty}" th:each="company : ${recipeMap.keySet()}"
th:data-companyID="${company.companyID}">
<h2 class="companyTabTitle" th:data-companyName="${company.companyName}"
th:text="${company.companyName}"></h2>
th:data-companyId="${company.id}">
<h2 class="companyTabTitle" th:data-companyName="${company.name}"
th:text="${company.name}"></h2>
<table style="display:none" th:id="'recipes_' + ${company.companyName}" class="recipesList"
<table style="display:none" th:id="'recipes_' + ${company.name}" class="recipesList"
th:if="${!recipeMap.get(company).empty}">
<tr>
<th th:text="#{recipe.color}"></th>
@ -32,12 +32,12 @@
<th></th>
</tr>
<tr class="recipeRow" th:each="recipe : ${recipeMap.get(company)}"
th:data-approbationDate="${recipe.approbationDate}" th:data-recipeID="${recipe.recipeID}">
<td class="descriptionCell" th:text="${recipe.recipeCode}"></td>
<td class="descriptionCell recipeDescription" th:text="${recipe.recipeDescription}"></td>
th:data-approbationDate="${recipe.approbationDate}" th:data-recipeId="${recipe.id}">
<td class="descriptionCell" th:text="${recipe.name}"></td>
<td class="descriptionCell recipeDescription" th:text="${recipe.description}"></td>
<td class="descriptionCell" th:text="'#' + ${recipe.sample}"></td>
<td>
<button class="gotoRecipe" th:data-recipeid="${recipe.recipeID}" type="button"
<button class="gotoRecipe" th:data-recipeid="${recipe.id}" type="button"
th:text="#{keyword.see}"></button>
</td>
</tr>
@ -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;
});
});
})();

View File

@ -61,8 +61,8 @@
<!-- Corps de la page -->
<section>
<th:block th:each="materialType : ${materialTypes}"
th:if="${materialType.materialTypeName.equalsIgnoreCase('aucun')}">
<input id="anyTypeId" th:value="${materialType.materialTypeID}" type="hidden"/>
th:if="${materialType.name.equalsIgnoreCase('aucun')}">
<input id="anyTypeId" th:value="${materialType.id}" type="hidden"/>
</th:block>
<h1 th:text="#{menu.inventory}"></h1>
@ -92,16 +92,16 @@
<!--Produits-->
<tr class="materialRow" th:each="material : ${materials}"
th:data-materialType="${material.materialType.materialTypeID}"
th:data-materialID="${material.materialID}">
<td class="materialCode" th:data-materialID="${material.materialID}"
th:text="${material.materialCode}"></td>
th:data-materialType="${material.materialType.id}"
th:data-materialId="${material.materialId}">
<td class="materialCode" th:data-materialId="${material.id}"
th:text="${material.name}"></td>
<td class="inventoryQuantity" th:data-quantityML="${material.inventoryQuantity}"
th:text="${material.inventoryQuantity}"></td>
<td><span class="inventoryQuantityUnits">mL</span></td>
<td class="materialType" th:text="${material.materialType.materialTypeName}"></td>
<td class="materialType" th:text="${material.materialType.name}"></td>
<td>
<button class="modifyMaterial" th:data-materialID="${material.materialID}" type="button"
<button class="modifyMaterial" th:data-materialId="${material.id}" type="button"
th:text="#{keyword.edit}"></button>
</td>
</tr>
@ -123,8 +123,8 @@
<label for="materialTypeSelect" th:text="#{inventory.showOnly} + ':'"> </label>
<select id="materialTypeSelect" name="materialTypeSelect" onchange="hideMaterialTypes(this)">
<th:block th:each="materialType : ${materialTypes}">
<option th:text="${materialType.materialTypeName}"
th:value="${materialType.materialTypeID}"></option>
<option th:text="${materialType.name}"
th:value="${materialType.id}"></option>
</th:block>
</select>
</div>

View File

@ -11,7 +11,7 @@
<header th:include="fragments.html :: header"></header>
<!-- Corps de la page -->
<section>
<p th:text="#{material.success.created(${materialCode})}"></p>
<p th:text="#{material.success.created(${name})}"></p>
<h1 th:text="#{material.add.title}"></h1>
<button class="returnButton" th:text="#{keyword.back}"></button>

View File

@ -9,7 +9,7 @@
<header th:include="fragments.html :: header"></header>
<!-- Corps de la page -->
<section>
<p th:if="${materialCode != null}" th:text="#{material.success.created(${materialCode})}" class="success"></p>
<p th:if="${name != null}" th:text="#{material.success.created(${name})}" class="success"></p>
<div th:include="fragments.html :: messages"></div>
<h1 th:text="#{material.add.title}"></h1>
@ -20,7 +20,7 @@
<div class="formWrap">
<div class="formColumn">
<div>
<label th:for="${#ids.next('materialCode')}" th:text="#{material.code} + ':'"></label>
<label th:for="${#ids.next('name')}" th:text="#{material.code} + ':'"></label>
</div>
<div>
<label for="quantity" th:text="#{material.inventoryQuantity} + ':'"></label>
@ -36,7 +36,7 @@
<div>
<input type="text"
class="rawInput"
th:field="*{materialCode}"
th:field="*{name}"
style="width: 145px"
required/>
</div>
@ -66,8 +66,8 @@
</div>
<div>
<select th:field="*{materialType}" required>
<option th:each="materialType : ${materialTypes}" th:value="${materialType.materialTypeID}"
th:text="${materialType.materialTypeName}"></option>
<option th:each="materialType : ${materialTypes}" th:value="${materialType.id}"
th:text="${materialType.name}"></option>
</select>
</div>
<div>

View File

@ -2,7 +2,7 @@
<html lang="fr" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block
th:include="fragments.html :: head(#{material.editing.title(${material.materialCode})}, 'form')"></th:block>
th:include="fragments.html :: head(#{material.editing.title(${material.name})}, 'form')"></th:block>
<link th:href="@{|${baseUrl}/css/forms.css|}" rel="stylesheet"/>
</head>
@ -14,19 +14,19 @@
<section>
<div th:include="fragments.html :: messages"></div>
<h1 class="materialCode" th:text="#{material.editing.title(${material.materialCode})}"></h1>
<h1 class="materialCode" th:text="#{material.editing.title(${material.name})}"></h1>
<form th:action="@{/material/editor}" th:object="${material}" class="requireAuth" method="POST">
<input type="hidden" th:field="*{materialID}"/>
<input type="hidden" th:field="*{id}"/>
<div class="content">
<div class="formWrap">
<div class="formColumn">
<div>
<label th:for="${#ids.next('materialID')}" th:text="#{keyword.id} + ':'"></label>
<label th:for="${#ids.next('id')}" th:text="#{keyword.id} + ':'"></label>
</div>
<div>
<label th:for="${#ids.next('materialCode')}" th:text="#{material.code} + ':'"></label>
<label th:for="${#ids.next('name')}" th:text="#{material.code} + ':'"></label>
</div>
<div>
<label for="quantity" th:text="#{material.inventoryQuantity}"></label>
@ -37,10 +37,10 @@
</div>
<div class="formColumn">
<div>
<input type="number" th:field="*{materialID}" required disabled/>
<input type="number" th:field="*{id}" required disabled/>
</div>
<div>
<input type="text" th:field="*{materialCode}"/>
<input type="text" th:field="*{name}"/>
</div>
<div style="display: flex; flex-direction: row">
<input data-unit="mL"
@ -66,9 +66,9 @@
<div>
<select th:field="*{materialType}">
<option th:each="mType : ${materialTypes}"
th:attrappend="selected=${mType.materialTypeID == material.materialType.materialTypeID}"
th:text="${mType.materialTypeName}"
th:value="${mType.materialTypeID}"></option>
th:attrappend="selected=${mType.id == material.materialType.id}"
th:text="${mType.name}"
th:value="${mType.id}"></option>
</select>
</div>
</div>
@ -83,14 +83,14 @@
<script>
(() => {
const materialID = document.querySelector("#materialID").value;
const materialId = document.querySelector("#materialId").value;
document.querySelector("#showSIMDUT").addEventListener("click", () => {
window.open(`/simdut/${materialID}`);
window.open(`/simdut/${materialId}`);
});
document.querySelector("#editSIMDUT").addEventListener("click", () => {
document.location.href = `/material/simdut/${materialID}`;
document.location.href = `/material/simdut/${materialId}`;
});
})();

View File

@ -21,8 +21,8 @@
<!-- Corps de la page -->
<section>
<div th:include="fragments.html :: messages"></div>
<p class="success" th:if="${materialCode != null}"
th:text="#{material.success.saved(${materialCode})}"></b>
<p class="success" th:if="${name != null}"
th:text="#{material.success.saved(${name})}"></b>
</p>
<h1 th:text="#{material.edit.title}"></h1>
@ -33,11 +33,11 @@
<th></th>
</tr>
<tr th:each="material : ${materials}">
<td class="materialCode" th:data-materialID="${material.materialID}"
th:text="${material.materialCode}"></td>
<td th:text="${material.materialType.materialTypeName}"></td>
<td class="materialCode" th:data-materialId="${material.id}"
th:text="${material.name}"></td>
<td th:text="${material.materialType.name}"></td>
<td>
<button class="editor" th:data-materialID="${material.materialID}" type="button"
<button class="editor" th:data-materialId="${material.id}" type="button"
th:text="#{keyword.edit}"></button>
</td>
</tr>
@ -53,9 +53,9 @@
(() => {
document.querySelectorAll(".editor").forEach((e) => {
e.addEventListener("click", () => {
const materialID = e.getAttribute("data-materialID");
const materialId = e.getAttribute("data-materialId");
document.location.href = "/material/editor/" + materialID;
document.location.href = "/material/editor/" + materialId;
});
});
})();

View File

@ -21,8 +21,8 @@
<!-- Corps de la page -->
<section>
<div th:include="fragments.html :: messages"></div>
<p class="success" th:if="${materialCode != null}"
th:text="#{material.success.deleted(${materialCode})}"></p>
<p class="success" th:if="${name != null}"
th:text="#{material.success.deleted(${name})}"></p>
<h1 th:text="#{material.delete.title}"></h1>
<form th:action="@{/material/remover/}" class="requireAuth-remover" method="POST">
@ -33,12 +33,12 @@
<th></th>
</tr>
<tr th:each="material : ${materials}">
<td class="materialCode" th:data-materialID="${material.materialID}"
th:text="${material.materialCode}"></td>
<td th:text="${material.materialType.materialTypeName}"></td>
<td class="materialCode" th:data-materialId="${material.id}"
th:text="${material.name}"></td>
<td th:text="${material.materialType.name}"></td>
<td>
<button class="remover" th:data-code="${material.materialCode}"
th:data-entityID="${material.materialID}"
<button class="remover" th:data-code="${material.name}"
th:data-entityId="${material.materialId}"
type="button" th:text="#{keyword.delete}"></button>
</td>
</tr>

View File

@ -14,7 +14,7 @@
<h1 th:text="#{material.add.title}"></h1>
<div class="form">
<form th:action="@{/material/simdut}" class="requireAuth" enctype="multipart/form-data" method="POST">
<input name="materialID" th:value="${materialID}" type="hidden"/>
<input name="materialId" th:value="${id}" type="hidden"/>
<label for="simdut" th:text="#{material.simdut.choose} + ':'"></label>
<input id="simdut" name="simdut" type="file"/>

View File

@ -19,7 +19,7 @@
<div class="formWrap">
<div class="formColumn">
<div>
<label th:for="${#ids.next('materialTypeName')}"
<label th:for="${#ids.next('name')}"
th:text="#{materialType.name} + ':'"></label>
</div>
<div><label th:for="${#ids.next('prefix')}"
@ -34,7 +34,7 @@
<div>
<input required
class="rawInput"
th:field="*{materialTypeName}"
th:field="*{name}"
type="text"/>
</div>
<div>

View File

@ -2,7 +2,7 @@
<html lang="fr" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block
th:include="fragments.html :: head(#{materialType.editing.title(${materialType.materialTypeName})}, 'form')"></th:block>
th:include="fragments.html :: head(#{materialType.editing.title(${materialType.name})}, 'form')"></th:block>
</head>
<body>
@ -12,17 +12,17 @@
<section>
<div th:include="fragments.html :: messages"></div>
<h1 class="materialCode" th:text="#{materialType.editing.title(${materialType.materialTypeName})}"></h1>
<h1 class="materialCode" th:text="#{materialType.editing.title(${materialType.name})}"></h1>
<form th:action="@{/materialType/editor}" th:object="${materialType}" class="requireAuth" method="POST">
<div class="content">
<div class="formWrap">
<div class="formColumn">
<div>
<label th:for="${#ids.next('materialTypeID')}" th:text="#{material.type}"></label>
<label th:for="${#ids.next('id')}" th:text="#{material.type}"></label>
</div>
<div>
<label th:for="${#ids.next('materialTypeName')}" th:text="#{materialType.name} + ':'"></label>
<label th:for="${#ids.next('name')}" th:text="#{materialType.name} + ':'"></label>
</div>
<div>
<label th:for="${#ids.next('prefix')}"
@ -35,10 +35,10 @@
</div>
<div class="formColumn">
<div>
<input type="number" th:field="*{materialTypeID}" required disabled/>
<input type="number" th:field="*{id}" required disabled/>
</div>
<div>
<input type="text" th:field="*{materialTypeName}" required/>
<input type="text" th:field="*{name}" required/>
</div>
<div>
<input type="text" minlength="3" maxlength="3" th:field="*{prefix}" required/>

View File

@ -21,8 +21,8 @@
<!-- Corps de la page -->
<section>
<div th:include="fragments.html :: messages"></div>
<p class="success" th:if="${materialTypeName != null}"
th:text="#{materialType.success.saved(${materialTypeName})}"></b>
<p class="success" th:if="${name != null}"
th:text="#{materialType.success.saved(${name})}"></b>
</p>
<h1 th:text="#{materialType.editor.title}"></h1>
@ -32,10 +32,10 @@
<th></th>
</tr>
<tr th:each="materialType : ${materialTypes}">
<td class="materialType" th:data-materialTypeID="${materialType.materialTypeID}"
th:text="${materialType.materialTypeName}"></td>
<td class="materialType" th:data-materialTypeId="${materialType.id}"
th:text="${materialType.name}"></td>
<td>
<button class="editor" th:data-materialTypeID="${materialType.materialTypeID}" type="button"
<button class="editor" th:data-materialTypeId="${materialType.id}" type="button"
th:text="#{keyword.edit}"></button>
</td>
</tr>
@ -51,9 +51,9 @@
(() => {
document.querySelectorAll(".editor").forEach((e) => {
e.addEventListener("click", () => {
const materialTypeID = e.getAttribute("data-materialTypeID");
const materialTypeId = e.getAttribute("data-materialTypeId");
document.location.href = "/materialType/editor/" + materialTypeID;
document.location.href = "/materialType/editor/" + materialTypeId;
});
});
})();

View File

@ -21,8 +21,8 @@
<!-- Corps de la page -->
<section>
<div th:include="fragments.html :: messages"></div>
<p class="success" th:if="${materialTypeName != null}"
th:text="#{materialType.success.deleted(${materialTypeName})}"></p>
<p class="success" th:if="${name != null}"
th:text="#{materialType.success.deleted(${name})}"></p>
<h1 th:text="#{materialType.delete.title}"></h1>
<form th:action="@{/materialType/remover/}" class="requireAuth-remover" method="POST">
@ -32,11 +32,11 @@
<th></th>
</tr>
<tr th:each="materialType : ${materialTypes}">
<td class="materialTypeName" th:data-materialTypeID="${materialType.materialTypeID}"
th:text="${materialType.materialTypeName}"></td>
<td class="materialTypeName" th:data-materialTypeId="${materialType.id}"
th:text="${materialType.name}"></td>
<td>
<button class="remover" th:data-code="${materialType.materialTypeName}"
th:data-entityID="${materialType.materialTypeID}"
<button class="remover" th:data-code="${materialType.name}"
th:data-entityId="${materialType.id}"
type="button" th:text="#{keyword.delete}"></button>
</td>
</tr>

View File

@ -12,13 +12,13 @@
<!-- Corps de la page -->
<section>
<div th:include="fragments.html :: messages"></div>
<h1 th:text="#{mix.add.subtitle(${recipe.recipeCode})}"></h1>
<h1 th:text="#{mix.add.subtitle(${recipe.name})}"></h1>
<br/>
<br/>
<form th:action="@{/mix/creator}" class="requireAuth" method="POST">
<!-- Information nécessaire à la création des mélanges -->
<input id="recipeID" name="recipe" th:value="${recipe.recipeID}" type="hidden"/>
<input id="recipeId" name="recipe" th:value="${recipe.id}" type="hidden"/>
<div class="content">
<div class="flexContent formWrap">
@ -39,8 +39,8 @@
</div>
<div>
<select name="materialType" id="materialType">
<option th:each="materialType : ${materialTypes}" th:value="${materialType.materialTypeID}"
th:text="${materialType.materialTypeName}"></option>
<option th:each="materialType : ${materialTypes}" th:value="${materialType.id}"
th:text="${materialType.name}"></option>
</select></div>
</div>
</div>

View File

@ -11,14 +11,14 @@
<!-- Corps de la page -->
<section>
<div th:include="fragments.html :: messages"></div>
<h1 th:text="#{mix.edit.subtitle(${recipe.recipeCode}, ${mix.mixType.typeName})}"></h1>
<h1 th:text="#{mix.edit.subtitle(${recipe.name}, ${mix.mixType.name})}"></h1>
<br/>
<br/>
<form th:action="@{/mix/editor/}" class="requireAuth" method="POST">
<!-- Information nécessaire à la création des mélanges -->
<input id="recipeID" name="recipe" th:value="${recipe.recipeID}" type="hidden"/>
<input id="mixID" name="mixID" th:value="${mix.mixID}" type="hidden"/>
<input id="recipeId" name="recipe" th:value="${recipe.id}" type="hidden"/>
<input id="mixId" name="mixId" th:value="${mix.id}" type="hidden"/>
<div class="content">
<div class="flexContent formWrap">
@ -35,15 +35,15 @@
<input type="text" id="mixType"
name="mixTypeName"
placeholder="ex: Teinture"
th:value="${mix.mixType.typeName}"
th:value="${mix.mixType.name}"
required/>
</div>
<div>
<select name="materialType" id="materialType">
<option th:each="currentMaterialType : ${materialTypes}"
th:value="${currentMaterialType.materialTypeID}"
th:text="${currentMaterialType.materialTypeName}"
th:selected="${currentMaterialType.materialTypeID == materialType.materialTypeID}"></option>
th:value="${currentMaterialType.id}"
th:text="${currentMaterialType.name}"
th:selected="${currentMaterialType.id == materialType.id}"></option>
</select></div>
</div>
</div>
@ -87,7 +87,7 @@
document.querySelector("#removeMix").addEventListener("click", () => {
showElement(errorMsgBox);
checkPassword(null, () => document.location.href = `/mix/remover/[[${mix.mixID}]]`);
checkPassword(null, () => document.location.href = `/mix/remover/[[${mix.id}]]`);
});
})();

View File

@ -16,9 +16,9 @@
<div class="materialList">
<p
th:each="material : ${materials}"
th:text="${material.materialType.materialTypeName == 'Aucun' ? '' : '[' + material.materialType.prefix + ']'} + ' ' + ${material.materialCode}"
th:data-materialcode="${material.materialCode}"
th:data-materialtype="${material.materialType.materialTypeName}"
th:text="${material.materialType.name == 'Aucun' ? '' : '[' + material.materialType.prefix + ']'} + ' ' + ${material.name}"
th:data-materialcode="${material.name}"
th:data-materialtype="${material.materialType.name}"
th:data-usepercentages="${material.materialType.usePercentages}"></p>
</div>
</div>

View File

@ -1,6 +1,6 @@
<div class="form">
<form th:action="@{/recipe/editor}" th:object="${recipe}" class="requireAuth" method="POST">
<input type="hidden" th:field="*{recipeID}"/>
<input type="hidden" th:field="*{id}"/>
<table class="mainTable">
<tr>
@ -8,13 +8,13 @@
<table>
<tr>
<td><b th:text="#{keyword.id} + ':'"></b></td>
<td th:text="${recipe.recipeID}"></td>
<td th:text="${recipe.id}"></td>
</tr>
<tr th:include="fragments.html :: separator"></tr>
<tr>
<td><b><label th:for="${#ids.next('recipeCode')}"
<td><b><label th:for="${#ids.next('name')}"
th:text="#{recipe.color} + ':'"></label></b></td>
<td><input type="text" th:field="*{recipeCode}"></td>
<td><input type="text" th:field="*{name}"></td>
</tr>
<tr th:include="fragments.html :: separator"></tr>
<tr>
@ -25,16 +25,16 @@
<select th:field="*{company}">
<option th:each="company : ${companies}"
th:selected="${recipe.company.equals(company)}"
th:text="${company.companyName}"
th:value="${company.companyID}"></option>
th:text="${company.name}"
th:value="${company.id}"></option>
</select>
</td>
</tr>
<tr th:include="fragments.html :: separator"></tr>
<tr>
<td><b><label th:for="${#ids.next('recipeDescription')}"
<td><b><label th:for="${#ids.next('description')}"
th:text="#{recipe.description} + ':'"></label></b></td>
<td><input type="text" th:field="*{recipeDescription}"/></td>
<td><input type="text" th:field="*{description}"/></td>
</tr>
<tr th:include="fragments.html :: separator"></tr>
<tr>
@ -67,10 +67,10 @@
<th:block th:each="mix : ${mixes}">
<tr>
<td class="mixNameColumn">
<b th:text="${mix.mixType.typeName} + ':'"></b>
<b th:text="${mix.mixType.name} + ':'"></b>
<br/>
<th:block th:if="${mix != null}">
<button class="mixEditor" th:data-mixID="${mix.mixID}" type="button"
<button class="mixEditor" th:data-mixId="${mix.id}" type="button"
th:text="#{keyword.edit}"></button>
</th:block>
</td>
@ -85,11 +85,11 @@
</tr>
<tr th:each="mixQuantity : ${mix.mixQuantities}"
th:with="material = ${mixQuantity.material}">
<td th:classappend="${material.isMixType()} ? '' : materialCode"
th:data-materialID="${material.materialID}"
th:text="${material.materialCode}"></td>
<td th:classappend="${material.isMixType()} ? '' : name"
th:data-materialId="${material.id}"
th:text="${material.name}"></td>
<td>
<p th:text="${material.materialType.materialTypeName}"></p>
<p th:text="${material.materialType.name}"></p>
</td>
<td th:text="${mixQuantity.quantity} + ' ' + ${material.materialType.usePercentages ? '%' : 'mL'}"></td>
</tr>
@ -145,7 +145,7 @@
</tr>
<tr>
<td>
<button id="addImg" th:data-recipeID="${recipe.recipeID}" type="button"
<button id="addImg" th:data-recipeId="${recipe.id}" type="button"
th:text="#{recipe.edit.addImage}"></button>
</td>
</tr>

View File

@ -12,8 +12,8 @@
<div th:include="fragments.html :: messages"></div>
<h1 th:text="#{recipe.add.title}"></h1>
<p th:text="#{recipe.sucess.saved(${recipe.recipeCode})}"></p>
<button th:onclick="'document.location.href=\'/recipe/editor/' + ${recipe.recipeID} + '\''"
<p th:text="#{recipe.sucess.saved(${recipe.name})}"></p>
<button th:onclick="'document.location.href=\'/recipe/editor/' + ${recipe.id} + '\''"
th:text="#{keyword.continue}"></button>
</section>
<!-- Fragment du pied de page -->

View File

@ -17,13 +17,13 @@
<div class="formWrap">
<div class="formColumn">
<div>
<label th:for="${#ids.next('recipeCode')}" th:text="#{recipe.color} + ':'"></label>
<label th:for="${#ids.next('name')}" th:text="#{recipe.color} + ':'"></label>
</div>
<div>
<label th:for="${#ids.next('company')}" th:text="#{keyword.company} + ':'"></label>
</div>
<div>
<label th:for="${#ids.next('recipeDescription')}" th:text="#{recipe.description} + ':'"></label>
<label th:for="${#ids.next('description')}" th:text="#{recipe.description} + ':'"></label>
</div>
<div>
<label th:for="${#ids.next('sample')}" th:text="#{recipe.sample} + ':'"></label>
@ -38,16 +38,16 @@
</div>
<div class="formColumn">
<div>
<input type="text" th:field="*{recipeCode}" required/>
<input type="text" th:field="*{name}" required/>
</div>
<div>
<select th:field="*{company}">
<option th:each="company : ${companies}" th:text="${company.companyName}"
th:value="${company.companyID}"></option>
<option th:each="company : ${companies}" th:text="${company.name}"
th:value="${company.id}"></option>
</select>
</div>
<div>
<input type="text" th:field="*{recipeDescription}" required/>
<input type="text" th:field="*{description}" required/>
</div>
<div>
<input type="number" th:field="*{sample}" required/>

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="fr" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="fragments.html :: head(#{recipe.editing.title(${recipe.recipeCode})}, 'form')"></th:block>
<th:block th:include="fragments.html :: head(#{recipe.editing.title(${recipe.name})}, 'form')"></th:block>
<link href="/css/explore.css" rel="stylesheet"/>
@ -75,27 +75,27 @@
<section>
<div th:include="fragments.html :: messages"></div>
<h1 th:text="#{recipe.editing.title(${recipe.recipeCode})}"></h1>
<h1 th:text="#{recipe.editing.title(${recipe.name})}"></h1>
<button id="gotoRecipe" type="button" th:text="#{keyword.see}"></button>
<form th:action="@{/recipe/editor}" th:object="${recipe}" class="requireAuth" method="POST">
<div class="content">
<!-- Informations -->
<div class="flexContent" style="padding-top: 40px">
<input type="hidden" th:field="*{recipeID}"/>
<input type="hidden" th:field="*{recipeId}"/>
<div class="formWrap">
<div class="formColumn">
<div>
<label th:for="${#ids.next('recipeID')}" th:text="#{keyword.id}"></label>
<label th:for="${#ids.next('recipeId')}" th:text="#{keyword.id}"></label>
</div>
<div>
<label th:for="${#ids.next('recipeCode')}" th:text="#{recipe.color}"></label>
<label th:for="${#ids.next('name')}" th:text="#{recipe.color}"></label>
</div>
<div>
<label th:for="${#ids.next('banner')}" th:text="#{keyword.company}"></label>
</div>
<div>
<label th:for="${#ids.next('recipeDescription')}" th:text="#{recipe.description}"></label>
<label th:for="${#ids.next('description')}" th:text="#{recipe.description}"></label>
</div>
<div>
<label th:for="${#ids.next('sample')}" th:text="#{recipe.sample}"></label>
@ -109,21 +109,21 @@
</div>
<div class="formColumn">
<div>
<input type="number" th:field="*{recipeID}" required disabled/>
<input type="number" th:field="*{recipeId}" required disabled/>
</div>
<div>
<input type="text" th:field="*{recipeCode}" required/>
<input type="text" th:field="*{name}" required/>
</div>
<div>
<select th:field="*{company}">
<option th:each="company : ${companies}"
th:selected="${recipe.company.equals(company)}"
th:text="${company.companyName}"
th:value="${company.companyID}"></option>
th:text="${company.name}"
th:value="${company.id}"></option>
</select>
</div>
<div>
<input type="text" th:field="*{recipeDescription}"/>
<input type="text" th:field="*{description}"/>
</div>
<div>
<input type="number" th:field="*{sample}"/>
@ -144,13 +144,13 @@
</div>
<div th:each="mix : ${mixes}" class="mixContainer">
<div class="mixInfo">
<b th:text="${mix.mixType.typeName} + ':'"></b>
<button class="mixEditor" th:data-mixID="${mix.mixID}" type="button"
<b th:text="${mix.mixType.name} + ':'"></b>
<button class="mixEditor" th:data-mixId="${mix.id}" type="button"
th:text="#{keyword.edit}" style="width: 75%"></button>
</div>
<div>
<table class="mix"
th:id="'mix-' + ${mix.mixID}">
th:id="'mix-' + ${mix.id}">
<tr>
<th th:text="#{keyword.material}"></th>
<th th:text="#{keyword.type}"></th>
@ -159,13 +159,13 @@
<!-- Produits -->
<tr th:each="mixQuantity : ${mix.mixQuantities}"
th:with="material = ${mixQuantity.material}"
th:id="'material-' + ${material.materialID}">
th:id="'material-' + ${material.id}">
<td class="materialCodeColumn"
th:classappend="${material.isMixType()} ? '' : materialCode"
th:data-materialID="${material.materialID}"
th:text="${material.materialCode}"></td>
th:classappend="${material.isMixType()} ? '' : name"
th:data-materialId="${material.id}"
th:text="${material.name}"></td>
<td class="materialTypeColumn"
th:text="${material.materialType.materialTypeName}"></td>
th:text="${material.materialType.name}"></td>
<td class="materialQuantityColumn"
th:text="${mixQuantity.quantity} + ' ' + ${material.materialType.usePercentages ? '%' : 'mL'}"></td>
</tr>
@ -217,21 +217,21 @@
(() => {
document.querySelector("#gotoRecipe").addEventListener("click", () => {
window.open("/recipe/explore/" + document.querySelector("#recipeID").value, "_blank");
window.open("/recipe/explore/" + document.querySelector("#recipeId").value, "_blank");
});
document.querySelectorAll(".mixEditor").forEach(e => {
e.addEventListener("click", () => {
const mixID = e.getAttribute("data-mixID");
const mixId = e.getAttribute("data-mixId");
document.location.href = "/mix/editor/" + mixID;
document.location.href = "/mix/editor/" + mixId;
});
});
document.querySelector("#newMix").addEventListener("click", () => {
const recipeID = "[[${recipe.recipeID}]]";
const recipeId = "[[${recipe.id}]]";
document.location.href = "/mix/creator/" + recipeID;
document.location.href = "/mix/creator/" + recipeId;
});
document.querySelectorAll(".deleteImg").forEach(e => {
@ -266,7 +266,7 @@
document.querySelector("#addImage").addEventListener("click", () => {
if (confirm(askChangePage)) {
document.location.href = "/images/add/[[${recipe.recipeID}]]";
document.location.href = "/images/add/[[${recipe.id}]]";
}
});
@ -312,9 +312,9 @@
stepNbr++;
}
function deleteStep(stepID) {
function deleteStep(stepId) {
// Supprime la rangée de l'étape
document.querySelector(`#${stepID}`).parentElement.remove();
document.querySelector(`#${stepId}`).parentElement.remove();
}
/*]]*/

View File

@ -20,11 +20,11 @@
<div class="content recipesContainer">
<div class="companyTab" th:if="${!recipeMap.empty}" th:each="company : ${recipeMap.keySet()}"
th:data-companyID="${company.companyID}">
<h2 class="companyTabTitle" th:data-companyName="${company.companyName}"
th:text="${company.companyName}"></h2>
th:data-companyId="${company.id}">
<h2 class="companyTabTitle" th:data-companyName="${company.name}"
th:text="${company.name}"></h2>
<table style="display:none" th:id="'recipes_' + ${company.companyName}" class="recipesList"
<table style="display:none" th:id="'recipes_' + ${company.name}" class="recipesList"
th:if="${!recipeMap.get(company).empty}">
<tr>
<th th:text="#{recipe.color}"></th>
@ -33,13 +33,13 @@
<th></th>
</tr>
<tr class="recipeRow" th:each="recipe : ${recipeMap.get(company)}"
th:data-approbationDate="${recipe.approbationDate}" th:data-recipeID="${recipe.recipeID}">
<td class="descriptionCell" th:text="${recipe.recipeCode}"></td>
<td class="descriptionCell recipeDescription" th:text="${recipe.recipeDescription}"></td>
th:data-approbationDate="${recipe.approbationDate}" th:data-recipeId="${recipe.id}">
<td class="descriptionCell" th:text="${recipe.name}"></td>
<td class="descriptionCell recipeDescription" th:text="${recipe.description}"></td>
<td class="descriptionCell" th:text="'#' + ${recipe.sample}"></td>
<td>
<button class="editRecipe" th:data-code="${recipe.recipeCode}"
th:data-recipeID="${recipe.recipeID}" type="button" th:text="#{menu.edit}"></button>
<button class="editRecipe" th:data-code="${recipe.name}"
th:data-recipeId="${recipe.id}" type="button" th:text="#{menu.edit}"></button>
</td>
</tr>
</table>
@ -56,9 +56,9 @@
(() => {
document.querySelectorAll(".editRecipe").forEach((e) => {
e.addEventListener("click", () => {
const recipeID = e.getAttribute("data-recipeID");
const recipeId = e.getAttribute("data-recipeId");
document.location.href = "/recipe/editor/" + recipeID;
document.location.href = "/recipe/editor/" + recipeId;
});
});
})();

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="fr" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="fragments.html :: head(#{recipe.explore.title(${recipe.recipeCode})}, null)"></th:block>
<th:block th:include="fragments.html :: head(#{recipe.explore.title(${recipe.name})}, null)"></th:block>
<link rel="stylesheet" href="/css/explore.css"/>
</head>
@ -13,7 +13,7 @@
<section>
<div th:include="fragments.html :: messages"></div>
<h1 th:text="#{recipe.explore.title(${recipe.recipeCode})}"></h1>
<h1 th:text="#{recipe.explore.title(${recipe.name})}"></h1>
<button id="modifyRecipe" type="button" th:text="#{menu.edit}"></button>
<button id="useSubmit" type="button" th:text="#{keyword.use}"></button>
<select id="unitsSelect"
@ -24,14 +24,14 @@
</select>
<br/>
<br/>
<button th:onclick="'location.href=\'' + @{|${baseUrl}/recipe/xls/__${recipe.recipeID}__|} + '\''"
<button th:onclick="'location.href=\'' + @{|${baseUrl}/recipe/xls/__${recipe.id}__|} + '\''"
th:text="#{recipe.xlsVersion}">
</button>
<input id="recipeID"
name="recipeID"
<input id="recipeId"
name="recipeId"
type="hidden"
th:value="${recipe.recipeID}"/>
th:value="${recipe.id}"/>
<!-- Formulaires sans autocomplétion pour éviter que le navigateur cache des valeurs lors d'un rafraichissement-->
<form action="#" autocomplete="off">
@ -39,15 +39,15 @@
<div class="flexContent recipeDescription">
<div>
<b th:text="#{recipe.color} + ':'"></b>
<p th:text="${recipe.recipeCode}">
<p th:text="${recipe.name}">
</div>
<div>
<b th:text="#{keyword.company} + ':'"></b>
<p th:text="${recipe.company.companyName}">
<p th:text="${recipe.company.name}">
</div>
<div>
<b th:text="#{recipe.description} + ':'"></b>
<p th:text="${recipe.recipeDescription}">
<p th:text="${recipe.description}">
</div>
<div>
<b th:text="#{recipe.sample} + ':'"></b>
@ -82,22 +82,22 @@
<th:block th:each="mix : ${mixes}">
<div class="mixContainer">
<div class="mixInfo">
<b th:text="${mix.mixType.typeName} + ':'"></b><br/><br/>
<label th:for="'location' + ${mix.mixID}"
<b th:text="${mix.mixType.name} + ':'"></b><br/><br/>
<label th:for="'location' + ${mix.id}"
th:text="' ' + #{mix.location} + ': '">
</label>
<input class="recipeLocation rawInput toSave"
th:id="'location' + ${mix.mixID}"
th:id="'location' + ${mix.id}"
name="location"
th:data-mixID="${mix.mixID}"
th:data-mixId="${mix.id}"
th:value="${mix.location}"
placeholder="N/A"
type="text"/>
</div>
<div>
<table class="mix"
th:id="'mix-' + ${mix.mixID}">
th:id="'mix-' + ${mix.id}">
<tr>
<th th:text="#{keyword.material}"></th>
<th th:text="#{keyword.type}"></th>
@ -117,12 +117,12 @@
<!-- Produits -->
<tr th:each="mixQuantity : ${mix.mixQuantities}"
th:with="material = ${mixQuantity.material}"
th:id="'material-' + ${material.materialID}">
th:id="'material-' + ${material.id}">
<td class="materialCodeColumn"
th:classappend="${material.isMixType()} ? '' : materialCode"
th:data-materialID="${material.materialID}"
th:text="${material.materialCode}"></td>
<td th:text="${material.materialType.materialTypeName}"></td>
th:classappend="${material.isMixType()} ? '' : name"
th:data-materialId="${material.id}"
th:text="${material.name}"></td>
<td th:text="${material.materialType.name}"></td>
<td class="inventoryQuantityColumn">
<p class="inventoryQuantity"
th:data-quantityML="${mixQuantity.quantity}"
@ -132,8 +132,8 @@
<input th:if="${!material.isMixType()}"
class="quantityCustomizer noStyle"
min="0.001" step="0.001"
th:data-materialID="${material.materialID}"
th:data-mixID="${mix.mixID}"
th:data-materialId="${material.id}"
th:data-mixId="${mix.id}"
th:data-quantityML="${mixQuantity.quantity}"
th:data-usePercentages="${material.materialType.usePercentages}"
th:value="${mixQuantity.quantity}"
@ -145,8 +145,8 @@
<p th:if="${material.materialType.usePercentages}">%</p>
</td>
<td class="calculationColumn">
<p class="calculation" th:data-mixID="${mix.mixID}"
th:data-materialID="${material.materialID}"></p>
<p class="calculation" th:data-mixId="${mix.id}"
th:data-materialId="${material.id}"></p>
</td>
</tr>
<tr>
@ -159,7 +159,7 @@
type="number"
min="0.001"
step="0.001"
th:data-mixID="${mix.mixID}"
th:data-mixId="${mix.id}"
/>
</td>
<td>
@ -211,8 +211,8 @@
(() => {
document.querySelector("#modifyRecipe").addEventListener("click", () => {
const recipeID = document.querySelector("#recipeID").value;
document.location.href = `/recipe/editor/${recipeID}`;
const recipeId = document.querySelector("#recipeId").value;
document.location.href = `/recipe/editor/${recipeId}`;
});
document.querySelectorAll(".quantityCustomizer").forEach(e => {
@ -258,8 +258,8 @@
console.log(e);
const value = e.valueAsNumber;
const oldValue = e.defaultValue;
const mixID = e.dataset.mixid;
const mixTable = document.querySelector(`#mix-${mixID}`);
const mixId = e.dataset.mixid;
const mixTable = document.querySelector(`#mix-${mixId}`);
mixTable.querySelectorAll(".quantityCustomizer").forEach(elem => {
if (elem.dataset.usepercentages === "false") {
@ -280,7 +280,7 @@
let formData = {};
// Identifiant de la recette
formData.recipeID = document.querySelector("#recipeID").value;
formData.recipeId = document.querySelector("#recipeId").value;
// Position
formData.locations = {};
@ -301,14 +301,14 @@
let formData = {};
document.querySelectorAll(".quantityCustomizer").forEach(e => {
const materialID = e.dataset.materialid;
const mixID = e.dataset.mixid;
const materialId = e.dataset.materialid;
const mixId = e.dataset.mixid;
if (formData[mixID] === undefined) {
formData[mixID] = {};
if (formData[mixId] === undefined) {
formData[mixId] = {};
}
formData[mixID][materialID] = e.dataset.quantityml;
formData[mixId][materialId] = e.dataset.quantityml;
});
clearNotEnoughClasses();
@ -324,14 +324,14 @@
let formData = {};
e.parentElement.parentElement.querySelectorAll(".quantityCustomizer").forEach(elem => {
const materialID = elem.getAttribute("data-materialID");
const mixID = elem.getAttribute("data-mixID");
const materialId = elem.getAttribute("data-materialId");
const mixId = elem.getAttribute("data-mixId");
if (formData[mixID] === undefined) {
formData[mixID] = {};
if (formData[mixId] === undefined) {
formData[mixId] = {};
}
formData[mixID][materialID] = elem.dataset.quantityml;
formData[mixId][materialId] = elem.dataset.quantityml;
});
clearNotEnoughClasses();
@ -363,10 +363,10 @@
function displayNotEnoughReason(reason) {
const splitReason = reason.split("-");
const mixID = splitReason[0];
const materialID = splitReason[1];
const mixId = splitReason[0];
const materialId = splitReason[1];
document.querySelector(`#mix-${mixID}`).querySelector(`#material-${materialID}`).classList.add("notEnough");
document.querySelector(`#mix-${mixId}`).querySelector(`#material-${materialId}`).classList.add("notEnough");
}
function hideQuantities(button) {
@ -431,11 +431,11 @@
let lastQuantity = 0;
parent.querySelectorAll(".quantityCustomizer").forEach(e => {
const materialID = e.dataset.materialid;
const mixID = e.dataset.mixid;
const materialId = e.dataset.materialid;
const mixId = e.dataset.mixid;
const quantity = e.dataset.usepercentages === "true" ? round(convertMlToUnit(e.dataset.quantityml)) : round(e.value);
const p = parent.querySelector(`.calculation[data-materialid='${materialID}'][data-mixid='${mixID}']`);
const p = parent.querySelector(`.calculation[data-materialid='${materialId}'][data-mixid='${mixId}']`);
let totalQuantity = round(lastQuantity + parseFloat(quantity));
p.dataset.quantity = quantity;
@ -472,9 +472,9 @@
const labelPath = dataFolder + "/Couleur.lbx";
console.log(labelPath);
const recipeCode = "[[${recipe.recipeCode}]]";
const banner = "[[${recipe.company.companyName}]]";
const baseMaterial = "[[${recipe.getBase().materialCode}]]";
const recipeCode = "[[${recipe.name}]]";
const banner = "[[${recipe.company.name}]]";
const baseMaterial = "[[${recipe.getBase().name}]]";
async function print(mix) {
if (!document.querySelector(".bpac-extension-installed")) {
@ -483,7 +483,7 @@
}
try {
const objDoc = bpac.IDocument;
const objDoc = bpac.Idocument;
await objDoc.Open("http://localhost:9090/lbx/Couleur.lbx");
const objColor = await objDoc.GetObject("color");

View File

@ -21,11 +21,11 @@
<div class="content recipesContainer">
<form th:action="@{/recipe/remover/}" class="requireAuth-remover" method="POST">
<div class="companyTab" th:if="${!recipeMap.empty}" th:each="company : ${recipeMap.keySet()}"
th:data-companyID="${company.companyID}">
<h2 class="companyTabTitle" th:data-companyName="${company.companyName}"
th:text="${company.companyName}"></h2>
th:data-companyId="${company.id}">
<h2 class="companyTabTitle" th:data-companyName="${company.name}"
th:text="${company.name}"></h2>
<table style="display:none" th:id="'recipes_' + ${company.companyName}" class="recipesList"
<table style="display:none" th:id="'recipes_' + ${company.name}" class="recipesList"
th:if="${!recipeMap.get(company).empty}">
<tr>
<th th:text="#{recipe.color}"></th>
@ -34,13 +34,13 @@
<th></th>
</tr>
<tr class="recipeRow" th:each="recipe : ${recipeMap.get(company)}"
th:data-approbationDate="${recipe.approbationDate}" th:data-recipeID="${recipe.recipeID}">
<td class="descriptionCell" th:text="${recipe.recipeCode}"></td>
<td class="descriptionCell recipeDescription" th:text="${recipe.recipeDescription}"></td>
th:data-approbationDate="${recipe.approbationDate}" th:data-recipeId="${recipe.id}">
<td class="descriptionCell" th:text="${recipe.name}"></td>
<td class="descriptionCell recipeDescription" th:text="${recipe.description}"></td>
<td class="descriptionCell" th:text="'#' + ${recipe.sample}"></td>
<td>
<button class="remover" th:data-code="${recipe.recipeCode}"
th:data-entityid="${recipe.recipeID}" type="button"
<button class="remover" th:data-code="${recipe.name}"
th:data-entityid="${recipe.id}" type="button"
th:text="#{keyword.delete}"></button>
</td>
</tr>

View File

@ -40,7 +40,7 @@ public class CompanyServiceTests {
MockitoAnnotations.initMocks(this);
testCompany = new Company("Test Company");
testCompany.setCompanyID(0);
testCompany.setCompanyId(0);
testCompany2 = new Company("Test Company 2");
testCompany.setCompanyID(1);
@ -53,7 +53,7 @@ public class CompanyServiceTests {
@Test
public void isValidForCreationTestShouldBeTrue() {
// Arrange
when(companyService.existsByName(testCompany.getCompanyName())).thenReturn(false);
when(companyService.existsByName(testCompany.getName())).thenReturn(false);
when(companyService.exists(testCompany)).thenReturn(false);
// Act
@ -66,7 +66,7 @@ public class CompanyServiceTests {
@Test
public void isValidForCreationTestShouldBeFalse() {
// Arrange
when(companyService.existsByName(testCompany.getCompanyName())).thenReturn(true);
when(companyService.existsByName(testCompany.getName())).thenReturn(true);
when(companyService.exists(testCompany)).thenReturn(true);
// Act
@ -79,7 +79,7 @@ public class CompanyServiceTests {
@Test
public void isValidForCreationTestExists() {
// Arrange
when(companyService.existsByName(testCompany.getCompanyName())).thenReturn(false);
when(companyService.existsByName(testCompany.getName())).thenReturn(false);
when(companyService.exists(testCompany)).thenReturn(true);
// Act
@ -92,7 +92,7 @@ public class CompanyServiceTests {
@Test
public void isValidForCreationTestNameExists() {
// Arrange
when(companyService.existsByName(testCompany.getCompanyName())).thenReturn(true);
when(companyService.existsByName(testCompany.getName())).thenReturn(true);
when(companyService.exists(testCompany)).thenReturn(false);
// Act
@ -114,10 +114,10 @@ public class CompanyServiceTests {
@Test
public void existsByNameTestShouldBeTrue() {
// Arrange
when(companyDao.existsByCompanyName(testCompany.getCompanyName())).thenReturn(true);
when(companyDao.existsByCompanyName(testCompany.getName())).thenReturn(true);
// Act
boolean actual = companyService.existsByName(testCompany.getCompanyName());
boolean actual = companyService.existsByName(testCompany.getName());
// Assert
assertTrue(actual);
@ -126,10 +126,10 @@ public class CompanyServiceTests {
@Test
public void existsByNameTestShouldBeFalse() {
// Arrange
when(companyDao.existsByCompanyName(testCompany.getCompanyName())).thenReturn(false);
when(companyDao.existsByCompanyName(testCompany.getName())).thenReturn(false);
// Act
boolean actual = companyService.existsByName(testCompany.getCompanyName());
boolean actual = companyService.existsByName(testCompany.getName());
// Assert
assertFalse(actual);

View File

@ -42,7 +42,7 @@ public class MaterialServiceTests {
testMaterial = new Material();
testMaterial.setMaterialID(0);
testMaterial.setMaterialCode("Test Material");
testMaterial.setName("Test Material");
testMaterialType = new MaterialType();
testMaterialType.setMaterialTypeID(0);
@ -180,7 +180,7 @@ public class MaterialServiceTests {
public void existsTestShouldBeTrue() {
// Arrange
doReturn(true).when((GenericService<Material, MaterialDao>) materialService).exists(testMaterial);
doReturn(true).when(materialDao).existsByMaterialCode(testMaterial.getMaterialCode());
doReturn(true).when(materialDao).existsByMaterialCode(testMaterial.getName());
// Act
boolean actual = materialService.exists(testMaterial);
@ -193,7 +193,7 @@ public class MaterialServiceTests {
public void existsTestShouldBeFalse() {
// Arrange
doReturn(false).when((GenericService<Material, MaterialDao>) materialService).exists(testMaterial);
doReturn(false).when(materialDao).existsByMaterialCode(testMaterial.getMaterialCode());
doReturn(false).when(materialDao).existsByMaterialCode(testMaterial.getName());
// Act
boolean actual = materialService.exists(testMaterial);
@ -205,7 +205,7 @@ public class MaterialServiceTests {
@Test
public void existsTestShouldBeTrueOneConditionMet() {
// Arrange
doReturn(true).when(materialDao).existsByMaterialCode(testMaterial.getMaterialCode());
doReturn(true).when(materialDao).existsByMaterialCode(testMaterial.getName());
// Act
boolean actual = materialService.exists(testMaterial);
@ -229,7 +229,7 @@ public class MaterialServiceTests {
@Test
public void isValidForUpdateTestShouldBeTrue() {
// Arrange
doReturn(null).when(materialDao).findByMaterialCode(testMaterial.getMaterialCode());
doReturn(null).when(materialDao).findByMaterialCode(testMaterial.getName());
doReturn(true).when((GenericService<Material, MaterialDao>) materialService).isValidForUpdate(testMaterial);
// Act
@ -242,7 +242,7 @@ public class MaterialServiceTests {
@Test
public void isValidForUpdateTestShouldBeTrueMaterialCodeExistsWithSameId() {
// Arrange
doReturn(testMaterial).when(materialDao).findByMaterialCode(testMaterial.getMaterialCode());
doReturn(testMaterial).when(materialDao).findByMaterialCode(testMaterial.getName());
doReturn(true).when((GenericService<Material, MaterialDao>) materialService).isValidForUpdate(testMaterial);
// Act
@ -255,7 +255,7 @@ public class MaterialServiceTests {
@Test
public void isValidForUpdateTestShouldBeFalse() {
// Arrange
doReturn(testMaterial).when(materialDao).findByMaterialCode(testMaterial.getMaterialCode());
doReturn(testMaterial).when(materialDao).findByMaterialCode(testMaterial.getName());
doReturn(false).when((GenericService<Material, MaterialDao>) materialService).isValidForUpdate(testMaterial);
// Act
@ -269,10 +269,10 @@ public class MaterialServiceTests {
public void isValidForUpdateTestShouldBeFalseMaterialCodeExists() {
// Arrange
Material otherMaterial = new Material();
otherMaterial.setMaterialCode(testMaterial.getMaterialCode());
otherMaterial.setName(testMaterial.getName());
otherMaterial.setMaterialID(1);
doReturn(otherMaterial).when(materialDao).findByMaterialCode(testMaterial.getMaterialCode());
doReturn(otherMaterial).when(materialDao).findByMaterialCode(testMaterial.getName());
// Act
boolean actual = materialService.isValidForUpdate(testMaterial);
@ -284,7 +284,7 @@ public class MaterialServiceTests {
@Test
public void isValidForUpdateShouldNull() {
// Arrange
doReturn(testMaterial).when(materialDao).findByMaterialCode(testMaterial.getMaterialCode());
doReturn(testMaterial).when(materialDao).findByMaterialCode(testMaterial.getName());
// Act
boolean actual = materialService.isValidForUpdate(null);
@ -296,10 +296,10 @@ public class MaterialServiceTests {
@Test
public void getAllBySearchStringTest() {
// Arrange
doReturn(testMaterialsList).when(materialDao).findAllByMaterialCodeContainingIgnoreCase(testMaterial.getMaterialCode());
doReturn(testMaterialsList).when(materialDao).findAllByMaterialCodeContainingIgnoreCase(testMaterial.getName());
// Act
List<Material> actual = materialService.getAllBySearchString(testMaterial.getMaterialCode());
List<Material> actual = materialService.getAllBySearchString(testMaterial.getName());
// Assert
assertTrue(actual.contains(testMaterial));
@ -308,10 +308,10 @@ public class MaterialServiceTests {
@Test
public void getAllBySearchStringTestShouldBeEmpty() {
// Arrange
doReturn(new ArrayList<>()).when(materialDao).findAllByMaterialCodeContainingIgnoreCase(testMaterial.getMaterialCode());
doReturn(new ArrayList<>()).when(materialDao).findAllByMaterialCodeContainingIgnoreCase(testMaterial.getName());
// Act
List<Material> actual = materialService.getAllBySearchString(testMaterial.getMaterialCode());
List<Material> actual = materialService.getAllBySearchString(testMaterial.getName());
// Assert
assertTrue(actual.isEmpty());
@ -322,15 +322,15 @@ public class MaterialServiceTests {
// Arrange
Material mixTypeMaterial = new Material();
mixTypeMaterial.setMaterialID(2);
mixTypeMaterial.setMaterialCode("Mix Type");
mixTypeMaterial.setName("Mix Type");
mixTypeMaterial.setMixType(true);
testMaterialsList.add(mixTypeMaterial);
doReturn(testMaterialsList).when(materialDao).findAllByMaterialCodeContainingIgnoreCase(mixTypeMaterial.getMaterialCode());
doReturn(testMaterialsList).when(materialDao).findAllByMaterialCodeContainingIgnoreCase(mixTypeMaterial.getName());
// Act
List<Material> actual = materialService.getAllBySearchString(mixTypeMaterial.getMaterialCode());
List<Material> actual = materialService.getAllBySearchString(mixTypeMaterial.getName());
// Assert
assertFalse(actual.contains(mixTypeMaterial));

View File

@ -45,7 +45,7 @@ public class MaterialTypeServiceTests {
testMaterial = new Material();
testMaterial.setMaterialID(0);
testMaterial.setMaterialCode("Test Material");
testMaterial.setName("Test Material");
}
@Test
@ -117,7 +117,7 @@ public class MaterialTypeServiceTests {
@Test
public void isValidForCreationTestShouldBeTrue() {
doReturn(false).when(materialTypeService).existsByName(testMaterialType.getMaterialTypeName());
doReturn(false).when(materialTypeService).existsByName(testMaterialType.getName());
boolean actual = materialTypeService.isValidForCreation(testMaterialType);
assertTrue(actual);
@ -125,7 +125,7 @@ public class MaterialTypeServiceTests {
@Test
public void isValidForCreationTestShouldBeFalse() {
doReturn(true).when(materialTypeService).existsByName(testMaterialType.getMaterialTypeName());
doReturn(true).when(materialTypeService).existsByName(testMaterialType.getName());
boolean actual = materialTypeService.isValidForCreation(testMaterialType);
assertFalse(actual);
@ -133,7 +133,7 @@ public class MaterialTypeServiceTests {
@Test
public void isValidForCreationTestNull() {
doReturn(false).when(materialTypeService).existsByName(testMaterialType.getMaterialTypeName());
doReturn(false).when(materialTypeService).existsByName(testMaterialType.getName());
boolean actual = materialTypeService.isValidForCreation(null);
assertFalse(actual);
@ -171,24 +171,24 @@ public class MaterialTypeServiceTests {
@Test
public void getByNameTest() {
doReturn(Optional.of(testMaterialType)).when(materialTypeDao).findByMaterialTypeName(testMaterialType.getMaterialTypeName());
doReturn(Optional.of(testMaterialType)).when(materialTypeDao).findByMaterialTypeName(testMaterialType.getName());
Optional<MaterialType> actual = materialTypeService.getByName(testMaterialType.getMaterialTypeName());
Optional<MaterialType> actual = materialTypeService.getByName(testMaterialType.getName());
assertTrue(actual.isPresent());
assertEquals(testMaterialType.getMaterialTypeName(), actual.get().getMaterialTypeName());
assertEquals(testMaterialType.getName(), actual.get().getName());
}
@Test
public void getByNameTestShouldBeEmpty() {
doReturn(Optional.empty()).when(materialTypeDao).findByMaterialTypeName(testMaterialType.getMaterialTypeName());
doReturn(Optional.empty()).when(materialTypeDao).findByMaterialTypeName(testMaterialType.getName());
Optional<MaterialType> actual = materialTypeService.getByName(testMaterialType.getMaterialTypeName());
Optional<MaterialType> actual = materialTypeService.getByName(testMaterialType.getName());
assertFalse(actual.isPresent());
}
@Test
public void getByNameTestNull() {
doReturn(Optional.empty()).when(materialTypeDao).findByMaterialTypeName(testMaterialType.getMaterialTypeName());
doReturn(Optional.empty()).when(materialTypeDao).findByMaterialTypeName(testMaterialType.getName());
Optional<MaterialType> actual = materialTypeService.getByName(null);
assertFalse(actual.isPresent());
@ -213,17 +213,17 @@ public class MaterialTypeServiceTests {
@Test
public void existsByNameTestShouldBeTrue() {
doReturn(Optional.of(testMaterialType)).when(materialTypeService).getByName(testMaterialType.getMaterialTypeName());
doReturn(Optional.of(testMaterialType)).when(materialTypeService).getByName(testMaterialType.getName());
boolean actual = materialTypeService.existsByName(testMaterialType.getMaterialTypeName());
boolean actual = materialTypeService.existsByName(testMaterialType.getName());
assertTrue(actual);
}
@Test
public void existsByNameTestShouldBeFalse() {
doReturn(Optional.empty()).when(materialTypeService).getByName(testMaterialType.getMaterialTypeName());
doReturn(Optional.empty()).when(materialTypeService).getByName(testMaterialType.getName());
boolean actual = materialTypeService.existsByName(testMaterialType.getMaterialTypeName());
boolean actual = materialTypeService.existsByName(testMaterialType.getName());
assertFalse(actual);
}

View File

@ -31,7 +31,7 @@ public class MixQuantityServiceTests {
testMaterial = new Material();
testMaterial.setMaterialID(0);
testMaterial.setMaterialCode("Test Material");
testMaterial.setName("Test Material");
}
@Test

View File

@ -32,11 +32,11 @@ public class MixServiceTests {
MockitoAnnotations.initMocks(this);
Recipe recipe = new Recipe();
recipe.setRecipeID(0);
recipe.setRecipeCode("Test Recipe");
recipe.setRecipeId(0);
recipe.setName("Test Recipe");
testMix = new Mix();
testMix.setMixID(0);
testMix.setMixId(0);
testMix.setRecipe(recipe);
}
@ -49,7 +49,7 @@ public class MixServiceTests {
// mquantities.add(new MixQuantity());
// quantities.add(1000f);
// MixType type = new MixType();
// type.setTypeName("Test Type");
// type.setName("Test Type");
//
// doReturn(Optional.of(testMix)).when(mixService).save(any());
// doReturn(mquantities).when(mixService).createMixQuantities(any(), any(), any());
@ -68,7 +68,7 @@ public class MixServiceTests {
// mquantities.add(new MixQuantity());
// quantities.add(1000f);
// MixType type = new MixType();
// type.setTypeName("Test Type");
// type.setName("Test Type");
//
// doReturn(Optional.of(testMix)).when(mixService).save(any());
// doReturn(mquantities).when(mixService).createMixQuantities(any(), any(), any());

View File

@ -42,11 +42,11 @@ public class MixTypeServiceTests {
testMaterial = new Material();
testMaterial.setMaterialID(0);
testMaterial.setMaterialCode("Test Material");
testMaterial.setName("Test Material");
testMixType = new MixType();
testMixType.setTypeID(0);
testMixType.setTypeName("Test Type");
testMixType.setName("Test Type");
testMixType.setMaterial(testMaterial);
testMaterialType = new MaterialType();
@ -56,17 +56,17 @@ public class MixTypeServiceTests {
@Test
public void getByNameTest() {
doReturn(Optional.of(testMixType)).when(mixTypeDao).findByTypeName(testMixType.getTypeName());
doReturn(Optional.of(testMixType)).when(mixTypeDao).findByTypeName(testMixType.getName());
Optional<MixType> actual = mixTypeService.getByName(testMixType.getTypeName());
Optional<MixType> actual = mixTypeService.getByName(testMixType.getName());
assertTrue(actual.isPresent());
}
@Test
public void getByNameTestShouldBeEmpty() {
doReturn(Optional.empty()).when(mixTypeDao).findByTypeName(testMixType.getTypeName());
doReturn(Optional.empty()).when(mixTypeDao).findByTypeName(testMixType.getName());
Optional<MixType> actual = mixTypeService.getByName(testMixType.getTypeName());
Optional<MixType> actual = mixTypeService.getByName(testMixType.getName());
assertFalse(actual.isPresent());
}
@ -106,9 +106,9 @@ public class MixTypeServiceTests {
public void createByNameTest() {
doReturn(Optional.of(testMaterialType)).when(materialTypeService).getDefaultMaterialType();
doReturn(Optional.of(testMixType)).when(mixTypeService).save(any());
doReturn(Optional.empty()).when(mixTypeService).getByName(testMixType.getTypeName());
doReturn(Optional.empty()).when(mixTypeService).getByName(testMixType.getName());
Optional<MixType> actual = mixTypeService.createByName(testMixType.getTypeName());
Optional<MixType> actual = mixTypeService.createByName(testMixType.getName());
assertTrue(actual.isPresent());
}
@ -116,9 +116,9 @@ public class MixTypeServiceTests {
public void createByNameTestExistsByName() {
doReturn(Optional.of(testMixType)).when(materialTypeService).getDefaultMaterialType();
doReturn(Optional.of(testMixType)).when(mixTypeService).save(any());
doReturn(Optional.of(testMixType)).when(mixTypeService).getByName(testMixType.getTypeName());
doReturn(Optional.of(testMixType)).when(mixTypeService).getByName(testMixType.getName());
Optional<MixType> actual = mixTypeService.createByName(testMixType.getTypeName());
Optional<MixType> actual = mixTypeService.createByName(testMixType.getName());
verify(mixTypeService, times(0)).save(any());
assertTrue(actual.isPresent());
}
@ -127,9 +127,9 @@ public class MixTypeServiceTests {
public void createByNameTestShouldBeEmpty() {
doReturn(Optional.empty()).when(materialTypeService).getDefaultMaterialType();
doReturn(Optional.empty()).when(mixTypeService).save(any());
doReturn(Optional.empty()).when(mixTypeService).getByName(testMixType.getTypeName());
doReturn(Optional.empty()).when(mixTypeService).getByName(testMixType.getName());
Optional<MixType> actual = mixTypeService.createByName(testMixType.getTypeName());
Optional<MixType> actual = mixTypeService.createByName(testMixType.getName());
assertFalse(actual.isPresent());
}

View File

@ -59,7 +59,7 @@ public class RecipeServiceTests {
testRecipe = new Recipe();
testRecipe.setRecipeID(Integer.MAX_VALUE);
testRecipe.setRecipeCode("Test Recipe");
testRecipe.setName("Test Recipe");
testRecipe.setCompany(testCompany);
Mix mix1 = new Mix();
@ -125,13 +125,13 @@ public class RecipeServiceTests {
// @Test
// public void getSortedMixesTest() {
//// doReturn(testMixesList).when(testRecipe).getRecipeMixes();
//// doReturn(testMixesList).when(testRecipe).getMixes();
// testRecipe.setRecipeMixes(testMixesList);
//
// List<Mix> actual = recipeService.getSortedMixes(testRecipe);
// assertFalse(actual.isEmpty());
// assertEquals(testMixesList.get(1).getMixID(), actual.get(0).getMixID());
// assertEquals(testMixesList.get(0).getMixID(), actual.get(1).getMixID());
// assertEquals(testMixesList.get(1).getId(), actual.get(0).getId());
// assertEquals(testMixesList.get(0).getId(), actual.get(1).getId());
// }
//
// @Test
@ -144,7 +144,7 @@ public class RecipeServiceTests {
//
// @Test
// public void getSortedMixesTestNull() {
// doReturn(new ArrayList<>()).when(testRecipe).getRecipeMixes();
// doReturn(new ArrayList<>()).when(testRecipe).getMixes();
//
// List<Mix> actual = recipeService.getSortedMixes(null);
// assertTrue(actual.isEmpty());