Skip to content

Commit

Permalink
Merge pull request #140 from AlexanderBlanchardAC/24.12.00_treat_item…
Browse files Browse the repository at this point in the history
…_type_as_econtent

24.12.00 treat item type as econtent
  • Loading branch information
AlexanderBlanchardAC authored Nov 15, 2024
2 parents 3d85819 + 0580f86 commit 253c5d1
Show file tree
Hide file tree
Showing 25 changed files with 44 additions and 3 deletions.
Binary file modified code/axis_360_export/axis_360_export.jar
Binary file not shown.
Binary file modified code/carlx_export/carlx_export.jar
Binary file not shown.
Binary file modified code/cloud_library_export/cloud_library_export.jar
Binary file not shown.
Binary file modified code/course_reserves_indexer/course_reserves_indexer.jar
Binary file not shown.
Binary file modified code/cron/cron.jar
Binary file not shown.
Binary file modified code/events_indexer/events_indexer.jar
Binary file not shown.
Binary file modified code/evergreen_export/evergreen_export.jar
Binary file not shown.
Binary file modified code/evolve_export/evolve_export.jar
Binary file not shown.
Binary file modified code/hoopla_export/hoopla_export.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public class IndexingProfile extends BaseIndexingSettings {
private long lastUpdateOfAuthorities;
private long lastChangeProcessed;
private Pattern suppressRecordsWithUrlsMatching;
private Pattern treatItemsAsEcontent;
private String fallbackFormatField;
private boolean processRecordLinking;
private int evergreenOrgUnitSchema;
Expand Down Expand Up @@ -194,6 +195,7 @@ public IndexingProfile(String serverName, ResultSet indexingProfileRS, Connectio

this.setDoAutomaticEcontentSuppression(indexingProfileRS.getBoolean("doAutomaticEcontentSuppression"));
this.setSuppressRecordsWithUrlsMatching(indexingProfileRS.getString("suppressRecordsWithUrlsMatching"));
this.setTreatItemsAsEcontent(indexingProfileRS.getString("treatItemsAsEcontent"));
this.setEContentDescriptor(getCharFromRecordSet(indexingProfileRS, "eContentDescriptor"));

this.setLastYearCheckoutsSubfield(getCharFromRecordSet(indexingProfileRS, "lastYearCheckouts"));
Expand Down Expand Up @@ -892,10 +894,22 @@ public void setSuppressRecordsWithUrlsMatching(String suppressRecordsWithUrlsMat
}
}

public void setTreatItemsAsEcontent(String treatItemsAsEcontent) {
if (treatItemsAsEcontent.isEmpty()){
this.treatItemsAsEcontent = null;
} else {
this.treatItemsAsEcontent = Pattern.compile(treatItemsAsEcontent, Pattern.CASE_INSENSITIVE);
}
}

public Pattern getSuppressRecordsWithUrlsMatching() {
return suppressRecordsWithUrlsMatching;
}

public Pattern getTreatItemsAsEcontent() {
return treatItemsAsEcontent;
}

public void setFallbackFormatField(String fallbackFormatField) {
this.fallbackFormatField = fallbackFormatField;
}
Expand Down
Binary file modified code/koha_export/koha_export.jar
Binary file not shown.
Binary file modified code/oai_indexer/oai_indexer.jar
Binary file not shown.
Binary file modified code/overdrive_extract/overdrive_extract.jar
Binary file not shown.
Binary file modified code/palace_project_export/palace_project_export.jar
Binary file not shown.
Binary file modified code/polaris_export/polaris_export.jar
Binary file not shown.
Binary file modified code/reindexer/reindexer.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.nio.charset.StandardCharsets;
import java.sql.*;
import java.util.*;

import java.util.regex.Pattern;
class KohaRecordProcessor extends IlsRecordProcessor {
private final HashSet<String> inTransitItems = new HashSet<>();
private final HashSet<String> onHoldShelfItems = new HashSet<>();
Expand Down Expand Up @@ -288,6 +288,8 @@ private String getStatusFromSubfield(DataField itemField, char subfield, String

protected StringBuilder loadUnsuppressedPrintItems(AbstractGroupedWorkSolr groupedWork, RecordInfo recordInfo, String identifier, Record record, StringBuilder suppressionNotes){
List<DataField> itemRecords = MarcUtil.getDataFields(record, settings.getItemTagInt());
//Retrieve the eContent type Regex from the indexing profile
Pattern eContentTypeRegex = settings.getTreatItemsAsEcontent();
for (DataField itemField : itemRecords){
String itemIdentifier = MarcUtil.getItemSubfieldData(settings.getItemRecordNumberSubfield(), itemField, indexer.getLogEntry(), logger);
ResultWithNotes isSuppressed = isItemSuppressed(itemField, itemIdentifier, suppressionNotes);
Expand All @@ -297,7 +299,7 @@ protected StringBuilder loadUnsuppressedPrintItems(AbstractGroupedWorkSolr group
boolean isEContent = false;
if (itemField.getSubfield(settings.getITypeSubfield()) != null){
String iType = itemField.getSubfield(settings.getITypeSubfield()).getData().toLowerCase().trim();
if (iType.equals("ebook") || iType.equals("ebk") || iType.equals("eaudio") || iType.equals("evideo") || iType.equals("online") || iType.equals("oneclick") || iType.equals("eaudiobook") || iType.equals("download")){
if (eContentTypeRegex.matcher(iType).matches()){
isEContent = true;
}
}
Expand All @@ -314,6 +316,9 @@ protected List<RecordInfo> loadUnsuppressedEContentItems(AbstractGroupedWorkSolr
List<DataField> itemRecords = MarcUtil.getDataFields(record, settings.getItemTagInt());
List<RecordInfo> unsuppressedEcontentRecords = new ArrayList<>();

//Retrieve the Regex for eContent types from the indexing profile
Pattern eContentTypeRegex = settings.getTreatItemsAsEcontent();

for (DataField itemField : itemRecords){
String itemIdentifier = MarcUtil.getItemSubfieldData(settings.getItemRecordNumberSubfield(), itemField, indexer.getLogEntry(), logger);
ResultWithNotes isSuppressed = isItemSuppressed(itemField, itemIdentifier, suppressionNotes);
Expand All @@ -327,7 +332,7 @@ protected List<RecordInfo> loadUnsuppressedEContentItems(AbstractGroupedWorkSolr
boolean isOneClickDigital = false;
if (itemField.getSubfield(settings.getITypeSubfield()) != null){
String iType = itemField.getSubfield(settings.getITypeSubfield()).getData().toLowerCase().trim();
if (iType.equals("ebook") || iType.equals("ebk") || iType.equals("eaudio") || iType.equals("evideo") || iType.equals("online") || iType.equals("oneclick") || iType.equals("eaudiobook") || iType.equals("download")){
if (eContentTypeRegex.matcher(iType).matches()){
isEContent = true;
String sourceType = getSourceType(record, itemField);
if (sourceType != null){
Expand Down
Binary file modified code/sideload_processing/sideload_processing.jar
Binary file not shown.
Binary file modified code/sierra_export_api/sierra_export_api.jar
Binary file not shown.
Binary file modified code/symphony_export/symphony_export.jar
Binary file not shown.
Binary file modified code/user_list_indexer/user_list_indexer.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions code/web/release_notes/24.12.00.MD
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// james staub - Nashville

// alexander - PTFSE
### Other Updates
- Add Regular Expression field for item types to be treated as eContent to Indexing Profiles in order to allow libraries to add to this. All item types currently treated as eContent are included by default. (*AB*)

// Chloe - PTFSE

Expand Down
7 changes: 7 additions & 0 deletions code/web/sys/DBMaintenance/version_updates/24.12.00.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ function getUpdates24_12_00(): array {


//alexander - PTFS-Europe
'add_regular_expression_for_iTypes_to_treat_as_eContent' => [
'title' => 'Add Regular Expression For iTypes To Treat As Econtent',
'description' => 'Add treatItemsAsEcontent to give control over iTypes to be treated as eContent',
'sql' => [
"ALTER TABLE indexing_profiles ADD COLUMN treatItemsAsEcontent VARCHAR(512) DEFAULT 'ebook|ebk|eaudio|evideo|online|oneclick|eaudiobook|download|eresource|electronic resource'",
],
], //add_treatItemsAsEcontent_field

//chloe - PTFS-Europe

Expand Down
13 changes: 13 additions & 0 deletions code/web/sys/Indexing/IndexingProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ class IndexingProfile extends DataObject {
$iCode2sToSuppress;
public /** @noinspection PhpUnused */
$bCode3sToSuppress;
public /** @noinspection PhpUnused */
$treatItemsAsEcontent;
public $format;
public $useSierraMatTypeForFormat;
public /** @noinspection PhpUnused */
Expand Down Expand Up @@ -502,6 +504,17 @@ static function getObjectStructure($context = ''): array {
'forcesReindex' => true,
],

'treatItemsAsEcontent' => [
'property' => 'treatItemsAsEcontent',
'hiddenByDefault' => true,
'type' => 'regularExpression',
'label' => 'Treat Item Types As eContent',
'description' => 'Any records with an item type matching the pattern will be treated as eContent',
'defaultValue' => 'ebook|ebk|eaudio|evideo|online|oneclick|eaudiobook|download|eresource|electronic resource',
'hideInLists' => true,
'forcesReindex' => true,
],

'determineAudienceBy' => [
'property' => 'determineAudienceBy',
'hiddenByDefault' => true ,
Expand Down
Binary file modified code/web_indexer/web_indexer.jar
Binary file not shown.

0 comments on commit 253c5d1

Please sign in to comment.