Index: topia2/src/java/org/codelutin/topia/event/TopiaTransactionEvent.java diff -u topia2/src/java/org/codelutin/topia/event/TopiaTransactionEvent.java:1.2 topia2/src/java/org/codelutin/topia/event/TopiaTransactionEvent.java:1.3 --- topia2/src/java/org/codelutin/topia/event/TopiaTransactionEvent.java:1.2 Mon Oct 9 14:20:18 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaTransactionEvent.java Mon Oct 23 15:01:57 2006 @@ -1,5 +1,5 @@ /* - * *##% Copyright (C) 2002, 2003 Code Lutin + * *##% Copyright (C) 2005 Code Lutin, Cédric Pineau, Benjamin Poussin * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software @@ -16,141 +16,35 @@ * Place - Suite 330, Boston, MA 02111-1307, USA. ##% */ -/******************************************************************************* - * TopiaEntityEvent.java - * - * Created: 14 mai 2004 - * - * @author Benjamin Poussin Copyright Code Lutin - * - * @version $Revision: 1.2 $ - * - * Mise a jour: $Date: 2006/10/09 14:20:18 $ par : $Author: bpoussin $ - */ - package org.codelutin.topia.event; -import java.util.Date; import java.util.EventObject; +import java.util.HashSet; +import java.util.Set; -import org.apache.commons.lang.ObjectUtils; import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.persistence.TopiaEntity; -/** - * Permet de savoir que l'entite ayant l'id passé en parametre du constructeur - * a ete impacté par la fin de la transation, mais on ne sait pas si l'objet - * a ete modifier, creer, detruit. Il faut faire un findByTopiaId pour connaitre - * l'action qui a ete reellement faite. Si on ne retrouve pas l'objet c une - * destruction, si l'objet que l'on a n'a pas la meme version c une modification - * Si l'objet a la version 0 c'est une creation (si une autre transaction - * impactant aussi cette objet creer a ete commité entre temps il est possible - * que la version ne soit pas 0 mais 1 ou plus) - * - * @author poussin - * - */ -public class TopiaTransactionEvent extends EventObject { // TopiaEntityEvent +public class TopiaTransactionEvent extends EventObject { - public enum TYPE {CREATE, UPDATE, DELETE}; - - /** */ private static final long serialVersionUID = 1L; - protected TYPE type; + private Set entities; - protected long date = 0; - - protected Class entityClass; - - protected Object id = null; - - /** - * @param source l'objet d'ou provient l'event - * @param entity l'entity sur lequel porte l'event - */ - protected TopiaTransactionEvent(TopiaContext source, TYPE type, Class entityClass, Object id) { + public TopiaTransactionEvent(Object source) { super(source); - this.entityClass = entityClass; - this.type = type; - this.id = id; - date = System.currentTimeMillis(); + entities = new HashSet(); } - static public TopiaTransactionEvent create( - TopiaContext source, Class entityClass, Object id) { - TopiaTransactionEvent result = new TopiaTransactionEvent( - source, TYPE.CREATE, entityClass, id); - return result; - } - - static public TopiaTransactionEvent update( - TopiaContext source, Class entityClass, Object id) { - TopiaTransactionEvent result = new TopiaTransactionEvent( - source, TYPE.UPDATE, entityClass, id); - return result; + public void addEntity(TopiaEntity entity) { + entities.add(entity); } - - static public TopiaTransactionEvent delete( - TopiaContext source, Class entityClass, Object id) { - TopiaTransactionEvent result = new TopiaTransactionEvent( - source, TYPE.DELETE, entityClass, id); - return result; - } - - public TopiaContext getTopiaContext() { - TopiaContext result = (TopiaContext)getSource(); - return result; - } - - /** - * @return Returns the entityClass. - */ - public Class getEntityClass() { - return this.entityClass; - } - - /** - * @return the type - */ - public TYPE getType() { - return this.type; + public Set getEntities() { + return entities; } - /** - * L'identifiant ou null si on a pas pu avoir d'identifiant, cela arrive par - * exemple pour un create ou l'objet peu ne pas encore avoir d'idenfiant - * - * @return l'idenfiant s'il y en a un - */ - public Object getId() { - return id; + public TopiaContext getSource() { + return (TopiaContext) super.getSource(); } - - /** - * Le moment ou l'event a ete créé. - */ - public Date getCreationDate() { - return new Date(date); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj instanceof TopiaTransactionEvent == false) { - return false; - } - TopiaTransactionEvent other = (TopiaTransactionEvent) obj; - return ObjectUtils.equals(getId(), other.getId()) - && ObjectUtils.equals(getEntityClass(), other.getEntityClass()); - } - -} // TopiaEntityEvent - +} Index: topia2/src/java/org/codelutin/topia/event/TopiaEntityListener.java diff -u topia2/src/java/org/codelutin/topia/event/TopiaEntityListener.java:1.3 topia2/src/java/org/codelutin/topia/event/TopiaEntityListener.java:1.4 --- topia2/src/java/org/codelutin/topia/event/TopiaEntityListener.java:1.3 Mon Jan 30 14:38:53 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaEntityListener.java Mon Oct 23 15:01:57 2006 @@ -1,32 +1,19 @@ -/* *##% - * Copyright (C) 2002, 2003 Code Lutin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *##%*/ - -/* * - * TopiaEntityListener.java - * - * Created: 14 mai 2004 - * - * @author Benjamin Poussin - * Copyright Code Lutin - * @version $Revision: 1.3 $ - * - * Mise a jour: $Date: 2006/01/30 14:38:53 $ - * par : $Author: thimel $ +/* + * *##% Copyright (C) 2005 Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307, USA. ##% */ package org.codelutin.topia.event; @@ -35,19 +22,9 @@ public interface TopiaEntityListener extends EventListener { - /** - * Appelé lorsqu'une ou plusieurs entités ont été créées - */ - public void entityCreated(TopiaEntityEvent event); - - /** - * Appelé lorsqu'une ou plusieurs entités ont été modifiées - */ - public void entityUpdated(TopiaEntityEvent event); - - /** - * Appelé lorsqu'une ou plusieurs entités ont été supprimées - */ - public void entityDeleted(TopiaEntityEvent event); + public void create(TopiaEntityEvent event); + public void load(TopiaEntityEvent event); + public void update(TopiaEntityEvent event); + public void delete(TopiaEntityEvent event); } Index: topia2/src/java/org/codelutin/topia/event/TopiaEntityEvent.java diff -u topia2/src/java/org/codelutin/topia/event/TopiaEntityEvent.java:1.2 topia2/src/java/org/codelutin/topia/event/TopiaEntityEvent.java:1.3 --- topia2/src/java/org/codelutin/topia/event/TopiaEntityEvent.java:1.2 Mon Jan 23 13:51:52 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaEntityEvent.java Mon Oct 23 15:01:57 2006 @@ -1,90 +1,52 @@ -/* *##% - * Copyright (C) 2002, 2003 Code Lutin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *##%*/ - -/* * - * TopiaEntityEvent.java - * - * Created: 14 mai 2004 - * - * @author Benjamin Poussin - * Copyright Code Lutin - * @version $Revision: 1.2 $ - * - * Mise a jour: $Date: 2006/01/23 13:51:52 $ - * par : $Author: bpoussin $ +/* + * *##% Copyright (C) 2005 Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307, USA. ##% */ -package org.codelutin.topia.event; + package org.codelutin.topia.event; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; import java.util.EventObject; -public class TopiaEntityEvent extends EventObject { // TopiaEntityEvent +import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.persistence.TopiaEntity; + +public class TopiaEntityEvent extends EventObject { - /** */ private static final long serialVersionUID = 1L; - - protected long date = 0; - protected Collection entities = null; - /** - * @param source l'objet d'ou provient l'event - * @param entity l'entity sur lequel porte l'event - */ - public TopiaEntityEvent(Object source, Object entity){ + private TopiaEntity entity; + private Object[] state; + + public TopiaEntityEvent(Object source, TopiaEntity entity, Object[] state) { super(source); - date = System.currentTimeMillis(); - ArrayList tmp = new ArrayList(); - tmp.add(entity); - this.entities = Collections.unmodifiableList(tmp); + this.entity = entity; + this.state = state; } - /** - * @param source l'objet d'ou provient l'event - * @param entities la liste des entitées sur lequel porte l'event - */ - public TopiaEntityEvent(Object source, Collection entities){ - super(source); - date = System.currentTimeMillis(); - // on fait une copie pour que l'on ne soit pas affecté par des - // changement fait sur la collection passé en parametre - ArrayList tmp = new ArrayList(); - tmp.addAll(entities); - this.entities = Collections.unmodifiableCollection(tmp); + public TopiaEntity getEntity() { + return entity; } - - /** - * Retourne la liste des entitées sur lequel porte l'event - * @return une liste non modifiable d'entité - */ - public Collection getTopiaEntities(){ - return entities; + + public TopiaContext getSource() { + return (TopiaContext) super.getSource(); } - /** - * Le moment ou l'event a ete créé. - */ - public Date getCreationDate(){ - return new Date(date); + public Object[] getState() { + return state; } - -} // TopiaEntityEvent + +} Index: topia2/src/java/org/codelutin/topia/event/TopiaTransactionListener.java diff -u topia2/src/java/org/codelutin/topia/event/TopiaTransactionListener.java:1.4 topia2/src/java/org/codelutin/topia/event/TopiaTransactionListener.java:1.5 --- topia2/src/java/org/codelutin/topia/event/TopiaTransactionListener.java:1.4 Wed Aug 2 12:42:56 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaTransactionListener.java Mon Oct 23 15:01:57 2006 @@ -1,32 +1,19 @@ -/* *##% - * Copyright (C) 2002, 2003 Code Lutin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - *##%*/ - -/* * - * TopiaEntityListener.java - * - * Created: 14 mai 2004 - * - * @author Benjamin Poussin - * Copyright Code Lutin - * @version $Revision: 1.4 $ - * - * Mise a jour: $Date: 2006/08/02 12:42:56 $ - * par : $Author: bpoussin $ +/* + * *##% Copyright (C) 2005 Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307, USA. ##% */ package org.codelutin.topia.event; @@ -34,17 +21,8 @@ import java.util.EventListener; public interface TopiaTransactionListener extends EventListener { - - /** - * Appelé apres un commit - * @param events la liste de tous les objets impacté par le commit - */ - public void commit(TopiaTransactionEvents event); - - /** - * Appelé apres un rollback - * @param events la liste de tous les objets impacté par le rollback - */ - public void rollback(TopiaTransactionEvents event); - + + public void commit(TopiaTransactionEvent event); + public void rollback(TopiaTransactionEvent event); + } Index: topia2/src/java/org/codelutin/topia/event/TopiaEntityVetoable.java diff -u /dev/null topia2/src/java/org/codelutin/topia/event/TopiaEntityVetoable.java:1.1 --- /dev/null Mon Oct 23 15:02:03 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaEntityVetoable.java Mon Oct 23 15:01:57 2006 @@ -0,0 +1,30 @@ +/* + * *##% Copyright (C) 2005 Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307, USA. ##% + */ + +package org.codelutin.topia.event; + +import java.util.EventListener; + +public interface TopiaEntityVetoable extends EventListener { + + public void create(TopiaEntityEvent event); + public void load(TopiaEntityEvent event); + public void update(TopiaEntityEvent event); + public void delete(TopiaEntityEvent event); + +} Index: topia2/src/java/org/codelutin/topia/event/TopiaTransactionVetoable.java diff -u /dev/null topia2/src/java/org/codelutin/topia/event/TopiaTransactionVetoable.java:1.1 --- /dev/null Mon Oct 23 15:02:03 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaTransactionVetoable.java Mon Oct 23 15:01:57 2006 @@ -0,0 +1,27 @@ +/* + * *##% Copyright (C) 2005 Code Lutin, Cédric Pineau, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 Temple + * Place - Suite 330, Boston, MA 02111-1307, USA. ##% + */ + +package org.codelutin.topia.event; + +import java.util.EventListener; + +public interface TopiaTransactionVetoable extends EventListener { + + public void beginTransaction(TopiaTransactionEvent event); + +}