Subversion Repositories eFlore/Applications.del

Rev

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

package org.tela_botanica.del.client.modeles;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gwt.user.client.Window;

public class Image {

        private String idImage;
        private Observation observation;
        private String url;
        private String urlFormat;
        private String miniature;
        private List<String> motsClefs;

        public String getUrl() {
                return url;
        }

        public String getMiniature() {
                return miniature;
        }

        public String getUrlFormat(String format) {
                return urlFormat.replaceAll("%s%", format);
        }

        public void setUrlFormat(String urlFormat) {
                this.urlFormat = urlFormat;
        }

        public void setUrl(String url) {
                this.url = url;
        }

        public void setMiniature(String url) {
                miniature = url;
        }

        public String getIdImage() {
                return idImage;
        }

        public void setIdImage(String idImage) {
                this.idImage = idImage;
        }

        // Impossible d'utiliser le type générique Map ici, pourquoi ? je ne sais pas !
        private HashMap<String, HashMap<String, VoteProtocole>> votesProtocoles = new HashMap<String, HashMap<String, VoteProtocole>>();

        public void ajouterVoteProtocole(VoteProtocole voteProcotole) {
                getVotesProtocoles(voteProcotole.getIdProtocole()).put(voteProcotole.getContributeur(), voteProcotole);
        }
        
        public void supprimerVoteProtocole(String idProtocole, String idContributeur) {
                if(utilisateurAVotePourProtocole(idProtocole, idContributeur)) {
                        votesProtocoles.get(idProtocole).remove(idContributeur);
                }
        }
        
        public boolean utilisateurAVotePourProtocole(String idProtocole, String idContributeur) {
                boolean aVote = false;
                if (votesProtocoles.containsKey(idProtocole) && votesProtocoles.get(idProtocole).containsKey(idContributeur)) {
                        aVote = true;
                }
                return aVote;
        }
        
        public HashMap<String, VoteProtocole> getVotesProtocoles(String id_protocole) {
                if(!votesProtocoles.containsKey(""+id_protocole) || votesProtocoles.get(""+id_protocole) == null) {
                        votesProtocoles.put(""+id_protocole, new HashMap<String, VoteProtocole>());
                }
                return votesProtocoles.get(id_protocole+"");
        }
        
        public HashMap<String, VoteProtocole> getVotesProtocoles(int id_protocole) {    
                return getVotesProtocoles(id_protocole+"");
        }
        
        public HashMap<String, HashMap<String, VoteProtocole>> getListeVotesProtocoles() {
                return votesProtocoles;
        }
        
        public void setVoteProtocoles(HashMap<String, HashMap<String, VoteProtocole>> voteProtocoles) {
                this.votesProtocoles = voteProtocoles;
        }

        public void setVoteProtocoles(String id_protocole, HashMap<String, VoteProtocole> voteProtocoles) {
                this.votesProtocoles.put(id_protocole, voteProtocoles);
        }

        public Observation getObservation() {
                return observation;
        }

        public void setObservation(Observation observation) {
                this.observation = observation;
        }
        
        public List<String> getMotsClefs() {
                return motsClefs;
        }

        public void setMotsClefs(List<String> motsClefs) {
                this.motsClefs = motsClefs;
        }

        public void ajouterMotsClef(String motsClefs) {
                if (this.motsClefs == null) {
                        this.motsClefs = new ArrayList<String>();
                }
                this.motsClefs.add(motsClefs);
        }
        
        public boolean estADeterminer() {
                return observation == null || observation.estADeterminer() || motsClefs.contains("aDeterminer");
        }

}