Skip to content
Draft
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
6 changes: 2 additions & 4 deletions local/config/finna/ReservationList.yaml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@
#
# General settings for how to fetch list configurations
# Settings:
# Methods available yaml, api. If yaml is selected, will read list configurations from this file,
# method: [yaml, api]
# url: if api is selected, will fetch configurations from api endpoint
# Methods available yaml, database. If yaml is selected, will read list configurations from this file
# method: [yaml, database]
# ttl: How long does cached config live, default is 60 minutes
#
Settings:
method: yaml
#url:
ttl: 60
Institutions:
Example Institution:
Expand Down
3 changes: 3 additions & 0 deletions module/Finna/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@
'Finna\Db\Row\UserCard' => 'VuFind\Db\Row\RowGatewayFactory',
'Finna\Db\Row\UserList' => 'VuFind\Db\Row\UserListFactory',
\Finna\Db\Row\FinnaResourceList::class => \VuFind\Db\Row\RowGatewayFactory::class,
\Finna\Db\Row\FinnaResourceListHandler::class => \VuFind\Db\Row\RowGatewayFactory::class,
\Finna\Db\Row\FinnaResourceListResource::class => \VuFind\Db\Row\RowGatewayFactory::class,
'Finna\Db\Row\UserResource' => 'VuFind\Db\Row\RowGatewayFactory',
],
Expand Down Expand Up @@ -678,6 +679,7 @@
=> \VuFind\Db\Service\AbstractDbServiceFactory::class,
\Finna\Db\Service\RatingsService::class => \VuFind\Db\Service\AbstractDbServiceFactory::class,
\Finna\Db\Service\RecordService::class => \VuFind\Db\Service\AbstractDbServiceFactory::class,
\Finna\Db\Service\FinnaResourceListHandlerService::class => \VuFind\Db\Service\AbstractDbServiceFactory::class,
\Finna\Db\Service\FinnaResourceListService::class => \VuFind\Db\Service\AbstractDbServiceFactory::class,
\Finna\Db\Service\FinnaResourceListResourceService::class => \VuFind\Db\Service\AbstractDbServiceFactory::class,
\Finna\Db\Service\SearchService::class => \VuFind\Db\Service\AbstractDbServiceFactory::class,
Expand Down Expand Up @@ -740,6 +742,7 @@
'Finna\Db\Table\User' => 'VuFind\Db\Table\UserFactory',
'Finna\Db\Table\UserList' => 'VuFind\Db\Table\GatewayFactory',
\Finna\Db\Table\FinnaResourceList::class => \VuFind\Db\Table\GatewayFactory::class,
\Finna\Db\Table\FinnaResourceListHandler::class => \VuFind\Db\Table\GatewayFactory::class,
\Finna\Db\Table\FinnaResourceListResource::class => \VuFind\Db\Table\GatewayFactory::class,
'Finna\Db\Table\UserResource' => 'VuFind\Db\Table\GatewayFactory',
],
Expand Down
15 changes: 15 additions & 0 deletions module/Finna/sql/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,21 @@ CREATE TABLE `finna_resource_list` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `finna_resource_list_handler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`institution` varchar(255) NOT NULL,
`identifier` varchar(255) NOT NULL,
`enabled` int(1) NOT NULL DEFAULT 0,
`data` json DEFAULT '',
`created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00',
`published` datetime NOT NULL DEFAULT '2000-01-01 00:00:00',
PRIMARY KEY (`id`),
KEY `institution` (`institution`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `finna_resource_list_resource` (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

/**
* Finna resource list handler entity interface
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2025.
*
* 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 Db_Interface
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/

namespace Finna\Db\Entity;

use DateTime;
use VuFind\Db\Entity\EntityInterface;

/**
* Finna resource list handler entity interface
*
* @category VuFind
* @package Db_Interface
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*
* @property int $id
* @property string $institution
* @property string $identifier
* @property int $enabled
* @property string $data
* @property string $created
*/
interface FinnaResourceListHandlerEntityInterface extends EntityInterface
{
/**
* Get the ID of the list.
*
* @return ?int
*/
public function getId(): ?int;

/**
* Get user entity
*
* @return string
*/
public function getInstitution(): string;

/**
* Get list identifier
*
* @return string;
*/
public function getIdentifier(): string;

/**
* Is the list enabled
*
* @return bool
*/
public function getEnabled(): bool;

/**
* Get list data as associative array
*
* @return array
*/
public function getData(): array;

/**
* Get time when list has been created
*
* @return DateTime
*/
public function getCreated(): DateTime;
}
120 changes: 120 additions & 0 deletions module/Finna/src/Finna/Db/Row/FinnaResourceListHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php

/**
* Finna resource list handler entity
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2025.
*
* 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 Db_Interface
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/

namespace Finna\Db\Row;

use DateTime;
use Finna\Db\Entity\FinnaResourceListHandlerEntityInterface;
use VuFind\Db\Row\RowGateway;

/**
* Finna resource list handler entity
*
* @category VuFind
* @package Db_Interface
* @author Ere Maijala <ere.maijala@helsinki.fi>
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*
* @property int $id
* @property string $institution
* @property string $identifier
* @property int $enabled
* @property string $data
* @property string $created
*/
class FinnaResourceListHandler extends RowGateway implements
\VuFind\Db\Service\DbServiceAwareInterface,
FinnaResourceListHandlerEntityInterface
{
use \VuFind\Db\Table\DbTableAwareTrait;
use \VuFind\Db\Service\DbServiceAwareTrait;

/**
* Get the ID of the list handler.
*
* @return int
*/
public function getId(): int
{
return $this->id;
}

/**
* Get user entity
*
* @return string
*/
public function getInstitution(): string
{
return $this->institution;
}

/**
* Get list identifier
*
* @return string;
*/
public function getIdentifier(): string
{
return $this->identifier;
}

/**
* Is the list enabled
*
* @return bool
*/
public function getEnabled(): bool
{
return (bool)$this->enabled;
}

/**
* Get list data as associative array
*
* @return array
*/
public function getData(): array
{
return json_decode($this->data, true);
}

/**
* Get time when list has been created
*
* @return DateTime
*/
public function getCreated(): DateTime
{
return DateTime::createFromFormat('Y-m-d H:i:s', $this->created);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/**
* Resource list handler service
*
* PHP version 8
*
* Copyright (C) The National Library of Finland 2025.
*
* 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 Db_Service
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/

namespace Finna\Db\Service;

use VuFind\Db\Service\AbstractDbService;
use VuFind\Db\Service\DbServiceAwareTrait;
use VuFind\Db\Table\DbTableAwareInterface;
use VuFind\Db\Table\DbTableAwareTrait;

/**
* Resource list handler service
*
* @category VuFind
* @package Db_Service
* @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 Wiki
*/
class FinnaResourceListHandlerService extends AbstractDbService implements
DbTableAwareInterface,
FinnaResourceListHandlerServiceInterface
{
use DbTableAwareTrait;
use DbServiceAwareTrait;

/**
* Get resource list handlers
*
* @return array
*/
public function getResourceListHandlers(): array
{
return iterator_to_array(
$this->getDbTable(\Finna\Db\Table\FinnaResourceListHandler::class)->select(['enabled' => 1])
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* Resource list service interface
*
* 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 Db_Service
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/

namespace Finna\Db\Service;

use VuFind\Db\Service\DbServiceInterface;

/**
* Resource list handler service interface
*
* @category VuFind
* @package Db_Service
* @author Juha Luoma <juha.luoma@helsinki.fi>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link http://vufind.org Main Site
*/
interface FinnaResourceListHandlerServiceInterface extends DbServiceInterface
{
/**
* Get resource list handlers
*
* @return array
*/
public function getResourceListHandlers(): array;
}
Loading