update solr index

This commit is contained in:
Arno Kaimbacher 2019-02-14 15:09:11 +01:00
parent 7c6654398d
commit 535a9363cc
18 changed files with 773 additions and 90 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace App\Events\Dataset;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
/**
* Class DatasetUpdated.
*/
class DatasetUpdated
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* @var
*/
public $dataset;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($dataset)
{
$this->dataset = $dataset;
}
}

View File

@ -1,7 +1,7 @@
<?php namespace App\Events;
abstract class Event {
//
<?php
namespace App\Events;
abstract class Event
{
//
}

View File

@ -32,11 +32,13 @@ class PagesController extends Controller
$dataset->load('titles');
$dataset->load('abstracts');
$authors = $dataset->authors()
$authors = $dataset->persons()
->wherePivot('role', 'author')
->orderBy('link_documents_persons.sort_order', 'desc')
->get();
$contributors = $dataset->contributors()
$contributors = $dataset->persons()
->wherePivot('role', 'contributor')
->orderBy('link_documents_persons.sort_order', 'desc')
->get();

View File

@ -449,7 +449,8 @@ class RequestController extends Controller
$xmlModel = new \App\Library\Xml\XmlModel();
$xmlModel->setModel($dataset);
$xmlModel->excludeEmptyFields();
$xmlModel->setXmlCache(new \App\Models\XmlCache());
$cache = ($dataset->xmlCache) ? $dataset->xmlCache : new \App\Models\XmlCache();
$xmlModel->setXmlCache($cache);
return $xmlModel->getDomDocument()->getElementsByTagName('Rdr_Dataset')->item(0);
}

View File

@ -12,6 +12,7 @@ use Illuminate\View\View;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Exceptions\GeneralException;
class DatasetController extends Controller
{
@ -22,7 +23,6 @@ class DatasetController extends Controller
public function index(Request $request) : View
{
$searchType = $request->input('searchtype');
$builder = Dataset::query();
//$registers = array();
@ -155,8 +155,11 @@ class DatasetController extends Controller
{
$dataset = Dataset::findOrFail($id);
//$input = $request->all();
$input = $request->except('licenses', 'titles');
$dataset->update($input);
$input = $request->except('abstracts', 'licenses', 'titles', '_method', '_token');
// foreach ($input as $key => $value) {
// $dataset[$key] = $value;
// }
//$dataset->update($input);
// $dataset->type = $input['type'];
// $dataset->thesis_year_accepted = $input['thesis_year_accepted'];
// $dataset->project_id = $input['project_id'];
@ -188,8 +191,17 @@ class DatasetController extends Controller
}
}
session()->flash('flash_message', 'You have updated 1 dataset!');
return redirect()->route('settings.document');
if (! $dataset->isDirty(dataset::UPDATED_AT)) {
$time = new \Illuminate\Support\Carbon();
$dataset->setUpdatedAt($time);
}
// $dataset->save();
if ($dataset->update($input)) {
//event(new DatasetUpdated($dataset));
session()->flash('flash_message', 'You have updated 1 dataset!');
return redirect()->route('settings.document');
}
throw new GeneralException(trans('exceptions.backend.dataset.update_error'));
}

View File

@ -3,9 +3,12 @@
namespace App\Library\Search;
//use App\Library\Util\SolrSearchQuery;
use App\Library\Util\SearchParameter;
use App\Library\Search\SearchResult;
use App\Library\Util\SearchParameter;
use Illuminate\Support\Facades\Log;
use App\Library\Search\SolariumDocument;
use App\Models\Dataset;
use \Solarium\QueryType\Select\Query\Query;
class SolariumAdapter
{
@ -50,7 +53,55 @@ class SolariumAdapter
return 'solr';
}
public function createQuery() : SearchParameter
public function addDatasetsToIndex($datasets)
{
$datasets = $this->normalizeDocuments($datasets);
$builder = new SolariumDocument($this->options);
$slices = array_chunk($datasets, 16);
// update documents of every chunk in a separate request
foreach ($slices as $slice) {
$update = $this->client->createUpdate();
$updateDocs = array_map(function ($rdrDoc) use ($builder, $update) {
return $builder->toSolrUpdateDocument($rdrDoc, $update->createDocument());
}, $slice);
// adding the document to the update query
$update->addDocuments($updateDocs);
// Then commit the update:
$update->addCommit();
$result = $this->client->update($update);
//$this->execute($update, 'failed updating slice of documents');
}
// finally commit all updates
// $update = $this->client->createUpdate();
// $update->addCommit();
// $this->execute($update, 'failed committing update of documents');
return $this;
}
protected function normalizeDocuments($documents)
{
if (!is_array($documents)) {
$documents = array($documents);
}
foreach ($documents as $document) {
if (!($document instanceof Dataset)) {
throw new InvalidArgumentException("invalid dataset in provided set");
}
}
return $documents;
}
public function createQuery(): SearchParameter
{
return new SearchParameter();
}
@ -63,13 +114,14 @@ class SolariumAdapter
return $searchResult;
}
protected function applyParametersToSolariumQuery(\Solarium\QueryType\Select\Query\Query $query, SearchParameter $parameters = null, $preferOriginalQuery = false)
protected function applyParametersToSolariumQuery(Query $query, SearchParameter $parameters, $preferOriginalQuery)
{
if ($parameters) {
//$subfilters = $parameters->getSubFilters();
//if ( $subfilters !== null ) {
// foreach ( $subfilters as $name => $subfilter ) {
// if ( $subfilter instanceof Opus_Search_Solr_Filter_Raw || $subfilter instanceof Opus_Search_Solr_Solarium_Filter_Complex ) {
// if ( $subfilter instanceof Opus_Search_Solr_Filter_Raw
//|| $subfilter instanceof Opus_Search_Solr_Solarium_Filter_Complex ) {
// $query->createFilterQuery( $name )
// ->setQuery( $subfilter->compile( $query ) );
// }
@ -87,14 +139,13 @@ class SolariumAdapter
// }
// }
$filter = $parameters->getFilter();//"aa" all: '*:*'
$filter = $parameters->getFilter(); //"aa" all: '*:*'
if ($filter !== null) {
//$query->setStart( intval( $start ) );
//$query->setQuery('%P1%', array($filter));
$query->setQuery($filter);
}
$start = $parameters->getStart();
if ($start !== null) {
$query->setStart(intval($start));
@ -154,7 +205,7 @@ class SolariumAdapter
// }
}
protected function processQuery(\Solarium\QueryType\Select\Query\Query $query) : SearchResult
protected function processQuery(\Solarium\QueryType\Select\Query\Query $query): SearchResult
{
// send search query to service
$request = $this->execute($query, 'failed querying search engine');

View File

@ -0,0 +1,34 @@
<?php
namespace App\Library\Search;
use App\Models\Dataset;
use Solarium\QueryType\Update\Query\Document\Document;
class SolariumDocument extends SolrDocumentXslt
{
public function __construct($options)
{
parent::__construct($options);
}
public function toSolrUpdateDocument(Dataset $rdrDataset, Document $solrDoc)
{
if (!($solrDoc instanceof Document)) {
throw new \Exception('provided Solr document must be instance of Solarium Update Document');
}
// convert Opus document to Solr XML document for supporting custom transformations
$solrDomDoc = parent::toSolrDocument($rdrDataset, new \DomDocument());
// read back fields from generated Solr XML document
$solrXmlDoc = simplexml_import_dom($solrDomDoc)->doc[0];
$solrDoc->clear();
foreach ($solrXmlDoc->field as $field) {
$solrDoc->addField(strval($field['name']), strval($field));
}
return $solrDoc;
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace App\Library\Search;
use App\Models\Dataset;
class SolrDocumentXslt
{
/**
* @var XSLTProcessor
*/
protected $processor;
public function __construct($options)
{
//parent::__construct($options);
try {
$xslt = new \DomDocument;
$xslt->load($options['xsltfile']);
$this->processor = new \XSLTProcessor;
$this->processor->importStyleSheet($xslt);
} catch (Exception $e) {
throw new Exception('invalid XSLT file for deriving Solr documents', 0, $e);
}
}
public function toSolrDocument(Dataset $rdrDataset, \DOMDocument $solrDoc)
{
if (!($solrDoc instanceof \DOMDocument)) {
throw new Exception('provided Solr document must be instance of DOMDocument');
}
$modelXml = $this->getModelXml($rdrDataset);//->saveXML();
$solrDoc->preserveWhiteSpace = false;
$solrDoc->loadXML($this->processor->transformToXML($modelXml));
// if (Opus_Config::get()->log->prepare->xml) {
// $modelXml->formatOutput = true;
// Opus_Log::get()->debug("input xml\n" . $modelXml->saveXML());
// $solrDoc->formatOutput = true;
// Opus_Log::get()->debug("transformed solr xml\n" . $solrDoc->saveXML());
// }
return $solrDoc;
}
/**
* Retrieves XML describing model data of provided RDR dataset.
*
* @param Dataset $rdrDataset
* @return DOMDocument
*/
protected function getModelXml(Dataset $rdrDataset)
{
$rdrDataset->fetchValues();
// Set up caching xml-model and get XML representation of document.
$xmlModel = new \App\Library\Xml\XmlModel();
//$caching_xml_model = new Opus_Model_Xml;
//$caching_xml_model->setModel($opusDoc);
$xmlModel->setModel($rdrDataset);
$xmlModel->excludeEmptyFields();
//$xmlModel->setStrategy(new Opus_Model_Xml_Version1);
//$cache = new Opus_Model_Xml_Cache($opusDoc->hasPlugin('Opus_Document_Plugin_Index'));
//$xmlModel->setXmlCache($cache);
$cache = ($rdrDataset->xmlCache) ? $rdrDataset->xmlCache : new \App\Models\XmlCache();
$xmlModel->setXmlCache($cache);
$modelXml = $xmlModel->getDomDocument();
// extract fulltext from file and append it to the generated xml.
//$this->attachFulltextToXml($modelXml, $opusDoc->getFile(), $opusDoc->getId());
return $modelXml;
}
}

View File

@ -133,12 +133,21 @@ class XmlModel
return $domDocument;
} else {
//create cache relation
$this->cache->fill(array(
'document_id' => $dataset->id,
'xml_version' => (int)$this->strategy->getVersion(),
'server_date_modified' => $dataset->server_date_modified,
'xml_data' => $domDocument->saveXML()
));
// $this->cache->updateOrCreate(array(
// 'document_id' => $dataset->id,
// 'xml_version' => (int)$this->strategy->getVersion(),
// 'server_date_modified' => $dataset->server_date_modified,
// 'xml_data' => $domDocument->saveXML()
// ));
if (!$this->cache->document_id) {
$this->cache->document_id = $dataset->id;
}
$this->cache->xml_version = (int)$this->strategy->getVersion();
$this->cache->server_date_modified = $dataset->server_date_modified;
$this->cache->xml_data = $domDocument->saveXML();
$this->cache->save();
Log::debug(__METHOD__ . ' cache refreshed for ' . get_class($dataset) . '#' . $dataset->id);
@ -161,20 +170,35 @@ class XmlModel
Log::debug(__METHOD__ . ' skipping cache for ' . get_class($dataset));
return null;
}
//$cached = $this->cache->hasValidEntry(
// $dataset->id,
// (int) $this->strategy->getVersion(),
// $dataset->server_date_modified
//);
//$cached = false;
$cache = XmlCache::where('document_id', $dataset->id)
->first();// model or null
if (!$cache) {
$actuallyCached = $this->cache->hasValidEntry(
$dataset->id,
$dataset->server_date_modified
);
//no actual cache
if (true !== $actuallyCached) {
Log::debug(__METHOD__ . ' cache miss for ' . get_class($dataset) . '#' . $dataset->id);
return null;
} else {
return $cache->getDomDocument();
}
//cache is actual return it for oai:
Log::debug(__METHOD__ . ' cache hit for ' . get_class($dataset) . '#' . $dataset->id);
try {
//return $this->_cache->get($model->getId(), (int) $this->_strategy->getVersion());
$cache = XmlCache::where('document_id', $dataset->id)->first();
return $cache->getDomDocument();
} catch (Exception $e) {
Log::warning(__METHOD__ . " Access to XML cache failed on " . get_class($dataset) . '#' . $dataset->id . ". Trying to recover.");
}
return null;
// // $cache = XmlCache::where('document_id', $dataset->id)
// // ->first();// model or null
// if (!$cache) {
// Log::debug(__METHOD__ . ' cache miss for ' . get_class($dataset) . '#' . $dataset->id);
// return null;
// } else {
// return $cache->getDomDocument();
// }
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace App\Listeners;
// use Illuminate\Queue\InteractsWithQueue;
// use Illuminate\Contracts\Queue\ShouldQueue;
use App\Events\Dataset\DatasetUpdated as DatasetUpdatedEvent;
use App\Models\Dataset;
use Illuminate\Support\Facades\Log;
use App\Library\Search\SolariumAdapter;
class DatasetUpdated
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param DatasetUpdatedEvent $event
* @return void
*/
public function handle(DatasetUpdatedEvent $event)
{
$dataset = $event->dataset;
// only index Opus_Document instances
if (false === ($dataset instanceof Dataset)) {
return;
}
if ($dataset->server_state !== 'published') {
// if ($dataset->getServerState() !== 'temporary') {
// $this->removeDocumentFromIndexById($model->getId());
// }
return;
}
$this->addDatasetToIndex($dataset);
}
/**
* Helper method to add dataset to index.
*
* @param Opus_Document $document
* @return void
*/
private function addDatasetToIndex(Dataset $dataset)
{
$datasetId = $dataset->id;
Log::debug(__METHOD__ . ': ' . 'Adding index job for dataset ' . $datasetId . '.');
try {
// Opus_Search_Service::selectIndexingService('onDocumentChange')
$service = new SolariumAdapter("solr", config('solarium'));
$service->addDatasetsToIndex($dataset);
} catch (Opus_Search_Exception $e) {
Log::debug(__METHOD__ . ': ' . 'Indexing document ' . $documentId . ' failed: ' . $e->getMessage());
} catch (InvalidArgumentException $e) {
Log::warning(__METHOD__ . ': ' . $e->getMessage());
}
}
}

View File

@ -26,16 +26,17 @@ class Dataset extends Model
const UPDATED_AT = 'server_date_modified';
const PUBLISHED_AT = 'server_date_published';
protected $fillable = [
'type',
'language',
'server_state',
'creating_corporation',
'project_id',
'embargo_date',
'belongs_to_bibliography',
];
/**
// protected $fillable = [
// 'type',
// 'language',
// 'server_state',
// 'creating_corporation',
// 'project_id',
// 'embargo_date',
// 'belongs_to_bibliography',
// ];
protected $guarded = [];
/**
* The attributes that should be mutated to dates.
*
* @var array
@ -54,6 +55,11 @@ class Dataset extends Model
// $this->_init();
}
// public function setUpdatedAt($value)
// {
// $this->{static::UPDATED_AT} = $value;
// }
/**
* Get the geolocation that owns the dataset.
*/
@ -62,6 +68,8 @@ class Dataset extends Model
return $this->hasOne(GeolocationBox::class, 'dataset_id', 'id');
}
/**
* Get the project that the dataset belongs to.
*/

View File

@ -4,6 +4,7 @@ namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use App\Models\Dataset;
use Illuminate\Support\Facades\DB;
class XmlCache extends Model
{
@ -22,7 +23,8 @@ class XmlCache extends Model
* @var integer
* @access protected
*/
protected $primaryKey = null;
//protected $primaryKey = null;
public $primaryKey = 'document_id';
public $incrementing = false;
/**
@ -61,22 +63,18 @@ class XmlCache extends Model
* @param mixed $serverDateModified
* @return bool Returns true on cached hit else false.
*/
//public function scopeHasValidEntry($query, $datasetId, $xmlVersion, $serverDateModified)
//{
// //$select = $this->_table->select()->from($this->_table);
// $query->where('document_id = ?', $datasetId)
// ->where('xml_version = ?', $xmlVersion)
// ->where('server_date_modified = ?', $serverDateModified);
public function hasValidEntry($datasetId, $serverDateModified)
{
$select = DB::table('document_xml_cache');
$select->where('document_id', '=', $datasetId)
->where('server_date_modified', '=', $serverDateModified);
// $row = $query->get();
$row = $select->first();
// if (null === $row)
// {
// return false;
// }
// else
// {
// return true;
// }
//}
if (null === $row) {
return false;
} else {
return true;
}
}
}

View File

@ -5,6 +5,7 @@ namespace App\Observers;
//php artisan make:observer DatasetObserver --model=Models\Dataset
use App\Models\Dataset;
use Illuminate\Support\Facades\Log;
use App\Library\Search\SolariumAdapter;
class DatasetObserver
{
@ -33,12 +34,12 @@ class DatasetObserver
if (false === ($dataset instanceof Dataset)) {
return;
}
// if ($dataset->getServerState() !== 'published') {
// if ($model->getServerState() !== 'temporary') {
// $this->removeDocumentFromIndexById($model->getId());
// }
// return;
// }
if ($dataset->server_state !== 'published') {
// if ($dataset->getServerState() !== 'temporary') {
// $this->removeDocumentFromIndexById($model->getId());
// }
return;
}
$this->addDatasetToIndex($dataset);
}
@ -85,6 +86,16 @@ class DatasetObserver
private function addDatasetToIndex(Dataset $dataset)
{
$datasetId = $dataset->id;
Log::debug(__METHOD__ . ': ' . 'Adding index job for document ' . $datasetId . '.');
Log::debug(__METHOD__ . ': ' . 'Adding index job for dataset ' . $datasetId . '.');
try {
// Opus_Search_Service::selectIndexingService('onDocumentChange')
$service = new SolariumAdapter("solr", config('solarium'));
$service->addDatasetsToIndex($dataset);
} catch (Opus_Search_Exception $e) {
Log::debug(__METHOD__ . ': ' . 'Indexing document ' . $documentId . ' failed: ' . $e->getMessage());
} catch (InvalidArgumentException $e) {
Log::warning(__METHOD__ . ': ' . $e->getMessage());
}
}
}

View File

@ -14,6 +14,9 @@ class EventServiceProvider extends ServiceProvider
'App\Events\Event' => [
'App\Listeners\EventListener',
],
\App\Events\Dataset\DatasetUpdated::class => [
\App\Listeners\DatasetUpdated::class,
],
];
/**

26
composer.lock generated
View File

@ -427,26 +427,26 @@
},
{
"name": "felixkiss/uniquewith-validator",
"version": "3.1.2",
"version": "3.2.0",
"source": {
"type": "git",
"url": "https://github.com/felixkiss/uniquewith-validator.git",
"reference": "a27d5823bcf52dac6760638c8d987760212dbf5c"
"reference": "11e3c12758f8f1c335618ab8eabecd338985aff9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/felixkiss/uniquewith-validator/zipball/a27d5823bcf52dac6760638c8d987760212dbf5c",
"reference": "a27d5823bcf52dac6760638c8d987760212dbf5c",
"url": "https://api.github.com/repos/felixkiss/uniquewith-validator/zipball/11e3c12758f8f1c335618ab8eabecd338985aff9",
"reference": "11e3c12758f8f1c335618ab8eabecd338985aff9",
"shasum": ""
},
"require": {
"illuminate/support": "5.*",
"illuminate/validation": "5.*",
"php": ">=5.4.0"
"php": ">=5.6.0"
},
"require-dev": {
"bossa/phpspec2-expect": "dev-phpspec-3.2",
"phpspec/phpspec": "^3.2"
"bossa/phpspec2-expect": "^2.3",
"phpspec/phpspec": "^3.4"
},
"type": "library",
"extra": {
@ -476,7 +476,7 @@
"keywords": [
"laravel"
],
"time": "2017-08-06T23:28:53+00:00"
"time": "2019-02-12T18:30:56+00:00"
},
{
"name": "fideloper/proxy",
@ -2792,16 +2792,16 @@
},
{
"name": "yajra/laravel-datatables-oracle",
"version": "v8.13.4",
"version": "v8.13.5",
"source": {
"type": "git",
"url": "https://github.com/yajra/laravel-datatables.git",
"reference": "8aedd88a02599d5d0a4a1a2bb5aac849397dd594"
"reference": "a97a173a52f2b60075f310dac39932faa377fb4f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yajra/laravel-datatables/zipball/8aedd88a02599d5d0a4a1a2bb5aac849397dd594",
"reference": "8aedd88a02599d5d0a4a1a2bb5aac849397dd594",
"url": "https://api.github.com/repos/yajra/laravel-datatables/zipball/a97a173a52f2b60075f310dac39932faa377fb4f",
"reference": "a97a173a52f2b60075f310dac39932faa377fb4f",
"shasum": ""
},
"require": {
@ -2859,7 +2859,7 @@
"jquery",
"laravel"
],
"time": "2019-01-29T03:12:37+00:00"
"time": "2019-02-13T01:34:34+00:00"
},
{
"name": "zizaco/entrust",

View File

@ -8,5 +8,6 @@ return [
'path' => env('SOLR_PATH', '/solr/'),
'core' => env('SOLR_CORE', 'opus4')
]
]
],
'xsltfile' => "solr.xslt"
];

361
public/solr.xslt Normal file
View File

@ -0,0 +1,361 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* This file is part of OPUS. The software OPUS has been originally developed
* at the University of Stuttgart with funding from the German Research Net,
* the Federal Department of Higher Education and Research and the Ministry
* of Science, Research and the Arts of the State of Baden-Wuerttemberg.
*
* OPUS 4 is a complete rewrite of the original OPUS software and was developed
* by the Stuttgart University Library, the Library Service Center
* Baden-Wuerttemberg, the North Rhine-Westphalian Library Service Center,
* the Cooperative Library Network Berlin-Brandenburg, the Saarland University
* and State Library, the Saxon State Library - Dresden State and University
* Library, the Bielefeld University Library and the University Library of
* Hamburg University of Technology with funding from the German Research
* Foundation and the European Regional Development Fund.
*
* LICENCE
* OPUS is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the Licence, or any later version.
* OPUS is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License
* along with OPUS; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @category Framework
* @package Opus_SolrSearch
* @author Oliver Marahrens <o.marahrens@tu-harburg.de>
* @author Sascha Szott <szott@zib.de>
* @copyright Copyright (c) 2008-2011, OPUS 4 development team
* @license http://www.gnu.org/licenses/gpl.html General Public License
* @version $Id$
*/
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output method="xml" indent="yes" />
<!-- Suppress output for all elements that don't have an explicit template. -->
<xsl:template match="*" />
<xsl:template match="/">
<xsl:element name="add">
<xsl:element name="doc">
<!-- id -->
<xsl:element name="field">
<xsl:attribute name="name">id</xsl:attribute>
<xsl:value-of select="/Opus/Rdr_Dataset/@Id" />
</xsl:element>
<!-- year -->
<xsl:variable name="year">
<xsl:choose>
<xsl:when test="/Opus/Rdr_Dataset/PublishedDate/@Year != ''">
<xsl:value-of select="/Opus/Rdr_Dataset/PublishedDate/@Year" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="/Opus/Rdr_Dataset/@PublishedYear" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:element name="field">
<xsl:attribute name="name">year</xsl:attribute>
<xsl:value-of select="$year"/>
</xsl:element>
<!-- year inverted -->
<xsl:if test="$year">
<xsl:variable name="yearInverted" select="65535 - $year"/>
<xsl:element name="field">
<xsl:attribute name="name">year_inverted</xsl:attribute>
<xsl:value-of select="$yearInverted"/>:<xsl:value-of select="$year"/>
</xsl:element>
</xsl:if>
<!-- server_date_published -->
<xsl:if test="/Opus/Rdr_Dataset/ServerDatePublished/@UnixTimestamp != ''">
<xsl:element name="field">
<xsl:attribute name="name">server_date_published</xsl:attribute>
<xsl:value-of select="/Opus/Rdr_Dataset/ServerDatePublished/@UnixTimestamp" />
</xsl:element>
</xsl:if>
<!-- server_date_modified -->
<xsl:if test="/Opus/Rdr_Dataset/ServerDateModified/@UnixTimestamp != ''">
<xsl:element name="field">
<xsl:attribute name="name">server_date_modified</xsl:attribute>
<xsl:value-of select="/Opus/Rdr_Dataset/ServerDateModified/@UnixTimestamp" />
</xsl:element>
</xsl:if>
<!-- language -->
<xsl:variable name="language" select="/Opus/Rdr_Dataset/@Language" />
<xsl:element name="field">
<xsl:attribute name="name">language</xsl:attribute>
<xsl:value-of select="$language" />
</xsl:element>
<!-- title / title_output -->
<xsl:for-each select="/Opus/Rdr_Dataset/TitleMain">
<xsl:element name="field">
<xsl:attribute name="name">title</xsl:attribute>
<xsl:value-of select="@Value" />
</xsl:element>
<xsl:if test="@Language = $language">
<xsl:element name="field">
<xsl:attribute name="name">title_output</xsl:attribute>
<xsl:value-of select="@Value" />
</xsl:element>
</xsl:if>
</xsl:for-each>
<!-- abstract / abstract_output -->
<xsl:for-each select="/Opus/Rdr_Dataset/TitleAbstract">
<xsl:element name="field">
<xsl:attribute name="name">abstract</xsl:attribute>
<xsl:value-of select="@Value" />
</xsl:element>
<xsl:if test="@Language = $language">
<xsl:element name="field">
<xsl:attribute name="name">abstract_output</xsl:attribute>
<xsl:value-of select="@Value" />
</xsl:element>
</xsl:if>
</xsl:for-each>
<!-- author -->
<xsl:for-each select="/Opus/Rdr_Dataset/PersonAuthor">
<xsl:element name="field">
<xsl:attribute name="name">author</xsl:attribute>
<xsl:value-of select="@LastName" />
<xsl:text>, </xsl:text>
<xsl:value-of select="@FirstName" />
</xsl:element>
</xsl:for-each>
<!-- author_sort -->
<xsl:element name="field">
<xsl:attribute name="name">author_sort</xsl:attribute>
<xsl:for-each select="/Opus/Rdr_Dataset/PersonAuthor">
<xsl:value-of select="@LastName" />
<xsl:text> </xsl:text>
<xsl:value-of select="@FirstName" />
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:element>
<!-- fulltext -->
<xsl:for-each select="/Opus/Rdr_Dataset/Fulltext_Index">
<xsl:element name="field">
<xsl:attribute name="name">fulltext</xsl:attribute>
<xsl:value-of select="." />
</xsl:element>
</xsl:for-each>
<!-- has fulltext -->
<xsl:element name="field">
<xsl:attribute name="name">has_fulltext</xsl:attribute>
<xsl:value-of select="/Opus/Rdr_Dataset/Has_Fulltext" />
</xsl:element>
<!-- IDs der Dateien, die mit nicht leerem Resultat extrahiert werden konnten -->
<xsl:for-each select="/Opus/Rdr_Dataset/Fulltext_ID_Success">
<xsl:element name="field">
<xsl:attribute name="name">fulltext_id_success</xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<!-- IDs der Dateien, die nicht erfolgreich extrahiert werden konnten -->
<xsl:for-each select="/Opus/Rdr_Dataset/Fulltext_ID_Failure">
<xsl:element name="field">
<xsl:attribute name="name">fulltext_id_failure</xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
<!-- referee -->
<xsl:for-each select="/Opus/Rdr_Dataset/PersonReferee">
<xsl:element name="field">
<xsl:attribute name="name">referee</xsl:attribute>
<xsl:value-of select="@FirstName" />
<xsl:text> </xsl:text>
<xsl:value-of select="@LastName" />
</xsl:element>
</xsl:for-each>
<!-- other persons (non-authors) -->
<xsl:for-each select="/Opus/Rdr_Dataset/*">
<xsl:if test="local-name() != 'Person' and local-name() != 'PersonAuthor' and local-name() != 'PersonSubmitter' and substring(local-name(), 1, 6) = 'Person'">
<xsl:element name="field">
<xsl:attribute name="name">persons</xsl:attribute>
<xsl:value-of select="@FirstName" />
<xsl:text> </xsl:text>
<xsl:value-of select="@LastName" />
</xsl:element>
</xsl:if>
</xsl:for-each>
<!-- doctype -->
<xsl:element name="field">
<xsl:attribute name="name">doctype</xsl:attribute>
<xsl:value-of select="/Opus/Rdr_Dataset/@Type" />
</xsl:element>
<!-- subject (swd) -->
<xsl:for-each select="/Opus/Rdr_Dataset/Subject[@Type = 'swd']">
<xsl:element name="field">
<xsl:attribute name="name">subject</xsl:attribute>
<xsl:value-of select="@Value" />
</xsl:element>
</xsl:for-each>
<!-- subject (uncontrolled) -->
<xsl:for-each select="/Opus/Rdr_Dataset/Subject[@Type = 'uncontrolled']">
<xsl:element name="field">
<xsl:attribute name="name">subject</xsl:attribute>
<xsl:value-of select="@Value" />
</xsl:element>
</xsl:for-each>
<!-- belongs_to_bibliography -->
<xsl:element name="field">
<xsl:attribute name="name">belongs_to_bibliography</xsl:attribute>
<xsl:choose>
<xsl:when test="/Opus/Rdr_Dataset/@BelongsToBibliography = 0" >
<xsl:text>false</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>true</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:element>
<!-- collections: project, app_area, institute, ids -->
<xsl:for-each select="/Opus/Rdr_Dataset/Collection">
<xsl:choose>
<xsl:when test="@RoleName = 'projects'">
<xsl:element name="field">
<xsl:attribute name="name">project</xsl:attribute>
<xsl:value-of select="@Number" />
</xsl:element>
<xsl:element name="field">
<xsl:attribute name="name">app_area</xsl:attribute>
<xsl:value-of select="substring(@Number, 0, 2)" />
</xsl:element>
</xsl:when>
<xsl:when test="@RoleName = 'institutes'">
<xsl:element name="field">
<xsl:attribute name="name">institute</xsl:attribute>
<xsl:value-of select="@Name" />
</xsl:element>
</xsl:when>
</xsl:choose>
<xsl:element name="field">
<xsl:attribute name="name">collection_ids</xsl:attribute>
<xsl:value-of select="@Id" />
</xsl:element>
</xsl:for-each>
<!-- title parent -->
<xsl:for-each select="/Opus/Rdr_Dataset/TitleParent">
<xsl:element name="field">
<xsl:attribute name="name">title_parent</xsl:attribute>
<xsl:value-of select="@Value" />
</xsl:element>
</xsl:for-each>
<!-- title sub -->
<xsl:for-each select="/Opus/Rdr_Dataset/TitleSub">
<xsl:element name="field">
<xsl:attribute name="name">title_sub</xsl:attribute>
<xsl:value-of select="@Value" />
</xsl:element>
</xsl:for-each>
<!-- title additional -->
<xsl:for-each select="/Opus/Rdr_Dataset/TitleAdditional">
<xsl:element name="field">
<xsl:attribute name="name">title_additional</xsl:attribute>
<xsl:value-of select="@Value" />
</xsl:element>
</xsl:for-each>
<!-- series ids and series number per id (modeled as dynamic field) -->
<xsl:for-each select="/Opus/Rdr_Dataset/Series">
<xsl:element name="field">
<xsl:attribute name="name">series_ids</xsl:attribute>
<xsl:value-of select="@Id"/>
</xsl:element>
<xsl:element name="field">
<xsl:attribute name="name">
<xsl:text>series_number_for_id_</xsl:text><xsl:value-of select="@Id"/>
</xsl:attribute>
<xsl:value-of select="@Number"/>
</xsl:element>
<xsl:element name="field">
<xsl:attribute name="name">
<xsl:text>doc_sort_order_for_seriesid_</xsl:text><xsl:value-of select="@Id"/>
</xsl:attribute>
<xsl:value-of select="@DocSortOrder"/>
</xsl:element>
</xsl:for-each>
<!-- creating corporation (single valued) -->
<xsl:if test="/Opus/Rdr_Dataset/@CreatingCorporation">
<xsl:element name="field">
<xsl:attribute name="name">creating_corporation</xsl:attribute>
<xsl:value-of select="/Opus/Rdr_Dataset/@CreatingCorporation"/>
</xsl:element>
</xsl:if>
<!-- contributing corporation (single valued) -->
<xsl:if test="/Opus/Rdr_Dataset/@ContributingCorporation">
<xsl:element name="field">
<xsl:attribute name="name">contributing_corporation</xsl:attribute>
<xsl:value-of select="/Opus/Rdr_Dataset/@ContributingCorporation"/>
</xsl:element>
</xsl:if>
<!-- publisher name (single valued) -->
<xsl:if test="/Opus/Rdr_Dataset/@PublisherName">
<xsl:element name="field">
<xsl:attribute name="name">publisher_name</xsl:attribute>
<xsl:value-of select="/Opus/Rdr_Dataset/@PublisherName"/>
</xsl:element>
</xsl:if>
<!-- publisher place (single valued) -->
<xsl:if test="/Opus/Rdr_Dataset/@PublisherPlace">
<xsl:element name="field">
<xsl:attribute name="name">publisher_place</xsl:attribute>
<xsl:value-of select="/Opus/Rdr_Dataset/@PublisherPlace"/>
</xsl:element>
</xsl:if>
<!-- identifier (multi valued) -->
<xsl:for-each select="/Opus/Rdr_Dataset/Identifier">
<xsl:element name="field">
<xsl:attribute name="name">identifier</xsl:attribute>
<xsl:value-of select="@Value"/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

View File

@ -28,11 +28,11 @@
<br />
@endforeach
@foreach ($contributors as $contributor)
<em>Contributor: {{ $contributors->full_name }}</em>
<em>Contributor: {{ $contributor->full_name }}</em>
<br />
@endforeach
@foreach ($submitters as $submitter)
<em>Contributor: {{ $submitter->full_name }}</em>
<em>Submitter: {{ $submitter->full_name }}</em>
<br />
@endforeach