Skip to content
Snippets Groups Projects
Commit f401b483 authored by Gregor Gawol's avatar Gregor Gawol
Browse files

set comments to source code and readme file

parent a6e42fac
Branches
Tags
No related merge requests found
Pipeline #5609 passed with stage
in 16 seconds
# 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
<?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
...@@ -28,6 +28,16 @@ use Zend\Http\PhpEnvironment\Request; ...@@ -28,6 +28,16 @@ use Zend\Http\PhpEnvironment\Request;
use Zend\Mvc\Controller\Plugin\Params; use Zend\Mvc\Controller\Plugin\Params;
use Zend\View\Renderer\RendererInterface; 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 class GetBoss extends \VuFind\AjaxHandler\AbstractBase
{ {
...@@ -191,6 +201,14 @@ class GetBoss extends \VuFind\AjaxHandler\AbstractBase ...@@ -191,6 +201,14 @@ class GetBoss extends \VuFind\AjaxHandler\AbstractBase
return []; return [];
} }
/**
* Get the call numbers of a certain isil
*
* @param $namespace
* @param $data
*
* @return array
*/
private function getCallnumbers($namespace, $data) private function getCallnumbers($namespace, $data)
{ {
if ($this->isISIL(array_keys($data), $namespace)) { if ($this->isISIL(array_keys($data), $namespace)) {
...@@ -205,6 +223,14 @@ class GetBoss extends \VuFind\AjaxHandler\AbstractBase ...@@ -205,6 +223,14 @@ class GetBoss extends \VuFind\AjaxHandler\AbstractBase
return []; return [];
} }
/**
* Get all call numbers with array structure
* [ isil => call number]
*
* @param $results
*
* @return array
*/
private function getISILCallNumber($results) private function getISILCallNumber($results)
{ {
$retval = []; $retval = [];
...@@ -226,6 +252,14 @@ class GetBoss extends \VuFind\AjaxHandler\AbstractBase ...@@ -226,6 +252,14 @@ class GetBoss extends \VuFind\AjaxHandler\AbstractBase
return $retval; return $retval;
} }
/**
* Has the isil call numbers?
*
* @param $data
* @param $isil
*
* @return bool
*/
private function isISIL($data, $isil) private function isISIL($data, $isil)
{ {
return preg_grep('/'.$isil.'/', $data) ? return preg_grep('/'.$isil.'/', $data) ?
......
...@@ -23,6 +23,13 @@ namespace finc\Boss\AjaxHandler; ...@@ -23,6 +23,13 @@ namespace finc\Boss\AjaxHandler;
use fid\Service\Client; use fid\Service\Client;
use Interop\Container\ContainerInterface; 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 class GetBossFactory
{ {
/** /**
......
...@@ -21,30 +21,22 @@ ...@@ -21,30 +21,22 @@
namespace finc\Boss\Client; 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\Request;
use GuzzleHttp\Psr7\Uri; use GuzzleHttp\Psr7\Uri;
use Psr\Http\Client\ClientInterface; 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\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\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\SerializerInterface; 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 * @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 class BossClient
{ {
...@@ -52,6 +44,7 @@ class BossClient ...@@ -52,6 +44,7 @@ class BossClient
protected $baseUrl; protected $baseUrl;
/** /**
*
* @var ClientInterface * @var ClientInterface
*/ */
protected $httpClient; protected $httpClient;
...@@ -77,6 +70,8 @@ class BossClient ...@@ -77,6 +70,8 @@ class BossClient
} }
/** /**
* Retrieve Worldcat search webservice with ISBN or ISSN
*
* @param $isxns * @param $isxns
* @param $network * @param $network
* @return array * @return array
...@@ -91,6 +86,7 @@ class BossClient ...@@ -91,6 +86,7 @@ class BossClient
$uri = $this->baseUrl->withQuery("isxn[]=$isxn&network=$network"); $uri = $this->baseUrl->withQuery("isxn[]=$isxn&network=$network");
$request = new Request('GET', $uri); $request = new Request('GET', $uri);
$response = $this->httpClient->sendRequest($request); $response = $this->httpClient->sendRequest($request);
if ($response->getStatusCode() == "200") { if ($response->getStatusCode() == "200") {
$data = $this->lookupData($response); $data = $this->lookupData($response);
if (!empty($data->getHoldings())) { if (!empty($data->getHoldings())) {
...@@ -105,6 +101,8 @@ class BossClient ...@@ -105,6 +101,8 @@ class BossClient
} }
/** /**
* Retrieve Worldcat search webservice with zdb id
*
* @param $zdb * @param $zdb
* @param $network * @param $network
* @return array|void * @return array|void
...@@ -117,6 +115,7 @@ class BossClient ...@@ -117,6 +115,7 @@ class BossClient
$uri = $this->baseUrl->withQuery("zdb=$zdb&network=$network"); $uri = $this->baseUrl->withQuery("zdb=$zdb&network=$network");
$request = new Request('GET', $uri); $request = new Request('GET', $uri);
$response = $this->httpClient->sendRequest($request); $response = $this->httpClient->sendRequest($request);
if ($response->getStatusCode() == "200") { if ($response->getStatusCode() == "200") {
$retval['data'] = $this->lookupData($response)->getHoldings(); $retval['data'] = $this->lookupData($response)->getHoldings();
$retval['param'] = $zdb; $retval['param'] = $zdb;
...@@ -126,6 +125,9 @@ class BossClient ...@@ -126,6 +125,9 @@ class BossClient
} }
/** /**
* Retrieve Worldcat search webservice with query params
* author, title, year
*
* @param $author * @param $author
* @param $title * @param $title
* @param $year * @param $year
...@@ -139,6 +141,7 @@ class BossClient ...@@ -139,6 +141,7 @@ class BossClient
$uri = $this->baseUrl->withQuery("author=$author&title=$title&year=$year&network=$network"); $uri = $this->baseUrl->withQuery("author=$author&title=$title&year=$year&network=$network");
$request = new Request('GET', $uri); $request = new Request('GET', $uri);
$response = $this->httpClient->sendRequest($request); $response = $this->httpClient->sendRequest($request);
if ($response->getStatusCode() == "200") { if ($response->getStatusCode() == "200") {
$retval['data'] = $this->lookupData($response)->getHoldings(); $retval['data'] = $this->lookupData($response)->getHoldings();
$retval['param'] = ''; $retval['param'] = '';
...@@ -147,8 +150,15 @@ class BossClient ...@@ -147,8 +150,15 @@ class BossClient
return []; return [];
} }
/**
* Transform retrieving Response data (JSON Object) to PHP classes
*
* @param $response
* @return Root
*/
private function lookupData($response): Root private function lookupData($response): Root
{ {
/** @var Root $root */
$root = $this->serializer->deserialize( $root = $this->serializer->deserialize(
(string)$response->getBody(), Root::class, 'json', [ (string)$response->getBody(), Root::class, 'json', [
ObjectNormalizer::class => true, ObjectNormalizer::class => true,
......
...@@ -24,6 +24,16 @@ use Interop\Container\ContainerInterface; ...@@ -24,6 +24,16 @@ use Interop\Container\ContainerInterface;
use Psr\Http\Client\ClientInterface; use Psr\Http\Client\ClientInterface;
use Symfony\Component\Serializer\SerializerInterface; 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 class BossClientFactory
{ {
/** /**
......
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
namespace finc\Boss\Client; 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 class ClientException extends \Exception
{ {
} }
...@@ -22,6 +22,14 @@ ...@@ -22,6 +22,14 @@
namespace finc\Boss\Client; 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 class Holding
{ {
/** /**
......
...@@ -22,6 +22,14 @@ ...@@ -22,6 +22,14 @@
namespace finc\Boss\Client; 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 class Root
{ {
/** /**
......
...@@ -20,13 +20,15 @@ ...@@ -20,13 +20,15 @@
*/ */
namespace finc\Boss; 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 class Module
{ {
public function __construct()
{
return;
}
/** /**
* Get module configuration * Get module configuration
* *
...@@ -34,28 +36,6 @@ class Module ...@@ -34,28 +36,6 @@ class Module
*/ */
public function getConfig() public function getConfig()
{ {
return [ return require __DIR__ . '/../res/config/module.config.php';
'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'
]
]
]
]
];
} }
} }
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