Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 637 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 637 Rev 661
Line 61... Line 61...
61
			$this->traiterErreur($e->getMessage());
61
			$this->traiterErreur($e->getMessage());
62
		}
62
		}
63
	}
63
	}
Line 64... Line 64...
64
 
64
 
65
	private function chargerBdtxa() {
65
	private function chargerBdtxa() {
66
		$chemin = Config::get('chemins.bdtxa');
66
		$chemin = Config::get('chemins.bdt');
67
		$table = Config::get('tables.bdtxa');
67
		$table = Config::get('tables.bdtxa');
68
		$requete = "LOAD DATA INFILE '$chemin' ".
68
		$requete = "LOAD DATA INFILE '$chemin' ".
69
				"REPLACE INTO TABLE $table ".
69
				"REPLACE INTO TABLE $table ".
70
				'CHARACTER SET utf8 '.
70
				'CHARACTER SET utf8 '.
Line 79... Line 79...
79
	private function genererChpNomSciHtml() {
79
	private function genererChpNomSciHtml() {
80
		$this->initialiserGenerationChamps();
80
		$this->initialiserGenerationChamps();
81
		$this->preparerTablePrChpNomSciHtml();
81
		$this->preparerTablePrChpNomSciHtml();
82
		$generateur = new GenerateurNomSciHtml();
82
		$generateur = new GenerateurNomSciHtml();
83
		$nbreTotal = $this->recupererNbTotalTuples();
83
		$nbreTotal = $this->recupererNbTotalTuples();
-
 
84
		$erreurs = array();
84
		$this->departInsertion = 0;
85
		$this->departInsertion = 0;
85
		while ($this->departInsertion < $nbreTotal) {
86
		while ($this->departInsertion < $nbreTotal) {
86
			$resultat = $this->recupererTuplesPrChpNomSciHtml();
87
			$resultat = $this->recupererTuplesPrChpNomSciHtml();
-
 
88
 
-
 
89
			try {
87
			$nomsSciEnHtml = $generateur->generer($resultat);
90
				$nomsSciEnHtml = $generateur->generer($resultat);
-
 
91
			} catch (Exception $e) {
-
 
92
				$erreurs[] = $e->getMessage();
-
 
93
			}
-
 
94
 
88
			$this->remplirChpNomSciHtm($nomsSciEnHtml);
95
			$this->remplirChpNomSciHtm($nomsSciEnHtml);
89
			$this->departInsertion += $this->pasInsertion;
96
			$this->departInsertion += $this->pasInsertion;
90
			$this->afficherAvancement("Insertion des noms scientifique au format HTML dans la base par paquet de {$this->pasInsertion} en cours");
97
			$this->afficherAvancement("Insertion des noms scientifique au format HTML dans la base par paquet de {$this->pasInsertion} en cours");
91
			if ($this->stopperLaBoucle($this->getParametre('t'))) break;
98
			if ($this->stopperLaBoucle($this->getParametre('t'))) break;
92
		}
99
		}
93
		echo "\n";
100
		echo "\n";
-
 
101
 
-
 
102
		$this->creerFichierLog('Erreurs lors de la génération HTML des noms scientifiques', $erreurs, 'erreurs_noms_sci_html');
94
	}
103
	}
Line 95... Line 104...
95
 
104
 
96
	private function initialiserGenerationChamps() {
105
	private function initialiserGenerationChamps() {
97
		$this->table = Config::get('tables.bdtxa');
106
		$this->table = Config::get('tables.bdtxa');
Line 150... Line 159...
150
			$this->getBdd()->requeter($requete);
159
			$this->getBdd()->requeter($requete);
151
		}
160
		}
152
	}
161
	}
Line 153... Line 162...
153
	
162
 
154
	private function remplirChpNomComplet() {
163
	private function remplirChpNomComplet() {
155
		$this->afficherAvancement("Attribution du champ nom complet au taxons");
164
		echo "Attribution du champ nom complet au taxons : ";
156
		$requete = "UPDATE {$this->table} SET nom_complet = CONCAT(nom_sci,' ',auteur)";
165
		$requete = "UPDATE {$this->table} SET nom_complet = CONCAT(nom_sci,' ',auteur)";
157
		$resultat = $this->getBdd()->requeter($requete);
166
		$resultat = $this->getBdd()->requeter($requete);
-
 
167
		if ($resultat === false) {
158
		if ($resultat === false) {
168
			echo "KO\n";
-
 
169
			throw new Exception("Erreur de génération du champ nom complet");
-
 
170
		} else {
159
			throw new Exception("Erreur de génération du champ nom complet");
171
			echo "OK\n";
160
		}
172
		}
Line 161... Line 173...
161
	}
173
	}
162
 
174
 
Line 208... Line 220...
208
			unset($introuvablesSyno[$id]);
220
			unset($introuvablesSyno[$id]);
209
			$this->afficherAvancement("Attribution de leur famille aux synonymes en cours");
221
			$this->afficherAvancement("Attribution de leur famille aux synonymes en cours");
210
		}
222
		}
211
		echo "\n";
223
		echo "\n";
Line 212... Line -...
212
 
-
 
213
		if (count($introuvables) != 0) {
224
 
214
			$introuvablesNbre = count($introuvables);
225
		$msg = 'Plusieurs familles sont introuvables';
Line 215... Line -...
215
			echo "Famille introuvable pour $introuvablesNbre noms ! Voir le log.\n";
-
 
216
 
-
 
217
			$logContenu = implode(", \n", $introuvables);
-
 
218
			$logFichier = realpath(dirname(__FILE__)).'/log/famille_introuvable.log';
-
 
219
			echo $logFichier."\n";
-
 
220
			file_put_contents($logFichier, $logContenu);
226
		$this->creerFichierLog($msg, $introuvables, 'famille_introuvable');
221
		}
227
 
Line 222... Line 228...
222
		$this->remplirChpFamille($noms);
228
		$this->remplirChpFamille($noms);
223
	}
229
	}
Line 264... Line 270...
264
		$this->getBdd()->requeter($requete);
270
		$this->getBdd()->requeter($requete);
265
	}
271
	}
Line 266... Line 272...
266
	
272
 
267
	private function supprimerDonneesTestMultiVersion() {
273
	private function supprimerDonneesTestMultiVersion() {
268
		$tableMeta = Config::get('tables.bdtxaMeta');
274
		$tableMeta = Config::get('tables.bdtxaMeta');
269
		$requete = "DELETE FROM $tableMeta WHERE guid = 'urn:lsid:tela-botanica.org:bdtfx:1.02'";
275
		$requete = "DELETE FROM $tableMeta WHERE guid = 'urn:lsid:tela-botanica.org:bdtxa:1.00'";
Line 270... Line 276...
270
		$this->getBdd()->requeter($requete);
276
		$this->getBdd()->requeter($requete);
271
	
277
 
272
		$tableTest = Config::get('tables.bdtxaTest');
278
		$tableTest = Config::get('tables.bdtxaTest');
273
		$requete = "DROP TABLE IF EXISTS $tableTest";
279
		$requete = "DROP TABLE IF EXISTS $tableTest";
274
		$this->getBdd()->requeter($requete);
280
		$this->getBdd()->requeter($requete);
275
	}
281
	}
276
	private function supprimerTous() {
282
	private function supprimerTous() {
277
		$requete = "DROP TABLE IF EXISTS bdtxa_meta, bdtxa_v0_01";
283
		$requete = "DROP TABLE IF EXISTS bdtxa_meta, bdtxa_v0_01, bdtxa_v1_00";
-
 
284
		$this->getBdd()->requeter($requete);
-
 
285
	}
-
 
286
 
-
 
287
	private function creerFichierLog($message, $lignes, $nomFichier) {
-
 
288
		$lignesNbre = count($lignes);
-
 
289
		if ($lignesNbre != 0) {
-
 
290
			echo "$message. Voir le log de $lignesNbre lignes :\n";
-
 
291
 
-
 
292
			$logContenu = implode(", \n", $lignes);
-
 
293
			$logFichier = realpath(dirname(__FILE__))."/log/$nomFichier.log";
-
 
294
			echo $logFichier."\n";
-
 
295
			file_put_contents($logFichier, $logContenu);
278
		$this->getBdd()->requeter($requete);
296
		}
279
	}
297
	}
280
}
298
}