Subversion Repositories eFlore/Applications.cel

Rev

Rev 729 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 729 Rev 965
Line 2... Line 2...
2
 
2
 
3
import java.util.HashMap;
3
import java.util.HashMap;
4
import java.util.Iterator;
4
import java.util.Iterator;
Line -... Line 5...
-
 
5
import java.util.Set;
5
import java.util.Set;
6
 
-
 
7
import com.google.gwt.core.client.GWT;
-
 
8
import com.google.gwt.json.client.JSONObject;
-
 
9
import com.google.gwt.xml.client.Document;
-
 
10
import com.google.gwt.xml.client.NodeList;
Line 6... Line 11...
6
 
11
import com.google.gwt.xml.client.XMLParser;
7
import com.google.gwt.json.client.JSONObject;
12
import com.google.gwt.xml.client.impl.DOMParseException;
8
 
13
 
9
/**
14
/**
Line 105... Line 110...
105
	 * 
110
	 * 
106
	 * @return l'id de l'image
111
	 * @return l'id de l'image
107
	 */
112
	 */
108
	public String getId() {
113
	public String getId() {
Line 109... Line 114...
109
 
114
 
110
		return renvoyerValeurCorrecte("ci_id_image");
115
		return renvoyerValeurCorrecte("id_image");
Line 111... Line 116...
111
	}
116
	}
112
 
117
 
113
	/**
118
	/**
114
	 * Acesseur pour le numero d'ordre de l'image
119
	 * Acesseur pour le numero d'ordre de l'image
115
	 * 
120
	 * 
116
	 * @return l'ordre de l'image
121
	 * @return l'ordre de l'image
Line 117... Line 122...
117
	 */
122
	 */
118
	public String getOrdre() {
123
	public String getOrdre() {
Line 119... Line 124...
119
 
124
 
120
		return renvoyerValeurCorrecte("ci_ordre");
125
		return renvoyerValeurCorrecte("ordre");
121
	}
126
	}
Line 239... Line 244...
239
	 * Renvoie la taille de l'image
244
	 * Renvoie la taille de l'image
240
	 * 
245
	 * 
241
	 * @return un tableau de deux string contenant la hauteur puis la largeur
246
	 * @return un tableau de deux string contenant la hauteur puis la largeur
242
	 */
247
	 */
243
	public String[] getTailleImage() {
248
	public String[] getTailleImage() {
244
		String[] XY = { renvoyerValeurCorrecte("ci_meta_height"),
249
		String[] XY = { renvoyerValeurCorrecte("hauteur"),
245
				renvoyerValeurCorrecte("ci_meta_width") };
250
				renvoyerValeurCorrecte("largeur") };
246
		return XY;
251
		return XY;
247
	}
252
	}
Line 248... Line 253...
248
 
253
 
249
	public String[] getNote() {
254
	public String[] getNote() {
250
		String[] note = { renvoyerValeurCorrecte("ci_note_image") };
255
		String[] note = { renvoyerValeurCorrecte("note_qualite") };
251
		return note;
256
		return note;
Line 252... Line 257...
252
	}
257
	}
253
 
258
 
254
	/**
259
	/**
255
	 * Renvoie la date exif associée à l'image
260
	 * Renvoie la date exif associée à l'image
256
	 * 
261
	 * 
257
	 * @return la date associée à l'image
262
	 * @return la date associée à l'image
Line 258... Line 263...
258
	 */
263
	 */
259
	public String getDate() {
264
	public String getDate() {
260
 
265
 
261
		if(renvoyerValeurCorrecte("ci_meta_date").equals("00/00/0000"))
266
		if(renvoyerValeurCorrecte("date_prise_de_vue").equals("00/00/0000"))
262
		{
267
		{
263
			return "" ;
268
			return "" ;
Line 264... Line 269...
264
		}
269
		}
265
		return renvoyerValeurCorrecte("ci_meta_date");
270
		return renvoyerValeurCorrecte("date_prise_de_vue");
266
	}
271
	}
267
 
272
 
268
	/**
273
	/**
269
	 * Renvoie la ville associée à l'image
274
	 * Renvoie la ville associée à l'image
Line 270... Line 275...
270
	 * 
275
	 * 
271
	 * @return la ville iptc
276
	 * @return la ville iptc
Line 272... Line 277...
272
	 */
277
	 */
273
	public Object getIptcCity() {
278
	public Object getIptcCity() {
274
 
279
 
275
		return renvoyerValeurCorrecte("ci_meta_iptc_city");
280
		return renvoyerValeurCorrecte("");
276
	}
281
	}
277
 
282
 
Line 278... Line 283...
278
	/**
283
	/**
279
	 * Renvoie le fabricant de l'appareil
284
	 * Renvoie le fabricant de l'appareil
Line 280... Line 285...
280
	 * 
285
	 * 
281
	 * @return le fabricant
286
	 * @return le fabricant
282
	 */
287
	 */
283
	public String getMake() {
288
	public String getMake() {
284
 
289
 
285
		return renvoyerValeurCorrecte("ci_meta_make");
290
		return renvoyerValeurCorrecte("appareil_fabricant");
Line 286... Line 291...
286
	}
291
	}
287
 
292
 
Line 288... Line 293...
288
	/**
293
	/**
289
	 * Renvoie le modele de l'appareil
294
	 * Renvoie le modele de l'appareil
290
	 * 
295
	 * 
291
	 * @return le modele
296
	 * @return le modele
292
	 */
297
	 */
293
	public String getModel() {
298
	public String getModel() {
294
 
299
 
295
		return renvoyerValeurCorrecte("ci_meta_model");
300
		return renvoyerValeurCorrecte("appareil_modele");
296
	}
-
 
297
 
301
	}
298
	/**
302
 
299
	 * Renvoie un tableau nom / valeur de toutes les metadonnées Iptc
303
	/**
300
	 * 
304
	 * Renvoie un tableau nom / valeur de toutes les metadonnées Iptc
-
 
305
	 * 
-
 
306
	 * @return les métadonnées iptc
-
 
307
	 */
-
 
308
	public String[][] getMetadonnesIptc() {
-
 
309
		
-
 
310
		String[][] metaIptc = {{},{}};
301
	 * @return les métadonnées iptc
311
		
302
	 */
312
		String xml = renvoyerValeurCorrecte("meta_iptc");
303
	public String[][] getMetadonnesIptc() {
313
		
-
 
314
		String invalidXmlPattern = "[^"
304
 
315
            + "\\u0009\\u000A\\u000D"
305
		String[][] metaIptc = new String[14][2];
316
            + "\\u0020-\\uD7FF"
306
		int elem = 0;
317
            + "\\uE000-\\uFFFD"
307
 
318
            + "\\u10000-\\u10FFFF"
308
		for (Iterator<String> it = this.keySet().iterator(); it.hasNext();) {
319
            + "]+";
309
 
320
		xml = xml.replaceAll(invalidXmlPattern, " ");
310
			String key = it.next();
321
		try {
311
 
322
			Document d = XMLParser.parse(xml);
312
			// on filtre le "ci"
-
 
313
			String type[] = key.split("_", 3);
-
 
314
 
-
 
315
			// si c'est une metadonnee exif ou iptc
323
			NodeList attributs = d.getFirstChild().getChildNodes();
316
			if (type[1].equals("meta")) {
324
 
-
 
325
			
-
 
326
			int taille = attributs.getLength();
-
 
327
			metaIptc = new String[taille][2];
317
				String[] genre = type[2].split("_", 2);
328
			for(int i = 0; i < taille; i++)  {
318
				if (genre[0].equals("iptc")) {
329
				XMLParser.removeWhitespace(attributs.item(i));
319
					String nom = genre[1];
330
				attributs.item(i).normalize();
320
					metaIptc[elem][0] = nom;
331
				metaIptc[i][0] = attributs.item(i).getNodeName();
Line 321... Line 332...
321
					metaIptc[elem][1] = renvoyerValeurCorrecte(key);
332
				metaIptc[i][1] = attributs.item(i).getNodeValue();
322
					elem++;
333
			}
323
				}
334
			
324
 
335
			return metaIptc;
325
			}
336
		} catch(DOMParseException e) {
326
 
337
			
327
		}
338
		}	
328
 
339
		
329
		return metaIptc;
-
 
330
	}
340
		return metaIptc;
331
 
341
	}
332
	/**
342
 
333
	 * Renvoie un tableau nom / valeur de toutes les metadonnées Exif
343
	/**
-
 
344
	 * Renvoie un tableau nom / valeur de toutes les metadonnées Exif
-
 
345
	 * 
-
 
346
	 * @return les métadonnées Exif
-
 
347
	 */
-
 
348
	public String[][] getMetadonnesExif() {
-
 
349
		
334
	 * 
350
		String[][] metaExif = {{},{}};
-
 
351
		
335
	 * @return les métadonnées Exif
352
		String xml = renvoyerValeurCorrecte("meta_exif");
336
	 */
353
		
337
	public String[][] getMetadonnesExif() {
354
		String invalidXmlPattern = "[^"
338
 
355
		                             + "\\u0009\\u000A\\u000D"
339
		String[][] metaExif = new String[31][2];
356
		                             + "\\u0020-\\uD7FF"
340
		int elem = 0;
357
		                             + "\\uE000-\\uFFFD"
341
 
358
		                             + "\\u10000-\\u10FFFF"
342
		for (Iterator<String> it = this.keySet().iterator(); it.hasNext();) {
359
		                             + "]+";
343
 
360
		xml = xml.replaceAll(invalidXmlPattern, " ");
344
			String key = it.next();
361
 
345
 
-
 
346
			// on filtre le "ci"
-
 
347
			String type[] = key.split("_", 3);
-
 
348
 
362
		try {
-
 
363
			Document d = XMLParser.parse(xml);
349
			// si c'est une metadonnee exif ou iptc
364
			NodeList attributs = d.getFirstChild().getChildNodes();
350
			if (type[1].equals("meta")) {
365
			
351
				String[] genre = type[2].split("_", 2);
366
			int taille = attributs.getLength();
352
				if (genre[0].equals("exif")) {
367
			metaExif = new String[taille][2];
Line 353... Line 368...
353
					String nom = genre[1];
368
			for(int i = 0; i < taille; i++)  {
Line 354... Line 369...
354
					metaExif[elem][0] = nom;
369
				XMLParser.removeWhitespace(attributs.item(i));
Line 371... Line 386...
371
	 */
386
	 */
372
	public String[][] getInfoGenerales() {
387
	public String[][] getInfoGenerales() {
Line 373... Line 388...
373
 
388
 
Line 374... Line 389...
374
		String[][] metaGen = new String[2][2];
389
		String[][] metaGen = new String[2][2];
375
 
390
 
Line 376... Line 391...
376
		metaGen[0][0] = "ci_meta_comment";
391
		metaGen[0][0] = "commentaire";
377
		metaGen[0][1] = this.renvoyerValeurCorrecte("ci_meta_comment");
392
		metaGen[0][1] = this.renvoyerValeurCorrecte("commentaire");
Line 378... Line 393...
378
 
393
 
379
		metaGen[1][0] = "ci_meta_date";
394
		metaGen[1][0] = "date_prise_de_vue";
Line 380... Line 395...
380
		metaGen[1][1] = this.renvoyerValeurCorrecte("ci_meta_date");
395
		metaGen[1][1] = this.renvoyerValeurCorrecte("date_prise_de_vue");
Line 387... Line 402...
387
	 * 
402
	 * 
388
	 * @return les mots clés
403
	 * @return les mots clés
389
	 */
404
	 */
390
	public String getMotsCles() {
405
	public String getMotsCles() {
Line 391... Line 406...
391
 
406
 
392
		return renvoyerValeurCorrecte("ci_meta_mots_cles");
407
		return renvoyerValeurCorrecte("mots_cles");
Line 393... Line 408...
393
	}
408
	}
394
 
409
 
395
	/**
410
	/**
Line 400... Line 415...
400
	 * @param date
415
	 * @param date
401
	 *            la nouvelle date
416
	 *            la nouvelle date
402
	 */
417
	 */
403
	public void miseAJourInfoGenerales(String commentaires, String date,
418
	public void miseAJourInfoGenerales(String commentaires, String date,
404
			String note) {
419
			String note) {
405
		put("ci_meta_comment", commentaires);
420
		put("commentaire", commentaires);
406
		put("ci_note_image", note);
421
		put("note_qualite", note);
407
		put("ci_meta_date", date);
422
		put("date_prise_de_vue", date);
408
	}
423
	}
Line 409... Line 424...
409
 
424
 
410
	/**
425
	/**
411
	 * Met à jour les mots clés
426
	 * Met à jour les mots clés
412
	 * 
427
	 * 
413
	 * @param motsClesEnCours
428
	 * @param motsClesEnCours
414
	 *            la liste de mots clés séparés par des ','
429
	 *            la liste de mots clés séparés par des ','
415
	 */
430
	 */
Line 416... Line 431...
416
	public void mettreAjourMotsCles(String motsClesEnCours) {
431
	public void mettreAjourMotsCles(String motsClesEnCours) {
Line 417... Line 432...
417
 
432
 
Line 418... Line 433...
418
		put("ci_meta_mots_cles", motsClesEnCours);
433
		put("mots_cles", motsClesEnCours);
419
 
434
 
420
	}
435
	}
Line 421... Line 436...
421
	
436
	
422
	public void mettreAjourObsAssociees(String idsObsAssociees) {
437
	public void mettreAjourObsAssociees(String idsObsAssociees) {
423
		put("ci_ce_observation", idsObsAssociees);
438
		put("id_observation", idsObsAssociees);
424
	}
439
	}
425
	
440
	
426
	/**
441
	/**
427
	 * Accesseur pour le nom original
442
	 * Accesseur pour le nom original
428
	 * 
443
	 * 
Line 429... Line 444...
429
	 * @return le nom orginal de l'image
444
	 * @return le nom orginal de l'image
Line 430... Line 445...
430
	 */
445
	 */
431
	public String getNomOriginal() {
446
	public String getNomOriginal() {
Line 432... Line 447...
432
		return renvoyerValeurCorrecte("ci_nom_original");
447
		return renvoyerValeurCorrecte("nom_original");
433
	}
448
	}