diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookMetadata.java b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookMetadata.java index 14052fef3..622836db2 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookMetadata.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/model/dto/BookMetadata.java @@ -44,7 +44,6 @@ public class BookMetadata { private String providerBookId; private String thumbnailUrl; - private Boolean allFieldsLocked; private Boolean titleLocked; private Boolean subtitleLocked; private Boolean publisherLocked; diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/model/entity/BookMetadataEntity.java b/booklore-api/src/main/java/com/adityachandel/booklore/model/entity/BookMetadataEntity.java index acf78ad43..87f2138f2 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/model/entity/BookMetadataEntity.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/model/entity/BookMetadataEntity.java @@ -82,8 +82,6 @@ public class BookMetadataEntity { private Integer goodreadsReviewCount; // Locking fields - @Column(name = "all_fields_locked") - private Boolean allFieldsLocked = Boolean.FALSE; @Column(name = "title_locked") private Boolean titleLocked = Boolean.FALSE; @@ -176,7 +174,6 @@ public class BookMetadataEntity { private List awards; public void applyLockToAllFields(boolean lock) { - this.allFieldsLocked = lock; this.titleLocked = lock; this.subtitleLocked = lock; this.publisherLocked = lock; @@ -200,4 +197,54 @@ public class BookMetadataEntity { this.goodreadsRatingLocked = lock; this.goodreadsReviewCountLocked = lock; } + + public boolean isAnyFieldLocked() { + return Boolean.TRUE.equals(this.titleLocked) + || Boolean.TRUE.equals(this.subtitleLocked) + || Boolean.TRUE.equals(this.publisherLocked) + || Boolean.TRUE.equals(this.publishedDateLocked) + || Boolean.TRUE.equals(this.descriptionLocked) + || Boolean.TRUE.equals(this.isbn13Locked) + || Boolean.TRUE.equals(this.isbn10Locked) + || Boolean.TRUE.equals(this.pageCountLocked) + || Boolean.TRUE.equals(this.thumbnailLocked) + || Boolean.TRUE.equals(this.languageLocked) + || Boolean.TRUE.equals(this.ratingLocked) + || Boolean.TRUE.equals(this.reviewCountLocked) + || Boolean.TRUE.equals(this.coverLocked) + || Boolean.TRUE.equals(this.seriesNameLocked) + || Boolean.TRUE.equals(this.seriesNumberLocked) + || Boolean.TRUE.equals(this.seriesTotalLocked) + || Boolean.TRUE.equals(this.authorsLocked) + || Boolean.TRUE.equals(this.categoriesLocked) + || Boolean.TRUE.equals(this.amazonRatingLocked) + || Boolean.TRUE.equals(this.amazonReviewCountLocked) + || Boolean.TRUE.equals(this.goodreadsRatingLocked) + || Boolean.TRUE.equals(this.goodreadsReviewCountLocked); + } + + public boolean areAllFieldsLocked() { + return Boolean.TRUE.equals(this.titleLocked) + && Boolean.TRUE.equals(this.subtitleLocked) + && Boolean.TRUE.equals(this.publisherLocked) + && Boolean.TRUE.equals(this.publishedDateLocked) + && Boolean.TRUE.equals(this.descriptionLocked) + && Boolean.TRUE.equals(this.isbn13Locked) + && Boolean.TRUE.equals(this.isbn10Locked) + && Boolean.TRUE.equals(this.pageCountLocked) + && Boolean.TRUE.equals(this.thumbnailLocked) + && Boolean.TRUE.equals(this.languageLocked) + && Boolean.TRUE.equals(this.ratingLocked) + && Boolean.TRUE.equals(this.reviewCountLocked) + && Boolean.TRUE.equals(this.coverLocked) + && Boolean.TRUE.equals(this.seriesNameLocked) + && Boolean.TRUE.equals(this.seriesNumberLocked) + && Boolean.TRUE.equals(this.seriesTotalLocked) + && Boolean.TRUE.equals(this.authorsLocked) + && Boolean.TRUE.equals(this.categoriesLocked) + && Boolean.TRUE.equals(this.amazonRatingLocked) + && Boolean.TRUE.equals(this.amazonReviewCountLocked) + && Boolean.TRUE.equals(this.goodreadsRatingLocked) + && Boolean.TRUE.equals(this.goodreadsReviewCountLocked); + } } \ No newline at end of file diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/BookMetadataService.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/BookMetadataService.java index df74c0a75..abe812f83 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/BookMetadataService.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/BookMetadataService.java @@ -106,9 +106,8 @@ public class BookMetadataService { List books = getBookEntities(request); for (BookEntity bookEntity : books) { try { - Boolean allFieldsLocked = bookEntity.getMetadata().getAllFieldsLocked(); - if (Boolean.TRUE.equals(allFieldsLocked)) { - log.info("Skipping metadata refresh for locked book: {}", bookEntity.getFileName()); + if (bookEntity.getMetadata().areAllFieldsLocked()) { + log.info("Skipping metadata refresh for fully locked book: {}", bookEntity.getFileName()); continue; } Map metadataMap = fetchMetadataForBook(providers, bookEntity); diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/BookMetadataUpdater.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/BookMetadataUpdater.java index 0ccccf0bd..4f15c15ea 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/BookMetadataUpdater.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/BookMetadataUpdater.java @@ -39,7 +39,7 @@ public class BookMetadataUpdater { updateLocks(newMetadata, metadata); - if (Boolean.TRUE.equals(metadata.getAllFieldsLocked())) { + if (metadata.areAllFieldsLocked()) { log.warn("Attempted to update metadata for book with ID {}, but all fields are locked. No update performed.", bookId); return metadata; } @@ -252,9 +252,6 @@ public class BookMetadataUpdater { if (newMetadata.getCoverLocked() != null) { metadata.setCoverLocked(newMetadata.getCoverLocked()); } - if (newMetadata.getAllFieldsLocked() != null) { - metadata.setAllFieldsLocked(newMetadata.getAllFieldsLocked()); - } } } \ No newline at end of file