| 989 |
aurelien |
1 |
package org.tela_botanica.client.modeles.objets;
|
| 2 |
aperonnet |
2 |
|
| 1542 |
aurelien |
3 |
import java.util.ArrayList;
|
|
|
4 |
import java.util.HashMap;
|
| 1967 |
aurelien |
5 |
import java.util.Iterator;
|
| 1542 |
aurelien |
6 |
import java.util.List;
|
|
|
7 |
import java.util.Map;
|
|
|
8 |
|
| 2 |
aperonnet |
9 |
import com.google.gwt.i18n.client.Dictionary;
|
| 1967 |
aurelien |
10 |
import com.google.gwt.json.client.JSONObject;
|
|
|
11 |
import com.google.gwt.json.client.JSONParser;
|
|
|
12 |
import com.google.gwt.json.client.JSONValue;
|
| 1542 |
aurelien |
13 |
import com.google.gwt.user.client.Window;
|
| 1966 |
aurelien |
14 |
import com.google.gwt.user.client.Window.Location;
|
| 2 |
aperonnet |
15 |
|
|
|
16 |
/**
|
| 5 |
aperonnet |
17 |
* Classe chargeant certains paramètres de configuration à partir d'un fichier
|
|
|
18 |
* javascript (config.js)
|
|
|
19 |
*
|
| 2 |
aperonnet |
20 |
* @author aurelien
|
| 5 |
aperonnet |
21 |
*
|
| 2 |
aperonnet |
22 |
*/
|
|
|
23 |
public class Configuration {
|
| 5 |
aperonnet |
24 |
|
| 2 |
aperonnet |
25 |
/**
|
|
|
26 |
* L'url de base du serveur jrest
|
|
|
27 |
*/
|
| 100 |
jpm |
28 |
private static String serviceBaseUrl;
|
| 5 |
aperonnet |
29 |
|
| 100 |
jpm |
30 |
private static String imageBaseUrl;
|
| 81 |
jpm |
31 |
|
| 100 |
jpm |
32 |
private static String suiviBugUrl ;
|
|
|
33 |
|
|
|
34 |
private static String aideBaseUrl ;
|
| 252 |
aurelien |
35 |
|
| 431 |
aurelien |
36 |
private static String emailContact;
|
|
|
37 |
|
| 252 |
aurelien |
38 |
private static String referentielGeo ;
|
| 271 |
aurelien |
39 |
|
|
|
40 |
private static String cleGoogleMaps ;
|
| 5 |
aperonnet |
41 |
|
| 318 |
aurelien |
42 |
private static String lienEfloreBaseUrl;
|
|
|
43 |
|
|
|
44 |
private static String refTax;
|
|
|
45 |
|
|
|
46 |
private static String refTaxVersion;
|
| 596 |
aurelien |
47 |
|
|
|
48 |
private static String licence ="";
|
| 641 |
aurelien |
49 |
|
|
|
50 |
private static String formatOriginal = "";
|
|
|
51 |
|
|
|
52 |
private static String formatZoom = "";
|
|
|
53 |
|
|
|
54 |
private static String formatGalerie = "";
|
|
|
55 |
|
|
|
56 |
private static String formatListe = "";
|
| 318 |
aurelien |
57 |
|
| 731 |
aurelien |
58 |
private static String utiliseRedirectionImage;
|
|
|
59 |
|
|
|
60 |
private static String imageRedirectUrl;
|
| 1285 |
aurelien |
61 |
|
|
|
62 |
private static String tailleMaxUpload;
|
| 1542 |
aurelien |
63 |
|
|
|
64 |
private static List<InfosReferentielNom> referentielsDispos;
|
| 1940 |
aurelien |
65 |
|
| 1967 |
aurelien |
66 |
private static Map<String,HashMap<String, String>> groupesChampsEtendus;
|
|
|
67 |
|
| 1940 |
aurelien |
68 |
private static String activerSaisieChampsEtendus = "0";
|
| 731 |
aurelien |
69 |
|
| 2 |
aperonnet |
70 |
/**
|
|
|
71 |
* Constructeur sans argument
|
|
|
72 |
*/
|
| 5 |
aperonnet |
73 |
public Configuration() {
|
|
|
74 |
// on utilise le dictionnaire d'internationalisation pour lire les
|
|
|
75 |
// variables du fichier javascript
|
| 140 |
aurelien |
76 |
|
| 322 |
aurelien |
77 |
//if(GWT.isScript()) {
|
| 157 |
aurelien |
78 |
serviceBaseUrl = Dictionary.getDictionary("configuration").get(
|
|
|
79 |
"serviceBaseUrl");
|
| 252 |
aurelien |
80 |
|
| 431 |
aurelien |
81 |
emailContact = Dictionary.getDictionary("configuration").get(
|
|
|
82 |
"emailContact");
|
|
|
83 |
|
| 157 |
aurelien |
84 |
suiviBugUrl = Dictionary.getDictionary("configuration").get(
|
|
|
85 |
"suiviBugUrl");
|
| 252 |
aurelien |
86 |
|
| 157 |
aurelien |
87 |
imageBaseUrl = Dictionary.getDictionary("configuration").get(
|
|
|
88 |
"imageBaseUrl");
|
| 252 |
aurelien |
89 |
|
| 157 |
aurelien |
90 |
aideBaseUrl = Dictionary.getDictionary("configuration").get(
|
|
|
91 |
"aideBaseUrl");
|
| 252 |
aurelien |
92 |
|
|
|
93 |
referentielGeo = Dictionary.getDictionary("configuration").get(
|
|
|
94 |
"referentielGeo");
|
|
|
95 |
|
| 271 |
aurelien |
96 |
cleGoogleMaps = Dictionary.getDictionary("configuration").get(
|
| 318 |
aurelien |
97 |
"cleGoogleMaps");
|
| 271 |
aurelien |
98 |
|
| 318 |
aurelien |
99 |
lienEfloreBaseUrl = Dictionary.getDictionary("configuration").get(
|
|
|
100 |
"lienEfloreBaseUrl");
|
|
|
101 |
|
| 641 |
aurelien |
102 |
formatOriginal = Dictionary.getDictionary("configuration").get(
|
|
|
103 |
"formatOriginal");
|
|
|
104 |
|
|
|
105 |
formatZoom = Dictionary.getDictionary("configuration").get(
|
|
|
106 |
"formatZoom");
|
|
|
107 |
|
|
|
108 |
formatGalerie = Dictionary.getDictionary("configuration").get(
|
|
|
109 |
"formatGalerie");
|
|
|
110 |
|
|
|
111 |
formatListe = Dictionary.getDictionary("configuration").get(
|
|
|
112 |
"formatListe");
|
|
|
113 |
|
| 731 |
aurelien |
114 |
utiliseRedirectionImage = Dictionary.getDictionary("configuration").get(
|
|
|
115 |
"utiliseRedirectionImage");
|
|
|
116 |
|
|
|
117 |
imageRedirectUrl = Dictionary.getDictionary("configuration").get(
|
|
|
118 |
"imageRedirectUrl");
|
|
|
119 |
|
| 1285 |
aurelien |
120 |
tailleMaxUpload = Dictionary.getDictionary("configuration").get(
|
|
|
121 |
"tailleMaxUpload");
|
|
|
122 |
|
| 1542 |
aurelien |
123 |
referentielsDispos = parserReferentielsDispos(Dictionary.getDictionary("configuration").get(
|
|
|
124 |
"referentielsDispos"));
|
| 1940 |
aurelien |
125 |
|
|
|
126 |
activerSaisieChampsEtendus = Dictionary.getDictionary("configuration").get(
|
|
|
127 |
"activerSaisieChampsEtendus");
|
| 1966 |
aurelien |
128 |
|
|
|
129 |
// Pour test, l'activation de l'ajout des champs étendus est activable ou désactivable par
|
|
|
130 |
// l'url
|
|
|
131 |
if(Location.getParameter("activerSaisieChampsEtendus") != null) {
|
|
|
132 |
if(Location.getParameter("activerSaisieChampsEtendus").equals("1")) {
|
|
|
133 |
activerSaisieChampsEtendus = "1";
|
|
|
134 |
} else if(Location.getParameter("activerSaisieChampsEtendus").equals("0")) {
|
|
|
135 |
activerSaisieChampsEtendus = "0";
|
|
|
136 |
}
|
|
|
137 |
}
|
| 1967 |
aurelien |
138 |
|
|
|
139 |
groupesChampsEtendus = new HashMap<String,HashMap<String, String>>();
|
|
|
140 |
if(activerSaisieChampsEtendus.equals("1")) {
|
|
|
141 |
if(Dictionary.getDictionary("configuration").get("groupesChampsEtendus") != null &&
|
|
|
142 |
!Dictionary.getDictionary("configuration").get("groupesChampsEtendus").isEmpty()) {
|
|
|
143 |
groupesChampsEtendus = parserGroupesChampsEtendus(Dictionary.getDictionary("configuration").get(
|
|
|
144 |
"groupesChampsEtendus"));
|
|
|
145 |
}
|
|
|
146 |
}
|
| 2 |
aperonnet |
147 |
}
|
| 1542 |
aurelien |
148 |
|
| 1967 |
aurelien |
149 |
private HashMap<String,HashMap<String, String>> parserGroupesChampsEtendus(String groupeChampsEtendusJson) {
|
|
|
150 |
HashMap<String,HashMap<String, String>> groupesChampsEtendus = new HashMap<String,HashMap<String, String>>();
|
|
|
151 |
try {
|
|
|
152 |
JSONValue groupesJson = JSONParser.parse(groupeChampsEtendusJson);
|
|
|
153 |
JSONObject groupes = groupesJson.isObject();
|
|
|
154 |
|
|
|
155 |
for (Iterator<String> iterator = groupes.keySet().iterator(); iterator.hasNext();) {
|
|
|
156 |
String groupe = iterator.next();
|
|
|
157 |
JSONValue listeClesLabelsJson = groupes.get(groupe);
|
|
|
158 |
JSONObject listeClesLabels = listeClesLabelsJson.isObject();
|
|
|
159 |
HashMap<String, String> groupesClesLabel = new HashMap<String, String>();
|
|
|
160 |
for (Iterator<String> itCleLabels = listeClesLabels.keySet().iterator(); itCleLabels.hasNext();) {
|
|
|
161 |
String cle = itCleLabels.next();
|
|
|
162 |
String label = listeClesLabels.get(cle).isString().stringValue();
|
|
|
163 |
groupesClesLabel.put(cle, label);
|
|
|
164 |
}
|
|
|
165 |
groupesChampsEtendus.put(groupe, groupesClesLabel);
|
|
|
166 |
}
|
|
|
167 |
} catch (Exception e) {
|
|
|
168 |
// TODO: handle exception
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
return groupesChampsEtendus;
|
|
|
172 |
}
|
|
|
173 |
|
| 1542 |
aurelien |
174 |
private List<InfosReferentielNom> parserReferentielsDispos(String chaineListeReferentiels) {
|
|
|
175 |
String[] tabReferentiels = chaineListeReferentiels.split(";");
|
|
|
176 |
List<InfosReferentielNom> referentiels = new ArrayList<InfosReferentielNom>(tabReferentiels.length);
|
|
|
177 |
for (int i = 0; i < tabReferentiels.length; i++) {
|
|
|
178 |
InfosReferentielNom infoRef = new InfosReferentielNom(tabReferentiels[i]);
|
|
|
179 |
referentiels.add(infoRef);
|
|
|
180 |
}
|
|
|
181 |
return referentiels;
|
|
|
182 |
}
|
| 5 |
aperonnet |
183 |
|
| 2 |
aperonnet |
184 |
/**
|
|
|
185 |
* Accesseur pour l'url de base du serveur jrest
|
| 5 |
aperonnet |
186 |
*
|
| 2 |
aperonnet |
187 |
* @return une url de la forme http://emplacement_serveur/jrest
|
|
|
188 |
*/
|
| 100 |
jpm |
189 |
public static String getServiceBaseUrl() {
|
| 5 |
aperonnet |
190 |
return serviceBaseUrl;
|
| 2 |
aperonnet |
191 |
}
|
| 81 |
jpm |
192 |
|
|
|
193 |
/**
|
|
|
194 |
* Accesseur pour l'url de base du suivi de bug
|
|
|
195 |
*
|
|
|
196 |
* @return une url pointant vers le suivi des bugs
|
|
|
197 |
*/
|
| 100 |
jpm |
198 |
public static String getSuiviBugUrl() {
|
| 81 |
jpm |
199 |
return suiviBugUrl;
|
|
|
200 |
}
|
| 100 |
jpm |
201 |
|
|
|
202 |
/**
|
|
|
203 |
* Accesseur pour l'url de base des images
|
|
|
204 |
*
|
|
|
205 |
* @return une url pointant vers la racine du dossier contenant les images
|
|
|
206 |
*/
|
|
|
207 |
public static String getImageBaseUrl() {
|
|
|
208 |
return imageBaseUrl ;
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
/**
|
|
|
212 |
* Accesseur pour l'url de base de l'aide
|
|
|
213 |
*
|
|
|
214 |
* @return une url pointant vers la racine de l'aide
|
|
|
215 |
*/
|
|
|
216 |
public static String getAideBaseUrl() {
|
|
|
217 |
return aideBaseUrl ;
|
|
|
218 |
}
|
|
|
219 |
|
| 252 |
aurelien |
220 |
/**
|
| 431 |
aurelien |
221 |
* Accesseur pour l'email de contact du carnet en ligne
|
|
|
222 |
*
|
|
|
223 |
* @return une chaine contenant l'email de contact
|
|
|
224 |
*/
|
|
|
225 |
public static String getEmailContact() {
|
|
|
226 |
return emailContact;
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
/**
|
| 271 |
aurelien |
230 |
* Accesseur pour le référentiel geo
|
| 252 |
aurelien |
231 |
*
|
| 271 |
aurelien |
232 |
* @return le référentiel geo
|
| 252 |
aurelien |
233 |
*/
|
|
|
234 |
public static String getReferentielGeo() {
|
|
|
235 |
return referentielGeo ;
|
|
|
236 |
}
|
| 271 |
aurelien |
237 |
|
|
|
238 |
/**
|
|
|
239 |
* Accesseur pour la clé google maps
|
|
|
240 |
*
|
|
|
241 |
* @return la clé google maps
|
|
|
242 |
*/
|
|
|
243 |
public static String getCleGoogleMaps() {
|
|
|
244 |
return cleGoogleMaps ;
|
|
|
245 |
}
|
| 2 |
aperonnet |
246 |
|
| 318 |
aurelien |
247 |
public static String getLienEfloreBaseUrl() {
|
| 1285 |
aurelien |
248 |
return lienEfloreBaseUrl;
|
| 318 |
aurelien |
249 |
}
|
|
|
250 |
|
| 596 |
aurelien |
251 |
public static String getLicence() {
|
|
|
252 |
return licence;
|
|
|
253 |
}
|
| 641 |
aurelien |
254 |
|
|
|
255 |
public static String getFormatOriginal() {
|
|
|
256 |
return formatOriginal;
|
|
|
257 |
}
|
|
|
258 |
|
|
|
259 |
public static String getFormatZoom() {
|
|
|
260 |
return formatZoom;
|
|
|
261 |
}
|
|
|
262 |
|
|
|
263 |
public static String getFormatGalerie() {
|
|
|
264 |
return formatGalerie;
|
|
|
265 |
}
|
|
|
266 |
|
|
|
267 |
public static String getFormatListe() {
|
|
|
268 |
return formatListe;
|
|
|
269 |
}
|
| 731 |
aurelien |
270 |
|
| 1285 |
aurelien |
271 |
public static boolean utiliseRedirectionImages() {
|
| 731 |
aurelien |
272 |
return utiliseRedirectionImage.equals("1");
|
|
|
273 |
}
|
|
|
274 |
|
| 1285 |
aurelien |
275 |
public static String getImageRedirectUrl() {
|
|
|
276 |
return imageRedirectUrl;
|
| 731 |
aurelien |
277 |
}
|
| 1285 |
aurelien |
278 |
|
|
|
279 |
public static String getTailleMaxUpload() {
|
|
|
280 |
return tailleMaxUpload;
|
|
|
281 |
}
|
| 1542 |
aurelien |
282 |
|
|
|
283 |
public static List<InfosReferentielNom> getReferentielsDispos() {
|
|
|
284 |
return referentielsDispos;
|
|
|
285 |
}
|
| 1940 |
aurelien |
286 |
|
|
|
287 |
public static boolean saisieChampsEtendusActivee() {
|
|
|
288 |
return activerSaisieChampsEtendus.equals("1");
|
|
|
289 |
}
|
| 1967 |
aurelien |
290 |
|
|
|
291 |
public static Map<String,HashMap<String, String>> getGroupesChampsEtendus() {
|
|
|
292 |
return groupesChampsEtendus;
|
|
|
293 |
}
|
| 2 |
aperonnet |
294 |
}
|