Commit ea96c2e3 authored by Laurent's avatar Laurent

Marc 21 integration experiments

parent 5811c1d6
......@@ -16,7 +16,7 @@
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//////////////////////////////////////////////////////////////////////////////////////
// CLASSE MARC21 (Surcharge la classe notice_unimarc)
......@@ -30,7 +30,7 @@ class notice_marc21 extends notice_unimarc
private $map;
// ----------------------------------------------------------------
// Constructeur
// Constructeur
// ----------------------------------------------------------------
function __construct()
{
......@@ -72,6 +72,7 @@ class notice_marc21 extends notice_unimarc
$this->map["517"]["n"]="h";
$this->map["517"]["p"]="v";
$this->map["996"]="*";
$this->map["952"]="*";
$this->map["600"]["a"]="a";
$this->map["600"]["d"]="y";
$this->map["600"]["e"]="z";
......@@ -104,7 +105,7 @@ class notice_marc21 extends notice_unimarc
$this->setNotice($this->marc21ToUnimarc());
return true;
}
public function setNotice($string, $type_accents = 0) {
parent::setNotice($string, 4);
}
......@@ -125,7 +126,7 @@ class notice_marc21 extends notice_unimarc
// identifiants
$bloc=$this->get_subfield('001');
$this->notice_unimarc->add_field("001","",$bloc[0]);
// date de nouveaute
$bloc=$this->get_subfield('008');
$this->notice_unimarc->add_field("005","",$bloc[0]);
......@@ -143,7 +144,7 @@ class notice_marc21 extends notice_unimarc
// titres
$this->traiteZone("245","200");
$this->traiteZone("246","510");
$this->traiteZone("246","510");
$this->traiteZone("130","500"); // titre uniforme
$this->traiteZone("505","464"); // titres de depouillement
$this->traiteZone("856","464"); // morceaux docs sonores
......@@ -152,7 +153,7 @@ class notice_marc21 extends notice_unimarc
$this->traiteZone("765","510"); // titre original
$this->traiteZone("780","432"); // titre précédent pour périodiques
$this->traiteZone("785","440"); // titre successeur
// auteurs
$this->traiteZone("100","700");
$this->traiteZone("110","710");
......@@ -191,6 +192,7 @@ class notice_marc21 extends notice_unimarc
// exemplaires
$this->traiteZone("999","996");
$this->traiteZone("952","952");
// fin
return $this->marc21_decode($this->notice_unimarc->update());
......
......@@ -85,6 +85,7 @@ class notice_unimarc extends iso2709_record {
public function getNoticeIntegration() {
xdebug_break();
$type_doc = $this->getTypeDoc(true);
if($type_doc['code'] == 100)
return $this->getNoticeIntegrationArticlePeriodique();
......@@ -291,6 +292,8 @@ class notice_unimarc extends iso2709_record {
return $this->getExemplaires852(); // Moulins
if ($champ_code_barres == '999')
return $this->getExemplaires999(); // La plaine centrale
if ($champ_code_barres == '952')
return $this->getExemplaires952(); // test marc21
$champ_cote = trim($this->profil['attributs'][0]['champ_cote']);
if (!$champ_cote)
......@@ -660,6 +663,92 @@ class notice_unimarc extends iso2709_record {
}
/**
* Marc 21 experimentation
*/
private function getExemplaires952() {
xdebug_break();
$champ_annexe=$this->profil['attributs'][0]["champ_annexe"];
$champ_section=$this->profil['attributs'][0]["champ_section"];
$champ_emplacement=$this->profil['attributs'][0]["champ_emplacement"];
$ret["warnings"] = [];
$codes_barres = $cotes = false;
$exemplaires = $this->get_subfield("952");
for ($i = 0; $i < count($exemplaires); $i++) {
$ex = $this->withExemplaireDo(
$exemplaires[$i],
function ($champ, &$ex) use ($ret, $codes_barres, $cotes,
$champ_emplacement, $champ_section, $champ_annexe) {
if($champ["code"] == "p") {
$this->setCodeBarre($champ['valeur'], $ex, $ret, $codes_barres);
return;
}
if($champ["code"]=="o") {
$cotes = true;
$ex["cote"] = $champ["valeur"];
return;
}
if ($champ["code"] == $champ_section) {
if(($section = $this->getIdCodeExemplaire("section","952",$champ_section,$champ["valeur"]))
&& $this->isSectionInvisible($section)) {
$ex["ignore_exemplaire"] = true;
return;
}
$ex["section"] = $section;
return;
}
if($champ["code"]==$champ_annexe) {
if($champ["valeur"] && $this->isAnnexeInvisible($champ['valeur'])) {
$ex["ignore_exemplaire"]=true;
return;
}
$ex["annexe"]=$champ['valeur'];
return;
}
if($champ["code"]==$champ_emplacement) {
$ex["emplacement"] = $this->getIdCodeExemplaire("emplacement","952",$champ_emplacement,$champ["valeur"]);
if($ex['emplacement'] && $this->isEmplacementInvisible($ex['emplacement']))
$ex["ignore_exemplaire"] = true;
return;
}
if ($champ["code"]=="k") {
if (in_array($champ['valeur'],
["LOST-ASSUM", "MISSING", "LOST-CLAIM", "LOST"]))
$ex["ignore_exemplaire"]=true;
return;
}
if($champ["code"]=="u")
$ex["date_nouveaute"] = $this->calculDateNouveaute($champ["valeur"]);
});
// ajouter aux exemplaires
if($ex["code_barres"]>"") {
$nb_ex++;
if($ex["ignore_exemplaire"]==true) {
$nb_ex_detruits++;
$ex["activite"]="d";
}
$ret["exemplaires"][]=$ex;
}
}
$ret['statut_exemplaires'] = $this->setStatut($nb_ex, $nb_ex_detruits,
$codes_barres, $cotes);
return $ret;
}
public function filtreCodeBarres($code_barres) {
if ($this->controle_codes_barres == 1)
return utf8_encode(addslashes($code_barres));
......
......@@ -1580,7 +1580,36 @@ class NoticeIntegrationConcertoSaintSaensTest extends NoticeIntegrationTestCase
/** @see http://forge.afi-sa.fr/issues/13769 */
class NoticeIntegrationTerraMarc21Test extends NoticeIntegrationTestCase {
public function getProfilDonnees() {
$profil = Class_IntProfilDonnees::forDynix()->setIdProfil(108);
$profil->setBarCodeField('952');
return $profil->getRawAttributes();
}
public function setUp() {
parent::setUp();
$this->loadNotice('marc21_terra');
}
/** @test */
public function numberOfRecordsShouldBe100() {
$this->assertEquals(100, count(Class_Notice::findAllBy([])));
}
/** @test */
public function firstNoticeTitreShouldBeTerra() {
$this->assertEquals('Non merci, Oncle Sam', Class_Notice::find(1)->getTitrePrincipal());
}
}
/** @$ http://forge.afi-sa.fr/issues/13769 */
class NoticeIntegrationAvailabilityFacetTest extends NoticeIntegrationTestCase {
public function getProfilDonnees() {
return Class_IntProfilDonnees::forNanook()
......
This diff is collapsed.
......@@ -358,6 +358,13 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
$config[0]['champ_availability'] = $value;
return $this->setAttributs($config);
}
public function setBarCodeField($value) {
$config = unserialize($this->getAttributs());
$config[0]['champ_code_barres'] = $value;
return $this->setAttributs($config);
}
}
?>
\ 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