Index: topia/src/java/org/codelutin/topia/persistence/PersistenceHelper.java diff -u /dev/null topia/src/java/org/codelutin/topia/persistence/PersistenceHelper.java:1.3 --- /dev/null Sun Aug 1 14:52:37 2004 +++ topia/src/java/org/codelutin/topia/persistence/PersistenceHelper.java Sun Aug 1 14:52:32 2004 @@ -0,0 +1,65 @@ +/* *##% + * Copyright (C) 2002, 2003, 2004 + * 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. + *##%*/ + +/* * + * PersistenceHelper.java + * + * Created: Aug 1, 2004 + * + * @author Cédric Pineau + * @version $Revision: 1.3 $ + * + * Last update : $Date: 2004/08/01 14:52:32 $ + * by : $Author: pineau $ + */ + +package org.codelutin.topia.persistence; + +import java.util.List; + +import org.codelutin.topia.TopiaEntity; +import org.codelutin.topia.TopiaException; +import org.codelutin.topia.TopiaQuery; + +/** + * + */ +public interface PersistenceHelper { + + public abstract TopiaEntity create(Class entityClass) throws TopiaException; + + public abstract TopiaEntity makePersistent(TopiaEntity entity) + throws TopiaException; + + public abstract TopiaEntity update(TopiaEntity entity) + throws TopiaException; + + public abstract void delete(TopiaEntity entity) throws TopiaException; + + /** + * Permet de récupéré une liste d'objet par rapport a une requete. + * + * @param query + * la requete a executer + * @return une List d'objets + */ + public abstract List find(TopiaQuery query) throws TopiaException; + + public abstract int size(TopiaQuery query) throws TopiaException; +} \ No newline at end of file Index: topia/src/java/org/codelutin/topia/persistence/AbstractPersistenceHelper.java diff -u topia/src/java/org/codelutin/topia/persistence/AbstractPersistenceHelper.java:1.1 topia/src/java/org/codelutin/topia/persistence/AbstractPersistenceHelper.java:1.2 --- topia/src/java/org/codelutin/topia/persistence/AbstractPersistenceHelper.java:1.1 Fri Jul 30 16:57:58 2004 +++ topia/src/java/org/codelutin/topia/persistence/AbstractPersistenceHelper.java Sun Aug 1 14:52:32 2004 @@ -23,9 +23,9 @@ * Created: Jul 30, 2004 * * @author Cédric Pineau - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * - * Last update : $Date: 2004/07/30 16:57:58 $ + * Last update : $Date: 2004/08/01 14:52:32 $ * by : $Author: pineau $ */ @@ -41,7 +41,7 @@ import org.codelutin.topia.persistence.jdo.AbstractLazyEntity; import org.codelutin.topia.persistence.jdo.Util; -public abstract class AbstractPersistenceHelper { // AbstractPersistenceHelper +public abstract class AbstractPersistenceHelper implements PersistenceHelper { // AbstractPersistenceHelper /** * Le context a partir duquel on a recupere ce AbstractPersistenceHelper @@ -91,7 +91,7 @@ public abstract int size(TopiaQuery query) throws TopiaException; - protected abstract TopiaEntity findByTopiaId(String id) throws TopiaException; + public abstract TopiaEntity findByTopiaId(String id) throws TopiaException; } // AbstractPersistenceHelper Index: topia/src/java/org/codelutin/topia/persistence/DistributedPersistenceHelper.java diff -u topia/src/java/org/codelutin/topia/persistence/DistributedPersistenceHelper.java:1.1 topia/src/java/org/codelutin/topia/persistence/DistributedPersistenceHelper.java:1.2 --- topia/src/java/org/codelutin/topia/persistence/DistributedPersistenceHelper.java:1.1 Fri Jul 30 16:57:58 2004 +++ topia/src/java/org/codelutin/topia/persistence/DistributedPersistenceHelper.java Sun Aug 1 14:52:32 2004 @@ -23,9 +23,9 @@ * Created: Jul 30, 2004 * * @author Cédric Pineau - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * - * Last update : $Date: 2004/07/30 16:57:58 $ + * Last update : $Date: 2004/08/01 14:52:32 $ * by : $Author: pineau $ */ @@ -34,6 +34,7 @@ import java.util.List; import java.util.Properties; +import org.codelutin.topia.TopiaArgument; import org.codelutin.topia.TopiaContext; import org.codelutin.topia.TopiaEntity; import org.codelutin.topia.TopiaException; @@ -49,14 +50,15 @@ } public TopiaEntity makePersistent(TopiaEntity entity) throws TopiaException { - return null; + return (TopiaEntity) context.getDistributionHelper().call(PersistenceHelper.class,"makePersistent", new TopiaArgument().addArg(entity)); } public TopiaEntity update(TopiaEntity entity) throws TopiaException { - return null; + return (TopiaEntity) context.getDistributionHelper().call(PersistenceHelper.class,"update", new TopiaArgument().addArg(entity)); } public void delete(TopiaEntity entity) throws TopiaException { + context.getDistributionHelper().call(PersistenceHelper.class,"delete", new TopiaArgument().addArg(entity)); } /** @@ -65,15 +67,15 @@ * @return une List d'objets */ public List find(TopiaQuery query) throws TopiaException { - return null; + return (List) context.getDistributionHelper().call(PersistenceHelper.class,"find", new TopiaArgument().addArg(query)); } public int size(TopiaQuery query) throws TopiaException { - return 0; + return ((Integer) context.getDistributionHelper().call(PersistenceHelper.class,"size", new TopiaArgument().addArg(query))).intValue(); } - protected TopiaEntity findByTopiaId(String id) throws TopiaException { - return null; + public TopiaEntity findByTopiaId(String id) throws TopiaException { + return (TopiaEntity) context.getDistributionHelper().call(PersistenceHelper.class,"findByTopiaId", new TopiaArgument().addArg(id)); } }