Subversion Repositories eFlore/Applications.cel

Rev

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

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