From bd1ff3c85ec25377cb8e614587e74c224d0c1da7 Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 20 Jan 2015 16:03:33 -0500 Subject: [PATCH] Upgrade script support for fixing WorldCat author index. --- module/VuFind/src/VuFind/Config/Upgrade.php | 12 +++++ .../configs/worldcatupgrades/WorldCat.ini | 47 +++++++++++++++++++ .../configs/worldcatupgrades/config.ini | 2 + .../src/VuFindTest/Config/UpgradeTest.php | 20 ++++++++ 4 files changed, 81 insertions(+) create mode 100644 module/VuFind/tests/fixtures/configs/worldcatupgrades/WorldCat.ini create mode 100644 module/VuFind/tests/fixtures/configs/worldcatupgrades/config.ini diff --git a/module/VuFind/src/VuFind/Config/Upgrade.php b/module/VuFind/src/VuFind/Config/Upgrade.php index faa2c6b3198..77187d31435 100644 --- a/module/VuFind/src/VuFind/Config/Upgrade.php +++ b/module/VuFind/src/VuFind/Config/Upgrade.php @@ -882,6 +882,18 @@ class Upgrade ); $this->applyOldSettings('WorldCat.ini', $groups); + // we need to fix an obsolete search setting for authors + foreach (array('Basic_Searches', 'Advanced_Searches') as $section) { + $new = array(); + foreach ($this->newConfigs['WorldCat.ini'][$section] as $k => $v) { + if ($k == 'srw.au:srw.pn:srw.cn') { + $k = 'srw.au'; + } + $new[$k] = $v; + } + $this->newConfigs['WorldCat.ini'][$section] = $new; + } + // save the file $this->saveModifiedConfig('WorldCat.ini'); } diff --git a/module/VuFind/tests/fixtures/configs/worldcatupgrades/WorldCat.ini b/module/VuFind/tests/fixtures/configs/worldcatupgrades/WorldCat.ini new file mode 100644 index 00000000000..5342a6d59a1 --- /dev/null +++ b/module/VuFind/tests/fixtures/configs/worldcatupgrades/WorldCat.ini @@ -0,0 +1,47 @@ +; This section contains global settings affecting search behavior. +[General] +; This setting controls the default sort order of search results; the selected +; option should be one of the options present in the [Sorting] section below. +default_sort = relevance + +; This section shows which search types will display in the basic search box at +; the top of WorldCat pages. The name of each setting below corresponds with one +; or more indices defined in the WorldCat API (multiple values are separated by +; colons). The value of each setting is the text to display on screen. All +; on-screen text will be run through the translator, so be sure to update language +; files if necessary. The order of these settings will be maintained in the +; drop-down list in the UI. +; +; For a complete list of legal values, see the SRU Explain page here: +; http://worldcat.org/webservices/catalog/ +[Basic_Searches] +srw.kw = "All Fields" +srw.ti:srw.se = Title +srw.au:srw.pn:srw.cn = Author +srw.su = Subject +srw.dd:srw.lc = "Call Number" +srw.bn:srw.in = "ISBN/ISSN" + +; This section defines which search options will be included on the advanced +; search screen. All the notes above [Basic_Searches] also apply here. +[Advanced_Searches] +srw.kw = adv_search_all +srw.ti:srw.se = adv_search_title +srw.au:srw.pn:srw.cn = adv_search_author +srw.su = adv_search_subject +srw.dd:srw.lc = adv_search_callnumber +srw.bn:srw.in = adv_search_isn +srw.pb = adv_search_publisher +srw.se = adv_search_series +srw.yr = adv_search_year + +; This section defines the sort options available on WorldCat search results. +; Values on the left of the equal sign are WorldCat API sort values. Values +; on the right of the equal sign are text that will be run through the +; translation module and displayed on screen. +[Sorting] +relevance = sort_relevance +Date,,0 = sort_year +Date = "sort_year asc" +Author = sort_author +Title = sort_title diff --git a/module/VuFind/tests/fixtures/configs/worldcatupgrades/config.ini b/module/VuFind/tests/fixtures/configs/worldcatupgrades/config.ini new file mode 100644 index 00000000000..7017b9d297e --- /dev/null +++ b/module/VuFind/tests/fixtures/configs/worldcatupgrades/config.ini @@ -0,0 +1,2 @@ +[WorldCat] +apiKey = fake \ No newline at end of file diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php index c21e3c2cd7d..2b3bf4fc01b 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Config/UpgradeTest.php @@ -304,6 +304,26 @@ class UpgradeTest extends \VuFindTest\Unit\TestCase ); } + /** + * Test WorldCat-specific upgrades. + * + * @return void + */ + public function testWorldCatUpgrades() + { + $upgrader = $this->getUpgrader('worldcatupgrades'); + $upgrader->run(); + $results = $upgrader->getNewConfigs(); + $this->assertEquals( + 'Author', + $results['WorldCat.ini']['Basic_Searches']['srw.au'] + ); + $this->assertEquals( + 'adv_search_author', + $results['WorldCat.ini']['Advanced_Searches']['srw.au'] + ); + } + /** * Test "meaningful line" detection in SolrMarc properties files. * -- GitLab