Commit f25c4258 authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'dev#71412_negative' into 'master'

Dev#71412 negative

See merge request afi/opacce!2520
parents 190ebcaa bdc09cf8
- ticket #71412 : Intégrations cosmogramme : correction de la prise en compte des fichiers de suppressions d'exemplaires
......@@ -170,7 +170,7 @@ class notice_integration {
$id_notice = $this->chercheNotice();
if($this->type_operation == 1) {
if(Class_Cosmogramme_Integration::TYPE_OPERATION_ITEM_DELETE == $this->type_operation) {
$this->statut = static::RECORD_DELETE;
if($this->format == Class_IntProfilDonnees::FORMAT_UNIMARC )
......@@ -439,9 +439,13 @@ class notice_integration {
private function chercheNotice() {
$this->identification = ['statut' => static::STATUS_NOTFOUND];
$double = new Class_Notice_DoubleFinder($this->notice,
$this->id_int_bib,
$this->id_profil);
$double_class = Class_Cosmogramme_Integration::TYPE_OPERATION_ITEM_DELETE == $this->type_operation
? 'Class_Notice_BarcodeDoubleFinder'
: 'Class_Notice_DoubleFinder';
$double = new $double_class($this->notice,
$this->id_int_bib,
$this->id_profil);
if (!$double->find())
return '';
......
<?php
/**
* 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
* 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_BarcodeDoubleFinder extends Class_Notice_DoubleFinder {
public function find() {
$this->_on_barcode = null;
$this->_id = null;
if ($this->_id = $this->findByBarcodes()) {
$this->_found_on = 'code_barres';
return true;
}
return false;
}
protected function _getRecordIdByItem($conditions) {
if ($id = parent::_getRecordIdByItem($conditions))
return $id;
$founds = Class_Exemplaire::findAllBy($conditions);
if (empty($founds))
return;
foreach($founds as $found)
if ($found->isSigbLoanable())
return $found->getIdNotice();
}
}
\ No newline at end of file
......@@ -53,7 +53,7 @@ class Class_Notice_DoubleFinder {
return true;
}
if($this->_profil && ($this->_profil->isFormatDublinCore() || $this->_profil->isBibliondemand()))
if ($this->_profil && ($this->_profil->isFormatDublinCore() || $this->_profil->isBibliondemand()))
return false;
if ($this->_id = $this->findByIdOrigine()) {
......@@ -108,11 +108,11 @@ class Class_Notice_DoubleFinder {
protected function _getRecordIdByItem($conditions) {
$founds = Class_Exemplaire::findAllBy($conditions);
if(empty($founds))
if (empty($founds))
return;
foreach($founds as $found)
if($this->_data->gettype_doc() == $found->getTypeDoc())
if ($this->_data->gettype_doc() == $found->getTypeDoc())
return $found->getIdNotice();
}
......
......@@ -39,6 +39,19 @@ abstract class DoubleFinderTestCase extends ModelTestCase {
protected function _prepareFixtures() {
$item = $this->fixture('Class_Exemplaire',
['id' => 1,
'code_barres' => '159',
'id_origine' => '88903',
'id_int_bib' => 1]);
$this->fixture('Class_Notice',
['id' => 1,
'type_doc' => Class_TypeDoc::LIVRE,
'isbn' => '2-85868-161-9',
'clef_alpha' => 'JESUISNEBONHOMME--SARA--EDTHIERRYMAGNIER-2010-1',
'exemplaires' => [$item]]);
$dilicom_item = $this->fixture('Class_Exemplaire',
['id' => 2,
'code_barres' => '0001-2',
......@@ -53,10 +66,10 @@ abstract class DoubleFinderTestCase extends ModelTestCase {
'exemplaires' => [$dilicom_item]]);
$rss_item = $this->fixture('Class_Exemplaire',
['id' => 3,
'code_barres' => '159',
'id_origine' => '789',
'id_int_bib' => 1]);
['id' => 3,
'code_barres' => '159',
'id_origine' => '789',
'id_int_bib' => 1]);
$this->fixture('Class_Notice',
['id' => 3,
......@@ -65,18 +78,6 @@ abstract class DoubleFinderTestCase extends ModelTestCase {
'clef_alpha' => 'JESUISNEBONHOMME--SARA--EDTHIERRYMAGNIER-2010-1',
'exemplaires' => [$rss_item]]);
$item = $this->fixture('Class_Exemplaire',
['id' => 1,
'code_barres' => '159',
'id_origine' => '88903',
'id_int_bib' => 1]);
$this->fixture('Class_Notice',
['id' => 1,
'type_doc' => Class_TypeDoc::LIVRE,
'isbn' => '2-85868-161-9',
'clef_alpha' => 'JESUISNEBONHOMME--SARA--EDTHIERRYMAGNIER-2010-1',
'exemplaires' => [$item]]);
}
......@@ -102,6 +103,7 @@ class DoubleFinderWithoutAnyRecordTest extends DoubleFinderTestCase {
abstract class DoubleFinderWithRecordMatchingTestCase extends DoubleFinderTestCase {
/** @test */
public function shouldFindRecord() {
$this->assertFound();
......@@ -130,6 +132,29 @@ class DoubleFinderWithExistingItemTest extends DoubleFinderWithRecordMatchingTes
class DoubleFinderWithExistingItemForDeletionTest extends DoubleFinderWithRecordMatchingTestCase {
protected $_data = ['type_doc' => Class_TypeDoc::UNKNOWN,
'statut_exemplaires' => ['nb_ex' => 1],
'exemplaires' => [ ['code_barres' => '159'] ]];
public function setUp() {
parent::setUp();
$this->_prepareFixtures();
$this->_finder = new Class_Notice_BarcodeDoubleFinder($this->_data, $this->_library_id);
$this->_found = $this->_finder->find();
}
/** @test */
public function shouldHaveMatchedBarcode() {
$this->assertEquals('code_barres', $this->_finder->getMatchedCriteria());
}
}
class DoubleFinderWithExistingIsbnTest extends DoubleFinderWithRecordMatchingTestCase {
protected $_data = ['type_doc' => Class_TypeDoc::LIVRE,
'isbn13' => '2-85868-161-9'];
......@@ -254,4 +279,4 @@ class DoubleFinderWithExistingIdOrigneNoDedupModeForNanookTestTest extends Doubl
public function shouldHaveMatchedIdOrigine() {
$this->assertEquals('id_origine', $this->_finder->getMatchedCriteria());
}
}
}
\ 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