Salome HOME
The draft of the "Copy from existing study" action is added. The YACS step is introdu...
[tools/siman.git] / Workspace / Siman-Common / src / org / splat / dal / bo / kernel / Entity.java
index debc3f65f035398ea672c1a0cf1ec15dbf12b946..152661bc642929db34eef58389235ef648fce473 100644 (file)
@@ -169,8 +169,7 @@ public abstract class Entity extends Any {
                }
                if (res != null) {
                        if (LOG.isDebugEnabled()) {
-                               LOG.debug("Contains: "
-                                               + this.getAllRelations().contains(res));
+                               LOG.debug("Contains: " + this.getAllRelations().contains(res));
                                LOG.debug("Nb relations of this before: "
                                                + this.getAllRelations().size());
                        }
@@ -183,15 +182,37 @@ public abstract class Entity extends Any {
                        if (res.isBidirectional()) {
                                if (LOG.isDebugEnabled()) {
                                        LOG.debug("Nb relations of reverse before: "
-                                                       + ((Entity)res.getTo()).getAllRelations().size());
+                                                       + ((Entity) res.getTo()).getAllRelations().size());
                                }
-                               ((Entity)res.getTo()).getAllRelations().remove(res.getReverse());
+                               ((Entity) res.getTo()).getAllRelations().remove(
+                                               res.getReverse());
                                if (LOG.isDebugEnabled()) {
                                        LOG.debug("Nb relations of reverse after: "
-                                                       + ((Entity)res.getTo()).getAllRelations().size());
+                                                       + ((Entity) res.getTo()).getAllRelations().size());
                                }
                        }
                }
                return res;
        }
+
+       /**
+        * {@inheritDoc}
+        * 
+        * @see org.splat.dal.bo.kernel.Any#evict()
+        */
+       @Override
+       public void evict() {
+               super.evict();
+               // Evict all attributes of the persistent object
+               Set<Relation> tmpSet = new HashSet<Relation>();
+               tmpSet.addAll(relations);
+               relations.clear();
+               // Evict relations
+               for (Relation rel : tmpSet) {
+                       if (rel.isSaved()) { // to avoid recursive evict
+                               rel.evict();
+                       }
+                       relations.add(rel);
+               }
+       }
 }
\ No newline at end of file