Index: topia/src/java/org/codelutin/topia/AbstractTopiaEntity.java diff -u topia/src/java/org/codelutin/topia/AbstractTopiaEntity.java:1.9 topia/src/java/org/codelutin/topia/AbstractTopiaEntity.java:1.10 --- topia/src/java/org/codelutin/topia/AbstractTopiaEntity.java:1.9 Thu Aug 11 16:35:23 2005 +++ topia/src/java/org/codelutin/topia/AbstractTopiaEntity.java Wed Sep 7 15:34:59 2005 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * - * Mise a jour: $Date: 2005/08/11 16:35:23 $ - * par : $Author: thimel $ + * Mise a jour: $Date: 2005/09/07 15:34:59 $ + * par : $Author: bpoussin $ */ package org.codelutin.topia; @@ -37,6 +37,9 @@ import org.codelutin.util.VersionNumberUtil; +/** +* @deprecated ne sert plus a rien normalement car on utilise le proxy +*/ public abstract class AbstractTopiaEntity extends AbstractTopiaElement implements TopiaEntity { // AbstractTopiaEntity protected String _topiaId_ = null; @@ -44,11 +47,11 @@ protected Date _topiaCreationDate_; protected Date _topiaLastUpdateDate_; protected TopiaUser _topiaLastUpdateUser_; - + protected Collection _dependentEntities; //Faut-il sécuriser ces méthodes ? - //Réponse : Après discussion avec et selon Benjamin : non ! + //Réponse : Après discussion avec et selon Benjamin : non ! public AbstractTopiaEntity() throws TopiaException { set_topiaId_(TopiaId.create(getEntityClass())); @@ -129,14 +132,14 @@ this._dependentEntities = new java.util.ArrayList(); return this._dependentEntities.add(entity); } - + public void remove_dependentEntities_(TopiaEntity entity) throws TopiaException { if (this._dependentEntities == null) this._dependentEntities = new java.util.ArrayList(); else this._dependentEntities.remove(entity); } - + public Iterator iterator_dependentEntities_() throws TopiaException { if (this._dependentEntities == null) this._dependentEntities = new java.util.ArrayList(); Index: topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java diff -u topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java:1.13 topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java:1.14 --- topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java:1.13 Fri Aug 26 17:53:35 2005 +++ topia/src/java/org/codelutin/topia/AbstractTopiaPersistenceService.java Wed Sep 7 15:34:59 2005 @@ -23,22 +23,22 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ * - * Mise a jour: $Date: 2005/08/26 17:53:35 $ + * Mise a jour: $Date: 2005/09/07 15:34:59 $ * par : $Author: bpoussin $ */ package org.codelutin.topia; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; public abstract class AbstractTopiaPersistenceService extends AbstractTopiaService implements TopiaPersistenceService { // AbstractTopiaPersistenceService /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Logger log = Logger.getLogger("org.codelutin.topia.AbstractTopiaPersistenceService"); + static private Log log = LogFactory.getLog(AbstractTopiaPersistenceService.class); /** * Adds a new TopiaEntityListener to the subscribers list. @@ -68,9 +68,9 @@ Entity result = null; result = (Entity)getContext().getPersistenceHelper().create(getEntityClass()); try { - getContext().getListeners().fire(this.getClass(), "entityAdded", new TopiaEntityEvent(this, result)); + getContext().getListeners().fire(getEntityClass(), "entityAdded", new TopiaEntityEvent(this, result)); } catch (Exception eee) { - log.log(Level.FINE, "Erreur durant l'envoie de l'event de creation d'entity", eee); + log.debug("Erreur durant l'envoie de l'event de creation d'entity", eee); } return result; } @@ -81,24 +81,30 @@ } Entity result = (Entity)getContext().getPersistenceHelper().makePersistent(topiaEntity); try { - getContext().getListeners().fire(this.getClass(), "entityAdded", new TopiaEntityEvent(this, result)); + getContext().getListeners().fire(getEntityClass(), "entityAdded", new TopiaEntityEvent(this, result)); } catch (Exception eee) { - log.log(Level.FINE, "Erreur durant l'envoie de l'event de creation d'entity", eee); + log.debug("Erreur durant l'envoie de l'event de creation d'entity", eee); } return result; } public Entity update(Entity topiaEntity) throws TopiaException{ + log.debug("update: " + topiaEntity); if(!getEntityClass().isAssignableFrom(topiaEntity.getClass())){ throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); } Entity result = (Entity)getContext().getPersistenceHelper().update(topiaEntity); + // la notification ne se fait pas ici, mais dans le proxy + // fireEntityModified(result); + return result; + } + + public void fireEntityModified(Entity topiaEntity){ try { - getContext().getListeners().fire(this.getClass(), "entityModified", new TopiaEntityEvent(this, result)); + getContext().getListeners().fire(getEntityClass(), "entityModified", new TopiaEntityEvent(this, topiaEntity)); } catch (Exception eee) { - log.log(Level.FINE, "Erreur durant l'envoie de l'event de modification d'entity", eee); + log.debug("Erreur durant l'envoie de l'event de modification d'entity", eee); } - return result; } public void delete(Entity topiaEntity) throws TopiaException{ @@ -107,9 +113,9 @@ } getContext().getPersistenceHelper().delete(topiaEntity); try { - getContext().getListeners().fire(this.getClass(), "entityRemoved", new TopiaEntityEvent(this, topiaEntity)); + getContext().getListeners().fire(getEntityClass(), "entityRemoved", new TopiaEntityEvent(this, topiaEntity)); } catch (Exception eee) { - log.log(Level.FINE, "Erreur durant l'envoie de l'event de suppression d'entity", eee); + log.debug("Erreur durant l'envoie de l'event de suppression d'entity", eee); } } Index: topia/src/java/org/codelutin/topia/TopiaContext.java diff -u topia/src/java/org/codelutin/topia/TopiaContext.java:1.47 topia/src/java/org/codelutin/topia/TopiaContext.java:1.48 --- topia/src/java/org/codelutin/topia/TopiaContext.java:1.47 Fri Sep 2 17:18:51 2005 +++ topia/src/java/org/codelutin/topia/TopiaContext.java Wed Sep 7 15:34:59 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin -* @version $Revision: 1.47 $ +* @version $Revision: 1.48 $ * -* Mise a jour: $Date: 2005/09/02 17:18:51 $ +* Mise a jour: $Date: 2005/09/07 15:34:59 $ * par : $Author: bpoussin $ */ @@ -420,6 +420,8 @@ /** * Retourne l'objet gérant les associations entre les entités + + // FIXME cette methode sert encore ? arnaud tu as une reponse ? */ public TopiaAssociationManager getAssociationManager() { if (associationManager == null) @@ -436,6 +438,21 @@ persistenceHelper = (PersistenceHelper) contextHelper.getHelper(TopiaConst.HELPER_PERSISTENCE); } return persistenceHelper; + } + + /** + * indique si l'update est fait de facon automatique des que l'entity + * est modifie ou s'il faut appeler update explicitement. + * L'utilisation en non automatique permet de modifier plusieurs champs + * de l'entity sans qu'il y ait d'acces a la persistence sous jacente + * ce qui permet de gagner du temps dans certain cas. + */ + public boolean isAutoUpdate() throws TopiaNotFoundException { + return getPersistenceHelper().isAutoUpdate(); + } + + public void setAutoUpdate(boolean autoUpdate) throws TopiaNotFoundException { + getPersistenceHelper().setAutoUpdate(autoUpdate); } /** Index: topia/src/java/org/codelutin/topia/TopiaEntity.java diff -u topia/src/java/org/codelutin/topia/TopiaEntity.java:1.19 topia/src/java/org/codelutin/topia/TopiaEntity.java:1.20 --- topia/src/java/org/codelutin/topia/TopiaEntity.java:1.19 Tue Aug 30 13:19:52 2005 +++ topia/src/java/org/codelutin/topia/TopiaEntity.java Wed Sep 7 15:34:59 2005 @@ -23,9 +23,9 @@ * * @author Cédric Pineau * Copyright Code Lutin -* @version $Revision: 1.19 $ +* @version $Revision: 1.20 $ * -* Last update : $Date: 2005/08/30 13:19:52 $ +* Last update : $Date: 2005/09/07 15:34:59 $ * by : $Author: bpoussin $ */ package org.codelutin.topia; @@ -41,6 +41,9 @@ * Top Level common interface to all topia entityes. */ public interface TopiaEntity extends TopiaElement, Serializable{ // TopiaEntity + + @MethodInfo ( type = MethodType.GENERATED ) + public TopiaPersistenceService getPersistenceService(); @MethodInfo ( type = MethodType.GENERATED ) public Class getEntityClass(); Index: topia/src/java/org/codelutin/topia/TopiaPersistenceService.java diff -u topia/src/java/org/codelutin/topia/TopiaPersistenceService.java:1.11 topia/src/java/org/codelutin/topia/TopiaPersistenceService.java:1.12 --- topia/src/java/org/codelutin/topia/TopiaPersistenceService.java:1.11 Thu Aug 11 16:38:57 2005 +++ topia/src/java/org/codelutin/topia/TopiaPersistenceService.java Wed Sep 7 15:34:59 2005 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.11 $ + * @version $Revision: 1.12 $ * - * Mise a jour: $Date: 2005/08/11 16:38:57 $ - * par : $Author: thimel $ + * Mise a jour: $Date: 2005/09/07 15:34:59 $ + * par : $Author: bpoussin $ */ package org.codelutin.topia; @@ -73,6 +73,8 @@ * @param topiaEntity - the TopiaEntity whose changes must be made persistent. */ public Entity update(Entity topiaEntity) throws TopiaException; + + public void fireEntityModified(Entity topiaEntity); /** * Returns all TopiaEntity related to this CRUD.