Subversion Repositories eFlore/Applications.moissonnage

Rev

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

Rev 26 Rev 31
Line 10... Line 10...
10
	private $verificateur;
10
	private $verificateur;
11
	private $parametresRecherche;
11
	private $parametresRecherche;
Line 12... Line 12...
12
	
12
	
13
	
-
 
14
	public function consulter($ressources, $parametres) {
13
	
15
		
14
	public function consulter($ressources, $parametres) {
16
		$this->recupererRessourcesEtParametres($ressources, $parametres);
-
 
17
		$retour = null;
15
		$this->recupererRessourcesEtParametres($ressources, $parametres);
18
		
16
		$retour = null;
19
		try {
17
		try {
20
			if (!$this->verifierExistenceSourcesDonnees()) {
18
			if (!$this->verifierExistenceSourcesDonnees()) {
21
				$message = "Source de donnees indisponible";
19
				$message = "Source de donnees indisponible";
22
				throw new Exception($message, RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
-
 
23
			} else {
20
				throw new Exception($message, RestServeur::HTTP_CODE_RESSOURCE_INTROUVABLE);
24
				$this->chargerNomSource();
21
			} else {
25
				$this->verifierParametres();
22
				$this->verifierParametres();
-
 
23
				if ($this->ressources[0] == 'mailles') {
-
 
24
					$retour = $this->recupererMaillage();
26
				$this->chargerNomService();
25
				} else {
27
				$objetTraitement = new $this->nomService($this->parametresRecherche);
26
					$this->chargerNomSource();
-
 
27
					$this->chargerNomService();
28
				$methode = $this->genererNomMethodeAExecuter();
28
					$retour = $this->executerServicePourSource();
29
				$retour = $objetTraitement->$methode();
-
 
30
			}
29
				}
31
			
30
			}
32
		} catch (Exception $erreur) {
31
		} catch (Exception $erreur) {
33
			$retour = $erreur; 
-
 
34
		}
32
			$retour = $erreur; 
35
		
33
		}
Line 36... Line 34...
36
		return $retour;
34
		return $retour;
37
	}
35
	}
38
	
36
	
39
	private function recupererRessourcesEtParametres($ressources, $parametres) {
37
	private function recupererRessourcesEtParametres($ressources, $parametres) {
Line 40... Line -...
40
		$this->ressources = $ressources;
-
 
41
		$this->parametres = $parametres;
-
 
42
	}
-
 
43
	
-
 
44
	private function chargerNomService() {
-
 
45
		$this->nomService = ucfirst($this->parametres['source']) . 'Formateur';
-
 
46
		Projets::chargerConfigurationSource($this->parametres['source']);
-
 
47
	}
-
 
48
	
-
 
49
	private function genererNomMethodeAExecuter() {
38
		$this->ressources = $ressources;
50
		return 'recuperer' . ucfirst($this->ressources[0]);
39
		$this->parametres = $parametres;
51
	}
40
	}
52
	
41
	
53
	private function verifierExistenceSourcesDonnees() {
42
	private function verifierExistenceSourcesDonnees() {
Line 62... Line 51...
62
			$estDisponible = true;
51
			$estDisponible = true;
63
		}
52
		}
64
		return $estDisponible;
53
		return $estDisponible;
65
	}
54
	}
Line 66... Line -...
66
	
-
 
67
	private function chargerNomSource() {
-
 
68
		if (isset($this->parametres['source'])) {
-
 
69
			$this->nomSource = $this->parametres['source'];
-
 
70
		} else {
-
 
71
			$this->nomSource = Config::get('source_defaut');
-
 
72
		}
-
 
73
	}
-
 
74
	
55
	
75
	private function verifierParametres() {
56
	private function verifierParametres() {
76
		$this->verificateur = new VerificateurParametres($this->parametres);
57
		$this->verificateur = new VerificateurParametres($this->parametres);
77
		$this->verificateur->verifierParametres();
58
		$this->verificateur->verifierParametres();
78
		if ($this->verificateur->contientErreurs()) {
59
		if ($this->verificateur->contientErreurs()) {
Line 84... Line 65...
84
	
65
	
85
	private function recupererParametresRecherche() {
66
	private function recupererParametresRecherche() {
86
		$this->parametresRecherche = $this->verificateur->renvoyerResultatVerification();
67
		$this->parametresRecherche = $this->verificateur->renvoyerResultatVerification();
Line -... Line 68...
-
 
68
	}
-
 
69
	
-
 
70
	private function chargerNomSource() {
-
 
71
		if (isset($this->parametres['source'])) {
-
 
72
			$this->nomSource = $this->parametres['source'];
-
 
73
		} else {
-
 
74
			$this->nomSource = Config::get('source_defaut');
-
 
75
		}
-
 
76
	}
-
 
77
	
-
 
78
	private function chargerNomService() {
-
 
79
		$this->nomService = ucfirst($this->parametres['source']) . 'Formateur';
-
 
80
		Projets::chargerConfigurationSource($this->parametres['source']);
-
 
81
	}
-
 
82
	
-
 
83
	private function recupererMaillage() {
-
 
84
		$maillage = new Maillage($this->parametresRecherche->bbox, $this->parametresRecherche->zoom);
-
 
85
		$maillage->genererMaillesVides();
-
 
86
		$formateurJSON = new FormateurJson();
-
 
87
		return $formateurJSON->formaterMaillesVides($maillage->formaterSortie(true));
-
 
88
	}
-
 
89
	
-
 
90
	private function executerServicePourSource() {
-
 
91
		$objetTraitement = new $this->nomService($this->parametresRecherche);
-
 
92
		$methode = $this->genererNomMethodeAExecuter();
-
 
93
		return $objetTraitement->$methode();
-
 
94
	}
-
 
95
	
-
 
96
	private function genererNomMethodeAExecuter() {
Line 87... Line 97...
87
	}
97
		return 'recuperer' . ucfirst($this->ressources[0]);
Line 88... Line 98...
88
	
98
	}
89
	
99