Subversion Repositories eFlore/Applications.coel

Rev

Rev 268 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

package org.tela_botanica.client.modeles;

import java.util.LinkedHashMap;

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

/**
 * Table de hachage composée d'informations sur les Valeurs des listes, renvoyé par un objet de type DAO
 * La clé est l'id de l'entite.
 * 
 * @author Grégoire DUCHÉ
 * 
 */
public class ProjetListe extends LinkedHashMap<String, Projet> {
        
        private int id = 0;
        
        /**
         * Constructeur sans paramètres 
         */
        public ProjetListe() {
                super();
        }
        
        /**
         * Constructeur avec paramètre
         * @param taille la taille de la table de hachage
         */
        public ProjetListe(int taille) {
                super(taille);
        }
        
        /**
         * Constructeur pour une liste de projets
         * @param dates
         */
        public ProjetListe(JSONArray projetsListe) {
                super(projetsListe.size());
                
                final int taillemax = projetsListe.size();
                
                for (int i = 0; i < taillemax; i++) {
                        JSONObject projetCourant = projetsListe.get(i).isObject() ;
                        
                        if (projetCourant != null)      {
                                Projet projet = new Projet(projetCourant);
                                this.put(projet.getId(), projet);                               
                        }
                }
        }
        
        /**
         * @param id l'identifiant à définir
         */
        public void setId(int id) {
                this.id = id;
        }

        /**
         * @return l'identifiant de la liste
         */
        public Integer getId() {
                return id;
        }
}