Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FINNA-2767] Initial implementation of disec support for reservation lists #3091

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions local/config/finna/FeedbackForms.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,9 @@ forms:
settings:
- [rows, 3]
ReservationListRequest:
allowLocalOverride: true
allowLocalOverride: false
title: ReservationList::form_title
enabled: true
sendMethod: "email"
onlyForLoggedUsers: true
emailSubject: ReservationList::form_email_subject
response: ReservationList::form_response
Expand Down
11 changes: 8 additions & 3 deletions local/config/finna/ReservationList.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
# List can contain same information as under institution information to be more specific
# about where the order is being delivered
# LibraryCardSources is used to check for active connection to ILS to be able to use lists
# Connection holds information about type of lists, currently only value supported is type: Database
# and is the default value, if omitted
# Connection defines how the orders are handled with institutions:
# Type:
# feedbackform: Uses feedback forms for sending orders, see FeedbackForms.yaml.sample : ReservationListRequest for examples
# disec: Uses Disec api for sending orders
# base_url: Api base url
# secret: Api specific secret
# use_cat_id: [Optional] Use catalog id for user instead of firstName, lastName, email. Default false.
#
# Each list declared uses their own translation keys under translation domain ReservationList::
#
Expand Down Expand Up @@ -46,4 +51,4 @@ Institutions:
LibraryCardSources:
- connection_established_to_use_lists
Connection:
type: Database
type: feedbackform
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/en-gb.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = "Reservation lists name"
Send Reservation Request = "Send reservation request"
select_desired_contact_method = "Select desired contact method"
Select = "Select"

; List statuses:
status_unknown = ""
status_delivered = "Delivered"
status_in_process = "In process"
status_canceled = "Cancelled"
status_on_loan = "On Loan"
status_returned = "Returned"
status_renewed = "Renewed"
status_pending = "Pending"
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/fi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = "Varauslistan nimi"
Send Reservation Request = "Lähetä varauspyyntö"
select_desired_contact_method = "Valitse haluamasi yhteydenottotapa"
Select = "Valitse"

; List statuses:
status_unknown = ""
status_delivered = "Toimitettu"
status_in_process = "Käsittelyssä"
status_canceled = "Peruutettu"
status_on_loan = "Lainassa"
status_returned = "Palautettu"
status_renewed = "Uusittu"
status_pending = "Odottaa"
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/se.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = ""
Send Reservation Request = ""
select_desired_contact_method = ""
Select = ""

; List statuses:
status_unknown = ""
status_delivered = ""
status_in_process = ""
status_canceled = ""
status_on_loan = ""
status_returned = ""
status_renewed = ""
status_pending = ""
10 changes: 10 additions & 0 deletions local/languages/finna/ReservationList/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,13 @@ Reservation List Name = "Namn för bokningslista"
Send Reservation Request = "Skicka bokningsförfrågan"
select_desired_contact_method = "Välj önskad kontaktmetod"
Select = "Välj"

; List statuses:
status_unknown = ""
status_delivered = "Levererad"
status_in_process = "Behandlas"
status_canceled = "Annullerad"
status_on_loan = "Utlånad"
status_returned = "Returnerad"
status_renewed = "Förnyad"
status_pending = "Väntar"
6 changes: 6 additions & 0 deletions module/Finna/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@
'Finna\Service\UserPreferenceService' => 'Finna\Service\UserPreferenceServiceFactory',
'Finna\Statistics\Driver\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'Finna\Statistics\EventHandler' => 'Finna\Statistics\EventHandlerFactory',
\Finna\ReservationList\Form\Form::class => \Finna\Form\FormFactory::class,
\Finna\ReservationList\ReservationListService::class => \Finna\ReservationList\ReservationListServiceFactory::class,
\Finna\ReservationList\Connection\PluginManager::class => \VuFind\ServiceManager\AbstractPluginManagerFactory::class,
'Finna\Favorites\FavoritesService' => 'Finna\Favorites\FavoritesServiceFactory',
'Finna\View\CustomElement\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'Finna\Video\Handler\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
Expand Down Expand Up @@ -491,6 +493,8 @@
'Finna\AjaxHandler\GetUserListFactory',
'Finna\AjaxHandler\GetUserLists' =>
'Finna\AjaxHandler\GetUserListsFactory',
'Finna\AjaxHandler\ReservationList' =>
'Finna\AjaxHandler\ReservationListFactory',
'Finna\AjaxHandler\ImportFavorites' =>
'Finna\AjaxHandler\ImportFavoritesFactory',
'Finna\AjaxHandler\OnlinePaymentNotify' =>
Expand Down Expand Up @@ -531,6 +535,7 @@
'getSearchTabsRecommendations' => 'Finna\AjaxHandler\GetSearchTabsRecommendations',
'getSimilarRecords' => 'Finna\AjaxHandler\GetSimilarRecords',
'getUserList' => 'Finna\AjaxHandler\GetUserList',
'reservationList' => 'Finna\AjaxHandler\ReservationList',
'importFavorites' => 'Finna\AjaxHandler\ImportFavorites',
'onlinePaymentNotify' => 'Finna\AjaxHandler\OnlinePaymentNotify',
'registerOnlinePayment' => 'Finna\AjaxHandler\RegisterOnlinePayment',
Expand Down Expand Up @@ -763,6 +768,7 @@
],
'onlinepayment_handler' => [ /* see Finna\OnlinePayment\Handler\PluginManager for defaults */ ],
'video_handler' => [ /* see Finna\Video\Handler\PluginManager for defaults */ ],
'reservationlist_connection' => [ /* see Finna\ReservationList\Connection\PluginManager for defaults */ ],
'recommend' => [
'factories' => [
'VuFind\Recommend\CollectionSideFacets' => 'Finna\Recommend\Factory::getCollectionSideFacets',
Expand Down
3 changes: 2 additions & 1 deletion module/Finna/sql/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ CREATE TABLE `finna_resource_list` (
`list_type` varchar(200) NOT NULL DEFAULT 'resourcelist',
`ordered` datetime DEFAULT NULL,
`pickup_date` datetime DEFAULT NULL,
`connection` varchar(40) NOT NULL DEFAULT 'database',
`connection` varchar(40) NOT NULL DEFAULT 'feedbackform',
`external_id` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
CONSTRAINT `resource_list_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE
Expand Down
112 changes: 112 additions & 0 deletions module/Finna/src/Finna/AjaxHandler/ReservationList.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

/**
* Reservation list ajax handler
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2024.
*
* 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
*
* @category VuFind
* @package AjaxHandler
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki
*/

namespace Finna\AjaxHandler;

use Finna\ReservationList\Connection\PluginManager;
use Finna\ReservationList\ReservationListService;
use Laminas\Mvc\Controller\Plugin\Params;
use VuFind\Db\Entity\UserEntityInterface;
use VuFind\I18n\Translator\TranslatorAwareInterface;

/**
* Reservation list ajax handler
*
* @category VuFind
* @package AjaxHandler
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki
*/
class ReservationList extends \VuFind\AjaxHandler\AbstractBase implements TranslatorAwareInterface
{
use \VuFind\I18n\Translator\TranslatorAwareTrait;

/**
* Constructor
*
* @param ?UserEntityInterface $user Logged in user (or null)
* @param ReservationListService $reservationListService Reservation list service
* @param PluginManager $connectionHandler Reservation List connection handler
*/
public function __construct(
protected ?UserEntityInterface $user,
protected ReservationListService $reservationListService,
protected PluginManager $connectionHandler,
) {
}

/**
* Handle a request.
*
* @param Params $params Parameter helper from controller
*
* @return array [response data, HTTP status code]
*/
public function handleRequest(Params $params)
{
if ($this->user === null) {
return $this->formatResponse(
$this->translate('You must be logged in first'),
self::STATUS_HTTP_NEED_AUTH
);
}
$listId = (int)$params->fromQuery('list_id');
if (!$listId) {
return $this->formatResponse(
'Bad request',
self::STATUS_HTTP_BAD_REQUEST
);
}
$list = $this->reservationListService->getListById($listId, $this->user);
if (!$list) {
return $this->formatResponse(
'Bad request',
self::STATUS_HTTP_BAD_REQUEST
);
}
$result = [];
switch ($params->fromQuery('type')) {
case 'status':
$listProperties = $this->reservationListService->getListProperties(
$list->getInstitution(),
$list->getListConfigIdentifier()
);
$connectionType = $list->getConnection();
$handler = $this->connectionHandler->get($connectionType);
$handler->init($listProperties['properties']);
$response = $handler->getListStatus($list, $this->user);
$result['status'] = $this->translate($response);
break;
default:
break;
}
return $this->formatResponse($result);
}
}
75 changes: 75 additions & 0 deletions module/Finna/src/Finna/AjaxHandler/ReservationListFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php

/**
* Reservation list ajax handler factory
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2024.
*
* 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
*
* @category VuFind
* @package AjaxHandler
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki
*/

namespace Finna\AjaxHandler;

use Psr\Container\ContainerInterface;

/**
* Reservation list ajax handler
*
* @category VuFind
* @package AjaxHandler
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki
*/
class ReservationListFactory implements \Laminas\ServiceManager\Factory\FactoryInterface
{
/**
* Create an object
*
* @param ContainerInterface $container Service manager
* @param string $requestedName Service being created
* @param null|array $options Extra options (optional)
*
* @return object
*
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException if any other error occurs
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __invoke(
ContainerInterface $container,
$requestedName,
array $options = null
) {
if (!empty($options)) {
throw new \Exception('Unexpected options passed to factory.');
}
return new $requestedName(
$container->get(\VuFind\Auth\Manager::class)->getUserObject(),
$container->get(\Finna\ReservationList\ReservationListService::class),
$container->get(\Finna\ReservationList\Connection\PluginManager::class),
);
}
}
2 changes: 1 addition & 1 deletion module/Finna/src/Finna/Controller/FeedbackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function formAction()
{
// Always forward reservation list orders to reservation list controller
$formId = $this->params()->fromRoute('id', $this->params()->fromQuery('id'));
if ($formId === \Finna\Form\Form::RESERVATION_LIST_REQUEST) {
if ($formId === \Finna\ReservationList\Form\Form::RESERVATION_LIST_REQUEST) {
return $this->forwardTo('ReservationList', 'PlaceOrder');
}
// Copy any record_id from query params to post params so that it's available
Expand Down
Loading
Loading