diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000000000000000000000000000000000000..cbbf85221fd71084dbd60585d509cb65ba88a8b7 --- /dev/null +++ b/Readme.md @@ -0,0 +1,52 @@ +# VuFind Boss Module + +Introduction +------------ +This module is an Open Source Software of the University Library Leipzig. +The module retrieve the data of [BSZ One Stop Search (BOSS)](https://wiki.bsz-bw.de/doku.php?id=projekte:boss:start). + +Installation +------------ +Packagist Repo [Module for BOSS Webservice](https://packagist.org/packages/finc/boss-module) + +To Install use Composer + + php composer require finc\boss-module + +Configuration +------------- +You must to create a configuration file in config folder. + + Filename: boss.ini + + ; Which networks do you want to retrieve data? + [General] + networks[] = swb + networks[] = gbv + networks[] = bvb + networks[] = hebis + networks[] = hbz + networks[] = kobv + ; These are additional networks + addNetworks[] = öbv + addNetworks[] = swissbib + + ; search urls to the german/swiss network catalogs + ; if no data to a certain record when you can display this + [SearchUrls] + swb = "http://swb.bsz-bw.de/DB=2.1/SET=1/TTL=1/CMD?ACT=SRCHA&IKT=1007&TRM=%s" + gbv = "https://gso.gbv.de/DB=2.1/SET=1/TTL=1/CMD?ACT=SRCHA&IKT=1007&TRM=%s" + bvb = "https://opacplus.bib-bvb.de/TouchPoint_touchpoint/search.do?methodToCall=submitButtonCall&methodToCallParameter=submitSearch&refine=false&searchCategories[0]=-1&speedy=on&searchString[0]=%s" + hebis = "http://cbsopac.rz.uni-frankfurt.de/DB=2.1/SET=9/TTL=1/CMD?COLMODE=1&ACT=SRCHA&IKT=8520&SRT=YOP&TRM=%s" + hbz = "http://193.30.112.134/F/?func=find-c&ccl_term=IBN=%s" + kobv = "http://portal.kobv.de/simpleSearch.do?query=%s&plv=2" + swissbib = "https://www.swissbib.ch/Search/Results?lookfor=%s&type=ISN" + öbv = "http://search.obvsg.at/primo_library/libweb/action/search.do?fn=search&ct=search&initialSearch=true&mode=Basic&tab=default_tab&indx=1&dum=true&srt=rank&vid=OBV&frbg=&tb=t&vl(freeText0)=%s&scp.scps=scope=(OBV_aleph)" + + ; Which attributes to search with + ; you can search with isbn/issn or zdb attribute + [Search] + sequence[] = zdb + sequence[] = isbn + zdb = getZdbId + isbn = getISBNs \ No newline at end of file diff --git a/res/config/module.config.php b/res/config/module.config.php new file mode 100644 index 0000000000000000000000000000000000000000..ff5149823fbc00a777af2497e1f2cff3d3e1978d --- /dev/null +++ b/res/config/module.config.php @@ -0,0 +1,44 @@ +<?php +/** + * Copyright (C) 2019 Leipzig University Library + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php NU GPLv2 + */ + +return [ + 'service_manager' => [ + 'allow_override' => true, + 'factories' => [ + 'finc\Boss\Client\BossClient' => 'finc\Boss\Client\BossClientFactory' + ], + 'aliases' => [ + 'finc\BossClient' => 'finc\Boss\Client\BossClient' + ] + ], + 'vufind' => [ + 'plugin_managers' => [ + 'ajaxhandler' => [ + 'factories' => [ + 'finc\Boss\AjaxHandler\GetBoss' => 'finc\Boss\AjaxHandler\GetBossFactory' + ], + 'aliases' => [ + 'getBoss' => 'finc\Boss\AjaxHandler\GetBoss' + ] + ] + ] + ] +]; \ No newline at end of file diff --git a/src/AjaxHandler/GetBoss.php b/src/AjaxHandler/GetBoss.php index 16973fb1446307a9fa1d33ff02edce0e244ce0e0..31ddf5caf2dd3c504e1d67cdd4428dcf4c3d555e 100644 --- a/src/AjaxHandler/GetBoss.php +++ b/src/AjaxHandler/GetBoss.php @@ -28,6 +28,16 @@ use Zend\Http\PhpEnvironment\Request; use Zend\Mvc\Controller\Plugin\Params; use Zend\View\Renderer\RendererInterface; +/** + * "Get Boss data" AJAX Handler + * + * This service will retrieve the data of webservice BSZ One Stop Search (BOSS) + * to display the availability of a certain record + * + * @package finc\Boss\AjaxHandler + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + */ class GetBoss extends \VuFind\AjaxHandler\AbstractBase { @@ -191,6 +201,14 @@ class GetBoss extends \VuFind\AjaxHandler\AbstractBase return []; } + /** + * Get the call numbers of a certain isil + * + * @param $namespace + * @param $data + * + * @return array + */ private function getCallnumbers($namespace, $data) { if ($this->isISIL(array_keys($data), $namespace)) { @@ -205,6 +223,14 @@ class GetBoss extends \VuFind\AjaxHandler\AbstractBase return []; } + /** + * Get all call numbers with array structure + * [ isil => call number] + * + * @param $results + * + * @return array + */ private function getISILCallNumber($results) { $retval = []; @@ -226,6 +252,14 @@ class GetBoss extends \VuFind\AjaxHandler\AbstractBase return $retval; } + /** + * Has the isil call numbers? + * + * @param $data + * @param $isil + * + * @return bool + */ private function isISIL($data, $isil) { return preg_grep('/'.$isil.'/', $data) ? diff --git a/src/AjaxHandler/GetBossFactory.php b/src/AjaxHandler/GetBossFactory.php index a855c450e794b8f5eedd219efe4eb5b066b80cfc..7139bc63d5e9eb436f2f971f8e6de8915a66bd0d 100644 --- a/src/AjaxHandler/GetBossFactory.php +++ b/src/AjaxHandler/GetBossFactory.php @@ -23,6 +23,13 @@ namespace finc\Boss\AjaxHandler; use fid\Service\Client; use Interop\Container\ContainerInterface; +/** + * Factory for GetBoss AJAX handler. + * + * @package finc\Boss\AjaxHandler + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + */ class GetBossFactory { /** diff --git a/src/Client/BossClient.php b/src/Client/BossClient.php index 9744b09bc05339ecbe2e72c76351635f4eb2aaee..fe833f955f14ff18944bdaec3ced5ec0b52eddd9 100644 --- a/src/Client/BossClient.php +++ b/src/Client/BossClient.php @@ -21,30 +21,22 @@ namespace finc\Boss\Client; -use Doctrine\Common\Annotations\AnnotationReader; -use finc\SymfonySerializerZendBridge\Normalizer\SnakeCaseObjectNormalizer; -use finc\SymfonySerializerZendBridge\Normalizer\XmlAttributesDenormalizer; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Uri; use Psr\Http\Client\ClientInterface; -use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; -use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Symfony\Component\Serializer\Encoder\XmlEncoder; -use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory; -use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory; -use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader; -use Symfony\Component\Serializer\Mapping\Loader\XmlFileLoader; -use Symfony\Component\Serializer\Serializer; -use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; -use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\SerializerInterface; /** - * Class Client + * "Get Boss data" AJAX Handler + * + * This service will retrieve the data of webservice BSZ One Stop Search (BOSS) + * to display avaiabiblity of a certain record * * @package finc\Boss\Client + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License */ class BossClient { @@ -52,6 +44,7 @@ class BossClient protected $baseUrl; /** + * * @var ClientInterface */ protected $httpClient; @@ -77,6 +70,8 @@ class BossClient } /** + * Retrieve Worldcat search webservice with ISBN or ISSN + * * @param $isxns * @param $network * @return array @@ -91,6 +86,7 @@ class BossClient $uri = $this->baseUrl->withQuery("isxn[]=$isxn&network=$network"); $request = new Request('GET', $uri); $response = $this->httpClient->sendRequest($request); + if ($response->getStatusCode() == "200") { $data = $this->lookupData($response); if (!empty($data->getHoldings())) { @@ -105,6 +101,8 @@ class BossClient } /** + * Retrieve Worldcat search webservice with zdb id + * * @param $zdb * @param $network * @return array|void @@ -117,6 +115,7 @@ class BossClient $uri = $this->baseUrl->withQuery("zdb=$zdb&network=$network"); $request = new Request('GET', $uri); $response = $this->httpClient->sendRequest($request); + if ($response->getStatusCode() == "200") { $retval['data'] = $this->lookupData($response)->getHoldings(); $retval['param'] = $zdb; @@ -126,6 +125,9 @@ class BossClient } /** + * Retrieve Worldcat search webservice with query params + * author, title, year + * * @param $author * @param $title * @param $year @@ -139,6 +141,7 @@ class BossClient $uri = $this->baseUrl->withQuery("author=$author&title=$title&year=$year&network=$network"); $request = new Request('GET', $uri); $response = $this->httpClient->sendRequest($request); + if ($response->getStatusCode() == "200") { $retval['data'] = $this->lookupData($response)->getHoldings(); $retval['param'] = ''; @@ -147,8 +150,15 @@ class BossClient return []; } + /** + * Transform retrieving Response data (JSON Object) to PHP classes + * + * @param $response + * @return Root + */ private function lookupData($response): Root { + /** @var Root $root */ $root = $this->serializer->deserialize( (string)$response->getBody(), Root::class, 'json', [ ObjectNormalizer::class => true, diff --git a/src/Client/BossClientFactory.php b/src/Client/BossClientFactory.php index c151e2339c10f5d5147220091ff112203d6d73f3..8a98a03c8466de74cb409c641b615d00512be2ea 100644 --- a/src/Client/BossClientFactory.php +++ b/src/Client/BossClientFactory.php @@ -24,6 +24,16 @@ use Interop\Container\ContainerInterface; use Psr\Http\Client\ClientInterface; use Symfony\Component\Serializer\SerializerInterface; +/** + * "Get Boss data" AJAX Handler + * + * This service will retrieve the data of webservice BSZ One Stop Search (BOSS) + * to display avaiabiblity of a certain record + * + * @package finc\Boss\Client + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + */ class BossClientFactory { /** diff --git a/src/Client/ClientException.php b/src/Client/ClientException.php index 764f013f9458389b70f63cdf2d384fa97c2f8183..342a60c41c40bf893976b22dab786680b63444a5 100644 --- a/src/Client/ClientException.php +++ b/src/Client/ClientException.php @@ -21,6 +21,13 @@ namespace finc\Boss\Client; +/** + * Exception class + * + * @package finc\Boss\AjaxHandler + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + */ class ClientException extends \Exception { } diff --git a/src/Client/Holding.php b/src/Client/Holding.php index d21e8b76528cccadf7b4d576f3ac05e087b5bfb8..f5a0f66b25e11667199f7366a02e73b663a3b296 100644 --- a/src/Client/Holding.php +++ b/src/Client/Holding.php @@ -22,6 +22,14 @@ namespace finc\Boss\Client; +/** + * JSON Mapping Class Holding + * + * @package finc\Boss\Client + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class Holding { /** diff --git a/src/Client/Root.php b/src/Client/Root.php index d551b24877854015bd6db9be04b60d2a44cd35e1..cf2a0d324d75f1e7bfbe7266c49a7f5118206776 100644 --- a/src/Client/Root.php +++ b/src/Client/Root.php @@ -22,6 +22,14 @@ namespace finc\Boss\Client; +/** + * JSON Mapping Class Root + * + * @package finc\Boss\Client + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ class Root { /** diff --git a/src/Module.php b/src/Module.php index 3caa49e4b46da33aa522c1286866fc4dfae1b43e..bfcc5fc93d7297b1fa3b8c47e3873621f6988cfd 100644 --- a/src/Module.php +++ b/src/Module.php @@ -20,13 +20,15 @@ */ namespace finc\Boss; +/** + * Module config Class + * + * @package finc\Boss + * @author Gregor Gawol <gawol@ub.uni-leipzig.de> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + */ class Module { - public function __construct() - { - return; - } - /** * Get module configuration * @@ -34,28 +36,6 @@ class Module */ public function getConfig() { - return [ - 'service_manager' => [ - 'allow_override' => true, - 'factories' => [ - 'finc\Boss\Client\BossClient' => 'finc\Boss\Client\BossClientFactory' - ], - 'aliases' => [ - 'finc\BossClient' => 'finc\Boss\Client\BossClient' - ] - ], - 'vufind' => [ - 'plugin_managers' => [ - 'ajaxhandler' => [ - 'factories' => [ - 'finc\Boss\AjaxHandler\GetBoss' => 'finc\Boss\AjaxHandler\GetBossFactory' - ], - 'aliases' => [ - 'getBoss' => 'finc\Boss\AjaxHandler\GetBoss' - ] - ] - ] - ] - ]; + return require __DIR__ . '/../res/config/module.config.php'; } }