Subversion Repositories Applications.referentiel

Rev

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

Rev 175 Rev 176
Line 34... Line 34...
34
	private $tableStructureDao = null;
34
	private $tableStructureDao = null;
35
	private $referentielDao = null;
35
	private $referentielDao = null;
Line 36... Line 36...
36
	
36
	
37
	public function executer() {
37
	public function executer() {
-
 
38
		$this->manuel = parse_ini_file(Config::get('chemin_appli').DS.'..'.DS.'configurations'.DS.'referentiel_v4.1.ini');
38
		$this->manuel = parse_ini_file(Config::get('chemin_appli').DS.'..'.DS.'configurations'.DS.'referentiel_v4.1.ini');
39
		$this->definirConstantes();
Line 39... Line 40...
39
		$this->tests = parse_ini_file($this->getModuleChemin().DS.'configurations'.DS.'tests.ini', true);
40
		$this->tests = parse_ini_file($this->getModuleChemin().DS.'configurations'.DS.'tests.ini', true);
40
		
41
		
41
		$this->resultatDao = new ResultatDao();
42
		$this->resultatDao = new ResultatDao();
Line 79... Line 80...
79
		} else {
80
		} else {
80
			Debug::printr("Aucun dernier traitement trouvé pour le script '".self::SCRIPT_NOM."' !");
81
			Debug::printr("Aucun dernier traitement trouvé pour le script '".self::SCRIPT_NOM."' !");
81
		}
82
		}
82
    }
83
    }
Line -... Line 84...
-
 
84
    
-
 
85
    /**
-
 
86
     * Cette méthode définie des constantes qui peuvent ensuite être utilisée dans les fichier ini.
-
 
87
     * Surtout utile pour le fichier tests.ini
-
 
88
     */
-
 
89
    private function definirConstantes() {
-
 
90
    	define('RANG_GENRE', $this->manuel['rang_genre']);
-
 
91
    	define('RANG_SP', $this->manuel['rang_sp']);
-
 
92
    }
83
    
93
    
84
    public function recupererDonnees() {
94
    public function recupererDonnees() {
85
		// Récupération des données à tester
95
		// Récupération des données à tester
86
		$this->colonnes = $this->tableStructureDao->getColonnes($this->projet);
96
		$this->colonnes = $this->tableStructureDao->getColonnes($this->projet);
87
		$this->analyses = $this->tableStructureDao->getAnalyse($this->projet);
97
		$this->analyses = $this->tableStructureDao->getAnalyse($this->projet);
Line 112... Line 122...
112
    	
122
    	
113
    	// Analyse des résultats
123
    	// Analyse des résultats
114
    	if (isset($erreurs['special'])) {
124
    	if (isset($erreurs['special'])) {
115
    		$info = $erreurs;
125
    		$info = $erreurs;
116
    	} else {
126
    	} else {
117
			if (count($erreurs) > 0) {
127
    		if (count($erreurs) > 0) {
118
				$info['message']['entete'] = explode(',', $info['entete']);
128
				$info['message']['entete'] = explode(',', $info['entete']);
-
 
129
				$info['message']['lignes'] = $erreurs;
119
				$info['message']['lignes'] = $erreurs;
130
				unset($erreurs);
120
			} else {
131
			} else {
121
				$info['resultat'] = true;
132
				$info['resultat'] = true;
122
			}
133
			}
Line 395... Line 406...
395
	
406
	
396
	/**
407
	/**
397
	 * Test #07
408
	 * Test #07
398
	 */
409
	 */
399
	private function testerNumNomRetenuSuperieurAZero() {
-
 
400
		$info = $this->getInfosTest(7);
-
 
401
		
410
	private function testerNumNomRetenuSuperieurAZero() {
402
		// Réalisation du test
411
		// Réalisation du test
403
		$noms_erreur = array();
412
		$noms_erreur = array();
404
		foreach ($this->noms as &$nom) {
413
		foreach ($this->noms as &$nom) {
405
			if ($nom['num_nom_retenu'] != '' && $nom['num_nom_retenu'] <= 0) {
414
			if ($nom['num_nom_retenu'] != '' && $nom['num_nom_retenu'] <= 0) {
406
				$noms_erreur[] = array($nom['num_nom'], $nom['num_nom_retenu']);
415
				$noms_erreur[] = array($nom['num_nom'], $nom['num_nom_retenu']);
407
			}
416
			}
408
		}
-
 
409
		
-
 
410
		// Analyse des résultats
417
		}
411
		if (count($noms_erreur) > 0) {
-
 
412
			$info['message']['entete'] = array('num_nom', 'num_nom_retenu');
-
 
413
			$info['message']['lignes'] = $noms_erreur;
-
 
414
		} else {
-
 
415
			$info['resultat'] = true;
-
 
416
		}
-
 
417
		
-
 
418
		$this->traiterResultatTest($info);
418
		return $noms_erreur;
Line 419... Line 419...
419
	}
419
	}
420
	
420
	
421
	/**
421
	/**
422
	 * Test #08
422
	 * Test #08
423
	 */
-
 
424
	private function testerNumTaxSupEgalZeroUnique() {
-
 
425
		$info = $this->getInfosTest(8);
423
	 */
426
		
424
	private function testerNumTaxSupEgalZeroUnique() {
427
		// Réalisation du test
425
		// Réalisation du test
428
		$noms_erreur = array();
426
		$noms_erreur = array();
429
		foreach ($this->noms as &$nom) {
427
		foreach ($this->noms as &$nom) {
430
			if (preg_match('/^0$/', $nom['num_tax_sup'])) {
428
			if (preg_match('/^0$/', $nom['num_tax_sup'])) {
431
				$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup']);
429
				$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup']);
432
			}
-
 
433
		}
430
			}
434
		
431
		}
435
		// Analyse des résultats
-
 
436
		if (count($noms_erreur) > 1) {
-
 
437
			$info['message']['entete'] = array('num_nom', 'num_tax_sup');
-
 
438
			$info['message']['lignes'] = $noms_erreur;
432
		// Ce test est spécial car le nombre de noms en erreurs doit être supérieur à 1 et non à 0 pour être KO.
439
		} else {
433
		if (count($noms_erreur) == 1) {
440
			$info['resultat'] = true;
-
 
441
		}
434
			$noms_erreur[] = array();
442
		
435
		}
Line 443... Line 436...
443
		$this->traiterResultatTest($info);
436
		return $noms_erreur;
444
	}
437
	}
445
	
438
	
446
	/**
439
	/**
447
	 * Test #09
-
 
448
	 */
-
 
449
	private function testerTaxSupPourTaxon() {
440
	 * Test #09
450
		$info = $this->getInfosTest(9);
441
	 */
451
		
442
	private function testerTaxSupPourTaxon() {
452
		// Réalisation du test
443
		// Réalisation du test
453
		$noms_erreur = array();
444
		$noms_erreur = array();
454
		foreach ($this->noms as &$nom) {
445
		foreach ($this->noms as &$nom) {
455
			if ($nom['num_nom_retenu'] != $nom['num_nom'] && $nom['num_tax_sup'] != '') {
446
			if ($nom['num_nom_retenu'] != $nom['num_nom'] && $nom['num_tax_sup'] != '') {
456
				$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup']); 
-
 
457
			}
-
 
458
		}
447
				$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup']); 
459
		
-
 
460
		// Analyse des résultats
-
 
461
		if (count($noms_erreur) > 0) {
-
 
462
			$info['message']['entete'] = array('num_nom', 'num_tax_sup');
-
 
463
			$info['message']['lignes'] = $noms_erreur;
-
 
464
		} else {
-
 
465
			$info['resultat'] = true;
-
 
466
		}
448
			}
Line 467... Line 449...
467
		
449
		}
468
		$this->traiterResultatTest($info);
450
		return $noms_erreur;
469
	}
451
	}
470
	
452
	
471
	/**
-
 
472
	 * Test #10
-
 
473
	 */
453
	/**
474
	private function testerExitenceTaxonSuperieur() {
454
	 * Test #10
475
		$info = $this->getInfosTest(10);
455
	 */
476
		
456
	private function testerExitenceTaxonSuperieur() {
477
		// Réalisation du test
457
		// Réalisation du test
478
		$noms_erreur = array();
458
		$noms_erreur = array();
479
		foreach ($this->noms as &$nom) {
459
		foreach ($this->noms as &$nom) {
480
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
460
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
481
				if ($nom['num_tax_sup'] != 0 && !isset($this->noms[$nom['num_tax_sup']])) {
461
				if ($nom['num_tax_sup'] != 0 && !isset($this->noms[$nom['num_tax_sup']])) {
482
					$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup']);
-
 
483
				} 
-
 
484
			}
462
					$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup']);
485
		}
-
 
486
		
-
 
487
		// Analyse des résultats
-
 
488
		if (count($noms_erreur) > 0) {
-
 
489
			$info['message']['entete'] = array('num_nom', 'num_tax_sup');
-
 
490
			$info['message']['lignes'] = $noms_erreur;
-
 
491
		} else {
-
 
492
			$info['resultat'] = true;
463
				} 
Line 493... Line 464...
493
		}
464
			}
494
		
465
		}
495
		$this->traiterResultatTest($info);
466
		return $noms_erreur;
496
	}
467
	}
497
	
-
 
498
	/**
-
 
499
	 * Test #11
468
	
500
	 */
469
	/**
501
	private function testerClassificationRang() {
470
	 * Test #11
502
		$info = $this->getInfosTest(11);
471
	 */
503
		
472
	private function testerClassificationRang() {
Line 514... Line 483...
514
						}
483
						}
515
					}
484
					}
516
				}
485
				}
517
			}
486
			}
518
		}
487
		}
519
		
-
 
520
		// Analyse des résultats
-
 
521
		if (count($noms_erreur) > 0) {
488
		return $noms_erreur;
522
			$info['message']['entete'] = array('num_nom', 'rang', 'Taxon supérieur num_nom', 'Taxon supérieur rang');
-
 
523
			$info['message']['lignes'] = $noms_erreur;
-
 
524
		} else {
-
 
525
			$info['resultat'] = true;
-
 
526
		}
-
 
527
		
-
 
528
		$this->traiterResultatTest($info);
-
 
529
	}
489
	}
Line 530... Line 490...
530
	
490
	
531
	/**
491
	/**
532
	 * Test #12
492
	 * Test #12
533
	 */
493
	 */
534
	private function testerClassification() {
-
 
535
		$info = $this->getInfosTest(12);
-
 
536
		
494
	private function testerClassification() {
537
		// Réalisation du test
495
		// Réalisation du test
538
		$noms_erreur = array();
496
		$noms_erreur = array();
539
		$this->noms_ok = array();
497
		$this->noms_ok = array();
540
		foreach ($this->noms as &$nom) {
498
		foreach ($this->noms as &$nom) {
Line 553... Line 511...
553
					}
511
					}
554
				}
512
				}
555
			}
513
			}
556
		}
514
		}
557
		unset($this->noms_ok);
515
		unset($this->noms_ok);
558
		
-
 
559
		// Analyse des résultats
-
 
560
		if (count($noms_erreur) > 0) {
516
		return $noms_erreur;
561
			$info['message']['entete'] = array('num_nom', 'Message du problème');
-
 
562
			$info['message']['lignes'] = $noms_erreur;
-
 
563
		} else {
-
 
564
			$info['resultat'] = true;
-
 
565
		}
-
 
566
		
-
 
567
		$this->traiterResultatTest($info);
-
 
568
	}
517
	}
Line 569... Line 518...
569
	
518
	
570
	private function remonterClassif(&$nom) {
519
	private function remonterClassif(&$nom) {
571
		$this->detection_boucle_infini[$nom['num_nom']] = true;
520
		$this->detection_boucle_infini[$nom['num_nom']] = true;
Line 594... Line 543...
594
	
543
	
595
	/**
544
	/**
596
	 * Test #13
545
	 * Test #13
597
	 */
546
	 */
598
	private function testerRang() {
-
 
599
		$info = $this->getInfosTest(13);
-
 
600
		
547
	private function testerRang() {
Line 601... Line 548...
601
		$rangs = array_flip(explode(',', $this->manuel['rangs']));
548
		$rangs = array_flip(explode(',', $this->manuel['rangs']));
602
		
549
		
603
		// Réalisation du test
550
		// Réalisation du test
604
		$noms_erreur = array();
551
		$noms_erreur = array();
605
		foreach ($this->noms as &$nom) {
552
		foreach ($this->noms as &$nom) {
606
			if (!isset($rangs[$nom['rang']])) {
553
			if (!isset($rangs[$nom['rang']])) {
607
				$noms_erreur[] = array($nom['num_nom'], $nom['rang']);
554
				$noms_erreur[] = array($nom['num_nom'], $nom['rang']);
608
			}
-
 
609
		}
-
 
610
		
555
			}
611
		// Analyse des résultats
-
 
612
		if (count($noms_erreur) > 0) {
-
 
613
			$info['message']['entete'] = array('num_nom', 'Rang');
-
 
614
			$info['message']['lignes'] = $noms_erreur;
-
 
615
		} else {
-
 
616
			$info['resultat'] = true;
-
 
617
		}
-
 
618
		
556
		}
Line 619... Line 557...
619
		$this->traiterResultatTest($info);
557
		return $noms_erreur;
620
	}
558
	}
621
	
559
	
622
	/**
560
	/**
623
	 * Test #14
-
 
624
	 */
-
 
625
	private function testerNomCompletSupraGenerique() {
-
 
626
		$info = $this->getInfosTest(14);
561
	 * Test #14
627
		$info['description'] = sprintf($info['description'], $this->manuel['rang_genre']);
562
	 */
628
		
563
	private function testerNomCompletSupraGenerique() {
629
		// Réalisation du test
564
		// Réalisation du test
630
		$noms_erreur = array();
565
		$noms_erreur = array();
Line 637... Line 572...
637
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
572
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
638
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
573
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
639
				}
574
				}
640
			}
575
			}
641
		}
576
		}
642
		
-
 
643
		// Analyse des résultats
-
 
644
		if (count($noms_erreur) > 0) {
577
		return $noms_erreur;
645
			$info['message']['entete'] = array('num_nom', 'nom_sci', 'nom_sci corrigé');
-
 
646
			$info['message']['lignes'] = $noms_erreur;
-
 
647
		} else {
-
 
648
			$info['resultat'] = true;
-
 
649
		}
-
 
650
		
-
 
651
		$this->traiterResultatTest($info);
-
 
652
	}
578
	}
Line 653... Line 579...
653
	
579
	
654
	/**
580
	/**
655
	 * Test #15
581
	 * Test #15
656
	 */
582
	 */
657
	private function testerNomCompletGenre() {
-
 
658
		$info = $this->getInfosTest(15);
-
 
659
		$info['description'] = sprintf($info['description'], $this->manuel['rang_genre']);
-
 
660
		
583
	private function testerNomCompletGenre() {
661
		// Réalisation du test
584
		// Réalisation du test
662
		$noms_erreur = array();
585
		$noms_erreur = array();
663
		foreach ($this->noms as &$nom) {
586
		foreach ($this->noms as &$nom) {
664
			if ($nom['rang'] == $this->manuel['rang_genre']) {
587
			if ($nom['rang'] == $this->manuel['rang_genre']) {
Line 669... Line 592...
669
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
592
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
670
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
593
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
671
				}
594
				}
672
			}
595
			}
673
		}
596
		}
674
		
-
 
675
		// Analyse des résultats
-
 
676
		if (count($noms_erreur) > 0) {
597
		return $noms_erreur;
677
			$info['message']['entete'] = array('num_nom', 'nom_sci', 'nom_sci corrigé');
-
 
678
			$info['message']['lignes'] = $noms_erreur;
-
 
679
		} else {
-
 
680
			$info['resultat'] = true;
-
 
681
		}
-
 
682
		
-
 
683
		$this->traiterResultatTest($info);
-
 
684
	}
598
	}
Line 685... Line 599...
685
	
599
	
686
	/**
600
	/**
687
	 * Test #16
601
	 * Test #16
688
	 */
602
	 */
689
	private function testerNomCompletInfraGenre() {
-
 
690
		$info = $this->getInfosTest(16);
-
 
691
		$info['description'] = sprintf($info['description'], $this->manuel['rang_genre'], $this->manuel['rang_sp']);
-
 
692
		
603
	private function testerNomCompletInfraGenre() {
693
		// Réalisation du test
604
		// Réalisation du test
694
		$noms_erreur = array();
605
		$noms_erreur = array();
695
		foreach ($this->noms as &$nom) {
606
		foreach ($this->noms as &$nom) {
696
			if ($nom['rang'] > $this->manuel['rang_genre'] && $nom['rang'] < $this->manuel['rang_sp']) {
607
			if ($nom['rang'] > $this->manuel['rang_genre'] && $nom['rang'] < $this->manuel['rang_sp']) {
Line 710... Line 621...
710
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
621
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
711
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
622
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
712
				}
623
				}
713
			}
624
			}
714
		}
625
		}
715
		
-
 
716
		// Analyse des résultats
-
 
717
		if (count($noms_erreur) > 0) {
-
 
718
			$info['message']['entete'] = array('num_nom', 'nom_sci', 'nom_sci corrigé');
-
 
719
			$info['message']['lignes'] = $noms_erreur;
-
 
720
		} else {
-
 
721
			$info['resultat'] = true;
-
 
722
		}
-
 
723
		$noms_erreur = null;
626
		return $noms_erreur;
724
		
-
 
725
		$this->traiterResultatTest($info);
-
 
726
	}
627
	}
Line 727... Line 628...
727
	
628
	
728
	/**
629
	/**
729
	 * Test #17
630
	 * Test #17
730
	 */
631
	 */
731
	private function testerNomCompletEspece() {
-
 
732
		$info = $this->getInfosTest(17);
-
 
733
		$info['description'] = sprintf($info['description'], $this->manuel['rang_sp']);
-
 
734
		
632
	private function testerNomCompletEspece() {
735
		// Réalisation du test
633
		// Réalisation du test
736
		$noms_erreur = array();
634
		$noms_erreur = array();
737
		foreach ($this->noms as &$nom) {
635
		foreach ($this->noms as &$nom) {
738
			if ($nom['rang'] == $this->manuel['rang_sp']) {
636
			if ($nom['rang'] == $this->manuel['rang_sp']) {
Line 744... Line 642...
744
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
642
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
745
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
643
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
746
				}
644
				}
747
			}
645
			}
748
		}
646
		}
749
		
-
 
750
		// Analyse des résultats
-
 
751
		if (count($noms_erreur) > 0) {
-
 
752
			$info['message']['entete'] = array('num_nom', 'nom_sci', 'nom_sci corrigé');
-
 
753
			$info['message']['lignes'] = $noms_erreur;
-
 
754
		} else {
-
 
755
			$info['resultat'] = true;
-
 
756
		}
-
 
757
		$noms_erreur = null;
647
		return $noms_erreur;
758
		
-
 
759
		$this->traiterResultatTest($info);
-
 
760
	}
648
	}
Line 761... Line 649...
761
	
649
	
762
	/**
650
	/**
763
	 * Test #18
651
	 * Test #18
764
	 */
652
	 */
765
	private function testerNomCompletInfraSpecifique() {
-
 
766
		$info = $this->getInfosTest(18);
-
 
767
		$info['description'] = sprintf($info['description'], $this->manuel['rang_sp']);
-
 
768
		
653
	private function testerNomCompletInfraSpecifique() {
769
		// Réalisation du test
654
		// Réalisation du test
770
		$noms_erreur = array();
655
		$noms_erreur = array();
771
		foreach ($this->noms as &$nom) {
656
		foreach ($this->noms as &$nom) {
772
			if ($nom['rang'] > $this->manuel['rang_sp']) {
657
			if ($nom['rang'] > $this->manuel['rang_sp']) {
Line 780... Line 665...
780
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
665
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
781
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
666
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal);
782
				}
667
				}
783
			}
668
			}
784
		}
669
		}
785
		
-
 
786
		// Analyse des résultats
-
 
787
		if (count($noms_erreur) > 0) {
-
 
788
			$info['message']['entete'] = array('num_nom', 'nom_sci', 'nom_sci corrigé');
-
 
789
			$info['message']['lignes'] = $noms_erreur;
-
 
790
		} else {
-
 
791
			$info['resultat'] = true;
-
 
792
		}
-
 
793
		$noms_erreur = null;
670
		return $noms_erreur;
794
		
-
 
795
		$this->traiterResultatTest($info);
-
 
796
	}
671
	}
Line 797... Line 672...
797
	
672
	
798
	/**
673
	/**
799
	 * Test #19
674
	 * Test #19
800
	 */
675
	 */
801
	private function testerNomSupraGeneriqueEspaces() {
-
 
802
		$info = $this->getInfosTest(19);
-
 
803
		
676
	private function testerNomSupraGeneriqueEspaces() {
804
		// Réalisation du test
677
		// Réalisation du test
805
		$noms_erreur = array();
678
		$noms_erreur = array();
806
		foreach ($this->noms as &$nom) {
679
		foreach ($this->noms as &$nom) {
807
			if ($nom['nom_supra_generique'] != '') {
680
			if ($nom['nom_supra_generique'] != '') {
808
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s+$)/', $nom['nom_supra_generique'])) {
681
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s+$)/', $nom['nom_supra_generique'])) {
809
					$nom_supra_generique_traite = $this->repererEspace($nom['nom_supra_generique']);
682
					$nom_supra_generique_traite = $this->repererEspace($nom['nom_supra_generique']);
810
					$noms_erreur[] = array($nom['num_nom'], $nom_supra_generique_traite);
683
					$noms_erreur[] = array($nom['num_nom'], $nom_supra_generique_traite);
811
				}
684
				}
812
			}
685
			}
813
		}
-
 
814
		
-
 
815
		// Analyse des résultats
-
 
816
		if (count($noms_erreur) > 0) {
-
 
817
			$info['message']['entete'] = array('num_nom', 'nom_supra_generique erroné');
-
 
818
			$info['message']['lignes'] = $noms_erreur;
-
 
819
		} else {
-
 
820
			$info['resultat'] = true;
-
 
821
		}
686
		}
822
		$noms_erreur = null;
-
 
823
		
-
 
824
		$this->traiterResultatTest($info);
687
		return $noms_erreur;
Line 825... Line 688...
825
	}
688
	}
826
	
689
	
827
	/**
690
	/**