6,6 → 6,7 |
import org.tela_botanica.client.interfaces.Rafraichissable; |
import org.tela_botanica.client.modeles.EntiteGeographiqueObservation; |
import org.tela_botanica.client.modeles.ListeEntiteGeographiqueObservation; |
import org.tela_botanica.client.modeles.Observation; |
import org.tela_botanica.client.observation.ObservationMediateur; |
|
import com.google.gwt.core.client.GWT; |
230,23 → 231,19 |
|
if (nouvelleDonnees instanceof ListeEntiteGeographiqueObservation) { |
|
String entite=null; |
String idEntite=null; |
String idParent=null; |
String id_location=null; |
String location=null; |
String lieuDit=null; |
|
ListeEntiteGeographiqueObservation data = (ListeEntiteGeographiqueObservation) nouvelleDonnees ; |
|
|
if (data.isEmpty()) { |
// on crée un arbre vide |
TreeNode root = new TreeNode(); |
root.setId("racine_entite"); |
root.setText("Localités"); |
String[] usObj = { "Localités"}; |
root.setUserObject(usObj); |
String[] usObjRoot = { "Localités"}; |
root.setUserObject(usObjRoot); |
donneeEntitesGeographiques.setRootNode(root); |
|
} |
|
// on la parse et on récupère les informations qui nous interessent |
for (Iterator<String> it= data.keySet().iterator(); it.hasNext();) { |
253,75 → 250,214 |
|
EntiteGeographiqueObservation ent=(EntiteGeographiqueObservation) data.get(it.next()); |
|
entite=ent.getEntite(); |
id_location=ent.getIdLocation(); |
location=ent.getLocation(); |
lieuDit=ent.getLieuDit(); |
|
if(entite.contains("000null")) { |
entite="Inconnue" ; |
if(id_location.contains("000null")) { |
id_location="Inconnue" ; |
} |
|
idEntite=ent.getIdEntite(); |
idParent=ent.getIdParent(); |
if(location.contains("000null")) { |
location="Inconnue" ; |
} |
|
|
String[] usObj = { entite }; |
|
// et on construit l'arbre à partir de la racine (qui est |
// toujours le premier élément) |
if (entite.equals("racine_entite")) { |
TreeNode root = new TreeNode(); |
root.setId(idEntite); |
root.setText(entite); |
root.setUserObject(usObj); |
donneeEntitesGeographiques.setRootNode(root); |
} else { |
// et en ajoutant les noeuds un à un (qui sont renvoyé |
// dans l'ordre hierarchique de leur niveau |
// ce qui permet de les traiter séquentiellement) |
TreeNode node = new TreeNode(); |
node.setId(idEntite); |
node.setText(entite); |
Node parentNode = donneeEntitesGeographiques.getNodeById(idParent); |
if(parentNode != null) |
if(lieuDit.contains("000null")) { |
lieuDit="Inconnue" ; |
} |
|
Node noeudMemeId = donneeEntitesGeographiques.getNodeById(""+id_location); |
// si la région existe déjà |
if(noeudMemeId != null) |
{ |
// on teste si la localité existe |
Node noeudMemeLoc = donneeEntitesGeographiques.getNodeById(""+(id_location+location)); |
if(noeudMemeLoc != null) |
{ |
node.setUserObject(usObj); |
parentNode.appendChild(node); |
// enfin on teste si le lieu dit existe |
Node noeudMemeLieu = donneeEntitesGeographiques.getNodeById(""+(id_location+location+lieuDit)); |
if(noeudMemeLieu != null) |
{ |
// tous les noeuds existent déjà, normalement ça ne devrait pas arriver |
} |
else |
{ |
// enfin on ne crée que le noeud du lieu dit |
TreeNode node_lieu = new TreeNode(); |
node_lieu.setId(""+(id_location+location+lieuDit)); |
node_lieu.setText(lieuDit); |
noeudMemeLoc.appendChild(node_lieu) ; |
String[] usObj = {lieuDit}; |
node_lieu.setUserObject(usObj); |
} |
} |
else |
{ |
TreeNode node_loc = new TreeNode(); |
node_loc.setId(""+(id_location+location)); |
node_loc.setText(location); |
noeudMemeId.appendChild(node_loc) ; |
String[] usObj = {location}; |
node_loc.setUserObject(usObj); |
|
TreeNode node_lieu = new TreeNode(); |
node_lieu.setId(""+(id_location+location+lieuDit)); |
node_lieu.setText(lieuDit); |
node_loc.appendChild(node_lieu) ; |
String[] usObj2 = {lieuDit}; |
node_lieu.setUserObject(usObj2); |
|
} |
} |
else |
{ |
TreeNode node_id_loc = new TreeNode(); |
node_id_loc.setId(""+id_location); |
node_id_loc.setText(id_location); |
root.appendChild(node_id_loc) ; |
String[] usObj = {id_location}; |
node_id_loc.setUserObject(usObj); |
|
TreeNode node_loc = new TreeNode(); |
node_loc.setId(""+(id_location+location)); |
node_loc.setText(location); |
node_id_loc.appendChild(node_loc) ; |
String[] usObj2 = {location}; |
node_loc.setUserObject(usObj2); |
|
TreeNode node_lieu = new TreeNode(); |
node_lieu.setId(""+(id_location+location+lieuDit)); |
node_lieu.setText(lieuDit); |
node_loc.appendChild(node_lieu) ; |
String[] usObj3 = {lieuDit}; |
node_lieu.setUserObject(usObj3); |
} |
|
} |
|
} |
|
// on vide tous les noeuds |
arbreEntitesGeographiques.getRootNode().eachChild(new NodeTraversalCallback() { |
// on vide tous les noeuds |
arbreEntitesGeographiques.getRootNode().eachChild(new NodeTraversalCallback() { |
|
public boolean execute(Node node) { |
|
node.remove(); |
return true; |
} |
|
}); |
|
public boolean execute(Node node) { |
|
node.remove(); |
return true; |
// et on recopie le nouvel arbre |
copierFilsNoeud(donneeEntitesGeographiques.getRootNode(), arbreEntitesGeographiques |
.getRootNode()); |
|
// si l'arbre n'était pas encore considéré comme instancié |
if (!estInstancie) { |
// on signale que oui |
estInstancie = true; |
} |
|
// l'état du filtre est réinitialisé |
filtreModifie = false; |
//show() ; |
doLayout(); |
|
}); |
|
// et on recopie le nouvel arbre |
copierFilsNoeud(donneeEntitesGeographiques.getRootNode(), arbreEntitesGeographiques |
.getRootNode()); |
|
// si l'arbre n'était pas encore considéré comme instancié |
if (!estInstancie) { |
// on signale que oui |
estInstancie = true; |
} |
|
// l'état du filtre est réinitialisé |
filtreModifie = false; |
//show() ; |
doLayout(); |
|
if(nouvelleDonnees instanceof Observation) |
{ |
Observation obs = (Observation)nouvelleDonnees ; |
|
String id_location= obs.getIdentifiantLocalite(); |
id_location.replaceAll("\"", "") ; |
String location=obs.getLocalite(); |
String lieuDit=obs.getLieudit(); |
|
Node root = arbreEntitesGeographiques.getRootNode() ; |
|
if(id_location.contains("000null") || id_location.equals(null)) { |
id_location="Inconnue" ; |
} |
|
if(location.contains("000null") || location.equals(null)) { |
location="Inconnue" ; |
} |
|
if(lieuDit.contains("000null") || lieuDit.equals(null)) { |
lieuDit="Inconnue" ; |
} |
|
Node noeudMemeId = donneeEntitesGeographiques.getNodeById(""+id_location); |
// si la région existe déjà |
if(noeudMemeId != null) |
{ |
// on teste si la localité existe |
Node noeudMemeLoc = donneeEntitesGeographiques.getNodeById(""+(id_location+location)); |
if(noeudMemeLoc != null) |
{ |
// enfin on teste si le lieu dit existe |
Node noeudMemeLieu = donneeEntitesGeographiques.getNodeById(""+(id_location+location+lieuDit)); |
if(noeudMemeLieu != null) |
{ |
// tous les noeuds existent déjà, normalement ça ne devrait pas arriver |
} |
else |
{ |
// enfin on ne crée que le noeud du lieu dit |
TreeNode node_lieu = new TreeNode(); |
node_lieu.setId(""+(id_location+location+lieuDit)); |
node_lieu.setText(lieuDit); |
String[] usObj = {lieuDit}; |
node_lieu.setUserObject(usObj); |
noeudMemeLoc.appendChild(node_lieu) ; |
} |
} |
else |
{ |
TreeNode node_loc = new TreeNode(); |
node_loc.setId(""+(id_location+location)); |
node_loc.setText(location); |
String[] usObj = {location}; |
node_loc.setUserObject(usObj); |
noeudMemeId.appendChild(node_loc) ; |
|
TreeNode node_lieu = new TreeNode(); |
node_lieu.setId(""+(id_location+location+lieuDit)); |
node_lieu.setText(lieuDit); |
String[] usObj2 = {lieuDit}; |
node_lieu.setUserObject(usObj2); |
node_loc.appendChild(node_lieu) ; |
|
} |
} |
else |
{ |
TreeNode node_id_loc = new TreeNode(); |
node_id_loc.setId(""+id_location); |
node_id_loc.setText(id_location); |
String[] usObj = {id_location}; |
node_id_loc.setUserObject(usObj); |
root.appendChild(node_id_loc) ; |
|
TreeNode node_loc = new TreeNode(); |
node_loc.setId(""+(id_location+location)); |
node_loc.setText(location); |
String[] usObj2 = {location}; |
node_loc.setUserObject(usObj2); |
node_id_loc.appendChild(node_loc) ; |
|
TreeNode node_lieu = new TreeNode(); |
node_lieu.setId(""+(id_location+location+lieuDit)); |
node_lieu.setText(lieuDit); |
String[] usObj3 = {lieuDit}; |
node_lieu.setUserObject(usObj3); |
node_loc.appendChild(node_lieu) ; |
} |
|
arbreEntitesGeographiques.doLayout() ; |
} |
} |
|
|
|
|
|
/** |
* Accesseur pour le panneau contenant l'arbre |
* |