Commit 09422c8d authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

dev #93528 : numel records integrated in cosmogramme

parent 3c02fc5a
Pipeline #8469 failed with stage
in 30 minutes and 2 seconds
- ticket #93528 : Intégration : Meilleur prise en compte des types de documents Numel
\ No newline at end of file
......@@ -250,6 +250,9 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
public function resnumeriquesAction() {
if ($viewer = (new Class_Notice_Numel($this->notice))->getViewer())
return $this->_sendResponseWithScripts($viewer->renderOn($this->view));
$html = $add_album_tag = '';
if (1 == Class_AdminVar::isBibNumEnabled()
......
<?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
*/
abstract class Cosmo_DataProfileControllerNumelProfileTestCase extends CosmoControllerTestCase {
public function setUp() {
parent::setUp();
$this->fixture('Class_IntProfilDonnees',
['id' => 789,
'libelle' => 'OAI Numel',
'accents' => Class_IntProfilDonnees::ENCODING_UTF8,
'rejet_periodiques' => 0,
'id_article_periodique' => Class_IntProfilDonnees::SERIAL_FORMAT_NONE,
'type_fichier' => Class_IntProfilDonnees::FT_RECORDS,
'format' => Class_IntProfilDonnees::FORMAT_NUMEL,
'attributs' => [ [Class_IntProfilDonnees::FIELD_TYPE_DOC_RECOGNITION => []] ]
]);
}
}
class Cosmo_DataProfileControllerNumelEditTest extends Cosmo_DataProfileControllerNumelProfileTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/cosmo/data-profile/edit/id/789', true);
}
/** @test */
public function fileFormatShouldBeNumel() {
$this->assertXPath('//select/option[@label="Dublin Core Numel"][@value="12"][@selected]');
}
/** @test */
public function fieldsetDocTypesShouldBePresent() {
$this->assertXPathContentContains('//form//fieldset/legend', 'Type de documents');
}
/** @test */
public function typeDocColumnLabelsShouldBeType() {
$this->assertXPathContentContains('//script', 'fields:[{"name":"1_type","label":"dcterms:type"}]');
}
}
class Cosmo_DataProfileControllerNumelPostTest extends Cosmo_DataProfileControllerNumelProfileTestCase {
public function setUp() {
parent::setUp();
$post = ['1_type' => ['atlas',
'image fixe',
'image'],
Class_IntProfilDonnees::PROFILE_FILE_TYPE => (string) Class_IntProfilDonnees::FT_RECORDS,
Class_IntProfilDonnees::PROFILE_FILE_FORMAT => (string) Class_IntProfilDonnees::FORMAT_NUMEL];
$this->postDispatch('/cosmo/data-profile/edit/id/789', $post);
Class_IntProfilDonnees::clearCache();
}
/** @test */
public function docTypeFieldsShouldBeAsExpected() {
$this->assertEquals(['code' => '1',
'type' => 'atlas;image fixe;image',
'format' => ''],
Class_IntProfilDonnees::find(789)->getItemDocTypesPrefs()[1]);
}
}
\ No newline at end of file
......@@ -138,6 +138,10 @@ class notice_integration {
$this->analyseur = new Class_Cosmogramme_Integration_Record_Bibliondemand();
break;
case Class_IntProfilDonnees::FORMAT_NUMEL:
$this->analyseur = new Class_Cosmogramme_Integration_Record_Numel();
break;
default:
require_once("classe_notice_ascii.php");
$this->analyseur = new notice_ascii();
......@@ -593,8 +597,9 @@ class notice_integration {
$this->statut = static::RECORD_UPDATE;
if (in_array($this->format,
[ Class_IntProfilDonnees::FORMAT_DUBLIN_CORE,
Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND]))
[Class_IntProfilDonnees::FORMAT_DUBLIN_CORE,
Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND,
Class_IntProfilDonnees::FORMAT_NUMEL]))
return $this->_realUpdate($existing_notice);
// Zones forcees
......
......@@ -36,6 +36,7 @@ abstract class Class_Cosmogramme_FileParser {
Class_IntProfilDonnees::FORMAT_MARC21 => 'Marc',
Class_IntProfilDonnees::FORMAT_AVENIO => 'Ascii_Tab',
Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND => 'OaiDC',
Class_IntProfilDonnees::FORMAT_NUMEL => 'OaiDC',
];
protected $_file_handle, $_position, $_file_size, $_profil;
......
......@@ -93,6 +93,11 @@ class Class_Cosmogramme_Integration extends Storm_Model_Abstract {
}
public function isNumel() {
return $this->getProfilDonnees()->isNumel();
}
public function fileExists() {
return $this->getFileSystem()->file_exists($this->getFilePath());
}
......
......@@ -27,7 +27,9 @@ abstract class Class_Cosmogramme_Integration_DataSource {
public static function on($integration) {
if ($integration->isSourceHTTP()
&& ($integration->isFormatDublinCore() || $integration->isBibliondemand()))
&& ($integration->isFormatDublinCore()
|| $integration->isBibliondemand()
|| $integration->isNumel()))
return new Class_Cosmogramme_Integration_DataSourceOAIDublinCore($integration);
if ($integration->isSourceHTTP())
......@@ -250,9 +252,12 @@ class Class_Cosmogramme_Integration_DataSourceOAIMarc21 extends Class_Cosmogramm
class Class_Cosmogramme_Integration_DataSourceOAIDublinCore extends Class_Cosmogramme_Integration_DataSourceOAI {
public function newClient() {
$parser = $this->_integration->isBibliondemand()
? new Class_WebService_OAI_DublinCoreParser_Bibliondemand()
: new Class_WebService_OAI_DublinCoreParser();
$parser = new Class_WebService_OAI_DublinCoreParser();
if ($this->_integration->isBibliondemand())
$parser = new Class_WebService_OAI_DublinCoreParser_Bibliondemand();
if ($this->_integration->isNumel())
$parser = new Class_WebService_OAI_DublinCoreParser_Numel();
return (new Class_WebService_OAI())
->setOAIHandler($this->_uri)
......
<?php
/**
* Copyright (c) 2019, 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 Class_Cosmogramme_Integration_Record_Numel
extends Class_Cosmogramme_Integration_Record_DublinCore {
protected function _parseDatas($data) {
if (is_array($data))
return $data;
$parser = new Class_WebService_OAI_DublinCoreParser_Numel();
return $parser->parse($data)[0];
}
protected function _dublinCoreToUnimarc() {
$visitor = parent::_dublinCoreToUnimarc();
$visitor
->visitThumbnail($this->_datas['thumbnail'])
->visitPrivateUrl($this->_datas['external_uri'])
->visitCatalogAgency('Numel')
->visitLocations($this->_datas['source'])
->visitCollections($this->_datas['collections'])
->visitSubjectCommonNames($this->_datas['subjects']);
return $visitor;
}
protected function _achieveUnimarc($unimarc_visitor) {
return $unimarc_visitor;
}
protected function _getItem() {
return [['f', $this->_datas['id_oai']],
['r', implode(';', $this->_types)],
['k', $this->_datas['cote']],];
}
}
......@@ -178,6 +178,14 @@ class Class_Indexation_PseudoNotice_UnimarcVisitor extends Class_Indexation_Pseu
}
public function visitSubjectCommonNames($subjects) {
foreach($subjects as $subject)
$this->addUnimarcField('606', '1 ', [['a', $subject]]);
return $this;
}
public function visitRessource($ressource) {
$ressource->acceptVisitor($this);
}
......@@ -252,6 +260,14 @@ class Class_Indexation_PseudoNotice_UnimarcVisitor extends Class_Indexation_Pseu
}
public function visitCollections($datas) {
foreach($datas as $collection)
$this->addUnimarcField('225', ' ', [['a', $collection]]);
return $this;
}
public function visitCreationDate($data) {
return $this->_updateCreationDate($data);
}
......
......@@ -76,7 +76,8 @@ class IntProfilDonneesLoader extends Storm_Model_Loader {
Class_IntProfilDonnees::FORMAT_UNIMARC_XML => $this->_('Unimarc XML'),
Class_IntProfilDonnees::FORMAT_AVENIO => $this->_('Avenio'),
Class_IntProfilDonnees::FORMAT_DUBLIN_CORE => $this->_('Dublin Core'),
Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND => $this->_('Dublin Core Bibliondemand')];
Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND => $this->_('Dublin Core Bibliondemand'),
Class_IntProfilDonnees::FORMAT_NUMEL => $this->_('Dublin Core Numel')];
}
......@@ -121,7 +122,8 @@ class IntProfilDonneesLoader extends Storm_Model_Loader {
Class_IntProfilDonnees::FORMAT_UNIMARC_XML => '',
Class_IntProfilDonnees::FORMAT_AVENIO => '',
Class_IntProfilDonnees::FORMAT_DUBLIN_CORE => '',
Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND => '']);
Class_IntProfilDonnees::FORMAT_BIBLIONDEMAND => '',
Class_IntProfilDonnees::FORMAT_NUMEL => '',]);
}
......@@ -169,6 +171,11 @@ class IntProfilDonneesLoader extends Storm_Model_Loader {
}
public function isFormatNumel($format) {
return Class_IntProfilDonnees::FORMAT_NUMEL == $format;
}
public function getLoanFields() {
return Class_CosmoVar::getList('champs_pret');
}
......@@ -306,6 +313,7 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
FORMAT_DUBLIN_CORE = 9,
FORMAT_CG68_ARCHIVES = 10,
FORMAT_BIBLIONDEMAND = 11,
FORMAT_NUMEL = 12,
SERIAL_FORMAT_NONE = 0,
SERIAL_FORMAT_PERGAME = 1,
......@@ -938,6 +946,11 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
}
public function isNumel() {
return self::FORMAT_NUMEL == $this->getFormat();
}
public function getSeparator() {
switch ($this->getFormat()) {
case self::FORMAT_SEMI_COLON_ASCII : return ';';break;
......
......@@ -60,7 +60,9 @@ class Class_Notice_DoubleFinder {
protected function _strategyName() {
if ($this->_profil
&& ($this->_profil->isFormatDublinCore() || $this->_profil->isBibliondemand()))
&& ($this->_profil->isFormatDublinCore()
|| $this->_profil->isBibliondemand()
|| $this->_profil->isNumel()))
return 'Class_Notice_DoubleFinder_BarcodeStrategy';
if (($this->_double_mode == Class_CosmoVar::DOUBLE_SEARCH_NONE)
......
<?php
/**
* Copyright (c) 2019, 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 Class_Notice_Numel extends Class_Notice_ThirdParty {
public function getViewer() {
return ('Numel' == $this->getFirstCatalogAgency()
&& $this->getFirstPrivateUrl())
? $this
: null;
}
public function renderOn($view) {
if (!$viewer = $this->getFirstPrivateUrl())
return '';
$class = 'Numel_viewer';
Class_ScriptLoader::getInstance()
->addInlineStyle(sprintf('iframe.%s { height: %dpx; width: %dpx; margin-top: 2ex; }',
$class,
900,
600));
return
$view->tagAnchor($viewer,
$view->_('Voir en pleine page'),
['class' => 'bouton',
'target' => '_blank'])
. $view->tag('iframe',
null,
['src' => $viewer,
'class' => $class]);
}
}
......@@ -20,40 +20,15 @@
*/
class Class_Notice_Sso extends Class_Entity {
public function __construct($record) {
$this->setRecord($record);
}
class Class_Notice_Sso extends Class_Notice_ThirdParty {
public function isValid() {
if(!$this->getRecord())
return false;
if(!$catalog_agency = $this->getFirstCatalogAgency())
return false;
return $catalog_agency == 'Bibliondemand';
}
protected function getFirstCatalogAgency() {
$agencies = $this->getRecord()->get_subfield('801', 'b');
return reset($agencies);
}
public function getFirstPrivateUrl() {
$urls = $this->getRecord()->get_subfield('956', 'u');
return reset($urls);
return 'Bibliondemand' == $this->getFirstCatalogAgency();
}
public function getConfig() {
if (!$this->isValid())
return null;
return Class_DigitalResource::getInstance()
->configFor($this->getFirstCatalogAgency());
return $this->isValid()
? Class_DigitalResource::getInstance()->configFor($this->getFirstCatalogAgency())
: null;
}
}
<?php
/**
* Copyright (c) 2019, 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 Class_Notice_ThirdParty extends Class_Entity {
public function __construct($record) {
$this->setRecord($record);
}
public function getFirstCatalogAgency() {
return $this->_getFirstRecordSubfield('801', 'b');
}
public function getFirstPrivateUrl() {
return $this->_getFirstRecordSubfield('956', 'u');
}
protected function _getFirstRecordSubfield($field, $subfield) {
if (!$record = $this->getRecord())
return '';
$datas = $record->get_subfield($field, $subfield);
return reset($datas);
}
}
......@@ -39,6 +39,7 @@ class Class_ProfileSerializer {
if (Class_IntProfilDonnees::isRecordFileType($this->_fileType()))
return $this->_buildStrategyWith(['UnimarcRecord' => 'isFormatUnimarc',
'DublinCoreRecords' => 'isFormatDublinCoreOrBiblionDemand',
'Numel' => 'isFormatNumel',
'CSVItem' => 'isFormatCSV']);
if (Class_IntProfilDonnees::isPatronFileType($this->_fileType()))
......
<?php
/**
* Copyright (c) 2019, 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 Class_ProfileSerializer_Numel extends Class_ProfileSerializer_DublinCoreRecords {
public function buildForm($form) {
return $form->addDocTypeGroup(['type' => $this->_('dcterms:type')]);
}
public function populateForm($form) {
return $form->populateItemDocTypes(['type' => 'type']);
}
protected function _extractRecordsSettings() {
$doc_types_prefs = [];
$doc_types = Class_TypeDoc::findAll();
foreach($doc_types as $doc_type) {
$doc_type_id = $doc_type->getId();
$doc_types_prefs[$doc_type_id] = ['code' => $doc_type_id,
'type' => $this->_extractDocTypeType($doc_type_id),
'format' => ''];
}
return [Class_IntProfilDonnees::PROFILE_DOC_TYPES => $doc_types_prefs,
Class_IntProfilDonnees::FIELD_ITEM_BARCODE => 'f',
Class_IntProfilDonnees::FIELD_ITEM_COTE => '',
Class_IntProfilDonnees::FIELD_ITEM_TYPE_DOC => '',
Class_IntProfilDonnees::FIELD_ITEM_GENRE => '',
Class_IntProfilDonnees::FIELD_ITEM_SECTION => '',
Class_IntProfilDonnees::FIELD_ITEM_EMPLACEMENT => '',
Class_IntProfilDonnees::FIELD_ITEM_ANNEXE => '',
Class_IntProfilDonnees::FIELD_ITEM_AVAILABILITY => '',
Class_IntProfilDonnees::FIELD_ITEM_URL => ['zone' => '995',
'champ' => 'u']];
}
}
<?php
/**
* Copyright (c) 2019, 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 Class_WebService_OAI_DublinCoreParser_Numel
extends Class_WebService_OAI_DublinCoreParser {
protected
$_current_type,
$_current_relation_type;
public function endIdentifier($data) {
if(!$this->parser->getParent() == 'header')
return;
$this->_record['id_oai'] = $data;
}
public function enddcterms_identifier($data) {
$this->_record['url'] = trim($data);
}
public function enddcterms_title($data) {
$this->enddc_title(trim($data));
}
public function enddcterms_langage($data) {
$this->enddc_language('Fre');
}