X-Account-Key: account2
X-Mozilla-Keys: 
Return-Path: <topia-commits-bounces@lists.labs.libre-entreprise.org>
X-Original-To: thimel@bihar.codelutin.net
Delivered-To: thimel@bihar.codelutin.net
Received: from localhost (bihar.codelutin.com [79.98.16.206])
	by bihar.codelutin.net (Postfix) with ESMTP id C22F162A2D;
	Wed, 28 Jan 2009 18:19:24 +0100 (CET)
X-Virus-Scanned: Debian amavisd-new at bihar.codelutin.net
X-Spam-Score: -2.599
X-Spam-Level: 
X-Spam-Status: No, score=-2.599 tagged_above=-1002 required=6.31
	tests=[BAYES_00=-2.599]
Received: from bihar.codelutin.net ([79.98.16.206])
	by localhost (bihar.codelutin.net [79.98.16.206]) (amavisd-new, port 10024)
	with ESMTP id f53FXovI3K+S; Wed, 28 Jan 2009 18:19:22 +0100 (CET)
Received: from labs.libre-entreprise.org (labs.libre-entreprise.org
 [212.85.154.93])
	by bihar.codelutin.net (Postfix) with ESMTP id 82DF2626EC;
	Wed, 28 Jan 2009 18:19:22 +0100 (CET)
Received: from labs.libre-entreprise.org (labs.libre-entreprise.org
 [212.85.154.93])
	by labs.libre-entreprise.org (Postfix) with ESMTP id 1EB49461C5E;
	Wed, 28 Jan 2009 18:19:20 +0100 (CET)
X-Original-To: topia-commits@lists.labs.libre-entreprise.org
Delivered-To: topia-commits@lists.labs.libre-entreprise.org
Received: from localhost.localdomain (labs.libre-entreprise.org
	[212.85.154.93])
	by labs.libre-entreprise.org (Postfix) with ESMTP id 3BA10461C5E
	for <topia-commits@lists.labs.libre-entreprise.org>;
	Wed, 28 Jan 2009 18:19:18 +0100 (CET)
To: topia-commits@lists.labs.libre-entreprise.org
From: bpoussin@users.labs.libre-entreprise.org
Message-Id: <20090128171918.3BA10461C5E@labs.libre-entreprise.org>
Date: Wed, 28 Jan 2009 18:19:18 +0100 (CET)
Subject: [Topia-commits] r1318 - in
	topia/trunk/topia-persistence/src/main/java/org/codelutin/topia:
	generator persistence
X-BeenThere: topia-commits@lists.labs.libre-entreprise.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: <topia-commits.lists.labs.libre-entreprise.org>
List-Unsubscribe:
 <https://lists.labs.libre-entreprise.org/mailman/listinfo/topia-commits>,	
 =?utf-8?q?=3Cmailto=3Atopia-commits-request=40lists=2Elabs=2Elibre-entrepri?=
 =?utf-8?q?se=2Eorg=3Fsubject=3Dunsubscribe=3E?=
List-Archive: <http://lists.labs.libre-entreprise.org/pipermail/topia-commits>
List-Post: <mailto:topia-commits@lists.labs.libre-entreprise.org>
List-Help:
 <mailto:topia-commits-request@lists.labs.libre-entreprise.org?subject=help>
List-Subscribe:
 <https://lists.labs.libre-entreprise.org/mailman/listinfo/topia-commits>,	
 =?utf-8?q?=3Cmailto=3Atopia-commits-request=40lists=2Elabs=2Elibre-entrepri?=
 =?utf-8?q?se=2Eorg=3Fsubject=3Dsubscribe=3E?=
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Sender: topia-commits-bounces@lists.labs.libre-entreprise.org
Errors-To: topia-commits-bounces@lists.labs.libre-entreprise.org

Author: bpoussin
Date: 2009-01-28 17:19:17 +0000 (Wed, 28 Jan 2009)
New Revision: 1318

Added:
   topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persiste=
nce/EntityVisitor.java
Modified:
   topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generato=
r/EntityAbstractGenerator.java
Log:
ajout d'un methode accept pour visite tous les attributs d'une entity et de=
 la class EntityVisitor
(je laisse en exercice les tests et le debuggage, on dit merci qui :))

Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/g=
enerator/EntityAbstractGenerator.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
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generat=
or/EntityAbstractGenerator.java	2009-01-26 22:19:33 UTC (rev 1317)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generat=
or/EntityAbstractGenerator.java	2009-01-28 17:19:17 UTC (rev 1318)
@@ -225,7 +225,75 @@
 =

 }*/
 =

+
 /*{
+    /**
+     * Envoi via les methodes du visitor l'ensemble des champs de l'entity
+     * avec leur type et leur valeur
+     *)
+    public void accept(EntityVisitor visitor) throws TopiaException {
+        visitor.start(this);
+}*/
+
+        for (ObjectModelAttribute attr : clazz.getAttributes()) {
+            ObjectModelAttribute reverse =3D attr.getReverseAttribute();
+
+            // pour les asso quoi qu'il arrive il faut les lier des 2 cotes
+            // pour pouvoir supprimer en cascade l'asso lors de la suppres=
sion
+            // d'un des cotes
+            if (!(attr.isNavigable()
+                    || hasUnidirectionalRelationOnAbstractType(reverse, mo=
del)
+                    || attr.hasAssociationClass())) {
+                continue;
+            }
+
+            if (!Util.isNMultiplicity(attr)) {
+                if (!attr.hasAssociationClass()) {
+                    // FIXME il faut encapsuler getType() pour retourner l=
a version objet des types simples
+/*{    visitor.accept(this, <%=3Dattr.getType()%>.class, <%=3Dattr.getName=
()%>);
+
+}*/
+                } else {
+                    String assocAttrName =3D GeneratorUtil.getAssocAttrNam=
e(attr);
+/*{    visitor.accept(this, <%=3Dattr.getAssociationClass().getQualifiedNa=
me()%>.class, <%=3DUtil.toLowerCaseFirstLetter(assocAttrName)%>);
+
+}*/
+                }
+            } else {
+                String collectionType =3D GeneratorUtil.getNMultiplicityIn=
terfaceType(attr);
+                if (!attr.hasAssociationClass()) {
+/*{    visitor.accept(this, <%=3DcollectionType%>.class, <%=3Dattr.getType=
()%>.class, <%=3Dattr.getName()%>);
+
+}*/
+                } else {
+                    String assocAttrName =3D GeneratorUtil.getAssocAttrNam=
e(attr);
+/*{    visitor.accept(this, <%=3DcollectionType%>.class, <%=3Dattr.getAsso=
ciationClass().getQualifiedName()%>.class, <%=3DUtil.toLowerCaseFirstLetter=
(assocAttrName)%>);
+
+}*/
+                }
+            }
+        }
+
+        //D=E9claration des attributs d'une classe d'associations
+        if (clazz instanceof ObjectModelAssociationClass) {
+            ObjectModelAssociationClass assoc =3D (ObjectModelAssociationC=
lass) clazz;
+            for (ObjectModelAttribute attr : assoc.getParticipantsAttribut=
es()) {
+                if (attr !=3D null) {
+/*{    visitor.accept(this, <%=3Dattr.getType()%>.class, <%=3DUtil.toLower=
CaseFirstLetter(attr.getName())%>);
+
+}*/
+                }
+            }
+        }
+/*{
+        visitor.end(this);
+    }
+
+}*/
+
+
+
+/*{
     public List<TopiaEntity> getAggregate() throws TopiaException {
         List<TopiaEntity> tmp =3D new ArrayList<TopiaEntity>();
         // pour tous les attributs rechecher les composites et les class d=
'asso

Added: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/pers=
istence/EntityVisitor.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
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persist=
ence/EntityVisitor.java	                        (rev 0)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persist=
ence/EntityVisitor.java	2009-01-28 17:19:17 UTC (rev 1318)
@@ -0,0 +1,36 @@
+/* *##% ToPIA - Tools for Portable and Independent Architecture
+ * Copyright (C) 2004 - 2009 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
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program.  If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/
+
+package org.codelutin.topia.persistence;
+
+/**
+ *
+ * Created: 28 janv. 2009 18:10:34
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public interface EntityVisitor {
+
+    public void start(TopiaEntity e);
+    public void end(TopiaEntity e);
+    public void visit(TopiaEntity e, Class type, Object value);
+    public void visit(TopiaEntity e, Class collectionType, Class type, Obj=
ect value);
+}

_______________________________________________
Topia-commits mailing list
Topia-commits@lists.labs.libre-entreprise.org
https://lists.labs.libre-entreprise.org/mailman/listinfo/topia-commits

