Subversion Repositories eFlore/Applications.coel

Rev

Rev 758 | Rev 901 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 758 Rev 775
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
2
 
2
 
3
import java.util.Iterator;
3
import java.util.Iterator;
4
import java.util.Set;
4
import java.util.Set;
5
 
5
 
6
import com.google.gwt.json.client.JSONObject;
6
import com.google.gwt.json.client.JSONObject;
7
 
7
 
8
public class PublicationAPersonne extends aDonnee {
8
public class PublicationAPersonne extends aDonnee {
9
 
9
 
10
	private static final long serialVersionUID = 7769105365939978129L;
10
	private static final long serialVersionUID = 7769105365939978129L;
11
	
11
	
12
	public static final String PREFIXE = "cpuap";
12
	public static final String PREFIXE = "cpuap";
13
	public static final String ROLE_AUTEUR = "2360";
13
	public static final String ROLE_AUTEUR = "2360";
-
 
14
	private Personne personneLiee = null;
14
 
15
	
15
	public PublicationAPersonne(JSONObject pubAPersListe) {
16
	public PublicationAPersonne(JSONObject pubAPersListe) {
-
 
17
		personneLiee = new Personne(pubAPersListe);
-
 
18
		
16
		// l'objet JSON est une table de hachage
19
		// l'objet JSON est une table de hachage
17
		Set<String> im = pubAPersListe.keySet();
20
		Set<String> im = pubAPersListe.keySet();
18
 
21
 
19
		// Parcourt pour chaque clé
22
		// Parcourt pour chaque clé
20
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
23
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
21
			// Si elle est associée à une valeur, nous l'ajoutons
24
			// Si elle est associée à une valeur, nous l'ajoutons
22
			String cle = it.next();
25
			String cle = it.next();
23
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
26
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
24
			String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
27
			String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
25
			// Valeur vide par défaut
28
			// Valeur vide par défaut
26
			String valeur = "";
29
			String valeur = "";
27
			if (pubAPersListe.get(cle).isString() != null) {
30
			if (pubAPersListe.get(cle).isString() != null) {
28
				valeur = pubAPersListe.get(cle).isString().stringValue();
31
				valeur = pubAPersListe.get(cle).isString().stringValue();
29
				this.set(cleObjet, valeur);
32
				this.set(cleObjet, valeur);
30
			} else {
33
			} else {
31
				this.set(cleObjet, valeur);
34
				this.set(cleObjet, valeur);
32
			}
35
			}
33
		}
36
		}
34
	}
37
	}
35
	
38
	
36
	@Override
39
	@Override
37
	protected String getPrefixe() {
40
	protected String getPrefixe() {
38
		return PREFIXE;
41
		return PREFIXE;
39
	}
42
	}
40
 
43
 
41
	public String getIdAuteur() {
44
	public Personne getPersonne() {
42
		return renvoyerValeurCorrecte("id_personne");
-
 
43
	}
-
 
44
	
-
 
45
	public String getNomCompletAuteur() {
-
 
46
		return renvoyerValeurCorrecte("cp_fmt_nom_complet");
45
		return personneLiee;
47
	}
-
 
48
	
-
 
49
	public String getNomAuteur() {
-
 
50
		return renvoyerValeurCorrecte("cp_nom");
-
 
51
	}
-
 
52
	
46
	}
53
	public String getPrenomAuteur() {
47
	public void setPersonne(Personne personne) {
54
		return renvoyerValeurCorrecte("cp_prenom");
48
		personneLiee = personne;
55
	}
-
 
56
	
-
 
57
	public String getPublication() {
-
 
58
		return renvoyerValeurCorrecte("id_publication");
49
	}
59
	}
50
	
60
}
51
}