Subversion Repositories eFlore/Applications.coel

Rev

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

Rev 230 Rev 238
1
package org.tela_botanica.client.modeles;
1
package org.tela_botanica.client.modeles;
2
 
2
 
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;
6
 
6
 
7
import com.google.gwt.http.client.URL;
7
import com.google.gwt.http.client.URL;
8
import com.google.gwt.json.client.JSONObject;
8
import com.google.gwt.json.client.JSONObject;
9
import com.google.gwt.user.client.Window;
9
import com.google.gwt.user.client.Window;
10
 
10
 
11
public class Publication extends aDonnee {
11
public class Publication extends aDonnee {
12
 
12
 
13
	/**
13
	/**
14
	 * Préfixe à retirer pour construire les noms des clés
14
	 * Préfixe à retirer pour construire les noms des clés
15
	 * et à rajouter lors de la transformation en requête
15
	 * et à rajouter lors de la transformation en requête
16
	 */
16
	 */
17
	private static String prefixe = "cpu_";
17
	private static String prefixe = "cpu_";
18
	
18
	
19
	/**
19
	/**
20
	 * Constructeur vide
20
	 * Constructeur vide
21
	 * 
21
	 * 
22
	 */
22
	 */
23
	public Publication() {
23
	public Publication() {
24
		
24
		
25
	}
25
	}
26
	
26
	
27
	/**
27
	/**
28
	 * Constructeur avec un objet JSON
28
	 * Constructeur avec un objet JSON
29
	 * 
29
	 * 
30
	 * @param image
30
	 * @param image
31
	 */
31
	 */
32
	public Publication(JSONObject institution) {
32
	public Publication(JSONObject institution) {
33
		// l'objet JSON est une table de hachage
33
		// l'objet JSON est une table de hachage
34
		Set<String> im = institution.keySet();
34
		Set<String> im = institution.keySet();
35
 
35
 
36
		// Parcourt pour chaque clé
36
		// Parcourt pour chaque clé
37
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
37
		for (Iterator<String> it = im.iterator(); it.hasNext();) {
38
			// Si elle est associée à une valeur, nous l'ajoutons
38
			// Si elle est associée à une valeur, nous l'ajoutons
39
			String cle = it.next();
39
			String cle = it.next();
40
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
40
			// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet
41
			String cleObjet = cle.replaceFirst("^"+prefixe, "");
41
			String cleObjet = cle.replaceFirst("^"+prefixe, "");
42
			if (institution.get(cle).isString() != null) {
42
			if (institution.get(cle).isString() != null) {
43
				String valeur = institution.get(cle).isString().stringValue();
43
				String valeur = institution.get(cle).isString().stringValue();
44
				this.set(cleObjet, valeur);
44
				this.set(cleObjet, valeur);
45
			} else {
45
			} else {
46
				// Sinon, nous ajoutons la clé avec une valeur vide
46
				// Sinon, nous ajoutons la clé avec une valeur vide
47
				String valeur = " ";
47
				String valeur = " ";
48
				this.set(cleObjet, valeur);
48
				this.set(cleObjet, valeur);
49
			}
49
			}
50
		}
50
		}
51
	}
51
	}
52
	
52
	
53
	public Publication(String nom_complet, String uri, String auteur, String collection, String titre, String editeur,
53
	public Publication(String nom_complet, String uri, String auteur, String collection, String titre, String editeur,
54
			String dateParution, String indicationNvt, String fascicule, String pages) {
54
			String dateParution, String indicationNvt, String fascicule, String pages) {
55
		this.set("fmt_nom_complet", nom_complet);
55
		this.set("fmt_nom_complet", nom_complet);
56
		this.set("ce_projet", "");
56
		this.set("ce_projet", "");
57
		this.set("uri", uri);
57
		this.set("uri", uri);
58
		this.set("fmt_auteur", auteur);
58
		this.set("fmt_auteur", auteur);
59
		this.set("collection", collection);
59
		this.set("collection", collection);
60
		this.set("titre", nom_complet);
60
		this.set("titre", nom_complet);
61
		this.set("fmt_nom_complet", titre);
61
		this.set("fmt_nom_complet", titre);
62
		this.set("ce_truk_editeur", editeur);
62
		this.set("ce_truk_editeur", editeur);
63
		this.set("date_parution", dateParution);
63
		this.set("date_parution", dateParution);
64
		this.set("indication_nvt", indicationNvt);
64
		this.set("indication_nvt", indicationNvt);
65
		this.set("fascicule", fascicule);
65
		this.set("fascicule", fascicule);
66
		this.set("truk_pages", pages);
66
		this.set("truk_pages", pages);
67
		this.set("ce_meta", "");
67
		this.set("ce_meta", "");
68
	}
68
	}
69
	
69
	
70
	public Publication(String idPublication,String idProjet, String nom_complet, String uri, String auteur, String collection, String titre, String editeur,
70
	public Publication(String idPublication,String idProjet, String nom_complet, String uri, String auteur, String collection, String titre, String editeur,
71
			String dateParution, String indicationNvt, String fascicule, String pages) {
71
			String dateParution, String indicationNvt, String fascicule, String pages) {
72
		this.set("id_publication", idPublication);
72
		this.set("id_publication", idPublication);
73
		this.set("ce_projet", idProjet);
73
		this.set("ce_projet", idProjet);
74
		this.set("fmt_nom_complet", nom_complet);
74
		this.set("fmt_nom_complet", nom_complet);
75
		this.set("uri", uri);
75
		this.set("uri", uri);
76
		this.set("fmt_auteur", auteur);
76
		this.set("fmt_auteur", auteur);
77
		this.set("collection", collection);
77
		this.set("collection", collection);
78
		this.set("titre", nom_complet);
78
		this.set("titre", nom_complet);
79
		this.set("fmt_nom_complet", titre);
79
		this.set("fmt_nom_complet", titre);
80
		this.set("ce_truk_editeur", editeur);
80
		this.set("ce_truk_editeur", editeur);
81
		this.set("date_parution", dateParution);
81
		this.set("date_parution", dateParution);
82
		this.set("indication_nvt", indicationNvt);
82
		this.set("indication_nvt", indicationNvt);
83
		this.set("fascicule", fascicule);
83
		this.set("fascicule", fascicule);
84
		this.set("truk_pages", pages);
84
		this.set("truk_pages", pages);
85
		this.set("ce_meta", "");
85
		this.set("ce_meta", "");
86
	}
86
	}
87
 
87
 
88
	public String getId() {
88
	public String getId() {
89
		return (String) renvoyerValeurCorrecte("id_publication");
89
		return (String) renvoyerValeurCorrecte("id_publication");
90
	}
90
	}
91
	
91
	
92
	public String getProjet() {
92
	public String getProjet() {
93
		return (String) renvoyerValeurCorrecte("ce_projet");
93
		return (String) renvoyerValeurCorrecte("ce_projet");
94
	}
94
	}
95
	
95
	
96
	public String getNomComplet() {
96
	public String getNomComplet() {
97
		return (String) renvoyerValeurCorrecte("fmt_nom_complet");
97
		return (String) renvoyerValeurCorrecte("fmt_nom_complet");
98
	}
98
	}
99
	
99
	
100
	public String getURI() {
100
	public String getURI() {
101
		return (String) renvoyerValeurCorrecte("uri");
101
		return (String) renvoyerValeurCorrecte("uri");
102
	}
102
	}
103
 
103
 
104
	public String getAuteur() {
104
	public String getAuteur() {
105
		return (String) renvoyerValeurCorrecte("fmt_auteur");
105
		return (String) renvoyerValeurCorrecte("fmt_auteur");
106
	}
106
	}
107
 
107
 
108
	public String getCollection() {
108
	public String getCollection() {
109
		return (String) renvoyerValeurCorrecte("collection");
109
		return (String) renvoyerValeurCorrecte("collection");
110
	}
110
	}
111
	
111
	
112
	public String getTitre() {
112
	public String getTitre() {
113
		return (String) renvoyerValeurCorrecte("titre");
113
		return (String) renvoyerValeurCorrecte("titre");
114
	}
114
	}
115
 
115
 
116
	public String getEditeur() {
116
	public String getEditeur() {
117
		return (String) renvoyerValeurCorrecte("ce_truk_editeur");
117
		return (String) renvoyerValeurCorrecte("ce_truk_editeur");
118
	}
118
	}
119
 
119
 
120
	public String getDateParution() {
120
	public String getDateParution() {
121
		return (String) renvoyerValeurCorrecte("date_parution");
121
		return (String) renvoyerValeurCorrecte("date_parution");
122
	}
122
	}
123
 
123
 
124
	public String getIndicationNvt() {
124
	public String getIndicationNvt() {
125
		return (String) renvoyerValeurCorrecte("indication_nvt");
125
		return (String) renvoyerValeurCorrecte("indication_nvt");
126
	}
126
	}
127
	
127
	
128
	public String getFascicule() {
128
	public String getFascicule() {
129
		return (String) renvoyerValeurCorrecte("fascicule");
129
		return (String) renvoyerValeurCorrecte("fascicule");
130
	}
130
	}
131
	
131
	
132
	public String getPages() {
132
	public String getPages() {
133
		return (String) renvoyerValeurCorrecte("truk_pages");
133
		return (String) renvoyerValeurCorrecte("truk_pages");
134
	}
134
	}
135
	
135
	
136
	public String getMeta() {
136
	public String getMeta() {
137
		return (String) renvoyerValeurCorrecte("ce_meta");
137
		return (String) renvoyerValeurCorrecte("ce_meta");
138
	}
138
	}
-
 
139
	
-
 
140
	public String getIdAuteur() {
-
 
141
		return (String) renvoyerValeurCorrecte("id_personne");
-
 
142
	}
139
	
143
	
140
	public String toReqString() {
144
	public String toReqString() {
141
		String reqString = "" ;
145
		String reqString = "" ;
142
		
146
		
143
		Map<String,Object> clesValeurs = getProperties() ;
147
		Map<String,Object> clesValeurs = getProperties() ;
144
		for(Iterator<String> it = clesValeurs.keySet().iterator(); it.hasNext();) {
148
		for(Iterator<String> it = clesValeurs.keySet().iterator(); it.hasNext();) {
145
			String cle = it.next();
149
			String cle = it.next();
146
				reqString += "&"+prefixe+cle+"="+URL.encode((String)clesValeurs.get(cle));
150
				reqString += "&"+prefixe+cle+"="+URL.encode((String)clesValeurs.get(cle));
147
		}
151
		}
148
		Window.alert(reqString);
152
		Window.alert(reqString);
149
		return reqString;
153
		return reqString;
150
	}
154
	}
151
}
155
}