Subversion Repositories eFlore/Archives.cel-v2

Rev

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

Rev Author Line No. Line
27 aperonnet 1
package org.tela_botanica.client.modeles;
2
 
28 aperonnet 3
import java.util.HashMap;
4
import java.util.Iterator;
5
 
6
import org.tela_botanica.client.image.ImageMediateur;
7
import org.tela_botanica.client.interfaces.Rafraichissable;
8
 
30 aperonnet 9
import com.google.gwt.json.client.JSONArray;
10
import com.google.gwt.json.client.JSONObject;
11
import com.google.gwt.json.client.JSONParser;
12
import com.google.gwt.json.client.JSONValue;
28 aperonnet 13
import com.google.gwt.user.client.HTTPRequest;
14
import com.google.gwt.user.client.ResponseTextHandler;
15
import com.google.gwt.user.client.Window;
30 aperonnet 16
import com.gwtext.client.data.Node;
17
import com.gwtext.client.data.Tree;
28 aperonnet 18
import com.gwtext.client.widgets.tree.TreeNode;
19
 
27 aperonnet 20
public class MotsClesAsynchroneDAO {
28 aperonnet 21
 
22
	private ImageMediateur iMediateur = null ;
23
 
24
	public void setIMediateur(ImageMediateur im)
25
	{
26
		iMediateur = im ;
27
	}
28
 
30 aperonnet 29
	public void obtenirListeMotsCles(final Rafraichissable r)
28 aperonnet 30
	{
31
		HTTPRequest.asyncGet("jrest/InventoryKeyWordList/"+iMediateur.getIdentifiant(), new ResponseTextHandler() {
27 aperonnet 32
 
28 aperonnet 33
			public void onCompletion(String responseText) {
34
 
30 aperonnet 35
				final JSONValue responseValue = JSONParser.parse(responseText);
36
				if (responseValue.isArray() != null) {
37
 
38
					final JSONArray reponse = responseValue.isArray();
39
 
40
						r.rafraichir(reponse, true) ;
41
				}
42
			}
28 aperonnet 43
		});
44
	}
45
 
46
 
47
	public void ajouterBaseDeDonnees(String motcle)
48
	{
49
		if(!motcle.equals(""))
50
		{
51
			String postData = motcle ;
52
 
53
			HTTPRequest.asyncPost("jrest/InventoryKeyWordList/","&identifiant="+iMediateur.getIdentifiant()+postData, new ResponseTextHandler() {
54
 
55
				public void onCompletion(String responseText) {
56
 
30 aperonnet 57
 
58
					if(responseText.equals("ERROR"))
59
					{
60
						Window.alert("Attention, la base de données des mots clés n'est plus synchronisée avec l'application," +
61
								"nous vous invitons à recharger la page. ") ;
62
					}
28 aperonnet 63
				}
64
 
65
			}) ;
66
		}
67
	}
68
 
69
	public void supprimerBaseDeDonnees(String motcle)
70
	{
71
		if(!motcle.equals(""))
72
		{
73
			String postData = "" ;
74
			postData += "&action=DELETE" ;
75
 
76
			HTTPRequest.asyncPost("jrest/InventoryKeyWordList/"+iMediateur.getIdentifiant()+"/"+motcle,postData, new ResponseTextHandler() {
77
 
78
				public void onCompletion(String responseText) {
79
 
30 aperonnet 80
					if(responseText.equals("ERROR"))
81
					{
82
						Window.alert("Attention, la base de données des mots clés n'est plus synchronisée avec l'application," +
83
								"nous vous invitons à recharger la page. ") ;
84
					}
28 aperonnet 85
				}
86
 
87
			}) ;
88
		}
89
	}
90
 
91
	public void modifierBaseDeDonnees(String motcle) {
92
 
93
		if(!motcle.equals(""))
94
		{
95
 
96
		String postData = "" ;
97
		postData += "&action=modification"+motcle ;
98
 
99
		HTTPRequest.asyncPost("jrest/InventoryKeyWordList/"+iMediateur.getIdentifiant() ,postData, new ResponseTextHandler() {
100
 
101
				public void onCompletion(String responseText) {
102
 
103
 
104
				}
105
 
106
			}) ;
107
		}
108
 
109
	}
110
 
30 aperonnet 111
	public void deplacerBaseDeDonnees(String motcle) {
28 aperonnet 112
 
113
		if(!motcle.equals(""))
114
		{
115
 
116
		String postData = "" ;
117
		postData += "&action=deplacement"+motcle ;
118
 
119
		HTTPRequest.asyncPost("jrest/InventoryKeyWordList/"+iMediateur.getIdentifiant() ,postData, new ResponseTextHandler() {
120
 
121
				public void onCompletion(String responseText) {
122
 
123
 
124
				}
125
 
126
			}) ;
127
		}
128
 
129
	}
130
 
27 aperonnet 131
}