Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 1324 Rev 1325
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 taxref -a chargerTous
5
 * /opt/lampp/bin/php cli.php vascan -a chargerTous
6
 *
6
 *
7
 * @category	php 5.2
7
 * @category	php 5.2
8
 * @package		eFlore/Scripts
8
 * @package		eFlore/Scripts
9
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
 * @copyright	Copyright (c) 2012, Tela Botanica (accueil@tela-botanica.org)
10
 * @copyright	Copyright (c) 2012, Tela Botanica (accueil@tela-botanica.org)
11
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
13
 * @version		$Id$
13
 * @version		$Id$
14
 */
14
 */
15
class Taxref extends EfloreScript {
15
class Vascan extends EfloreScript {
Line 16... Line 16...
16
 
16
 
17
	private $table = null;
17
	private $table = null;
18
	private $pasInsertion = 1000;
18
	private $pasInsertion = 1000;
Line 28... Line 28...
28
			// Lancement de l'action demandée
28
			// Lancement de l'action demandée
29
			$cmd = $this->getParametre('a');
29
			$cmd = $this->getParametre('a');
30
			switch ($cmd) {
30
			switch ($cmd) {
31
				case 'chargerTous' :
31
				case 'chargerTous' :
32
					$this->chargerStructureSql();
32
					$this->chargerStructureSql();
33
					$this->chargertaxref();
33
					$this->chargerVascan();
34
					$this->genererChpNumTax();
34
					$this->genererChpNumTax();
35
					$this->genererChpNomSciHtml();
35
					$this->genererChpNomSciHtml();
36
					$this->genererChpFamille();
36
					$this->genererChpFamille();
37
					$this->genererChpNomComplet();
37
					$this->genererChpNomComplet();
38
					$this->genererChpHierarchie();
38
					$this->genererChpHierarchie();
39
					break;
39
					break;
40
				case 'chargerStructureSql' :
40
				case 'chargerStructureSql' :
41
					$this->chargerStructureSql();
41
					$this->chargerStructureSql();
42
					break;
42
					break;
43
				case 'chargerTaxref' :
43
				case 'chargerVascan' :
44
					$this->chargerTaxref();
44
					$this->chargerVascan();
45
					break;
45
					break;
46
				case 'genererChpNumTax' :
46
				case 'genererChpNumTax' :
47
					$this->genererChpNumTax();
47
					$this->genererChpNumTax();
48
					break;
48
					break;
49
				case 'genererChpNomSciHtml' :
49
				case 'genererChpNomSciHtml' :
Line 68... Line 68...
68
		} catch (Exception $e) {
68
		} catch (Exception $e) {
69
			$this->traiterErreur($e->getMessage());
69
			$this->traiterErreur($e->getMessage());
70
		}
70
		}
71
	}
71
	}
Line 72... Line 72...
72
 
72
 
73
	private function chargerTaxref() {
73
	private function chargerVascan() {
74
		$chemin = Config::get('chemins.bdt');
74
		$chemin = Config::get('chemins.bdt');
75
		$table = Config::get('tables.taxref');
75
		$table = Config::get('tables.vascan');
76
		$requete = "LOAD DATA INFILE '$chemin' ".
76
		$requete = "LOAD DATA INFILE '$chemin' ".
77
				"REPLACE INTO TABLE $table ".
77
				"REPLACE INTO TABLE $table ".
78
				'CHARACTER SET utf8 '.
78
				'CHARACTER SET utf8 '.
79
				'FIELDS '.
79
				'FIELDS '.
Line 145... Line 145...
145
 
145
 
146
		$this->creerFichierLog('Erreurs lors de la génération HTML des noms scientifiques', $erreurs, 'erreurs_noms_sci_html');
146
		$this->creerFichierLog('Erreurs lors de la génération HTML des noms scientifiques', $erreurs, 'erreurs_noms_sci_html');
Line 147... Line 147...
147
	}
147
	}
148
 
148
 
149
	private function initialiserGenerationChamps() {
149
	private function initialiserGenerationChamps() {
Line 150... Line 150...
150
		$this->table = Config::get('tables.taxref');
150
		$this->table = Config::get('tables.vascan');
151
	}
151
	}
152
 
152
 
Line 305... Line 305...
305
	}
305
	}
Line 306... Line 306...
306
	
306
	
307
	private function genererChpHierarchie() {
307
	private function genererChpHierarchie() {
308
		$this->initialiserGenerationChamps();
308
		$this->initialiserGenerationChamps();
309
		$this->preparerTablePrChpHierarchie();
309
		$this->preparerTablePrChpHierarchie();
Line 310... Line 310...
310
		$table = Config::get('tables.taxref');
310
		$table = Config::get('tables.vascan');
311
	
311
	
Line 312... Line 312...
312
		$requete = "UPDATE $table SET hierarchie = NULL ";
312
		$requete = "UPDATE $table SET hierarchie = NULL ";
Line 354... Line 354...
354
	
354
	
355
	private function genererDonneesTestMultiVersion() {
355
	private function genererDonneesTestMultiVersion() {
356
		$contenuSql = $this->recupererContenu(Config::get('chemins.structureSqlTest'));
356
		$contenuSql = $this->recupererContenu(Config::get('chemins.structureSqlTest'));
Line 357... Line 357...
357
		$this->executerScripSql($contenuSql);
357
		$this->executerScripSql($contenuSql);
358
 
358
 
359
		$table = Config::get('tables.taxref');
359
		$table = Config::get('tables.vascan');
360
		$tableTest = Config::get('tables.taxrefTest');
360
		$tableTest = Config::get('tables.vascanTest');
361
		$requete = "INSERT INTO $tableTest SELECT * FROM $table";
361
		$requete = "INSERT INTO $tableTest SELECT * FROM $table";
Line 362... Line 362...
362
		$this->getBdd()->requeter($requete);
362
		$this->getBdd()->requeter($requete);
363
	}
363
	}
364
 
364
 
365
	private function supprimerDonneesTestMultiVersion() {
365
	private function supprimerDonneesTestMultiVersion() {
Line 366... Line 366...
366
		$tableMeta = Config::get('tables.taxrefMeta');
366
		$tableMeta = Config::get('tables.vascanMeta');
367
		$requete = "DELETE FROM $tableMeta WHERE guid = 'urn:lsid:tela-botanica.org:taxref:1.00'";
367
		$requete = "DELETE FROM $tableMeta WHERE guid = 'urn:lsid:tela-botanica.org:vascan:1.00'";
368
		$this->getBdd()->requeter($requete);
368
		$this->getBdd()->requeter($requete);
369
 
369
 
370
		$tableTest = Config::get('tables.taxrefTest');
370
		$tableTest = Config::get('tables.vascanTest');
371
		$requete = "DROP TABLE IF EXISTS $tableTest";
371
		$requete = "DROP TABLE IF EXISTS $tableTest";
372
		$this->getBdd()->requeter($requete);
372
		$this->getBdd()->requeter($requete);
373
	}
373
	}
Line 374... Line 374...
374
	private function supprimerTous() {
374
	private function supprimerTous() {
375
		$requete = "DROP TABLE IF EXISTS taxref_meta, taxref_v0_01, taxref_v1_00";
375
		$requete = "DROP TABLE IF EXISTS vascan_meta, vascan_v0_01, vascan_v1_00";