Skip to content

Commit c9ab22e

Browse files
committed
Added expanded searching of comics [#2346]
Expanded the searched fields to include the publisher, series, title, description, and notes.
1 parent f6bae88 commit c9ab22e

File tree

5 files changed

+141
-62
lines changed

5 files changed

+141
-62
lines changed

comixed-model/src/main/java/org/comixedproject/model/library/DisplayableComic.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,21 @@ public class DisplayableComic {
105105
@Column(name = "title")
106106
@JsonView({View.ComicDetailsView.class})
107107
@Getter
108+
@Setter
108109
private String title;
109110

111+
@Column(name = "notes")
112+
@JsonView({View.ComicDetailsView.class})
113+
@Getter
114+
@Setter
115+
private String notes;
116+
117+
@Column(name = "description")
118+
@JsonView({View.ComicDetailsView.class})
119+
@Getter
120+
@Setter
121+
private String description;
122+
110123
@Column(name = "page_count")
111124
@JsonView({View.ComicDetailsView.class})
112125
@Getter

comixed-model/src/main/resources/db/liquibase-changelog.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
<include file="/db/migrations/2.1/changelog-2.1.xml"/>
1111
<include file="/db/migrations/2.2/changelog-2.2.xml"/>
1212
<include file="/db/migrations/2.3/changelog-2.3.xml"/>
13+
<include file="/db/migrations/2.4/changelog-2.4.xml"/>
1314

1415
</databaseChangeLog>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
5+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
6+
<changeSet id="001_2346_add_notes_to_displayable_comic_books.xml" author="mcpierce">
7+
8+
<createView viewName="displayable_comics_view" replaceIfExists="true">
9+
SELECT DISTINCT d.comic_book_id as comic_book_id,
10+
d.id as comic_detail_id,
11+
d.archive_type as archive_type,
12+
d.comic_state as comic_state,
13+
CASE
14+
WHEN EXISTS(SELECT *
15+
FROM comic_metadata_sources s
16+
WHERE s.comic_book_id = d.comic_book_id)
17+
THEN false
18+
ELSE true END AS is_unscraped,
19+
d.comic_type as comic_type,
20+
d.publisher as publisher,
21+
d.series as series,
22+
d.volume as volume,
23+
d.issue_number as issue_number,
24+
(SELECT RIGHT(CONCAT('0000000000', d.issue_number), 10)) as sortable_issue_number, d.title as title, (
25+
SELECT COUNT (*)
26+
FROM comic_pages cp
27+
WHERE cp.comic_book_id = d.comic_book_id) as page_count
28+
, d.cover_date as cover_date
29+
, CASE WHEN d.cover_date IS NULL THEN 0 ELSE MONTH (cover_date)
30+
END
31+
as month_published,
32+
CASE WHEN d.cover_date IS NULL THEN 0 ELSE YEAR (cover_date)
33+
END
34+
as year_published,
35+
d.store_date as store_date,
36+
d.added_date as added_date,
37+
d.notes as notes,
38+
d.description as description
39+
FROM comic_details d
40+
</createView>
41+
42+
</changeSet>
43+
</databaseChangeLog>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<databaseChangeLog
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
6+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
7+
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
8+
9+
<include file="/db/migrations/2.4/001_2346_add_notes_to_displayable_comic_books.xml"/>
10+
11+
</databaseChangeLog>

comixed-services/src/main/java/org/comixedproject/service/library/DisplayableComicExampleBuilder.java

Lines changed: 73 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -69,72 +69,83 @@ public Example<DisplayableComic> build() {
6969

7070
ExampleMatcher matcher = ExampleMatcher.matching();
7171

72-
if (coverYear != null) {
73-
log.debug("Setting cover year filter: {}", coverYear);
74-
detail.setYearPublished(coverYear);
75-
matcher = matcher.withMatcher("coverYear", ExampleMatcher.GenericPropertyMatchers.exact());
76-
}
77-
78-
if (coverMonth != null) {
79-
log.debug("Setting cover month filter: {}", coverMonth);
80-
detail.setMonthPublished(coverMonth);
81-
matcher = matcher.withMatcher("coverMonth", ExampleMatcher.GenericPropertyMatchers.exact());
82-
}
83-
84-
if (archiveType != null) {
85-
log.debug("Setting archive type filter: {}", archiveType);
86-
detail.setArchiveType(archiveType);
87-
matcher = matcher.withMatcher("archiveType", ExampleMatcher.GenericPropertyMatchers.exact());
88-
}
89-
90-
if (comicType != null) {
91-
log.debug("Setting comic type filter: {}", comicType);
92-
detail.setComicType(comicType);
93-
matcher = matcher.withMatcher("comicType", ExampleMatcher.GenericPropertyMatchers.exact());
94-
}
95-
96-
if (comicState != null) {
97-
log.debug("Setting comic state filter: {}", comicState);
98-
detail.setComicState(comicState);
99-
matcher = matcher.withMatcher("comicState", ExampleMatcher.GenericPropertyMatchers.exact());
100-
}
101-
102-
if (unscrapedState) {
103-
log.debug("Enabling unscraped filter");
104-
detail.setUnscraped(Boolean.TRUE);
105-
matcher = matcher.withMatcher("unscraped", ExampleMatcher.GenericPropertyMatchers.exact());
106-
}
107-
108-
if (StringUtils.hasLength(publisher)) {
109-
log.debug("Enabling publisher filter");
110-
detail.setPublisher(publisher);
111-
matcher = matcher.withMatcher("publisher", ExampleMatcher.GenericPropertyMatchers.exact());
112-
}
113-
114-
if (StringUtils.hasLength(series)) {
115-
log.debug("Enabling series filter");
116-
detail.setSeries(series);
117-
matcher = matcher.withMatcher("series", ExampleMatcher.GenericPropertyMatchers.exact());
118-
}
119-
120-
if (StringUtils.hasLength(volume)) {
121-
log.debug("Enabling volume filter");
122-
detail.setVolume(volume);
123-
matcher = matcher.withMatcher("volume", ExampleMatcher.GenericPropertyMatchers.exact());
124-
}
125-
126-
if (Objects.nonNull(pageCount) && pageCount >= 0) {
127-
log.debug("Enabling page count filter");
128-
detail.setPageCount(pageCount);
129-
matcher = matcher.withMatcher("pageCount", ExampleMatcher.GenericPropertyMatchers.exact());
130-
}
131-
13272
if (StringUtils.hasLength(searchText)) {
13373
log.debug("Returning comics with filter text: {}", searchText);
74+
detail.setPublisher(searchText);
13475
detail.setSeries(searchText);
76+
detail.setTitle(searchText);
77+
detail.setNotes(searchText);
78+
detail.setDescription(searchText);
13579
matcher =
136-
matcher.withMatcher(
137-
"series", ExampleMatcher.GenericPropertyMatchers.ignoreCase().contains());
80+
ExampleMatcher.matchingAny()
81+
.withMatcher(
82+
"publisher", ExampleMatcher.GenericPropertyMatchers.ignoreCase().contains())
83+
.withMatcher("series", ExampleMatcher.GenericPropertyMatchers.ignoreCase().contains())
84+
.withMatcher("title", ExampleMatcher.GenericPropertyMatchers.ignoreCase().contains())
85+
.withMatcher("notes", ExampleMatcher.GenericPropertyMatchers.ignoreCase().contains())
86+
.withMatcher(
87+
"setDescription", ExampleMatcher.GenericPropertyMatchers.ignoreCase().contains());
88+
} else {
89+
if (coverYear != null) {
90+
log.debug("Setting cover year filter: {}", coverYear);
91+
detail.setYearPublished(coverYear);
92+
matcher = matcher.withMatcher("coverYear", ExampleMatcher.GenericPropertyMatchers.exact());
93+
}
94+
95+
if (coverMonth != null) {
96+
log.debug("Setting cover month filter: {}", coverMonth);
97+
detail.setMonthPublished(coverMonth);
98+
matcher = matcher.withMatcher("coverMonth", ExampleMatcher.GenericPropertyMatchers.exact());
99+
}
100+
101+
if (archiveType != null) {
102+
log.debug("Setting archive type filter: {}", archiveType);
103+
detail.setArchiveType(archiveType);
104+
matcher =
105+
matcher.withMatcher("archiveType", ExampleMatcher.GenericPropertyMatchers.exact());
106+
}
107+
108+
if (comicType != null) {
109+
log.debug("Setting comic type filter: {}", comicType);
110+
detail.setComicType(comicType);
111+
matcher = matcher.withMatcher("comicType", ExampleMatcher.GenericPropertyMatchers.exact());
112+
}
113+
114+
if (comicState != null) {
115+
log.debug("Setting comic state filter: {}", comicState);
116+
detail.setComicState(comicState);
117+
matcher = matcher.withMatcher("comicState", ExampleMatcher.GenericPropertyMatchers.exact());
118+
}
119+
120+
if (unscrapedState) {
121+
log.debug("Enabling unscraped filter");
122+
detail.setUnscraped(Boolean.TRUE);
123+
matcher = matcher.withMatcher("unscraped", ExampleMatcher.GenericPropertyMatchers.exact());
124+
}
125+
126+
if (StringUtils.hasLength(publisher)) {
127+
log.debug("Enabling publisher filter");
128+
detail.setPublisher(publisher);
129+
matcher = matcher.withMatcher("publisher", ExampleMatcher.GenericPropertyMatchers.exact());
130+
}
131+
132+
if (StringUtils.hasLength(series)) {
133+
log.debug("Enabling series filter");
134+
detail.setSeries(series);
135+
matcher = matcher.withMatcher("series", ExampleMatcher.GenericPropertyMatchers.exact());
136+
}
137+
138+
if (StringUtils.hasLength(volume)) {
139+
log.debug("Enabling volume filter");
140+
detail.setVolume(volume);
141+
matcher = matcher.withMatcher("volume", ExampleMatcher.GenericPropertyMatchers.exact());
142+
}
143+
144+
if (Objects.nonNull(pageCount) && pageCount >= 0) {
145+
log.debug("Enabling page count filter");
146+
detail.setPageCount(pageCount);
147+
matcher = matcher.withMatcher("pageCount", ExampleMatcher.GenericPropertyMatchers.exact());
148+
}
138149
}
139150

140151
return Example.of(detail, matcher);

0 commit comments

Comments
 (0)