From ebb603b5694d8ec429b116c6a9c7ce620a83ab41 Mon Sep 17 00:00:00 2001 From: Jottyfan Date: Mon, 2 Dec 2024 22:58:28 +0100 Subject: [PATCH] basic extensions --- build.gradle | 4 +- .../modules/camp/RegistrationController.java | 5 +- .../modules/camp/RegistrationRepository.java | 42 +++- .../modules/camp/RegistrationService.java | 10 + .../modules/camp/model/RegistrationBean.java | 212 ++++++++++++++++++ src/main/resources/templates/camp/edit.html | 43 ++++ .../templates/camp/registration.html | 55 +++++ 7 files changed, 364 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index 6711840..7a86f59 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group = 'de.jottyfan.bico' -version = '0.1.6' +version = '0.1.7' description = """BibleClassOrganizer""" @@ -47,7 +47,7 @@ war { } dependencies { - implementation 'de.jottyfan:bicolib:5' + implementation 'de.jottyfan:bicolib:6' implementation 'org.mnode.ical4j:ical4j:4.0.4' diff --git a/src/main/java/de/jottyfan/bico/modules/camp/RegistrationController.java b/src/main/java/de/jottyfan/bico/modules/camp/RegistrationController.java index 09cd1a0..2389194 100644 --- a/src/main/java/de/jottyfan/bico/modules/camp/RegistrationController.java +++ b/src/main/java/de/jottyfan/bico/modules/camp/RegistrationController.java @@ -31,8 +31,9 @@ public class RegistrationController extends CommonController { @GetMapping("/camp/registration") public String loadForm(Model model, Principal principal) { model.addAttribute("registrations", service.getRegistrations(principal)); - model.addAttribute("bean", new RegistrationBean()); + model.addAttribute("bean", RegistrationBean.withAllDays()); model.addAttribute("sexes", EnumSex.values()); + model.addAttribute("ages", service.getAges()); return "/camp/registration"; } @@ -42,6 +43,7 @@ public class RegistrationController extends CommonController { if (bindingResult.hasErrors()) { model.addAttribute("registrations", new ArrayList()); // hack to make "Neue Anmeldung" appear model.addAttribute("sexes", EnumSex.values()); + model.addAttribute("ages", service.getAges()); return "/camp/registration"; } service.save(bean, principal); @@ -52,6 +54,7 @@ public class RegistrationController extends CommonController { public String loadEditForm(@PathVariable("id") Integer id, Model model, Principal principal) { model.addAttribute("bean", service.getBeanOfPrincipal(id, principal)); model.addAttribute("sexes", EnumSex.values()); + model.addAttribute("ages", service.getAges()); return "/camp/edit"; } diff --git a/src/main/java/de/jottyfan/bico/modules/camp/RegistrationRepository.java b/src/main/java/de/jottyfan/bico/modules/camp/RegistrationRepository.java index 8a0b3ad..ed49cfc 100644 --- a/src/main/java/de/jottyfan/bico/modules/camp/RegistrationRepository.java +++ b/src/main/java/de/jottyfan/bico/modules/camp/RegistrationRepository.java @@ -1,13 +1,15 @@ package de.jottyfan.bico.modules.camp; +import static de.jottyfan.bico.db.camp.Tables.T_AGE; import static de.jottyfan.bico.db.camp.Tables.T_REGISTRATION; import java.util.List; import org.jooq.DSLContext; import org.jooq.DeleteConditionStep; -import org.jooq.InsertValuesStep5; +import org.jooq.InsertValuesStep12; import org.jooq.SelectConditionStep; +import org.jooq.SelectSeekStep1; import org.jooq.UpdateConditionStep; import org.jooq.impl.DSL; import org.springframework.beans.factory.annotation.Autowired; @@ -16,6 +18,7 @@ import org.springframework.stereotype.Repository; import de.jottyfan.bico.Main; import de.jottyfan.bico.db.camp.enums.EnumCamp; import de.jottyfan.bico.db.camp.enums.EnumSex; +import de.jottyfan.bico.db.camp.tables.records.TAgeRecord; import de.jottyfan.bico.db.camp.tables.records.TRegistrationRecord; import de.jottyfan.bico.modules.camp.model.RegistrationBean; import jakarta.validation.Valid; @@ -39,15 +42,24 @@ public class RegistrationRepository { public void save(@Valid RegistrationBean bean, String registrator) { jooq.transaction(t -> { if (bean.getPkRegistration() == null) { - InsertValuesStep5 sql = DSL.using(t) + InsertValuesStep12 sql = DSL.using(t) // @formatter:off .insertInto(T_REGISTRATION, T_REGISTRATION.CAMP, T_REGISTRATION.REGISTRATOR, T_REGISTRATION.FORENAME, T_REGISTRATION.SURNAME, - T_REGISTRATION.SEX) - .values(EnumCamp.Gemeindefreizeit_2025, registrator, bean.getForename(), bean.getSurname(), EnumSex.lookupLiteral(bean.getSex())); + T_REGISTRATION.SEX, + T_REGISTRATION.BARRIER_FREE, + T_REGISTRATION.NUTRITION, + T_REGISTRATION.DRIVER_PROVIDE_PLACES, + T_REGISTRATION.WANT_PLACE_IN_CAR, + T_REGISTRATION.DISEASES, + T_REGISTRATION.REQUIRE_PAYMENT, + T_REGISTRATION.FK_AGE) + .values(EnumCamp.Gemeindefreizeit_2025, registrator, bean.getForename(), bean.getSurname(), EnumSex.lookupLiteral(bean.getSex()), + bean.getBarrierFree(), bean.getNutrition(), bean.getDriverProvidePlaces(), bean.getWantPlaceInCar(), bean.getDiseases(), bean.getRequirePayment(), + bean.getFkAge()); // @formatter:on Main.LOGGER.trace(sql); sql.execute(); @@ -59,6 +71,13 @@ public class RegistrationRepository { .set(T_REGISTRATION.SURNAME, bean.getSurname()) .set(T_REGISTRATION.SEX, EnumSex.lookupLiteral(bean.getSex())) .set(T_REGISTRATION.REGISTRATOR, registrator) + .set(T_REGISTRATION.BARRIER_FREE, bean.getBarrierFree()) + .set(T_REGISTRATION.NUTRITION, bean.getNutrition()) + .set(T_REGISTRATION.DRIVER_PROVIDE_PLACES, bean.getDriverProvidePlaces()) + .set(T_REGISTRATION.WANT_PLACE_IN_CAR, bean.getWantPlaceInCar()) + .set(T_REGISTRATION.DISEASES, bean.getDiseases()) + .set(T_REGISTRATION.REQUIRE_PAYMENT, bean.getRequirePayment()) + .set(T_REGISTRATION.FK_AGE, bean.getFkAge()) .where(T_REGISTRATION.PK_REGISTRATION.eq(bean.getPkRegistration())); // @formatter:on Main.LOGGER.trace(sql); @@ -117,4 +136,19 @@ public class RegistrationRepository { Main.LOGGER.trace(sql); sql.execute(); } + + /** + * get all ages + * + * @return the ages + */ + public List getAges() { + SelectSeekStep1 sql = jooq + // @formatter:off + .selectFrom(T_AGE) + .orderBy(T_AGE.PK_AGE); + // @formatter:on + Main.LOGGER.trace(sql); + return sql.fetchInto(TAgeRecord.class); + } } diff --git a/src/main/java/de/jottyfan/bico/modules/camp/RegistrationService.java b/src/main/java/de/jottyfan/bico/modules/camp/RegistrationService.java index d85432b..edbae16 100644 --- a/src/main/java/de/jottyfan/bico/modules/camp/RegistrationService.java +++ b/src/main/java/de/jottyfan/bico/modules/camp/RegistrationService.java @@ -6,6 +6,7 @@ import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import de.jottyfan.bico.db.camp.tables.records.TAgeRecord; import de.jottyfan.bico.modules.camp.model.RegistrationBean; import jakarta.validation.Valid; @@ -59,4 +60,13 @@ public class RegistrationService { public void delete(Integer id, Principal principal) { repository.delete(id, principal.getName()); } + + /** + * get the ages + * + * @return the ages + */ + public List getAges() { + return repository.getAges(); + } } diff --git a/src/main/java/de/jottyfan/bico/modules/camp/model/RegistrationBean.java b/src/main/java/de/jottyfan/bico/modules/camp/model/RegistrationBean.java index bed3bb0..b17d567 100644 --- a/src/main/java/de/jottyfan/bico/modules/camp/model/RegistrationBean.java +++ b/src/main/java/de/jottyfan/bico/modules/camp/model/RegistrationBean.java @@ -3,6 +3,7 @@ package de.jottyfan.bico.modules.camp.model; import java.io.Serializable; import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; /** * @@ -19,6 +20,35 @@ public class RegistrationBean implements Serializable { private String surname; @NotBlank private String sex; + @NotNull + private Boolean barrierFree; + + private Boolean day0; + private Boolean day1; + private Boolean day2; + private Boolean day3; + private Boolean day4; + private Boolean day5; + + private String nutrition; + private Integer driverProvidePlaces; + private Boolean wantPlaceInCar; + private String diseases; + private Boolean requirePayment; + + @NotNull + private Integer fkAge; + + public static final RegistrationBean withAllDays() { + RegistrationBean bean = new RegistrationBean(); + bean.setDay0(true); + bean.setDay1(true); + bean.setDay2(true); + bean.setDay3(true); + bean.setDay4(true); + bean.setDay5(true); + return bean; + } /** * @return the forename @@ -75,4 +105,186 @@ public class RegistrationBean implements Serializable { public void setPkRegistration(Integer pkRegistration) { this.pkRegistration = pkRegistration; } + + /** + * @return the barrierFree + */ + public Boolean getBarrierFree() { + return barrierFree; + } + + /** + * @param barrierFree the barrierFree to set + */ + public void setBarrierFree(Boolean barrierFree) { + this.barrierFree = barrierFree; + } + + /** + * @return the nutrition + */ + public String getNutrition() { + return nutrition; + } + + /** + * @param nutrition the nutrition to set + */ + public void setNutrition(String nutrition) { + this.nutrition = nutrition; + } + + /** + * @return the diseases + */ + public String getDiseases() { + return diseases; + } + + /** + * @param diseases the diseases to set + */ + public void setDiseases(String diseases) { + this.diseases = diseases; + } + + /** + * @return the driverProvidePlaces + */ + public Integer getDriverProvidePlaces() { + return driverProvidePlaces; + } + + /** + * @param driverProvidePlaces the driverProvidePlaces to set + */ + public void setDriverProvidePlaces(Integer driverProvidePlaces) { + this.driverProvidePlaces = driverProvidePlaces; + } + + /** + * @return the wantPlaceInCar + */ + public Boolean getWantPlaceInCar() { + return wantPlaceInCar; + } + + /** + * @param wantPlaceInCar the wantPlaceInCar to set + */ + public void setWantPlaceInCar(Boolean wantPlaceInCar) { + this.wantPlaceInCar = wantPlaceInCar; + } + + /** + * @return the requirePayment + */ + public Boolean getRequirePayment() { + return requirePayment; + } + + /** + * @param requirePayment the requirePayment to set + */ + public void setRequirePayment(Boolean requirePayment) { + this.requirePayment = requirePayment; + } + + /** + * @return the fkAge + */ + public Integer getFkAge() { + return fkAge; + } + + /** + * @param fkAge the fkAge to set + */ + public void setFkAge(Integer fkAge) { + this.fkAge = fkAge; + } + + /** + * @return the day0 + */ + public Boolean getDay0() { + return day0; + } + + /** + * @param day0 the day0 to set + */ + public void setDay0(Boolean day0) { + this.day0 = day0; + } + + /** + * @return the day1 + */ + public Boolean getDay1() { + return day1; + } + + /** + * @param day1 the day1 to set + */ + public void setDay1(Boolean day1) { + this.day1 = day1; + } + + /** + * @return the day2 + */ + public Boolean getDay2() { + return day2; + } + + /** + * @param day2 the day2 to set + */ + public void setDay2(Boolean day2) { + this.day2 = day2; + } + + /** + * @return the day3 + */ + public Boolean getDay3() { + return day3; + } + + /** + * @param day3 the day3 to set + */ + public void setDay3(Boolean day3) { + this.day3 = day3; + } + + /** + * @return the day4 + */ + public Boolean getDay4() { + return day4; + } + + /** + * @param day4 the day4 to set + */ + public void setDay4(Boolean day4) { + this.day4 = day4; + } + + /** + * @return the day5 + */ + public Boolean getDay5() { + return day5; + } + + /** + * @param day5 the day5 to set + */ + public void setDay5(Boolean day5) { + this.day5 = day5; + } } diff --git a/src/main/resources/templates/camp/edit.html b/src/main/resources/templates/camp/edit.html index 39ff8aa..ecec256 100644 --- a/src/main/resources/templates/camp/edit.html +++ b/src/main/resources/templates/camp/edit.html @@ -13,6 +13,7 @@
+
Vorname
@@ -28,6 +29,48 @@
+
Alter
+
+ + +
+
Barrierefrei
+
+ + +
+
Spezielle Ernährung (Allergien, Unverträglichkeiten)
+
+ +
+
Besonderheiten / Krankheiten
+
+ +
+
Biete Plätze zum Mitfahren
+
+ +
+
Benötige eine Mitfahrgelegenheit
+
+ + +
+
Besonderheiten / Krankheiten
+
+ +
+
Finanzierungsunterstützung
+
+ + +
+
diff --git a/src/main/resources/templates/camp/registration.html b/src/main/resources/templates/camp/registration.html index a5477ba..63254c4 100644 --- a/src/main/resources/templates/camp/registration.html +++ b/src/main/resources/templates/camp/registration.html @@ -40,6 +40,7 @@
+
Vorname
@@ -55,6 +56,60 @@
+
Alter
+
+ + +
+
Welche Tage
+
+ + + + + + + + + + + + + +
+
Barrierefrei
+
+ + +
+
Spezielle Ernährung (Allergien, Unverträglichkeiten)
+
+ +
+
Biete Plätze zum Mitfahren
+
+ +
+
Benötige eine Mitfahrgelegenheit
+
+ + +
+
Besonderheiten / Krankheiten
+
+ +
+
Finanzierungsunterstützung
+
+ + +
+