Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

24.11.00 item type as e content #132

Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,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 @@ -193,6 +194,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 @@ -882,10 +884,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/reindexer/reindexer.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +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<>();
Expand Down Expand Up @@ -288,6 +289,10 @@ 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 +302,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 +319,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 +335,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
2 changes: 2 additions & 0 deletions code/web/release_notes/24.11.00.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Indexing Updates
- Add Regular Expression field for item types to be treated as eContent to Indexing Profile in order to allow libraries to add to this. All item types currently treated as eContent are included by default. (*AB*)
13 changes: 13 additions & 0 deletions code/web/sys/DBMaintenance/version_updates/24.11.00.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

function getUpdates24_11_00(): array {
return [
'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'",
],
], //add_treatItemsAsEcontent_field
];
}
14 changes: 14 additions & 0 deletions code/web/sys/Indexing/IndexingProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ class IndexingProfile extends DataObject {
$doAutomaticEcontentSuppression;
public /** @noinspection PhpUnused */
$suppressRecordsWithUrlsMatching;
public /** @noinspection PhpUnused */
$treatItemsAsEcontent;
public /** @noinspection PhpUnused */
$determineAudienceBy;
public /** @noinspection PhpUnused */
Expand Down Expand Up @@ -493,6 +495,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 resources',
'hideInLists' => true,
'forcesReindex' => true,
],

'bCode3sToSuppress' => [
'property' => 'bCode3sToSuppress',
'hiddenByDefault' => true ,
Expand Down Expand Up @@ -1808,5 +1821,6 @@ public function getAccountProfile() : ?AccountProfile {
}
return $this->_accountProfile;
}

}

Loading