New file |
0,0 → 1,416 |
package org.tela_botanica.client.modeles.structure; |
|
import java.util.Date; |
import java.util.Iterator; |
import java.util.Map; |
import java.util.Set; |
|
import org.tela_botanica.client.modeles.aDonnee; |
import org.tela_botanica.client.modeles.personne.Personne; |
import org.tela_botanica.client.util.UtilString; |
|
import com.extjs.gxt.ui.client.data.BaseModelData; |
import com.extjs.gxt.ui.client.data.ModelData; |
import com.google.gwt.i18n.client.DateTimeFormat; |
import com.google.gwt.json.client.JSONObject; |
|
public class Structure extends aDonnee { |
|
private static final long serialVersionUID = -5623886668593288218L; |
|
public static final String PREFIXE = "cs"; |
public static final String URL_SITE = "WEB"; |
public static final String URL_LOGO = "LOGO"; |
|
private BaseModelData urls = null; |
private StructureAPersonneListe personnel = null; |
private StructureValorisation valorisation = null; |
private StructureConservation conservation = null; |
public static String[] champsObligatoires = {"cs_id_structure", "csc_id_structure", "csv_id_structure"}; |
|
public Structure() { |
// Constructions du tableau des urls interne |
urls = new BaseModelData(); |
} |
|
public Structure(ModelData model) |
{ |
Map<String, Object> a = model.getProperties(); |
|
Set<String> cles = a.keySet(); |
Iterator<String> it = cles.iterator(); |
while (it.hasNext()) { |
String cle = it.next(); |
if (a.get(cle) != null) { |
String cleObjet = cle.replaceFirst("^"+getPrefixe()+"_", ""); |
this.set(cleObjet, a.get(cle)); |
} |
} |
} |
|
public Structure(JSONObject institution) { |
// Constructions du tableau des urls interne |
urls = new BaseModelData(); |
|
// l'objet JSON est une table de hachage |
Set<String> im = institution.keySet(); |
|
// Parcourt pour chaque clé |
for (Iterator<String> it = im.iterator(); it.hasNext();) { |
// Si elle est associée à une valeur, nous l'ajoutons |
String cle = it.next(); |
if (cle.startsWith(PREFIXE+"_")) { |
// Suppression de l'abréviation du champ. Inutile dans le contexte d'un objet |
String cleObjet = cle.replaceFirst("^"+PREFIXE+"_", ""); |
// Sinon, nous ajoutons la clé avec une valeur vide |
String valeur = ""; |
if (institution.get(cle).isString() != null) { |
valeur = institution.get(cle).isString().stringValue(); |
} |
if (cleObjet.equals("truk_url")) { |
this.setUrl(valeur); |
} else { |
this.set(cleObjet, valeur); |
} |
} |
} |
} |
|
@Override |
protected String getPrefixe() { |
return PREFIXE; |
} |
|
protected String[] getChampsObligatoires() { |
return champsObligatoires; |
} |
|
public String getId() { |
return renvoyerValeurCorrecte("id_structure"); |
} |
public void setId(String idStructure) { |
this.set("id_structure", idStructure); |
} |
|
public String getIdProjet() { |
return renvoyerValeurCorrecte("ce_projet"); |
} |
public void setIdProjet(String idProjet) { |
this.set("ce_projet", idProjet); |
} |
|
public String getIdMere() { |
return renvoyerValeurCorrecte("ce_mere"); |
} |
public void setIdMere(String idMere) { |
this.set("ce_mere", idMere); |
} |
|
public String getGuid() { |
return renvoyerValeurCorrecte("guid"); |
} |
public void setGuid(String guid) { |
this.set("guid", guid); |
} |
|
public String getIdAlternatif() { |
return renvoyerValeurCorrecte("truk_identifiant_alternatif"); |
} |
public void setIdAlternatif(String idAlter) { |
this.set("truk_identifiant_alternatif", idAlter); |
} |
|
public String getNom() { |
return renvoyerValeurCorrecte("nom"); |
} |
public void setNom(String nom) { |
this.set("nom", nom); |
} |
|
public String getNomAlternatif() { |
return renvoyerValeurCorrecte("truk_nom_alternatif"); |
} |
|
public String getDescription() { |
return renvoyerValeurCorrecte("description"); |
} |
public void setDescription(String description) { |
this.set("description", description); |
} |
|
public String getType() { |
return renvoyerValeurCorrecte("ce_type"); |
} |
public void setType(String type) { |
this.set("ce_type", type); |
} |
|
public String getTypePrive() { |
return renvoyerValeurCorrecte("ce_truk_type_prive"); |
} |
public void setTypePrive(String typePrive) { |
this.set("ce_truk_type_prive", typePrive); |
} |
|
public String getTypePublic() { |
return renvoyerValeurCorrecte("ce_truk_type_public"); |
} |
public void setTypePublic(String typePublic) { |
this.set("ce_truk_type_public", typePublic); |
} |
|
public String getAbreviationProjet() { |
return renvoyerValeurCorrecte("_abreviationprojet_"); |
} |
public void setAbreviationProjet(String abreviation) { |
this.set("_abreviationprojet_", abreviation); |
} |
|
public String getAdresse() { |
return (String) renvoyerValeurCorrecte("adresse_01"); |
} |
public void setAdresse(String adr) { |
this.set("adresse_01", adr); |
} |
|
public String getAdresseComplement() { |
return renvoyerValeurCorrecte("adresse_02"); |
} |
public void setAdresseComplement(String adr) { |
this.set("adresse_02", adr); |
} |
|
public String getDateFondationFormatMysql() { |
return renvoyerValeurCorrecte("date_fondation"); |
} |
public String getDateFondationFormatLong() { |
String dateFormatee = ""; |
Date dateFondation = getDateFondation(); |
if (dateFondation != null) { |
dateFormatee = DateTimeFormat.getLongDateFormat().format(dateFondation); |
} |
return dateFormatee; |
} |
|
public String getAnneOuDateFondationFormatLong() { |
String dateFormatee = ""; |
String dateFondation = renvoyerValeurCorrecte("date_fondation"); |
if (!dateFondation.equals("")) { |
if (dateFondation.endsWith("00-00")) { |
dateFormatee = dateFondation.substring(0, 4); |
} else { |
Date date = DateTimeFormat.getFormat("yyyy-MM-dd").parse(dateFondation); |
dateFormatee = DateTimeFormat.getLongDateFormat().format(date); |
} |
} |
return dateFormatee; |
} |
public Date getDateFondation() { |
Date fondationDate = null; |
String fondationChaine = renvoyerValeurCorrecte("date_fondation"); |
if (!fondationChaine.isEmpty() && !fondationChaine.equals("0000-00-00")) { |
fondationDate = DateTimeFormat.getFormat("yyyy-MM-dd").parseStrict(fondationChaine); |
} |
return fondationDate; |
} |
|
public String getAnneeOuDateFondation() { |
String valeurDateFondation = get("date_fondation"); |
if (!UtilString.isEmpty(valeurDateFondation) && valeurDateFondation.endsWith("00-00")) { |
valeurDateFondation = valeurDateFondation.substring(0, 4); |
} else if (UtilString.isEmpty(valeurDateFondation) && valeurDateFondation.equals("0000-00-00")) { |
valeurDateFondation = ""; |
} |
return valeurDateFondation; |
} |
|
public void setDateFondation(Date dateFondation) { |
if (dateFondation != null) { |
this.set("date_fondation", DateTimeFormat.getFormat("yyyy-MM-dd").format(dateFondation)); |
} |
} |
public void setDateFondation(String dateFondation) { |
if (dateFondation != null) { |
this.set("date_fondation", dateFondation); |
} |
} |
|
public String getCodePostal() { |
return renvoyerValeurCorrecte("code_postal"); |
} |
public void setCodePostal(String codePostal) { |
this.set("code_postal", codePostal); |
} |
|
public String getVille() { |
return renvoyerValeurCorrecte("ville"); |
} |
public void setVille(String ville) { |
this.set("ville", ville); |
} |
|
public String getRegion() { |
return getChaineDenormaliseUnique("ce_truk_region"); |
} |
public void setRegion(String region) { |
this.set("ce_truk_region", region); |
} |
|
public String getPays() { |
return getChaineDenormaliseUnique("ce_truk_pays"); |
} |
public void setPays(String pays) { |
this.set("ce_truk_pays", pays); |
} |
|
public String getLatitude() { |
return renvoyerValeurCorrecte("latitude"); |
} |
public void setLatitude(String latitude) { |
if (latitude != null) { |
latitude = latitude.replace(".", ","); |
} |
this.set("latitude", latitude); |
} |
|
public String getLongitude() { |
return renvoyerValeurCorrecte("longitude"); |
} |
public void setLongitude(String longitude) { |
if (longitude != null) { |
longitude = longitude.replace(".", ","); |
} |
this.set("longitude", longitude); |
} |
|
// TELEPHONE |
public String getTelephone() { |
return renvoyerValeurCorrecte("truk_telephone"); |
} |
public void setTelephone(String tel) { |
this.set("truk_telephone", tel); |
} |
|
// TELEPHONE FIXE |
public String getTelephoneFixe() { |
return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), Personne.TELEPHONE_FIXE); |
} |
public void setTelephoneFixe(String fixe) { |
modifierChaineDenormaliseParType("truk_telephone", Personne.TELEPHONE_FIXE, fixe); |
} |
|
//TELEPHONE FAX |
public String getFax() { |
return getInfoDenormaliseParType(renvoyerValeurCorrecte("truk_telephone"), Personne.TELEPHONE_FAX); |
} |
public void setFax(String fax) { |
modifierChaineDenormaliseParType("truk_telephone", Personne.TELEPHONE_FAX, fax); |
} |
|
|
// COURRIEL |
public String getCourriel() { |
return renvoyerValeurCorrecte("courriel"); |
} |
public void setCourriel(String courriel) { |
this.set("courriel", courriel); |
} |
|
// URL |
public String getUrl(String type) { |
return urls.get(type); |
} |
public String getUrl() { |
String urlsDenormalise = ""; |
Set<String> proprietes = urls.getProperties().keySet(); |
for (Iterator<String> it = proprietes.iterator(); it.hasNext();) { |
String cle = it.next(); |
urlsDenormalise += cle+"##"+urls.get(cle)+";;"; |
} |
urlsDenormalise = urlsDenormalise.replaceFirst(";;$", ""); |
return urlsDenormalise; |
} |
public void setUrl(String urlsDenormalise) { |
if (urlsDenormalise != null && !urlsDenormalise.equals("")) { |
//GWT.log(urlsDenormalise, null); |
String[] tableauUrls = urlsDenormalise.split(";;"); |
for (int i = 0; i < tableauUrls.length; i++) { |
String url = tableauUrls[i]; |
//GWT.log("\t"+url, null); |
String[] tableauUrl = url.split("##"); |
if (tableauUrl.length == 2) { |
//GWT.log("\t\t"+tableauUrl[0]+"-"+tableauUrl[1], null); |
urls.set(tableauUrl[0], tableauUrl[1]); |
} |
} |
} |
} |
public void setUrl(String type, String url) { |
if (url != null) { |
urls.set(type, url); |
} |
} |
|
public int getNbrePersonne() { |
if (renvoyerValeurCorrecte("nbre_personne").equals("")) { |
return 0; |
} else { |
return Integer.parseInt(renvoyerValeurCorrecte("nbre_personne")); |
} |
} |
public void setNbrePersonne(int nbrePersonne) { |
this.set("nbre_personne", Integer.toString(nbrePersonne)); |
} |
|
public String getConditionAcces() { |
return renvoyerValeurCorrecte("condition_acces"); |
} |
public void setConditionAcces(String acces) { |
this.set("condition_acces", acces); |
} |
|
public String getConditionUsage() { |
return renvoyerValeurCorrecte("condition_usage"); |
} |
public void setConditionUsage(String usage) { |
this.set("condition_usage", usage); |
} |
|
public StructureAPersonneListe getPersonnel() { |
return personnel; |
} |
public void setPersonnel(StructureAPersonneListe personnelAStocker) { |
personnel = personnelAStocker; |
} |
|
public StructureValorisation getValorisation() { |
return valorisation; |
} |
public void setValorisation(StructureValorisation valorisationAStocker) { |
valorisation = valorisationAStocker; |
} |
|
public StructureConservation getConservation() { |
return conservation; |
} |
public void setConservation(StructureConservation conservationAStocker) { |
conservation = conservationAStocker; |
} |
|
public String toString() { |
String sortie = ""; |
|
// Champs du BaseModelData |
Set<String> proprietes = this.getProperties().keySet(); |
for (Iterator<String> it = proprietes.iterator(); it.hasNext();) { |
String cle = it.next(); |
sortie += cle+" : "+this.get(cle)+"\n"; |
} |
|
// Champs spéciaux |
sortie += getUrl(); |
|
return sortie; |
} |
|
} |
Property changes: |
Added: svn:mergeinfo |
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/structure/Structure.java:r1136-1368 |