Subversion Repositories eFlore/Archives.cel-v2

Rev

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

Rev 27 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
import java.util.Set;
5
import java.util.Set;
6
 
6
 
7
import com.google.gwt.json.client.JSONObject;
7
import com.google.gwt.json.client.JSONObject;
8
 
8
 
9
/**
9
/**
10
 * 
10
 * 
11
 * Classe representant une image du carnet,
11
 * Classe representant une image du carnet,
12
 * elle ne contient pas d'image à proprement parler mais
12
 * elle ne contient pas d'image à proprement parler mais
13
 * plutôt les informations associées ainsi que l'url distante 
13
 * plutôt les informations associées ainsi que l'url distante 
14
 * 
14
 * 
15
 */
15
 */
16
public class ImageCarnet extends HashMap {
16
public class ImageCarnet extends HashMap {
17
	
17
	
18
 
18
 
19
	public ImageCarnet(JSONObject image)
19
	public ImageCarnet(JSONObject image)
20
	{	
20
	{	
21
		Set im = image.keySet() ;
21
		Set im = image.keySet() ;
22
		
22
		
23
		for (Iterator iterator = im.iterator(); iterator.hasNext();) {
23
		for (Iterator iterator = im.iterator(); iterator.hasNext();) {
24
			
24
			
25
			String key = (String) iterator.next();
25
			String key = (String) iterator.next();
26
			if(image.get(key).isString() != null)
26
			if(image.get(key).isString() != null)
27
			{
27
			{
28
				String valeur = image.get(key).isString().stringValue() ;
28
				String valeur = image.get(key).isString().stringValue() ;
29
				this.put(key, valeur) ;
29
				this.put(key, valeur) ;
30
			}
30
			}
31
			else
31
			else
32
			{
32
			{
33
				String valeur = " " ;
33
				String valeur = " " ;
34
				this.put(key, valeur) ;
34
				this.put(key, valeur) ;
35
			}
35
			}
36
			
36
			
37
		}
37
		}
38
 
38
 
39
	}
39
	}
40
	
40
	
41
	public String toString()
41
	public String toString()
42
	{
42
	{
43
		String valeur = " ";
43
		String valeur = " ";
44
		
44
		
45
		for (Iterator iterator = this.keySet().iterator(); iterator.hasNext();) {
45
		for (Iterator iterator = this.keySet().iterator(); iterator.hasNext();) {
46
			
46
			
47
			
47
			
48
			String key = (String) iterator.next();
48
			String key = (String) iterator.next();
49
			if(this.get(key) != null)
49
			if(this.get(key) != null)
50
			{
50
			{
51
				valeur += "cle : "+key+" valeur :"+(String)this.get(key)+"\n" ;
51
				valeur += "cle : "+key+" valeur :"+(String)this.get(key)+"\n" ;
52
			}
52
			}
53
			
53
			
54
		}
54
		}
55
		
55
		
56
		return valeur ;
56
		return valeur ;
57
	}
57
	}
58
	
58
	
59
	public String renvoyerValeurCorrecte(String cle)
59
	public String renvoyerValeurCorrecte(String cle)
60
	{
60
	{
61
		if(this.containsKey((cle)))
61
		if(this.containsKey((cle)))
62
		{
62
		{
63
			String valeur = (String)this.get(cle) ;
63
			String valeur = (String)this.get(cle) ;
64
			if(valeur.equals("null"))
64
			if(valeur.equals("null") || valeur == null)
65
			{
65
			{
66
				return "null" ;
66
				return "null" ;
67
			}
67
			}			
68
			else
68
			else
69
			{
69
			{
70
				char nullChar = '\u0000' ;
70
				char nullChar = '\u0000' ;
71
				String sNull = ""+nullChar ; 
71
				String sNull = ""+nullChar ; 
72
				valeur = valeur.replaceAll(sNull, "") ;
72
				valeur = valeur.replaceAll(sNull, "") ;
73
				return valeur ;
73
				return valeur ;
74
			}
74
			}
75
		}
75
		}
76
		else
76
		else
77
		{
77
		{
78
			return "null" ;
78
			return "null" ;
79
		}
79
		}
80
	}
80
	}
81
 
81
 
82
	public String getId() {
82
	public String getId() {
83
		
83
		
84
		return renvoyerValeurCorrecte("ci_id_image") ;
84
		return renvoyerValeurCorrecte("ci_id_image") ;
85
	}
85
	}
86
	
86
	
87
	public String getOrdre() {
87
	public String getOrdre() {
88
		
88
		
89
		return renvoyerValeurCorrecte("ci_ordre") ;
89
		return renvoyerValeurCorrecte("ci_ordre") ;
90
	}
90
	}
91
	
91
	
92
	public String getBaseUrl()
92
	public String getBaseUrl()
93
	{
93
	{
94
		return "http://162.38.234.9/Documents/images_serveur/" ;
94
		return "http://162.38.234.9/Documents/images_serveur/" ;
95
	}
95
	}
96
 
96
 
97
	public String getUrl() {
97
	public String getUrl() {
98
		
98
		
99
		return getBaseUrl()+(String)this.get("ci_id_image")+".jpg" ;
99
		return getBaseUrl()+(String)this.get("ci_id_image")+".jpg" ;
100
	}
100
	}
101
	
101
	
102
	public String getSUrl() {
102
	public String getSUrl() {
103
		
103
		
104
		return getBaseUrl()+(String)this.get("ci_id_image")+"_S.jpg" ;
104
		return getBaseUrl()+(String)this.get("ci_id_image")+"_S.jpg" ;
105
	}
105
	}
106
	
106
	
107
	public String getMUrl() {
107
	public String getMUrl() {
108
		
108
		
109
		return getBaseUrl()+(String)this.get("ci_id_image")+"_M.jpg" ;
109
		return getBaseUrl()+(String)this.get("ci_id_image")+"_M.jpg" ;
110
	}
110
	}
111
	
111
	
112
 
112
 
113
 
113
 
114
	public String getDate() {
114
	public String getDate() {
115
		
115
		
116
		return renvoyerValeurCorrecte("ci_meta_date_time") ;
116
		return renvoyerValeurCorrecte("ci_meta_date_time") ;
117
	}
117
	}
118
 
118
 
119
 
119
 
120
	public Object getIptcCity() {
120
	public Object getIptcCity() {
121
		
121
		
122
		return renvoyerValeurCorrecte("ci_meta_iptc_city") ;
122
		return renvoyerValeurCorrecte("ci_meta_iptc_city") ;
123
	}
123
	}
124
 
124
 
125
 
125
 
126
	public String getMake() {
126
	public String getMake() {
127
		
127
		
128
		return renvoyerValeurCorrecte("ci_meta_make") ;
128
		return renvoyerValeurCorrecte("ci_meta_make") ;
129
	}
129
	}
130
 
130
 
131
 
131
 
132
	public String getModel() {
132
	public String getModel() {
133
		
133
		
134
		return renvoyerValeurCorrecte("ci_meta_model") ;
134
		return renvoyerValeurCorrecte("ci_meta_model") ;
135
	}
135
	}
136
	
136
	
137
	public String[][] getMetadonnesIptc() {
137
	public String[][] getMetadonnesIptc() {
138
		
138
		
139
		String[][] metaIptc = new String[12][2] ;
139
		String[][] metaIptc = new String[12][2] ;
140
		int elem = 0 ;
140
		int elem = 0 ;
141
		
141
		
142
		for (Iterator it = this.keySet().iterator(); it.hasNext();) 
142
		for (Iterator it = this.keySet().iterator(); it.hasNext();) 
143
		{
143
		{
144
						
144
						
145
			String key = (String)it.next();
145
			String key = (String)it.next();
146
			
146
			
147
				// on filtre le "ci"
147
				// on filtre le "ci"
148
				String type[] = key.split("_",3) ;
148
				String type[] = key.split("_",3) ;
149
				
149
				
150
				
150
				
151
				// si c'est une metadonnee exif ou iptc
151
				// si c'est une metadonnee exif ou iptc
152
				if(type[1].equals("meta"))
152
				if(type[1].equals("meta"))
153
				{
153
				{
154
					String[] genre =  type[2].split("_",2) ;
154
					String[] genre =  type[2].split("_",2) ;
155
					if(genre[0].equals("iptc"))
155
					if(genre[0].equals("iptc"))
156
					{
156
					{
157
						String nom = genre[1] ;
157
						String nom = genre[1] ;
158
						metaIptc[elem][0] = nom ;
158
						metaIptc[elem][0] = nom ;
159
						metaIptc[elem][1] = renvoyerValeurCorrecte(key) ;
159
						metaIptc[elem][1] = renvoyerValeurCorrecte(key) ;
160
						elem++ ;	
160
						elem++ ;	
161
					}
161
					}
162
					
162
					
163
				}	
163
				}	
164
							    	
164
							    	
165
		}
165
		}
166
		
166
		
167
		return metaIptc ;
167
		return metaIptc ;
168
	}
168
	}
169
	
169
	
170
	public Object[][] getMetadonnesExif() {
170
	public Object[][] getMetadonnesExif() {
171
		
171
		
172
		String[][] metaExif = new String[31][2] ;
172
		String[][] metaExif = new String[31][2] ;
173
		int elem = 0 ;
173
		int elem = 0 ;
174
		
174
		
175
		for (Iterator it = this.keySet().iterator(); it.hasNext();) 
175
		for (Iterator it = this.keySet().iterator(); it.hasNext();) 
176
		{
176
		{
177
						
177
						
178
			String key = (String)it.next();
178
			String key = (String)it.next();
179
			
179
			
180
				// on filtre le "ci"
180
				// on filtre le "ci"
181
				String type[] = key.split("_",3) ;
181
				String type[] = key.split("_",3) ;
182
				
182
				
183
				
183
				
184
				// si c'est une metadonnee exif ou iptc
184
				// si c'est une metadonnee exif ou iptc
185
				if(type[1].equals("meta"))
185
				if(type[1].equals("meta"))
186
				{
186
				{
187
					String[] genre =  type[2].split("_",2) ;
187
					String[] genre =  type[2].split("_",2) ;
188
					if(genre[0].equals("exif"))
188
					if(genre[0].equals("exif"))
189
					{
189
					{
190
						String nom = genre[1] ;
190
						String nom = genre[1] ;
191
						metaExif[elem][0] = nom ;
191
						metaExif[elem][0] = nom ;
192
						metaExif[elem][1] = renvoyerValeurCorrecte(key) ;
192
						metaExif[elem][1] = renvoyerValeurCorrecte(key) ;
193
						elem++ ;	
193
						elem++ ;	
194
					}
194
					}
195
					
195
					
196
				}	
196
				}	
197
							    	
197
							    	
198
		}
198
		}
199
		
199
		
200
		return metaExif ;
200
		return metaExif ;
201
	
201
	
202
	}
202
	}
203
	
203
	
204
	public Object[][] getInfoGenerales() {
204
	public Object[][] getInfoGenerales() {
205
		
205
		
206
		String[][] metaGen = new String[2][2] ;
206
		String[][] metaGen = new String[2][2] ;
207
		
207
		
208
		metaGen[0][0] = "ci_meta_comment" ;
208
		metaGen[0][0] = "ci_meta_comment" ;
209
		metaGen[0][1] = (String)this.get("ci_meta_comment") ;
209
		metaGen[0][1] = (String)this.get("ci_meta_comment") ;
210
		
210
		
211
		metaGen[1][0] = "ci_meta_date" ;
211
		metaGen[1][0] = "ci_meta_date" ;
212
		metaGen[1][1] = (String)this.get("ci_meta_date") ;
212
		metaGen[1][1] = (String)this.get("ci_meta_date") ;
213
		
213
		
214
		return metaGen ;
214
		return metaGen ;
215
	}
215
	}
216
	
216
	
217
	public String getMotsCles() {
217
	public String getMotsCles() {
218
		
218
		
219
		return renvoyerValeurCorrecte("ci_meta_mots_cles") ;
219
		return renvoyerValeurCorrecte("ci_meta_mots_cles") ;
220
	}
220
	}
221
	
221
	
222
	public void miseAJourInfoGenerales(String commentaires, String date)
222
	public void miseAJourInfoGenerales(String commentaires, String date)
223
	{
223
	{
224
			put("ci_meta_comment",commentaires) ;
224
			put("ci_meta_comment",commentaires) ;
225
		
225
		
226
			put("ci_meta_date",date) ;
226
			put("ci_meta_date",date) ;
227
	}
227
	}
228
 
228
 
229
	public void mettreAjourMotsCles(String motsClesEnCours) {
229
	public void mettreAjourMotsCles(String motsClesEnCours) {
230
		
230
		
231
		put("ci_meta_mots_cles",motsClesEnCours) ;
231
		put("ci_meta_mots_cles",motsClesEnCours) ;
232
		
232
		
233
	}
233
	}
234
}
234
}