From tchemit@users.nuiton.org Sat Aug 14 15:54:40 2010
From: tchemit@users.nuiton.org
To: topia-commits@list.nuiton.org
Subject: [Topia-commits] r2098 - in trunk/topia-service-replication/src:
	main/java/org/nuiton/topia/replication
	main/java/org/nuiton/topia/replication/model
	main/java/org/nuiton/topia/replication/operation
	main/resources/META-INF/services	test/java/org/nuiton/topia/replication
	test/java/org/nuiton/topia/replication/operation
Date: Sat, 14 Aug 2010 15:54:40 +0200
Message-ID: <20100814135440.6CC17159FD@nuiton.codelutin.com>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============0696721817822519244=="

--===============0696721817822519244==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Author: tchemit
Date: 2010-08-14 15:54:40 +0200 (Sat, 14 Aug 2010)
New Revision: 2098

Url: http://nuiton.org/repositories/revision/topia/2098

Log:
clean code
reformat code
add javadoc + project informations (author, since,...)
remove Dependencies-like operation
improve Engine code
use TopiaEntityIdsMap


Removed:
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/operation/AttachDependency.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/operation/DettachDependency.java
Modified:
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/ReplicationEngine.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/TopiaReplicationImplementor.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/TopiaReplicationOperation.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/TopiaReplicationService.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/model/Link.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/model/ReplicationModel.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/model/ReplicationNode.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/model/ReplicationOperationDef.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/model/ReplicationOperationPhase.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/operation/AttachAssociation.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/operation/AttachLink.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/operation/DettachAssociation.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/operation/Duplicate.java
   trunk/topia-service-replication/src/main/java/org/nuiton/topia/replication=
/operation/LoadLink.java
   trunk/topia-service-replication/src/main/resources/META-INF/services/org.n=
uiton.topia.replication.TopiaReplicationOperation
   trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication=
/AbstractReplicationEngineTest.java
   trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication=
/ReplicationEngineAllTest.java
   trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication=
/ReplicationEngineTest.java
   trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication=
/TopiaReplicationOperationTest.java
   trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication=
/operation/FakeOperation.java
   trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication=
/operation/UncreatableOperation.java
   trunk/topia-service-replication/src/test/java/org/nuiton/topia/replication=
/operation/UnregistredOperation.java

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/ReplicationEngine.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/ReplicationEngine.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/ReplicationEngine.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -33,6 +33,7 @@
 import org.nuiton.topia.persistence.TopiaEntity;
 import org.nuiton.topia.persistence.TopiaEntityEnum;
 import org.nuiton.topia.persistence.util.TopiaEntityHelper;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.model.ReplicationModel;
 import org.nuiton.topia.replication.model.ReplicationNode;
 import org.nuiton.topia.replication.model.ReplicationOperationDef;
@@ -40,9 +41,7 @@
=20
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.ServiceLoader;
 import java.util.Set;
=20
@@ -51,11 +50,12 @@
 /**
  * Implantation du service de replication.
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class ReplicationEngine implements TopiaReplicationImplementor {
=20
-    /** to use log facility, just put in your code: log.info(\"...\"); */
+    /** Logger */
     private static final Log log =3D LogFactory.getLog(ReplicationEngine.cla=
ss);
=20
     /** le contexte sur la base source de la replication */
@@ -67,7 +67,7 @@
      *
      * @see #preInit(TopiaContextImplementor)
      */
-    protected static TopiaReplicationOperation[] operations;
+    protected TopiaReplicationOperation[] operations;
=20
     //----------------------------------------------------------------------=
----
     //-- TopiaService implementation ---------------------------------------=
----
@@ -87,24 +87,22 @@
     @Override
     public boolean preInit(TopiaContextImplementor context) {
         if (operations =3D=3D null) {
+            // chargement des operations disponibles une seule fois
=20
-            // on effectue cette rechercher une seule fois par jvm
-            synchronized (this) {
-                // chargement des operations disponibles une seule fois
+            ServiceLoader<TopiaReplicationOperation> loader =3D
+                    ServiceLoader.load(TopiaReplicationOperation.class);
=20
-                ServiceLoader<TopiaReplicationOperation> loader =3D ServiceL=
oader.load(TopiaReplicationOperation.class);
+            List<TopiaReplicationOperation> operations =3D
+                    new ArrayList<TopiaReplicationOperation>();
=20
-                List<TopiaReplicationOperation> discoveredOperations =3D new=
 ArrayList<TopiaReplicationOperation>();
-
-                for (TopiaReplicationOperation op : loader) {
-                    if (log.isDebugEnabled()) {
-                        log.debug("detected operation " + op);
-                    }
-                    discoveredOperations.add(op);
-
+            for (TopiaReplicationOperation op : loader) {
+                if (log.isDebugEnabled()) {
+                    log.debug("detected operation " + op);
                 }
-                operations =3D discoveredOperations.toArray(new TopiaReplica=
tionOperation[discoveredOperations.size()]);
+                operations.add(op);
             }
+            this.operations =3D operations.toArray(
+                    new TopiaReplicationOperation[operations.size()]);
         }
         return true;
     }
@@ -127,7 +125,8 @@
     //----------------------------------------------------------------------=
----
=20
     @Override
-    public ReplicationModel prepare(TopiaEntityEnum[] contracts, String... e=
ntities) throws TopiaException {
+    public ReplicationModel prepare(TopiaEntityEnum[] contracts,
+                                    String... entities) throws TopiaExceptio=
n {
         ReplicationModel model =3D createModel(contracts, entities);
=20
         initModel(model, true);
@@ -145,7 +144,8 @@
     }
=20
     @Override
-    public ReplicationModel prepareWithComputedOrder(TopiaEntityEnum[] contr=
acts, String... topiaIds) throws TopiaException {
+    public ReplicationModel prepareWithComputedOrder(TopiaEntityEnum[] contr=
acts,
+                                                     String... topiaIds) thr=
ows TopiaException {
         ReplicationModel model =3D createModelWithComputedOrder(contracts, t=
opiaIds);
=20
         initModel(model, false);
@@ -154,24 +154,41 @@
     }
=20
     @Override
-    public void addBeforeOperation(ReplicationModel model, TopiaEntityEnum t=
ype, Class<? extends TopiaReplicationOperation> operationClass, Object... par=
ameters) {
-        createOperation(model, type, ReplicationOperationPhase.before, opera=
tionClass, parameters);
+    public void addBeforeOperation(ReplicationModel model,
+                                   TopiaEntityEnum type,
+                                   Class<? extends TopiaReplicationOperation=
> operationClass,
+                                   Object... parameters) {
+        createOperation(model,
+                        type,
+                        ReplicationOperationPhase.before,
+                        operationClass,
+                        parameters
+        );
     }
=20
     @Override
-    public void addAfterOperation(ReplicationModel model, TopiaEntityEnum ty=
pe, Class<? extends TopiaReplicationOperation> operationClass, Object... para=
meters) {
-        createOperation(model, type, ReplicationOperationPhase.after, operat=
ionClass, parameters);
+    public void addAfterOperation(ReplicationModel model,
+                                  TopiaEntityEnum type,
+                                  Class<? extends TopiaReplicationOperation>=
 operationClass,
+                                  Object... parameters) {
+        createOperation(model,
+                        type,
+                        ReplicationOperationPhase.after,
+                        operationClass,
+                        parameters
+        );
     }
=20
     @Override
-    public void doReplicate(ReplicationModel model, TopiaContext dstCtxt) th=
rows Exception {
+    public void doReplicate(ReplicationModel model,
+                            TopiaContext dstCtxt) throws Exception {
=20
         checkNotNull("doReplicate", "model", model);
         checkNotNull("doReplicate", "dstCtxt", dstCtxt);
=20
         TopiaContextImplementor srcCtxt =3D null;
=20
-        Map<Class<? extends TopiaEntity>, List<String>> data =3D null;
+        TopiaEntityIdsMap data =3D null;
=20
         // keep the list of treated nodes (to roolback them if something
         // is wrong).
@@ -205,7 +222,17 @@
                 try {
                     doReplicateNode(node, srcCtxt, tx, data, treated);
                 } catch (Exception e) {
-                    tx.rollbackTransaction();
+
+                    // un erreur est survenu sur le noeud de r=C3=A9plication
+                    // on rollback la transaction de ce noeud
+                    try {
+                        tx.rollbackTransaction();
+                    } finally {
+
+                        // on revert les noeuds deja commite
+                        doRollback(model, data, treated, dstCtxt);
+                    }
+
                     throw e;
                 } finally {
                     srcCtxt.closeContext();
@@ -236,34 +263,95 @@
         }
     }
=20
+    @Override
+    public void doRollback(ReplicationModel model,
+                           TopiaEntityIdsMap data,
+                           List<ReplicationNode> nodes,
+                           TopiaContext dstCtxt) throws Exception {
+        if (nodes.isEmpty()) {
+
+            // aucun noeud de r=C3=A9plication commit=C3=A9s
+            return;
+        }
+
+        TopiaContextImplementor srcCtxt;
+
+        TopiaContext tx;
+
+        boolean needTransaction =3D true;
+
+        log.info("Will rollback " + nodes.size() + " nodes...");
+
+        for (ReplicationNode node : nodes) {
+
+            log.info("Rollback node " + node);
+            srcCtxt =3D (TopiaContextImplementor) context.beginTransaction();
+
+            if (needTransaction) {
+                tx =3D dstCtxt.beginTransaction();
+            } else {
+                tx =3D dstCtxt;
+            }
+            try {
+                doRollbackNode(node, srcCtxt, tx, data);
+            } catch (Exception e) {
+
+                // un erreur est survenu sur le noeud de r=C3=A9plication
+                // on rollback la transaction de ce noeud
+
+                tx.rollbackTransaction();
+
+            } finally {
+                srcCtxt.rollbackTransaction();
+                srcCtxt.closeContext();
+
+                if (needTransaction) {
+                    // on doit fermer la transaction car on l'a ouverte dans
+                    // cette m=C3=A9thode, sinon c'est de la responsabilite =
du
+                    // code appellant
+                    tx.closeContext();
+                }
+            }
+
+        }
+    }
+
     //----------------------------------------------------------------------=
----
     //-- TopiaReplicationImplementor implementation ------------------------=
----
     //----------------------------------------------------------------------=
----
=20
     @Override
     public ReplicationModel createModel(TopiaEntityEnum[] contracts,
-                                        String... topiaIds) throws TopiaExce=
ption {
-        Set<Class<? extends TopiaEntity>> detectTypes =3D detectTypes(contra=
cts, topiaIds);
-        ReplicationModel model =3D new ReplicationModel(contracts, detectTyp=
es, topiaIds);
+                                        String... topiaIds)
+            throws TopiaException {
+
+        Set<Class<? extends TopiaEntity>> detectTypes =3D
+                detectTypes(contracts, topiaIds);
+        ReplicationModel model =3D
+                new ReplicationModel(contracts, detectTypes, topiaIds);
         return model;
     }
=20
     @Override
-    public ReplicationModel createModelWithComputedOrder(TopiaEntityEnum[] c=
ontracts,
-                                                         String... topiaIds)=
 throws TopiaException {
-        ReplicationModel model =3D new ReplicationModel(contracts, false, to=
piaIds);
+    public ReplicationModel createModelWithComputedOrder(
+            TopiaEntityEnum[] contracts, String... topiaIds)
+            throws TopiaException {
+        ReplicationModel model =3D
+                new ReplicationModel(contracts, false, topiaIds);
         return model;
     }
=20
     @Override
-    public ReplicationModel createModelForAll(TopiaEntityEnum[] contracts) t=
hrows TopiaException {
+    public ReplicationModel createModelForAll(TopiaEntityEnum[] contracts)
+            throws TopiaException {
         ReplicationModel model =3D new ReplicationModel(contracts, true);
         return model;
     }
=20
     @Override
     public ReplicationModel initModel(ReplicationModel model,
-                                      boolean computeOrder) throws TopiaExce=
ption {
+                                      boolean computeOrder)
+            throws TopiaException {
         checkNotNull("initModel", "model", model);
=20
         model.detectAssociations();
@@ -278,7 +366,8 @@
     }
=20
     @Override
-    public TopiaReplicationOperation getOperation(Class<? extends TopiaRepli=
cationOperation> operationClass) {
+    public TopiaReplicationOperation getOperation(
+            Class<? extends TopiaReplicationOperation> operationClass) {
         checkNotNull("getOperation", "operationClass", operationClass);
=20
         if (operations =3D=3D null) {
@@ -310,24 +399,35 @@
         TopiaReplicationOperation operation =3D getOperation(operationClass);
=20
         if (operation =3D=3D null) {
-            throw new IllegalArgumentException(_("topia.replication.engine.e=
rror.unkown.operation", operationClass.getSimpleName(), Arrays.toString(opera=
tions)));
+            throw new IllegalArgumentException(
+                    _("topia.replication.engine.error.unkown.operation",
+                      operationClass.getSimpleName(),
+                      Arrays.toString(operations))
+            );
         }
=20
         ReplicationNode node =3D model.getNode(type);
         if (node =3D=3D null) {
-            throw new IllegalArgumentException(_("topia.replication.engine.e=
rror.unkown.owner.node", type, operationClass.getSimpleName(), model.getNodes=
()));
+            throw new IllegalArgumentException(
+                    _("topia.replication.engine.error.unkown.owner.node",
+                      type,
+                      operationClass.getSimpleName(),
+                      model.getNodes())
+            );
         }
         operation.register(model, node, phase, parameters);
     }
=20
     @Override
-    public Set<Class<? extends TopiaEntity>> detectTypes(TopiaEntityEnum[] c=
ontracts, String... ids) throws TopiaException {
+    public Set<Class<? extends TopiaEntity>> detectTypes(
+            TopiaEntityEnum[] contracts, String... ids) throws TopiaExceptio=
n {
         TopiaContext ctxt =3D context.beginTransaction();
         try {
             TopiaEntity[] entities =3D getEntities(ctxt, ids);
=20
             // on detecte tous les types connus pour les entites donn=C3=A9es
-            Set<Class<? extends TopiaEntity>> types =3D TopiaEntityHelper.de=
tectTypes(contracts, entities);
+            Set<Class<? extends TopiaEntity>> types =3D
+                    TopiaEntityHelper.detectTypes(contracts, entities);
=20
             if (log.isDebugEnabled()) {
                 log.debug("for type : " + entities.getClass());
@@ -342,21 +442,33 @@
     }
=20
     @Override
-    public Map<Class<? extends TopiaEntity>, List<String>> getIds(Replicatio=
nModel model, TopiaContextImplementor srcCtxt) throws TopiaException {
-        Map<Class<? extends TopiaEntity>, List<String>> data;
+    public TopiaEntityIdsMap getIds(ReplicationModel model,
+                                    TopiaContextImplementor srcCtxt)
+            throws TopiaException {
+
+        TopiaEntityIdsMap data;
+
         // on recupere les objets a repliquer par type
         if (model.isReplicateAll()) {
+
             // on recupere pour chaque type tous les ids des entites a repli=
quer
-            data =3D new HashMap<Class<? extends TopiaEntity>, List<String>>=
();
+            data =3D new TopiaEntityIdsMap();
             for (TopiaEntityEnum e : model.getContracts()) {
                 List<String> ids =3D srcCtxt.getDAO(e.getContract()).findAll=
Ids();
                 data.put(e.getContract(), ids);
             }
         } else {
+
             // on recupere les entites specifies a repliquer
-            TopiaEntity[] entities =3D getEntities(srcCtxt, model.getTopiaId=
s());
+            TopiaEntity[] entities =3D getEntities(srcCtxt,
+                                                 model.getTopiaIds()
+            );
+
             // on calcule toutes les ids des entites a repliquer
-            data =3D TopiaEntityHelper.detectEntityIds(model.getContracts(),=
 model.getTypes(), entities);
+            data =3D TopiaEntityHelper.detectEntityIds(model.getContracts(),
+                                                     model.getTypes(),
+                                                     entities
+            );
         }
         return data;
     }
@@ -366,10 +478,11 @@
             ReplicationNode node,
             TopiaContext srcCtxt,
             TopiaContext dstCtxt,
-            Map<Class<? extends TopiaEntity>, List<String>> data,
+            TopiaEntityIdsMap data,
             List<ReplicationNode> treated) throws Exception {
=20
-        // on trie toujours les operations a realiser selon leur phase (avan=
t ou apres la duplication)
+        // on trie toujours les operations a realiser selon leur phase
+        //  (avant ou apres la duplication)
         node.sortOperations();
=20
         List<ReplicationOperationDef> operationDefs =3D node.getOperations();
@@ -378,11 +491,15 @@
             log.info("skip node " + node + " - no operation detected.");
         } else {
=20
-            log.info("start for " + node + " : " + operationDefs.size() + " =
operation(s)");
+            log.info("start for " + node + " : " + operationDefs.size() +
+                     " operation(s)");
=20
-            List<String> nodeEntityIds =3D data.get(node.getContract().getCo=
ntract());
+            List<String> nodeEntityIds =3D
+                    data.get(node.getContract().getContract());
+
             if (log.isInfoEnabled()) {
-                log.info("will replicate on " + nodeEntityIds.size() + " ent=
ity(ies)");
+                log.info("will replicate on " + nodeEntityIds.size() +
+                         " entity(ies)");
             }
             if (log.isDebugEnabled()) {
                 for (String id : nodeEntityIds) {
@@ -390,7 +507,10 @@
                 }
             }
=20
-            List<? extends TopiaEntity> nodeEntities =3D getEntitiesList(src=
Ctxt, nodeEntityIds.toArray(new String[nodeEntityIds.size()]));
+            List<? extends TopiaEntity> nodeEntities =3D getEntitiesList(
+                    srcCtxt,
+                    nodeEntityIds.toArray(new String[nodeEntityIds.size()])
+            );
=20
             for (ReplicationOperationDef operationDef : operationDefs) {
=20
@@ -417,14 +537,80 @@
         treated.add(node);
     }
=20
-    public static <E extends TopiaEntity> List<E> getEntities(TopiaContextIm=
plementor srcCtxt, List<E> entityList, boolean canBeNull) throws TopiaExcepti=
on {
+
+    @Override
+    public void doRollbackNode(
+            ReplicationNode node,
+            TopiaContext srcCtxt,
+            TopiaContext dstCtxt,
+            TopiaEntityIdsMap data) throws Exception {
+
+        // on trie toujours les operations a realiser selon leur phase
+        // (avant ou apres la duplication)
+        node.sortOperations();
+
+        List<ReplicationOperationDef> operationDefs =3D node.getOperations();
+
+        if (operationDefs.isEmpty()) {
+            log.info("skip node " + node + " - no operation detected.");
+        } else {
+
+            log.info("start for " + node + " : " + operationDefs.size() +
+                     " operation(s)");
+
+            List<String> nodeEntityIds =3D
+                    data.get(node.getContract().getContract());
+            if (log.isInfoEnabled()) {
+                log.info("will replicate on " + nodeEntityIds.size() +
+                         " entity(ies)");
+            }
+            if (log.isDebugEnabled()) {
+                for (String id : nodeEntityIds) {
+                    log.debug(id);
+                }
+            }
+
+            List<? extends TopiaEntity> nodeEntities =3D getEntitiesList(
+                    srcCtxt,
+                    nodeEntityIds.toArray(new String[nodeEntityIds.size()])
+            );
+
+            for (ReplicationOperationDef operationDef : operationDefs) {
+
+                log.info("start " + operationDef);
+
+                TopiaReplicationOperation operation =3D
+                        getOperation(operationDef.getOperationClass());
+
+                operation.rollback(operationDef,
+                                   (TopiaContextImplementor) srcCtxt,
+                                   (TopiaContextImplementor) dstCtxt,
+                                   nodeEntities,
+                                   data
+                );
+
+            }
+            // on rollback le context source (car on a peut-etre modifie
+            // des associations ou des dependances mais on ne veut rien
+            // retenir au niveau d'hibernate, sinon on s'expose a des erreurs
+            // lorsque l'on veut recharger des objets dans le context...)
+            srcCtxt.rollbackTransaction();
+        }
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public static <E extends TopiaEntity> List<E> getEntities(
+            TopiaContextImplementor srcCtxt,
+            List<E> entityList,
+            boolean canBeNull) throws TopiaException {
         List<E> srcList =3D new ArrayList<E>(entityList.size());
         for (E e : entityList) {
             E e2 =3D (E) srcCtxt.findByTopiaId(e.getTopiaId());
             if (e2 =3D=3D null && !canBeNull) {
-                if (!canBeNull) {
-                    throw new IllegalStateException("topia.replication.engin=
e.error.entity.must.exists");
-                }
+//                if (!canBeNull) {
+//                    throw new IllegalStateException(
+//                            "topia.replication.engine.error.entity.must.ex=
ists");
+//                }
                 continue;
             }
             srcList.add(e2);
@@ -432,7 +618,9 @@
         return srcList;
     }
=20
-    public static TopiaEntity[] getEntities(TopiaContext srcCtxt, String... =
entityList) throws TopiaException {
+    public static TopiaEntity[] getEntities(TopiaContext srcCtxt,
+                                            String... entityList)
+            throws TopiaException {
         TopiaEntity[] srcList =3D new TopiaEntity[entityList.length];
         int index =3D 0;
         for (String id : entityList) {
@@ -442,7 +630,9 @@
         return srcList;
     }
=20
-    public static List<? extends TopiaEntity> getEntitiesList(TopiaContext s=
rcCtxt, String... entityList) throws TopiaException {
+    public static List<? extends TopiaEntity> getEntitiesList(
+            TopiaContext srcCtxt,
+            String... entityList) throws TopiaException {
         List<TopiaEntity> srcList =3D new ArrayList<TopiaEntity>(entityList.=
length);
         for (String id : entityList) {
             TopiaEntity e2 =3D srcCtxt.findByTopiaId(id);
@@ -451,13 +641,18 @@
         return srcList;
     }
=20
-    public static void checkNotNull(String methodName, String parameterName,=
 Object value) {
+    public static void checkNotNull(String methodName,
+                                    String parameterName,
+                                    Object value) {
         if (value =3D=3D null) {
-            throw new NullPointerException(_("topia.replication.engine.error=
.null.param", parameterName, methodName));
+            throw new NullPointerException(
+                    _("topia.replication.engine.error.null.param",
+                      parameterName, methodName));
         }
     }
=20
-    public static void checkParameters(Class<?>[] paramsType, Object... para=
ms) {
+    public static void checkParameters(Class<?>[] paramsType,
+                                       Object... params) {
         checkSize(paramsType.length, params);
         for (int i =3D 0, j =3D paramsType.length; i < j; i++) {
             checkType(paramsType, i, params);
@@ -466,20 +661,28 @@
=20
     public static void checkSize(int size, Object[] params) {
         if (params.length !=3D size) {
-            throw new IllegalArgumentException("l'operation requiere " + siz=
e + " parametres mais en a " + params.length);
+            throw new IllegalArgumentException(
+                    "l'operation requiere " + size + " parametres mais en a =
" +
+                    params.length);
         }
     }
=20
-    public static void checkType(Class<?>[] paramsType, int index, Object[] =
params) {
+    public static void checkType(Class<?>[] paramsType,
+                                 int index,
+                                 Object[] params) {
         Class<?> requiredType =3D paramsType[index];
         Object value =3D params[index];
         if (value =3D=3D null) {
-            throw new IllegalArgumentException("le parametre de positiion" +=
 index + " est null!");
+            throw new IllegalArgumentException(
+                    "le parametre de positiion" + index + " est null!");
         }
         Class<?> foundType =3D value.getClass();
=20
         if (!requiredType.isAssignableFrom(foundType)) {
-            throw new IllegalArgumentException("le paremetre de position " +=
 index + "  requiere un parametre de type " + requiredType + " mais est de ty=
pe " + foundType);
+            throw new IllegalArgumentException(
+                    "le paremetre de position " + index +
+                    "  requiere un parametre de type " + requiredType +
+                    " mais est de type " + foundType);
         }
     }
 }

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/TopiaReplicationImplementor.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/TopiaReplicationImplementor.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/TopiaReplicationImplementor.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -41,19 +41,19 @@
 import org.nuiton.topia.framework.TopiaContextImplementor;
 import org.nuiton.topia.persistence.TopiaEntity;
 import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.model.ReplicationModel;
 import org.nuiton.topia.replication.model.ReplicationNode;
 import org.nuiton.topia.replication.model.ReplicationOperationPhase;
=20
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
=20
 /**
  * Class used internaly in framework, when you want implement new replication
  * engin, you must used this interface
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
  * @since 2.2.0
  */
 public interface TopiaReplicationImplementor extends TopiaReplicationService=
 {
@@ -136,11 +136,13 @@
      * @return les ids des donnes a repliquer.
      * @throws TopiaException pour toute erreur de recuperation d'ids en base
      */
-    Map<Class<? extends TopiaEntity>, List<String>> getIds(
+    TopiaEntityIdsMap getIds(
             ReplicationModel model,
             TopiaContextImplementor srcCtxt) throws TopiaException;
=20
     /**
+     * Lance la replication d'un noeud.
+     *
      * @param node    le noeud de replication
      * @param srcCtxt la base source
      * @param dstCtxt la base destination
@@ -152,6 +154,22 @@
             ReplicationNode node,
             TopiaContext srcCtxt,
             TopiaContext dstCtxt,
-            Map<Class<? extends TopiaEntity>, List<String>> data,
+            TopiaEntityIdsMap data,
             List<ReplicationNode> treated) throws Exception;
+
+    /**
+     * Annule la replication d'un noeud.
+     *
+     * @param node    le noeud de replication
+     * @param srcCtxt la base source
+     * @param dstCtxt la base destination
+     * @param data    le dictionnaire des ids a repliquer
+     * @throws Exception pour toute erreur
+     * @since 2.4.3
+     */
+    void doRollbackNode(
+            ReplicationNode node,
+            TopiaContext srcCtxt,
+            TopiaContext dstCtxt,
+            TopiaEntityIdsMap  data) throws Exception;
 }

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/TopiaReplicationOperation.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/TopiaReplicationOperation.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/TopiaReplicationOperation.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -28,13 +28,13 @@
 import org.nuiton.topia.framework.TopiaContextImplementor;
 import org.nuiton.topia.persistence.TopiaEntity;
 import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.model.ReplicationModel;
 import org.nuiton.topia.replication.model.ReplicationNode;
 import org.nuiton.topia.replication.model.ReplicationOperationDef;
 import org.nuiton.topia.replication.model.ReplicationOperationPhase;
=20
 import java.util.List;
-import java.util.Map;
 import java.util.ServiceLoader;
=20
 /**
@@ -53,7 +53,7 @@
  * <p/>
  * Lors du chargement du service, on detecte toutes les operations disponibl=
es.
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
  * @since 2.2.0
  */
 public interface TopiaReplicationOperation {
@@ -92,5 +92,24 @@
              TopiaContextImplementor srcCtxt,
              TopiaContextImplementor dstCtxt,
              List<? extends TopiaEntity> entities,
-             Map<Class<? extends TopiaEntity>, List<String>> data) throws Ex=
ception;
+             TopiaEntityIdsMap data) throws Exception;
+
+    /**
+     * Execute l'operation inverse avec le parametrage donnee
+     * (pour annuler l'op=C3=A9ration).
+     * <p/>
+     * Note : le commit sur le context cible doit etre geree dans la methode.
+     *
+     * @param operationDef la definition de l'operation a realiser
+     * @param srcCtxt      le context source
+     * @param dstCtxt      le context destination
+     * @param entities     la liste des
+     * @param data         le dictionnaire de toutes les donnees a repliquer
+     * @throws Exception pour toute erreur
+     */
+    void rollback(ReplicationOperationDef operationDef,
+                  TopiaContextImplementor srcCtxt,
+                  TopiaContextImplementor dstCtxt,
+                  List<? extends TopiaEntity> entities,
+                  TopiaEntityIdsMap data) throws Exception;
 }

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/TopiaReplicationService.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/TopiaReplicationService.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/TopiaReplicationService.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -40,8 +40,12 @@
 import org.nuiton.topia.TopiaException;
 import org.nuiton.topia.framework.TopiaService;
 import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.model.ReplicationModel;
+import org.nuiton.topia.replication.model.ReplicationNode;
=20
+import java.util.List;
+
 /**
  * User visible interface for replication engin
  * <p/>
@@ -57,7 +61,7 @@
  * <li> - lanch replication {@link #doReplicate(ReplicationModel,
  * TopiaContext)}
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
  * @since 2.2.0
  */
 public interface TopiaReplicationService extends TopiaService {
@@ -148,7 +152,22 @@
      * @param dstCtxt le context sur la source de donnees ou repliquer
      * @throws Exception pour toute erreur pendant la replication
      */
-    void doReplicate(ReplicationModel model, TopiaContext dstCtxt) throws Ex=
ception;
+    void doReplicate(ReplicationModel model,
+                     TopiaContext dstCtxt) throws Exception;
+
+    /**
+     * Pour revenir en arri=C3=A8re lorsque la r=C3=A9plication a =C3=A9chou=
=C3=A9e .
+     *
+     * @param model   le modele de replication
+     * @param data    le dictionnaire des donn=C3=A9es =C3=A0 repliquer par =
type d'entit=C3=A9s
+     * @param nodes   les nodes d=C3=A9j=C3=A0 trait=C3=A9s que l'on doit re=
verter
+     * @param dstCtxt le context sur la source de donnees ou repliquer
+     * @throws Exception pour toute erreur pendant la replication
+     */
+    void doRollback(ReplicationModel model,
+                    TopiaEntityIdsMap data,
+                    List<ReplicationNode> nodes,
+                    TopiaContext dstCtxt) throws Exception;
 }
=20
=20

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/model/Link.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/Link.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/Link.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -32,21 +32,34 @@
 /**
  * Pour definir un lien entre deux entites (deux noeuds de replication).
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class Link {
=20
+    /** le noeud source du lien */
     protected final ReplicationNode source;
=20
+    /** le noeud destination du lien */
+    protected final ReplicationNode target;
+
+    /**
+     * liste des noeuds requis.
+     * <p/>
+     * TODO tchemit 2010-08-14 Expliquer =C3=A0 quoi =C3=A7a sert vraiment...
+     */
     protected final Set<ReplicationNode> requires;
=20
-    protected final ReplicationNode target;
-
+    /** nom du lien */
     protected final String name;
=20
+    /** drapeau positionn=C3=A9 =C3=A0 {@code true} lorsque le lien est une =
association. */
     protected final boolean association;
=20
-    public Link(ReplicationNode source, ReplicationNode target, String name,=
 boolean association) {
+    public Link(ReplicationNode source,
+                ReplicationNode target,
+                String name,
+                boolean association) {
         this.source =3D source;
         this.target =3D target;
         this.name =3D name;
@@ -87,7 +100,8 @@
      * @param currentNode le noeud qui vient d'etre replique
      * @return <code>true</code> si on peut reattacher ce lien
      */
-    public boolean canReattach(Set<ReplicationNode> universe, ReplicationNod=
e currentNode) {
+    public boolean canReattach(Set<ReplicationNode> universe,
+                               ReplicationNode currentNode) {
         boolean result =3D universe.containsAll(requires);
         if (result) {
             result =3D currentNode.equals(target) || universe.contains(targe=
t);

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/model/ReplicationModel.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/ReplicationModel.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/ReplicationModel.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -32,6 +32,7 @@
 import org.nuiton.topia.persistence.TopiaEntityEnum;
 import org.nuiton.topia.persistence.util.EntityOperator;
 import org.nuiton.topia.persistence.util.TopiaEntityHelper;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.TopiaReplicationOperation;
 import org.nuiton.topia.replication.operation.AttachLink;
 import org.nuiton.topia.replication.operation.DettachAssociation;
@@ -49,9 +50,15 @@
 import java.util.Map.Entry;
 import java.util.Set;
=20
+/**
+ * Model of a replication operation.
+ *
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
+ */
 public class ReplicationModel {
=20
-    /** to use log facility, just put in your code: log.info(\"...\"); */
+    /** Logger */
     private static final Log log =3D LogFactory.getLog(ReplicationModel.clas=
s);
=20
     /** l'ensemble des contrats d'entites a repliquer */
@@ -159,7 +166,7 @@
     public void detectAssociations(TopiaEntityEnum... filter) throws TopiaEx=
ception {
         for (Class<? extends TopiaEntity> type : nodes.keySet()) {
             ReplicationNode node =3D getNode(type);
-            EntityOperator<? extends TopiaEntity> operator =3D node.getOpera=
tor();
+            EntityOperator<? super TopiaEntity> operator =3D node.getOperato=
r();
             List<String> associationProperties =3D operator.getAssociationPr=
operties();
             if (!associationProperties.isEmpty()) {
=20
@@ -179,7 +186,7 @@
     public void detectDirectDependencies() throws TopiaException {
         for (Class<? extends TopiaEntity> type : nodes.keySet()) {
             ReplicationNode node =3D getNode(type);
-            EntityOperator<? extends TopiaEntity> operator =3D node.getOpera=
tor();
+            EntityOperator<? super TopiaEntity> operator =3D node.getOperato=
r();
             List<String> properties =3D operator.getProperties();
             if (!properties.isEmpty()) {
                 for (String p : properties) {
@@ -258,13 +265,16 @@
         }
     }
=20
-    public void detectDependenciesOrder(Set<ReplicationNode> safeLevel, Set<=
ReplicationNode> doned) {
+    public void detectDependenciesOrder(Set<ReplicationNode> safeLevel,
+                                        Set<ReplicationNode> doned) {
         if (log.isDebugEnabled()) {
             log.debug("will detect " + safeLevel);
         }
-        Map<ReplicationNode, Set<ReplicationNode>> dico =3D new HashMap<Repl=
icationNode, Set<ReplicationNode>>();
+        Map<ReplicationNode, Set<ReplicationNode>> dico =3D
+                new HashMap<ReplicationNode, Set<ReplicationNode>>();
         for (ReplicationNode n : safeLevel) {
-            Set<ReplicationNode> shell =3D new HashSet<ReplicationNode>(n.ge=
tShell());
+            Set<ReplicationNode> shell =3D
+                    new HashSet<ReplicationNode>(n.getShell());
             shell.retainAll(safeLevel);
             if (log.isDebugEnabled()) {
                 log.debug("shell to use for " + n + " : " + shell);
@@ -411,7 +421,8 @@
                 Set<String> names =3D node.getAssociationsToDettach();
                 // operations de dettachement d'association
                 for (String name : names) {
-                    addOperation(node, node, ReplicationOperationPhase.befor=
e, DettachAssociation.class, name);
+//                    addOperation(node, node, ReplicationOperationPhase.bef=
ore, DettachAssociation.class, name);
+                    addPreOperation(node, node, DettachAssociation.class, na=
me);
                 }
             }
             Set<Link> tmpLinks =3D new HashSet<Link>();
@@ -426,26 +437,17 @@
             if (!tmpLinks.isEmpty()) {
                 // on a des associations a charger avant replication
                 for (Link link : tmpLinks) {
-                    ReplicationOperationDef op =3D new ReplicationOperationD=
ef(ReplicationOperationPhase.before, LoadLink.class, node, link);
-                    node.addOperation(op);
+                    addPreOperation(node, node, LoadLink.class, link);
+//                    ReplicationOperationDef op =3D new ReplicationOperatio=
nDef(ReplicationOperationPhase.before, LoadLink.class, node, link);
+//                    node.addOperation(op);
                 }
                 linksToLoad.removeAll(links);
                 tmpLinks.clear();
             }
=20
-            // on fait de meme pour les dependences directes
-            //TODO la resolution des conflits sur dependences n'est pas enco=
re
-            //TODO en place (mais cela ne devrait pas etre necessaire... pou=
r le moment)
-
-//                if (node.hasDependenciesToDettach()) {
-//                    Set<String> names =3D node.getDependenciesToDettach();
-//                    // operations de dettachement d'association
-//                    for (String name : names) {
-//                        addOperation(node, node, ReplicationOperationPhase=
.before, DettachDependency.class, name);
-//                    }
-//                }
             // operation de duplication
-            addOperation(node, node, ReplicationOperationPhase.duplicate, Du=
plicate.class);
+//            addOperation(node, node, ReplicationOperationPhase.duplicate, =
Duplicate.class);
+            addDuplicateOperation(node, node, Duplicate.class);
=20
             universe.add(node);
=20
@@ -459,8 +461,9 @@
             if (!tmpLinks.isEmpty()) {
                 // on a trouve des liens a reattacher
                 for (Link link : tmpLinks) {
-                    ReplicationOperationDef op =3D new ReplicationOperationD=
ef(ReplicationOperationPhase.after, AttachLink.class, node, link);
-                    node.addOperation(op);
+                    addPostOperation(node, node, AttachLink.class, link);
+//                    ReplicationOperationDef op =3D new ReplicationOperatio=
nDef(ReplicationOperationPhase.after, AttachLink.class, node, link);
+//                    node.addOperation(op);
                 }
                 // ces liens ne sont plus a traiter
                 links.removeAll(tmpLinks);
@@ -468,7 +471,7 @@
         }
     }
=20
-    public void adjustOperations(Map<Class<? extends TopiaEntity>, List<Stri=
ng>> data) {
+    public void adjustOperations(TopiaEntityIdsMap data) {
         for (TopiaEntityEnum e : getContracts()) {
             Class<? extends TopiaEntity> contract =3D e.getContract();
             List<String> ids =3D data.get(contract);
@@ -518,7 +521,32 @@
         }
     }
=20
-    protected void addOperation(ReplicationNode ownerNode, ReplicationNode n=
ode, ReplicationOperationPhase phase, Class<? extends TopiaReplicationOperati=
on> operationClass, Object... params) {
+    protected void addPreOperation(ReplicationNode ownerNode,
+                                      ReplicationNode node,
+                                      Class<? extends TopiaReplicationOperat=
ion> operationClass,
+                                      Object... params) {
+        addOperation(ownerNode, node, ReplicationOperationPhase.before, oper=
ationClass, params);
+    }
+
+    protected void addDuplicateOperation(ReplicationNode ownerNode,
+                                         ReplicationNode node,
+                                         Class<? extends TopiaReplicationOpe=
ration> operationClass,
+                                         Object... params) {
+        addOperation(ownerNode, node, ReplicationOperationPhase.duplicate, o=
perationClass, params);
+    }
+
+    protected void addPostOperation(ReplicationNode ownerNode,
+                                     ReplicationNode node,
+                                     Class<? extends TopiaReplicationOperati=
on> operationClass,
+                                     Object... params) {
+        addOperation(ownerNode, node, ReplicationOperationPhase.after, opera=
tionClass, params);
+    }
+
+    protected void addOperation(ReplicationNode ownerNode,
+                                ReplicationNode node,
+                                ReplicationOperationPhase phase,
+                                Class<? extends TopiaReplicationOperation> o=
perationClass,
+                                Object... params) {
         ReplicationOperationDef op =3D new ReplicationOperationDef(phase, op=
erationClass, node, params);
         ownerNode.addOperation(op);
     }

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/model/ReplicationNode.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/ReplicationNode.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/ReplicationNode.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -42,42 +42,52 @@
 import java.util.Set;
=20
 /**
- * Le modele d'un noeud de replication.
+ * Model of a replication's node.
  * <p/>
- * Un noeud represente exactement un type d'entite a repliquer
+ * The invariant of a replication's node is his {@link #contract}, means the
+ * type of entity to replicate.
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class ReplicationNode {
=20
-    /** to use log facility, just put in your code: log.info(\"...\"); */
+    /** Logger */
     private static final Log log =3D LogFactory.getLog(ReplicationNode.class=
);
=20
+    /** contract of entity of the node. */
     final TopiaEntityEnum contract;
=20
+    /** entity operator. */
     final EntityOperator<? super TopiaEntity> operator;
=20
-    /** les couples d'association a partir de ce noeud */
+    /** shell of the node. */
+    Set<ReplicationNode> shell;
+
+    /**
+     * dictionnary of associations defined on the node (keys are association
+     * name, and values are target node).
+     */
     Map<String, ReplicationNode> associations;
=20
-    /** les couples de composition a partir de ce noeud */
+    /** names of association to dettach while replication. */
+    Set<String> associationsToDettach;
+
+    /**
+     * compositions defined on the node (keys are association name,
+     * and values are target node).
+     */
     Map<String, ReplicationNode> dependencies;
=20
-    /** l'ensemble des associations a dettacher pendant la replication */
-    Set<String> associationsToDettach;
-
-    /** l'ensemble des dependences a dettacher pendant la replication */
+    /** names of dependency to dettach while replication. */
     Set<String> dependenciesToDettach;
=20
-    /** la couverture de ce noeud */
-    Set<ReplicationNode> shell;
-
-    /** la sequences d'operations a realiser lors de la replication de ce no=
de */
+    /** operations to fire when replication pass on this node. */
     List<ReplicationOperationDef> operations;
=20
     public ReplicationNode(TopiaEntityEnum contract) {
         this.contract =3D contract;
-        operator =3D EntityOperatorStore.getOperator(contract);
+        operator =3D EntityOperatorStore.<TopiaEntity>getOperator(contract);
         associations =3D new HashMap<String, ReplicationNode>();
         dependencies =3D new HashMap<String, ReplicationNode>();
         shell =3D new HashSet<ReplicationNode>();
@@ -123,7 +133,7 @@
         Set<String> result =3D new HashSet<String>();
         for (String name : associationsToDettach) {
             ReplicationNode get =3D associations.get(name);
-            if (get =3D=3D node) {
+            if (node.equals(get)) {
                 result.add(name);
             }
         }
@@ -134,7 +144,7 @@
         Set<String> result =3D new HashSet<String>();
         for (String name : dependenciesToDettach) {
             ReplicationNode get =3D dependencies.get(name);
-            if (get =3D=3D node) {
+            if (node.equals(get)) {
                 result.add(name);
             }
         }
@@ -227,6 +237,11 @@
         return contract.toString();
     }
=20
+    /**
+     * {@link ReplicationOperationDef} comparator based on operation's phase.
+     *
+     * @see ReplicationOperationDef#getPhase()
+     */
     public static final Comparator<ReplicationOperationDef>
             OPERATION_COMPARATOR =3D new Comparator<ReplicationOperationDef>=
() {
=20

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/model/ReplicationOperationDef.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/ReplicationOperationDef.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/ReplicationOperationDef.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -29,6 +29,25 @@
=20
 import java.util.Arrays;
=20
+/**
+ * Definition of a concrete operation to execute.
+ * <p/>
+ * A such operation involves :
+ * <ul>
+ * <li>the replication node</li>
+ * <li>the replication phase</li>
+ * <li>the replication operation type</li>
+ * <li>the replication operation arguments</li>
+ * </ul>
+ * <p/>
+ * This definition is detected when building replication model.
+ * <p/>
+ * Then when starting replication, base on this definition, we can build the
+ * operation to fire.
+ *
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
+ */
 public class ReplicationOperationDef {
=20
     final ReplicationOperationPhase phase;

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/model/ReplicationOperationPhase.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/ReplicationOperationPhase.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/model/ReplicationOperationPhase.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -30,10 +30,11 @@
 /**
  * Une enumeration pour definir quand appliquer une operation.
  * <p/>
- * L'ordre induit par cette enumeration sera utiliser pour trier les operati=
ons
+ * L'ordre induit par cette enumeration sera utilis=C3=A9 pour trier les ope=
rations
  * a realiser sur chaque noeud de replication.
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public enum ReplicationOperationPhase {
=20

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/operation/AttachAssociation.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/AttachAssociation.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/AttachAssociation.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -32,6 +32,7 @@
 import org.nuiton.topia.persistence.TopiaEntity;
 import org.nuiton.topia.persistence.util.EntityOperator;
 import org.nuiton.topia.persistence.util.TopiaEntityHelper;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.ReplicationEngine;
 import org.nuiton.topia.replication.TopiaReplicationOperation;
 import org.nuiton.topia.replication.model.ReplicationModel;
@@ -42,7 +43,6 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
=20
 import static org.nuiton.i18n.I18n._;
=20
@@ -66,7 +66,8 @@
  * via la methode {@link #register(ReplicationModel, ReplicationNode,
  * ReplicationOperationPhase, Object...)}.
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class AttachAssociation implements TopiaReplicationOperation {
=20
@@ -84,7 +85,7 @@
                     TopiaContextImplementor srcCtxt,
                     TopiaContextImplementor dstCtxt,
                     List<? extends TopiaEntity> nodeEntities,
-                    Map<Class<? extends TopiaEntity>, List<String>> data) th=
rows TopiaException {
+                    TopiaEntityIdsMap data) throws TopiaException {
=20
         String name =3D (String) operationDef.getParameters()[0];
         Boolean reverse =3D (Boolean) operationDef.getParameters()[1];
@@ -229,4 +230,14 @@
             dstCtxt.commitTransaction();
         }
     }
+
+    @Override
+    public void rollback(ReplicationOperationDef operationDef,
+                         TopiaContextImplementor srcCtxt,
+                         TopiaContextImplementor dstCtxt,
+                         List<? extends TopiaEntity> entities,
+                         TopiaEntityIdsMap data) throws Exception {
+
+        // il faut dettacher les associations
+    }
 }

Deleted: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repli=
cation/operation/AttachDependency.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/AttachDependency.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/AttachDependency.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -1,125 +0,0 @@
-/*
- * #%L
- * ToPIA :: Service Replication
- *=20
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as=20
- * published by the Free Software Foundation, either version 3 of the=20
- * License, or (at your option) any later version.
- *=20
- * 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 Lesser Public License for more details.
- *=20
- * You should have received a copy of the GNU General Lesser Public=20
- * License along with this program.  If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.topia.replication.operation;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.replication.TopiaReplicationOperation;
-import org.nuiton.topia.replication.model.ReplicationModel;
-import org.nuiton.topia.replication.model.ReplicationNode;
-import org.nuiton.topia.replication.model.ReplicationOperationDef;
-import org.nuiton.topia.replication.model.ReplicationOperationPhase;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Pour attacher une dependance.
- * <p/>
- * TODO non implante pour le moment
- * <p/>
- * Note : cette operation est interne, et n'est pas creable par l'utilisateur
- * via la methode {@link #register(ReplicationModel, ReplicationNode,
- * ReplicationOperationPhase, Object...)}.
- *
- * @author chemit
- */
-public class AttachDependency implements TopiaReplicationOperation {
-
-    private static final Log log =3D LogFactory.getLog(AttachDependency.clas=
s);
-
-    @Override
-    public void register(ReplicationModel model, ReplicationNode ownerNode, =
ReplicationOperationPhase phase, Object... parameters) {
-        throw new UnsupportedOperationException(_("topia.replication.operati=
on.error.uncreatable", getClass()));
-    }
-
-    @Override
-    public void run(ReplicationOperationDef operationDef,
-                    TopiaContextImplementor srcCtxt,
-                    TopiaContextImplementor dstCtxt,
-                    List<? extends TopiaEntity> nodeEntities,
-                    Map<Class<? extends TopiaEntity>, List<String>> data) th=
rows TopiaException {
-
-        throw new UnsupportedOperationException(_("topia.replication.operati=
on.error.notImplemented", getClass()));
-
-        //TODO non implante pour le moment
-//        ReplicationNode ownerNode =3D operationDef.getNode();
-//
-//        String[] names =3D (String[]) operationDef.getParameters();
-//
-//        EntityOperator<? super TopiaEntity> ownerOperator =3D ownerNode.ge=
tOperator();
-//
-//        List<? extends TopiaEntity> ownerEntities =3D data.get(ownerOperat=
or.getClazz());
-//
-//        if (ownerEntities =3D=3D null || ownerEntities.isEmpty()) {
-//            // pas de donnees a traiter
-//            log.info(_("topia.replication.attachAssociation.nothing.to.do"=
, ownerOperator));
-//            return;
-//        }
-//
-//        boolean shouldCommit =3D false;
-//        for (String name : names) {
-//
-//            // le noeud de l'entite dont on veut reattacher des associatio=
ns
-//            ReplicationNode targetNode =3D ownerNode.getAssociations().get=
(name);
-//
-//            List<TopiaEntity> targets =3D data.get(targetNode.getContract(=
).getContract());
-//            List<String> targetIds =3D TopiaEntityHelper.getTopiaIdList(ta=
rgets);
-//            targets.clear();
-//
-//
-//            for (TopiaEntity src : ownerEntities) {
-//
-//                // les association connues
-//                TopiaEntity target =3D (TopiaEntity) ownerOperator.get(nam=
e, src);
-//
-//                if (target =3D=3D null || !targetIds.contains(target.getTo=
piaId())) {
-//                    // pas de donnees a attacher, ou pas pour ce src
-//                    continue;
-//                }
-//
-//                // l'entite cible
-//                TopiaEntity dst =3D dstCtxt.findByTopiaId(src.getTopiaId()=
);
-//
-//                target =3D dstCtxt.findByTopiaId(target.getTopiaId());
-//
-//                ownerOperator.set(name, dst, target);
-//
-//                dst.update();
-//                shouldCommit =3D true;
-//
-//            }
-//        }
-//        if (shouldCommit) {
-//            dstCtxt.commitTransaction();
-//        }
-    }
-}

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/operation/AttachLink.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/AttachLink.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/AttachLink.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -32,6 +32,7 @@
 import org.nuiton.topia.persistence.TopiaEntity;
 import org.nuiton.topia.persistence.util.EntityOperator;
 import org.nuiton.topia.persistence.util.TopiaEntityHelper;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.ReplicationEngine;
 import org.nuiton.topia.replication.TopiaReplicationOperation;
 import org.nuiton.topia.replication.model.Link;
@@ -43,7 +44,6 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
=20
 import static org.nuiton.i18n.I18n._;
=20
@@ -67,7 +67,8 @@
  * via la methode {@link #register(ReplicationModel, ReplicationNode,
  * ReplicationOperationPhase, Object...)}.
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class AttachLink implements TopiaReplicationOperation {
=20
@@ -85,7 +86,7 @@
                     TopiaContextImplementor srcCtxt,
                     TopiaContextImplementor dstCtxt,
                     List<? extends TopiaEntity> nodeEntities,
-                    Map<Class<? extends TopiaEntity>, List<String>> data) th=
rows TopiaException {
+                    TopiaEntityIdsMap data) throws TopiaException {
=20
         Link link =3D (Link) operationDef.getParameters()[0];
=20
@@ -217,4 +218,14 @@
             dstCtxt.commitTransaction();
         }
     }
+
+    @Override
+    public void rollback(ReplicationOperationDef operationDef,
+                         TopiaContextImplementor srcCtxt,
+                         TopiaContextImplementor dstCtxt,
+                         List<? extends TopiaEntity> entities,
+                         TopiaEntityIdsMap data) throws Exception {
+
+        // il faut dettacher les liens
+    }
 }

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/operation/DettachAssociation.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/DettachAssociation.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/DettachAssociation.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -31,6 +31,7 @@
 import org.nuiton.topia.framework.TopiaContextImplementor;
 import org.nuiton.topia.persistence.TopiaEntity;
 import org.nuiton.topia.persistence.util.EntityOperator;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.TopiaReplicationOperation;
 import org.nuiton.topia.replication.model.ReplicationModel;
 import org.nuiton.topia.replication.model.ReplicationNode;
@@ -38,7 +39,6 @@
 import org.nuiton.topia.replication.model.ReplicationOperationPhase;
=20
 import java.util.List;
-import java.util.Map;
=20
 import static org.nuiton.i18n.I18n._;
=20
@@ -49,7 +49,8 @@
  * l'utilisateur via la methode
  * {@link #register(ReplicationModel, ReplicationNode, ReplicationOperationP=
hase, Object...)}.
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class DettachAssociation implements TopiaReplicationOperation {
=20
@@ -67,7 +68,7 @@
                     TopiaContextImplementor srcCtxt,
                     TopiaContextImplementor dstCtxt,
                     List<? extends TopiaEntity> entities,
-                    Map<Class<? extends TopiaEntity>, List<String>> data) th=
rows TopiaException {
+                    TopiaEntityIdsMap data) throws TopiaException {
=20
         String name =3D (String) operationDef.getParameters()[0];
=20
@@ -84,6 +85,16 @@
                 operator.setNull(name, e);
             }
         }
+    }
=20
+
+    @Override
+    public void rollback(ReplicationOperationDef operationDef,
+                         TopiaContextImplementor srcCtxt,
+                         TopiaContextImplementor dstCtxt,
+                         List<? extends TopiaEntity> entities,
+                         TopiaEntityIdsMap data) throws Exception {
+
+        // il faut attacher les associations ? ou bien ne rien faire ?      =
 =20
     }
 }

Deleted: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repli=
cation/operation/DettachDependency.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/DettachDependency.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/DettachDependency.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -1,90 +0,0 @@
-/*
- * #%L
- * ToPIA :: Service Replication
- *=20
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as=20
- * published by the Free Software Foundation, either version 3 of the=20
- * License, or (at your option) any later version.
- *=20
- * 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 Lesser Public License for more details.
- *=20
- * You should have received a copy of the GNU General Lesser Public=20
- * License along with this program.  If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package org.nuiton.topia.replication.operation;
-
-import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.topia.replication.TopiaReplicationOperation;
-import org.nuiton.topia.replication.model.ReplicationModel;
-import org.nuiton.topia.replication.model.ReplicationNode;
-import org.nuiton.topia.replication.model.ReplicationOperationDef;
-import org.nuiton.topia.replication.model.ReplicationOperationPhase;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Pour dettacher une dependance.
- * <p/>
- * TODO Pas implante pour le moment
- * <p/>
- * Note : cette operation est interne, et n'est pas creable par
- * l'utilisateur via la methode
- * {@link #register(ReplicationModel, ReplicationNode, ReplicationOperationP=
hase, Object...)}.
- *
- * @author chemit
- */
-public class DettachDependency implements TopiaReplicationOperation {
-
-    @Override
-    public void register(ReplicationModel model, ReplicationNode ownerNode, =
ReplicationOperationPhase phase, Object... parameters) {
-
-        throw new UnsupportedOperationException(_("topia.replication.operati=
on.error.uncreatable", getClass()));
-    }
-
-    @Override
-    public void run(ReplicationOperationDef operationDef,
-                    TopiaContextImplementor srcCtxt,
-                    TopiaContextImplementor dstCtxt,
-                    List<? extends TopiaEntity> nodeEntities,
-                    Map<Class<? extends TopiaEntity>, List<String>> data) th=
rows TopiaException {
-
-        throw new UnsupportedOperationException(_("topia.replication.operati=
on.error.notImplemented", getClass()));
-        //TODO non implante pour le moment
-//
-//        ReplicationNode node =3D operationDef.getNode();
-//
-//        String[] names =3D (String[]) operationDef.getParameters();
-//
-//        EntityOperator<? super TopiaEntity> operator =3D node.getOperator(=
);
-//
-////        // recuperation des donnees a traiter
-////        List<TopiaEntity> entities =3D data.get(operator.getClazz());
-////
-////        // recuperation de la liste sur le context actuel
-////        entities =3D ReplicationEngine.getEntities(srcCtxt, entities, fa=
lse);
-//
-//        // dettach les attributs
-//        for (TopiaEntity e : nodeEntities) {
-//            for (String name : names) {
-//                operator.setNull(name, e);
-//            }
-//        }
-    }
-}

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/operation/Duplicate.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/Duplicate.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/Duplicate.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -28,6 +28,7 @@
 import org.nuiton.topia.TopiaException;
 import org.nuiton.topia.framework.TopiaContextImplementor;
 import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.TopiaReplicationOperation;
 import org.nuiton.topia.replication.model.ReplicationModel;
 import org.nuiton.topia.replication.model.ReplicationNode;
@@ -35,7 +36,6 @@
 import org.nuiton.topia.replication.model.ReplicationOperationPhase;
=20
 import java.util.List;
-import java.util.Map;
=20
 import static org.nuiton.i18n.I18n._;
=20
@@ -46,7 +46,8 @@
  * l'utilisateur via la methode
  * {@link #register(ReplicationModel, ReplicationNode, ReplicationOperationP=
hase, Object...)}.
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class Duplicate implements TopiaReplicationOperation {
=20
@@ -60,7 +61,7 @@
                     TopiaContextImplementor srcCtxt,
                     TopiaContextImplementor dstCtxt,
                     List<? extends TopiaEntity> entities,
-                    Map<Class<? extends TopiaEntity>, List<String>> data) th=
rows TopiaException {
+                    TopiaEntityIdsMap data) throws TopiaException {
=20
         // replication des donnees vers la destination
         srcCtxt.replicateEntities(dstCtxt, entities);
@@ -69,4 +70,15 @@
         dstCtxt.commitTransaction();
=20
     }
+
+
+    @Override
+    public void rollback(ReplicationOperationDef operationDef,
+                         TopiaContextImplementor srcCtxt,
+                         TopiaContextImplementor dstCtxt,
+                         List<? extends TopiaEntity> entities,
+                         TopiaEntityIdsMap data) throws Exception {
+
+        // il faut supprimer les entities
+    }
 }

Modified: trunk/topia-service-replication/src/main/java/org/nuiton/topia/repl=
ication/operation/LoadLink.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/LoadLink.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/main/java/org/nuiton/topia/replicatio=
n/operation/LoadLink.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -31,6 +31,7 @@
 import org.nuiton.topia.framework.TopiaContextImplementor;
 import org.nuiton.topia.persistence.TopiaEntity;
 import org.nuiton.topia.persistence.util.EntityOperator;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.TopiaReplicationOperation;
 import org.nuiton.topia.replication.model.Link;
 import org.nuiton.topia.replication.model.ReplicationModel;
@@ -39,7 +40,6 @@
 import org.nuiton.topia.replication.model.ReplicationOperationPhase;
=20
 import java.util.List;
-import java.util.Map;
=20
 import static org.nuiton.i18n.I18n._;
=20
@@ -50,7 +50,8 @@
  * l'utilisateur via la methode
  * {@link #register(ReplicationModel, ReplicationNode, ReplicationOperationP=
hase, Object...)}.
  *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class LoadLink implements TopiaReplicationOperation {
=20
@@ -68,7 +69,7 @@
                     TopiaContextImplementor srcCtxt,
                     TopiaContextImplementor dstCtxt,
                     List<? extends TopiaEntity> nodeEntities,
-                    Map<Class<? extends TopiaEntity>, List<String>> data) th=
rows TopiaException {
+                    TopiaEntityIdsMap data) throws TopiaException {
=20
         Link link =3D (Link) operationDef.getParameters()[0];
=20
@@ -95,4 +96,15 @@
             }
         }
     }
+
+
+    @Override
+    public void rollback(ReplicationOperationDef operationDef,
+                         TopiaContextImplementor srcCtxt,
+                         TopiaContextImplementor dstCtxt,
+                         List<? extends TopiaEntity> entities,
+                         TopiaEntityIdsMap data) throws Exception {
+
+        // rien a faire ici=20
+    }
 }

Modified: trunk/topia-service-replication/src/main/resources/META-INF/service=
s/org.nuiton.topia.replication.TopiaReplicationOperation
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/main/resources/META-INF/services/org.=
nuiton.topia.replication.TopiaReplicationOperation	2010-08-14 13:53:11 UTC (r=
ev 2097)
+++ trunk/topia-service-replication/src/main/resources/META-INF/services/org.=
nuiton.topia.replication.TopiaReplicationOperation	2010-08-14 13:54:40 UTC (r=
ev 2098)
@@ -6,6 +6,4 @@
 org.nuiton.topia.replication.operation.LoadLink
 org.nuiton.topia.replication.operation.AttachAssociation
 org.nuiton.topia.replication.operation.DettachAssociation
-org.nuiton.topia.replication.operation.AttachDependency
-org.nuiton.topia.replication.operation.DettachDependency
 org.nuiton.topia.replication.operation.Duplicate

Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/repl=
ication/AbstractReplicationEngineTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/AbstractReplicationEngineTest.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/AbstractReplicationEngineTest.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -57,11 +57,9 @@
  * <p/>
  * Created: 07 jun. 09 17:14:22
  *
- * @author tchemit
- * @version $Revision$
- *          <p/>
- *          Last update: $Date$
- *          by :
+ * @author tchemit <chemit@codelutin.com>
+ * @version $Id$
+ * @since 2.2.0
  */
 public abstract class AbstractReplicationEngineTest extends Assert {
=20
@@ -219,9 +217,9 @@
=20
         detectTypes =3D service.detectTypes(getContracts(), entity.getTopiaI=
d());
         assertEquals("expected types : " +
-                Arrays.toString(expectedCouple) +
-                " but was " + detectTypes,
-                expectedCouple.length, detectTypes.size());
+                     Arrays.toString(expectedCouple) +
+                     " but was " + detectTypes,
+                     expectedCouple.length, detectTypes.size());
         for (Object o : expectedCouple) {
             assertTrue(detectTypes.contains(o));
         }
@@ -285,7 +283,7 @@
         shell =3D model.getNode(c.getContract()).getShell();
         assertEquals(
                 "expected shell : " + Arrays.toString(expected) + ", but was=
 " +
-                        shell, expected.length, shell.size());
+                shell, expected.length, shell.size());
=20
         for (int i =3D 0, j =3D expected.length; i < j; i++) {
             TopiaEntityEnum type =3D expected[i];
@@ -532,7 +530,7 @@
         }
         Assert.assertNotNull(
                 "contract not found for " + expected.getClass() + " in " +
-                        Arrays.toString(getContracts()), contract);
+                Arrays.toString(getContracts()), contract);
         EntityOperator<TopiaEntity> operator =3D EntityOperatorStore.getOper=
ator(contract);
         List<String> associationProperties =3D operator.getAssociationProper=
ties();
         for (String name : associationProperties) {

Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/repl=
ication/ReplicationEngineAllTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/ReplicationEngineAllTest.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/ReplicationEngineAllTest.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -25,50 +25,57 @@
=20
 package org.nuiton.topia.replication;
=20
-import java.io.File;
-import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.framework.TopiaContextImplementor;
-import org.nuiton.topia.test.entities.*;
-import org.junit.Test;
-
-import java.util.Properties;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.Test;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaContextFactory;
 import org.nuiton.topia.TopiaException;
 import org.nuiton.topia.TopiaTestDAOHelper.TopiaTestEntityEnum;
+import org.nuiton.topia.framework.TopiaContextImplementor;
 import org.nuiton.topia.persistence.TopiaEntity;
 import org.nuiton.topia.persistence.TopiaEntityEnum;
+import org.nuiton.topia.test.entities.Person;
+import org.nuiton.topia.test.entities.PersonImpl;
+import org.nuiton.topia.test.entities.Pet;
+import org.nuiton.topia.test.entities.PetImpl;
+import org.nuiton.topia.test.entities.Race;
+import org.nuiton.topia.test.entities.RaceImpl;
=20
+import java.io.File;
+import java.util.Properties;
+
 /**
  * ReplicationEngineTest on model TopiaTest
- *
+ * <p/>
  * Created: 07 jun. 09 17:14:22
  *
- * @author tchemit
- * @version $Revision$
- *
- * Last update: $Date$
- * by : */
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
+ */
 public class ReplicationEngineAllTest extends AbstractReplicationEngineTest {
=20
     /** to use log facility, just put in your code: log.info(\"...\"); */
     private static final Log log =3D LogFactory.getLog(ReplicationEngineTest=
.class);
+
     protected static final TopiaEntityEnum[] contracts =3D {
             TopiaTestEntityEnum.Person,
             TopiaTestEntityEnum.Pet,
             TopiaTestEntityEnum.Race
     };
+
     protected static final String entitiesList =3D
             PersonImpl.class.getName() + "," +
             PetImpl.class.getName() + "," +
             RaceImpl.class.getName();
-   =20
+
     static protected Person person, person2;
+
     static protected Pet pet, pet2, pet3;
+
     static protected Race race, race2, race3;
=20
     @AfterClass
@@ -101,6 +108,7 @@
     }
=20
 //    @Ignore
+
     @Test
     @Override
     public void testDetectTypes() throws Exception {
@@ -118,12 +126,14 @@
     }
=20
 //    @Ignore
+
     @Test
     @Override
     public void testGetOperation() throws Exception {
     }
=20
 //    @Ignore
+
     @Test
     @Override
     public void testDetectAssociations() throws Exception {
@@ -139,6 +149,7 @@
     }
=20
 //    @Ignore
+
     @Test
     @Override
     public void testDetectDirectDependencies() throws Exception {
@@ -153,6 +164,7 @@
     }
=20
 //    @Ignore
+
     @Test
     @Override
     public void testDetectShell() throws Exception {
@@ -166,15 +178,17 @@
     }
=20
 //    @Ignore
+
     @Test
     @Override
     public void testDetectDependencies() throws Exception {
=20
         detectDependencies(null,
-                new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Race}, new Top=
iaTestEntityEnum[]{TopiaTestEntityEnum.Person}, new TopiaTestEntityEnum[]{Top=
iaTestEntityEnum.Pet});
+                           new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Rac=
e}, new TopiaTestEntityEnum[]{TopiaTestEntityEnum.Person}, new TopiaTestEntit=
yEnum[]{TopiaTestEntityEnum.Pet});
     }
=20
 //    @Ignore
+
     @Test
     @Override
     public void testDetectObjectsToDettach() throws Exception {
@@ -183,6 +197,7 @@
     }
=20
 //    @Ignore
+
     @Test
     @Override
     public void testDetectOperations() throws Exception {
@@ -191,6 +206,7 @@
     }
=20
 //    @Ignore
+
     @Test
     @Override
     public void testDoReplicate() throws Exception {

Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/repl=
ication/ReplicationEngineTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/ReplicationEngineTest.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/ReplicationEngineTest.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -39,9 +39,7 @@
 import org.nuiton.topia.persistence.TopiaEntityEnum;
 import org.nuiton.topia.replication.model.ReplicationModel;
 import org.nuiton.topia.replication.operation.AttachAssociation;
-import org.nuiton.topia.replication.operation.AttachDependency;
 import org.nuiton.topia.replication.operation.DettachAssociation;
-import org.nuiton.topia.replication.operation.DettachDependency;
 import org.nuiton.topia.replication.operation.Duplicate;
 import org.nuiton.topia.replication.operation.FakeOperation;
 import org.nuiton.topia.replication.operation.UncreatableOperation;
@@ -54,7 +52,6 @@
 import org.nuiton.topia.test.entities.RaceImpl;
=20
 import java.io.File;
-import java.util.Map;
 import java.util.Properties;
=20
 /**
@@ -62,11 +59,8 @@
  * <p/>
  * Created: 07 jun. 09 17:14:22
  *
- * @author tchemit
- * @version $Revision$
- *          <p/>
- *          Last update: $Date$
- *          by :
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class ReplicationEngineTest extends AbstractReplicationEngineTest {
=20
@@ -138,8 +132,6 @@
         getOperation(Duplicate.class, true);
         getOperation(AttachAssociation.class, true);
         getOperation(DettachAssociation.class, true);
-        getOperation(AttachDependency.class, true);
-        getOperation(DettachDependency.class, true);
     }
=20
     @Test
@@ -281,7 +273,7 @@
=20
     /**
      * Cette methode montre comment manuellement on peut effectuer la
-     * replication (en dettachant les dependances qui forment des cyles)
+     * replication (en dettachant les dependances qui forment des cycles)
      * <p/>
      * La methode utilisee ici peut ne pas fonctionner : si une clef metier =
est
      * posee sur une dependance alors cela ne fonctionne pas.
@@ -328,7 +320,7 @@
=20
     /**
      * Cette methode montre comment manuellement on peut effectuer la
-     * replication (en dettachant les associations qui forment des cyles)
+     * replication (en dettachant les associations qui forment des cycles)
      * <p/>
      * La methode utilisee ici fonctionne mieux que la precedante : il parra=
it
      * dificille de pose une une clef metier sur une association :).
@@ -337,7 +329,7 @@
      * est pas obligee de la reattachee car elle est bi-directionnelle.
      * <p/>
      * On doit optimiser l'algorithme dans la methode {@link
-     * ReplicationModel#adjustOperations(Map)}.
+     * ReplicationModel#adjustOperations(org.nuiton.topia.persistence.util.T=
opiaEntityIdsMap)}.
      *
      * @throws Exception pour toute erreur
      */

Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/repl=
ication/TopiaReplicationOperationTest.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/TopiaReplicationOperationTest.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/TopiaReplicationOperationTest.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -38,9 +38,7 @@
 import org.nuiton.topia.persistence.TopiaEntityEnum;
 import org.nuiton.topia.replication.model.ReplicationOperationPhase;
 import org.nuiton.topia.replication.operation.AttachAssociation;
-import org.nuiton.topia.replication.operation.AttachDependency;
 import org.nuiton.topia.replication.operation.DettachAssociation;
-import org.nuiton.topia.replication.operation.DettachDependency;
 import org.nuiton.topia.replication.operation.Duplicate;
 import org.nuiton.topia.replication.operation.FakeOperation;
 import org.nuiton.topia.replication.operation.UncreatableOperation;
@@ -60,11 +58,8 @@
  * <p/>
  * Created: 07 jun. 09 17:14:22
  *
- * @author tchemit
- * @version $Revision$
- *          <p/>
- *          Last update: $Date$
- *          by : $Author$
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class TopiaReplicationOperationTest extends AbstractReplicationEngine=
Test {
=20
@@ -109,18 +104,14 @@
         }
     }
=20
-//    @Ignore
-
     @Test(expected =3D NullPointerException.class)
     public void testGetOperation_nullOperationClass() throws Exception {
         service.getOperation(null);
     }
=20
-//    @Ignore
-
     @Test(expected =3D IllegalStateException.class)
     public void testGetOperation_serviceNotInit() throws Exception {
-        ReplicationEngine.operations =3D null;
+//        ReplicationEngine.operations =3D null;
         try {
             new ReplicationEngine().getOperation(Duplicate.class);
         } catch (IllegalStateException e) {
@@ -134,8 +125,6 @@
         }
     }
=20
-//    @Ignore
-
     @Test
     @Override
     public void testGetOperation() throws Exception {
@@ -146,19 +135,13 @@
         getOperation(Duplicate.class, true);
         getOperation(AttachAssociation.class, true);
         getOperation(DettachAssociation.class, true);
-        getOperation(AttachDependency.class, true);
-        getOperation(DettachDependency.class, true);
     }
=20
-//    @Ignore
-
     @Test(expected =3D NullPointerException.class)
     public void testCreateOperation_nullModel() throws Exception {
         service.createOperation(null, null, null, null);
     }
=20
-//    @Ignore
-
     @Test(expected =3D NullPointerException.class)
     public void testCreateOperation_nullType() throws Exception {
=20
@@ -166,8 +149,6 @@
         service.createOperation(model, null, null, null);
     }
=20
-//    @Ignore
-
     @Test(expected =3D NullPointerException.class)
     public void testCreateOperation_nullPhase() throws Exception {
=20
@@ -175,8 +156,6 @@
         service.createOperation(model, TopiaTestEntityEnum.Pet, null, null);
     }
=20
-//    @Ignore
-
     @Test(expected =3D NullPointerException.class)
     public void testCreateOperation_nullOperationClass() throws Exception {
=20
@@ -184,8 +163,6 @@
         service.createOperation(model, TopiaTestEntityEnum.Pet, ReplicationO=
perationPhase.before, null);
     }
=20
-//    @Ignore
-
     @Test(expected =3D IllegalArgumentException.class)
     public void testCreateOperation_noNode() throws Exception {
=20
@@ -194,8 +171,6 @@
         service.addAfterOperation(model, TopiaTestEntityEnum.Pet, Duplicate.=
class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D IllegalArgumentException.class)
     public void testCreateOperation_noOperation() throws Exception {
=20
@@ -204,92 +179,46 @@
         service.addAfterOperation(model, TopiaTestEntityEnum.Pet, Unregistre=
dOperation.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D UnsupportedOperationException.class)
     public void testCreateUnsupportedBeforeOperation_Duplicate() throws Exce=
ption {
         createUnsupportedBeforeOperation(TopiaTestEntityEnum.Person, person,=
 Duplicate.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D UnsupportedOperationException.class)
     public void testCreateUnsupportedBeforeOperation_AttachAssociation() thr=
ows Exception {
         createUnsupportedBeforeOperation(TopiaTestEntityEnum.Person, person,=
 AttachAssociation.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D UnsupportedOperationException.class)
     public void testCreateUnsupportedBeforeOperation_DetachAssociation() thr=
ows Exception {
         createUnsupportedBeforeOperation(TopiaTestEntityEnum.Person, person,=
 DettachAssociation.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D UnsupportedOperationException.class)
-    public void testCreateUnsupportedBeforeOperation_AttachDependency() thro=
ws Exception {
-        createUnsupportedBeforeOperation(TopiaTestEntityEnum.Person, person,=
 AttachDependency.class);
-    }
-
-//    @Ignore
-
-    @Test(expected =3D UnsupportedOperationException.class)
-    public void testCreateUnsupportedBeforeOperation_DetachDependency() thro=
ws Exception {
-        createUnsupportedBeforeOperation(TopiaTestEntityEnum.Person, person,=
 DettachDependency.class);
-    }
-
-//    @Ignore
-
-    @Test(expected =3D UnsupportedOperationException.class)
     public void testCreateUnsupportedAfterOperation_Duplicate() throws Excep=
tion {
         createUnsupportedAfterOperation(TopiaTestEntityEnum.Person, person, =
Duplicate.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D UnsupportedOperationException.class)
     public void testCreateUnsupportedAfterOperation_AttachAssociation() thro=
ws Exception {
         createUnsupportedAfterOperation(TopiaTestEntityEnum.Person, person, =
AttachAssociation.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D UnsupportedOperationException.class)
     public void testCreateUnsupportedAfterOperation_DetachAssociation() thro=
ws Exception {
         createUnsupportedAfterOperation(TopiaTestEntityEnum.Person, person, =
DettachAssociation.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D UnsupportedOperationException.class)
-    public void testCreateUnsupportedAfterOperation_AttachDependency() throw=
s Exception {
-        createUnsupportedAfterOperation(TopiaTestEntityEnum.Person, person, =
AttachDependency.class);
-    }
-
-//    @Ignore
-
-    @Test(expected =3D UnsupportedOperationException.class)
-    public void testCreateUnsupportedAfterOperation_DetachDependency() throw=
s Exception {
-        createUnsupportedAfterOperation(TopiaTestEntityEnum.Person, person, =
DettachDependency.class);
-    }
-
-//    @Ignore
-
-    @Test(expected =3D UnsupportedOperationException.class)
     public void testCreateUnsupportedBeforeOperation_UncreatableOperation() =
throws Exception {
         createUnsupportedBeforeOperation(TopiaTestEntityEnum.Person, person,=
 UncreatableOperation.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D UnsupportedOperationException.class)
     public void testCreateUnsupportedAfterOperation_UncreatableOperation() t=
hrows Exception {
         createUnsupportedAfterOperation(TopiaTestEntityEnum.Person, person, =
UncreatableOperation.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D IllegalArgumentException.class)
     public void testCreateOperation_wrongParameterNumber() throws Exception {
=20
@@ -297,8 +226,6 @@
         service.addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOpera=
tion.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D IllegalArgumentException.class)
     public void testCreateOperation_wrongParameterNumber2() throws Exception=
 {
=20
@@ -306,8 +233,6 @@
         service.addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOpera=
tion.class, String.class, String.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D IllegalArgumentException.class)
     public void testCreateOperation_wrongParameterType() throws Exception {
=20
@@ -315,8 +240,6 @@
         service.addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOpera=
tion.class, Integer.class);
     }
=20
-//    @Ignore
-
     @Test(expected =3D IllegalArgumentException.class)
     public void testCreateOperation_nullParameter() throws Exception {
=20
@@ -324,8 +247,6 @@
         service.addBeforeOperation(model, TopiaTestEntityEnum.Pet, FakeOpera=
tion.class, (Object) null);
     }
=20
-//    @Ignore
-
     @Test
     public void testCreateOperation() throws Exception {
=20
@@ -334,16 +255,12 @@
         service.addAfterOperation(model, TopiaTestEntityEnum.Race, FakeOpera=
tion.class, "after");
     }
=20
-//    @Ignore
-
     @Test(expected =3D NullPointerException.class)
     public void testDoReplicate_nullModel() throws Exception {
=20
         service.doReplicate(null, null);
     }
=20
-//    @Ignore
-
     @Test(expected =3D NullPointerException.class)
     public void testDoReplicate_nullDstCtxt() throws Exception {
=20

Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/repl=
ication/operation/FakeOperation.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/operation/FakeOperation.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/operation/FakeOperation.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -25,22 +25,24 @@
=20
 package org.nuiton.topia.replication.operation;
=20
-import org.nuiton.topia.replication.*;
-import java.util.List;
-import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.nuiton.topia.TopiaException;
 import org.nuiton.topia.framework.TopiaContextImplementor;
 import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
+import org.nuiton.topia.replication.ReplicationEngine;
+import org.nuiton.topia.replication.TopiaReplicationOperation;
 import org.nuiton.topia.replication.model.ReplicationModel;
 import org.nuiton.topia.replication.model.ReplicationNode;
 import org.nuiton.topia.replication.model.ReplicationOperationDef;
 import org.nuiton.topia.replication.model.ReplicationOperationPhase;
=20
+import java.util.List;
+
 /**
- *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class FakeOperation implements TopiaReplicationOperation {
=20
@@ -48,7 +50,7 @@
     private static final Log log =3D LogFactory.getLog(FakeOperation.class);
=20
     public static final Class<?>[] PARAMETERS_CLASSES =3D new Class<?>[]{Str=
ing.class};
-   =20
+
     @Override
     public void register(ReplicationModel model,
                          ReplicationNode ownerNode,
@@ -67,11 +69,16 @@
=20
     @Override
     public void run(ReplicationOperationDef operationDef,
-            TopiaContextImplementor srcCtxt,
-            TopiaContextImplementor dstCtxt,
-            List<? extends TopiaEntity> nodeEntities,
-            Map<Class<? extends TopiaEntity>, List<String>> data)
+                    TopiaContextImplementor srcCtxt,
+                    TopiaContextImplementor dstCtxt,
+                    List<? extends TopiaEntity> nodeEntities,
+                    TopiaEntityIdsMap data)
             throws TopiaException {
=20
     }
+
+    @Override
+    public void rollback(ReplicationOperationDef operationDef, TopiaContextI=
mplementor srcCtxt, TopiaContextImplementor dstCtxt, List<? extends TopiaEnti=
ty> entities, TopiaEntityIdsMap data) throws Exception {
+        // rien a faire
+    }
 }

Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/repl=
ication/operation/UncreatableOperation.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/operation/UncreatableOperation.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/operation/UncreatableOperation.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -25,23 +25,25 @@
=20
 package org.nuiton.topia.replication.operation;
=20
-import org.nuiton.topia.replication.*;
-import java.util.List;
-import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.nuiton.topia.TopiaException;
 import org.nuiton.topia.framework.TopiaContextImplementor;
 import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
+import org.nuiton.topia.replication.TopiaReplicationOperation;
 import org.nuiton.topia.replication.model.ReplicationModel;
 import org.nuiton.topia.replication.model.ReplicationNode;
 import org.nuiton.topia.replication.model.ReplicationOperationDef;
 import org.nuiton.topia.replication.model.ReplicationOperationPhase;
+
+import java.util.List;
+
 import static org.nuiton.i18n.I18n._;
=20
 /**
- *
- * @author chemit
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
  */
 public class UncreatableOperation implements TopiaReplicationOperation {
=20
@@ -61,10 +63,15 @@
=20
     @Override
     public void run(ReplicationOperationDef operationDef,
-            TopiaContextImplementor srcCtxt,
-            TopiaContextImplementor dstCtxt,
-            List<? extends TopiaEntity> nodeEntities,
-            Map<Class<? extends TopiaEntity>, List<String>> data)
+                    TopiaContextImplementor srcCtxt,
+                    TopiaContextImplementor dstCtxt,
+                    List<? extends TopiaEntity> nodeEntities,
+                    TopiaEntityIdsMap data)
             throws TopiaException {
     }
+
+    @Override
+    public void rollback(ReplicationOperationDef operationDef, TopiaContextI=
mplementor srcCtxt, TopiaContextImplementor dstCtxt, List<? extends TopiaEnti=
ty> entities, TopiaEntityIdsMap data) throws Exception {
+        // rien a faire
+    }
 }

Modified: trunk/topia-service-replication/src/test/java/org/nuiton/topia/repl=
ication/operation/UnregistredOperation.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/operation/UnregistredOperation.java	2010-08-14 13:53:11 UTC (rev 2097)
+++ trunk/topia-service-replication/src/test/java/org/nuiton/topia/replicatio=
n/operation/UnregistredOperation.java	2010-08-14 13:54:40 UTC (rev 2098)
@@ -30,6 +30,7 @@
 import org.nuiton.topia.TopiaException;
 import org.nuiton.topia.framework.TopiaContextImplementor;
 import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.topia.persistence.util.TopiaEntityIdsMap;
 import org.nuiton.topia.replication.TopiaReplicationOperation;
 import org.nuiton.topia.replication.model.ReplicationModel;
 import org.nuiton.topia.replication.model.ReplicationNode;
@@ -37,9 +38,11 @@
 import org.nuiton.topia.replication.model.ReplicationOperationPhase;
=20
 import java.util.List;
-import java.util.Map;
=20
-/** @author chemit */
+/**
+ * @author tchemit <chemit@codelutin.com>
+ * @since 2.2.0
+ */
 public class UnregistredOperation implements TopiaReplicationOperation {
=20
     /** to use log facility, just put in your code: log.info(\"...\"); */
@@ -59,7 +62,12 @@
             TopiaContextImplementor srcCtxt,
             TopiaContextImplementor dstCtxt,
             List<? extends TopiaEntity> nodeEntities,
-            Map<Class<? extends TopiaEntity>, List<String>> data)
+            TopiaEntityIdsMap data)
             throws TopiaException {
     }
+
+    @Override
+    public void rollback(ReplicationOperationDef operationDef, TopiaContextI=
mplementor srcCtxt, TopiaContextImplementor dstCtxt, List<? extends TopiaEnti=
ty> entities, TopiaEntityIdsMap data) throws Exception {
+        // rien a faire
+    }
 }


--===============0696721817822519244==--


