Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…overy into 24.06.00
  • Loading branch information
catsoup11789 committed Jun 5, 2024
2 parents 47979a3 + d957d1f commit 26bfbd2
Show file tree
Hide file tree
Showing 38 changed files with 502 additions and 159 deletions.
Binary file modified code/carlx_export/carlx_export.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static void main(String[] args) {
if (extractSingleWork && singleWorkId == null) {
singleWorkId = AspenStringUtils.getInputFromCommandLine("Enter the id of the title to extract");
singleWorkId = StringUtils.replace(singleWorkId,"CARL", "");
//Strip leading zeroes
singleWorkId = Integer.toString(Integer.parseInt(singleWorkId));
}

Expand Down Expand Up @@ -184,8 +185,6 @@ public static void main(String[] args) {
} else {
logEntry.incErrors("Did not export holds because connection to the CARL.X database was not established");
}

processRecordsToReload(indexingProfile, logEntry);
}

logEntry.setFinished();
Expand Down Expand Up @@ -278,7 +277,7 @@ private static void disconnectDatabase(Connection dbConn) {
}
}

private static void processRecordsToReload(IndexingProfile indexingProfile, IlsExtractLogEntry logEntry) {
private static void loadRecordsToReload(HashSet<String> updatedBibs, IndexingProfile indexingProfile, IlsExtractLogEntry logEntry) {
try {
PreparedStatement getRecordsToReloadStmt = dbConn.prepareStatement("SELECT * from record_identifiers_to_reload WHERE processed = 0 and type='" + indexingProfile.getName() + "'", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
PreparedStatement markRecordToReloadAsProcessedStmt = dbConn.prepareStatement("UPDATE record_identifiers_to_reload SET processed = 1 where id = ?");
Expand All @@ -287,21 +286,17 @@ private static void processRecordsToReload(IndexingProfile indexingProfile, IlsE
while (getRecordsToReloadRS.next()) {
long recordToReloadId = getRecordsToReloadRS.getLong("id");
String recordIdentifier = getRecordsToReloadRS.getString("identifier");
org.marc4j.marc.Record marcRecord = getGroupedWorkIndexer(dbConn).loadMarcRecordFromDatabase(indexingProfile.getName(), recordIdentifier, logEntry);
if (marcRecord != null) {
logEntry.incRecordsRegrouped();
//Regroup the record
String groupedWorkId = getRecordGroupingProcessor(dbConn).processMarcRecord(marcRecord, true, null, getGroupedWorkIndexer(dbConn));
//Reindex the record
getGroupedWorkIndexer(dbConn).processGroupedWork(groupedWorkId);
}
recordIdentifier = StringUtils.replace(recordIdentifier,"CARL", "");
//Strip leading zeroes
recordIdentifier = Integer.toString(Integer.parseInt(recordIdentifier));
updatedBibs.add(recordIdentifier);

markRecordToReloadAsProcessedStmt.setLong(1, recordToReloadId);
markRecordToReloadAsProcessedStmt.executeUpdate();
numRecordsToReloadProcessed++;
}
if (numRecordsToReloadProcessed > 0) {
logEntry.addNote("Regrouped " + numRecordsToReloadProcessed + " records marked for reprocessing");
logEntry.addNote("Loaded " + numRecordsToReloadProcessed + " records marked for reprocessing");
}
getRecordsToReloadRS.close();
}catch (Exception e){
Expand Down Expand Up @@ -627,6 +622,11 @@ private static int updateRecordsUsingAPI(Connection dbConn, CarlXInstanceInforma
}
}

//Add any records that have been marked for reprocessing
if (singleWorkId == null) {
loadRecordsToReload(updatedBibs, indexingProfile, logEntry);
}

//Update total products to be processed
logEntry.setNumProducts(updatedBibs.size() + createdBibs.size() + deletedBibs.size());

Expand Down
Binary file modified code/cron/cron.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,15 @@ private void removeOldSearches(Connection dbConn, Logger logger, CronProcessLogE
//Remove old searches
try {
int rowsRemoved = 0;
ResultSet numSearchesRS = dbConn.prepareStatement("SELECT count(id) from search where created < (CURDATE() - INTERVAL 2 DAY) and saved = 0").executeQuery();
ResultSet numSearchesRS = dbConn.prepareStatement("SELECT count(id) from search where saved = 0").executeQuery();
numSearchesRS.next();
long numSearches = numSearchesRS.getLong(1);
long batchSize = 100000;
long numBatches = (numSearches / batchSize) + 1;
processLog.addNote("Found " + numSearches + " expired searches that need to be removed. Will process in " + numBatches + " batches");
processLog.saveResults();
for (int i = 0; i < numBatches; i++){
PreparedStatement searchesToRemove = dbConn.prepareStatement("SELECT id from search where created < (CURDATE() - INTERVAL 2 DAY) and saved = 0 LIMIT 0, " + batchSize, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
PreparedStatement searchesToRemove = dbConn.prepareStatement("SELECT id from search where saved = 0 LIMIT 0, " + batchSize, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
PreparedStatement removeSearchStmt = dbConn.prepareStatement("DELETE from search where id = ?");

ResultSet searchesToRemoveRs = searchesToRemove.executeQuery();
Expand Down
Binary file modified code/evergreen_export/evergreen_export.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ public static void main(String[] args) {
logEntry.incErrors("Could not load account profile.");
}

if (!extractSingleWork) {
processRecordsToReload(indexingProfile, logEntry);
}

if (recordGroupingProcessorSingleton != null) {
recordGroupingProcessorSingleton.close();
recordGroupingProcessorSingleton = null;
Expand Down Expand Up @@ -702,28 +698,30 @@ private synchronized static GroupedWorkIndexer getGroupedWorkIndexer() {

private static void processRecordsToReload(IndexingProfile indexingProfile, IlsExtractLogEntry logEntry) {
try {
MarcFactory marcFactory = MarcFactory.newInstance();

PreparedStatement getRecordsToReloadStmt = dbConn.prepareStatement("SELECT * from record_identifiers_to_reload WHERE processed = 0 and type='" + indexingProfile.getName() + "'", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
PreparedStatement markRecordToReloadAsProcessedStmt = dbConn.prepareStatement("UPDATE record_identifiers_to_reload SET processed = 1 where id = ?");
ResultSet getRecordsToReloadRS = getRecordsToReloadStmt.executeQuery();
int numRecordsToReloadProcessed = 0;
while (getRecordsToReloadRS.next()) {
long recordToReloadId = getRecordsToReloadRS.getLong("id");
String recordIdentifier = getRecordsToReloadRS.getString("identifier");
org.marc4j.marc.Record marcRecord = getGroupedWorkIndexer().loadMarcRecordFromDatabase(indexingProfile.getName(), recordIdentifier, logEntry);
if (marcRecord != null){
logEntry.incRecordsRegrouped();
//Regroup the record
String groupedWorkId = groupEvergreenRecord(marcRecord);
//Reindex the record
getGroupedWorkIndexer().processGroupedWork(groupedWorkId);
}
updateBibFromEvergreen(recordIdentifier, marcFactory, true);

markRecordToReloadAsProcessedStmt.setLong(1, recordToReloadId);
markRecordToReloadAsProcessedStmt.executeUpdate();
numRecordsToReloadProcessed++;

logEntry.incProducts();
logEntry.incUpdated();
if (numRecordsToReloadProcessed > 0 && numRecordsToReloadProcessed % 250 == 0) {
getGroupedWorkIndexer().commitChanges();
logEntry.saveResults();
}
}
if (numRecordsToReloadProcessed > 0) {
logEntry.addNote("Regrouped " + numRecordsToReloadProcessed + " records marked for reprocessing");
logEntry.addNote("Processed " + numRecordsToReloadProcessed + " records marked for reprocessing");
}
getRecordsToReloadRS.close();
}catch (Exception e){
Expand Down Expand Up @@ -855,6 +853,8 @@ private static int updateRecords() {
}
}

processRecordsToReload(indexingProfile, logEntry);

return totalChanges;
}

Expand Down
Binary file modified code/koha_export/koha_export.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1560,21 +1560,20 @@ private static void processRecordsToReload(IndexingProfile indexingProfile, IlsE
while (getRecordsToReloadRS.next()) {
long recordToReloadId = getRecordsToReloadRS.getLong("id");
String recordIdentifier = getRecordsToReloadRS.getString("identifier");
Record marcRecord = getGroupedWorkIndexer().loadMarcRecordFromDatabase(indexingProfile.getName(), recordIdentifier, logEntry);
if (marcRecord != null){
logEntry.incRecordsRegrouped();
//Regroup the record
String groupedWorkId = groupKohaRecord(marcRecord);
//Reindex the record
getGroupedWorkIndexer().processGroupedWork(groupedWorkId);
}
logEntry.incProducts();
updateBibRecord(recordIdentifier);

markRecordToReloadAsProcessedStmt.setLong(1, recordToReloadId);
markRecordToReloadAsProcessedStmt.executeUpdate();
numRecordsToReloadProcessed++;

if (numRecordsToReloadProcessed > 0 && numRecordsToReloadProcessed % 250 == 0) {
getGroupedWorkIndexer().commitChanges();
logEntry.saveResults();
}
}
if (numRecordsToReloadProcessed > 0) {
logEntry.addNote("Regrouped " + numRecordsToReloadProcessed + " records marked for reprocessing");
logEntry.addNote("Processed " + numRecordsToReloadProcessed + " records marked for reprocessing");
logEntry.saveResults();
}
getRecordsToReloadRS.close();
Expand Down
Binary file modified code/polaris_export/polaris_export.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -643,21 +643,14 @@ private static void processRecordsToReload(IndexingProfile indexingProfile, IlsE
while (getRecordsToReloadRS.next()) {
long recordToReloadId = getRecordsToReloadRS.getLong("id");
String recordIdentifier = getRecordsToReloadRS.getString("identifier");
org.marc4j.marc.Record marcRecord = getGroupedWorkIndexer().loadMarcRecordFromDatabase(indexingProfile.getName(), recordIdentifier, logEntry);
if (marcRecord != null){
logEntry.incRecordsRegrouped();
//Regroup the record
String groupedWorkId = groupPolarisRecord(marcRecord);
//Reindex the record
getGroupedWorkIndexer().processGroupedWork(groupedWorkId);
}
updateBibFromPolaris(recordIdentifier, null, 0, true);

markRecordToReloadAsProcessedStmt.setLong(1, recordToReloadId);
markRecordToReloadAsProcessedStmt.executeUpdate();
numRecordsToReloadProcessed++;
}
if (numRecordsToReloadProcessed > 0) {
logEntry.addNote("Regrouped " + numRecordsToReloadProcessed + " records marked for reprocessing");
logEntry.addNote("Processed " + numRecordsToReloadProcessed + " records marked for reprocessing");
logEntry.saveResults();
}
getRecordsToReloadRS.close();
Expand Down Expand Up @@ -954,7 +947,7 @@ private static int updateBibsFromPolaris(long lastExtractTime) {
}
logEntry.saveResults();
} catch (Exception e) {
logEntry.incErrors("Unable to parse document for replaced bubs response", e);
logEntry.incErrors("Unable to parse document for replaced bibs response", e);
}
}

Expand Down
Binary file modified code/sierra_export_api/sierra_export_api.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,14 @@ public static void main(String[] args){
getBibsAndItemUpdatesFromSierra(sierraInstanceInformation, sierraConn);
}

loadRecordsToReload(indexingProfile, logEntry);

logEntry.setNumProducts(allBibsToUpdate.size());
logEntry.saveResults();

numChanges = updateBibs(sierraInstanceInformation);

processRecordsToReload(indexingProfile, logEntry);


if (sierraConn != null){
try{
Expand Down Expand Up @@ -355,7 +357,7 @@ private static void disconnectDatabase() {
}
}

private static void processRecordsToReload(IndexingProfile indexingProfile, IlsExtractLogEntry logEntry) {
private static void loadRecordsToReload(IndexingProfile indexingProfile, IlsExtractLogEntry logEntry) {
try {
PreparedStatement getRecordsToReloadStmt = dbConn.prepareStatement("SELECT * from record_identifiers_to_reload WHERE processed = 0 and type='" + indexingProfile.getName() + "'", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
PreparedStatement markRecordToReloadAsProcessedStmt = dbConn.prepareStatement("UPDATE record_identifiers_to_reload SET processed = 1 where id = ?");
Expand All @@ -364,20 +366,17 @@ private static void processRecordsToReload(IndexingProfile indexingProfile, IlsE
while (getRecordsToReloadRS.next()) {
long recordToReloadId = getRecordsToReloadRS.getLong("id");
String recordIdentifier = getRecordsToReloadRS.getString("identifier");
org.marc4j.marc.Record marcRecord = getGroupedWorkIndexer().loadMarcRecordFromDatabase(indexingProfile.getName(), recordIdentifier, logEntry);
if (marcRecord != null){
//Regroup the record
String groupedWorkId = groupSierraRecord(marcRecord);
//Reindex the record
getGroupedWorkIndexer().processGroupedWork(groupedWorkId);
if (recordIdentifier.startsWith(".b")){
recordIdentifier = recordIdentifier.substring(2, recordIdentifier.length() -1);
}
allBibsToUpdate.add(recordIdentifier);

markRecordToReloadAsProcessedStmt.setLong(1, recordToReloadId);
markRecordToReloadAsProcessedStmt.executeUpdate();
numRecordsToReloadProcessed++;
}
if (numRecordsToReloadProcessed > 0) {
logEntry.addNote("Regrouped " + numRecordsToReloadProcessed + " records marked for reprocessing");
logEntry.addNote("Loaded " + numRecordsToReloadProcessed + " records marked for reprocessing");
}
getRecordsToReloadRS.close();
}catch (Exception e){
Expand Down
8 changes: 4 additions & 4 deletions code/web/Drivers/Koha.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function updatePatronInfo($patron, $canUpdateContactInfo, $fromMasquerade = fals
$loginResult = $this->loginToKohaOpac($patron);
if ($loginResult['success']) {

$updatePage = $this->getKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl');
$updatePage = $this->getKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl?DISABLE_SYSPREF_OPACUserCSS=1');
//Get the csr token
$csr_token = '';
if (preg_match('%<input type="hidden" name="csrf_token" value="(.*?)" />%s', $updatePage, $matches)) {
Expand Down Expand Up @@ -367,7 +367,7 @@ function updatePatronInfo($patron, $canUpdateContactInfo, $fromMasquerade = fals
$postVariables['resendEmail'] = strip_tags($_REQUEST['resendEmail']);
}

$postResults = $this->postToKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl', $postVariables);
$postResults = $this->postToKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl?DISABLE_SYSPREF_OPACUserCSS=1', $postVariables);

$messageInformation = [];
if (preg_match('%<div class="alert alert-danger">(.*?)</div>%s', $postResults, $messageInformation)) {
Expand Down Expand Up @@ -4476,7 +4476,7 @@ function selfRegister(): array {

if ($this->getKohaVersion() < 20.05) {
$catalogUrl = $this->accountProfile->vendorOpacUrl;
$selfRegPage = $this->getKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl');
$selfRegPage = $this->getKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl?DISABLE_SYSPREF_OPACUserCSS=1');
$captcha = '';
$captchaDigest = '';
$captchaInfo = [];
Expand Down Expand Up @@ -4540,7 +4540,7 @@ function selfRegister(): array {
$postFields['action'] = 'create';
$headers = ['Content-Type: application/x-www-form-urlencoded'];
$this->opacCurlWrapper->addCustomHeaders($headers, false);
$selfRegPageResponse = $this->postToKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl', $postFields);
$selfRegPageResponse = $this->postToKohaPage($catalogUrl . '/cgi-bin/koha/opac-memberentry.pl?DISABLE_SYSPREF_OPACUserCSS=1', $postFields);

$matches = [];
if (preg_match('%<h1>Registration Complete!</h1>.*?<span id="patron-userid">(.*?)</span>.*?<span id="patron-password">(.*?)</span>.*?<span id="patron-cardnumber">(.*?)</span>%s', $selfRegPageResponse, $matches)) {
Expand Down
9 changes: 7 additions & 2 deletions code/web/RecordDrivers/SideLoadedRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ function getEContentFormat($fileOrUrl, $iType) {
return '';
}

function createActionsFromUrls($relatedUrls, $itemInfo = null, $variationId = 'any') {
/** @var SideLoad[] $sideLoadSettings */ global $sideLoadSettings;
function createActionsFromUrls($relatedUrls, $itemInfo = null, $variationId = 'any') : array {
global $sideLoadSettings;
$sideLoad = $sideLoadSettings[strtolower($this->profileType)];

global $configArray;
Expand Down Expand Up @@ -146,6 +146,9 @@ function createActionsFromUrls($relatedUrls, $itemInfo = null, $variationId = 'a
]);
}
$action = $configArray['Site']['url'] . '/' . $this->getModule() . '/' . $this->id . "/AccessOnline?index=$i";
if ($itemInfo != null) {
$action .= '&itemId=' . $itemInfo->itemId;
}
$fileOrUrl = isset($urlInfo['url']) ? $urlInfo['url'] : $urlInfo['file'];
if (strlen($fileOrUrl) > 0) {
$actions[] = [
Expand All @@ -154,6 +157,8 @@ function createActionsFromUrls($relatedUrls, $itemInfo = null, $variationId = 'a
'title' => $title,
'requireLogin' => false,
'target' => '_blank',
'itemId' => $itemInfo->itemId,
'index' => $i
];
$i++;
}
Expand Down
27 changes: 18 additions & 9 deletions code/web/RecordDrivers/SummonRecordDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ public function isValid() {
}

public function getBookcoverUrl($size='large', $absolutePath = false) {
// require_once ROOT_DIR . '/sys/LibraryLocation/Library.php';
global $library;

global $configArray;
if ($size == 'small' || $size == 'medium'){
$sizeInArray = 'thumbnail_m';
}else{
$sizeInArray = 'thumbnail_l';
}
if (!empty($this->record[$sizeInArray][0])) {
$imageDimensions = getimagesize($this->record[$sizeInArray][0]);
if ($sizeInArray == 'thumbnail_m' && $imageDimensions[0] > 10) {
return $this->record[$sizeInArray][0];
} elseif ($sizeInArray == 'thumbnail_l' && $imageDimensions[0] > 10) {
return $this->record[$sizeInArray][0];
}

if ($library->showAvailableCoversInSummon) {
if(!empty($this->record[$sizeInArray][0])){
$imagePath = $this->record[$sizeInArray][0];

$imageDimensions = getImageSize($imagePath);
if($imageDimensions[0] > 10){
return $imagePath;
}
}
}
if ($absolutePath) {
$bookCoverUrl = $configArray['Site']['url'];
Expand Down Expand Up @@ -242,6 +248,9 @@ public function getStaffView() {
public function getTitle() {
if (isset($this->record['Title'])) {
$title=$this->record['Title'][0];
if (isset($this->record['Subtitle'])) {
$title .= ': ' . $this->record['Subtitle'][0];
}
} else {
$title='Unknown Title';
}
Expand Down Expand Up @@ -339,8 +348,8 @@ public function getPrimaryAuthor() {
}

public function getAuthor() {
if(isset($this->record['Author'][0])) {
$author=$this->record['Author'][0];
if(isset($this->record['Author_xml'][0]['fullname'])) {
$author=$this->record['Author_xml'][0]['fullname'];
} else {
$author='Unknown Title';
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<form id="copyFacetGroupForm" class="form-horizontal" role="form">
<input type="hidden" name="facetGroupId" id="facetGroupId" value="{$facetId}"/>
<div class="form-group col-xs-12">
<label for="groupName" class="control-label">{translate text="Name for New Group" isAdminFacing=true}</label>
<input type="text" id="groupName" name="groupName" class="form-control">
</div>
</form>
Loading

0 comments on commit 26bfbd2

Please sign in to comment.