Subversion Repositories Applications.referentiel

Rev

Rev 344 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 344 Rev 406
1
<?php
1
<?php
2
// Encodage : UTF-8
2
// Encodage : UTF-8
3
// +-------------------------------------------------------------------------------------------------------------------+
3
// +-------------------------------------------------------------------------------------------------------------------+
4
/**
4
/**
5
* Versionnage de référentiels de nomenclature et taxonomie
5
* Versionnage de référentiels de nomenclature et taxonomie
6
*
6
*
7
* Description : classe permettant de versionner les référentiels selon le manuel technique
7
* Description : classe permettant de versionner les référentiels selon le manuel technique
8
* Utilisation : php script.php famille -r bdtfx_v2_00
8
* Utilisation : php script.php famille -r bdtfx_v2_00
9
*
9
*
10
//Auteur original :
10
//Auteur original :
11
* @author       Jean-Pascal MILCENT <jpm@tela-botanica.org>
11
* @author       Jean-Pascal MILCENT <jpm@tela-botanica.org>
12
* @copyright	Tela-Botanica 1999-2010
12
* @copyright	Tela-Botanica 1999-2010
13
* @link			http://www.tela-botanica.org/wikini/RTaxMethodo/wakka.php?wiki=MaNuel
13
* @link			http://www.tela-botanica.org/wikini/RTaxMethodo/wakka.php?wiki=MaNuel
14
* @licence		GPL v3 & CeCILL v2
14
* @licence		GPL v3 & CeCILL v2
15
* @version		$Id$
15
* @version		$Id$
16
*/
16
*/
17
// +-------------------------------------------------------------------------------------------------------------------+
17
// +-------------------------------------------------------------------------------------------------------------------+
18
// 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.
18
// 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.
19
class Famille extends ScriptCommande {
19
class Famille extends ScriptCommande {
20
	
20
	
21
	const SCRIPT_NOM = 'famille';
21
	const SCRIPT_NOM = 'famille';
22
	private $referentielDao = null;
22
	private $referentielDao = null;
23
	public $parametres = array(
23
	public $parametres = array(
24
			'-r' => array(true, true, 'referentiel'));
24
			'-r' => array(true, true, 'referentiel'));
25
	
-
 
26
	
-
 
-
 
25
	private $noms = array();
-
 
26
	private $resultats = array();
27
	
27
	
28
	public function executer() {
28
	public function executer() {
29
		$this->referentielDao = new ReferentielDao();
29
		$this->referentielDao = new ReferentielDao();
30
		// Récupération du dernier traitement demandé
30
		// Récupération du dernier traitement demandé
31
		$referentiel = $this->getParam('r');
31
		$referentiel = $this->getParam('r');
32
		$resultats = $this->referentielDao->preparerTablePrChpFamille($referentiel); 
32
		$this->resultats = $this->referentielDao->preparerTablePrChpFamille($referentiel); 
33
		
33
		
34
		$noms = array();
34
		//$noms = array();
35
		$introuvables = array();
35
		$introuvables = array();
36
		$introuvablesSyno = array();
36
		$introuvablesSyno = array();
37
		$i = 1;
37
		$i = 1;
38
 
38
 
39
		while(true) {
39
		while(true) {
40
			printf("passe n°%d:\n", $i);
40
			printf("passe n°%d:\n", $i);
41
			$this->traiterResultatsFamille($resultats, $noms, $introuvables, $introuvablesSyno);
41
			$this->traiterResultatsFamille(  $introuvables, $introuvablesSyno);
42
			echo "\n\n";
42
			//echo "\n\n"; print_r(count($this->noms));
43
			// printf("noms: %d, introuvables: %d, introuvablesSyno: %d\n", count($noms), count($introuvables), count($introuvablesSyno));
43
			// printf("noms: %d, introuvables: %d, introuvablesSyno: %d\n", count($noms), count($introuvables), count($introuvablesSyno));
44
			// XXX, au 22/07/2013, 3 passes sont suffisantes
44
			// XXX, au 22/07/2013, 3 passes sont suffisantes
45
			// TODO: MySQL procédure stockée !
45
			// TODO: MySQL procédure stockée !
46
			if($i++ == 3) break;
46
			if($i++ == 4) break;
47
			$resultats = array_merge($resultats, $introuvables, $introuvablesSyno);
47
			$this->resultats = array_merge($this->resultats, $introuvables, $introuvablesSyno);
48
			$introuvables = $introuvablesSyno = array();
48
			$introuvables = $introuvablesSyno = array();
49
		}
49
		}
50
 
50
 
51
		foreach ($introuvablesSyno as $id => $nom) {
51
		foreach ($introuvablesSyno as $id => $nom) {
52
			$nn = $nom['num_nom'];
52
			$nn = $nom['num_nom'];
53
			$nnr = $nom['num_nom_retenu'];
53
			$nnr = $nom['num_nom_retenu'];
54
			if (isset($noms[$nnr])) {
54
			if (isset($this->noms[$nnr])) {
55
				$noms[$nn] = $noms[$nnr];
55
				$this->noms[$nn] = $this->noms[$nnr];
56
			} else {
56
			} else {
57
				$introuvables[] = $nn;
57
				$introuvables[] = $nn;
58
			}
58
			}
59
			unset($introuvablesSyno[$id]);
59
			unset($introuvablesSyno[$id]);
60
			
60
			
61
		}
61
		}
62
		echo "\n";
62
		echo "\n";
63
		
63
		
64
 
64
 
65
		/*$msg = 'Plusieurs familles sont introuvables';
65
		/*$msg = 'Plusieurs familles sont introuvables';
66
		$this->creerFichierLog($msg, $introuvables, 'famille_introuvable');*/
66
		$this->creerFichierLog($msg, $introuvables, 'famille_introuvable');*/
-
 
67
 
67
 
68
print_r(count($this->noms));echo "wtf:";
68
		$this->referentielDao->remplirChpFamille($referentiel, $noms);
69
		print_r($this->referentielDao->remplirChpFamille($referentiel, $this->noms));
69
    }
70
    }
70
 
71
 
71
	
72
	
72
 
73
 
73
	
74
	
-
 
75
	private function traiterResultatsFamille(&$introuvables, &$introuvablesSyno) {
74
	private function traiterResultatsFamille(&$resultats, &$noms, &$introuvables, &$introuvablesSyno) {
76
		
75
		foreach ($resultats as $id => $nom) {
77
		foreach ($this->resultats as $id => $nom) {
76
			$nn = $nom['num_nom'];
78
			$nn = $nom['num_nom']; 
77
			$nnr = $nom['num_nom_retenu'];
79
			$nnr = $nom['num_nom_retenu'];
78
			$nts = $nom['num_tax_sup'];
80
			$nts = $nom['num_tax_sup'];
79
			$rg = $nom['rang'];
81
			$rg = $nom['rang'];
80
			if ($nnr != '') {
82
			if ($nnr != '') {
81
				if ($rg == '180') {
83
				if ($rg == '180') {
82
					$noms[$nn] = $nom['nom_sci'];
84
					$this->noms[$nn] = $nom['nom_sci'];
83
				} else {
85
				} else {
84
					if ($nn == $nnr) {
86
					if ($nn == $nnr) {
85
						// nom retenu
87
						// nom retenu
86
						if (isset($noms[$nts])) {
88
						if (isset($this->noms[$nts])) {
87
							// signifie que recupererTuplesPrChpFamille() devrait
89
							// signifie que recupererTuplesPrChpFamille() devrait
88
							// récupérer ce record *avant*
90
							// récupérer ce record *avant*
89
							$noms[$nn] = $noms[$nts];
91
							$this->noms[$nn] = $this->noms[$nts];
90
						} else {
92
						} else {
91
							$introuvables[] = $nn;
93
							$introuvables[] = $nn;
92
						}
94
						}
93
					} else {// nom synonyme
95
					} else {// nom synonyme
94
						if (isset($noms[$nnr])) {
96
						if (isset($this->noms[$nnr])) {
95
							// signifie que recupererTuplesPrChpFamille() devrait
97
							// signifie que recupererTuplesPrChpFamille() devrait
96
							// récupérer ce record *avant*
98
							// récupérer ce record *avant*
97
							$noms[$nn] = $noms[$nnr];
99
							$this->noms[$nn] = $this->noms[$nnr];
98
						} else {
100
						} else {
99
							$introuvablesSyno[] = $nom;
101
							$introuvablesSyno[] = $nom;
100
						}
102
						}
101
					}
103
					}
102
				}
104
				}
103
			}
105
			}
104
			unset($resultats[$id]);
106
			unset($this->resultats[$id]);
105
		}
107
		}
106
	}
108
	}
107
 
109
 
108
}
110
}
109
?>
-
 
110
111
?>
-
 
112