Subversion Repositories eFlore/Applications.coel

Rev

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

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