Subversion Repositories eFlore/Archives.cel-v2

Rev

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

package org.tela_botanica.client.modeles;

import java.util.HashMap;
import java.util.Iterator;

import org.tela_botanica.client.image.ImageMediateur;
import org.tela_botanica.client.interfaces.Rafraichissable;

import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.HTTPRequest;
import com.google.gwt.user.client.ResponseTextHandler;
import com.google.gwt.user.client.Window;
import com.gwtext.client.data.Node;
import com.gwtext.client.data.Tree;
import com.gwtext.client.widgets.tree.TreeNode;

public class MotsClesAsynchroneDAO {
        
        private ImageMediateur iMediateur = null ;
        
        public void setIMediateur(ImageMediateur im)
        {
                iMediateur = im ; 
        }
        
        public void obtenirListeMotsCles(final Rafraichissable r)
        {
                HTTPRequest.asyncGet("jrest/InventoryKeyWordList/"+iMediateur.getIdentifiant(), new ResponseTextHandler() {

                        public void onCompletion(String responseText) {
                                
                                final JSONValue responseValue = JSONParser.parse(responseText);
                                if (responseValue.isArray() != null) {
                                        
                                        final JSONArray reponse = responseValue.isArray();

                                                r.rafraichir(reponse, true) ;           
                                }                                       
                        }                       
                });
        }
        
        
        public void ajouterBaseDeDonnees(String motcle)
        {
                if(!motcle.equals(""))
                {
                        String postData = motcle ;
                        
                        HTTPRequest.asyncPost("jrest/InventoryKeyWordList/","&identifiant="+iMediateur.getIdentifiant()+postData, new ResponseTextHandler() {
        
                                public void onCompletion(String responseText) {
                                
                                        
                                        if(responseText.equals("ERROR"))
                                        {
                                                Window.alert("Attention, la base de données des mots clés n'est plus synchronisée avec l'application," +
                                                                "nous vous invitons à recharger la page. ") ;
                                        }
                                }
                                
                        }) ;
                }
        } 
        
        public void supprimerBaseDeDonnees(String motcle)
        {
                if(!motcle.equals(""))
                {
                        String postData = "" ;
                        postData += "&action=DELETE" ;
                        
                        HTTPRequest.asyncPost("jrest/InventoryKeyWordList/"+iMediateur.getIdentifiant()+"/"+motcle,postData, new ResponseTextHandler() {
        
                                public void onCompletion(String responseText) {
                                        
                                        if(responseText.equals("ERROR"))
                                        {
                                                Window.alert("Attention, la base de données des mots clés n'est plus synchronisée avec l'application," +
                                                                "nous vous invitons à recharger la page. ") ;
                                        }
                                }
                                
                        }) ;
                }
        }

        public void modifierBaseDeDonnees(String motcle) {
                
                if(!motcle.equals(""))
                {

                String postData = "" ;
                postData += "&action=modification"+motcle ;
                        
                HTTPRequest.asyncPost("jrest/InventoryKeyWordList/"+iMediateur.getIdentifiant() ,postData, new ResponseTextHandler() {
        
                                public void onCompletion(String responseText) {
                                        
                                        
                                }
                                
                        }) ;
                }
                
        }
        
        public void deplacerBaseDeDonnees(String motcle) {
                
                if(!motcle.equals(""))
                {

                String postData = "" ;
                postData += "&action=deplacement"+motcle ;
                        
                HTTPRequest.asyncPost("jrest/InventoryKeyWordList/"+iMediateur.getIdentifiant() ,postData, new ResponseTextHandler() {
        
                                public void onCompletion(String responseText) {
                                        
                                        
                                }
                                
                        }) ;
                }
                
        } 

}