From c510665a1af092cdf18daee9367e2b4c11bc5407 Mon Sep 17 00:00:00 2001 From: Benjamin POCHAT Date: Thu, 15 Feb 2024 23:03:55 +0100 Subject: [PATCH] add missing attributes for beef production --- .../service/TestBeefProductionService.java | 2 +- .../test/resources/sql/create_test_data.sql | 6 +- .../viandeendirect/model/BeefProduction.java | 337 +++++++++++++++--- openapi/openapi.yml | 40 ++- 4 files changed, 334 insertions(+), 51 deletions(-) diff --git a/backend/app/src/test/java/eu/viandeendirect/service/TestBeefProductionService.java b/backend/app/src/test/java/eu/viandeendirect/service/TestBeefProductionService.java index c96e91d..9cd2ec1 100644 --- a/backend/app/src/test/java/eu/viandeendirect/service/TestBeefProductionService.java +++ b/backend/app/src/test/java/eu/viandeendirect/service/TestBeefProductionService.java @@ -36,7 +36,7 @@ void getBeefProduction_should_return_the_right_instance() { // then assertThat(beefProduction).isNotNull(); - assertThat(beefProduction.getAnimalLiveWeight()).isEqualTo(400); + assertThat(beefProduction.getWarmCarcassWeight()).isEqualTo(400); } @Test diff --git a/backend/app/src/test/resources/sql/create_test_data.sql b/backend/app/src/test/resources/sql/create_test_data.sql index eaebf04..0cb4859 100644 --- a/backend/app/src/test/resources/sql/create_test_data.sql +++ b/backend/app/src/test/resources/sql/create_test_data.sql @@ -72,21 +72,21 @@ values (1001, 'Un coli avec une majorité de steaks', 'Le coli cuisson rapide', -- PRODUCTIONS AND PACKAGE LOTS ----- ------------------------------------- -insert into beef_productions (id, production_type, producer_id, animal_identifier, animal_live_weight, animal_type, birth_date, birth_place, slaughter_date) +insert into beef_productions (id, production_type, producer_id, animal_identifier, warm_carcass_weight, animal_type, birth_date, birth_place, slaughter_date) values (1000, 1, 1000, '1234', '400', null, '2022-01-13', 'Béchy', '2023-12-25'); insert into package_lots (id, description, label, net_weight, photo, quantity, quantity_sold, unit_price, production_id) values (10000, 'Un coli avec un peu de tout', 'Le coli tradition', 10, null, 10, 2, 16, 1000); insert into package_lots (id, description, label, net_weight, photo, quantity, quantity_sold, unit_price, production_id) values (10001, 'Un coli avec une majorité de steaks', 'Le coli cuisson rapide', 7, null, 10, 3, 16, 1000); -insert into beef_productions (id, production_type, producer_id, animal_identifier, animal_live_weight, animal_type, birth_date, birth_place, slaughter_date) +insert into beef_productions (id, production_type, producer_id, animal_identifier, warm_carcass_weight, animal_type, birth_date, birth_place, slaughter_date) values (1001, 1, 1000, '2345', '350', null, '2020-02-13', 'Béchy', '2023-11-03'); insert into package_lots (id, description, label, net_weight, photo, quantity, quantity_sold, unit_price, production_id) values (10010, 'Un coli avec un peu de tout', 'Le coli tradition', 10, null, 12, 2, 16, 1001); insert into package_lots (id, description, label, net_weight, photo, quantity, quantity_sold, unit_price, production_id) values (10011, 'Un coli avec une majorité de steaks', 'Le coli cuisson rapide', 9, null, 10, 7, 16, 1001); -insert into beef_productions (id, production_type, producer_id, animal_identifier, animal_live_weight, animal_type, birth_date, birth_place, slaughter_date) +insert into beef_productions (id, production_type, producer_id, animal_identifier, warm_carcass_weight, animal_type, birth_date, birth_place, slaughter_date) values (2000, 1, 2000, '3456', '450', null, '2021-03-15', 'Gruffy', '2024-01-05'); insert into package_lots (id, description, label, net_weight, photo, quantity, quantity_sold, unit_price, production_id) values (20000, 'Un coli avec un peu de tout', 'Le coli tradition', 10, null, 7, 1, 16, 2000); diff --git a/backend/model/src/main/java/eu/viandeendirect/model/BeefProduction.java b/backend/model/src/main/java/eu/viandeendirect/model/BeefProduction.java index 8171bc6..7e8324c 100644 --- a/backend/model/src/main/java/eu/viandeendirect/model/BeefProduction.java +++ b/backend/model/src/main/java/eu/viandeendirect/model/BeefProduction.java @@ -48,9 +48,13 @@ public class BeefProduction extends Production { * type of animal */ public enum AnimalTypeEnum { - BEEFPRODUCTION("BeefProduction"), - - HONNEYPRODUCTION("HonneyProduction"); + COW("BEEF_COW"), + + HEIFER("BEEF_HEIFER"), + + BULL("BEEF_BULL"), + + VEAL("BEEF_VEAL"); private String value; @@ -82,12 +86,43 @@ public static AnimalTypeEnum fromValue(String value) { @JsonProperty("animalType") private AnimalTypeEnum animalType; - @JsonProperty("animalLiveWeight") - private Integer animalLiveWeight; + /** + * breed of the animal + */ + public enum CattleBreedEnum { + LIMOUSINE("LIMOUSINE"), - @JsonProperty("slaughterDate") - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) - private LocalDate slaughterDate; + CHAROLAISE("CHAROLAISE"); + + private String value; + + CattleBreedEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static CattleBreedEnum fromValue(String value) { + for (CattleBreedEnum b : CattleBreedEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + + @JsonProperty("cattleBreed") + private CattleBreedEnum cattleBreed; @JsonProperty("birthDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) @@ -96,6 +131,37 @@ public static AnimalTypeEnum fromValue(String value) { @JsonProperty("birthPlace") private String birthPlace; + @JsonProperty("birthFarm") + private String birthFarm; + + @JsonProperty("warmCarcassWeight") + private Integer warmCarcassWeight; + + @JsonProperty("meatWeight") + private Integer meatWeight; + + @JsonProperty("slaughterDate") + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) + private LocalDate slaughterDate; + + @JsonProperty("slaughterPlace") + private String slaughterPlace; + + @JsonProperty("slaughterHouse") + private String slaughterHouse; + + @JsonProperty("cuttingDate") + private String cuttingDate; + + @JsonProperty("cuttingPlace") + private String cuttingPlace; + + @JsonProperty("cuttingButcher") + private String cuttingButcher; + + @JsonProperty("labelRougeCertified") + private Boolean labelRougeCertified; + public BeefProduction animalIdentifier(String animalIdentifier) { this.animalIdentifier = animalIdentifier; return this; @@ -134,42 +200,23 @@ public void setAnimalType(AnimalTypeEnum animalType) { this.animalType = animalType; } - public BeefProduction animalLiveWeight(Integer animalLiveWeight) { - this.animalLiveWeight = animalLiveWeight; + public BeefProduction cattleBreed(CattleBreedEnum cattleBreed) { + this.cattleBreed = cattleBreed; return this; } /** - * weight of the animal before being killed, in kilograms - * @return animalLiveWeight + * breed of the animal + * @return cattleBreed */ - @Schema(name = "animalLiveWeight", description = "weight of the animal before being killed, in kilograms", required = false) - public Integer getAnimalLiveWeight() { - return animalLiveWeight; - } - - public void setAnimalLiveWeight(Integer animalLiveWeight) { - this.animalLiveWeight = animalLiveWeight; - } - - public BeefProduction slaughterDate(LocalDate slaughterDate) { - this.slaughterDate = slaughterDate; - return this; - } - - /** - * date when the animal has being killed - * @return slaughterDate - */ - @Valid - @Schema(name = "slaughterDate", description = "date when the animal has being killed", required = false) - public LocalDate getSlaughterDate() { - return slaughterDate; + @Schema(name = "cattleBreed", description = "breed of the animal", required = false) + public CattleBreedEnum getCattleBreed() { + return cattleBreed; } - public void setSlaughterDate(LocalDate slaughterDate) { - this.slaughterDate = slaughterDate; + public void setCattleBreed(CattleBreedEnum cattleBreed) { + this.cattleBreed = cattleBreed; } public BeefProduction birthDate(LocalDate birthDate) { @@ -210,6 +257,196 @@ public void setBirthPlace(String birthPlace) { this.birthPlace = birthPlace; } + public BeefProduction birthFarm(String birthFarm) { + this.birthFarm = birthFarm; + return this; + } + + /** + * farming company where the animal is born + * @return birthFarm + */ + + @Schema(name = "birthFarm", description = "farming company where the animal is born", required = false) + public String getBirthFarm() { + return birthFarm; + } + + public void setBirthFarm(String birthFarm) { + this.birthFarm = birthFarm; + } + + public BeefProduction warmCarcassWeight(Integer warmCarcassWeight) { + this.warmCarcassWeight = warmCarcassWeight; + return this; + } + + /** + * weight of the animal just after being killed, in kilograms + * @return warmCarcassWeight + */ + + @Schema(name = "warmCarcassWeight", description = "weight of the animal just after being killed, in kilograms", required = false) + public Integer getWarmCarcassWeight() { + return warmCarcassWeight; + } + + public void setWarmCarcassWeight(Integer warmCarcassWeight) { + this.warmCarcassWeight = warmCarcassWeight; + } + + public BeefProduction meatWeight(Integer meatWeight) { + this.meatWeight = meatWeight; + return this; + } + + /** + * weight of meat predicted, in kilograms + * @return meatWeight + */ + + @Schema(name = "meatWeight", description = "weight of meat predicted, in kilograms", required = false) + public Integer getMeatWeight() { + return meatWeight; + } + + public void setMeatWeight(Integer meatWeight) { + this.meatWeight = meatWeight; + } + + public BeefProduction slaughterDate(LocalDate slaughterDate) { + this.slaughterDate = slaughterDate; + return this; + } + + /** + * date when the animal has been killed + * @return slaughterDate + */ + @Valid + @Schema(name = "slaughterDate", description = "date when the animal has been killed", required = false) + public LocalDate getSlaughterDate() { + return slaughterDate; + } + + public void setSlaughterDate(LocalDate slaughterDate) { + this.slaughterDate = slaughterDate; + } + + public BeefProduction slaughterPlace(String slaughterPlace) { + this.slaughterPlace = slaughterPlace; + return this; + } + + /** + * the place where the animal has been killed + * @return slaughterPlace + */ + + @Schema(name = "slaughterPlace", description = "the place where the animal has been killed", required = false) + public String getSlaughterPlace() { + return slaughterPlace; + } + + public void setSlaughterPlace(String slaughterPlace) { + this.slaughterPlace = slaughterPlace; + } + + public BeefProduction slaughterHouse(String slaughterHouse) { + this.slaughterHouse = slaughterHouse; + return this; + } + + /** + * the company where the animal has been killed + * @return slaughterHouse + */ + + @Schema(name = "slaughterHouse", description = "the company where the animal has been killed", required = false) + public String getSlaughterHouse() { + return slaughterHouse; + } + + public void setSlaughterHouse(String slaughterHouse) { + this.slaughterHouse = slaughterHouse; + } + + public BeefProduction cuttingDate(String cuttingDate) { + this.cuttingDate = cuttingDate; + return this; + } + + /** + * date when the animal has been cutted + * @return cuttingDate + */ + + @Schema(name = "cuttingDate", description = "date when the animal has been cutted", required = false) + public String getCuttingDate() { + return cuttingDate; + } + + public void setCuttingDate(String cuttingDate) { + this.cuttingDate = cuttingDate; + } + + public BeefProduction cuttingPlace(String cuttingPlace) { + this.cuttingPlace = cuttingPlace; + return this; + } + + /** + * the place where the animal has been cutted + * @return cuttingPlace + */ + + @Schema(name = "cuttingPlace", description = "the place where the animal has been cutted", required = false) + public String getCuttingPlace() { + return cuttingPlace; + } + + public void setCuttingPlace(String cuttingPlace) { + this.cuttingPlace = cuttingPlace; + } + + public BeefProduction cuttingButcher(String cuttingButcher) { + this.cuttingButcher = cuttingButcher; + return this; + } + + /** + * butcher company where the animal has been cutted + * @return cuttingButcher + */ + + @Schema(name = "cuttingButcher", description = "butcher company where the animal has been cutted", required = false) + public String getCuttingButcher() { + return cuttingButcher; + } + + public void setCuttingButcher(String cuttingButcher) { + this.cuttingButcher = cuttingButcher; + } + + public BeefProduction labelRougeCertified(Boolean labelRougeCertified) { + this.labelRougeCertified = labelRougeCertified; + return this; + } + + /** + * true if the animal breeding process matches the french 'label rouge certification + * @return labelRougeCertified + */ + + @Schema(name = "labelRougeCertified", description = "true if the animal breeding process matches the french 'label rouge certification", required = false) + public Boolean getLabelRougeCertified() { + return labelRougeCertified; + } + + public void setLabelRougeCertified(Boolean labelRougeCertified) { + this.labelRougeCertified = labelRougeCertified; + } + public BeefProduction id(Integer id) { super.setId(id); return this; @@ -256,16 +493,25 @@ public boolean equals(Object o) { BeefProduction beefProduction = (BeefProduction) o; return Objects.equals(this.animalIdentifier, beefProduction.animalIdentifier) && Objects.equals(this.animalType, beefProduction.animalType) && - Objects.equals(this.animalLiveWeight, beefProduction.animalLiveWeight) && - Objects.equals(this.slaughterDate, beefProduction.slaughterDate) && + Objects.equals(this.cattleBreed, beefProduction.cattleBreed) && Objects.equals(this.birthDate, beefProduction.birthDate) && Objects.equals(this.birthPlace, beefProduction.birthPlace) && + Objects.equals(this.birthFarm, beefProduction.birthFarm) && + Objects.equals(this.warmCarcassWeight, beefProduction.warmCarcassWeight) && + Objects.equals(this.meatWeight, beefProduction.meatWeight) && + Objects.equals(this.slaughterDate, beefProduction.slaughterDate) && + Objects.equals(this.slaughterPlace, beefProduction.slaughterPlace) && + Objects.equals(this.slaughterHouse, beefProduction.slaughterHouse) && + Objects.equals(this.cuttingDate, beefProduction.cuttingDate) && + Objects.equals(this.cuttingPlace, beefProduction.cuttingPlace) && + Objects.equals(this.cuttingButcher, beefProduction.cuttingButcher) && + Objects.equals(this.labelRougeCertified, beefProduction.labelRougeCertified) && super.equals(o); } @Override public int hashCode() { - return Objects.hash(animalIdentifier, animalType, animalLiveWeight, slaughterDate, birthDate, birthPlace, super.hashCode()); + return Objects.hash(animalIdentifier, animalType, cattleBreed, birthDate, birthPlace, birthFarm, warmCarcassWeight, meatWeight, slaughterDate, slaughterPlace, slaughterHouse, cuttingDate, cuttingPlace, cuttingButcher, labelRougeCertified, super.hashCode()); } @Override @@ -275,10 +521,19 @@ public String toString() { sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" animalIdentifier: ").append(toIndentedString(animalIdentifier)).append("\n"); sb.append(" animalType: ").append(toIndentedString(animalType)).append("\n"); - sb.append(" animalLiveWeight: ").append(toIndentedString(animalLiveWeight)).append("\n"); - sb.append(" slaughterDate: ").append(toIndentedString(slaughterDate)).append("\n"); + sb.append(" cattleBreed: ").append(toIndentedString(cattleBreed)).append("\n"); sb.append(" birthDate: ").append(toIndentedString(birthDate)).append("\n"); sb.append(" birthPlace: ").append(toIndentedString(birthPlace)).append("\n"); + sb.append(" birthFarm: ").append(toIndentedString(birthFarm)).append("\n"); + sb.append(" warmCarcassWeight: ").append(toIndentedString(warmCarcassWeight)).append("\n"); + sb.append(" meatWeight: ").append(toIndentedString(meatWeight)).append("\n"); + sb.append(" slaughterDate: ").append(toIndentedString(slaughterDate)).append("\n"); + sb.append(" slaughterPlace: ").append(toIndentedString(slaughterPlace)).append("\n"); + sb.append(" slaughterHouse: ").append(toIndentedString(slaughterHouse)).append("\n"); + sb.append(" cuttingDate: ").append(toIndentedString(cuttingDate)).append("\n"); + sb.append(" cuttingPlace: ").append(toIndentedString(cuttingPlace)).append("\n"); + sb.append(" cuttingButcher: ").append(toIndentedString(cuttingButcher)).append("\n"); + sb.append(" labelRougeCertified: ").append(toIndentedString(labelRougeCertified)).append("\n"); sb.append("}"); return sb.toString(); } diff --git a/openapi/openapi.yml b/openapi/openapi.yml index d4cb8ee..faaf9b4 100644 --- a/openapi/openapi.yml +++ b/openapi/openapi.yml @@ -588,13 +588,10 @@ components: description: "type of animal" type: string enum: ['BEEF_COW', 'BEEF_HEIFER', 'BEEF_BULL', 'BEEF_VEAL'] - animalLiveWeight: - description: "weight of the animal before being killed, in kilograms" - type: integer - slaughterDate: - description: "date when the animal has being killed" + cattleBreed: + description: "breed of the animal" type: string - format: date + enum: ['LIMOUSINE', 'CHAROLAISE'] birthDate: description: "date when the animal is born" type: string @@ -602,6 +599,37 @@ components: birthPlace: description: "place where the animal is born" type: string + birthFarm: + description: "farming company where the animal is born" + type: string + warmCarcassWeight: + description: "weight of the animal just after being killed, in kilograms" + type: integer + meatWeight: + description: "weight of meat predicted, in kilograms" + type: integer + slaughterDate: + description: "date when the animal has been killed" + type: string + format: date + slaughterPlace: + description: "the place where the animal has been killed" + type: string + slaughterHouse: + description: "the company where the animal has been killed" + type: string + cuttingDate: + description: "date when the animal has been cutted" + type: string + cuttingPlace: + description: "the place where the animal has been cutted" + type: string + cuttingButcher: + description: "butcher company where the animal has been cutted" + type: string + labelRougeCertified: + description: "true if the animal breeding process matches the french 'label rouge certification" + type: boolean x-class-extra-annotation: '@jakarta.persistence.Entity @jakarta.persistence.Table(name = "beef_productions")' HonneyProduction: allOf: