Subversion Repositories eFlore/Applications.cel

Rev

Rev 79 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 79 Rev 86
1
package org.tela_botanica.client.observation;
1
package org.tela_botanica.client.observation;
2
 
2
 
3
 
3
 
4
//TODO : normaliser les noms de methodes (obtenir, ajouter ...)
4
//TODO : normaliser les noms de methodes (obtenir, ajouter ...)
5
 
5
 
6
import org.tela_botanica.client.interfaces.FournisseurListe;
6
import org.tela_botanica.client.interfaces.FournisseurListe;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
8
import org.tela_botanica.client.modeles.Configuration;
8
import org.tela_botanica.client.modeles.Configuration;
9
import org.tela_botanica.client.modeles.ImageGeneriqueVueAsynchroneDAO;
9
import org.tela_botanica.client.modeles.ImageGeneriqueVueAsynchroneDAO;
10
import org.tela_botanica.client.modeles.ImageInformationRepartitionAsynchroneDAO;
10
import org.tela_botanica.client.modeles.ImageInformationRepartitionAsynchroneDAO;
11
import org.tela_botanica.client.modeles.ListeEntiteGeographiqueObservation;
11
import org.tela_botanica.client.modeles.ListeEntiteGeographiqueObservation;
12
import org.tela_botanica.client.modeles.ListeEntiteGeographiqueObservationAsynchroneDAO;
12
import org.tela_botanica.client.modeles.ListeEntiteGeographiqueObservationAsynchroneDAO;
13
import org.tela_botanica.client.modeles.ListeObservationAsynchroneDAO;
13
import org.tela_botanica.client.modeles.ListeObservationAsynchroneDAO;
14
import org.tela_botanica.client.modeles.ListeReferentielCommuneAsynchroneDAO;
14
import org.tela_botanica.client.modeles.ListeReferentielCommuneAsynchroneDAO;
15
import org.tela_botanica.client.modeles.ListeReferentielNom;
15
import org.tela_botanica.client.modeles.ListeReferentielNom;
16
import org.tela_botanica.client.modeles.ListeReferentielNomAsynchroneDAO;
16
import org.tela_botanica.client.modeles.ListeReferentielNomAsynchroneDAO;
17
import org.tela_botanica.client.modeles.NombreObservationAsynchroneDAO;
17
import org.tela_botanica.client.modeles.NombreObservationAsynchroneDAO;
18
import org.tela_botanica.client.modeles.Observation;
18
import org.tela_botanica.client.modeles.Observation;
19
import org.tela_botanica.client.modeles.ObservationAsynchroneDAO;
19
import org.tela_botanica.client.modeles.ObservationAsynchroneDAO;
20
import org.tela_botanica.client.vues.InformationRepartitionVue;
20
import org.tela_botanica.client.vues.InformationRepartitionVue;
-
 
21
import org.tela_botanica.client.vues.ListeObservationVue;
21
 
22
 
22
import com.google.gwt.user.client.Window;
23
import com.google.gwt.user.client.Window;
23
 
24
 
24
 
25
 
25
public class ObservationModele  {
26
public class ObservationModele  {
26
 
27
 
27
	
28
	
28
	
29
	
29
	/**
30
	/**
30
	 * Booleen indiquant si le médiateur est instancié (l'instance doit être unique donc le booleen est static)
31
	 * Booleen indiquant si le médiateur est instancié (l'instance doit être unique donc le booleen est static)
31
	 */
32
	 */
32
	private static boolean estInstancie = false ;
33
	private static boolean estInstancie = false ;
33
	
34
	
34
	
35
	
35
	/**
36
	/**
36
	 * La configuration en cours
37
	 * La configuration en cours
37
	 */
38
	 */
38
	private Configuration config = null;
39
	private Configuration config = null;
39
 
40
 
40
	
41
	
41
	/**
42
	/**
42
	 * Le médiateur associé au modèle
43
	 * Le médiateur associé au modèle
43
	 */
44
	 */
44
	
45
	
45
	private ObservationMediateur observationMediateur = null ;
46
	private ObservationMediateur observationMediateur = null ;
46
	
47
	
47
	
48
	
48
	
49
	
49
 
50
 
50
	/**
51
	/**
51
	 * Retourne une instance de manière unique
52
	 * Retourne une instance de manière unique
52
	 * @param im le médiateur à associer
53
	 * @param im le médiateur à associer
53
	 * @return l'instance du modèle
54
	 * @return l'instance du modèle
54
	 */
55
	 */
55
	
56
	
56
	static ObservationModele Instance(ObservationMediateur observationMediateur)
57
	static ObservationModele Instance(ObservationMediateur observationMediateur)
57
	{
58
	{
58
		// si le modèle n'est pas encore instancié
59
		// si le modèle n'est pas encore instancié
59
		if(!estInstancie)
60
		if(!estInstancie)
60
		{
61
		{
61
			// on en crée un nouveau
62
			// on en crée un nouveau
62
			estInstancie = true ;
63
			estInstancie = true ;
63
			return new ObservationModele(observationMediateur);
64
			return new ObservationModele(observationMediateur);
64
		}
65
		}
65
		else
66
		else
66
		{
67
		{
67
			// sinon on renvoit null, interdisant explicitement la création d'un autre exemplaire
68
			// sinon on renvoit null, interdisant explicitement la création d'un autre exemplaire
68
			return null ;
69
			return null ;
69
		}
70
		}
70
	}
71
	}
71
 
72
 
72
	
73
	
73
	
74
	
74
	private ObservationModele(ObservationMediateur observationMediateur) {
75
	private ObservationModele(ObservationMediateur observationMediateur) {
75
		
76
		
76
		this.observationMediateur=observationMediateur;
77
		this.observationMediateur=observationMediateur;
77
		
78
		
78
		config = new Configuration();
79
		config = new Configuration();
79
 
80
 
80
		
81
		
81
	}
82
	}
82
 
83
 
83
 
84
 
84
	
85
	
85
	/**
86
	/**
86
	 * Appelle le DAO asynchrone pour obtenir le nombre d'observation
87
	 * Appelle le DAO asynchrone pour obtenir le nombre d'observation
87
	 * @param r le rafraichissable auxquel on enverra les données
88
	 * @param r le rafraichissable auxquel on enverra les données
-
 
89
	 * @param filtrage 
88
	 * @param taillePage 
90
	 * @param taillePage 
89
	 */
91
	 */
90
	public void obtenirNombreObservation(Rafraichissable r) {	
92
	public void obtenirNombreObservation(Rafraichissable r) {	
91
		
93
	
-
 
94
		String[][] criteres = {{"",""}} ;		
92
		 	String motsClesFiltres[][] = observationMediateur.renvoyerFiltres() ;
95
		 	criteres = observationMediateur.renvoyerFiltres() ;			
93
			
-
 
94
			// on rassemble les critères
96
			// on rassemble les critères
95
			String[][] criteres = {{motsClesFiltres[0][0], motsClesFiltres[0][1]} } ;
-
 
96
			
97
			
97
			
98
			
98
			// on les crée un DAO auquel on les transmet et qui demande le nombre d'images correspondantes (pour les pages)
99
			// on les crée un DAO auquel on les transmet et qui demande le nombre d'images correspondantes (pour les pages)
99
			
100
			
100
			NombreObservationAsynchroneDAO noaDAO = new NombreObservationAsynchroneDAO(this) ;
101
			NombreObservationAsynchroneDAO noaDAO = new NombreObservationAsynchroneDAO(this) ;
101
			noaDAO.obtenirNombreObservation(r, observationMediateur.getIdentifiant(), criteres) ;
102
			noaDAO.obtenirNombreObservation(r, observationMediateur.getIdentifiant(), criteres) ;
102
					
103
					
103
	}
104
	}
104
	
105
	
105
	
106
	
106
	/**
107
	/**
107
	 * Appelle le DAO asynchrone pour obtenir la liste des images
108
	 * Appelle le DAO asynchrone pour obtenir la liste des images
108
	 * @param r le rafraichissable auxquel on enverra les données
109
	 * @param r le rafraichissable auxquel on enverra les données
109
	 * @param taillePage 
110
	 * @param taillePage 
110
	 */
111
	 */
111
	public void obtenirListeObservation(Rafraichissable r, int taillePage, int pageEncours) {	
112
	public void obtenirListeObservation(Rafraichissable r, int taillePage, int pageEncours) {	
-
 
113
		
-
 
114
		
112
		
115
		 	String[][] motsClesFiltres = {{"",""}} ;
-
 
116
				motsClesFiltres = observationMediateur.renvoyerFiltres() ;			
113
		 	String motsClesFiltres[][] = observationMediateur.renvoyerFiltres() ;
117
				// on rassemble les critères
114
			
118
			
115
			
119
			
116
			// ensuite on demande la page correspondante avec les mêmes critères
120
			// ensuite on demande la page correspondante avec les mêmes critères
117
			String[][] criteres2 = { {"limite" ,""+taillePage },{"numero_page",""+pageEncours}, {motsClesFiltres[0][0], motsClesFiltres[0][1]}} ;
121
			String[][] criteres2 = { {"limite" ,""+taillePage },{"numero_page",""+pageEncours}, {motsClesFiltres[0][0], motsClesFiltres[0][1]}} ;
118
			
122
			
119
			// et on crée un DAO auquel on les transmet et qui envoie une requete pour recevoir les images
123
			// et on crée un DAO auquel on les transmet et qui envoie une requete pour recevoir les images
120
			
124
			
121
			ListeObservationAsynchroneDAO loaDAO = new ListeObservationAsynchroneDAO(this);
125
			ListeObservationAsynchroneDAO loaDAO = new ListeObservationAsynchroneDAO(this);
122
			loaDAO.obtenirListeObservation(r, observationMediateur.getIdentifiant(), criteres2);		
126
			loaDAO.obtenirListeObservation(r, observationMediateur.getIdentifiant(), criteres2);		
123
	}
127
	}
124
	
128
	
125
 
129
 
126
	/**
130
	/**
127
	 * Obtenir une liste de commune 
131
	 * Obtenir une liste de commune 
128
	 * @param r
132
	 * @param r
129
	 * @param critere
133
	 * @param critere
130
	 */
134
	 */
131
	
135
	
132
	public void obtenirListeReferentielCommune(Rafraichissable r, String critere) {
136
	public void obtenirListeReferentielCommune(Rafraichissable r, String critere) {
133
		
137
		
134
		ListeReferentielCommuneAsynchroneDAO refDAO=new ListeReferentielCommuneAsynchroneDAO(this);
138
		ListeReferentielCommuneAsynchroneDAO refDAO=new ListeReferentielCommuneAsynchroneDAO(this);
135
		refDAO.obtenirListeDonnees(r, critere);
139
		refDAO.obtenirListeDonnees(r, critere);
136
 
140
 
137
	}
141
	}
138
	
142
	
139
	/**
143
	/**
140
	 * Obtenir une liste de nom scientifique de plante
144
	 * Obtenir une liste de nom scientifique de plante
141
	 * @param r
145
	 * @param r
142
	 * @param critere
146
	 * @param critere
143
	 */
147
	 */
144
	
148
	
145
	public void obtenirListeReferentielNom(Rafraichissable r, String critere) {
149
	public void obtenirListeReferentielNom(Rafraichissable r, String critere) {
146
		
150
		
147
		ListeReferentielNomAsynchroneDAO nomDAO=new ListeReferentielNomAsynchroneDAO(this);
151
		ListeReferentielNomAsynchroneDAO nomDAO=new ListeReferentielNomAsynchroneDAO(this);
148
		nomDAO.obtenirListeDonnees(r, critere);
152
		nomDAO.obtenirListeDonnees(r, critere);
149
 
153
 
150
	}
154
	}
151
	
155
	
152
	
156
	
153
	/**
157
	/**
154
	 *  
158
	 *  
155
	 * Lance la creation d'une observation  
159
	 * Lance la creation d'une observation  
156
	 * @param r : la vue demandeuse de donnee
160
	 * @param r : la vue demandeuse de donnee
157
	 * @param critere : les criteres de selection
161
	 * @param critere : les criteres de selection
158
	 */
162
	 */
159
	
163
	
160
	public void ajouterObservation(Rafraichissable r, Observation obs) {
164
	public void ajouterObservation(Rafraichissable r, Observation obs) {
161
		
165
		
162
		ObservationAsynchroneDAO obsDAO=new ObservationAsynchroneDAO(this);
166
		ObservationAsynchroneDAO obsDAO=new ObservationAsynchroneDAO(this);
163
		obsDAO.ajouter(r, observationMediateur.getIdentifiant(), obs);
167
		obsDAO.ajouter(r, observationMediateur.getIdentifiant(), obs);
164
			
168
			
165
	}
169
	}
166
 
170
 
167
	/**
171
	/**
168
	 *  
172
	 *  
169
	 * Lance la creation d'une observation  
173
	 * Lance la creation d'une observation  
170
	 * @param r : la vue demandeuse de donnee
174
	 * @param r : la vue demandeuse de donnee
171
	 * @param critere : les criteres de selection
175
	 * @param critere : les criteres de selection
172
	 */
176
	 */
173
	
177
	
174
	public void modifierObservation(Rafraichissable r, Observation obs) {
178
	public void modifierObservation(Rafraichissable r, Observation obs) {
175
		
179
		
176
		ObservationAsynchroneDAO obsDAO=new ObservationAsynchroneDAO(this);
180
		ObservationAsynchroneDAO obsDAO=new ObservationAsynchroneDAO(this);
177
		obsDAO.modifier(r, observationMediateur.getIdentifiant(), obs);
181
		obsDAO.modifier(r, observationMediateur.getIdentifiant(), obs);
178
			
182
			
179
	}
183
	}
180
	
184
	
181
	public void supprimerObservation(Rafraichissable r, String numeroOrdre) {
185
	public void supprimerObservation(Rafraichissable r, String numeroOrdre) {
182
		
186
		
183
		ObservationAsynchroneDAO obsDao = new ObservationAsynchroneDAO(this) ;
187
		ObservationAsynchroneDAO obsDao = new ObservationAsynchroneDAO(this) ;
184
		obsDao.supprimer(r,observationMediateur.getIdentifiant(),numeroOrdre) ;
188
		obsDao.supprimer(r,observationMediateur.getIdentifiant(),numeroOrdre) ;
185
		
189
		
186
		
190
		
187
	}
191
	}
188
	
192
	
189
	
193
	
190
 
194
 
191
 
195
 
192
	/**
196
	/**
193
	 * Accesseur pour la configuration en cours d'utilisation
197
	 * Accesseur pour la configuration en cours d'utilisation
194
	 * 
198
	 * 
195
	 * @return la configuration
199
	 * @return la configuration
196
	 */
200
	 */
197
	public Configuration getConfig() {
201
	public Configuration getConfig() {
198
 
202
 
199
		return config;
203
		return config;
200
	}
204
	}
201
 
205
 
202
	
206
	
203
	/**
207
	/**
204
	 * Obtenir des informations de repartition relative a un numero nomenclatural
208
	 * Obtenir des informations de repartition relative a un numero nomenclatural
205
	 * @param r
209
	 * @param r
206
	 * @param numeroNomenclaturalSaisiObservation
210
	 * @param numeroNomenclaturalSaisiObservation
207
	 */
211
	 */
208
 
212
 
209
 
213
 
210
	public void obtenirImageInformationRepartition( Rafraichissable r,String numeroNomenclaturalSaisiObservation) {
214
	public void obtenirImageInformationRepartition( Rafraichissable r,String numeroNomenclaturalSaisiObservation) {
211
		
215
		
212
		ImageInformationRepartitionAsynchroneDAO repDAO=new ImageInformationRepartitionAsynchroneDAO(this);
216
		ImageInformationRepartitionAsynchroneDAO repDAO=new ImageInformationRepartitionAsynchroneDAO(this);
213
		repDAO.obtenirURLImage(r, numeroNomenclaturalSaisiObservation);
217
		repDAO.obtenirURLImage(r, numeroNomenclaturalSaisiObservation);
214
		
218
		
215
		
219
		
216
	}
220
	}
217
 
221
 
218
	/**
222
	/**
219
	 * Obtenir une image generique associee a un numero nomenclatural
223
	 * Obtenir une image generique associee a un numero nomenclatural
220
	 * @param r
224
	 * @param r
221
	 * @param numeroNomenclaturalSaisiObservation
225
	 * @param numeroNomenclaturalSaisiObservation
222
	 */
226
	 */
223
 
227
 
224
	public void obtenirImageGenerique( Rafraichissable r,String numeroNomenclaturalSaisiObservation) {
228
	public void obtenirImageGenerique( Rafraichissable r,String numeroNomenclaturalSaisiObservation) {
225
		
229
		
226
		ImageGeneriqueVueAsynchroneDAO imgDAO=new ImageGeneriqueVueAsynchroneDAO(this);
230
		ImageGeneriqueVueAsynchroneDAO imgDAO=new ImageGeneriqueVueAsynchroneDAO(this);
227
		imgDAO.obtenirURLImage(r, numeroNomenclaturalSaisiObservation);
231
		imgDAO.obtenirURLImage(r, numeroNomenclaturalSaisiObservation);
228
		
232
		
229
		
233
		
230
	}
234
	}
231
 
235
 
232
 
236
 
233
	/**
237
	/**
234
	 * Obtenir la liste de l'ensemble des entites geographiques associes aux observation d'un utilisateur 
238
	 * Obtenir la liste de l'ensemble des entites geographiques associes aux observation d'un utilisateur 
235
	 * @param r
239
	 * @param r
236
	 */
240
	 */
237
 
241
 
238
	public void obtenirListeEntiteGeographique(Rafraichissable r) {
242
	public void obtenirListeEntiteGeographique(Rafraichissable r) {
239
 
243
 
240
	    ListeEntiteGeographiqueObservationAsynchroneDAO entDAO = new ListeEntiteGeographiqueObservationAsynchroneDAO(this);
244
	    ListeEntiteGeographiqueObservationAsynchroneDAO entDAO = new ListeEntiteGeographiqueObservationAsynchroneDAO(this);
241
	    entDAO.obtenirListeEntitesGeographiques(r, observationMediateur.getIdentifiant());
245
	    entDAO.obtenirListeEntitesGeographiques(r, observationMediateur.getIdentifiant());
242
 
246
 
243
	}
247
	}
244
	
248
	
245
}
249
}