Subversion Repositories eFlore/Applications.del

Rev

Rev 360 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.del.client.services.rest;

import org.tela_botanica.del.client.modeles.InformationsRecherche;
import org.tela_botanica.del.client.services.rest.async.ImagesParTaxonCallback;

import com.google.gwt.http.client.RequestBuilder;

public class ImageServiceConcret implements ImageService {
        
        private String serverUrl = "../jrest/";

        @Override
        public void getImagesEfloreParTaxon(String taxon, ImagesParTaxonCallback callback) {
                
                RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, serverUrl+"ImagesEflore");
                try {
                        rb.sendRequest("nom_taxon="+taxon, callback);
                } catch (Exception e) {
                        // TODO: handle exception
                }
        }

        @Override
        public void getImagesParTaxon(InformationsRecherche infos, int debut, int fin, ImagesParTaxonCallback callback) {
                RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, serverUrl+"Observations");
                try {
                        rb.sendRequest(assemblerChaineRequete(infos, debut, fin), callback);
                } catch (Exception e) {
                        // TODO: handle exception
                }
        }
        
        private String assemblerChaineRequete(InformationsRecherche infos, int debut, int fin) {
                
                String chaineRequete = "&debut="+debut+"&limite="+(fin-debut);
                if(infos != null && infos.getTaxon() != null && !infos.getTaxon().trim().isEmpty()) {
                        chaineRequete = "nom_taxon="+infos.getTaxon()+chaineRequete;
                }
                
                return chaineRequete;
        }
}