Subversion Repositories eFlore/Applications.coel

Rev

Rev 453 | Rev 683 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package org.tela_botanica.client.modeles;

import java.util.Iterator;
import java.util.Set;

import com.google.gwt.json.client.JSONObject;

public class CollectionBotanique extends aDonnee {
        public static final String PREFIXE = "ccb";
        
        public CollectionBotanique() {
        }
        
        public CollectionBotanique(JSONObject botanique) {
                // l'objet JSON est une table de hachage
                Set<String> im = botanique.keySet();

                // Parcourt pour chaque clé
                for (Iterator<String> it = im.iterator(); it.hasNext();) {
                        // Si elle est associée à une valeur, nous l'ajoutons
                        String cle = it.next();
                        if (cle.startsWith(PREFIXE+"_")) {
                                // Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
                                String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
                                // Sinon, nous ajoutons la clé avec une valeur vide
                                String valeur = "";
                                if (botanique.get(cle).isString() != null) {
                                        valeur = botanique.get(cle).isString().stringValue();
                                }
                                this.set(cleObjet, valeur);
                        }
                }
        }
        
        // ID
        public String getId() {
                return renvoyerValeurCorrecte("id_collection");
        }
        public void setId(String idCollection) {
                this.set("id_collection", idCollection);
        }
        
        // TYPE
        public String getType() {
                return renvoyerValeurCorrecte("ce_truk_type");
        }
        public void setType(String type) {
                this.set("ce_truk_type", type);
        }
}