diff --git a/application/modules/telephone/controllers/RechercheController.php b/application/modules/telephone/controllers/RechercheController.php index 47c48c359b2e3376ca6752efcd500f53af4f56f9..c9eb13641ccec1e0803b6abdc4b7a40c51d84beb 100644 --- a/application/modules/telephone/controllers/RechercheController.php +++ b/application/modules/telephone/controllers/RechercheController.php @@ -40,13 +40,16 @@ class Telephone_RechercheController extends RechercheController { $action_array = ['action' => 'ressourcesnumeriques', 'attribs' => ['data-ajax' => 'false']]; + if($label = Class_DigitalResource::getInstance()->getPhoneLabelOf($notice)) + return [$label => $action_array]; + if ($notice->isLivreNumerique()|| $notice->isEpub()) return [$this->_('Feuilleter le livre') => $action_array]; if ($notice->isArteVOD()) return [$this->_('Accéder à la vidéo') => $action_array]; - if ($notice->isAudioRecord() || $notice->is1DTouch()) + if ($notice->isAudioRecord()) return [$this->_('Accéder à l\'album') => $action_array]; return [$this->_('Accéder à la ressource') => $action_array]; diff --git a/library/Class/DigitalResource.php b/library/Class/DigitalResource.php index 021c891c046b23163362faf6913265aa443f8969..207b45c553c97fcedc2fb41d1b1755f0bdd5217b 100644 --- a/library/Class/DigitalResource.php +++ b/library/Class/DigitalResource.php @@ -203,6 +203,22 @@ class Class_DigitalResource extends Class_Entity { } + public function getPhoneLabelOf($record) { + if (!$this->isPluginDocType($type = $record->getTypeDoc())) + return ''; + + return $this->configFor($type)->getPhoneLabel(); + } + + + public function getExternalUris($record) { + if (!$this->isPluginDocType($type = $record->getTypeDoc())) + return []; + + return $this->configFor($type)->getExternalUris($record); + } + + public function viewHelperFor($type, $helper, $view) { if (!is_readable($this->getBaseDir() . '/' . $type . '/View/Helper/' . $helper . '.php')) return; diff --git a/library/Class/DigitalResource/Config.php b/library/Class/DigitalResource/Config.php index 4b660ca557018549f4d4d43718ce7407d3dabbba..9592130f8d9ec2191ccfdc098e0f51ab2663da54 100644 --- a/library/Class/DigitalResource/Config.php +++ b/library/Class/DigitalResource/Config.php @@ -51,11 +51,21 @@ class Class_DigitalResource_Config extends Class_Entity { public function __construct($digital_resource) { $this->setDigitalResource($digital_resource); - $this->updateAttributes($this->getConfig()); + $this->updateAttributes(array_merge($this->_getDefaultConfig(), $this->_getConfig())); $this->_ensurePermission(); } + protected function _getDefaultConfig() { + return ['PhoneLabel' => $this->_('Accéder à la ressource')]; + } + + + protected function _getConfig() { + return []; + } + + public function registerFrontController($front_controller) { $front_controller->addControllerDirectory((new Class_DigitalResource_Name())->getPath($this) . '/controllers', $this->getModuleName()); @@ -352,4 +362,18 @@ class Class_DigitalResource_Config extends Class_Entity { ->getArrayCopy()); } + + + public function getExternalUris($record) { + return []; + } + + + public function newOAIClient() { + $parser_class = $this->withNameSpace('Service_Parser'); + return (new Class_WebService_OAI()) + ->setParser(new $parser_class) + ->setOAIHandler($this->getAdminVar('Harvest_Url')) + ->setNumericResourceClass($this->withNameSpace('Service_Album')); + } } \ No newline at end of file diff --git a/library/Class/WebService/BibNumerique/OneDTouch/Album.php b/library/Class/DigitalResource/ServiceOAI.php similarity index 53% rename from library/Class/WebService/BibNumerique/OneDTouch/Album.php rename to library/Class/DigitalResource/ServiceOAI.php index c09b6c856a9836c6bc883827fd7eb47060b3da93..f27e3433e68a27a460d21d3576cd9168b17ec93a 100644 --- a/library/Class/WebService/BibNumerique/OneDTouch/Album.php +++ b/library/Class/DigitalResource/ServiceOAI.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. + * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. * * BOKEH is free software; you can redistribute it and/or modify * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by @@ -20,30 +20,38 @@ */ -class Class_WebService_BibNumerique_OneDTouch_Album extends Class_WebService_BibNumerique_RessourceNumerique { +class Class_DigitalResource_ServiceOAI extends Class_WebService_BibNumerique_AbstractOAI { - public function getBaseUrl() { - return (new Class_AdminVar_OneDTouch())->url(); + protected $_config; + + + public static function getInstance() { + return Class_DigitalResource_Config::getInstanceFor(static::class)->getServiceInstance(); + } + + + public function __construct($config) { + $this->_config = $config; + $this->_oaiws = $config->newOAIClient(); } - public function fillAlbum($album) { - return $album->beOneDTouch(); + protected function getDocType() { + return $this->_config->getDocType(); } - public function isAlreadyHarvested() { - return false; + protected function getUrlOrigine() { + return $this->_config->getOAIUrl(); } - public function getRessourceCategorieLibelle() { - return Class_WebService_BibNumerique_OneDTouch::CATEGORY_LABEL; + public function isEnabled() { + return $this->_config->isEnabled(); } - public function setOaiId($data) { - return $this->setId($data); + public function getName() { + return $this->_config->getName(); } -} -?> +} \ No newline at end of file diff --git a/library/Class/Migration/DigitalResource/1DTouch.php b/library/Class/Migration/DigitalResource/1DTouch.php index abfa16d0de9efbed714d07133f957c6e9a792497..44a3716fce910727054c4cfa982ca83b513f06e9 100644 --- a/library/Class/Migration/DigitalResource/1DTouch.php +++ b/library/Class/Migration/DigitalResource/1DTouch.php @@ -64,7 +64,7 @@ class Class_Migration_DigitalResource_1DTouch extends Class_Migration_DigitalRes protected function upgradeAlbum($album) { - $album->setUrlOrigine('https://export.divercities.eu/oai?verb=ListRecords&set=music&metadataPrefix=oai1dtouch_dc'); + $album->setUrlOrigine(DiMusic_Config::getInstance()->getAdminVar('Sso_Url')); if (!$external_uri = $album->getExternalUri()) return parent::upgradeAlbum($album); diff --git a/library/Class/Notice.php b/library/Class/Notice.php index 270402a6ea797a61fe022ba8c0a7d65311011392..edc0d4880a5743660cbde341e1892d779bbe68d4 100644 --- a/library/Class/Notice.php +++ b/library/Class/Notice.php @@ -968,11 +968,6 @@ class Class_Notice extends Storm_Model_Abstract { } - public function is1DTouch() { - return Class_TypeDoc::ONEDTOUCH == $this->getTypeDoc(); - } - - public function getMorceaux() { return Class_Notice_TracksReader::getTracksOf($this); } diff --git a/library/Class/Notice/Urls.php b/library/Class/Notice/Urls.php index 60e06cd2b24d82a75c446d9e7b99c9a4c38a87d5..f43a1664ad2f33189f2d39a4060f6ac3daa818d8 100644 --- a/library/Class/Notice/Urls.php +++ b/library/Class/Notice/Urls.php @@ -99,8 +99,9 @@ class Class_Notice_Urls { if ($this->_notice->isCvs()) return []; - $result = ($this->_notice->is1DTouch()) ? - $this->_get1DTouchLink() : $this->_getDefaultLinks(); + $result = ($uris = Class_DigitalResource::getInstance()->getExternalUris($this->_notice)) + ? $uris + : $this->_getDefaultLinks(); $links = $this->_doBlackList($result); $links = $this->_applyTargets($links); @@ -109,15 +110,6 @@ class Class_Notice_Urls { } - protected function _get1DTouchLink() { - $renderer = function($view) { - return $view->tagOneDTouch($this->_notice->getAlbum()); - }; - - return [(new Class_Notice_Field())->setRenderer($renderer)]; - } - - protected function _getDefaultLinks() { $result = []; $closure = function ($datas) use (&$result) { diff --git a/library/Class/WebService/BibNumerique/Abstract.php b/library/Class/WebService/BibNumerique/Abstract.php index eeff341453cfcb56bd52d4da5bd1a29318f2792c..c3cf0c8c615e580c9fbb31bb0291463617d823be 100644 --- a/library/Class/WebService/BibNumerique/Abstract.php +++ b/library/Class/WebService/BibNumerique/Abstract.php @@ -151,7 +151,6 @@ abstract class Class_WebService_BibNumerique_Abstract extends Class_WebService_A protected function loadPage($page_number = 1) { return $this; - } diff --git a/library/ZendAfi/View/Helper/TagOneDTouch.php b/library/ZendAfi/View/Helper/TagOneDTouch.php deleted file mode 100644 index 32f4b55383bb6bc7898d5d6008cdda314ca8cf58..0000000000000000000000000000000000000000 --- a/library/ZendAfi/View/Helper/TagOneDTouch.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php -/** - * Copyright (c) 2012-2014, Agence Française Informatique (AFI). All rights reserved. - * - * BOKEH is free software; you can redistribute it and/or modify - * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by - * the Free Software Foundation. - * - * There are special exceptions to the terms and conditions of the AGPL as it - * is applied to this software (see README file). - * - * BOKEH 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 AFFERO GENERAL PUBLIC LICENSE for more details. - * - * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE - * along with BOKEH; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -class ZendAfi_View_Helper_TagOneDTouch extends ZendAfi_View_Helper_BaseHelper { - public function tagOneDTouch($album) { - return $this->_tag('a', - $this->_('Écouter l\'album sur 1DTouch'), - ['href' => (new Class_OneDTouchLink())->urlFor($album)]); - } -} -?> \ No newline at end of file diff --git a/library/digital_resources/Assimil/Config.php b/library/digital_resources/Assimil/Config.php index 065c67912741c2cbebba51fb3ecc3d36f1fd1660..58f5ac49a373de1385769bd2026390a17c4fbd6d 100644 --- a/library/digital_resources/Assimil/Config.php +++ b/library/digital_resources/Assimil/Config.php @@ -20,8 +20,7 @@ */ class Assimil_Config extends Class_DigitalResource_Config { - - public function getConfig() { + protected function _getConfig() { return [ 'DocTypeLabel' => $this->_('ASSIMIL e-méthode'), 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à ASSIMIL'), diff --git a/library/digital_resources/Bibliondemand/Config.php b/library/digital_resources/Bibliondemand/Config.php index 6e6db0730c853e5c49510fd674b13a0bce4fbd5f..e07e436cddf089d2390173e694a35c2134f4d4cc 100644 --- a/library/digital_resources/Bibliondemand/Config.php +++ b/library/digital_resources/Bibliondemand/Config.php @@ -21,7 +21,7 @@ class Bibliondemand_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return ['Introduction' => $this->_('Bibliondemand, solution pour bibliothèque numérique.'), 'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO des ressources Bibliondemand')) ->bePrivate()], diff --git a/library/digital_resources/Capturator/Config.php b/library/digital_resources/Capturator/Config.php index f43cf4a06c0298730ce8a351bf0144b439c5ca2d..cd5608caf237d017dc7b87b9db41ce50a436acfa 100644 --- a/library/digital_resources/Capturator/Config.php +++ b/library/digital_resources/Capturator/Config.php @@ -21,7 +21,7 @@ class Capturator_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return ['Introduction' => $this->_('Capturator, apprendre les langues quand et où vous voulez!'), 'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO des ressources Capturator')) ->bePrivate()], diff --git a/library/digital_resources/Cvs/Config.php b/library/digital_resources/Cvs/Config.php index f5e36b1ac4c103e8316a09e89ae2edac2b7cf846..71381e3d2784ffbd8cde293c3b7fb4c1eabd9daf 100644 --- a/library/digital_resources/Cvs/Config.php +++ b/library/digital_resources/Cvs/Config.php @@ -22,7 +22,7 @@ class Cvs_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return [ 'Introduction' => $this->_('“ Spécialiste de la fourniture de produits audiovisuels aux collectivités depuis 1987. â€'), diff --git a/library/digital_resources/DiMusic/Config.php b/library/digital_resources/DiMusic/Config.php index 20f10ad9beda0226435b63f01abdcd27b1615179..06facb6118cf612c9b89735419cb1d53bc803c67 100644 --- a/library/digital_resources/DiMusic/Config.php +++ b/library/digital_resources/DiMusic/Config.php @@ -21,7 +21,7 @@ class DiMusic_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return ['Introduction' => $this->_('DiMusic'), 'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/DiMusic', 'Url' => '', @@ -39,6 +39,7 @@ class DiMusic_Config extends Class_DigitalResource_Config { 'Batch' => $this->withNameSpace('Batch'), 'DocTypeLabel' => $this->_('ressource DiMusic'), + 'PhoneLabel' => $this->_('Accéder à l\'album'), 'AdminVars' => ['Id' => Class_AdminVar_Meta::newDefault($this->_('Identifiant du portail chez 1D touch'))->bePrivate(), @@ -46,13 +47,27 @@ class DiMusic_Config extends Class_DigitalResource_Config { ['value' => 'https://music.divercities.eu'])->bePrivate(), 'Harvest_Url' => Class_AdminVar_Meta::newDefault($this->_('Adresse du serveur OAI DiMusic'), - ['value' => 'https://export.divercities.eu/oai'])->bePrivate()] + ['value' => 'https://export.divercities.eu/oai?set=music'])->bePrivate(), + + 'OAI_metadataPrefix' => Class_AdminVar_Meta::newDefault($this->_('metadataPrefix utilisé pour récuprer le flux OAI'), + ['value' => 'oai1dtouch_dc'])] ]; } public function isEnabled() { - return '' != $this->getAdminVar('SSO_URL'); + return '' != $this->getAdminVar('Sso_Url'); + } + + + public function getExternalUris($record) { + $renderer = function($view) use ($record) { + return $view->tag('a', + $this->_('Écouter l\'album sur diMusic'), + ['href' => $this->getAlbumSsoUrl(Class_Users::getIdentity(), $record->getAlbum())]); + }; + + return [(new Class_Notice_Field())->setRenderer($renderer)]; } @@ -60,14 +75,29 @@ class DiMusic_Config extends Class_DigitalResource_Config { if(!$user) return ''; - return $this->getAdminVar('SSO_URL'); + return $this->getAdminVar('Sso_Url'); } public function getAlbumSsoUrl($user, $album) { - if(!$album) + if (!$album) return ''; - return $this->getAdminVar('SSO_URL'); + $sso_url = $this->getAdminVar('Sso_Url'); + $album_id = 'albums/' . $album->getIdOrigine(); + + if (!$id = $this->getAdminVar('Id')) + return $sso_url . '/' . $album_id; + + return $sso_url + . '/users/auth/afi?' + . http_build_query(['bibid' => $id, + 'dest' => $album_id]); + } + + + public function newOAIClient() { + return parent::newOAIClient() + ->setMetadataPrefix($this->getAdminVar('OAI_metadataPrefix')); } } \ No newline at end of file diff --git a/library/digital_resources/DiMusic/Service.php b/library/digital_resources/DiMusic/Service.php index 31c2b829789980c96ad326b554044762e551b7be..92c14393d250cb4aa87549c60f57eeaed5491c40 100644 --- a/library/digital_resources/DiMusic/Service.php +++ b/library/digital_resources/DiMusic/Service.php @@ -20,4 +20,4 @@ */ -class DiMusic_Service extends Class_DigitalResource_Service {} \ No newline at end of file +class DiMusic_Service extends Class_DigitalResource_ServiceOAI {} \ No newline at end of file diff --git a/library/digital_resources/DiMusic/Service/Album.php b/library/digital_resources/DiMusic/Service/Album.php index 406ccb3303eeb82738bd859eda4933210b45c68e..2f3991a97cd4f7b2fc9b5087dcb805c75f45ca3d 100644 --- a/library/digital_resources/DiMusic/Service/Album.php +++ b/library/digital_resources/DiMusic/Service/Album.php @@ -24,7 +24,7 @@ class DiMusic_Service_Album extends Class_WebService_BibNumerique_RessourceNumer public function getBaseUrl() { - return DiMusic_Config::getInstance()->getAdminVar('SSO_URL'); + return DiMusic_Config::getInstance()->getAdminVar('Sso_Url'); } @@ -32,6 +32,7 @@ class DiMusic_Service_Album extends Class_WebService_BibNumerique_RessourceNumer return DiMusic_Config::getInstance()->getDocType(); } + public function fillAlbum($album) { $album ->setTypeDocId($this->getTypeDoc()); @@ -43,4 +44,14 @@ class DiMusic_Service_Album extends Class_WebService_BibNumerique_RessourceNumer public function getRessourceCategorieLibelle() { return DiMusic_Config::getInstance()->getDocTypeLabel(); } + + + public function isAlreadyHarvested() { + return false; + } + + + public function setOaiId($data) { + return $this->setId($data); + } } \ No newline at end of file diff --git a/library/digital_resources/DiMusic/Service/Parser.php b/library/digital_resources/DiMusic/Service/Parser.php index 3dee8075d0ab8cccc63fc9d8ea2163dff465409b..fc5dfde3ddc8af2696ac5764df461f62b55486a0 100644 --- a/library/digital_resources/DiMusic/Service/Parser.php +++ b/library/digital_resources/DiMusic/Service/Parser.php @@ -1,6 +1,6 @@ <?php /** - * Copyright (c) 2012-2018, Agence Française Informatique (AFI). All rights reserved. + * Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved. * * BOKEH is free software; you can redistribute it and/or modify * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by @@ -20,32 +20,76 @@ */ -class DiMusic_Service_Parser { +class DiMusic_Service_Parser extends Class_WebService_OAI_DublinCoreParser_ForRessourceNumerique { - protected - $_albums = [], - $_current_album; + + public function endId($data) { + if ($this->parser->getParent() == 'track') + return; + $this->enddc_identifier($data); + } + + + public function endTitle($data) { + if ($this->parser->getParent()=='track') + return $this->current_track->setTitre($data); + $this->enddc_title($data); + } + + + public function endUrl($data) { + if ($this->parser->getParent() == 'track') { + return $this->current_track->setUrl($data); + } + $this->getRessourceNumerique()->setExternalUri($data); + } + + + public function endLength($data) { + $this->current_track->setDuration($data); + } + + + public function startTracks() { + $this->tracks = []; + } + + + public function startTrack() { + $this->current_track = new Class_AlbumRessource(); + $this->tracks[] = $this->current_track; + } + + + public function endTracks() { + $this->getRessourceNumerique()->setRessources($this->tracks); + } + + + public function endLabel($data) { + $this->enddc_publisher($data); + } - public function parseXML($xml) { - $this->_parser = new Class_WebService_FasterXMLParser(); - $this->_parser->setElementHandler($this); - $this->_parser->parse($xml); - return $this; + public function endDescription($data) { + $this->enddc_description($data); } - public function startAlbum($attributes) { - $this->_current_album = new DiMusic_Service_Album(); + public function endCover_url($data) { + $this->getRessourceNumerique()->addPoster($data); } - public function endAlbum() { - $this->_albums[] = $this->_current_album; + public function endArtist($data) { + if ($this->parser->inParents('track')) + return $this->current_track->addAuthor($data); + + $this->enddc_creator($data); } - public function getAlbums() { - return $this->_albums; + public function endStyle($data) { + $this->enddc_subject($data); } -} \ No newline at end of file +} diff --git a/library/digital_resources/DiMusic/tests/DiMusicTest.php b/library/digital_resources/DiMusic/tests/DiMusicTest.php index 4c3fc42620d81142c6519324b841a40156b98906..34b6fdcf5fd6ee0ee4b6efd3bf26741767f88dbb 100644 --- a/library/digital_resources/DiMusic/tests/DiMusicTest.php +++ b/library/digital_resources/DiMusic/tests/DiMusicTest.php @@ -27,7 +27,6 @@ abstract class DiMusicActivatedTestCase extends AbstractControllerTestCase { public function setUp() { parent::setUp(); - Class_AdminVar::set('DiMusic_SSO_URL', 'https://test.org/api/bokeh/login'); $group = $this->fixture('Class_UserGroup', ['id' => 1, @@ -191,62 +190,58 @@ class DiMusicPhoneRecordTest extends TelephoneAbstractControllerTestCase { -class OneDTouchFullTest extends ModelTestCase { - protected $_storm_default_to_volatile = true; +class DiMusicFullTest extends DiMusicActivatedTestCase { + + protected + $_storm_default_to_volatile = true, + $_http_client, + $_service; + public function setUp() { parent::setUp(); - RessourcesNumeriquesFixtures::activate1Dtouch(); - - $catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/onedtouch_oai.xml'); + $catalogue_xml = file_get_contents(__DIR__ . '/oai_page1.xml'); - $catalogue_xml_end = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/onedtouch_oai_end.xml'); + $catalogue_xml_end = file_get_contents(__DIR__ . '/oai_page2.xml'); $this->_http_client = $this->mock(); $this->_http_client ->whenCalled('open_url') - ->with('https://dev.1dtouch.com/oai?verb=ListRecords&metadataPrefix=oai1dtouch_dc') + ->with('https://export.divercities.eu/oai?set=music&verb=ListRecords&metadataPrefix=oai1dtouch_dc') ->answers($catalogue_xml) ->whenCalled('open_url') - ->with('https://dev.1dtouch.com/oai?verb=ListRecords&resumptionToken=oai1dtouch_dc.f%282015-02-09T08%3A46%3A09Z%29.u%282015-02-09T08%3A47%3A27Z%29%3A133') + ->with('https://export.divercities.eu/oai?set=music&verb=ListRecords&resumptionToken=oai1dtouch_dc.f%282015-02-09T08%3A46%3A09Z%29.u%282015-02-09T08%3A47%3A27Z%29%3A133') ->answers($catalogue_xml_end) - - ->whenCalled('open_url') - ->with('https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159181474.jpg') - ->answers("image") - ->whenCalled('open_url') - ->with('https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159181993.jpg') - ->answers("image") - ->whenCalled('open_url') - ->with('https://commondatastorage.googleapis.com/music-staging/cargo/medium_3610159198724.jpg') - ->answers("image") ->beStrict(); - $this->_service = new Class_WebService_BibNumerique_OneDTouch(); + $this->_service = DiMusic_Service::getInstance(); $this->_service->setTimeSource(new TimeSourceForTest('2015-01-18 10:00:00')); - Class_WebService_BibNumerique_OneDTouch::setDefaultHttpClient($this->_http_client); + DiMusic_Service::setDefaultHttpClient($this->_http_client); $this->_service->harvest(); Class_Album::clearCache(); - } + /** @test */ - public function nameShouldBeOneDTouch() { - $this->assertEquals('1D touch', $this->_service->getName()); + public function nameShouldBeDiMusic() { + $this->assertEquals('DiMusic', $this->_service->getName()); } + /** @test */ public function shouldBeEnabled() { $this->assertTrue($this->_service->isEnabled()); } + /** @test */ public function shouldHaveSaved4Albums() { $this->assertEquals(4, count(Class_Album::findAll())); } + public function getAlbums() { return [ [ @@ -321,11 +316,14 @@ class OneDTouchFullTest extends ModelTestCase { -class OneDTouchIncTest extends ModelTestCase { +class DiMusicIncTest extends DiMusicActivatedTestCase { + protected $_storm_default_to_volatile = true, $_logger, - $_debug_log = ''; + $_debug_log = '', + $_http_client, + $_service; protected function _setupLogger() { @@ -342,7 +340,7 @@ class OneDTouchIncTest extends ModelTestCase { ->willDo($append_log) ->whenCalled('info') ->willDo($append_log); - Class_WebService_BibNumerique_RessourceNumerique::setLogger($this->_logger); + DiMusic_Service_Album::setLogger($this->_logger); } @@ -351,20 +349,19 @@ class OneDTouchIncTest extends ModelTestCase { $this->_setupLogger(); - RessourcesNumeriquesFixtures::activate1Dtouch(); - $catalogue_xml = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/onedtouch_oai.xml'); + $catalogue_xml = file_get_contents(__DIR__ . '/oai_page1.xml'); - $catalogue_xml_end = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/onedtouch_oai_end.xml'); + $catalogue_xml_end = file_get_contents(__DIR__ . '/oai_page2.xml'); $this->_http_client = $this->mock(); $this->_http_client ->whenCalled('open_url') - ->with('https://dev.1dtouch.com/oai?verb=ListRecords&metadataPrefix=oai1dtouch_dc&from=2015-02-01') + ->with('https://export.divercities.eu/oai?set=music&verb=ListRecords&metadataPrefix=oai1dtouch_dc&from=2015-02-01') ->answers($catalogue_xml) ->whenCalled('open_url') - ->with('https://dev.1dtouch.com/oai?verb=ListRecords&resumptionToken=oai1dtouch_dc.f%282015-02-09T08%3A46%3A09Z%29.u%282015-02-09T08%3A47%3A27Z%29%3A133') + ->with('https://export.divercities.eu/oai?set=music&verb=ListRecords&resumptionToken=oai1dtouch_dc.f%282015-02-09T08%3A46%3A09Z%29.u%282015-02-09T08%3A47%3A27Z%29%3A133') ->answers($catalogue_xml_end) ->whenCalled('open_url') @@ -382,19 +379,19 @@ class OneDTouchIncTest extends ModelTestCase { $this->fixture('Class_WebService_HarvestLog', ['id' => 1, 'end_date' => '2015-02-01', - 'type_doc' => Class_TypeDoc::ONEDTOUCH]); + 'type_doc' => 'DiMusic']); $this->fixture('Class_Album', ['id' => 1, - 'type_doc_id' => Class_TypeDoc::ONEDTOUCH, + 'type_doc_id' => 'DiMusic', 'titre' => '1Dtouch res', 'id_origine' => 128, - 'url_origine' => 'https://dev.1dtouch.com/oai']); + 'url_origine' => 'https://music.divercities.eu']); - $this->_service = new Class_WebService_BibNumerique_OneDTouch(); + $this->_service = DiMusic_Service::getInstance(); $this->_service->setTimeSource(new TimeSourceForTest('2015-03-18 10:00:00')); - Class_WebService_BibNumerique_OneDTouch::setDefaultHttpClient($this->_http_client); + DiMusic_Service::setDefaultHttpClient($this->_http_client); $this->_service->setLogger($this->_logger); $this->_service->harvest(); Class_Album::clearCache(); @@ -402,20 +399,21 @@ class OneDTouchIncTest extends ModelTestCase { public function tearDown() { - Class_WebService_BibNumerique_RessourceNumerique::setLogger(null); + DiMusic_Service_Album::setLogger(null); parent::tearDown(); } /** @test */ public function shouldHave4Albums() { - $this->assertEquals(4, count(Class_Album::findAll())); + $all = Class_Album::findAll(); + $this->assertEquals(4, count($all)); } /** @test */ public function harvestLogShouldContainsExpectedDate() { - $this->assertNotNull(Class_WebService_HarvestLog::findFirstBy(['type_doc' => Class_TypeDoc::ONEDTOUCH, + $this->assertNotNull(Class_WebService_HarvestLog::findFirstBy(['type_doc' => 'DiMusic', 'end_date' => '2015-03-18'])); } @@ -448,30 +446,34 @@ class OneDTouchIncTest extends ModelTestCase { -class oneDTouchWithErrorResponseTest extends ModelTestCase { - protected $_storm_default_to_volatile = true; +class DiMusicWithErrorResponseTest extends DiMusicActivatedTestCase { + + protected + $_storm_default_to_volatile = true, + $_http_client, + $_service; + public function setUp() { parent::setUp(); - RessourcesNumeriquesFixtures::activate1Dtouch(); - $error_response = file_get_contents(realpath(dirname(__FILE__)). '/../../../fixtures/onedtouch_error_response.html'); + $error_response = file_get_contents(__DIR__ . '/error_response.html'); $this->_http_client = $this->mock(); $this->_http_client ->whenCalled('open_url') - ->with('https://dev.1dtouch.com/oai?verb=ListRecords&metadataPrefix=oai1dtouch_dc') + ->with('https://export.divercities.eu/oai?set=music&verb=ListRecords&metadataPrefix=oai1dtouch_dc') ->answers($error_response) ->beStrict(); $this->fixture('Class_WebService_HarvestLog', ['id' => 1, 'end_date' => '2015-02-01', - 'type_doc' => Class_TypeDoc::ONEDTOUCH]); + 'type_doc' => 'DiMusic']); - $this->_service = new Class_WebService_BibNumerique_OneDTouch(); + $this->_service = DiMusic_Service::getInstance(); $this->_service->setTimeSource(new TimeSourceForTest('2015-03-18 10:00:00')); - Class_WebService_BibNumerique_OneDTouch::setDefaultHttpClient($this->_http_client); + DiMusic_Service::setDefaultHttpClient($this->_http_client); $this->_service->harvest(); Class_Album::clearCache(); } @@ -486,9 +488,11 @@ class oneDTouchWithErrorResponseTest extends ModelTestCase { -abstract class RechercheControllerAlbum1DTouchTestCase extends AbstractControllerTestCase { +abstract class DiMusicRechercheControllerTestCase extends AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); @@ -498,11 +502,11 @@ abstract class RechercheControllerAlbum1DTouchTestCase extends AbstractControlle ['id' => 74721, 'titre' => 'Bridges', 'date_maj' => '2015-06-22 16:55:37', - 'type_doc_id' => 114, + 'type_doc_id' => 'DiMusic', 'id_langue' => 'fre', 'id_origine' => 1, 'notes' => 'a:7:{i:0;a:2:{s:5:"field";s:3:"701";s:4:"data";a:2:{s:1:"a";s:5:"Eivor";i:4;s:0:"";}}i:1;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:6:"poster";s:1:"a";s:88:"https://commondatastorage.googleapis.com/music-production/cargo/medium_0663993761558.jpg";}}i:2;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:12:"external_uri";s:1:"a";s:33:"http://music.1dtouch.com/albums/1";}}i:3;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:6:"poster";s:1:"a";s:88:"https://commondatastorage.googleapis.com/music-production/cargo/medium_0663993761558.jpg";}}i:4;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:12:"external_uri";s:1:"a";s:33:"http://music.1dtouch.com/albums/1";}}i:5;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:6:"poster";s:1:"a";s:88:"https://commondatastorage.googleapis.com/music-production/cargo/medium_0663993761558.jpg";}}i:6;a:2:{s:5:"field";s:3:"856";s:4:"data";a:2:{s:1:"x";s:12:"external_uri";s:1:"a";s:33:"http://music.1dtouch.com/albums/1";}}}', - 'url_origine' => 'http://export.1dtouch.com/oai', + 'url_origine' => 'https://music.divercities.eu', 'visible' => 1, 'status' => 3]); $bridges->index(); @@ -524,83 +528,50 @@ abstract class RechercheControllerAlbum1DTouchTestCase extends AbstractControlle - -class RechercheControllerAlbum1DTouchWithSSOTest - extends RechercheControllerAlbum1DTouchTestCase { +class DiMusicRechercheControllerWithSSOTest + extends DiMusicRechercheControllerTestCase { protected function _prepareFixtures() { - $this->fixture('Class_AdminVar', - ['id' => 'ONEDTOUCH_ID', - 'clef' => 'ONEDTOUCH_ID', - 'valeur' => 'my_bib']); - - $this->fixture('Class_AdminVar', - ['id' => 'ONEDTOUCH_VERSION_URL', - 'clef' => 'ONEDTOUCH_VERSION_URL', - 'valeur' => Class_OneDTouchLink::OLD_VERSION]); - } - - - /** @test */ - public function externalUrlShouldBeSSO() { - $this->assertXPathContentContains('//a[@href="https://music.1dtouch.com/users/auth/my_bib?dest=albums/1"]', - 'l\'album sur 1DTouch'); - } - -} - - -class RechercheControllerAlbum1DTouchWithSSOVersion2Test - extends RechercheControllerAlbum1DTouchTestCase { - - protected function _prepareFixtures() { - $this->fixture('Class_AdminVar', - ['id' => 'ONEDTOUCH_ID', - 'clef' => 'ONEDTOUCH_ID', - 'valeur' => 'my_bib']); - - $this->fixture('Class_AdminVar', - ['id' => 'ONEDTOUCH_VERSION_URL', - 'clef' => 'ONEDTOUCH_VERSION_URL', - 'valeur' => Class_OneDTouchLink::NEW_VERSION]); + Class_AdminVar::set('DiMusic_Id', 'my_bib'); } /** @test */ public function externalUrlWithBibParamAsUrlShouldBeSSO() { - - $this->assertXPathContentContains('//a[@href="https://music.1dtouch.com/users/auth/afi?bibid=my_bib&dest=albums/1"]', - 'l\'album sur 1DTouch',$this->_response->getBody()); + $this->assertXPathContentContains('//a[@href="https://music.divercities.eu/users/auth/afi?bibid=my_bib&dest=albums%2F1"]', + 'l\'album sur diMusic', + $this->_response->getBody()); } } -class RechercheControllerAlbum1DTouchWithoutSSOTest - extends RechercheControllerAlbum1DTouchTestCase { +class DiMusicRechercheControllerWithoutSSOTest + extends DiMusicRechercheControllerTestCase { + protected function _prepareFixtures() { - $this->fixture('Class_AdminVar', - ['id' => 'ONEDTOUCH_ID', - 'clef' => 'ONEDTOUCH_ID', - 'valeur' => '']); + Class_AdminVar::set('DiMusic_Id', ''); } + /** @test */ public function externalUrlShouldBeSSO() { - $this->assertXPathContentContains('//a[@href="https://music.1dtouch.com/albums/1"]', - 'l\'album sur 1DTouch'); + $this->assertXPathContentContains('//a[@href="https://music.divercities.eu/albums/1"]', + 'l\'album sur diMusic', + $this->_response->getBody()); } } -class NoticeAjaxController1DTouchTest extends AbstractControllerTestCase { +class DiMusicNoticeAjaxControllerTest extends AbstractControllerTestCase { protected $_storm_default_to_volatile = true; + public function setUp() { parent::setUp(); diff --git a/tests/fixtures/onedtouch_error_response.html b/library/digital_resources/DiMusic/tests/error_response.html similarity index 100% rename from tests/fixtures/onedtouch_error_response.html rename to library/digital_resources/DiMusic/tests/error_response.html diff --git a/tests/fixtures/onedtouch_oai.xml b/library/digital_resources/DiMusic/tests/oai_page1.xml similarity index 100% rename from tests/fixtures/onedtouch_oai.xml rename to library/digital_resources/DiMusic/tests/oai_page1.xml diff --git a/tests/fixtures/onedtouch_oai_end.xml b/library/digital_resources/DiMusic/tests/oai_page2.xml similarity index 100% rename from tests/fixtures/onedtouch_oai_end.xml rename to library/digital_resources/DiMusic/tests/oai_page2.xml diff --git a/library/digital_resources/LaSourisQuiRaconte/Config.php b/library/digital_resources/LaSourisQuiRaconte/Config.php index b8c1e11096d820a0002e64a472dcd947dfd3ad1c..aba1272b0d226da1c77eb73fdaa1d017bec30f38 100644 --- a/library/digital_resources/LaSourisQuiRaconte/Config.php +++ b/library/digital_resources/LaSourisQuiRaconte/Config.php @@ -23,7 +23,7 @@ class LaSourisQuiRaconte_Config extends Class_DigitalResource_Config { const LSQR_URL = 'http://www.lasourisquiraconte.com'; - public function getConfig() { + protected function _getConfig() { return ['Introduction' => $this->_('La Souris Qui Raconte, histoires et contes intéractifs pour enfants'), 'DocTypeLabel' => $this->_('Histoire (La souris qui raconte)'), 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à La Souris Qui Raconte'), diff --git a/library/digital_resources/Lekiosk/Config.php b/library/digital_resources/Lekiosk/Config.php index 2f2e6e6922ac1498c5ba4a8823f5db518c293791..64c59cbfb45c2375449cbdbc6745afe3b8c20b6a 100644 --- a/library/digital_resources/Lekiosk/Config.php +++ b/library/digital_resources/Lekiosk/Config.php @@ -21,7 +21,7 @@ class Lekiosk_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return [ 'DocTypeLabel' => $this->_('Magazine numérique LeKiosk'), 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à LeKiosk'), diff --git a/library/digital_resources/LesYeuxDoc/Config.php b/library/digital_resources/LesYeuxDoc/Config.php index 5d00ddfd50b13259b9c9b5767f315035e6143a49..cc06a43099c1f682247733217b5efcb5f21016cd 100644 --- a/library/digital_resources/LesYeuxDoc/Config.php +++ b/library/digital_resources/LesYeuxDoc/Config.php @@ -22,7 +22,7 @@ class LesYeuxDoc_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return ['Introduction' => $this->_('"Les Yeux Doc" est une plateforme de vidéo à la demande conçue spécifiquement pour les bibliothèques'), 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à la ressource LesYeuxDoc'), diff --git a/library/digital_resources/Musicme/Config.php b/library/digital_resources/Musicme/Config.php index f38d15d987d290e2e4cdb832d659477530b88f3e..9941b4c9b63560cc9fb6cf145669f115a6f4f7b7 100644 --- a/library/digital_resources/Musicme/Config.php +++ b/library/digital_resources/Musicme/Config.php @@ -21,7 +21,7 @@ class Musicme_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return [ 'DocTypeLabel' => $this->_('musicMe'), 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à musicMe'), diff --git a/library/digital_resources/Omeka/Config.php b/library/digital_resources/Omeka/Config.php index 40d31359bfbe2e4ed94bb7ff32d7ff7d1ffa99d8..5de33efb30abdad9e02001cb8ea666291cfba194 100644 --- a/library/digital_resources/Omeka/Config.php +++ b/library/digital_resources/Omeka/Config.php @@ -21,7 +21,7 @@ class Omeka_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return ['Introduction' => $this->_('Omeka, logiciel de gestion de bibliothèque numérique'), 'DocTypeLabel' => $this->_('Ressource numérique Omeka'), 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder aux ressources Omeka'), @@ -53,11 +53,8 @@ class Omeka_Config extends Class_DigitalResource_Config { public function newOAIClient() { - $parser_class = $this->withNameSpace('Service_Parser'); - return (new Class_WebService_OAI()) - ->setOAIHandler($this->getRootUrl() . '/oai-pmh-repository/request') - ->setParser(new $parser_class) - ->setNumericResourceClass($this->withNameSpace('Service_Resource')); + return parent::newOAIClient() + ->setOAIHandler($this->getRootUrl() . '/oai-pmh-repository/request'); } diff --git a/library/digital_resources/Omeka/Service.php b/library/digital_resources/Omeka/Service.php index bdad451fb34904e936e3d57cc422c80d4c57eee1..46e666caa22d848d05ffbd74b925e428ac06935c 100644 --- a/library/digital_resources/Omeka/Service.php +++ b/library/digital_resources/Omeka/Service.php @@ -20,37 +20,4 @@ */ -class Omeka_Service extends Class_WebService_BibNumerique_AbstractOAI { - protected $_config; - - public static function getInstance() { - return Class_DigitalResource_Config::getInstanceFor(static::class)->getServiceInstance(); - } - - - public function __construct($config) { - $this->_config = $config; - $this->_oaiws = $config->newOAIClient(); - } - - - protected function getDocType() { - return $this->_config->getDocType(); - } - - - protected function getUrlOrigine() { - return $this->_config->getOAIUrl(); - } - - - public function isEnabled() { - return $this->_config->isEnabled(); - } - - - public function getName() { - return $this->_config->getName(); - } -} -?> \ No newline at end of file +class Omeka_Service extends Class_DigitalResource_ServiceOAI {} \ No newline at end of file diff --git a/library/digital_resources/Omeka/Service/Resource.php b/library/digital_resources/Omeka/Service/Album.php similarity index 96% rename from library/digital_resources/Omeka/Service/Resource.php rename to library/digital_resources/Omeka/Service/Album.php index 4b95d38a073bafff94c39ab125c05501eb6defc6..be1dabc72cd168359a602ad2af98ef4b379bed14 100644 --- a/library/digital_resources/Omeka/Service/Resource.php +++ b/library/digital_resources/Omeka/Service/Album.php @@ -20,7 +20,7 @@ */ -class Omeka_Service_Resource extends Class_WebService_BibNumerique_RessourceNumerique { +class Omeka_Service_Album extends Class_WebService_BibNumerique_RessourceNumerique { protected $_identifier_hash; diff --git a/library/digital_resources/Orthodidacte/Config.php b/library/digital_resources/Orthodidacte/Config.php index b7635df058a0274ff3ea68ddd03fde63e3d003ba..e0e79ae1d22e4e5488aa3852a6fc871288ff1635 100644 --- a/library/digital_resources/Orthodidacte/Config.php +++ b/library/digital_resources/Orthodidacte/Config.php @@ -21,7 +21,7 @@ class Orthodidacte_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return ['Introduction' => $this->_('Orthodidacte constitue une nouvelle approche pour apprendre l’orthographe et la grammaire de la langue française en ligne.'), 'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/Orthodidacte', 'Url' => 'https://www.orthodidacte.com/', diff --git a/library/digital_resources/Skilleos/Config.php b/library/digital_resources/Skilleos/Config.php index 3f7274d0d5ec57fc759a72b866c5b8e0eba00406..d43d9e26dc623a76ff7afa8a1bfe7722995943aa 100644 --- a/library/digital_resources/Skilleos/Config.php +++ b/library/digital_resources/Skilleos/Config.php @@ -21,7 +21,8 @@ class Skilleos_Config extends Class_DigitalResource_Config { const SKILLEOS_URL = 'http://skilleos.com/sigb/sso/'; - public function getConfig() { + + protected function _getConfig() { return [ 'DocTypeLabel' => $this->_('Cours en ligne Skilleos'), 'PermissionLabel' => $this->_('Bibliothèque numérique: accéder à Skilleos'), diff --git a/library/digital_resources/StoryPlayR/Config.php b/library/digital_resources/StoryPlayR/Config.php index a904d0d9ad5497fdbeffa908071af4de3b35d9ff..c9b57bdda103c0b83464fcd654843862f53f58a0 100644 --- a/library/digital_resources/StoryPlayR/Config.php +++ b/library/digital_resources/StoryPlayR/Config.php @@ -21,7 +21,7 @@ class StoryPlayR_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return ['Introduction' => $this->_('Plusieurs centaines d\'albums jeunesse et livres audio !'), 'AdminVars' => ['SSO_URL' => Class_AdminVar_Meta::newDefault($this->_('URL SSO de la plateforme StoryPlay*r')) ->bePrivate(), diff --git a/library/digital_resources/ToutApprendre/Config.php b/library/digital_resources/ToutApprendre/Config.php index 9538a03c4e501f41f4fda1d21b65a3a7c3be9828..3d2dd4457c60fb6cbb95234f1a83974a9c20c7af 100644 --- a/library/digital_resources/ToutApprendre/Config.php +++ b/library/digital_resources/ToutApprendre/Config.php @@ -21,7 +21,7 @@ class ToutApprendre_Config extends Class_DigitalResource_Config { - public function getConfig() { + protected function _getConfig() { return ['Introduction' => $this->_('toutapprendre.com, leader du e-Learning auprès du grand public, propose des centaines de cours en ligne pour le développement des compétences personnelles de chacun.'), 'HelpLink' => 'http://wiki.bokeh-library-portal.org/index.php/ToutApprendre', diff --git a/tests/library/Class/Migration/DigitalResource/1DTouchTest.php b/tests/library/Class/Migration/DigitalResource/1DTouchTest.php index 16d16f111ce9c5dbce1e23070c664b12e0f68629..a53b82f977ec4d541018e401aa342cb31b83b3bc 100644 --- a/tests/library/Class/Migration/DigitalResource/1DTouchTest.php +++ b/tests/library/Class/Migration/DigitalResource/1DTouchTest.php @@ -103,7 +103,7 @@ class Class_Migration_DigitialResource_1DTouchTest extends ModelTestCase { /** @test */ public function updateMeDocAlbumUrlOrigineShouldBeDivercities() { - $this->assertEquals('https://export.divercities.eu/oai?verb=ListRecords&set=music&metadataPrefix=oai1dtouch_dc', + $this->assertEquals('https://music.divercities.eu', Class_Album::find(456)->getUrlOrigine()); } @@ -136,7 +136,7 @@ class Class_Migration_DigitialResource_1DTouchTest extends ModelTestCase { /** @test */ public function adminVarDiMusicHarvestUrlShoudBeCreated() { - $this->assertEquals('https://export.divercities.eu/oai', + $this->assertEquals('https://export.divercities.eu/oai?set=music', Class_AdminVar::getValueOrDefault('DiMusic_Harvest_Url')); }