Skip to content

Commit 362ec44

Browse files
committed
Added showing a set of duplicate comics [#2459]
1 parent f0c0180 commit 362ec44

File tree

45 files changed

+1465
-382
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1465
-382
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* ComiXed - A digital comic book library management application.
3+
* Copyright (C) 2024, The ComiXed Project
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see <http:/www.gnu.org/licenses>
17+
*/
18+
19+
package org.comixedproject.model.net.library;
20+
21+
import com.fasterxml.jackson.annotation.JsonProperty;
22+
import lombok.AllArgsConstructor;
23+
import lombok.Getter;
24+
import lombok.NoArgsConstructor;
25+
import org.comixedproject.model.comicbooks.ComicDetail;
26+
27+
/**
28+
* <code>LoadComicDetailsForReadingListRequest</code> represents the request payload when loading
29+
* {@link ComicDetail} for duplicate comic books in the library.
30+
*
31+
* @author Darryl L. Pierce
32+
*/
33+
@NoArgsConstructor
34+
@AllArgsConstructor
35+
public class LoadDuplicateComicsListRequest {
36+
@JsonProperty("pageSize")
37+
@Getter
38+
private int pageSize;
39+
40+
@JsonProperty("pageIndex")
41+
@Getter
42+
private int pageIndex;
43+
44+
@JsonProperty("sortBy")
45+
@Getter
46+
private String sortBy;
47+
48+
@JsonProperty("sortDirection")
49+
@Getter
50+
private String sortDirection;
51+
52+
@Override
53+
public String toString() {
54+
return "LoadDuplicateComicsListRequest{"
55+
+ "pageSize="
56+
+ pageSize
57+
+ ", pageIndex="
58+
+ pageIndex
59+
+ ", sortBy='"
60+
+ sortBy
61+
+ '\''
62+
+ ", sortDirection='"
63+
+ sortDirection
64+
+ '\''
65+
+ '}';
66+
}
67+
}

comixed-model/src/main/java/org/comixedproject/model/net/library/LoadDuplicateComicsResponse.java renamed to comixed-model/src/main/java/org/comixedproject/model/net/library/LoadDuplicateComicsListResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
import org.comixedproject.views.View;
2828

2929
/**
30-
* <code>LoadDuplicateComicsResponse</code> represents the response payload when loading a page
30+
* <code>LoadDuplicateComicsListResponse</code> represents the response payload when loading a page
3131
* worth of duplicate comics.
3232
*
3333
* @author Darryl L. Pierce
3434
*/
3535
@AllArgsConstructor
36-
public class LoadDuplicateComicsResponse {
36+
public class LoadDuplicateComicsListResponse {
3737
@JsonProperty("comics")
3838
@JsonView(View.DuplicateComicListView.class)
3939
@Getter
Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,53 @@
1-
/*
2-
* ComiXed - A digital comic book library management application.
3-
* Copyright (C) 2024, The ComiXed Project
4-
*
5-
* This program is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU General Public License as published by
7-
* the Free Software Foundation, either version 3 of the License, or
8-
* (at your option) any later version.
9-
*
10-
* This program is distributed in the hope that it will be useful,
11-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
* GNU General Public License for more details.
14-
*
15-
* You should have received a copy of the GNU General Public License
16-
* along with this program. If not, see <http:/www.gnu.org/licenses>
17-
*/
18-
191
package org.comixedproject.model.net.library;
202

213
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.util.Date;
225
import lombok.AllArgsConstructor;
236
import lombok.Getter;
247
import lombok.NoArgsConstructor;
25-
import org.comixedproject.model.comicbooks.ComicDetail;
268

279
/**
28-
* <code>LoadComicDetailsForReadingListRequest</code> represents the request payload when loading
29-
* {@link ComicDetail} for duplicate comic books in the library.
10+
* <code>LoadDuplicateComicsRequest</code> represents the request body when loading a set of
11+
* duplicate comics.
3012
*
3113
* @author Darryl L. Pierce
3214
*/
3315
@NoArgsConstructor
3416
@AllArgsConstructor
3517
public class LoadDuplicateComicsRequest {
36-
@JsonProperty("pageSize")
18+
@JsonProperty("publisher")
3719
@Getter
38-
private int pageSize;
20+
private String publisher;
21+
22+
@JsonProperty("series")
23+
@Getter
24+
private String series;
25+
26+
@JsonProperty("volume")
27+
@Getter
28+
private String volume;
29+
30+
@JsonProperty("issueNumber")
31+
@Getter
32+
private String issueNumber;
33+
34+
@JsonProperty("coverDate")
35+
@Getter
36+
private Date coverDate;
3937

4038
@JsonProperty("pageIndex")
4139
@Getter
4240
private int pageIndex;
4341

42+
@JsonProperty("pageSize")
43+
@Getter
44+
private int pageSize;
45+
4446
@JsonProperty("sortBy")
4547
@Getter
4648
private String sortBy;
4749

4850
@JsonProperty("sortDirection")
4951
@Getter
5052
private String sortDirection;
51-
52-
@Override
53-
public String toString() {
54-
return "LoadDuplicateComicsRequest{"
55-
+ "pageSize="
56-
+ pageSize
57-
+ ", pageIndex="
58-
+ pageIndex
59-
+ ", sortBy='"
60-
+ sortBy
61-
+ '\''
62-
+ ", sortDirection='"
63-
+ sortDirection
64-
+ '\''
65-
+ '}';
66-
}
6753
}

comixed-repositories/src/main/java/org/comixedproject/repositories/library/DisplayableComicRepository.java

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ long getComicCountForTagTypeAndValue(
118118
List<DisplayableComic> loadReadComics(@Param("ids") Set<Long> ids, Pageable pageable);
119119

120120
/**
121-
* Retutnrs comics for the specified reading list.
121+
* Returns comics for the specified reading list.
122122
*
123123
* @param listId the reading list id
124124
* @param pageable the request
@@ -128,15 +128,6 @@ long getComicCountForTagTypeAndValue(
128128
"SELECT d FROM DisplayableComic d WHERE d.comicDetailId IN (SELECT l.entryIds FROM ReadingList l WHERE l.readingListId = :listId)")
129129
List<DisplayableComic> loadComicsForList(@Param("listId") Long listId, Pageable pageable);
130130

131-
/**
132-
* Returns the comic ids for all duplicate comics.
133-
*
134-
* @return the comic ids
135-
*/
136-
@Query(
137-
"SELECT d.comicDetailId FROM DisplayableComic d JOIN (SELECT c.publisher AS publisher, c.series AS series, c.volume AS volume, c.issueNumber AS issueNumber, c.coverDate as coverDate FROM ComicDetail c WHERE c.publisher IS NOT NULL AND LENGTH(c.publisher) > 0 AND c.series IS NOT NULL AND LENGTH(c.series) > 0 AND c.volume IS NOT NULL AND LENGTH(c.volume) > 0 AND c.issueNumber IS NOT NULL AND LENGTH(c.issueNumber) > 0 AND c.coverDate IS NOT NULL GROUP BY c.publisher, c.series, c.volume, c.issueNumber, c.coverDate HAVING count(*) > 1) g ON g.publisher = d.publisher AND g.series = d.series AND g.volume = d.volume AND g.issueNumber = d.issueNumber AND g.coverDate = d.coverDate")
138-
List<Long> getDuplicateComicIds();
139-
140131
/**
141132
* Returns all comic ids for a given publisher.
142133
*
@@ -168,4 +159,40 @@ long getComicCountForTagTypeAndValue(
168159
@Query(
169160
"SELECT d.comicDetailId FROM DisplayableComic d WHERE d.comicDetailId IN (SELECT t.comicDetail.comicDetailId FROM ComicTag t WHERE t.type = :tagType AND t.value = :tagValue)")
170161
List<Long> getIdsByTagTypeAndValue(ComicTagType tagType, String tagValue);
162+
163+
/**
164+
* Loads the comics with the given metadata values.
165+
*
166+
* @param publisher the publisher
167+
* @param series the series
168+
* @param volume the volume
169+
* @param issueNumber the issue number
170+
* @param pageable the page request
171+
* @return the comics
172+
*/
173+
@Query(
174+
"SELECT d FROM DisplayableComic d WHERE d.publisher = :publisher AND d.series = :series AND d.volume = :volume AND d.issueNumber = :issueNumber")
175+
List<DisplayableComic> loadComics(
176+
@Param("publisher") String publisher,
177+
@Param("series") String series,
178+
@Param("volume") String volume,
179+
@Param("issueNumber") String issueNumber,
180+
Pageable pageable);
181+
182+
/**
183+
* Returns the number of comics with the given metadata values.
184+
*
185+
* @param publisher the publisher
186+
* @param series the series
187+
* @param volume the volume
188+
* @param issueNumber the issue number
189+
* @return the comics
190+
*/
191+
@Query(
192+
"SELECT COUNT(d) FROM DisplayableComic d WHERE d.publisher = :publisher AND d.series = :series AND d.volume = :volume AND d.issueNumber = :issueNumber")
193+
long getComicCount(
194+
@Param("publisher") String publisher,
195+
@Param("series") String series,
196+
@Param("volume") String volume,
197+
@Param("issueNumber") String issueNumber);
171198
}

comixed-repositories/src/main/java/org/comixedproject/repositories/library/DuplicateComicRepository.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818

1919
package org.comixedproject.repositories.library;
2020

21+
import java.util.List;
2122
import org.comixedproject.model.library.DuplicateComic;
2223
import org.comixedproject.model.library.DuplicateComicId;
2324
import org.springframework.data.jpa.repository.JpaRepository;
25+
import org.springframework.data.jpa.repository.Query;
2426
import org.springframework.stereotype.Repository;
2527

2628
/**
@@ -30,4 +32,13 @@
3032
* @author Darryl L. Pierce
3133
*/
3234
@Repository
33-
public interface DuplicateComicRepository extends JpaRepository<DuplicateComic, DuplicateComicId> {}
35+
public interface DuplicateComicRepository extends JpaRepository<DuplicateComic, DuplicateComicId> {
36+
/**
37+
* Returns the list of comic book ids for all duplicated comic books.
38+
*
39+
* @return the comic book ids
40+
*/
41+
@Query(
42+
"SELECT DISTINCT d.comicBookId FROM DuplicateComic dc JOIN DisplayableComic d ON d.publisher = dc.id.publisher AND d.series = dc.id.series AND d.volume = dc.id.volume AND d.issueNumber = dc.id.issueNumber AND d.coverDate = dc.id.coverDate ")
43+
List<Long> getDuplicateComicIds();
44+
}

comixed-rest/src/main/java/org/comixedproject/rest/comicbooks/ComicBookSelectionController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.comixedproject.service.comicbooks.ComicBookSelectionException;
3030
import org.comixedproject.service.comicbooks.ComicSelectionService;
3131
import org.comixedproject.service.library.DisplayableComicService;
32+
import org.comixedproject.service.library.DuplicateComicService;
3233
import org.comixedproject.service.user.ComiXedUserException;
3334
import org.comixedproject.service.user.UserService;
3435
import org.springframework.beans.factory.annotation.Autowired;
@@ -52,6 +53,7 @@ public class ComicBookSelectionController {
5253
@Autowired private UserService userService;
5354
@Autowired private OPDSUtils opdsUtils;
5455
@Autowired private DisplayableComicService displayableComicService;
56+
@Autowired private DuplicateComicService duplicateComicService;
5557

5658
/**
5759
* Loads the user's comic book selections.
@@ -370,7 +372,7 @@ public void addDuplicateComicBooksSelection(
370372
final List<Long> selections =
371373
this.comicSelectionService.decodeSelections(session.getAttribute(LIBRARY_SELECTIONS));
372374

373-
final List<Long> idList = this.displayableComicService.getDuplicateComicIds();
375+
final List<Long> idList = this.duplicateComicService.getDuplicateComicIds();
374376
if (selected) {
375377
log.info("Selecting ids for duplicate comic books");
376378
selections.addAll(idList);

0 commit comments

Comments
 (0)