New file |
0,0 → 1,65 |
package org.tela_botanica.del.client.services.rest; |
|
import org.tela_botanica.del.client.config.Config; |
import org.tela_botanica.del.client.modeles.VoteDetermination; |
import org.tela_botanica.del.client.services.rest.async.VoteDeterminationCallBack; |
import org.tela_botanica.del.client.services.rest.async.VoteDeterminationCallBack.ModeRequete; |
|
import com.google.gwt.http.client.RequestBuilder; |
import com.google.gwt.user.client.Window; |
|
public class VoteDeterminationServiceConcret implements VoteDeterminationService { |
|
private String baseUrl; |
|
public VoteDeterminationServiceConcret() { |
Config config = new Config(); |
this.baseUrl = config.getServiceBaseUrl(); |
} |
|
public VoteDeterminationServiceConcret(Config config) { |
this.baseUrl = config.getServiceBaseUrl(); |
} |
|
@Override |
public void ajouterVote(VoteDetermination voteDetermination, VoteDeterminationCallBack callback) { |
String idObservation = voteDetermination.getPropositionDetermination().getObservation().getId(); |
String idProposition = voteDetermination.getPropositionDetermination().getId(); |
|
String urlService = baseUrl+"observations/"+idObservation+"/"+idProposition+"/vote/"; |
RequestBuilder rb = new RequestBuilder(RequestBuilder.PUT, urlService); |
|
Window.alert("Ajout :"+urlService); |
/*callback.setMode(ModeRequete.AJOUT); |
String chainePost = assemblerChaineRequeteAjoutModif(voteDetermination); |
try { |
rb.sendRequest(chainePost, callback); |
} catch (Exception e) { |
//TODO: quoi faire si la requete est mal formée coté client avant d'être envoyée ? |
}*/ |
} |
|
@Override |
public void modifierVote(VoteDetermination voteDetermination, VoteDeterminationCallBack callback) { |
String idObservation = voteDetermination.getPropositionDetermination().getObservation().getId(); |
String idProposition = voteDetermination.getPropositionDetermination().getId(); |
|
String urlService = baseUrl+"observations/"+idObservation+"/"+idProposition+"/vote/"; |
RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, urlService); |
|
Window.alert("Ajout :"+urlService); |
/*callback.setMode(ModeRequete.MODIFICATION); |
String chainePost = assemblerChaineRequeteAjoutModif(voteDetermination); |
try { |
rb.sendRequest(chainePost, callback); |
} catch (Exception e) { |
//TODO: quoi faire si la requete est mal formée coté client avant d'être envoyée ? |
}*/ |
} |
|
private String assemblerChaineRequeteAjoutModif(VoteDetermination voteDetermination) { |
String chaineRequete = "utilisateur="+voteDetermination.getContributeur()+"&"+ |
"valeur="+voteDetermination.getVote(); |
return chaineRequete; |
} |
} |