Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 1428 Rev 1513
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 79... Line 128...
79
	}
128
	}
Line 80... Line 129...
80
	
129
	
81
	public Personne getPersonne() {
130
	public Personne getPersonne() {
82
		return personneLiee;
131
		return personneLiee;
-
 
132
	}
83
	}
133
	
-
 
134
	public void setPersonne(Personne personne) {
-
 
135
		setPersonne(personne, false);
-
 
136
	}
-
 
137
	
84
	public void setPersonne(Personne personne) {
138
	public void setPersonne(Personne personne, boolean integrerProprietes) {
85
		personneLiee = personne;
139
		personneLiee = personne;
86
		if (personne != null) {
140
		if (personne != null) {
87
			setIdPersonne(personne.getId());
141
			setIdPersonne(personne.getId());
Line -... Line 142...
-
 
142
		}
88
		}
143
		
89
		
144
		if (integrerProprietes) {
90
		Map<String, Object> a = personne.getProperties();
145
			Map<String, Object> a = personne.getProperties();
91
 
146
	
92
		Set<String> cles = a.keySet();
147
			Set<String> cles = a.keySet();
93
		Iterator<String> it = cles.iterator();
148
			Iterator<String> it = cles.iterator();
94
		while (it.hasNext()) {
149
			while (it.hasNext()) {
-
 
150
				String cle = it.next();			
-
 
151
				if (a.get(cle) != null) {
95
			String cle = it.next();			
152
					String cleObjet = "";
-
 
153
					if (removePrefix) {
-
 
154
						cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", "");
-
 
155
					}
-
 
156
					else {
96
			if (a.get(cle) != null) {
157
						cleObjet = cle;
-
 
158
					}
97
				String cleObjet = cle.replaceFirst("^"+Personne.PREFIXE+"_", "");
159
					this.set(cleObjet, a.get(cle));
98
				this.set(cleObjet, a.get(cle));
160
				}
99
			}
161
			}
Line 100... Line 162...
100
		}
162
		}
Line 112... Line 174...
112
		}
174
		}
113
	}
175
	}
Line 114... Line 176...
114
	
176
	
115
	// ID PUBLICATION
177
	// ID PUBLICATION
-
 
178
	public String getIdPublication() {
116
	public String getIdPublication() {
179
		if (removePrefix) return renvoyerValeurCorrecte("id_publication");
117
		return renvoyerValeurCorrecte("id_publication");
180
		else return renvoyerValeurCorrecte("cpuap_id_publication");
118
	}
181
	}
-
 
182
	public void setIdPublication(String id) {
119
	public void setIdPublication(String id) {
183
		if (removePrefix) set("id_publication", id);
120
		set("id_publication", id);
184
		else set("cpuap_id_publication", id);
Line 121... Line 185...
121
	}
185
	}
122
	
186
	
123
	// PUBLICATION LIEE
187
	// PUBLICATION LIEE
Line 141... Line 205...
141
		}
205
		}
142
	}
206
	}
Line 143... Line 207...
143
	
207
	
144
	// ID PERSONNE
208
	// ID PERSONNE
-
 
209
	public String getIdPersonne() {
145
	public String getIdPersonne() {
210
		if (removePrefix) return renvoyerValeurCorrecte("id_personne");
146
		return renvoyerValeurCorrecte("id_personne");
211
		else return renvoyerValeurCorrecte("cpuap_id_personne");
147
	}
212
	}
-
 
213
	public void setIdPersonne(String id) {
148
	public void setIdPersonne(String id) {
214
		if (removePrefix) set("id_personne", id);
149
		set("id_personne", id);
215
		else set(PREFIXE+"_id_personne", id);
Line 150... Line 216...
150
	}
216
	}
151
	
217
	
152
	// ID RôLE
218
	// ID RôLE
Line 168... Line 234...
168
		setChaineDenormaliseUnique("ce_truk_type", type, valeur);
234
		setChaineDenormaliseUnique("ce_truk_type", type, valeur);
169
	}
235
	}
Line 170... Line 236...
170
	
236
	
171
	// ORDRE DES AUTEURS
237
	// ORDRE DES AUTEURS
-
 
238
	public String getOrdreAuteurs() {
172
	public String getOrdreAuteurs() {
239
		if (removePrefix) return renvoyerValeurCorrecte("ordre");
173
		return renvoyerValeurCorrecte("ordre");
240
		else return renvoyerValeurCorrecte(PREFIXE+"_ordre");
174
	}
241
	}
175
	public void setOrdreAuteurs(String ordre) {
242
	public void setOrdreAuteurs(String ordre) {
-
 
243
		if (ordre.matches("[0-9]+")) {
-
 
244
			if (removePrefix) this.set("ordre", ordre);
-
 
245
			else this.set(PREFIXE+"_ordre", ordre);
176
		if (ordre.matches("[0-9]+")) {
246
			
177
			this.set("ordre", ordre);
247
			this.set("_ordre_", ordre);
178
		}
248
		}
179
	}
249
	}
180
}
250
}