Skip to content
Snippets Groups Projects
Commit dcca27a4 authored by Gregor Gawol's avatar Gregor Gawol Committed by André Lahmann
Browse files

refs #4533:

* implemented full finc specific RecordDriver stack including most of functionality of VuFind1.x finc-RecordDrivers
* extended config.ini by several finc specific settings (cf. finc block at the bottom of config.ini)
parent b11dd3bd
No related merge requests found
;####################################################################
;##################### DO NOT DELETE THIS HEADER ####################
;################### Leipzig University Library © 2015 ##############
;
; This is the default ALPHA-INI-file and inherits
; all the settings from the INI-file defined in [Parent_Config] which
; points to the default INI-file located in the folder vufind2/local
;
[Parent_Config]
relative_path = ../../../config/vufind/SolrMarcRemoteFinc.ini
; A comma-separated list of config sections from the parent which should be
; completely overwritten by the equivalent sections in this configuration;
; any sections not listed here will be merged on a section-by-section basis.
;override_full_sections = "Languages,AlphaBrowse_Types"
;
; Add ALPHA-specific customization after this header.
;
;##################### DO NOT DELETE THIS HEADER ####################
;####################################################################
[General]
; Set the URI-pattern of the server which serves the raw Marc-data.
baseUrl = http://172.18.113.147/%s
\ No newline at end of file
...@@ -1145,6 +1145,26 @@ max_tag_length = 64 ...@@ -1145,6 +1145,26 @@ max_tag_length = 64
;sigel = "15" ;sigel = "15"
;isil = "DE-15" ;isil = "DE-15"
;bik = "952000-4" ;bik = "952000-4"
; This section defines libraries forms a group.
;[LibraryGroup]
;libraries = DE-15,DE-15-292,DE-15-100
; This section contains all site related customization for finc
;[CustomSite]
; Combine more formats to one css class. If false first format entry will taken
; to display icon symbol
;combinedIcons = false
;namespace = ubl
; This section contains all index related customizations for finc
;[CustomIndex]
; Special settings to control single instances of libaries within one vufind
; installation.
;indexExtension = "de15" ; for solr index of hmt
; take general format field of Solr index. If false it takes the format fields
; with index extension defined above.
;generalFormats = true ;for ubl & htwk it should be true
; ***************** ; *****************
; * EOF finc ; * EOF finc
; ***************** ; *****************
;####################################################################
;##################### DO NOT DELETE THIS HEADER ####################
;################### Leipzig University Library © 2015 ##############
;
; This is the default DEV-INI-file and inherits
; all the settings from the INI-file defined in [Parent_Config] which
; points to the default INI-file located in the folder vufind2/local
;
[Parent_Config]
relative_path = ../../../config/vufind/SolrMarcRemoteFinc.ini
; A comma-separated list of config sections from the parent which should be
; completely overwritten by the equivalent sections in this configuration;
; any sections not listed here will be merged on a section-by-section basis.
;override_full_sections = "Languages,AlphaBrowse_Types"
;
; Add DEV-specific customization after this header.
;
;##################### DO NOT DELETE THIS HEADER ####################
;####################################################################
...@@ -15,11 +15,34 @@ $config = array( ...@@ -15,11 +15,34 @@ $config = array(
), ),
'recorddriver' => array( 'recorddriver' => array(
'factories' => array( 'factories' => array(
'solrmarcremote' => 'finc\RecordDriver\Factory::getSolrMarcRemote' 'solrdefault' => 'finc\RecordDriver\Factory::getSolrDefault',
'solrmarc' => 'finc\RecordDriver\Factory::getSolrMarc',
'solrmarcremote' => 'finc\RecordDriver\Factory::getSolrMarcRemote',
'solrmarcremotefinc' => 'finc\RecordDriver\Factory::getSolrMarcRemoteFinc'
), ),
), ),
), ),
'recorddriver_tabs' => array( 'recorddriver_tabs' => array(
'finc\RecordDriver\SolrDefault' => array(
'tabs' => array (
'Holdings' => 'HoldingsILS', 'Description' => 'Description',
'TOC' => 'TOC', 'UserComments' => 'UserComments',
'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt',
'HierarchyTree' => 'HierarchyTree', 'Map' => 'Map',
'Details' => 'StaffViewArray',
),
'defaultTab' => null,
),
'finc\RecordDriver\SolrMarc' => array(
'tabs' => array(
'Holdings' => 'HoldingsILS', 'Description' => 'Description',
'TOC' => 'TOC', 'UserComments' => 'UserComments',
'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt',
'HierarchyTree' => 'HierarchyTree', 'Map' => 'Map',
'Details' => 'StaffViewMARC',
),
'defaultTab' => null,
),
'finc\RecordDriver\SolrMarcRemote' => array( 'finc\RecordDriver\SolrMarcRemote' => array(
'tabs' => array( 'tabs' => array(
'Holdings' => 'HoldingsILS', 'Description' => 'Description', 'Holdings' => 'HoldingsILS', 'Description' => 'Description',
...@@ -31,6 +54,17 @@ $config = array( ...@@ -31,6 +54,17 @@ $config = array(
), ),
'defaultTab' => null, 'defaultTab' => null,
), ),
'finc\RecordDriver\SolrMarcRemoteFinc' => array(
'tabs' => array(
'Holdings' => 'HoldingsILS', 'Description' => 'Description',
'TOC' => 'TOC', 'UserComments' => 'UserComments',
'Reviews' => 'Reviews', 'Excerpt' => 'Excerpt',
'Preview' => 'preview',
'HierarchyTree' => 'HierarchyTree', 'Map' => 'Map',
'Details' => 'StaffViewMARC',
),
'defaultTab' => null,
),
), ),
), ),
); );
......
...@@ -62,4 +62,26 @@ class Factory extends \VuFind\RecordDriver\Factory ...@@ -62,4 +62,26 @@ class Factory extends \VuFind\RecordDriver\Factory
); );
return $driver; return $driver;
} }
/**
* Factory for SolrMarcRemoteFinc record driver.
*
* @param ServiceManager $sm Service manager.
*
* @return SolrMarc
*/
public static function getSolrMarcRemoteFinc(ServiceManager $sm)
{
$driver = new SolrMarcRemoteFinc(
$sm->getServiceLocator()->get('VuFind\Config')->get('config'),
$sm->getServiceLocator()->get('VuFind\Config')->get('SolrMarcRemoteFinc'),
$sm->getServiceLocator()->get('VuFind\Config')->get('searches')
);
$driver->attachILS(
$sm->getServiceLocator()->get('VuFind\ILSConnection'),
$sm->getServiceLocator()->get('VuFind\ILSHoldLogic'),
$sm->getServiceLocator()->get('VuFind\ILSTitleHoldLogic')
);
return $driver;
}
} }
<?php
/**
* finc specific model for Solr records based on the stock
* VuFind\RecordDriver\SolrDefault
*
* PHP version 5
*
* Copyright (C) Leipzig University Library 2015.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package RecordDrivers
* @author André Lahmann <lahmann@ub.uni-leipzig.de>
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @author Frank Morgner <morgnerf@ub.uni-leipzig.de>
* @author Ulf Seltmann <seltmann@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:record_drivers Wiki
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
*/
namespace finc\RecordDriver;
/**
* finc specific model for Solr records based on the stock
* VuFind\RecordDriver\SolrDefault
*
* @category VuFind2
* @package RecordDrivers
* @author André Lahmann <lahmann@ub.uni-leipzig.de>
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @author Frank Morgner <morgnerf@ub.uni-leipzig.de>
* @author Ulf Seltmann <seltmann@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:record_drivers Wiki
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
*/
class SolrDefault extends \VuFind\RecordDriver\SolrDefault
{
/**
* Return the custom index field local_heading if indexExtension is set.
* If indexExtension is set local_heading_{indexExtension} is returned,
* if local_heading_{indexExtesion} is empty,
* local_heading_facet_{indexExtension} is returned.
*
* @return array Containing local_heading_[facet_]{indexExtension} fields.
* @access public
*/
public function getLocalHeading() {
$array = array();
if (isset($this->mainConfig->Site->indexExtension)) {
$array = isset($this->fields['local_heading_' . ($this->mainConfig->Site->indexExtension)]) ?
$this->fields['local_heading_' . ($this->mainConfig->Site->indexExtension)] : array();
// Use local_heading_facet field if local_heading field delivers no results at first
if (count($array) == 0) {
$array = isset($this->fields['local_heading_facet_' . ($this->mainConfig->Site->indexExtension)]) ?
$this->fields['local_heading_facet_' . ($this->mainConfig->Site->indexExtension)] : array();
}
}
return $array;
}
/**
* Controller to decide when local format field of a library should be
* retrieved from marc. Pass through method for PrimoCentral
*
* Public method for tuf to display format at search modul.
*
* @internal This method should be dropped or renamed (getStandardFormat())
* as it is only a wrapper for the custom method getFormat() which
* in turn behaves as the stock getFormats() method.
*
* @deprecated No need for this wrapper in custom SolrDefault
*
* @return array
* @access public
*/
public function getLocalFormat()
{
return $this->getFormat();
}
/**
* Get back the standardizied format field of Solr index.
*
* @deprecated Should also be possible to be dropped (@see getLocalFormat())
*
* @return array
* @access protected
*/
public function getFormat()
{
return isset($this->fields['format']) ? $this->fields['format'] : array();
}
/**
* Get an array of all the formats associated with the record. If indexExtension
* is set and generalFormats is disabled in config.ini return the field
* format_{indexExtension}, format otherwise.
*
* @return array Array with formats associated with the record.
* @access protected
*/
public function getFormats()
{
// check if general 'format' index field should be used
$isGeneralFormat = (isset($this->mainConfig->Site->generalFormats)
&& true == $this->mainConfig->Site->generalFormats)
? true : false;
// check if there's an extension defined for the library depended format
// index field
$isExtension = (isset($this->mainConfig->Site->indexExtension))
? true : false;
$format = (false === $isGeneralFormat && true === $isExtension)
? 'format_' . $this->mainConfig->Site->indexExtension : 'format' ;
return isset($this->fields[$format]) ? $this->fields[$format] : array();
}
/**
* Get the formats for displaying the icons. Renders the format information to
* a specific css class.
* There are two setups possible. If combinedIcons sets to true at config.ini
* all format values will be concatenated to one string; if it's false only
* the first vlaue will be taken.
*
* @internal Should be moved out of RecordDriver (Controller/View?)
* @todo Should be moved out of RecordDriver (Controller/View?)
*
* @return array
* @access protected
*/
/* protected function getFormatIcon()
{
global $configArray;
$format = $this->getFormats();
// check which method to build the css class is chosen
if (isset($this->mainConfig->Site->combinedIcons) && true == $this->mainConfig->Site->combinedIcons) {
// sort it
sort($format, SORT_LOCALE_STRING);
return strtolower(implode('', $format));
// otherwise take the first format
} else {
if (isset($this->fields['multipart_set'])) {
switch ($this->fields['multipart_set']) {
case 'a': return 'sets';
case 'b': break; //return 'part-related';
case 'c': break; //return 'part-not-related';
}
}
//echo "<pre>"; print_r($format); echo "</pre>";
return $format[0];
}
}*/
/**
* Get the source id of the record.
*
* @return string
* @access public
*/
public function getSourceID()
{
return isset($this->fields['source_id']) ?
$this->fields['source_id'] : '';
}
/**
* Get the GND of an author.
*
* @return array
* @access protected
*/
protected function getAuthorId()
{
return isset($this->fields['author_id']) ?
$this->fields['author_id'] : array();
}
/**
* Combined fields of author data.
*
* @todo Check whether static call of getCorporateAuthor is necessary
*
* @return array
* @access protected
* @link https://intern.finc.info/issues/1866
*/
protected function getCombinedAuthors()
{
$retval = array();
if ($this->getPrimaryAuthor() != '') {
$original = '';
if ($this->getPrimaryAuthorOrig() != '') {
$original = $this->getPrimaryAuthorOrig();
}
$retval[] = ($original == '') ? $this->getPrimaryAuthor()
: $this->getPrimaryAuthor() . ' (' . $original . ')';
} elseif ( self::getCorporateAuthor() != '' ) {
$retval[] = self::getCorporateAuthor();
} elseif (count($this->getSecondaryAuthors()) > 0) {
foreach ($this->getSecondaryAuthors() as $val) {
$retval[] = $val;
}
} elseif (count($this->getCorporateSecondaryAuthors()) > 0) {
foreach ($this->getCorporateSecondaryAuthors() as $val) {
$retval[] = $val;
}
}
return $retval;
}
/**
* Get the original author of the record.
*
* @return string
* @access protected
*/
protected function getPrimaryAuthorOrig()
{
return isset($this->fields['author_orig']) ?
$this->_filterAuthorDates($this->fields['author_orig']) : '';
}
/**
* Get the main author of the record.
*
* @return string
* @access protected
* @deprecated
*/
protected function getPrimaryAuthorRaw()
{
return isset($this->fields['author']) ?
$this->_removeAuthorDates($this->fields['author']) : '';
}
/**
* Get the main corporate author (if any) for the record.
*
* @return string
* @access public
*/
public function getCorporateAuthor()
{
return isset($this->fields['author_corp']) ?
$this->fields['author_corp'] : '';
}
/**
* Get the secondary corporate authors (if any) for the record.
*
* @return array
* @access protected
*/
protected function getCorporateSecondaryAuthors()
{
return isset($this->fields['author_corp2']) ?
$this->fields['author_corp2'] : array();
}
/**
* Get an array of all ISMNs associated with the record (may be empty).
*
* @return array
* @access protected
*/
protected function getISMNs()
{
return isset($this->fields['ismn']) && is_array($this->fields['ismn']) ?
$this->fields['ismn'] : array();
}
/**
* Get an array of newer titles for the record.
*
* @return array
* @access protected
*/
protected function getNewTitles()
{
return isset($this->fields['title_new']) ?
$this->fields['title_new'] : array();
}
/**
* After giving a record ids as e.g. ppn of the BSZ check if a record exists.
* This method can be used to indicate a direct link than to form a general
* look for query.
*
* @todo 1. Check if this method is still needed
* @todo 2. Refactor Solr-Query to be compatible with VuFind2
*
* @param array $rids Array of record ids to test.
*
* @return int mixed If success return at least one finc id otherwise null.
* @access protected
* @deprecated Not used.
*/
protected function addFincIDToRecord ( $array ) {
/*
// record ids
$rids = array();
// return array
$retval = array();
// check if array contain record_ids and collect it as an array to
// use only one solr request for all
if (isset($array) && is_array($array)) {
foreach ($array as $line) {
if (isset($line['record_id'])) {
$rids[] = $line['record_id'];
}
}
}
// solr call
// call index
$index = $this->getIndexEngine();
// build query and accept limit of solr
$limit = $index->getBooleanClauseLimit();
if (count($rids) > $limit) {
$rids = array_slice($rids, 0, $limit);
$retVal = array();
}
// build the query:
if (count($rids) == 1) {
// single query:
$query = "(record_id:". $rids[0] .")";
} elseif (count($rids) > 1) {
// multi query:
$query = 'record_id:(' . implode(' OR ', $rids) . ')';
} else {
return $array;
}
// set hidden filter to limited the range
$this->setHiddenFilters();
// limited search for id and record_id values only
$result = $index->search($query, null, $this->hiddenFilters, 0, 100, null, '', null, null, 'id, record_id', HTTP_REQUEST_METHOD_POST , false, false);
// log to find test data
// temporary logger
if (isset($result['response']['numFound'])
&& isset($result['response']['numFound']) != 0) {
}
// if error break down
if (PEAR::isError($result)) {
return null;
}
if (isset($result['response']['docs'])
&& !empty($result['response']['docs'])
) {
foreach( $result['response']['docs'] as $key => $doc) {
$retval[($doc['record_id'])]=$doc['id'];
}
}
// write back in array
foreach ($array as &$val) {
if (isset($val['record_id'])) {
if (isset($retval[($val['record_id'])])) {
$val['id'] = $retval[($val['record_id'])];
}
}
}
unset($val);
//echo "<pre>"; print_r($array); echo "</pre>";*/
return $array;
}
/**
* Get percentage of relevance of a title. First implementaion for TUBAF.
*
* @return float Percentage of Score / Maximum Score rounded by 5.
* @access protected
* @link https://intern.finc.info/issues/1908
*/
protected function getRelevance() {
$score = isset($this->fields['score']) ? $this->fields['score'] : 0;
$maxScore = isset($this->fields['score_maximum']) ? $this->fields['score_maximum'] : 0;
if ($score == 0 || $maxScore == 0) {
return 0;
}
return round( ($score / $maxScore) , 5);
}
/**
* Get RVK classifcation number from Solr index.
*
* @return string
* @access protected
*/
protected function getRvk() {
return isset($this->fields['rvk_facet']) ?
$this->fields['rvk_facet'] : '';
}
/**
* Get special record_id of libero system.
*
* @todo refactor to a more meaningful name?
*
* @return string
* @access protected
*/
public function getRID()
{
return isset($this->fields['record_id']) ?
$this->fields['record_id'] : '';
}
/**
* Get the original title of the record.
*
* @return string
* @access protected
*/
protected function getTitleOrig()
{
return isset($this->fields['title_orig']) ?
$this->fields['title_orig'] : '';
}
/**
* Get the GND of topic.
*
* @return array
* @access protected
*/
protected function getTopicId()
{
return isset($this->fields['topic_id']) ?
$this->fields['topic_id'] : array();
}
/**
* Get alternatives series titles as array.
*
* @return array
* @access protected
*/
protected function getSeriesAlternative()
{
if (isset($this->fields['series2']) && !empty($this->fields['series2'])) {
return $this->fields['series2'];
}
return array();
}
/**
* Get alternatives series titles as array.
*
* @return array
* @access protected
*/
protected function getSeriesOrig()
{
if (isset($this->fields['series_orig']) && !empty($this->fields['series_orig'])) {
return $this->fields['series_orig'];
}
return array();
}
/**
* Filter author data for author year of birth and death
* to give a better mark up.
*
* @param string authordata
* @return strings
* @access protected
*/
protected function _filterAuthorDates( $authordata )
{
if (preg_match('/^(\s|.*)(\d{4})\s?-?\s?(\d{4})?$/Uu',$authordata, $match)) {
return (isset($match[3]))
? $match[1] .' *'. $match[2] . '-†'. $match[3]
: $match[1] .' *'. $match[2] . '-';
}
return $authordata;
}
/**
* Remove author dates if exists.
*
* @param string authordata
*
* @return strings
* @access protected
* @deprecated
*/
protected function _removeAuthorDates( $authordata )
{
if (preg_match('/^(\s|.*)\s(fl.\s|d.\s|ca.\s)*\s?(\d{4})\??(\sor\s\d\d?)?\s?(-|–)?\s?(ca.\s|after\s)?(\d{1,4})?(.|,)?$/Uu',$authordata, $match)) {
return (isset($match[1])) ? $match[1] : $authordata;
}
return $authordata;
}
}
This diff is collapsed.
...@@ -22,7 +22,9 @@ ...@@ -22,7 +22,9 @@
* *
* @category VuFind2 * @category VuFind2
* @package RecordDrivers * @package RecordDrivers
* @author André Lahmann <lahmann@ub.uni-leipzig.de>, Ulf Seltmann <seltmann@ub.uni-leipzig.de> * @author André Lahmann <lahmann@ub.uni-leipzig.de>
* @author Ulf Seltmann <seltmann@ub.uni-leipzig.de>
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:record_drivers Wiki * @link http://vufind.org/wiki/vufind2:record_drivers Wiki
*/ */
...@@ -35,11 +37,13 @@ use \Zend\Log\LoggerInterface; ...@@ -35,11 +37,13 @@ use \Zend\Log\LoggerInterface;
* *
* @category VuFind2 * @category VuFind2
* @package RecordDrivers * @package RecordDrivers
* @author André Lahmann <lahmann@ub.uni-leipzig.de>, Ulf Seltmann <seltmann@ub.uni-leipzig.de> * @author André Lahmann <lahmann@ub.uni-leipzig.de>
* @author Ulf Seltmann <seltmann@ub.uni-leipzig.de>
* @author Gregor Gawol <gawol@ub.uni-leipzig.de>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org/wiki/vufind2:record_drivers Wiki * @link http://vufind.org/wiki/vufind2:record_drivers Wiki
*/ */
class SolrMarcRemote extends \VuFind\RecordDriver\SolrMarc class SolrMarcRemote extends SolrMarc
{ {
/** /**
* Logger (or false for none) * Logger (or false for none)
...@@ -69,6 +73,13 @@ class SolrMarcRemote extends \VuFind\RecordDriver\SolrMarc ...@@ -69,6 +73,13 @@ class SolrMarcRemote extends \VuFind\RecordDriver\SolrMarc
*/ */
protected $mainConfig; protected $mainConfig;
/**
* holds searches.ini data
*
* @var array
*/
protected $searchesConfig;
/** /**
* Constructor * Constructor
* *
...@@ -95,6 +106,7 @@ class SolrMarcRemote extends \VuFind\RecordDriver\SolrMarc ...@@ -95,6 +106,7 @@ class SolrMarcRemote extends \VuFind\RecordDriver\SolrMarc
} }
$this->mainConfig = $mainConfig; $this->mainConfig = $mainConfig;
$this->searchesConfig = $searchSettings;
} }
/** /**
...@@ -173,7 +185,7 @@ class SolrMarcRemote extends \VuFind\RecordDriver\SolrMarc ...@@ -173,7 +185,7 @@ class SolrMarcRemote extends \VuFind\RecordDriver\SolrMarc
* @throws \Exception * @throws \Exception
* @throws \File_MARC_Exception * @throws \File_MARC_Exception
*/ */
private function getRemoteData() { protected function getRemoteData() {
// handle availability of fullrecord // handle availability of fullrecord
if (isset($this->fields['fullrecord'])) { if (isset($this->fields['fullrecord'])) {
......
This diff is collapsed.
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment