personalweb

Archived
git clone git://git.wimdupont.com/personalweb.git
Log | Files | Refs | README | LICENSE

commit 6ce819df070e8d1ed5d5f8db9b27d752f80b57db
parent e696cf6232f8c966ad54ffbe078619ee06493085
Author: WimDupont <WimDupont@users.noreply.gitlab.com>
Date:   Wed, 11 Aug 2021 12:48:05 +0200

books added with book series addition

Diffstat:
Mpom.xml | 2+-
Msrc/main/java/com/wimdupont/personalweb/controller/BookController.java | 6++++--
Msrc/main/java/com/wimdupont/personalweb/converter/BookToBookDtoConverter.java | 2++
Msrc/main/java/com/wimdupont/personalweb/model/dao/Book.java | 2++
Msrc/main/java/com/wimdupont/personalweb/model/dto/BookDto.java | 2++
Msrc/main/resources/db/migration/V1_0__db-init.sql | 9+++++----
Msrc/main/resources/db/migration/repeatable/R__fill_book_table.sql | 103+++++++++++++++++++++++++++++++++++++++++++------------------------------------
Msrc/main/resources/templates/books.html | 1+
8 files changed, 73 insertions(+), 54 deletions(-)

diff --git a/pom.xml b/pom.xml @@ -16,7 +16,7 @@ <properties> <java.version>11</java.version> - <flyway.maven.plugin.version>7.11.0</flyway.maven.plugin.version> + <flyway.maven.plugin.version>7.12.1</flyway.maven.plugin.version> <asciidoctorj.version>2.5.1</asciidoctorj.version> <rome.rometools.version>1.16.0</rome.rometools.version> </properties> diff --git a/src/main/java/com/wimdupont/personalweb/controller/BookController.java b/src/main/java/com/wimdupont/personalweb/controller/BookController.java @@ -25,10 +25,12 @@ public class BookController { @SuppressWarnings("unused") public String getBooks(Model model) { List<BookDto> bookDtoList = bookService.findAll().stream().map(bookToBookDtoConverter::convert).collect(Collectors.toList()); - bookDtoList = bookDtoList.stream().sorted(Comparator.comparing(BookDto::getCategory) + bookDtoList = bookDtoList.stream().sorted(Comparator.nullsFirst(Comparator.comparing(BookDto::getCategory) .thenComparing(BookDto::getAuthor) + .thenComparing(BookDto::getSeries, Comparator.nullsFirst(Comparator.naturalOrder())) + .thenComparing(BookDto::getSeriesNumber, Comparator.nullsFirst(Comparator.naturalOrder())) .thenComparing(BookDto::getTitle) - ).collect(Collectors.toList()); + )).collect(Collectors.toList()); model.addAttribute("books", bookDtoList); return "books"; diff --git a/src/main/java/com/wimdupont/personalweb/converter/BookToBookDtoConverter.java b/src/main/java/com/wimdupont/personalweb/converter/BookToBookDtoConverter.java @@ -15,6 +15,8 @@ public class BookToBookDtoConverter implements Converter<Book, BookDto> { .author(entity.getAuthor()) .isbn(entity.getIsbn()) .category(entity.getCategory()) + .series(entity.getSeries()) + .seriesNumber(entity.getSeriesNumber()) .build(); } } diff --git a/src/main/java/com/wimdupont/personalweb/model/dao/Book.java b/src/main/java/com/wimdupont/personalweb/model/dao/Book.java @@ -26,4 +26,6 @@ public class Book { private String author; private String isbn; private String category; + private String series; + private Double seriesNumber; } diff --git a/src/main/java/com/wimdupont/personalweb/model/dto/BookDto.java b/src/main/java/com/wimdupont/personalweb/model/dto/BookDto.java @@ -18,4 +18,6 @@ public class BookDto implements DTO{ private String author; private String isbn; private String category; + private String series; + private Double seriesNumber; } diff --git a/src/main/resources/db/migration/V1_0__db-init.sql b/src/main/resources/db/migration/V1_0__db-init.sql @@ -2,6 +2,8 @@ CREATE TABLE book ( id VARCHAR(36) primary key NOT NULL, title VARCHAR(200) NOT NULL, author VARCHAR(500) NOT NULL, - isbn VARCHAR(100), - category VARCHAR(100) -) -\ No newline at end of file + isbn VARCHAR(100) UNIQUE NOT NULL, + category VARCHAR(100) NOT NULL, + series VARCHAR(200), + series_number DECIMAL +) diff --git a/src/main/resources/db/migration/repeatable/R__fill_book_table.sql b/src/main/resources/db/migration/repeatable/R__fill_book_table.sql @@ -1,51 +1,60 @@ DELETE FROM book; INSERT INTO book VALUES - (UUID(), "Effective Java, Second Edition", "Joshua Block", "9780321356680", "Programming: Java"), - (UUID(), "The Elements of Java", "Allan Vermeulen, Scott W. Ambler", "9780521777681", "Programming: Java"), - (UUID(), "Core Java for the Impatient", "Cay S. Horstmann", "9780321996329", "Programming: Java"), - (UUID(), "Java Concurrency in Practice", "Brian Goetz, Tim Peierls", "9780321349606", "Programming: Java"), - (UUID(), "Head First Design Patterns, 2nd Edition", "Eric Freeman, Elisabeth Robson", "9781492078005", "Programming: Java"), - (UUID(), "Java Generics", "Maurice Naftalin, Philip Wadler", "9780596527754", "Programming: Java"), - (UUID(), "Java How to Program, Seventh Edition", "Harvey M. Deitel, Paul J. Deitel", "9780132222204", "Programming: Java"), - - (UUID(), "Computer Networking: A Top-Down Approach, Seventh Edition", "James Kurose, Keith Ross", "9781292153599", "IT"), - - (UUID(), "Introduction to Probability, Second Edition", "Joseph K. Blitzstein, Jessica Hwang", "9781138369917", "Math"), - (UUID(), "Introduction to Linear Algebra, Fifth Edition", "Gilbert Strang", "9780980232776", "Math"), - - (UUID(), "How to Reassess Your Chess, 4th Edition", "Jeremy Silman", "9781890085131", "Chess"), - (UUID(), "Bobby Fischer Teaches Chess", "Bobby Fischer, Stuart Margulies", "9780553263152", "Chess"), - (UUID(), "My 60 Memorable Games", "Bobby Fischer", "9781906388300", "Chess"), - - (UUID(), "Man's Search For Meaning", "Viktor E. Frankl", "9781846041242", "Psychology"), - (UUID(), "The Happiness Trap : Stop Struggling, Start Living", "Russ Harris", "9781845298258", "Psychology"), - (UUID(), "The paradox of choice", "Barry Schwartz", "9780062449924", "Psychology"), - (UUID(), "The Blank Slate", "Steven Pinker", "9780140276053", "Psychology"), - (UUID(), "Thinking, fast and slow", "Daniel Kahneman", "9780141033570", "Psychology"), - (UUID(), "How to win friends and influence people", "Dale Carnegie", "9780091906818", "Psychology"), - - (UUID(), "Story of Philosophy", "Will Durant", "9780671739164", "Philosophy"), - (UUID(), "The virtue of selfishness", "Ayn Rand", "9780451163936", "Philosophy"), - (UUID(), "Free Will", "Sam Harris", "9781451683400", "Philosophy"), - - (UUID(), "Echt Radmilo", "Radmilo Soda", "9789035141575", "Health"), - - (UUID(), "The Way of Kings (The Stormlight Archive #1)", "Brandon Sanderson", "9780765365279", "Fantasy"), - (UUID(), "The Name of the Wind (The Kingkiller Chronicle: Day 1)", "Patrick Rothfuss", "9780575081406", "Fantasy"), - - (UUID(), "To Kill A Mockingbird", "Harper Lee", "9780099549482", "Fiction"), - (UUID(), "The Midnight Library", "Matt Haig", "9781786892720", "Fiction"), - (UUID(), "Of Mice and Men", "John Steinbeck", "9780141023571", "Fiction"), - (UUID(), "1984", "George Orwell", "9780141036144", "Fiction"), - (UUID(), "The Remains of the Day", "Kazuo Ishiguro", "9780679731726", "Fiction"), - (UUID(), "Lord of the Flies", "William Golding", "9780571273577", "Fiction"), - (UUID(), "The Heart Is a Lonely Hunter", "Carson Mc Cullers", "9780618526413", "Fiction"), - (UUID(), "Animal Farm", "George Orwell", "9780141036137", "Fiction"), - (UUID(), "The Unbearable Lightness of Being", "Milan Kundera", "9780571135394", "Fiction"), - (UUID(), "The Book Thief", "Markus Zusak", "9781784162122", "Fiction"), - (UUID(), "Slaughterhouse-Five", "Kurt Vonnegut", "9780440180296", "Fiction"), - (UUID(), "A Clockwork Orange", "Anthony Burgess", "9780241951446", "Fiction"), - (UUID(), "The Melody", "Jim Grace", "9781509841370", "Fiction"), - (UUID(), "Brave New World", "Aldous Huxley", "9780099477464", "Fiction") + (UUID(), "Effective Java, Second Edition", "Joshua Block", "9780321356680", "Programming: Java", null, null), + (UUID(), "The Elements of Java", "Allan Vermeulen, Scott W. Ambler", "9780521777681", "Programming: Java", null, null), + (UUID(), "Core Java for the Impatient", "Cay S. Horstmann", "9780321996329", "Programming: Java", null, null), + (UUID(), "Java Concurrency in Practice", "Brian Goetz, Tim Peierls", "9780321349606", "Programming: Java", null, null), + (UUID(), "Head First Design Patterns, 2nd Edition", "Eric Freeman, Elisabeth Robson", "9781492078005", "Programming: Java", null, null), + (UUID(), "Java Generics", "Maurice Naftalin, Philip Wadler", "9780596527754", "Programming: Java", null, null), + (UUID(), "Java How to Program, Seventh Edition", "Harvey M. Deitel, Paul J. Deitel", "9780132222204", "Programming: Java", null, null), + + (UUID(), "Computer Networking: A Top-Down Approach, Seventh Edition", "James Kurose, Keith Ross", "9781292153599", "IT", null, null), + + (UUID(), "Introduction to Probability, Second Edition", "Joseph K. Blitzstein, Jessica Hwang", "9781138369917", "Math", null, null), + (UUID(), "Introduction to Linear Algebra, Fifth Edition", "Gilbert Strang", "9780980232776", "Math", null, null), + + (UUID(), "How to Reassess Your Chess, 4th Edition", "Jeremy Silman", "9781890085131", "Chess", null, null), + (UUID(), "Bobby Fischer Teaches Chess", "Bobby Fischer, Stuart Margulies", "9780553263152", "Chess", null, null), + (UUID(), "My 60 Memorable Games", "Bobby Fischer", "9781906388300", "Chess", null, null), + + (UUID(), "Man's Search For Meaning", "Viktor E. Frankl", "9781846041242", "Psychology", null, null), + (UUID(), "The Happiness Trap : Stop Struggling, Start Living", "Russ Harris", "9781845298258", "Psychology", null, null), + (UUID(), "The paradox of choice", "Barry Schwartz", "9780062449924", "Psychology", null, null), + (UUID(), "The Blank Slate", "Steven Pinker", "9780140276053", "Psychology", null, null), + (UUID(), "Thinking, fast and slow", "Daniel Kahneman", "9780141033570", "Psychology", null, null), + (UUID(), "How to win friends and influence people", "Dale Carnegie", "9780091906818", "Psychology", null, null), + + (UUID(), "Story of Philosophy", "Will Durant", "9780671739164", "Philosophy", null, null), + (UUID(), "The virtue of selfishness", "Ayn Rand", "9780451163936", "Philosophy", null, null), + (UUID(), "Free Will", "Sam Harris", "9781451683400", "Philosophy", null, null), + + (UUID(), "Echt Radmilo", "Radmilo Soda", "9789035141575", "Health", null, null), + + (UUID(), "The Way of Kings (The Stormlight Archive #1)", "Brandon Sanderson", "9780765365279", "Fantasy", "The Stormlight Archive", 1), + (UUID(), "Words of Radiance (The Stormlight Archive #2)", "Brandon Sanderson", "9780765365286", "Fantasy", "The Stormlight Archive", 2), + (UUID(), "Edgedancer (The Stormlight Archive #2.5)", "Brandon Sanderson", "9781250166548", "Fantasy", "The Stormlight Archive", 2.5), + (UUID(), "Oathbringer (The Stormlight Archive #3)", "Brandon Sanderson", "9780765365293", "Fantasy", "The Stormlight Archive", 3), + (UUID(), "Rhythm of War (The Stormlight Archive #4)", "Brandon Sanderson", "9781250784261", "Fantasy", "The Stormlight Archive", 4), + (UUID(), "The Name of the Wind (The Kingkiller Chronicle: Day 1)", "Patrick Rothfuss", "9780575081406", "Fantasy", "The Kingkiller Chronicle", 1), + (UUID(), "The Wise Mans Fear (The Kingkiller Chronicle: Day 2)", "Patrick Rothfuss", "9780575081437", "Fantasy", "The Kingkiller Chronicle", 2), + (UUID(), "The Hobbit", "J.R.R. Tolkien", "9780544445796", "Fantasy", null, null), + (UUID(), "The Fellowship of the Ring (The Lord of the Rings: #1)", "J.R.R. Tolkien", "9780544448933", "Fantasy", "The Lord of the Rings", 1), + (UUID(), "The Two Towers (The Lord of the Rings: #2)", "J.R.R. Tolkien", "9780544449732", "Fantasy", "The Lord of the Rings", 2), + (UUID(), "The Return of the King (The Lord of the Rings: #3)", "J.R.R. Tolkien", "9780544449749", "Fantasy", "The Lord of the Rings", 3), + + (UUID(), "To Kill A Mockingbird", "Harper Lee", "9780099549482", "Fiction", null, null), + (UUID(), "The Midnight Library", "Matt Haig", "9781786892720", "Fiction", null, null), + (UUID(), "Of Mice and Men", "John Steinbeck", "9780141023571", "Fiction", null, null), + (UUID(), "1984", "George Orwell", "9780141036144", "Fiction", null, null), + (UUID(), "The Remains of the Day", "Kazuo Ishiguro", "9780679731726", "Fiction", null, null), + (UUID(), "Lord of the Flies", "William Golding", "9780571273577", "Fiction", null, null), + (UUID(), "The Heart Is a Lonely Hunter", "Carson Mc Cullers", "9780618526413", "Fiction", null, null), + (UUID(), "Animal Farm", "George Orwell", "9780141036137", "Fiction", null, null), + (UUID(), "The Unbearable Lightness of Being", "Milan Kundera", "9780571135394", "Fiction", null, null), + (UUID(), "The Book Thief", "Markus Zusak", "9781784162122", "Fiction", null, null), + (UUID(), "Slaughterhouse-Five", "Kurt Vonnegut", "9780440180296", "Fiction", null, null), + (UUID(), "A Clockwork Orange", "Anthony Burgess", "9780241951446", "Fiction", null, null), + (UUID(), "The Melody", "Jim Grace", "9781509841370", "Fiction", null, null), + (UUID(), "Brave New World", "Aldous Huxley", "9780099477464", "Fiction", null, null) ; diff --git a/src/main/resources/templates/books.html b/src/main/resources/templates/books.html @@ -11,6 +11,7 @@ <h1>Books</h1> <div th:insert="navigation"/> </header> + <p class="subheader">This is the collection of books of which I own a physical copy</p> <table> <tr> <th>Title</th>