Subversion Repositories eFlore/Archives.cel-v2

Rev

Rev 28 | Rev 36 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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