| New file |
| 0,0 → 1,109 |
| <?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')); |
| |
| |
| |
| public function executer() { |
| $this->referentielDao = new ReferentielDao(); |
| // Récupération du dernier traitement demandé |
| $referentiel = $this->getParam('r'); |
| $resultats = $this->referentielDao->preparerTablePrChpFamille($referentiel); |
| |
| $noms = array(); |
| $introuvables = array(); |
| $introuvablesSyno = array(); |
| $i = 1; |
| |
| while(true) { |
| printf("passe n°%d:\n", $i); |
| $this->traiterResultatsFamille($resultats, $noms, $introuvables, $introuvablesSyno); |
| echo "\n\n"; |
| // 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++ == 3) break; |
| $resultats = array_merge($resultats, $introuvables, $introuvablesSyno); |
| $introuvables = $introuvablesSyno = array(); |
| } |
| |
| foreach ($introuvablesSyno as $id => $nom) { |
| $nn = $nom['num_nom']; |
| $nnr = $nom['num_nom_retenu']; |
| if (isset($noms[$nnr])) { |
| $noms[$nn] = $noms[$nnr]; |
| } else { |
| $introuvables[] = $nn; |
| } |
| unset($introuvablesSyno[$id]); |
| |
| } |
| echo "\n"; |
| |
| |
| /*$msg = 'Plusieurs familles sont introuvables'; |
| $this->creerFichierLog($msg, $introuvables, 'famille_introuvable');*/ |
| |
| $this->referentielDao->remplirChpFamille($referentiel, $noms); |
| } |
| |
| |
| |
| |
| private function traiterResultatsFamille(&$resultats, &$noms, &$introuvables, &$introuvablesSyno) { |
| foreach ($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') { |
| $noms[$nn] = $nom['nom_sci']; |
| } else { |
| if ($nn == $nnr) { |
| // nom retenu |
| if (isset($noms[$nts])) { |
| // signifie que recupererTuplesPrChpFamille() devrait |
| // récupérer ce record *avant* |
| $noms[$nn] = $noms[$nts]; |
| } else { |
| $introuvables[] = $nn; |
| } |
| } else {// nom synonyme |
| if (isset($noms[$nnr])) { |
| // signifie que recupererTuplesPrChpFamille() devrait |
| // récupérer ce record *avant* |
| $noms[$nn] = $noms[$nnr]; |
| } else { |
| $introuvablesSyno[] = $nom; |
| } |
| } |
| } |
| } |
| unset($resultats[$id]); |
| } |
| } |
| |
| } |
| ?> |