Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 1182 Rev 1219
Line 13... Line 13...
13
			$cmd = $this->getParametre('a');
13
			$cmd = $this->getParametre('a');
14
			switch ($cmd) {
14
			switch ($cmd) {
15
				case 'chargerStructureSql' :
15
				case 'chargerStructureSql' :
16
					$this->chargerStructureSql();
16
					$this->chargerStructureSql();
17
					break;
17
					break;
18
				case 'chargerMetadonnees':
18
				case 'chargerMetadonnees':
19
					$this->chargerMetadonnees();
19
					$this->chargerMetadonnees();
20
					break;
20
					break;
21
				case 'chargerOntologies' :
21
				case 'chargerOntologies' :
22
					$this->chargerOntologies();
22
					$this->chargerOntologies();
23
					break;
23
					break;
24
				case 'verifierFichier' :
24
				case 'verifierFichier' :
25
					$this->verifierFichier();
25
					$this->verifierFichier();
26
					break;
26
					break;
27
				case 'chargerDonnees' :
27
				case 'chargerDonnees' :
28
					$this->chargerDonnees();
28
					$this->chargerBaseflor();
29
					break;
29
					break;
30
				case 'genererChamps' :
30
				case 'genererChamps' :
31
					 $this->genererChamps();
31
					 $this->genererChamps();
32
					 break;
32
					 break;
33
				case 'chargerTous':
33
				case 'chargerTous':
34
					$this->chargerStructureSql();
34
					$this->chargerStructureSql();
35
					$this->chargerMetadonnees();
35
					$this->chargerMetadonnees();
36
					$this->chargerOntologies();
36
					$this->chargerOntologies();
37
					$this->chargerDonnees();
37
					$this->chargerBaseflor();
38
					$this->genererChamps();
38
					$this->genererChamps();
39
					$this->insererDonneesBaseflorRangSupEcolo();
39
					$this->insererDonneesBaseflorRangSupEcolo();
40
					$this->insererDonneesIndex();
40
					$this->insererDonneesIndex();
41
					break;
41
					break;
42
				case 'insererDonneesRangSup' :
42
				case 'insererDonneesRangSup' :
43
					$this->insererDonneesBaseflorRangSupEcolo();
43
					$this->insererDonneesBaseflorRangSupEcolo();
44
					break;
44
					break;
45
				case 'supprimerTous' :
45
				case 'supprimerTous' :
46
					$this->supprimerTous();
46
					$this->supprimerTous();
47
					break;
47
					break;
48
				case 'voirRangSup' :
48
				case 'voirRangSup' :
49
					$this->voirRangSup();
49
					$this->voirRangSup();
50
					break;
50
					break;
51
				case 'voirRangSupEcologie' :
51
				case 'voirRangSupEcologie' :
Line 109... Line 109...
109
		$this->initialiserGenerationChamps();
109
		$this->initialiserGenerationChamps();
110
		$this->ajouterChamps();
110
		$this->ajouterChamps();
111
		$this->analyserChampsExistant();
111
		$this->analyserChampsExistant();
112
	}
112
	}
Line 113... Line 113...
113
 
113
 
114
	private function initialiserGenerationChamps() {
114
	private function initialiserGenerationChamps() {
115
		$this->table = Config::get('tables.donnees');
115
		$this->table = Config::get('tables.donnees');
Line 116... Line 116...
116
	}
116
	}
117
 
117
 
118
	private function ajouterChamps() {
118
	private function ajouterChamps() {
119
		$this->preparerTablePrChpsBDNT();
119
		$this->preparerTablePrChpsBDNT();
120
		$this->preparerTablePrChpsNumTaxon();
120
		$this->preparerTablePrChpsNumTaxon();
121
		$this->preparerTablePrChpsNumNomen();
121
		$this->preparerTablePrChpsNumNomen();
122
	}
122
	}
123
 
123
 
124
	private function preparerTablePrChpsBDNT() {
124
	private function preparerTablePrChpsBDNT() {
125
		$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'BDNT' ";
125
		$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'BDNT' ";
126
		$resultat = $this->getBdd()->recuperer($requete);
126
		$resultat = $this->getBdd()->recuperer($requete);
127
		if ($resultat === false) {
127
		if ($resultat === false) {
128
			$requete = 	"ALTER TABLE {$this->table} ".
128
			$requete = 	"ALTER TABLE {$this->table} ".
129
					'ADD BDNT VARCHAR( 6 ) '.
129
					'ADD BDNT VARCHAR( 6 ) '.
130
					'CHARACTER SET utf8 COLLATE utf8_general_ci '.
130
					'CHARACTER SET utf8 COLLATE utf8_general_ci '.
131
					'NOT NULL AFTER catminat_code ';
131
					'NOT NULL AFTER catminat_code ';
132
			$this->getBdd()->requeter($requete);
132
			$this->getBdd()->requeter($requete);
133
		}
133
		}
134
	}
134
	}
135
 
135
 
136
	private function preparerTablePrChpsNumTaxon() {
136
	private function preparerTablePrChpsNumTaxon() {
137
		$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'num_taxon' ";
137
		$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'num_taxon' ";
138
		$resultat = $this->getBdd()->recuperer($requete);
138
		$resultat = $this->getBdd()->recuperer($requete);
139
		if ($resultat === false) {
139
		if ($resultat === false) {
140
			$requete = "ALTER TABLE {$this->table} ".
140
			$requete = "ALTER TABLE {$this->table} ".
141
					'ADD num_taxon INT( 10 ) NOT NULL '.
141
					'ADD num_taxon INT( 10 ) NOT NULL '.
142
					'AFTER catminat_code';
142
					'AFTER catminat_code';
143
			$this->getBdd()->requeter($requete);
143
			$this->getBdd()->requeter($requete);
144
		}
144
		}
145
	}
145
	}
146
 
146
 
147
	private function preparerTablePrChpsNumNomen() {
147
	private function preparerTablePrChpsNumNomen() {
148
		$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'num_nomen' ";
148
		$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'num_nomen' ";
149
		$resultat = $this->getBdd()->recuperer($requete);
149
		$resultat = $this->getBdd()->recuperer($requete);
150
		if ($resultat === false) {
150
		if ($resultat === false) {
151
			$requete = "ALTER TABLE {$this->table} ".
151
			$requete = "ALTER TABLE {$this->table} ".
152
					'ADD num_nomen INT( 10 ) NOT NULL '.
152
					'ADD num_nomen INT( 10 ) NOT NULL '.
153
					'AFTER catminat_code';
153
					'AFTER catminat_code';
154
			$this->getBdd()->requeter($requete);
154
			$this->getBdd()->requeter($requete);
Line 155... Line 155...
155
		}
155
		}
156
	}
156
	}
157
 
157
 
158
	private function analyserChampsExistant() {
158
	private function analyserChampsExistant() {
159
		$resultats = $this->recupererTuplesNumsOriginels();
159
		$resultats = $this->recupererTuplesNumsOriginels();
160
		foreach ($resultats as $chps) {
160
		foreach ($resultats as $chps) {
Line 161... Line 161...
161
			$cle = $chps['cle'];
161
			$cle = $chps['cle'];
Line 171... Line 171...
171
 
171
 
172
			$this->afficherAvancement("Insertion des valeurs dans la base en cours");
172
			$this->afficherAvancement("Insertion des valeurs dans la base en cours");
173
		}
173
		}
174
		echo "\n";
174
		echo "\n";
175
	}
175
	}
176
 
176
 
177
	private function recupererTuplesNumsOriginels(){
177
	private function recupererTuplesNumsOriginels(){
178
		$requete = "SELECT cle, num_taxon_originel, num_nomen_originel FROM {$this->table} ";
178
		$requete = "SELECT cle, num_taxon_originel, num_nomen_originel FROM {$this->table} ";
179
		$resultat = $this->getBdd()->recupererTous($requete);
179
		$resultat = $this->getBdd()->recupererTous($requete);
180
		return $resultat;
180
		return $resultat;
Line 181... Line 181...
181
	}
181
	}
182
 
182
 
183
	private function genererChpsBDNT($nno, $nto) {
183
	private function genererChpsBDNT($nno, $nto) {
Line 263... Line 263...
263
		foreach ($requetes as $requete) {
263
		foreach ($requetes as $requete) {
264
			$this->getBdd()->requeter($requete);
264
			$this->getBdd()->requeter($requete);
265
		}
265
		}
266
	}
266
	}
Line 267... Line 267...
267
 
267
 
268
	protected function chargerDonnees() {
268
	protected function chargerBaseflor() {
269
		//$nb_err = $this->verifierFichier();
269
		//$nb_err = $this->verifierFichier();
270
		if ($nb_err > 0) {
270
		if ($nb_err > 0) {
271
			$e = "Je ne peux pas charger les données car le fichier comporte des erreurs.".
271
			$e = "Je ne peux pas charger les données car le fichier comporte des erreurs.".
272
					"Voir le fichier baseflor_verif.txt\n";
272
					"Voir le fichier baseflor_verif.txt\n";
273
			throw new Exception($e);
273
			throw new Exception($e);
Line 274... Line 274...
274
		}
274
		}
275
 
275
 
276
		$table = Config::get('tables.donnees');
276
		$table = Config::get('tables.donnees');