Commit 26276a09 authored by Laurent's avatar Laurent
Browse files

dev #92386 Import serials from PMB

parent 8c6ba4c2
Pipeline #7977 failed with stage
in 32 minutes and 31 seconds
'92386' =>
['Label' => $this->_('Import périodiques PMB'),
'Desc' => '',
'Image' => '',
'Video' => '',
'Category' => '',
'Right' => function($feature_description, $user) {return true;},
'Wiki' => '',
'Test' => '',
'Date' => '2019-05-15'],
\ No newline at end of file
- ticket #92386 : Import périodiques PMB
\ No newline at end of file
......@@ -115,10 +115,15 @@ class NoticeAjaxController extends ZendAfi_Controller_Action {
public function exemplairesAction() {
if (($first_item = $this->notice->getFirstExemplaire()) && $first_item->isTypeSerialArticle())
$this->notice = $first_item->getPMBSerialRecord();
$nb_notices_oeuvre = Class_Notice::countBy(['clef_oeuvre' => $this->notice->getClefOeuvre(),
'id_notice not' => $this->id_notice]);
'id_notice not' => $this->notice->getId()]);
$this->renderExemplaires($this->id_notice, $nb_notices_oeuvre, 'normal');
$this->renderExemplaires($this->notice->getId(),
$nb_notices_oeuvre,
'normal');
}
......
......@@ -366,7 +366,7 @@ class Cosmo_DataProfileControllerEditUnimarcKohaTest extends Cosmo_DataProfileCo
/** @test */
public function selectIdArticlePeriodiqueShouldBePresent() {
$this->assertXPath('//form//select[@id="id_article_periodique"]/option[@value="' . Class_IntProfilDonnees::SERIAL_FORMAT_KOHA . '"][@selected]');
$this->assertXPathContentContains('//form//select[@id="id_article_periodique"]/option[@value="' . Class_IntProfilDonnees::SERIAL_FORMAT_KOHA . '"][@selected]', 'Koha');
}
......
......@@ -191,7 +191,7 @@ class notice_integration {
return;
}
if($this->notice["type_doc"] == Class_TypeDoc::PERIODIQUE) {
if ($this->notice["type_doc"] == Class_TypeDoc::PERIODIQUE) {
// Periodiques Koha et orphee (1 exemplaire pour chaque numéro)
if(($this->id_article_periodique == Class_IntProfilDonnees::SERIAL_FORMAT_KOHA
or $this->id_article_periodique == Class_IntProfilDonnees::SERIAL_FORMAT_ORPHEE)
......@@ -212,6 +212,10 @@ class notice_integration {
'date_maj not' => $date]);
}
if($this->id_article_periodique == Class_IntProfilDonnees::SERIAL_FORMAT_PMB)
$this->_traitePeriodiquesPMB();
// opsys indexpresse : on cree les articles manquants
if($this->id_article_periodique == Class_IntProfilDonnees::SERIAL_FORMAT_ALOES_INDEXPRESS
and $this->notice['articles_periodiques']) {
......@@ -263,6 +267,37 @@ class notice_integration {
}
protected function _traitePeriodiquesPMB() {
if ($this->notice['exemplaires']) {
$titre_chapeau = $this->analyseur->get_subfield('200', 'h')[0];
$this->notice["clef_chapeau"] = $this->indexation->codeAlphaTitre($titre_chapeau);
return;
}
$head_link = $this->analyseur->get_subfield('463', '9');
if (!$id_bull = end(explode(':', $head_link[0])))
return;
$id_head_record = $id_bull . '-bull';
$titre_chapeau = $this->analyseur->get_subfield('461', 't')[0] . ' ' . $id_head_record;
$this->notice["clef_chapeau"] = $this->indexation->codeAlphaTitre($titre_chapeau);
$this->notice['exemplaires'] =
[
['code_barres' => sprintf('%s-%s',
$this->id_int_bib,
$this->notice["id_origine"]),
'type' => Class_Notice::TYPE_SERIAL_ARTICLE,
'zone995' => serialize([ ['code' => '0',
'valeur' => $id_head_record] ])
]
];
$this->notice["statut_exemplaires"]["nb_ex"] = 1;
}
public function traiteHomogene($id_notice, $isbn, $ean, $id_commerciale, $no_request) {
global $sql;
......
......@@ -121,7 +121,7 @@ class notice_unimarc extends iso2709_record {
if ($type_doc['code'] == Class_TypeDoc::SERIAL_ARTICLE)
return $this->getNoticeIntegrationArticlePeriodique();
if ($type_doc['code'] == 2)
if ($type_doc['code'] == Class_TypeDoc::PERIODIQUE)
$notice['articles_periodiques'] = $this->getIdArticlesPeriodiques();
// exemplaires
......@@ -254,8 +254,7 @@ class notice_unimarc extends iso2709_record {
// identifiants
switch($this->profil["id_article_periodique"])
{
// pergame
case 1:
case Class_IntProfilDonnees::SERIAL_FORMAT_PERGAME:
$titre=$this->get_subfield("461","t");
$numero=$this->get_subfield("461","v");
$notice["clef_chapeau"]=$this->indexation->codeAlphaTitre($titre[0]);
......@@ -263,8 +262,7 @@ class notice_unimarc extends iso2709_record {
$notice["titre_numero"]=$titre[0]." n° ".$numero[0];
break;
// opsys indexpresse
case 2:
case Class_IntProfilDonnees::SERIAL_FORMAT_ALOES_INDEXPRESS:
$id=$this->get_subfield("001");
$notice["clef_unimarc"]=$id[0];
$notice["info_id"]=$id[0];
......@@ -286,8 +284,7 @@ class notice_unimarc extends iso2709_record {
// Identifiants des articles de periodiques a partir de la notice du numero
// ----------------------------------------------------------------------------
private function getIdArticlesPeriodiques() {
// opsys indexpresse
if ($this->profil["id_article_periodique"] != 2)
if ($this->profil["id_article_periodique"] != Class_IntProfilDonnees::SERIAL_FORMAT_ALOES_INDEXPRESS)
return [];
$ret = [];
......@@ -342,6 +339,7 @@ class notice_unimarc extends iso2709_record {
return $champs_nouveaute;
}
public function getExemplaires() {
$champ_code_barres = $this->getBarcode();
......@@ -1004,6 +1002,7 @@ class notice_unimarc extends iso2709_record {
public function getClefChapeau() {
if (!$titre = $this->get_subfield('461', 't'))
$titre = $this->get_subfield('410', 't');
return $titre
? $this->indexation->codeAlphaTitre(trim($titre[0]))
: '';
......
......@@ -79,6 +79,7 @@ class PMBIntegrationRecordsTest extends PMBIntegrationRecordsTestCase {
class PMBIntegrationRecordsSixSequencesTest extends PMBIntegrationRecordsTestCase {
public function setUp() {
parent::setUp();
......@@ -103,4 +104,70 @@ class PMBIntegrationRecordsSixSequencesTest extends PMBIntegrationRecordsTestCas
$this->assertEquals('Angers',
$this->_record->getFirstExemplaire()->getLibelleSite());
}
}
class PMBIntegrationSerialsTest extends PMBIntegrationRecordsTestCase {
public function setUp() {
parent::setUp();
$this->loadRecordsFromFile('unimarc_pmb_periodiques');
}
/** @test */
public function numberOfRecordsShouldBeFourtySix() {
$this->assertCount(46, Class_Notice::findAll());
}
/** @test */
public function firstRecordItemBarCodeShouldBeIdIntBibOneDashIdRecord21119() {
$this->assertEquals('1-21119',
Class_Notice::find(1)->getFirstExemplaire()->getCodeBarres());
}
/** @test */
public function firstRecordItemIdIntBibShouldBeOne() {
$this->assertEquals(1,
Class_Notice::find(1)->getFirstExemplaire()->getIdIntBib());
}
/** @test */
public function itemWithBarcode0012036ShouldBeTypeBibliographic() {
$this->assertEquals(Class_Notice::TYPE_BIBLIOGRAPHIC,
Class_Exemplaire::findFirstBy(['code_barres' => '0012036'])->getType());
}
/** @test */
public function item0012036ClefChapeauShouldBeREVUE_FR() {
$this->assertEquals('REVUE FRANCAISE DE PEDAGOGIE',
Class_Exemplaire::findFirstBy(['code_barres' => '0012036'])->getNotice()->getClefChapeau());
}
/** @test */
public function itemWithBarcode1Dash21331ShouldBeTypeSerialArticle() {
$this->assertEquals(Class_Notice::TYPE_SERIAL_ARTICLE,
Class_Exemplaire::findFirstBy(['code_barres' => '1-21331'])->getType());
}
/** @test */
public function itemWithBarcode1Dash21331ShouldHaveZone995Dollar0ToEquals60DashBull() {
$this->assertEquals('60-bull',
Class_Exemplaire::findFirstBy(['code_barres' => '1-21331'])->getSubfield(0));
}
/** @test */
public function record21331ClefChapeauShouldBeREVUE_FR_60_BULL() {
$this->assertEquals('REVUE FRANCAISE DE PEDAGOGIE 60 BULL',
Class_Exemplaire::findFirstBy(['code_barres' => '1-21331'])->getNotice()->getClefChapeau());
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -262,19 +262,24 @@ class Class_Codification {
if(!$notice)
return '';
$me = new static();
$message = $me->_('Voir tous les tomes');
switch ($notice->getTypeDoc()) {
case Class_TypeDoc::PERIODIQUE:
$message = $me->_('Voir tous les numéros');
break;
case Class_TypeDoc::DVD:
$message = $me->_('Voir tous les épisodes');
break;
}
$prefix = function($notice) {
$me = new static();
if ($notice->isDVD())
return $me->_('Voir tous les épisodes');
if (!$notice->isPeriodique())
return $me->_('Voir tous les tomes');
if (($first_item = $notice->getFirstExemplaire()) && $first_item->isTypeSerialArticle())
return $me->_('Voir tous les articles de ce numéro');
return $me->_('Voir tous les numéros');
};
return self::concatLibelleWithTitreChapeau($message, $notice->getTitreChapeau());
return self::concatLibelleWithTitreChapeau($prefix($notice),
$notice->getTitreChapeau());
}
......
......@@ -119,6 +119,19 @@ class Class_Exemplaire extends Storm_Model_Abstract {
}
public function isTypeSerialArticle() {
return $this->getType() == Class_Notice::TYPE_SERIAL_ARTICLE;
}
public function getPMBSerialRecord() {
//see Cosmogramme PMBIntegrationSerialsTest
$item = $this->getLoader()->findFirstBy(['id_origine' => $this->getSubfield('0'),
'id_int_bib' => $this->getIdIntBib()]);
return $item->getNotice();
}
public function getPret() {
return Class_Pret::findFirstBy(['id_site' => $this->getIdBib(),
'id_notice_origine' => $this->getIdOrigine(),
......
......@@ -228,7 +228,14 @@ class IntProfilDonneesLoader extends Storm_Model_Loader {
public function getNewsSerialIds() {
return Class_CosmoVar::getList('id_article_periodique');
return [
Class_IntProfilDonnees::SERIAL_FORMAT_NONE => $this->_('Aucun'),
Class_IntProfilDonnees::SERIAL_FORMAT_PERGAME => $this->_('Pergame'),
Class_IntProfilDonnees::SERIAL_FORMAT_ALOES_INDEXPRESS => $this->_('Indexpresse'),
Class_IntProfilDonnees::SERIAL_FORMAT_KOHA => $this->_('Koha'),
Class_IntProfilDonnees::SERIAL_FORMAT_ORPHEE => $this->_('Orphée'),
Class_IntProfilDonnees::SERIAL_FORMAT_PMB => $this->_('PMB')
];
}
......@@ -312,6 +319,7 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
SERIAL_FORMAT_ALOES_INDEXPRESS = 2,
SERIAL_FORMAT_KOHA = 3,
SERIAL_FORMAT_ORPHEE = 4,
SERIAL_FORMAT_PMB = 5,
NOVELTY_DATE_FORMAT_NONE = 0,
NOVELTY_DATE_FORMAT_AAAA_MM_JJ = 1,
......@@ -765,14 +773,14 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
newInstance(['libelle' => 'Unimarc PMB',
'accents' => self::ENCODING_ISO2709,
'rejet_periodiques' => '0',
'id_article_periodique' => self::SERIAL_FORMAT_NONE,
'id_article_periodique' => self::SERIAL_FORMAT_PMB,
'type_fichier' => self::FT_RECORDS,
'format' => self::FORMAT_UNIMARC,
'attributs' =>
[['type_doc' =>
[[ 'code' => '0', 'label' => '', 'zone_995' => '' ],
[ 'code' => '1', 'label' => 'am;na', 'zone_995' => '' ],
[ 'code' => '2', 'label' => 'as', 'zone_995' => ''],
[ 'code' => '2', 'label' => 'as;aa', 'zone_995' => ''],
[ 'code' => '3', 'label' => 'i;j', 'zone_995' => ''],
[ 'code' => '4', 'label' => 'g','zone_995' => ''],
[ 'code' => '5', 'label' => 'l;m', 'zone_995' => ''],
......
......@@ -165,7 +165,8 @@ class Class_Notice extends Storm_Model_Abstract {
const
TYPE_BIBLIOGRAPHIC = 1,
TYPE_AUTHORITY = 2;
TYPE_AUTHORITY = 2,
TYPE_SERIAL_ARTICLE = 3;
protected $_loader_class = 'NoticeLoader';
protected $_table_name = 'notices';
......
......@@ -92,7 +92,7 @@ class NoticeAjaxControllerPMBRecordTest extends AbstractControllerTestCase {
/** @test */
public function libraryLabelShouldBeLeKiosqueLibrary() {
public function libraryLabelShouldBePMBLibrary() {
$this->assertXPathContentContains('//table//td', 'PMB library');
}
......@@ -102,3 +102,80 @@ class NoticeAjaxControllerPMBRecordTest extends AbstractControllerTestCase {
$this->assertXPathContentContains('//script', 'setupAnchorsTarget');
}
}
class NoticeAjaxControllerPMBSerialArticleTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
$with_item_other_int_bib = $this->fixture('Class_Notice',
['id' => '666',
'exemplaires' => [
$this->fixture('Class_Exemplaire',
['id' => 666,
'id_origine' => '60-bull',
'id_int_bib' => 2,
'code_barres' => '666',
'type' => Class_Notice::TYPE_BIBLIOGRAPHIC,
'cote' => 'THIS IS NOT GOOD'])
]
]);
$serial = $this->fixture('Class_Notice',
['id' => '123',
'type_doc' => Class_TypeDoc::PERIODIQUE,
'exemplaires' => [
$this->fixture('Class_Exemplaire',
['id' => 1,
'id_origine' => '60-bull',
'id_int_bib' => 3,
'code_barres' => 'ZXY60',
'type' => Class_Notice::TYPE_BIBLIOGRAPHIC,
'cote' => 'RFI1'])
]
]);
$article = $this->fixture('Class_Notice',
['id' => '234',
'clef_chapeau' => 'REVUE FRANC',
'type_doc' => Class_TypeDoc::PERIODIQUE,
'unimarc' => file_get_contents(ROOT_PATH . '/tests/fixtures/unimarc_article_rfp.txt'),
'exemplaires' => [
$this->fixture('Class_Exemplaire',
['id' => 2,
'id_origine' => '1787',
'id_int_bib' => 3,
'code_barres' => '1-234',
'type' => Class_Notice::TYPE_SERIAL_ARTICLE,
'zone995' => serialize([ ['code' => '0',
'valeur' => '60-bull'] ])])
]
]);
}
/** @test */
public function itemsTableShouldContainsCoteRFI1() {
$this->dispatch('/opac/noticeajax/exemplaires/id_notice/234', true);
$this->assertXPathContentContains('//table//td[@class="cote"]',
'RFI1');
}
/** @test */
public function recordShouldContainsLinkForSerie() {
$this->dispatch('/opac/recherche/viewnotice/id/234', true);
$this->assertXPathContentContains('//a[contains(@href,"/serie/REVUE+FRANC-2/")]',
'Voir tous les articles de ce numéro de Revue française de pédagogie',
$this->_response->getBody());
}
}
\ No newline at end of file
01031naa2 22002051i 450 00100060000010000350000600900150004120001770005685600460023310100080027921500150028730000290030233002140033131900280054570000350057321000090060889600220061746100630063946301230070221349 a20190509u u u0frey50  a2018-08-011 aGARNIER Pascale, BROUGÈRE Gilles, RAYNA Sylvie & RUPIN Pablo. À 2 ans, vivre dans un collectif d’enfants. Crèche, école maternelle, classe passerelle, jardin maternel uhttps://journals.openedition.org/rfp/53910 afre ap. 115-119 aTexte intégral en ligne a Notes critiques Référence(s) : GARNIER Pascale, BROUGÈRE Gilles, RAYNA Sylvie & RUPIN Pablo. À 2 ans, vivre dans un collectif d’enfants. Crèche, école maternelle, classe passerelle, jardin maternel. aAucun droit spécifique 1aPlaisancebÉric40709id:4605 d2018 a./images/vide.png 017165tRevue française de pédagogie9id:171659lnk:perio d2018-08-01eJanvier-Février-Mars 2017vn° 198tRegards croisés sur le baccalauréat professionnel 9id:359lnk:bull
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment