Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 81 Rev 94
Line 1... Line 1...
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
Line 2... Line 2...
2
 
2
 
3
import org.tela_botanica.client.image.ImageModele;
3
import org.tela_botanica.client.image.ImageModele;
-
 
4
import org.tela_botanica.client.interfaces.Rafraichissable;
Line 4... Line 5...
4
import org.tela_botanica.client.interfaces.Rafraichissable;
5
import org.tela_botanica.client.observation.ObservationModele;
5
 
6
 
6
import com.google.gwt.http.client.Request;
7
import com.google.gwt.http.client.Request;
7
import com.google.gwt.http.client.RequestBuilder;
8
import com.google.gwt.http.client.RequestBuilder;
8
import com.google.gwt.http.client.RequestCallback;
9
import com.google.gwt.http.client.RequestCallback;
-
 
10
import com.google.gwt.http.client.RequestException;
-
 
11
import com.google.gwt.http.client.Response;
-
 
12
import com.google.gwt.json.client.JSONArray;
-
 
13
import com.google.gwt.json.client.JSONParser;
9
import com.google.gwt.http.client.RequestException;
14
import com.google.gwt.json.client.JSONString;
Line 10... Line 15...
10
import com.google.gwt.http.client.Response;
15
import com.google.gwt.json.client.JSONValue;
Line 11... Line 16...
11
import com.google.gwt.user.client.Window;
16
import com.google.gwt.user.client.Window;
Line -... Line 17...
-
 
17
 
-
 
18
public class LienImageAsynchroneDAO {
-
 
19
 
-
 
20
	private ImageModele iModele = null ;
12
 
21
	
13
public class LienImageAsynchroneDAO {
22
	private ObservationModele oModele = null ;
14
 
23
	
-
 
24
	private Rafraichissable raf = null ;
-
 
25
	
-
 
26
	public LienImageAsynchroneDAO(ImageModele im) {
-
 
27
		iModele = im;
Line 15... Line 28...
15
	private ImageModele iModele = null ;
28
	}
16
	
29
	
17
	public LienImageAsynchroneDAO(ImageModele im) {
30
	public LienImageAsynchroneDAO(ObservationModele om) {
18
		iModele = im;
31
		oModele = om;
Line 53... Line 66...
53
				});
66
				});
Line 54... Line 67...
54
	
67
	
55
			} catch (RequestException e) {
68
			} catch (RequestException e) {
56
				// TODO Auto-generated catch block
69
				// TODO Auto-generated catch block
-
 
70
				e.printStackTrace();
-
 
71
			}
-
 
72
	}
-
 
73
	
-
 
74
	public void obtenirLiaisonsObservationsImages(Rafraichissable r,String idObs, String utilisateur)
-
 
75
	{
-
 
76
		String paramGet = "&coi_ce_observation="+idObs ;
-
 
77
		raf = r ;
-
 
78
 
-
 
79
		// et on envoie ça au serveur
-
 
80
		RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, oModele
-
 
81
				.getConfig().getServiceBaseUrl()
-
 
82
				+ "/inventoryImageLink/" + utilisateur + "/" + paramGet);
-
 
83
			try {
-
 
84
				rb.sendRequest(null, new RequestCallback() {
-
 
85
	
-
 
86
					public void onError(Request request, Throwable exception) {
-
 
87
						// TODO Auto-generated method stub
-
 
88
	
-
 
89
					}
-
 
90
	
-
 
91
					public void onResponseReceived(Request request,
-
 
92
							Response response) {
-
 
93
	
-
 
94
						String baseUrl = "http://162.38.234.9/Documents/images_serveur/";
-
 
95
						
-
 
96
						final JSONValue responseValue = JSONParser.parse(response
-
 
97
								.getText());
-
 
98
						// si c'est un tableau
-
 
99
						if (responseValue.isArray() != null) {
-
 
100
 
-
 
101
							final JSONArray reponse = responseValue.isArray();
-
 
102
							
-
 
103
							final int taillemax = reponse.size();
-
 
104
							
-
 
105
							String urlTab[] = new String[taillemax] ;
-
 
106
							
-
 
107
							for(int i = 0 ;i<taillemax ;i++)
-
 
108
							{
-
 
109
								
-
 
110
								final JSONArray reponseInt = reponse.get(i).isArray();
-
 
111
								String idImg = ((JSONString)reponseInt.get(0)).stringValue() ;
-
 
112
								
-
 
113
								int maxZeros = 9 - idImg.length();
-
 
114
		
-
 
115
								for (int j = 0; j < maxZeros; j++) {
-
 
116
									idImg = "0" + idImg;
-
 
117
								}
-
 
118
		
-
 
119
								String dossierNv1 = idImg.substring(0, 3);
-
 
120
								String dossierNv2 = idImg.substring(3, 6);
-
 
121
								String fichierNv = idImg.substring(6, 9);
-
 
122
		
-
 
123
								String nomFichier = dossierNv1 + "_" + dossierNv2 + "_" + fichierNv;
-
 
124
		
-
 
125
								String[] infosFichier = { nomFichier, dossierNv1, dossierNv2 };
-
 
126
								
-
 
127
								String url_img = baseUrl + infosFichier[1] + "/" + infosFichier[2] + "/M/"
-
 
128
								+ infosFichier[0] + "_M.jpg";
-
 
129
								
-
 
130
								urlTab[i]= url_img ;
-
 
131
							}
-
 
132
							
-
 
133
							raf.rafraichir(urlTab, false) ;
-
 
134
						}
-
 
135
						else
-
 
136
						{
-
 
137
							String urlTab[] = new String[0] ;
-
 
138
							raf.rafraichir(urlTab, false) ;
-
 
139
						}
-
 
140
					}
-
 
141
					
-
 
142
				});
-
 
143
	
-
 
144
			} catch (RequestException e) {
-
 
145
				// TODO Auto-generated catch block
57
				e.printStackTrace();
146
				e.printStackTrace();
58
			}
147
			}
Line 59... Line 148...
59
	}
148
	}