Subversion Repositories eFlore/Applications.coel-consultation

Rev

Rev 172 | Rev 193 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 172 Rev 180
Line 4... Line 4...
4
 * Modèle d'accès à la base de données des Collections pour la Recherche
4
 * Modèle d'accès à la base de données des Collections pour la Recherche
5
 *
5
 *
6
 * @package		Collection
6
 * @package		Collection
7
 * @category	php5
7
 * @category	php5
8
 * @author		aurelien <aurelien@tela-botanica.org>
8
 * @author		aurelien <aurelien@tela-botanica.org>
-
 
9
 * @author		mathias <mathias@tela-botanica.org>
9
 * @copyright	2010 Tela-Botanica
10
 * @copyright	2010 Tela-Botanica
10
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @version		SVN: $Id: RechercheDao.php 172 2011-03-15 14:59:57Z delphine $
13
 * @version		SVN: $Id: RechercheDao.php 180 2013-12-20 10:29:51Z mathias $
13
 *
14
 *
14
 */
15
 */
15
class RechercheDao extends Dao {
16
class RechercheDao extends Dao {
16
	const SERVICE = 'CoelRecherche';
17
	const SERVICE = 'CoelRecherche';
Line 17... Line -...
17
	
-
 
18
	/**
18
 
19
	 * Recherche une collection en fonction de paramêtres
-
 
20
	 * @return array un tableau contenant des objets d'informations sur les collections
-
 
21
	 */
19
	/** @deprecated retro-compatibilité */
-
 
20
	public function chercherStructureNbre($parametres) {
-
 
21
		return $this->chercherCollectionsNbre($parametres);
-
 
22
	}
-
 
23
	/** @deprecated retro-compatibilité */
-
 
24
	public function chercher($parametres) {
-
 
25
   		return $this->chercherCollections($parametres);
-
 
26
	}
-
 
27
 
-
 
28
	// recherche du nombre de collections : nouveau
22
   public function chercherStructureNbre($parametres) {
29
	public function chercherCollectionsNbre($parametres) {
23
		$url = $this->construireUrlRecherche('Nombre', $parametres, false);
30
		$url = $this->construireUrlRechercheCollections('NombreCollections', $parametres, false);
24
		$json = $this->envoyerRequeteConsultation($url);
31
   		$json = $this->envoyerRequeteConsultation($url);
-
 
32
   		$donnees = json_decode($json, true);
25
		$donnees = json_decode($json);
33
 
26
		return $donnees;
34
		return $donnees;
Line 27... Line -...
27
	}
-
 
28
	
35
	}
-
 
36
 
29
	/**
37
	// recherche du nombre de personnes : nouveau
-
 
38
	public function chercherPersonnesNbre($parametres) {
-
 
39
		$url = $this->construireUrlRecherchePersonnes('NombrePersonnes', $parametres, false);
-
 
40
   		$json = $this->envoyerRequeteConsultation($url);
-
 
41
   		$donnees = json_decode($json, true);
30
	 * Recherche une collection en fonction de paramêtres
42
 
-
 
43
		return $donnees;
-
 
44
	}
31
	 * @return array un tableau contenant des objets d'informations sur les collections
45
 
32
	 */
46
	// recherche de collections : nouveau 
33
   public function chercher($parametres) {
47
	public function chercherCollections($parametres) {
34
		$url = $this->construireUrlRecherche('ParDefaut', $parametres);
48
		$url = $this->construireUrlRechercheCollections('Collections', $parametres);
Line 35... Line 49...
35
   		$json = $this->envoyerRequeteConsultation($url);
49
   		$json = $this->envoyerRequeteConsultation($url);
36
   		$donnees = json_decode($json, true);
50
   		$donnees = json_decode($json, true);
Line -... Line 51...
-
 
51
 
-
 
52
		return $donnees;
-
 
53
	}
-
 
54
 
-
 
55
	// recherche de personnes : nouveau 
-
 
56
	public function chercherPersonnes($parametres) {
-
 
57
		$url = $this->construireUrlRecherchePersonnes('Personnes', $parametres);
-
 
58
   		$json = $this->envoyerRequeteConsultation($url);
-
 
59
   		$donnees = json_decode($json, true);
-
 
60
 
-
 
61
		return $donnees;
-
 
62
	}
-
 
63
 
-
 
64
	// construit l'URL du service CoelRecherche pour obtenir des collections
-
 
65
	// Attention au nombre et à l'ordre des paramètres !
-
 
66
	private function construireUrlRechercheCollections($type, $parametres, $limitation = true) {
-
 
67
		return $this->construireUrlRecherche(
-
 
68
			$type,
-
 
69
			$parametres,
-
 
70
			$limitation,
-
 
71
			array('mots', 'sci', 'bot', 'lieu-stockage', 'zg', 'p', 'pr', 'str-d', 'veg', 'projets')
-
 
72
		);
37
		
73
	}
-
 
74
 
-
 
75
	// construit l'URL du service CoelRecherche pour obtenir des personnes
-
 
76
	// Attention au nombre et à l'ordre des paramètres !
-
 
77
	private function construireUrlRecherchePersonnes($type, $parametres, $limitation = true) {
-
 
78
		return $this->construireUrlRecherche(
-
 
79
			$type,
-
 
80
			$parametres,
-
 
81
			$limitation,
-
 
82
			array('nom-famille', 'adresse', 'date-vivant')
-
 
83
		);
-
 
84
	}
-
 
85
 
38
		return $donnees;
86
	// fabrique une URL pour le service CoelRecherche en collant les paramètres fournis (sinon "*")
Line 39... Line -...
39
   }
-
 
40
   
87
	// dans l'ordre attendu par le service demandé ($type)
41
   private function construireUrlRecherche($type, $parametres, $limitation = true) {
88
	private function construireUrlRecherche($type, $parametres, $limitation, $paramsAPasser) {
42
   		$url = $this->url_jrest.self::SERVICE.'/'.$type;
89
 
43
		
90
		$url = $this->url_jrest . self::SERVICE . '/' . $type;
44
		$params_a_passer = array('mots', 'sci', 'bot', 'zg', 'p', 'pr', 'str-d', 'veg', 'projets');
91
 
45
		foreach ($params_a_passer as $param_cle) {
92
		foreach ($paramsAPasser as $param_cle) {