Subversion Repositories eFlore/Applications.cel

Rev

Rev 989 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 989 Rev 1293
Line 1... Line 1...
1
package org.tela_botanica.client.modeles.dao;
1
package org.tela_botanica.client.modeles.dao;
Line 2... Line 2...
2
 
2
 
3
import org.tela_botanica.client.interfaces.Rafraichissable;
3
import org.tela_botanica.client.interfaces.Rafraichissable;
4
import org.tela_botanica.client.modeles.objets.Configuration;
4
import org.tela_botanica.client.modeles.objets.Configuration;
-
 
5
import org.tela_botanica.client.modeles.objets.EntiteGeographiqueObservation;
Line 5... Line -...
5
import org.tela_botanica.client.modeles.objets.EntiteGeographiqueObservation;
-
 
6
 
6
import org.tela_botanica.client.util.Util;
7
import com.google.gwt.core.client.GWT;
7
 
8
import com.google.gwt.http.client.Request;
8
import com.google.gwt.http.client.Request;
9
import com.google.gwt.http.client.RequestBuilder;
9
import com.google.gwt.http.client.RequestBuilder;
10
import com.google.gwt.http.client.RequestCallback;
10
import com.google.gwt.http.client.RequestCallback;
11
import com.google.gwt.http.client.RequestException;
11
import com.google.gwt.http.client.RequestException;
12
import com.google.gwt.http.client.Response;
-
 
13
import com.google.gwt.http.client.URL;
12
import com.google.gwt.http.client.Response;
14
import com.google.gwt.json.client.JSONArray;
13
import com.google.gwt.http.client.URL;
15
import com.google.gwt.json.client.JSONObject;
14
import com.google.gwt.json.client.JSONObject;
16
import com.google.gwt.json.client.JSONParser;
-
 
17
import com.google.gwt.json.client.JSONValue;
15
import com.google.gwt.json.client.JSONParser;
Line 18... Line 16...
18
import com.google.gwt.maps.client.geom.LatLng;
16
import com.google.gwt.json.client.JSONValue;
Line 19... Line 17...
19
import com.google.gwt.user.client.Window;
17
import com.google.gwt.user.client.Window;
Line 38... Line 36...
38
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, adresseAppel);
36
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, adresseAppel);
Line 39... Line 37...
39
 
37
 
40
		try {
38
		try {
Line -... Line 39...
-
 
39
			rb.sendRequest(null, new RequestCallback() {
41
			rb.sendRequest(null, new RequestCallback() {
40
 
42
 
41
				@Override
43
				public void onError(Request request, Throwable exception) {
42
				public void onError(Request request, Throwable exception) {
Line -... Line 43...
-
 
43
					Window.alert(exception.getMessage());
44
					Window.alert(exception.getMessage());
44
				}
45
				}
45
 
Line 46... Line 46...
46
 
46
				@Override
47
				public void onResponseReceived(Request request,
47
				public void onResponseReceived(Request request,
Line 111... Line 111...
111
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, adresseAppel);
111
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, adresseAppel);
Line 112... Line 112...
112
 
112
 
113
		try {
113
		try {
Line -... Line 114...
-
 
114
			rb.sendRequest(null, new RequestCallback() {
114
			rb.sendRequest(null, new RequestCallback() {
115
 
115
 
116
				@Override
116
				public void onError(Request request, Throwable exception) {
117
				public void onError(Request request, Throwable exception) {
Line -... Line 118...
-
 
118
					Window.alert(exception.getMessage());
117
					Window.alert(exception.getMessage());
119
				}
118
				}
120
 
Line 119... Line 121...
119
 
121
				@Override
120
				public void onResponseReceived(Request request,
122
				public void onResponseReceived(Request request,
Line 140... Line 142...
140
								.parse(response.getText());
142
								.parse(response.getText());
Line 141... Line 143...
141
						
143
						
Line 142... Line 144...
142
						if (responseValue.isObject() != null) {
144
						if (responseValue.isObject() != null) {
143
							
-
 
144
							EntiteGeographiqueObservation infos;
-
 
145
							String idLocalite = "";
145
							
146
							String nomCommune = "";
146
							EntiteGeographiqueObservation infos;
Line 147... Line 147...
147
							Double lng = 0.0;
147
							Double lng = 0.0;
Line 148... Line -...
148
							Double lat = 0.0;
-
 
149
								
148
							Double lat = 0.0;
150
							JSONObject objectRetour = responseValue.isObject();
-
 
151
							
-
 
152
							if(objectRetour.get("nom").isString() != null) {
-
 
153
								nomCommune = objectRetour.get("nom").isString().stringValue();
149
								
154
							}
-
 
155
							
-
 
156
							if(objectRetour.get("code_insee").isString() != null) {
-
 
157
								idLocalite = objectRetour.get("code_insee").isString().stringValue().substring(0, 2);
150
							JSONObject objectRetour = responseValue.isObject();
158
							}
-
 
159
							
-
 
160
							if(objectRetour.get("lat").isNumber() != null) {
-
 
161
								lat = objectRetour.get("lat").isNumber().doubleValue();
151
							
162
							}
-
 
163
							
-
 
164
							if(objectRetour.get("lng").isNumber() != null) {
152
							String nomCommune = Util.getValeurJsonOuVide(objectRetour, "nom");
165
								lng = objectRetour.get("lng").isNumber().doubleValue();
153
							String idLocalite = Util.getValeurJsonOuVide(objectRetour, "code_insee");
166
							}
154
							lat = Util.jsonNonNull(objectRetour,"lat") ? objectRetour.get("lat").isNumber().doubleValue(): 0.0;
167
 
155
							lng = Util.jsonNonNull(objectRetour,"lng") ? objectRetour.get("lng").isNumber().doubleValue(): 0.0;
Line 168... Line 156...
168
							
156