Skip to content

Commit

Permalink
CloudLibrary comics
Browse files Browse the repository at this point in the history
  • Loading branch information
mdnoble73 committed Apr 27, 2024
1 parent a20b6cb commit 8c251c5
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 19 deletions.
Binary file modified code/cloud_library_export/cloud_library_export.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public CloudLibraryExporter(String serverName, Ini configIni, CloudLibrarySettin
deleteCloudLibraryItemStmt = aspenConn.prepareStatement("UPDATE cloud_library_title SET deleted = 1 where id = ?");
deleteCloudLibraryAvailabilityStmt = aspenConn.prepareStatement("DELETE FROM cloud_library_availability where id = ?");
cloudLibraryTitleHasAvailabilityStmt = aspenConn.prepareStatement("SELECT count(*) as numAvailability FROM cloud_library_availability where id = ?");
getAllExistingCloudLibraryItemsStmt = aspenConn.prepareStatement("SELECT cloud_library_title.id, cloud_library_title.cloudLibraryId, cloud_library_title.rawChecksum, deleted, cloud_library_availability.id as availabilityId from cloud_library_title left join cloud_library_availability on cloud_library_availability.cloudLibraryId = cloud_library_title.cloudLibraryId where settingId = ?");
getAllExistingCloudLibraryItemsStmt = aspenConn.prepareStatement("SELECT cloud_library_title.id, cloud_library_title.cloudLibraryId, cloud_library_title.format, cloud_library_title.rawChecksum, deleted, cloud_library_availability.id as availabilityId from cloud_library_title left join cloud_library_availability on cloud_library_availability.cloudLibraryId = cloud_library_title.cloudLibraryId where settingId = ?");

createDbLogEntry(startTime, aspenConn);
}
Expand Down Expand Up @@ -320,6 +320,7 @@ private void loadExistingTitles(long settingId) {
CloudLibraryTitle newTitle = new CloudLibraryTitle(
allRecordsRS.getLong("id"),
cloudLibraryId,
allRecordsRS.getString("format"),
allRecordsRS.getLong("rawChecksum"),
allRecordsRS.getBoolean("deleted"),
allRecordsRS.getLong("availabilityId")
Expand Down Expand Up @@ -408,7 +409,7 @@ CloudLibraryAvailability loadAvailabilityForRecord(String cloudLibraryId) {

WebServiceResponse response = callCloudLibrary(apiPath);
if (response == null) {
//Something really bad happened, we're done.
//Something bad happened, we're done.
return null;
} else if (!response.isSuccess()) {
if (response.getResponseCode() != 500) {
Expand Down Expand Up @@ -439,7 +440,7 @@ CloudLibraryAvailabilityType loadAvailabilityTypeForRecord(String cloudLibraryId

WebServiceResponse response = callCloudLibrary(apiPath);
if (response == null) {
//Something really bad happened, we're done.
//Something bad happened, we're done.
return null;
} else if (!response.isSuccess()) {
if (response.getResponseCode() != 500) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.CRC32;
Expand All @@ -23,6 +25,7 @@
import org.marc4j.marc.ControlField;
import org.marc4j.marc.DataField;
import org.marc4j.marc.MarcFactory;
import org.marc4j.marc.Subfield;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

Expand Down Expand Up @@ -282,6 +285,51 @@ private void processMarcRecord() {
}
if (format == null) {
logger.error("Format was not found");
}else if (format.equals("EPUB") || format.equals("PDF")) {
ControlField fixedField008 = (ControlField) marcRecord.getVariableField(8);
if (fixedField008 != null && fixedField008.getData().length() >= 25) {
char formatCode;
formatCode = fixedField008.getData().toUpperCase().charAt(24);
if (formatCode == '6') {
format = "eComic";
}else if (fixedField008.getData().length() >= 26) {
formatCode = fixedField008.getData().toUpperCase().charAt(25);
if (formatCode == '6') {
format = "eComic";
}else if (fixedField008.getData().length() >= 27) {
formatCode = fixedField008.getData().toUpperCase().charAt(26);
if (formatCode == '6') {
format = "eComic";
}else if (fixedField008.getData().length() >= 28) {
formatCode = fixedField008.getData().toUpperCase().charAt(27);
if (formatCode == '6') {
format = "eComic";
}
}
}
}
}
if (!format.equals("eComic")) {
List<DataField> genreFormTerm = MarcUtil.getDataFields(marcRecord, 650);
Iterator<DataField> fieldIterator = genreFormTerm.iterator();
DataField field;
while (fieldIterator.hasNext()) {
field = fieldIterator.next();
List<Subfield> subfields = field.getSubfields();
for (Subfield subfield : subfields) {
if (subfield.getCode() == 'a') {
String subfieldData = subfield.getData().toLowerCase();
if (subfieldData.contains("graphic novel")) {
format = "eComic";
if (existingTitle == null || existingTitle.getFormat() == null || !existingTitle.getFormat().equals(format)) {
metadataChanged = true;
}
break;
}
}
}
}
}
}
if (metadataChanged || doFullReload) {
logEntry.incMetadataChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
class CloudLibraryTitle {
private final long id;
private final String cloudLibraryId;
private final String format;
private final long checksum;
private final boolean deleted;
private final Long availabilityId;

CloudLibraryTitle(long id, String cloudLibraryId, long checksum, boolean deleted, Long availabilityId) {
CloudLibraryTitle(long id, String cloudLibraryId, String format, long checksum, boolean deleted, Long availabilityId) {
this.id = id;
this.cloudLibraryId = cloudLibraryId;
this.format = format;
this.checksum = checksum;
this.deleted = deleted;
this.availabilityId = availabilityId;
Expand All @@ -34,4 +36,8 @@ boolean isDeleted() {
Long getAvailabilityId(){
return availabilityId;
}

public String getFormat() {
return format;
}
}
Binary file modified code/reindexer/reindexer.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,25 @@ public void processRecord(AbstractGroupedWorkSolr groupedWork, String identifier
char formatCode;
formatCode = fixedField008.getData().toUpperCase().charAt(24);
if (formatCode == '6') {
primaryFormat = "GraphicNovel";
primaryFormat = "eComic";
}else if (fixedField008.getData().length() >= 26) {
formatCode = fixedField008.getData().toUpperCase().charAt(25);
if (formatCode == '6') {
primaryFormat = "GraphicNovel";
primaryFormat = "eComic";
}else if (fixedField008.getData().length() >= 27) {
formatCode = fixedField008.getData().toUpperCase().charAt(26);
if (formatCode == '6') {
primaryFormat = "GraphicNovel";
primaryFormat = "eComic";
}else if (fixedField008.getData().length() >= 28) {
formatCode = fixedField008.getData().toUpperCase().charAt(27);
if (formatCode == '6') {
primaryFormat = "GraphicNovel";
primaryFormat = "eComic";
}
}
}
}
}
if (!primaryFormat.equals("GraphicNovel")) {
if (!primaryFormat.equals("eComic")) {
List<DataField> genreFormTerm = MarcUtil.getDataFields(marcRecord, 650);
Iterator<DataField> fieldIterator = genreFormTerm.iterator();
DataField field;
Expand All @@ -107,14 +107,18 @@ public void processRecord(AbstractGroupedWorkSolr groupedWork, String identifier
if (subfield.getCode() == 'a') {
String subfieldData = subfield.getData().toLowerCase();
if (subfieldData.contains("graphic novel")) {
primaryFormat = "GraphicNovel";
primaryFormat = "eComic";
break;
}
}
}
}
}
break;
case "eComic":
formatCategory = "eBook";
primaryFormat = format;
break;
default:
logEntry.addNote("Unhandled cloud_library format " + format);
formatCategory = format;
Expand All @@ -138,11 +142,14 @@ public void processRecord(AbstractGroupedWorkSolr groupedWork, String identifier

//get target audience from Marc
targetAudience = productRS.getString("targetAudience");
if (targetAudience.equals("ADULT")) {
targetAudience.equals("Adult");
}
groupedWork.addTargetAudience(targetAudience);

boolean isAdult = targetAudience.equals("Adult");
boolean isTeen = targetAudience.equals("Young Adult");
boolean isKids = targetAudience.equals("Juvenile");
boolean isAdult = targetAudience.equalsIgnoreCase("Adult");
boolean isTeen = targetAudience.equalsIgnoreCase("Young Adult");
boolean isKids = targetAudience.equalsIgnoreCase("Juvenile");

//Update to create one item per settings, so we can have uniform availability at the item level
getAvailabilityStmt.setString(1, identifier);
Expand Down Expand Up @@ -221,14 +228,14 @@ public void processRecord(AbstractGroupedWorkSolr groupedWork, String identifier
okToAdd = true;
}
}
}
if (okToAdd) {
ScopingInfo scopingInfo = itemInfo.addScope(scope);
groupedWork.addScopingInfo(scope.getScopeName(), scopingInfo);
if (okToAdd) {
ScopingInfo scopingInfo = itemInfo.addScope(scope);
groupedWork.addScopingInfo(scope.getScopeName(), scopingInfo);

scopingInfo.setLibraryOwned(true);
scopingInfo.setLocallyOwned(true);
scopingInfo.setLibraryOwned(true);
scopingInfo.setLocallyOwned(true);

}
}
}
cloudLibraryRecord.addItem(itemInfo);
Expand Down

0 comments on commit 8c251c5

Please sign in to comment.