Rev 18 | Rev 30 | 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 java.util.Set;
import com.google.gwt.json.client.JSONObject;
/**
*
* Classe representant une image du carnet,
* elle ne contient pas d'image à proprement parler mais
* plutôt les informations associées ainsi que l'url distante
*
*/
public class ImageCarnet extends HashMap {
public ImageCarnet(JSONObject image)
{
Set im = image.keySet() ;
for (Iterator iterator = im.iterator(); iterator.hasNext();) {
String key = (String) iterator.next();
if(image.get(key).isString() != null)
{
String valeur = image.get(key).isString().stringValue() ;
this.put(key, valeur) ;
}
else
{
String valeur = " " ;
this.put(key, valeur) ;
}
}
}
public String toString()
{
String valeur = " ";
for (Iterator iterator = this.keySet().iterator(); iterator.hasNext();) {
String key = (String) iterator.next();
if(this.get(key) != null)
{
valeur += "cle : "+key+" valeur :"+(String)this.get(key)+"\n" ;
}
}
return valeur ;
}
public String renvoyerValeurCorrecte(String cle)
{
if(this.containsKey((cle)))
{
String valeur = (String)this.get(cle) ;
if(valeur.equals("null"))
{
return "null" ;
}
else
{
char nullChar = '\u0000' ;
String sNull = ""+nullChar ;
valeur = valeur.replaceAll(sNull, "") ;
return valeur ;
}
}
else
{
return "null" ;
}
}
public String getId() {
return renvoyerValeurCorrecte("ci_id_image") ;
}
public String getOrdre() {
return renvoyerValeurCorrecte("ci_ordre") ;
}
public String getBaseUrl()
{
return "http://162.38.234.9/Documents/images_serveur/" ;
}
public String getUrl() {
return getBaseUrl()+(String)this.get("ci_id_image")+".jpg" ;
}
public String getSUrl() {
return getBaseUrl()+(String)this.get("ci_id_image")+"_S.jpg" ;
}
public String getMUrl() {
return getBaseUrl()+(String)this.get("ci_id_image")+"_M.jpg" ;
}
public String getDate() {
return renvoyerValeurCorrecte("ci_meta_date_time") ;
}
public Object getIptcCity() {
return renvoyerValeurCorrecte("ci_meta_iptc_city") ;
}
public String getMake() {
return renvoyerValeurCorrecte("ci_meta_make") ;
}
public String getModel() {
return renvoyerValeurCorrecte("ci_meta_model") ;
}
public String[][] getMetadonnesIptc() {
String[][] metaIptc = new String[12][2] ;
int elem = 0 ;
for (Iterator it = this.keySet().iterator(); it.hasNext();)
{
String key = (String)it.next();
// on filtre le "ci"
String type[] = key.split("_",3) ;
// si c'est une metadonnee exif ou iptc
if(type[1].equals("meta"))
{
String[] genre = type[2].split("_",2) ;
if(genre[0].equals("iptc"))
{
String nom = genre[1] ;
metaIptc[elem][0] = nom ;
metaIptc[elem][1] = renvoyerValeurCorrecte(key) ;
elem++ ;
}
}
}
return metaIptc ;
}
public Object[][] getMetadonnesExif() {
String[][] metaExif = new String[31][2] ;
int elem = 0 ;
for (Iterator it = this.keySet().iterator(); it.hasNext();)
{
String key = (String)it.next();
// on filtre le "ci"
String type[] = key.split("_",3) ;
// si c'est une metadonnee exif ou iptc
if(type[1].equals("meta"))
{
String[] genre = type[2].split("_",2) ;
if(genre[0].equals("exif"))
{
String nom = genre[1] ;
metaExif[elem][0] = nom ;
metaExif[elem][1] = renvoyerValeurCorrecte(key) ;
elem++ ;
}
}
}
return metaExif ;
}
public Object[][] getInfoGenerales() {
String[][] metaGen = new String[2][2] ;
metaGen[0][0] = "ci_meta_comment" ;
metaGen[0][1] = (String)this.get("ci_meta_comment") ;
metaGen[1][0] = "ci_meta_date" ;
metaGen[1][1] = (String)this.get("ci_meta_date") ;
return metaGen ;
}
public void miseAJourInfoGenerales(String commentaires, String date)
{
put("ci_meta_comment",commentaires) ;
put("ci_meta_date",date) ;
}
}