Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 935 Rev 992
1
package org.tela_botanica.client.modeles.publication;
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
 
5
 
6
import org.tela_botanica.client.modeles.aDonnee;
6
import org.tela_botanica.client.modeles.aDonnee;
7
import org.tela_botanica.client.modeles.personne.Personne;
7
import org.tela_botanica.client.modeles.personne.Personne;
8
 
8
 
9
import com.google.gwt.json.client.JSONObject;
9
import com.google.gwt.json.client.JSONObject;
10
 
10
 
11
public class PublicationAPersonne extends aDonnee {
11
public class PublicationAPersonne extends aDonnee {
12
 
12
 
13
	private static final long serialVersionUID = 7769105365939978129L;
13
	private static final long serialVersionUID = 7769105365939978129L;
14
	
14
	
15
	public static final String PREFIXE = "cpuap";
15
	public static final String PREFIXE = "cpuap";
16
	public static final String ROLE_AUTEUR = "2360";
16
	public static final String ROLE_AUTEUR = "2360";
-
 
17
	//FIXME: insérer en base de données une valeur cohérente pour l'identifiant ci-dessous
-
 
18
	public static final String ROLE_SUJET = "30762";
-
 
19
	
17
	private Personne personneLiee = null;
20
	private Personne personneLiee = null;
-
 
21
	private Publication publicationLiee = null;
18
	
22
	
-
 
23
	public PublicationAPersonne() {
-
 
24
		new PublicationAPersonne(new JSONObject());
19
	public PublicationAPersonne() {}
25
	}
20
	
26
	
21
	public PublicationAPersonne(JSONObject pubAPersListe) {
27
	public PublicationAPersonne(JSONObject pubAPersListe) {
22
		personneLiee = new Personne(pubAPersListe);
28
		personneLiee = new Personne(pubAPersListe);
-
 
29
		publicationLiee = new Publication(pubAPersListe);
-
 
30
		
23
		
31
		System.out.println("publication liee : " + publicationLiee);
24
		// l'objet JSON est une table de hachage
32
		// l'objet JSON est une table de hachage
25
		Set<String> im = pubAPersListe.keySet();
33
		Set<String> im = pubAPersListe.keySet();
26
 
34
 
27
		// Parcourt pour chaque clé
35
		// Parcourt pour chaque clé
28
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
36
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
29
			// Si elle est associée à une valeur, nous l'ajoutons
37
			// Si elle est associée à une valeur, nous l'ajoutons
30
			String cle = it.next();
38
			String cle = it.next();
31
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
39
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
32
			String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
40
			String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
33
			// Valeur vide par défaut
41
			// Valeur vide par défaut
34
			String valeur = "";
42
			String valeur = "";
35
			if (pubAPersListe.get(cle).isString() != null) {
43
			if (pubAPersListe.get(cle).isString() != null) {
36
				valeur = pubAPersListe.get(cle).isString().stringValue();
44
				valeur = pubAPersListe.get(cle).isString().stringValue();
37
				this.set(cleObjet, valeur);
45
				this.set(cleObjet, valeur);
38
			} else {
46
			} else {
39
				this.set(cleObjet, valeur);
47
				this.set(cleObjet, valeur);
40
			}
48
			}
41
		}
49
		}
-
 
50
		
-
 
51
		initialiserChampsPourGrille();
-
 
52
	}
-
 
53
	
-
 
54
	
-
 
55
	private void initialiserChampsPourGrille() {
-
 
56
		set("fmt_auteur", publicationLiee.getAuteur());
-
 
57
		set("titre", publicationLiee.getTitre());
-
 
58
		set("collection", publicationLiee.getCollection());
-
 
59
		set("_editeur_", "");
-
 
60
		set("_annee_", "");
-
 
61
		set("indication_nvt", publicationLiee.getIndicationNvt());
-
 
62
		set("fascicule", publicationLiee.getFascicule());
-
 
63
		set("truk_pages", publicationLiee.getPages());
-
 
64
		set("_etat_", "");
42
	}
65
	}
-
 
66
	
43
	
67
	
44
	@Override
68
	@Override
45
	protected String getPrefixe() {
69
	protected String getPrefixe() {
46
		return PREFIXE;
70
		return PREFIXE;
47
	}
71
	}
48
 
72
 
49
	public Personne getPersonne() {
73
	public Personne getPersonne() {
50
		return personneLiee;
74
		return personneLiee;
51
	}
75
	}
52
	public void setPersonne(Personne personne) {
76
	public void setPersonne(Personne personne) {
53
		personneLiee = personne;
77
		personneLiee = personne;
54
		if (personne != null) {
78
		if (personne != null) {
55
			setIdPersonne(personne.getId());
79
			setIdPersonne(personne.getId());
56
		}
80
		}
57
	}
81
	}
58
	
82
	
59
	// ID
83
	// ID
60
	public String getId() {
84
	public String getId() {
61
		String idPublication = getIdPublication();
85
		String idPublication = getIdPublication();
62
		String idPersonne = getIdPersonne();
86
		String idPersonne = getIdPersonne();
63
		String idRole = getIdRole();
87
		String idRole = getIdRole();
64
		if (idPublication.equals("") && idPersonne.equals("") && idRole.equals("")) {
88
		if (idPublication.equals("") && idPersonne.equals("") && idRole.equals("")) {
65
			return null;
89
			return null;
66
		} else {
90
		} else {
67
			return (idPublication+"-"+idPersonne+"-"+idRole);
91
			return (idPublication+"-"+idPersonne+"-"+idRole);
68
		}
92
		}
69
	}
93
	}
70
	
94
	
71
	// ID PUBLICATION
95
	// ID PUBLICATION
72
	public String getIdPublication() {
96
	public String getIdPublication() {
73
		return renvoyerValeurCorrecte("id_publication");
97
		return renvoyerValeurCorrecte("id_publication");
74
	}
98
	}
75
	public void setIdPublication(String id) {
99
	public void setIdPublication(String id) {
76
		set("id_publication", id);
100
		set("id_publication", id);
77
	}
101
	}
-
 
102
	
-
 
103
	// PUBLICATION LIEE
-
 
104
	public Publication getPublicationLiee()	{
-
 
105
		return this.publicationLiee;
-
 
106
	}
-
 
107
	
-
 
108
	// LIER PUBLICATION
-
 
109
	public void setPublicationLiee(Publication publication)	{
-
 
110
		this.publicationLiee = publication;
-
 
111
		initialiserChampsPourGrille();
-
 
112
	}
78
	
113
	
79
	// ID PERSONNE
114
	// ID PERSONNE
80
	public String getIdPersonne() {
115
	public String getIdPersonne() {
81
		return renvoyerValeurCorrecte("id_personne");
116
		return renvoyerValeurCorrecte("id_personne");
82
	}
117
	}
83
	public void setIdPersonne(String id) {
118
	public void setIdPersonne(String id) {
84
		set("id_personne", id);
119
		set("id_personne", id);
85
	}
120
	}
86
	
121
	
87
	// ID RôLE
122
	// ID RôLE
88
	public String getIdRole() {
123
	public String getIdRole() {
89
		return renvoyerValeurCorrecte("id_role");
124
		return renvoyerValeurCorrecte("id_role");
90
	}
125
	}
91
	public void setIdRole(String id) {
126
	public void setIdRole(String id) {
92
		set("id_role", id);
127
		set("id_role", id);
93
	}
128
	}
94
		
129
		
95
	// TYPE
130
	// TYPE
96
	public String getType() {
131
	public String getType() {
97
		return renvoyerValeurCorrecte("ce_truk_type");
132
		return renvoyerValeurCorrecte("ce_truk_type");
98
	}
133
	}
99
	public void setType(String type) {
134
	public void setType(String type) {
100
		set("ce_truk_type", type);
135
		set("ce_truk_type", type);
101
	}
136
	}
102
	public void setFonction(String type, String valeur) {
137
	public void setFonction(String type, String valeur) {
103
		setChaineDenormaliseUnique("ce_truk_type", type, valeur);
138
		setChaineDenormaliseUnique("ce_truk_type", type, valeur);
104
	}
139
	}
105
}
140
}