diff --git a/build.gradle b/build.gradle index 7f810ae..21ac55f 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { } group = 'de.jottyfan.bico' -version = '0.0.1' +version = '0.0.2' description = """BibleClassOrganizer""" @@ -41,13 +41,13 @@ war { } dependencies { - implementation 'de.jottyfan:bicolib:2' + implementation 'de.jottyfan:bicolib:3' implementation 'org.springframework.boot:spring-boot-starter-jooq' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:3.0.0' + implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:latest.release' implementation 'org.webjars:bootstrap:5.3.1' implementation 'org.webjars.npm:bootstrap-icons:1.10.5' diff --git a/src/main/java/de/jottyfan/bico/modules/item/ItemController.java b/src/main/java/de/jottyfan/bico/modules/item/ItemController.java new file mode 100644 index 0000000..615b7f3 --- /dev/null +++ b/src/main/java/de/jottyfan/bico/modules/item/ItemController.java @@ -0,0 +1,27 @@ +package de.jottyfan.bico.modules.item; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +import de.jottyfan.bico.modules.CommonController; + +/** + * + * @author jotty + * + */ +@Controller +public class ItemController extends CommonController { + + @Autowired + private ItemService service; + + @GetMapping("/item/{slot}") + public String getItem(@PathVariable Integer slot, Model model) { + model.addAttribute("bean", service.getItem(slot)); + return "/item"; + } +} diff --git a/src/main/java/de/jottyfan/bico/modules/item/ItemRepository.java b/src/main/java/de/jottyfan/bico/modules/item/ItemRepository.java new file mode 100644 index 0000000..5e316b5 --- /dev/null +++ b/src/main/java/de/jottyfan/bico/modules/item/ItemRepository.java @@ -0,0 +1,93 @@ +package de.jottyfan.bico.modules.item; + +import static de.jottyfan.bico.db.Tables.T_LESSON; +import static de.jottyfan.bico.db.Tables.T_LESSON_SUBJECT; +import static de.jottyfan.bico.db.Tables.T_PERSON; +import static de.jottyfan.bico.db.Tables.T_SLOT; +import static de.jottyfan.bico.db.Tables.T_SOURCE; +import static de.jottyfan.bico.db.Tables.T_SUBJECT; + +import java.time.LocalDate; +import java.util.Iterator; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jooq.DSLContext; +import org.jooq.Record17; +import org.jooq.SelectConditionStep; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import de.jottyfan.bico.modules.item.model.ItemBean; +import de.jottyfan.bico.modules.item.model.LessonBean; +import de.jottyfan.bico.modules.item.model.PersonBean; +import de.jottyfan.bico.modules.item.model.SourceBean; +import de.jottyfan.bico.modules.item.model.SubjectBean; + +/** + * + * @author jotty + * + */ +@Repository +public class ItemRepository { + private static final Logger LOGGER = LogManager.getLogger(ItemRepository.class); + + @Autowired + private DSLContext jooq; + + /** + * get the item of slot + * + * @param slot the ID of the slot + * @return the bean + */ + public ItemBean getItem(Integer slot) { + SelectConditionStep> sql = jooq + // @formatter:off + .select(T_SLOT.PK_SLOT, + T_SLOT.SLOT_DAY, + T_SLOT.NOTE, + T_LESSON.NOTES, + T_PERSON.PK_PERSON, + T_PERSON.FORENAME, + T_PERSON.SURNAME, + T_PERSON.ABBREVIATION, + T_SOURCE.PK_SOURCE, + T_SOURCE.NAME, + T_SUBJECT.PK_SUBJECT, + T_SUBJECT.THEME, + T_SUBJECT.SUBTHEME, + T_SUBJECT.WORKSHEETS, + T_SUBJECT.BIBLEVERSE, + T_SUBJECT.BOOK_PAGES, + T_SOURCE.NAME) + .from(T_SLOT) + .leftJoin(T_LESSON).on(T_LESSON.FK_SLOT.eq(T_SLOT.PK_SLOT)) + .leftJoin(T_PERSON).on(T_PERSON.PK_PERSON.eq(T_LESSON.FK_PERSON)) + .leftJoin(T_LESSON_SUBJECT).on(T_LESSON_SUBJECT.FK_LESSON.eq(T_LESSON.PK_LESSON)) + .leftJoin(T_SUBJECT).on(T_SUBJECT.PK_SUBJECT.eq(T_LESSON_SUBJECT.FK_SUBJECT)) + .leftJoin(T_SOURCE).on(T_SOURCE.PK_SOURCE.eq(T_SUBJECT.FK_SOURCE)) + .where(T_SLOT.PK_SLOT.eq(slot)); + // @formatter:on + LOGGER.trace(sql); + Iterator> i = sql + .fetch().iterator(); + ItemBean bean = new ItemBean(); + while (i.hasNext()) { + Record17 r = i + .next(); + bean.setPkSlot(r.get(T_SLOT.PK_SLOT)); + bean.setSlotDay(r.get(T_SLOT.SLOT_DAY)); + bean.setSlotNote(r.get(T_SLOT.NOTE)); + bean.getLessons() + .add(LessonBean.of( + r.get(T_LESSON.NOTES), new PersonBean(r.get(T_PERSON.PK_PERSON), r.get(T_PERSON.FORENAME), + r.get(T_PERSON.SURNAME), r.get(T_PERSON.ABBREVIATION)), + new SubjectBean(new SourceBean(r.get(T_SOURCE.PK_SOURCE), r.get(T_SOURCE.NAME)), r.get(T_SUBJECT.PK_SUBJECT), r.get(T_SUBJECT.THEME), + r.get(T_SUBJECT.SUBTHEME), r.get(T_SUBJECT.WORKSHEETS), r.get(T_SUBJECT.BIBLEVERSE), + r.get(T_SUBJECT.BOOK_PAGES)))); + } + return bean; + } +} diff --git a/src/main/java/de/jottyfan/bico/modules/item/ItemService.java b/src/main/java/de/jottyfan/bico/modules/item/ItemService.java new file mode 100644 index 0000000..ef65b96 --- /dev/null +++ b/src/main/java/de/jottyfan/bico/modules/item/ItemService.java @@ -0,0 +1,22 @@ +package de.jottyfan.bico.modules.item; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import de.jottyfan.bico.modules.item.model.ItemBean; + +/** + * + * @author jotty + * + */ +@Service +public class ItemService { + + @Autowired + private ItemRepository repository; + + public ItemBean getItem(Integer slot) { + return repository.getItem(slot); + } +} diff --git a/src/main/java/de/jottyfan/bico/modules/item/model/ItemBean.java b/src/main/java/de/jottyfan/bico/modules/item/model/ItemBean.java new file mode 100644 index 0000000..9ec0532 --- /dev/null +++ b/src/main/java/de/jottyfan/bico/modules/item/model/ItemBean.java @@ -0,0 +1,73 @@ +package de.jottyfan.bico.modules.item.model; + +import java.io.Serializable; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author jotty + * + */ +public class ItemBean implements Serializable { + private static final long serialVersionUID = 1L; + + private Integer pkSlot; + private LocalDate slotDay; + private String slotNote; + private List lessons; + + public ItemBean() { + lessons = new ArrayList<>(); + } + + /** + * @return the pkSlot + */ + public Integer getPkSlot() { + return pkSlot; + } + + /** + * @param pkSlot the pkSlot to set + */ + public void setPkSlot(Integer pkSlot) { + this.pkSlot = pkSlot; + } + + /** + * @return the slotDay + */ + public LocalDate getSlotDay() { + return slotDay; + } + + /** + * @param slotDay the slotDay to set + */ + public void setSlotDay(LocalDate slotDay) { + this.slotDay = slotDay; + } + + /** + * @return the slotNote + */ + public String getSlotNote() { + return slotNote; + } + + /** + * @param slotNote the slotNote to set + */ + public void setSlotNote(String slotNote) { + this.slotNote = slotNote; + } + + /** + * @return the lessons + */ + public List getLessons() { + return lessons; + } +} diff --git a/src/main/java/de/jottyfan/bico/modules/item/model/LessonBean.java b/src/main/java/de/jottyfan/bico/modules/item/model/LessonBean.java new file mode 100644 index 0000000..16ded8b --- /dev/null +++ b/src/main/java/de/jottyfan/bico/modules/item/model/LessonBean.java @@ -0,0 +1,59 @@ +package de.jottyfan.bico.modules.item.model; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author jotty + * + */ +public class LessonBean implements Serializable { + + private static final long serialVersionUID = 1L; + + private String lessonNote; + private List persons; + private List subjects; + + public LessonBean() { + persons = new ArrayList<>(); + subjects = new ArrayList<>(); + } + + public static final LessonBean of(String lessonNote, PersonBean persons, SubjectBean subject) { + LessonBean bean = new LessonBean(); + bean.getPersons().add(persons); + bean.getSubjects().add(subject); + return bean; + } + + /** + * @return the lessonNote + */ + public String getLessonNote() { + return lessonNote; + } + + /** + * @param lessonNote the lessonNote to set + */ + public void setLessonNote(String lessonNote) { + this.lessonNote = lessonNote; + } + + /** + * @return the persons + */ + public List getPersons() { + return persons; + } + + /** + * @return the subjects + */ + public List getSubjects() { + return subjects; + } +} diff --git a/src/main/java/de/jottyfan/bico/modules/item/model/PersonBean.java b/src/main/java/de/jottyfan/bico/modules/item/model/PersonBean.java new file mode 100644 index 0000000..114f420 --- /dev/null +++ b/src/main/java/de/jottyfan/bico/modules/item/model/PersonBean.java @@ -0,0 +1,9 @@ +package de.jottyfan.bico.modules.item.model; + +/** + * + * @author jotty + * + */ +public record PersonBean(Integer pkPerson, String forename, String surname, String abbreviation) { +} diff --git a/src/main/java/de/jottyfan/bico/modules/item/model/SourceBean.java b/src/main/java/de/jottyfan/bico/modules/item/model/SourceBean.java new file mode 100644 index 0000000..726b27b --- /dev/null +++ b/src/main/java/de/jottyfan/bico/modules/item/model/SourceBean.java @@ -0,0 +1,10 @@ +package de.jottyfan.bico.modules.item.model; + +/** + * + * @author jotty + * + */ +public record SourceBean(Integer pkSource, String name) { + +} diff --git a/src/main/java/de/jottyfan/bico/modules/item/model/SubjectBean.java b/src/main/java/de/jottyfan/bico/modules/item/model/SubjectBean.java new file mode 100644 index 0000000..ff3d2de --- /dev/null +++ b/src/main/java/de/jottyfan/bico/modules/item/model/SubjectBean.java @@ -0,0 +1,11 @@ +package de.jottyfan.bico.modules.item.model; + +/** + * + * @author jotty + * + */ +public record SubjectBean(SourceBean source, Integer pkSubject, String theme, String subtheme, String worksheets, + String bibleverse, String bookPages) { + +} diff --git a/src/main/java/de/jottyfan/bico/modules/sheet/SheetRepository.java b/src/main/java/de/jottyfan/bico/modules/sheet/SheetRepository.java index 2534fb2..80aadb9 100644 --- a/src/main/java/de/jottyfan/bico/modules/sheet/SheetRepository.java +++ b/src/main/java/de/jottyfan/bico/modules/sheet/SheetRepository.java @@ -35,6 +35,8 @@ public class SheetRepository { List list = new ArrayList<>(); for (VCalendarRecord r : sql.fetch()) { SheetBean bean = new SheetBean(); + bean.setPkSlot(r.getPkSlot()); + bean.setPkSubject(r.getPkSubject()); bean.setAbbreviation(r.getAbbreviation()); bean.setBibleverse(r.getBibleverse()); bean.setBookPages(r.getBookPages()); diff --git a/src/main/java/de/jottyfan/bico/modules/sheet/model/SheetBean.java b/src/main/java/de/jottyfan/bico/modules/sheet/model/SheetBean.java index f26783d..696037d 100644 --- a/src/main/java/de/jottyfan/bico/modules/sheet/model/SheetBean.java +++ b/src/main/java/de/jottyfan/bico/modules/sheet/model/SheetBean.java @@ -23,6 +23,8 @@ public class SheetBean implements Serializable { private String subjectNotes; private String lessonNotes; private String slotNotes; + private Integer pkSlot; + private Integer pkSubject; /** * @return the slotDay @@ -191,4 +193,32 @@ public class SheetBean implements Serializable { public void setSlotNotes(String slotNotes) { this.slotNotes = slotNotes; } + + /** + * @return the pkSlot + */ + public Integer getPkSlot() { + return pkSlot; + } + + /** + * @param pkSlot the pkSlot to set + */ + public void setPkSlot(Integer pkSlot) { + this.pkSlot = pkSlot; + } + + /** + * @return the pkSubject + */ + public Integer getPkSubject() { + return pkSubject; + } + + /** + * @param pkSubject the pkSubject to set + */ + public void setPkSubject(Integer pkSubject) { + this.pkSubject = pkSubject; + } } diff --git a/src/main/resources/static/js/stylehelp.js b/src/main/resources/static/js/stylehelp.js index 0002208..1a1fcef 100644 --- a/src/main/resources/static/js/stylehelp.js +++ b/src/main/resources/static/js/stylehelp.js @@ -16,6 +16,6 @@ toggleDarkMode = function() { * only because th:data-bs-theme="${theme}" does not work */ $(document).ready(function(){ - var theme = /*[[${theme}]]*/ 'dark'; + var theme = /*[[${theme}]]*/ 'light'; $("html").attr("data-bs-theme", theme); }); diff --git a/src/main/resources/templates/item.html b/src/main/resources/templates/item.html new file mode 100644 index 0000000..2bfcf61 --- /dev/null +++ b/src/main/resources/templates/item.html @@ -0,0 +1,41 @@ + + + + +
+
+
+
Tag
+
+
Lehreinheiten
+
+
+
Dozent
+
+
+
+
Themen
+
+
+
Thema
+
+
Unterthema
+
+
Buchseiten
+
+
Arbeitsblätter
+
+
Bibelvers
+
+
Quelle
+
+
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/sheet.html b/src/main/resources/templates/sheet.html index d7cdbc9..c374e23 100644 --- a/src/main/resources/templates/sheet.html +++ b/src/main/resources/templates/sheet.html @@ -12,6 +12,7 @@ Thema Unterthema Tag-Anmerkungen + @@ -22,6 +23,7 @@ +