Subversion Repositories eFlore/Archives.cel-v1

Rev

Rev 10 | Rev 12 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 ddelon 1
package org.tela_botanica.client;
2
 
3
 
4
// TODO : sortie User vers une classe ...
5
// TODO : sortie les boutons supprimer et exporter et inclure ici
6
 
7
import com.google.gwt.i18n.client.Dictionary;
8
import com.google.gwt.json.client.JSONParser;
9
import com.google.gwt.json.client.JSONString;
10
import com.google.gwt.json.client.JSONValue;
11
import com.google.gwt.user.client.HTTPRequest;
12
import com.google.gwt.user.client.ResponseTextHandler;
13
 
14
public class Mediator {
15
 
16
 
17
		private String serviceBaseUrl = getServiceBaseUrlFromDictionnary();
18
		private String user = null;
11 ddelon 19
		private InventoryItemList inventoryItemList = null;
10 ddelon 20
		private LocationList locationList = null;
11 ddelon 21
		private NameAssistant nameAssistant=null;
22
		private LocationAssistant locationAssistant=null;
23
 
10 ddelon 24
		private Cel cel = null;
25
 
26
 
27
		Mediator() {
28
 
29
 
30
		}
31
 
32
		/**
33
		 * Recuperation information utilisateur
34
		 *
35
		 */
36
 
37
		public void initUser() {
38
			getUserFromService();
39
 
40
		}
41
 
42
		/**
11 ddelon 43
		 * Action sur selection d'un lieu : affichage de la liste des taxons correspondants
10 ddelon 44
		 *
45
		 */
46
 
47
		public void onLocationSelected(String loc) {
48
 
11 ddelon 49
			inventoryItemList.setLocation(loc);
50
			inventoryItemList.updateCount();
10 ddelon 51
 
11 ddelon 52
			if ((loc.compareTo("000null")==0) || (loc.compareTo("all")==0)) {
53
				locationAssistant.setText("");
54
			}
55
			else {
56
				locationAssistant.setText(loc);
57
			}
10 ddelon 58
 
59
		}
60
 
61
		/**
11 ddelon 62
		 * Action sur ajout d'un taxon : affichage du lieu corresondant
10 ddelon 63
		 */
64
 
65
 
11 ddelon 66
		public void onInventoryItemUpdate(String loc) {
10 ddelon 67
 
68
			locationList.setLocation(loc);
11 ddelon 69
			locationList.updateCount();
10 ddelon 70
 
71
		}
72
 
73
		/**
11 ddelon 74
		 * Declaration InventoryItemList
75
		 * @param inventoryItemList
10 ddelon 76
		 */
77
 
11 ddelon 78
		public void registerInventoryItemList(InventoryItemList inventoryItemList) {
10 ddelon 79
 
11 ddelon 80
			this.inventoryItemList=inventoryItemList;
10 ddelon 81
 
82
		}
83
 
84
		/**
11 ddelon 85
		 * Declaration LocationList
10 ddelon 86
		 * @param locationList
87
		 */
88
 
89
		public void registerLocationList(LocationList locationList) {
90
 
91
			this.locationList=locationList;
92
		}
93
 
94
		/**
11 ddelon 95
		 * Declaration Cel
10 ddelon 96
		 * @param cel
97
		 */
98
 
99
		public void registerCel(Cel cel) {
100
 
101
			this.cel=cel;
102
		}
103
 
104
 
11 ddelon 105
		/**
106
		 * Declaration NameAssistant
107
		 * @param nameassistant
108
		 */
109
 
110
		public void registerNameAssistant(NameAssistant nameAssistant) {
111
			this.nameAssistant=nameAssistant;
112
 
113
		}
114
 
115
		/**
116
		 * Declaration LocationAssistant
117
		 * @param locationassistant
118
		 */
119
 
120
		public void registerLocationAssistant(LocationAssistant locationAssistant) {
121
			this.locationAssistant=locationAssistant;
122
 
123
		}
124
 
10 ddelon 125
 
126
		/**
127
		 * Recherche distante et asynchrone de l'utilisateur connecté, en retour lancement methode initialisation
11 ddelon 128
		 * de l'appellant Cel. (initAsync)
10 ddelon 129
		 *
130
		 */
131
 
132
		private void getUserFromService() {
133
 
134
 
135
			HTTPRequest.asyncGet(serviceBaseUrl + "/User/",
136
					new ResponseTextHandler() {
137
 
138
						public void onCompletion(String str) {
139
							JSONValue jsonValue = JSONParser.parse(str);
140
							JSONString jsonString;
141
							if ((jsonString = jsonValue.isString()) != null) {
142
								user = jsonString.stringValue();
143
							}
144
							cel.initAsync();
145
						}
146
					});
147
 
148
		}
149
 
150
		/**
151
		 * Accesseur Url de base
152
		 * @return Url de base
153
		 */
154
 
155
		public String getServiceBaseUrl() {
156
 
157
			return serviceBaseUrl;
158
 
159
		}
160
 
161
 
162
		/**
163
		 * Recuperation du prefixe d'appel des services
164
		 * @return prefix appel des service
165
		 */
166
 
167
		private String getServiceBaseUrlFromDictionnary() {
168
 
169
			Dictionary theme = Dictionary.getDictionary("Parameters");
170
			return theme.get("serviceBaseUrl");
171
 
172
		}
173
 
174
 
175
		/**
176
		 *  Accesseur Utilisateur
177
		 * @return utilisateur connecté ou identifiant de session
178
		 */
179
 
180
		public String getUser() {
181
			return user;
182
		}
11 ddelon 183
 
10 ddelon 184
 
11 ddelon 185
 
186
		public InventoryItemList getInventoryItemList() {
187
			return inventoryItemList;
188
		}
10 ddelon 189
 
11 ddelon 190
		public LocationList getLocationList() {
191
			return locationList;
192
		}
10 ddelon 193
 
11 ddelon 194
		public NameAssistant getNameAssistant() {
195
			return nameAssistant;
196
		}
197
 
198
		public LocationAssistant getLocationAssistant() {
199
			return locationAssistant;
200
		}
201
 
202
 
203
 
10 ddelon 204
	}