Subversion Repositories Applications.referentiel

Rev

Rev 195 | Rev 215 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 195 Rev 214
Line 35... Line 35...
35
	private $zip_chemin_fichier_partiel = null;
35
	private $zip_chemin_fichier_partiel = null;
Line 36... Line 36...
36
	
36
	
37
	private $noms = null;
37
	private $noms = null;
38
	private $noms_precedents = null;
38
	private $noms_precedents = null;
-
 
39
	private $noms_stat = null;
39
	private $noms_stat = null;
40
	private $noms_stat_partiel = null;
40
	private $champs_ordre = null;
41
	private $champs_ordre = null;
41
	private $champs_nom = null;
42
	private $champs_nom = null;
42
	private $champs_nom_partiel = null;
43
	private $champs_nom_partiel = null;
43
	private $champs_diff = null;
44
	private $champs_diff = null;
44
	private $diff_champs_nom = null;
45
	private $diff_champs_nom = null;
45
	private $diff_modif_types = null;
46
	private $diff_modif_types = null;
46
	private $signature_md5 = null;
47
	private $signature_md5 = null;
-
 
48
	private $signature_md5_partiel = null;
Line 47... Line 49...
47
	private $signature_md5_partiel = null;
49
	private $exclure_taxref = null;
48
	
50
	
49
	private $resultatDao = null;
51
	private $resultatDao = null;
50
	private $traitementDao = null;
52
	private $traitementDao = null;
Line 152... Line 154...
152
	
154
	
153
	private function analyserNomsATraiter() {
155
	private function analyserNomsATraiter() {
154
		$this->noms_stat['combinaison'] = $this->getNombreCombinaison();
156
		$this->noms_stat['combinaison'] = $this->getNombreCombinaison();
155
		$this->noms_stat['taxon'] = $this->getNombreTaxon();
157
		$this->noms_stat['taxon'] = $this->getNombreTaxon();
-
 
158
		Debug::printr("Stats :".print_r($this->noms_stat, true));
-
 
159
		$this->noms_stat_partiel = $this->getStatsPartiel();
156
		Debug::printr("Stats :".print_r($this->noms_stat, true));
160
		Debug::printr("Stats partiel:".print_r($this->noms_stat_partiel, true));
Line 157... Line 161...
157
	}
161
	}
158
	
162
	
159
	private function getNombreCombinaison() {
163
	private function getNombreCombinaison() {
Line 168... Line 172...
168
			}
172
			}
169
		}
173
		}
170
		return $nbre;
174
		return $nbre;
171
	}
175
	}
Line -... Line 176...
-
 
176
	
-
 
177
	private function getStatsPartiel() {
-
 
178
		$stat['combinaison'] = 0;
-
 
179
		$stat['taxon'] = 0;
-
 
180
		foreach ($this->noms as $nom) {
-
 
181
			if ($nom['exclure_taxref'] != '1') {
-
 
182
				$stat['combinaison']++;
-
 
183
				if ($nom['num_nom_retenu'] == $nom['num_nom']) {
-
 
184
					$stat['taxon']++;
-
 
185
				}
-
 
186
			}
-
 
187
		}
-
 
188
		return $stat;
-
 
189
	}
172
	
190
	
173
	private function creerFichiers() {
191
	private function creerFichiers() {
174
		// Respecter l'ordre de traitement : BDNT puis DIFF puis META
192
		// Respecter l'ordre de traitement : BDNT puis DIFF puis META
175
		$donnees =& $this->creerFichierBdnt();
193
		$donnees =& $this->creerFichierBdnt();
176
		$this->creerFichierBdntPartiel($donnees);
194
		$this->creerFichierBdntPartiel($donnees);
Line 376... Line 394...
376
	private function realiserDiff() {
394
	private function realiserDiff() {
377
		$this->chargerTableauChampsModifTypes();
395
		$this->chargerTableauChampsModifTypes();
378
		$this->noms_stat['modification'] = 0;
396
		$this->noms_stat['modification'] = 0;
Line 379... Line 397...
379
		
397
		
-
 
398
		$diff = array();
380
		$diff = array();
399
		$i = 0;
381
		foreach ($this->noms as $id => $nom) {
400
		foreach ($this->noms as $id => $nom) {
382
			$this->noms[$id] = null;
401
			$this->noms[$id] = null;
383
			$infos = array();
402
			$infos = array();
384
			if (!isset($this->noms_precedents[$id])) {
403
			if (!isset($this->noms_precedents[$id])) {
385
				$infos = $this->traiterDiffAjout($nom);
404
				$infos = $this->traiterDiffAjout($nom);
386
			} else {
405
			} else {
387
				$nom_precedent = $this->noms_precedents[$id];
406
				$nom_precedent = $this->noms_precedents[$id];
-
 
407
				$this->noms_precedents[$id] = null;
388
				$this->noms_precedents[$id] = null;
408
				array_walk($nom_precedent, create_function('&$val', '$val = trim($val);')); 
389
				$infos = $this->traiterDiffModif($nom, $nom_precedent);
409
				$infos = $this->traiterDiffModif($nom, $nom_precedent);
-
 
410
			}
-
 
411
			if ($nom['exclure_taxref'] == '1') {
-
 
412
				$this->exclure_taxref[] = $id;
Line 390... Line 413...
390
			}
413
			}
391
			
414
			
392
			if (count($infos) > 0) {
415
			if (count($infos) > 0) {
393
				$infos = $this->remplacerTabulation($infos);
416
				$infos = $this->remplacerTabulation($infos);
394
				$infos = $this->remplacerSautsDeLigne($infos);
417
				$infos = $this->remplacerSautsDeLigne($infos);
395
				$diff[$id] = $infos;
418
				$diff[$id] = $infos;
-
 
419
			}
-
 
420
		}
396
			}
421
		$this->verifierLignesSupprimees();
397
		}
422
		
Line -... Line 423...
-
 
423
		return $diff;
-
 
424
	}
-
 
425
	
-
 
426
	private function verifierLignesSupprimees() {
-
 
427
		$e = count($this->noms_precedents)." lignes ont été supprimées vis à vis de la version ".
-
 
428
			"précédentes. Cela concerne les noms : ".implode(', ', array_keys($this->noms_precedents));
398
		return $diff;
429
		$this->ajouterMessage($e);
399
	}
430
	} 
400
	
431
	
401
	private function traiterDiffAjout(&$nom) {
432
	private function traiterDiffAjout(&$nom) {
402
		$infos = $nom;
433
		$infos = $nom;
Line 408... Line 439...
408
		return $infos;
439
		return $infos;
409
	}
440
	}
Line 410... Line 441...
410
	
441
	
411
	private function traiterDiffModif(&$nom, &$nom_precedent) {
442
	private function traiterDiffModif(&$nom, &$nom_precedent) {
412
		$infos = array();
443
		$infos = array();
-
 
444
		$nom_diff = array_diff_assoc($nom, $nom_precedent);
413
		$nom_diff = array_diff_assoc($nom, $nom_precedent);		$bdnt_partielle_tsv = 'trest';
445
		
414
		if (count($nom_diff) > 0) {
446
		if (count($nom_diff) > 0) {
415
			$modif['modification_type'] = 'M';
447
			$modif['modification_type'] = 'M';
416
			$modif['modification_type_1'] = '0';
448
			$modif['modification_type_1'] = '0';
417
			$modif['modification_type_2'] = '0';
449
			$modif['modification_type_2'] = '0';
Line 418... Line 450...
418
			$modif['modification_type_3'] = '0';
450
			$modif['modification_type_3'] = '0';
419
			
451
			
-
 
452
			foreach ($this->champs_nom as $champ) {
420
			foreach ($this->champs_nom as $champ) {
453
				if (isset($nom_diff[$champ])) {
421
				if (isset($nom_diff[$champ])) {
454
					// Si le champ modifié est vide nous retournons le mot clé "NULL" pour identifier le champ modifié
422
					$infos[$champ] = $nom_diff[$champ];
455
					$infos[$champ] = ($nom_diff[$champ] != '') ? $nom_diff[$champ] : 'NULL';
423
					$type = $this->getDiffType($champ);
456
					$type = $this->getDiffType($champ);
424
					$modif['modification_type_'.$type] = '1';
457
					$modif['modification_type_'.$type] = '1';
425
				} else {
458
				} else {
Line 461... Line 494...
461
			$this->ajouterMessage("Écriture du fichier diff réussie.");
494
			$this->ajouterMessage("Écriture du fichier diff réussie.");
462
		}
495
		}
463
	}
496
	}
Line 464... Line 497...
464
	
497
	
-
 
498
	private function creerFichierDiffPartiel(&$donnees) {
465
	private function creerFichierDiffPartiel(&$donnees) {
499
		$this->noms_stat_partiel['modification'] = 0;
-
 
500
		if (count($donnees) > 0 && count($donnees['diff']) > 0) {
-
 
501
			foreach ($donnees['diff'] as $id => $nom) {
-
 
502
				if (!in_array($id, $this->exclure_taxref)) {
-
 
503
					if ($nom['modification_type'] == 'A') {
-
 
504
						$donnees['diff_partiel'][$id] = $nom;
-
 
505
					} else {
-
 
506
						foreach ($nom as $champ => $valeur) {
-
 
507
							$ok = false;
-
 
508
							if ($valeur != '' && $champ != 'num_nom' && in_array($champ, $this->champs_nom_partiel)) {
-
 
509
								$donnees['diff_partiel'][$id] = $nom;
-
 
510
								Debug::printr($id.":".$champ."/".$valeur);
-
 
511
								break;
-
 
512
							}
-
 
513
						}
-
 
514
					}
-
 
515
					if (array_key_exists($id, $donnees['diff_partiel'])) {
-
 
516
						$this->noms_stat_partiel['modification']++;
-
 
517
					}
-
 
518
				}
-
 
519
				unset($donnees['diff'][$id]);
466
		if (count($donnees) > 0) {
520
			}
467
			$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff);
521
			$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff);
468
			$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']);
522
			$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']);
469
			$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv');
523
			$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv');
470
			$this->ecrireFichierDiffPartiel($diff_tsv_partiel);
524
			$this->ecrireFichierDiffPartiel($diff_tsv_partiel);
Line 504... Line 558...
504
		}
558
		}
505
	}
559
	}
Line 506... Line 560...
506
	
560
	
507
	private function creerFichierMetaPartiel(&$donnees) {
561
	private function creerFichierMetaPartiel(&$donnees) {
-
 
562
		$donnees['signature'] = $this->signature_md5_partiel;
-
 
563
		$donnees['stats'] = $this->noms_stat_partiel;
508
		$donnees['signature'] = $this->signature_md5_partiel;
564
		$donnees['notes'] = trim('Édition partielle. '.$donnees['notes']);
509
		$meta_tsv_partiel =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
565
		$meta_tsv_partiel =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
510
		$this->ecrireFichierMetaPartiel($meta_tsv_partiel);
566
		$this->ecrireFichierMetaPartiel($meta_tsv_partiel);
Line 511... Line 567...
511
	}
567
	}