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