Skip to content
Snippets Groups Projects
Commit ae794a93 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

hotline #67202 fix RT comment : Improve doubleFinder

parent 7d8bf43b
Branches
Tags
3 merge requests!2445Master,!2444Hotline master,!2432Hotline#67202 titres remplaces par d autres titres dans bokeh urgent svp
Pipeline #3114 failed with stage
in 15 minutes and 41 seconds
......@@ -247,6 +247,11 @@ class Class_Exemplaire extends Storm_Model_Abstract {
}
public function getTypeDoc() {
return $this->getNotice()->getTypeDoc();
}
public function getMailIntBib() {
return $this->getIntBib()->getMail();
}
......
......@@ -34,7 +34,7 @@ class Class_Notice_DoubleFinder {
$_id;
public function __construct($data, $library_id, $profil_id = null) {
$this->_data = (new Class_Entity())->updateAttributes($data);
$this->_data = new Class_Entity($data);
$this->_barcode_uniq_mode = Class_CosmoVar::get(static::VAR_BARCODE_UNIQ_MODE);
$this->_double_mode = Class_CosmoVar::get(static::VAR_DOUBLE_MODE);
$this->_profil = Class_IntProfilDonnees::find($profil_id);
......@@ -65,6 +65,16 @@ class Class_Notice_DoubleFinder {
}
public function getMatchedCriteria() {
return $this->_found_on;
}
public function getId() {
return $this->_id;
}
protected function findByBarcodes() {
if (!$this->_hasItems())
return;
......@@ -79,12 +89,11 @@ class Class_Notice_DoubleFinder {
if (!$item['code_barres'])
return;
$condition = ['code_barres' => $item['code_barres']];
$conditions = ['code_barres' => $item['code_barres']];
if ($this->_barcode_uniq_mode == '1')
$condition['id_int_bib'] = (int) $this->_library->getId();
$conditions['id_int_bib'] = (int) $this->_library->getId();
if ($found = Class_Exemplaire::findFirstBy($condition))
return $found->getIdNotice();
return $this->_getRecordIdByItem($conditions);
}
......@@ -93,8 +102,18 @@ class Class_Notice_DoubleFinder {
|| !$this->_library->isPergame())
return;
if ($found = Class_Exemplaire::findFirstBy(['id_origine' => $this->_data->getid_origine()]))
return $found->getIdNotice();
return $this->_getRecordIdByItem(['id_origine' => $this->_data->getid_origine()]);
}
protected function _getRecordIdByItem($conditions) {
$founds = Class_Exemplaire::findAllBy($conditions);
if(empty($founds))
return;
foreach($founds as $found)
if($this->_data->gettype_doc() == $found->getTypeDoc())
return $found->getIdNotice();
}
......@@ -141,14 +160,4 @@ class Class_Notice_DoubleFinder {
return ($statuses = $this->_data->getstatut_exemplaires())
|| $statuses['nb_ex'] > 0;
}
public function getMatchedCriteria() {
return $this->_found_on;
}
public function getId() {
return $this->_id;
}
}
\ No newline at end of file
......@@ -23,10 +23,12 @@
abstract class DoubleFinderTestCase extends ModelTestCase {
protected
$_storm_default_to_volatile = true,
$_data = [], $_library_id = 1,
$_data = [],
$_library_id = 1,
$_finder,
$_found;
public function setUp() {
parent::setUp();
......@@ -37,6 +39,32 @@ abstract class DoubleFinderTestCase extends ModelTestCase {
protected function _prepareFixtures() {
$dilicom_item = $this->fixture('Class_Exemplaire',
['id' => 2,
'code_barres' => '0001-2',
'id_origine' => '88903',
'id_int_bib' => 1]);
$this->fixture('Class_Notice',
['id' => 2,
'type_doc' => Class_TypeDoc::DILICOM,
'isbn' => '2-85868-161-9',
'clef_alpha' => 'JESUISNEBONHOMME--SARA--EDTHIERRYMAGNIER-2010-1',
'exemplaires' => [$dilicom_item]]);
$rss_item = $this->fixture('Class_Exemplaire',
['id' => 3,
'code_barres' => '159',
'id_origine' => '789',
'id_int_bib' => 1]);
$this->fixture('Class_Notice',
['id' => 3,
'type_doc' => Class_TypeDoc::RSS,
'isbn' => '2-85868-161-9',
'clef_alpha' => 'JESUISNEBONHOMME--SARA--EDTHIERRYMAGNIER-2010-1',
'exemplaires' => [$rss_item]]);
$item = $this->fixture('Class_Exemplaire',
['id' => 1,
'code_barres' => '159',
......@@ -45,6 +73,7 @@ abstract class DoubleFinderTestCase extends ModelTestCase {
$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]]);
......@@ -157,7 +186,8 @@ class DoubleFinderWithExistingItemInAnotherLibraryTest extends DoubleFinderTestC
class DoubleFinderWithExistingItemAndNoDedupModeTest extends DoubleFinderWithRecordMatchingTestCase {
protected $_data = ['statut_exemplaires' => ['nb_ex' => 1],
protected $_data = ['type_doc' => Class_TypeDoc::LIVRE,
'statut_exemplaires' => ['nb_ex' => 1],
'exemplaires' => [ ['code_barres' => '159'] ]];
......@@ -199,7 +229,8 @@ class DoubleFinderWithExistingIdOrigneNoDedupModeDefaultTest extends DoubleFinde
class DoubleFinderWithExistingIdOrigneNoDedupModeForNanookTestTest extends DoubleFinderWithRecordMatchingTestCase {
protected $_data = ['id_origine' => '88903'];
protected $_data = ['type_doc' => Class_TypeDoc::LIVRE,
'id_origine' => '88903'];
protected function _prepareFixtures() {
parent::_prepareFixtures();
......@@ -215,7 +246,7 @@ class DoubleFinderWithExistingIdOrigneNoDedupModeForNanookTestTest extends Doubl
/** @test */
public function shouldHaveMatchedBarcode() {
public function shouldHaveMatchedIdOrigine() {
$this->assertEquals('id_origine', $this->_finder->getMatchedCriteria());
}
}
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