Skip to content
Snippets Groups Projects
Commit 3c14c47d authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch...

Merge branch 'hotline#126248_nouvelle_version_bokeh_doublon_dans_bokeh_suite_a_changerment_de_type_de_document_dans_koha' into 'hotline'

hotline #126248 : fix double when doc type is modified

See merge request !3846
parents e7592b34 b41d431c
Branches
Tags
1 merge request!3846hotline #126248 : fix double when doc type is modified
Pipeline #12384 passed with stage
in 1 hour, 15 minutes, and 30 seconds
- ticket #126248 : Intégrations : Correction du dédoublonnage en mode aucun dédoublonnage lorsque le type de document est modifié
\ No newline at end of file
......@@ -21,14 +21,9 @@
class Class_Notice_BarcodeDoubleFinder extends Class_Notice_DoubleFinder {
protected function _buildStrategy() {
parent::_buildStrategy();
$this->_strategy->addItemFilter([$this, 'filterSigbLoanable']);
}
protected function _strategyName() {
return 'Class_Notice_DoubleFinder_BarcodeStrategy';
protected function _chooseStrategy() {
return (new Class_Notice_DoubleFinder_BarcodeStrategy($this->_libraryLimit()))
->addItemFilter([$this, 'filterSigbLoanable']);
}
......
......@@ -57,9 +57,7 @@ class Class_Notice_DoubleFinder {
if ((string)$this->_data->gettype_doc() == (string)Class_TypeDoc::PERIODIQUE_TITLE)
return new Class_Notice_DoubleFinder_PeriodicTitle(null);
$library_limit = ($this->_barcode_uniq_mode == Class_CosmoVar::UNIQ_BARCODE_WITHIN_LIBRARY)
? (int) $this->_library->getId()
: null;
$library_limit = $this->_libraryLimit();
if ($this->_profil
&& ($this->_profil->isFormatDublinCore()
......@@ -87,6 +85,13 @@ class Class_Notice_DoubleFinder {
}
protected function _libraryLimit() {
return ($this->_barcode_uniq_mode == Class_CosmoVar::UNIQ_BARCODE_WITHIN_LIBRARY)
? (int) $this->_library->getId()
: null;
}
public function find() {
return $this->_strategy->find($this->_data);
}
......@@ -181,6 +186,14 @@ abstract class Class_Notice_DoubleFinder_Strategy {
}
protected function _getRecordIdByItemWithoutFilters($conditions) {
$conditions['type'] = Class_Notice::TYPE_BIBLIOGRAPHIC;
return ($item = Class_Exemplaire::findFirstBy($conditions))
? $item->getIdNotice()
: null;
}
protected function _getRecordIdByItemFilters() {
return $this->_item_filters;
}
......@@ -237,7 +250,7 @@ class Class_Notice_DoubleFinder_GlobalNoDedupStrategy extends Class_Notice_Doubl
protected function _findByIdOrigine() {
return $this->_getRecordIdByItem(['id_origine' => $this->_data->getid_origine()]);
return $this->_getRecordIdByItemWithoutFilters(['id_origine' => $this->_data->getid_origine()]);
}
......@@ -350,8 +363,8 @@ class Class_Notice_DoubleFinder_AlphaKeyStrategy extends Class_Notice_DoubleFind
class Class_Notice_DoubleFinder_NoDedupStrategy extends Class_Notice_DoubleFinder_GlobalNoDedupStrategy {
protected function _findByIdOrigine() {
return $this->_getRecordIdByItem(['id_origine' => $this->_data->getid_origine(),
'id_int_bib' => $this->_library_limit]);
return $this->_getRecordIdByItemWithoutFilters(['id_origine' => $this->_data->getid_origine(),
'id_int_bib' => $this->_library_limit]);
}
}
......
......@@ -490,4 +490,47 @@ class DoubleFinderWithDublinCoreProfileTest extends ModelTestCase {
$this->assertFalse($finder->find());
}
}
/** @see 126248 */
class DoubleFinderWithExistingDoctypeModificationTest extends DoubleFinderTestCase {
protected $_data = ['type_doc' => Class_TypeDoc::DVD,
'id_origine' => '16423',
'statut_exemplaires' => ['nb_ex' => 1],
'exemplaires' => [ ['code_barres' => 'ACCRDM13335'] ]
];
protected function _prepareFixtures() {
$this->fixture('Class_IntBib',
['id' => 1,
'sigb' => Class_IntBib::SIGB_KOHA]);
Class_CosmoVar::set(Class_Notice_DoubleFinder::VAR_DOUBLE_MODE,
Class_CosmoVar::DOUBLE_SEARCH_NONE);
$this->fixture('Class_Notice',
['id' => 1,
'type_doc' => Class_TypeDoc::LIVRE,
'exemplaires' => [$this->fixture('Class_Exemplaire',
['id' => 1,
'id_origine' => '16423',
'code_barres' => 'ACCRDM13335',
'id_int_bib' => 1])]]);
}
/** @test */
public function shouldFind() {
$this->assertFound();
}
/** @test */
public function shouldFindOnIdOrigine() {
$this->assertEquals(Class_Notice_DoubleFinder_Strategy::FOUND_ON_ID_ORIGINE,
$this->_finder->getMatchedCriteria());
}
}
\ No newline at end of file
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