2,6 → 2,7 |
|
import org.tela_botanica.client.image.ImageModele; |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.observation.ObservationModele; |
|
import com.google.gwt.http.client.Request; |
import com.google.gwt.http.client.RequestBuilder; |
8,6 → 9,10 |
import com.google.gwt.http.client.RequestCallback; |
import com.google.gwt.http.client.RequestException; |
import com.google.gwt.http.client.Response; |
import com.google.gwt.json.client.JSONArray; |
import com.google.gwt.json.client.JSONParser; |
import com.google.gwt.json.client.JSONString; |
import com.google.gwt.json.client.JSONValue; |
import com.google.gwt.user.client.Window; |
|
public class LienImageAsynchroneDAO { |
14,9 → 19,17 |
|
private ImageModele iModele = null ; |
|
private ObservationModele oModele = null ; |
|
private Rafraichissable raf = null ; |
|
public LienImageAsynchroneDAO(ImageModele im) { |
iModele = im; |
} |
|
public LienImageAsynchroneDAO(ObservationModele om) { |
oModele = om; |
} |
|
/** |
* Setteur pour le modèle |
58,6 → 71,82 |
} |
} |
|
public void obtenirLiaisonsObservationsImages(Rafraichissable r,String idObs, String utilisateur) |
{ |
String paramGet = "&coi_ce_observation="+idObs ; |
raf = r ; |
|
// et on envoie ça au serveur |
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, oModele |
.getConfig().getServiceBaseUrl() |
+ "/inventoryImageLink/" + utilisateur + "/" + paramGet); |
try { |
rb.sendRequest(null, new RequestCallback() { |
|
public void onError(Request request, Throwable exception) { |
// TODO Auto-generated method stub |
|
} |
|
public void onResponseReceived(Request request, |
Response response) { |
|
String baseUrl = "http://162.38.234.9/Documents/images_serveur/"; |
|
final JSONValue responseValue = JSONParser.parse(response |
.getText()); |
// si c'est un tableau |
if (responseValue.isArray() != null) { |
|
final JSONArray reponse = responseValue.isArray(); |
|
final int taillemax = reponse.size(); |
|
String urlTab[] = new String[taillemax] ; |
|
for(int i = 0 ;i<taillemax ;i++) |
{ |
|
final JSONArray reponseInt = reponse.get(i).isArray(); |
String idImg = ((JSONString)reponseInt.get(0)).stringValue() ; |
|
int maxZeros = 9 - idImg.length(); |
|
for (int j = 0; j < maxZeros; j++) { |
idImg = "0" + idImg; |
} |
|
String dossierNv1 = idImg.substring(0, 3); |
String dossierNv2 = idImg.substring(3, 6); |
String fichierNv = idImg.substring(6, 9); |
|
String nomFichier = dossierNv1 + "_" + dossierNv2 + "_" + fichierNv; |
|
String[] infosFichier = { nomFichier, dossierNv1, dossierNv2 }; |
|
String url_img = baseUrl + infosFichier[1] + "/" + infosFichier[2] + "/M/" |
+ infosFichier[0] + "_M.jpg"; |
|
urlTab[i]= url_img ; |
} |
|
raf.rafraichir(urlTab, false) ; |
} |
else |
{ |
String urlTab[] = new String[0] ; |
raf.rafraichir(urlTab, false) ; |
} |
} |
|
}); |
|
} catch (RequestException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
public void lierImageBaseDeDonnees(String idsImages, String idsObs) { |
|
String postData = ""; |