Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 516 Rev 517
Line 26... Line 26...
26
	private $champs_ontologiques = array();
26
	private $champs_ontologiques = array();
27
	private $requete_condition = "";
27
	private $requete_condition = "";
28
	private $format_reponse = 'informations';
28
	private $format_reponse = 'informations';
29
	private $champs_recherches = '*';
29
	private $champs_recherches = '*';
30
	protected $serviceNom = 'informations';
30
	protected $serviceNom = 'informations';
-
 
31
	private $retour_format = 'max';
Line 31... Line 32...
31
	
32
	
32
	public function consulter($ressources, $parametres) {
33
	public function consulter($ressources, $parametres) {
33
		$this->ressources = $ressources;
34
		$this->ressources = $ressources;
Line 80... Line 81...
80
							.' ve_humidite_edaph_min, ve_humidite_edaph_max, ve_reaction_sol_min,'
81
							.' ve_humidite_edaph_min, ve_humidite_edaph_max, ve_reaction_sol_min,'
81
							.' ve_reaction_sol_max, ve_nutriments_sol_min, ve_nutriments_sol_max,'
82
							.' ve_reaction_sol_max, ve_nutriments_sol_min, ve_nutriments_sol_max,'
82
							.' ve_salinite_min, ve_salinite_max, ve_texture_sol_min,ve_texture_sol_max,'
83
							.' ve_salinite_min, ve_salinite_max, ve_texture_sol_min,ve_texture_sol_max,'
83
							.' ve_mat_org_sol_min, ve_mat_org_sol_max ';
84
							.' ve_mat_org_sol_min, ve_mat_org_sol_max ';
84
						} else {
85
						} else {
85
							$e = 'Les données recherchées sont introuvables pour ce numero nomenclatural. ';
86
							$e = "Valeur de paramètre inconnue pour 'categorie'.";
86
							$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
87
							$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
87
						}
88
						}
88
						break;
89
						break;
-
 
90
					case 'retour.format'  :
-
 
91
						if ($valeur == 'min' || $valeur == 'max') {
-
 
92
							$this->retour_format = $valeur;
-
 
93
							break;
-
 
94
						} else {
-
 
95
							$e = "Valeur de paramètre inconnue pour 'retour.format'.";
-
 
96
							$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);
-
 
97
						}
89
					default :
98
					default :
90
						$e = 'Erreur dans les parametres de votre requête : </br> Le paramètre " '
99
						$e = 'Erreur dans les parametres de votre requête : </br> Le paramètre " '
91
					.$param.' " n\'existe pas.';
100
					.$param.' " n\'existe pas.';
92
					$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);	break;
101
					$this->renvoyerErreur(RestServeur::HTTP_CODE_MAUVAISE_REQUETE, $e);	break;
93
				}
102
				}
Line 120... Line 129...
120
	//+--------------------------formatages de resultats  -------------------------------------------+
129
	//+--------------------------formatages de resultats  -------------------------------------------+
Line 121... Line 130...
121
	
130
	
122
	
131
	
-
 
132
	public function retournerResultatFormate($resultat) {
123
	public function retournerResultatFormate($resultat) {
133
		$resultat_json = $resultat[0];
-
 
134
		if ($this->retour_format == 'max') {
124
		$resultat_json = $resultat[0];
135
			$this->champs_ontologiques = $this->recupererTableauConfig('champs_ontologiques');
125
		$this->champs_ontologiques = $this->recupererTableauConfig('champs_ontologiques');
136
			$graphique_presence = false;
-
 
137
			foreach ($this->champs_ontologiques as $cle => $valeur){
126
		foreach ($this->champs_ontologiques as $cle => $valeur){
138
				if ($resultat_json[$cle.'_min'] != ""){
127
			if ($resultat_json[$cle.'_min'] != ""){
139
					$graphique_presence = true;
-
 
140
					$tab_ontologie = $this->recupererOntologies($resultat_json[$cle.'_min'], $cle.'_min');
-
 
141
					unset($resultat_json[$cle.'_min']);
-
 
142
					$resultat_json= array_merge($resultat_json,$tab_ontologie);
-
 
143
				}
-
 
144
				if ($resultat_json[$cle.'_max'] != ""){
128
				$tab_ontologie = $this->recupererOntologies($resultat_json[$cle.'_min'], $cle.'_min');
145
					$tab_ontologie = $this->recupererOntologies($resultat_json[$cle.'_max'], $cle.'_max');
-
 
146
					unset($resultat_json[$cle.'_max']);
129
				unset($resultat_json[$cle.'_min']);
147
					$resultat_json= array_merge($resultat_json,$tab_ontologie);
-
 
148
				}
130
				$resultat_json= array_merge($resultat_json,$tab_ontologie);
149
			}
131
			}
150
			if ($graphique_presence) {
132
			if ($resultat_json[$cle.'_max'] != ""){
151
				$resultat_json['graphique_climat']['libelle'] = 'climat';
133
				$tab_ontologie = $this->recupererOntologies($resultat_json[$cle.'_max'], $cle.'_max');
152
				$resultat_json['graphique_climat']['href'] = $this->ajouterHref('graphiques/climat', strtolower($resultat_json['bdnt']).'.nn:'.$resultat_json['num_nomen']);
134
				unset($resultat_json[$cle.'_max']);
153
				$resultat_json['graphique_sol']['libelle'] = 'sol';
135
				$resultat_json= array_merge($resultat_json,$tab_ontologie);
154
				$resultat_json['graphique_sol']['href'] = $this->ajouterHref('graphiques/sol', strtolower($resultat_json['bdnt']).'.nn:'.$resultat_json['num_nomen']);
136
			}
-
 
137
		}
-
 
138
		$resultat_json['graphique_climat']['libelle'] = 'climat';
-
 
139
		$resultat_json['graphique_climat']['href'] = $this->ajouterHref('graphiques/climat', strtolower($resultat_json['bdnt']).'.nn:'.$resultat_json['num_nomen']);
-
 
140
		$resultat_json['graphique_sol']['libelle'] = 'sol';
155
			}
Line 141... Line 156...
141
		$resultat_json['graphique_sol']['href'] = $this->ajouterHref('graphiques/sol', strtolower($resultat_json['bdnt']).'.nn:'.$resultat_json['num_nomen']);
156
		}
Line 142... Line 157...
142
		return $resultat_json ;
157
		return $resultat_json ;