Subversion Repositories eFlore/Applications.cel

Rev

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

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