Rev 344 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php// Encodage : UTF-8// +-------------------------------------------------------------------------------------------------------------------+/*** Versionnage de référentiels de nomenclature et taxonomie** Description : classe permettant de versionner les référentiels selon le manuel technique* Utilisation : php script.php famille -r bdtfx_v2_00*//Auteur original :* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>* @copyright Tela-Botanica 1999-2010* @link http://www.tela-botanica.org/wikini/RTaxMethodo/wakka.php?wiki=MaNuel* @licence GPL v3 & CeCILL v2* @version $Id$*/// +-------------------------------------------------------------------------------------------------------------------+// TODO : lors de la génération de la version 2 de la BDTFX tester les diff! Il se peut que la mémoire soit dépassée.class Famille extends ScriptCommande {const SCRIPT_NOM = 'famille';private $referentielDao = null;public $parametres = array('-r' => array(true, true, 'referentiel'));private $noms = array();private $resultats = array();public function executer() {$this->referentielDao = new ReferentielDao();// Récupération du dernier traitement demandé$referentiel = $this->getParam('r');$this->resultats = $this->referentielDao->preparerTablePrChpFamille($referentiel);//$noms = array();$introuvables = array();$introuvablesSyno = array();$i = 1;while(true) {printf("passe n°%d:\n", $i);$this->traiterResultatsFamille( $introuvables, $introuvablesSyno);//echo "\n\n"; print_r(count($this->noms));// printf("noms: %d, introuvables: %d, introuvablesSyno: %d\n", count($noms), count($introuvables), count($introuvablesSyno));// XXX, au 22/07/2013, 3 passes sont suffisantes// TODO: MySQL procédure stockée !if($i++ == 4) break;$this->resultats = array_merge($this->resultats, $introuvables, $introuvablesSyno);$introuvables = $introuvablesSyno = array();}foreach ($introuvablesSyno as $id => $nom) {$nn = $nom['num_nom'];$nnr = $nom['num_nom_retenu'];if (isset($this->noms[$nnr])) {$this->noms[$nn] = $this->noms[$nnr];} else {$introuvables[] = $nn;}unset($introuvablesSyno[$id]);}echo "\n";/*$msg = 'Plusieurs familles sont introuvables';$this->creerFichierLog($msg, $introuvables, 'famille_introuvable');*/print_r(count($this->noms));echo "wtf:";print_r($this->referentielDao->remplirChpFamille($referentiel, $this->noms));}private function traiterResultatsFamille(&$introuvables, &$introuvablesSyno) {foreach ($this->resultats as $id => $nom) {$nn = $nom['num_nom'];$nnr = $nom['num_nom_retenu'];$nts = $nom['num_tax_sup'];$rg = $nom['rang'];if ($nnr != '') {if ($rg == '180') {$this->noms[$nn] = $nom['nom_sci'];} else {if ($nn == $nnr) {// nom retenuif (isset($this->noms[$nts])) {// signifie que recupererTuplesPrChpFamille() devrait// récupérer ce record *avant*$this->noms[$nn] = $this->noms[$nts];} else {$introuvables[] = $nn;}} else {// nom synonymeif (isset($this->noms[$nnr])) {// signifie que recupererTuplesPrChpFamille() devrait// récupérer ce record *avant*$this->noms[$nn] = $this->noms[$nnr];} else {$introuvablesSyno[] = $nom;}}}}unset($this->resultats[$id]);}}}?>