Subversion Repositories eFlore/Applications.coel

Compare Revisions

No changes between revisions

Ignore whitespace Rev 1943 → Rev 1944

/tags/v1.11-okuzgozu/src/org/tela_botanica/client/modeles/collection/CollectionACommentaire.java
New file
0,0 → 1,146
package org.tela_botanica.client.modeles.collection;
 
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.commentaire.Commentaire;
import org.tela_botanica.client.modeles.personne.Personne;
import org.tela_botanica.client.modeles.publication.Publication;
 
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.json.client.JSONObject;
 
public class CollectionACommentaire extends aDonnee {
private static final long serialVersionUID = 8751553802444398035L;
public static final String PREFIXE = "ccac";
private boolean removePrefix = true;
private Commentaire commentaireLiee = null;
public static String[] champsObligatoires = {"cc_id_collection", "ccac_id_commentaire"};
public CollectionACommentaire() {
initialiser(new JSONObject(), false);
}
public CollectionACommentaire(JSONObject collectionACommentaireListe) {
initialiser(collectionACommentaireListe, true);
}
public CollectionACommentaire(JSONObject collectionACommentaireListe, boolean chargerCommentaire) {
initialiser(collectionACommentaireListe, chargerCommentaire);
}
public CollectionACommentaire(ModelData model, boolean removePrefix)
{
this.removePrefix = removePrefix;
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 = "";
if (removePrefix) {
cleObjet = cle.replaceFirst("^"+CollectionACommentaire.PREFIXE+"_", "");
cleObjet = cleObjet.replaceFirst("^"+Commentaire.PREFIXE+"_", "");
}
else {
cleObjet = cle;
}
this.set(cleObjet, a.get(cle));
}
}
 
setCommentaire(new Commentaire(model));
this.set("_etat_", a.get("_etat_"));
this.set("_type_", a.get("_type_"));
}
@Override
protected String getPrefixe() {
return PREFIXE;
}
protected String[] getChampsObligatoires() {
return champsObligatoires;
}
private void initialiser(JSONObject collectionACommentaireListe, boolean chargerCommentaire) {
if (chargerCommentaire) {
setCommentaire(new Commentaire(collectionACommentaireListe, false));
} else {
setCommentaire(new Commentaire());
}
initialiserModele(collectionACommentaireListe);
initialiserChampsPourGrille();
}
// COMMENTAIRE
public Commentaire getCommentaire() {
return commentaireLiee;
}
public void setCommentaire(Commentaire commentaire) {
commentaireLiee = commentaire;
initialiserChampsPourGrille();
if (commentaire != null) {
setIdCommentaire(commentaire.getId());
}
}
private void initialiserChampsPourGrille() {
set("_type_", getType());
set("_titre_", getCommentaire().getTitre());
set("_texte_", getCommentaire().getTexte());
set("_ponderation_", getCommentaire().getPonderation());
set("_public_", getCommentaire().getPublic());
set("_etat_", "");
}
// ID
/** Génère un identifiant de CollectionACommentaire.
*
* C'est une concaténation des clés primaires de la table coel_collection_a_commentaire séparées par un tiret "-".
*
* @return identifiant unique d'une relation "collection à commentaire".
*/
public String getId() {
String idCollection = getIdCollection();
String idCommentaire = getIdCommentaire();
if (idCollection.equals("") && idCommentaire.equals("")) {
return null;
} else {
return (idCollection+"-"+idCommentaire);
}
}
//+---------------------------------------------------------------------------------------------------------------+
// CHAMPS PROVENANT de la TABLE COEL_COLLECTION_A_COMMENTAIRE
// ID COLLECTION
public String getIdCollection() {
return renvoyerValeurCorrecte("id_collection");
}
public void setIdCollection(String idCollection) {
set("id_collection", idCollection);
}
// ID COMENTAIRE
public String getIdCommentaire() {
return renvoyerValeurCorrecte("id_commentaire");
}
public void setIdCommentaire(String ic) {
set("id_commentaire", ic);
}
// TRUCK TYPE
public String getType() {
return renvoyerValeurCorrecte("truk_type");
}
public void setType(String type) {
set("truk_type", type);
}
}
Property changes:
Added: svn:mergeinfo
Merged /branches/v1.0-syrah/src/org/tela_botanica/client/modeles/collection/CollectionACommentaire.java:r1136-1368
Merged /trunk/src/org/tela_botanica/client/modeles/collection/CollectionACommentaire.java:r11-984,1209-1382
Merged /branches/v1.1-aramon/src/org/tela_botanica/client/modeles/collection/CollectionACommentaire.java:r1383-1511