Subversion Repositories eFlore/Applications.coel

Rev

Rev 1426 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1426 Rev 1485
Line 3... Line 3...
3
import java.util.Iterator;
3
import java.util.Iterator;
4
import java.util.Map;
4
import java.util.Map;
5
import java.util.Set;
5
import java.util.Set;
Line 6... Line 6...
6
 
6
 
-
 
7
import org.tela_botanica.client.modeles.aDonnee;
7
import org.tela_botanica.client.modeles.aDonnee;
8
import org.tela_botanica.client.modeles.collection.CollectionAPublication;
8
import org.tela_botanica.client.modeles.personne.Personne;
9
import org.tela_botanica.client.modeles.personne.Personne;
Line -... Line 10...
-
 
10
import org.tela_botanica.client.util.Debug;
9
import org.tela_botanica.client.util.Debug;
11
 
Line 10... Line 12...
10
 
12
import com.extjs.gxt.ui.client.data.ModelData;
Line 11... Line 13...
11
import com.google.gwt.json.client.JSONObject;
13
import com.google.gwt.json.client.JSONObject;
Line 12... Line 14...
12
 
14
 
-
 
15
public class PublicationAPersonne extends aDonnee {
13
public class PublicationAPersonne extends aDonnee {
16
 
14
 
17
	private static final long serialVersionUID = 7769105365939978129L;
15
	private static final long serialVersionUID = 7769105365939978129L;
18
	
Line 16... Line 19...
16
	
19
	public static final String PREFIXE = "cpuap";
Line 25... Line 28...
25
	
28
	
26
	public PublicationAPersonne() {
29
	public PublicationAPersonne() {
27
		new PublicationAPersonne(new JSONObject());
30
		new PublicationAPersonne(new JSONObject());
Line -... Line 31...
-
 
31
	}
-
 
32
	
-
 
33
	public PublicationAPersonne(boolean removePrefix) {
-
 
34
		this.removePrefix = removePrefix;
-
 
35
		new PublicationAPersonne(new JSONObject());
28
	}
36
	}
29
	
37
	
30
	public PublicationAPersonne(JSONObject pubAPersListe) {
38
	public PublicationAPersonne(JSONObject pubAPersListe) {
31
		Personne personne = new Personne(pubAPersListe);
39
		Personne personne = new Personne(pubAPersListe);
Line 37... Line 45...
37
 
45
 
38
		// Parcourt pour chaque clé
46
		// Parcourt pour chaque clé
39
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
47
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
40
			// Si elle est associée à une valeur, nous l'ajoutons
48
			// Si elle est associée à une valeur, nous l'ajoutons
41
			String cle = it.next();
49
			String cle = it.next();
42
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
50
			String cleObjet = "";
-
 
51
			if (removePrefix) cleObjet = cle.replaceFirst("^"+getPrefixe()+"_", "");
43
			String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", "");
52
			else cleObjet=cle;
44
			// Valeur vide par défaut
53
			// Valeur vide par défaut
45
			String valeur = "";
54
			String valeur = "";
46
			if (pubAPersListe.get(cle).isString() != null) {
55
			if (pubAPersListe.get(cle).isString() != null) {
47
				valeur = pubAPersListe.get(cle).isString().stringValue();
-
 
48
				this.set(cleObjet, valeur);
56
				valeur = pubAPersListe.get(cle).isString().stringValue();
49
			} else {
57
			}			
50
				this.set(cleObjet, valeur);
-
 
51
			}
58
			this.set(cleObjet, valeur);
Line 52... Line 59...
52
		}
59
		}
53
		
60
		
Line -... Line 61...
-
 
61
		initialiserChampsPourGrille();
-
 
62
	}
-
 
63
	
-
 
64
	public PublicationAPersonne(ModelData model, boolean removePrefix)
-
 
65
	{
-
 
66
		this.removePrefix = removePrefix;
-
 
67
		
-
 
68
		Map<String, Object> a = model.getProperties();
-
 
69
		
-
 
70
		Set<String> cles = a.keySet();
-
 
71
		Iterator<String> it = cles.iterator();
-
 
72
		while (it.hasNext()) {
-
 
73
			String cle = it.next();
-
 
74
			if (a.get(cle) != null) {
-
 
75
				String cleObjet = "";
-
 
76
				if (removePrefix) {
-
 
77
					cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", "");
-
 
78
					cleObjet = cle.replaceFirst("^"+Publication.PREFIXE+"_", "");
-
 
79
					cleObjet = cleObjet.replaceFirst("^"+PREFIXE+"_", "");
-
 
80
				}
-
 
81
				else {
-
 
82
					cleObjet = cle;
-
 
83
				}
-
 
84
				this.set(cleObjet, a.get(cle));
-
 
85
			}
-
 
86
		}
-
 
87
 
-
 
88
		setPersonne(new Personne(model, removePrefix));
-
 
89
		setPublicationLiee(new Publication(model, removePrefix));
Line 54... Line 90...
54
		initialiserChampsPourGrille();
90
		this.set("_role_", a.get("_role_"));
-
 
91
		this.set("_etat_", a.get("_etat_"));
55
	}
92
	}
56
	
93
	
57
	
94
	private void initialiserChampsPourGrille() {
58
	private void initialiserChampsPourGrille() {
95
		if (removePrefix) {
59
		set("fmt_auteur", publicationLiee.getAuteur());
96
			set("fmt_auteur", publicationLiee.getAuteur());
60
		set("titre", publicationLiee.getTitre());
97
			set("titre", publicationLiee.getTitre());
61
		set("collection", publicationLiee.getCollection());
98
			set("collection", publicationLiee.getCollection());
62
		set("_editeur_", "");
99
			set("_editeur_", "");
-
 
100
			set("_annee_", "");
-
 
101
			set("indication_nvt", publicationLiee.getIndicationNvt());
-
 
102
			set("fascicule", publicationLiee.getFascicule());
-
 
103
			set("truk_pages", publicationLiee.getPages());
-
 
104
			set("_etat_", "");
-
 
105
			set("_role_", this.get("id_role"));
-
 
106
		} else {
-
 
107
			set("cpu_fmt_auteur", publicationLiee.getAuteur());
-
 
108
			set("cpu_titre", publicationLiee.getTitre());
-
 
109
			set("cpu_collection", publicationLiee.getCollection());
-
 
110
			set("_editeur_", "");
63
		set("_annee_", "");
111
			set("_annee_", "");
64
		set("indication_nvt", publicationLiee.getIndicationNvt());
112
			set("cpu_indication_nvt", publicationLiee.getIndicationNvt());
-
 
113
			set("cpu_fascicule", publicationLiee.getFascicule());
65
		set("fascicule", publicationLiee.getFascicule());
114
			set("cpu_truk_pages", publicationLiee.getPages());
Line 66... Line 115...
66
		set("truk_pages", publicationLiee.getPages());
115
			set("_etat_", "");
67
		set("_etat_", "");
116
			set("_role_", this.get("id_role"));
Line 84... Line 133...
84
	public void setPersonne(Personne personne) {
133
	public void setPersonne(Personne personne) {
85
		personneLiee = personne;
134
		personneLiee = personne;
86
		if (personne != null) {
135
		if (personne != null) {
87
			setIdPersonne(personne.getId());
136
			setIdPersonne(personne.getId());
88
		}
137
		}
89
		
138
		/*
90
		Map<String, Object> a = personne.getProperties();
139
		Map<String, Object> a = personne.getProperties();
Line 91... Line 140...
91
 
140
 
92
		Set<String> cles = a.keySet();
141
		Set<String> cles = a.keySet();
93
		Iterator<String> it = cles.iterator();
142
		Iterator<String> it = cles.iterator();
94
		while (it.hasNext()) {
143
		while (it.hasNext()) {
95
			String cle = it.next();			
144
			String cle = it.next();			
-
 
145
			if (a.get(cle) != null) {
-
 
146
				String cleObjet = "";
96
			if (a.get(cle) != null) {
147
				if (removePrefix) {
-
 
148
					cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", "");
-
 
149
				}
-
 
150
				else {
-
 
151
					cleObjet = cle;
97
				String cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", "");
152
				}
98
				this.set(cleObjet, a.get(cle));
153
				this.set(cleObjet, a.get(cle));
99
			}
154
			}
100
		}
155
		}*/
Line 101... Line 156...
101
	}
156
	}
102
	
157
	
103
	// ID
158
	// ID
Line 112... Line 167...
112
		}
167
		}
113
	}
168
	}
Line 114... Line 169...
114
	
169
	
115
	// ID PUBLICATION
170
	// ID PUBLICATION
-
 
171
	public String getIdPublication() {
116
	public String getIdPublication() {
172
		if (removePrefix) return renvoyerValeurCorrecte("id_publication");
117
		return renvoyerValeurCorrecte("id_publication");
173
		else return renvoyerValeurCorrecte("cpuap_id_publication");
118
	}
174
	}
-
 
175
	public void setIdPublication(String id) {
119
	public void setIdPublication(String id) {
176
		if (removePrefix) set("id_publication", id);
120
		set("id_publication", id);
177
		else set("cpuap_id_publication", id);
Line 121... Line 178...
121
	}
178
	}
122
	
179
	
123
	// PUBLICATION LIEE
180
	// PUBLICATION LIEE
Line 141... Line 198...
141
		}
198
		}
142
	}
199
	}
Line 143... Line 200...
143
	
200
	
144
	// ID PERSONNE
201
	// ID PERSONNE
-
 
202
	public String getIdPersonne() {
145
	public String getIdPersonne() {
203
		if (removePrefix) return renvoyerValeurCorrecte("id_personne");
146
		return renvoyerValeurCorrecte("id_personne");
204
		else return renvoyerValeurCorrecte("cpuap_id_personne");
147
	}
205
	}
-
 
206
	public void setIdPersonne(String id) {
148
	public void setIdPersonne(String id) {
207
		if (removePrefix) set("id_personne", id);
149
		set("id_personne", id);
208
		else set(PREFIXE+"_id_personne", id);
Line 150... Line 209...
150
	}
209
	}
151
	
210
	
152
	// ID RôLE
211
	// ID RôLE