Skip to content
Snippets Groups Projects
Commit 38a88ee4 authored by efalcy's avatar efalcy
Browse files

Lecture du Thesaurus sur 4 chiffres

parent 38274b8b
Branches
Tags
No related merge requests found
......@@ -5094,6 +5094,7 @@ tests/library/Class/BatchTest.php -text
tests/library/Class/BibTest.php -text
tests/library/Class/CatalogueTest.php -text
tests/library/Class/CmsUrlTransformerTest.php -text
tests/library/Class/CodifThesaurusTest.php -text
tests/library/Class/CommSigbTest.php -text
tests/library/Class/CompositeBuilderTest.php -text
tests/library/Class/CompositeBuilderTreeTest.php -text
......
......@@ -34,15 +34,23 @@ class Class_CodifThesaurusLoader extends Storm_Model_Loader {
}
public function getCodeSur4Chiffres($code) {
$length=strlen($code);
while (strlen($code) %4 != 0)
$code .='0';
return $code;
}
public function getIndices($pere)
{
if ($pere == "root")
return $this->findAllBy(['where' => 'code not like "catalogue" and LENGTH(id_thesaurus) in (1,2)', 'order' => 'id_thesaurus']);
return $this->findAllBy(['where' => 'code not like "catalogue" and LENGTH(id_thesaurus) in (1,4)', 'order' => 'id_thesaurus']);
$pere = $this->getCodeSur4Chiffres($pere);
$length=strlen($pere);
if ($length % 2 == 1)
$length++;
return $this->findAllBy(['where' => 'id_thesaurus like "'.$pere.'%" and LENGTH(id_thesaurus) in ('.($length+1).','.($length+2).')','order'=> 'id_thesaurus']);
return $this->findAllBy(['where' => 'id_thesaurus like "'.$pere.'%" and LENGTH(id_thesaurus) in ('.($length+1).','.($length+4).')','order'=> 'id_thesaurus']);
}
......
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* AFI-OPAC 2.0 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).
*
* AFI-OPAC 2.0 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 AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class CodifThesaurusTest extends AbstractControllerTestCase {
/** @test */
public function code01Sur4ChiffresShouldReturn0100() {
$this->assertEquals('0100',Class_CodifThesaurus::getCodeSur4Chiffres('01'));
}
/** @test */
public function codeASur4ChiffresShouldReturn0100() {
$this->assertEquals('A000',Class_CodifThesaurus::getCodeSur4Chiffres('A'));
}
}
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