1,6 → 1,7 |
package org.tela_botanica.client.modeles; |
|
import java.io.Serializable; |
import java.util.ArrayList; |
import java.util.Collection; |
import java.util.Collections; |
import java.util.HashMap; |
15,6 → 16,7 |
|
import com.extjs.gxt.ui.client.core.FastMap; |
import com.extjs.gxt.ui.client.data.BaseModelData; |
import com.google.gwt.core.client.GWT; |
import com.google.gwt.http.client.URL; |
|
/** |
76,11 → 78,11 |
protected void supprimerTypeDansChaineDenormalise(String champ, String type) { |
String chaineExistante = renvoyerValeurCorrecte(champ); |
if (!chaineExistante.equals("")) { |
// Si la valeur à ajouter n'est pas déjà présente, nous l'ajoutons |
if (chaineExistante.matches("(^|;;)"+type+"##")) { |
chaineExistante = chaineExistante.replaceFirst(type+"##", ""); |
chaineExistante = chaineExistante.replaceAll(";;;;", ";;"); |
chaineExistante = chaineExistante.replaceAll("(^;;|;;$)", ""); |
if (chaineExistante.matches("(?:^|.*;;)"+type+"##.*")) { |
chaineExistante = chaineExistante.replaceFirst("(^|.*;;)"+type+"##.*?(;;.*|$)", "$1$2"); |
chaineExistante = chaineExistante.replaceAll("(.*);;;;(.*)", "$1;;$2"); |
chaineExistante = chaineExistante.replaceAll("^;;(.*)", "$1"); |
chaineExistante = chaineExistante.replaceAll("(.*);;$", "$1"); |
this.set(champ, chaineExistante); |
} |
} |
206,6 → 208,7 |
/** |
* Permet de modifier correctement une chaine dénormalisée (champ de type "truk"). |
* Remplace par la valeur de la première instance du type indiqué dans la chaine dénormalisée. |
* Si aucun type n'est trouvé, nous en ajoutons un avec la nouvelle valeur. |
* |
* @param champ le nom du champ dénormalisé |
* @param type le type de la valeur à modifier |
212,19 → 215,31 |
* @param valeur la valeur pour le type en question |
*/ |
protected void modifierChaineDenormaliseParType(String champ, String type, Object valeur) { |
if (valeur instanceof String) { |
if (valeur == null) { |
supprimerTypeDansChaineDenormalise(champ, type); |
GWT.log("Champ:"+get(champ), null); |
} else if (valeur instanceof String) { |
String chaineExistante = renvoyerValeurCorrecte(champ); |
|
if (chaineExistante.equals("")) { |
this.set(champ, type+"##"+valeur); |
} else { |
String[] valeurs = chaineExistante.split(";;"); |
HashMap<String,String> valeursModifiees = new HashMap<String,String>(); |
for (int i = 0; i < valeurs.length; i++) { |
if (valeurs[i].startsWith(type+"##") || i == (valeurs.length -1)) { |
valeurs[i] = type+"##"+valeur; |
break; |
if (valeurs[i].startsWith(type+"##")) { |
valeursModifiees.put(type, type+"##"+valeur); |
GWT.log("Valeur:"+valeurs[i], null); |
} else if (i == (valeurs.length -1) && !valeurs[i].startsWith(type+"##")) { |
valeursModifiees.put(valeurs[i].split("##")[0], valeurs[i]); |
valeursModifiees.put(type, type+"##"+valeur); |
} else { |
valeursModifiees.put(valeurs[i].split("##")[0], valeurs[i]); |
} |
} |
this.set(champ, UtilArray.implode(valeurs, ";;")); |
String[] tableauValeursModifiees = valeursModifiees.values().toArray(new String[valeursModifiees.size()]); |
this.set(champ, UtilArray.implode(tableauValeursModifiees, ";;")); |
GWT.log("Chaine:"+chaineExistante+"-"+renvoyerValeurCorrecte(champ), null); |
} |
} |
} |