| Line 21... |
Line 21... |
| 21 |
* @author jpm
|
21 |
* @author jpm
|
| 22 |
*
|
22 |
*
|
| 23 |
*/
|
23 |
*/
|
| 24 |
public abstract class aDonnee extends BaseModelData implements Serializable {
|
24 |
public abstract class aDonnee extends BaseModelData implements Serializable {
|
| Line 25... |
Line -... |
| 25 |
|
- |
|
| 26 |
/**
|
- |
|
| 27 |
* Identifiant pour sérialisé l'objet...
|
- |
|
| 28 |
*/
|
25 |
|
| Line -... |
Line 26... |
| - |
|
26 |
private static final long serialVersionUID = 3527760464061629791L;
|
| - |
|
27 |
|
| - |
|
28 |
public static final String TYPE_AUTRE = "AUTRE";
|
| - |
|
29 |
public static final String TYPE_TOTAL = "TOTAL";
|
| - |
|
30 |
public static final String SEPARATEUR_TYPE_VALEUR = "##";
|
| - |
|
31 |
public static final String SEPARATEUR_VALEURS = ";;";
|
| 29 |
private static final long serialVersionUID = 3527760464061629791L;
|
32 |
public static final String SEPARATEUR_DONNEES = "||";
|
| Line -... |
Line 33... |
| - |
|
33 |
|
| - |
|
34 |
protected abstract String getPrefixe();
|
| - |
|
35 |
|
| - |
|
36 |
public String getDateModification() {
|
| - |
|
37 |
return (String) renvoyerValeurCorrecte("cmhl_date_modification");
|
| - |
|
38 |
}
|
| - |
|
39 |
|
| - |
|
40 |
public String getNotes() {
|
| - |
|
41 |
return (String) renvoyerValeurCorrecte("cmhl_notes");
|
| - |
|
42 |
}
|
| - |
|
43 |
|
| - |
|
44 |
public String getIdModifierPar() {
|
| - |
|
45 |
return (String) renvoyerValeurCorrecte("cmhl_ce_modifier_par");
|
| - |
|
46 |
}
|
| - |
|
47 |
|
| - |
|
48 |
public String getIdEtat() {
|
| - |
|
49 |
return (String) renvoyerValeurCorrecte("cmhl_ce_etat");
|
| - |
|
50 |
}
|
| - |
|
51 |
|
| - |
|
52 |
public String getIp() {
|
| 30 |
|
53 |
return (String) renvoyerValeurCorrecte("cmhl_ip");
|
| 31 |
protected abstract String getPrefixe();
|
54 |
}
|
| 32 |
|
55 |
|
| Line 33... |
Line 56... |
| 33 |
protected void initialiserModele(JSONObject jsonObjet) {
|
56 |
protected void initialiserModele(JSONObject jsonObjet) {
|
| Line 84... |
Line 107... |
| 84 |
*/
|
107 |
*/
|
| 85 |
protected void ajouterChaineDenormaliseAvecType(String champ, String type, Object valeur) {
|
108 |
protected void ajouterChaineDenormaliseAvecType(String champ, String type, Object valeur) {
|
| 86 |
if (valeur instanceof String) {
|
109 |
if (valeur instanceof String) {
|
| 87 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
110 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
| 88 |
if (chaineExistante.equals("")) {
|
111 |
if (chaineExistante.equals("")) {
|
| 89 |
this.set(champ, type+"##"+valeur);
|
112 |
this.set(champ, type+SEPARATEUR_TYPE_VALEUR+valeur);
|
| 90 |
} else {
|
113 |
} else {
|
| 91 |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons
|
114 |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons
|
| 92 |
if (!chaineExistante.matches("(^|;;)"+type+"##"+valeur+"(;;|$)")) {
|
115 |
if (!chaineExistante.matches("(^|"+SEPARATEUR_VALEURS+")"+type+SEPARATEUR_TYPE_VALEUR+valeur+"("+SEPARATEUR_VALEURS+"|$)")) {
|
| 93 |
this.set(champ, chaineExistante+";;"+type+"##"+valeur);
|
116 |
this.set(champ, chaineExistante+";;"+type+SEPARATEUR_TYPE_VALEUR+valeur);
|
| 94 |
}
|
117 |
}
|
| 95 |
}
|
118 |
}
|
| 96 |
}
|
119 |
}
|
| 97 |
}
|
120 |
}
|
| Line 98... |
Line 121... |
| 98 |
|
121 |
|
| 99 |
protected void supprimerTypeDansChaineDenormalise(String champ, String type) {
|
122 |
protected void supprimerTypeDansChaineDenormalise(String champ, String type) {
|
| 100 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
123 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
| 101 |
if (!chaineExistante.equals("")) {
|
124 |
if (!chaineExistante.equals("")) {
|
| 102 |
if (chaineExistante.matches("(?:^|.*;;)"+type+"##.*")) {
|
125 |
if (chaineExistante.matches("(?:^|.*"+SEPARATEUR_VALEURS+")"+type+SEPARATEUR_TYPE_VALEUR+".*")) {
|
| 103 |
chaineExistante = chaineExistante.replaceFirst("(^|.*;;)"+type+"##.*?(;;.*|$)", "$1$2");
|
126 |
chaineExistante = chaineExistante.replaceFirst("(^|.*"+SEPARATEUR_VALEURS+")"+type+SEPARATEUR_TYPE_VALEUR+".*?("+SEPARATEUR_VALEURS+".*|$)", "$1$2");
|
| 104 |
chaineExistante = chaineExistante.replaceAll("(.*);;;;(.*)", "$1;;$2");
|
127 |
chaineExistante = chaineExistante.replaceAll("(.*)"+SEPARATEUR_VALEURS+SEPARATEUR_VALEURS+"(.*)", "$1"+SEPARATEUR_VALEURS+"$2");
|
| 105 |
chaineExistante = chaineExistante.replaceAll("^;;(.*)", "$1");
|
128 |
chaineExistante = chaineExistante.replaceAll("^"+SEPARATEUR_VALEURS+"(.*)", "$1");
|
| 106 |
chaineExistante = chaineExistante.replaceAll("(.*);;$", "$1");
|
129 |
chaineExistante = chaineExistante.replaceAll("(.*)"+SEPARATEUR_VALEURS+"$", "$1");
|
| 107 |
this.set(champ, chaineExistante);
|
130 |
this.set(champ, chaineExistante);
|
| 108 |
}
|
131 |
}
|
| 109 |
}
|
132 |
}
|
| Line 129... |
Line 152... |
| 129 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
152 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
| 130 |
if (chaineExistante.equals("")) {
|
153 |
if (chaineExistante.equals("")) {
|
| 131 |
this.set(champ, valeur);
|
154 |
this.set(champ, valeur);
|
| 132 |
} else {
|
155 |
} else {
|
| 133 |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons
|
156 |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons
|
| 134 |
if (!chaineExistante.matches("(^|;;)"+valeur+"(;;|$)")) {
|
157 |
if (!chaineExistante.matches("(^|"+SEPARATEUR_VALEURS+")"+valeur+"("+SEPARATEUR_VALEURS+"|$)")) {
|
| 135 |
this.set(champ, chaineExistante+";;"+valeur);
|
158 |
this.set(champ, chaineExistante+SEPARATEUR_VALEURS+valeur);
|
| 136 |
}
|
159 |
}
|
| 137 |
}
|
160 |
}
|
| 138 |
}
|
161 |
}
|
| 139 |
}
|
162 |
}
|
| Line 147... |
Line 170... |
| 147 |
*/
|
170 |
*/
|
| 148 |
protected void setChaineDenormaliseUnique(String champ, String type, Object valeur) {
|
171 |
protected void setChaineDenormaliseUnique(String champ, String type, Object valeur) {
|
| 149 |
if (valeur == null || valeur.equals("")) {
|
172 |
if (valeur == null || valeur.equals("")) {
|
| 150 |
this.set(champ, "");
|
173 |
this.set(champ, "");
|
| 151 |
} else if (valeur instanceof String) {
|
174 |
} else if (valeur instanceof String) {
|
| 152 |
this.set(champ, type+"##"+valeur);
|
175 |
this.set(champ, type+SEPARATEUR_VALEURS+valeur);
|
| 153 |
}
|
176 |
}
|
| 154 |
}
|
177 |
}
|
| Line 155... |
Line 178... |
| 155 |
|
178 |
|
| 156 |
/**
|
179 |
/**
|
| Line 160... |
Line 183... |
| 160 |
*/
|
183 |
*/
|
| 161 |
protected String getChaineDenormaliseUnique(String champ) {
|
184 |
protected String getChaineDenormaliseUnique(String champ) {
|
| 162 |
String sortie = renvoyerValeurCorrecte(champ);
|
185 |
String sortie = renvoyerValeurCorrecte(champ);
|
| Line 163... |
Line 186... |
| 163 |
|
186 |
|
| 164 |
if (!sortie.equals("")) {
|
187 |
if (!sortie.equals("")) {
|
| 165 |
sortie = sortie.replaceFirst("^AUTRE##", "");
|
188 |
sortie = sortie.replaceFirst("^"+TYPE_AUTRE+SEPARATEUR_TYPE_VALEUR, "");
|
| Line 166... |
Line 189... |
| 166 |
}
|
189 |
}
|
| 167 |
|
190 |
|
| Line 168... |
Line 191... |
| 168 |
return sortie;
|
191 |
return sortie;
|
| 169 |
}
|
192 |
}
|
| 170 |
|
193 |
|
| 171 |
protected String getInfoDenormaliseParType(String chaineExistante, String type) {
|
194 |
protected String getInfoDenormaliseParType(String chaineExistante, String type) {
|
| 172 |
String sortie = "";
|
195 |
String sortie = "";
|
| 173 |
if (!chaineExistante.equals("")) {
|
196 |
if (!chaineExistante.equals("")) {
|
| 174 |
String[] valeurs = chaineExistante.split(";;");
|
197 |
String[] valeurs = chaineExistante.split(SEPARATEUR_VALEURS);
|
| 175 |
for (int i = 0; i < valeurs.length; i++) {
|
198 |
for (int i = 0; i < valeurs.length; i++) {
|
| 176 |
if (valeurs[i].startsWith(type+"##")) {
|
199 |
if (valeurs[i].startsWith(type+SEPARATEUR_TYPE_VALEUR)) {
|
| 177 |
sortie = valeurs[i].replaceFirst("^"+type+"##", "");
|
200 |
sortie = valeurs[i].replaceFirst("^"+type+SEPARATEUR_TYPE_VALEUR, "");
|
| 178 |
}
|
201 |
}
|
| 179 |
}
|
202 |
}
|
| Line 194... |
Line 217... |
| 194 |
Object retourObjet = null;
|
217 |
Object retourObjet = null;
|
| Line 195... |
Line 218... |
| 195 |
|
218 |
|
| Line 196... |
Line 219... |
| 196 |
String valeurChamp = renvoyerValeurCorrecte(champ);
|
219 |
String valeurChamp = renvoyerValeurCorrecte(champ);
|
| 197 |
|
220 |
|
| Line 198... |
Line 221... |
| 198 |
if ((valeurChamp!=null)&&(!valeurChamp.trim().equals(""))) {
|
221 |
if ((valeurChamp!=null)&&(!valeurChamp.trim().equals(""))) {
|
| 199 |
String[] valeurs = valeurChamp.split(";;");
|
222 |
String[] valeurs = valeurChamp.split(SEPARATEUR_VALEURS);
|
| 200 |
|
223 |
|
| 201 |
if (valeurs.length > 0) {
|
224 |
if (valeurs.length > 0) {
|
| 202 |
if (valeurs[0].contains("##")) {
|
225 |
if (valeurs[0].contains(SEPARATEUR_TYPE_VALEUR)) {
|
| 203 |
// Les champs sont typés, on en fait une Map
|
226 |
// Les champs sont typés, on en fait une Map
|
| 204 |
HashMap<String,String> mapValeurs = new HashMap<String,String>();
|
227 |
HashMap<String,String> mapValeurs = new HashMap<String,String>();
|
| 205 |
for (int i = 0; i < valeurs.length; i++) {
|
228 |
for (int i = 0; i < valeurs.length; i++) {
|
| 206 |
String typeEtValeur[] = valeurs[i].split("##");
|
229 |
String typeEtValeur[] = valeurs[i].split(SEPARATEUR_TYPE_VALEUR);
|
| 207 |
mapValeurs.put(typeEtValeur[1], typeEtValeur[0]);
|
230 |
mapValeurs.put(typeEtValeur[1], typeEtValeur[0]);
|
| 208 |
}
|
231 |
}
|
| Line 243... |
Line 266... |
| 243 |
GWT.log("Champ:"+get(champ), null);
|
266 |
GWT.log("Champ:"+get(champ), null);
|
| 244 |
} else if (valeur instanceof String) {
|
267 |
} else if (valeur instanceof String) {
|
| 245 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
268 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
| Line 246... |
Line 269... |
| 246 |
|
269 |
|
| 247 |
if (chaineExistante.equals("")) {
|
270 |
if (chaineExistante.equals("")) {
|
| 248 |
this.set(champ, type+"##"+valeur);
|
271 |
this.set(champ, type+SEPARATEUR_TYPE_VALEUR+valeur);
|
| 249 |
} else {
|
272 |
} else {
|
| 250 |
String[] valeurs = chaineExistante.split(";;");
|
273 |
String[] valeurs = chaineExistante.split(SEPARATEUR_VALEURS);
|
| 251 |
HashMap<String,String> valeursModifiees = new HashMap<String,String>();
|
274 |
HashMap<String,String> valeursModifiees = new HashMap<String,String>();
|
| 252 |
for (int i = 0; i < valeurs.length; i++) {
|
275 |
for (int i = 0; i < valeurs.length; i++) {
|
| 253 |
if (valeurs[i].startsWith(type+"##")) {
|
276 |
if (valeurs[i].startsWith(type+SEPARATEUR_TYPE_VALEUR)) {
|
| 254 |
valeursModifiees.put(type, type+"##"+valeur);
|
277 |
valeursModifiees.put(type, type+SEPARATEUR_TYPE_VALEUR+valeur);
|
| 255 |
GWT.log("Valeur:"+valeurs[i], null);
|
278 |
GWT.log("Valeur:"+valeurs[i], null);
|
| 256 |
} else if (i == (valeurs.length -1) && !valeurs[i].startsWith(type+"##")) {
|
279 |
} else if (i == (valeurs.length -1) && !valeurs[i].startsWith(type+SEPARATEUR_TYPE_VALEUR)) {
|
| 257 |
valeursModifiees.put(valeurs[i].split("##")[0], valeurs[i]);
|
280 |
valeursModifiees.put(valeurs[i].split(SEPARATEUR_TYPE_VALEUR)[0], valeurs[i]);
|
| 258 |
valeursModifiees.put(type, type+"##"+valeur);
|
281 |
valeursModifiees.put(type, type+SEPARATEUR_TYPE_VALEUR+valeur);
|
| 259 |
} else {
|
282 |
} else {
|
| 260 |
valeursModifiees.put(valeurs[i].split("##")[0], valeurs[i]);
|
283 |
valeursModifiees.put(valeurs[i].split(SEPARATEUR_TYPE_VALEUR)[0], valeurs[i]);
|
| 261 |
}
|
284 |
}
|
| 262 |
}
|
285 |
}
|
| 263 |
String[] tableauValeursModifiees = valeursModifiees.values().toArray(new String[valeursModifiees.size()]);
|
286 |
String[] tableauValeursModifiees = valeursModifiees.values().toArray(new String[valeursModifiees.size()]);
|
| 264 |
this.set(champ, UtilArray.implode(tableauValeursModifiees, ";;"));
|
287 |
this.set(champ, UtilArray.implode(tableauValeursModifiees, SEPARATEUR_VALEURS));
|
| 265 |
GWT.log("Chaine:"+chaineExistante+"-"+renvoyerValeurCorrecte(champ), null);
|
288 |
GWT.log("Chaine:"+chaineExistante+"-"+renvoyerValeurCorrecte(champ), null);
|
| 266 |
}
|
289 |
}
|
| 267 |
}
|
290 |
}
|
| Line 268... |
Line 291... |
| 268 |
}
|
291 |
}
|
| 269 |
|
292 |
|
| 270 |
protected String getInfoDenormaliseParPosition(String chaineExistante, int position) {
|
293 |
protected String getInfoDenormaliseParPosition(String chaineExistante, int position) {
|
| 271 |
String sortie = "";
|
294 |
String sortie = "";
|
| 272 |
if (!chaineExistante.equals("")) {
|
295 |
if (!chaineExistante.equals("")) {
|
| 273 |
String[] valeurs = chaineExistante.split(";;");
|
296 |
String[] valeurs = chaineExistante.split(SEPARATEUR_VALEURS);
|
| 274 |
if (valeurs.length >= position) {
|
297 |
if (valeurs.length >= position) {
|
| 275 |
for (int i = 0; i < valeurs.length; i++) {
|
298 |
for (int i = 0; i < valeurs.length; i++) {
|
| 276 |
if (i == (position - 1)) {
|
299 |
if (i == (position - 1)) {
|
| 277 |
if (valeurs[i].contains("##")) {
|
300 |
if (valeurs[i].contains(SEPARATEUR_TYPE_VALEUR)) {
|
| 278 |
sortie = valeurs[i].replaceFirst("^[^#]+##", "");
|
301 |
sortie = valeurs[i].replaceFirst("^[^#]+"+SEPARATEUR_VALEURS, "");
|
| 279 |
} else {
|
302 |
} else {
|
| 280 |
sortie = valeurs[i];
|
303 |
sortie = valeurs[i];
|
| 281 |
}
|
304 |
}
|
| Line 303... |
Line 326... |
| 303 |
} else if (valeur instanceof String) {
|
326 |
} else if (valeur instanceof String) {
|
| 304 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
327 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
| 305 |
if (chaineExistante.equals("")) {
|
328 |
if (chaineExistante.equals("")) {
|
| 306 |
this.set(champ, valeur);
|
329 |
this.set(champ, valeur);
|
| 307 |
} else {
|
330 |
} else {
|
| 308 |
String[] valeurs = chaineExistante.split(";;");
|
331 |
String[] valeurs = chaineExistante.split(SEPARATEUR_VALEURS);
|
| 309 |
if (valeurs.length >= position) {
|
332 |
if (valeurs.length >= position) {
|
| 310 |
for (int i = 0; i < valeurs.length; i++) {
|
333 |
for (int i = 0; i < valeurs.length; i++) {
|
| 311 |
if (i == (position - 1)) {
|
334 |
if (i == (position - 1)) {
|
| 312 |
valeurs[i] = (String) valeur;
|
335 |
valeurs[i] = (String) valeur;
|
| 313 |
break;
|
336 |
break;
|
| 314 |
}
|
337 |
}
|
| 315 |
}
|
338 |
}
|
| 316 |
this.set(champ, UtilArray.implode(valeurs, ";;"));
|
339 |
this.set(champ, UtilArray.implode(valeurs, SEPARATEUR_VALEURS));
|
| 317 |
}
|
340 |
}
|
| 318 |
}
|
341 |
}
|
| 319 |
}
|
342 |
}
|
| 320 |
}
|
343 |
}
|
| Line 321... |
Line 344... |
| 321 |
|
344 |
|
| 322 |
protected void supprimerChaineDenormaliseParPosition(String champ, int position) {
|
345 |
protected void supprimerChaineDenormaliseParPosition(String champ, int position) {
|
| 323 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
346 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
| 324 |
if (!chaineExistante.equals("")) {
|
347 |
if (!chaineExistante.equals("")) {
|
| 325 |
String[] valeurs = chaineExistante.split(";;");
|
348 |
String[] valeurs = chaineExistante.split(SEPARATEUR_VALEURS);
|
| 326 |
HashMap<String,String> valeursModifiees = new HashMap<String,String>();
|
349 |
HashMap<String,String> valeursModifiees = new HashMap<String,String>();
|
| 327 |
if (valeurs.length >= position) {
|
350 |
if (valeurs.length >= position) {
|
| 328 |
for (int i = 0; i < valeurs.length; i++) {
|
351 |
for (int i = 0; i < valeurs.length; i++) {
|
| 329 |
if (i != (position - 1)) {
|
352 |
if (i != (position - 1)) {
|
| 330 |
valeursModifiees.put(""+i, valeurs[i]);
|
353 |
valeursModifiees.put(""+i, valeurs[i]);
|
| 331 |
}
|
354 |
}
|
| 332 |
}
|
355 |
}
|
| 333 |
String[] tableauValeursModifiees = valeursModifiees.values().toArray(new String[valeursModifiees.size()]);
|
356 |
String[] tableauValeursModifiees = valeursModifiees.values().toArray(new String[valeursModifiees.size()]);
|
| 334 |
this.set(champ, UtilArray.implode(tableauValeursModifiees, ";;"));
|
357 |
this.set(champ, UtilArray.implode(tableauValeursModifiees, SEPARATEUR_VALEURS));
|
| 335 |
}
|
358 |
}
|
| 336 |
}
|
359 |
}
|
| Line 337... |
Line -... |
| 337 |
}
|
- |
|
| 338 |
|
- |
|
| 339 |
public String getDateModification() {
|
- |
|
| 340 |
return (String) renvoyerValeurCorrecte("cmhl_date_modification");
|
- |
|
| 341 |
}
|
- |
|
| 342 |
|
- |
|
| 343 |
public String getNotes() {
|
- |
|
| 344 |
return (String) renvoyerValeurCorrecte("cmhl_notes");
|
- |
|
| 345 |
}
|
- |
|
| 346 |
|
- |
|
| 347 |
public String getIdModifierPar() {
|
- |
|
| 348 |
return (String) renvoyerValeurCorrecte("cmhl_ce_modifier_par");
|
- |
|
| 349 |
}
|
- |
|
| 350 |
|
- |
|
| 351 |
public String getIdEtat() {
|
- |
|
| 352 |
return (String) renvoyerValeurCorrecte("cmhl_ce_etat");
|
- |
|
| 353 |
}
|
- |
|
| 354 |
|
- |
|
| 355 |
public String getIp() {
|
- |
|
| 356 |
return (String) renvoyerValeurCorrecte("cmhl_ip");
|
- |
|
| 357 |
}
|
360 |
}
|
| 358 |
|
361 |
|
| 359 |
/** (non-Javadoc)
|
362 |
/** (non-Javadoc)
|
| 360 |
* @see java.lang.Object#toString()
|
363 |
* @see java.lang.Object#toString()
|
| 361 |
*/
|
364 |
*/
|