Index: topia2/src/java/org/codelutin/topia/event/TopiaVetoableEntityEvent.java diff -u topia2/src/java/org/codelutin/topia/event/TopiaVetoableEntityEvent.java:1.1 topia2/src/java/org/codelutin/topia/event/TopiaVetoableEntityEvent.java:1.2 --- topia2/src/java/org/codelutin/topia/event/TopiaVetoableEntityEvent.java:1.1 Thu Jan 5 04:51:23 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaVetoableEntityEvent.java Fri Jan 6 12:15:20 2006 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * - * Mise a jour: $Date: 2006/01/05 04:51:23 $ + * Mise a jour: $Date: 2006/01/06 12:15:20 $ * par : $Author: bpoussin $ */ @@ -40,21 +40,32 @@ private static final long serialVersionUID = 1L; 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 */ - public TopiaVetoableEntityEvent(Object source, Object id){ + public TopiaVetoableEntityEvent(Object source, Class entityClass, Object id){ super(source); + this.entityClass = entityClass; this.id = id; date = System.currentTimeMillis(); } + + /** + * @return Returns the entityClass. + */ + public Class getEntityClass() { + return this.entityClass; + } + /** - * Retourne la liste des entitées sur lequel porte l'event - * @return une liste non modifiable d'entité + * 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; Index: topia2/src/java/org/codelutin/topia/event/TopiaTransactionEvent.java diff -u /dev/null topia2/src/java/org/codelutin/topia/event/TopiaTransactionEvent.java:1.1 --- /dev/null Fri Jan 6 12:15:26 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaTransactionEvent.java Fri Jan 6 12:15:20 2006 @@ -0,0 +1,116 @@ +/* + * *##% 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.1 $ + * + * Mise a jour: $Date: 2006/01/06 12:15:20 $ par : $Author: bpoussin $ + */ + +package org.codelutin.topia.event; + +import java.util.Date; +import java.util.EventObject; + +import org.apache.commons.lang.ObjectUtils; + +/** + * 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 + + /** */ + private static final long serialVersionUID = 1L; + + 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 + */ + public TopiaTransactionEvent(Object source, Class entityClass, Object id) { + super(source); + this.entityClass = entityClass; + this.id = id; + date = System.currentTimeMillis(); + } + + /** + * @return Returns the entityClass. + */ + public Class getEntityClass() { + return this.entityClass; + } + + /** + * 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; + } + + /** + * 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/TopiaTransactionListener.java diff -u /dev/null topia2/src/java/org/codelutin/topia/event/TopiaTransactionListener.java:1.1 --- /dev/null Fri Jan 6 12:15:27 2006 +++ topia2/src/java/org/codelutin/topia/event/TopiaTransactionListener.java Fri Jan 6 12:15:20 2006 @@ -0,0 +1,51 @@ +/* *##% + * 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.1 $ + * + * Mise a jour: $Date: 2006/01/06 12:15:20 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.event; + +import java.util.EventListener; +import java.util.List; + +public interface TopiaTransactionListener extends EventListener { + + /** + * Appelé apres un commit + * @param events la liste de tous les objets impacté par le commit + */ + public void commit(List events); + + /** + * Appelé apres un rollback + * @param events la liste de tous les objets impacté par le commit + */ + public void rollback(List events); + +}