| Line 1... |
Line 1... |
| 1 |
package org.tela_botanica.client.modeles;
|
1 |
package org.tela_botanica.client.modeles;
|
| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| - |
|
3 |
import java.io.Serializable;
|
| 3 |
import java.io.Serializable;
|
4 |
import java.util.ArrayList;
|
| 4 |
import java.util.Collection;
|
5 |
import java.util.Collection;
|
| 5 |
import java.util.Collections;
|
6 |
import java.util.Collections;
|
| 6 |
import java.util.HashMap;
|
7 |
import java.util.HashMap;
|
| 7 |
import java.util.Iterator;
|
8 |
import java.util.Iterator;
|
| Line 13... |
Line 14... |
| 13 |
|
14 |
|
| Line 14... |
Line 15... |
| 14 |
import org.tela_botanica.client.util.UtilArray;
|
15 |
import org.tela_botanica.client.util.UtilArray;
|
| 15 |
|
16 |
|
| - |
|
17 |
import com.extjs.gxt.ui.client.core.FastMap;
|
| 16 |
import com.extjs.gxt.ui.client.core.FastMap;
|
18 |
import com.extjs.gxt.ui.client.data.BaseModelData;
|
| Line 17... |
Line 19... |
| 17 |
import com.extjs.gxt.ui.client.data.BaseModelData;
|
19 |
import com.google.gwt.core.client.GWT;
|
| 18 |
import com.google.gwt.http.client.URL;
|
20 |
import com.google.gwt.http.client.URL;
|
| 19 |
|
21 |
|
| Line 74... |
Line 76... |
| 74 |
}
|
76 |
}
|
| Line 75... |
Line 77... |
| 75 |
|
77 |
|
| 76 |
protected void supprimerTypeDansChaineDenormalise(String champ, String type) {
|
78 |
protected void supprimerTypeDansChaineDenormalise(String champ, String type) {
|
| 77 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
79 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
| 78 |
if (!chaineExistante.equals("")) {
|
80 |
if (!chaineExistante.equals("")) {
|
| 79 |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons
|
81 |
if (chaineExistante.matches("(?:^|.*;;)"+type+"##.*")) {
|
| 80 |
if (chaineExistante.matches("(^|;;)"+type+"##")) {
|
82 |
chaineExistante = chaineExistante.replaceFirst("(^|.*;;)"+type+"##.*?(;;.*|$)", "$1$2");
|
| 81 |
chaineExistante = chaineExistante.replaceFirst(type+"##", "");
|
83 |
chaineExistante = chaineExistante.replaceAll("(.*);;;;(.*)", "$1;;$2");
|
| 82 |
chaineExistante = chaineExistante.replaceAll(";;;;", ";;");
|
84 |
chaineExistante = chaineExistante.replaceAll("^;;(.*)", "$1");
|
| 83 |
chaineExistante = chaineExistante.replaceAll("(^;;|;;$)", "");
|
85 |
chaineExistante = chaineExistante.replaceAll("(.*);;$", "$1");
|
| 84 |
this.set(champ, chaineExistante);
|
86 |
this.set(champ, chaineExistante);
|
| 85 |
}
|
87 |
}
|
| 86 |
}
|
88 |
}
|
| Line 204... |
Line 206... |
| 204 |
|
206 |
|
| 205 |
|
207 |
|
| 206 |
/**
|
208 |
/**
|
| - |
|
209 |
* Permet de modifier correctement une chaine dénormalisée (champ de type "truk").
|
| 207 |
* Permet de modifier correctement une chaine dénormalisée (champ de type "truk").
|
210 |
* Remplace par la valeur de la première instance du type indiqué dans la chaine dénormalisée.
|
| 208 |
* Remplace par la valeur de la première instance du type indiqué dans la chaine dénormalisée.
|
211 |
* Si aucun type n'est trouvé, nous en ajoutons un avec la nouvelle valeur.
|
| 209 |
*
|
212 |
*
|
| 210 |
* @param champ le nom du champ dénormalisé
|
213 |
* @param champ le nom du champ dénormalisé
|
| 211 |
* @param type le type de la valeur à modifier
|
214 |
* @param type le type de la valeur à modifier
|
| 212 |
* @param valeur la valeur pour le type en question
|
215 |
* @param valeur la valeur pour le type en question
|
| - |
|
216 |
*/
|
| - |
|
217 |
protected void modifierChaineDenormaliseParType(String champ, String type, Object valeur) {
|
| - |
|
218 |
if (valeur == null) {
|
| 213 |
*/
|
219 |
supprimerTypeDansChaineDenormalise(champ, type);
|
| 214 |
protected void modifierChaineDenormaliseParType(String champ, String type, Object valeur) {
|
220 |
GWT.log("Champ:"+get(champ), null);
|
| - |
|
221 |
} else if (valeur instanceof String) {
|
| 215 |
if (valeur instanceof String) {
|
222 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
| 216 |
String chaineExistante = renvoyerValeurCorrecte(champ);
|
223 |
|
| 217 |
if (chaineExistante.equals("")) {
|
224 |
if (chaineExistante.equals("")) {
|
| 218 |
this.set(champ, type+"##"+valeur);
|
225 |
this.set(champ, type+"##"+valeur);
|
| - |
|
226 |
} else {
|
| 219 |
} else {
|
227 |
String[] valeurs = chaineExistante.split(";;");
|
| 220 |
String[] valeurs = chaineExistante.split(";;");
|
228 |
HashMap<String,String> valeursModifiees = new HashMap<String,String>();
|
| - |
|
229 |
for (int i = 0; i < valeurs.length; i++) {
|
| - |
|
230 |
if (valeurs[i].startsWith(type+"##")) {
|
| - |
|
231 |
valeursModifiees.put(type, type+"##"+valeur);
|
| - |
|
232 |
GWT.log("Valeur:"+valeurs[i], null);
|
| 221 |
for (int i = 0; i < valeurs.length; i++) {
|
233 |
} else if (i == (valeurs.length -1) && !valeurs[i].startsWith(type+"##")) {
|
| 222 |
if (valeurs[i].startsWith(type+"##") || i == (valeurs.length -1)) {
|
234 |
valeursModifiees.put(valeurs[i].split("##")[0], valeurs[i]);
|
| - |
|
235 |
valeursModifiees.put(type, type+"##"+valeur);
|
| 223 |
valeurs[i] = type+"##"+valeur;
|
236 |
} else {
|
| 224 |
break;
|
237 |
valeursModifiees.put(valeurs[i].split("##")[0], valeurs[i]);
|
| - |
|
238 |
}
|
| 225 |
}
|
239 |
}
|
| - |
|
240 |
String[] tableauValeursModifiees = valeursModifiees.values().toArray(new String[valeursModifiees.size()]);
|
| 226 |
}
|
241 |
this.set(champ, UtilArray.implode(tableauValeursModifiees, ";;"));
|
| 227 |
this.set(champ, UtilArray.implode(valeurs, ";;"));
|
242 |
GWT.log("Chaine:"+chaineExistante+"-"+renvoyerValeurCorrecte(champ), null);
|
| 228 |
}
|
243 |
}
|
| Line 229... |
Line 244... |
| 229 |
}
|
244 |
}
|