r1287 - in topia/tags: . 2.1.2 2.1.2/topia-persistence 2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator 2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util 2.1.2/topia-soa 2.1.2/topia-ui
Author: tchemit Date: 2009-01-07 08:35:25 +0000 (Wed, 07 Jan 2009) New Revision: 1287 Added: topia/tags/2.1.2/ topia/tags/2.1.2/pom.xml topia/tags/2.1.2/topia-persistence/changelog.txt topia/tags/2.1.2/topia-persistence/pom.xml topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/BeanPropertyLoador.java topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/Loador.java topia/tags/2.1.2/topia-soa/pom.xml topia/tags/2.1.2/topia-ui/pom.xml Removed: topia/tags/2.1.2/pom.xml topia/tags/2.1.2/topia-persistence/changelog.txt topia/tags/2.1.2/topia-persistence/pom.xml topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/BeanPropertyLoador.java topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/Loador.java topia/tags/2.1.2/topia-soa/pom.xml topia/tags/2.1.2/topia-ui/pom.xml Log: [maven-release-plugin] copy for tag 2.1.2 Copied: topia/tags/2.1.2 (from rev 1284, topia/trunk) Deleted: topia/tags/2.1.2/pom.xml =================================================================== --- topia/trunk/pom.xml 2009-01-05 08:40:44 UTC (rev 1284) +++ topia/tags/2.1.2/pom.xml 2009-01-07 08:35:25 UTC (rev 1287) @@ -1,127 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <!-- ************************************************************* --> - <!-- *** POM Relationships *************************************** --> - <!-- ************************************************************* --> - <parent> - <groupId>org.codelutin</groupId> - <artifactId>lutinproject</artifactId> - <version>3.2</version> - </parent> - - <artifactId>topia</artifactId> - <version>2.1.2-SNAPSHOT</version> - - <modules> - <module>topia-persistence</module> - <module>topia-soa</module> - <module>topia-ui</module> - </modules> - - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutingenerator</artifactId> - <version>${generator.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutinutil</artifactId> - <version>${lutinutil.version}</version> - <scope>compile</scope> - </dependency> - </dependencies> - </dependencyManagement> - - <!-- ************************************************************* --> - <!-- *** Project Information ************************************* --> - <!-- ************************************************************* --> - <name>ToPIA - Tools for Portable and Independent Architecture</name> - <description>Framework de persistance et de distribution d'application.</description> - <inceptionYear>2004</inceptionYear> - - <!-- ************************************************************* --> - <!-- *** Build Settings ****************************************** --> - <!-- ************************************************************* --> - - <packaging>pom</packaging> - - <properties> - <!-- id du projet du labs --> - <labs.id>21</labs.id> - - <!-- nom du projet sur le labs --> - <labs.project>topia</labs.project> - - <!-- Ignore failure test for now --> - <maven.test.testFailureIgnore>true</maven.test.testFailureIgnore> - - <!-- generator version --> - <generator.version>0.63</generator.version> - - <!-- processor version --> - <processor.version>0.16</processor.version> - - <!-- lutinutil version --> - <lutinutil.version>1.0</lutinutil.version> - - </properties> - - <build> - <defaultGoal>install</defaultGoal> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.codelutin</groupId> - <artifactId>maven-processor-plugin</artifactId> - <version>${processor.version}</version> - <executions> - <execution> - <phase>generate-sources</phase> - <goals> - <goal>process</goal> - </goals> - </execution> - </executions> - <configuration> - <!-- You might change defaut directories --> - <!-- srcDir>${basedir}/src/main/java</srcDir> - <destDir>${basedir}/target/processed-sources/java</destDir--> - <addCompileDirectory>true</addCompileDirectory> - <includes> - <include>**/*.java</include> - </includes> - <filters> - org.codelutin.processor.filters.GeneratorTemplatesFilter, - org.codelutin.processor.filters.ActiveLogsCodeFilter - </filters> - <verbose>${maven.verbose}</verbose> - </configuration> - </plugin> - </plugins> - </pluginManagement> - - <plugins> - - <plugin> - <artifactId>maven-javadoc-plugin</artifactId> - </plugin> - - </plugins> - </build> - - <!-- ************************************************************* --> - <!-- *** Build Environment ************************************** --> - <!-- ************************************************************* --> - <scm> - <connection>${maven.scm.connection}</connection> - <developerConnection>${maven.scm.developerConnection}</developerConnection> - <url>${maven.scm.url}</url> - </scm> - -</project> Copied: topia/tags/2.1.2/pom.xml (from rev 1286, topia/trunk/pom.xml) =================================================================== --- topia/tags/2.1.2/pom.xml (rev 0) +++ topia/tags/2.1.2/pom.xml 2009-01-07 08:35:25 UTC (rev 1287) @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + <parent> + <groupId>org.codelutin</groupId> + <artifactId>lutinproject</artifactId> + <version>3.2</version> + </parent> + + <artifactId>topia</artifactId> + <version>2.1.2</version> + + <modules> + <module>topia-persistence</module> + <module>topia-soa</module> + <module>topia-ui</module> + </modules> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.codelutin</groupId> + <artifactId>lutingenerator</artifactId> + <version>${generator.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.codelutin</groupId> + <artifactId>lutinutil</artifactId> + <version>${lutinutil.version}</version> + <scope>compile</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + <name>ToPIA - Tools for Portable and Independent Architecture</name> + <description>Framework de persistance et de distribution d'application.</description> + <inceptionYear>2004</inceptionYear> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>pom</packaging> + + <properties> + <!-- id du projet du labs --> + <labs.id>21</labs.id> + + <!-- nom du projet sur le labs --> + <labs.project>topia</labs.project> + + <!-- Ignore failure test for now --> + <maven.test.testFailureIgnore>true</maven.test.testFailureIgnore> + + <!-- generator version --> + <generator.version>0.63</generator.version> + + <!-- processor version --> + <processor.version>0.16</processor.version> + + <!-- lutinutil version --> + <lutinutil.version>1.0</lutinutil.version> + + </properties> + + <build> + <defaultGoal>install</defaultGoal> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.codelutin</groupId> + <artifactId>maven-processor-plugin</artifactId> + <version>${processor.version}</version> + <executions> + <execution> + <phase>generate-sources</phase> + <goals> + <goal>process</goal> + </goals> + </execution> + </executions> + <configuration> + <!-- You might change defaut directories --> + <!-- srcDir>${basedir}/src/main/java</srcDir> + <destDir>${basedir}/target/processed-sources/java</destDir--> + <addCompileDirectory>true</addCompileDirectory> + <includes> + <include>**/*.java</include> + </includes> + <filters> + org.codelutin.processor.filters.GeneratorTemplatesFilter, + org.codelutin.processor.filters.ActiveLogsCodeFilter + </filters> + <verbose>${maven.verbose}</verbose> + </configuration> + </plugin> + </plugins> + </pluginManagement> + + <plugins> + + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + </plugin> + + </plugins> + </build> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + <scm> + <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/topia/topia/tags/2.1.2</connection> + <developerConnection>scm:svn:svn+ssh://tchemit@labs.libre-entreprise.org/svnroot/topia/topia/tags/2.1.2</developerConnection> + <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/topia/tags/2.1.2?root=topia</url> + </scm> + +</project> Deleted: topia/tags/2.1.2/topia-persistence/changelog.txt =================================================================== --- topia/trunk/topia-persistence/changelog.txt 2009-01-05 08:40:44 UTC (rev 1284) +++ topia/tags/2.1.2/topia-persistence/changelog.txt 2009-01-07 08:35:25 UTC (rev 1287) @@ -1,14 +0,0 @@ -2.1.2 ??? 200901?? -* 20090104 [chemit] - utilisation foreach dans les générateurs - - ajout de méthode getXXXByTopiaId pour les attributs à multiplicité dans les entités (interface et abstract) - - fix generic dans les méthodes générées - - ajout d'un tagValue i18n pour générer dans les entités abstraites les chaines i18n - - ajout d'un paquetage org.codelutin.topia.persistence.util avec du code utile :) (javadoc a faire...) - -2.1.1 chemit 20081215 -* 20081215 [chemit] - new release for isis-fish :) -* 20081212 [chemit] - add a InterfaceGenerator to generate simple with no stereotype interfaces. - -2.1.0 chemit 20081210 -* 20081205 [chemit] - improve poms, use lutinproject 3.2 - - add some usefull methods in TopiaUtil to help with regex on topiaId expression \ No newline at end of file Copied: topia/tags/2.1.2/topia-persistence/changelog.txt (from rev 1285, topia/trunk/topia-persistence/changelog.txt) =================================================================== --- topia/tags/2.1.2/topia-persistence/changelog.txt (rev 0) +++ topia/tags/2.1.2/topia-persistence/changelog.txt 2009-01-07 08:35:25 UTC (rev 1287) @@ -0,0 +1,21 @@ +2.1.2 ??? 200901?? +* 20090106 [chemit] - amélioration du générateur de mapping hibernate : + - génération des clefs metier dans le mapping hibernate via la tag value naturalId + - mise en constantes des tagValues utiliser dans le génératuer du mapping hibernate + - ajout du tagValue notNull pour le mapping hibernate + - changement du tagValue order-by en orderBy car sinon on récupère order au lieu de order-by + - ajout de la méthode obtainProgperties sur la classe Loador pour recuperer la map des propriétés à binder + (car pour les clef métiers on doit les ajouter à la création sinon hibernate pleure...) +* 20090104 [chemit] - utilisation foreach dans les générateurs + - ajout de méthode getXXXByTopiaId pour les attributs à multiplicité dans les entités (interface et abstract) + - fix generic dans les méthodes générées + - ajout d'un tagValue i18n pour générer dans les entités abstraites les chaines i18n + - ajout d'un paquetage org.codelutin.topia.persistence.util avec du code utile :) (javadoc a faire...) + +2.1.1 chemit 20081215 +* 20081215 [chemit] - new release for isis-fish :) +* 20081212 [chemit] - add a InterfaceGenerator to generate simple with no stereotype interfaces. + +2.1.0 chemit 20081210 +* 20081205 [chemit] - improve poms, use lutinproject 3.2 + - add some usefull methods in TopiaUtil to help with regex on topiaId expression \ No newline at end of file Deleted: topia/tags/2.1.2/topia-persistence/pom.xml =================================================================== --- topia/trunk/topia-persistence/pom.xml 2009-01-05 08:40:44 UTC (rev 1284) +++ topia/tags/2.1.2/topia-persistence/pom.xml 2009-01-07 08:35:25 UTC (rev 1287) @@ -1,108 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <!-- ************************************************************* --> - <!-- *** POM Relationships *************************************** --> - <!-- ************************************************************* --> - - <parent> - <groupId>org.codelutin</groupId> - <artifactId>topia</artifactId> - <version>2.1.2-SNAPSHOT</version> - </parent> - - <groupId>org.codelutin.topia</groupId> - <artifactId>topia-persistence</artifactId> - - <dependencies> - - <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutinutil</artifactId> - </dependency> - - <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutingenerator</artifactId> - </dependency> - - <dependency> - <groupId>commons-collections</groupId> - <artifactId>commons-collections</artifactId> - <version>3.2.1</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-core</artifactId> - <version>3.3.1.GA</version> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.hibernate</groupId> - <artifactId>hibernate-ehcache</artifactId> - <version>3.3.1.GA</version> - <scope>runtime</scope> - </dependency> - <dependency> - <groupId>javassist</groupId> - <artifactId>javassist</artifactId> - <version>3.4.GA</version> - <scope>runtime</scope> - </dependency> - <!-- hibernate-core only include api, need core --> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.5.2</version> - <scope>runtime</scope> - </dependency> - - <!-- BD H2 for testing --> - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <version>1.1.104</version> - <scope>test</scope> - </dependency> - </dependencies> - - <!-- ************************************************************* --> - <!-- *** Project Information ************************************* --> - <!-- ************************************************************* --> - - <name>ToPIA - Persistence</name> - <description>Hibernate based persistence module</description> - - <!-- ************************************************************* --> - <!-- *** Build Settings ****************************************** --> - <!-- ************************************************************* --> - - <packaging>jar</packaging> - - <build> - <defaultGoal>install</defaultGoal> - <plugins> - - <plugin> - <groupId>org.codelutin</groupId> - <artifactId>maven-processor-plugin</artifactId> - </plugin> - - </plugins> - </build> - - <!-- ************************************************************* --> - <!-- *** Build Environment ************************************** --> - <!-- ************************************************************* --> - <scm> - <connection>${maven.scm.connection.child}</connection> - <developerConnection>${maven.scm.developerConnection.child}</developerConnection> - <url>${maven.scm.url.child}</url> - </scm> - - -</project> Copied: topia/tags/2.1.2/topia-persistence/pom.xml (from rev 1286, topia/trunk/topia-persistence/pom.xml) =================================================================== --- topia/tags/2.1.2/topia-persistence/pom.xml (rev 0) +++ topia/tags/2.1.2/topia-persistence/pom.xml 2009-01-07 08:35:25 UTC (rev 1287) @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.codelutin</groupId> + <artifactId>topia</artifactId> + <version>2.1.2</version> + </parent> + + <groupId>org.codelutin.topia</groupId> + <artifactId>topia-persistence</artifactId> + + <dependencies> + + <dependency> + <groupId>org.codelutin</groupId> + <artifactId>lutinutil</artifactId> + </dependency> + + <dependency> + <groupId>org.codelutin</groupId> + <artifactId>lutingenerator</artifactId> + </dependency> + + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>3.2.1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-core</artifactId> + <version>3.3.1.GA</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.hibernate</groupId> + <artifactId>hibernate-ehcache</artifactId> + <version>3.3.1.GA</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>javassist</groupId> + <artifactId>javassist</artifactId> + <version>3.4.GA</version> + <scope>runtime</scope> + </dependency> + <!-- hibernate-core only include api, need core --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.5.2</version> + <scope>runtime</scope> + </dependency> + + <!-- BD H2 for testing --> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <version>1.1.104</version> + <scope>test</scope> + </dependency> + </dependencies> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <name>ToPIA - Persistence</name> + <description>Hibernate based persistence module</description> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>jar</packaging> + + <build> + <defaultGoal>install</defaultGoal> + <plugins> + + <plugin> + <groupId>org.codelutin</groupId> + <artifactId>maven-processor-plugin</artifactId> + </plugin> + + </plugins> + </build> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + <scm> + <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/topia/topia/tags/2.1.2/topia-persistence</connection> + <developerConnection>scm:svn:svn+ssh://tchemit@labs.libre-entreprise.org/svnroot/topia/topia/tags/2.1.2/topia-persistence</developerConnection> + <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/topia/tags/2.1.2/topia-persistence?root=topia</url> + </scm> + + +</project> Deleted: topia/tags/2.1.2/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-05 08:40:44 UTC (rev 1284) +++ topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java 2009-01-07 08:35:25 UTC (rev 1287) @@ -1,447 +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>. ##%*/ - -/* * -* EntityHibernateMappingGenerator.java -* -* Created: 12 déc. 2005 -* -* @author Arnaud Thimel <thimel@codelutin.com> -* @version $Revision$ -* -* Mise a jour: $Date$ -* par : $Author$ -* Mise a jour: $Date$ -* par : $Author$ -*/ - -package org.codelutin.topia.generator; - -import java.io.File; -import java.io.IOException; -import java.io.Writer; -import java.util.HashMap; -import java.util.Map; - -import org.apache.commons.logging.Log; -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.models.object.ObjectModelAssociationClass; -import org.codelutin.generator.models.object.ObjectModelAttribute; -import org.codelutin.generator.models.object.ObjectModelClass; - -import static org.codelutin.topia.generator.GeneratorUtil.notEmpty; -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.PERSISTENCE_TYPE_HIBERNATE; -import static org.codelutin.topia.generator.GeneratorUtil.hasUnidirectionalRelationOnAbstractType; - -/** - * FIXME mettre les attributs node="..." sur tous les attributs - * @author poussin - * - */ -public class EntityHibernateMappingGenerator extends ObjectModelGenerator { - - /** - * Logger for this class - */ - private static final Log log = LogFactory - .getLog(EntityHibernateMappingGenerator.class); - - private Map<String, String[]> columnNamesMap = new HashMap<String, String[]>(); - - public EntityHibernateMappingGenerator() { - super(); - } - - public EntityHibernateMappingGenerator(Generator parent) { - super(parent); - } - - @Override - public String getFilenameForClass(ObjectModelClass clazz) { - String DOName = GeneratorUtil.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); - if (!clazz.hasStereotype(STEREOTYPE_ENTITY) && PERSISTENCE_TYPE_HIBERNATE.equals(persistenceType)) { - return; - } -/*{<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> -<hibernate-mapping default-access="field" auto-import="true" package="<%=clazz.getPackageName()%>"> -}*/ - boolean haveSuper = clazz.getSuperclasses().size() > 0; - - 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%>" }*/ - } -/*{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()%>" }*/ -/*{> - <!--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()%>" }*/ -/*{> - <id name="topiaId" type="string" length="255" node="@topiaId"/> - <version name="topiaVersion" type="long" node="@topiaVersion"/> - <property name="topiaCreateDate" type="date" node="@topiaCreateDate"/> -}*/ - } - - for (Object o : clazz.getAttributes()) { - ObjectModelAttribute attr = (ObjectModelAttribute) o; - ObjectModelAttribute reverse = attr.getReverseAttribute(); - - // pour les asso quoi qu'il arrive il faut les lier des 2 cotes - // pour pouvoir supprimer en cascade l'asso lors de la suppression - // d'un des cotes - if (attr.isNavigable() - || hasUnidirectionalRelationOnAbstractType(reverse, model) - || attr.hasAssociationClass()) { - if (!Util.isNMultiplicity(attr)) { - if (attr.getClassifier() != null && attr.getClassifier().hasStereotype(STEREOTYPE_ENTITY)) { - if (Util.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) { - generateHibernateManyToOne(output, attr); - } else { - generateHibernateOneToOne(output, attr); - } - } else { - generateHibernateProperty(output, attr); - } - } else { - if (attr.getClassifier() != null && attr.getClassifier().hasStereotype(STEREOTYPE_ENTITY)) { - if (Util.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) { - generateHibernateManyToMany(output, attr); - } else { - generateHibernateOneToMany(output, attr); - } - } else { - generateHibernateMany(output, attr); - } - } - } - } - - //Attributs pour les classes d'association - if (clazz instanceof ObjectModelAssociationClass) { - ObjectModelAssociationClass assoc = (ObjectModelAssociationClass)clazz; - for (Object o : assoc.getParticipantsAttributes()) { - ObjectModelAttribute attr = (ObjectModelAttribute) o; - if (attr != null) { - -// 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\"":"")%>/> -// } */ -// } else { - -/*{ <many-to-one name="<%=getName(attr, true)%>" class="<%=getType(attr, true)%>" column="<%=GeneratorUtil.getDBName(attr)%>" node="<%=getName(attr, true)%>/@topiaId" embed-xml="false"/> -}*/ -// } - //Ne sert plus grâce à l'utilisation de la navigabilité -// if (!attr.getReverseAttribute().isNavigable()) { -// String type = GeneratorUtil.getDOType(((ObjectModelClassifier)attr.getDeclaringElement()).getQualifiedName(), model); -// String name = Util.toLowerCaseFirstLetter(attr.getDeclaringElement().getName()); -// if (log.isTraceEnabled()) {log.trace("reverse: " + type + " " + name);} -// if (!Util.isNMultiplicity(attr)) { -//{<!-- <one-to-one name="<%=name%>" class="<%=type%>"/> -//} -// } else { -//{ <many-to-one name="<%=name%>" class="<%=type%>" column="<%=name.toLowerCase()%>"/> --> -//} -// } -// } - } - } - } - - if (haveSuper) { -/*{ </union-subclass> -}*/ - } else { -/*{ </class> -}*/ - } -/*{</hibernate-mapping> -}*/ - } - - protected String getName(ObjectModelAttribute attr) { - return getName(attr, false); - } - - protected String getName(ObjectModelAttribute attr, boolean isAssoc) { - String result = Util.toLowerCaseFirstLetter(attr.getName()); - if (attr.hasAssociationClass() && !isAssoc) { - result = GeneratorUtil.getAssocAttrName(attr); - } - return result; - } - - protected String getType(ObjectModelAttribute attr) { - return getType(attr, false); - } - - protected String getType(ObjectModelAttribute attr, boolean isAssoc) { - String type = attr.getType(); - if (GeneratorUtil.notEmpty(model.getTagValue(type))) { - String typeString = model.getTagValue(type); - int bracketIndex = typeString.indexOf('('); - if (bracketIndex != -1) { - type = typeString.substring(0, bracketIndex); - int bracketEndIndex = typeString.indexOf(')', bracketIndex + 1); - String colmunList; - if (bracketEndIndex != -1) { - colmunList = typeString.substring(bracketIndex + 1, bracketEndIndex); - } else { - colmunList = typeString.substring(bracketIndex); - } - columnNamesMap.put(type, colmunList.split(",")); - } else { - type = typeString; - } - } - if (attr.hasAssociationClass() && !isAssoc) { - type = attr.getAssociationClass().getQualifiedName(); - } - return GeneratorUtil.getDOType(type, model); - } - - protected void generateHibernateProperty(Writer output, ObjectModelAttribute attr) throws IOException { - String type = getType(attr); - if (type.trim().endsWith("[]")) { - type = type.trim().substring(0, type.trim().length()-2); -/*{ <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); - if (schema != null) { -/*{schema="<%=schema%>" }*/ - } - if (attr.isIndexed()) { -/*{index="<%=GeneratorUtil.getDBName(attr.getDeclaringElement()) + "_" + getName(attr)%>_idx" }*/ - } -/*{> - <key column="<%=GeneratorUtil.getDBName(attr.getDeclaringElement())%>"/> - <list-index column="<%=getName(attr)%>_idx"/> - <element type="<%=type%>"/> - </primitive-array> -}*/ - } else { -/*{ <property name="<%=getName(attr)%>" type="<%=type%>" }*/ - String accessField = attr.getTagValue(TAG_ACCESS); - if (notEmpty(accessField)) { -/*{access="<%=accessField%>" }*/ - } else { -/*{access="field" }*/ - } - if (attr.isIndexed()) { -/*{index="<%=GeneratorUtil.getDBName(attr.getDeclaringElement()) + "_" + getName(attr)%>_idx" }*/ - } - String[] columnNames = this.columnNamesMap.get(type); - 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)%>"/> -}*/ - } else { -/*{> -}*/ - for (String columnName : columnNames) { - columnName = columnName.trim(); -/*{ <column name="<%=getName(attr) + "_" + columnName%>"/> -}*/ - } -/*{ </property> -}*/ - } - } - } - - protected void generateHibernateOneToOne(Writer output, ObjectModelAttribute attr) throws IOException { - generateHibernateManyToOne(output, attr, true); -// 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"/> -//} */ - } - - protected void generateHibernateOneToMany(Writer output, ObjectModelAttribute attr) throws IOException { - boolean needsIndex = attr.isIndexed(); - boolean isInverse = attr.getReverseAttribute().isNavigable(); - isInverse |= hasUnidirectionalRelationOnAbstractType(attr, model); - String orderBy = attr.getTagValue("order-by"); - if (orderBy == null) { - orderBy = ""; - } else { - orderBy = "order-by=\"" + orderBy + "\""; - } - - String cascade = ""; - if (attr.isComposite() || attr.hasAssociationClass()) { - cascade += "cascade=\"all,delete-orphan\""; - } - - String lazy = "lazy=\""; - if (attr.getTagValue("lazy") != null){ - lazy += attr.getTagValue("lazy"); - } - else { - lazy += "true"; - } - lazy += "\""; - - String fetch = ""; - if (attr.getTagValue("fetch") != null){ - fetch = "fetch=\"" + attr.getTagValue("fetch") + "\""; - } - - String collType = GeneratorUtil.getNMultiplicityHibernateType(attr); - if (!needsIndex) { -/*{ <<%=collType%> name="<%=getName(attr)%>" <%=orderBy%> <%=((!isInverse)?"":"inverse=\"true\"")%> <%=fetch%> <%=lazy%> <%=cascade%> node="<%=getName(attr)%>" embed-xml="true"> - <key column="<%=GeneratorUtil.getReverseDBName(attr)%>"/> - <one-to-many class="<%=getType(attr)%>" node="topiaId" embed-xml="false"/> - </<%=collType%>> -}*/ - }else { -/*{ <<%=collType%> name="<%=getName(attr)%>"<%=((!isInverse)?"":" inverse=\"true\"")%> <%=lazy%> <%=cascade%> node="<%=getName(attr)%>" embed-xml="false"> - <key column="<%=GeneratorUtil.getReverseDBName(attr)%>"/> - <list-index column="<%=GeneratorUtil.getReverseDBName(attr)%>_idx"/> - <one-to-many class="<%=getType(attr)%>" node="topiaId" embed-xml="false"/> - </<%=collType%>> -}*/ - } - } - - protected void generateHibernateMany(Writer output, ObjectModelAttribute attr) throws IOException { - boolean needsIndex = attr.isIndexed(); - String collType = GeneratorUtil.getNMultiplicityHibernateType(attr); - String lazy = ""; - if (attr.getTagValue("lazy") != null) { - lazy = "lazy=\"" + attr.getTagValue("lazy") + "\""; - } - -/*{ <<%=collType%> name="<%=getName(attr)%>" node="<%=getName(attr)%>" embed-xml="true" <%=lazy%>> - <key column="OWNER"/> -}*/ - if (needsIndex) { -/*{ <list-index/> -}*/ - } -/*{ <element type="<%=getType(attr)%>" column="<%=GeneratorUtil.getDBName(attr)%>" node="id"/> - </<%=collType%>> -}*/ - } - - protected void generateHibernateManyToOne(Writer output, ObjectModelAttribute attr) throws IOException { - generateHibernateManyToOne(output, attr, false); - } - - protected void generateHibernateManyToOne(Writer output, ObjectModelAttribute attr, boolean isUnique) throws IOException { -/*{ <many-to-one name="<%=getName(attr)%>" class="<%=getType(attr)%>" column="<%=GeneratorUtil.getDBName(attr)%>"}*/ - if (attr.isComposite() || attr.hasAssociationClass()) { -/*{ cascade="delete"}*/ - } - // Pour le test suivant, on verifie d'abord que l'attribut a un reverse. - // S'il n'en a pas, cela signifie qu'il ne s'agit pas d'un entite - // (au sens stereotype entity), donc a donc pas besoin de faire un access=field. - if (attr.getReverseAttribute() != null && hasUnidirectionalRelationOnAbstractType(attr.getReverseAttribute(), model)) { -/*{ access="field"}*/ - } - if (isUnique) { -/*{ unique="true"}*/ - } -/*{ node="<%=getName(attr)%>/@topiaId" embed-xml="false"}*/ - - // vérifier si le tag lazy est defini par defaut dans le fichier de proprietes - if (attr.getTagValue("lazy") != null){ -/*{ lazy="<%=attr.getTagValue("lazy")%>"}*/ - } -/*{/> -}*/ - } - - protected void generateHibernateManyToMany(Writer output, ObjectModelAttribute attr) throws IOException { - // On ne met le inverse="true" uniquement pour un seul coté de la relation. - // Dans le cas contraire, les modifications dans la relation ne seront - // pas sauvegardées. Ceci n'est vrai que si les deux coté sont navigable - 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); - - boolean needsIndex = attr.isIndexed(); - String cascade = ""; - if (attr.isComposite() || attr.hasAssociationClass()) { - cascade += "cascade=\"delete,delete-orphan\""; - } - cascade += ""; - - String lazy = "lazy=\""; - if (attr.getTagValue("lazy") != null){ - lazy += attr.getTagValue("lazy"); - } - else { - lazy += "true"; - } - lazy += "\""; - String collType = GeneratorUtil.getNMultiplicityHibernateType(attr); - -/*{ <<%=collType%> name="<%=getName(attr)%>" table="<%=GeneratorUtil.getManyToManyTableName(attr)%>" <%=(isInverse?"inverse=\"true\" ":"")%> <%=lazy%> <%=cascade%> node="<%=getName(attr)%>" embed-xml="true"> - <key column="<%=GeneratorUtil.getReverseDBName(attr)%>"/> -}*/ - if (needsIndex) { -/*{ <list-index column="<%=GeneratorUtil.getReverseDBName(attr)%>_idx"/> -}*/ - } -/*{ <many-to-many class="<%=getType(attr)%>" column="<%=GeneratorUtil.getDBName(attr)%>" node="topiaId"/> - </<%=collType%>> -}*/ - } - -} //EntityHibernateMappingGenerator Copied: topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java (from rev 1285, topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java) =================================================================== --- topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java (rev 0) +++ topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/EntityHibernateMappingGenerator.java 2009-01-07 08:35:25 UTC (rev 1287) @@ -0,0 +1,486 @@ +/* *##% 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>. ##%*/ + +/* * +* EntityHibernateMappingGenerator.java +* +* Created: 12 déc. 2005 +* +* @author Arnaud Thimel <thimel@codelutin.com> +* @version $Revision$ +* +* Mise a jour: $Date$ +* par : $Author$ +* Mise a jour: $Date$ +* par : $Author$ +*/ + +package org.codelutin.topia.generator; + +import org.apache.commons.logging.Log; +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.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 java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * FIXME mettre les attributs node="..." sur tous les attributs + * @author poussin + * + */ +public class EntityHibernateMappingGenerator extends ObjectModelGenerator { + + /** + * Logger for this class + */ + private static final Log log = LogFactory + .getLog(EntityHibernateMappingGenerator.class); + + private Map<String, String[]> columnNamesMap = new HashMap<String, String[]>(); + + public EntityHibernateMappingGenerator() { + super(); + } + + public EntityHibernateMappingGenerator(Generator parent) { + super(parent); + } + + @Override + public String getFilenameForClass(ObjectModelClass clazz) { + String DOName = GeneratorUtil.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); + if (!clazz.hasStereotype(STEREOTYPE_ENTITY) && PERSISTENCE_TYPE_HIBERNATE.equals(persistenceType)) { + return; + } +/*{<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> +<hibernate-mapping default-access="field" auto-import="true" package="<%=clazz.getPackageName()%>"> +}*/ + boolean haveSuper = clazz.getSuperclasses().size() > 0; + List<ObjectModelAttribute> noneNaturalAttributes = new ArrayList<ObjectModelAttribute >(); + 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%>" }*/ + } +/*{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()%>" }*/ +/*{> + <!--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()%>" }*/ +/*{> + <id name="topiaId" type="string" length="255" node="@topiaId"/> +}*/ + List<String> attributes = GeneratorUtil.getNaturalId(clazz); + if (log.isDebugEnabled()) { + log.debug("natural-id for class "+clazz.getName()+" : "+attributes); + } + + if (attributes.isEmpty()) { + // pas de clef metiers sur la classe + noneNaturalAttributes.addAll(clazz.getAttributes()); + } else { + // une clef métier sur la classe a ete detectee + List<ObjectModelAttribute> naturalAttributes = new ArrayList<ObjectModelAttribute >(attributes.size()); + for (ObjectModelAttribute attr : clazz.getAttributes()) { + if (attributes.contains(attr.getName())) { + naturalAttributes.add(attr); + } else { + noneNaturalAttributes.add(attr); + } + } +/*{ <natural-id> +}*/ + generateAttributes(output, clazz, naturalAttributes," "); +/*{ </natural-id> +}*/ + } + +/*{ <version name="topiaVersion" type="long" node="@topiaVersion"/> + <property name="topiaCreateDate" type="date" node="@topiaCreateDate"/> +}*/ + } + generateAttributes(output, clazz, noneNaturalAttributes,""); + + if (haveSuper) { +/*{ </union-subclass> +}*/ + } else { +/*{ </class> +}*/ + } +/*{</hibernate-mapping> +}*/ + } + + protected void generateAttributes(Writer output, ObjectModelClass clazz, List<ObjectModelAttribute> attributes,String prefix) throws IOException { + for (ObjectModelAttribute attr : attributes) { + ObjectModelAttribute reverse = attr.getReverseAttribute(); + + // pour les asso quoi qu'il arrive il faut les lier des 2 cotes + // pour pouvoir supprimer en cascade l'asso lors de la suppression + // d'un des cotes + if (attr.isNavigable() + || hasUnidirectionalRelationOnAbstractType(reverse, model) + || attr.hasAssociationClass()) { + if (!Util.isNMultiplicity(attr)) { + if (attr.getClassifier() != null && attr.getClassifier().hasStereotype(STEREOTYPE_ENTITY)) { + if (Util.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) { + generateHibernateManyToOne(output, attr, prefix); + } else { + generateHibernateOneToOne(output, attr, prefix); + } + } else { + generateHibernateProperty(output, attr, prefix); + } + } else { + if (attr.getClassifier() != null && attr.getClassifier().hasStereotype(STEREOTYPE_ENTITY)) { + if (Util.isNMultiplicity(attr.getReverseMaxMultiplicity()) && !attr.hasAssociationClass()) { + generateHibernateManyToMany(output, attr, prefix); + } else { + generateHibernateOneToMany(output, attr, prefix); + } + } else { + generateHibernateMany(output, attr, prefix); + } + } + } + } + + //Attributs pour les classes d'association + if (clazz instanceof ObjectModelAssociationClass) { + ObjectModelAssociationClass assoc = (ObjectModelAssociationClass)clazz; + for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) { + if (attr != null) { + +// 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\"":"")%>/> +// } */ +// } else { + String notNull = attr.getTagValue(GeneratorUtil.TAG_NOT_NULL); + if (notNull!=null) { + notNull = "not-null=\""+notNull.trim()+"\""; + } +/*{<%=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%> /> +}*/ +// } + //Ne sert plus grâce à l'utilisation de la navigabilité +// if (!attr.getReverseAttribute().isNavigable()) { +// String type = GeneratorUtil.getDOType(((ObjectModelClassifier)attr.getDeclaringElement()).getQualifiedName(), model); +// String name = Util.toLowerCaseFirstLetter(attr.getDeclaringElement().getName()); +// if (log.isTraceEnabled()) {log.trace("reverse: " + type + " " + name);} +// if (!Util.isNMultiplicity(attr)) { +//{<!-- <one-to-one name="<%=name%>" class="<%=type%>"/> +//} +// } else { +//{ <many-to-one name="<%=name%>" class="<%=type%>" column="<%=name.toLowerCase()%>"/> --> +//} +// } +// } + } + } + } + + } + protected String getName(ObjectModelAttribute attr) { + return getName(attr, false); + } + + protected String getName(ObjectModelAttribute attr, boolean isAssoc) { + String result = Util.toLowerCaseFirstLetter(attr.getName()); + if (attr.hasAssociationClass() && !isAssoc) { + result = GeneratorUtil.getAssocAttrName(attr); + } + return result; + } + + protected String getType(ObjectModelAttribute attr) { + return getType(attr, false); + } + + protected String getType(ObjectModelAttribute attr, boolean isAssoc) { + String type = attr.getType(); + if (GeneratorUtil.notEmpty(model.getTagValue(type))) { + String typeString = model.getTagValue(type); + int bracketIndex = typeString.indexOf('('); + if (bracketIndex != -1) { + type = typeString.substring(0, bracketIndex); + int bracketEndIndex = typeString.indexOf(')', bracketIndex + 1); + String colmunList; + if (bracketEndIndex != -1) { + colmunList = typeString.substring(bracketIndex + 1, bracketEndIndex); + } else { + colmunList = typeString.substring(bracketIndex); + } + columnNamesMap.put(type, colmunList.split(",")); + } else { + type = typeString; + } + } + if (attr.hasAssociationClass() && !isAssoc) { + type = attr.getAssociationClass().getQualifiedName(); + } + return GeneratorUtil.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); + if (schema != null) { +/*{schema="<%=schema%>" }*/ + } + if (attr.isIndexed()) { +/*{index="<%=GeneratorUtil.getDBName(attr.getDeclaringElement()) + "_" + getName(attr)%>_idx" }*/ + } +/*{> +<%=prefix%> <key column="<%=GeneratorUtil.getDBName(attr.getDeclaringElement())%>"/> +<%=prefix%> <list-index column="<%=getName(attr)%>_idx"/> +<%=prefix%> <element type="<%=type%>"/> +<%=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" }*/ + } + if (attr.isIndexed()) { +/*{index="<%=GeneratorUtil.getDBName(attr.getDeclaringElement()) + "_" + getName(attr)%>_idx" }*/ + } + String notNull = attr.getTagValue(GeneratorUtil.TAG_NOT_NULL); + if (notNull != null) { +/*{ not-null="<%=notNull.trim()%>" }*/ + } + String[] columnNames = this.columnNamesMap.get(type); + 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)%>"/> +}*/ + } else { +/*{> +}*/ + for (String columnName : columnNames) { + columnName = columnName.trim(); +/*{<%=prefix%> <column name="<%=getName(attr) + "_" + columnName%>"/> +}*/ + } +/*{<%=prefix%> </property> +}*/ + } + } + } + + 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"/> +//} */ + } + + protected void generateHibernateOneToMany(Writer output, ObjectModelAttribute attr, String prefix) throws IOException { + 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 cascade = ""; + if (attr.isComposite() || attr.hasAssociationClass()) { + cascade += "cascade=\"all,delete-orphan\""; + } + + String lazy = "lazy=\""; + if (attr.getTagValue(GeneratorUtil.TAG_LAZY) != null){ + lazy += attr.getTagValue(GeneratorUtil.TAG_LAZY); + } + else { + lazy += "true"; + } + lazy += "\""; + + String fetch = ""; + if (attr.getTagValue(GeneratorUtil.TAG_FETCH) != null){ + fetch = "fetch=\"" + attr.getTagValue(GeneratorUtil.TAG_FETCH) + "\""; + } + + String collType = GeneratorUtil.getNMultiplicityHibernateType(attr); + if (!needsIndex) { +/*{<%=prefix%> <<%=collType%> name="<%=getName(attr)%>" <%=orderBy%> <%=((!isInverse)?"":"inverse=\"true\"")%> <%=fetch%> <%=lazy%> <%=cascade%> node="<%=getName(attr)%>" embed-xml="true"> +<%=prefix%> <key column="<%=GeneratorUtil.getReverseDBName(attr)%>"/> +<%=prefix%> <one-to-many class="<%=getType(attr)%>" 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"/> +<%=prefix%> </<%=collType%>> +}*/ + } + } + + 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) + "\""; + } + +/*{<%=prefix%> <<%=collType%> name="<%=getName(attr)%>" node="<%=getName(attr)%>" 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%> </<%=collType%>> +}*/ + } + + protected void generateHibernateManyToOne(Writer output, ObjectModelAttribute attr, String prefix) throws IOException { + generateHibernateManyToOne(output, attr, false, prefix); + } + + 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)%>"}*/ + if (attr.isComposite() || attr.hasAssociationClass()) { +/*{ cascade="delete"}*/ + } + // Pour le test suivant, on verifie d'abord que l'attribut a un reverse. + // S'il n'en a pas, cela signifie qu'il ne s'agit pas d'un entite + // (au sens stereotype entity), donc a donc pas besoin de faire un access=field. + if (attr.getReverseAttribute() != null && hasUnidirectionalRelationOnAbstractType(attr.getReverseAttribute(), model)) { +/*{ access="field"}*/ + } + if (isUnique) { +/*{ unique="true"}*/ + } +/*{ node="<%=getName(attr)%>/@topiaId" embed-xml="false"}*/ + + // vérifier si le tag lazy est defini par defaut dans le fichier de proprietes + if (attr.getTagValue("lazy") != null){ +/*{ lazy="<%=attr.getTagValue("lazy")%>"}*/ + } + String notNull = attr.getTagValue(GeneratorUtil.TAG_NOT_NULL); + if (notNull != null) { +/*{ not-null="<%=notNull.trim()%>"}*/ + } +/*{/> +}*/ + } + + protected void generateHibernateManyToMany(Writer output, ObjectModelAttribute attr, String prefix) throws IOException { + // On ne met le inverse="true" uniquement pour un seul coté de la relation. + // Dans le cas contraire, les modifications dans la relation ne seront + // pas sauvegardées. Ceci n'est vrai que si les deux coté sont navigable + 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); + + boolean needsIndex = attr.isIndexed(); + String cascade = ""; + if (attr.isComposite() || attr.hasAssociationClass()) { + cascade += "cascade=\"delete,delete-orphan\""; + } + cascade += ""; + + String lazy = "lazy=\""; + if (attr.getTagValue("lazy") != null){ + lazy += attr.getTagValue("lazy"); + } + else { + lazy += "true"; + } + lazy += "\""; + String collType = GeneratorUtil.getNMultiplicityHibernateType(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)%>"/> +}*/ + if (needsIndex) { +/*{<%=prefix%> <list-index column="<%=GeneratorUtil.getReverseDBName(attr)%>_idx"/> +}*/ + } +/*{<%=prefix%> <many-to-many class="<%=getType(attr)%>" column="<%=GeneratorUtil.getDBName(attr)%>" node="topiaId"/> +<%=prefix%> </<%=collType%>> +}*/ + } + +} //EntityHibernateMappingGenerator Deleted: topia/tags/2.1.2/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-05 08:40:44 UTC (rev 1284) +++ topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java 2009-01-07 08:35:25 UTC (rev 1287) @@ -1,601 +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@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"; - - /** 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); - } - - /** - * 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; - } -} // GeneratorUtil Copied: topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java (from rev 1285, topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java) =================================================================== --- topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java (rev 0) +++ topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/generator/GeneratorUtil.java 2009-01-07 08:35:25 UTC (rev 1287) @@ -0,0 +1,635 @@ +/* *##% 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@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 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"; + + /** 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; + } + + /** + * 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; + } +} // GeneratorUtil Deleted: topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/BeanPropertyLoador.java =================================================================== --- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/BeanPropertyLoador.java 2009-01-05 08:40:44 UTC (rev 1284) +++ topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/BeanPropertyLoador.java 2009-01-07 08:35:25 UTC (rev 1287) @@ -1,154 +0,0 @@ -package org.codelutin.topia.persistence.util; - -import org.apache.commons.beanutils.MethodUtils; - -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.List; - -/** @author chemit */ -public class BeanPropertyLoador<E> implements Loador<E> { - - public static <E> BeanPropertyLoador<E> newLoador(Class<E> klass, String... properties) { - return new BeanPropertyLoador<E>(klass, properties); - } - - private static final long serialVersionUID = 1L; - - protected static final Integer ZERO = 0; - protected static final Float ZEROF = 0f; - protected static final Long ZEROL = 0l; - protected static final Double ZEROD = 0.; - protected static final Byte ZEROB = 0; - - protected List<String> properties; - protected transient PropertyDescriptor[] descriptors; - protected Class<E> klass; - - protected BeanPropertyLoador(Class<E> klass, String... properties) { - this.properties = java.util.Collections.unmodifiableList(Arrays.asList(properties)); - this.klass = klass; - } - - public List<String> getProperties() { - return properties; - } - - public PropertyDescriptor[] getDescriptors() { - if (descriptors == null) { - try { - descriptors = new PropertyDescriptor[properties.size()]; - for (PropertyDescriptor propertydescriptor : Introspector.getBeanInfo(klass).getPropertyDescriptors()) { - int index = properties.indexOf(propertydescriptor.getName()); - if (index != -1) { - descriptors[index] = propertydescriptor; - } - } - } catch (IntrospectionException e) { - throw new RuntimeException(e); - } - } - return descriptors; - } - - @Override - public void load(E from, E dst, boolean tech) { - if (from == null) { - // reset all fields - for (PropertyDescriptor descriptor : getDescriptors()) { - Object read = getNullValue(descriptor.getPropertyType()); - setProperty(dst, descriptor, read); - } - } else { - // set all fields from - for (PropertyDescriptor descriptor : getDescriptors()) { - try { - Object value = descriptor.getReadMethod().invoke(from); - setProperty(dst, descriptor, value); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } catch (InvocationTargetException e) { - throw new RuntimeException(e); - } - } - } - } - - protected void setProperty(E dst, PropertyDescriptor descriptor, Object value) { - try { - descriptor.getWriteMethod().invoke(dst, value); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - protected static Object getNullValue(Class<?> type) { - if (type.isPrimitive()) { - type = MethodUtils.getPrimitiveWrapper(type); - if (Boolean.class.isAssignableFrom(type)) { - return Boolean.FALSE; - } - if (Integer.class.isAssignableFrom(type)) { - return ZERO; - } - if (Float.class.isAssignableFrom(type)) { - return ZEROF; - } - if (Long.class.isAssignableFrom(type)) { - return ZEROL; - } - if (Double.class.isAssignableFrom(type)) { - return ZEROD; - } - if (Byte.class.isAssignableFrom(type)) { - return ZEROB; - } - } - return null; - } - - public static boolean isNullValue(Object value) { - if (value == null) { - return true; - } - Class<?> type = value.getClass(); - if (type.isPrimitive()) { - type = MethodUtils.getPrimitiveWrapper(type); - } - if (Boolean.class.isAssignableFrom(type)) { - return Boolean.FALSE.equals(value); - } - if (Integer.class.isAssignableFrom(type)) { - return ZERO.equals(value); - } - if (Float.class.isAssignableFrom(type)) { - return ZEROF.equals(value); - } - if (Long.class.isAssignableFrom(type)) { - return ZEROL.equals(value); - } - if (Double.class.isAssignableFrom(type)) { - return ZEROD.equals(value); - } - return Byte.class.isAssignableFrom(type) && ZEROB.equals(value); - } - - protected void checkProperties() { - PropertyDescriptor[] descriptors = getDescriptors(); - for (int i = 0; i < descriptors.length; i++) { - PropertyDescriptor descriptor = descriptors[i]; - if (descriptor == null) { - throw new IllegalStateException("could not find descriptor for property " + properties.get(i) + " on " + klass); - } - if (descriptor.getReadMethod() == null) { - throw new IllegalStateException("property " + properties.get(i) + " is not readable on " + klass); - } - if (descriptor.getWriteMethod() == null) { - throw new IllegalStateException("property " + properties.get(i) + " is not writable on " + klass); - } - } - } -} Copied: topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/BeanPropertyLoador.java (from rev 1285, topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/BeanPropertyLoador.java) =================================================================== --- topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/BeanPropertyLoador.java (rev 0) +++ topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/BeanPropertyLoador.java 2009-01-07 08:35:25 UTC (rev 1287) @@ -0,0 +1,178 @@ +package org.codelutin.topia.persistence.util; + +import org.apache.commons.beanutils.MethodUtils; + +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.lang.reflect.InvocationTargetException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** @author chemit */ +public class BeanPropertyLoador<E> implements Loador<E> { + + public static <E> BeanPropertyLoador<E> newLoador(Class<E> klass, String... properties) { + return new BeanPropertyLoador<E>(klass, properties); + } + + private static final long serialVersionUID = 1L; + + protected static final Integer ZERO = 0; + protected static final Float ZEROF = 0f; + protected static final Long ZEROL = 0l; + protected static final Double ZEROD = 0.; + protected static final Byte ZEROB = 0; + + protected List<String> properties; + protected transient PropertyDescriptor[] descriptors; + protected Class<E> klass; + + protected BeanPropertyLoador(Class<E> klass, String... properties) { + this.properties = java.util.Collections.unmodifiableList(Arrays.asList(properties)); + this.klass = klass; + } + + public List<String> getProperties() { + return properties; + } + + public PropertyDescriptor[] getDescriptors() { + if (descriptors == null) { + try { + descriptors = new PropertyDescriptor[properties.size()]; + for (PropertyDescriptor propertydescriptor : Introspector.getBeanInfo(klass).getPropertyDescriptors()) { + int index = properties.indexOf(propertydescriptor.getName()); + if (index != -1) { + descriptors[index] = propertydescriptor; + } + } + } catch (IntrospectionException e) { + throw new RuntimeException(e); + } + } + return descriptors; + } + + public Map<String, Object> obtainProgperties(E from) { + if (from == null) { + return java.util.Collections.emptyMap(); + } + Map<String, Object> result = new HashMap<String, Object>(); + for (PropertyDescriptor descriptor : getDescriptors()) { + Object read = null; + try { + read = descriptor.getReadMethod().invoke(from); + if (read != null) { + result.put(descriptor.getName(), read); + } + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + + } + return result; + } + + @Override + public void load(E from, E dst, boolean tech) { + if (from == null) { + // reset all fields + for (PropertyDescriptor descriptor : getDescriptors()) { + Object read = getNullValue(descriptor.getPropertyType()); + setProperty(dst, descriptor, read); + } + } else { + // set all fields from + for (PropertyDescriptor descriptor : getDescriptors()) { + try { + Object value = descriptor.getReadMethod().invoke(from); + setProperty(dst, descriptor, value); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } catch (InvocationTargetException e) { + throw new RuntimeException(e); + } + } + } + } + + protected void setProperty(E dst, PropertyDescriptor descriptor, Object value) { + try { + descriptor.getWriteMethod().invoke(dst, value); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + protected static Object getNullValue(Class<?> type) { + if (type.isPrimitive()) { + type = MethodUtils.getPrimitiveWrapper(type); + if (Boolean.class.isAssignableFrom(type)) { + return Boolean.FALSE; + } + if (Integer.class.isAssignableFrom(type)) { + return ZERO; + } + if (Float.class.isAssignableFrom(type)) { + return ZEROF; + } + if (Long.class.isAssignableFrom(type)) { + return ZEROL; + } + if (Double.class.isAssignableFrom(type)) { + return ZEROD; + } + if (Byte.class.isAssignableFrom(type)) { + return ZEROB; + } + } + return null; + } + + public static boolean isNullValue(Object value) { + if (value == null) { + return true; + } + Class<?> type = value.getClass(); + if (type.isPrimitive()) { + type = MethodUtils.getPrimitiveWrapper(type); + } + if (Boolean.class.isAssignableFrom(type)) { + return Boolean.FALSE.equals(value); + } + if (Integer.class.isAssignableFrom(type)) { + return ZERO.equals(value); + } + if (Float.class.isAssignableFrom(type)) { + return ZEROF.equals(value); + } + if (Long.class.isAssignableFrom(type)) { + return ZEROL.equals(value); + } + if (Double.class.isAssignableFrom(type)) { + return ZEROD.equals(value); + } + return Byte.class.isAssignableFrom(type) && ZEROB.equals(value); + } + + protected void checkProperties() { + PropertyDescriptor[] descriptors = getDescriptors(); + for (int i = 0; i < descriptors.length; i++) { + PropertyDescriptor descriptor = descriptors[i]; + if (descriptor == null) { + throw new IllegalStateException("could not find descriptor for property " + properties.get(i) + " on " + klass); + } + if (descriptor.getReadMethod() == null) { + throw new IllegalStateException("property " + properties.get(i) + " is not readable on " + klass); + } + if (descriptor.getWriteMethod() == null) { + throw new IllegalStateException("property " + properties.get(i) + " is not writable on " + klass); + } + } + } +} Deleted: topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/Loador.java =================================================================== --- topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/Loador.java 2009-01-05 08:40:44 UTC (rev 1284) +++ topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/Loador.java 2009-01-07 08:35:25 UTC (rev 1287) @@ -1,7 +0,0 @@ -package org.codelutin.topia.persistence.util; - -/** @author chemit */ -public interface Loador<E> extends java.io.Serializable { - - void load(E from, E dst, boolean tech); -} Copied: topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/Loador.java (from rev 1285, topia/trunk/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/Loador.java) =================================================================== --- topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/Loador.java (rev 0) +++ topia/tags/2.1.2/topia-persistence/src/main/java/org/codelutin/topia/persistence/util/Loador.java 2009-01-07 08:35:25 UTC (rev 1287) @@ -0,0 +1,11 @@ +package org.codelutin.topia.persistence.util; + +import java.util.Map; + +/** @author chemit */ +public interface Loador<E> extends java.io.Serializable { + + Map<String, Object> obtainProgperties(E from); + + void load(E from, E dst, boolean tech); +} Deleted: topia/tags/2.1.2/topia-soa/pom.xml =================================================================== --- topia/trunk/topia-soa/pom.xml 2009-01-05 08:40:44 UTC (rev 1284) +++ topia/tags/2.1.2/topia-soa/pom.xml 2009-01-07 08:35:25 UTC (rev 1287) @@ -1,123 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <!-- ************************************************************* --> - <!-- *** POM Relationships *************************************** --> - <!-- ************************************************************* --> - - <parent> - <groupId>org.codelutin</groupId> - <artifactId>topia</artifactId> - <version>2.1.2-SNAPSHOT</version> - </parent> - - <groupId>org.codelutin.topia</groupId> - <artifactId>topia-soa</artifactId> - - <dependencies> - - <dependency> - <groupId>org.codelutin.topia</groupId> - <artifactId>topia-persistence</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutinutil</artifactId> - </dependency> - - <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutingenerator</artifactId> - </dependency> - - <!-- Dependencies for services --> - <dependency> - <groupId>org.apache.xmlrpc</groupId> - <artifactId>xmlrpc-server</artifactId> - <version>3.1</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.apache.xmlrpc</groupId> - <artifactId>xmlrpc-client</artifactId> - <version>3.1</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>commons-httpclient</groupId> - <artifactId>commons-httpclient</artifactId> - <version>3.1</version> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>org.codehaus.xfire</groupId> - <artifactId>xfire-java5</artifactId> - <version>1.2.6</version> - <exclusions> - <!-- Fix org.apache.ant conflict) --> - <exclusion> - <groupId>ant</groupId> - <artifactId>ant</artifactId> - </exclusion> - </exclusions> - </dependency> - - <!-- branch 5.1 : ne fonctionne pas en 6+ --> - <dependency> - <groupId>jetty</groupId> - <artifactId>jetty</artifactId> - <version>5.1.10</version> - <scope>test</scope> - </dependency> - - <!-- Dependencies for class generation --> - <dependency> - <groupId>asm</groupId> - <artifactId>asm</artifactId> - <version>1.5.3</version> - <scope>compile</scope> - </dependency> - </dependencies> - - <!-- ************************************************************* --> - <!-- *** Project Information ************************************* --> - <!-- ************************************************************* --> - - <name>ToPIA - SOA</name> - <description>Service Oriented Architecture module</description> - - <!-- ************************************************************* --> - <!-- *** Build Settings ****************************************** --> - <!-- ************************************************************* --> - - <packaging>jar</packaging> - - <build> - <defaultGoal>install</defaultGoal> - <plugins> - - <plugin> - <groupId>org.codelutin</groupId> - <artifactId>maven-processor-plugin</artifactId> - </plugin> - - </plugins> - </build> - - <!-- ************************************************************* --> - <!-- *** Build Environment ************************************** --> - <!-- ************************************************************* --> - <scm> - <connection>${maven.scm.connection.child}</connection> - <developerConnection>${maven.scm.developerConnection.child}</developerConnection> - <url>${maven.scm.url.child}</url> - </scm> - -</project> Copied: topia/tags/2.1.2/topia-soa/pom.xml (from rev 1286, topia/trunk/topia-soa/pom.xml) =================================================================== --- topia/tags/2.1.2/topia-soa/pom.xml (rev 0) +++ topia/tags/2.1.2/topia-soa/pom.xml 2009-01-07 08:35:25 UTC (rev 1287) @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.codelutin</groupId> + <artifactId>topia</artifactId> + <version>2.1.2</version> + </parent> + + <groupId>org.codelutin.topia</groupId> + <artifactId>topia-soa</artifactId> + + <dependencies> + + <dependency> + <groupId>org.codelutin.topia</groupId> + <artifactId>topia-persistence</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.codelutin</groupId> + <artifactId>lutinutil</artifactId> + </dependency> + + <dependency> + <groupId>org.codelutin</groupId> + <artifactId>lutingenerator</artifactId> + </dependency> + + <!-- Dependencies for services --> + <dependency> + <groupId>org.apache.xmlrpc</groupId> + <artifactId>xmlrpc-server</artifactId> + <version>3.1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.apache.xmlrpc</groupId> + <artifactId>xmlrpc-client</artifactId> + <version>3.1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <version>3.1</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.codehaus.xfire</groupId> + <artifactId>xfire-java5</artifactId> + <version>1.2.6</version> + <exclusions> + <!-- Fix org.apache.ant conflict) --> + <exclusion> + <groupId>ant</groupId> + <artifactId>ant</artifactId> + </exclusion> + </exclusions> + </dependency> + + <!-- branch 5.1 : ne fonctionne pas en 6+ --> + <dependency> + <groupId>jetty</groupId> + <artifactId>jetty</artifactId> + <version>5.1.10</version> + <scope>test</scope> + </dependency> + + <!-- Dependencies for class generation --> + <dependency> + <groupId>asm</groupId> + <artifactId>asm</artifactId> + <version>1.5.3</version> + <scope>compile</scope> + </dependency> + </dependencies> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <name>ToPIA - SOA</name> + <description>Service Oriented Architecture module</description> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>jar</packaging> + + <build> + <defaultGoal>install</defaultGoal> + <plugins> + + <plugin> + <groupId>org.codelutin</groupId> + <artifactId>maven-processor-plugin</artifactId> + </plugin> + + </plugins> + </build> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + <scm> + <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/topia/topia/tags/2.1.2/topia-soa</connection> + <developerConnection>scm:svn:svn+ssh://tchemit@labs.libre-entreprise.org/svnroot/topia/topia/tags/2.1.2/topia-soa</developerConnection> + <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/topia/tags/2.1.2/topia-soa?root=topia</url> + </scm> + +</project> Deleted: topia/tags/2.1.2/topia-ui/pom.xml =================================================================== --- topia/trunk/topia-ui/pom.xml 2009-01-05 08:40:44 UTC (rev 1284) +++ topia/tags/2.1.2/topia-ui/pom.xml 2009-01-07 08:35:25 UTC (rev 1287) @@ -1,74 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <!-- ************************************************************* --> - <!-- *** POM Relationships *************************************** --> - <!-- ************************************************************* --> - - <parent> - <groupId>org.codelutin</groupId> - <artifactId>topia</artifactId> - <version>2.1.2-SNAPSHOT</version> - </parent> - - <groupId>org.codelutin.topia</groupId> - <artifactId>topia-ui</artifactId> - - <dependencies> - - <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutinutil</artifactId> - </dependency> - - <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutingenerator</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.tapestry</groupId> - <artifactId>tapestry-core</artifactId> - <version>5.0.7</version> - <scope>compile</scope> - </dependency> - - </dependencies> - - <!-- ************************************************************* --> - <!-- *** Project Information ************************************* --> - <!-- ************************************************************* --> - - <name>ToPIA - UI</name> - <description>User interface module</description> - - <!-- ************************************************************* --> - <!-- *** Build Settings ****************************************** --> - <!-- ************************************************************* --> - - <packaging>jar</packaging> - - <build> - <defaultGoal>install</defaultGoal> - <plugins> - - <plugin> - <groupId>org.codelutin</groupId> - <artifactId>maven-processor-plugin</artifactId> - </plugin> - - </plugins> - </build> - - <!-- ************************************************************* --> - <!-- *** Build Environment ************************************** --> - <!-- ************************************************************* --> - <scm> - <connection>${maven.scm.connection.child}</connection> - <developerConnection>${maven.scm.developerConnection.child}</developerConnection> - <url>${maven.scm.url.child}</url> - </scm> - -</project> Copied: topia/tags/2.1.2/topia-ui/pom.xml (from rev 1286, topia/trunk/topia-ui/pom.xml) =================================================================== --- topia/tags/2.1.2/topia-ui/pom.xml (rev 0) +++ topia/tags/2.1.2/topia-ui/pom.xml 2009-01-07 08:35:25 UTC (rev 1287) @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.codelutin</groupId> + <artifactId>topia</artifactId> + <version>2.1.2</version> + </parent> + + <groupId>org.codelutin.topia</groupId> + <artifactId>topia-ui</artifactId> + + <dependencies> + + <dependency> + <groupId>org.codelutin</groupId> + <artifactId>lutinutil</artifactId> + </dependency> + + <dependency> + <groupId>org.codelutin</groupId> + <artifactId>lutingenerator</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.tapestry</groupId> + <artifactId>tapestry-core</artifactId> + <version>5.0.7</version> + <scope>compile</scope> + </dependency> + + </dependencies> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <name>ToPIA - UI</name> + <description>User interface module</description> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>jar</packaging> + + <build> + <defaultGoal>install</defaultGoal> + <plugins> + + <plugin> + <groupId>org.codelutin</groupId> + <artifactId>maven-processor-plugin</artifactId> + </plugin> + + </plugins> + </build> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + <scm> + <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/topia/topia/tags/2.1.2/topia-ui</connection> + <developerConnection>scm:svn:svn+ssh://tchemit@labs.libre-entreprise.org/svnroot/topia/topia/tags/2.1.2/topia-ui</developerConnection> + <url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/topia/tags/2.1.2/topia-ui?root=topia</url> + </scm> + +</project>
participants (1)
-
tchemit@users.labs.libre-entreprise.org