Subversion Repositories eFlore/Applications.cel

Rev

Rev 1918 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1918 Rev 2695
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;
Line -... Line 5...
-
 
5
import org.tela_botanica.client.observation.ObservationModele;
5
import org.tela_botanica.client.observation.ObservationModele;
6
 
6
 
7
import com.google.gwt.core.client.Callback;
7
import com.google.gwt.http.client.Request;
8
import com.google.gwt.http.client.Request;
8
import org.tela_botanica.client.util.RequestBuilderWithCredentials;
9
import org.tela_botanica.client.util.RequestBuilderWithCredentials;
9
import com.google.gwt.http.client.RequestCallback;
10
import com.google.gwt.http.client.RequestCallback;
-
 
11
import com.google.gwt.http.client.RequestException;
10
import com.google.gwt.http.client.RequestException;
12
import com.google.gwt.http.client.Response;
11
import com.google.gwt.http.client.Response;
13
import com.google.gwt.http.client.URL;
12
import com.google.gwt.json.client.JSONArray;
14
import com.google.gwt.json.client.JSONArray;
13
import com.google.gwt.json.client.JSONParser;
15
import com.google.gwt.json.client.JSONParser;
Line 82... Line 84...
82
			// TODO Auto-generated catch block
84
			// TODO Auto-generated catch block
83
			e.printStackTrace();
85
			e.printStackTrace();
84
		}
86
		}
85
	}
87
	}
Line -... Line 88...
-
 
88
	
-
 
89
	public static void taxonEstPresentDansZoneGeo(String referentielTaxo, String numeroNomenclaturalSaisiObservation, String pays, String zoneGeo, final Callback<String, String> callback) {
-
 
90
		String referentielDefaut =  Configuration.getReferentielsDispos().get(0).getCode();
-
 
91
		referentielTaxo = (referentielTaxo != null && !referentielTaxo.isEmpty()) ? referentielTaxo : referentielDefaut;
-
 
92
		
-
 
93
		String url = Configuration.getServiceBaseUrl()+"/InventoryTaxonPresent/"+referentielTaxo+"/"+numeroNomenclaturalSaisiObservation+"?pays="+URL.encode(pays)+"&ce_zone_geo="+URL.encode(zoneGeo);
-
 
94
		
-
 
95
		RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.GET, url) ;
-
 
96
		try {
Line -... Line 97...
-
 
97
			rb.sendRequest(null, new RequestCallback() {
-
 
98
 
-
 
99
				@Override
-
 
100
				public void onError(Request request, Throwable exception) {
-
 
101
					callback.onFailure(exception.getMessage());
-
 
102
				}
-
 
103
 
-
 
104
				@Override
-
 
105
				public void onResponseReceived(Request request,
-
 
106
						Response response) {
-
 
107
					final JSONValue responseValue = JSONParser
-
 
108
							.parse(response.getText());
-
 
109
					
-
 
110
					if (responseValue.isString() != null) {
-
 
111
						//Window.alert(response.getText()+responseValue.isString().stringValue());
-
 
112
						callback.onSuccess(responseValue.isString().stringValue());
-
 
113
					} else {
-
 
114
						callback.onFailure(response.getText());
-
 
115
					}
-
 
116
				}
-
 
117
			}) ;
-
 
118
 
-
 
119
		} catch (RequestException e) {
-
 
120
			callback.onFailure(e.getMessage());
Line 86... Line 121...
86
	
121
		}
87
 
122
	}