Topia-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
January 2009
- 5 participants
- 54 discussions
r1337 - in topia/trunk/topia-persistence/src: main/java/org/codelutin/topia/persistence test/java/org/codelutin/topia/persistence
by chatellier@users.labs.libre-entreprise.org 29 Jan '09
by chatellier@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: chatellier
Date: 2009-01-29 17:23:41 +0000 (Thu, 29 Jan 2009)
New Revision: 1337
Added:
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/DepthEntityVisitor.java
Modified:
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/TopiaEntity.java
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/EntityVisitorExportXmlTest.java
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/ExportXMLVisitor.java
Log:
Ajout d'un implementation de parcourt par defaut.
Added: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/DepthEntityVisitor.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/DepthEntityVisitor.java (rev 0)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/DepthEntityVisitor.java 2009-01-29 17:23:41 UTC (rev 1337)
@@ -0,0 +1,112 @@
+/* *##%
+ * Copyright (C) 2009 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+package org.codelutin.topia.persistence;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.topia.TopiaException;
+
+/**
+ * Parcourt du graphes d'entité en profondeur.
+ *
+ * @author chatellier
+ * @version $Revision: 1.0 $
+ *
+ * Last update : $Date: 29 janv. 2009 $
+ * By : $Author: chatellier $
+ */
+public class DepthEntityVisitor implements EntityVisitor {
+
+ private static Log log = LogFactory.getLog(DepthEntityVisitor.class);
+
+ protected Collection<TopiaEntity> alreadyExplored;
+
+ /**
+ * Le visiteur metier.
+ */
+ protected EntityVisitor delegateVisitor;
+
+ public DepthEntityVisitor(EntityVisitor delegateVisitor) {
+
+ alreadyExplored = new ArrayList<TopiaEntity>();
+
+ this.delegateVisitor = delegateVisitor;
+ }
+
+ /*
+ * @see org.codelutin.topia.persistence.EntityVisitor#start(org.codelutin.topia.persistence.TopiaEntity)
+ */
+ @Override
+ public void start(TopiaEntity e) {
+ delegateVisitor.start(e);
+ alreadyExplored.add(e);
+ }
+
+ /*
+ * @see org.codelutin.topia.persistence.EntityVisitor#visit(org.codelutin.topia.persistence.TopiaEntity, java.lang.Class, java.lang.Object)
+ */
+ @Override
+ public void visit(TopiaEntity e, Class type, Object value) {
+ // si c'est une entité
+ if(value instanceof TopiaEntity) {
+ TopiaEntity entity = (TopiaEntity)value;
+ try {
+ if(!alreadyExplored.contains(entity)) {
+ entity.accept(this);
+ }
+ } catch (TopiaException e1) {
+ if(log.isErrorEnabled()) {
+ log.error("Error on depth exploration", e1);
+ }
+ }
+ }
+ else {
+ delegateVisitor.visit(e, type, value);
+ }
+ }
+
+ /*
+ * @see org.codelutin.topia.persistence.EntityVisitor#visit(org.codelutin.topia.persistence.TopiaEntity, java.lang.Class, java.lang.Class, java.lang.Object)
+ */
+ @Override
+ public void visit(TopiaEntity e, Class collectionType, Class type,
+ Object value) {
+
+ Collection cValue = (Collection)value;
+ if(cValue != null && !cValue.isEmpty()) {
+ Iterator itOnValues = cValue.iterator();
+ while(itOnValues.hasNext()) {
+ Object currentValue = itOnValues.next();
+ visit(e, type, currentValue);
+ }
+ }
+ }
+
+ /*
+ * @see org.codelutin.topia.persistence.EntityVisitor#end(org.codelutin.topia.persistence.TopiaEntity)
+ */
+ @Override
+ public void end(TopiaEntity e) {
+ delegateVisitor.end(e);
+ }
+}
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/TopiaEntity.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/TopiaEntity.java 2009-01-29 16:22:56 UTC (rev 1336)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/TopiaEntity.java 2009-01-29 17:23:41 UTC (rev 1337)
@@ -130,4 +130,12 @@
public void removeVetoableListener(VetoableChangeListener vetoable);
+ /**
+ * Parcourt de l'entité via un visiteur.
+ *
+ * @param visitor visitor
+ * @throws TopiaException
+ */
+ public void accept(EntityVisitor visitor) throws TopiaException;
+
} //TopiaEntity
Modified: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/EntityVisitorExportXmlTest.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/EntityVisitorExportXmlTest.java 2009-01-29 16:22:56 UTC (rev 1336)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/EntityVisitorExportXmlTest.java 2009-01-29 17:23:41 UTC (rev 1337)
@@ -31,7 +31,6 @@
import org.codelutin.topiatest.Address;
import org.codelutin.topiatest.AddressDAO;
import org.codelutin.topiatest.Company;
-import org.codelutin.topiatest.CompanyAbstract;
import org.codelutin.topiatest.CompanyDAO;
import org.codelutin.topiatest.Department;
import org.codelutin.topiatest.DepartmentDAO;
@@ -161,10 +160,13 @@
/**
* Test l'export XML via un visiteur.
+ *
+ * Parcourt en profondeur.
+ *
* @throws TopiaException
*/
@Test
- public void testExportXML() throws TopiaException {
+ public void testExportXMLDepth() throws TopiaException {
TopiaContext rootContext = TopiaContextFactory.getContext(config);
TopiaContext context = rootContext.beginTransaction();
@@ -172,13 +174,13 @@
CompanyDAO companyDAO = TopiaTestDAOHelper.getCompanyDAO(context);
Company clCompany = companyDAO.findByName("CodeLutin");
- ExportXMLVisitor visitor = new ExportXMLVisitor();
- // FIXME voir pour l'abstract
- ((CompanyAbstract)clCompany).accept(visitor);
+ EntityVisitor delegateVisitor = new ExportXMLVisitor();
+ EntityVisitor visitor = new DepthEntityVisitor(delegateVisitor);
+ clCompany.accept(visitor);
context.closeContext();
if(log.isInfoEnabled()) {
- log.info("Export XML = \n" + visitor.toString());
+ log.info("Export XML = \n" + delegateVisitor.toString());
}
}
}
Modified: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/ExportXMLVisitor.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/ExportXMLVisitor.java 2009-01-29 16:22:56 UTC (rev 1336)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/ExportXMLVisitor.java 2009-01-29 17:23:41 UTC (rev 1337)
@@ -80,24 +80,7 @@
@Override
public void visit(TopiaEntity e, Class collectionType, Class type,
Object value) {
- if(log.isDebugEnabled()) {
- log.debug("visit collection : " + e);
- }
-
-
- Collection cValue = (Collection)value;
- if(cValue != null && !cValue.isEmpty()) {
- buffer.append("<" + collectionType.getName() + ">\n");
- Iterator itOnValues = cValue.iterator();
- while(itOnValues.hasNext()) {
- TopiaEntityAbstract entity = (TopiaEntityAbstract)itOnValues.next();
-
- buffer.append("<" + type.getName() + ">\n");
- buffer.append("TODO sublist visit\n");
- buffer.append("</" + type.getName() + ">\n");
- }
- buffer.append("</" + collectionType.getName() + ">\n");
- }
+
}
/*
1
0
r1336 - topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/generator
by chatellier@users.labs.libre-entreprise.org 29 Jan '09
by chatellier@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: chatellier
Date: 2009-01-29 16:22:56 +0000 (Thu, 29 Jan 2009)
New Revision: 1336
Modified:
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/generator/TopiaTestCase.java
Log:
Method init() should be public :(
Modified: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/generator/TopiaTestCase.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/generator/TopiaTestCase.java 2009-01-29 16:15:38 UTC (rev 1335)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/generator/TopiaTestCase.java 2009-01-29 16:22:56 UTC (rev 1336)
@@ -60,7 +60,7 @@
* Init les proprietes de connection a la base
*/
@BeforeClass
- protected static void init() {
+ public static void init() {
config = new Properties();
config.setProperty("topia.persistence.classes",TopiaTestDAOHelper.entitiesList);
1
0
r1335 - in topia/trunk/topia-persistence/src/test/java/org/codelutin/topia: . framework generator persistence
by chatellier@users.labs.libre-entreprise.org 29 Jan '09
by chatellier@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: chatellier
Date: 2009-01-29 16:15:38 +0000 (Thu, 29 Jan 2009)
New Revision: 1335
Removed:
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/Person.hbm.xml
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/Person.java
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/PersonAbstract.java
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/PersonImpl.java
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/TopiaContextTest.java
Modified:
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/framework/EntityStateTest.java
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/framework/TopiaUtilTest.java
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/generator/TopiaTestCase.java
topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/ExportXMLVisitor.java
Log:
Mise ?\195?\160 jour des test, utilisation des entit?\195?\169s du modeles de test
Deleted: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/Person.hbm.xml
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/Person.hbm.xml 2009-01-29 15:47:42 UTC (rev 1334)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/Person.hbm.xml 2009-01-29 16:15:38 UTC (rev 1335)
@@ -1,16 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping>
- <class name="org.codelutin.topia.PersonImpl" table="person" node="org.codelutin.topia.Person" proxy="org.codelutin.topia.Person">
- <id name="topiaId" length="255" node="@topiaId" access="field">
- <!-- on utilise des TopiaId maintenant <generator class="uuid.hex"/> -->
- </id>
- <version name="topiaVersion" type="long" node="@topiaVersion" access="field"/>
- <property name="topiaCreateDate" type="date" node="@topiaCreateDate" access="field"/>
- <property name="name" type="string" node="@name" access="field"/>
- <property name="firstname" type="string" node="@firstname" access="field"/>
- </class>
-</hibernate-mapping>
Deleted: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/Person.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/Person.java 2009-01-29 15:47:42 UTC (rev 1334)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/Person.java 2009-01-29 16:15:38 UTC (rev 1335)
@@ -1,59 +0,0 @@
-/* *##% ToPIA - Tools for Portable and Independent Architecture
- * Copyright (C) 2004 - 2008 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>. ##%*/
-
-/* *
- * Person.java
- *
- * Created: 29 déc. 2005 00:27:53
- *
- * @author poussin
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-
-package org.codelutin.topia;
-
-import org.codelutin.topia.persistence.TopiaEntity;
-
-/**
- * @author poussin
- */
-public interface Person extends TopiaEntity {
-
- /**
- * @return Returns the firstname.
- */
- public abstract String getFirstname();
-
- /**
- * @param firstname The firstname to set.
- */
- public abstract void setFirstname(String firstname);
-
- /**
- * @return Returns the name.
- */
- public abstract String getName();
-
- /**
- * @param name The name to set.
- */
- public abstract void setName(String name);
-
-}
Deleted: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/PersonAbstract.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/PersonAbstract.java 2009-01-29 15:47:42 UTC (rev 1334)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/PersonAbstract.java 2009-01-29 16:15:38 UTC (rev 1335)
@@ -1,86 +0,0 @@
-/* *##% ToPIA - Tools for Portable and Independent Architecture
- * Copyright (C) 2004 - 2008 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>. ##%*/
-
-/* *
- * PersonAbstract.java
- *
- * Created: 29 déc. 2005 00:27:53
- *
- * @author poussin
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-
-package org.codelutin.topia;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.codelutin.topia.TopiaException;
-import org.codelutin.topia.persistence.TopiaEntity;
-import org.codelutin.topia.persistence.TopiaEntityAbstract;
-
-/**
- * @author poussin
- *
- */
-public abstract class PersonAbstract extends TopiaEntityAbstract implements
- Person {
-
- protected String name;
-
- protected String firstname;
-
- public String getFirstname() {
- fireOnPreRead("firstname", name);
- String result = firstname;
- fireOnPreRead("firstname", result);
- return result;
- }
-
- public void setFirstname(String firstname) {
- String _oldValue = this.firstname;
- fireOnPreWrite("firstName", _oldValue, firstname);
- this.firstname = firstname;
- fireOnPostWrite("firstName", _oldValue, firstname);
- }
-
- public String getName() {
- fireOnPreRead("name", name);
- String result = name;
- fireOnPreRead("name", result);
- return result;
- }
-
- public void setName(String name) {
- String _oldValue = this.name;
- fireOnPreWrite("name", _oldValue, name);
- this.name = name;
- fireOnPostWrite("name", _oldValue, name);
- }
-
- public List<TopiaEntity> getComposite() throws TopiaException {
- return new ArrayList<TopiaEntity>();
- }
-
- public List<TopiaEntity> getAggregate() throws TopiaException {
- return new ArrayList<TopiaEntity>();
- }
-
-}
Deleted: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/PersonImpl.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/PersonImpl.java 2009-01-29 15:47:42 UTC (rev 1334)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/PersonImpl.java 2009-01-29 16:15:38 UTC (rev 1335)
@@ -1,38 +0,0 @@
-/* *##% ToPIA - Tools for Portable and Independent Architecture
- * Copyright (C) 2004 - 2008 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>. ##%*/
-
-/*******************************************************************************
- * PersonImpl.java
- *
- * Created: 28 déc. 2005 16:14:04
- *
- * @author poussin
- *
- * @version $Revision$
- *
- * Last update: $Date$ by : $Author$
- */
-
-package org.codelutin.topia;
-
-/**
- * @author poussin
- *
- */
-public class PersonImpl extends PersonAbstract implements Person {
-
-}
Deleted: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/TopiaContextTest.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/TopiaContextTest.java 2009-01-29 15:47:42 UTC (rev 1334)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/TopiaContextTest.java 2009-01-29 16:15:38 UTC (rev 1335)
@@ -1,504 +0,0 @@
-/* *##% ToPIA - Tools for Portable and Independent Architecture
- * Copyright (C) 2004 - 2008 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>. ##%*/
-
-/*******************************************************************************
- * TopiaContextTest.java
- *
- * Created: 28 d?c. 2005 16:26:24
- *
- * @author poussin
- *
- * @version $Revision$
- *
- * Last update: $Date$ by : $Author$
- */
-
-package org.codelutin.topia;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.topia.event.TopiaEntityEvent;
-import org.codelutin.topia.event.TopiaEntityListener;
-import org.codelutin.topia.event.TopiaEntityVetoable;
-import org.codelutin.topia.event.TopiaTransactionEvent;
-import org.codelutin.topia.event.TopiaTransactionListener;
-import org.codelutin.topia.framework.TopiaContextImplementor;
-import org.codelutin.topia.persistence.TopiaDAO;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.util.Properties;
-
-/** @author poussin */
-public class TopiaContextTest extends Assert {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(TopiaContextTest.class);
-
- protected String entitiesList = Person.class.getName();
-
- protected String timeStamp;
-
- protected TopiaContext context;
-
- protected static File testDir;
-
- @BeforeClass
- public static void beforeClass() {
- String basedir = System.getProperty("basedir");
- if (basedir==null) {
- basedir = new File("").getAbsolutePath();
- }
- testDir = new File(basedir, "target" + File.separator + "tests" + File.separator + TopiaContextTest.class.getSimpleName());
- }
-
- @Before
- public void before() {
- timeStamp = System.nanoTime() + "";
- }
-
- @After
- public void after() throws TopiaException {
- if (context != null && !context.isClosed()) {
- context.closeContext();
- }
- }
-
- protected Properties getPostgreSQLProperties() {
- Properties config = new Properties();
- config.setProperty("hibernate.show_sql", "true");
- config.setProperty("hibernate.hbm2ddl.auto", "create");
-
- config.setProperty("topia.dao.flatfile.directory", new File(testDir, "topiadb_" + timeStamp).getAbsolutePath());
- config.setProperty("topia.dao.flatfile.mapping.key", "firstname");
-
- config.setProperty("topia.persistence.classes", entitiesList);
- config.setProperty("hibernate.dialect",
- "org.hibernate.dialect.PostgreSQLDialect");
- config.setProperty("hibernate.connection.driver_class",
- "org.postgresql.Driver");
- config.setProperty("hibernate.connection.url", "jdbc:postgresql:database");
- config.setProperty("hibernate.connection.username", "dbuser");
- config.setProperty("hibernate.connection.password", "xxxxxxxx");
-
- return config;
- }
-
- protected Properties getDerbyProperties() {
- Properties config = new Properties();
- config.setProperty("hibernate.show_sql", "true");
- config.setProperty("hibernate.hbm2ddl.auto", "create");
-
- config.setProperty("topia.dao.flatfile.directory", new File(testDir, "topiadb_" + timeStamp).getAbsolutePath());
- config.setProperty("topia.dao.flatfile.mapping.key", "firstname");
-
- config.setProperty("topia.persistence.classes", entitiesList);
- config.setProperty("hibernate.dialect",
- "org.hibernate.dialect.DerbyDialect");
- config.setProperty("hibernate.connection.driver_class",
- "org.apache.derby.jdbc.EmbeddedDriver");
- config.setProperty("hibernate.connection.url",
- "jdbc:derby:/tmp/topiaderby;create=true");
- config.setProperty("hibernate.connection.username", "dbuser");
- config.setProperty("hibernate.connection.password", "xxxxxxxx");
-
- return config;
- }
-
- protected Properties getH2Properties() {
- Properties config = new Properties();
- config.setProperty("hibernate.show_sql", "true");
- config.setProperty("hibernate.hbm2ddl.auto", "create");
-
- File dbFile = new File(testDir, "topiadb");
- if (!dbFile.exists() && !dbFile.mkdirs()) {
- throw new RuntimeException("could not create directory " + dbFile);
- }
- //new File("/tmp/topiadb/").mkdirs();
- config.setProperty("topia.dao.flatfile.directory", new File(dbFile,"topiadb2_" + timeStamp + "/h2").getAbsolutePath());
- config.setProperty("topia.dao.flatfile.mapping.key", "firstname");
-
- config.setProperty("topia.persistence.classes", entitiesList);
- config.setProperty("hibernate.dialect",
- "org.hibernate.dialect.HSQLDialect");
- config
- .setProperty("hibernate.connection.driver_class",
- "org.h2.Driver");
- config.setProperty("hibernate.connection.url",
- "jdbc:h2:file:"+new File(testDir,"topiadb_" + timeStamp).getAbsolutePath() + "/h2;create=true;LOCK_MODE=0");
- config.setProperty("hibernate.connection.username", "sa");
- config.setProperty("hibernate.connection.password", "");
-
- return config;
- }
-
- protected Properties getProperties() {
- return getH2Properties();
- }
-
- /*
- * #hibernate.dialect org.hibernate.dialect.DerbyDialect
- * #hibernate.connection.driver_class org.apache.derby.jdbc.EmbeddedDriver
- * #hibernate.connection.url jdbc:derby:/test;create=true
- * #hibernate.connection.username #hibernate.connection.password
- */
- @Test
- public void testGetParentContext() throws Exception {
- Properties config = getProperties();
-
- context = TopiaContextFactory
- .getContext(config);
-
- TopiaContextImplementor child1 = (TopiaContextImplementor) context
- .beginTransaction();
- TopiaContextImplementor child2 = (TopiaContextImplementor) child1
- .beginTransaction();
-
- assertEquals(child1, child2.getParentContext());
- assertEquals(context, child1.getParentContext());
- assertEquals(null, ((TopiaContextImplementor) context).getParentContext());
-
- assertEquals(context, ((TopiaContextImplementor) context).getRootContext());
- assertEquals(context, child1.getRootContext());
- assertEquals(context, child2.getRootContext());
- }
-
- @Test
- public void testHibernate() throws Exception {
- System.out.println("Debut du test Hibernate");
-
- Properties config = getProperties();
-
- context = TopiaContextFactory.getContext(config);
-
- TopiaContextImplementor childContext = (TopiaContextImplementor) context
- .beginTransaction();
- TopiaDAO<Person> persons = childContext.getDAO(Person.class);
- Person p = persons.create();
- p.setName("poussin");
- p.setFirstname("benjamin");
- persons.update(p);
- childContext.commitTransaction();
-
- String id = p.getTopiaId();
-
- Person p1 = persons.create();
- p1.setName("poussin");
- p1.setFirstname("jacques");
- persons.update(p1);
- childContext.commitTransaction();
-
- Person p2 = persons.create();
- p2.setName("poussin");
- p2.setFirstname("mylene");
- persons.update(p2);
- childContext.rollbackTransaction();
-
- p.setFirstname("berengere");
- persons.update(p);
- childContext.commitTransaction();
-
- p.setFirstname("toto");
- persons.update(p);
- assertEquals("toto", p.getFirstname());
- childContext.rollbackTransaction();
-
- p = persons.findByTopiaId(id);
- assertEquals("berengere", p.getFirstname());
-
- TopiaContextImplementor childContext2 = (TopiaContextImplementor) context
- .beginTransaction();
- TopiaDAO<Person> persons2 = childContext2.getDAO(Person.class);
-
- Person pp = persons2.findByTopiaId(id);
- assertEquals("berengere", pp.getFirstname());
- }
-
- @Ignore
- //FIXME :
- public void testIsolation() throws Exception {
- System.out.println("Debut du test Isolation");
-
- Properties config = getProperties();
-
- context = TopiaContextFactory.getContext(config);
-
- TopiaContextImplementor c1 = (TopiaContextImplementor) context
- .beginTransaction();
- TopiaContextImplementor c2 = (TopiaContextImplementor) context
- .beginTransaction();
-
- TopiaDAO<Person> ps1 = c1.getDAO(Person.class);
- TopiaDAO<Person> ps2 = c2.getDAO(Person.class);
-
- assertEquals(0, ps1.findAll().size());
- assertEquals(0, ps2.findAll().size());
-
- Person p = ps1.create();
- p.setName("poussin");
- p.setFirstname("benjamin");
- ps1.update(p);
-
- c1.rollbackTransaction();
-
- assertEquals(0, ps1.findAll().size());
- assertEquals(0, ps2.findAll().size());
-
- p = ps1.create();
- p.setName("poussin");
- p.setFirstname("benjamin");
- ps1.update(p);
-
- assertEquals(1, ps1.findAll().size());
- //FIXME this test does not work (anylonger?), this is a bit scaring...
- assertEquals(0, ps2.findAll().size());
-
- c1.commitTransaction();
-
- assertEquals(1, ps1.findAll().size());
- assertEquals(0, ps2.findAll().size());
-
- ps1.delete(p);
-
- assertEquals(0, ps1.findAll().size());
- assertEquals(0, ps2.findAll().size());
-
- c1.commitTransaction();
-
- assertEquals(0, ps1.findAll().size());
- assertEquals(0, ps2.findAll().size());
-
- }
-
- @Test
- public void testFlatFile() throws Exception {
- System.out.println("Debut du test FlatFile");
-
- Properties config = getProperties();
- config.setProperty("topia.dao.default.class", "flatfile");
-
- context = TopiaContextFactory.getContext(config);
-
- TopiaContextImplementor childContext = (TopiaContextImplementor) context
- .beginTransaction();
- TopiaDAO<Person> persons = childContext.getDAO(Person.class);
- Person p = persons.create();
- p.setName("poussin");
- p.setFirstname("benjamin");
- persons.update(p);
- childContext.commitTransaction();
-
- Person p1 = persons.create();
- p1.setName("poussin");
- p1.setFirstname("jacques");
- persons.update(p1);
- childContext.commitTransaction();
-
- Person p2 = persons.create();
- p2.setName("poussin");
- p2.setFirstname("mylene");
- persons.update(p2);
- childContext.rollbackTransaction();
-
- p.setFirstname("berengere");
- persons.update(p);
- childContext.commitTransaction();
-
- }
-
- @Test
- public void testConstructor() throws Exception {
- System.out.println("Debut du test constructor");
-
- Properties config = getProperties();
-
- context = TopiaContextFactory.getContext(config);
-
- TopiaContextImplementor childContext = (TopiaContextImplementor) context
- .beginTransaction();
-
- TopiaDAO<Person> persons = childContext.getDAO(Person.class);
- Person p = persons.create("name", "poussin", "firstname", "toto");
- assertEquals("poussin", p.getName());
- assertEquals("toto", p.getFirstname());
-
- persons.update(p);
- childContext.commitTransaction();
-
- p.setFirstname("titi");
- assertEquals("titi", p.getFirstname());
-
- persons.update(p);
- childContext.commitTransaction();
-
- p.setFirstname("benjamin");
- assertEquals("benjamin", p.getFirstname());
-
- persons.update(p);
- childContext.commitTransaction();
-
- persons.delete(p);
- childContext.commitTransaction();
- }
-
- String state = "";
-
- @Test
- public void testEventHibernate() throws Exception {
- System.out.println("Debut du test Event");
-
- Properties config = getProperties();
- context = TopiaContextFactory.getContext(config);
-
- TopiaEntityVetoable entityVetoable = new TopiaEntityVetoable() {
- private void print(TopiaEntityEvent event, String _state) {
- state += _state;
- if (log.isInfoEnabled()) {
- log.info(_state + " " + event.getEntity());
- }
- }
-
- public void create(TopiaEntityEvent event) {
- print(event, "vetoCreate");
- }
-
- public void update(TopiaEntityEvent event) {
- print(event, "vetoUpdate");
- }
-
- public void delete(TopiaEntityEvent event) {
- print(event, "vetoDelete");
- }
-
- public void load(TopiaEntityEvent event) {
- print(event, "vetoLoad");
- }
- };
-
- TopiaEntityListener entityListener = new TopiaEntityListener() {
- private void print(TopiaEntityEvent event, String _state) {
- state += _state;
- if (log.isInfoEnabled()) {
- log.info(_state + " " + event.getEntity());
- }
- }
-
- public void create(TopiaEntityEvent event) {
- print(event, "entityCreated");
- }
-
- public void update(TopiaEntityEvent event) {
- print(event, "entityUpdated");
- }
-
- public void delete(TopiaEntityEvent event) {
- print(event, "entityDeleted");
- }
-
- public void load(TopiaEntityEvent event) {
- print(event, "entityLoaded");
- }
- };
-
- TopiaTransactionListener transactionListener = new TopiaTransactionListener() {
- public void commit(TopiaTransactionEvent event) {
- log.info("commit " + event.getEntities());
- }
-
- public void rollback(TopiaTransactionEvent event) {
- log.info("rollback " + event.getEntities());
- }
- };
-
- TopiaContextImplementor childContext = (TopiaContextImplementor) context
- .beginTransaction();
- childContext.addTopiaEntityVetoable(entityVetoable);
- childContext.addTopiaEntityListener(entityListener);
- childContext.addTopiaTransactionListener(transactionListener);
- TopiaDAO<Person> persons = childContext.getDAO(Person.class);
-
- Person p = persons.create();
- p.setName("poussin");
- p.setFirstname("benjamin");
- persons.update(p);
- childContext.commitTransaction();
-
- assertEquals("vetoCreateentityCreatedvetoUpdateentityUpdated", state);
- state = "";
-
- p.setFirstname("toto");
- persons.update(p);
- childContext.commitTransaction();
-
- assertEquals("vetoUpdateentityUpdated", state);
- state = "";
-
- TopiaContextImplementor childContext2 = (TopiaContextImplementor) context
- .beginTransaction();
- childContext2.addTopiaEntityVetoable(entityVetoable);
- childContext2.addTopiaEntityListener(entityListener);
- childContext2.addTopiaTransactionListener(transactionListener);
- TopiaDAO<Person> persons2 = childContext2.getDAO(Person.class);
-
- Person pp = persons2.findByTopiaId(p.getTopiaId());
-
- assertEquals(p.getFirstname(), pp.getFirstname());
- assertEquals("vetoLoadentityLoaded", state);
- state = "";
-
- persons2.delete(pp);
- childContext2.commitTransaction();
-
- assertEquals("vetoDeleteentityDeleted", state);
- state = "";
-
- }
-
- @Test
- public void testPropertyEvent() throws Exception {
- PropertyChangeListener l = new PropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent evt) {
- System.out.println("entityUpdated " + evt.getSource());
- state = "entityUpdated";
- }
- };
-
- Properties config = getProperties();
-
- context = TopiaContextFactory.getContext(config).beginTransaction();
-
- TopiaDAO<Person> personDAO = ((TopiaContextImplementor) context).getDAO(Person.class);
- Person p = personDAO.create();
- p.addPropertyChangeListener("firstName", l);
-
- p.setFirstname("Arno");
- assertEquals("entityUpdated", state);
- state = "";
-
- p.setName("Arno");
- assertEquals("", state);
- state = "";
- }
-
-} //TopiaContextTest
Modified: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/framework/EntityStateTest.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/framework/EntityStateTest.java 2009-01-29 15:47:42 UTC (rev 1334)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/framework/EntityStateTest.java 2009-01-29 16:15:38 UTC (rev 1335)
@@ -1,5 +1,5 @@
/* *##% ToPIA - Tools for Portable and Independent Architecture
- * Copyright (C) 2004 - 2008 CodeLutin
+ * 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
@@ -15,7 +15,14 @@
* License along with this program. If not, see
* <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/
-/* *
+
+
+package org.codelutin.topia.framework;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
* EntityStateTest.java
*
* Created: 22 nov. 06 12:15:11
@@ -26,61 +33,58 @@
* Last update: $Date$
* by : $Author$
*/
+public class EntityStateTest {
-package org.codelutin.topia.framework;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-/** @author poussin */
-
-public class EntityStateTest extends Assert {
-
+ /**
+ * Test les changements d'etat de {@link EntityState}.
+ *
+ * @throws Exception
+ */
@Test
public void testState() throws Exception {
EntityState state = new EntityState();
state.addLoad();
- assertTrue(state.isLoad());
- assertFalse(state.isRead());
- assertFalse(state.isCreate());
- assertFalse(state.isUpdate());
- assertFalse(state.isDelete());
+ Assert.assertTrue(state.isLoad());
+ Assert.assertFalse(state.isRead());
+ Assert.assertFalse(state.isCreate());
+ Assert.assertFalse(state.isUpdate());
+ Assert.assertFalse(state.isDelete());
state.addRead();
- assertTrue(state.isLoad());
- assertTrue(state.isRead());
- assertFalse(state.isCreate());
- assertFalse(state.isUpdate());
- assertFalse(state.isDelete());
+ Assert.assertTrue(state.isLoad());
+ Assert.assertTrue(state.isRead());
+ Assert.assertFalse(state.isCreate());
+ Assert.assertFalse(state.isUpdate());
+ Assert.assertFalse(state.isDelete());
//state.addRead();
state.addCreate();
- assertTrue(state.isLoad());
- assertTrue(state.isRead());
- assertTrue(state.isCreate());
- assertFalse(state.isUpdate());
- assertFalse(state.isDelete());
+ Assert.assertTrue(state.isLoad());
+ Assert.assertTrue(state.isRead());
+ Assert.assertTrue(state.isCreate());
+ Assert.assertFalse(state.isUpdate());
+ Assert.assertFalse(state.isDelete());
state.addUpdate();
- assertTrue(state.isLoad());
- assertTrue(state.isRead());
- assertTrue(state.isCreate());
- assertTrue(state.isUpdate());
- assertFalse(state.isDelete());
+ Assert.assertTrue(state.isLoad());
+ Assert.assertTrue(state.isRead());
+ Assert.assertTrue(state.isCreate());
+ Assert.assertTrue(state.isUpdate());
+ Assert.assertFalse(state.isDelete());
state.addDelete();
- assertTrue(state.isLoad());
- assertTrue(state.isRead());
- assertTrue(state.isCreate());
- assertTrue(state.isUpdate());
- assertTrue(state.isDelete());
+ Assert.assertTrue(state.isLoad());
+ Assert.assertTrue(state.isRead());
+ Assert.assertTrue(state.isCreate());
+ Assert.assertTrue(state.isUpdate());
+ Assert.assertTrue(state.isDelete());
state = new EntityState();
state.addDelete();
- assertFalse(state.isRead());
- assertFalse(state.isCreate());
- assertFalse(state.isUpdate());
- assertTrue(state.isDelete());
+ Assert.assertFalse(state.isRead());
+ Assert.assertFalse(state.isCreate());
+ Assert.assertFalse(state.isUpdate());
+ Assert.assertTrue(state.isDelete());
}
}
Modified: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/framework/TopiaUtilTest.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/framework/TopiaUtilTest.java 2009-01-29 15:47:42 UTC (rev 1334)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/framework/TopiaUtilTest.java 2009-01-29 16:15:38 UTC (rev 1335)
@@ -1,36 +1,64 @@
+/* *##%
+ * Copyright (C) 2009 Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
package org.codelutin.topia.framework;
-import org.codelutin.topia.Person;
-import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-/** @author chemit */
+import org.codelutin.topiatest.Personne;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test pour les methodes de {@link TopiaUtil}.
+ *
+ * @author chemit
+ * @version $Revision: 1242 $
+ *
+ * Last update: $Date: 2008-12-05 00:33:31 +0100 (ven 05 déc 2008) $
+ * by : $Author: tchemit $
+ */
public class TopiaUtilTest {
- protected static final String PERSON_ID = "org.codelutin.topia.Person#1226701039001#0.6502325993664224";
- protected static final String PERSON_ID2 = "org.codelutin.topia.Person#1226701039001#0.6502325993664999";
+ protected static final String PERSON_ID = "org.codelutin.topiatest.Personne#1226701039001#0.6502325993664224";
+ protected static final String PERSON_ID2 = "org.codelutin.topiatest.Personne#1226701039001#0.6502325993664999";
- @org.junit.Test
+ @Test
public void testGetTopiaIdPattern() throws Exception {
String expected;
String actual;
- expected = "org\\.codelutin\\.topia\\.Person#(?:\\d+?)#(?:\\d+)\\.(?:\\d+)";
- actual = TopiaUtil.getTopiaIdPattern(Person.class);
+ expected = "org\\.codelutin\\.topiatest\\.Personne#(?:\\d+?)#(?:\\d+)\\.(?:\\d+)";
+ actual = TopiaUtil.getTopiaIdPattern(Personne.class);
assertEquals(expected, actual);
}
- @org.junit.Test
+ @Test
public void testGetTopiaPattern() throws Exception {
String expected;
Pattern pattern;
- expected = "(\\d+)-(org\\.codelutin\\.topia\\.Person#(?:\\d+?)#(?:\\d+)\\.(?:\\d+))-(org\\.codelutin\\.topia\\.Person#(?:\\d+?)#(?:\\d+)\\.(?:\\d+))(.*)";
- pattern = TopiaUtil.getTopiaPattern("(\\d+)-%1$s-%1$s(.*)", Person.class);
+ expected = "(\\d+)-(org\\.codelutin\\.topiatest\\.Personne#(?:\\d+?)#(?:\\d+)\\.(?:\\d+))-(org\\.codelutin\\.topiatest\\.Personne#(?:\\d+?)#(?:\\d+)\\.(?:\\d+))(.*)";
+ pattern = TopiaUtil.getTopiaPattern("(\\d+)-%1$s-%1$s(.*)", Personne.class);
assertEquals(expected, pattern.toString());
String expression = 123 + "-" + PERSON_ID + "-" + PERSON_ID2 + "-afterall";
@@ -46,6 +74,4 @@
assertEquals(PERSON_ID2, matcher.group(3));
assertEquals("-afterall", matcher.group(4));
}
-
-
}
Modified: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/generator/TopiaTestCase.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/generator/TopiaTestCase.java 2009-01-29 15:47:42 UTC (rev 1334)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/generator/TopiaTestCase.java 2009-01-29 16:15:38 UTC (rev 1335)
@@ -1,5 +1,5 @@
/* *##% ToPIA Testing
- * Copyright (C) 2007 - 2008 CodeLutin
+ * Copyright (C) 2007 - 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
@@ -26,17 +26,18 @@
import org.codelutin.topia.TopiaException;
import org.codelutin.topia.TopiaNotFoundException;
import org.codelutin.topia.TopiaTestDAOHelper;
-import org.codelutin.topiatest.CompanyDAO;
-import org.codelutin.topiatest.DepartmentDAO;
import org.codelutin.topiatest.Company;
+import org.codelutin.topiatest.CompanyDAO;
import org.codelutin.topiatest.Department;
+import org.codelutin.topiatest.DepartmentDAO;
import org.hibernate.cfg.Environment;
-import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
- * TopiaTestCase
+ * TopiaTestCase.
*
* @author chatellier
* @version $Revision: 1186 $
@@ -50,18 +51,17 @@
private final static Log log = LogFactory.getLog(TopiaTestCase.class);
/** Proprietes */
- protected Properties config = null;
+ protected static Properties config = null;
/** TopiaContext */
protected TopiaContext context = null;
/**
- * Retourne les proprietes de connection a la base
- * @return la config
+ * Init les proprietes de connection a la base
*/
- protected Properties getProperties() {
-
- Properties config = new Properties();
+ @BeforeClass
+ protected static void init() {
+ config = new Properties();
config.setProperty("topia.persistence.classes",TopiaTestDAOHelper.entitiesList);
config.setProperty(Environment.USER, "sa");
@@ -70,27 +70,18 @@
config.setProperty(Environment.DIALECT,"org.hibernate.dialect.H2Dialect");
config.setProperty(Environment.DRIVER,"org.h2.Driver");
config.setProperty(Environment.URL,"jdbc:h2:file:/tmp/db/data");
-
- return config;
}
/**
- * Init
+ * Create base with schema created.
*/
- protected void init() {
- if(config == null) {
- config = getProperties();
- }
- }
-
@Before
public void setUp() {
+
if(log.isInfoEnabled()) {
log.info("Junit beforeTest");
}
- init();
-
try {
context = TopiaContextFactory.getContext(config);
@@ -148,8 +139,8 @@
company = companyDAO.findByTopiaId(company.getTopiaId());
- org.junit.Assert.assertEquals(company.getName(),"Ma société");
- org.junit.Assert.assertEquals(company.getDepartment().size(),4);
+ Assert.assertEquals(company.getName(),"Ma société");
+ Assert.assertEquals(company.getDepartment().size(),4);
newContext.commitTransaction();
newContext.closeContext();
@@ -157,18 +148,4 @@
log.error("Erreur pendant le test testCompositeAssociations",e);
}
}
-
- /*@Test
- public void testOther() {
- if(log.isInfoEnabled()) {
- log.info("Junit Test testOther");
- }
- }*/
-
- @After
- public void tearDown() {
- if(log.isInfoEnabled()) {
- log.info("Junit afterTest");
- }
- }
}
\ No newline at end of file
Modified: topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/ExportXMLVisitor.java
===================================================================
--- topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/ExportXMLVisitor.java 2009-01-29 15:47:42 UTC (rev 1334)
+++ topia/trunk/topia-persistence/src/test/java/org/codelutin/topia/persistence/ExportXMLVisitor.java 2009-01-29 16:15:38 UTC (rev 1335)
@@ -84,17 +84,20 @@
log.debug("visit collection : " + e);
}
+
Collection cValue = (Collection)value;
- buffer.append("<" + collectionType.getName() + ">");
- Iterator itOnValues = cValue.iterator();
- while(itOnValues.hasNext()) {
- TopiaEntityAbstract entity = (TopiaEntityAbstract)itOnValues.next();
-
- buffer.append("<" + type.getName() + ">\n");
- buffer.append("TODO sublist visit\n");
- buffer.append("</" + type.getName() + ">\n");
+ if(cValue != null && !cValue.isEmpty()) {
+ buffer.append("<" + collectionType.getName() + ">\n");
+ Iterator itOnValues = cValue.iterator();
+ while(itOnValues.hasNext()) {
+ TopiaEntityAbstract entity = (TopiaEntityAbstract)itOnValues.next();
+
+ buffer.append("<" + type.getName() + ">\n");
+ buffer.append("TODO sublist visit\n");
+ buffer.append("</" + type.getName() + ">\n");
+ }
+ buffer.append("</" + collectionType.getName() + ">\n");
}
- buffer.append("</" + collectionType.getName() + ">");
}
/*
1
0
r1334 - in topia/trunk: . topia-persistence topia-persistence/src/main/java/org/codelutin/topia/generator topia-soa/src/main/java/org/codelutin/topia/generator topia-ui/src/main/java/org/codelutin/topia/generator
by thimel@users.labs.libre-entreprise.org 29 Jan '09
by thimel@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: thimel
Date: 2009-01-29 15:47:42 +0000 (Thu, 29 Jan 2009)
New Revision: 1334
Added:
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaGeneratorUtil.java
Removed:
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java
Modified:
topia/trunk/changelog.txt
topia/trunk/pom.xml
topia/trunk/topia-persistence/changelog.txt
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOAbstractGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOHelperGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOImplGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DTOGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityAbstractGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityDTOGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityEnumGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityImplGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityInterfaceGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityProviderGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/InterfaceGenerator.java
topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaRelationValidator.java
topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java
topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java
topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java
topia/trunk/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java
Log:
Merge with branch generators-refactoring
Modified: topia/trunk/changelog.txt
===================================================================
--- topia/trunk/changelog.txt 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/changelog.txt 2009-01-29 15:47:42 UTC (rev 1334)
@@ -1,5 +1,6 @@
2.1.3 ??? 200902??
* 20090126 [chemit] - refactor poms (all dependencies in parent-pom dependencyManagment)
+ * 20090129 [chemit] - use lutinproject 3.4
2.1.2 chemit 20090115
* 20090114 [chemit] - using lutinproject 3.3
Modified: topia/trunk/pom.xml
===================================================================
--- topia/trunk/pom.xml 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/pom.xml 2009-01-29 15:47:42 UTC (rev 1334)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>lutinproject</artifactId>
- <version>3.3</version>
+ <version>3.4-SNAPSHOT</version>
</parent>
<artifactId>topia</artifactId>
@@ -165,12 +165,13 @@
<labs.project>topia</labs.project>
<!-- libs version -->
- <generator.version>0.63</generator.version>
+ <generator.version>0.64-SNAPSHOT</generator.version>
<processor.version>0.16</processor.version>
<lutinutil.version>1.0</lutinutil.version>
<xmlrpc.version>3.1</xmlrpc.version>
<hibernate.version>3.3.1.GA</hibernate.version>
-
+ <!-- todo pour la montee de version voir la doc -->
+ <topia.version>${project.version}</topia.version>
</properties>
<build>
Modified: topia/trunk/topia-persistence/changelog.txt
===================================================================
--- topia/trunk/topia-persistence/changelog.txt 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/changelog.txt 2009-01-29 15:47:42 UTC (rev 1334)
@@ -1,4 +1,8 @@
2.1.3 ??? 200902??
+* 20090129 [chemit] - add methods in TopiaGeneratorUtil class to optimize imports
+* 20090129 [thimel] - Refactor generators (part1 : remove any methods calls in <%=...%>)
+* 20090129 [thimel] - Renamed GeneratorUtil to TopiaGeneratorUtil
+* 20090128 [bpoussin] - introduce Visitor design pattern on generated TopiaEntityAbstract
* 20090126 [chemit] - refactor poms (all dependencies in parent-pom dependencyManagment)
* 20090126 [chemit] - add somes junit tests to check none-regression when modify ToPIA's templates.
- fix generation bug (notNull could ne null (line 226 EntityHibernateMappingGenerator)
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOAbstractGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOAbstractGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOAbstractGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -37,8 +37,8 @@
import java.util.regex.Pattern;
import org.codelutin.generator.Generator;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
@@ -71,11 +71,11 @@
@Override
public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
@@ -86,15 +86,14 @@
import org.codelutin.topia.TopiaException;
import org.codelutin.topia.framework.TopiaContextImplementor;
}*/
- String securityCreate = clazz.getTagValue("securityCreate");
- String securityLoad = clazz.getTagValue("securityLoad");
- String securityUpdate = clazz.getTagValue("securityUpdate");
- String securityDelete = clazz.getTagValue("securityDelete");
+ boolean enableSecurity = (
+ clazz.hasTagValue(TopiaGeneratorUtil.TAG_SECURITY_CREATE) ||
+ clazz.hasTagValue(TopiaGeneratorUtil.TAG_SECURITY_LOAD) ||
+ clazz.hasTagValue(TopiaGeneratorUtil.TAG_SECURITY_UPDATE) ||
+ clazz.hasTagValue(TopiaGeneratorUtil.TAG_SECURITY_DELETE)
+ );
- if(GeneratorUtil.notEmpty(securityCreate) ||
- GeneratorUtil.notEmpty(securityLoad) ||
- GeneratorUtil.notEmpty(securityUpdate) ||
- GeneratorUtil.notEmpty(securityDelete)) {
+ if (enableSecurity) {
/*{
import java.util.ArrayList;
import java.security.Permission;
@@ -107,19 +106,20 @@
import static org.codelutin.topia.taas.TaasUtil.UPDATE;
}*/
}
+ String clazzName = clazz.getName();
/*{
/**
- * Implantation DAO pour l'entité <%=Util.toUpperCaseFirstLetter(clazz.getName())%>.
+ * Implantation DAO pour l'entité <%=GeneratorUtil.toUpperCaseFirstLetter(clazz.getName())%>.
* Cette classe contient une implantation de TopiaDAO a laquel elle peut
* deleguer des traitements
*
*)
-public abstract class <%=clazz.getName()%>DAOAbstract<E extends <%=clazz.getName()%>> extends }*/
+public abstract class <%=clazzName%>DAOAbstract<E extends <%=clazzName%>> extends }*/
String extendClass = "";
- for (Iterator i=clazz.getSuperclasses().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (Iterator<ObjectModelClass> i=clazz.getSuperclasses().iterator(); i.hasNext();) {
+ ObjectModelClassifier parent = i.next();
extendClass += parent.getQualifiedName();
- if (parent.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
extendClass += "DAOImpl<E>";
}
if (i.hasNext()) {
@@ -133,44 +133,51 @@
/*{<%=extendClass%> implements org.codelutin.topia.persistence.TopiaDAO<E> {
public Class<E> getEntityClass() {
- return (Class<E>)<%=clazz.getName()%>.class;
+ return (Class<E>)<%=clazzName%>.class;
}
public void delete(E entity) throws TopiaException {
}*/
String providerFQN = getProperty("defaultPackage") + "." + model.getName() + "EntityEnum.getImplementationClass";
for (ObjectModelAttribute attr : clazz.getAttributes()) {
+ String attrType = attr.getType();
+ String reverseAttrName = attr.getReverseAttributeName();
ObjectModelAttribute reverse = attr.getReverseAttribute();
if (!attr.hasAssociationClass() && reverse != null && reverse.isNavigable()
- && Util.isNMultiplicity(attr) && Util.isNMultiplicity(reverse)) {
+ && GeneratorUtil.isNMultiplicity(attr) && GeneratorUtil.isNMultiplicity(reverse)) {
// On doit absolument supprimer pour les relations many-to-many
// le this de la collection de l'autre cote
+ String attrDBName = TopiaGeneratorUtil.getDBName(attr);
+ String attrClassifierDBName = TopiaGeneratorUtil.getDBName(attr.getClassifier());
+ String attrJoinTableName = TopiaGeneratorUtil.getManyToManyTableName(attr);
+ String attrReverseDBName = TopiaGeneratorUtil.getReverseDBName(attr);
/*{
{
- List<<%=attr.getType()%>> list = getContext().getHibernate().createSQLQuery(
+ List<<%=attrType%>> list = getContext().getHibernate().createSQLQuery(
"SELECT {main.*} " +
- "from <%=GeneratorUtil.getDBName(attr.getClassifier())%> main, <%=GeneratorUtil.getManyToManyTableName(attr)%> secondary " +
- "where main.topiaid=secondary.<%=GeneratorUtil.getDBName(attr)%>" +
- " and secondary.<%=GeneratorUtil.getReverseDBName(attr)%>='"+entity.getTopiaId()+"'")
- .addEntity("main", <%=providerFQN%>(<%=attr.getType()%>.class)).list();
- for (<%=attr.getType()%> item : list) {
- item.remove<%=Util.capitalize(attr.getReverseAttributeName())%>(entity);
+ "from <%=attrClassifierDBName%> main, <%=attrJoinTableName%> secondary " +
+ "where main.topiaid=secondary.<%=attrDBName%>" +
+ " and secondary.<%=attrReverseDBName%>='" + entity.getTopiaId() + "'")
+ .addEntity("main", <%=providerFQN%>(<%=attrType%>.class)).list();
+ for (<%=attrType%> item : list) {
+ item.remove<%=TopiaGeneratorUtil.capitalize(reverseAttrName)%>(entity);
}
}
}*/
} else if (!attr.hasAssociationClass() && reverse != null
- && reverse.isNavigable() && !Util.isNMultiplicity(reverse)) {
- // On doit mettre a null les attributs qui ont cette objet sur les
+ && reverse.isNavigable() && !GeneratorUtil.isNMultiplicity(reverse)) {
+ // On doit mettre a null les attributs qui ont cet objet sur les
// autres entites en one-to-*
// TODO peut-etre qu'hibernate est capable de faire ca tout seul ?
+ // THIMEL: J'ai remplacé reverse.getName() par reverseAttrName sans certitude
/*{
{
- List<<%=attr.getType()%>> list = getContext()
- .getDAO(<%=attr.getType()%>.class)
- .findAllByProperties("<%=reverse.getName()%>", entity);
- for (<%=attr.getType()%> item : list) {
- item.set<%=Util.capitalize(attr.getReverseAttributeName())%>(null);
+ List<<%=attrType%>> list = getContext()
+ .getDAO(<%=attrType%>.class)
+ .findAllByProperties("<%=reverseAttrName%>", entity);
+ for (<%=attrType%> item : list) {
+ item.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(null);
}*/
if(attr.isAggregate()){
/*{
@@ -189,7 +196,7 @@
}
/**
- * Retourne tous les <%=clazz.getName()%>
+ * Retourne tous les <%=clazzName%>
* @return une liste
*)
public List<E> findAll() throws TopiaException {
@@ -197,42 +204,37 @@
return result;
}
}*/
- for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
if (!attr.isNavigable()) {
continue;
}
+ String attrName = attr.getName();
/*{ /**
- * Recherche sur l'attribut <%=attr.getName()%>
+ * Recherche sur l'attribut <%=attrName%>
*)
}*/
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, false);
} else {
- generateNMultiplicity(output, attr, false);
+ generateNMultiplicity(output, attr);
}
}
if (clazz instanceof ObjectModelAssociationClass) {
ObjectModelAssociationClass assocClass = (ObjectModelAssociationClass)clazz;
- Iterator it = assocClass.getParticipantsAttributes().iterator();
- while (it.hasNext()) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : assocClass.getParticipantsAttributes()) {
if (attr != null) {
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, true);
} else {
- generateNMultiplicity(output, attr, true);
+ generateNMultiplicity(output, attr);
}
}
}
}
- if(GeneratorUtil.notEmpty(securityCreate) ||
- GeneratorUtil.notEmpty(securityLoad) ||
- GeneratorUtil.notEmpty(securityUpdate) ||
- GeneratorUtil.notEmpty(securityDelete)) {
+ if(enableSecurity) {
/*{
/**
* Retourne les permissions a verifier pour l'acces a l'entite pour le service Taas
@@ -244,27 +246,30 @@
List<Permission> resultPermissions = new ArrayList<Permission>();
if ((actions & CREATE) == CREATE) {
}*/
- generateSecurity(output, clazz, securityCreate);
+ generateSecurity(output, clazz, TopiaGeneratorUtil.TAG_SECURITY_CREATE);
/*{
}
if ((actions & LOAD) == LOAD) {
}*/
- generateSecurity(output, clazz, securityLoad);
+ generateSecurity(output, clazz, TopiaGeneratorUtil.TAG_SECURITY_LOAD);
/*{
}
if ((actions & UPDATE) == UPDATE) {
}*/
- generateSecurity(output, clazz, securityUpdate);
+ generateSecurity(output, clazz, TopiaGeneratorUtil.TAG_SECURITY_UPDATE);
/*{
}
if ((actions & DELETE) == DELETE) {
}*/
- generateSecurity(output, clazz, securityDelete);
+ generateSecurity(output, clazz, TopiaGeneratorUtil.TAG_SECURITY_DELETE);
/*{
}
return resultPermissions;
}
-
+
+}*/
+ // THIMEL : Le code suivant doit pouvoir être déplacé dans DAODelegator ?
+/*{
/**
* Retourne les permissions a verifier pour l'acces a l'entite pour le service Taas
* @param topiaId topiaId d'une entite
@@ -276,7 +281,7 @@
protected List<Permission> getRequestPermission(String topiaId, int actions, String query, Class daoClass) throws TopiaException {
TopiaContextImplementor context = getContext();
List<String> result = context.find(query, "id", topiaId);
-
+
List<Permission> resultPermissions = new ArrayList<Permission>();
for (String topiaIdPermission : result) {
TopiaDAO dao = context.getDAO(daoClass);
@@ -293,12 +298,13 @@
}*/
}
/*{
-} //<%=clazz.getName()%>DAOAbstract
+} // <%=clazz.getName()%>DAOAbstract
}*/
}
- private void generateSecurity(Writer output, ObjectModelClass clazz, String security) throws IOException {
- if(security != null) {
+ private void generateSecurity(Writer output, ObjectModelClass clazz, String securityTagName) throws IOException {
+ if (clazz.hasTagValue(securityTagName)) {
+ String security = clazz.getTagValue(securityTagName);
Pattern propertiesPattern = Pattern
.compile("((?:[_a-zA-Z0-9]+\\.)+(?:_?[A-Z][_a-zA-Z0-9]*\\.)+)attribute\\.(?:([_a-z0-9][_a-zA-Z0-9]*))#(?:(create|load|update|delete))");
String[] valuesSecurity = security.split(":");
@@ -323,91 +329,99 @@
query = "select at.topiaId from " + className + " at inner join at." + attributeName + " cl where cl.topiaId = :id";
daoClass = className;
}
-/*{ resultPermissions.addAll(getRequestPermission(topiaId,
+/*{ resultPermissions.addAll(getRequestPermission(topiaId,
<%=actions%>,
"<%=query%>",
<%=daoClass%>.class));
}*/
}
} else {
-/*{ return null;
+/*{ return null;
}*/
}
}
protected void generateNoNMultiplicity(Writer output, ObjectModelAttribute attr, boolean isAssoc) throws IOException {
- String propertyName = attr.getName();
+ String attrName = attr.getName();
+ String attrType = attr.getType();
+ String propertyName = attrName;
if (!isAssoc && attr.hasAssociationClass()) {
- propertyName = GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
+ propertyName = TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
}
/*{
/**
* Retourne le premier élément trouvé ayant comme valeur pour l'attribut
- * <%=attr.getName()%> le paramètre
- * @param v la valeur que doit avoir <%=attr.getName()%>
+ * <%=attrName%> le paramètre
+ * @param v la valeur que doit avoir <%=attrName%>
* @return un element ou null
*)
- public E findBy<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException {
+ public E findBy<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException {
E result = getParentDAO().findByProperty("<%=propertyName%>", v);
return result;
}
+
/**
* Retourne les éléments ayant comme valeur pour l'attribut
- * <%=attr.getName()%> le paramètre
- * @param v la valeur que doit avoir <%=attr.getName()%>
+ * <%=attrName%> le paramètre
+ * @param v la valeur que doit avoir <%=attrName%>
* @return une liste
*)
- public List<E> findAllBy<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException {
+ public List<E> findAllBy<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException {
List<E> result = getParentDAO().findAllByProperty("<%=propertyName%>", v);
return result;
}
}*/
if (attr.hasAssociationClass()) {
+ String assocClassName = attr.getAssociationClass().getName();
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
/*{
/**
* Retourne le premier élément trouvé ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le paramètre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> le paramètre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>
* @return un element ou null
*)
- public E findBy<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException {
- E result = getParentDAO().findByProperty("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>", value);
+ public E findBy<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException {
+ E result = getParentDAO().findByProperty("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>", value);
return result;
}
+
/**
* Retourne les éléments ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le paramètre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> le paramètre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>
* @return une liste
*)
- public List<E> findAllBy<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException {
- List<E> result = getParentDAO().findAllByProperty("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>", value);
+ public List<E> findAllBy<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException {
+ List<E> result = getParentDAO().findAllByProperty("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>", value);
return result;
}
}*/
}
}
-
- protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr, boolean isAssoc) throws IOException {
+
+ protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr) throws IOException {
+ String attrName = attr.getName();
+ String attrType = attr.getType();
/*{
/**
* Retourne le premier élément trouvé dont l'attribut
- * <%=attr.getName()%> contient le paramètre
- * @param v la valeur que doit contenir <%=attr.getName()%>
+ * <%=attrName%> contient le paramètre
+ * @param v la valeur que doit contenir <%=attrName%>
* @return un element ou null
*)
- public E findContains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException {
- E result = getParentDAO().findContainsProperties("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
+ public E findContains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException {
+ E result = getParentDAO().findContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attrName)%>", Arrays.asList(v));
return result;
}
/**
* Retourne les éléments trouvé dont l'attribut
- * <%=attr.getName()%> contient le paramètre
- * @param v la valeur que doit contenir <%=attr.getName()%>
+ * <%=attrName%> contient le paramètre
+ * @param v la valeur que doit contenir <%=attrName%>
* @return une liste
*)
- public List<E> findAllContains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException {
- List<E> results = getParentDAO().findAllContainsProperties("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
+ public List<E> findAllContains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException {
+ List<E> results = getParentDAO().findAllContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attrName)%>", Arrays.asList(v));
return results;
}
}*/
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -54,14 +54,16 @@
@Override
public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
/*{package <%=clazz.getPackageName()%>;
/**
@@ -69,11 +71,11 @@
* Cette classe est marque finale car l'heritage entre les DAO se fait
* sur les DOAImpl, c-a-d que DAOAbstract peut etendre le DAOImpl
*)
-public final class <%=clazz.getName()%>DAO extends <%=clazz.getQualifiedName()%>DAOImpl<<%=clazz.getName()%>> {
+public final class <%=clazzName%>DAO extends <%=clazzFQN%>DAOImpl<<%=clazzName%>> {
}*/
-/*{} //<%=clazz.getName()%>DAO
+/*{} //<%=clazzName%>DAO
}*/
}
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOHelperGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOHelperGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOHelperGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -71,22 +71,23 @@
@Override
public void generateFromModel(Writer output, ObjectModel model)
throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
+ String modelName = model.getName();
/*{package <%=getProperty("defaultPackage")%>;
import org.codelutin.topia.TopiaContext;
import org.codelutin.topia.framework.TopiaContextImplementor;
import org.codelutin.topia.TopiaException;
-public class <%=model.getName()%>DAOHelper {
+public class <%=modelName%>DAOHelper {
}*/
String entitiesList = "";
- List<ObjectModelClass> classes = GeneratorUtil.getEntityClasses(model,true);
+ List<ObjectModelClass> classes = TopiaGeneratorUtil.getEntityClasses(model,true);
if (classes.isEmpty()) {
/*{
public static final String entitiesList = "";
@@ -96,10 +97,11 @@
public static final String entitiesList = "" +
}*/
- for (Iterator i=classes.iterator(); i.hasNext();) {
+ for (Iterator<ObjectModelClass> i=classes.iterator(); i.hasNext();) {
ObjectModelClass clazz = (ObjectModelClass)i.next();
- entitiesList += GeneratorUtil.getDOType(clazz, model) + (i.hasNext()?",":"");
-/*{ "<%=GeneratorUtil.getDOType(clazz, model)%><%=(i.hasNext()?",\" +":"\";")%>
+ String doType = TopiaGeneratorUtil.getDOType(clazz, model);
+ entitiesList += doType + (i.hasNext()?",":"");
+/*{ "<%=doType%><%=(i.hasNext()?",\" +":"\";")%>
}*/
}
}
@@ -108,22 +110,23 @@
}
/*{ /**
*)
- protected <%=model.getName()%>DAOHelper() {
+ protected <%=modelName%>DAOHelper() {
}
}*/
- for (ObjectModelClass objectModelClass : classes) {
- ObjectModelClass clazz = objectModelClass;
+ for (ObjectModelClass clazz : classes) {
+ String clazzFQN = clazz.getQualifiedName();
+ String clazzName = clazz.getName();
/*{
- static public <%=clazz.getQualifiedName()%>DAO get<%=clazz.getName()%>DAO(TopiaContext context) throws TopiaException {
+ static public <%=clazzFQN%>DAO get<%=clazzName%>DAO(TopiaContext context) throws TopiaException {
TopiaContextImplementor ci = (TopiaContextImplementor)context;
- <%=clazz.getQualifiedName()%>DAO result = (<%=clazz.getQualifiedName()%>DAO)ci.getDAO(<%=clazz.getQualifiedName()%>.class);
+ <%=clazzFQN%>DAO result = (<%=clazzFQN%>DAO)ci.getDAO(<%=clazzFQN%>.class);
return result;
}
}*/
}
/*{
-}
+} //<%=modelName%>DAOHelper
}*/
}
-
-} // DAOHelperGenerator
+
+} //DAOHelperGenerator
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOImplGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOImplGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DAOImplGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -54,28 +54,28 @@
@Override
public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
/*{package <%=clazz.getPackageName()%>;
/**
- * Implantation du DAO pour l'entité <%=clazz.getName()%>.
+ * Implantation du DAO pour l'entité <%=clazzName%>.
* L'utilisateur peut remplacer cette classe par la sienne en la mettant
* simplement dans ces sources. Cette classe générée sera alors simplement
- * écrasé.
+ * écrasée.
*)
-public class <%=clazz.getName()%>DAOImpl<E extends <%=clazz.getName()%>> extends <%=clazz.getQualifiedName()%>DAOAbstract<E> {
+public class <%=clazzName%>DAOImpl<E extends <%=clazzName%>> extends <%=clazzFQN%>DAOAbstract<E> {
+} //<%=clazzName%>DAO
}*/
-
-/*{} //<%=clazz.getName()%>DAO
-}*/
}
} //DAOGenerator
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DTOGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DTOGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/DTOGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -29,7 +29,7 @@
package org.codelutin.topia.generator;
-import static org.codelutin.topia.generator.GeneratorUtil.TAG_ANNOTATION;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.TAG_ANNOTATION;
import java.io.File;
import java.io.IOException;
@@ -39,7 +39,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
@@ -68,28 +68,31 @@
public boolean isDTO(String type) {
ObjectModelClassifier clazz = model.getClassifier(type);
- return clazz != null && clazz.hasStereotype(GeneratorUtil.STEREOTYPE_DTO);
+ return clazz != null && clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO);
}
@Override
public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_DTO)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
return;
}
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
+ String clazzName = clazz.getName();
/*{package <%=clazz.getPackageName()%>;
import org.apache.commons.lang.builder.ToStringBuilder;
import java.beans.PropertyChangeListener;
+import java.util.List;
+import java.util.Collection;
/**
- * DTO implantation for <%=Util.capitalize(clazz.getName())%> entity.
+ * DTO implantation for <%=GeneratorUtil.capitalize(clazzName)%> entity.
*)
-public class <%=clazz.getName()%>DTO }*/
+public class <%=clazzName%>DTO}*/
/*
* Définition de la super classe : il ne doit y avoir qu'une
@@ -99,7 +102,7 @@
Iterator<ObjectModelClass> j = clazz.getSuperclasses().iterator();
if (j.hasNext()) {
ObjectModelClassifier parent = j.next();
- if (parent.hasStereotype(GeneratorUtil.STEREOTYPE_DTO)) {
+ if (parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
extendClass += parent.getName() + "DTO";
} else {
extendClass += parent.getName();
@@ -107,16 +110,16 @@
}
if (extendClass.length() > 0) {
- /*{extends <%=extendClass%> }*/
+/*{ extends <%=extendClass%>}*/
}
/*
* Définition des interfaces
*/
- /*{implements java.io.Serializable }*/
+/*{ implements java.io.Serializable}*/
String implInterface = "";
for (Iterator<ObjectModelInterface> i=clazz.getInterfaces().iterator(); i.hasNext();) {
ObjectModelClassifier parentInterface = i.next();
- if (parentInterface.hasStereotype(GeneratorUtil.STEREOTYPE_DTO)) {
+ if (parentInterface.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
implInterface += parentInterface.getName() + "DTO";
} else {
implInterface += parentInterface.getName();
@@ -127,7 +130,7 @@
}
}
if (implInterface.length() > 0) {
- /*{,<%=implInterface%> {
+/*{, <%=implInterface%> {
}*/
} else {
@@ -136,7 +139,8 @@
}*/
}
- String svUID = GeneratorUtil.findTagValue("dto-serialVersionUID", clazz, model);
+ String svUID = TopiaGeneratorUtil.findTagValue("dto-serialVersionUID", clazz, model);
+ // TODO Calculer un serialVersionUID si il n'y en a pas
if (svUID != null) {
/*{ public static final long serialVersionUID = <%=svUID%>;
@@ -153,7 +157,7 @@
continue;
}
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ /**
* <%=attr.getDocumentation()%>
*)
@@ -164,22 +168,52 @@
/*{ <%=annotation%>
}*/
}
- if (!Util.isNMultiplicity(attr)) {
+ String attrName = attr.getName();
+ String attrVisibility = attr.getVisibility();
+ String attrType = attr.getType();
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
-/*{ <%=attr.getVisibility()%> <%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%> <%=attr.getName()%>;
+ if (isDTO(attrType)) {
+ attrType += "DTO";
+ }
+/*{ <%=attrVisibility%> <%=attrType%> <%=attrName%>;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ <%=attr.getVisibility()%> <%=attr.getAssociationClass().getQualifiedName()%>DTO <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+/*{ <%=attrVisibility%> <%=assocClassFQN%>DTO <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}*/
}
} else {
if (!attr.hasAssociationClass()) {
-/*{ <%=attr.getVisibility()%> <%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%>> <%=attr.getName()%>;
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = "List<";
+ } else {
+ nMultType = "Collection<";
+ }
+ nMultType += attrType;
+ if (isDTO(attrType)) {
+ nMultType += "DTO";
+ }
+ nMultType += ">";
+/*{ <%=attrVisibility%> <%=nMultType%> <%=attrName%>;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ <%=attr.getVisibility()%> <%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>DTO> <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = "List<";
+ } else {
+ nMultType = "Collection<";
+ }
+ nMultType += assocClassFQN;
+ if (isDTO(attrType)) {
+ nMultType += "DTO";
+ }
+ nMultType += ">";
+/*{ <%=attrVisibility%> <%=nMultType%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}*/
}
}
@@ -188,34 +222,36 @@
//Déclaration des attributs d'une classe d'associations
if (clazz instanceof ObjectModelAssociationClass) {
ObjectModelAssociationClass assoc = (ObjectModelAssociationClass)clazz;
- for (Object o : assoc.getParticipantsAttributes()) {
- ObjectModelAttribute attr = (ObjectModelAttribute) o;
+ for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
if (attr != null) {
-/*{ <%=attr.getVisibility()%> <%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>;
+ String attrName = attr.getName();
+ String attrVisibility = attr.getVisibility();
+ String attrType = attr.getType();
+ if (isDTO(attrType)) {
+ attrType += "DTO";
+ }
+/*{ <%=attrVisibility%> <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>;
}*/
}
}
}
/*{
- protected java.beans.PropertyChangeSupport p;
+ protected java.beans.PropertyChangeSupport p;
-}*/
-
-/*{ /**
- * Default constructor of <%=clazz.getName()%>DTO.
+ /**
+ * Default constructor of <%=clazzName%>DTO.
*)
- public <%=clazz.getName()%>DTO() { p = new java.beans.PropertyChangeSupport(this); }
+ public <%=clazzName%>DTO() {
+ p = new java.beans.PropertyChangeSupport(this);
+ }
-}*/
-
-/*{ /**
- * Constructor of <%=clazz.getName()%>DTO with all parameters.
+ /**
+ * Constructor of <%=clazzName%>DTO with all parameters.
*)
- public <%=clazz.getName()%>DTO(}*/
+ public <%=clazzName%>DTO(}*/
boolean une_fois = true;
- for (Object o : clazz.getAttributes()) {
- ObjectModelAttribute attr = (ObjectModelAttribute) o;
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
if (!(attr.isNavigable()
|| attr.hasAssociationClass())) {
@@ -225,22 +261,43 @@
if (une_fois) {
une_fois = false;
} else {
- /*{, }*/
+/*{, }*/
}
- if (!Util.isNMultiplicity(attr)) {
+ String attrName = attr.getName();
+ String attrVisibility = attr.getVisibility();
+ String attrType = attr.getType();
+ String attrTypeDTO = attr.getType();
+ if (isDTO(attrType)) {
+ attrTypeDTO += "DTO";
+ }
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
-/*{<%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%> <%=attr.getName()%>}*/
+/*{<%=attrTypeDTO%> <%=attrName%>}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{<%=attr.getAssociationClass().getQualifiedName()%>DTO <%=Util.toLowerCaseFirstLetter(assocAttrName)%>}*/
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+/*{<%=assocClassFQN%>DTO <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>}*/
}
} else {
if (!attr.hasAssociationClass()) {
-/*{<%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%>> <%=attr.getName()%>}*/
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = "List<" + attrTypeDTO + ">";
+ } else {
+ nMultType = "Collection<" + attrTypeDTO + ">";
+ }
+/*{<%=nMultType%> <%=attrName%>}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{<%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>DTO> <%=Util.toLowerCaseFirstLetter(assocAttrName)%>}*/
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = "List<" + assocClassFQN + "DTO>";
+ } else {
+ nMultType = "Collection<" + assocClassFQN + "DTO>";
+ }
+/*{<%=nMultType%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>}*/
}
}
@@ -248,34 +305,35 @@
} // end for
/*{ ) {
- this();
+ this();
}*/
- for (Object o : clazz.getAttributes()) {
- ObjectModelAttribute attr = (ObjectModelAttribute) o;
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
if (!(attr.isNavigable()
|| attr.hasAssociationClass())) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ String attrName = attr.getName();
+
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
-/*{ this.<%=attr.getName()%> = <%=attr.getName()%>;
+/*{ this.<%=attrName%> = <%=attrName%>;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> = <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+/*{ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}*/
}
} else {
if (!attr.hasAssociationClass()) {
-/*{ this.<%=attr.getName()%> = <%=attr.getName()%>;
+/*{ this.<%=attrName%> = <%=attrName%>;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> = <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+/*{ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}*/
}
}
@@ -311,95 +369,131 @@
if (!attr.isNavigable()) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+
+ String attrName = attr.getName();
+ String attrType = attr.getType();
+ String attrTypeDTO = attr.getType();
+ if (isDTO(attrType)) {
+ attrTypeDTO += "DTO";
+ }
+
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
-/*{ public void set<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%> value) {
- <%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%> oldValue = this.<%=attr.getName()%>;
- this.<%=attr.getName()%> = value;
- p.firePropertyChange("<%=attr.getName()%>", oldValue, value);
+/*{ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=attrTypeDTO%> value) {
+ <%=attrTypeDTO%> oldValue = this.<%=attrName%>;
+ this.<%=attrName%> = value;
+ p.firePropertyChange("<%=attrName%>", oldValue, value);
}
- public <%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%> get<%=Util.capitalize(attr.getName())%>() {
- return <%=attr.getName()%>;
+ public <%=attrTypeDTO%> get<%=GeneratorUtil.capitalize(attrName)%>() {
+ return <%=attrName%>;
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
if (log.isTraceEnabled()) {
log.trace("assocAttrName: " + assocAttrName);
}
-/*{ public void set<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%>DTO association) {
- <%=attr.getAssociationClass().getQualifiedName()%>DTO oldAssocation= this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
- this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> = association;
- p.firePropertyChange("<%=attr.getName()%>", oldAssocation, assocation);
+/*{ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%>DTO association) {
+ <%=assocClassFQN%>DTO oldAssocation = this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = association;
+ p.firePropertyChange("<%=attrName%>", oldAssocation, assocation);
}
- public <%=attr.getAssociationClass().getQualifiedName()%>DTO get<%=Util.capitalize(assocAttrName)%>() {
- return <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+ public <%=assocClassFQN%>DTO get<%=GeneratorUtil.capitalize(assocAttrName)%>() {
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}
}*/
}
} else { //NMultiplicity
if (!attr.hasAssociationClass()) { //Méthodes remplacées par des accesseurs sur les classes d'assoc
-/*{ public void set<%=Util.capitalize(attr.getName())%>(<%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%>> values) {
- <%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%>> oldValues = this.<%=attr.getName()%>;
- this.<%=attr.getName()%> = values;
- p.firePropertyChange("<%=attr.getName()%>", oldValues, values);
+ String reverseAttrName = reverse.getName();
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = "List<" + attrTypeDTO + ">";
+ } else {
+ nMultType = "Collection<" + attrTypeDTO + ">";
+ }
+/*{ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=nMultType%> values) {
+ <%=nMultType%> oldValues = this.<%=attrName%>;
+ this.<%=attrName%> = values;
+ p.firePropertyChange("<%=attrName%>", oldValues, values);
}
}*/
//AddChild
-/*{ public <%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%> addChild(<%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%> <%=attr.getName()%>) {
- this.<%=attr.getName()%>.add(<%=attr.getName()%>);
+/*{ public <%=attrTypeDTO%> addChild(<%=attrTypeDTO%> <%=attrName%>) {
+ this.<%=attrName%>.add(<%=attrName%>);
}*/
if (reverse.isNavigable()) {
-/*{ <%=attr.getName()%>.set<%=Util.capitalize(reverse.getName())%>(this);
+/*{ <%=attrName%>.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(this);
}*/
}
-/*{ return <%=attr.getName()%>;
+/*{ return <%=attrName%>;
}
}*/
//RemoveChild
-/*{ public void removeChild(<%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%> <%=attr.getName()%>) {
- this.<%=attr.getName()%>.remove(<%=attr.getName()%>);
+/*{ public void removeChild(<%=attrTypeDTO%> <%=attrName%>) {
+ this.<%=attrName%>.remove(<%=attrName%>);
}*/
if (reverse.isNavigable()) {
-/*{ <%=attr.getName()%>.set<%=Util.capitalize(reverse.getName())%>(null);
+/*{ <%=attrName%>.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(null);
}*/
}
/*{ }
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = "List<" + assocClassFQN + "DTO>";
+ } else {
+ nMultType = "Collection<" + assocClassFQN + "DTO>";
+ }
if (log.isTraceEnabled()) {
log.trace("assocAttrName: " + assocAttrName);
}
-/*{ public void set<%=Util.capitalize(assocAttrName)%>(<%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>DTO> values) {
- <%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>DTO> oldValues =this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
- this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> = values;
- p.firePropertyChange("<%=attr.getName()%>", oldValues, values);
+/*{ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=nMultType%> values) {
+ <%=nMultType%> oldValues = this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = values;
+ p.firePropertyChange("<%=attrName%>", oldValues, values);
}
}*/
}
if (!attr.hasAssociationClass()) {
-/*{ public <%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getType()%><%=(isDTO(attr.getType())?"DTO":"")%>> get<%=Util.capitalize(attr.getName())%>() {
- return this.<%=attr.getName()%>;
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = "List<" + attrTypeDTO + ">";
+ } else {
+ nMultType = "Collection<" + attrTypeDTO + ">";
+ }
+/*{ public <%=nMultType%> get<%=GeneratorUtil.capitalize(attrName)%>() {
+ return this.<%=attrName%>;
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = "List<" + assocClassFQN + "DTO>";
+ } else {
+ nMultType = "Collection<" + assocClassFQN + "DTO>";
+ }
if (log.isTraceEnabled()) {
log.trace("assocAttrName: " + assocAttrName);
}
-/*{ public <%=((attr.isOrdered())?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>DTO> get<%=Util.capitalize(assocAttrName)%>() {
- return this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+/*{ public <%=nMultType%> get<%=GeneratorUtil.capitalize(assocAttrName)%>() {
+ return this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}
}*/
@@ -407,26 +501,27 @@
}
}
-/*{
+/*{
@Override
public String toString() {
String result = new ToStringBuilder(this).
}*/
- for (Object o : clazz.getAttributes()) {
- ObjectModelAttribute attr = (ObjectModelAttribute) o;
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
if (!(attr.isNavigable()
|| attr.hasAssociationClass())) {
continue;
}
+
//FIXME possibilité de boucles (non directes)
ObjectModelClass attrEntity = null;
if (model.hasClass(attr.getType())) {
attrEntity = model.getClass(attr.getType());
}
- boolean isDTO = (attrEntity != null && attrEntity.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY));
+ boolean isDTO = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)); //THIMEL : STEREOTYPE ENTITY ???
ObjectModelAttribute reverse = attr.getReverseAttribute();
if ((isDTO && (reverse == null || !reverse.isNavigable()) && !attr.hasAssociationClass()) || (!isDTO)) {
-/*{ append("<%=attr.getName()%>", this.<%=attr.getName()%>).
+ String attrName = attr.getName();
+/*{ append("<%=attrName%>", this.<%=attrName%>).
}*/
}
}
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityAbstractGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityAbstractGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityAbstractGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -33,20 +33,19 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.Generator;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
-import org.codelutin.generator.models.object.ObjectModelClassifier;
-import static org.codelutin.topia.generator.GeneratorUtil.TAG_ANNOTATION;
-import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType;
-import static org.codelutin.topia.generator.GeneratorUtil.shouldBeAbstract;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.shouldBeAbstract;
import org.codelutin.topia.persistence.TopiaEntityAbstract;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
+import java.util.List;
/**
* Generateur d'entites abstraites. Il s'agit de l'implatation par defaut d'une
@@ -59,6 +58,14 @@
private static final Log log = LogFactory
.getLog(EntityAbstractGenerator.class);
+ // TODO THIMEL : Je pense qu'il faudrait que l'EntityInterfaceGenerator
+ // hérite de ce générateur, avec generateBody qui renvoie false, et que dans
+ // ce générateur, on ne génère pas les corps de méthode, etc ... quand
+ // generateBoody() renvoie false
+ protected boolean generateBody() {
+ return true;
+ }
+
public EntityAbstractGenerator() {
super();
}
@@ -74,30 +81,45 @@
@Override
public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
+ String clazzName = clazz.getName();
+ String clazzFQN = TopiaGeneratorUtil.getSimpleName(clazz.getQualifiedName());
/*{package <%=clazz.getPackageName()%>;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.codelutin.topia.TopiaException;
-import org.codelutin.topia.framework.TopiaContextImplementor;
-import org.codelutin.topia.persistence.TopiaEntity;
-import org.codelutin.topia.persistence.EntityVisitor;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collection;
-
+}*/
+ List<String> imports = TopiaGeneratorUtil.getImports(clazz,
+ org.apache.commons.lang.builder.ToStringBuilder.class.getName(),
+ org.codelutin.topia.TopiaException.class.getName(),
+ org.codelutin.topia.framework.TopiaContextImplementor.class.getName(),
+ org.codelutin.topia.persistence.TopiaEntity.class.getName(),
+ TopiaEntityAbstract.class.getName(),
+ org.codelutin.topia.persistence.EntityVisitor.class.getName(),
+ java.util.List.class.getName(),
+ java.util.ArrayList.class.getName(),
+ java.io.Serializable.class.getName()
+ );
+ if (log.isDebugEnabled()) {
+ log.debug("imports for class <" + clazzFQN + ">");
+ }
+ for (String anImport : imports) {
+ if (log.isDebugEnabled()) {
+ log.debug("import " + anImport);
+ }
+/*{import <%=anImport%>;
+}*/
+ }
+/*{
/**
- * Implantation POJO pour l'entité <%=Util.capitalize(clazz.getName())%>.
+ * Implantation POJO pour l'entité {@link <%=TopiaGeneratorUtil.capitalize(clazzFQN)%>}.
}*/
{
- String dbName = clazz.getTagValue(GeneratorUtil.TAG_DB_NAME);
+ String dbName = clazz.getTagValue(TopiaGeneratorUtil.TAG_DB_NAME);
if (dbName != null) {
/*{ *
* <p>Nom de l'entité en BD : <%=dbName%>.</p>
@@ -105,18 +127,18 @@
}
}
/*{ *)
-public abstract class <%=clazz.getName()%>Abstract extends }*/
+}*/
String extendClass = "";
- for (Iterator i = clazz.getSuperclasses().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier) i.next();
+ for (Iterator<ObjectModelClass> i = clazz.getSuperclasses().iterator(); i.hasNext();) {
+ ObjectModelClass parent = i.next();
extendClass += parent.getQualifiedName();
//Si une des classes parentes définies des méthodes abstraites, son
// impl ne sera pas créé
boolean abstractParent = false;
if (parent instanceof ObjectModelClass) {
- abstractParent = shouldBeAbstract((ObjectModelClass) parent);
+ abstractParent = shouldBeAbstract(parent);
}
- if (parent.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
if (abstractParent) {
extendClass += "Abstract";
} else {
@@ -128,14 +150,14 @@
}
}
if (extendClass.length() == 0) {
- extendClass += TopiaEntityAbstract.class.getName();
+ extendClass += TopiaEntityAbstract.class.getSimpleName();
}
- /*{<%=extendClass%> implements java.io.Serializable, <%=clazz.getQualifiedName()%> {
+/*{public abstract class <%=clazzName%>Abstract extends <%=extendClass%> implements Serializable, <%=clazzName%> {
}*/
- String svUID = GeneratorUtil.findTagValue("serialVersionUID", clazz, model);
+ String svUID = TopiaGeneratorUtil.findTagValue("serialVersionUID", clazz, model);
if (svUID != null) {
/*{ public static final long serialVersionUID = <%=svUID%>;
@@ -152,46 +174,55 @@
|| attr.hasAssociationClass())) {
continue;
}
- String dbName = attr.getTagValue(GeneratorUtil.TAG_DB_NAME);
- if (GeneratorUtil.hasDocumentation(attr) || dbName != null) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr) || attr.hasTagValue(TopiaGeneratorUtil.TAG_DB_NAME)) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
-/*{ * <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ String attrDocumentation = attr.getDocumentation();
+/*{ * <%=attrDocumentation%>
}*/
}
- if (dbName != null) {
+ if (attr.hasTagValue(TopiaGeneratorUtil.TAG_DB_NAME)) {
+ String dbName = attr.getTagValue(TopiaGeneratorUtil.TAG_DB_NAME);
/*{ * Nom de l'attribut en BD : <%=dbName%>.
}*/
}
/*{ *)
}*/
}
- String annotation = attr.getTagValue(TAG_ANNOTATION);
- if (annotation != null && annotation.length() > 0) {
+ if (attr.hasTagValue(TopiaGeneratorUtil.TAG_ANNOTATION)) {
+ String annotation = attr.getTagValue(TopiaGeneratorUtil.TAG_ANNOTATION);
/*{ <%=annotation%>
}*/
}
- if (!Util.isNMultiplicity(attr)) {
- if (!attr.hasAssociationClass()) {
-/*{ <%=attr.getVisibility()%> <%=attr.getType()%> <%=attr.getName()%>;
+ String attrVisibility = attr.getVisibility();
+
+ // In case attribute is NMultiplicity
+ String collectionType = TopiaGeneratorUtil.getSimpleName(TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr));
+
+ if (!attr.hasAssociationClass()) {
+ String attrName = attr.getName();
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+/*{ <%=attrVisibility%> <%=attrType%> <%=attrName%>;
+
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ <%=attr.getVisibility()%> <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+/*{ <%=attrVisibility%> <%=collectionType%><<%=attrType%>> <%=attrName%>;
}*/
}
} else {
- String collectionType = GeneratorUtil.getNMultiplicityInterfaceType(attr);
- if (!attr.hasAssociationClass()) {
-/*{ <%=attr.getVisibility()%> <%=collectionType%><<%=attr.getType()%>> <%=attr.getName()%>;
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+ //TODO THIMEL : Je pense que les GeneratorUtil.toLowerCaseFirstLetter sont inutiles ici, ou alors il faudrait le faire partout
+/*{ <%=attrVisibility%> <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ <%=attr.getVisibility()%> <%=collectionType%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+/*{ <%=attrVisibility%> <%=collectionType%><<%=assocClassFQN%>> <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}*/
}
@@ -203,7 +234,10 @@
ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz;
for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
if (attr != null) {
-/*{ <%=attr.getVisibility()%> <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>;
+ String attrVisibility = attr.getVisibility();
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
+ String attrName = attr.getName();
+/*{ <%=attrVisibility%> <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>;
}*/
}
@@ -211,28 +245,26 @@
}
/*{ /**
- * Constructeur de <%=clazz.getName()%>Abstract par défaut.
+ * Constructeur de <%=clazzName%>Abstract par défaut.
*)
- public <%=clazz.getName()%>Abstract() {
+ public <%=clazzName%>Abstract() {
}
public void update() throws TopiaException {
- ((TopiaContextImplementor)getTopiaContext()).getDAO(<%=clazz.getName()%>.class).update(this);
+ ((TopiaContextImplementor)getTopiaContext()).getDAO(<%=clazzName%>.class).update(this);
}
public void delete() throws TopiaException {
- ((TopiaContextImplementor)getTopiaContext()).getDAO(<%=clazz.getName()%>.class).delete(this);
+ ((TopiaContextImplementor)getTopiaContext()).getDAO(<%=clazzName%>.class).delete(this);
}
-}*/
-
-
-/*{
/**
* Envoi via les methodes du visitor l'ensemble des champs de l'entity
* avec leur type et leur valeur.
*
- * @param visitor : le visiteur de l'entite.
+ * @param visitor : le visiteur de l'entite.
+ *
+ * @throws TopiaException if any pb while visit
*)
public void accept(EntityVisitor visitor) throws TopiaException {
visitor.start(this);
@@ -250,27 +282,31 @@
continue;
}
- if (!Util.isNMultiplicity(attr)) {
- if (!attr.hasAssociationClass()) {
- // FIXME il faut encapsuler getType() pour retourner la version objet des types simples
-/*{ visitor.visit(this, <%=attr.getType()%>.class, <%=attr.getName()%>);
+ if (!attr.hasAssociationClass()) {
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
+ String attrName = attr.getName();
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+/*{ visitor.visit(this, <%=attrType%>.class, <%=attrName%>);
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ visitor.visit(this, <%=attr.getAssociationClass().getQualifiedName()%>.class, <%=Util.toLowerCaseFirstLetter(assocAttrName)%>);
+ String collectionType = TopiaGeneratorUtil.getSimpleName(TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr));
+/*{ visitor.visit(this, <%=collectionType%>.class, <%=attrType%>.class, <%=attrName%>);
}*/
}
} else {
- String collectionType = GeneratorUtil.getNMultiplicityInterfaceType(attr);
- if (!attr.hasAssociationClass()) {
-/*{ visitor.visit(this, <%=collectionType%>.class, <%=attr.getType()%>.class, <%=attr.getName()%>);
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
+/*{ visitor.visit(this, <%=assocClassFQN%>.class, <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>);
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ visitor.visit(this, <%=collectionType%>.class, <%=attr.getAssociationClass().getQualifiedName()%>.class, <%=Util.toLowerCaseFirstLetter(assocAttrName)%>);
+ String collectionType = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
+/*{ visitor.visit(this, <%=collectionType%>.class, <%=assocClassFQN%>.class, <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>);
}*/
}
@@ -282,7 +318,9 @@
ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz;
for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
if (attr != null) {
-/*{ visitor.visit(this, <%=attr.getType()%>.class, <%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
+ String attrName = attr.getName();
+/*{ visitor.visit(this, <%=attrType%>.class, <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>);
}*/
}
@@ -292,26 +330,21 @@
visitor.end(this);
}
-}*/
-
-
-
-/*{
public List<TopiaEntity> getAggregate() throws TopiaException {
List<TopiaEntity> tmp = new ArrayList<TopiaEntity>();
+
// pour tous les attributs rechecher les composites et les class d'asso
// on les ajoute dans tmp
}*/
for (ObjectModelAttribute attr : clazz.getAttributes()) {
- if (attr.referenceClassifier() && attr.getClassifier().hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (attr.referenceClassifier() && attr.getClassifier().hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
if (attr.isAggregate()) {
- if (Util.isNMultiplicity(attr)) {
-/*{
- tmp.addAll(get<%=Util.capitalize(attr.getName())%>());
+ String attrName = attr.getName();
+ if (GeneratorUtil.isNMultiplicity(attr)) {
+/*{ tmp.addAll(get<%=GeneratorUtil.capitalize(attrName)%>());
}*/
} else {
-/*{
- tmp.add(get<%=Util.capitalize(attr.getName())%>());
+/*{ tmp.add(get<%=GeneratorUtil.capitalize(attrName)%>());
}*/
}
}
@@ -329,36 +362,35 @@
return result;
}
-}*/
-
-/*{
public List<TopiaEntity> getComposite() throws TopiaException {
List<TopiaEntity> tmp = new ArrayList<TopiaEntity>();
+
// pour tous les attributs rechecher les composites et les class d'asso
// on les ajoute dans tmp
}*/
for (ObjectModelAttribute attr : clazz.getAttributes()) {
- ObjectModelAttribute reverse = attr.getReverseAttribute();
- if (attr.referenceClassifier() && attr.getClassifier().hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (attr.referenceClassifier() && attr.getClassifier().hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
if (attr.isComposite()) {
- if (Util.isNMultiplicity(attr)) {
-/*{
- tmp.addAll(get<%=Util.capitalize(attr.getName())%>());
+ String attrName = attr.getName();
+ if (GeneratorUtil.isNMultiplicity(attr)) {
+/*{ tmp.addAll(get<%=GeneratorUtil.capitalize(attrName)%>());
}*/
} else {
-/*{
- tmp.add(get<%=Util.capitalize(attr.getName())%>());
+/*{ tmp.add(get<%=GeneratorUtil.capitalize(attrName)%>());
}*/
}
} else if (attr.hasAssociationClass()) {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (!Util.isNMultiplicity(attr)) {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
/*{
- if (this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> != null) {
- tmp.add(this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>);
+ if (this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> != null) {
+ tmp.add(this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>);
}
}*/
} else {
+ ObjectModelAttribute reverse = attr.getReverseAttribute();
+ String reverseAttrName = reverse.getName();
// On utilise pas l'attribut car il est potentiellement
// pas a jour, car pour les asso avec cardinalité
// personne ne fait de add. Ce qui est normal, mais
@@ -366,13 +398,13 @@
// sur les asso, le champs est dans le mapping
// hibernate et donc il le faut aussi dans la classe
// sinon hibernate rale lorsqu'il charge l'objet
-// if (this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> != null) {
-// tmp.addAll(this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>);
+// if (this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> != null) {
+// tmp.addAll(this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>);
// }
/*{
tmp.addAll(((TopiaContextImplementor)getTopiaContext())
- .getDAO(<%=attr.getAssociationClass().getQualifiedName()%>.class)
- .findAllByProperties("<%=reverse.getName()%>", this));
+ .getDAO(<%=assocClassFQN%>.class)
+ .findAllByProperties("<%=reverseAttrName%>", this));
}*/
}
}
@@ -397,303 +429,306 @@
for (ObjectModelAttribute attr : clazz.getAttributes()) {
ObjectModelAttribute reverse = attr.getReverseAttribute();
+ String attrName = attr.getName();
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
+
if (!(attr.isNavigable()
|| hasUnidirectionalRelationOnAbstractType(reverse, model))) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
/*{ /* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#set<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%>)
+ * @see <%=clazzFQN%>#set<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%>)
*)
- public void set<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%> value) {
- <%=attr.getType()%> _oldValue = this.<%=attr.getName()%>;
- fireOnPreWrite("<%=attr.getName()%>", _oldValue, value);
- this.<%=attr.getName()%> = value;
- fireOnPostWrite("<%=attr.getName()%>", _oldValue, value);
+ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%> value) {
+ <%=attrType%> _oldValue = this.<%=attrName%>;
+ fireOnPreWrite("<%=attrName%>", _oldValue, value);
+ this.<%=attrName%> = value;
+ fireOnPostWrite("<%=attrName%>", _oldValue, value);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#get<%=Util.capitalize(attr.getName())%>()
+ * @see <%=clazzFQN%>#get<%=GeneratorUtil.capitalize(attrName)%>()
*)
- public <%=attr.getType()%> get<%=Util.capitalize(attr.getName())%>() {
- fireOnPreRead("<%=attr.getName()%>", <%=attr.getName()%>);
- <%=attr.getType()%> result = this.<%=attr.getName()%>;
- fireOnPostRead("<%=attr.getName()%>", <%=attr.getName()%>);
+ public <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>() {
+ fireOnPreRead("<%=attrName%>", <%=attrName%>);
+ <%=attrType%> result = this.<%=attrName%>;
+ fireOnPostRead("<%=attrName%>", <%=attrName%>);
return result;
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (log.isTraceEnabled()) {
- log.trace("assocAttrName: " + assocAttrName);
- }
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
/*{ /* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#set<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%>)
+ * @see <%=clazzFQN%>#set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%>)
*)
- public void set<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%> association) {
- <%=attr.getAssociationClass().getQualifiedName()%> _oldValue = this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
- fireOnPreWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, association);
- this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> = association;
- fireOnPostWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, association);
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%> association) {
+ <%=assocClassFQN%> _oldValue = this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ fireOnPreWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, association);
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = association;
+ fireOnPostWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, association);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#get<%=Util.capitalize(assocAttrName)%>()
+ * @see <%=clazzFQN%>#get<%=GeneratorUtil.capitalize(assocAttrName)%>()
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>() {
- return <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+ public <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>() {
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}
}*/
}
} else { //NMultiplicity
- String collectionInterface = GeneratorUtil.getNMultiplicityInterfaceType(attr);
- String collectionObject = GeneratorUtil.getNMultiplicityObjectType(attr);
+ String collectionInterface = TopiaGeneratorUtil.getSimpleName(TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr));
+ String collectionObject = TopiaGeneratorUtil.getSimpleName(TopiaGeneratorUtil.getNMultiplicityObjectType(attr));
if (!attr.hasAssociationClass()) { //Méthodes remplacées par des accesseurs sur les classes d'assoc
/*{ /* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#add<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%>)
+ * @see <%=clazzFQN%>#add<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%>)
*)
- public void add<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) {
- fireOnPreWrite("<%=attr.getName()%>", null, <%=attr.getName()%>);
- if (this.<%=attr.getName()%> == null) {
- this.<%=attr.getName()%> = new <%=collectionObject%><<%=attr.getType()%>>();
+ public void add<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%> <%=attrName%>) {
+ fireOnPreWrite("<%=attrName%>", null, <%=attrName%>);
+ if (this.<%=attrName%> == null) {
+ this.<%=attrName%> = new <%=collectionObject%><<%=attrType%>>();
}
}*/
if (reverse != null && (reverse.isNavigable() ||
hasUnidirectionalRelationOnAbstractType(attr, model))) {
- if (!Util.isNMultiplicity(reverse)) {
-/*{ <%=attr.getName()%>.set<%=Util.capitalize(reverse.getName())%>(this);
+ String reverseAttrName = reverse.getName();
+ String reverseAttrType = TopiaGeneratorUtil.getSimpleName(reverse.getType());
+ if (!GeneratorUtil.isNMultiplicity(reverse)) {
+/*{ <%=attrName%>.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(this);
}*/
} else {
-/*{ if (<%=attr.getName()%>.get<%=Util.capitalize(reverse.getName())%>() == null) {
- <%=attr.getName()%>.set<%=Util.capitalize(reverse.getName())%>(new <%=collectionObject%><<%=reverse.getType()%>>());
- }
- <%=attr.getName()%>.get<%=Util.capitalize(reverse.getName())%>().add(this);
+/*{ if (<%=attrName%>.get<%=GeneratorUtil.capitalize(reverseAttrName)%>() == null) {
+ <%=attrName%>.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(new <%=collectionObject%><<%=reverseAttrType%>>());
+ }
+ <%=attrName%>.get<%=GeneratorUtil.capitalize(reverseAttrName)%>().add(this);
}*/
}
}
-/*{ this.<%=attr.getName()%>.add(<%=attr.getName()%>);
- fireOnPostWrite("<%=attr.getName()%>", this.<%=attr.getName()%>.size(), null, <%=attr.getName()%>);
+/*{ this.<%=attrName%>.add(<%=attrName%>);
+ fireOnPostWrite("<%=attrName%>", this.<%=attrName%>.size(), null, <%=attrName%>);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#addAll<%=Util.capitalize(attr.getName())%>(<%=collectionInterface%><<%=attr.getType()%>>)
+ * @see <%=clazzFQN%>#addAll<%=GeneratorUtil.capitalize(attrName)%>(<%=collectionInterface%><<%=attrType%>>)
*)
- public void addAll<%=Util.capitalize(attr.getName())%>(<%=collectionInterface%><<%=attr.getType()%>> values) {
+ public void addAll<%=GeneratorUtil.capitalize(attrName)%>(<%=collectionInterface%><<%=attrType%>> values) {
if (values == null) {
return;
}
- for (<%=attr.getType()%> item : values) {
- add<%=Util.capitalize(attr.getName())%>(item);
+ for (<%=attrType%> item : values) {
+ add<%=GeneratorUtil.capitalize(attrName)%>(item);
}
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#get<%=Util.capitalize(attr.getName())%>ByTopiaId(String)
+ * @see <%=clazzFQN%>#get<%=GeneratorUtil.capitalize(attrName)%>ByTopiaId(String)
*)
- public <%=attr.getType()%> get<%=Util.capitalize(attr.getName())%>ByTopiaId(String topiaId) {
- return org.codelutin.topia.persistence.util.TopiaEntityHelper.getEntityByTopiaId(<%=attr.getName()%>, topiaId);
+ public <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>ByTopiaId(String topiaId) {
+ return org.codelutin.topia.persistence.util.TopiaEntityHelper.getEntityByTopiaId(<%=attrName%>, topiaId);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#set<%=Util.capitalize(attr.getName())%>(<%=collectionInterface%><<%=attr.getType()%>>)
+ * @see <%=clazzFQN%>#set<%=GeneratorUtil.capitalize(attrName)%>(<%=collectionInterface%><<%=attrType%>>)
*)
- public void set<%=Util.capitalize(attr.getName())%>(<%=collectionInterface%><<%=attr.getType()%>> values) {
- <%=collectionInterface%><<%=attr.getType()%>> _oldValue = <%=attr.getName()%>;
- fireOnPreWrite("<%=attr.getName()%>", _oldValue, values);
- <%=attr.getName()%> = values;
- fireOnPostWrite("<%=attr.getName()%>", _oldValue, values);
+ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=collectionInterface%><<%=attrType%>> values) {
+ <%=collectionInterface%><<%=attrType%>> _oldValue = <%=attrName%>;
+ fireOnPreWrite("<%=attrName%>", _oldValue, values);
+ <%=attrName%> = values;
+ fireOnPostWrite("<%=attrName%>", _oldValue, values);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#remove<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%>)
+ * @see <%=clazzFQN%>#remove<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%>)
*)
- public void remove<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%> value) {
- fireOnPreWrite("<%=attr.getName()%>", value, null);
- if ((this.<%=attr.getName()%> == null) || (!this.<%=attr.getName()%>.remove(value))) {
+ public void remove<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%> value) {
+ fireOnPreWrite("<%=attrName%>", value, null);
+ if ((this.<%=attrName%> == null) || (!this.<%=attrName%>.remove(value))) {
throw new IllegalArgumentException("List does not contain given element");
}
}*/
if (reverse != null && (reverse.isNavigable() ||
hasUnidirectionalRelationOnAbstractType(attr, model))) {
- if (!Util.isNMultiplicity(reverse)) {
-/*{ value.set<%=Util.capitalize(reverse.getName())%>(null);
+ String reverseAttrName = reverse.getName();
+ if (!GeneratorUtil.isNMultiplicity(reverse)) {
+/*{ value.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(null);
}*/
} else {
-/*{ value.get<%=Util.capitalize(reverse.getName())%>().remove(this);
+/*{ value.get<%=GeneratorUtil.capitalize(reverseAttrName)%>().remove(this);
}*/
}
}
-/*{ fireOnPostWrite("<%=attr.getName()%>", this.<%=attr.getName()%>.size()+1, value, null);
+/*{ fireOnPostWrite("<%=attrName%>", this.<%=attrName%>.size()+1, value, null);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#clear<%=Util.capitalize(attr.getName())%>()
+ * @see <%=clazzFQN%>#clear<%=GeneratorUtil.capitalize(attrName)%>()
*)
- public void clear<%=Util.capitalize(attr.getName())%>() {
- if (this.<%=attr.getName()%> == null) {
+ public void clear<%=GeneratorUtil.capitalize(attrName)%>() {
+ if (this.<%=attrName%> == null) {
return;
}
}*/
if (reverse != null && (reverse.isNavigable() ||
hasUnidirectionalRelationOnAbstractType(attr, model))) {
-
-/*{ for (<%=attr.getType()%> item : this.<%=attr.getName()%>) {
+ String reverseAttrName = reverse.getName();
+/*{ for (<%=attrType%> item : this.<%=attrName%>) {
}*/
- if (!Util.isNMultiplicity(reverse)) {
-/*{ item.set<%=Util.capitalize(reverse.getName())%>(null);
+ if (!GeneratorUtil.isNMultiplicity(reverse)) {
+/*{ item.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(null);
}*/
} else {
-/*{ item.get<%=Util.capitalize(reverse.getName())%>().remove(this);
+/*{ item.get<%=GeneratorUtil.capitalize(reverseAttrName)%>().remove(this);
}*/
}
/*{ }
}*/
}
-/*{ <%=collectionInterface%><<%=attr.getType()%>> _oldValue = new <%=collectionObject%><<%=attr.getType()%>>(this.<%=attr.getName()%>);
- fireOnPreWrite("<%=attr.getName()%>", _oldValue, this.<%=attr.getName()%>);
- this.<%=attr.getName()%>.clear();
- fireOnPostWrite("<%=attr.getName()%>", _oldValue, this.<%=attr.getName()%>);
+/*{ <%=collectionInterface%><<%=attrType%>> _oldValue = new <%=collectionObject%><<%=attrType%>>(this.<%=attrName%>);
+ fireOnPreWrite("<%=attrName%>", _oldValue, this.<%=attrName%>);
+ this.<%=attrName%>.clear();
+ fireOnPostWrite("<%=attrName%>", _oldValue, this.<%=attrName%>);
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (log.isTraceEnabled()) {
- log.trace("assocAttrName: " + assocAttrName);
- }
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
/*{ /* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#add<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%>)
+ * @see <%=clazzFQN%>#add<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%>)
*)
- public void add<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%> value) {
- fireOnPreWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", null, value);
- if (this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> == null) {
- this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> = new <%=collectionObject%><<%=attr.getAssociationClass().getQualifiedName()%>>();
+ public void add<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%> value) {
+ fireOnPreWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", null, value);
+ if (this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) {
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = new <%=collectionObject%><<%=assocClassFQN%>>();
}
}*/
if (reverse != null && (reverse.isNavigable() ||
hasUnidirectionalRelationOnAbstractType(attr, model))) {
-/*{ value.set<%=Util.capitalize(reverse.getName())%>(this);
+ String reverseAttrName = reverse.getName();
+/*{ value.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(this);
}*/
}
-/*{ this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>.add(value);
- fireOnPostWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>.size(), null, value);
+/*{ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.add(value);
+ fireOnPostWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.size(), null, value);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#get<%=Util.capitalize(attr.getName())%>ByTopiaId(String)
+ * @see <%=clazzFQN%>#get<%=GeneratorUtil.capitalize(attrName)%>ByTopiaId(String)
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>ByTopiaId(String topiaId) {
+ public <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>ByTopiaId(String topiaId) {
return org.codelutin.topia.persistence.util.TopiaEntityHelper.getEntityByTopiaId(<%=assocAttrName%>, topiaId);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#addAll<%=Util.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>>()
+ * @see <%=clazzFQN%>#addAll<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=assocClassFQN%>>()
*)
- public void addAll<%=Util.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>> values) {
+ public void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=assocClassFQN%>> values) {
if (values == null) {
return;
}
- for (<%=attr.getAssociationClass().getQualifiedName()%> item : values) {
- add<%=Util.capitalize(assocAttrName)%>(item);
+ for (<%=assocClassFQN%> item : values) {
+ add<%=GeneratorUtil.capitalize(assocAttrName)%>(item);
}
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#set<%=Util.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>>()
+ * @see <%=clazzFQN%>#set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=assocClassFQN%>>()
*)
- public void set<%=Util.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>> values) {
-// clear<%=Util.capitalize(assocAttrName)%>();
-// addAll<%=Util.capitalize(assocAttrName)%>(values);
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=assocClassFQN%>> values) {
+// clear<%=GeneratorUtil.capitalize(assocAttrName)%>();
+// addAll<%=GeneratorUtil.capitalize(assocAttrName)%>(values);
// FIXME
- <%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>> _oldValue = <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
- fireOnPreWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, values);
- <%=Util.toLowerCaseFirstLetter(assocAttrName)%> = values;
- fireOnPostWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, values);
+ <%=collectionInterface%><<%=assocClassFQN%>> _oldValue = <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ fireOnPreWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, values);
+ <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = values;
+ fireOnPostWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, values);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#remove<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%>)
+ * @see <%=clazzFQN%>#remove<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%>)
*)
- public void remove<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%> value) {
- fireOnPreWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", value, null);
- if ((this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> == null) || (!this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>.remove(value))) {
+ public void remove<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%> value) {
+ fireOnPreWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", value, null);
+ if ((this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) || (!this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.remove(value))) {
throw new IllegalArgumentException("List does not contain given element");
}
}*/
if (reverse != null && (reverse.isNavigable() ||
hasUnidirectionalRelationOnAbstractType(attr, model))) {
-/*{ value.set<%=Util.capitalize(reverse.getName())%>(null);
+ String reverseAttrName = reverse.getName();
+/*{ value.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(null);
}*/
}
-/*{ fireOnPostWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>.size()+1, value, null);
+/*{ fireOnPostWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.size()+1, value, null);
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#clear<%=Util.capitalize(assocAttrName)%>()
+ * @see <%=clazzFQN%>#clear<%=GeneratorUtil.capitalize(assocAttrName)%>()
*)
- public void clear<%=Util.capitalize(assocAttrName)%>() {
- if (this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> == null) {
+ public void clear<%=GeneratorUtil.capitalize(assocAttrName)%>() {
+ if (this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) {
return;
}
}*/
if (reverse != null && (reverse.isNavigable() ||
hasUnidirectionalRelationOnAbstractType(attr, model))) {
-/*{ for (<%=attr.getAssociationClass().getQualifiedName()%> item : this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>) {
- item.set<%=Util.capitalize(reverse.getName())%>(null);
+ String reverseAttrName = reverse.getName();
+/*{ for (<%=assocClassFQN%> item : this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>) {
+ item.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(null);
}
}*/
}
-/*{ <%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>> _oldValue = new <%=collectionObject%><<%=attr.getAssociationClass().getQualifiedName()%>>(this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>);
- fireOnPreWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, null);
- this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>.clear();
- fireOnPostWrite("<%=Util.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, null);
+/*{ <%=collectionInterface%><<%=assocClassFQN%>> _oldValue = new <%=collectionObject%><<%=assocClassFQN%>>(this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>);
+ fireOnPreWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, null);
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.clear();
+ fireOnPostWrite("<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>", _oldValue, null);
}
}*/
}
if (!attr.hasAssociationClass()) {
/*{ /* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#get<%=Util.capitalize(attr.getName())%>()
+ * @see <%=clazzFQN%>#get<%=GeneratorUtil.capitalize(attrName)%>()
*)
- public <%=collectionInterface%><<%=attr.getType()%>> get<%=Util.capitalize(attr.getName())%>() {
- return <%=attr.getName()%>;
+ public <%=collectionInterface%><<%=attrType%>> get<%=GeneratorUtil.capitalize(attrName)%>() {
+ return <%=attrName%>;
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#size<%=Util.capitalize(attr.getName())%>()
+ * @see <%=clazzFQN%>#size<%=GeneratorUtil.capitalize(attrName)%>()
*)
- public int size<%=Util.capitalize(attr.getName())%>() {
- if (<%=attr.getName()%> == null) {
+ public int size<%=GeneratorUtil.capitalize(attrName)%>() {
+ if (<%=attrName%> == null) {
return 0;
}
- return <%=attr.getName()%>.size();
+ return <%=attrName%>.size();
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (log.isTraceEnabled()) {
- log.trace("assocAttrName: " + assocAttrName);
- }
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
/*{ /* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#get<%=Util.capitalize(assocAttrName)%>()
+ * @see <%=clazzFQN%>#get<%=GeneratorUtil.capitalize(assocAttrName)%>()
*)
- public <%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=Util.capitalize(assocAttrName)%>() {
- return <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+ public <%=collectionInterface%><<%=assocClassFQN%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>() {
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#get<%=Util.capitalize(assocAttrName)%>(<%=attr.getType()%>)
+ * @see <%=clazzFQN%>#get<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=attrType%>)
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>(<%=attr.getType()%> value) {
- if (value == null || <%=Util.toLowerCaseFirstLetter(assocAttrName)%> == null) {
+ public <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=attrType%> value) {
+ if (value == null || <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) {
return null;
}
- for (<%=attr.getAssociationClass().getQualifiedName()%> item : <%=Util.toLowerCaseFirstLetter(assocAttrName)%>) {
- if (value.equals(item.get<%=Util.capitalize(attr.getName())%>())) {
+ for (<%=assocClassFQN%> item : <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>) {
+ if (value.equals(item.get<%=GeneratorUtil.capitalize(attrName)%>())) {
return item;
}
}
@@ -701,13 +736,13 @@
}
/* (non-Javadoc)
- * @see <%=clazz.getQualifiedName()%>#size<%=Util.capitalize(assocAttrName)%>()
+ * @see <%=clazzFQN%>#size<%=GeneratorUtil.capitalize(assocAttrName)%>()
*)
- public int size<%=Util.capitalize(assocAttrName)%>() {
- if (<%=Util.toLowerCaseFirstLetter(assocAttrName)%> == null) {
+ public int size<%=GeneratorUtil.capitalize(assocAttrName)%>() {
+ if (<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> == null) {
return 0;
}
- return <%=Util.toLowerCaseFirstLetter(assocAttrName)%>.size();
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>.size();
}
}*/
@@ -720,15 +755,15 @@
ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz;
for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
if (attr != null) {
- String type = attr.getType();
- String name = attr.getName();
- generateAssociationAccessors(output, name, type);
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
+ String attrName = attr.getName();
+ generateAssociationAccessors(output, attrName, attrType);
// //Ne sert plus à rien normalement avec la navigabilité
// ObjectModelAttribute reverse = attr.getReverseAttribute();
// if (reverse == null) {
-// type = ((ObjectModelClassifier)attr.getDeclaringElement()).getQualifiedName();
-// name = attr.getDeclaringElement().getName();
-// generateAssociationAccessors(output, name, type);
+// attrType = ((ObjectModelClassifier)attr.getDeclaringElement()).getQualifiedName();
+// attrName = attr.getDeclaringElement().getName();
+// generateAssociationAccessors(output, attrName, attrType);
// }
}
}
@@ -746,24 +781,25 @@
if (model.hasClass(attr.getType())) {
attrEntity = model.getClass(attr.getType());
}
- boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY));
+ boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY));
ObjectModelAttribute reverse = attr.getReverseAttribute();
if ((isEntity && (reverse == null || !reverse.isNavigable()) && !attr.hasAssociationClass()) || (!isEntity)) {
-/*{ append("<%=attr.getName()%>", this.<%=attr.getName()%>).
+ String attrName = attr.getName();
+/*{ append("<%=attrName%>", this.<%=attrName%>).
}*/
}
}
-/*{ toString();
+/*{ toString();
return result;
}
}*/
- String i18nPrefix = GeneratorUtil.getI18nPrefix(clazz, model);
+ String i18nPrefix = TopiaGeneratorUtil.getI18nPrefix(clazz, model);
if (i18nPrefix != null) {
// generate i18n prefix
generateI18n(output, i18nPrefix, clazz);
}
/*{
-} //<%=clazz.getName()%>Abstract
+} //<%=clazzName%>Abstract
}*/
}
@@ -771,18 +807,18 @@
/*{ /**
* @param value La valeur de l'attribut <%=name%> à positionner.
*)
- public void set<%=Util.capitalize(name)%>(<%=type%> value) {
- <%=type%> _oldValue = this.<%=Util.toLowerCaseFirstLetter(name)%>;
+ public void set<%=GeneratorUtil.capitalize(name)%>(<%=type%> value) {
+ <%=type%> _oldValue = this.<%=GeneratorUtil.toLowerCaseFirstLetter(name)%>;
fireOnPreWrite("<%=name%>", _oldValue, value);
- this.<%=Util.toLowerCaseFirstLetter(name)%> = value;
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(name)%> = value;
fireOnPostWrite("<%=name%>", _oldValue, value);
}
/**
* @return La valeur de l'attribut <%=name%>.
*)
- public <%=type%> get<%=Util.capitalize(name)%>() {
- return <%=Util.toLowerCaseFirstLetter(name)%>;
+ public <%=type%> get<%=GeneratorUtil.capitalize(name)%>() {
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(name)%>;
}
}*/
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityDTOGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityDTOGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityDTOGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -29,8 +29,8 @@
package org.codelutin.topia.generator;
-import static org.codelutin.topia.generator.GeneratorUtil.TAG_ANNOTATION;
-import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.TAG_ANNOTATION;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
import java.io.File;
import java.io.IOException;
@@ -40,7 +40,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
@@ -70,45 +70,46 @@
public boolean isEntity(String type) {
ObjectModelClassifier clazz = model.getClassifier(type);
- return clazz != null && clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY);
+ return clazz != null && clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY);
}
@Override
public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
+ String clazzName = clazz.getName();
/*{package <%=clazz.getPackageName()%>;
import org.apache.commons.lang.builder.ToStringBuilder;
import java.beans.PropertyChangeListener;
/**
- * Implantation DTO pour l'entité <%=Util.capitalize(clazz.getName())%>.
+ * Implantation DTO pour l'entité <%=GeneratorUtil.capitalize(clazzName)%>.
*)
-public class <%=clazz.getName()%>DTO }*/
+}*/
String extendClass = "";
- for (Iterator i=clazz.getSuperclasses().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (Iterator<ObjectModelClass> i=clazz.getSuperclasses().iterator(); i.hasNext();) {
+ ObjectModelClass parent = i.next();
extendClass += parent.getQualifiedName() + "DTO";
if (i.hasNext()) {
extendClass += ", ";
}
}
if (extendClass.length() > 0) {
- /*{extends <%=extendClass%> }*/
+ extendClass = "extends " + extendClass + " ";
}
- /*{implements java.io.Serializable {
+/*{public class <%=clazzName%>DTO <%=extendClass%>implements java.io.Serializable {
}*/
- String svUID = GeneratorUtil.findTagValue("dto-serialVersionUID", clazz, model);
+ String svUID = TopiaGeneratorUtil.findTagValue("dto-serialVersionUID", clazz, model);
if (svUID != null) {
/*{ public static final long serialVersionUID = <%=svUID%>;
@@ -125,36 +126,43 @@
|| attr.hasAssociationClass())) {
continue;
}
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ /**
* <%=attr.getDocumentation()%>
*)
}*/
}
- String annotation = attr.getTagValue(TAG_ANNOTATION);
- if (annotation != null && annotation.length() > 0) {
+ if (attr.hasTagValue(TAG_ANNOTATION)) {
+ String annotation = attr.getTagValue(TAG_ANNOTATION);
/*{ <%=annotation%>
}*/
}
- if (!Util.isNMultiplicity(attr)) {
- if (!attr.hasAssociationClass()) {
-/*{ <%=attr.getVisibility()%> <%=attr.getType()%><%=(isEntity(attr.getType())?"DTO":"")%> <%=attr.getName()%>;
+ String attrVisibility = attr.getVisibility();
+ if (!attr.hasAssociationClass()) {
+ String attrType = attr.getType();
+ String attrName = attr.getName();
+ if (isEntity(attrType)) {
+ attrType += "DTO";
+ }
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+/*{ <%=attrVisibility%> <%=attrType%> <%=attrName%>;
+
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ <%=attr.getVisibility()%> <%=attr.getAssociationClass().getQualifiedName()%>DTO <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+/*{ <%=attrVisibility%> <%=attrType%>[] <%=attrName%>;
}*/
}
} else {
- if (!attr.hasAssociationClass()) {
-/*{ <%=attr.getVisibility()%> <%=attr.getType()%><%=(isEntity(attr.getType())?"DTO":"")%>[] <%=attr.getName()%>;
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+/*{ <%=attrVisibility%> <%=assocClassFQN%>DTO <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
-/*{ <%=attr.getVisibility()%> <%=attr.getAssociationClass().getQualifiedName()%>DTO[] <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+/*{ <%=attrVisibility%> <%=assocClassFQN%>DTO[] <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}*/
}
@@ -164,10 +172,15 @@
//Déclaration des attributs d'une classe d'associations
if (clazz instanceof ObjectModelAssociationClass) {
ObjectModelAssociationClass assoc = (ObjectModelAssociationClass)clazz;
- for (Object o : assoc.getParticipantsAttributes()) {
- ObjectModelAttribute attr = (ObjectModelAttribute) o;
+ for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
if (attr != null) {
-/*{ <%=attr.getVisibility()%> <%=attr.getType()%><%=(isEntity(attr.getType())?"DTO":"")%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>;
+ String attrVisibility = attr.getVisibility();
+ String attrType = attr.getType();
+ String attrName = attr.getName();
+ if (isEntity(attrType)) {
+ attrType += "DTO";
+ }
+/*{ <%=attrVisibility%> <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>;
}*/
}
@@ -180,9 +193,9 @@
}*/
/*{ /**
- * Constructeur de <%=clazz.getName()%>DTO par défaut.
+ * Constructeur de <%=clazzName%>DTO par défaut.
*)
- public <%=clazz.getName()%>DTO() { p = new java.beans.PropertyChangeSupport(this); }
+ public <%=clazzName%>DTO() { p = new java.beans.PropertyChangeSupport(this); }
public void addPropertyChangeListener(PropertyChangeListener listener) {
p.addPropertyChangeListener(listener);
@@ -202,84 +215,75 @@
}*/
- for (Object o : clazz.getAttributes()) {
- ObjectModelAttribute attr = (ObjectModelAttribute) o;
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
ObjectModelAttribute reverse = attr.getReverseAttribute();
if (!(attr.isNavigable()
|| hasUnidirectionalRelationOnAbstractType(reverse, model))) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
- if (!attr.hasAssociationClass()) {
-/*{ public void set<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%><%=(isEntity(attr.getType())?"DTO":"")%> value) {
- <%=attr.getType()%><%=(isEntity(attr.getType())?"DTO":"")%> oldValue = this.<%=attr.getName()%>;
- this.<%=attr.getName()%> = value;
- p.firePropertyChange("<%=attr.getName()%>", oldValue, value);
+ String attrName = attr.getName();
+
+ if (!attr.hasAssociationClass()) {
+ String attrType = attr.getType();
+ if (isEntity(attrType)) {
+ attrType += "DTO";
+ }
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+/*{ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%> value) {
+ <%=attrType%> oldValue = this.<%=attrName%>;
+ this.<%=attrName%> = value;
+ p.firePropertyChange("<%=attrName%>", oldValue, value);
}
- public <%=attr.getType()%><%=(isEntity(attr.getType())?"DTO":"")%> get<%=Util.capitalize(attr.getName())%>() {
- return <%=attr.getName()%>;
+ public <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>() {
+ return <%=attrName%>;
}
}*/
- } else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (log.isTraceEnabled()) {
- log.trace("assocAttrName: " + assocAttrName);
- }
-/*{ public void set<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%>DTO association) {
- <%=attr.getAssociationClass().getQualifiedName()%>DTO oldAssocation= this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
- this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> = association;
- p.firePropertyChange("<%=attr.getName()%>", oldAssocation, assocation);
+ } else {
+/*{ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%>[] values) {
+ <%=attrType%>[] oldValues = this.<%=attrName%>;
+ this.<%=attrName%> = values;
+ p.firePropertyChange("<%=attrName%>", oldValues, values);
}
- public <%=attr.getAssociationClass().getQualifiedName()%>DTO get<%=Util.capitalize(assocAttrName)%>() {
- return <%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+ public <%=attrType%>[] get<%=GeneratorUtil.capitalize(attrName)%>() {
+ return this.<%=attrName%>;
}
}*/
- }
- } else { //NMultiplicity
- if (!attr.hasAssociationClass()) { //Méthodes remplacées par des accesseurs sur les classes d'assoc
-/*{ public void set<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%><%=(isEntity(attr.getType())?"DTO":"")%>[] values) {
- <%=attr.getType()%><%=(isEntity(attr.getType())?"DTO":"")%>[] oldValues = this.<%=attr.getName()%>;
- this.<%=attr.getName()%> = values;
- p.firePropertyChange("<%=attr.getName()%>", oldValues, values);
+ }
+ } else {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+/*{ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%>DTO association) {
+ <%=assocClassFQN%>DTO oldAssocation= this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = association;
+ p.firePropertyChange("<%=attrName%>", oldAssocation, assocation);
}
-}*/
- } else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (log.isTraceEnabled()) {
- log.trace("assocAttrName: " + assocAttrName);
- }
-/*{ public void set<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%>DTO[] values) {
- <%=attr.getAssociationClass().getQualifiedName()%>DTO[] oldValues = this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
- this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%> = values;
- p.firePropertyChange("<%=attr.getName()%>", oldValues, values);
+ public <%=assocClassFQN%>DTO get<%=GeneratorUtil.capitalize(assocAttrName)%>() {
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}
}*/
- }
- if (!attr.hasAssociationClass()) {
-/*{ public <%=attr.getType()%><%=(isEntity(attr.getType())?"DTO":"")%>[] get<%=Util.capitalize(attr.getName())%>() {
- return this.<%=attr.getName()%>;
+ } else {
+/*{ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%>DTO[] values) {
+ <%=assocClassFQN%>DTO[] oldValues = this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = values;
+ p.firePropertyChange("<%=attrName%>", oldValues, values);
}
-}*/
- } else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (log.isTraceEnabled()) {
- log.trace("assocAttrName: " + assocAttrName);
- }
-/*{ public <%=attr.getAssociationClass().getQualifiedName()%>DTO[] get<%=Util.capitalize(assocAttrName)%>() {
- return this.<%=Util.toLowerCaseFirstLetter(assocAttrName)%>;
+ public <%=assocClassFQN%>DTO[] get<%=GeneratorUtil.capitalize(assocAttrName)%>() {
+ return this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
}
}*/
- }
+ }
}
+
}
/*{
@@ -294,10 +298,11 @@
if (model.hasClass(attr.getType())) {
attrEntity = model.getClass(attr.getType());
}
- boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY));
+ boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY));
ObjectModelAttribute reverse = attr.getReverseAttribute();
if ((isEntity && (reverse == null || !reverse.isNavigable()) && !attr.hasAssociationClass()) || (!isEntity)) {
-/*{ append("<%=attr.getName()%>", this.<%=attr.getName()%>).
+ String attrName = attr.getName();
+/*{ append("<%=attrName%>", this.<%=attrName%>).
}*/
}
}
@@ -305,8 +310,23 @@
return result;
}
-} //<%=clazz.getName()%>DTO
+} //<%=clazzName%>DTO
}*/
}
+ //TODO Check wether this method could be used to generate getter and setters
+ protected void generateNormalGetterAndSetterWithPropertyChangeSupport(Writer output, String attrType, String attrName) throws IOException {
+/*{ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%> value) {
+ <%=attrType%> _oldValue = this.<%=attrName%>;
+ this.<%=attrName%> = value;
+ p.firePropertyChange("<%=attrName%>", _oldValue, value);
+ }
+
+ public <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>() {
+ return this.<%=attrName%>;
+ }
+
+}*/
+ }
+
} //EntityDTOGenerator
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityEnumGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityEnumGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityEnumGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -65,13 +65,13 @@
@Override
public void generateFromModel(Writer output, ObjectModel model)
throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
String modelName = model.getName();
String className = modelName + "EntityEnum";
if (log.isDebugEnabled()) {
log.debug("generating " + className);
}
- if (GeneratorUtil.notEmpty(copyright)) {
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
@@ -89,23 +89,23 @@
@SuppressWarnings({"unchecked"})
+public enum <%=className%> {
}*/
-
-/*{public enum <%=className%> {
-}*/
- List<ObjectModelClass> classes = GeneratorUtil.getEntityClasses(model, true);
+ List<ObjectModelClass> classes = TopiaGeneratorUtil.getEntityClasses(model, true);
if (classes.isEmpty()) {
/*{
TopiaEntity(TopiaEntity.class);
}*/
} else {
- for (Iterator i = classes.iterator(); i.hasNext();) {
- ObjectModelClass clazz = (ObjectModelClass) i.next();
+ for (Iterator<ObjectModelClass> i = classes.iterator(); i.hasNext();) {
+ ObjectModelClass clazz = i.next();
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
boolean hasNext = i.hasNext();
if (log.isDebugEnabled()) {
- log.debug("generating entry " + clazz + " (hasNext:" + hasNext + ")");
+ log.debug("generating entry " + clazzFQN + " (hasNext:" + hasNext + ")");
}
-/*{ <%=clazz.getName()%>(<%=clazz.getQualifiedName()%>.class)<%=(hasNext?",":";")%>
+/*{ <%=clazzName%>(<%=clazzFQN%>.class)<%=(hasNext?",":";")%>
}*/
}
}
@@ -302,7 +302,7 @@
return entry.findAllContainsProperties(ctxt, propertyName, values, others);
}
-}
+} //<%=className%>
}*/
}
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -35,15 +35,14 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.Generator;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
-import static org.codelutin.topia.generator.GeneratorUtil.PERSISTENCE_TYPE_HIBERNATE;
-import static org.codelutin.topia.generator.GeneratorUtil.STEREOTYPE_ENTITY;
-import static org.codelutin.topia.generator.GeneratorUtil.TAG_ACCESS;
-import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType;
-import static org.codelutin.topia.generator.GeneratorUtil.notEmpty;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.PERSISTENCE_TYPE_HIBERNATE;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.STEREOTYPE_ENTITY;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.TAG_ACCESS;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
import java.io.File;
import java.io.IOException;
@@ -78,13 +77,13 @@
@Override
public String getFilenameForClass(ObjectModelClass clazz) {
- String DOName = GeneratorUtil.getDOType(clazz, model);
+ String DOName = TopiaGeneratorUtil.getDOType(clazz, model);
return DOName.replace('.', File.separatorChar) + ".hbm.xml";
}
@Override
public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- String persistenceType = GeneratorUtil.getPersistenceType(clazz);
+ String persistenceType = TopiaGeneratorUtil.getPersistenceType(clazz);
if (!clazz.hasStereotype(STEREOTYPE_ENTITY) && PERSISTENCE_TYPE_HIBERNATE.equals(persistenceType)) {
return;
}
@@ -97,43 +96,37 @@
List<ObjectModelAttribute> naturalAttributes = new ArrayList<ObjectModelAttribute>();
// la liste des autres attributs
List<ObjectModelAttribute> noneNaturalAttributes = new ArrayList<ObjectModelAttribute>();
+
+ String clazzDOType = TopiaGeneratorUtil.getDOType(clazz, model);
+ String tableName = TopiaGeneratorUtil.getDBName(clazz);
+ String isAbstract = clazz.isAbstract()?"true":"false";
+ String clazzFQN = clazz.getQualifiedName();
+
+ String optionalAttributes = "";
+ String schema = TopiaGeneratorUtil.getSchemaName(clazz, model);
+ if (schema != null) {
+ optionalAttributes += "schema=\"" + schema + "\" ";
+ }
+
if (haveSuper) {
ObjectModelClass superClass = clazz.getSuperclasses().iterator().next();
String superClassname = superClass.getQualifiedName();
- if (log.isDebugEnabled()) {log.debug("superClass for " + clazz.getQualifiedName() + " is " + superClassname);}
-/*{ <union-subclass }*/
-/*{name="<%=GeneratorUtil.getDOType(clazz, model)%>" }*/
-/*{extends="<%=GeneratorUtil.getDOType(superClassname, model)%>" }*/
-/*{table="<%=GeneratorUtil.getDBName(clazz)%>" }*/
- String schema = GeneratorUtil.getSchemaName(clazz, model);
- if (schema != null) {
-/*{schema="<%=schema%>" }*/
+ if (log.isDebugEnabled()) {
+ log.debug("superClass for " + clazz.getQualifiedName() + " is " + superClassname);
}
-/*{node="<%=GeneratorUtil.getDOType(clazz, model)%>" }*/
-/*{abstract="<%=(clazz.isAbstract()?"true":"false")%>" }*/
- //On précise au proxy de quelle interface hérite l'objet
-/*{proxy="<%=clazz.getQualifiedName()%>" }*/
-/*{>
+ String superClassDOType = TopiaGeneratorUtil.getDOType(superClassname, model);
+ //On précise au proxy de quelle interface hérite l'objet
+
+/*{ <union-subclass name="<%=clazzDOType%>" extends="<%=superClassDOType%>" table="<%=tableName%>" node="<%=clazzDOType%>" abstract="<%=isAbstract%>" proxy="<%=clazzFQN%>" <%=optionalAttributes%>>
<!--key column="topiaId"/-->
}*/
} else {
-/*{ <class }*/
-/*{name="<%=GeneratorUtil.getDOType(clazz, model)%>" }*/
-/*{table="<%=GeneratorUtil.getDBName(clazz)%>" }*/
- String schema = GeneratorUtil.getSchemaName(clazz, model);
- if (schema != null) {
-/*{schema="<%=schema%>" }*/
- }
-/*{node="<%=GeneratorUtil.getDOType(clazz, model)%>" }*/
-/*{abstract="<%=(clazz.isAbstract()?"true":"false")%>" }*/
- //On précise au proxy de quelle interface hérite l'objet
-/*{proxy="<%=clazz.getQualifiedName()%>" }*/
-/*{>
+/*{ <class name="<%=clazzDOType%>" table="<%=tableName%>" node="<%=clazzDOType%>" abstract="<%=isAbstract%>" proxy="<%=clazzFQN%>" <%=optionalAttributes%>>
<id name="topiaId" type="string" length="255" node="@topiaId"/>
}*/
// on detecte les attributs des clef metiers
for (ObjectModelAttribute attr : clazz.getAttributes()) {
- if (GeneratorUtil.isNaturalId(attr)) {
+ if (TopiaGeneratorUtil.isNaturalId(attr)) {
// attribut metier
naturalAttributes.add(attr);
} else {
@@ -143,14 +136,14 @@
}
if (!naturalAttributes.isEmpty()) {
// generation de la clef metier
- boolean mutable = GeneratorUtil.isNaturalIdMutable(clazz);
+ boolean mutable = TopiaGeneratorUtil.isNaturalIdMutable(clazz);
String mutableStr = mutable ? " mutable=\"true\"" : "";
if (log.isDebugEnabled()) {
log.debug("natural-id detected for class " + clazz.getName() + " (" + mutableStr + ") attributes : " + naturalAttributes);
}
/*{ <natural-id<%=mutableStr%>>
}*/
- generateAttributes(output, clazz, naturalAttributes," ");
+ generateAttributes(output, clazz, naturalAttributes, " ");
/*{ </natural-id>
}*/
}
@@ -158,8 +151,9 @@
<property name="topiaCreateDate" type="date" node="@topiaCreateDate"/>
}*/
}
- generateAttributes(output, clazz, noneNaturalAttributes,"");
+ generateAttributes(output, clazz, noneNaturalAttributes, "");
+
if (haveSuper) {
/*{ </union-subclass>
}*/
@@ -171,7 +165,7 @@
}*/
}
- protected void generateAttributes(Writer output, ObjectModelClass clazz, List<ObjectModelAttribute> attributes,String prefix) throws IOException {
+ protected void generateAttributes(Writer output, ObjectModelClass clazz, List<ObjectModelAttribute> attributes, String prefix) throws IOException {
for (ObjectModelAttribute attr : attributes) {
ObjectModelAttribute reverse = attr.getReverseAttribute();
@@ -181,9 +175,9 @@
if (attr.isNavigable()
|| hasUnidirectionalRelationOnAbstractType(reverse, model)
|| attr.hasAssociationClass()) {
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (attr.getClassifier() != null && attr.getClassifier().hasStereotype(STEREOTYPE_ENTITY)) {
- if (Util.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) {
+ if (GeneratorUtil.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) {
generateHibernateManyToOne(output, attr, prefix);
} else {
generateHibernateOneToOne(output, attr, prefix);
@@ -193,7 +187,7 @@
}
} else {
if (attr.getClassifier() != null && attr.getClassifier().hasStereotype(STEREOTYPE_ENTITY)) {
- if (Util.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) {
+ if (GeneratorUtil.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) {
generateHibernateManyToMany(output, attr, prefix);
} else {
generateHibernateOneToMany(output, attr, prefix);
@@ -214,16 +208,14 @@
// Note(poussin) pour moi quoi qu'il arrive sur la classe d'association il faut
// un many-to-one, sinon on a des problemes.
// if ((!attr.getReverseAttribute().isNavigable()) || !Util.isNMultiplicity(attr.getReverseAttribute())) {
-// / *{ <one-to-one name="<%=getName(attr, true)%>" class="<%=getType(attr, true)%>"<%=(GeneratorUtil.notEmpty(attr.getTagValue(GeneratorUtil.TAG_LENGTH))?(" length=\"" + attr.getTagValue(GeneratorUtil.TAG_LENGTH) + "\""):"")%><%=(attr.isComposite()?" cascade=\"delete\"":"")%>/>
+// / *{ <one-to-one name="<%=getName(attr, true)%>" class="<%=getType(attr, true)%>"<%=(TopiaGeneratorUtil.notEmpty(attr.getTagValue(TopiaGeneratorUtil.TAG_LENGTH))?(" length=\"" + attr.getTagValue(TopiaGeneratorUtil.TAG_LENGTH) + "\""):"")%><%=(attr.isComposite()?" cascade=\"delete\"":"")%>/>
// } */
// } else {
- String notNull = attr.getTagValue(GeneratorUtil.TAG_NOT_NULL);
- if (notEmpty(notNull)) {
- notNull = " not-null=\""+notNull.trim()+"\"";
- } else {
- notNull="";
- }
-/*{<%=prefix%> <many-to-one name="<%=getName(attr, true)%>" class="<%=getType(attr, true)%>" column="<%=GeneratorUtil.getDBName(attr)%>" node="<%=getName(attr, true)%>/@topiaId" embed-xml="false"<%=notNull%>/>
+ String notNull = " " + generateFromTagValue(attr, TopiaGeneratorUtil.TAG_NOT_NULL, "not-null");
+ String attrName = getName(attr, true);
+ String attrType = getType(attr, true);
+ String attrColumn = TopiaGeneratorUtil.getDBName(attr);
+/*{<%=prefix%> <many-to-one name="<%=attrName%>" class="<%=attrType%>" column="<%=attrColumn%>" node="<%=attrName%>/@topiaId" embed-xml="false" <%=notNull%>/>
}*/
// }
//Ne sert plus grâce à l'utilisation de la navigabilité
@@ -242,16 +234,16 @@
}
}
}
+ }
- }
protected String getName(ObjectModelAttribute attr) {
return getName(attr, false);
}
protected String getName(ObjectModelAttribute attr, boolean isAssoc) {
- String result = Util.toLowerCaseFirstLetter(attr.getName());
+ String result = GeneratorUtil.toLowerCaseFirstLetter(attr.getName());
if (attr.hasAssociationClass() && !isAssoc) {
- result = GeneratorUtil.getAssocAttrName(attr);
+ result = TopiaGeneratorUtil.getAssocAttrName(attr);
}
return result;
}
@@ -262,7 +254,7 @@
protected String getType(ObjectModelAttribute attr, boolean isAssoc) {
String type = attr.getType();
- if (GeneratorUtil.notEmpty(model.getTagValue(type))) {
+ if (TopiaGeneratorUtil.notEmpty(model.getTagValue(type))) {
String typeString = model.getTagValue(type);
int bracketIndex = typeString.indexOf('(');
if (bracketIndex != -1) {
@@ -282,58 +274,64 @@
if (attr.hasAssociationClass() && !isAssoc) {
type = attr.getAssociationClass().getQualifiedName();
}
- return GeneratorUtil.getDOType(type, model);
+ return TopiaGeneratorUtil.getDOType(type, model);
}
protected void generateHibernateProperty(Writer output, ObjectModelAttribute attr, String prefix) throws IOException {
- String type = getType(attr);
- if (type.trim().endsWith("[]")) {
- type = type.trim().substring(0, type.trim().length()-2);
-/*{<%=prefix%> <primitive-array name="<%=getName(attr)%>" table="<%=GeneratorUtil.getDBName(attr.getDeclaringElement()) + "_" + getName(attr)%>" }*/
- String accessField = attr.getTagValue(TAG_ACCESS);
- if (notEmpty(accessField)) {
-/*{access="<%=accessField%>" }*/
- } else {
-/*{access="field" }*/
- }
- String schema = GeneratorUtil.getSchemaName(attr, model);
+ String attrType = getType(attr);
+
+ String accessField = "field";
+ if (attr.hasTagValue(TAG_ACCESS)) {
+ accessField = attr.getTagValue(TAG_ACCESS);
+ }
+ String attrName = attr.getName();
+ String declaringElementDBName = TopiaGeneratorUtil.getDBName(attr.getDeclaringElement());
+ String tableName = declaringElementDBName + "_" + attrName;
+
+ if (attrType.trim().endsWith("[]")) {
+ attrType = attrType.trim().substring(0, attrType.trim().length()-2);
+
+ String optionalAttributes = "";
+ String schema = TopiaGeneratorUtil.getSchemaName(attr, model);
if (schema != null) {
-/*{schema="<%=schema%>" }*/
+ optionalAttributes += "schema=\"" + schema + "\" ";
}
+
if (attr.isIndexed()) {
-/*{index="<%=GeneratorUtil.getDBName(attr.getDeclaringElement()) + "_" + getName(attr)%>_idx" }*/
+ String indexName = tableName + "_idx";
+ optionalAttributes += "index=\"" + indexName + "\" ";
}
-/*{>
-<%=prefix%> <key column="<%=GeneratorUtil.getDBName(attr.getDeclaringElement())%>"/>
-<%=prefix%> <list-index column="<%=getName(attr)%>_idx"/>
-<%=prefix%> <element type="<%=type%>"/>
+
+/*{<%=prefix%> <primitive-array name="<%=attrName%>" table="<%=tableName%>" access="<%=accessField%>" <%=optionalAttributes%>>
+<%=prefix%> <key column="<%=declaringElementDBName%>"/>
+<%=prefix%> <list-index column="<%=attrName%>_idx"/>
+<%=prefix%> <element type="<%=attrType%>"/>
<%=prefix%> </primitive-array>
}*/
} else {
-/*{<%=prefix%> <property name="<%=getName(attr)%>" type="<%=type%>" }*/
- String accessField = attr.getTagValue(TAG_ACCESS);
- if (notEmpty(accessField)) {
-/*{access="<%=accessField%>" }*/
- } else {
-/*{access="field" }*/
- }
+ String optionalAttributes = "";
if (attr.isIndexed()) {
-/*{index="<%=GeneratorUtil.getDBName(attr.getDeclaringElement()) + "_" + getName(attr)%>_idx" }*/
+ String indexName = tableName + "_idx";
+ optionalAttributes += "index=\"" + indexName + "\"";
}
- String notNull = attr.getTagValue(GeneratorUtil.TAG_NOT_NULL);
- if (notNull != null) {
-/*{ not-null="<%=notNull.trim()%>" }*/
- }
- String[] columnNames = this.columnNamesMap.get(type);
+ optionalAttributes += generateFromTagValue(attr, TopiaGeneratorUtil.TAG_NOT_NULL, "not-null");
+/*{<%=prefix%> <property name="<%=attrName%>" type="<%=attrType%>" access="<%=accessField%>" }*/
+ optionalAttributes = optionalAttributes.trim();
+ String[] columnNames = this.columnNamesMap.get(attrType);
if (columnNames == null || columnNames.length == 0) {
-/*{column="<%=GeneratorUtil.getDBName(attr)%>"<%=(GeneratorUtil.notEmpty(attr.getTagValue(GeneratorUtil.TAG_LENGTH))?(" length=\"" + attr.getTagValue(GeneratorUtil.TAG_LENGTH) + "\""):"")%> node="<%=getName(attr)%>"/>
+ optionalAttributes += generateFromTagValue(attr, TopiaGeneratorUtil.TAG_LENGTH, "length");
+ String attrColumn = TopiaGeneratorUtil.getDBName(attr);
+ optionalAttributes = optionalAttributes.trim();
+ if (!optionalAttributes.isEmpty())
+ optionalAttributes = " " + optionalAttributes;
+/*{column="<%=attrColumn%>" node="<%=attrName%>"<%=optionalAttributes%>/>
}*/
} else {
-/*{>
+/*{<%=optionalAttributes%>>
}*/
for (String columnName : columnNames) {
- columnName = columnName.trim();
-/*{<%=prefix%> <column name="<%=getName(attr) + "_" + columnName%>"/>
+ columnName = attrName + "_" + columnName.trim();
+/*{<%=prefix%> <column name="<%=columnName%>"/>
}*/
}
/*{<%=prefix%> </property>
@@ -345,7 +343,7 @@
protected void generateHibernateOneToOne(Writer output, ObjectModelAttribute attr, String prefix) throws IOException {
generateHibernateManyToOne(output, attr, true, prefix);
// boolean accessField = hasUnidirectionalRelationOnAbstractType(attr.getReverseAttribute(), model);
-/// *{ <one-to-one name="<%=getName(attr)%>" class="<%=getType(attr)%>"<%=(GeneratorUtil.notEmpty(attr.getTagValue(GeneratorUtil.TAG_LENGTH))?(" length=\"" + attr.getTagValue(GeneratorUtil.TAG_LENGTH) + "\""):"")%><%=((attr.isComposite() || attr.hasAssociationClass())?" cascade=\"delete\"":"")%><%=((accessField)?" access=\"field\"":"")%> node="<%=getName(attr)%>/@topiaId" embed-xml="false"/>
+/// *{ <one-to-one name="<%=getName(attr)%>" class="<%=getType(attr)%>"<%=(TopiaGeneratorUtil.notEmpty(attr.getTagValue(GeneratorUtil.TAG_LENGTH))?(" length=\"" + attr.getTagValue(GeneratorUtil.TAG_LENGTH) + "\""):"")%><%=((attr.isComposite() || attr.hasAssociationClass())?" cascade=\"delete\"":"")%><%=((accessField)?" access=\"field\"":"")%> node="<%=getName(attr)%>/@topiaId" embed-xml="false"/>
//} */
}
@@ -353,68 +351,81 @@
boolean needsIndex = attr.isIndexed();
boolean isInverse = attr.getReverseAttribute().isNavigable();
isInverse |= hasUnidirectionalRelationOnAbstractType(attr, model);
- String orderBy = attr.getTagValue(GeneratorUtil.TAG_ORDER_BY);
- if (orderBy == null) {
- orderBy = "";
- } else {
- orderBy = " order-by=\"" + orderBy + "\"";
- }
+ String attrName = getName(attr);
+ String attrType = getType(attr);
+ String reverseAttrDBName = TopiaGeneratorUtil.getReverseDBName(attr);
+ String orderBy = generateFromTagValue(attr, TopiaGeneratorUtil.TAG_ORDER_BY, "order-by");
+
String cascade = "";
if (attr.isComposite() || attr.hasAssociationClass()) {
- cascade += " cascade=\"all,delete-orphan\"";
+ cascade += "cascade=\"all,delete-orphan\" ";
}
- String lazy = " lazy=\"";
- if (notEmpty(attr.getTagValue(GeneratorUtil.TAG_LAZY))){
- lazy += attr.getTagValue(GeneratorUtil.TAG_LAZY);
- }
- else {
- lazy += "true";
- }
- lazy += "\"";
+ String lazy = generateFromTagValue(attr, TopiaGeneratorUtil.TAG_LAZY, "lazy", "true");
- String fetch = "";
- if (notEmpty(attr.getTagValue(GeneratorUtil.TAG_FETCH))){
- fetch = " fetch=\"" + attr.getTagValue(GeneratorUtil.TAG_FETCH) + "\"";
+ String fetch = generateFromTagValue(attr, TopiaGeneratorUtil.TAG_FETCH, "fetch");
+
+ String collType = TopiaGeneratorUtil.getNMultiplicityHibernateType(attr);
+ String inverse = "";
+ if (isInverse) {
+ inverse = "inverse=\"true\" ";
}
-
- String collType = GeneratorUtil.getNMultiplicityHibernateType(attr);
- if (!needsIndex) {
- //fixme pour le moment, on ne calcule pas si on doit autoriser le embed-xml à true
- // on le positionne manuellement
- //TC-20090115 embed-xml wasat true but nobody could tellme why
-/*{<%=prefix%> <<%=collType%> name="<%=getName(attr)%>"<%=orderBy%><%=((!isInverse)?"":" inverse=\"true\"")%><%=fetch%><%=lazy%><%=cascade%> node="<%=getName(attr)%>" embed-xml="false">
-<%=prefix%> <key column="<%=GeneratorUtil.getReverseDBName(attr)%>"/>
-<%=prefix%> <one-to-many class="<%=getType(attr)%>" node="topiaId" embed-xml="false"/>
+ if (needsIndex) {
+/*{<%=prefix%> <<%=collType%> name="<%=attrName%>" <%=inverse%><%=lazy%><%=cascade%>node="<%=attrName%>" embed-xml="false">
+<%=prefix%> <key column="<%=reverseAttrDBName%>"/>
+<%=prefix%> <list-index column="<%=reverseAttrDBName%>_idx"/>
+<%=prefix%> <one-to-many class="<%=attrType%>" node="topiaId" embed-xml="false"/>
<%=prefix%> </<%=collType%>>
}*/
}else {
-/*{<%=prefix%> <<%=collType%> name="<%=getName(attr)%>"<%=((!isInverse)?"":" inverse=\"true\"")%><%=lazy%><%=cascade%> node="<%=getName(attr)%>" embed-xml="false">
-<%=prefix%> <key column="<%=GeneratorUtil.getReverseDBName(attr)%>"/>
-<%=prefix%> <list-index column="<%=GeneratorUtil.getReverseDBName(attr)%>_idx"/>
-<%=prefix%> <one-to-many class="<%=getType(attr)%>" node="topiaId" embed-xml="false"/>
+//fixme pour le moment, on ne calcule pas si on doit autoriser le embed-xml à true
+// on le positionne manuellement
+//TC-20090115 embed-xml wasat true but nobody could tellme why
+/*{<%=prefix%> <<%=collType%> name="<%=attrName%>" <%=inverse%><%=orderBy%><%=fetch%><%=lazy%><%=cascade%>node="<%=attrName%>" embed-xml="false">
+<%=prefix%> <key column="<%=reverseAttrDBName%>"/>
+<%=prefix%> <one-to-many class="<%=attrType%>" node="topiaId" embed-xml="false"/>
<%=prefix%> </<%=collType%>>
}*/
}
}
- protected void generateHibernateMany(Writer output, ObjectModelAttribute attr, String prefix) throws IOException {
+ private String generateFromTagValue(ObjectModelAttribute attr,
+ String tagName, String attributeName) {
+ return generateFromTagValue(attr, tagName, attributeName, null);
+ }
+
+ private String generateFromTagValue(ObjectModelAttribute attr,
+ String tagName, String attributeName, String defaultValue) {
+ String result = "";
+ if (attr.hasTagValue(tagName) || defaultValue != null) {
+ result+= attributeName + "=\"";
+ if (attr.hasTagValue(tagName)) {
+ result += attr.getTagValue(tagName);
+ } else {
+ result += defaultValue;
+ }
+ result += "\" ";
+ }
+ return result;
+ }
+
+ protected void generateHibernateMany(Writer output, ObjectModelAttribute attr, String prefix) throws IOException {
boolean needsIndex = attr.isIndexed();
- String collType = GeneratorUtil.getNMultiplicityHibernateType(attr);
- String lazy = "";
- if (attr.getTagValue(GeneratorUtil.TAG_LAZY) != null) {
- lazy = " lazy=\"" + attr.getTagValue(GeneratorUtil.TAG_LAZY) + "\"";
- }
+ String attrName = getName(attr);
+ String attrType = getType(attr);
+ String collType = TopiaGeneratorUtil.getNMultiplicityHibernateType(attr);
+ String lazy = generateFromTagValue(attr, TopiaGeneratorUtil.TAG_LAZY, "lazy");
+ String attrColumn = TopiaGeneratorUtil.getDBName(attr);
-/*{<%=prefix%> <<%=collType%> name="<%=getName(attr)%>" node="<%=getName(attr)%>" embed-xml="true"<%=lazy%>>
+/*{<%=prefix%> <<%=collType%> name="<%=attrName%>" node="<%=attrName%>" embed-xml="true"<%=lazy%>>
<%=prefix%> <key column="OWNER"/>
}*/
if (needsIndex) {
/*{<%=prefix%> <list-index/>
}*/
}
-/*{<%=prefix%> <element type="<%=getType(attr)%>" column="<%=GeneratorUtil.getDBName(attr)%>" node="id"/>
+/*{<%=prefix%> <element type="<%=attrType%>" column="<%=attrColumn%>" node="id"/>
<%=prefix%> </<%=collType%>>
}*/
}
@@ -424,7 +435,10 @@
}
protected void generateHibernateManyToOne(Writer output, ObjectModelAttribute attr, boolean isUnique, String prefix) throws IOException {
-/*{<%=prefix%> <many-to-one name="<%=getName(attr)%>" class="<%=getType(attr)%>" column="<%=GeneratorUtil.getDBName(attr)%>"}*/
+ String attrName = getName(attr);
+ String attrType = getType(attr);
+ String attrColumn = TopiaGeneratorUtil.getDBName(attr);
+/*{<%=prefix%> <many-to-one name="<%=attrName%>" class="<%=attrType%>" column="<%=attrColumn%>"}*/
if (attr.isComposite() || attr.hasAssociationClass()) {
/*{ cascade="delete"}*/
}
@@ -437,16 +451,13 @@
if (isUnique) {
/*{ unique="true"}*/
}
-/*{ node="<%=getName(attr)%>/@topiaId" embed-xml="false"}*/
+/*{ node="<%=attrName%>/@topiaId" embed-xml="false"}*/
// vérifier si le tag lazy est defini par defaut dans le fichier de proprietes
- if (attr.getTagValue(GeneratorUtil.TAG_LAZY) != null){
-/*{ lazy="<%=attr.getTagValue("lazy")%>"}*/
- }
- String notNull = attr.getTagValue(GeneratorUtil.TAG_NOT_NULL);
- if (notNull != null) {
-/*{ not-null="<%=notNull.trim()%>"}*/
- }
+ String lazy = generateFromTagValue(attr, TopiaGeneratorUtil.TAG_LAZY, "lazy");
+/*{<%=lazy%>}*/
+ String notNull = " " + generateFromTagValue(attr, TopiaGeneratorUtil.TAG_NOT_NULL, "not-null");
+/*{<%=notNull%>}*/
/*{/>
}*/
}
@@ -458,36 +469,34 @@
boolean isInverse = attr.isNavigable() && attr.getReverseAttribute().isNavigable();
//isInverse |= !Util.isFirstAttribute(attr);
//isInverse = false; // 20070117 poussin: pour du many, jamais de inverse
- isInverse &= Util.isFirstAttribute(attr);
+ isInverse &= GeneratorUtil.isFirstAttribute(attr);
boolean needsIndex = attr.isIndexed();
String cascade = "";
if (attr.isComposite() || attr.hasAssociationClass()) {
- // a quoi ca sert ? de concatener "" avec autre chose ???
- //cascade += "cascade=\"delete,delete-orphan\"";
cascade = " cascade=\"delete,delete-orphan\"";
}
- // a quoi ca sert ? :)
- //cascade += "";
- String lazy = " lazy=\"";
- if (attr.getTagValue(GeneratorUtil.TAG_LAZY) != null){
- lazy += attr.getTagValue(GeneratorUtil.TAG_LAZY);
+ String attrType = getType(attr);
+ String attrName = getName(attr);
+ String attrColumn = TopiaGeneratorUtil.getDBName(attr);
+ String lazy = generateFromTagValue(attr, TopiaGeneratorUtil.TAG_LAZY, "lazy", "true");
+ String collType = TopiaGeneratorUtil.getNMultiplicityHibernateType(attr);
+ String tableName = TopiaGeneratorUtil.getManyToManyTableName(attr);
+ String inverse = "";
+ if (isInverse) {
+ inverse = "inverse=\"true\" ";
}
- else {
- lazy += "true";
- }
- lazy += "\"";
- String collType = GeneratorUtil.getNMultiplicityHibernateType(attr);
+ String reverseAttrDBName = TopiaGeneratorUtil.getReverseDBName(attr);
-/*{<%=prefix%> <<%=collType%> name="<%=getName(attr)%>" table="<%=GeneratorUtil.getManyToManyTableName(attr)%>"<%=(isInverse?" inverse=\"true\" ":"")%><%=lazy%><%=cascade%> node="<%=getName(attr)%>" embed-xml="true">
-<%=prefix%> <key column="<%=GeneratorUtil.getReverseDBName(attr)%>"/>
+/*{<%=prefix%> <<%=collType%> name="<%=attrName%>" table="<%=tableName%>" <%=inverse%><%=lazy%><%=cascade%> node="<%=attrName%>" embed-xml="true">
+<%=prefix%> <key column="<%=reverseAttrDBName%>"/>
}*/
if (needsIndex) {
-/*{<%=prefix%> <list-index column="<%=GeneratorUtil.getReverseDBName(attr)%>_idx"/>
+/*{<%=prefix%> <list-index column="<%=reverseAttrDBName%>_idx"/>
}*/
}
-/*{<%=prefix%> <many-to-many class="<%=getType(attr)%>" column="<%=GeneratorUtil.getDBName(attr)%>" node="topiaId"/>
+/*{<%=prefix%> <many-to-many class="<%=attrType%>" column="<%=attrColumn%>" node="topiaId"/>
<%=prefix%> </<%=collType%>>
}*/
}
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityImplGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityImplGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityImplGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -60,7 +60,7 @@
@Override
public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY) || clazz.getOperations().size() > 0) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY) || clazz.getOperations().size() > 0) {
return;
}
//De même, on ne génère pas le impl si il y a des opérations venant des
@@ -70,44 +70,29 @@
return;
}
}
-
- boolean isAbstract = isAbstract(clazz);
- //boolean isAbstract = clazz.isAbstract();
- //Une classe peut être abstraite si elle a des méthodes définies dans
- // ses superinterface et non implantées dans ses superclasses
- /*if (!isAbstract) {
- for (Iterator operations = clazz.getAllInterfaceOperations(true).iterator(); (!isAbstract) && operations.hasNext(); ) {
- ObjectModelOperation op = (ObjectModelOperation)operations.next();
- boolean implementationFound = false;
- for (Iterator superClasses = clazz.getSuperclasses().iterator(); (!implementationFound) && superClasses.hasNext(); ) {
- ObjectModelClass superClazz = (ObjectModelClass)superClasses.next();
- for (Iterator matchingOps = superClazz.getOperations(op.getName()).iterator(); (!implementationFound) && matchingOps.hasNext(); ) {
- ObjectModelOperation matchingOp = (ObjectModelOperation)matchingOps.next();
- implementationFound = (op.equals(matchingOp) && !matchingOp.isAbstract());
- }
- }
- isAbstract = !implementationFound;
- }
- }*/
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
+ String abstractStr = isAbstract(clazz)?"abstract ":" ";
/*{package <%=clazz.getPackageName()%>;
import java.io.Serializable;
/**
- * Implantation des operations pour l'entité <%=GeneratorUtil.capitalize(clazz.getName())%>.
+ * Implantation des operations pour l'entité <%=TopiaGeneratorUtil.capitalize(clazz.getName())%>.
*)
-public <%=(isAbstract?"abstract ":" ")%>class <%=clazz.getName()%>Impl extends <%=clazz.getQualifiedName()%>Abstract implements Serializable, <%=clazz.getQualifiedName()%> {
+public <%=abstractStr%>class <%=clazzName%>Impl extends <%=clazzFQN%>Abstract implements Serializable, <%=clazzFQN%> {
private static final long serialVersionUID = 1L;
}*/
-/*{} //<%=clazz.getName()%>Impl
+/*{} //<%=clazzName%>Impl
}*/
}
@@ -142,4 +127,4 @@
return false;
}
-} //EntityPOJOGenerator
+} //EntityImplGenerator
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityInterfaceGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityInterfaceGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityInterfaceGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -33,7 +33,7 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.Generator;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
@@ -41,11 +41,11 @@
import org.codelutin.generator.models.object.ObjectModelInterface;
import org.codelutin.generator.models.object.ObjectModelOperation;
import org.codelutin.generator.models.object.ObjectModelParameter;
-import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType;
-import static org.codelutin.topia.generator.GeneratorUtil.isBooleanType;
-import static org.codelutin.topia.generator.GeneratorUtil.isDateType;
-import static org.codelutin.topia.generator.GeneratorUtil.isNumericType;
-import static org.codelutin.topia.generator.GeneratorUtil.isTextType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.isBooleanType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.isDateType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.isNumericType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.isTextType;
import java.io.File;
import java.io.IOException;
@@ -85,7 +85,7 @@
*/
@Override
public void generateFromInterface(Writer output, ObjectModelInterface interfacez) throws IOException {
- if (!interfacez.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!interfacez.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
@@ -93,7 +93,7 @@
log.debug("Generating interface for : " + interfacez.getName());
}
- generateInterfaceHeader(output, interfacez);
+ generateInterfaceHeaderFromClassifier(output, interfacez);
generateInterfaceOperations(output, interfacez);
@@ -127,7 +127,7 @@
allAttrs.addAll(clazz.getAllOtherAttributes());
boolean needAnnotation = false;
for (ObjectModelAttribute attr : allAttrs) {
- String name = Util.toLowerCaseFirstLetter(attr.getName());
+ String name = GeneratorUtil.toLowerCaseFirstLetter(attr.getName());
if (isTextType(attr)) {
txtFields.add(name);
needAnnotation = true;
@@ -173,28 +173,32 @@
}*/
}
- private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ private void generateInterfaceHeaderFromClassifier(Writer output, ObjectModelClassifier classifier) throws IOException {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
/*{package <%=classifier.getPackageName()%>;
import org.codelutin.topia.persistence.SearchFields;
+import org.codelutin.topia.persistence.TopiaEntity;
}*/
- if (GeneratorUtil.hasDocumentation(classifier)) {
+ if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
+ String documentation = classifier.getDocumentation();
/*{
/**
- * <%=classifier.getDocumentation()%>
+ * <%=documentation%>
*)
}*/
}
+ //
if (classifier instanceof ObjectModelClass) {
generateSearchFields(output, (ObjectModelClass) classifier);
}
-/*{public interface <%=classifier.getName()%> extends }*/
+ String classifierName = classifier.getName();
+/*{public interface <%=classifierName%> extends }*/
String extendClass = "";
for (ObjectModelClassifier parent : classifier.getInterfaces()) {
extendClass += parent.getQualifiedName();
@@ -203,214 +207,208 @@
if (classifier instanceof ObjectModelClass) {
ObjectModelClass clazz = (ObjectModelClass) classifier;
for (ObjectModelClassifier parent : clazz.getSuperclasses()) {
- if (parent.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
extendClass += parent.getQualifiedName();
}
extendClass += ", ";
}
}
-/*{<%=extendClass%>org.codelutin.topia.persistence.TopiaEntity {
+/*{<%=extendClass%>TopiaEntity {
}*/
}
@Override
public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
- generateInterfaceHeader(output, clazz);
+ String clazzName = clazz.getName();
+ generateInterfaceHeaderFromClassifier(output, clazz);
for (ObjectModelAttribute attr : clazz.getAttributes()) {
ObjectModelAttribute reverse = attr.getReverseAttribute();
if (!attr.isNavigable()
&& !hasUnidirectionalRelationOnAbstractType(reverse, model)) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
- if (!attr.hasAssociationClass()) {
+
+ String attrName = attr.getName();
+ String attrType = attr.getType();
+ if (!attr.hasAssociationClass()) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> à positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> La valeur de l'attribut <%=attrName%> à positionner.
*)
- public void set<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>);
}*/
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @return La valeur de l'attribut <%=attr.getName()%>.
+/*{ * @return La valeur de l'attribut <%=attrName%>.
*)
- public <%=attr.getType()%> get<%=Util.capitalize(attr.getName())%>();
+ public <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>();
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (log.isTraceEnabled()) {
- log.trace("assocAttrName: " + assocAttrName);
- }
+ String collectionInterface = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr);
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> à positionner.
- *)
- public void set<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
-
- /**
- * @return La valeur de l'attribut <%=attr.getAssociationClass().getName()%>.
- *)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>();
-
}*/
- }
- } else { //NMultiplicity
- String collectionInterface = GeneratorUtil.getNMultiplicityInterfaceType(attr);
- if (!attr.hasAssociationClass()) { //Méthodes remplacées par des add/set sur les classes d'assoc
-/*{ /**
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
-}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> L'instance de <%=attrName%> à ajouter.
*)
- public void add<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ public void add<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>);
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> à ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> Les instances de <%=attrName%> à ajouter.
*)
- public void addAll<%=Util.capitalize(attr.getName())%>(<%=collectionInterface%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ public void addAll<%=GeneratorUtil.capitalize(attrName)%>(<%=collectionInterface%><<%=attrType%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>);
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> à positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> La Collection de <%=attrName%> à positionner.
*)
- public void set<%=Util.capitalize(attr.getName())%>(<%=collectionInterface%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=collectionInterface%><<%=attrType%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>);
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à retirer.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> L'instance de <%=attrName%> à retirer.
*)
- public void remove<%=Util.capitalize(attr.getName())%>(<%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ public void remove<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>);
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * Vide la Collection de <%=attr.getName()%>.
+/*{ * Vide la Collection de <%=attrName%>.
*)
- public void clear<%=Util.capitalize(attr.getName())%>();
+ public void clear<%=GeneratorUtil.capitalize(attrName)%>();
}*/
- } else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (log.isTraceEnabled()) {
- log.trace("assocAttrName: " + assocAttrName);
- }
+
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à ajouter.
+}*/
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
+}*/
+ }
+/*{ * @return La Liste de <%=attrName%>.
*)
- public void add<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ public <%=collectionInterface%><<%=attrType%>> get<%=GeneratorUtil.capitalize(attrName)%>();
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> à ajouter.
+ * Recupère l'attribut <%=attrName%> à partir de son topiaId.
+ *
+ * @param topiaId le topia id de l'entité recherchée
+ *
+ * @return l'attribut recherché, ou <code>null</code> s'il n'existe pas.
*)
- public void addAll<%=Util.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ public <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>ByTopiaId(String topiaId);
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> à positionner.
+ * @return Le nombre d'éléments de la collection <%=attrName%>.
*)
- public void set<%=Util.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ public int size<%=GeneratorUtil.capitalize(attrName)%>();
- /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à retirer.
+}*/
+
+ }
+ } else {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassName = attr.getAssociationClass().getName();
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+/*{ /**
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> La valeur de l'attribut <%=assocClassName%> à positionner.
*)
- public void remove<%=Util.capitalize(assocAttrName)%>(<%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>);
/**
- * Vide la Collection de <%=attr.getAssociationClass().getName()%>.
+ * @return La valeur de l'attribut <%=assocClassName%>.
*)
- public void clear<%=Util.capitalize(assocAttrName)%>();
+ public <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>();
}*/
- }
-
- if (!attr.hasAssociationClass()) {
+ } else {
+ String collectionInterface = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr);
/*{ /**
-}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
-}*/
- }
-/*{ * @return La Liste de <%=attr.getName()%>.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> L'instance de <%=assocClassName%> à ajouter.
*)
- public <%=collectionInterface%><<%=attr.getType()%>> get<%=Util.capitalize(attr.getName())%>();
+ public void add<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>);
/**
- * Recupère l'attribut <%=attr.getName()%> à partir de son topiaId.
- *
- * @param topiaId le topia id de l'entité recherchée
- *
- * @return l'attribut recherché, ou <code>null</code> s'il n'existe pas.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> Les instances de <%=assocClassName%> à ajouter.
*)
- public <%=attr.getType()%> get<%=Util.capitalize(attr.getName())%>ByTopiaId(String topiaId);
-
+ public void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=assocClassFQN%>> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>);
+
/**
- * @return Le nombre d'éléments de la collection <%=attr.getName()%>.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> La Collection de <%=assocClassName%> à positionner.
*)
- public int size<%=Util.capitalize(attr.getName())%>();
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=collectionInterface%><<%=assocClassFQN%>> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>);
-}*/
- } else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
- if (log.isTraceEnabled()) {
- log.trace("assocAttrName: " + assocAttrName);
- }
-/*{ /**
- * @return La liste des attributs <%=attr.getAssociationClass().getName()%>.
+ /**
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> L'instance de <%=assocClassName%> à retirer.
*)
- public <%=collectionInterface%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=Util.capitalize(assocAttrName)%>();
+ public void remove<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>);
/**
- * Recupère l'attribut <%=attr.getName()%> à partir de son topiaId.
+ * Vide la Collection de <%=assocClassName%>.
+ *)
+ public void clear<%=GeneratorUtil.capitalize(assocAttrName)%>();
+
+ /**
+ * @return La liste des attributs <%=assocClassName%>.
+ *)
+ public <%=collectionInterface%><<%=assocClassFQN%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>();
+
+ /**
+ * Recupère l'attribut <%=attrName%> à partir de son topiaId.
*
* @param topiaId le topia id de l'attribut recherchée
*
* @return l'attribut recherché, ou <code>null</code> s'il n'existe pas.
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>ByTopiaId(String topiaId);
+ public <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>ByTopiaId(String topiaId);
/**
- * @return L'attribut <%=attr.getAssociationClass().getName()%> associé à la valeur <code>value</code> de l'attribut <%=attr.getName()%>.
+ * @return L'attribut <%=assocClassName%> associé à la valeur <code>value</code> de l'attribut <%=attrName%>.
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>(<%=attr.getType()%> value);
+ public <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=attrType%> value);
/**
- * @return Le nombre d'éléments de la collection <%=attr.getName()%>.
+ * @return Le nombre d'éléments de la collection <%=attrName%>.
*)
- public int size<%=Util.capitalize(assocAttrName)%>();
+ public int size<%=GeneratorUtil.capitalize(assocAttrName)%>();
}*/
+
}
}
}
@@ -434,45 +432,44 @@
generateInterfaceOperations(output, clazz);
-/*{} //<%=clazz.getName()%>
+/*{} //<%=clazzName%>
}*/
}
private void generateInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
for (ObjectModelOperation op : classifier.getOperations()) {
+ String opName = op.getName();
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
-/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
+ String opDocumentation = op.getDocumentation();
+/*{ * <%=opName%> : <%=opDocumentation%>
}*/
}
Collection<ObjectModelParameter> params = op.getParameters();
for (ObjectModelParameter param : params) {
- if (log.isTraceEnabled()) {
- log.trace("Param" + param);
- }
-/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%>
+ String paramName = param.getName();
+ String paramDocumentation = param.getDocumentation();
+/*{ * @param <%=paramName%> <%=paramDocumentation%>
}*/
}
+ String opVisibility = op.getVisibility();
+ String opType = op.getReturnType();
/*{ *)
- <%=op.getVisibility()%> <%=op.getReturnType()%> <%=op.getName()%>(}*/
- String vir = "";
+ <%=opVisibility%> <%=opType%> <%=opName%>(}*/
+ String comma = "";
for (ObjectModelParameter param : params) {
- if (log.isTraceEnabled()) {
- log.trace("Param" + param + " vir" + vir);
- }
-/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
- vir = ", ";
+ String paramName = param.getName();
+ String paramType = param.getType();
+/*{<%=comma%><%=paramType%> <%=paramName%>}*/
+ comma = ", ";
}
/*{)}*/
Set<String> exceptions = op.getExceptions();
- vir = " throws ";
+ comma = " throws ";
for (String exception : exceptions) {
- if (log.isTraceEnabled()) {
- log.trace("exception" + exception + " vir" + vir);
- }
-/*{<%=vir%><%=exception%>}*/
- vir = ", ";
+/*{<%=comma%><%=exception%>}*/
+ comma = ", ";
}
/*{;
@@ -480,16 +477,16 @@
}
}
- private void generateAssociationAccessors(Writer output, String name, String type) throws IOException {
+ private void generateAssociationAccessors(Writer output, String attrName, String attrType) throws IOException {
/*{ /**
- * @param value La valeur de l'attribut <%=name%> à positionner.
+ * @param value La valeur de l'attribut <%=attrName%> à positionner.
*)
- public void set<%=Util.capitalize(name)%>(<%=type%> value);
+ public void set<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%> value);
/**
- * @return La valeur de l'attribut <%=name%>.
+ * @return La valeur de l'attribut <%=attrName%>.
*)
- public <%=type%> get<%=Util.capitalize(name)%>();
+ public <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>();
}*/
}
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityProviderGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityProviderGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityProviderGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -67,22 +67,26 @@
@Override
public void generateFromModel(Writer output, ObjectModel model)
throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
+ String modelName = model.getName();
/*{package <%=getProperty("defaultPackage")%>;
import org.codelutin.topia.persistence.TopiaEntity;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
@SuppressWarnings({"unchecked"})
-public class <%=model.getName()%>EntityProvider {
+public class <%=modelName%>EntityProvider {
- protected static java.util.Map<Class<? extends TopiaEntity>, Class<? extends TopiaEntity>> cache;
+ protected static Map<Class<? extends TopiaEntity>, Class<? extends TopiaEntity>> cache;
}*/
- List<ObjectModelClass> classes = GeneratorUtil.getEntityClasses(model,true);
+ List<ObjectModelClass> classes = TopiaGeneratorUtil.getEntityClasses(model, true);
if (classes.isEmpty()) {
/*{
protected static Class<? extends TopiaEntity>[] entitiesClass = new Class[]{};
@@ -92,17 +96,18 @@
protected static Class<? extends TopiaEntity>[] entitiesClass = new Class[]{
}*/
}
- for (Iterator i=classes.iterator(); i.hasNext();) {
- ObjectModelClass clazz = (ObjectModelClass)i.next();
-/*{ <%=clazz.getQualifiedName()%>.class<%=(i.hasNext()?", ":"\n};")%>
-}*/
+ for (Iterator<ObjectModelClass> i=classes.iterator(); i.hasNext();) {
+ ObjectModelClass clazz = i.next();
+ String clazzFQN = clazz.getQualifiedName();
+/*{ <%=clazzFQN%>.class<%=(i.hasNext()?", ":"\n};")%>
+}*/
}
/*{
public static <E extends TopiaEntity> Class<E> getImpl(Class<E> klazz) {
return (Class<E>) getCache().get(klazz);
}
- public static java.util.Map<Class<? extends TopiaEntity>, Class<? extends TopiaEntity>> getCache() {
+ public static Map<Class<? extends TopiaEntity>, Class<? extends TopiaEntity>> getCache() {
if (cache == null) {
initCache();
}
@@ -110,7 +115,7 @@
}
private static void initCache() {
- java.util.Map<Class<? extends TopiaEntity>, Class<? extends TopiaEntity>> cache = new java.util.HashMap<Class<? extends TopiaEntity>, Class<? extends TopiaEntity>>();
+ Map<Class<? extends TopiaEntity>, Class<? extends TopiaEntity>> cache = new HashMap<Class<? extends TopiaEntity>, Class<? extends TopiaEntity>>();
for (Class<? extends TopiaEntity> entitiesClas : entitiesClass) {
String implFQN = entitiesClas.getName() + "Impl";
try {
@@ -120,15 +125,16 @@
throw new RuntimeException("could not find entity implementation class " + implFQN);
}
}
- <%=model.getName()%>EntityProvider.cache = java.util.Collections.unmodifiableMap(cache);
+ <%=modelName%>EntityProvider.cache = Collections.unmodifiableMap(cache);
}
/**
* should have no instance
*)
- protected <%=model.getName()%>EntityProvider() {
+ protected <%=modelName%>EntityProvider() {
}
-}
+
+} //<%=modelName%>EntityProvider
}*/
}
Deleted: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -1,685 +0,0 @@
-/* *##% ToPIA - Tools for Portable and Independent Architecture
- * Copyright (C) 2004 - 2008 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>. ##%*/
-
-/*******************************************************************************
- * GeneratorUtil.java
- *
- * Created: 13 déc. 2005
- *
- * @author Arnaud Thimel <thimel(a)codelutin.com>
- *
- * @version $Revision$
- *
- * Mise a jour: $Date$ par : $Author$
- */
-
-package org.codelutin.topia.generator;
-
-import org.apache.commons.lang.StringUtils;
-import org.codelutin.generator.Generator;
-import org.codelutin.generator.Util;
-import org.codelutin.generator.models.Model;
-import org.codelutin.generator.models.object.ObjectModel;
-import org.codelutin.generator.models.object.ObjectModelAttribute;
-import org.codelutin.generator.models.object.ObjectModelClass;
-import org.codelutin.generator.models.object.ObjectModelElement;
-import org.codelutin.generator.models.object.ObjectModelInterface;
-import org.codelutin.generator.models.object.ObjectModelOperation;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-/** Classe regroupant divers méthodes utiles pour la génération des entités */
-public class GeneratorUtil extends Util {
-
- /** Stéréotype pour les interfaces devant être générées sous forme de facades */
- public final static String STEREOTYPE_FACADE = "facade";
-
- /** Stéréotype pour les objets devant être générées sous forme d'entités */
- public static final String STEREOTYPE_ENTITY = "entity";
-
- /** Stéréotype pour les objets devant être générées sous forme de DTO */
- public static final String STEREOTYPE_DTO = "dto";
-
- /**
- * Stéréotype pour les interfaces devant être générées sous forme de
- * services
- */
- public static final String STEREOTYPE_SERVICE = "service";
-
- /** Stéréotype pour les interfaces devant être générées sous forme de DAO */
- public static final String STEREOTYPE_DAO = "dao";
-
- /** Stéréotype pour les attributs à indexer en base */
- public static final String STEREOTYPE_INDEXED = "indexed";
-
- /** Stéréotype pour les collections avec unicité */
- public static final String STEREOTYPE_UNIQUE = "unique";
-
- /** Stéréotype pour les attributs étant des clés primaires */
- public static final String STEREOTYPE_PRIMARYKAY = "primaryKey";
-
- /** Tag pour le type de persistence */
- public static final String TAG_PERSISTENCE_TYPE = "persistenceType";
-
- /** Tag pour le nom du champ / entité en BD */
- public static final String TAG_DB_NAME = "dbName";
-
- /** Tag pour le nom du schema en BD */
- public static final String TAG_SCHEMA_NAME = "dbSchema";
-
- /** Tag pour la taille du champ en BD */
- public static final String TAG_LENGTH = "length";
-
- /** Tag pour ajouter une annotation à un champ */
- public static final String TAG_ANNOTATION = "annotation";
-
- /** Tag pour ajouter specifier le copyright d'un fichier */
- public static final String TAG_COPYRIGHT = "copyright";
-
- /** Tag pour specfier le type d'acces a un champ */
- public static final String TAG_ACCESS = "access";
-
- /** Tag pour specfier si on doit générer i18n */
- public static final String TAG_I18N_PREFIX = "i18n";
-
- /** Tag pour ajouter un attribut dans une clef métier */
- public static final String TAG_NATURAL_ID = "naturalId";
-
- /** Tag pour specifier si une clef metier est mutable */
- public static final String TAG_NATURAL_ID_MUTABLE = "naturalIdMutable";
-
- /** Tag pour spécifier la caractèrelazy d'une association multiple */
- public static final String TAG_LAZY = "lazy";
-
- /** Tag pour spécifier la caractère fetch d'une association multiple */
- public static final String TAG_FETCH = "fetch";
-
- /** Tag pour spécifier la caractère order-by d'une association multiple */
- public static final String TAG_ORDER_BY = "orderBy";
-
- /** Tag pour spécifier la caractère not-null d'un attribut */
- public static final String TAG_NOT_NULL = "notNull";
-
- /** Tag pour spécifier la caractère embed-xml d'une association */
- public static final String TAG_EMBED_XML = "embedXml";
-
- /** Type de persistence Hibernate */
- public static final String PERSISTENCE_TYPE_HIBERNATE = "hibernate";
-
- /** Type de persistence LDAP */
- public static final String PERSISTENCE_TYPE_LDAP = "ldap";
-
- /** Type de persistence par défaut (si aucun précisé) */
- public static final String PERSISTENCE_TYPE_DEFAULT = PERSISTENCE_TYPE_HIBERNATE;
-
- /** Propriété des générateurs indiquant le package par défaut */
- public static final String PROPERTY_DEFAULT_PACKAGE = "defaultPackage";
-
- /** Le package par défaut si aucun n'est spécifié */
- public static final String DEFAULT_PACKAGE = "org.codelutin.malo";
-
- /**
- * Renvoie le package par défaut pour le générateur donné
- *
- * @param generator le générateur donné
- * @return le package par défaut du générator donné
- */
- public static String getDefaultPackage(Generator generator) {
- String packageName = generator.getProperty(PROPERTY_DEFAULT_PACKAGE);
- if (packageName == null || "".equals(packageName)) {
- packageName = DEFAULT_PACKAGE;
- }
- return packageName;
- }
-
- /**
- * Indique si l'élément spécifié dispose de documentation
- *
- * @param element l'élément à tester
- * @return true s'il y a documentation, false sinon
- */
- public static boolean hasDocumentation(ObjectModelElement element) {
- return notEmpty(element.getDocumentation());
- }
-
- /**
- * Indique si la chaine de caratère n'est pas vide (null ou "")
- *
- * @param s la chaine de caractères à tester
- * @return true si <code>s</code> n'est pas vide
- */
- public static boolean notEmpty(String s) {
- return (s != null && !"".equals(s));
- }
-
- /**
- * Renvoie l'interface DAO associée à la classe passée en paramètre
- *
- * @param clazz la classe à tester
- * @param model le modele utilisé
- * @return l'interface trouvée ou null sinon
- */
- public static ObjectModelInterface getDAOInterface(ObjectModelClass clazz,
- ObjectModel model) {
- for (Object o : model.getInterfaces()) {
- ObjectModelInterface daoInterface = (ObjectModelInterface) o;
- if (daoInterface.getName().equals(clazz.getName() + "DAO")) {
- if (daoInterface.hasStereotype(STEREOTYPE_DAO)) {
- return daoInterface;
- }
- }
- }
- return null;
- }
-
- /**
- * Renvoie le type de persistence pour l'élément donné. Si aucun n'est
- * trouvé, le type par défaut est utilisé
- *
- * @param element l'élément à tester
- * @return le type de persitence pour l'élément donné.
- */
- public static String getPersistenceType(ObjectModelElement element) {
- String tag = element.getTagValue(TAG_PERSISTENCE_TYPE);
- if (tag == null) {
- tag = PERSISTENCE_TYPE_DEFAULT;
- }
- return tag;
- }
-
- public static String getReverseDBName(ObjectModelAttribute attr) {
- if (attr.getReverseAttribute() != null) {
- return getDBName(attr.getReverseAttribute());
- } else {
- return getDBName(attr) + "_id";
- }
- }
-
- /**
- * Renvoie le nom BD de l'élement passé en paramètre. Elle se base sur le
- * tag associé si il existe, sinon sur le nom de l'élément
- *
- * @param element l'élément à tester
- * @return le nom de table
- */
- public static String getDBName(ObjectModelElement element) {
- if (element == null) {
- return null;
- }
- if (notEmpty(element.getTagValue(TAG_DB_NAME))) {
- return element.getTagValue(TAG_DB_NAME);
- }
- return toLowerCaseFirstLetter(element.getName());
- }
-
- /**
- * Cherche et renvoie le schema a utiliser sur cet element, sinon sur le model.
- *
- * @param element l'élément à tester
- * @param model le modele utilisé
- * @return le nom du schema ou null
- */
- public static String getSchemaName(ObjectModelElement element,
- ObjectModel model) {
- return findTagValue(TAG_SCHEMA_NAME, element, model);
- }
-
- /**
- * Cherche et renvoie le prefixe i18n à utiliser sur cet element, sinon sur le model.
- *
- * @param element l'élément à tester
- * @param model le modele utilisé
- * @return le prefix i18n ou <code>null</code> si non spécifié
- */
- public static String getI18nPrefix(ObjectModelElement element,
- ObjectModel model) {
- return findTagValue(TAG_I18N_PREFIX, element, model);
- }
-
- /**
- * Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
- *
- * @param clazz la classe à tester
- * @return la liste des attributs de la clef métier ou null si pas de clef métier.
- */
- public static List<String> getNaturalId(ObjectModelClass clazz) {
- String value = clazz.getTagValue(TAG_NATURAL_ID);
- if (value == null || value.trim().isEmpty()) {
- return java.util.Collections.emptyList();
- }
- List<String> result = new ArrayList<String>();
- for (String attribute : value.split(",")) {
- result.add(attribute.trim());
- }
- return result;
- }
-
- /**
- * Detecte si un attribut fait partie d'une clef metier.
- *
- * @param attribute l'attribut à tester
- * @return <code>true</code> si l'attribut fait partie d'une clef metier, <code>false</cdoe> sinon.
- */
- public static boolean isNaturalId(ObjectModelAttribute attribute) {
- String value = attribute.getTagValue(TAG_NATURAL_ID);
- if (!notEmpty(value)) {
- // valeur null, donc pas positionnee
- return false;
- }
- try {
- return Boolean.valueOf(value.trim());
- } catch (Exception e) {
- // on a pas reussi a convertir en boolean.
- //todo peut-être declancher une exception ?
- return false;
- }
- }
-
- /**
- * Cherches et renvoie le copyright a utiliser sur le model.
- *
- * @param model le modele utilisé
- * @return le texte du copyright ou null
- */
- public static String getCopyright(Model model) {
- return findTagValue(TAG_COPYRIGHT, null, model);
- }
-
- /**
- * Cherches et renvoie la valeur du tagvalue indique sur cet element,
- * sinon sur le model.
- *
- * @param tagName le nom du tag
- * @param element l'élément à tester
- * @param model le modele utilisé
- * @return la valeur du tagValue ou null
- */
- public static String findTagValue(String tagName,
- ObjectModelElement element, Model model) {
- if (element == null) {
- if (model != null) {
- if (notEmpty(model.getTagValue(tagName))) {
- return model.getTagValue(tagName);
- }
- }
- return null;
- }
- if (notEmpty(element.getTagValue(tagName))) {
- return element.getTagValue(tagName);
- }
- //On va chercher sur l'element declarant
- return findTagValue(tagName, element.getDeclaringElement(), model);
- }
-
- public static <Type extends ObjectModelElement> Collection<Type> getElementsWithStereotype(
- Collection<Type> elements, String... stereotypes) {
- Collection<Type> result = new ArrayList<Type>();
- for (Type element : elements) {
- if (hasStereotypes(element, stereotypes)) {
- result.add(element);
- }
- }
- return result;
- }
-
- public static boolean hasStereotypes(ObjectModelElement element,
- String... stereotypes) {
- for (String stereotype : stereotypes) {
- if (!element.hasStereotype(stereotype)) {
- return false;
- }
- }
- return true;
- }
-
- public static String getPrimaryKeyAttributesListDeclaration(
- ObjectModelClass clazz, boolean includeName) {
- String attributes = "";
- for (ObjectModelAttribute attr : getElementsWithStereotype(clazz
- .getAttributes(), STEREOTYPE_PRIMARYKAY)) {
- attributes += attr.getType();
- if (includeName) {
- attributes += " " + attr.getName();
- }
- attributes += ", ";
- }
- if (attributes.length() > 0) {
- attributes = attributes.substring(0, attributes.length() - 2);
- }
- return attributes;
- }
-
- public static String capitalize(String s) {
- return StringUtils.capitalize(s);
- }
-
- public static boolean isAssociationClassDoublon(ObjectModelAttribute attr) {
- return (attr.getReverseAttribute() != null)
- && (attr.getDeclaringElement().equals(attr
- .getReverseAttribute().getDeclaringElement()))
- && (!Util.isFirstAttribute(attr));
- }
-
- /**
- * Renvoie le nom de l'attribut de classe d'association en fonction des cas:
- * Si l'attribut porte le même nom que le type (extrémité inverse de
- * l'association), on lui ajoute le nom de la classe d'association
- *
- * @param attr l'attribut a traiter
- * @return le nom de l'attribut de classe d'association
- */
- public static String getAssocAttrName(ObjectModelAttribute attr) {
- String typeName = attr.getType().substring(
- attr.getType().lastIndexOf(".") + 1);
- String result = attr.getName();
- if (attr.getName().equalsIgnoreCase(typeName)) {
- result += GeneratorUtil.capitalize(attr.getAssociationClass()
- .getName());
- }
- return result;
- }
-
- public static String getDOType(ObjectModelElement elem, ObjectModel model) {
- String type = elem.getName();
- if (elem instanceof ObjectModelAttribute) {
- type = ((ObjectModelAttribute) elem).getType();
- }
- if (elem instanceof ObjectModelClass) {
- type = ((ObjectModelClass) elem).getQualifiedName();
- }
- return getDOType(type, model);
- }
-
- public static String getDOType(String type, ObjectModel model) {
- if (!model.hasClass(type)) {
- return type;
- }
- ObjectModelClass clazz = model.getClass(type);
- if (clazz.hasStereotype(STEREOTYPE_ENTITY)) {
- if (shouldBeAbstract(clazz)) {
- type += "Abstract";
- } else {
- type += "Impl";
- }
- }
- return type;
- }
-
- private static Set<String> numberTypes = new HashSet<String>();
-
- static {
- numberTypes.add("byte");
- numberTypes.add("java.lang.Byte");
- numberTypes.add("short");
- numberTypes.add("java.lang.Short");
- numberTypes.add("int");
- numberTypes.add("java.lang.Integer");
- numberTypes.add("long");
- numberTypes.add("java.lang.Long");
- numberTypes.add("float");
- numberTypes.add("java.lang.Float");
- numberTypes.add("double");
- numberTypes.add("java.lang.Double");
- }
-
- public static boolean isNumericType(ObjectModelAttribute attr) {
- return numberTypes.contains(attr.getType());
- }
-
- private static Set<String> textTypes = new HashSet<String>();
-
- static {
- textTypes.add("char");
- textTypes.add("java.lang.Char");
- textTypes.add("java.lang.String");
- }
-
- public static boolean isTextType(ObjectModelAttribute attr) {
- return textTypes.contains(attr.getType());
- }
-
- public static boolean isDateType(ObjectModelAttribute attr) {
- return "java.util.Date".equals(attr.getType());
- }
-
- public static boolean isBooleanType(ObjectModelAttribute attr) {
- return ("boolean".equals(attr.getType()) || "java.lang.Boolean"
- .equals(attr.getType()));
- }
-
- /**
- * Indique si la classe specifiee n'a aucune ou que des methodes abstraites
- *
- * @param clazz l'instance de ObjectModelClass
- * @return true si la classe n'a que des operations abstraite ou aucune
- * operation
- */
- public static boolean hasNothingOrAbstractMethods(ObjectModelClass clazz) {
- boolean result = true;
- Iterator operations = clazz.getOperations().iterator();
- while (result && operations.hasNext()) {
- ObjectModelOperation op = (ObjectModelOperation) operations.next();
- result = op.isAbstract();
- }
- return result;
- }
-
- /**
- * Indique si la classe specifiee devrait etre abstraite
- *
- * @param clazz l'instance de ObjectModelClass
- * @return true dans ce cas, false sinon
- */
- public static boolean shouldBeAbstract(ObjectModelClass clazz) {
- return clazz != null
- && (clazz.isAbstract() && hasNothingOrAbstractMethods(clazz));
- }
-
- /**
- * <p>
- * Cette méthode permet de détecter si
- * - l'attribut représente une relation 1-n
- * - cette relation est unidirectionnelle
- * - le type de l'attribut représente un entité
- * - cette entité a des sous-classes dans le modèle
- * <p/>
- * Ce cas correspond à une incompatibilité d'Hibernate qui nous oblige a
- * adopter un comportement particulier.
- * </p>
- *
- * @param attr l'attribut a tester
- * @param model le model
- * @return true si et seulement si il s'agit bien de ce type de relation
- */
- public static boolean hasUnidirectionalRelationOnAbstractType(
- ObjectModelAttribute attr, ObjectModel model) {
- ObjectModelAttribute reverse = attr.getReverseAttribute();
- //relation 1-n
- if (reverse != null && isNMultiplicity(attr)
- && !isNMultiplicity(reverse)) {
- //Pas de navigabilité
- if (!reverse.isNavigable()) {
- //Il s'agit d'une entity
- ObjectModelClass clazz = model.getClass(attr.getType());
- if (clazz != null && clazz.hasStereotype(STEREOTYPE_ENTITY)) {
- //Cette classe a des sous-classes dans le modèle
- for (ObjectModelClass subClass : model.getClasses()) {
- if (subClass.getSuperclasses().contains(clazz)) {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Renvoie le nom unique de table pour une relation ManyToMany en fonction
- * de l'attribut <code>attr</code>
- * <p/>
- * Plusieurs cas de figure:
- * <li>
- *
- * @param attr l'attribut servant de base au calcul du nom
- * @return le nom de la table
- */
- public static String getManyToManyTableName(ObjectModelAttribute attr) {
- String result;
-
- if (attr.hasAssociationClass()) {
- result = GeneratorUtil.getDBName(attr.getAssociationClass());
- } else {
- String name = attr.getName();
- String revers = attr.getReverseAttributeName();
-
- if (name.compareToIgnoreCase(revers) < 0) {
- result = name + "_" + revers;
- } else {
- result = revers + "_" + name;
- }
- }
- // String result;
- // if (!Util.isFirstAttribute(attr)) {
- // result = attr.getDeclaringElement().getName() + "_" + attr.getReverseAttribute().getDeclaringElement().getName();
- // } else {
- // result = attr.getReverseAttribute().getDeclaringElement().getName() + "_" + attr.getDeclaringElement().getName();
- // }
- return result.toLowerCase();
- }
-
- /**
- * Renvoie le type d'interface à utiliser en fonction de l'attribut
- *
- * @param attr l'attribut a traiter
- * @return String
- */
- public static String getNMultiplicityInterfaceType(ObjectModelAttribute attr) {
- if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
- return Set.class.getName();
- } else if (attr.isIndexed() || attr.isOrdered()) {
- return List.class.getName();
- }
- return Collection.class.getName();
- }
-
- /**
- * Renvoie le type d'objet (instance) à utiliser en fonction de l'attribut
- *
- * @param attr l'attribut a traiter
- * @return String
- */
- public static String getNMultiplicityObjectType(ObjectModelAttribute attr) {
- if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
- return HashSet.class.getName();
- } else if (attr.isIndexed() || attr.isOrdered()) {
- //On considère qu'on ne sait pas traiter vraiment l'attribut "ordered"
- // puisqu'on va conserver l'ordre d'insertion, et non un ordre en
- // fonction d'un élément donné. Donc on renvoi une ArrayList
- return ArrayList.class.getName();
- }
- LinkedList.class.getName();
- return ArrayList.class.getName();
- }
-
- /**
- * Renvoie le type d'interface à utiliser en fonction de l'attribut
- *
- * @param attr l'attribut a traiter
- * @return String
- */
- public static String getNMultiplicityHibernateType(ObjectModelAttribute attr) {
- if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
- return "set";
- } else if (attr.isIndexed()) {
- return "list";
- }
- //attr.isOrdered() - On génère le ordered en bag
- return "bag";
- }
-
- /**
- * Obtain the list of entities classes with the possibility to sort the result.
- *
- * @param model the current model to scan
- * @param sort flag to allow sort the result
- * @return the list of filtred classes by their stereotype
- */
- public static List<ObjectModelClass> getEntityClasses(ObjectModel model,
- boolean sort) {
- return getClassesByStereotype(STEREOTYPE_ENTITY, model, sort);
- }
-
- /**
- * Obtain the list of classes for a given stereotype with the possibility to sort the result.
- *
- * @param stereotype filter stereotype
- * @param model the current model to scan
- * @param sort flag to allow sort the result
- * @return the list of filtred classes by their stereotype
- */
- public static List<ObjectModelClass> getClassesByStereotype(
- String stereotype, ObjectModel model, boolean sort) {
- List<ObjectModelClass> classes = new ArrayList<ObjectModelClass>();
- for (ObjectModelClass clazz : model.getClasses()) {
- if (clazz.hasStereotype(stereotype)) {
- classes.add(clazz);
- }
- }
- if (sort && !classes.isEmpty()) {
- java.util.Collections.sort(classes,
- new java.util.Comparator<ObjectModelClass>() {
- public int compare(ObjectModelClass o1,
- ObjectModelClass o2) {
- return o1.getQualifiedName().compareTo(
- o2.getQualifiedName());
- }
- });
- }
- return classes;
- }
-
- /**
- * Detecte si la clef metier d'une classe est mutable ou pas.
- * <p/>
- * On respecte la valeur par defaut d'hibernate, à savoir que par default une clef metier est non mutable.
- *
- * @param clazz la classe a tester
- * @return <code>true</code> si le tag value a ete positionne sur la classe via le tag
- * {@link #TAG_NATURAL_ID_MUTABLE}, , <code>false</code> sinon.
- */
- public static boolean isNaturalIdMutable(ObjectModelClass clazz) {
- String value = clazz.getTagValue(TAG_NATURAL_ID_MUTABLE);
- if (!notEmpty(value)) {
- // valeur null, donc par default positionnee
- return false;
- }
- try {
- return Boolean.valueOf(value.trim());
- } catch (Exception e) {
- // on a pas reussi a convertir en boolean.
- //todo peut-être declancher une exception ?
- return false;
- }
- }
-} // GeneratorUtil
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/InterfaceGenerator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/InterfaceGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/InterfaceGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -80,34 +80,38 @@
log.debug("Generating interface for : " + interfacez.getName());
}
+ String interfacezName = interfacez.getName();
+
generateInterfaceHeader(output, interfacez);
generateInterfaceOperations(output, interfacez);
-/*{} //<%=interfacez.getName()%>
+/*{} //<%=interfacezName%>
}*/
}
- private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ private void generateInterfaceHeader(Writer output, ObjectModelInterface interfacez) throws IOException {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
-/*{package <%=classifier.getPackageName()%>;
+/*{package <%=interfacez.getPackageName()%>;
}*/
- if (GeneratorUtil.hasDocumentation(classifier)) {
+ if (TopiaGeneratorUtil.hasDocumentation(interfacez)) {
+ String documentation = interfacez.getDocumentation();
/*{
/**
- * <%=classifier.getDocumentation()%>
+ * <%=documentation%>
*)
}*/
}
-/*{public interface <%=classifier.getName()%> }*/
+ String interfacezName = interfacez.getName();
+/*{public interface <%=interfacezName%> }*/
String extendClass = "";
- if (!classifier.getInterfaces().isEmpty()) {
- for (ObjectModelClassifier parent : classifier.getInterfaces()) {
+ if (!interfacez.getInterfaces().isEmpty()) {
+ for (ObjectModelClassifier parent : interfacez.getInterfaces()) {
extendClass += parent.getQualifiedName();
extendClass += ", ";
}
@@ -127,8 +131,9 @@
for (ObjectModelOperation op : classifier.getOperations()) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
-/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
+ String documentation = op.getDocumentation();
+/*{ * <%=documentation%>
}*/
}
Collection<ObjectModelParameter> params = op.getParameters();
@@ -136,28 +141,35 @@
if (log.isTraceEnabled()) {
log.trace("Param" + param);
}
-/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%>
+ String paramName = param.getName();
+ String paramDocumentation = param.getDocumentation();
+/*{ * @param <%=paramName%> <%=paramDocumentation%>
}*/
}
+ String opVisibility = op.getVisibility();
+ String opType = op.getReturnType();
+ String opName = op.getName();
/*{ *)
- <%=op.getVisibility()%> <%=op.getReturnType()%> <%=op.getName()%>(}*/
- String vir = "";
+ <%=opVisibility%> <%=opType%> <%=opName%>(}*/
+ String comma = "";
for (ObjectModelParameter param : params) {
if (log.isTraceEnabled()) {
- log.trace("Param" + param + " vir" + vir);
+ log.trace("Param" + param + " comma" + comma);
}
-/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
- vir = ", ";
+ String paramName = param.getName();
+ String paramType = param.getType();
+/*{<%=comma%><%=paramType%> <%=paramName%>}*/
+ comma = ", ";
}
/*{)}*/
Set<String> exceptions = op.getExceptions();
- vir = " throws ";
+ comma = " throws ";
for (String exception : exceptions) {
if (log.isTraceEnabled()) {
- log.trace("exception" + exception + " vir" + vir);
+ log.trace("exception" + exception + " vir" + comma);
}
-/*{<%=vir%><%=exception%>}*/
- vir = ", ";
+/*{<%=comma%><%=exception%>}*/
+ comma = ", ";
}
/*{;
Copied: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaGeneratorUtil.java (from rev 1333, topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaGeneratorUtil.java)
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaGeneratorUtil.java (rev 0)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaGeneratorUtil.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -0,0 +1,872 @@
+/* *##% ToPIA - Tools for Portable and Independent Architecture
+ * Copyright (C) 2004 - 2008 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>. ##%*/
+
+/*******************************************************************************
+ * GeneratorUtil.java
+ *
+ * Created: 13 déc. 2005
+ *
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ *
+ * @version $Revision: 1298 $
+ *
+ * Mise a jour: $Date: 2009-01-15 00:01:45 +0100 (jeu 15 jan 2009) $ par : $Author: tchemit $
+ */
+
+package org.codelutin.topia.generator;
+
+import org.apache.commons.lang.StringUtils;
+import org.codelutin.generator.Generator;
+import org.codelutin.generator.GeneratorUtil;
+import org.codelutin.generator.models.Model;
+import org.codelutin.generator.models.object.ObjectModel;
+import org.codelutin.generator.models.object.ObjectModelAttribute;
+import org.codelutin.generator.models.object.ObjectModelClass;
+import org.codelutin.generator.models.object.ObjectModelElement;
+import org.codelutin.generator.models.object.ObjectModelInterface;
+import org.codelutin.generator.models.object.ObjectModelOperation;
+import org.codelutin.generator.models.object.ObjectModelAssociationClass;
+import org.codelutin.generator.models.object.ObjectModelParameter;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.Arrays;
+
+/** Classe regroupant divers méthodes utiles pour la génération des entités */
+public class TopiaGeneratorUtil extends GeneratorUtil {
+
+ /** Stéréotype pour les interfaces devant être générées sous forme de facades */
+ public final static String STEREOTYPE_FACADE = "facade";
+
+ /** Stéréotype pour les objets devant être générées sous forme d'entités */
+ public static final String STEREOTYPE_ENTITY = "entity";
+
+ /** Stéréotype pour les objets devant être générées sous forme de DTO */
+ public static final String STEREOTYPE_DTO = "dto";
+
+ /**
+ * Stéréotype pour les interfaces devant être générées sous forme de
+ * services
+ */
+ public static final String STEREOTYPE_SERVICE = "service";
+
+ /** Stéréotype pour les interfaces devant être générées sous forme de DAO */
+ public static final String STEREOTYPE_DAO = "dao";
+
+ /** Stéréotype pour les attributs à indexer en base */
+ public static final String STEREOTYPE_INDEXED = "indexed";
+
+ /** Stéréotype pour les collections avec unicité */
+ public static final String STEREOTYPE_UNIQUE = "unique";
+
+ /** Stéréotype pour les attributs étant des clés primaires */
+ public static final String STEREOTYPE_PRIMARYKAY = "primaryKey";
+
+ /** Tag pour le type de persistence */
+ public static final String TAG_PERSISTENCE_TYPE = "persistenceType";
+
+ /** Tag pour le nom du champ / entité en BD */
+ public static final String TAG_DB_NAME = "dbName";
+
+ /** Tag pour le nom du schema en BD */
+ public static final String TAG_SCHEMA_NAME = "dbSchema";
+
+ /** Tag pour la taille du champ en BD */
+ public static final String TAG_LENGTH = "length";
+
+ /** Tag pour ajouter une annotation à un champ */
+ public static final String TAG_ANNOTATION = "annotation";
+
+ /** Tag pour ajouter specifier le copyright d'un fichier */
+ public static final String TAG_COPYRIGHT = "copyright";
+
+ /** Tag pour specfier le type d'acces a un champ */
+ public static final String TAG_ACCESS = "access";
+
+ /** Tag pour specfier si on doit générer i18n */
+ public static final String TAG_I18N_PREFIX = "i18n";
+
+ /** Tag pour ajouter un attribut dans une clef métier */
+ public static final String TAG_NATURAL_ID = "naturalId";
+
+ /** Tag pour specifier si une clef metier est mutable */
+ public static final String TAG_NATURAL_ID_MUTABLE = "naturalIdMutable";
+
+ /** Tag pour spécifier la caractèrelazy d'une association multiple */
+ public static final String TAG_LAZY = "lazy";
+
+ /** Tag pour spécifier la caractère fetch d'une association multiple */
+ public static final String TAG_FETCH = "fetch";
+
+ /** Tag pour spécifier la caractère order-by d'une association multiple */
+ public static final String TAG_ORDER_BY = "orderBy";
+
+ /** Tag pour spécifier la caractère not-null d'un attribut */
+ public static final String TAG_NOT_NULL = "notNull";
+
+ /** Tag pour spécifier la caractère embed-xml d'une association */
+ public static final String TAG_EMBED_XML = "embedXml";
+
+ /** Tag pour spécifier le permissions à la création */
+ public static final String TAG_SECURITY_CREATE = "securityCreate";
+
+ /** Tag pour spécifier le permissions au chargement */
+ public static final String TAG_SECURITY_LOAD = "securityLoad";
+
+ /** Tag pour spécifier le permissions à la mise à jour */
+ public static final String TAG_SECURITY_UPDATE = "securityUpdate";
+
+ /** Tag pour spécifier le permissions à la suppression */
+ public static final String TAG_SECURITY_DELETE = "securityDelete";
+
+ /** Type de persistence Hibernate */
+ public static final String PERSISTENCE_TYPE_HIBERNATE = "hibernate";
+
+ /** Type de persistence LDAP */
+ public static final String PERSISTENCE_TYPE_LDAP = "ldap";
+
+ /** Type de persistence par défaut (si aucun précisé) */
+ public static final String PERSISTENCE_TYPE_DEFAULT = PERSISTENCE_TYPE_HIBERNATE;
+
+ /** Propriété des générateurs indiquant le package par défaut */
+ public static final String PROPERTY_DEFAULT_PACKAGE = "defaultPackage";
+
+ /** Le package par défaut si aucun n'est spécifié */
+ public static final String DEFAULT_PACKAGE = "org.codelutin.malo";
+
+ /**
+ * Renvoie le package par défaut pour le générateur donné
+ *
+ * @param generator le générateur donné
+ * @return le package par défaut du générator donné
+ */
+ public static String getDefaultPackage(Generator generator) {
+ String packageName = generator.getProperty(PROPERTY_DEFAULT_PACKAGE);
+ if (packageName == null || "".equals(packageName)) {
+ packageName = DEFAULT_PACKAGE;
+ }
+ return packageName;
+ }
+
+ /**
+ * Indique si l'élément spécifié dispose de documentation
+ *
+ * @param element l'élément à tester
+ * @return true s'il y a documentation, false sinon
+ */
+ public static boolean hasDocumentation(ObjectModelElement element) {
+ return notEmpty(element.getDocumentation());
+ }
+
+ /**
+ * Indique si la chaine de caratère n'est pas vide (null ou "")
+ *
+ * @param s la chaine de caractères à tester
+ * @return true si <code>s</code> n'est pas vide
+ */
+ public static boolean notEmpty(String s) {
+ return (s != null && !"".equals(s));
+ }
+
+ /**
+ * Renvoie l'interface DAO associée à la classe passée en paramètre
+ *
+ * @param clazz la classe à tester
+ * @param model le modele utilisé
+ * @return l'interface trouvée ou null sinon
+ */
+ public static ObjectModelInterface getDAOInterface(ObjectModelClass clazz,
+ ObjectModel model) {
+ for (Object o : model.getInterfaces()) {
+ ObjectModelInterface daoInterface = (ObjectModelInterface) o;
+ if (daoInterface.getName().equals(clazz.getName() + "DAO")) {
+ if (daoInterface.hasStereotype(STEREOTYPE_DAO)) {
+ return daoInterface;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Renvoie le type de persistence pour l'élément donné. Si aucun n'est
+ * trouvé, le type par défaut est utilisé
+ *
+ * @param element l'élément à tester
+ * @return le type de persitence pour l'élément donné.
+ */
+ public static String getPersistenceType(ObjectModelElement element) {
+ String tag = element.getTagValue(TAG_PERSISTENCE_TYPE);
+ if (tag == null) {
+ tag = PERSISTENCE_TYPE_DEFAULT;
+ }
+ return tag;
+ }
+
+ public static String getReverseDBName(ObjectModelAttribute attr) {
+ if (attr.getReverseAttribute() != null) {
+ return getDBName(attr.getReverseAttribute());
+ } else {
+ return getDBName(attr) + "_id";
+ }
+ }
+
+ /**
+ * Renvoie le nom BD de l'élement passé en paramètre. Elle se base sur le
+ * tag associé si il existe, sinon sur le nom de l'élément
+ *
+ * @param element l'élément à tester
+ * @return le nom de table
+ */
+ public static String getDBName(ObjectModelElement element) {
+ if (element == null) {
+ return null;
+ }
+ if (notEmpty(element.getTagValue(TAG_DB_NAME))) {
+ return element.getTagValue(TAG_DB_NAME);
+ }
+ return toLowerCaseFirstLetter(element.getName());
+ }
+
+ /**
+ * Cherche et renvoie le schema a utiliser sur cet element, sinon sur le model.
+ *
+ * @param element l'élément à tester
+ * @param model le modele utilisé
+ * @return le nom du schema ou null
+ */
+ public static String getSchemaName(ObjectModelElement element,
+ ObjectModel model) {
+ return findTagValue(TAG_SCHEMA_NAME, element, model);
+ }
+
+ /**
+ * Cherche et renvoie le prefixe i18n à utiliser sur cet element, sinon sur le model.
+ *
+ * @param element l'élément à tester
+ * @param model le modele utilisé
+ * @return le prefix i18n ou <code>null</code> si non spécifié
+ */
+ public static String getI18nPrefix(ObjectModelElement element,
+ ObjectModel model) {
+ return findTagValue(TAG_I18N_PREFIX, element, model);
+ }
+
+ /**
+ * Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
+ *
+ * @param clazz la classe à tester
+ * @return la liste des attributs de la clef métier ou null si pas de clef métier.
+ */
+ public static List<String> getNaturalId(ObjectModelClass clazz) {
+ String value = clazz.getTagValue(TAG_NATURAL_ID);
+ if (value == null || value.trim().isEmpty()) {
+ return java.util.Collections.emptyList();
+ }
+ List<String> result = new ArrayList<String>();
+ for (String attribute : value.split(",")) {
+ result.add(attribute.trim());
+ }
+ return result;
+ }
+
+ /**
+ * Detecte si un attribut fait partie d'une clef metier.
+ *
+ * @param attribute l'attribut à tester
+ * @return <code>true</code> si l'attribut fait partie d'une clef metier, <code>false</cdoe> sinon.
+ */
+ public static boolean isNaturalId(ObjectModelAttribute attribute) {
+ String value = attribute.getTagValue(TAG_NATURAL_ID);
+ if (!notEmpty(value)) {
+ // valeur null, donc pas positionnee
+ return false;
+ }
+ try {
+ return Boolean.valueOf(value.trim());
+ } catch (Exception e) {
+ // on a pas reussi a convertir en boolean.
+ //todo peut-être declancher une exception ?
+ return false;
+ }
+ }
+
+ /**
+ * Cherches et renvoie le copyright a utiliser sur le model.
+ *
+ * @param model le modele utilisé
+ * @return le texte du copyright ou null
+ */
+ public static String getCopyright(Model model) {
+ return findTagValue(TAG_COPYRIGHT, null, model);
+ }
+
+ /**
+ * Cherches et renvoie la valeur du tagvalue indique sur cet element,
+ * sinon sur le model.
+ *
+ * @param tagName le nom du tag
+ * @param element l'élément à tester
+ * @param model le modele utilisé
+ * @return la valeur du tagValue ou null
+ */
+ public static String findTagValue(String tagName,
+ ObjectModelElement element, Model model) {
+ if (element == null) {
+ if (model != null) {
+ if (notEmpty(model.getTagValue(tagName))) {
+ return model.getTagValue(tagName);
+ }
+ }
+ return null;
+ }
+ if (notEmpty(element.getTagValue(tagName))) {
+ return element.getTagValue(tagName);
+ }
+ //On va chercher sur l'element declarant
+ return findTagValue(tagName, element.getDeclaringElement(), model);
+ }
+
+ public static <Type extends ObjectModelElement> Collection<Type> getElementsWithStereotype(
+ Collection<Type> elements, String... stereotypes) {
+ Collection<Type> result = new ArrayList<Type>();
+ for (Type element : elements) {
+ if (hasStereotypes(element, stereotypes)) {
+ result.add(element);
+ }
+ }
+ return result;
+ }
+
+ public static boolean hasStereotypes(ObjectModelElement element,
+ String... stereotypes) {
+ for (String stereotype : stereotypes) {
+ if (!element.hasStereotype(stereotype)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static String getPrimaryKeyAttributesListDeclaration(
+ ObjectModelClass clazz, boolean includeName) {
+ String attributes = "";
+ for (ObjectModelAttribute attr : getElementsWithStereotype(clazz
+ .getAttributes(), STEREOTYPE_PRIMARYKAY)) {
+ attributes += attr.getType();
+ if (includeName) {
+ attributes += " " + attr.getName();
+ }
+ attributes += ", ";
+ }
+ if (attributes.length() > 0) {
+ attributes = attributes.substring(0, attributes.length() - 2);
+ }
+ return attributes;
+ }
+
+ public static String capitalize(String s) {
+ return StringUtils.capitalize(s);
+ }
+
+ public static boolean isAssociationClassDoublon(ObjectModelAttribute attr) {
+ return (attr.getReverseAttribute() != null)
+ && (attr.getDeclaringElement().equals(attr
+ .getReverseAttribute().getDeclaringElement()))
+ && (!GeneratorUtil.isFirstAttribute(attr));
+ }
+
+ /**
+ * Renvoie le nom de l'attribut de classe d'association en fonction des cas:
+ * Si l'attribut porte le même nom que le type (extrémité inverse de
+ * l'association), on lui ajoute le nom de la classe d'association
+ *
+ * @param attr l'attribut a traiter
+ * @return le nom de l'attribut de classe d'association
+ */
+ public static String getAssocAttrName(ObjectModelAttribute attr) {
+ String typeName = attr.getType().substring(
+ attr.getType().lastIndexOf(".") + 1);
+ String result = attr.getName();
+ if (attr.getName().equalsIgnoreCase(typeName)) {
+ result += TopiaGeneratorUtil.capitalize(attr.getAssociationClass()
+ .getName());
+ }
+ return result;
+ }
+
+ public static String getDOType(ObjectModelElement elem, ObjectModel model) {
+ String type = elem.getName();
+ if (elem instanceof ObjectModelAttribute) {
+ type = ((ObjectModelAttribute) elem).getType();
+ }
+ if (elem instanceof ObjectModelClass) {
+ type = ((ObjectModelClass) elem).getQualifiedName();
+ }
+ return getDOType(type, model);
+ }
+
+ public static String getDOType(String type, ObjectModel model) {
+ if (!model.hasClass(type)) {
+ return type;
+ }
+ ObjectModelClass clazz = model.getClass(type);
+ if (clazz.hasStereotype(STEREOTYPE_ENTITY)) {
+ if (shouldBeAbstract(clazz)) {
+ type += "Abstract";
+ } else {
+ type += "Impl";
+ }
+ }
+ return type;
+ }
+
+ private static final Set<String> numberTypes = new HashSet<String>();
+ private static final Set<String> textTypes = new HashSet<String>();
+ private static final Set<String> booleanTypes =new HashSet<String>();
+ private static final Set<String> primitiveTypes =new HashSet<String>();
+ private static final String VOID_TYPE = "void";
+
+ static {
+ numberTypes.add("byte");
+ numberTypes.add("java.lang.Byte");
+ numberTypes.add("short");
+ numberTypes.add("java.lang.Short");
+ numberTypes.add("int");
+ numberTypes.add("java.lang.Integer");
+ numberTypes.add("long");
+ numberTypes.add("java.lang.Long");
+ numberTypes.add("float");
+ numberTypes.add("java.lang.Float");
+ numberTypes.add("double");
+ numberTypes.add("java.lang.Double");
+
+ textTypes.add("char");
+ textTypes.add("java.lang.Char");
+ textTypes.add("java.lang.String");
+
+ booleanTypes.add("boolean");
+ booleanTypes.add("java.lang.Boolean");
+
+ primitiveTypes.addAll(numberTypes);
+ primitiveTypes.addAll(textTypes);
+ primitiveTypes.addAll(booleanTypes);
+ }
+
+ public static boolean isNumericType(ObjectModelAttribute attr) {
+ return numberTypes.contains(attr.getType());
+ }
+
+ public static boolean isTextType(ObjectModelAttribute attr) {
+ return textTypes.contains(attr.getType());
+ }
+
+ public static boolean isDateType(ObjectModelAttribute attr) {
+ return "java.util.Date".equals(attr.getType());
+ }
+
+ public static boolean isBooleanType(ObjectModelAttribute attr) {
+ return booleanTypes.contains(attr.getType());
+ }
+
+ public static boolean isPrimitiveType(ObjectModelAttribute attr) {
+ return primitiveTypes.contains(attr.getType());
+ }
+
+ /**
+ * Indique si la classe specifiee n'a aucune ou que des methodes abstraites
+ *
+ * @param clazz l'instance de ObjectModelClass
+ * @return true si la classe n'a que des operations abstraite ou aucune
+ * operation
+ */
+ public static boolean hasNothingOrAbstractMethods(ObjectModelClass clazz) {
+ boolean result = true;
+ Iterator operations = clazz.getOperations().iterator();
+ while (result && operations.hasNext()) {
+ ObjectModelOperation op = (ObjectModelOperation) operations.next();
+ result = op.isAbstract();
+ }
+ return result;
+ }
+
+ /**
+ * Indique si la classe specifiee devrait etre abstraite
+ *
+ * @param clazz l'instance de ObjectModelClass
+ * @return true dans ce cas, false sinon
+ */
+ public static boolean shouldBeAbstract(ObjectModelClass clazz) {
+ return clazz != null
+ && (clazz.isAbstract() && hasNothingOrAbstractMethods(clazz));
+ }
+
+ /**
+ * <p>
+ * Cette méthode permet de détecter si
+ * - l'attribut représente une relation 1-n
+ * - cette relation est unidirectionnelle
+ * - le type de l'attribut représente un entité
+ * - cette entité a des sous-classes dans le modèle
+ * <p/>
+ * Ce cas correspond à une incompatibilité d'Hibernate qui nous oblige a
+ * adopter un comportement particulier.
+ * </p>
+ *
+ * @param attr l'attribut a tester
+ * @param model le model
+ * @return true si et seulement si il s'agit bien de ce type de relation
+ */
+ public static boolean hasUnidirectionalRelationOnAbstractType(
+ ObjectModelAttribute attr, ObjectModel model) {
+ ObjectModelAttribute reverse = attr.getReverseAttribute();
+ //relation 1-n
+ if (reverse != null && isNMultiplicity(attr)
+ && !isNMultiplicity(reverse)) {
+ //Pas de navigabilité
+ if (!reverse.isNavigable()) {
+ //Il s'agit d'une entity
+ ObjectModelClass clazz = model.getClass(attr.getType());
+ if (clazz != null && clazz.hasStereotype(STEREOTYPE_ENTITY)) {
+ //Cette classe a des sous-classes dans le modèle
+ for (ObjectModelClass subClass : model.getClasses()) {
+ if (subClass.getSuperclasses().contains(clazz)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Renvoie le nom unique de table pour une relation ManyToMany en fonction
+ * de l'attribut <code>attr</code>
+ * <p/>
+ * Plusieurs cas de figure:
+ * <li>
+ *
+ * @param attr l'attribut servant de base au calcul du nom
+ * @return le nom de la table
+ */
+ public static String getManyToManyTableName(ObjectModelAttribute attr) {
+ String result;
+
+ if (attr.hasAssociationClass()) {
+ result = TopiaGeneratorUtil.getDBName(attr.getAssociationClass());
+ } else {
+ String name = attr.getName();
+ String revers = attr.getReverseAttributeName();
+
+ if (name.compareToIgnoreCase(revers) < 0) {
+ result = name + "_" + revers;
+ } else {
+ result = revers + "_" + name;
+ }
+ }
+ // String result;
+ // if (!Util.isFirstAttribute(attr)) {
+ // result = attr.getDeclaringElement().getName() + "_" + attr.getReverseAttribute().getDeclaringElement().getName();
+ // } else {
+ // result = attr.getReverseAttribute().getDeclaringElement().getName() + "_" + attr.getDeclaringElement().getName();
+ // }
+ return result.toLowerCase();
+ }
+
+ /**
+ * Renvoie le type d'interface à utiliser en fonction de l'attribut
+ *
+ * @param attr l'attribut a traiter
+ * @return String
+ */
+ public static String getNMultiplicityInterfaceType(ObjectModelAttribute attr) {
+ if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
+ return Set.class.getName();
+ } else if (attr.isIndexed() || attr.isOrdered()) {
+ return List.class.getName();
+ }
+ return Collection.class.getName();
+ }
+
+ /**
+ * Renvoie le type d'objet (instance) à utiliser en fonction de l'attribut
+ *
+ * @param attr l'attribut a traiter
+ * @return String
+ */
+ public static String getNMultiplicityObjectType(ObjectModelAttribute attr) {
+ if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
+ return HashSet.class.getName();
+ } else if (attr.isIndexed() || attr.isOrdered()) {
+ //On considère qu'on ne sait pas traiter vraiment l'attribut "ordered"
+ // puisqu'on va conserver l'ordre d'insertion, et non un ordre en
+ // fonction d'un élément donné. Donc on renvoi une ArrayList
+ return ArrayList.class.getName();
+ }
+ LinkedList.class.getName();
+ return ArrayList.class.getName();
+ }
+
+ /**
+ * Renvoie le type d'interface à utiliser en fonction de l'attribut
+ *
+ * @param attr l'attribut a traiter
+ * @return String
+ */
+ public static String getNMultiplicityHibernateType(ObjectModelAttribute attr) {
+ if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
+ return "set";
+ } else if (attr.isIndexed()) {
+ return "list";
+ }
+ //attr.isOrdered() - On génère le ordered en bag
+ return "bag";
+ }
+
+ /**
+ * Obtain the list of entities classes with the possibility to sort the result.
+ *
+ * @param model the current model to scan
+ * @param sort flag to allow sort the result
+ * @return the list of filtred classes by their stereotype
+ */
+ public static List<ObjectModelClass> getEntityClasses(ObjectModel model,
+ boolean sort) {
+ return getClassesByStereotype(STEREOTYPE_ENTITY, model, sort);
+ }
+
+ /**
+ * Obtain the list of classes for a given stereotype with the possibility to sort the result.
+ *
+ * @param stereotype filter stereotype
+ * @param model the current model to scan
+ * @param sort flag to allow sort the result
+ * @return the list of filtred classes by their stereotype
+ */
+ public static List<ObjectModelClass> getClassesByStereotype(
+ String stereotype, ObjectModel model, boolean sort) {
+ List<ObjectModelClass> classes = new ArrayList<ObjectModelClass>();
+ for (ObjectModelClass clazz : model.getClasses()) {
+ if (clazz.hasStereotype(stereotype)) {
+ classes.add(clazz);
+ }
+ }
+ if (sort && !classes.isEmpty()) {
+ java.util.Collections.sort(classes,
+ new java.util.Comparator<ObjectModelClass>() {
+ public int compare(ObjectModelClass o1,
+ ObjectModelClass o2) {
+ return o1.getQualifiedName().compareTo(
+ o2.getQualifiedName());
+ }
+ });
+ }
+ return classes;
+ }
+
+ /**
+ * Detecte si la clef metier d'une classe est mutable ou pas.
+ * <p/>
+ * On respecte la valeur par defaut d'hibernate, à savoir que par default une clef metier est non mutable.
+ *
+ * @param clazz la classe a tester
+ * @return <code>true</code> si le tag value a ete positionne sur la classe via le tag
+ * {@link #TAG_NATURAL_ID_MUTABLE}, , <code>false</code> sinon.
+ */
+ public static boolean isNaturalIdMutable(ObjectModelClass clazz) {
+ String value = clazz.getTagValue(TAG_NATURAL_ID_MUTABLE);
+ if (!notEmpty(value)) {
+ // valeur null, donc par default positionnee
+ return false;
+ }
+ try {
+ return Boolean.valueOf(value.trim());
+ } catch (Exception e) {
+ // on a pas reussi a convertir en boolean.
+ //todo peut-être declancher une exception ?
+ return false;
+ }
+ }
+
+
+ /**
+ * Obtain the list of fqn of object involed in the given class.
+ *
+ * @param aClass the clazz to inspect
+ * @return the list of fqn of attributes
+ */
+ public static List<String> getImports(ObjectModelClass aClass, String... incomingFqns) {
+ Set<String> tmp = new HashSet<String>();
+ tmp.addAll(Arrays.asList(incomingFqns));
+ getImports(aClass, tmp);
+ List<String> result = cleanImports(aClass.getPackageName(),tmp);
+ return result;
+ }
+
+ /**
+ * Obtain the list of fqn of object involed in the given interface.
+ *
+ * @param anInterface the interface to inspect
+ * @return the list of fqn of attributes
+ */
+ public static List<String> getImports(ObjectModelInterface anInterface, String... incomingFqns) {
+ Set<String> tmp = new HashSet<String>();
+ tmp.addAll(Arrays.asList(incomingFqns));
+ getImports(anInterface, tmp);
+ List<String> result = cleanImports(anInterface.getPackageName(),tmp);
+ return result;
+ }
+
+
+ public static String getSimpleName(String fqn) {
+ int lasIndex = fqn.lastIndexOf(".");
+ if (lasIndex==1) {
+ // primitive type
+ return fqn;
+ }
+ return fqn.substring(lasIndex + 1);
+ /*if (lasIndex == aClass.getPackageName().length()) {
+ // same package
+ return fqn.substring(lasIndex + 1);
+ }
+
+ return fqn;*/
+ }
+ /**
+ * Obtain the list of fqn of object involed in the given class.
+ *
+ * @param aClass the class to inspect
+ * @param fqns where to store found fqns
+ */
+ protected static void getImports(ObjectModelClass aClass, Set<String> fqns) {
+ // scan attributes
+ for (ObjectModelAttribute attr : aClass.getAttributes()) {
+ fqns.add(attr.getType());
+ if (isNMultiplicity(attr)) {
+ String collectionType = getNMultiplicityInterfaceType(attr);
+ fqns.add(collectionType);
+ String collectionObject = getNMultiplicityObjectType(attr);
+ fqns.add(collectionObject);
+ }
+ }
+ for (ObjectModelAttribute attribute : aClass.getAllOtherAttributes()) {
+ fqns.add(attribute.getType());
+ }
+ // scan associations
+ if (aClass instanceof ObjectModelAssociationClass) {
+ ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) aClass;
+ for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
+ if (attr == null) {
+ continue;
+ }
+ fqns.add(attr.getType());
+ if (isNMultiplicity(attr)) {
+ String collectionType = getNMultiplicityInterfaceType(attr);
+ fqns.add(collectionType);
+ String collectionObject = getNMultiplicityObjectType(attr);
+ fqns.add(collectionObject);
+ }
+ }
+ }
+ // scan operations
+ for (ObjectModelOperation operation : aClass.getOperations()) {
+ getImports(operation, fqns);
+ }
+ // scan super interfaces
+ for (ObjectModelInterface modelInterface : aClass.getInterfaces()) {
+ fqns.add(modelInterface.getQualifiedName());
+ getImports(modelInterface, fqns);
+ }
+ // scan super classes
+ for (ObjectModelClass modelClass : aClass.getSuperclasses()) {
+ fqns.add(modelClass.getQualifiedName());
+ getImports(modelClass);
+ }
+ }
+
+ /**
+ * Obtain the list of fqn of object involed in the given interface.
+ *
+ * @param anInterface the interface to inspect
+ * @param fqns where to store found fqns
+ */
+ protected static void getImports(ObjectModelInterface anInterface, Set<String> fqns) {
+ // scan operations
+ for (ObjectModelOperation operation : anInterface.getOperations()) {
+ getImports(operation, fqns);
+ }
+ // scan super interfaces
+ for (ObjectModelInterface modelInterface : anInterface.getInterfaces()) {
+ fqns.add(modelInterface.getQualifiedName());
+ getImports(modelInterface, fqns);
+ }
+ }
+
+ /**
+ * Obtain the fqn's list of all involed type in a givne operation.
+ *
+ * @param operation operation to inspect
+ * @param fqns where to store found fqns
+ */
+ protected static void getImports(ObjectModelOperation operation, Set<String> fqns) {
+ String fqn = operation.getReturnType();
+ fqns.add(fqn);
+ for (ObjectModelParameter parameter : operation.getParameters()) {
+ fqns.add(parameter.getType());
+ }
+ }
+
+ /**
+ * Clean a set of fqns, transform it into a {@link List} and sort it.
+ *
+ * @param packageName the current package name
+ * @param fqns the dirty set of fqns
+ * @return the sorted cleaned list of fqns.
+ */
+ protected static List<String> cleanImports(String packageName, Set<String> fqns) {
+ fqns.removeAll(primitiveTypes);
+ fqns.remove(VOID_TYPE);
+ int packageLength = packageName.length();
+ List<String> genericType = new ArrayList<String>();
+ for (Iterator<String> it = fqns.iterator(); it.hasNext();) {
+ String fqn = it.next();
+ int lastIndex = fqn.lastIndexOf(".");
+ if (lastIndex == packageLength) {
+ // same package
+ it.remove();
+ continue;
+ }
+ int genericIndex = fqn.indexOf('<');
+ if (genericIndex!=-1) {
+ genericType.add(fqn.substring(0,genericIndex));
+ it.remove();
+ }
+ }
+ fqns.addAll(genericType);
+
+ ArrayList<String> result = new ArrayList<String>(fqns);
+ java.util.Collections.sort(result);
+ return result;
+ }
+
+} // GeneratorUtil
Modified: topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaRelationValidator.java
===================================================================
--- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaRelationValidator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaRelationValidator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -29,9 +29,6 @@
package org.codelutin.topia.generator;
-import static org.codelutin.generator.Util.isFirstAttribute;
-import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType;
-
import org.codelutin.generator.models.object.ObjectModel;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.validator.ObjectModelValidator;
@@ -68,7 +65,7 @@
/* Relation navigabilité */
//Pour ne pas avoir de doublons, on ne vérifie que sur le premier
//attribut par ordre alphabétique
- if (isFirstAttribute(attr)) {
+ if (TopiaGeneratorUtil.isFirstAttribute(attr)) {
if (!attr.isNavigable() && !reverse.isNavigable()) {
addError(attr, "La relation entre " + "\"" + reverse.getType()
+ "\"[" + attr.getName() + "] et " + "\""
@@ -79,7 +76,7 @@
}
/* Relation héritage */
- if (hasUnidirectionalRelationOnAbstractType(attr, model)) {
+ if (TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType(attr, model)) {
isValid = false;
addError(
attr,
Modified: topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java
===================================================================
--- topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -16,7 +16,7 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/
package org.codelutin.topia.generator;
-import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
import java.io.File;
import java.io.IOException;
@@ -29,7 +29,7 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.Generator;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
@@ -80,7 +80,7 @@
@Override
public void generateFromInterface(Writer output, ObjectModelInterface interfacez) throws IOException {
- if (!interfacez.hasStereotype(GeneratorUtil.STEREOTYPE_SERVICE)) {
+ if (!interfacez.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) {
return;
}
@@ -104,8 +104,9 @@
}
private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ String classifierName = classifier.getName();
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
@@ -117,13 +118,11 @@
import org.codelutin.topia.service.TopiaApplicationServiceAbstract;
import org.codelutin.topia.framework.TopiaContextImplementor;}*/
- // <%=clazz.getName()%>DAOAbstract
classifier.getInterfaces();
// ajouter les imports des interfaces de DAO
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
- if(parent.hasStereotype(GeneratorUtil.STEREOTYPE_DAO)){
- // r�cup�rer la classe de l'object model correspondant � la DAO
+ for (ObjectModelInterface parent : classifier.getInterfaces()) {
+ if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
+ // récupérer la classe de l'object model correspondant à la DAO
String className = parent.getQualifiedName().replace("DAO", "");
String interfaceName = parent.getQualifiedName()+"Abstract";
/*{
@@ -132,8 +131,7 @@
}
}
- if (GeneratorUtil.hasDocumentation(classifier)) {
-
+ if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
/*{
/**
*
@@ -143,49 +141,53 @@
}
/*{
-public abstract class <%=classifier.getName()+"Abstract"%> extends TopiaApplicationServiceAbstract implements <%=classifier.getName()%>{ }*/
+public abstract class <%=classifierName%>Abstract extends TopiaApplicationServiceAbstract implements <%=classifierName%>{ }*/
}
private void generateMethodsGetter(Writer output, ObjectModelClassifier classifier) throws IOException {
/*{ public String[] getMethods(){
return methods;
}
-}*/
+}*/
}
private void generateInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator it = classifier.getOperations().iterator(); it.hasNext();) {
- ObjectModelOperation op = (ObjectModelOperation)it.next();
+ for (ObjectModelOperation op : classifier.getOperations()) {
+ String opName = op.getName();
+ String opVisibility = op.getVisibility();
+ String opType = op.getReturnType();
/*{
/**
* Implementation a la charge du developpeur
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
-/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
+ String opDocumentation = op.getDocumentation();
+/*{ * <%=opName%> : <%=opDocumentation%>
}*/
}
Collection<ObjectModelParameter> params = (Collection<ObjectModelParameter>)op.getParameters();
for(ObjectModelParameter param : params) {
- if(log.isTraceEnabled()) {log.trace("Param" + param);}
-/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%>
+ String paramName = param.getName();
+ String paramDocumentation = param.getDocumentation();
+/*{ * @param <%=paramName%> <%=paramDocumentation%>
}*/
}
/*{ *)
- <%=op.getVisibility()%> abstract <%=op.getReturnType()%> <%=op.getName()%>(}*/
- String vir = "";
+ <%=opVisibility%> abstract <%=opType%> <%=opName%>(}*/
+ String comma = "";
for(ObjectModelParameter param : params){
- if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
-/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
- vir = ", ";
+ String paramName = param.getName();
+ String paramType = param.getType();
+/*{<%=comma%><%=paramType%> <%=paramName%>}*/
+ comma = ", ";
}
/*{)}*/
Set<String> exceptions = (Set<String>)op.getExceptions();
- vir = " throws ";
+ comma = " throws ";
for (String exception : exceptions) {
- if(log.isTraceEnabled()) {log.trace("exception" + exception + " vir" + vir);}
-/*{<%=vir%><%=exception%>}*/
- vir = ", ";
+/*{<%=comma%><%=exception%>}*/
+ comma = ", ";
}
/*{;
@@ -195,81 +197,81 @@
private void generateInheritedInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelInterface parent : classifier.getInterfaces()) {
// pour tous les DAOInterface
- if(parent.hasStereotype(GeneratorUtil.STEREOTYPE_DAO)){
+ if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
- // r�cup�rer la classe de l'object model correspondant � la DAO
+ // récupérer la classe de l'object model correspondant à la DAO
String entityClassName = parent.getQualifiedName().replace("DAO", "");
if(getModel().hasClass(entityClassName)){
ObjectModelClass clazz = getModel().getClass(entityClassName);
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
/*{
/**
- * Supprime l'entite <%=clazz.getName()%> passee en parametre
+ * Supprime l'entite <%=clazzName%> passee en parametre
* @param entity l'entite a supprimer
*)
- public void delete<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException{
+ public void delete<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
dao.delete(entity);
}
/**
- * Creer l'entite <%=clazz.getName()%> avec les proprietes passees en parametre
+ * Creer l'entite <%=clazzName%> avec les proprietes passees en parametre
* @param properties les proprietes de l'entite a creer
*)
- public <%=clazz.getQualifiedName()%> create<%=clazz.getName()%>(Object ... properties) throws TopiaException{
+ public <%=clazzFQN%> create<%=clazzName%>(Object ... properties) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>) dao.create(properties);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>) dao.create(properties);
return entity;
}
/**
- * Mise a jour de l'entite <%=clazz.getName()%> passee en parametre
+ * Mise a jour de l'entite <%=clazzName%> passee en parametre
* @param entity l'entite a mettre a jour
*)
- public <%=clazz.getQualifiedName()%> update<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException{
+ public <%=clazzFQN%> update<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entit = (<%=clazz.getName()%>) dao.update(entity);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entit = (<%=clazzName%>) dao.update(entity);
return entit;
}
/**
- * Retourne tous les <%=clazz.getName()%>
+ * Retourne tous les <%=clazzName%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>() throws TopiaException {
+ public List<<%=clazzFQN%>> findAll<%=clazzName%>() throws TopiaException {
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> result = dao.findAll();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ List<<%=clazzName%>> result = dao.findAll();
return result;
}
/**
- * Retourne le <%=clazz.getName()%> par son TopiaId
- * @return le <%=clazz.getName()%>
+ * Retourne le <%=clazzName%> par son TopiaId
+ * @return le <%=clazzName%>
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>ByTopiaId(String v) throws TopiaException {
+ public <%=clazzFQN%> find<%=clazzName%>ByTopiaId(String v) throws TopiaException {
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(v);
return entity;
}
}*/
- for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
if (!attr.isNavigable()) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, false);
} else {
generateNMultiplicity(output, attr, clazz, false);
@@ -278,11 +280,9 @@
if (clazz instanceof ObjectModelAssociationClass) {
ObjectModelAssociationClass assocClass = (ObjectModelAssociationClass)clazz;
- Iterator it = assocClass.getParticipantsAttributes().iterator();
- while (it.hasNext()) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : assocClass.getParticipantsAttributes()) {
if (attr != null) {
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, true);
} else {
generateNMultiplicity(output, attr, clazz, true);
@@ -298,8 +298,10 @@
protected void generateNoNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
String propertyName = attr.getName();
if (!isAssoc && attr.hasAssociationClass()) {
- propertyName = GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
+ propertyName = TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
}
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
@@ -307,10 +309,10 @@
* @param v la valeur que doit avoir <%=attr.getName()%>
* @return un element ou null
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
+ public <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = dao.findBy<%=GeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = dao.findBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entity;
};
@@ -320,10 +322,10 @@
* @param v la valeur que doit avoir <%=attr.getName()%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
+ public List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> entityList = dao.findAllBy<%=GeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ List<<%=clazzName%>> entityList = dao.findAllBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entityList;
};
}*/
@@ -331,27 +333,27 @@
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le parametre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le parametre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
* @return un element ou null
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
+ public <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = dao.findBy<%=GeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = dao.findBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entity;
};
/**
* Retourne les elements ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le param�tre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le param�tre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
+ public List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> entityList = dao.findAllBy<%=GeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ List<<%=clazzName%>> entityList = dao.findAllBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entityList;
};
}*/
@@ -359,6 +361,8 @@
}
protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
/*{
/**
* Retourne le premier element trouve dont l'attribut
@@ -366,10 +370,10 @@
* @param v la valeur que doit contenir <%=attr.getName()%>
* @return un element ou null
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>Contains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
+ public <%=clazzFQN%> find<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>) dao.findContainsProperties("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>) dao.findContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
return entity;
};
@@ -379,10 +383,10 @@
* @param v la valeur que doit contenir <%=attr.getName()%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>Contains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
+ public List<<%=clazzFQN%>> findAll<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> entityList = dao.findAllContainsProperties("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ List<<%=clazzName%>> entityList = dao.findAllContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
return entityList;
};
}*/
@@ -390,10 +394,9 @@
private void generateAssociatedClassOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelInterface parent : classifier.getInterfaces()) {
// pour tous les DAOInterface
- if(parent.hasStereotype(GeneratorUtil.STEREOTYPE_DAO)){
+ if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
// r�cup�rer la classe de l'object model correspondant � la DAO
String entityClassName = null;
@@ -407,73 +410,75 @@
}
private void generateFromDAOClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
- for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
+
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
ObjectModelAttribute reverse = attr.getReverseAttribute();
if (!attr.isNavigable()
&& !hasUnidirectionalRelationOnAbstractType(reverse, model)) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> � positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> � positionner.
*)
- public void set<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.set<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
usedContextImpl.commitTransaction();
}
}*/
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
/*{ * @return La valeur de l'attribut <%=attr.getName()%>.
*)
- public <%=attr.getType()%> get<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=attr.getType()%> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(attr.getName())%>();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ return entity.get<%=GeneratorUtil.capitalize(attr.getName())%>();
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner.
*)
- public void set<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
* @return La valeur de l'attribut <%=attr.getAssociationClass().getName()%>.
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(assocAttrName)%>();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ return entity.get<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
}*/
@@ -482,131 +487,131 @@
if (!attr.hasAssociationClass()) { //M�thodes remplac�es par des add/set sur les classes d'assoc
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � ajouter.
*)
- public void add<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void add<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.add<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.add<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> � ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> � ajouter.
*)
- public void addAll<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void addAll<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.addAll<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.addAll<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> � positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> � positionner.
*)
- public void set<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.set<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � retirer.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � retirer.
*)
- public void remove<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void remove<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.remove<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.remove<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
/*{ * Vide la Collection de <%=attr.getName()%>.
*)
- public void clear<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public void clear<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.clear<%=Util.capitalize(attr.getName())%>();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.clear<%=GeneratorUtil.capitalize(attr.getName())%>();
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � ajouter.
*)
- public void add<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.add<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.add<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> � ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> � ajouter.
*)
- public void addAll<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.addAll<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.addAll<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> � positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> � positionner.
*)
- public void set<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � retirer.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � retirer.
*)
- public void remove<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.remove<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.remove<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
* Vide la Collection de <%=attr.getAssociationClass().getName()%>.
*)
- public void clear<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.clear<%=Util.capitalize(assocAttrName)%>();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.clear<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
}*/
@@ -615,61 +620,61 @@
if (!attr.hasAssociationClass()) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
/*{ * @return La Liste de <%=attr.getName()%>.
*)
- public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(attr.getName())%>();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ return entity.get<%=GeneratorUtil.capitalize(attr.getName())%>();
}
/**
* @return Le nombre d'�l�ments de la collection <%=attr.getName()%>.
*)
- public int size<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public int size<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.size<%=Util.capitalize(attr.getName())%>();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ return entity.size<%=GeneratorUtil.capitalize(attr.getName())%>();
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
/*{ /**
* @return La liste des attributs <%=attr.getAssociationClass().getName()%>.
*)
- public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(assocAttrName)%>();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ return entity.get<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
/**
* @return L'attribut <%=attr.getAssociationClass().getName()%> associ� � la valeur <code>value</code> de l'attribut <%=attr.getName()%>.
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> value) throws TopiaException{
+ public <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(assocAttrName)%>((<%=attr.getType()%>) value);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ return entity.get<%=GeneratorUtil.capitalize(assocAttrName)%>((<%=attr.getType()%>) value);
}
/**
* @return Le nombre d'�l�ments de la collection <%=attr.getName()%>.
*)
- public int size<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.size<%=Util.capitalize(assocAttrName)%>();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ return entity.size<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
}*/
@@ -700,52 +705,56 @@
}
private void generateInterfaceOperationsOfClass(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator it = classifier.getOperations().iterator(); it.hasNext();) {
- ObjectModelOperation op = (ObjectModelOperation)it.next();
+ String classifierName = classifier.getName();
+ for (ObjectModelOperation op : classifier.getOperations()) {
+ String opName = op.getName();
+ String opVisibility = op.getVisibility();
+ String opType = op.getReturnType();
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
-/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
+/*{ * <%=opName%> : <%=op.getDocumentation()%>
}*/
}
Collection<ObjectModelParameter> params = (Collection<ObjectModelParameter>)op.getParameters();
for(ObjectModelParameter param : params) {
- if(log.isTraceEnabled()) {log.trace("Param" + param);}
-/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%>
+ String paramName = param.getName();
+ String paramDocumentation = param.getDocumentation();
+/*{ * @param <%=paramName%> <%=paramDocumentation%>
}*/
}
/*{ *)
- <%=op.getVisibility()%> <%=op.getReturnType()%> <%=op.getName()%>Of<%=classifier.getName()%>(String topiaId}*/
- String vir = ",";
+ <%=opVisibility%> <%=opType%> <%=opName%>Of<%=classifierName%>(String topiaId}*/
+ String comma = ",";
for(ObjectModelParameter param : params){
- if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
-/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
+ String paramName = param.getName();
+ String paramType = param.getType();
+/*{<%=comma%><%=paramType%> <%=paramName%>}*/
}
/*{)}*/
Set<String> exceptions = (Set<String>)op.getExceptions();
if(exceptions.isEmpty()){
/*{throws TopiaException}*/
}
- vir = " throws ";
+ comma = " throws ";
for (String exception : exceptions) {
- if(log.isTraceEnabled()) {log.trace("exception" + exception + " vir" + vir);}
-/*{<%=vir%><%=exception%>}*/
- vir = ", ";
+/*{<%=comma%><%=exception%>}*/
+ comma = ", ";
}
/*{{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=classifier.getName()%>DAOAbstract dao = (<%=classifier.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=classifier.getName()%>.class);
- <%=classifier.getName()%> entity = (<%=classifier.getName()%>)dao.findByTopiaId(topiaId);
+ <%=classifierName%>DAOAbstract dao = (<%=classifierName%>DAOAbstract)usedContextImpl.getDAO(<%=classifierName%>.class);
+ <%=classifierName%> entity = (<%=classifierName%>)dao.findByTopiaId(topiaId);
}*/
if(!op.getReturnType().toString().equalsIgnoreCase("void")){
/*{ return }*/
}
-/*{ entity.<%=op.getName()%>(}*/
- vir = "";
+/*{ entity.<%=opName%>(}*/
+ comma = "";
for(ObjectModelParameter param : params){
- if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
-/*{<%=vir%><%=param.getName()%>}*/
- vir = ", ";
+ String paramName = param.getName();
+/*{<%=comma%><%=paramName%>}*/
+ comma = ", ";
}
/*{);
}
@@ -758,27 +767,28 @@
}
private void generateAssociationAccessors(Writer output, ObjectModelClass clazz, String name, String type) throws IOException {
- /*{ /**
- * @param value La valeur de l'attribut <%=name%> � positionner.
- *)
- public void set<%=Util.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId, <%=type%> value) throws TopiaException{
- TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(name)%>( value);
- }
+ String clazzName = clazz.getName();
+/*{ /**
+ * @param value La valeur de l'attribut <%=name%> à positionner.
+ *)
+ public void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId, <%=type%> value) throws TopiaException{
+ TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.set<%=GeneratorUtil.capitalize(name)%>( value);
+ }
- /**
- * @return La valeur de l'attribut <%=name%>.
- *)
- public <%=type%> get<%=Util.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
- TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(name)%>();
- }
+ /**
+ * @return La valeur de l'attribut <%=name%>.
+ *)
+ public <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
+ TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ return entity.get<%=GeneratorUtil.capitalize(name)%>();
+ }
- }*/
+}*/
}
} //ServiceAbstractGenerator
Modified: topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java
===================================================================
--- topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -76,7 +76,7 @@
@Override
public void generateFromInterface(Writer output, ObjectModelInterface interfacez) throws IOException {
- if (!interfacez.hasStereotype(GeneratorUtil.STEREOTYPE_SERVICE)) {
+ if (!interfacez.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) {
return;
}
@@ -89,7 +89,7 @@
for (Iterator i=interfacez.getInterfaces().iterator(); i.hasNext();) {
ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
// pour tous les DAOInterface
- if(parent.hasStereotype(GeneratorUtil.STEREOTYPE_DAO)){
+ if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
// récupérer la classe de l'object model correspondant à la DAO
String entityClassName = null;
entityClassName = parent.getQualifiedName().replace("DAO", "");
@@ -109,15 +109,15 @@
}
private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ String classifierName = classifier.getName();
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
/*{package <%=classifier.getPackageName()%>;}*/
- if (GeneratorUtil.hasDocumentation(classifier)) {
-
+ if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
/*{
/**
*
@@ -127,7 +127,7 @@
}
/*{
-public class <%=classifier.getName()+"Impl"%> extends <%=classifier.getName()+"Abstract"%>{ }*/
+public class <%=classifierName%>Impl extends <%=classifierName%>Abstract { }*/
}
} //ServiceImplGenerator
Modified: topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java
===================================================================
--- topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -17,7 +17,7 @@
package org.codelutin.topia.generator;
-import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
import java.io.File;
import java.io.IOException;
@@ -31,8 +31,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.Generator;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
@@ -97,7 +97,7 @@
@Override
public void generateFromInterface(Writer output, ObjectModelInterface interfacez) throws IOException {
- if (!interfacez.hasStereotype(GeneratorUtil.STEREOTYPE_SERVICE)) {
+ if (!interfacez.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) {
return;
}
@@ -120,41 +120,44 @@
// methodes du service
public String[] methods = {
}*/
- String vir=" ";
- for(String m : methods){
-/*{ <%=vir%>"<%=m%>"
+ String comma=" ";
+ for(String method : methods){
+/*{ <%=comma%>"<%=method%>"
}*/
- vir=", ";
+ comma=", ";
}
-/*{ }; }*/
-/*{
+/*{ };
+
} //<%=interfacez.getName()%>
}*/
}
private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ String classifierName = classifier.getName();
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
/*{package <%=classifier.getPackageName()%>;
import java.util.List;
+import java.util.Collection;
import org.codelutin.topia.TopiaException;
+import org.codelutin.topia.service.TopiaApplicationService;
}*/
- if (GeneratorUtil.hasDocumentation(classifier)) {
+ if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
+ String documentation = classifier.getDocumentation();
/*{
/**
- * <%=classifier.getDocumentation()%>
+ * <%=documentation%>
*)
}*/
}
-/*{public interface <%=classifier.getName()%> extends }*/
+/*{public interface <%=classifierName%> extends }*/
String extendClass = "";
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelClassifier parent : classifier.getInterfaces()) {
// pas pour les interfaces de DAO
if(!parent.hasStereotype(DAO)){
extendClass += parent.getQualifiedName();
@@ -164,16 +167,15 @@
if (classifier instanceof ObjectModelClass) {
ObjectModelClass clazz = (ObjectModelClass)classifier;
- for (Iterator i=clazz.getSuperclasses().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
- if (parent.hasStereotype(GeneratorUtil.STEREOTYPE_SERVICE)) {
+ for (ObjectModelClass parent : clazz.getSuperclasses()) {
+ if (parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) {
extendClass += parent.getQualifiedName();
}
extendClass += ", ";
}
}
-/*{<%=extendClass%>org.codelutin.topia.service.TopiaApplicationService {
+/*{<%=extendClass%>TopiaApplicationService {
}*/
}
@@ -187,50 +189,51 @@
private void generateInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator it = classifier.getOperations().iterator(); it.hasNext();) {
- ObjectModelOperation op = (ObjectModelOperation)it.next();
-
- String method = op.getReturnType()+ " "+op.getName()+"(";
+ for (ObjectModelOperation op : classifier.getOperations()) {
+ String opName = op.getName();
+ String opVisibility = op.getVisibility();
+ String opType = op.getReturnType();
+ String method = opType + " " + opName + "(";
/*{
/**
- * Methode <%=op.getName()%>.
+ * Methode <%=opName%>.
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
-/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
+ String opDocumentation = op.getDocumentation();
+/*{ * <%=opName%> : <%=opDocumentation%>
}*/
}
Collection<ObjectModelParameter> params = (Collection<ObjectModelParameter>)op.getParameters();
for(ObjectModelParameter param : params) {
- if(log.isTraceEnabled()) {
- log.trace("Param" + param);
- }
- if (GeneratorUtil.hasDocumentation(param)) {
-/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(param)) {
+ String paramName = param.getName();
+ String paramDocumentation = param.getDocumentation();
+/*{ * @param <%=paramName%> <%=paramDocumentation%>
}*/
}
}
/*{ *)
- <%=op.getVisibility()%> <%=op.getReturnType()%> <%=op.getName()%>(}*/
- String vir = "";
+ <%=opVisibility%> <%=opType%> <%=opName%>(}*/
+ String comma = "";
for(ObjectModelParameter param : params){
- method += vir + param.getType()+" "+param.getName();
- if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
-/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
- vir = ", ";
+ String paramName = param.getName();
+ String paramType = param.getType();
+ method += comma + paramType + " " + paramName;
+/*{<%=comma%><%=paramType%> <%=paramName%>}*/
+ comma = ", ";
}
/*{)}*/
- Set<String> exceptions = (Set<String>)op.getExceptions();
- vir = " throws ";
+ Set<String> exceptions = op.getExceptions();
+ comma = " throws ";
for (String exception : exceptions) {
- if(log.isTraceEnabled()) {log.trace("exception" + exception + " vir" + vir);}
-/*{<%=vir%><%=exception%>}*/
- vir = ", ";
+/*{<%=comma%><%=exception%>}*/
+ comma = ", ";
}
/*{;
}*/
// ajout des methodes
- methods.add(method+")");
+ methods.add(method + ")");
}
}
@@ -238,8 +241,7 @@
/*{
// methodes utilisant celles des daos
}*/
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelInterface parent : classifier.getInterfaces()) {
// pour tous les DAOInterface
if(parent.hasStereotype(DAO)){
@@ -248,56 +250,57 @@
entityClassName = parent.getQualifiedName().replace("DAO", "");
if(getModel().hasClass(entityClassName)){
ObjectModelClass clazz = getModel().getClass(entityClassName);
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
// ajouter les methodes à la liste
- methods.add("void delete"+clazz.getName()+"("+clazz.getName()+" entity)");
- methods.add(clazz.getName()+" create"+clazz.getName()+"(Object ... properties)");
- methods.add(clazz.getName()+" update"+clazz.getName()+"("+clazz.getName()+")");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"()");
- methods.add(clazz.getName()+" find"+clazz.getName()+"ByTopiaId(String v)");
+ methods.add("void delete"+clazzName+"("+clazzName+" entity)");
+ methods.add(clazzName+" create"+clazzName+"(Object ... properties)");
+ methods.add(clazzName+" update"+clazzName+"("+clazzName+")");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"()");
+ methods.add(clazzName+" find"+clazzName+"ByTopiaId(String v)");
/*{
/**
- * Supprime l'entite <%=clazz.getName()%> passee en parametre
+ * Supprime l'entite <%=clazzName%> passee en parametre
* @param entity l'entite a supprimer
*)
- public abstract void delete<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException;
+ public abstract void delete<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException;
/**
- * Creer l'entite <%=clazz.getName()%> avec les proprietes passees en parametre
+ * Creer l'entite <%=clazzName%> avec les proprietes passees en parametre
* @param entity l'entite a mettre a jour
*)
- public abstract <%=clazz.getQualifiedName()%> create<%=clazz.getName()%>(Object ... properties) throws TopiaException;
+ public abstract <%=clazzFQN%> create<%=clazzName%>(Object ... properties) throws TopiaException;
/**
- * Mise a jour de l'entite <%=clazz.getName()%> passee en parametre
+ * Mise a jour de l'entite <%=clazzName%> passee en parametre
* @param properties les proprietes de l'entite a creer
*)
- public abstract <%=clazz.getQualifiedName()%> update<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException;
+ public abstract <%=clazzFQN%> update<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException;
/**
- * Retourne tous les <%=clazz.getName()%>
+ * Retourne tous les <%=clazzName%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>() throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>() throws TopiaException;
/**
- * Retourne le <%=clazz.getName()%> par son TopiaId
- * @return le <%=clazz.getName()%>
+ * Retourne le <%=clazzName%> par son TopiaId
+ * @return le <%=clazzName%>
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>ByTopiaId(String v) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>ByTopiaId(String v) throws TopiaException;
}*/
- for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
if (!attr.isNavigable()) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, false);
} else {
generateNMultiplicity(output, attr, clazz, false);
@@ -306,14 +309,12 @@
if (clazz instanceof ObjectModelAssociationClass) {
ObjectModelAssociationClass assocClass = (ObjectModelAssociationClass)clazz;
- Iterator it = assocClass.getParticipantsAttributes().iterator();
- while (it.hasNext()) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : assocClass.getParticipantsAttributes()) {
if (attr != null) {
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, true);
} else {
- generateNMultiplicity(output, attr, clazz, true);
+ generateNMultiplicity(output, attr, clazz, true);
}
}
}
@@ -322,72 +323,82 @@
}
}
}
-
+
protected void generateNoNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
- String propertyName = attr.getName();
+ String attrName = attr.getName();
+ String propertyName = attrName;
+ String attrType = attr.getType();
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
if (!isAssoc && attr.hasAssociationClass()) {
- propertyName = GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
+ propertyName = TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
}
// ajouter les methodes à la liste
- methods.add(clazz.getName()+" find"+clazz.getName()+"By"+GeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+GeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)");
+ methods.add(clazzName+" find"+clazzName+"By"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" v)");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" v)");
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
- * <%=attr.getName()%> le parametre
- * @param v la valeur que doit avoir <%=attr.getName()%>
+ * <%=attrName%> le parametre
+ * @param v la valeur que doit avoir <%=attrName%>
* @return un element ou null
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException;
/**
* Retourne les éléments ayant comme valeur pour l'attribut
- * <%=attr.getName()%> le paramêtre
- * @param v la valeur que doit avoir <%=attr.getName()%>
+ * <%=attrName%> le paramêtre
+ * @param v la valeur que doit avoir <%=attrName%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException;
}*/
if (attr.hasAssociationClass()) {
- methods.add(clazz.getName() +" find"+clazz.getName()+"By"+GeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+GeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)");
+ String assocClassName = attr.getAssociationClass().getName();
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ methods.add(clazzName +" find"+clazzName+"By"+TopiaGeneratorUtil.capitalize(assocClassName)+"("+assocClassFQN+" value)");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+TopiaGeneratorUtil.capitalize(assocClassName)+"("+assocClassFQN+" value)");
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le parametre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> le parametre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>
* @return un element ou null
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException;
/**
* Retourne les éléments ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le paramêtre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> le paramêtre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException;
}*/
}
}
protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
- methods.add(clazz.getName() + " find"+clazz.getName()+"Contains"+GeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"Contains"+GeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)");
+ String attrName = attr.getName();
+ String attrType = attr.getType();
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
+ methods.add(clazzName + " find"+clazzName+"Contains"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" ... v)");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"Contains"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" ... v)");
/*{
/**
* Retourne le premier element trouve dont l'attribut
- * <%=attr.getName()%> contient le parametre
- * @param v la valeur que doit contenir <%=attr.getName()%>
+ * <%=attrName%> contient le parametre
+ * @param v la valeur que doit contenir <%=attrName%>
* @return un element ou null
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>Contains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException;
/**
* Retourne les elements trouve dont l'attribut
- * <%=attr.getName()%> contient le parametre
- * @param v la valeur que doit contenir <%=attr.getName()%>
+ * <%=attrName%> contient le parametre
+ * @param v la valeur que doit contenir <%=attrName%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>Contains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException;
}*/
}
@@ -396,7 +407,7 @@
ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
// pour tous les DAOInterface
if(parent.hasStereotype(DAO)){
- // r�cup�rer la classe de l'object model correspondant à la DAO
+ // récupérer la classe de l'object model correspondant à la DAO
String entityClassName = null;
entityClassName = parent.getQualifiedName().replace("DAO", "");
if(getModel().hasClass(entityClassName)){
@@ -409,59 +420,62 @@
}
private void generateFromDAOClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
- for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ String clazzName = clazz.getName();
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
+ String attrName = attr.getName();
+ String attrType = attr.getType();
ObjectModelAttribute reverse = attr.getReverseAttribute();
if (!attr.isNavigable()
&& !hasUnidirectionalRelationOnAbstractType(reverse, model)) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void set"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+Util.toLowerCaseFirstLetter(attr.getName())+")");
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void set"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+attrType+ " "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> à positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> La valeur de l'attribut <%=attrName%> à positionner.
*)
- public abstract void set<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
}*/
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add(attr.getType()+" get"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add(attrType+" get"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @return La valeur de l'attribut <%=attr.getName()%>.
+/*{ * @return La valeur de l'attribut <%=attrName%>.
*)
- public abstract <%=attr.getType()%> get<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassName = attr.getAssociationClass().getName();
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
- methods.add("void set"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add(attr.getAssociationClass().getName()+" get"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
-
+ methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+assocClassName+" "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add(assocClassName+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId)");
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> La valeur de l'attribut <%=assocClassName%> à positionner.
*)
- public abstract void set<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * @return La valeur de l'attribut <%=attr.getAssociationClass().getName()%>.
+ * @return La valeur de l'attribut <%=assocClassName%>.
*)
- public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
}
@@ -469,93 +483,95 @@
if (!attr.hasAssociationClass()) { //Méthodes remplacées par des add/set sur les classes d'assoc
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void add"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" "+Util.toLowerCaseFirstLetter(attr.getName())+")");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void add"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+attrType+" "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> L'instance de <%=attrName%> à ajouter.
*)
- public abstract void add<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void add<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void addAll"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+Util.toLowerCaseFirstLetter(attr.getName())+")");;
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void addAll"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attrType+"> "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");;
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> à ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> Les instances de <%=attrName%> à ajouter.
*)
- public abstract void addAll<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void addAll<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attrType%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void set"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+ (attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+Util.toLowerCaseFirstLetter(attr.getName())+")");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void set"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+ (attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attrType+"> "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> à positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> La Collection de <%=attrName%> à positionner.
*)
- public abstract void set<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attrType%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void remove"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+Util.toLowerCaseFirstLetter(attr.getName())+")");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void remove"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+attrType+ " "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à retirer.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> L'instance de <%=attrName%> à retirer.
*)
- public abstract void remove<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void remove<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void clear"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void clear"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * Vide la Collection de <%=attr.getName()%>.
+/*{ * Vide la Collection de <%=attrName%>.
*)
- public abstract void clear<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract void clear<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocClassName = attr.getAssociationClass().getName();
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
- methods.add("void add"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void addAll"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void set"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void remove"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void clear"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add("void add"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+assocClassName+" "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add("void addAll"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+assocClassName+"> "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+assocClassName+"> "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add("void remove"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+assocClassName+" "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add("void clear"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId)");
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> L'instance de <%=assocClassName%> à ajouter.
*)
- public abstract void add<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> à ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> Les instances de <%=assocClassName%> à ajouter.
*)
- public abstract void addAll<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"List":"Collection")%><<%=assocClassFQN%>> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> à positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> La Collection de <%=assocClassName%> à positionner.
*)
- public abstract void set<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"List":"Collection")%><<%=assocClassFQN%>> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à retirer.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> L'instance de <%=assocClassName%> à retirer.
*)
- public abstract void remove<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * Vide la Collection de <%=attr.getAssociationClass().getName()%>.
+ * Vide la Collection de <%=assocClassName%>.
*)
- public abstract void clear<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
}
@@ -563,43 +579,45 @@
if (!attr.hasAssociationClass()) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> get"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
- methods.add("int size"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attrType+"> get"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)");
+ methods.add("int size"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @return La Liste de <%=attr.getName()%>.
+/*{ * @return La Liste de <%=attrName%>.
*)
- public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attrType%>> get<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
/**
- * @return Le nombre d'éléments de la collection <%=attr.getName()%>.
+ * @return Le nombre d'éléments de la collection <%=attrName%>.
*)
- public abstract int size<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract int size<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassName = attr.getAssociationClass().getName();
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
- methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> get"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"Of"+clazz.getName()+"(String topiaId)");
- methods.add(attr.getAssociationClass().getName()+" get"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" value)");
- methods.add("int size"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+assocClassName+"> get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"Of"+clazzName+"(String topiaId)");
+ methods.add(assocClassName+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+attrType+" value)");
+ methods.add("int size"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId)");
/*{ /**
- * @return La liste des attributs <%=attr.getAssociationClass().getName()%>.
+ * @return La liste des attributs <%=assocClassName%>.
*)
- public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=assocClassFQN%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
/**
- * @return L'attribut <%=attr.getAssociationClass().getName()%> associé à la valeur <code>value</code> de l'attribut <%=attr.getName()%>.
+ * @return L'attribut <%=assocClassName%> associé à la valeur <code>value</code> de l'attribut <%=attrName%>.
*)
- public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> value) throws TopiaException;
+ public abstract <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> value) throws TopiaException;
/**
- * @return Le nombre d'éléments de la collection <%=attr.getName()%>.
+ * @return Le nombre d'éléments de la collection <%=attrName%>.
*)
- public abstract int size<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
}
@@ -634,7 +652,7 @@
String method = op.getReturnType()+ " "+op.getName()+"(";
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
}*/
}
@@ -675,17 +693,18 @@
}
private void generateAssociationAccessors(Writer output, ObjectModelClass clazz, String name, String type) throws IOException {
- methods.add("=> "+"void set"+Util.capitalize(name)+"Of"+clazz.getName()+"(String topiaId, "+type+" value)");
- methods.add("=> "+type+" get"+Util.capitalize(name)+"Of"+clazz.getName()+"(String topiaId)");
+ String clazzName = clazz.getName();
+ methods.add("=> "+"void set"+GeneratorUtil.capitalize(name)+"Of"+clazzName+"(String topiaId, "+type+" value)");
+ methods.add("=> "+type+" get"+GeneratorUtil.capitalize(name)+"Of"+clazzName+"(String topiaId)");
/*{ /**
* @param value La valeur de l'attribut <%=name%> à positionner.
*)
- public abstract void set<%=Util.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId, <%=type%> value) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId, <%=type%> value) throws TopiaException;
/**
* @return La valeur de l'attribut <%=name%>.
*)
- public abstract <%=type%> get<%=Util.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
}
Modified: topia/trunk/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java
===================================================================
--- topia/trunk/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
+++ topia/trunk/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java 2009-01-29 15:47:42 UTC (rev 1334)
@@ -30,7 +30,7 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.MonitorWriter;
import org.codelutin.generator.StateModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.state.StateModel;
import org.codelutin.generator.models.state.StateModelComplexState;
import org.codelutin.generator.models.state.StateModelSimpleState;
@@ -105,7 +105,7 @@
* @return name
*/
protected String getNameFromState(StateModelState state) {
- return "Abstract" + Util.toUpperCaseFirstLetter(state.getName());
+ return "Abstract" + GeneratorUtil.toUpperCaseFirstLetter(state.getName());
}
/**
@@ -202,7 +202,7 @@
* @throws IOException
*/
protected void generateFromSimpleState(Writer output, StateModelStateChart chart, StateModelState state) throws IOException {
- //String copyright = GeneratorUtil.getCopyright(model);
+ //String copyright = GeneratorGeneratorUtil.getCopyright(model);
String copyright = model.getTagValue("copyright");
if (copyright != null && !copyright.isEmpty()) {
/*{<%=copyright%>
@@ -256,21 +256,21 @@
/*{
/* linked state "<%=toState.getName()%>" *)
@InjectPage
- private <%=Util.toUpperCaseFirstLetter(toInitState.getName())%> <%=Util.toLowerCaseFirstLetter(toInitState.getName())%>;
+ private <%=GeneratorUtil.toUpperCaseFirstLetter(toInitState.getName())%> <%=GeneratorUtil.toLowerCaseFirstLetter(toInitState.getName())%>;
}*/
// l'attribut etant prive, il faut un getter
/*{
/* getter for state "<%=toState.getName()%>" *)
- protected <%=Util.toUpperCaseFirstLetter(toInitState.getName())%> get<%=Util.toUpperCaseFirstLetter(toInitState.getName())%>() {
- return <%=Util.toLowerCaseFirstLetter(toInitState.getName())%>;
+ protected <%=GeneratorUtil.toUpperCaseFirstLetter(toInitState.getName())%> get<%=GeneratorUtil.toUpperCaseFirstLetter(toInitState.getName())%>() {
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(toInitState.getName())%>;
}
}*/
}
/*{
/* transition on <%=transition.getEvent()%> event *)
- public Object onActionFrom<%=Util.toUpperCaseFirstLetter(transition.getEvent())%>() {
+ public Object onActionFrom<%=GeneratorUtil.toUpperCaseFirstLetter(transition.getEvent())%>() {
enterUseCase();
- return <%=Util.toLowerCaseFirstLetter(toInitState.getName())%>;
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(toInitState.getName())%>;
}
}*/
}
@@ -287,26 +287,26 @@
/*{
/* linked state "<%=simpleToState.getName()%>" *)
@InjectPage
- private <%=Util.toUpperCaseFirstLetter(simpleToState.getName())%> <%=Util.toLowerCaseFirstLetter(simpleToState.getName())%>;
+ private <%=GeneratorUtil.toUpperCaseFirstLetter(simpleToState.getName())%> <%=GeneratorUtil.toLowerCaseFirstLetter(simpleToState.getName())%>;
}*/
// l'attribut etant prive, il faut un getter
/*{
/* getter for state "<%=simpleToState.getName()%>" *)
- protected <%=Util.toUpperCaseFirstLetter(simpleToState.getName())%> get<%=Util.toUpperCaseFirstLetter(simpleToState.getName())%>() {
- return <%=Util.toLowerCaseFirstLetter(simpleToState.getName())%>;
+ protected <%=GeneratorUtil.toUpperCaseFirstLetter(simpleToState.getName())%> get<%=GeneratorUtil.toUpperCaseFirstLetter(simpleToState.getName())%>() {
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(simpleToState.getName())%>;
}
}*/
}
} // isFinal
/*{
/* transition on "<%=transition.getEvent()%>" event *)
- public Object onActionFrom<%=Util.toUpperCaseFirstLetter(transition.getEvent())%>() {
+ public Object onActionFrom<%=GeneratorUtil.toUpperCaseFirstLetter(transition.getEvent())%>() {
}*/
if(simpleToState.isFinal()) {
/*{ return leaveUseCase();
}*/
} else {
-/*{ return <%=Util.toLowerCaseFirstLetter(simpleToState.getName())%>;
+/*{ return <%=GeneratorUtil.toLowerCaseFirstLetter(simpleToState.getName())%>;
}*/
}
/*{ }
1
0
r1333 - in topia/branches/generators-refactoring: . topia-persistence topia-persistence/src/main/java/org/codelutin/topia/generator
by tchemit@users.labs.libre-entreprise.org 29 Jan '09
by tchemit@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: tchemit
Date: 2009-01-29 15:09:31 +0000 (Thu, 29 Jan 2009)
New Revision: 1333
Modified:
topia/branches/generators-refactoring/changelog.txt
topia/branches/generators-refactoring/pom.xml
topia/branches/generators-refactoring/topia-persistence/changelog.txt
topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityAbstractGenerator.java
topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java
topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaGeneratorUtil.java
Log:
- use lutinproject 3.4
- add methods in TopiaGeneratorUtil class to optimize imports
- optimize imports on EntityAbstractGenerator
- fix missing space on HibernateMappingGenerator
Modified: topia/branches/generators-refactoring/changelog.txt
===================================================================
--- topia/branches/generators-refactoring/changelog.txt 2009-01-29 14:22:19 UTC (rev 1332)
+++ topia/branches/generators-refactoring/changelog.txt 2009-01-29 15:09:31 UTC (rev 1333)
@@ -1,5 +1,6 @@
2.1.3 ??? 200902??
* 20090126 [chemit] - refactor poms (all dependencies in parent-pom dependencyManagment)
+ * 20090129 [chemit] - use lutinproject 3.4
2.1.2 chemit 20090115
* 20090114 [chemit] - using lutinproject 3.3
Modified: topia/branches/generators-refactoring/pom.xml
===================================================================
--- topia/branches/generators-refactoring/pom.xml 2009-01-29 14:22:19 UTC (rev 1332)
+++ topia/branches/generators-refactoring/pom.xml 2009-01-29 15:09:31 UTC (rev 1333)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.codelutin</groupId>
<artifactId>lutinproject</artifactId>
- <version>3.3</version>
+ <version>3.4-SNAPSHOT</version>
</parent>
<artifactId>topia</artifactId>
@@ -170,7 +170,8 @@
<lutinutil.version>1.0</lutinutil.version>
<xmlrpc.version>3.1</xmlrpc.version>
<hibernate.version>3.3.1.GA</hibernate.version>
-
+ <!-- todo pour la montee de version voir la doc -->
+ <topia.version>${project.version}</topia.version>
</properties>
<build>
Modified: topia/branches/generators-refactoring/topia-persistence/changelog.txt
===================================================================
--- topia/branches/generators-refactoring/topia-persistence/changelog.txt 2009-01-29 14:22:19 UTC (rev 1332)
+++ topia/branches/generators-refactoring/topia-persistence/changelog.txt 2009-01-29 15:09:31 UTC (rev 1333)
@@ -1,4 +1,7 @@
2.1.3 ??? 200902??
+* 20090129 [chemit] - add methods in TopiaGeneratorUtil class to optimize imports
+* 20090129 [thimel] - ???
+* 20090128 [bpoussin] - introduce Visitor design pattern on generated TopiaEntityAbstract
* 20090126 [chemit] - refactor poms (all dependencies in parent-pom dependencyManagment)
* 20090126 [chemit] - add somes junit tests to check none-regression when modify ToPIA's templates.
- fix generation bug (notNull could ne null (line 226 EntityHibernateMappingGenerator)
Modified: topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityAbstractGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityAbstractGenerator.java 2009-01-29 14:22:19 UTC (rev 1332)
+++ topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityAbstractGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
@@ -45,6 +45,7 @@
import java.io.IOException;
import java.io.Writer;
import java.util.Iterator;
+import java.util.List;
/**
* Generateur d'entites abstraites. Il s'agit de l'implatation par defaut d'une
@@ -89,21 +90,33 @@
}*/
}
String clazzName = clazz.getName();
- String clazzFQN = clazz.getQualifiedName();
+ String clazzFQN = TopiaGeneratorUtil.getSimpleName(clazz.getQualifiedName());
/*{package <%=clazz.getPackageName()%>;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.codelutin.topia.TopiaException;
-import org.codelutin.topia.framework.TopiaContextImplementor;
-import org.codelutin.topia.persistence.TopiaEntity;
-import org.codelutin.topia.persistence.EntityVisitor;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.io.Serializable;
-
+}*/
+ List<String> imports = TopiaGeneratorUtil.getImports(clazz,
+ org.apache.commons.lang.builder.ToStringBuilder.class.getName(),
+ org.codelutin.topia.TopiaException.class.getName(),
+ org.codelutin.topia.framework.TopiaContextImplementor.class.getName(),
+ org.codelutin.topia.persistence.TopiaEntity.class.getName(),
+ TopiaEntityAbstract.class.getName(),
+ org.codelutin.topia.persistence.EntityVisitor.class.getName(),
+ java.util.List.class.getName(),
+ java.util.ArrayList.class.getName(),
+ java.io.Serializable.class.getName()
+ );
+ if (log.isDebugEnabled()) {
+ log.debug("imports for class <" + clazzFQN + ">");
+ }
+ for (String anImport : imports) {
+ if (log.isDebugEnabled()) {
+ log.debug("import " + anImport);
+ }
+/*{import <%=anImport%>;
+}*/
+ }
+/*{
/**
- * Implantation POJO pour l'entité <%=GeneratorUtil.capitalize(clazzName)%>.
+ * Implantation POJO pour l'entité {@link <%=TopiaGeneratorUtil.capitalize(clazzFQN)%>}.
}*/
{
String dbName = clazz.getTagValue(TopiaGeneratorUtil.TAG_DB_NAME);
@@ -123,7 +136,7 @@
// impl ne sera pas créé
boolean abstractParent = false;
if (parent instanceof ObjectModelClass) {
- abstractParent = shouldBeAbstract((ObjectModelClass) parent);
+ abstractParent = shouldBeAbstract(parent);
}
if (parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
if (abstractParent) {
@@ -137,10 +150,10 @@
}
}
if (extendClass.length() == 0) {
- extendClass += TopiaEntityAbstract.class.getName();
+ extendClass += TopiaEntityAbstract.class.getSimpleName();
}
-/*{public abstract class <%=clazzName%>Abstract extends <%=extendClass%> implements Serializable, <%=clazzFQN%> {
+/*{public abstract class <%=clazzName%>Abstract extends <%=extendClass%> implements Serializable, <%=clazzName%> {
}*/
@@ -161,7 +174,6 @@
|| attr.hasAssociationClass())) {
continue;
}
- ;
if (TopiaGeneratorUtil.hasDocumentation(attr) || attr.hasTagValue(TopiaGeneratorUtil.TAG_DB_NAME)) {
/*{ /**
}*/
@@ -187,11 +199,11 @@
String attrVisibility = attr.getVisibility();
// In case attribute is NMultiplicity
- String collectionType = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr);
+ String collectionType = TopiaGeneratorUtil.getSimpleName(TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr));
if (!attr.hasAssociationClass()) {
String attrName = attr.getName();
- String attrType = attr.getType();
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
if (!GeneratorUtil.isNMultiplicity(attr)) {
/*{ <%=attrVisibility%> <%=attrType%> <%=attrName%>;
@@ -203,7 +215,7 @@
}
} else {
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
if (!GeneratorUtil.isNMultiplicity(attr)) {
//TODO THIMEL : Je pense que les GeneratorUtil.toLowerCaseFirstLetter sont inutiles ici, ou alors il faudrait le faire partout
/*{ <%=attrVisibility%> <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
@@ -223,7 +235,7 @@
for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
if (attr != null) {
String attrVisibility = attr.getVisibility();
- String attrType = attr.getType();
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
String attrName = attr.getName();
/*{ <%=attrVisibility%> <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>;
@@ -250,7 +262,9 @@
* Envoi via les methodes du visitor l'ensemble des champs de l'entity
* avec leur type et leur valeur.
*
- * @param visitor : le visiteur de l'entite.
+ * @param visitor : le visiteur de l'entite.
+ *
+ * @throws TopiaException if any pb while visit
*)
public void accept(EntityVisitor visitor) throws TopiaException {
visitor.start(this);
@@ -269,14 +283,14 @@
}
if (!attr.hasAssociationClass()) {
- String attrType = attr.getType();
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
String attrName = attr.getName();
if (!GeneratorUtil.isNMultiplicity(attr)) {
/*{ visitor.visit(this, <%=attrType%>.class, <%=attrName%>);
}*/
} else {
- String collectionType = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr);
+ String collectionType = TopiaGeneratorUtil.getSimpleName(TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr));
/*{ visitor.visit(this, <%=collectionType%>.class, <%=attrType%>.class, <%=attrName%>);
}*/
@@ -284,14 +298,14 @@
} else {
if (!GeneratorUtil.isNMultiplicity(attr)) {
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
/*{ visitor.visit(this, <%=assocClassFQN%>.class, <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>);
}*/
} else {
String collectionType = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr);
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
/*{ visitor.visit(this, <%=collectionType%>.class, <%=assocClassFQN%>.class, <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>);
}*/
@@ -304,7 +318,7 @@
ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz;
for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
if (attr != null) {
- String attrType = attr.getType();
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
String attrName = attr.getName();
/*{ visitor.visit(this, <%=attrType%>.class, <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>);
@@ -367,7 +381,7 @@
}
} else if (attr.hasAssociationClass()) {
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
if (!GeneratorUtil.isNMultiplicity(attr)) {
/*{
if (this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> != null) {
@@ -416,7 +430,7 @@
ObjectModelAttribute reverse = attr.getReverseAttribute();
String attrName = attr.getName();
- String attrType = attr.getType();
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
if (!(attr.isNavigable()
|| hasUnidirectionalRelationOnAbstractType(reverse, model))) {
@@ -447,7 +461,7 @@
}*/
} else {
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
/*{ /* (non-Javadoc)
* @see <%=clazzFQN%>#set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%>)
*)
@@ -468,8 +482,8 @@
}*/
}
} else { //NMultiplicity
- String collectionInterface = TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr);
- String collectionObject = TopiaGeneratorUtil.getNMultiplicityObjectType(attr);
+ String collectionInterface = TopiaGeneratorUtil.getSimpleName(TopiaGeneratorUtil.getNMultiplicityInterfaceType(attr));
+ String collectionObject = TopiaGeneratorUtil.getSimpleName(TopiaGeneratorUtil.getNMultiplicityObjectType(attr));
if (!attr.hasAssociationClass()) { //Méthodes remplacées par des accesseurs sur les classes d'assoc
/*{ /* (non-Javadoc)
* @see <%=clazzFQN%>#add<%=GeneratorUtil.capitalize(attrName)%>(<%=attrType%>)
@@ -483,7 +497,7 @@
if (reverse != null && (reverse.isNavigable() ||
hasUnidirectionalRelationOnAbstractType(attr, model))) {
String reverseAttrName = reverse.getName();
- String reverseAttrType = reverse.getType();
+ String reverseAttrType = TopiaGeneratorUtil.getSimpleName(reverse.getType());
if (!GeneratorUtil.isNMultiplicity(reverse)) {
/*{ <%=attrName%>.set<%=GeneratorUtil.capitalize(reverseAttrName)%>(this);
}*/
@@ -583,7 +597,7 @@
}*/
} else {
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
/*{ /* (non-Javadoc)
* @see <%=clazzFQN%>#add<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=assocClassFQN%>)
*)
@@ -698,7 +712,7 @@
}*/
} else {
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassFQN = TopiaGeneratorUtil.getSimpleName(attr.getAssociationClass().getQualifiedName());
/*{ /* (non-Javadoc)
* @see <%=clazzFQN%>#get<%=GeneratorUtil.capitalize(assocAttrName)%>()
*)
@@ -741,7 +755,7 @@
ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz;
for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
if (attr != null) {
- String attrType = attr.getType();
+ String attrType = TopiaGeneratorUtil.getSimpleName(attr.getType());
String attrName = attr.getName();
generateAssociationAccessors(output, attrName, attrType);
// //Ne sert plus à rien normalement avec la navigabilité
Modified: topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java 2009-01-29 14:22:19 UTC (rev 1332)
+++ topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java 2009-01-29 15:09:31 UTC (rev 1333)
@@ -211,11 +211,11 @@
// / *{ <one-to-one name="<%=getName(attr, true)%>" class="<%=getType(attr, true)%>"<%=(TopiaGeneratorUtil.notEmpty(attr.getTagValue(TopiaGeneratorUtil.TAG_LENGTH))?(" length=\"" + attr.getTagValue(TopiaGeneratorUtil.TAG_LENGTH) + "\""):"")%><%=(attr.isComposite()?" cascade=\"delete\"":"")%>/>
// } */
// } else {
- String notNull = generateFromTagValue(attr, TopiaGeneratorUtil.TAG_NOT_NULL, "not-null");
+ String notNull = " " + generateFromTagValue(attr, TopiaGeneratorUtil.TAG_NOT_NULL, "not-null");
String attrName = getName(attr, true);
String attrType = getType(attr, true);
String attrColumn = TopiaGeneratorUtil.getDBName(attr);
-/*{<%=prefix%> <many-to-one name="<%=attrName%>" class="<%=attrType%>" column="<%=attrColumn%>" node="<%=attrName%>/@topiaId" embed-xml="false"<%=notNull%>/>
+/*{<%=prefix%> <many-to-one name="<%=attrName%>" class="<%=attrType%>" column="<%=attrColumn%>" node="<%=attrName%>/@topiaId" embed-xml="false" <%=notNull%>/>
}*/
// }
//Ne sert plus grâce à l'utilisation de la navigabilité
@@ -312,16 +312,19 @@
String optionalAttributes = "";
if (attr.isIndexed()) {
String indexName = tableName + "_idx";
- optionalAttributes += "index=\"" + indexName + "\" ";
+ optionalAttributes += "index=\"" + indexName + "\"";
}
optionalAttributes += generateFromTagValue(attr, TopiaGeneratorUtil.TAG_NOT_NULL, "not-null");
/*{<%=prefix%> <property name="<%=attrName%>" type="<%=attrType%>" access="<%=accessField%>" }*/
-
+ optionalAttributes = optionalAttributes.trim();
String[] columnNames = this.columnNamesMap.get(attrType);
if (columnNames == null || columnNames.length == 0) {
optionalAttributes += generateFromTagValue(attr, TopiaGeneratorUtil.TAG_LENGTH, "length");
String attrColumn = TopiaGeneratorUtil.getDBName(attr);
-/*{column="<%=attrColumn%>" node="<%=attrName%>" <%=optionalAttributes%>/>
+ optionalAttributes = optionalAttributes.trim();
+ if (!optionalAttributes.isEmpty())
+ optionalAttributes = " " + optionalAttributes;
+/*{column="<%=attrColumn%>" node="<%=attrName%>"<%=optionalAttributes%>/>
}*/
} else {
/*{<%=optionalAttributes%>>
@@ -453,7 +456,7 @@
// vérifier si le tag lazy est defini par defaut dans le fichier de proprietes
String lazy = generateFromTagValue(attr, TopiaGeneratorUtil.TAG_LAZY, "lazy");
/*{<%=lazy%>}*/
- String notNull = generateFromTagValue(attr, TopiaGeneratorUtil.TAG_NOT_NULL, "not-null");
+ String notNull = " " + generateFromTagValue(attr, TopiaGeneratorUtil.TAG_NOT_NULL, "not-null");
/*{<%=notNull%>}*/
/*{/>
}*/
Modified: topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaGeneratorUtil.java
===================================================================
--- topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaGeneratorUtil.java 2009-01-29 14:22:19 UTC (rev 1332)
+++ topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/TopiaGeneratorUtil.java 2009-01-29 15:09:31 UTC (rev 1333)
@@ -39,6 +39,8 @@
import org.codelutin.generator.models.object.ObjectModelElement;
import org.codelutin.generator.models.object.ObjectModelInterface;
import org.codelutin.generator.models.object.ObjectModelOperation;
+import org.codelutin.generator.models.object.ObjectModelAssociationClass;
+import org.codelutin.generator.models.object.ObjectModelParameter;
import java.util.ArrayList;
import java.util.Collection;
@@ -47,6 +49,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import java.util.Arrays;
/** Classe regroupant divers méthodes utiles pour la génération des entités */
public class TopiaGeneratorUtil extends GeneratorUtil {
@@ -437,7 +440,11 @@
return type;
}
- private static Set<String> numberTypes = new HashSet<String>();
+ private static final Set<String> numberTypes = new HashSet<String>();
+ private static final Set<String> textTypes = new HashSet<String>();
+ private static final Set<String> booleanTypes =new HashSet<String>();
+ private static final Set<String> primitiveTypes =new HashSet<String>();
+ private static final String VOID_TYPE = "void";
static {
numberTypes.add("byte");
@@ -452,20 +459,23 @@
numberTypes.add("java.lang.Float");
numberTypes.add("double");
numberTypes.add("java.lang.Double");
+
+ textTypes.add("char");
+ textTypes.add("java.lang.Char");
+ textTypes.add("java.lang.String");
+
+ booleanTypes.add("boolean");
+ booleanTypes.add("java.lang.Boolean");
+
+ primitiveTypes.addAll(numberTypes);
+ primitiveTypes.addAll(textTypes);
+ primitiveTypes.addAll(booleanTypes);
}
public static boolean isNumericType(ObjectModelAttribute attr) {
return numberTypes.contains(attr.getType());
}
- private static Set<String> textTypes = new HashSet<String>();
-
- static {
- textTypes.add("char");
- textTypes.add("java.lang.Char");
- textTypes.add("java.lang.String");
- }
-
public static boolean isTextType(ObjectModelAttribute attr) {
return textTypes.contains(attr.getType());
}
@@ -475,10 +485,13 @@
}
public static boolean isBooleanType(ObjectModelAttribute attr) {
- return ("boolean".equals(attr.getType()) || "java.lang.Boolean"
- .equals(attr.getType()));
+ return booleanTypes.contains(attr.getType());
}
+ public static boolean isPrimitiveType(ObjectModelAttribute attr) {
+ return primitiveTypes.contains(attr.getType());
+ }
+
/**
* Indique si la classe specifiee n'a aucune ou que des methodes abstraites
*
@@ -694,4 +707,166 @@
return false;
}
}
+
+
+ /**
+ * Obtain the list of fqn of object involed in the given class.
+ *
+ * @param aClass the clazz to inspect
+ * @return the list of fqn of attributes
+ */
+ public static List<String> getImports(ObjectModelClass aClass, String... incomingFqns) {
+ Set<String> tmp = new HashSet<String>();
+ tmp.addAll(Arrays.asList(incomingFqns));
+ getImports(aClass, tmp);
+ List<String> result = cleanImports(aClass.getPackageName(),tmp);
+ return result;
+ }
+
+ /**
+ * Obtain the list of fqn of object involed in the given interface.
+ *
+ * @param anInterface the interface to inspect
+ * @return the list of fqn of attributes
+ */
+ public static List<String> getImports(ObjectModelInterface anInterface, String... incomingFqns) {
+ Set<String> tmp = new HashSet<String>();
+ tmp.addAll(Arrays.asList(incomingFqns));
+ getImports(anInterface, tmp);
+ List<String> result = cleanImports(anInterface.getPackageName(),tmp);
+ return result;
+ }
+
+
+ public static String getSimpleName(String fqn) {
+ int lasIndex = fqn.lastIndexOf(".");
+ if (lasIndex==1) {
+ // primitive type
+ return fqn;
+ }
+ return fqn.substring(lasIndex + 1);
+ /*if (lasIndex == aClass.getPackageName().length()) {
+ // same package
+ return fqn.substring(lasIndex + 1);
+ }
+
+ return fqn;*/
+ }
+ /**
+ * Obtain the list of fqn of object involed in the given class.
+ *
+ * @param aClass the class to inspect
+ * @param fqns where to store found fqns
+ */
+ protected static void getImports(ObjectModelClass aClass, Set<String> fqns) {
+ // scan attributes
+ for (ObjectModelAttribute attr : aClass.getAttributes()) {
+ fqns.add(attr.getType());
+ if (isNMultiplicity(attr)) {
+ String collectionType = getNMultiplicityInterfaceType(attr);
+ fqns.add(collectionType);
+ String collectionObject = getNMultiplicityObjectType(attr);
+ fqns.add(collectionObject);
+ }
+ }
+ for (ObjectModelAttribute attribute : aClass.getAllOtherAttributes()) {
+ fqns.add(attribute.getType());
+ }
+ // scan associations
+ if (aClass instanceof ObjectModelAssociationClass) {
+ ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) aClass;
+ for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
+ if (attr == null) {
+ continue;
+ }
+ fqns.add(attr.getType());
+ if (isNMultiplicity(attr)) {
+ String collectionType = getNMultiplicityInterfaceType(attr);
+ fqns.add(collectionType);
+ String collectionObject = getNMultiplicityObjectType(attr);
+ fqns.add(collectionObject);
+ }
+ }
+ }
+ // scan operations
+ for (ObjectModelOperation operation : aClass.getOperations()) {
+ getImports(operation, fqns);
+ }
+ // scan super interfaces
+ for (ObjectModelInterface modelInterface : aClass.getInterfaces()) {
+ fqns.add(modelInterface.getQualifiedName());
+ getImports(modelInterface, fqns);
+ }
+ // scan super classes
+ for (ObjectModelClass modelClass : aClass.getSuperclasses()) {
+ fqns.add(modelClass.getQualifiedName());
+ getImports(modelClass);
+ }
+ }
+
+ /**
+ * Obtain the list of fqn of object involed in the given interface.
+ *
+ * @param anInterface the interface to inspect
+ * @param fqns where to store found fqns
+ */
+ protected static void getImports(ObjectModelInterface anInterface, Set<String> fqns) {
+ // scan operations
+ for (ObjectModelOperation operation : anInterface.getOperations()) {
+ getImports(operation, fqns);
+ }
+ // scan super interfaces
+ for (ObjectModelInterface modelInterface : anInterface.getInterfaces()) {
+ fqns.add(modelInterface.getQualifiedName());
+ getImports(modelInterface, fqns);
+ }
+ }
+
+ /**
+ * Obtain the fqn's list of all involed type in a givne operation.
+ *
+ * @param operation operation to inspect
+ * @param fqns where to store found fqns
+ */
+ protected static void getImports(ObjectModelOperation operation, Set<String> fqns) {
+ String fqn = operation.getReturnType();
+ fqns.add(fqn);
+ for (ObjectModelParameter parameter : operation.getParameters()) {
+ fqns.add(parameter.getType());
+ }
+ }
+
+ /**
+ * Clean a set of fqns, transform it into a {@link List} and sort it.
+ *
+ * @param packageName the current package name
+ * @param fqns the dirty set of fqns
+ * @return the sorted cleaned list of fqns.
+ */
+ protected static List<String> cleanImports(String packageName, Set<String> fqns) {
+ fqns.removeAll(primitiveTypes);
+ fqns.remove(VOID_TYPE);
+ int packageLength = packageName.length();
+ List<String> genericType = new ArrayList<String>();
+ for (Iterator<String> it = fqns.iterator(); it.hasNext();) {
+ String fqn = it.next();
+ int lastIndex = fqn.lastIndexOf(".");
+ if (lastIndex == packageLength) {
+ // same package
+ it.remove();
+ continue;
+ }
+ int genericIndex = fqn.indexOf('<');
+ if (genericIndex!=-1) {
+ genericType.add(fqn.substring(0,genericIndex));
+ it.remove();
+ }
+ }
+ fqns.addAll(genericType);
+
+ ArrayList<String> result = new ArrayList<String>(fqns);
+ java.util.Collections.sort(result);
+ return result;
+ }
+
} // GeneratorUtil
1
0
r1332 - topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator
by thimel@users.labs.libre-entreprise.org 29 Jan '09
by thimel@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: thimel
Date: 2009-01-29 14:22:19 +0000 (Thu, 29 Jan 2009)
New Revision: 1332
Modified:
topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/DTOGenerator.java
Log:
Fixed DTOGenerator
Modified: topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/DTOGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/DTOGenerator.java 2009-01-29 13:46:04 UTC (rev 1331)
+++ topia/branches/generators-refactoring/topia-persistence/src/main/java/org/codelutin/topia/generator/DTOGenerator.java 2009-01-29 14:22:19 UTC (rev 1332)
@@ -376,7 +376,6 @@
if (isDTO(attrType)) {
attrTypeDTO += "DTO";
}
- String reverseAttrName = reverse.getName();
if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
@@ -411,6 +410,7 @@
}
} else { //NMultiplicity
if (!attr.hasAssociationClass()) { //Méthodes remplacées par des accesseurs sur les classes d'assoc
+ String reverseAttrName = reverse.getName();
String nMultType;
if (attr.isOrdered()) {
nMultType = "List<" + attrTypeDTO + ">";
1
0
r1331 - topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator
by thimel@users.labs.libre-entreprise.org 29 Jan '09
by thimel@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: thimel
Date: 2009-01-29 13:46:04 +0000 (Thu, 29 Jan 2009)
New Revision: 1331
Modified:
topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java
Log:
ServiceInterfaceGenerator refactored
Modified: topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 11:46:59 UTC (rev 1330)
+++ topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 13:46:04 UTC (rev 1331)
@@ -31,8 +31,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.Generator;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
@@ -120,20 +120,21 @@
// methodes du service
public String[] methods = {
}*/
- String vir=" ";
- for(String m : methods){
-/*{ <%=vir%>"<%=m%>"
+ String comma=" ";
+ for(String method : methods){
+/*{ <%=comma%>"<%=method%>"
}*/
- vir=", ";
+ comma=", ";
}
-/*{ }; }*/
-/*{
- } //<%=interfacez.getName()%>
+/*{ };
+
+} //<%=interfacez.getName()%>
}*/
}
private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
String copyright = TopiaGeneratorUtil.getCopyright(model);
+ String classifierName = classifier.getName();
if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
@@ -141,20 +142,22 @@
/*{package <%=classifier.getPackageName()%>;
import java.util.List;
+import java.util.Collection;
import org.codelutin.topia.TopiaException;
+import org.codelutin.topia.service.TopiaApplicationService;
}*/
if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
+ String documentation = classifier.getDocumentation();
/*{
/**
- * <%=classifier.getDocumentation()%>
+ * <%=documentation%>
*)
}*/
}
-/*{public interface <%=classifier.getName()%> extends }*/
+/*{public interface <%=classifierName%> extends }*/
String extendClass = "";
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelClassifier parent : classifier.getInterfaces()) {
// pas pour les interfaces de DAO
if(!parent.hasStereotype(DAO)){
extendClass += parent.getQualifiedName();
@@ -164,8 +167,7 @@
if (classifier instanceof ObjectModelClass) {
ObjectModelClass clazz = (ObjectModelClass)classifier;
- for (Iterator i=clazz.getSuperclasses().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelClass parent : clazz.getSuperclasses()) {
if (parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) {
extendClass += parent.getQualifiedName();
}
@@ -173,7 +175,7 @@
}
}
-/*{<%=extendClass%>org.codelutin.topia.service.TopiaApplicationService {
+/*{<%=extendClass%>TopiaApplicationService {
}*/
}
@@ -181,61 +183,65 @@
private void generateMethodsGetter(Writer output, ObjectModelClassifier classifier) throws IOException {
/*{ public abstract String[] getMethods();
- // =====> methodes utilisant celles des entites <====
+ // methodes utilisant celles des entites
}*/
}
private void generateInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator it = classifier.getOperations().iterator(); it.hasNext();) {
- ObjectModelOperation op = (ObjectModelOperation)it.next();
-
- String method = op.getReturnType()+ " "+op.getName()+"(";
+ for (ObjectModelOperation op : classifier.getOperations()) {
+ String opName = op.getName();
+ String opVisibility = op.getVisibility();
+ String opType = op.getReturnType();
+ String method = opType + " " + opName + "(";
/*{
/**
- * Methode metier
+ * Methode <%=opName%>.
}*/
if (TopiaGeneratorUtil.hasDocumentation(op)) {
-/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
+ String opDocumentation = op.getDocumentation();
+/*{ * <%=opName%> : <%=opDocumentation%>
}*/
}
Collection<ObjectModelParameter> params = (Collection<ObjectModelParameter>)op.getParameters();
for(ObjectModelParameter param : params) {
- if(log.isTraceEnabled()) {log.trace("Param" + param);}
-/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%>
-}*/
+ if (TopiaGeneratorUtil.hasDocumentation(param)) {
+ String paramName = param.getName();
+ String paramDocumentation = param.getDocumentation();
+/*{ * @param <%=paramName%> <%=paramDocumentation%>
+}*/
+ }
}
/*{ *)
- <%=op.getVisibility()%> <%=op.getReturnType()%> <%=op.getName()%>(}*/
- String vir = "";
+ <%=opVisibility%> <%=opType%> <%=opName%>(}*/
+ String comma = "";
for(ObjectModelParameter param : params){
- method += " " + param.getType()+" "+param.getName();
- if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
-/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
- vir = ", ";
+ String paramName = param.getName();
+ String paramType = param.getType();
+ method += comma + paramType + " " + paramName;
+/*{<%=comma%><%=paramType%> <%=paramName%>}*/
+ comma = ", ";
}
/*{)}*/
- Set<String> exceptions = (Set<String>)op.getExceptions();
- vir = " throws ";
+ Set<String> exceptions = op.getExceptions();
+ comma = " throws ";
for (String exception : exceptions) {
- if(log.isTraceEnabled()) {log.trace("exception" + exception + " vir" + vir);}
-/*{<%=vir%><%=exception%>}*/
- vir = ", ";
+/*{<%=comma%><%=exception%>}*/
+ comma = ", ";
}
/*{;
}*/
// ajout des methodes
- methods.add(method+")");
+ methods.add(method + ")");
}
}
private void generateInheritedInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
/*{
- // =====> methodes utilisant celles des daos <====
+ // methodes utilisant celles des daos
}*/
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelInterface parent : classifier.getInterfaces()) {
// pour tous les DAOInterface
if(parent.hasStereotype(DAO)){
@@ -244,51 +250,52 @@
entityClassName = parent.getQualifiedName().replace("DAO", "");
if(getModel().hasClass(entityClassName)){
ObjectModelClass clazz = getModel().getClass(entityClassName);
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
// ajouter les methodes à la liste
- methods.add("void delete"+clazz.getName()+"("+clazz.getName()+" entity)");
- methods.add(clazz.getName()+" create"+clazz.getName()+"(Object ... properties)");
- methods.add(clazz.getName()+" update"+clazz.getName()+"("+clazz.getName()+")");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"()");
- methods.add(clazz.getName()+" find"+clazz.getName()+"ByTopiaId(String v)");
+ methods.add("void delete"+clazzName+"("+clazzName+" entity)");
+ methods.add(clazzName+" create"+clazzName+"(Object ... properties)");
+ methods.add(clazzName+" update"+clazzName+"("+clazzName+")");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"()");
+ methods.add(clazzName+" find"+clazzName+"ByTopiaId(String v)");
/*{
/**
- * Supprime l'entite <%=clazz.getName()%> passee en parametre
+ * Supprime l'entite <%=clazzName%> passee en parametre
* @param entity l'entite a supprimer
*)
- public abstract void delete<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException;
+ public abstract void delete<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException;
/**
- * Creer l'entite <%=clazz.getName()%> avec les proprietes passees en parametre
+ * Creer l'entite <%=clazzName%> avec les proprietes passees en parametre
* @param entity l'entite a mettre a jour
*)
- public abstract <%=clazz.getQualifiedName()%> create<%=clazz.getName()%>(Object ... properties) throws TopiaException;
+ public abstract <%=clazzFQN%> create<%=clazzName%>(Object ... properties) throws TopiaException;
/**
- * Mise a jour de l'entite <%=clazz.getName()%> passee en parametre
+ * Mise a jour de l'entite <%=clazzName%> passee en parametre
* @param properties les proprietes de l'entite a creer
*)
- public abstract <%=clazz.getQualifiedName()%> update<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException;
+ public abstract <%=clazzFQN%> update<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException;
/**
- * Retourne tous les <%=clazz.getName()%>
+ * Retourne tous les <%=clazzName%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>() throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>() throws TopiaException;
/**
- * Retourne le <%=clazz.getName()%> par son TopiaId
- * @return le <%=clazz.getName()%>
+ * Retourne le <%=clazzName%> par son TopiaId
+ * @return le <%=clazzName%>
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>ByTopiaId(String v) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>ByTopiaId(String v) throws TopiaException;
}*/
- for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
if (!attr.isNavigable()) {
continue;
}
@@ -302,14 +309,12 @@
if (clazz instanceof ObjectModelAssociationClass) {
ObjectModelAssociationClass assocClass = (ObjectModelAssociationClass)clazz;
- Iterator it = assocClass.getParticipantsAttributes().iterator();
- while (it.hasNext()) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : assocClass.getParticipantsAttributes()) {
if (attr != null) {
if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, true);
} else {
- generateNMultiplicity(output, attr, clazz, true);
+ generateNMultiplicity(output, attr, clazz, true);
}
}
}
@@ -318,72 +323,82 @@
}
}
}
-
+
protected void generateNoNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
- String propertyName = attr.getName();
+ String attrName = attr.getName();
+ String propertyName = attrName;
+ String attrType = attr.getType();
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
if (!isAssoc && attr.hasAssociationClass()) {
propertyName = TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
}
// ajouter les methodes à la liste
- methods.add(clazz.getName()+" find"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)");
+ methods.add(clazzName+" find"+clazzName+"By"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" v)");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" v)");
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
- * <%=attr.getName()%> le parametre
- * @param v la valeur que doit avoir <%=attr.getName()%>
+ * <%=attrName%> le parametre
+ * @param v la valeur que doit avoir <%=attrName%>
* @return un element ou null
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException;
/**
* Retourne les éléments ayant comme valeur pour l'attribut
- * <%=attr.getName()%> le paramêtre
- * @param v la valeur que doit avoir <%=attr.getName()%>
+ * <%=attrName%> le paramêtre
+ * @param v la valeur que doit avoir <%=attrName%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException;
}*/
if (attr.hasAssociationClass()) {
- methods.add(clazz.getName() +" find"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)");
+ String assocClassName = attr.getAssociationClass().getName();
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ methods.add(clazzName +" find"+clazzName+"By"+TopiaGeneratorUtil.capitalize(assocClassName)+"("+assocClassFQN+" value)");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+TopiaGeneratorUtil.capitalize(assocClassName)+"("+assocClassFQN+" value)");
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
- * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le parametre
- * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> le parametre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>
* @return un element ou null
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException;
/**
* Retourne les éléments ayant comme valeur pour l'attribut
- * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le paramêtre
- * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> le paramêtre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException;
}*/
}
}
protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
- methods.add(clazz.getName() + " find"+clazz.getName()+"Contains"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"Contains"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)");
+ String attrName = attr.getName();
+ String attrType = attr.getType();
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
+ methods.add(clazzName + " find"+clazzName+"Contains"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" ... v)");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"Contains"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" ... v)");
/*{
/**
* Retourne le premier element trouve dont l'attribut
- * <%=attr.getName()%> contient le parametre
- * @param v la valeur que doit contenir <%=attr.getName()%>
+ * <%=attrName%> contient le parametre
+ * @param v la valeur que doit contenir <%=attrName%>
* @return un element ou null
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException;
/**
* Retourne les elements trouve dont l'attribut
- * <%=attr.getName()%> contient le parametre
- * @param v la valeur que doit contenir <%=attr.getName()%>
+ * <%=attrName%> contient le parametre
+ * @param v la valeur que doit contenir <%=attrName%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException;
}*/
}
@@ -392,7 +407,7 @@
ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
// pour tous les DAOInterface
if(parent.hasStereotype(DAO)){
- // r�cup�rer la classe de l'object model correspondant à la DAO
+ // récupérer la classe de l'object model correspondant à la DAO
String entityClassName = null;
entityClassName = parent.getQualifiedName().replace("DAO", "");
if(getModel().hasClass(entityClassName)){
@@ -409,8 +424,10 @@
return;
}
- for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ String clazzName = clazz.getName();
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
+ String attrName = attr.getName();
+ String attrType = attr.getType();
ObjectModelAttribute reverse = attr.getReverseAttribute();
if (!attr.isNavigable()
&& !hasUnidirectionalRelationOnAbstractType(reverse, model)) {
@@ -421,43 +438,44 @@
/*{ /**
}*/
if (TopiaGeneratorUtil.hasDocumentation(attr)) {
- methods.add("void set"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");
+ methods.add("void set"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+attrType+ " "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> à positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> La valeur de l'attribut <%=attrName%> à positionner.
*)
- public abstract void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
}*/
/*{ /**
}*/
if (TopiaGeneratorUtil.hasDocumentation(attr)) {
- methods.add(attr.getType()+" get"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ methods.add(attrType+" get"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @return La valeur de l'attribut <%=attr.getName()%>.
+/*{ * @return La valeur de l'attribut <%=attrName%>.
*)
- public abstract <%=attr.getType()%> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=attrType%> get<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
} else {
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassName = attr.getAssociationClass().getName();
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
- methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add(attr.getAssociationClass().getName()+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
-
+ methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+assocClassName+" "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add(assocClassName+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId)");
/*{ /**
- * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> La valeur de l'attribut <%=assocClassName%> à positionner.
*)
- public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * @return La valeur de l'attribut <%=attr.getAssociationClass().getName()%>.
+ * @return La valeur de l'attribut <%=assocClassName%>.
*)
- public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
}
@@ -466,92 +484,94 @@
/*{ /**
}*/
if (TopiaGeneratorUtil.hasDocumentation(attr)) {
- methods.add("void add"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ methods.add("void add"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+attrType+" "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> L'instance de <%=attrName%> à ajouter.
*)
- public abstract void add<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void add<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
/**
}*/
if (TopiaGeneratorUtil.hasDocumentation(attr)) {
- methods.add("void addAll"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");;
+ methods.add("void addAll"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attrType+"> "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");;
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> à ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> Les instances de <%=attrName%> à ajouter.
*)
- public abstract void addAll<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void addAll<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attrType%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
/**
}*/
if (TopiaGeneratorUtil.hasDocumentation(attr)) {
- methods.add("void set"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+ (attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ methods.add("void set"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+ (attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attrType+"> "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> à positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> La Collection de <%=attrName%> à positionner.
*)
- public abstract void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attrType%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
/**
}*/
if (TopiaGeneratorUtil.hasDocumentation(attr)) {
- methods.add("void remove"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ methods.add("void remove"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId, "+attrType+ " "+GeneratorUtil.toLowerCaseFirstLetter(attrName)+")");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à retirer.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%> L'instance de <%=attrName%> à retirer.
*)
- public abstract void remove<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void remove<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> <%=GeneratorUtil.toLowerCaseFirstLetter(attrName)%>) throws TopiaException;
/**
}*/
if (TopiaGeneratorUtil.hasDocumentation(attr)) {
- methods.add("void clear"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+ methods.add("void clear"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)");
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * Vide la Collection de <%=attr.getName()%>.
+/*{ * Vide la Collection de <%=attrName%>.
*)
- public abstract void clear<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract void clear<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
} else {
+ String assocClassName = attr.getAssociationClass().getName();
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
- methods.add("void add"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void addAll"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void remove"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void clear"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add("void add"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+assocClassName+" "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add("void addAll"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+assocClassName+"> "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+assocClassName+"> "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add("void remove"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+assocClassName+" "+GeneratorUtil.toLowerCaseFirstLetter(assocClassName)+")");
+ methods.add("void clear"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId)");
/*{ /**
- * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> L'instance de <%=assocClassName%> à ajouter.
*)
- public abstract void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> à ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> Les instances de <%=assocClassName%> à ajouter.
*)
- public abstract void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"List":"Collection")%><<%=assocClassFQN%>> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> à positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> La Collection de <%=assocClassName%> à positionner.
*)
- public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"List":"Collection")%><<%=assocClassFQN%>> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à retirer.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> L'instance de <%=assocClassName%> à retirer.
*)
- public abstract void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=assocClassFQN%> <%=GeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>) throws TopiaException;
/**
- * Vide la Collection de <%=attr.getAssociationClass().getName()%>.
+ * Vide la Collection de <%=assocClassName%>.
*)
- public abstract void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
}
@@ -560,42 +580,44 @@
/*{ /**
}*/
if (TopiaGeneratorUtil.hasDocumentation(attr)) {
- methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> get"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
- methods.add("int size"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attrType+"> get"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)");
+ methods.add("int size"+GeneratorUtil.capitalize(attrName)+"Of"+clazzName+"(String topiaId)");
-/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
+/*{ * <%=attrName%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @return La Liste de <%=attr.getName()%>.
+/*{ * @return La Liste de <%=attrName%>.
*)
- public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attrType%>> get<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
/**
- * @return Le nombre d'éléments de la collection <%=attr.getName()%>.
+ * @return Le nombre d'éléments de la collection <%=attrName%>.
*)
- public abstract int size<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract int size<%=GeneratorUtil.capitalize(attrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
} else {
String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String assocClassName = attr.getAssociationClass().getName();
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
- methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"Of"+clazz.getName()+"(String topiaId)");
- methods.add(attr.getAssociationClass().getName()+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" value)");
- methods.add("int size"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+assocClassName+"> get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"Of"+clazzName+"(String topiaId)");
+ methods.add(assocClassName+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId, "+attrType+" value)");
+ methods.add("int size"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazzName+"(String topiaId)");
/*{ /**
- * @return La liste des attributs <%=attr.getAssociationClass().getName()%>.
+ * @return La liste des attributs <%=assocClassName%>.
*)
- public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=assocClassFQN%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
/**
- * @return L'attribut <%=attr.getAssociationClass().getName()%> associé à la valeur <code>value</code> de l'attribut <%=attr.getName()%>.
+ * @return L'attribut <%=assocClassName%> associé à la valeur <code>value</code> de l'attribut <%=attrName%>.
*)
- public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> value) throws TopiaException;
+ public abstract <%=assocClassFQN%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attrType%> value) throws TopiaException;
/**
- * @return Le nombre d'éléments de la collection <%=attr.getName()%>.
+ * @return Le nombre d'éléments de la collection <%=attrName%>.
*)
- public abstract int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
}
@@ -648,7 +670,7 @@
String vir = "";
for(ObjectModelParameter param : params){
if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
- method += " " + param.getType()+" "+param.getName();
+ method += vir + param.getType()+" "+param.getName();
/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
vir = ", ";
}
@@ -671,17 +693,18 @@
}
private void generateAssociationAccessors(Writer output, ObjectModelClass clazz, String name, String type) throws IOException {
- methods.add("=> "+"void set"+GeneratorUtil.capitalize(name)+"Of"+clazz.getName()+"(String topiaId, "+type+" value)");
- methods.add("=> "+type+" get"+GeneratorUtil.capitalize(name)+"Of"+clazz.getName()+"(String topiaId)");
+ String clazzName = clazz.getName();
+ methods.add("=> "+"void set"+GeneratorUtil.capitalize(name)+"Of"+clazzName+"(String topiaId, "+type+" value)");
+ methods.add("=> "+type+" get"+GeneratorUtil.capitalize(name)+"Of"+clazzName+"(String topiaId)");
/*{ /**
* @param value La valeur de l'attribut <%=name%> à positionner.
*)
- public abstract void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId, <%=type%> value) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId, <%=type%> value) throws TopiaException;
/**
* @return La valeur de l'attribut <%=name%>.
*)
- public abstract <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId) throws TopiaException;
}*/
}
1
0
r1330 - topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator
by thimel@users.labs.libre-entreprise.org 29 Jan '09
by thimel@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: thimel
Date: 2009-01-29 11:46:59 +0000 (Thu, 29 Jan 2009)
New Revision: 1330
Modified:
topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java
topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java
Log:
Refactored ServiceImpl and ServiceAbstract generators
Modified: topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java 2009-01-29 11:22:36 UTC (rev 1329)
+++ topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java 2009-01-29 11:46:59 UTC (rev 1330)
@@ -105,6 +105,7 @@
private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
String copyright = TopiaGeneratorUtil.getCopyright(model);
+ String classifierName = classifier.getName();
if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
@@ -117,13 +118,11 @@
import org.codelutin.topia.service.TopiaApplicationServiceAbstract;
import org.codelutin.topia.framework.TopiaContextImplementor;}*/
- // <%=clazz.getName()%>DAOAbstract
classifier.getInterfaces();
// ajouter les imports des interfaces de DAO
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelInterface parent : classifier.getInterfaces()) {
if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
- // r�cup�rer la classe de l'object model correspondant � la DAO
+ // récupérer la classe de l'object model correspondant à la DAO
String className = parent.getQualifiedName().replace("DAO", "");
String interfaceName = parent.getQualifiedName()+"Abstract";
/*{
@@ -133,7 +132,6 @@
}
if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
-
/*{
/**
*
@@ -143,49 +141,53 @@
}
/*{
-public abstract class <%=classifier.getName()+"Abstract"%> extends TopiaApplicationServiceAbstract implements <%=classifier.getName()%>{ }*/
+public abstract class <%=classifierName%>Abstract extends TopiaApplicationServiceAbstract implements <%=classifierName%>{ }*/
}
private void generateMethodsGetter(Writer output, ObjectModelClassifier classifier) throws IOException {
/*{ public String[] getMethods(){
return methods;
}
-}*/
+}*/
}
private void generateInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator it = classifier.getOperations().iterator(); it.hasNext();) {
- ObjectModelOperation op = (ObjectModelOperation)it.next();
+ for (ObjectModelOperation op : classifier.getOperations()) {
+ String opName = op.getName();
+ String opVisibility = op.getVisibility();
+ String opType = op.getReturnType();
/*{
/**
* Implementation a la charge du developpeur
}*/
if (TopiaGeneratorUtil.hasDocumentation(op)) {
-/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
+ String opDocumentation = op.getDocumentation();
+/*{ * <%=opName%> : <%=opDocumentation%>
}*/
}
Collection<ObjectModelParameter> params = (Collection<ObjectModelParameter>)op.getParameters();
for(ObjectModelParameter param : params) {
- if(log.isTraceEnabled()) {log.trace("Param" + param);}
-/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%>
+ String paramName = param.getName();
+ String paramDocumentation = param.getDocumentation();
+/*{ * @param <%=paramName%> <%=paramDocumentation%>
}*/
}
/*{ *)
- <%=op.getVisibility()%> abstract <%=op.getReturnType()%> <%=op.getName()%>(}*/
- String vir = "";
+ <%=opVisibility%> abstract <%=opType%> <%=opName%>(}*/
+ String comma = "";
for(ObjectModelParameter param : params){
- if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
-/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
- vir = ", ";
+ String paramName = param.getName();
+ String paramType = param.getType();
+/*{<%=comma%><%=paramType%> <%=paramName%>}*/
+ comma = ", ";
}
/*{)}*/
Set<String> exceptions = (Set<String>)op.getExceptions();
- vir = " throws ";
+ comma = " throws ";
for (String exception : exceptions) {
- if(log.isTraceEnabled()) {log.trace("exception" + exception + " vir" + vir);}
-/*{<%=vir%><%=exception%>}*/
- vir = ", ";
+/*{<%=comma%><%=exception%>}*/
+ comma = ", ";
}
/*{;
@@ -195,76 +197,76 @@
private void generateInheritedInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelInterface parent : classifier.getInterfaces()) {
// pour tous les DAOInterface
if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
- // r�cup�rer la classe de l'object model correspondant � la DAO
+ // récupérer la classe de l'object model correspondant à la DAO
String entityClassName = parent.getQualifiedName().replace("DAO", "");
if(getModel().hasClass(entityClassName)){
ObjectModelClass clazz = getModel().getClass(entityClassName);
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
/*{
/**
- * Supprime l'entite <%=clazz.getName()%> passee en parametre
+ * Supprime l'entite <%=clazzName%> passee en parametre
* @param entity l'entite a supprimer
*)
- public void delete<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException{
+ public void delete<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
dao.delete(entity);
}
/**
- * Creer l'entite <%=clazz.getName()%> avec les proprietes passees en parametre
+ * Creer l'entite <%=clazzName%> avec les proprietes passees en parametre
* @param properties les proprietes de l'entite a creer
*)
- public <%=clazz.getQualifiedName()%> create<%=clazz.getName()%>(Object ... properties) throws TopiaException{
+ public <%=clazzFQN%> create<%=clazzName%>(Object ... properties) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>) dao.create(properties);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>) dao.create(properties);
return entity;
}
/**
- * Mise a jour de l'entite <%=clazz.getName()%> passee en parametre
+ * Mise a jour de l'entite <%=clazzName%> passee en parametre
* @param entity l'entite a mettre a jour
*)
- public <%=clazz.getQualifiedName()%> update<%=clazz.getName()%>(<%=clazz.getQualifiedName()%> entity) throws TopiaException{
+ public <%=clazzFQN%> update<%=clazzName%>(<%=clazzFQN%> entity) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entit = (<%=clazz.getName()%>) dao.update(entity);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entit = (<%=clazzName%>) dao.update(entity);
return entit;
}
/**
- * Retourne tous les <%=clazz.getName()%>
+ * Retourne tous les <%=clazzName%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>() throws TopiaException {
+ public List<<%=clazzFQN%>> findAll<%=clazzName%>() throws TopiaException {
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> result = dao.findAll();
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ List<<%=clazzName%>> result = dao.findAll();
return result;
}
/**
- * Retourne le <%=clazz.getName()%> par son TopiaId
- * @return le <%=clazz.getName()%>
+ * Retourne le <%=clazzName%> par son TopiaId
+ * @return le <%=clazzName%>
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>ByTopiaId(String v) throws TopiaException {
+ public <%=clazzFQN%> find<%=clazzName%>ByTopiaId(String v) throws TopiaException {
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(v);
return entity;
}
}*/
- for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
if (!attr.isNavigable()) {
continue;
}
@@ -278,9 +280,7 @@
if (clazz instanceof ObjectModelAssociationClass) {
ObjectModelAssociationClass assocClass = (ObjectModelAssociationClass)clazz;
- Iterator it = assocClass.getParticipantsAttributes().iterator();
- while (it.hasNext()) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ for (ObjectModelAttribute attr : assocClass.getParticipantsAttributes()) {
if (attr != null) {
if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, true);
@@ -300,6 +300,8 @@
if (!isAssoc && attr.hasAssociationClass()) {
propertyName = TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
}
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
@@ -307,10 +309,10 @@
* @param v la valeur que doit avoir <%=attr.getName()%>
* @return un element ou null
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
+ public <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = dao.findBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = dao.findBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entity;
};
@@ -320,10 +322,10 @@
* @param v la valeur que doit avoir <%=attr.getName()%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
+ public List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> entityList = dao.findAllBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ List<<%=clazzName%>> entityList = dao.findAllBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entityList;
};
}*/
@@ -335,10 +337,10 @@
* @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
* @return un element ou null
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
+ public <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = dao.findBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = dao.findBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entity;
};
@@ -348,10 +350,10 @@
* @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
+ public List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> entityList = dao.findAllBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ List<<%=clazzName%>> entityList = dao.findAllBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entityList;
};
}*/
@@ -359,6 +361,8 @@
}
protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
/*{
/**
* Retourne le premier element trouve dont l'attribut
@@ -366,10 +370,10 @@
* @param v la valeur que doit contenir <%=attr.getName()%>
* @return un element ou null
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
+ public <%=clazzFQN%> find<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>) dao.findContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>) dao.findContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
return entity;
};
@@ -379,10 +383,10 @@
* @param v la valeur que doit contenir <%=attr.getName()%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
+ public List<<%=clazzFQN%>> findAll<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> entityList = dao.findAllContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ List<<%=clazzName%>> entityList = dao.findAllContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
return entityList;
};
}*/
@@ -390,8 +394,7 @@
private void generateAssociatedClassOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
+ for (ObjectModelInterface parent : classifier.getInterfaces()) {
// pour tous les DAOInterface
if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
@@ -411,8 +414,10 @@
return;
}
- for (Iterator it = clazz.getAttributes().iterator(); it.hasNext();) {
- ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
+ String clazzName = clazz.getName();
+ String clazzFQN = clazz.getQualifiedName();
+
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
ObjectModelAttribute reverse = attr.getReverseAttribute();
if (!attr.isNavigable()
&& !hasUnidirectionalRelationOnAbstractType(reverse, model)) {
@@ -428,10 +433,10 @@
}
/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> � positionner.
*)
- public void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.set<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
usedContextImpl.commitTransaction();
}
@@ -445,10 +450,10 @@
}
/*{ * @return La valeur de l'attribut <%=attr.getName()%>.
*)
- public <%=attr.getType()%> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=attr.getType()%> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
return entity.get<%=GeneratorUtil.capitalize(attr.getName())%>();
}
@@ -459,20 +464,20 @@
/*{ /**
* @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner.
*)
- public void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
* @return La valeur de l'attribut <%=attr.getAssociationClass().getName()%>.
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
return entity.get<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
@@ -488,10 +493,10 @@
}
/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � ajouter.
*)
- public void add<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void add<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.add<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
@@ -503,10 +508,10 @@
}
/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> � ajouter.
*)
- public void addAll<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void addAll<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.addAll<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
@@ -518,10 +523,10 @@
}
/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> � positionner.
*)
- public void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.set<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
@@ -533,10 +538,10 @@
}
/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � retirer.
*)
- public void remove<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void remove<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.remove<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
@@ -548,10 +553,10 @@
}
/*{ * Vide la Collection de <%=attr.getName()%>.
*)
- public void clear<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public void clear<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.clear<%=GeneratorUtil.capitalize(attr.getName())%>();
}
@@ -562,50 +567,50 @@
/*{ /**
* @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � ajouter.
*)
- public void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.add<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
* @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> � ajouter.
*)
- public void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.addAll<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
* @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> � positionner.
*)
- public void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
* @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � retirer.
*)
- public void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.remove<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
* Vide la Collection de <%=attr.getAssociationClass().getName()%>.
*)
- public void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
entity.clear<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
@@ -621,20 +626,20 @@
}
/*{ * @return La Liste de <%=attr.getName()%>.
*)
- public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
return entity.get<%=GeneratorUtil.capitalize(attr.getName())%>();
}
/**
* @return Le nombre d'�l�ments de la collection <%=attr.getName()%>.
*)
- public int size<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public int size<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
return entity.size<%=GeneratorUtil.capitalize(attr.getName())%>();
}
@@ -645,30 +650,30 @@
/*{ /**
* @return La liste des attributs <%=attr.getAssociationClass().getName()%>.
*)
- public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
return entity.get<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
/**
* @return L'attribut <%=attr.getAssociationClass().getName()%> associ� � la valeur <code>value</code> de l'attribut <%=attr.getName()%>.
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> value) throws TopiaException{
+ public <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
return entity.get<%=GeneratorUtil.capitalize(assocAttrName)%>((<%=attr.getType()%>) value);
}
/**
* @return Le nombre d'�l�ments de la collection <%=attr.getName()%>.
*)
- public int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
return entity.size<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
@@ -700,52 +705,56 @@
}
private void generateInterfaceOperationsOfClass(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (Iterator it = classifier.getOperations().iterator(); it.hasNext();) {
- ObjectModelOperation op = (ObjectModelOperation)it.next();
+ String classifierName = classifier.getName();
+ for (ObjectModelOperation op : classifier.getOperations()) {
+ String opName = op.getName();
+ String opVisibility = op.getVisibility();
+ String opType = op.getReturnType();
/*{ /**
}*/
if (TopiaGeneratorUtil.hasDocumentation(op)) {
-/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
+/*{ * <%=opName%> : <%=op.getDocumentation()%>
}*/
}
Collection<ObjectModelParameter> params = (Collection<ObjectModelParameter>)op.getParameters();
for(ObjectModelParameter param : params) {
- if(log.isTraceEnabled()) {log.trace("Param" + param);}
-/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%>
+ String paramName = param.getName();
+ String paramDocumentation = param.getDocumentation();
+/*{ * @param <%=paramName%> <%=paramDocumentation%>
}*/
}
/*{ *)
- <%=op.getVisibility()%> <%=op.getReturnType()%> <%=op.getName()%>Of<%=classifier.getName()%>(String topiaId}*/
- String vir = ",";
+ <%=opVisibility%> <%=opType%> <%=opName%>Of<%=classifierName%>(String topiaId}*/
+ String comma = ",";
for(ObjectModelParameter param : params){
- if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
-/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
+ String paramName = param.getName();
+ String paramType = param.getType();
+/*{<%=comma%><%=paramType%> <%=paramName%>}*/
}
/*{)}*/
Set<String> exceptions = (Set<String>)op.getExceptions();
if(exceptions.isEmpty()){
/*{throws TopiaException}*/
}
- vir = " throws ";
+ comma = " throws ";
for (String exception : exceptions) {
- if(log.isTraceEnabled()) {log.trace("exception" + exception + " vir" + vir);}
-/*{<%=vir%><%=exception%>}*/
- vir = ", ";
+/*{<%=comma%><%=exception%>}*/
+ comma = ", ";
}
/*{{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=classifier.getName()%>DAOAbstract dao = (<%=classifier.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=classifier.getName()%>.class);
- <%=classifier.getName()%> entity = (<%=classifier.getName()%>)dao.findByTopiaId(topiaId);
+ <%=classifierName%>DAOAbstract dao = (<%=classifierName%>DAOAbstract)usedContextImpl.getDAO(<%=classifierName%>.class);
+ <%=classifierName%> entity = (<%=classifierName%>)dao.findByTopiaId(topiaId);
}*/
if(!op.getReturnType().toString().equalsIgnoreCase("void")){
/*{ return }*/
}
-/*{ entity.<%=op.getName()%>(}*/
- vir = "";
+/*{ entity.<%=opName%>(}*/
+ comma = "";
for(ObjectModelParameter param : params){
- if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
-/*{<%=vir%><%=param.getName()%>}*/
- vir = ", ";
+ String paramName = param.getName();
+/*{<%=comma%><%=paramName%>}*/
+ comma = ", ";
}
/*{);
}
@@ -758,27 +767,28 @@
}
private void generateAssociationAccessors(Writer output, ObjectModelClass clazz, String name, String type) throws IOException {
- /*{ /**
- * @param value La valeur de l'attribut <%=name%> � positionner.
- *)
- public void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId, <%=type%> value) throws TopiaException{
- TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=GeneratorUtil.capitalize(name)%>( value);
- }
+ String clazzName = clazz.getName();
+/*{ /**
+ * @param value La valeur de l'attribut <%=name%> à positionner.
+ *)
+ public void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId, <%=type%> value) throws TopiaException{
+ TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ entity.set<%=GeneratorUtil.capitalize(name)%>( value);
+ }
- /**
- * @return La valeur de l'attribut <%=name%>.
- *)
- public <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
- TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
- <%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=GeneratorUtil.capitalize(name)%>();
- }
+ /**
+ * @return La valeur de l'attribut <%=name%>.
+ *)
+ public <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazzName%>(String topiaId) throws TopiaException{
+ TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
+ <%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
+ <%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
+ return entity.get<%=GeneratorUtil.capitalize(name)%>();
+ }
- }*/
+}*/
}
} //ServiceAbstractGenerator
Modified: topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java 2009-01-29 11:22:36 UTC (rev 1329)
+++ topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java 2009-01-29 11:46:59 UTC (rev 1330)
@@ -110,6 +110,7 @@
private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
String copyright = TopiaGeneratorUtil.getCopyright(model);
+ String classifierName = classifier.getName();
if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
@@ -117,7 +118,6 @@
/*{package <%=classifier.getPackageName()%>;}*/
if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
-
/*{
/**
*
@@ -127,7 +127,7 @@
}
/*{
-public class <%=classifier.getName()+"Impl"%> extends <%=classifier.getName()+"Abstract"%>{ }*/
+public class <%=classifierName%>Impl extends <%=classifierName%>Abstract { }*/
}
} //ServiceImplGenerator
1
0
r1329 - topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator
by chatellier@users.labs.libre-entreprise.org 29 Jan '09
by chatellier@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: chatellier
Date: 2009-01-29 11:22:36 +0000 (Thu, 29 Jan 2009)
New Revision: 1329
Modified:
topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java
Log:
Correction de la doc
Modified: topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java
===================================================================
--- topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 11:18:00 UTC (rev 1328)
+++ topia/trunk/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 11:22:36 UTC (rev 1329)
@@ -128,7 +128,7 @@
}
/*{ }; }*/
/*{
- } //<%=interfacez.getName()%>
+} //<%=interfacez.getName()%>
}*/
}
@@ -181,7 +181,7 @@
private void generateMethodsGetter(Writer output, ObjectModelClassifier classifier) throws IOException {
/*{ public abstract String[] getMethods();
- // =====> methodes utilisant celles des entites <====
+ // methodes utilisant celles des entites
}*/
}
@@ -193,7 +193,7 @@
String method = op.getReturnType()+ " "+op.getName()+"(";
/*{
/**
- * Methode metier
+ * Methode <%=op.getName()%>.
}*/
if (GeneratorUtil.hasDocumentation(op)) {
/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
@@ -201,15 +201,19 @@
}
Collection<ObjectModelParameter> params = (Collection<ObjectModelParameter>)op.getParameters();
for(ObjectModelParameter param : params) {
- if(log.isTraceEnabled()) {log.trace("Param" + param);}
+ if(log.isTraceEnabled()) {
+ log.trace("Param" + param);
+ }
+ if (GeneratorUtil.hasDocumentation(param)) {
/*{ * @param <%=param.getName()%> <%=param.getDocumentation()%>
-}*/
+}*/
+ }
}
/*{ *)
<%=op.getVisibility()%> <%=op.getReturnType()%> <%=op.getName()%>(}*/
String vir = "";
for(ObjectModelParameter param : params){
- method += " " + param.getType()+" "+param.getName();
+ method += vir + param.getType()+" "+param.getName();
if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
vir = ", ";
@@ -232,7 +236,7 @@
private void generateInheritedInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
/*{
- // =====> methodes utilisant celles des daos <====
+ // methodes utilisant celles des daos
}*/
for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
@@ -648,7 +652,7 @@
String vir = "";
for(ObjectModelParameter param : params){
if(log.isTraceEnabled()) {log.trace("Param" + param + " vir" + vir);}
- method += " " + param.getType()+" "+param.getName();
+ method += vir + param.getType()+" "+param.getName();
/*{<%=vir%><%=param.getType()%> <%=param.getName()%>}*/
vir = ", ";
}
1
0
r1328 - in topia/branches/generators-refactoring: topia-soa/src/main/java/org/codelutin/topia/generator topia-ui/src/main/java/org/codelutin/topia/generator
by thimel@users.labs.libre-entreprise.org 29 Jan '09
by thimel@users.labs.libre-entreprise.org 29 Jan '09
29 Jan '09
Author: thimel
Date: 2009-01-29 11:18:00 +0000 (Thu, 29 Jan 2009)
New Revision: 1328
Modified:
topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java
topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java
topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java
topia/branches/generators-refactoring/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java
Log:
Apply LutinGenerator Util rename in topia-soa and topia-ui
Modified: topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java 2009-01-29 10:53:27 UTC (rev 1327)
+++ topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceAbstractGenerator.java 2009-01-29 11:18:00 UTC (rev 1328)
@@ -16,7 +16,7 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*/
package org.codelutin.topia.generator;
-import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
import java.io.File;
import java.io.IOException;
@@ -29,7 +29,7 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.Generator;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
@@ -80,7 +80,7 @@
@Override
public void generateFromInterface(Writer output, ObjectModelInterface interfacez) throws IOException {
- if (!interfacez.hasStereotype(GeneratorUtil.STEREOTYPE_SERVICE)) {
+ if (!interfacez.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) {
return;
}
@@ -104,8 +104,8 @@
}
private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
@@ -122,7 +122,7 @@
// ajouter les imports des interfaces de DAO
for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
- if(parent.hasStereotype(GeneratorUtil.STEREOTYPE_DAO)){
+ if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
// r�cup�rer la classe de l'object model correspondant � la DAO
String className = parent.getQualifiedName().replace("DAO", "");
String interfaceName = parent.getQualifiedName()+"Abstract";
@@ -132,7 +132,7 @@
}
}
- if (GeneratorUtil.hasDocumentation(classifier)) {
+ if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
/*{
/**
@@ -161,7 +161,7 @@
/**
* Implementation a la charge du developpeur
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
}*/
}
@@ -198,14 +198,14 @@
for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
// pour tous les DAOInterface
- if(parent.hasStereotype(GeneratorUtil.STEREOTYPE_DAO)){
+ if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
// r�cup�rer la classe de l'object model correspondant � la DAO
String entityClassName = parent.getQualifiedName().replace("DAO", "");
if(getModel().hasClass(entityClassName)){
ObjectModelClass clazz = getModel().getClass(entityClassName);
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
/*{
@@ -269,7 +269,7 @@
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, false);
} else {
generateNMultiplicity(output, attr, clazz, false);
@@ -282,7 +282,7 @@
while (it.hasNext()) {
ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
if (attr != null) {
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, true);
} else {
generateNMultiplicity(output, attr, clazz, true);
@@ -298,7 +298,7 @@
protected void generateNoNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
String propertyName = attr.getName();
if (!isAssoc && attr.hasAssociationClass()) {
- propertyName = GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
+ propertyName = TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
}
/*{
/**
@@ -307,10 +307,10 @@
* @param v la valeur que doit avoir <%=attr.getName()%>
* @return un element ou null
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
+ public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = dao.findBy<%=GeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazz.getName()%> entity = dao.findBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entity;
};
@@ -320,10 +320,10 @@
* @param v la valeur que doit avoir <%=attr.getName()%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
+ public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> entityList = dao.findAllBy<%=GeneratorUtil.capitalize(attr.getName())%>(v);
+ List<<%=clazz.getName()%>> entityList = dao.findAllBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entityList;
};
}*/
@@ -331,27 +331,27 @@
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le parametre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le parametre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
* @return un element ou null
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
+ public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = dao.findBy<%=GeneratorUtil.capitalize(attr.getName())%>(v);
+ <%=clazz.getName()%> entity = dao.findBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entity;
};
/**
* Retourne les elements ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le param�tre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le param�tre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
+ public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> entityList = dao.findAllBy<%=GeneratorUtil.capitalize(attr.getName())%>(v);
+ List<<%=clazz.getName()%>> entityList = dao.findAllBy<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(v);
return entityList;
};
}*/
@@ -366,10 +366,10 @@
* @param v la valeur que doit contenir <%=attr.getName()%>
* @return un element ou null
*)
- public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>Contains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
+ public <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- <%=clazz.getName()%> entity = (<%=clazz.getName()%>) dao.findContainsProperties("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
+ <%=clazz.getName()%> entity = (<%=clazz.getName()%>) dao.findContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
return entity;
};
@@ -379,10 +379,10 @@
* @param v la valeur que doit contenir <%=attr.getName()%>
* @return une liste
*)
- public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>Contains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
+ public List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
- List<<%=clazz.getName()%>> entityList = dao.findAllContainsProperties("<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
+ List<<%=clazz.getName()%>> entityList = dao.findAllContainsProperties("<%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>", Arrays.asList(v));
return entityList;
};
}*/
@@ -393,7 +393,7 @@
for (Iterator i=classifier.getInterfaces().iterator(); i.hasNext();) {
ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
// pour tous les DAOInterface
- if(parent.hasStereotype(GeneratorUtil.STEREOTYPE_DAO)){
+ if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
// r�cup�rer la classe de l'object model correspondant � la DAO
String entityClassName = null;
@@ -407,7 +407,7 @@
}
private void generateFromDAOClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
@@ -418,62 +418,62 @@
&& !hasUnidirectionalRelationOnAbstractType(reverse, model)) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> � positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> � positionner.
*)
- public void set<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ entity.set<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
usedContextImpl.commitTransaction();
}
}*/
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
/*{ * @return La valeur de l'attribut <%=attr.getName()%>.
*)
- public <%=attr.getType()%> get<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=attr.getType()%> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(attr.getName())%>();
+ return entity.get<%=GeneratorUtil.capitalize(attr.getName())%>();
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner.
*)
- public void set<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ entity.set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
* @return La valeur de l'attribut <%=attr.getAssociationClass().getName()%>.
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(assocAttrName)%>();
+ return entity.get<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
}*/
@@ -482,131 +482,131 @@
if (!attr.hasAssociationClass()) { //M�thodes remplac�es par des add/set sur les classes d'assoc
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � ajouter.
*)
- public void add<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void add<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.add<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ entity.add<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> � ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> � ajouter.
*)
- public void addAll<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void addAll<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.addAll<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ entity.addAll<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> � positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> � positionner.
*)
- public void set<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ entity.set<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � retirer.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> � retirer.
*)
- public void remove<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void remove<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.remove<%=Util.capitalize(attr.getName())%>(<%=Util.toLowerCaseFirstLetter(attr.getName())%>);
+ entity.remove<%=GeneratorUtil.capitalize(attr.getName())%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>);
}
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
/*{ * Vide la Collection de <%=attr.getName()%>.
*)
- public void clear<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public void clear<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.clear<%=Util.capitalize(attr.getName())%>();
+ entity.clear<%=GeneratorUtil.capitalize(attr.getName())%>();
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � ajouter.
*)
- public void add<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.add<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ entity.add<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> � ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> � ajouter.
*)
- public void addAll<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.addAll<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ entity.addAll<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> � positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> � positionner.
*)
- public void set<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ entity.set<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � retirer.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> � retirer.
*)
- public void remove<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
+ public void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.remove<%=Util.capitalize(assocAttrName)%>(<%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
+ entity.remove<%=GeneratorUtil.capitalize(assocAttrName)%>(<%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>);
}
/**
* Vide la Collection de <%=attr.getAssociationClass().getName()%>.
*)
- public void clear<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.clear<%=Util.capitalize(assocAttrName)%>();
+ entity.clear<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
}*/
@@ -615,61 +615,61 @@
if (!attr.hasAssociationClass()) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
/*{ * @return La Liste de <%=attr.getName()%>.
*)
- public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(attr.getName())%>();
+ return entity.get<%=GeneratorUtil.capitalize(attr.getName())%>();
}
/**
* @return Le nombre d'�l�ments de la collection <%=attr.getName()%>.
*)
- public int size<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public int size<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.size<%=Util.capitalize(attr.getName())%>();
+ return entity.size<%=GeneratorUtil.capitalize(attr.getName())%>();
}
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
/*{ /**
* @return La liste des attributs <%=attr.getAssociationClass().getName()%>.
*)
- public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(assocAttrName)%>();
+ return entity.get<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
/**
* @return L'attribut <%=attr.getAssociationClass().getName()%> associ� � la valeur <code>value</code> de l'attribut <%=attr.getName()%>.
*)
- public <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> value) throws TopiaException{
+ public <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(assocAttrName)%>((<%=attr.getType()%>) value);
+ return entity.get<%=GeneratorUtil.capitalize(assocAttrName)%>((<%=attr.getType()%>) value);
}
/**
* @return Le nombre d'�l�ments de la collection <%=attr.getName()%>.
*)
- public int size<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.size<%=Util.capitalize(assocAttrName)%>();
+ return entity.size<%=GeneratorUtil.capitalize(assocAttrName)%>();
}
}*/
@@ -704,7 +704,7 @@
ObjectModelOperation op = (ObjectModelOperation)it.next();
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
}*/
}
@@ -761,21 +761,21 @@
/*{ /**
* @param value La valeur de l'attribut <%=name%> � positionner.
*)
- public void set<%=Util.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId, <%=type%> value) throws TopiaException{
+ public void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId, <%=type%> value) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- entity.set<%=Util.capitalize(name)%>( value);
+ entity.set<%=GeneratorUtil.capitalize(name)%>( value);
}
/**
* @return La valeur de l'attribut <%=name%>.
*)
- public <%=type%> get<%=Util.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
+ public <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazz.getName()%>DAOAbstract dao = (<%=clazz.getName()%>DAOAbstract)usedContextImpl.getDAO(<%=clazz.getName()%>.class);
<%=clazz.getName()%> entity = (<%=clazz.getName()%>)dao.findByTopiaId(topiaId);
- return entity.get<%=Util.capitalize(name)%>();
+ return entity.get<%=GeneratorUtil.capitalize(name)%>();
}
}*/
Modified: topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java 2009-01-29 10:53:27 UTC (rev 1327)
+++ topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceImplGenerator.java 2009-01-29 11:18:00 UTC (rev 1328)
@@ -76,7 +76,7 @@
@Override
public void generateFromInterface(Writer output, ObjectModelInterface interfacez) throws IOException {
- if (!interfacez.hasStereotype(GeneratorUtil.STEREOTYPE_SERVICE)) {
+ if (!interfacez.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) {
return;
}
@@ -89,7 +89,7 @@
for (Iterator i=interfacez.getInterfaces().iterator(); i.hasNext();) {
ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
// pour tous les DAOInterface
- if(parent.hasStereotype(GeneratorUtil.STEREOTYPE_DAO)){
+ if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
// récupérer la classe de l'object model correspondant à la DAO
String entityClassName = null;
entityClassName = parent.getQualifiedName().replace("DAO", "");
@@ -109,14 +109,14 @@
}
private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
/*{package <%=classifier.getPackageName()%>;}*/
- if (GeneratorUtil.hasDocumentation(classifier)) {
+ if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
/*{
/**
Modified: topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 10:53:27 UTC (rev 1327)
+++ topia/branches/generators-refactoring/topia-soa/src/main/java/org/codelutin/topia/generator/ServiceInterfaceGenerator.java 2009-01-29 11:18:00 UTC (rev 1328)
@@ -17,7 +17,7 @@
package org.codelutin.topia.generator;
-import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType;
+import static org.codelutin.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
import java.io.File;
import java.io.IOException;
@@ -32,7 +32,7 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.Generator;
import org.codelutin.generator.ObjectModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.object.ObjectModelAssociationClass;
import org.codelutin.generator.models.object.ObjectModelAttribute;
import org.codelutin.generator.models.object.ObjectModelClass;
@@ -97,7 +97,7 @@
@Override
public void generateFromInterface(Writer output, ObjectModelInterface interfacez) throws IOException {
- if (!interfacez.hasStereotype(GeneratorUtil.STEREOTYPE_SERVICE)) {
+ if (!interfacez.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) {
return;
}
@@ -133,8 +133,8 @@
}
private void generateInterfaceHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
- String copyright = GeneratorUtil.getCopyright(model);
- if (GeneratorUtil.notEmpty(copyright)) {
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
/*{<%=copyright%>
}*/
}
@@ -144,7 +144,7 @@
import org.codelutin.topia.TopiaException;
}*/
- if (GeneratorUtil.hasDocumentation(classifier)) {
+ if (TopiaGeneratorUtil.hasDocumentation(classifier)) {
/*{
/**
* <%=classifier.getDocumentation()%>
@@ -166,7 +166,7 @@
ObjectModelClass clazz = (ObjectModelClass)classifier;
for (Iterator i=clazz.getSuperclasses().iterator(); i.hasNext();) {
ObjectModelClassifier parent = (ObjectModelClassifier)i.next();
- if (parent.hasStereotype(GeneratorUtil.STEREOTYPE_SERVICE)) {
+ if (parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_SERVICE)) {
extendClass += parent.getQualifiedName();
}
extendClass += ", ";
@@ -195,7 +195,7 @@
/**
* Methode metier
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
}*/
}
@@ -245,7 +245,7 @@
if(getModel().hasClass(entityClassName)){
ObjectModelClass clazz = getModel().getClass(entityClassName);
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
@@ -293,7 +293,7 @@
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, false);
} else {
generateNMultiplicity(output, attr, clazz, false);
@@ -306,7 +306,7 @@
while (it.hasNext()) {
ObjectModelAttribute attr = (ObjectModelAttribute)it.next();
if (attr != null) {
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
generateNoNMultiplicity(output, attr, clazz, true);
} else {
generateNMultiplicity(output, attr, clazz, true);
@@ -322,12 +322,12 @@
protected void generateNoNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
String propertyName = attr.getName();
if (!isAssoc && attr.hasAssociationClass()) {
- propertyName = GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
+ propertyName = TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName()) + "." + propertyName;
}
// ajouter les methodes à la liste
- methods.add(clazz.getName()+" find"+clazz.getName()+"By"+GeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+GeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)");
+ methods.add(clazz.getName()+" find"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)");
+ methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" v)");
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
@@ -335,40 +335,40 @@
* @param v la valeur que doit avoir <%=attr.getName()%>
* @return un element ou null
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException;
+ public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException;
/**
* Retourne les éléments ayant comme valeur pour l'attribut
* <%=attr.getName()%> le paramêtre
* @param v la valeur que doit avoir <%=attr.getName()%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException;
+ public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException;
}*/
if (attr.hasAssociationClass()) {
- methods.add(clazz.getName() +" find"+clazz.getName()+"By"+GeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+GeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)");
+ methods.add(clazz.getName() +" find"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)");
+ methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"By"+TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())+"("+attr.getAssociationClass().getQualifiedName()+" value)");
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le parametre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le parametre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
* @return un element ou null
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException;
+ public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException;
/**
* Retourne les éléments ayant comme valeur pour l'attribut
- * <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le paramêtre
- * @param value la valeur que doit avoir <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
+ * <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> le paramêtre
+ * @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=GeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException;
+ public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>By<%=TopiaGeneratorUtil.capitalize(attr.getAssociationClass().getName())%>(<%=attr.getAssociationClass().getQualifiedName()%> value) throws TopiaException;
}*/
}
}
protected void generateNMultiplicity(Writer output, ObjectModelAttribute attr, ObjectModelClass clazz, boolean isAssoc) throws IOException {
- methods.add(clazz.getName() + " find"+clazz.getName()+"Contains"+GeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)");
- methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"Contains"+GeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)");
+ methods.add(clazz.getName() + " find"+clazz.getName()+"Contains"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)");
+ methods.add("List<"+clazz.getName()+"> findAll"+clazz.getName()+"Contains"+TopiaGeneratorUtil.capitalize(attr.getName())+"("+attr.getType()+" ... v)");
/*{
/**
* Retourne le premier element trouve dont l'attribut
@@ -376,14 +376,14 @@
* @param v la valeur que doit contenir <%=attr.getName()%>
* @return un element ou null
*)
- public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>Contains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException;
+ public abstract <%=clazz.getQualifiedName()%> find<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException;
/**
* Retourne les elements trouve dont l'attribut
* <%=attr.getName()%> contient le parametre
* @param v la valeur que doit contenir <%=attr.getName()%>
* @return une liste
*)
- public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>Contains<%=GeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException;
+ public abstract List<<%=clazz.getQualifiedName()%>> findAll<%=clazz.getName()%>Contains<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> ... v) throws TopiaException;
}*/
}
@@ -405,7 +405,7 @@
}
private void generateFromDAOClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(GeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
return;
}
@@ -416,48 +416,48 @@
&& !hasUnidirectionalRelationOnAbstractType(reverse, model)) {
continue;
}
- if (!Util.isNMultiplicity(attr)) {
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
if (!attr.hasAssociationClass()) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void set"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+Util.toLowerCaseFirstLetter(attr.getName())+")");
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void set"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> à positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> à positionner.
*)
- public abstract void set<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
}*/
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add(attr.getType()+" get"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add(attr.getType()+" get"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
/*{ * @return La valeur de l'attribut <%=attr.getName()%>.
*)
- public abstract <%=attr.getType()%> get<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=attr.getType()%> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
- methods.add("void set"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add(attr.getAssociationClass().getName()+" get"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
+ methods.add(attr.getAssociationClass().getName()+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La valeur de l'attribut <%=attr.getAssociationClass().getName()%> � positionner.
*)
- public abstract void set<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
/**
* @return La valeur de l'attribut <%=attr.getAssociationClass().getName()%>.
*)
- public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
}*/
}
@@ -465,93 +465,93 @@
if (!attr.hasAssociationClass()) { //Méthodes remplacées par des add/set sur les classes d'assoc
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void add"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" "+Util.toLowerCaseFirstLetter(attr.getName())+")");
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void add"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à ajouter.
*)
- public abstract void add<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void add<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void addAll"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+Util.toLowerCaseFirstLetter(attr.getName())+")");;
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void addAll"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");;
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> à ajouter.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> Les instances de <%=attr.getName()%> à ajouter.
*)
- public abstract void addAll<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void addAll<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void set"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+ (attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+Util.toLowerCaseFirstLetter(attr.getName())+")");
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void set"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+ (attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> à positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La Collection de <%=attr.getName()%> à positionner.
*)
- public abstract void set<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void remove"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+Util.toLowerCaseFirstLetter(attr.getName())+")");
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void remove"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+ " "+GeneratorUtil.toLowerCaseFirstLetter(attr.getName())+")");
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=Util.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à retirer.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> L'instance de <%=attr.getName()%> à retirer.
*)
- public abstract void remove<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=Util.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
+ public abstract void remove<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException;
/**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add("void clear"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add("void clear"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
/*{ * Vide la Collection de <%=attr.getName()%>.
*)
- public abstract void clear<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract void clear<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
- methods.add("void add"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void addAll"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void set"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void remove"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
- methods.add("void clear"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add("void add"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
+ methods.add("void addAll"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
+ methods.add("void set"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+(attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
+ methods.add("void remove"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getAssociationClass().getName()+" "+GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())+")");
+ methods.add("void clear"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
/*{ /**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à ajouter.
*)
- public abstract void add<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void add<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> à ajouter.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> Les instances de <%=attr.getAssociationClass().getName()%> à ajouter.
*)
- public abstract void addAll<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void addAll<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> à positionner.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> La Collection de <%=attr.getAssociationClass().getName()%> à positionner.
*)
- public abstract void set<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
/**
- * @param <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à retirer.
+ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%> L'instance de <%=attr.getAssociationClass().getName()%> à retirer.
*)
- public abstract void remove<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
+ public abstract void remove<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getAssociationClass().getQualifiedName()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getAssociationClass().getName())%>) throws TopiaException;
/**
* Vide la Collection de <%=attr.getAssociationClass().getName()%>.
*)
- public abstract void clear<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract void clear<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
}*/
}
@@ -559,43 +559,43 @@
if (!attr.hasAssociationClass()) {
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(attr)) {
- methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> get"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
- methods.add("int size"+Util.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getType()+"> get"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add("int size"+GeneratorUtil.capitalize(attr.getName())+"Of"+clazz.getName()+"(String topiaId)");
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
/*{ * @return La Liste de <%=attr.getName()%>.
*)
- public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getType()%>> get<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
/**
* @return Le nombre d'éléments de la collection <%=attr.getName()%>.
*)
- public abstract int size<%=Util.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract int size<%=GeneratorUtil.capitalize(attr.getName())%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
}*/
} else {
- String assocAttrName = GeneratorUtil.getAssocAttrName(attr);
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
if (log.isTraceEnabled()) { log.trace("assocAttrName: " + assocAttrName); }
- methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> get"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"Of"+clazz.getName()+"(String topiaId)");
- methods.add(attr.getAssociationClass().getName()+" get"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" value)");
- methods.add("int size"+Util.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add((attr.isOrdered()?"java.util.List":"java.util.Collection")+"<"+attr.getAssociationClass().getName()+"> get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add(attr.getAssociationClass().getName()+" get"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId, "+attr.getType()+" value)");
+ methods.add("int size"+GeneratorUtil.capitalize(assocAttrName)+"Of"+clazz.getName()+"(String topiaId)");
/*{ /**
* @return La liste des attributs <%=attr.getAssociationClass().getName()%>.
*)
- public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=(attr.isOrdered()?"java.util.List":"java.util.Collection")%><<%=attr.getAssociationClass().getQualifiedName()%>> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
/**
* @return L'attribut <%=attr.getAssociationClass().getName()%> associé à la valeur <code>value</code> de l'attribut <%=attr.getName()%>.
*)
- public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> value) throws TopiaException;
+ public abstract <%=attr.getAssociationClass().getQualifiedName()%> get<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId, <%=attr.getType()%> value) throws TopiaException;
/**
* @return Le nombre d'éléments de la collection <%=attr.getName()%>.
*)
- public abstract int size<%=Util.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract int size<%=GeneratorUtil.capitalize(assocAttrName)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
}*/
}
@@ -630,7 +630,7 @@
String method = op.getReturnType()+ " "+op.getName()+"(";
/*{ /**
}*/
- if (GeneratorUtil.hasDocumentation(op)) {
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
/*{ * <%=op.getName()%> : <%=op.getDocumentation()%>
}*/
}
@@ -671,17 +671,17 @@
}
private void generateAssociationAccessors(Writer output, ObjectModelClass clazz, String name, String type) throws IOException {
- methods.add("=> "+"void set"+Util.capitalize(name)+"Of"+clazz.getName()+"(String topiaId, "+type+" value)");
- methods.add("=> "+type+" get"+Util.capitalize(name)+"Of"+clazz.getName()+"(String topiaId)");
+ methods.add("=> "+"void set"+GeneratorUtil.capitalize(name)+"Of"+clazz.getName()+"(String topiaId, "+type+" value)");
+ methods.add("=> "+type+" get"+GeneratorUtil.capitalize(name)+"Of"+clazz.getName()+"(String topiaId)");
/*{ /**
* @param value La valeur de l'attribut <%=name%> à positionner.
*)
- public abstract void set<%=Util.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId, <%=type%> value) throws TopiaException;
+ public abstract void set<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId, <%=type%> value) throws TopiaException;
/**
* @return La valeur de l'attribut <%=name%>.
*)
- public abstract <%=type%> get<%=Util.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
+ public abstract <%=type%> get<%=GeneratorUtil.capitalize(name)%>Of<%=clazz.getName()%>(String topiaId) throws TopiaException;
}*/
}
Modified: topia/branches/generators-refactoring/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java
===================================================================
--- topia/branches/generators-refactoring/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java 2009-01-29 10:53:27 UTC (rev 1327)
+++ topia/branches/generators-refactoring/topia-ui/src/main/java/org/codelutin/topia/generator/TapestryWebGenerator.java 2009-01-29 11:18:00 UTC (rev 1328)
@@ -30,7 +30,7 @@
import org.apache.commons.logging.LogFactory;
import org.codelutin.generator.MonitorWriter;
import org.codelutin.generator.StateModelGenerator;
-import org.codelutin.generator.Util;
+import org.codelutin.generator.GeneratorUtil;
import org.codelutin.generator.models.state.StateModel;
import org.codelutin.generator.models.state.StateModelComplexState;
import org.codelutin.generator.models.state.StateModelSimpleState;
@@ -105,7 +105,7 @@
* @return name
*/
protected String getNameFromState(StateModelState state) {
- return "Abstract" + Util.toUpperCaseFirstLetter(state.getName());
+ return "Abstract" + GeneratorUtil.toUpperCaseFirstLetter(state.getName());
}
/**
@@ -202,7 +202,7 @@
* @throws IOException
*/
protected void generateFromSimpleState(Writer output, StateModelStateChart chart, StateModelState state) throws IOException {
- //String copyright = GeneratorUtil.getCopyright(model);
+ //String copyright = GeneratorGeneratorUtil.getCopyright(model);
String copyright = model.getTagValue("copyright");
if (copyright != null && !copyright.isEmpty()) {
/*{<%=copyright%>
@@ -256,21 +256,21 @@
/*{
/* linked state "<%=toState.getName()%>" *)
@InjectPage
- private <%=Util.toUpperCaseFirstLetter(toInitState.getName())%> <%=Util.toLowerCaseFirstLetter(toInitState.getName())%>;
+ private <%=GeneratorUtil.toUpperCaseFirstLetter(toInitState.getName())%> <%=GeneratorUtil.toLowerCaseFirstLetter(toInitState.getName())%>;
}*/
// l'attribut etant prive, il faut un getter
/*{
/* getter for state "<%=toState.getName()%>" *)
- protected <%=Util.toUpperCaseFirstLetter(toInitState.getName())%> get<%=Util.toUpperCaseFirstLetter(toInitState.getName())%>() {
- return <%=Util.toLowerCaseFirstLetter(toInitState.getName())%>;
+ protected <%=GeneratorUtil.toUpperCaseFirstLetter(toInitState.getName())%> get<%=GeneratorUtil.toUpperCaseFirstLetter(toInitState.getName())%>() {
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(toInitState.getName())%>;
}
}*/
}
/*{
/* transition on <%=transition.getEvent()%> event *)
- public Object onActionFrom<%=Util.toUpperCaseFirstLetter(transition.getEvent())%>() {
+ public Object onActionFrom<%=GeneratorUtil.toUpperCaseFirstLetter(transition.getEvent())%>() {
enterUseCase();
- return <%=Util.toLowerCaseFirstLetter(toInitState.getName())%>;
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(toInitState.getName())%>;
}
}*/
}
@@ -287,26 +287,26 @@
/*{
/* linked state "<%=simpleToState.getName()%>" *)
@InjectPage
- private <%=Util.toUpperCaseFirstLetter(simpleToState.getName())%> <%=Util.toLowerCaseFirstLetter(simpleToState.getName())%>;
+ private <%=GeneratorUtil.toUpperCaseFirstLetter(simpleToState.getName())%> <%=GeneratorUtil.toLowerCaseFirstLetter(simpleToState.getName())%>;
}*/
// l'attribut etant prive, il faut un getter
/*{
/* getter for state "<%=simpleToState.getName()%>" *)
- protected <%=Util.toUpperCaseFirstLetter(simpleToState.getName())%> get<%=Util.toUpperCaseFirstLetter(simpleToState.getName())%>() {
- return <%=Util.toLowerCaseFirstLetter(simpleToState.getName())%>;
+ protected <%=GeneratorUtil.toUpperCaseFirstLetter(simpleToState.getName())%> get<%=GeneratorUtil.toUpperCaseFirstLetter(simpleToState.getName())%>() {
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(simpleToState.getName())%>;
}
}*/
}
} // isFinal
/*{
/* transition on "<%=transition.getEvent()%>" event *)
- public Object onActionFrom<%=Util.toUpperCaseFirstLetter(transition.getEvent())%>() {
+ public Object onActionFrom<%=GeneratorUtil.toUpperCaseFirstLetter(transition.getEvent())%>() {
}*/
if(simpleToState.isFinal()) {
/*{ return leaveUseCase();
}*/
} else {
-/*{ return <%=Util.toLowerCaseFirstLetter(simpleToState.getName())%>;
+/*{ return <%=GeneratorUtil.toLowerCaseFirstLetter(simpleToState.getName())%>;
}*/
}
/*{ }
1
0