Rev 2846 | Blame | Compare with Previous | Last modification | View Log | RSS feed
package org.tela_botanica.client.modeles.dao;
import org.tela_botanica.client.interfaces.Rafraichissable;
import org.tela_botanica.client.modeles.objets.Configuration;
import org.tela_botanica.client.modeles.objets.Utilisateur;
import org.tela_botanica.client.observation.ObservationModele;
import org.tela_botanica.client.util.Analytics;
import com.google.gwt.http.client.Request;
import org.tela_botanica.client.util.RequestBuilderWithCredentials;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;
import com.google.gwt.http.client.Response;
public class TransmissionObservationAsynchroneDAO {
ObservationModele om = null ;
public TransmissionObservationAsynchroneDAO(ObservationModele observationModele) {
om = observationModele ;
}
public void transmettreObservations(final Rafraichissable r, final String identifiant, final String idsObs, final boolean publier) {
// on envoie le get asynchrone
String post = "&transmission=";
if(publier) {
post += "1";
}
else
{
post += "0" ;
}
RequestBuilderWithCredentials rb = new RequestBuilderWithCredentials(RequestBuilderWithCredentials.POST,Configuration.getServiceBaseUrl()
+"/InventoryTransmit/"+Utilisateur.getInstance().getIdentifiantUtilisateurConsulte()+"/"+idsObs) ;
try {
rb.sendRequest(post, new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
// TODO Auto-generated method stub
}
@Override
public void onResponseReceived(Request request, Response response) {
// stats
String action = "";
if (publier) {
action = "rendre-publiques";
} else {
action = "rendre-privees";
}
Analytics.evenement("observation", action, "{\"utilisateur\": \"" + identifiant + "\", \"observations\": \"" + idsObs + "\"}");
// Attention OK n'est pas un terme à traduire ici
r.rafraichir("OK",true);
}
}) ;
} catch (RequestException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}