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

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7c15adb
Initial implementation of disec support for reservation lists
LuomaJuha Nov 28, 2024
a8a59ae
Adjusted to log values, added ReservationListStatus enumerator
LuomaJuha Nov 29, 2024
9adda13
Merge branch 'dev' into reservationlist-disec-implementation
LuomaJuha Dec 3, 2024
412e76b
Review fixes
LuomaJuha Dec 5, 2024
64f5ee2
Adjusted sample file to match
LuomaJuha Dec 5, 2024
f18570f
Added missing empty translation
LuomaJuha Dec 5, 2024
389e207
Moved properties to proper class
LuomaJuha Dec 5, 2024
83221b9
Adjusted keys
LuomaJuha Dec 5, 2024
04db089
Fixed typos in translations, moved Connection specific classes to the…
LuomaJuha Dec 10, 2024
8427a2d
Manipulate post params less, use form more properly.
LuomaJuha Dec 11, 2024
371302a
Adjusted setListOrdered default values set
LuomaJuha Dec 11, 2024
a5f3652
Moved reservation list specific form functionality to its own class
LuomaJuha Dec 11, 2024
ea5f3bc
Removed unused parts of code
LuomaJuha Dec 11, 2024
94fa86a
Readded in_process as it is a plausible state for order, adjusted com…
LuomaJuha Dec 11, 2024
030f466
Revert php versions to 8
LuomaJuha Dec 11, 2024
7c9b98f
And also this one
LuomaJuha Dec 11, 2024
8add8c4
Adjusted to not use feedback
LuomaJuha Jan 3, 2025
2a072c7
Removed sample from feedbackforms.yaml.sample
LuomaJuha Jan 3, 2025
d5515e6
Removed odd variable from default values
LuomaJuha Jan 3, 2025
01dac99
Adjusted param types
LuomaJuha Jan 3, 2025
ef99018
Renamed to match handler instead of connection
LuomaJuha Jan 14, 2025
ae47fcd
Adjusted comments
LuomaJuha Jan 14, 2025
61d0be0
Adjusted variable name in reservationlistservice
LuomaJuha Jan 15, 2025
a7873af
Line length fix
LuomaJuha Jan 15, 2025
e40eaea
removed switch case from reservationlist ajax handler
LuomaJuha Jan 15, 2025
a7501a9
Adjusted to use function defined in abstractbase to fetch required va…
LuomaJuha Jan 15, 2025
cd30dcb
Removed some calls to helper
LuomaJuha Jan 15, 2025
57d01e7
Update module/Finna/src/Finna/ReservationList/ReservationListService.php
LuomaJuha Jan 15, 2025
8d2cfc1
Update module/Finna/src/Finna/ReservationList/ReservationListService.php
LuomaJuha Jan 15, 2025
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
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 holds information about type of lists:
EreMaijala marked this conversation as resolved.
Show resolved Hide resolved
# feedbackform: Default connection, orders handled with sending forms
# handler: email [Optional] Default handler email, other values found in FeedbackForms.yaml primary handlers
EreMaijala marked this conversation as resolved.
Show resolved Hide resolved
# disec:
# 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
13 changes: 13 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,16 @@ 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_in_process = "In process"
status_processed = "Handled"
EreMaijala marked this conversation as resolved.
Show resolved Hide resolved
status_delivered = "Delivered"
status_cancelled = "Canceled"
EreMaijala marked this conversation as resolved.
Show resolved Hide resolved
status_replied = "Replied"
status_removed_item = "Item removed"
status_on_loan = "Loaned"
EreMaijala marked this conversation as resolved.
Show resolved Hide resolved
status_returned = "Returned"
status_renewed = "Renewed"
status_pending = "Pending"
13 changes: 13 additions & 0 deletions local/languages/finna/ReservationList/fi.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ 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_in_process = "Käsittelyssä"
status_processed = "Käsitelty"
status_delivered = "Toimitettu"
status_cancelled = "Peruutettu"
status_replied = "Vastattu"
status_removed_item = "Aineisto poistettu"
status_on_loan = "Lainassa"
status_returned = "Palautettu"
status_renewed = "Uusittu"
status_pending = "Odottaa"
13 changes: 13 additions & 0 deletions local/languages/finna/ReservationList/se.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ Reservation List Name = ""
Send Reservation Request = ""
select_desired_contact_method = ""
Select = ""

; List statuses:
status_unknown = ""
status_in_process = ""
status_processed = ""
status_delivered = ""
status_cancelled = ""
status_replied = ""
status_removed_item = ""
status_on_loan = ""
status_returned = ""
status_renewed = ""
status_pending = ""
13 changes: 13 additions & 0 deletions local/languages/finna/ReservationList/sv.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,16 @@ 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_in_process = "Behandlas"
status_processed = "Behandlad"
status_delivered = "Levererad"
status_cancelled = "Annulerad"
EreMaijala marked this conversation as resolved.
Show resolved Hide resolved
status_replied = "Besvarad"
status_removed_item = "Objekt borttaget"
status_on_loan = "Lånad"
EreMaijala marked this conversation as resolved.
Show resolved Hide resolved
status_returned = "Returnerad"
status_renewed = "Förnyad"
status_pending = "Väntar"
5 changes: 5 additions & 0 deletions module/Finna/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@
'Finna\Statistics\Driver\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'Finna\Statistics\EventHandler' => 'Finna\Statistics\EventHandlerFactory',
\Finna\ReservationList\ReservationListService::class => \Finna\ReservationList\ReservationListServiceFactory::class,
\Finna\ReservationList\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 +492,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 +534,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 +767,7 @@
],
'onlinepayment_handler' => [ /* see Finna\OnlinePayment\Handler\PluginManager for defaults */ ],
'video_handler' => [ /* see Finna\Video\Handler\PluginManager for defaults */ ],
'reservationlist' => [ /* see Finna\ReservationList\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.1
*
* 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 <[email protected]>
* @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\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 <[email protected]>
* @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.1
*
* 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 <[email protected]>
* @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 <[email protected]>
* @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\PluginManager::class),
);
}
}
Loading
Loading