Skip to content

Commit

Permalink
Updates for graphic novel grouping
Browse files Browse the repository at this point in the history
Also null pointer check when indexing Palace Project
  • Loading branch information
mdnoble73 committed May 6, 2024
1 parent db50f5c commit e398694
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 55 deletions.
Binary file modified code/palace_project_export/palace_project_export.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ private static void setLastUpdateTimeForSetting(boolean doFullReload, long setti
}
}

private static SimpleDateFormat dateModifiedFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
private static final SimpleDateFormat dateModifiedFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");
private static void extractRecordsForPalaceProjectCollection(String collectionName, HashMap<String, String> validCollections, HashMap<String, String> headers, PalaceProjectCollection collection, HashMap<Long, PalaceProjectTitleAvailability> titlesForCollection, boolean doFullReload, long indexStartTime) {
logEntry.addNote("Extracting Records for " + collectionName + " in setting " + collection.settingId);
//Index all records in the collection
Expand Down
Binary file modified code/reindexer/reindexer.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ String setGroupingCategoryForWork(Record marcRecord, GroupedWork workForTitle) {
switch (baseSettings.getFormatSource()) {
case "bib":
String format = formatClassifier.getFirstFormatFromBib(marcRecord, baseSettings);
if (formatsToFormatCategory.containsKey(format.toLowerCase())) {
groupingFormat = categoryMap.getOrDefault(formatsToFormatCategory.get(format.toLowerCase()), "other");
String formatLower = format.toLowerCase();
if (formatLower.contains("graphic novel") || (formatLower.contains("comic") && !formatLower.contains("ecomic")) || formatLower.contains("manga")) {
formatLower = "graphic novel";
}
if (formatsToFormatCategory.containsKey(formatLower)) {
groupingFormat = categoryMap.getOrDefault(formatsToFormatCategory.get(formatLower), "other");
}else{
groupingFormat = "book";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ public String processRecord(RecordIdentifier primaryIdentifier, String title, St
formatsToFormatCategory.put("xps", "ebook");
formatsToFormatCategory.put("bingepass", "other");
formatsToFormatCategory.put("graphicnovel", "comic");
formatsToFormatCategory.put("graphic novel", "comic");
formatsToFormatCategory.put("manga", "comic");
formatsToFormatCategory.put("comic", "comic");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,68 +281,71 @@ void processRecord(AbstractGroupedWorkSolr groupedWork, String identifier, BaseI
while (collectionsForTitleRS.next()) {
long collectionId = collectionsForTitleRS.getLong("collectionId");
PalaceProjectCollection collection = allCollections.get(collectionId);
String collectionName = collection.displayName;
ItemInfo itemInfo = new ItemInfo();
itemInfo.setItemIdentifier(identifier);
itemInfo.seteContentSource(collectionName);
itemInfo.setIsEContent(true);
itemInfo.seteContentUrl(contentUrl);
itemInfo.setShelfLocation("Online " + collectionName);
itemInfo.setDetailedLocation("Online " + collectionName);
itemInfo.setCallNumber("Online " + collectionName);
itemInfo.setSortableCallNumber("Online " + collectionName);
itemInfo.setFormat(primaryFormat);
itemInfo.setFormatCategory(formatCategory);
//Palace Project does not currently provide more info so can't give accurate number of copies, but we can tell if it's available or not
itemInfo.setNumCopies(1);
itemInfo.setAvailable(available);
itemInfo.setDetailedStatus("Available Online");
itemInfo.setGroupedStatus("Available Online");
itemInfo.setHoldable(false);
itemInfo.setInLibraryUseOnly(false);
//Collection will sometimes be null if the collection is deleted
if (collection != null) {
String collectionName = collection.displayName;
ItemInfo itemInfo = new ItemInfo();
itemInfo.setItemIdentifier(identifier);
itemInfo.seteContentSource(collectionName);
itemInfo.setIsEContent(true);
itemInfo.seteContentUrl(contentUrl);
itemInfo.setShelfLocation("Online " + collectionName);
itemInfo.setDetailedLocation("Online " + collectionName);
itemInfo.setCallNumber("Online " + collectionName);
itemInfo.setSortableCallNumber("Online " + collectionName);
itemInfo.setFormat(primaryFormat);
itemInfo.setFormatCategory(formatCategory);
//Palace Project does not currently provide more info so can't give accurate number of copies, but we can tell if it's available or not
itemInfo.setNumCopies(1);
itemInfo.setAvailable(available);
itemInfo.setDetailedStatus("Available Online");
itemInfo.setGroupedStatus("Available Online");
itemInfo.setHoldable(false);
itemInfo.setInLibraryUseOnly(false);

Date dateAdded = new Date(productRS.getLong("dateFirstDetected") * 1000);
itemInfo.setDateAdded(dateAdded);
Date dateAdded = new Date(productRS.getLong("dateFirstDetected") * 1000);
itemInfo.setDateAdded(dateAdded);

boolean isTeen = audience.equals("Young Adult");
boolean isKids = audience.equals("Juvenile");
//Account for cases where audience is Unknown, General, etc
boolean isAdult = !isKids && !isTeen;
boolean isTeen = audience.equals("Young Adult");
boolean isKids = audience.equals("Juvenile");
//Account for cases where audience is Unknown, General, etc
boolean isAdult = !isKids && !isTeen;

for (Scope scope : indexer.getScopes()) {
boolean okToAdd;
PalaceProjectScope palaceProjectScope = scope.getPalaceProjectScope();
if (palaceProjectScope != null) {
okToAdd = true;
}else{
continue;
}
if (palaceProjectScope.getSettingId() != collection.settingId) {
okToAdd = false;
}
if (okToAdd) {
//Check based on the audience as well
okToAdd = false;
//noinspection RedundantIfStatement
if (isAdult && palaceProjectScope.isIncludeAdult()) {
okToAdd = true;
}
if (isTeen && palaceProjectScope.isIncludeTeen()) {
for (Scope scope : indexer.getScopes()) {
boolean okToAdd;
PalaceProjectScope palaceProjectScope = scope.getPalaceProjectScope();
if (palaceProjectScope != null) {
okToAdd = true;
} else {
continue;
}
if (isKids && palaceProjectScope.isIncludeKids()) {
okToAdd = true;
if (palaceProjectScope.getSettingId() != collection.settingId) {
okToAdd = false;
}
if (okToAdd) {
ScopingInfo scopingInfo = itemInfo.addScope(scope);
groupedWork.addScopingInfo(scope.getScopeName(), scopingInfo);
scopingInfo.setLibraryOwned(true);
scopingInfo.setLocallyOwned(true);
//Check based on the audience as well
okToAdd = false;
//noinspection RedundantIfStatement
if (isAdult && palaceProjectScope.isIncludeAdult()) {
okToAdd = true;
}
if (isTeen && palaceProjectScope.isIncludeTeen()) {
okToAdd = true;
}
if (isKids && palaceProjectScope.isIncludeKids()) {
okToAdd = true;
}
if (okToAdd) {
ScopingInfo scopingInfo = itemInfo.addScope(scope);
groupedWork.addScopingInfo(scope.getScopeName(), scopingInfo);
scopingInfo.setLibraryOwned(true);
scopingInfo.setLocallyOwned(true);
}
}
}
}

palaceProjectRecord.addItem(itemInfo);
palaceProjectRecord.addItem(itemInfo);
}
}
}
productRS.close();
Expand Down

0 comments on commit e398694

Please sign in to comment.