Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 901 Rev 935
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles.publication;
2
 
2
 
3
import java.util.Iterator;
3
import java.util.Iterator;
4
import java.util.Set;
4
import java.util.Set;
-
 
5
 
-
 
6
import org.tela_botanica.client.modeles.aDonnee;
-
 
7
import org.tela_botanica.client.modeles.personne.Personne;
5
 
8
 
6
import com.google.gwt.json.client.JSONObject;
9
import com.google.gwt.json.client.JSONObject;
7
 
10
 
8
public class PublicationAPersonne extends aDonnee {
11
public class PublicationAPersonne extends aDonnee {
9
 
12
 
10
	private static final long serialVersionUID = 7769105365939978129L;
13
	private static final long serialVersionUID = 7769105365939978129L;
11
	
14
	
12
	public static final String PREFIXE = "cpuap";
15
	public static final String PREFIXE = "cpuap";
13
	public static final String ROLE_AUTEUR = "2360";
16
	public static final String ROLE_AUTEUR = "2360";
14
	private Personne personneLiee = null;
17
	private Personne personneLiee = null;
15
	
18
	
16
	public PublicationAPersonne() {}
19
	public PublicationAPersonne() {}
17
	
20
	
18
	public PublicationAPersonne(JSONObject pubAPersListe) {
21
	public PublicationAPersonne(JSONObject pubAPersListe) {
19
		personneLiee = new Personne(pubAPersListe);
22
		personneLiee = new Personne(pubAPersListe);
20
		
23
		
21
		// l'objet JSON est une table de hachage
24
		// l'objet JSON est une table de hachage
22
		Set<String> im = pubAPersListe.keySet();
25
		Set<String> im = pubAPersListe.keySet();
23
 
26
 
24
		// Parcourt pour chaque clé
27
		// Parcourt pour chaque clé
25
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
28
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
26
			// Si elle est associée à une valeur, nous l'ajoutons
29
			// Si elle est associée à une valeur, nous l'ajoutons
27
			String cle = it.next();
30
			String cle = it.next();
28
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
31
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
29
			String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
32
			String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
30
			// Valeur vide par défaut
33
			// Valeur vide par défaut
31
			String valeur = "";
34
			String valeur = "";
32
			if (pubAPersListe.get(cle).isString() != null) {
35
			if (pubAPersListe.get(cle).isString() != null) {
33
				valeur = pubAPersListe.get(cle).isString().stringValue();
36
				valeur = pubAPersListe.get(cle).isString().stringValue();
34
				this.set(cleObjet, valeur);
37
				this.set(cleObjet, valeur);
35
			} else {
38
			} else {
36
				this.set(cleObjet, valeur);
39
				this.set(cleObjet, valeur);
37
			}
40
			}
38
		}
41
		}
39
	}
42
	}
40
	
43
	
41
	@Override
44
	@Override
42
	protected String getPrefixe() {
45
	protected String getPrefixe() {
43
		return PREFIXE;
46
		return PREFIXE;
44
	}
47
	}
45
 
48
 
46
	public Personne getPersonne() {
49
	public Personne getPersonne() {
47
		return personneLiee;
50
		return personneLiee;
48
	}
51
	}
49
	public void setPersonne(Personne personne) {
52
	public void setPersonne(Personne personne) {
50
		personneLiee = personne;
53
		personneLiee = personne;
51
		if (personne != null) {
54
		if (personne != null) {
52
			setIdPersonne(personne.getId());
55
			setIdPersonne(personne.getId());
53
		}
56
		}
54
	}
57
	}
55
	
58
	
56
	// ID
59
	// ID
57
	public String getId() {
60
	public String getId() {
58
		String idPublication = getIdPublication();
61
		String idPublication = getIdPublication();
59
		String idPersonne = getIdPersonne();
62
		String idPersonne = getIdPersonne();
60
		String idRole = getIdRole();
63
		String idRole = getIdRole();
61
		if (idPublication.equals("") && idPersonne.equals("") && idRole.equals("")) {
64
		if (idPublication.equals("") && idPersonne.equals("") && idRole.equals("")) {
62
			return null;
65
			return null;
63
		} else {
66
		} else {
64
			return (idPublication+"-"+idPersonne+"-"+idRole);
67
			return (idPublication+"-"+idPersonne+"-"+idRole);
65
		}
68
		}
66
	}
69
	}
67
	
70
	
68
	// ID PUBLICATION
71
	// ID PUBLICATION
69
	public String getIdPublication() {
72
	public String getIdPublication() {
70
		return renvoyerValeurCorrecte("id_publication");
73
		return renvoyerValeurCorrecte("id_publication");
71
	}
74
	}
72
	public void setIdPublication(String id) {
75
	public void setIdPublication(String id) {
73
		set("id_publication", id);
76
		set("id_publication", id);
74
	}
77
	}
75
	
78
	
76
	// ID PERSONNE
79
	// ID PERSONNE
77
	public String getIdPersonne() {
80
	public String getIdPersonne() {
78
		return renvoyerValeurCorrecte("id_personne");
81
		return renvoyerValeurCorrecte("id_personne");
79
	}
82
	}
80
	public void setIdPersonne(String id) {
83
	public void setIdPersonne(String id) {
81
		set("id_personne", id);
84
		set("id_personne", id);
82
	}
85
	}
83
	
86
	
84
	// ID RôLE
87
	// ID RôLE
85
	public String getIdRole() {
88
	public String getIdRole() {
86
		return renvoyerValeurCorrecte("id_role");
89
		return renvoyerValeurCorrecte("id_role");
87
	}
90
	}
88
	public void setIdRole(String id) {
91
	public void setIdRole(String id) {
89
		set("id_role", id);
92
		set("id_role", id);
90
	}
93
	}
91
		
94
		
92
	// TYPE
95
	// TYPE
93
	public String getType() {
96
	public String getType() {
94
		return renvoyerValeurCorrecte("ce_truk_type");
97
		return renvoyerValeurCorrecte("ce_truk_type");
95
	}
98
	}
96
	public void setType(String type) {
99
	public void setType(String type) {
97
		set("ce_truk_type", type);
100
		set("ce_truk_type", type);
98
	}
101
	}
99
	public void setFonction(String type, String valeur) {
102
	public void setFonction(String type, String valeur) {
100
		setChaineDenormaliseUnique("ce_truk_type", type, valeur);
103
		setChaineDenormaliseUnique("ce_truk_type", type, valeur);
101
	}
104
	}
102
}
105
}