- solr.xslt autor and author_sort are now sorted by @SortOrder

- composer updates
- new artisan command 'update:dataset {dataset : The ID of the dataset}' for updating solr index for specific datasets
- DatasetExtension.php: alaso svae 'sort_order' for authors and contributors
- twice solr.xslt: sort authors also in solr index
This commit is contained in:
Arno Kaimbacher 2020-10-01 18:38:31 +02:00
parent 30afb3b1f8
commit 390b2396eb
8 changed files with 226 additions and 89 deletions

View file

@ -0,0 +1,55 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Dataset;
use App\Library\Search\SolariumAdapter;
use \Exception;
class UpdateSolrDataset extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'update:dataset {dataset : The ID of the dataset}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Update solr dataset with given ID';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$datasetId = $this->argument('dataset');
$dataset = Dataset::find($datasetId);
// $this->info($dataset->authors->implode('full_name', ', '));
try {
// Opus_Search_Service::selectIndexingService('onDocumentChange')
$service = new SolariumAdapter("solr", config('solarium'));
$service->addDatasetsToIndex($dataset);
} catch (Exception $e) {
$this->error(__METHOD__ . ': ' . 'Indexing document ' . $dataset->id . ' failed: ' . $e->getMessage());
}
}
}

View file

@ -15,7 +15,8 @@ class Kernel extends ConsoleKernel
'App\Console\Commands\Inspire',
'App\Console\Commands\DatasetState',
'App\Console\Commands\SolrIndexBuilder',
'App\Console\Commands\Log\ClearLogFile'
'App\Console\Commands\Log\ClearLogFile',
'App\Console\Commands\UpdateSolrDataset'
];
/**

View file

@ -95,7 +95,7 @@ class SolariumAdapter
foreach ($documents as $document) {
if (!($document instanceof Dataset)) {
throw new InvalidArgumentException("invalid dataset in provided set");
throw new \InvalidArgumentException("invalid dataset in provided set");
}
}

View file

@ -50,7 +50,7 @@ trait DatasetExtension
'PersonAuthor' => array(
'model' => Person::class,
'through' => 'link_documents_persons',
'pivot' => array('role' => 'author'),
'pivot' => array('role' => 'author', 'sort_order' => 'sort_order'),
//'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
//'sort_field' => 'SortOrder',
'relation' => 'persons',
@ -59,7 +59,7 @@ trait DatasetExtension
'PersonContributor' => array(
'model' => Person::class,
'through' => 'link_documents_persons',
'pivot' => array('role' => 'contributor', 'contributor_type' => 'contributor_type'),
'pivot' => array('role' => 'contributor', 'contributor_type' => 'contributor_type', 'sort_order' => 'sort_order'),
// 'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
//'sort_field' => 'SortOrder',
'relation' => 'persons',

View file

@ -60,7 +60,7 @@ class DatasetUpdated
$service = new SolariumAdapter("solr", config('solarium'));
$service->addDatasetsToIndex($dataset);
} catch (Opus_Search_Exception $e) {
Log::debug(__METHOD__ . ': ' . 'Indexing document ' . $documentId . ' failed: ' . $e->getMessage());
Log::debug(__METHOD__ . ': ' . 'Indexing document ' . $dataset->id . ' failed: ' . $e->getMessage());
} catch (InvalidArgumentException $e) {
Log::warning(__METHOD__ . ': ' . $e->getMessage());
}