Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 1144 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1144 Rev 1146
Line 1... Line 1...
1
<?php
1
<?php
2
//declare(encoding='UTF-8');
2
//declare(encoding='UTF-8');
3
/**
3
/**
4
 * Exemple de lancement du script : :
4
 * Exemple de lancement du script : :
5
 * /opt/lampp/bin/php cli.php lef -a chargerTous
5
 * /opt/lampp/bin/php cli.php lbf -a chargerTous
6
 *
6
 *
7
 * @category	php 5.2
7
 * @category	php 5.2
8
 * @package		eFlore/Scripts
8
 * @package		eFlore/Scripts
9
 * @author		Jennifer DHÉ <jennifer@tela-botanica.org>
9
 * @author		Delphine Cauquil <delphine@tela-botanica.org>
10
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
 * @author		Aurélien PERONNET <aurelien@tela-botanica.org>
11
 * @copyright	Copyright (c) 2011, Tela Botanica (accueil@tela-botanica.org)
11
 * @copyright	Copyright (c) 2014, Tela Botanica (accueil@tela-botanica.org)
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
13
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
13
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
14
 * @version		$Id$
14
 * @version		$Id$
15
 */
15
 */
16
class Lef extends EfloreScript {
16
class Lbf extends EfloreScript {
Line 17... Line 17...
17
 
17
 
18
	private $table = null;
18
	private $table = null;
19
	private $pasInsertion = 1000;
19
	private $pasInsertion = 1000;
Line 20... Line 20...
20
	private $departInsertion = 0;
20
	private $departInsertion = 0;
21
 
21
 
Line 22... Line 22...
22
	protected $parametres_autorises = array(
22
	protected $parametres_autorises = array(
23
		'-t' => array(false, false, 'Permet de tester le script sur un jeu réduit de données (indiquer le nombre de lignes).'));
23
		'-t' => array(false, false, 'Permet de tester le script sur un jeu réduit de données (indiquer le nombre de lignes).'));
24
 
24
 
Line 25... Line 25...
25
	public function executer() {
25
	public function executer() {
26
		try {
26
		try {
27
			$this->initialiserProjet('lef');
27
			$this->initialiserProjet('lbf');
28
 
28
 
29
			// Lancement de l'action demandée
29
			// Lancement de l'action demandée
30
			$cmd = $this->getParametre('a');
30
			$cmd = $this->getParametre('a');
31
			switch ($cmd) {
31
			switch ($cmd) {
32
				case 'chargerTous' :
32
				case 'chargerTous' :
33
					$this->chargerStructureSql();
33
					$this->chargerStructureSql();
34
					$this->chargerLef();
34
					$this->chargerlbf();
35
					$this->genererChpNomSciHtml();
35
					$this->genererChpNomSciHtml();
36
					$this->genererChpFamille();
36
					$this->genererChpFamille();
37
					//$this->genererChpHierarchie();
37
					//$this->genererChpHierarchie();
38
					break;
38
					break;
39
				case 'chargerStructureSql' :
39
				case 'chargerStructureSql' :
40
					$this->chargerStructureSql();
40
					$this->chargerStructureSql();
41
					break;
41
					break;
42
				case 'chargerLef' :
42
				case 'chargerlbf' :
43
					$this->chargerLef();
43
					$this->chargerlbf();
44
					break;
44
					break;
Line 57... Line 57...
57
		} catch (Exception $e) {
57
		} catch (Exception $e) {
58
			$this->traiterErreur($e->getMessage());
58
			$this->traiterErreur($e->getMessage());
59
		}
59
		}
60
	}
60
	}
Line 61... Line 61...
61
 
61
 
62
	private function chargerLef() {
62
	private function chargerlbf() {
63
		$chemin = Config::get('chemins.lef');
63
		$chemin = Config::get('chemins.lbf');
64
		$table = Config::get('tables.lef');
64
		$table = Config::get('tables.lbf');
65
		$requete = "LOAD DATA INFILE '$chemin' ".
65
		$requete = "LOAD DATA INFILE '$chemin' ".
66
				"REPLACE INTO TABLE $table ".
66
				"REPLACE INTO TABLE $table ".
67
				'CHARACTER SET utf8 '.
67
				'CHARACTER SET utf8 '.
68
				'FIELDS '.
68
				'FIELDS '.
Line 98... Line 98...
98
 
98
 
99
		$this->creerFichierLog('Erreurs lors de la génération HTML des noms scientifiques', $erreurs, 'erreurs_noms_sci_html');
99
		$this->creerFichierLog('Erreurs lors de la génération HTML des noms scientifiques', $erreurs, 'erreurs_noms_sci_html');
Line 100... Line 100...
100
	}
100
	}
101
 
101
 
102
	private function initialiserGenerationChamps() {
102
	private function initialiserGenerationChamps() {
Line 103... Line 103...
103
		$this->table = Config::get('tables.lef');
103
		$this->table = Config::get('tables.lbf');
104
	}
104
	}
105
 
105
 
Line 250... Line 250...
250
	}
250
	}
Line 251... Line 251...
251
	
251
	
252
	private function genererChpHierarchie() {
252
	private function genererChpHierarchie() {
253
		$this->initialiserGenerationChamps();
253
		$this->initialiserGenerationChamps();
254
		$this->preparerTablePrChpHierarchie();
254
		$this->preparerTablePrChpHierarchie();
Line 255... Line 255...
255
		$table = Config::get('tables.lef');
255
		$table = Config::get('tables.lbf');
256
		
256
		
Line 257... Line 257...
257
		$requete = "UPDATE $table SET hierarchie = NULL ";
257
		$requete = "UPDATE $table SET hierarchie = NULL ";
Line 299... Line 299...
299
 
299
 
300
	private function genererDonneesTestMultiVersion() {
300
	private function genererDonneesTestMultiVersion() {
301
		$contenuSql = $this->recupererContenu(Config::get('chemins.structureSqlTest'));
301
		$contenuSql = $this->recupererContenu(Config::get('chemins.structureSqlTest'));
Line 302... Line 302...
302
		$this->executerScripSql($contenuSql);
302
		$this->executerScripSql($contenuSql);
303
 
303
 
304
		$table = Config::get('tables.lef');
304
		$table = Config::get('tables.lbf');
305
		$tableTest = Config::get('tables.lefTest');
305
		$tableTest = Config::get('tables.lbfTest');
306
		$requete = "INSERT INTO $tableTest SELECT * FROM $table";
306
		$requete = "INSERT INTO $tableTest SELECT * FROM $table";
Line 307... Line 307...
307
		$this->getBdd()->requeter($requete);
307
		$this->getBdd()->requeter($requete);
308
	}
308
	}
309
 
309
 
310
	private function supprimerDonneesTestMultiVersion() {
310
	private function supprimerDonneesTestMultiVersion() {
Line 311... Line 311...
311
		$tableMeta = Config::get('tables.lefMeta');
311
		$tableMeta = Config::get('tables.lbfMeta');
312
		$requete = "DELETE FROM $tableMeta WHERE guid = 'urn:lsid:tela-botanica.org:lef:1.02'";
312
		$requete = "DELETE FROM $tableMeta WHERE guid = 'urn:lsid:tela-botanica.org:lbf:1.02'";
313
		$this->getBdd()->requeter($requete);
313
		$this->getBdd()->requeter($requete);
314
 
314
 
Line 315... Line 315...
315
		$tableTest = Config::get('tables.lefTest');
315
		$tableTest = Config::get('tables.lbfTest');
316
		$requete = "DROP TABLE IF EXISTS $tableTest";
316
		$requete = "DROP TABLE IF EXISTS $tableTest";
317
		$this->getBdd()->requeter($requete);
317
		$this->getBdd()->requeter($requete);
318
	}
318
	}
Line 319... Line 319...
319
 
319
 
320
	private function supprimerTous() {
320
	private function supprimerTous() {