Skip to content

Commit 8c251c5

Browse files
committed
CloudLibrary comics
1 parent a20b6cb commit 8c251c5

File tree

6 files changed

+81
-19
lines changed

6 files changed

+81
-19
lines changed
809 Bytes
Binary file not shown.

code/cloud_library_export/src/com/turning_leaf_technologies/cloud_library/CloudLibraryExporter.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public CloudLibraryExporter(String serverName, Ini configIni, CloudLibrarySettin
6666
deleteCloudLibraryItemStmt = aspenConn.prepareStatement("UPDATE cloud_library_title SET deleted = 1 where id = ?");
6767
deleteCloudLibraryAvailabilityStmt = aspenConn.prepareStatement("DELETE FROM cloud_library_availability where id = ?");
6868
cloudLibraryTitleHasAvailabilityStmt = aspenConn.prepareStatement("SELECT count(*) as numAvailability FROM cloud_library_availability where id = ?");
69-
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 = ?");
69+
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 = ?");
7070

7171
createDbLogEntry(startTime, aspenConn);
7272
}
@@ -320,6 +320,7 @@ private void loadExistingTitles(long settingId) {
320320
CloudLibraryTitle newTitle = new CloudLibraryTitle(
321321
allRecordsRS.getLong("id"),
322322
cloudLibraryId,
323+
allRecordsRS.getString("format"),
323324
allRecordsRS.getLong("rawChecksum"),
324325
allRecordsRS.getBoolean("deleted"),
325326
allRecordsRS.getLong("availabilityId")
@@ -408,7 +409,7 @@ CloudLibraryAvailability loadAvailabilityForRecord(String cloudLibraryId) {
408409

409410
WebServiceResponse response = callCloudLibrary(apiPath);
410411
if (response == null) {
411-
//Something really bad happened, we're done.
412+
//Something bad happened, we're done.
412413
return null;
413414
} else if (!response.isSuccess()) {
414415
if (response.getResponseCode() != 500) {
@@ -439,7 +440,7 @@ CloudLibraryAvailabilityType loadAvailabilityTypeForRecord(String cloudLibraryId
439440

440441
WebServiceResponse response = callCloudLibrary(apiPath);
441442
if (response == null) {
442-
//Something really bad happened, we're done.
443+
//Something bad happened, we're done.
443444
return null;
444445
} else if (!response.isSuccess()) {
445446
if (response.getResponseCode() != 500) {

code/cloud_library_export/src/com/turning_leaf_technologies/cloud_library/CloudLibraryMarcHandler.java

+48
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import java.sql.ResultSet;
1313
import java.sql.SQLException;
1414
import java.util.HashMap;
15+
import java.util.Iterator;
16+
import java.util.List;
1517
import java.util.Set;
1618
import java.util.regex.Pattern;
1719
import java.util.zip.CRC32;
@@ -23,6 +25,7 @@
2325
import org.marc4j.marc.ControlField;
2426
import org.marc4j.marc.DataField;
2527
import org.marc4j.marc.MarcFactory;
28+
import org.marc4j.marc.Subfield;
2629
import org.xml.sax.Attributes;
2730
import org.xml.sax.helpers.DefaultHandler;
2831

@@ -282,6 +285,51 @@ private void processMarcRecord() {
282285
}
283286
if (format == null) {
284287
logger.error("Format was not found");
288+
}else if (format.equals("EPUB") || format.equals("PDF")) {
289+
ControlField fixedField008 = (ControlField) marcRecord.getVariableField(8);
290+
if (fixedField008 != null && fixedField008.getData().length() >= 25) {
291+
char formatCode;
292+
formatCode = fixedField008.getData().toUpperCase().charAt(24);
293+
if (formatCode == '6') {
294+
format = "eComic";
295+
}else if (fixedField008.getData().length() >= 26) {
296+
formatCode = fixedField008.getData().toUpperCase().charAt(25);
297+
if (formatCode == '6') {
298+
format = "eComic";
299+
}else if (fixedField008.getData().length() >= 27) {
300+
formatCode = fixedField008.getData().toUpperCase().charAt(26);
301+
if (formatCode == '6') {
302+
format = "eComic";
303+
}else if (fixedField008.getData().length() >= 28) {
304+
formatCode = fixedField008.getData().toUpperCase().charAt(27);
305+
if (formatCode == '6') {
306+
format = "eComic";
307+
}
308+
}
309+
}
310+
}
311+
}
312+
if (!format.equals("eComic")) {
313+
List<DataField> genreFormTerm = MarcUtil.getDataFields(marcRecord, 650);
314+
Iterator<DataField> fieldIterator = genreFormTerm.iterator();
315+
DataField field;
316+
while (fieldIterator.hasNext()) {
317+
field = fieldIterator.next();
318+
List<Subfield> subfields = field.getSubfields();
319+
for (Subfield subfield : subfields) {
320+
if (subfield.getCode() == 'a') {
321+
String subfieldData = subfield.getData().toLowerCase();
322+
if (subfieldData.contains("graphic novel")) {
323+
format = "eComic";
324+
if (existingTitle == null || existingTitle.getFormat() == null || !existingTitle.getFormat().equals(format)) {
325+
metadataChanged = true;
326+
}
327+
break;
328+
}
329+
}
330+
}
331+
}
332+
}
285333
}
286334
if (metadataChanged || doFullReload) {
287335
logEntry.incMetadataChanges();

code/cloud_library_export/src/com/turning_leaf_technologies/cloud_library/CloudLibraryTitle.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
class CloudLibraryTitle {
44
private final long id;
55
private final String cloudLibraryId;
6+
private final String format;
67
private final long checksum;
78
private final boolean deleted;
89
private final Long availabilityId;
910

10-
CloudLibraryTitle(long id, String cloudLibraryId, long checksum, boolean deleted, Long availabilityId) {
11+
CloudLibraryTitle(long id, String cloudLibraryId, String format, long checksum, boolean deleted, Long availabilityId) {
1112
this.id = id;
1213
this.cloudLibraryId = cloudLibraryId;
14+
this.format = format;
1315
this.checksum = checksum;
1416
this.deleted = deleted;
1517
this.availabilityId = availabilityId;
@@ -34,4 +36,8 @@ boolean isDeleted() {
3436
Long getAvailabilityId(){
3537
return availabilityId;
3638
}
39+
40+
public String getFormat() {
41+
return format;
42+
}
3743
}

code/reindexer/reindexer.jar

100 Bytes
Binary file not shown.

code/reindexer/src/org/aspen_discovery/reindexer/CloudLibraryProcessor.java

+22-15
Original file line numberDiff line numberDiff line change
@@ -78,25 +78,25 @@ public void processRecord(AbstractGroupedWorkSolr groupedWork, String identifier
7878
char formatCode;
7979
formatCode = fixedField008.getData().toUpperCase().charAt(24);
8080
if (formatCode == '6') {
81-
primaryFormat = "GraphicNovel";
81+
primaryFormat = "eComic";
8282
}else if (fixedField008.getData().length() >= 26) {
8383
formatCode = fixedField008.getData().toUpperCase().charAt(25);
8484
if (formatCode == '6') {
85-
primaryFormat = "GraphicNovel";
85+
primaryFormat = "eComic";
8686
}else if (fixedField008.getData().length() >= 27) {
8787
formatCode = fixedField008.getData().toUpperCase().charAt(26);
8888
if (formatCode == '6') {
89-
primaryFormat = "GraphicNovel";
89+
primaryFormat = "eComic";
9090
}else if (fixedField008.getData().length() >= 28) {
9191
formatCode = fixedField008.getData().toUpperCase().charAt(27);
9292
if (formatCode == '6') {
93-
primaryFormat = "GraphicNovel";
93+
primaryFormat = "eComic";
9494
}
9595
}
9696
}
9797
}
9898
}
99-
if (!primaryFormat.equals("GraphicNovel")) {
99+
if (!primaryFormat.equals("eComic")) {
100100
List<DataField> genreFormTerm = MarcUtil.getDataFields(marcRecord, 650);
101101
Iterator<DataField> fieldIterator = genreFormTerm.iterator();
102102
DataField field;
@@ -107,14 +107,18 @@ public void processRecord(AbstractGroupedWorkSolr groupedWork, String identifier
107107
if (subfield.getCode() == 'a') {
108108
String subfieldData = subfield.getData().toLowerCase();
109109
if (subfieldData.contains("graphic novel")) {
110-
primaryFormat = "GraphicNovel";
110+
primaryFormat = "eComic";
111111
break;
112112
}
113113
}
114114
}
115115
}
116116
}
117117
break;
118+
case "eComic":
119+
formatCategory = "eBook";
120+
primaryFormat = format;
121+
break;
118122
default:
119123
logEntry.addNote("Unhandled cloud_library format " + format);
120124
formatCategory = format;
@@ -138,11 +142,14 @@ public void processRecord(AbstractGroupedWorkSolr groupedWork, String identifier
138142

139143
//get target audience from Marc
140144
targetAudience = productRS.getString("targetAudience");
145+
if (targetAudience.equals("ADULT")) {
146+
targetAudience.equals("Adult");
147+
}
141148
groupedWork.addTargetAudience(targetAudience);
142149

143-
boolean isAdult = targetAudience.equals("Adult");
144-
boolean isTeen = targetAudience.equals("Young Adult");
145-
boolean isKids = targetAudience.equals("Juvenile");
150+
boolean isAdult = targetAudience.equalsIgnoreCase("Adult");
151+
boolean isTeen = targetAudience.equalsIgnoreCase("Young Adult");
152+
boolean isKids = targetAudience.equalsIgnoreCase("Juvenile");
146153

147154
//Update to create one item per settings, so we can have uniform availability at the item level
148155
getAvailabilityStmt.setString(1, identifier);
@@ -221,14 +228,14 @@ public void processRecord(AbstractGroupedWorkSolr groupedWork, String identifier
221228
okToAdd = true;
222229
}
223230
}
224-
}
225-
if (okToAdd) {
226-
ScopingInfo scopingInfo = itemInfo.addScope(scope);
227-
groupedWork.addScopingInfo(scope.getScopeName(), scopingInfo);
231+
if (okToAdd) {
232+
ScopingInfo scopingInfo = itemInfo.addScope(scope);
233+
groupedWork.addScopingInfo(scope.getScopeName(), scopingInfo);
228234

229-
scopingInfo.setLibraryOwned(true);
230-
scopingInfo.setLocallyOwned(true);
235+
scopingInfo.setLibraryOwned(true);
236+
scopingInfo.setLocallyOwned(true);
231237

238+
}
232239
}
233240
}
234241
cloudLibraryRecord.addItem(itemInfo);

0 commit comments

Comments
 (0)