Eugene-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
December 2009
- 2 participants
- 49 discussions
r750 - in branches/eugene-2.0: . eugene/src/main/java/org/nuiton/eugene eugene/src/test/java/org/nuiton/eugene
by tchemit@users.nuiton.org 14 Dec '09
by tchemit@users.nuiton.org 14 Dec '09
14 Dec '09
Author: tchemit
Date: 2009-12-14 03:53:36 +0100 (Mon, 14 Dec 2009)
New Revision: 750
Removed:
branches/eugene-2.0/eugene-test/
Modified:
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java
branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java
Log:
- fix getSimpleName for variable array type
- remove module eugene-test
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java 2009-12-14 01:57:24 UTC (rev 749)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/GeneratorUtil.java 2009-12-14 02:53:36 UTC (rev 750)
@@ -588,11 +588,21 @@
* @return the simple name associated to the str given
*/
public static String getSimpleName(String str) {
+ // variable array type
+ boolean variableArrayType=false;
+ if (str.endsWith("...")) {
+ variableArrayType = true;
+ str = str.substring(0, str.length() - 3);
+ }
if (str.startsWith("\"") && str.endsWith("\"")) {
return str;
}
//return str.replaceAll("[a-zA-Z]\\w*\\.","");
- return str.replaceAll("\\p{Alpha}\\w*\\.","");
+ String result = str.replaceAll("\\p{Alpha}\\w*\\.", "");
+ if (variableArrayType) {
+ result += "...";
+ }
+ return result;
}
public static Set<String> getTypesList(String str) {
Modified: branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java
===================================================================
--- branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java 2009-12-14 01:57:24 UTC (rev 749)
+++ branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java 2009-12-14 02:53:36 UTC (rev 750)
@@ -132,6 +132,24 @@
result = GeneratorUtil.getSimpleName(str);
log.info(str + " -> " + result);
assertEquals(expResult, result);
+
+ str = "Object...";
+ expResult = "Object...";
+ result = GeneratorUtil.getSimpleName(str);
+ log.info(str + " -> " + result);
+ assertEquals(expResult, result);
+
+ str = "Class<A>...";
+ expResult = "Class<A>...";
+ result = GeneratorUtil.getSimpleName(str);
+ log.info(str + " -> " + result);
+ assertEquals(expResult, result);
+
+ str = "java.lang.Class<A>...";
+ expResult = "Class<A>...";
+ result = GeneratorUtil.getSimpleName(str);
+ log.info(str + " -> " + result);
+ assertEquals(expResult, result);
}
@Test
1
0
Author: tchemit
Date: 2009-12-14 02:57:24 +0100 (Mon, 14 Dec 2009)
New Revision: 749
Added:
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/LICENSE.txt
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/README.txt
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/changelog.txt
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/invoker.properties
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/pom.xml
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/Megatron.java
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestBuilder.java
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestReader.java
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TopiaGeneratorUtil.java
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/models/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/models/dtotest.objectmodel
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/models/dtotest2.objectmodel
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/resources/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/resources/log4j.properties
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/nuiton/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/nuiton/eugene/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/nuiton/eugene/test/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/nuiton/eugene/test/generator/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/nuiton/eugene/test/generator/TestBuilderTest.java
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/resources/
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/resources/log4j.properties
branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/verify.groovy
Removed:
branches/eugene-2.0/eugene-test/pom.xml
branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java
branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java
branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/Megatron.java
branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TestBuilder.java
branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TestReader.java
branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TopiaGeneratorUtil.java
branches/eugene-2.0/eugene-test/src/main/models/
branches/eugene-2.0/eugene-test/src/main/resources/log4j.properties
branches/eugene-2.0/eugene-test/src/test/java/org/nuiton/eugene/test/generator/TestBuilderTest.java
branches/eugene-2.0/eugene-test/src/test/resources/log4j.properties
Modified:
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaGenerator.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelModifier.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ExternalCacheExtension.java
branches/eugene-2.0/maven-eugene-plugin/pom.xml
branches/eugene-2.0/pom.xml
Log:
- must takes account of variable array in import manager
- fix filename of a classifier with a generic declaration
- move eugene-test to an integration test in maven-eugene-plugin
- remove weaker exception
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -102,6 +102,11 @@
return;
}
ImportsManager manager = managers.getManager(classifier);
+ imports = imports.trim();
+ // remove ... operator
+ if (imports.endsWith("...")) {
+ imports = imports.substring(0, imports.length() - 3);
+ }
for (String oneType : GeneratorUtil.getTypesList(imports)) {
manager.addImport(oneType);
if (log.isDebugEnabled()) {
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaGenerator.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaGenerator.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaGenerator.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -75,7 +75,12 @@
@Override
public String getFilenameForClassifier(ObjectModelClassifier clazz) {
- return clazz.getQualifiedName().replace('.', File.separatorChar) + ".java";
+ String s = clazz.getQualifiedName();
+ int index = s.indexOf("<");
+ if (index > -1) {
+ s = s.substring(0, index);
+ }
+ return s.replace('.', File.separatorChar) + ".java";
}
/**
@@ -114,6 +119,9 @@
implement += ", ";
}
}
+ if (log.isInfoEnabled()) {
+ log.info(className+" : super : "+extend+", interfaces : "+implement);
+ }
/*{
<%=prefix%>public<%=abstractStr%>class <%=className%>}*/
@@ -263,8 +271,8 @@
Arrays.fill(tmp, ' ');
prefix = new String(tmp);
}
- if (log.isInfoEnabled()) {
- log.info("prefix to use for classifier " + clazz.getName() + " : [" + prefix + "]");
+ if (log.isDebugEnabled()) {
+ log.debug("prefix to use for classifier " + clazz.getName() + " : [" + prefix + "]");
}
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelModifier.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelModifier.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelModifier.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -34,12 +34,22 @@
*/
public enum ObjectModelModifier {
- STATIC("static"), FINAL("final"), ABSTRACT("abstract"),
- PUBLIC("public"), PROTECTED("protected"), PRIVATE("private"), PACKAGE(""),
+ STATIC("static"),
+ FINAL("final"),
+ ABSTRACT("abstract"),
+
+ PUBLIC("public"),
+ PROTECTED("protected"),
+ PRIVATE("private"),
+ PACKAGE(""),
- AGGREGATE("aggregate"), COMPOSITE("composite"), UNIQUE("unique"),
- ORDERED("ordered"), NAVIGABLE("navigable");
+ AGGREGATE("aggregate"),
+ COMPOSITE("composite"),
+ UNIQUE("unique"),
+ ORDERED("ordered"),
+ NAVIGABLE("navigable");
+
private String stringValue;
ObjectModelModifier(String stringValue) {
@@ -60,18 +70,6 @@
@Override
public String toString() {
-// switch (this) {
-// //case STATIC: return "static";
-// //case ABSTRACT: return "abstract";
-// //case FINAL: return "final";
-// case PUBLIC: return "public";
-// case PRIVATE: return "private";
-// case PROTECTED: return "protected";
-// case PACKAGE: return "";
-// case ORDERED: return "ordered";
-// case AGGREGATE: return "aggregate";
-// case COMPOSITE: return "composite";
-// }
return stringValue;
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ExternalCacheExtension.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ExternalCacheExtension.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ExternalCacheExtension.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -52,7 +52,7 @@
@SuppressWarnings("unchecked")
public <C extends ObjectModelClassifierImpl> C getCache(ObjectModelImplRef reference, Class<C> classifierClass)
- throws ClassCastException, RuntimeException {
+ throws RuntimeException {
ObjectModelClassifierImpl classifier = cache.get(reference.getName());
C result;
if (classifier != null && !classifierClass.isAssignableFrom(classifier.getClass())) {
Deleted: branches/eugene-2.0/eugene-test/pom.xml
===================================================================
--- branches/eugene-2.0/eugene-test/pom.xml 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/pom.xml 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,175 +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.nuiton</groupId>
- <artifactId>eugene</artifactId>
- <version>2.0.0-beta-2-SNAPSHOT</version>
- </parent>
-
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>eugene-test</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>eugene</artifactId>
- <version>${project.version}</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-
- <!-- ************************************************************* -->
- <!-- *** Project Information ************************************* -->
- <!-- ************************************************************* -->
-
- <name>EUGene :: Test</name>
- <description>Test module for generators.</description>
- <inceptionYear>2007</inceptionYear>
-
- <contributors>
- <contributor>
- <name>Florian Desbois</name>
- <email>fdesbois(a)codelutin.com</email>
- <timezone>+2</timezone>
- <roles>
- <role>Developpeur</role>
- </roles>
- </contributor>
- </contributors>
-
- <!-- ************************************************************* -->
- <!-- *** Build Settings ****************************************** -->
- <!-- ************************************************************* -->
-
- <packaging>jar</packaging>
-
- <properties>
- <processor.version>1.0.2-SNAPSHOT</processor.version>
-
- </properties>
-
- <build>
-
- <plugins>
-
- <plugin>
- <groupId>org.nuiton.processor</groupId>
- <artifactId>maven-processor-plugin</artifactId>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>process</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <includes>**/*.java</includes>
- <filters>
- org.nuiton.processor.filters.GeneratorTemplatesFilter
- </filters>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.nuiton.eugene</groupId>
- <artifactId>maven-eugene-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <id>Test Regression Generator</id>
- <phase>generate-test-sources</phase>
- <configuration>
- <reader>org.nuiton.eugene.ObjectModelReader</reader>
- <includes>dtotest.objectmodel</includes>
- <templates>org.nuiton.eugene.test.generator.BeanGenerator</templates>
- <defaultPackage>org.nuiton.eugene.test</defaultPackage>
- <extraClassPathDirectory>target/classes</extraClassPathDirectory>
- <generateResources>
- <input>src/main/models</input>
- </generateResources>
- </configuration>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- <execution>
- <id>Test Java Generator</id>
- <phase>generate-test-sources</phase>
- <configuration>
- <reader>org.nuiton.eugene.test.generator.TestReader</reader>
- <templates>org.nuiton.eugene.java.JavaGenerator</templates>
- <defaultPackage>org.nuiton.eugene.test</defaultPackage>
- <extraClassPathDirectory>target/classes</extraClassPathDirectory>
- <generateResources>
- <input>src/main/models</input>
- </generateResources>
- </configuration>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- <execution>
- <id>Test Bean Transformer</id>
- <phase>generate-test-sources</phase>
- <configuration>
- <reader>org.nuiton.eugene.ObjectModelReader</reader>
- <includes>dtotest2.objectmodel</includes>
- <templates>org.nuiton.eugene.test.generator.BeanTransformer</templates>
- <defaultPackage>org.nuiton.eugene.test</defaultPackage>
- <extraClassPathDirectory>target/classes</extraClassPathDirectory>
- <generateResources>
- <input>src/main/models</input>
- </generateResources>
- </configuration>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.14</version>
- </dependency>
- </dependencies>
- </plugin>
-
- <!--plugin>
- <groupId>org.nuiton.i18n</groupId>
- <artifactId>maven-i18n-plugin</artifactId>
- <version>${i18n.version}</version>
- </plugin>
-
- <plugin>
- <artifactId>maven-site-plugin</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.nuiton.jrst</groupId>
- <artifactId>doxia-module-jrst</artifactId>
- <version>${jrst.version}</version>
- </dependency>
- </dependencies>
- </plugin-->
-
- </plugins>
- </build>
-
-</project>
-
-
Deleted: branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java
===================================================================
--- branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,620 +0,0 @@
-/* *##%
- * EUGene Test
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * 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>.
- * ##%*/
-
-/* *
-* BeanGenerator.java
-*
-* Created: 17 avril 2009
-*
-* @author tony Chemit <chemit(a)codelutin.com>
-* @version $Revision: 1334 $
-*
-* Mise a jour: $Date: 2009-01-29 16:47:42 +0100 (jeu 29 jan 2009) $
-* par : $Author: chemit $
-*/
-
-package org.nuiton.eugene.test.generator;
-
-import static org.nuiton.eugene.test.generator.TopiaGeneratorUtil.TAG_ANNOTATION;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Serializable;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Iterator;
-
-import java.util.List;
-import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
-import org.nuiton.eugene.GeneratorUtil;
-import org.nuiton.eugene.ImportsManager;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelClassifier;
-import org.nuiton.eugene.models.object.ObjectModelDependency;
-import org.nuiton.eugene.models.object.ObjectModelInterface;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-import org.nuiton.eugene.models.object.ObjectModelParameter;
-//import org.nuiton.topia.persistence.TopiaEntity;
-import static org.nuiton.eugene.test.generator.TopiaGeneratorUtil.isPrimitiveType;
-import static org.nuiton.eugene.test.generator.TopiaGeneratorUtil.isDateType;
-
-/**
- * DTO generator
- */
-public class BeanGenerator extends ObjectModelGenerator {
-
- /**
- * Logger for this class
- */
- private static final Log log = LogFactory.getLog(BeanGenerator.class);
-
- public BeanGenerator() {
- super();
- }
-
- @Override
- public String getFilenameForClass(ObjectModelClass clazz) {
- return clazz.getQualifiedName().replace('.', File.separatorChar) + ".java";
- }
-
- @Override
- public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
- if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_BEAN) &&
- !clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
- return;
- }
- //
- // première phase : calcul des variables
- //
- String copyright = TopiaGeneratorUtil.getCopyright(model);
- String clazzName = clazz.getName();
- String abstractStr = isAbstract(clazz) ? " abstract " : " ";
- boolean needGetEntityMethod = false;
- boolean generateToString = TopiaGeneratorUtil.generateToString(clazz, model);
-
- ImportsManager imports = new ImportsManager();
-
- String extendClass = "";
- Iterator<ObjectModelClass> j = clazz.getSuperclasses().iterator();
- if (j.hasNext()) {
- ObjectModelClassifier p = j.next();
- imports.addImport(p.getQualifiedName());
- extendClass += p.getName();
- }
- String implInterface = "";
- for (Iterator<ObjectModelInterface> i=clazz.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parentInterface = i.next();
- imports.addImport(parentInterface.getQualifiedName());
- implInterface += parentInterface.getName();
- if (i.hasNext()) {
- implInterface += ", ";
- }
- }
- // Add Serializable implements for DTO generation
- if (clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
- imports.addImport(Serializable.class);
- if (!implInterface.isEmpty()) {
- implInterface += ", ";
- }
- implInterface += Serializable.class.getName();
- }
- String svUID = TopiaGeneratorUtil.findTagValue("dto-serialVersionUID", clazz, model);
-
- List<ObjectModelAttribute> attributes = new ArrayList<ObjectModelAttribute>();
- List<ObjectModelAttribute> multipleAttr = new ArrayList<ObjectModelAttribute>();
-
- setAttributesForDTO(clazz, attributes,imports);
-
- boolean needListInImport=false;
-
- for (ObjectModelAttribute attr : clazz.getAttributes()) {
- if (attr.isNavigable()) {
- attributes.add(attr);
- imports.addImport(attr.getType());
- if (GeneratorUtil.isNMultiplicity(attr)) {
- multipleAttr.add(attr);
- ObjectModelClass attrEntity = null;
- if (model.hasClass(attr.getType())) {
- attrEntity = model.getClass(attr.getType());
- }
- boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY));
- needGetEntityMethod |= isEntity;
- if (attr.isOrdered()) {
- needListInImport = true;
- }
- }
- }
- }
-
- imports.addImport(java.beans.PropertyChangeListener.class.getName());
- imports.addImport(java.beans.PropertyChangeSupport.class.getName());
-
- for (ObjectModelOperation operation : clazz.getOperations()) {
- imports.addImport(operation.getReturnType());
- for (ObjectModelParameter parameter : operation.getParameters()) {
- imports.addImport(parameter.getType());
- }
- }
-
- if (needGetEntityMethod) {
- imports.addImport("org.nuiton.topia.persistence.TopiaEntity");
- }
- if (!multipleAttr.isEmpty()) {
- imports.addImport(Collection.class);
- }
- if (needListInImport) {
- imports.addImport(List.class);
- }
- if (generateToString) {
- imports.addImport(org.apache.commons.lang.builder.ToStringBuilder.class);
- }
-
- boolean sortAttribute = TopiaGeneratorUtil.sortAttribute(clazz, model);
- if (sortAttribute) {
- Comparator<ObjectModelAttribute> comp = new Comparator<ObjectModelAttribute>(){
-
- @Override
- public int compare(ObjectModelAttribute o1, ObjectModelAttribute o2) {
- return o1.getName().compareTo(o2.getName());
- }
- };
- java.util.Collections.sort(attributes,comp);
- java.util.Collections.sort(multipleAttr,comp);
- }
- //
- // seconde phase : génération
- //
-
- if (TopiaGeneratorUtil.notEmpty(copyright)) {
-/*{<%=copyright%>
-}*/
- }
-
-/*{package <%=clazz.getPackageName()%>;
-
- }*/
-
- if (log.isDebugEnabled()) {
- log.debug("imports for class <" + clazzName + ">");
- }
- //for (String anImport : imports) {
- for (String anImport : imports.getImports(clazz.getPackageName())) {
- if (log.isDebugEnabled()) {
- log.debug("import " + anImport);
- }
-/*{import <%=anImport%>;
-}*/
- }
-/*{
-public<%=abstractStr%>class <%=clazzName%>}*/
-
-/*
- * Définition de la super classe : il ne doit y avoir qu'une
- */
- if (extendClass.length() > 0) {
-/*{ extends <%=extendClass%>}*/
- }
-
- if (implInterface.length() > 0) {
-/*{ implements <%=implInterface%> {
-
-}*/
- } else {
- /*{ {
-
-}*/
- }
-
-
- // TODO Calculer un serialVersionUID si il n'y en a pas
- if (svUID != null) {
-/*{ public static final long serialVersionUID = <%=svUID%>;
-
-}*/
- }
- generateInterfaceOperations(output, clazz);
- generateAttributes(output, attributes);
-/*{ protected final PropertyChangeSupport pcs;
-
- /**
- * Default constructor of <%=clazzName%>.
- *)
- public <%=clazzName%>() {
- pcs = new PropertyChangeSupport(this);
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
-}*/
- generateGetters(output, attributes);
- generateSetters(output, attributes);
- generateGetChild(output, multipleAttr);
- generateAddChild(output, multipleAttr);
- generateRemoveChild(output, multipleAttr);
- if (generateToString) {
- generateToString(output, clazz);
- }
- if (!multipleAttr.isEmpty()) {
-/*{
-
- protected <T> T getChild(Collection<T> childs, int index) {
- if (childs != null) {
- int i = 0;
- for (T o : childs) {
- if (index == i) {
- return o;
- }
- i++;
- }
- }
- return null;
- }
-
- }*/
- if (needGetEntityMethod) {
-/*{ protected <T extends TopiaEntity> T getEntity(Collection<T> childs, String topiaId) {
- if (childs != null) {
- for (T o : childs) {
- if (topiaId.equals(o.getTopiaId())) {
- return o;
- }
- }
- }
- return null;
- }
- }*/
- }
- }
-
-/*{
- protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- pcs.firePropertyChange(propertyName, oldValue, newValue);
- }
-
-} //<%=clazz.getName()%>
-}*/
- }
-
- protected void generateAttributes(Writer output, List<ObjectModelAttribute> attributes) throws IOException {
-
- for (ObjectModelAttribute attr : attributes) {
-
- if (!(attr.isNavigable()
- || attr.hasAssociationClass())) {
- continue;
- }
-
- if (TopiaGeneratorUtil.hasDocumentation(attr)) {
-/*{ /**
- * <%=attr.getDocumentation()%>
- *)
-}*/
- }
- String annotation = attr.getTagValue(TAG_ANNOTATION);
- if (annotation != null && annotation.length() > 0) {
-/*{ <%=annotation%>
-}*/
- }
- String attrName = attr.getName();
- String attrVisibility = attr.getVisibility();
- String attrType = attr.getType();
- if (attr.hasAssociationClass()) {
- String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- attrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
- attrType = attr.getAssociationClass().getName();
- }
- int dot = attrType.lastIndexOf(".");
- if (dot>-1) {
- attrType = attrType.substring(dot + 1);
- }
- if (GeneratorUtil.isNMultiplicity(attr)) {
- attrType = getCollection(attr, attrType);
- }
-
-/*{ <%=attrVisibility%> <%=attrType%> <%=attrName%>;
-}*/
- }
- }
-
- protected void generateGetters(Writer output, List<ObjectModelAttribute> attributes) throws IOException {
- /*
- * Définition des getteurs et setteurs
- */
- for (ObjectModelAttribute attr : attributes) {
-
- if (!attr.isNavigable()) {
- continue;
- }
-
- String attrName = attr.getName();
- String attrType = attr.getType();
- if (attr.hasAssociationClass()) {
- String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- attrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
- attrType = attr.getAssociationClass().getName();
- }
- String attrNameCapitalized = GeneratorUtil.capitalize(attrName);
- int dot = attrType.lastIndexOf(".");
- if (dot>-1) {
- attrType = attrType.substring(dot + 1);
- }
- if (GeneratorUtil.isNMultiplicity(attr)) {
- attrType = getCollection(attr, attrType);
- }
-/*{ public <%=attrType%> get<%=attrNameCapitalized%>() {
- return <%=attrName%>;
- }
-
-}*/
- }
- }
-
- protected void generateSetters(Writer output, List<ObjectModelAttribute> attributes) throws IOException {
- /*
- * Définition des getteurs et setteurs
- */
- for (ObjectModelAttribute attr : attributes) {
-
- if (!attr.isNavigable()) {
- continue;
- }
-
- String attrName = attr.getName();
- String attrType = attr.getType();
-
- if (attr.hasAssociationClass()) {
- String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- attrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
- attrType = attr.getAssociationClass().getName();
- }
- String attrNameCapitalized = GeneratorUtil.capitalize(attrName);
- int dot = attrType.lastIndexOf(".");
- if (dot>-1) {
- attrType = attrType.substring(dot + 1);
- }
- if (GeneratorUtil.isNMultiplicity(attr)) {
- attrType = getCollection(attr, attrType);
- }
-/*{ public void set<%=attrNameCapitalized%>(<%=attrType%> newValue) {
- <%=attrType%> oldValue = get<%=attrNameCapitalized%>();
- this.<%=attrName%> = newValue;
- firePropertyChange("<%=attrName%>", oldValue, newValue);
- }
-
-}*/
- }
- }
-
- protected void generateGetChild(Writer output, List<ObjectModelAttribute> multipleAttr) throws IOException {
-
- for (ObjectModelAttribute attr : multipleAttr) {
-
- String attrName = attr.getName();
- String attrNameCapitalized = GeneratorUtil.capitalize(attrName);
- String attrType = attr.getType();
- int dot = attrType.lastIndexOf(".");
- if (dot>-1) {
- attrType = attrType.substring(dot + 1);
- }
- ObjectModelClass attrEntity=null;
- if (model.hasClass(attr.getType())) {
- attrEntity = model.getClass(attr.getType());
- }
- boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY));
-/*{ public <%=attrType%> get<%=attrNameCapitalized%>(int index) {
- <%=attrType%> o = getChild(<%=attrName%>, index);
- return o;
- }
-
-}*/
- if (isEntity) {
-/*{ public <%=attrType%> get<%=attrNameCapitalized%>(String topiaId) {
- <%=attrType%> o = getEntity(<%=attrName%>, topiaId);
- return o;
- }
-
-}*/
- }
- }
- }
- protected void generateAddChild(Writer output, List<ObjectModelAttribute> multipleAttr) throws IOException {
- for (ObjectModelAttribute attr : multipleAttr) {
-
- String attrName = attr.getName();
- String attrNameCapitalized = GeneratorUtil.capitalize(attrName);
- String attrType = attr.getType();
- int dot = attrType.lastIndexOf(".");
- if (dot>-1) {
- attrType = attrType.substring(dot + 1);
- }
-/*{ public <%=attrType%> add<%=attrNameCapitalized%>(<%=attrType%> <%=attrName%>) {
- get<%=attrNameCapitalized%>().add(<%=attrName%>);
- firePropertyChange("<%=attrName%>", null, <%=attrName%>);
- return <%=attrName%>;
- }
-
-}*/
- }
- }
-
- protected void generateRemoveChild(Writer output, List<ObjectModelAttribute> multipleAttr) throws IOException {
- for (ObjectModelAttribute attr : multipleAttr) {
- String attrName = attr.getName();
- String attrNameCapitalized = GeneratorUtil.capitalize(attrName);
- String attrType = attr.getType();
- int dot = attrType.lastIndexOf(".");
- if (dot>-1) {
- attrType = attrType.substring(dot + 1);
- }
-/*{ public boolean remove<%=attrNameCapitalized%>(<%=attrType%> <%=attrName%>) {
- boolean removed = get<%=attrNameCapitalized%>().remove(<%=attrName%>);
- if (removed) {
- firePropertyChange("<%=attrName%>", <%=attrName%>, null);
- }
- return removed;
- }
-
-}*/
- }
- }
-
- protected void generateInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
- for (ObjectModelOperation op : classifier.getOperations()) {
- String opName = op.getName();
-/*{ /**
-}*/
- if (TopiaGeneratorUtil.hasDocumentation(op)) {
- String opDocumentation = op.getDocumentation();
-/*{ * <%=opName%> : <%=opDocumentation%>
-}*/
- }
- Collection<ObjectModelParameter> params = op.getParameters();
- for (ObjectModelParameter param : params) {
- String paramName = param.getName();
- String paramDocumentation = param.getDocumentation();
-/*{ * @param <%=paramName%> <%=paramDocumentation%>
- }*/
- }
- String opVisibility = op.getVisibility();
- String opType = op.getReturnType();
-/*{ *)
- <%=opVisibility%> abstract <%=opType%> <%=opName%>(}*/
- String comma = "";
- for (ObjectModelParameter param : params) {
- String paramName = param.getName();
- String paramType = param.getType();
-/*{<%=comma%><%=paramType%> <%=paramName%>}*/
- comma = ", ";
- }
-/*{)}*/
- Set<String> exceptions = op.getExceptions();
- comma = " throws ";
- for (String exception : exceptions) {
-/*{<%=comma%><%=exception%>}*/
- comma = ", ";
- }
-/*{;
-
-}*/
- }
- }
- protected void generateToString(Writer output, ObjectModelClass clazz) throws IOException {
-/*{
- @Override
- public String toString() {
- String result = new ToStringBuilder(this).
-}*/
- for (ObjectModelAttribute attr : clazz.getAttributes()) {
- if (!(attr.isNavigable() || attr.hasAssociationClass())) {
- continue;
- }
- //FIXME possibilité de boucles (non directes)
- String attrName = attr.getName();
-/*{ append("<%=attrName%>", this.<%=attrName%>).
-}*/
- }
-/*{ toString();
- return result;
- }
- }*/
- }
-
- protected String getCollection(ObjectModelAttribute attr, String attrType) {
- String nMultType;
- if (attr.isOrdered()) {
- nMultType = "List<";
- } else {
- nMultType = "Collection<";
- }
- nMultType += attrType;
- nMultType += ">";
- return nMultType;
- }
-
- protected boolean isAbstract(ObjectModelClass clazz) {
- if (clazz.isAbstract()) {
- return true;
- }
- return !clazz.getOperations().isEmpty();
- }
-
- /**
- * Dependecy gestion for DTO generation.
- * All primitives attributes (and dates) of dependencies entities of the DTO are
- * copied in the DTO. This method only prepare a list of attributes to be generated.
- * @param clazz DTO ObjectModelClass
- * @param attributes list of attributes for the generation (may be not empty)
- * @param imports the ImportsManager used to generate the header imports of the DTO
- * @return the same list of attributes in parameter with attributes from entities dependencies
- * @see org.nuiton.eugene.ImportsManager
- * @see org.nuiton.eugene.models.object.ObjectModelDependency
- */
- private List<ObjectModelAttribute> setAttributesForDTO(ObjectModelClass clazz,
- List<ObjectModelAttribute> attributes, ImportsManager imports) {
-
- if (clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
- if (log.isInfoEnabled()) {
- log.info("DTO dependency gestion");
- }
- for (ObjectModelDependency dependency : clazz.getDependencies()) {
- ObjectModelClass supplier = (ObjectModelClass)dependency.getSupplier();
-
- // ENTITY dependency
- // Copy all primitives attributes from the Entity (supplier) to the DTO
- // Prepare a list to future generation of all object generated attributes
- if (supplier.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
- if (log.isInfoEnabled()) {
- log.info("Create primitive and date fields in DTO from Entity : "
- + supplier.getQualifiedName());
- }
- for (ObjectModelAttribute attr : supplier.getAttributes()) {
- if (isPrimitiveType(attr) || isDateType(attr)) {
- attributes.add(attr);
- imports.addImport(attr.getType());
- }
- if (GeneratorUtil.isNMultiplicity(attr)) {
- imports.addImport("java.util.Collection");
- }
- }
- }
- }
- }
- return attributes;
- }
-} //BeanGenerator
Deleted: branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java
===================================================================
--- branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,342 +0,0 @@
-/*
- * *##%
- * EUGene Test
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-package org.nuiton.eugene.test.generator;
-
-import org.apache.commons.lang.StringUtils;
-import org.nuiton.eugene.GeneratorUtil;
-import org.nuiton.eugene.java.ObjectModelTransformerToJava;
-import org.nuiton.eugene.models.object.*;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-/*{generator option: parentheses = false}*/
-
-/*{generator option: writeString = +}*/
-/**
- * BeanTransformer
- * <p/>
- * Created: 28 oct. 2009
- *
- * @author fdesbois
- * @version $Revision$
- * <p/>
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class BeanTransformer extends ObjectModelTransformerToJava {
-
- public BeanTransformer() {
- super();
- }
-
- @Override
- public void transformFromClass(ObjectModelClass clazz) {
- if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_BEAN) &&
- !clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
- return;
- }
-
- ObjectModelClass resultClass = null;
- if (!clazz.getOperations().isEmpty()) {
- resultClass = createAbstractClass(clazz.getName(), clazz.getPackageName());
- } else {
- resultClass = createClass(clazz.getName(), clazz.getPackageName());
- }
-
- createForDTO(resultClass, clazz);
-
- // Set superclass
- Iterator<ObjectModelClass> j = clazz.getSuperclasses().iterator();
- if (j.hasNext()) {
- ObjectModelClass p = j.next();
- setSuperClass(resultClass, p.getQualifiedName());
- }
-
- // Add interfaces from inputModel
- for (Iterator<ObjectModelInterface> i = clazz.getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifier parentInterface = i.next();
- addInterface(resultClass, parentInterface.getQualifiedName());
- }
-
- createListeners(resultClass, clazz);
-
- boolean hasEntity = false;
- boolean hasMultipleAttribute = false;
-
- // Add attributes with getter/setter
- for (ObjectModelAttribute attr : clazz.getAttributes()) {
-
- if (attr.isNavigable()/* || attr.hasAssociationClass()*/) {
- String attrType = attr.getType();
- String simpleType = GeneratorUtil.getSimpleName(attrType);
- String attrName = attr.getName();
- String attrNameCapitalized = StringUtils.capitalize(attrName);
-
- // multiple attribute
- if (GeneratorUtil.isNMultiplicity(attr)) {
- hasMultipleAttribute = true;
-
- // Add getChild
- ObjectModelOperation getChild = addOperation(resultClass, "get" + attrNameCapitalized,
- attrType, ObjectModelModifier.PUBLIC);
- addParameter(getChild, "int", "index");
- setOperationBody(getChild, ""
- /*{
- <%=simpleType%> o = getChild(<%=attrName%>, index);
- return o;
- }*/
- );
-
- // Add getEntity
- ObjectModelClass attrEntity = null;
- if (getModel().hasClass(attr.getType())) {
- attrEntity = getModel().getClass(attr.getType());
- }
- boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY));
-
- if (isEntity) {
- hasEntity = true;
- ObjectModelOperation getChildEntity = addOperation(resultClass, "get" + attrNameCapitalized,
- attrType, ObjectModelModifier.PUBLIC);
- addParameter(getChildEntity, String.class.getName(), "topiaId");
- setOperationBody(getChildEntity, ""
- /*{
- <%=simpleType%> o = getEntity(<%=attrName%>, topiaId);
- return o;
- }*/
- );
- }
-
- // Add addChild
- ObjectModelOperation addChild = addOperation(resultClass, "add" + attrNameCapitalized,
- attrType, ObjectModelModifier.PUBLIC);
- addParameter(addChild, attrType, attrName);
- setOperationBody(addChild, ""
-
- /*{
- get<%=attrNameCapitalized%>().add(<%=attrName%>);
- firePropertyChange("<%=attrName%>", null, <%=attrName%>);
- return <%=attrName%>;
- }*/
- );
-
- // Add removeChild
- ObjectModelOperation removeChild = addOperation(resultClass, "remove" + attrNameCapitalized,
- "boolean", ObjectModelModifier.PUBLIC);
- addParameter(removeChild, attrType, attrName);
- setOperationBody(removeChild, ""
-
- /*{
- boolean removed = get<%=attrNameCapitalized%>().remove(<%=attrName%>);
- if (removed) {
- firePropertyChange("<%=attrName%>", <%=attrName%>, null);
- }
- return removed;
- }*/
- );
-
- // Change type for Multiple attribute
- if (attr.isOrdered()) {
- attrType = List.class.getName() + "<" + attrType + ">";
- } else {
- attrType = Collection.class.getName() + "<" + attrType + ">";
- }
- simpleType = GeneratorUtil.getSimpleName(attrType);
- }
-
- if (attr.hasAssociationClass()) {
- String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
- attrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
- attrType = attr.getAssociationClass().getName();
- }
-
- // Add attribute
- String visibility = attr.getVisibility();
- addAttribute(resultClass, attrName, attrType, "", ObjectModelModifier.toValue(visibility));
-
- // Add getter
- ObjectModelOperation getter = addOperation(resultClass, "get" + attrNameCapitalized, attrType,
- ObjectModelModifier.PUBLIC);
- setOperationBody(getter, ""
- /*{
- return this.<%=attrName%>;
- }*/
- );
-
- // Add setter
- ObjectModelOperation setter = addOperation(resultClass, "set" + attrNameCapitalized, "void",
- ObjectModelModifier.PUBLIC);
- addParameter(setter, attrType, "newValue");
- setOperationBody(setter, ""
- /*{
- <%=simpleType%> oldValue = get<%=attrNameCapitalized%>();
- this.<%=attrName%> = newValue;
- firePropertyChange("<%=attrName%>", oldValue, newValue);
- }*/
- );
-
- }
- }
-
- // Add helper methods
- if (hasMultipleAttribute) {
- ObjectModelOperation getChild = addOperation(resultClass, "getChild", "<T> T",
- ObjectModelModifier.PROTECTED);
- addParameter(getChild, "java.util.Collection<T>", "childs");
- addParameter(getChild, "int", "index");
- setOperationBody(getChild, ""
- /*{
- if (childs != null) {
- int i = 0;
- for (T o : childs) {
- if (index == i) {
- return o;
- }
- i++;
- }
- }
- return null;
- }*/
- );
- }
-
- if (hasEntity) {
- ObjectModelOperation getEntity = addOperation(resultClass, "getEntity",
- "<T extends org.nuiton.topia.persistence.TopiaEntity> T", ObjectModelModifier.PROTECTED);
- addParameter(getEntity, "java.util.Collection<T>", "childs");
- addParameter(getEntity, "java.lang.String", "topiaId");
- setOperationBody(getEntity, ""
- /*{
- if (childs != null) {
- for (T o : childs) {
- if (topiaId.equals(o.getTopiaId())) {
- return o;
- }
- }
- }
- return null;
- }*/
- );
- }
-
- // Add operations
- for (ObjectModelOperation op : clazz.getOperations()) {
- String visibility = op.getVisibility();
- ObjectModelOperation resultOperation = addOperation(resultClass, op.getName(), op.getReturnType(),
- ObjectModelModifier.toValue(visibility), ObjectModelModifier.ABSTRACT);
-
- for (ObjectModelParameter param : op.getParameters()) {
- addParameter(resultOperation, param.getType(), param.getName());
- }
-
- for (String exception : op.getExceptions()) {
- addException(resultOperation, exception);
- }
- }
-
-
- }
-
- private void createForDTO(ObjectModelClass resultClass, ObjectModelClass inputClass) {
-
- // Add Serializable implements for DTO generation
- if (inputClass.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
- addInterface(resultClass, "java.io.Serializable");
- }
-
- String svUID = TopiaGeneratorUtil.findTagValue("dto-serialVersionUID", inputClass, getModel());
- if (svUID != null) {
- addConstant(resultClass, "serialVersionUID", "long", svUID, ObjectModelModifier.PUBLIC);
- }
- }
-
- protected void createListeners(ObjectModelClass resultClass, ObjectModelClass inputClass) {
-
- addAttribute(resultClass, "pcs", "java.beans.PropertyChangeSupport", "",
- ObjectModelModifier.PROTECTED, ObjectModelModifier.FINAL);
-
- // Default constructor
- ObjectModelOperation constructor = addConstructor(resultClass, ObjectModelModifier.PUBLIC);
- setOperationBody(constructor, ""
- /*{
- pcs = new PropertyChangeSupport(this);
- }*/
- );
-
- // Add PropertyListener
- String propType = "java.beans.PropertyChangeListener";
- String strType = String.class.getName();
- String objectType = Object.class.getName();
-
- ObjectModelOperation addPropertyChangeListener = addOperation(resultClass,
- "addPropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
- addParameter(addPropertyChangeListener, propType, "listener");
- setOperationBody(addPropertyChangeListener, ""
- /*{
- pcs.addPropertyChangeListener(listener);
- }*/
- );
-
- ObjectModelOperation addPropertyChangeListenerPlus = addOperation(resultClass,
- "addPropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
- addParameter(addPropertyChangeListenerPlus, strType, "propertyName");
- addParameter(addPropertyChangeListenerPlus, propType, "listener");
- setOperationBody(addPropertyChangeListenerPlus, ""
- /*{
- pcs.addPropertyChangeListener(propertyName, listener);
- }*/
- );
-
- ObjectModelOperation removePropertyChangeListener = addOperation(resultClass,
- "removePropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
- addParameter(removePropertyChangeListener, propType, "listener");
- setOperationBody(removePropertyChangeListener, ""
- /*{
- pcs.removePropertyChangeListener(listener);
- }*/
- );
-
- ObjectModelOperation removePropertyChangeListenerPlus = addOperation(resultClass,
- "removePropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
- addParameter(removePropertyChangeListenerPlus, strType, "propertyName");
- addParameter(removePropertyChangeListenerPlus, propType, "listener");
- setOperationBody(removePropertyChangeListenerPlus, ""
- /*{
- pcs.removePropertyChangeListener(propertyName, listener);
- }*/
- );
-
- ObjectModelOperation firePropertyChange = addOperation(resultClass,
- "firePropertyChange", "void", ObjectModelModifier.PROTECTED);
- addParameter(firePropertyChange, strType, "propertyName");
- addParameter(firePropertyChange, objectType, "oldValue");
- addParameter(firePropertyChange, objectType, "newValue");
- setOperationBody(firePropertyChange, ""
- /*{
- pcs.firePropertyChange(propertyName, oldValue, newValue);
- }*/
- );
- }
-
-
-}
Deleted: branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/Megatron.java
===================================================================
--- branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/Megatron.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/Megatron.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,41 +0,0 @@
-
-package org.nuiton.eugene.test.generator;
-
-import org.nuiton.eugene.java.ObjectModelTransformerToJava;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-
-/**
- * Megatron
- *
- * Chainage des transformer : Modele de depart -> transformation dans BeanTransformer = modele d'entrée de Megatron
- *
- * Created: 12 nov. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class Megatron extends ObjectModelTransformerToJava {
-
- public Megatron() {
- super();
- }
-
- /*
- CAS modele de sortie vide : modele d'entree transformee par BeanTransformer
- */
- @Override
- protected ObjectModelTransformerToJava initPreviousTransformer() {
- return new BeanTransformer();
- }
-
- @Override
- public void transformFromClass(ObjectModelClass clazz) {
-
-
-
- }
-
-}
Deleted: branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TestBuilder.java
===================================================================
--- branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TestBuilder.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TestBuilder.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,93 +0,0 @@
-/*
- * *##%
- * EUGene Test
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-
-package org.nuiton.eugene.test.generator;
-
-import org.nuiton.eugene.java.JavaBuilder;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelModifier;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-
-/*{generator option: parentheses = false}*/
-/*{generator option: writeString = +}*/
-/**
- * TestBuilder
- *
- * Created: 25 oct. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class TestBuilder extends JavaBuilder {
-
- public TestBuilder() {
- super("TestModel");
- }
-
- //@Override
- public void build() {
- createRole();
- createPerson();
- }
-
- private void createRole() {
- ObjectModelClass roleClass = createClass("Role", "org.chorem.bonzoms");
-
- addAttribute(roleClass, "name", "java.lang.String");
-
- //this.addImportForClassifier(roleClass, Date.class);
- addAttribute(roleClass, "fromDate", "java.util.Date");
- addAttribute(roleClass, "thruDate", "java.util.Date");
- }
-
- private void createPerson() {
- ObjectModelClass personneClass = createClass("Person", "org.chorem.bonzoms");
-
- addAttribute(personneClass, "lastName", "java.lang.String");
- addAttribute(personneClass, "firstName", "java.lang.String", "\"2.0\"");
-
- //this.addImportForClassifier(personneClass, List.class);
- addAttribute(personneClass, "roles", "java.util.List<org.chorem.bonzoms.Role>",
- "new java.util.ArrayList<org.chorem.bonzoms.Role>()");
-
-
- ObjectModelOperation setLastName = addOperation(personneClass, "setLastName", "void",
- ObjectModelModifier.PUBLIC);
- addParameter(setLastName, "java.lang.String", "lastName");
- setOperationBody(setLastName, ""
- /*{
- this.lastName = lastName;
- }*/
- );
-
- ObjectModelOperation getLastName = addOperation(personneClass, "getLastName", "java.lang.String",
- ObjectModelModifier.PUBLIC);
- setOperationBody(getLastName, ""
- /*{
- return this.lastName;
- }*/
- );
- }
-
-}
Deleted: branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TestReader.java
===================================================================
--- branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TestReader.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TestReader.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,51 +0,0 @@
-/*
- * *##%
- * EUGene Test
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*
- */
-
-package org.nuiton.eugene.test.generator;
-
-import java.io.File;
-import org.nuiton.eugene.ModelReader;
-import org.nuiton.eugene.models.object.ObjectModel;
-
-/**
- * TestReader
- *
- * Created: 27 oct. 2009
- *
- * @author fdesbois
- * @version $Revision$
- *
- * Mise a jour: $Date$
- * par : $Author$
- */
-public class TestReader extends ModelReader<ObjectModel> {
-
-
- @Override
- public ObjectModel read(File[] file) {
- TestBuilder builder = new TestBuilder();
-
- builder.build();
-
- return builder.getModel();
- }
-
-}
Deleted: branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TopiaGeneratorUtil.java
===================================================================
--- branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TopiaGeneratorUtil.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/src/main/java/org/nuiton/eugene/test/generator/TopiaGeneratorUtil.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,948 +0,0 @@
-/* *##%
- * EUGene Test
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%*/
-/*******************************************************************************
- * GeneratorUtil.java
- *
- * Created: 13 déc. 2005
- *
- * @author Arnaud Thimel <thimel(a)codelutin.com>
- *
- * @version $Revision: 1298 $
- *
- * Mise a jour: $Date: 2009-01-15 00:01:45 +0100 (jeu 15 jan 2009) $ par : $Author: tchemit $
- */
-package org.nuiton.eugene.test.generator;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.commons.lang.StringUtils;
-import org.nuiton.eugene.Template;
-import org.nuiton.eugene.GeneratorUtil;
-import org.nuiton.eugene.models.Model;
-import org.nuiton.eugene.models.object.ObjectModel;
-import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelElement;
-import org.nuiton.eugene.models.object.ObjectModelInterface;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-import org.nuiton.eugene.models.object.ObjectModelParameter;
-
-/** Classe regroupant divers méthodes utiles pour la génération des entités */
-public class TopiaGeneratorUtil extends GeneratorUtil {
-
- /** Stéréotype pour les interfaces devant être générées sous forme de facades */
- public final static String STEREOTYPE_FACADE = "facade";
- /** Stéréotype pour les objets devant être générées sous forme d'entités */
- public static final String STEREOTYPE_ENTITY = "entity";
- /** Stéréotype pour les objets devant être générées sous forme de DTO */
- public static final String STEREOTYPE_DTO = "dto";
- /** Stéréotype pour les objets devant être générées sous forme de bean */
- public static final String STEREOTYPE_BEAN = "bean";
- /**
- * Stéréotype pour les interfaces devant être générées sous forme de
- * services
- */
- public static final String STEREOTYPE_SERVICE = "service";
- /** Stéréotype pour les interfaces devant être générées sous forme de DAO */
- public static final String STEREOTYPE_DAO = "dao";
- /** Stéréotype pour les attributs à indexer en base */
- public static final String STEREOTYPE_INDEXED = "indexed";
- /** Stéréotype pour les collections avec unicité */
- public static final String STEREOTYPE_UNIQUE = "unique";
- /** Stéréotype pour les attributs étant des clés primaires */
- public static final String STEREOTYPE_PRIMARYKAY = "primaryKey";
- /** Tag pour le type de persistence */
- public static final String TAG_PERSISTENCE_TYPE = "persistenceType";
- /** Tag pour le nom du champ / entité en BD */
- public static final String TAG_DB_NAME = "dbName";
- /** Tag pour le nom du schema en BD */
- public static final String TAG_SCHEMA_NAME = "dbSchema";
- /** Tag pour la taille du champ en BD */
- public static final String TAG_LENGTH = "length";
- /** Tag pour ajouter une annotation à un champ */
- public static final String TAG_ANNOTATION = "annotation";
- /** Tag pour ajouter specifier le copyright d'un fichier */
- public static final String TAG_COPYRIGHT = "copyright";
- /** Tag pour specfier le type d'acces a un champ */
- public static final String TAG_ACCESS = "access";
- /** Tag pour specfier si on doit générer i18n */
- public static final String TAG_I18N_PREFIX = "i18n";
- /** Tag pour ajouter un attribut dans une clef métier */
- public static final String TAG_NATURAL_ID = "naturalId";
- /** Tag pour specifier si une clef metier est mutable */
- public static final String TAG_NATURAL_ID_MUTABLE = "naturalIdMutable";
- /** Tag pour spécifier la caractèrelazy d'une association multiple */
- public static final String TAG_LAZY = "lazy";
- /** Tag pour spécifier la caractère fetch d'une association multiple */
- public static final String TAG_FETCH = "fetch";
- /** Tag pour spécifier la caractère order-by d'une association multiple */
- public static final String TAG_ORDER_BY = "orderBy";
- /** Tag pour spécifier la caractère not-null d'un attribut */
- public static final String TAG_NOT_NULL = "notNull";
- /** Tag pour spécifier la caractère embed-xml d'une association */
- public static final String TAG_EMBED_XML = "embedXml";
- /**
- * Tag pour configurer l'interface du proxy sur autre chose que l'implementation par defaut.
- *
- * Par defaut :
- * null > generere le proxy sur l'interface de l'implementation
- * Autre valeur :
- * "none" > laisse la configuration par defaut d'hibernate
- */
- public static final String TAG_PROXY_INTERFACE = "hibernateProxyInterface";
- /** Tag pour spécifier le permissions à la création */
- public static final String TAG_SECURITY_CREATE = "securityCreate";
- /** Tag pour spécifier le permissions au chargement */
- public static final String TAG_SECURITY_LOAD = "securityLoad";
- /** Tag pour spécifier le permissions à la mise à jour */
- public static final String TAG_SECURITY_UPDATE = "securityUpdate";
- /** Tag pour spécifier le permissions à la suppression */
- public static final String TAG_SECURITY_DELETE = "securityDelete";
- /** Tag pour specifier de ne pas generer la methode toString */
- public static final String TAG_NOT_GENERATE_TO_STRING = "notGenerateToString";
- /** Tag pour specifier de trier les attributs par nom lors de la generation */
- public static final String TAG_SORT_ATTRIBUTE = "sortAttribute";
- /** Tag pour specfier si on doit générer la methode getOperator dans les daohelpers )*/
- public static final String TAG_GENERATE_OPERATOR_FOR_DAO_HELPER = "generateOperatorForDAOHelper";
- /** 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(Template generator) {
- String packageName = generator.getProperty(PROPERTY_DEFAULT_PACKAGE);
- if (packageName == null || "".equals(packageName)) {
- packageName = DEFAULT_PACKAGE;
- }
- return packageName;
- }
-
- /**
- * @see GeneratorUtil#hasDocumentation
- * @deprecated
- */
- @Deprecated
- public static boolean hasDocumentation(ObjectModelElement element) {
- return notEmpty(element.getDocumentation());
- }
-
- /**
- * @see GeneratorUtil#notEmpty
- * @deprecated
- */
- @Deprecated
- 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 GeneratorUtil.findTagValue(TAG_I18N_PREFIX, 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 boolean shouldgenerateOperatorForDAOHelper(ObjectModelElement element,
- ObjectModel model) {
- String tagValue = GeneratorUtil.findTagValue(TAG_GENERATE_OPERATOR_FOR_DAO_HELPER, element, model);
- boolean generate = GeneratorUtil.notEmpty(tagValue) && Boolean.valueOf(tagValue);
- return generate;
- }
-
- /**
- * 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;
- }
-
- /**
- * Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
- *
- * @param clazz la classe à tester
- * @param model le modele
- * @return la liste des attributs de la clef métier ou null si pas de clef métier.
- */
- public static boolean generateToString(ObjectModelClass clazz,
- ObjectModel model) {
- String value;
- value = model.getTagValue(TAG_NOT_GENERATE_TO_STRING);
- if (value != null && !value.trim().isEmpty()) {
- return false;
- }
- value = clazz.getTagValue(TAG_NOT_GENERATE_TO_STRING);
- if (value != null && !value.trim().isEmpty()) {
- return false;
- }
- return true;
- }
-
- /**
- * Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
- *
- * @param clazz la classe à tester
- * @param model le modele
- * @return la liste des attributs de la clef métier ou null si pas de clef métier.
- */
- public static boolean sortAttribute(ObjectModelClass clazz,
- ObjectModel model) {
- String value;
- value = clazz.getTagValue(TAG_SORT_ATTRIBUTE);
- if (value == null || value.trim().isEmpty() || "false".equals(value.trim())) {
- return false;
- }
- if (value != null && "true".equals(value.trim())) {
- return true;
- }
-
- value = model.getTagValue(TAG_SORT_ATTRIBUTE);
- if (value == null || value.trim().isEmpty() || "false".equals(value.trim())) {
- return false;
- }
- if (value != null && "true".equals(value.trim())) {
- return true;
- }
- return true;
- }
-
- /**
- * Detecte si un attribut fait partie d'une clef metier.
- *
- * @param attribute l'attribut à tester
- * @return <code>true</code> si l'attribut fait partie d'une clef metier, <code>false</cdoe> sinon.
- */
- public static boolean isNaturalId(ObjectModelAttribute attribute) {
- String value = attribute.getTagValue(TAG_NATURAL_ID);
- if (!GeneratorUtil.notEmpty(value)) {
- // valeur null, donc pas positionnee
- return false;
- }
- try {
- return Boolean.valueOf(value.trim());
- } catch (Exception e) {
- // on a pas reussi a convertir en boolean.
- //todo peut-être declancher une exception ?
- return false;
- }
- }
-
- /**
- * Cherches et renvoie le copyright a utiliser sur le model.
- *
- * @param model le modele utilisé
- * @return le texte du copyright ou null
- */
- public static String getCopyright(Model model) {
- return findTagValue(TAG_COPYRIGHT, null, model);
- }
-
- /**
- * @see GeneratorUtil#findTagValue
- * @deprecated
- */
- @Deprecated
- public static String findTagValue(String tagName,
- ObjectModelElement element, Model model) {
- if (element == null) {
- if (model != null) {
- if (notEmpty(model.getTagValue(tagName))) {
- return model.getTagValue(tagName);
- }
- }
- return null;
- }
- if (notEmpty(element.getTagValue(tagName))) {
- return element.getTagValue(tagName);
- }
- //On va chercher sur l'element declarant
- return findTagValue(tagName, element.getDeclaringElement(), model);
- }
-
- public static <Type extends ObjectModelElement> Collection<Type> getElementsWithStereotype(
- Collection<Type> elements, String... stereotypes) {
- Collection<Type> result = new ArrayList<Type>();
- for (Type element : elements) {
- if (hasStereotypes(element, stereotypes)) {
- result.add(element);
- }
- }
- return result;
- }
-
- public static boolean hasStereotypes(ObjectModelElement element,
- String... stereotypes) {
- for (String stereotype : stereotypes) {
- if (!element.hasStereotype(stereotype)) {
- return false;
- }
- }
- return true;
- }
-
- public static String getPrimaryKeyAttributesListDeclaration(
- ObjectModelClass clazz, boolean includeName) {
- String attributes = "";
- for (ObjectModelAttribute attr : getElementsWithStereotype(clazz.getAttributes(), STEREOTYPE_PRIMARYKAY)) {
- attributes += attr.getType();
- if (includeName) {
- attributes += " " + attr.getName();
- }
- attributes += ", ";
- }
- if (attributes.length() > 0) {
- attributes = attributes.substring(0, attributes.length() - 2);
- }
- return attributes;
- }
-
- public static String capitalize(String s) {
- return StringUtils.capitalize(s);
- }
-
- public static boolean isAssociationClassDoublon(ObjectModelAttribute attr) {
- return (attr.getReverseAttribute() != null) && (attr.getDeclaringElement().equals(attr.getReverseAttribute().getDeclaringElement())) && (!GeneratorUtil.isFirstAttribute(attr));
- }
-
- /**
- * Renvoie le nom de l'attribut de classe d'association en fonction des cas:
- * Si l'attribut porte le même nom que le type (extrémité inverse de
- * l'association), on lui ajoute le nom de la classe d'association
- *
- * @param attr l'attribut a traiter
- * @return le nom de l'attribut de classe d'association
- */
- public static String getAssocAttrName(ObjectModelAttribute attr) {
- String typeName = attr.getType().substring(
- attr.getType().lastIndexOf(".") + 1);
- String result = attr.getName();
- if (attr.getName().equalsIgnoreCase(typeName)) {
- result += capitalize(attr.getAssociationClass().getName());
- }
- return result;
- }
-
- public static String getDOType(ObjectModelElement elem, ObjectModel model) {
- String type = elem.getName();
- if (elem instanceof ObjectModelAttribute) {
- type = ((ObjectModelAttribute) elem).getType();
- }
- if (elem instanceof ObjectModelClass) {
- type = ((ObjectModelClass) elem).getQualifiedName();
- }
- return getDOType(type, model);
- }
-
- public static String getDOType(String type, ObjectModel model) {
- if (!model.hasClass(type)) {
- return type;
- }
- ObjectModelClass clazz = model.getClass(type);
- if (clazz.hasStereotype(STEREOTYPE_ENTITY)) {
- if (shouldBeAbstract(clazz)) {
- type += "Abstract";
- } else {
- type += "Impl";
- }
- }
- return type;
- }
- private static final Set<String> numberTypes = new HashSet<String>();
- private static final Set<String> textTypes = new HashSet<String>();
- private static final Set<String> booleanTypes = new HashSet<String>();
- private static final Set<String> primitiveTypes = new HashSet<String>();
- private static final String VOID_TYPE = "void";
-
- static {
- numberTypes.add("byte");
- numberTypes.add("java.lang.Byte");
- numberTypes.add("Byte");
- numberTypes.add("short");
- numberTypes.add("java.lang.Short");
- numberTypes.add("Short");
- numberTypes.add("int");
- numberTypes.add("java.lang.Integer");
- numberTypes.add("Integer");
- numberTypes.add("long");
- numberTypes.add("java.lang.Long");
- numberTypes.add("Long");
- numberTypes.add("float");
- numberTypes.add("java.lang.Float");
- numberTypes.add("Float");
- numberTypes.add("double");
- numberTypes.add("java.lang.Double");
- numberTypes.add("Double");
-
- textTypes.add("char");
- textTypes.add("java.lang.Char");
- textTypes.add("Char");
- textTypes.add("java.lang.String");
- textTypes.add("String");
-
- booleanTypes.add("boolean");
- booleanTypes.add("java.lang.Boolean");
- booleanTypes.add("Boolean");
-
- primitiveTypes.addAll(numberTypes);
- primitiveTypes.addAll(textTypes);
- primitiveTypes.addAll(booleanTypes);
- }
-
- public static boolean isNumericType(ObjectModelAttribute attr) {
- return numberTypes.contains(attr.getType());
- }
-
- public static boolean isTextType(ObjectModelAttribute attr) {
- return textTypes.contains(attr.getType());
- }
-
- public static boolean isDateType(ObjectModelAttribute attr) {
- return "java.util.Date".equals(attr.getType());
- }
-
- public static boolean isBooleanType(ObjectModelAttribute attr) {
- return booleanTypes.contains(attr.getType());
- }
-
- public static boolean isPrimitiveType(ObjectModelAttribute attr) {
- return primitiveTypes.contains(attr.getType());
- }
-
- /**
- * Indique si la classe specifiee n'a aucune ou que des methodes abstraites
- *
- * @param clazz l'instance de ObjectModelClass
- * @return true si la classe n'a que des operations abstraite ou aucune
- * operation
- */
- public static boolean hasNothingOrAbstractMethods(ObjectModelClass clazz) {
- boolean result = true;
- Iterator<?> operations = clazz.getOperations().iterator();
- while (result && operations.hasNext()) {
- ObjectModelOperation op = (ObjectModelOperation) operations.next();
- result = op.isAbstract();
- }
- return result;
- }
-
- /**
- * Indique si la classe specifiee devrait etre abstraite
- *
- * @param clazz l'instance de ObjectModelClass
- * @return true dans ce cas, false sinon
- */
- public static boolean shouldBeAbstract(ObjectModelClass clazz) {
- return clazz != null && (clazz.isAbstract() && hasNothingOrAbstractMethods(clazz));
- }
-
- /**
- * <p>
- * Cette méthode permet de détecter si
- * - l'attribut représente une relation 1-n
- * - cette relation est unidirectionnelle
- * - le type de l'attribut représente un entité
- * - cette entité a des sous-classes dans le modèle
- * <p/>
- * Ce cas correspond à une incompatibilité d'Hibernate qui nous oblige a
- * adopter un comportement particulier.
- * </p>
- *
- * @param attr l'attribut a tester
- * @param model le model
- * @return true si et seulement si il s'agit bien de ce type de relation
- */
- public static boolean hasUnidirectionalRelationOnAbstractType(
- ObjectModelAttribute attr, ObjectModel model) {
- ObjectModelAttribute reverse = attr.getReverseAttribute();
- //relation 1-n
- if (reverse != null && isNMultiplicity(attr) && !isNMultiplicity(reverse)) {
- //Pas de navigabilité
- if (!reverse.isNavigable()) {
- //Il s'agit d'une entity
- ObjectModelClass clazz = model.getClass(attr.getType());
- if (clazz != null && clazz.hasStereotype(STEREOTYPE_ENTITY)) {
- //Cette classe a des sous-classes dans le modèle
- for (ObjectModelClass subClass : model.getClasses()) {
- if (subClass.getSuperclasses().contains(clazz)) {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- /**
- * Renvoie le nom unique de table pour une relation ManyToMany en fonction
- * de l'attribut <code>attr</code>
- * <p/>
- * Plusieurs cas de figure:
- * <li>
- *
- * @param attr l'attribut servant de base au calcul du nom
- * @return le nom de la table
- */
- public static String getManyToManyTableName(ObjectModelAttribute attr) {
- String result;
-
- if (attr.hasAssociationClass()) {
- result = TopiaGeneratorUtil.getDBName(attr.getAssociationClass());
- } else {
- String name = attr.getName();
- String revers = attr.getReverseAttributeName();
-
- if (name.compareToIgnoreCase(revers) < 0) {
- result = name + "_" + revers;
- } else {
- result = revers + "_" + name;
- }
- }
- // String result;
- // if (!Util.isFirstAttribute(attr)) {
- // result = attr.getDeclaringElement().getName() + "_" + attr.getReverseAttribute().getDeclaringElement().getName();
- // } else {
- // result = attr.getReverseAttribute().getDeclaringElement().getName() + "_" + attr.getDeclaringElement().getName();
- // }
- return result.toLowerCase();
- }
-
- /**
- * Renvoie le type d'interface à utiliser en fonction de l'attribut
- *
- * @param attr l'attribut a traiter
- * @return String
- */
- public static String getNMultiplicityInterfaceType(ObjectModelAttribute attr) {
- if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
- return Set.class.getName();
- } else if (attr.isIndexed() || attr.isOrdered()) {
- return List.class.getName();
- }
- return Collection.class.getName();
- }
-
- /**
- * Renvoie le type d'objet (instance) à utiliser en fonction de l'attribut
- *
- * @param attr l'attribut a traiter
- * @return String
- */
- public static String getNMultiplicityObjectType(ObjectModelAttribute attr) {
- if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
- return HashSet.class.getName();
- } else if (attr.isIndexed() || attr.isOrdered()) {
- //On considère qu'on ne sait pas traiter vraiment l'attribut "ordered"
- // puisqu'on va conserver l'ordre d'insertion, et non un ordre en
- // fonction d'un élément donné. Donc on renvoi une ArrayList
- return ArrayList.class.getName();
- }
- LinkedList.class.getName();
- return ArrayList.class.getName();
- }
-
- /**
- * Renvoie le type d'interface à utiliser en fonction de l'attribut
- *
- * @param attr l'attribut a traiter
- * @return String
- */
- public static String getNMultiplicityHibernateType(ObjectModelAttribute attr) {
- if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
- return "set";
- } else if (attr.isIndexed()) {
- return "list";
- }
- //attr.isOrdered() - On génère le ordered en bag
- return "bag";
- }
-
- /**
- * Obtain the list of entities classes with the possibility to sort the result.
- *
- * @param model the current model to scan
- * @param sort flag to allow sort the result
- * @return the list of filtred classes by their stereotype
- */
- public static List<ObjectModelClass> getEntityClasses(ObjectModel model,
- boolean sort) {
- return getClassesByStereotype(STEREOTYPE_ENTITY, model, sort);
- }
-
- /**
- * Obtain the list of classes for a given stereotype with the possibility to sort the result.
- *
- * @param stereotype filter stereotype
- * @param model the current model to scan
- * @param sort flag to allow sort the result
- * @return the list of filtred classes by their stereotype
- */
- public static List<ObjectModelClass> getClassesByStereotype(
- String stereotype, ObjectModel model, boolean sort) {
- List<ObjectModelClass> classes = new ArrayList<ObjectModelClass>();
- for (ObjectModelClass clazz : model.getClasses()) {
- if (clazz.hasStereotype(stereotype)) {
- classes.add(clazz);
- }
- }
- if (sort && !classes.isEmpty()) {
- java.util.Collections.sort(classes,
- new java.util.Comparator<ObjectModelClass>() {
-
- @Override
- public int compare(ObjectModelClass o1,
- ObjectModelClass o2) {
- return o1.getQualifiedName().compareTo(
- o2.getQualifiedName());
- }
- });
- }
- return classes;
- }
-
- /**
- * Detecte si la clef metier d'une classe est mutable ou pas.
- * <p/>
- * On respecte la valeur par defaut d'hibernate, à savoir que par default une clef metier est non mutable.
- *
- * @param clazz la classe a tester
- * @return <code>true</code> si le tag value a ete positionne sur la classe via le tag
- * {@link #TAG_NATURAL_ID_MUTABLE}, , <code>false</code> sinon.
- */
- public static boolean isNaturalIdMutable(ObjectModelClass clazz) {
- String value = clazz.getTagValue(TAG_NATURAL_ID_MUTABLE);
- if (!notEmpty(value)) {
- // valeur null, donc par default positionnee
- return false;
- }
- try {
- return Boolean.valueOf(value.trim());
- } catch (Exception e) {
- // on a pas reussi a convertir en boolean.
- //todo peut-être declancher une exception ?
- return false;
- }
- }
-
- /**
- * Obtain the list of fqn of object involed in the given class.
- *
- * @param aClass the clazz to inspect
- * @param incomingFqns incoming fqns
- * @return the list of fqn of attributes
- */
- public static List<String> getImports(ObjectModelClass aClass, String... incomingFqns) {
- Set<String> tmp = new HashSet<String>();
- tmp.addAll(Arrays.asList(incomingFqns));
- getImports(aClass, tmp);
- List<String> result = cleanImports(aClass.getPackageName(), tmp);
- return result;
- }
-
- /**
- * Obtain the list of fqn of object involed in the given interface.
- *
- * @param anInterface the interface to inspect
- * @param incomingFqns incoming fqns
- * @return the list of fqn of attributes
- */
- public static List<String> getImports(ObjectModelInterface anInterface, String... incomingFqns) {
- Set<String> tmp = new HashSet<String>();
- tmp.addAll(Arrays.asList(incomingFqns));
- getImports(anInterface, tmp);
- List<String> result = cleanImports(anInterface.getPackageName(), tmp);
- return result;
- }
-
- public static String getSimpleName(String fqn) {
- int lasIndex = fqn.lastIndexOf(".");
- if (lasIndex == 1) {
- // primitive type
- return fqn;
- }
- return fqn.substring(lasIndex + 1);
- /*if (lasIndex == aClass.getPackageName().length()) {
- // same package
- return fqn.substring(lasIndex + 1);
- }
-
- return fqn;*/
- }
-
- /**
- * Obtain the list of fqn of object involed in the given class.
- *
- * @param aClass the class to inspect
- * @param fqns where to store found fqns
- */
- protected static void getImports(ObjectModelClass aClass, Set<String> fqns) {
- // scan attributes
- for (ObjectModelAttribute attr : aClass.getAttributes()) {
- fqns.add(attr.getType());
- if (isNMultiplicity(attr)) {
- String collectionType = getNMultiplicityInterfaceType(attr);
- fqns.add(collectionType);
- String collectionObject = getNMultiplicityObjectType(attr);
- fqns.add(collectionObject);
- }
- }
- for (ObjectModelAttribute attribute : aClass.getAllOtherAttributes()) {
- fqns.add(attribute.getType());
- }
- // scan associations
- if (aClass instanceof ObjectModelAssociationClass) {
- ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) aClass;
- for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
- if (attr == null) {
- continue;
- }
- fqns.add(attr.getType());
- if (isNMultiplicity(attr)) {
- String collectionType = getNMultiplicityInterfaceType(attr);
- fqns.add(collectionType);
- String collectionObject = getNMultiplicityObjectType(attr);
- fqns.add(collectionObject);
- }
- }
- }
- // scan operations
- for (ObjectModelOperation operation : aClass.getOperations()) {
- getImports(operation, fqns);
- }
- // scan super interfaces
- for (ObjectModelInterface modelInterface : aClass.getInterfaces()) {
- fqns.add(modelInterface.getQualifiedName());
- getImports(modelInterface, fqns);
- }
- // scan super classes
- for (ObjectModelClass modelClass : aClass.getSuperclasses()) {
- fqns.add(modelClass.getQualifiedName());
- getImports(modelClass);
- }
- }
-
- /**
- * Obtain the list of fqn of object involed in the given interface.
- *
- * @param anInterface the interface to inspect
- * @param fqns where to store found fqns
- */
- protected static void getImports(ObjectModelInterface anInterface, Set<String> fqns) {
- // scan operations
- for (ObjectModelOperation operation : anInterface.getOperations()) {
- getImports(operation, fqns);
- }
- // scan super interfaces
- for (ObjectModelInterface modelInterface : anInterface.getInterfaces()) {
- fqns.add(modelInterface.getQualifiedName());
- getImports(modelInterface, fqns);
- }
- }
-
- /**
- * Obtain the fqn's list of all involed type in a givne operation.
- *
- * @param operation operation to inspect
- * @param fqns where to store found fqns
- */
- protected static void getImports(ObjectModelOperation operation, Set<String> fqns) {
- String fqn = operation.getReturnType();
- fqns.add(fqn);
- for (ObjectModelParameter parameter : operation.getParameters()) {
- fqns.add(parameter.getType());
- }
- }
-
- /**
- * Clean a set of fqns, transform it into a {@link List} and sort it.
- *
- * @param packageName the current package name
- * @param fqns the dirty set of fqns
- * @return the sorted cleaned list of fqns.
- */
- protected static List<String> cleanImports(String packageName, Set<String> fqns) {
- fqns.removeAll(primitiveTypes);
- fqns.remove(VOID_TYPE);
- int packageLength = packageName.length();
- List<String> genericType = new ArrayList<String>();
- for (Iterator<String> it = fqns.iterator(); it.hasNext();) {
- String fqn = it.next();
- int lastIndex = fqn.lastIndexOf(".");
- if (lastIndex == packageLength && fqn.startsWith(packageName)) {
- // same package
- it.remove();
- continue;
- }
- int genericIndex = fqn.indexOf('<');
- if (genericIndex != -1) {
- genericType.add(fqn.substring(0, genericIndex));
- it.remove();
- }
- }
- fqns.addAll(genericType);
-
- ArrayList<String> result = new ArrayList<String>(fqns);
- java.util.Collections.sort(result);
- return result;
- }
-
- /**
- * Convertit un nom de variable en nom de constante.
- *
- * @param variableName le nom de variable a convertir
- * @return le nom de la constante à partir du nom de la variable
- */
- public static String convertVariableNameToConstantName(String variableName) {
- //TODO Faire des tests pour savoir si variableName est non null et valide
- //TODO Ameliorer l'algo pour tenir compte des caractères non alpha
- //TODO pour le moment cela convient, donc...
- StringBuilder buffer = new StringBuilder();
- boolean lastCarIsUp = false;
- for (int i = 0, j = variableName.length(); i < j; i++) {
- char c = variableName.charAt(i);
- boolean carIsUp = Character.isUpperCase(c);
- if (i > 0 && !lastCarIsUp && carIsUp) {
- // ajout d'un _
- buffer.append('_');
- }
- if (carIsUp) {
- buffer.append(c);
- } else {
- buffer.append(Character.toUpperCase(c));
- }
- lastCarIsUp = carIsUp;
- }
- return buffer.toString();
- }
-} // GeneratorUtil
-
Deleted: branches/eugene-2.0/eugene-test/src/main/resources/log4j.properties
===================================================================
--- branches/eugene-2.0/eugene-test/src/main/resources/log4j.properties 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/src/main/resources/log4j.properties 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,12 +0,0 @@
-# Global logging configuration
-log4j.rootLogger=ERROR, stdout
-
-# Console output...
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-
-# package level
-log4j.logger.org.nuiton.eugene=DEBUG
-log4j.logger.org.nuiton.eugene.test=DEBUG
-log4j.logger.org.nuiton.processor=DEBUG
Deleted: branches/eugene-2.0/eugene-test/src/test/java/org/nuiton/eugene/test/generator/TestBuilderTest.java
===================================================================
--- branches/eugene-2.0/eugene-test/src/test/java/org/nuiton/eugene/test/generator/TestBuilderTest.java 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/src/test/java/org/nuiton/eugene/test/generator/TestBuilderTest.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,91 +0,0 @@
-/*
- * *##%
- * EUGene Test
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * 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>.
- * ##%*
- */
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-package org.nuiton.eugene.test.generator;
-
-import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import org.nuiton.eugene.models.object.ObjectModel;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-
-/**
- *
- * @author fdesbois
- */
-public class TestBuilderTest {
-
- private static final Log log = LogFactory.getLog(TestBuilderTest.class);
-
- public TestBuilderTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
- /**
- * Test of build method, of class TestBuilder.
- */
- @Test
- public void testBuild() {
- System.out.println("build");
- TestBuilder instance = new TestBuilder();
-
- instance.build();
-
- ObjectModel result = instance.getModel();
- assertNotNull(result);
- assertEquals(result.getClasses().size(), 2);
- ObjectModelClass clazz = result.getClass("org.chorem.bonzoms.Person");
- assertNotNull(clazz);
- assertEquals(clazz.getAttributes().size(), 3);
- assertEquals(clazz.getOperations().size(), 2);
- List<ObjectModelOperation> operations = (List<ObjectModelOperation>)clazz.getOperations();
- ObjectModelOperation operation = operations.get(0);
- log.debug("Body code [" + operation.getName() + "] : " + operation.getBodyCode());
- assertFalse(operation.getBodyCode().isEmpty());
- }
-
-}
\ No newline at end of file
Deleted: branches/eugene-2.0/eugene-test/src/test/resources/log4j.properties
===================================================================
--- branches/eugene-2.0/eugene-test/src/test/resources/log4j.properties 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/eugene-test/src/test/resources/log4j.properties 2009-12-14 01:57:24 UTC (rev 749)
@@ -1,12 +0,0 @@
-# Global logging configuration
-log4j.rootLogger=ERROR, stdout
-
-# Console output...
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-
-# package level
-log4j.logger.org.nuiton.eugene=DEBUG
-log4j.logger.org.nuiton.eugene.test=DEBUG
-log4j.logger.org.nuiton.processor=DEBUG
Modified: branches/eugene-2.0/maven-eugene-plugin/pom.xml
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/pom.xml 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/maven-eugene-plugin/pom.xml 2009-12-14 01:57:24 UTC (rev 749)
@@ -508,7 +508,7 @@
<id>run-its</id>
<activation>
<property>
- <name>performRedmineRelease</name>
+ <name>performRelease</name>
<value>true</value>
</property>
</activation>
@@ -518,6 +518,7 @@
<artifactId>maven-invoker-plugin</artifactId>
<configuration>
<pomIncludes>
+ <!--<pomInclude>generate/generators/pom.xml</pomInclude>-->
<pomInclude>**/pom.xml</pomInclude>
</pomIncludes>
<postBuildHookScript>verify</postBuildHookScript>
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/LICENSE.txt
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/LICENSE.txt (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/LICENSE.txt 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/README.txt
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/README.txt (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/README.txt 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,2 @@
+To deploy new version of pom: mvn deploy
+To install localy: mvn install
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/changelog.txt
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/changelog.txt (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/changelog.txt 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,53 @@
+1.0.0 xxx xxx
+ * Add multiple models loading and restricted package generation
+ * Recode EugenePlugin without ant
+ * Move to org.nuiton groupid
+ * Rename project to Eugene
+
+0.64 chemit 20090218
+ * 20090211 [chatellier] add testPhase property in mojo to specify when using it in test phase
+ * 20090210 [chatellier] add info and debug maven log messages
+ * 20090210 [chatellier] add default value on all non required parameters
+ * 20090209 [chemit] fix bug when using sibling dependencies in a multi-module project
+ * 20090129 [chemit] use lutinproject 3.4 (suppress javadoc plugin invocation)
+
+0.63 chemit 20081215
+ * 20081215 [chemit] follow lutingenerator release
+
+0.62 chemit 20081210
+ * 20081210 [chemit] use lutinpluginproject 3.2
+ * 20081203 [chemit] add a encoding goal property to be dispatched in all generator to control file generation encoding
+ * 20081118 [chemit] use lutinproject 3.1
+ * 20081117 [chemit]
+ - add extraClassPathDirectory parameter to can specify an extra directory to add in classLoader
+ - bump lutingenerator version
+
+0.61 chatellier 20081114
+ * 20081107 [chatellier]
+ - add test compile dir and test resources in generation gaol
+ * 20081101 [chemit]
+ - add an excludeTemplates property on GeneratorPlugin to permit exclusion of generators for some composite generator
+ - bump lutingenerator to 0.61
+
+0.60 chemit 20081013
+ * 20081013 [chemit]
+ - remove addCompileDirectory option (always done) + add dynamic resources
+ - use lutingenerator 0.60
+ - clean pom
+
+0.51 thimel 20080925
+ * 20080925 [thimel] Refactor pom using the correct architecture
+ * 20080925 [thimel] Switched License to LGPL
+ * 20080723 [chemit]
+ - add generated sources in maven project's compilation directories via addCompilationDirectory plugin property
+
+ * 20070525 [chatellier]
+ - add Xmi2StateModel goal
+ - improve Xmi2Model Hierarchy
+ * 20070525 [chatellier] update ant dependency to 1.7.0
+ * 20070525 [chatellier] replacing lutinxml.XSLAntTask by Ant.XSLTProcess
+
+0.50 ??? ???
+
+ * 20070420 [chatellier] add goal to copy a set of generated files
+ * 20070420 [chatellier] update lutingenerator depencency to 0.50
\ No newline at end of file
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/invoker.properties
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/invoker.properties (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/invoker.properties 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,21 @@
+# A comma or space separated list of goals/phases to execute, may
+# specify an empty list to execute the default goal of the IT project
+invoker.goals=clean test
+
+# Optionally, a list of goals to run during further invocations of Maven
+#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run
+
+# A comma or space separated list of profiles to activate
+#invoker.profiles=run-all run-once
+
+# The value for the environment variable MAVEN_OPTS
+#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m
+
+# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never"
+invoker.failureBehavior=fail-at-end
+
+# The expected result of the build, possible values are "success" (default) and "failure"
+#invoker.buildResult=success
+
+# A boolean value controlling the -N flag, defaults to "false"
+#invoker.nonRecursive=false
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/pom.xml
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/pom.xml (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/pom.xml 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,155 @@
+<?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.nuiton</groupId>
+ <artifactId>eugene</artifactId>
+ <version>@pom.version@</version>
+ </parent>
+
+ <groupId>org.nuiton.test</groupId>
+ <artifactId>eugene-test-modelreader</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>eugene</artifactId>
+ <version>${project.version}</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>EUGene :: Test</name>
+ <description>Test module for generators.</description>
+ <inceptionYear>2007</inceptionYear>
+
+ <contributors>
+ <contributor>
+ <name>Florian Desbois</name>
+ <email>fdesbois(a)codelutin.com</email>
+ <timezone>+2</timezone>
+ <roles>
+ <role>Developpeur</role>
+ </roles>
+ </contributor>
+ </contributors>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.nuiton.processor</groupId>
+ <artifactId>maven-processor-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <includes>**/*.java</includes>
+ <filters>
+ org.nuiton.processor.filters.GeneratorTemplatesFilter
+ </filters>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>maven-eugene-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <id>Test Regression Generator</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <reader>org.nuiton.eugene.ObjectModelReader</reader>
+ <includes>dtotest.objectmodel</includes>
+ <templates>org.nuiton.eugene.test.generator.BeanGenerator</templates>
+ <defaultPackage>org.nuiton.eugene.test</defaultPackage>
+ <extraClassPathDirectory>target/classes</extraClassPathDirectory>
+ <generateResources>
+ <input>src/main/models</input>
+ </generateResources>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>Test Java Generator</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <reader>org.nuiton.eugene.test.generator.TestReader</reader>
+ <templates>org.nuiton.eugene.java.JavaGenerator</templates>
+ <defaultPackage>org.nuiton.eugene.test</defaultPackage>
+ <extraClassPathDirectory>target/classes</extraClassPathDirectory>
+ <generateResources>
+ <input>src/main/models</input>
+ </generateResources>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>Test Bean Transformer</id>
+ <phase>generate-test-sources</phase>
+ <configuration>
+ <reader>org.nuiton.eugene.ObjectModelReader</reader>
+ <includes>dtotest2.objectmodel</includes>
+ <templates>org.nuiton.eugene.test.generator.BeanTransformer</templates>
+ <defaultPackage>org.nuiton.eugene.test</defaultPackage>
+ <extraClassPathDirectory>target/classes</extraClassPathDirectory>
+ <generateResources>
+ <input>src/main/models</input>
+ </generateResources>
+ </configuration>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
+</project>
+
+
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,621 @@
+/* *##%
+ * EUGene Test
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * 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>.
+ * ##%*/
+
+/* *
+* BeanGenerator.java
+*
+* Created: 17 avril 2009
+*
+* @author tony Chemit <chemit(a)codelutin.com>
+* @version $Revision$
+*
+* Mise a jour: $Date$
+* par : $Author: chemit $
+*/
+
+package org.nuiton.eugene.test.generator;
+
+import org.apache.commons.lang.StringUtils;
+import static org.nuiton.eugene.test.generator.TopiaGeneratorUtil.TAG_ANNOTATION;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+
+import java.util.List;
+import java.util.Set;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.GeneratorUtil;
+import org.nuiton.eugene.ImportsManager;
+import org.nuiton.eugene.models.object.ObjectModelAttribute;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelClassifier;
+import org.nuiton.eugene.models.object.ObjectModelDependency;
+import org.nuiton.eugene.models.object.ObjectModelInterface;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+import org.nuiton.eugene.models.object.ObjectModelParameter;
+//import org.nuiton.topia.persistence.TopiaEntity;
+import static org.nuiton.eugene.test.generator.TopiaGeneratorUtil.isPrimitiveType;
+import static org.nuiton.eugene.test.generator.TopiaGeneratorUtil.isDateType;
+
+/**
+ * DTO generator
+ */
+public class BeanGenerator extends ObjectModelGenerator {
+
+ /**
+ * Logger for this class
+ */
+ private static final Log log = LogFactory.getLog(BeanGenerator.class);
+
+ public BeanGenerator() {
+ super();
+ }
+
+ @Override
+ public String getFilenameForClass(ObjectModelClass clazz) {
+ return clazz.getQualifiedName().replace('.', File.separatorChar) + ".java";
+ }
+
+ @Override
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_BEAN) &&
+ !clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
+ return;
+ }
+ //
+ // première phase : calcul des variables
+ //
+ String copyright = TopiaGeneratorUtil.getCopyright(model);
+ String clazzName = clazz.getName();
+ String abstractStr = isAbstract(clazz) ? " abstract " : " ";
+ boolean needGetEntityMethod = false;
+ boolean generateToString = TopiaGeneratorUtil.generateToString(clazz, model);
+
+ ImportsManager imports = new ImportsManager();
+
+ String extendClass = "";
+ Iterator<ObjectModelClass> j = clazz.getSuperclasses().iterator();
+ if (j.hasNext()) {
+ ObjectModelClassifier p = j.next();
+ imports.addImport(p.getQualifiedName());
+ extendClass += p.getName();
+ }
+ String implInterface = "";
+ for (Iterator<ObjectModelInterface> i=clazz.getInterfaces().iterator(); i.hasNext();) {
+ ObjectModelClassifier parentInterface = i.next();
+ imports.addImport(parentInterface.getQualifiedName());
+ implInterface += parentInterface.getName();
+ if (i.hasNext()) {
+ implInterface += ", ";
+ }
+ }
+ // Add Serializable implements for DTO generation
+ if (clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
+ imports.addImport(Serializable.class);
+ if (!implInterface.isEmpty()) {
+ implInterface += ", ";
+ }
+ implInterface += Serializable.class.getName();
+ }
+ String svUID = TopiaGeneratorUtil.findTagValue("dto-serialVersionUID", clazz, model);
+
+ List<ObjectModelAttribute> attributes = new ArrayList<ObjectModelAttribute>();
+ List<ObjectModelAttribute> multipleAttr = new ArrayList<ObjectModelAttribute>();
+
+ setAttributesForDTO(clazz, attributes,imports);
+
+ boolean needListInImport=false;
+
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
+ if (attr.isNavigable()) {
+ attributes.add(attr);
+ imports.addImport(attr.getType());
+ if (GeneratorUtil.isNMultiplicity(attr)) {
+ multipleAttr.add(attr);
+ ObjectModelClass attrEntity = null;
+ if (model.hasClass(attr.getType())) {
+ attrEntity = model.getClass(attr.getType());
+ }
+ boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY));
+ needGetEntityMethod |= isEntity;
+ if (attr.isOrdered()) {
+ needListInImport = true;
+ }
+ }
+ }
+ }
+
+ imports.addImport(java.beans.PropertyChangeListener.class.getName());
+ imports.addImport(java.beans.PropertyChangeSupport.class.getName());
+
+ for (ObjectModelOperation operation : clazz.getOperations()) {
+ imports.addImport(operation.getReturnType());
+ for (ObjectModelParameter parameter : operation.getParameters()) {
+ imports.addImport(parameter.getType());
+ }
+ }
+
+ if (needGetEntityMethod) {
+ imports.addImport("org.nuiton.topia.persistence.TopiaEntity");
+ }
+ if (!multipleAttr.isEmpty()) {
+ imports.addImport(Collection.class);
+ }
+ if (needListInImport) {
+ imports.addImport(List.class);
+ }
+ if (generateToString) {
+ imports.addImport(org.apache.commons.lang.builder.ToStringBuilder.class);
+ }
+
+ boolean sortAttribute = TopiaGeneratorUtil.sortAttribute(clazz, model);
+ if (sortAttribute) {
+ Comparator<ObjectModelAttribute> comp = new Comparator<ObjectModelAttribute>(){
+
+ @Override
+ public int compare(ObjectModelAttribute o1, ObjectModelAttribute o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ };
+ java.util.Collections.sort(attributes,comp);
+ java.util.Collections.sort(multipleAttr,comp);
+ }
+ //
+ // seconde phase : génération
+ //
+
+ if (TopiaGeneratorUtil.notEmpty(copyright)) {
+/*{<%=copyright%>
+}*/
+ }
+
+/*{package <%=clazz.getPackageName()%>;
+
+ }*/
+
+ if (log.isDebugEnabled()) {
+ log.debug("imports for class <" + clazzName + ">");
+ }
+ //for (String anImport : imports) {
+ for (String anImport : imports.getImports(clazz.getPackageName())) {
+ if (log.isDebugEnabled()) {
+ log.debug("import " + anImport);
+ }
+/*{import <%=anImport%>;
+}*/
+ }
+/*{
+public<%=abstractStr%>class <%=clazzName%>}*/
+
+/*
+ * Définition de la super classe : il ne doit y avoir qu'une
+ */
+ if (extendClass.length() > 0) {
+/*{ extends <%=extendClass%>}*/
+ }
+
+ if (implInterface.length() > 0) {
+/*{ implements <%=implInterface%> {
+
+}*/
+ } else {
+ /*{ {
+
+}*/
+ }
+
+
+ // TODO Calculer un serialVersionUID si il n'y en a pas
+ if (svUID != null) {
+/*{ public static final long serialVersionUID = <%=svUID%>;
+
+}*/
+ }
+ generateInterfaceOperations(output, clazz);
+ generateAttributes(output, attributes);
+/*{ protected final PropertyChangeSupport pcs;
+
+ /**
+ * Default constructor of <%=clazzName%>.
+ *)
+ public <%=clazzName%>() {
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+}*/
+ generateGetters(output, attributes);
+ generateSetters(output, attributes);
+ generateGetChild(output, multipleAttr);
+ generateAddChild(output, multipleAttr);
+ generateRemoveChild(output, multipleAttr);
+ if (generateToString) {
+ generateToString(output, clazz);
+ }
+ if (!multipleAttr.isEmpty()) {
+/*{
+
+ protected <T> T getChild(Collection<T> childs, int index) {
+ if (childs != null) {
+ int i = 0;
+ for (T o : childs) {
+ if (index == i) {
+ return o;
+ }
+ i++;
+ }
+ }
+ return null;
+ }
+
+ }*/
+ if (needGetEntityMethod) {
+/*{ protected <T extends TopiaEntity> T getEntity(Collection<T> childs, String topiaId) {
+ if (childs != null) {
+ for (T o : childs) {
+ if (topiaId.equals(o.getTopiaId())) {
+ return o;
+ }
+ }
+ }
+ return null;
+ }
+ }*/
+ }
+ }
+
+/*{
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+} //<%=clazz.getName()%>
+}*/
+ }
+
+ protected void generateAttributes(Writer output, List<ObjectModelAttribute> attributes) throws IOException {
+
+ for (ObjectModelAttribute attr : attributes) {
+
+ if (!(attr.isNavigable()
+ || attr.hasAssociationClass())) {
+ continue;
+ }
+
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+/*{ /**
+ * <%=attr.getDocumentation()%>
+ *)
+}*/
+ }
+ String annotation = attr.getTagValue(TAG_ANNOTATION);
+ if (annotation != null && annotation.length() > 0) {
+/*{ <%=annotation%>
+}*/
+ }
+ String attrName = attr.getName();
+ String attrVisibility = attr.getVisibility();
+ String attrType = attr.getType();
+ if (attr.hasAssociationClass()) {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ attrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
+ attrType = attr.getAssociationClass().getName();
+ }
+ int dot = attrType.lastIndexOf(".");
+ if (dot>-1) {
+ attrType = attrType.substring(dot + 1);
+ }
+ if (GeneratorUtil.isNMultiplicity(attr)) {
+ attrType = getCollection(attr, attrType);
+ }
+
+/*{ <%=attrVisibility%> <%=attrType%> <%=attrName%>;
+}*/
+ }
+ }
+
+ protected void generateGetters(Writer output, List<ObjectModelAttribute> attributes) throws IOException {
+ /*
+ * Définition des getteurs et setteurs
+ */
+ for (ObjectModelAttribute attr : attributes) {
+
+ if (!attr.isNavigable()) {
+ continue;
+ }
+
+ String attrName = attr.getName();
+ String attrType = attr.getType();
+ if (attr.hasAssociationClass()) {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ attrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
+ attrType = attr.getAssociationClass().getName();
+ }
+ String attrNameCapitalized = StringUtils.capitalize(attrName);
+ int dot = attrType.lastIndexOf(".");
+ if (dot>-1) {
+ attrType = attrType.substring(dot + 1);
+ }
+ if (GeneratorUtil.isNMultiplicity(attr)) {
+ attrType = getCollection(attr, attrType);
+ }
+/*{ public <%=attrType%> get<%=attrNameCapitalized%>() {
+ return <%=attrName%>;
+ }
+
+}*/
+ }
+ }
+
+ protected void generateSetters(Writer output, List<ObjectModelAttribute> attributes) throws IOException {
+ /*
+ * Définition des getteurs et setteurs
+ */
+ for (ObjectModelAttribute attr : attributes) {
+
+ if (!attr.isNavigable()) {
+ continue;
+ }
+
+ String attrName = attr.getName();
+ String attrType = attr.getType();
+
+ if (attr.hasAssociationClass()) {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ attrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
+ attrType = attr.getAssociationClass().getName();
+ }
+ String attrNameCapitalized = StringUtils.capitalize(attrName);
+ int dot = attrType.lastIndexOf(".");
+ if (dot>-1) {
+ attrType = attrType.substring(dot + 1);
+ }
+ if (GeneratorUtil.isNMultiplicity(attr)) {
+ attrType = getCollection(attr, attrType);
+ }
+/*{ public void set<%=attrNameCapitalized%>(<%=attrType%> newValue) {
+ <%=attrType%> oldValue = get<%=attrNameCapitalized%>();
+ this.<%=attrName%> = newValue;
+ firePropertyChange("<%=attrName%>", oldValue, newValue);
+ }
+
+}*/
+ }
+ }
+
+ protected void generateGetChild(Writer output, List<ObjectModelAttribute> multipleAttr) throws IOException {
+
+ for (ObjectModelAttribute attr : multipleAttr) {
+
+ String attrName = attr.getName();
+ String attrNameCapitalized = StringUtils.capitalize(attrName);
+ String attrType = attr.getType();
+ int dot = attrType.lastIndexOf(".");
+ if (dot>-1) {
+ attrType = attrType.substring(dot + 1);
+ }
+ ObjectModelClass attrEntity=null;
+ if (model.hasClass(attr.getType())) {
+ attrEntity = model.getClass(attr.getType());
+ }
+ boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY));
+/*{ public <%=attrType%> get<%=attrNameCapitalized%>(int index) {
+ <%=attrType%> o = getChild(<%=attrName%>, index);
+ return o;
+ }
+
+}*/
+ if (isEntity) {
+/*{ public <%=attrType%> get<%=attrNameCapitalized%>(String topiaId) {
+ <%=attrType%> o = getEntity(<%=attrName%>, topiaId);
+ return o;
+ }
+
+}*/
+ }
+ }
+ }
+ protected void generateAddChild(Writer output, List<ObjectModelAttribute> multipleAttr) throws IOException {
+ for (ObjectModelAttribute attr : multipleAttr) {
+
+ String attrName = attr.getName();
+ String attrNameCapitalized = StringUtils.capitalize(attrName);
+ String attrType = attr.getType();
+ int dot = attrType.lastIndexOf(".");
+ if (dot>-1) {
+ attrType = attrType.substring(dot + 1);
+ }
+/*{ public <%=attrType%> add<%=attrNameCapitalized%>(<%=attrType%> <%=attrName%>) {
+ get<%=attrNameCapitalized%>().add(<%=attrName%>);
+ firePropertyChange("<%=attrName%>", null, <%=attrName%>);
+ return <%=attrName%>;
+ }
+
+}*/
+ }
+ }
+
+ protected void generateRemoveChild(Writer output, List<ObjectModelAttribute> multipleAttr) throws IOException {
+ for (ObjectModelAttribute attr : multipleAttr) {
+ String attrName = attr.getName();
+ String attrNameCapitalized = StringUtils.capitalize(attrName);
+ String attrType = attr.getType();
+ int dot = attrType.lastIndexOf(".");
+ if (dot>-1) {
+ attrType = attrType.substring(dot + 1);
+ }
+/*{ public boolean remove<%=attrNameCapitalized%>(<%=attrType%> <%=attrName%>) {
+ boolean removed = get<%=attrNameCapitalized%>().remove(<%=attrName%>);
+ if (removed) {
+ firePropertyChange("<%=attrName%>", <%=attrName%>, null);
+ }
+ return removed;
+ }
+
+}*/
+ }
+ }
+
+ protected void generateInterfaceOperations(Writer output, ObjectModelClassifier classifier) throws IOException {
+ for (ObjectModelOperation op : classifier.getOperations()) {
+ String opName = op.getName();
+/*{ /**
+}*/
+ if (TopiaGeneratorUtil.hasDocumentation(op)) {
+ String opDocumentation = op.getDocumentation();
+/*{ * <%=opName%> : <%=opDocumentation%>
+}*/
+ }
+ Collection<ObjectModelParameter> params = op.getParameters();
+ for (ObjectModelParameter param : params) {
+ String paramName = param.getName();
+ String paramDocumentation = param.getDocumentation();
+/*{ * @param <%=paramName%> <%=paramDocumentation%>
+ }*/
+ }
+ String opVisibility = op.getVisibility();
+ String opType = op.getReturnType();
+/*{ *)
+ <%=opVisibility%> abstract <%=opType%> <%=opName%>(}*/
+ String comma = "";
+ for (ObjectModelParameter param : params) {
+ String paramName = param.getName();
+ String paramType = param.getType();
+/*{<%=comma%><%=paramType%> <%=paramName%>}*/
+ comma = ", ";
+ }
+/*{)}*/
+ Set<String> exceptions = op.getExceptions();
+ comma = " throws ";
+ for (String exception : exceptions) {
+/*{<%=comma%><%=exception%>}*/
+ comma = ", ";
+ }
+/*{;
+
+}*/
+ }
+ }
+ protected void generateToString(Writer output, ObjectModelClass clazz) throws IOException {
+/*{
+ @Override
+ public String toString() {
+ String result = new ToStringBuilder(this).
+}*/
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
+ if (!(attr.isNavigable() || attr.hasAssociationClass())) {
+ continue;
+ }
+ //FIXME possibilité de boucles (non directes)
+ String attrName = attr.getName();
+/*{ append("<%=attrName%>", this.<%=attrName%>).
+}*/
+ }
+/*{ toString();
+ return result;
+ }
+ }*/
+ }
+
+ protected String getCollection(ObjectModelAttribute attr, String attrType) {
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = "List<";
+ } else {
+ nMultType = "Collection<";
+ }
+ nMultType += attrType;
+ nMultType += ">";
+ return nMultType;
+ }
+
+ protected boolean isAbstract(ObjectModelClass clazz) {
+ if (clazz.isAbstract()) {
+ return true;
+ }
+ return !clazz.getOperations().isEmpty();
+ }
+
+ /**
+ * Dependecy gestion for DTO generation.
+ * All primitives attributes (and dates) of dependencies entities of the DTO are
+ * copied in the DTO. This method only prepare a list of attributes to be generated.
+ * @param clazz DTO ObjectModelClass
+ * @param attributes list of attributes for the generation (may be not empty)
+ * @param imports the ImportsManager used to generate the header imports of the DTO
+ * @return the same list of attributes in parameter with attributes from entities dependencies
+ * @see org.nuiton.eugene.ImportsManager
+ * @see org.nuiton.eugene.models.object.ObjectModelDependency
+ */
+ private List<ObjectModelAttribute> setAttributesForDTO(ObjectModelClass clazz,
+ List<ObjectModelAttribute> attributes, ImportsManager imports) {
+
+ if (clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
+ if (log.isInfoEnabled()) {
+ log.info("DTO dependency gestion");
+ }
+ for (ObjectModelDependency dependency : clazz.getDependencies()) {
+ ObjectModelClass supplier = (ObjectModelClass)dependency.getSupplier();
+
+ // ENTITY dependency
+ // Copy all primitives attributes from the Entity (supplier) to the DTO
+ // Prepare a list to future generation of all object generated attributes
+ if (supplier.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)) {
+ if (log.isInfoEnabled()) {
+ log.info("Create primitive and date fields in DTO from Entity : "
+ + supplier.getQualifiedName());
+ }
+ for (ObjectModelAttribute attr : supplier.getAttributes()) {
+ if (isPrimitiveType(attr) || isDateType(attr)) {
+ attributes.add(attr);
+ imports.addImport(attr.getType());
+ }
+ if (GeneratorUtil.isNMultiplicity(attr)) {
+ imports.addImport("java.util.Collection");
+ }
+ }
+ }
+ }
+ }
+ return attributes;
+ }
+} //BeanGenerator
Property changes on: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,341 @@
+/*
+ * *##%
+ * EUGene Test
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.eugene.test.generator;
+
+import org.apache.commons.lang.StringUtils;
+import org.nuiton.eugene.GeneratorUtil;
+import org.nuiton.eugene.java.ObjectModelTransformerToJava;
+import org.nuiton.eugene.models.object.*;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+/*{generator option: parentheses = false}*/
+
+/*{generator option: writeString = +}*/
+/**
+ * BeanTransformer
+ * <p/>
+ * Created: 28 oct. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author: fdesbois $
+ */
+public class BeanTransformer extends ObjectModelTransformerToJava {
+
+ public BeanTransformer() {
+ super();
+ }
+
+ @Override
+ public void transformFromClass(ObjectModelClass clazz) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_BEAN) &&
+ !clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
+ return;
+ }
+
+ ObjectModelClass resultClass;
+ if (!clazz.getOperations().isEmpty()) {
+ resultClass = createAbstractClass(clazz.getName(), clazz.getPackageName());
+ } else {
+ resultClass = createClass(clazz.getName(), clazz.getPackageName());
+ }
+
+ createForDTO(resultClass, clazz);
+
+ // Set superclass
+ Iterator<ObjectModelClass> j = clazz.getSuperclasses().iterator();
+ if (j.hasNext()) {
+ ObjectModelClass p = j.next();
+ setSuperClass(resultClass, p.getQualifiedName());
+ }
+
+ // Add interfaces from inputModel
+ for (ObjectModelInterface parentInterface : clazz.getInterfaces()) {
+ addInterface(resultClass, parentInterface.getQualifiedName());
+ }
+
+ createListeners(resultClass, clazz);
+
+ boolean hasEntity = false;
+ boolean hasMultipleAttribute = false;
+
+ // Add attributes with getter/setter
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
+
+ if (attr.isNavigable()/* || attr.hasAssociationClass()*/) {
+ String attrType = attr.getType();
+ String simpleType = GeneratorUtil.getSimpleName(attrType);
+ String attrName = attr.getName();
+ String attrNameCapitalized = StringUtils.capitalize(attrName);
+
+ // multiple attribute
+ if (GeneratorUtil.isNMultiplicity(attr)) {
+ hasMultipleAttribute = true;
+
+ // Add getChild
+ ObjectModelOperation getChild = addOperation(resultClass, "get" + attrNameCapitalized,
+ attrType, ObjectModelModifier.PUBLIC);
+ addParameter(getChild, "int", "index");
+ setOperationBody(getChild, ""
+ /*{
+ <%=simpleType%> o = getChild(<%=attrName%>, index);
+ return o;
+ }*/
+ );
+
+ // Add getEntity
+ ObjectModelClass attrEntity = null;
+ if (getModel().hasClass(attr.getType())) {
+ attrEntity = getModel().getClass(attr.getType());
+ }
+ boolean isEntity = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY));
+
+ if (isEntity) {
+ hasEntity = true;
+ ObjectModelOperation getChildEntity = addOperation(resultClass, "get" + attrNameCapitalized,
+ attrType, ObjectModelModifier.PUBLIC);
+ addParameter(getChildEntity, String.class.getName(), "topiaId");
+ setOperationBody(getChildEntity, ""
+ /*{
+ <%=simpleType%> o = getEntity(<%=attrName%>, topiaId);
+ return o;
+ }*/
+ );
+ }
+
+ // Add addChild
+ ObjectModelOperation addChild = addOperation(resultClass, "add" + attrNameCapitalized,
+ attrType, ObjectModelModifier.PUBLIC);
+ addParameter(addChild, attrType, attrName);
+ setOperationBody(addChild, ""
+
+ /*{
+ get<%=attrNameCapitalized%>().add(<%=attrName%>);
+ firePropertyChange("<%=attrName%>", null, <%=attrName%>);
+ return <%=attrName%>;
+ }*/
+ );
+
+ // Add removeChild
+ ObjectModelOperation removeChild = addOperation(resultClass, "remove" + attrNameCapitalized,
+ "boolean", ObjectModelModifier.PUBLIC);
+ addParameter(removeChild, attrType, attrName);
+ setOperationBody(removeChild, ""
+
+ /*{
+ boolean removed = get<%=attrNameCapitalized%>().remove(<%=attrName%>);
+ if (removed) {
+ firePropertyChange("<%=attrName%>", <%=attrName%>, null);
+ }
+ return removed;
+ }*/
+ );
+
+ // Change type for Multiple attribute
+ if (attr.isOrdered()) {
+ attrType = List.class.getName() + "<" + attrType + ">";
+ } else {
+ attrType = Collection.class.getName() + "<" + attrType + ">";
+ }
+ simpleType = GeneratorUtil.getSimpleName(attrType);
+ }
+
+ if (attr.hasAssociationClass()) {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ attrName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
+ attrType = attr.getAssociationClass().getName();
+ }
+
+ // Add attribute
+ String visibility = attr.getVisibility();
+ addAttribute(resultClass, attrName, attrType, "", ObjectModelModifier.toValue(visibility));
+
+ // Add getter
+ ObjectModelOperation getter = addOperation(resultClass, "get" + attrNameCapitalized, attrType,
+ ObjectModelModifier.PUBLIC);
+ setOperationBody(getter, ""
+ /*{
+ return this.<%=attrName%>;
+ }*/
+ );
+
+ // Add setter
+ ObjectModelOperation setter = addOperation(resultClass, "set" + attrNameCapitalized, "void",
+ ObjectModelModifier.PUBLIC);
+ addParameter(setter, attrType, "newValue");
+ setOperationBody(setter, ""
+ /*{
+ <%=simpleType%> oldValue = get<%=attrNameCapitalized%>();
+ this.<%=attrName%> = newValue;
+ firePropertyChange("<%=attrName%>", oldValue, newValue);
+ }*/
+ );
+
+ }
+ }
+
+ // Add helper methods
+ if (hasMultipleAttribute) {
+ ObjectModelOperation getChild = addOperation(resultClass, "getChild", "<T> T",
+ ObjectModelModifier.PROTECTED);
+ addParameter(getChild, "java.util.Collection<T>", "childs");
+ addParameter(getChild, "int", "index");
+ setOperationBody(getChild, ""
+ /*{
+ if (childs != null) {
+ int i = 0;
+ for (T o : childs) {
+ if (index == i) {
+ return o;
+ }
+ i++;
+ }
+ }
+ return null;
+ }*/
+ );
+ }
+
+ if (hasEntity) {
+ ObjectModelOperation getEntity = addOperation(resultClass, "getEntity",
+ "<T extends org.nuiton.topia.persistence.TopiaEntity> T", ObjectModelModifier.PROTECTED);
+ addParameter(getEntity, "java.util.Collection<T>", "childs");
+ addParameter(getEntity, "java.lang.String", "topiaId");
+ setOperationBody(getEntity, ""
+ /*{
+ if (childs != null) {
+ for (T o : childs) {
+ if (topiaId.equals(o.getTopiaId())) {
+ return o;
+ }
+ }
+ }
+ return null;
+ }*/
+ );
+ }
+
+ // Add operations
+ for (ObjectModelOperation op : clazz.getOperations()) {
+ String visibility = op.getVisibility();
+ ObjectModelOperation resultOperation = addOperation(resultClass, op.getName(), op.getReturnType(),
+ ObjectModelModifier.toValue(visibility), ObjectModelModifier.ABSTRACT);
+
+ for (ObjectModelParameter param : op.getParameters()) {
+ addParameter(resultOperation, param.getType(), param.getName());
+ }
+
+ for (String exception : op.getExceptions()) {
+ addException(resultOperation, exception);
+ }
+ }
+
+
+ }
+
+ private void createForDTO(ObjectModelClass resultClass, ObjectModelClass inputClass) {
+
+ // Add Serializable implements for DTO generation
+ if (inputClass.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
+ addInterface(resultClass, "java.io.Serializable");
+ }
+
+ String svUID = TopiaGeneratorUtil.findTagValue("dto-serialVersionUID", inputClass, getModel());
+ if (svUID != null) {
+ addConstant(resultClass, "serialVersionUID", "long", svUID, ObjectModelModifier.PUBLIC);
+ }
+ }
+
+ protected void createListeners(ObjectModelClass resultClass, ObjectModelClass inputClass) {
+
+ addAttribute(resultClass, "pcs", "java.beans.PropertyChangeSupport", "",
+ ObjectModelModifier.PROTECTED, ObjectModelModifier.FINAL);
+
+ // Default constructor
+ ObjectModelOperation constructor = addConstructor(resultClass, ObjectModelModifier.PUBLIC);
+ setOperationBody(constructor, ""
+ /*{
+ pcs = new PropertyChangeSupport(this);
+ }*/
+ );
+
+ // Add PropertyListener
+ String propType = "java.beans.PropertyChangeListener";
+ String strType = String.class.getName();
+ String objectType = Object.class.getName();
+
+ ObjectModelOperation addPropertyChangeListener = addOperation(resultClass,
+ "addPropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
+ addParameter(addPropertyChangeListener, propType, "listener");
+ setOperationBody(addPropertyChangeListener, ""
+ /*{
+ pcs.addPropertyChangeListener(listener);
+ }*/
+ );
+
+ ObjectModelOperation addPropertyChangeListenerPlus = addOperation(resultClass,
+ "addPropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
+ addParameter(addPropertyChangeListenerPlus, strType, "propertyName");
+ addParameter(addPropertyChangeListenerPlus, propType, "listener");
+ setOperationBody(addPropertyChangeListenerPlus, ""
+ /*{
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }*/
+ );
+
+ ObjectModelOperation removePropertyChangeListener = addOperation(resultClass,
+ "removePropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
+ addParameter(removePropertyChangeListener, propType, "listener");
+ setOperationBody(removePropertyChangeListener, ""
+ /*{
+ pcs.removePropertyChangeListener(listener);
+ }*/
+ );
+
+ ObjectModelOperation removePropertyChangeListenerPlus = addOperation(resultClass,
+ "removePropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
+ addParameter(removePropertyChangeListenerPlus, strType, "propertyName");
+ addParameter(removePropertyChangeListenerPlus, propType, "listener");
+ setOperationBody(removePropertyChangeListenerPlus, ""
+ /*{
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }*/
+ );
+
+ ObjectModelOperation firePropertyChange = addOperation(resultClass,
+ "firePropertyChange", "void", ObjectModelModifier.PROTECTED);
+ addParameter(firePropertyChange, strType, "propertyName");
+ addParameter(firePropertyChange, objectType, "oldValue");
+ addParameter(firePropertyChange, objectType, "newValue");
+ setOperationBody(firePropertyChange, ""
+ /*{
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }*/
+ );
+ }
+
+
+}
Property changes on: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/BeanTransformer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/Megatron.java
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/Megatron.java (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/Megatron.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,40 @@
+package org.nuiton.eugene.test.generator;
+
+import org.nuiton.eugene.java.ObjectModelTransformerToJava;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+
+/**
+ * Megatron
+ *
+ * Chainage des transformer : Modele de depart -> transformation dans BeanTransformer = modele d'entrée de Megatron
+ *
+ * Created: 12 nov. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class Megatron extends ObjectModelTransformerToJava {
+
+ public Megatron() {
+ super();
+ }
+
+ /*
+ CAS modele de sortie vide : modele d'entree transformee par BeanTransformer
+ */
+ @Override
+ protected ObjectModelTransformerToJava initPreviousTransformer() {
+ return new BeanTransformer();
+ }
+
+ @Override
+ public void transformFromClass(ObjectModelClass clazz) {
+
+
+
+ }
+
+}
Property changes on: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/Megatron.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestBuilder.java
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestBuilder.java (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestBuilder.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,93 @@
+/*
+ * *##%
+ * EUGene Test
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+
+package org.nuiton.eugene.test.generator;
+
+import org.nuiton.eugene.java.JavaBuilder;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelModifier;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+
+/*{generator option: parentheses = false}*/
+/*{generator option: writeString = +}*/
+/**
+ * TestBuilder
+ *
+ * Created: 25 oct. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author: fdesbois $
+ */
+public class TestBuilder extends JavaBuilder {
+
+ public TestBuilder() {
+ super("TestModel");
+ }
+
+ //@Override
+ public void build() {
+ createRole();
+ createPerson();
+ }
+
+ private void createRole() {
+ ObjectModelClass roleClass = createClass("Role", "org.chorem.bonzoms");
+
+ addAttribute(roleClass, "name", "java.lang.String");
+
+ //this.addImportForClassifier(roleClass, Date.class);
+ addAttribute(roleClass, "fromDate", "java.util.Date");
+ addAttribute(roleClass, "thruDate", "java.util.Date");
+ }
+
+ private void createPerson() {
+ ObjectModelClass personneClass = createClass("Person", "org.chorem.bonzoms");
+
+ addAttribute(personneClass, "lastName", "java.lang.String");
+ addAttribute(personneClass, "firstName", "java.lang.String", "\"2.0\"");
+
+ //this.addImportForClassifier(personneClass, List.class);
+ addAttribute(personneClass, "roles", "java.util.List<org.chorem.bonzoms.Role>",
+ "new java.util.ArrayList<org.chorem.bonzoms.Role>()");
+
+
+ ObjectModelOperation setLastName = addOperation(personneClass, "setLastName", "void",
+ ObjectModelModifier.PUBLIC);
+ addParameter(setLastName, "java.lang.String", "lastName");
+ setOperationBody(setLastName, ""
+ /*{
+ this.lastName = lastName;
+ }*/
+ );
+
+ ObjectModelOperation getLastName = addOperation(personneClass, "getLastName", "java.lang.String",
+ ObjectModelModifier.PUBLIC);
+ setOperationBody(getLastName, ""
+ /*{
+ return this.lastName;
+ }*/
+ );
+ }
+
+}
Property changes on: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestReader.java
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestReader.java (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestReader.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,51 @@
+/*
+ * *##%
+ * EUGene Test
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+
+package org.nuiton.eugene.test.generator;
+
+import java.io.File;
+import org.nuiton.eugene.ModelReader;
+import org.nuiton.eugene.models.object.ObjectModel;
+
+/**
+ * TestReader
+ *
+ * Created: 27 oct. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author: fdesbois $
+ */
+public class TestReader extends ModelReader<ObjectModel> {
+
+
+ @Override
+ public ObjectModel read(File[] file) {
+ TestBuilder builder = new TestBuilder();
+
+ builder.build();
+
+ return builder.getModel();
+ }
+
+}
Property changes on: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TestReader.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TopiaGeneratorUtil.java
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TopiaGeneratorUtil.java (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TopiaGeneratorUtil.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,948 @@
+/* *##%
+ * EUGene Test
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*/
+/*******************************************************************************
+ * GeneratorUtil.java
+ *
+ * Created: 13 déc. 2005
+ *
+ * @author Arnaud Thimel <thimel(a)codelutin.com>
+ *
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$ par : $Author: tchemit $
+ */
+package org.nuiton.eugene.test.generator;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
+import org.nuiton.eugene.Template;
+import org.nuiton.eugene.GeneratorUtil;
+import org.nuiton.eugene.models.Model;
+import org.nuiton.eugene.models.object.ObjectModel;
+import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
+import org.nuiton.eugene.models.object.ObjectModelAttribute;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelElement;
+import org.nuiton.eugene.models.object.ObjectModelInterface;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+import org.nuiton.eugene.models.object.ObjectModelParameter;
+
+/** Classe regroupant divers méthodes utiles pour la génération des entités */
+public class TopiaGeneratorUtil extends GeneratorUtil {
+
+ /** Stéréotype pour les interfaces devant être générées sous forme de facades */
+ public final static String STEREOTYPE_FACADE = "facade";
+ /** Stéréotype pour les objets devant être générées sous forme d'entités */
+ public static final String STEREOTYPE_ENTITY = "entity";
+ /** Stéréotype pour les objets devant être générées sous forme de DTO */
+ public static final String STEREOTYPE_DTO = "dto";
+ /** Stéréotype pour les objets devant être générées sous forme de bean */
+ public static final String STEREOTYPE_BEAN = "bean";
+ /**
+ * Stéréotype pour les interfaces devant être générées sous forme de
+ * services
+ */
+ public static final String STEREOTYPE_SERVICE = "service";
+ /** Stéréotype pour les interfaces devant être générées sous forme de DAO */
+ public static final String STEREOTYPE_DAO = "dao";
+ /** Stéréotype pour les attributs à indexer en base */
+ public static final String STEREOTYPE_INDEXED = "indexed";
+ /** Stéréotype pour les collections avec unicité */
+ public static final String STEREOTYPE_UNIQUE = "unique";
+ /** Stéréotype pour les attributs étant des clés primaires */
+ public static final String STEREOTYPE_PRIMARYKAY = "primaryKey";
+ /** Tag pour le type de persistence */
+ public static final String TAG_PERSISTENCE_TYPE = "persistenceType";
+ /** Tag pour le nom du champ / entité en BD */
+ public static final String TAG_DB_NAME = "dbName";
+ /** Tag pour le nom du schema en BD */
+ public static final String TAG_SCHEMA_NAME = "dbSchema";
+ /** Tag pour la taille du champ en BD */
+ public static final String TAG_LENGTH = "length";
+ /** Tag pour ajouter une annotation à un champ */
+ public static final String TAG_ANNOTATION = "annotation";
+ /** Tag pour ajouter specifier le copyright d'un fichier */
+ public static final String TAG_COPYRIGHT = "copyright";
+ /** Tag pour specfier le type d'acces a un champ */
+ public static final String TAG_ACCESS = "access";
+ /** Tag pour specfier si on doit générer i18n */
+ public static final String TAG_I18N_PREFIX = "i18n";
+ /** Tag pour ajouter un attribut dans une clef métier */
+ public static final String TAG_NATURAL_ID = "naturalId";
+ /** Tag pour specifier si une clef metier est mutable */
+ public static final String TAG_NATURAL_ID_MUTABLE = "naturalIdMutable";
+ /** Tag pour spécifier la caractèrelazy d'une association multiple */
+ public static final String TAG_LAZY = "lazy";
+ /** Tag pour spécifier la caractère fetch d'une association multiple */
+ public static final String TAG_FETCH = "fetch";
+ /** Tag pour spécifier la caractère order-by d'une association multiple */
+ public static final String TAG_ORDER_BY = "orderBy";
+ /** Tag pour spécifier la caractère not-null d'un attribut */
+ public static final String TAG_NOT_NULL = "notNull";
+ /** Tag pour spécifier la caractère embed-xml d'une association */
+ public static final String TAG_EMBED_XML = "embedXml";
+ /**
+ * Tag pour configurer l'interface du proxy sur autre chose que l'implementation par defaut.
+ *
+ * Par defaut :
+ * null > generere le proxy sur l'interface de l'implementation
+ * Autre valeur :
+ * "none" > laisse la configuration par defaut d'hibernate
+ */
+ public static final String TAG_PROXY_INTERFACE = "hibernateProxyInterface";
+ /** Tag pour spécifier le permissions à la création */
+ public static final String TAG_SECURITY_CREATE = "securityCreate";
+ /** Tag pour spécifier le permissions au chargement */
+ public static final String TAG_SECURITY_LOAD = "securityLoad";
+ /** Tag pour spécifier le permissions à la mise à jour */
+ public static final String TAG_SECURITY_UPDATE = "securityUpdate";
+ /** Tag pour spécifier le permissions à la suppression */
+ public static final String TAG_SECURITY_DELETE = "securityDelete";
+ /** Tag pour specifier de ne pas generer la methode toString */
+ public static final String TAG_NOT_GENERATE_TO_STRING = "notGenerateToString";
+ /** Tag pour specifier de trier les attributs par nom lors de la generation */
+ public static final String TAG_SORT_ATTRIBUTE = "sortAttribute";
+ /** Tag pour specfier si on doit générer la methode getOperator dans les daohelpers )*/
+ public static final String TAG_GENERATE_OPERATOR_FOR_DAO_HELPER = "generateOperatorForDAOHelper";
+ /** 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(Template generator) {
+ String packageName = generator.getProperty(PROPERTY_DEFAULT_PACKAGE);
+ if (packageName == null || "".equals(packageName)) {
+ packageName = DEFAULT_PACKAGE;
+ }
+ return packageName;
+ }
+
+// /**
+// * @see GeneratorUtil#hasDocumentation
+// * @deprecated
+// */
+// @Deprecated
+// public static boolean hasDocumentation(ObjectModelElement element) {
+// return notEmpty(element.getDocumentation());
+// }
+
+// /**
+// * @see GeneratorUtil#notEmpty
+// * @deprecated
+// */
+// @Deprecated
+// 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 GeneratorUtil.findTagValue(TAG_I18N_PREFIX, 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 boolean shouldgenerateOperatorForDAOHelper(ObjectModelElement element,
+ ObjectModel model) {
+ String tagValue = GeneratorUtil.findTagValue(TAG_GENERATE_OPERATOR_FOR_DAO_HELPER, element, model);
+ boolean generate = GeneratorUtil.notEmpty(tagValue) && Boolean.valueOf(tagValue);
+ return generate;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
+ *
+ * @param clazz la classe à tester
+ * @param model le modele
+ * @return la liste des attributs de la clef métier ou null si pas de clef métier.
+ */
+ public static boolean generateToString(ObjectModelClass clazz,
+ ObjectModel model) {
+ String value;
+ value = model.getTagValue(TAG_NOT_GENERATE_TO_STRING);
+ if (value != null && !value.trim().isEmpty()) {
+ return false;
+ }
+ value = clazz.getTagValue(TAG_NOT_GENERATE_TO_STRING);
+ if (value != null && !value.trim().isEmpty()) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Cherche et renvoie la liste des attributs constituant la clef metier d'une classe.
+ *
+ * @param clazz la classe à tester
+ * @param model le modele
+ * @return la liste des attributs de la clef métier ou null si pas de clef métier.
+ */
+ public static boolean sortAttribute(ObjectModelClass clazz,
+ ObjectModel model) {
+ String value;
+ value = clazz.getTagValue(TAG_SORT_ATTRIBUTE);
+ if (value == null || value.trim().isEmpty() || "false".equals(value.trim())) {
+ return false;
+ }
+ if (value != null && "true".equals(value.trim())) {
+ return true;
+ }
+
+ value = model.getTagValue(TAG_SORT_ATTRIBUTE);
+ if (value == null || value.trim().isEmpty() || "false".equals(value.trim())) {
+ return false;
+ }
+ if (value != null && "true".equals(value.trim())) {
+ return true;
+ }
+ return true;
+ }
+
+ /**
+ * Detecte si un attribut fait partie d'une clef metier.
+ *
+ * @param attribute l'attribut à tester
+ * @return <code>true</code> si l'attribut fait partie d'une clef metier, <code>false</cdoe> sinon.
+ */
+ public static boolean isNaturalId(ObjectModelAttribute attribute) {
+ String value = attribute.getTagValue(TAG_NATURAL_ID);
+ if (!GeneratorUtil.notEmpty(value)) {
+ // valeur null, donc pas positionnee
+ return false;
+ }
+ try {
+ return Boolean.valueOf(value.trim());
+ } catch (Exception e) {
+ // on a pas reussi a convertir en boolean.
+ //todo peut-être declancher une exception ?
+ return false;
+ }
+ }
+
+ /**
+ * Cherches et renvoie le copyright a utiliser sur le model.
+ *
+ * @param model le modele utilisé
+ * @return le texte du copyright ou null
+ */
+ public static String getCopyright(Model model) {
+ return findTagValue(TAG_COPYRIGHT, null, model);
+ }
+
+// /**
+// * @see GeneratorUtil#findTagValue
+// * @deprecated
+// */
+// @Deprecated
+// public static String findTagValue(String tagName,
+// ObjectModelElement element, Model model) {
+// if (element == null) {
+// if (model != null) {
+// if (notEmpty(model.getTagValue(tagName))) {
+// return model.getTagValue(tagName);
+// }
+// }
+// return null;
+// }
+// if (notEmpty(element.getTagValue(tagName))) {
+// return element.getTagValue(tagName);
+// }
+// //On va chercher sur l'element declarant
+// return findTagValue(tagName, element.getDeclaringElement(), model);
+// }
+
+ public static <Type extends ObjectModelElement> Collection<Type> getElementsWithStereotype(
+ Collection<Type> elements, String... stereotypes) {
+ Collection<Type> result = new ArrayList<Type>();
+ for (Type element : elements) {
+ if (hasStereotypes(element, stereotypes)) {
+ result.add(element);
+ }
+ }
+ return result;
+ }
+
+ public static boolean hasStereotypes(ObjectModelElement element,
+ String... stereotypes) {
+ for (String stereotype : stereotypes) {
+ if (!element.hasStereotype(stereotype)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static String getPrimaryKeyAttributesListDeclaration(
+ ObjectModelClass clazz, boolean includeName) {
+ String attributes = "";
+ for (ObjectModelAttribute attr : getElementsWithStereotype(clazz.getAttributes(), STEREOTYPE_PRIMARYKAY)) {
+ attributes += attr.getType();
+ if (includeName) {
+ attributes += " " + attr.getName();
+ }
+ attributes += ", ";
+ }
+ if (attributes.length() > 0) {
+ attributes = attributes.substring(0, attributes.length() - 2);
+ }
+ return attributes;
+ }
+
+// public static String capitalize(String s) {
+// return StringUtils.capitalize(s);
+// }
+
+ public static boolean isAssociationClassDoublon(ObjectModelAttribute attr) {
+ return (attr.getReverseAttribute() != null) && (attr.getDeclaringElement().equals(attr.getReverseAttribute().getDeclaringElement())) && (!GeneratorUtil.isFirstAttribute(attr));
+ }
+
+ /**
+ * Renvoie le nom de l'attribut de classe d'association en fonction des cas:
+ * Si l'attribut porte le même nom que le type (extrémité inverse de
+ * l'association), on lui ajoute le nom de la classe d'association
+ *
+ * @param attr l'attribut a traiter
+ * @return le nom de l'attribut de classe d'association
+ */
+ public static String getAssocAttrName(ObjectModelAttribute attr) {
+ String typeName = attr.getType().substring(
+ attr.getType().lastIndexOf(".") + 1);
+ String result = attr.getName();
+ if (attr.getName().equalsIgnoreCase(typeName)) {
+ result += StringUtils.capitalize(attr.getAssociationClass().getName());
+ }
+ return result;
+ }
+
+ public static String getDOType(ObjectModelElement elem, ObjectModel model) {
+ String type = elem.getName();
+ if (elem instanceof ObjectModelAttribute) {
+ type = ((ObjectModelAttribute) elem).getType();
+ }
+ if (elem instanceof ObjectModelClass) {
+ type = ((ObjectModelClass) elem).getQualifiedName();
+ }
+ return getDOType(type, model);
+ }
+
+ public static String getDOType(String type, ObjectModel model) {
+ if (!model.hasClass(type)) {
+ return type;
+ }
+ ObjectModelClass clazz = model.getClass(type);
+ if (clazz.hasStereotype(STEREOTYPE_ENTITY)) {
+ if (shouldBeAbstract(clazz)) {
+ type += "Abstract";
+ } else {
+ type += "Impl";
+ }
+ }
+ return type;
+ }
+ private static final Set<String> numberTypes = new HashSet<String>();
+ private static final Set<String> textTypes = new HashSet<String>();
+ private static final Set<String> booleanTypes = new HashSet<String>();
+ private static final Set<String> primitiveTypes = new HashSet<String>();
+ private static final String VOID_TYPE = "void";
+
+ static {
+ numberTypes.add("byte");
+ numberTypes.add("java.lang.Byte");
+ numberTypes.add("Byte");
+ numberTypes.add("short");
+ numberTypes.add("java.lang.Short");
+ numberTypes.add("Short");
+ numberTypes.add("int");
+ numberTypes.add("java.lang.Integer");
+ numberTypes.add("Integer");
+ numberTypes.add("long");
+ numberTypes.add("java.lang.Long");
+ numberTypes.add("Long");
+ numberTypes.add("float");
+ numberTypes.add("java.lang.Float");
+ numberTypes.add("Float");
+ numberTypes.add("double");
+ numberTypes.add("java.lang.Double");
+ numberTypes.add("Double");
+
+ textTypes.add("char");
+ textTypes.add("java.lang.Char");
+ textTypes.add("Char");
+ textTypes.add("java.lang.String");
+ textTypes.add("String");
+
+ booleanTypes.add("boolean");
+ booleanTypes.add("java.lang.Boolean");
+ booleanTypes.add("Boolean");
+
+ primitiveTypes.addAll(numberTypes);
+ primitiveTypes.addAll(textTypes);
+ primitiveTypes.addAll(booleanTypes);
+ }
+
+ public static boolean isNumericType(ObjectModelAttribute attr) {
+ return numberTypes.contains(attr.getType());
+ }
+
+ public static boolean isTextType(ObjectModelAttribute attr) {
+ return textTypes.contains(attr.getType());
+ }
+
+ public static boolean isDateType(ObjectModelAttribute attr) {
+ return "java.util.Date".equals(attr.getType());
+ }
+
+ public static boolean isBooleanType(ObjectModelAttribute attr) {
+ return booleanTypes.contains(attr.getType());
+ }
+
+ public static boolean isPrimitiveType(ObjectModelAttribute attr) {
+ return primitiveTypes.contains(attr.getType());
+ }
+
+ /**
+ * Indique si la classe specifiee n'a aucune ou que des methodes abstraites
+ *
+ * @param clazz l'instance de ObjectModelClass
+ * @return true si la classe n'a que des operations abstraite ou aucune
+ * operation
+ */
+ public static boolean hasNothingOrAbstractMethods(ObjectModelClass clazz) {
+ boolean result = true;
+ Iterator<?> operations = clazz.getOperations().iterator();
+ while (result && operations.hasNext()) {
+ ObjectModelOperation op = (ObjectModelOperation) operations.next();
+ result = op.isAbstract();
+ }
+ return result;
+ }
+
+ /**
+ * Indique si la classe specifiee devrait etre abstraite
+ *
+ * @param clazz l'instance de ObjectModelClass
+ * @return true dans ce cas, false sinon
+ */
+ public static boolean shouldBeAbstract(ObjectModelClass clazz) {
+ return clazz != null && (clazz.isAbstract() && hasNothingOrAbstractMethods(clazz));
+ }
+
+ /**
+ * <p>
+ * Cette méthode permet de détecter si
+ * - l'attribut représente une relation 1-n
+ * - cette relation est unidirectionnelle
+ * - le type de l'attribut représente un entité
+ * - cette entité a des sous-classes dans le modèle
+ * <p/>
+ * Ce cas correspond à une incompatibilité d'Hibernate qui nous oblige a
+ * adopter un comportement particulier.
+ * </p>
+ *
+ * @param attr l'attribut a tester
+ * @param model le model
+ * @return true si et seulement si il s'agit bien de ce type de relation
+ */
+ public static boolean hasUnidirectionalRelationOnAbstractType(
+ ObjectModelAttribute attr, ObjectModel model) {
+ ObjectModelAttribute reverse = attr.getReverseAttribute();
+ //relation 1-n
+ if (reverse != null && isNMultiplicity(attr) && !isNMultiplicity(reverse)) {
+ //Pas de navigabilité
+ if (!reverse.isNavigable()) {
+ //Il s'agit d'une entity
+ ObjectModelClass clazz = model.getClass(attr.getType());
+ if (clazz != null && clazz.hasStereotype(STEREOTYPE_ENTITY)) {
+ //Cette classe a des sous-classes dans le modèle
+ for (ObjectModelClass subClass : model.getClasses()) {
+ if (subClass.getSuperclasses().contains(clazz)) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Renvoie le nom unique de table pour une relation ManyToMany en fonction
+ * de l'attribut <code>attr</code>
+ * <p/>
+ * Plusieurs cas de figure:
+ * <li>
+ *
+ * @param attr l'attribut servant de base au calcul du nom
+ * @return le nom de la table
+ */
+ public static String getManyToManyTableName(ObjectModelAttribute attr) {
+ String result;
+
+ if (attr.hasAssociationClass()) {
+ result = TopiaGeneratorUtil.getDBName(attr.getAssociationClass());
+ } else {
+ String name = attr.getName();
+ String revers = attr.getReverseAttributeName();
+
+ if (name.compareToIgnoreCase(revers) < 0) {
+ result = name + "_" + revers;
+ } else {
+ result = revers + "_" + name;
+ }
+ }
+ // String result;
+ // if (!Util.isFirstAttribute(attr)) {
+ // result = attr.getDeclaringElement().getName() + "_" + attr.getReverseAttribute().getDeclaringElement().getName();
+ // } else {
+ // result = attr.getReverseAttribute().getDeclaringElement().getName() + "_" + attr.getDeclaringElement().getName();
+ // }
+ return result.toLowerCase();
+ }
+
+ /**
+ * Renvoie le type d'interface à utiliser en fonction de l'attribut
+ *
+ * @param attr l'attribut a traiter
+ * @return String
+ */
+ public static String getNMultiplicityInterfaceType(ObjectModelAttribute attr) {
+ if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
+ return Set.class.getName();
+ } else if (attr.isIndexed() || attr.isOrdered()) {
+ return List.class.getName();
+ }
+ return Collection.class.getName();
+ }
+
+ /**
+ * Renvoie le type d'objet (instance) à utiliser en fonction de l'attribut
+ *
+ * @param attr l'attribut a traiter
+ * @return String
+ */
+ public static String getNMultiplicityObjectType(ObjectModelAttribute attr) {
+ if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
+ return HashSet.class.getName();
+ } else if (attr.isIndexed() || attr.isOrdered()) {
+ //On considère qu'on ne sait pas traiter vraiment l'attribut "ordered"
+ // puisqu'on va conserver l'ordre d'insertion, et non un ordre en
+ // fonction d'un élément donné. Donc on renvoi une ArrayList
+ return ArrayList.class.getName();
+ }
+ LinkedList.class.getName();
+ return ArrayList.class.getName();
+ }
+
+ /**
+ * Renvoie le type d'interface à utiliser en fonction de l'attribut
+ *
+ * @param attr l'attribut a traiter
+ * @return String
+ */
+ public static String getNMultiplicityHibernateType(ObjectModelAttribute attr) {
+ if (attr.hasStereotype(STEREOTYPE_UNIQUE)) {
+ return "set";
+ } else if (attr.isIndexed()) {
+ return "list";
+ }
+ //attr.isOrdered() - On génère le ordered en bag
+ return "bag";
+ }
+
+ /**
+ * Obtain the list of entities classes with the possibility to sort the result.
+ *
+ * @param model the current model to scan
+ * @param sort flag to allow sort the result
+ * @return the list of filtred classes by their stereotype
+ */
+ public static List<ObjectModelClass> getEntityClasses(ObjectModel model,
+ boolean sort) {
+ return getClassesByStereotype(STEREOTYPE_ENTITY, model, sort);
+ }
+
+ /**
+ * Obtain the list of classes for a given stereotype with the possibility to sort the result.
+ *
+ * @param stereotype filter stereotype
+ * @param model the current model to scan
+ * @param sort flag to allow sort the result
+ * @return the list of filtred classes by their stereotype
+ */
+ public static List<ObjectModelClass> getClassesByStereotype(
+ String stereotype, ObjectModel model, boolean sort) {
+ List<ObjectModelClass> classes = new ArrayList<ObjectModelClass>();
+ for (ObjectModelClass clazz : model.getClasses()) {
+ if (clazz.hasStereotype(stereotype)) {
+ classes.add(clazz);
+ }
+ }
+ if (sort && !classes.isEmpty()) {
+ java.util.Collections.sort(classes,
+ new java.util.Comparator<ObjectModelClass>() {
+
+ @Override
+ public int compare(ObjectModelClass o1,
+ ObjectModelClass o2) {
+ return o1.getQualifiedName().compareTo(
+ o2.getQualifiedName());
+ }
+ });
+ }
+ return classes;
+ }
+
+ /**
+ * Detecte si la clef metier d'une classe est mutable ou pas.
+ * <p/>
+ * On respecte la valeur par defaut d'hibernate, à savoir que par default une clef metier est non mutable.
+ *
+ * @param clazz la classe a tester
+ * @return <code>true</code> si le tag value a ete positionne sur la classe via le tag
+ * {@link #TAG_NATURAL_ID_MUTABLE}, , <code>false</code> sinon.
+ */
+ public static boolean isNaturalIdMutable(ObjectModelClass clazz) {
+ String value = clazz.getTagValue(TAG_NATURAL_ID_MUTABLE);
+ if (!notEmpty(value)) {
+ // valeur null, donc par default positionnee
+ return false;
+ }
+ try {
+ return Boolean.valueOf(value.trim());
+ } catch (Exception e) {
+ // on a pas reussi a convertir en boolean.
+ //todo peut-être declancher une exception ?
+ return false;
+ }
+ }
+
+ /**
+ * Obtain the list of fqn of object involed in the given class.
+ *
+ * @param aClass the clazz to inspect
+ * @param incomingFqns incoming fqns
+ * @return the list of fqn of attributes
+ */
+ public static List<String> getImports(ObjectModelClass aClass, String... incomingFqns) {
+ Set<String> tmp = new HashSet<String>();
+ tmp.addAll(Arrays.asList(incomingFqns));
+ getImports(aClass, tmp);
+ List<String> result = cleanImports(aClass.getPackageName(), tmp);
+ return result;
+ }
+
+ /**
+ * Obtain the list of fqn of object involed in the given interface.
+ *
+ * @param anInterface the interface to inspect
+ * @param incomingFqns incoming fqns
+ * @return the list of fqn of attributes
+ */
+ public static List<String> getImports(ObjectModelInterface anInterface, String... incomingFqns) {
+ Set<String> tmp = new HashSet<String>();
+ tmp.addAll(Arrays.asList(incomingFqns));
+ getImports(anInterface, tmp);
+ List<String> result = cleanImports(anInterface.getPackageName(), tmp);
+ return result;
+ }
+
+ public static String getSimpleName(String fqn) {
+ int lasIndex = fqn.lastIndexOf(".");
+ if (lasIndex == 1) {
+ // primitive type
+ return fqn;
+ }
+ return fqn.substring(lasIndex + 1);
+ /*if (lasIndex == aClass.getPackageName().length()) {
+ // same package
+ return fqn.substring(lasIndex + 1);
+ }
+
+ return fqn;*/
+ }
+
+ /**
+ * Obtain the list of fqn of object involed in the given class.
+ *
+ * @param aClass the class to inspect
+ * @param fqns where to store found fqns
+ */
+ protected static void getImports(ObjectModelClass aClass, Set<String> fqns) {
+ // scan attributes
+ for (ObjectModelAttribute attr : aClass.getAttributes()) {
+ fqns.add(attr.getType());
+ if (isNMultiplicity(attr)) {
+ String collectionType = getNMultiplicityInterfaceType(attr);
+ fqns.add(collectionType);
+ String collectionObject = getNMultiplicityObjectType(attr);
+ fqns.add(collectionObject);
+ }
+ }
+ for (ObjectModelAttribute attribute : aClass.getAllOtherAttributes()) {
+ fqns.add(attribute.getType());
+ }
+ // scan associations
+ if (aClass instanceof ObjectModelAssociationClass) {
+ ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) aClass;
+ for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
+ if (attr == null) {
+ continue;
+ }
+ fqns.add(attr.getType());
+ if (isNMultiplicity(attr)) {
+ String collectionType = getNMultiplicityInterfaceType(attr);
+ fqns.add(collectionType);
+ String collectionObject = getNMultiplicityObjectType(attr);
+ fqns.add(collectionObject);
+ }
+ }
+ }
+ // scan operations
+ for (ObjectModelOperation operation : aClass.getOperations()) {
+ getImports(operation, fqns);
+ }
+ // scan super interfaces
+ for (ObjectModelInterface modelInterface : aClass.getInterfaces()) {
+ fqns.add(modelInterface.getQualifiedName());
+ getImports(modelInterface, fqns);
+ }
+ // scan super classes
+ for (ObjectModelClass modelClass : aClass.getSuperclasses()) {
+ fqns.add(modelClass.getQualifiedName());
+ getImports(modelClass);
+ }
+ }
+
+ /**
+ * Obtain the list of fqn of object involed in the given interface.
+ *
+ * @param anInterface the interface to inspect
+ * @param fqns where to store found fqns
+ */
+ protected static void getImports(ObjectModelInterface anInterface, Set<String> fqns) {
+ // scan operations
+ for (ObjectModelOperation operation : anInterface.getOperations()) {
+ getImports(operation, fqns);
+ }
+ // scan super interfaces
+ for (ObjectModelInterface modelInterface : anInterface.getInterfaces()) {
+ fqns.add(modelInterface.getQualifiedName());
+ getImports(modelInterface, fqns);
+ }
+ }
+
+ /**
+ * Obtain the fqn's list of all involed type in a givne operation.
+ *
+ * @param operation operation to inspect
+ * @param fqns where to store found fqns
+ */
+ protected static void getImports(ObjectModelOperation operation, Set<String> fqns) {
+ String fqn = operation.getReturnType();
+ fqns.add(fqn);
+ for (ObjectModelParameter parameter : operation.getParameters()) {
+ fqns.add(parameter.getType());
+ }
+ }
+
+ /**
+ * Clean a set of fqns, transform it into a {@link List} and sort it.
+ *
+ * @param packageName the current package name
+ * @param fqns the dirty set of fqns
+ * @return the sorted cleaned list of fqns.
+ */
+ protected static List<String> cleanImports(String packageName, Set<String> fqns) {
+ fqns.removeAll(primitiveTypes);
+ fqns.remove(VOID_TYPE);
+ int packageLength = packageName.length();
+ List<String> genericType = new ArrayList<String>();
+ for (Iterator<String> it = fqns.iterator(); it.hasNext();) {
+ String fqn = it.next();
+ int lastIndex = fqn.lastIndexOf(".");
+ if (lastIndex == packageLength && fqn.startsWith(packageName)) {
+ // same package
+ it.remove();
+ continue;
+ }
+ int genericIndex = fqn.indexOf('<');
+ if (genericIndex != -1) {
+ genericType.add(fqn.substring(0, genericIndex));
+ it.remove();
+ }
+ }
+ fqns.addAll(genericType);
+
+ ArrayList<String> result = new ArrayList<String>(fqns);
+ java.util.Collections.sort(result);
+ return result;
+ }
+
+ /**
+ * Convertit un nom de variable en nom de constante.
+ *
+ * @param variableName le nom de variable a convertir
+ * @return le nom de la constante à partir du nom de la variable
+ */
+ public static String convertVariableNameToConstantName(String variableName) {
+ //TODO Faire des tests pour savoir si variableName est non null et valide
+ //TODO Ameliorer l'algo pour tenir compte des caractères non alpha
+ //TODO pour le moment cela convient, donc...
+ StringBuilder buffer = new StringBuilder();
+ boolean lastCarIsUp = false;
+ for (int i = 0, j = variableName.length(); i < j; i++) {
+ char c = variableName.charAt(i);
+ boolean carIsUp = Character.isUpperCase(c);
+ if (i > 0 && !lastCarIsUp && carIsUp) {
+ // ajout d'un _
+ buffer.append('_');
+ }
+ if (carIsUp) {
+ buffer.append(c);
+ } else {
+ buffer.append(Character.toUpperCase(c));
+ }
+ lastCarIsUp = carIsUp;
+ }
+ return buffer.toString();
+ }
+} // GeneratorUtil
+
Property changes on: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/java/org/nuiton/eugene/test/generator/TopiaGeneratorUtil.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/models/dtotest.objectmodel
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/models/dtotest.objectmodel (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/models/dtotest.objectmodel 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<objectModel xmlns="http://www.codelutin.org/eugene/objectModel" name="TopiaTest" version="1">
+ <class name="Personne" package="org.nuiton.eugene.test">
+ <stereotype name="entity"/>
+ <superclass name="org.nuiton.eugene.test.Party2" discriminator=""/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="otherNames" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="0" maxMultiplicity="-1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Address" reverseAttributeName="" associationType="aggregate" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Employe" package="org.nuiton.eugene.test">
+ <stereotype name="entity"/>
+ <superclass name="org.nuiton.eugene.test.Personne" discriminator=""/>
+ <attribute name="salary" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Company" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ <attribute name="lead" visibility="public" type="org.nuiton.eugene.test.Department" reverseAttributeName="leader" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Company" package="org.nuiton.eugene.test">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Employe" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" associationClassName="org.nuiton.eugene.test.Bill" type="org.nuiton.eugene.test.Store" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Department" reverseAttributeName="" associationType="composite" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Address" package="org.nuiton.eugene.test">
+ <stereotype name="entity"/>
+ <attribute name="city" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="adress" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Personne" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Department" package="org.nuiton.eugene.test">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="leader" visibility="public" type="org.nuiton.eugene.test.Employe" reverseAttributeName="lead" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Company" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Product" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Product" package="org.nuiton.eugene.test">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Department" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Type" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Store" package="org.nuiton.eugene.test">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="DEFAULT_NUM" associationType="composite" visibility="public" static="true" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="numStore" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <operation name="getDefaultNum" visibility="public" static="true">
+ <returnParameter type="java.lang.String"/>
+ </operation>
+ <class name="Row" package="org.nuiton.eugene.test">
+ <attribute name="num" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="position" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ </class>
+ <attribute visibility="public" associationClassName="org.nuiton.eugene.test.Bill" type="org.nuiton.eugene.test.Company" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="0" maxMultiplicity="-1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Type" package="org.nuiton.eugene.test">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Product" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="false" ordering="unordered"/>
+ </class>
+ <associationClass name="Bill" package="org.nuiton.eugene.test">
+ <stereotype name="entity"/>
+ <participant name="org.nuiton.eugene.test.Company" attribute=""/>
+ <participant name="org.nuiton.eugene.test.Store" attribute=""/>
+ <attribute name="cost" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="date" associationType="composite" visibility="public" type="java.util.Date" minMultiplicity="1" maxMultiplicity="1"/>
+ </associationClass>
+ <class name="Voiture" abstract="true" package="org.nuiton.eugene.test.beangen">
+ <stereotype name="bean"/>
+ <tagValue name="documentation" value="Doc for BeanA"/>
+ <attribute name="immatriculation" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1">
+ <tagValue name="documentation" value="attrA of BeanA"/>
+ </attribute>
+ <attribute name="modele" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="proprietaire" associationType="composite" visibility="public" type="org.nuiton.eugene.test.beangen.PersonneDTO" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.beangen.Roue" reverseAttributeName="" associationType="composite" reverseMaxMultiplicity="1" minMultiplicity="4" maxMultiplicity="4" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.beangen.Siege" reverseAttributeName="" associationType="composite" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="4" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Roue" package="org.nuiton.eugene.test.beangen">
+ <stereotype name="bean"/>
+ <operation name="mount" visibility="public">
+ <returnParameter type="void"/>
+ </operation>
+ <operation name="getModel" visibility="public">
+ <returnParameter type="int"/>
+ <parameter name="id" type="java.lang.String"/>
+ </operation>
+ <attribute visibility="public" type="org.nuiton.eugene.test.beangen.Voiture" reverseAttributeName="" reverseMaxMultiplicity="4" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="RelationDTO" package="org.nuiton.eugene.test.beangen">
+ <stereotype name="dto"/>
+ <attribute name="idCompany" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="idDepartement" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="dateDebut" associationType="composite" visibility="public" type="java.util.Date" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="person" visibility="public" type="org.nuiton.eugene.test.beangen.PersonneDTO" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="PersonneDTO" package="org.nuiton.eugene.test.beangen">
+ <dependency name="" supplierName="org.nuiton.eugene.test.Personne"/>
+ <stereotype name="dto"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.beangen.RelationDTO" reverseAttributeName="person" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Siege" package="org.nuiton.eugene.test.beangen">
+ <stereotype name="bean"/>
+ <attribute name="noSerie" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test.beangen.Voiture" reverseAttributeName="" reverseMaxMultiplicity="4" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <interface name="Vehicule" package="org.nuiton.eugene.test.beangen">
+ <operation name="start" visibility="public">
+ <returnParameter type="void"/>
+ </operation>
+ </interface>
+ <class name="Contact2" package="org.nuiton.eugene.test.deletetest">
+ <stereotype name="entity"/>
+ <attribute name="contactValue" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="type" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <operation name="findAllByCompany" visibility="public">
+ <returnParameter type="java.util.Set<Contact2>"/>
+ <parameter name="company" type="org.nuiton.eugene.test.Company"/>
+ <stereotype name="dao"/>
+ </operation>
+ <attribute visibility="public" type="org.nuiton.eugene.test.Party2" reverseAttributeName="contacts" reverseMaxMultiplicity="-1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Telephone2" package="org.nuiton.eugene.test.deletetest">
+ <stereotype name="entity"/>
+ <superclass name="org.nuiton.eugene.test.Contact2" discriminator=""/>
+ <attribute name="prefix" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="country" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ </class>
+ <class name="Party2" package="org.nuiton.eugene.test.deletetest">
+ <stereotype name="entity"/>
+ <attribute name="contacts" visibility="public" type="org.nuiton.eugene.test.Contact2" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Person" package="org.nuiton.topia.test.entities">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="firstname" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.topia.test.entities.Pet" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Pet" package="org.nuiton.topia.test.entities">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="type" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.topia.test.entities.Person" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.topia.test.entities.Race" reverseAttributeName="" associationType="composite" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Race" package="org.nuiton.topia.test.entities">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.topia.test.entities.Pet" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Set<Contact2>" package="java.util"/>
+</objectModel>
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/models/dtotest2.objectmodel
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/models/dtotest2.objectmodel (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/models/dtotest2.objectmodel 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<objectModel xmlns="http://www.codelutin.org/eugene/objectModel" name="TopiaTest" version="1">
+ <class name="Personne" package="org.nuiton.eugene.test2">
+ <stereotype name="entity"/>
+ <superclass name="org.nuiton.eugene.test2.Party2" discriminator=""/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="otherNames" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="0" maxMultiplicity="-1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Address" reverseAttributeName="" associationType="aggregate" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Employe" package="org.nuiton.eugene.test2">
+ <stereotype name="entity"/>
+ <superclass name="org.nuiton.eugene.test2.Personne" discriminator=""/>
+ <attribute name="salary" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Company" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ <attribute name="lead" visibility="public" type="org.nuiton.eugene.test2.Department" reverseAttributeName="leader" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Company" package="org.nuiton.eugene.test2">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Employe" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" associationClassName="org.nuiton.eugene.test2.Bill" type="org.nuiton.eugene.test2.Store" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Department" reverseAttributeName="" associationType="composite" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Address" package="org.nuiton.eugene.test2">
+ <stereotype name="entity"/>
+ <attribute name="city" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="adress" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Personne" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Department" package="org.nuiton.eugene.test2">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="leader" visibility="public" type="org.nuiton.eugene.test2.Employe" reverseAttributeName="lead" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Company" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Product" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Product" package="org.nuiton.eugene.test2">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Department" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Type" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Store" package="org.nuiton.eugene.test2">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="DEFAULT_NUM" associationType="composite" visibility="public" static="true" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="numStore" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <operation name="getDefaultNum" visibility="public" static="true">
+ <returnParameter type="java.lang.String"/>
+ </operation>
+ <class name="Row" package="org.nuiton.eugene.test2">
+ <attribute name="num" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="position" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ </class>
+ <attribute visibility="public" associationClassName="org.nuiton.eugene.test2.Bill" type="org.nuiton.eugene.test2.Company" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="0" maxMultiplicity="-1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Type" package="org.nuiton.eugene.test2">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Product" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="false" ordering="unordered"/>
+ </class>
+ <associationClass name="Bill" package="org.nuiton.eugene.test2">
+ <stereotype name="entity"/>
+ <participant name="org.nuiton.eugene.test2.Company" attribute=""/>
+ <participant name="org.nuiton.eugene.test2.Store" attribute=""/>
+ <attribute name="cost" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="date" associationType="composite" visibility="public" type="java.util.Date" minMultiplicity="1" maxMultiplicity="1"/>
+ </associationClass>
+ <class name="Voiture" abstract="true" package="org.nuiton.eugene.test2.beangen">
+ <stereotype name="bean"/>
+ <tagValue name="documentation" value="Doc for BeanA"/>
+ <attribute name="immatriculation" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1">
+ <tagValue name="documentation" value="attrA of BeanA"/>
+ </attribute>
+ <attribute name="modele" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="proprietaire" associationType="composite" visibility="public" type="org.nuiton.eugene.test2.beangen.PersonneDTO" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.beangen.Roue" reverseAttributeName="" associationType="composite" reverseMaxMultiplicity="1" minMultiplicity="4" maxMultiplicity="4" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.beangen.Siege" reverseAttributeName="" associationType="composite" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="4" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Roue" package="org.nuiton.eugene.test2.beangen">
+ <stereotype name="bean"/>
+ <operation name="mount" visibility="public">
+ <returnParameter type="void"/>
+ </operation>
+ <operation name="getModel" visibility="public">
+ <returnParameter type="int"/>
+ <parameter name="id" type="java.lang.String"/>
+ </operation>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.beangen.Voiture" reverseAttributeName="" reverseMaxMultiplicity="4" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="RelationDTO" package="org.nuiton.eugene.test2.beangen">
+ <stereotype name="dto"/>
+ <attribute name="idCompany" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="idDepartement" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="dateDebut" associationType="composite" visibility="public" type="java.util.Date" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="person" visibility="public" type="org.nuiton.eugene.test2.beangen.PersonneDTO" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="PersonneDTO" package="org.nuiton.eugene.test2.beangen">
+ <dependency name="" supplierName="org.nuiton.eugene.test2.Personne"/>
+ <stereotype name="dto"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.beangen.RelationDTO" reverseAttributeName="person" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Siege" package="org.nuiton.eugene.test2.beangen">
+ <stereotype name="bean"/>
+ <attribute name="noSerie" associationType="composite" visibility="public" type="int" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.beangen.Voiture" reverseAttributeName="" reverseMaxMultiplicity="4" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <interface name="Vehicule" package="org.nuiton.eugene.test2.beangen">
+ <operation name="start" visibility="public">
+ <returnParameter type="void"/>
+ </operation>
+ </interface>
+ <class name="Contact2" package="org.nuiton.eugene.test2.deletetest">
+ <stereotype name="entity"/>
+ <attribute name="contactValue" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="type" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <operation name="findAllByCompany" visibility="public">
+ <returnParameter type="java.util.Set<Contact2>"/>
+ <parameter name="company" type="org.nuiton.eugene.test2.Company"/>
+ <stereotype name="dao"/>
+ </operation>
+ <attribute visibility="public" type="org.nuiton.eugene.test2.Party2" reverseAttributeName="contacts" reverseMaxMultiplicity="-1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Telephone2" package="org.nuiton.eugene.test2.deletetest">
+ <stereotype name="entity"/>
+ <superclass name="org.nuiton.eugene.test2.Contact2" discriminator=""/>
+ <attribute name="prefix" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="country" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ </class>
+ <class name="Party2" package="org.nuiton.eugene.test2.deletetest">
+ <stereotype name="entity"/>
+ <attribute name="contacts" visibility="public" type="org.nuiton.eugene.test2.Contact2" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Person" package="org.nuiton.topia.test.entities">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="firstname" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.topia.test.entities.Pet" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="0" maxMultiplicity="-1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Pet" package="org.nuiton.topia.test.entities">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute name="type" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.topia.test.entities.Person" reverseAttributeName="" reverseMaxMultiplicity="-1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ <attribute visibility="public" type="org.nuiton.topia.test.entities.Race" reverseAttributeName="" associationType="composite" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="true" ordering="unordered"/>
+ </class>
+ <class name="Race" package="org.nuiton.topia.test.entities">
+ <stereotype name="entity"/>
+ <attribute name="name" associationType="composite" visibility="public" type="java.lang.String" minMultiplicity="1" maxMultiplicity="1"/>
+ <attribute visibility="public" type="org.nuiton.topia.test.entities.Pet" reverseAttributeName="" reverseMaxMultiplicity="1" minMultiplicity="1" maxMultiplicity="1" navigable="false" ordering="unordered"/>
+ </class>
+ <class name="Set<Contact2>" package="java.util"/>
+</objectModel>
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/resources/log4j.properties
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/resources/log4j.properties (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/main/resources/log4j.properties 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,12 @@
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+# package level
+log4j.logger.org.nuiton.eugene=DEBUG
+log4j.logger.org.nuiton.eugene.test=DEBUG
+log4j.logger.org.nuiton.processor=DEBUG
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/nuiton/eugene/test/generator/TestBuilderTest.java
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/nuiton/eugene/test/generator/TestBuilderTest.java (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/nuiton/eugene/test/generator/TestBuilderTest.java 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,91 @@
+/*
+ * *##%
+ * EUGene Test
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * 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>.
+ * ##%*
+ */
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.nuiton.eugene.test.generator;
+
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.nuiton.eugene.models.object.ObjectModel;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+
+/**
+ *
+ * @author fdesbois
+ */
+public class TestBuilderTest {
+
+ private static final Log log = LogFactory.getLog(TestBuilderTest.class);
+
+ public TestBuilderTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of build method, of class TestBuilder.
+ */
+ @Test
+ public void testBuild() {
+ System.out.println("build");
+ TestBuilder instance = new TestBuilder();
+
+ instance.build();
+
+ ObjectModel result = instance.getModel();
+ assertNotNull(result);
+ assertEquals(result.getClasses().size(), 2);
+ ObjectModelClass clazz = result.getClass("org.chorem.bonzoms.Person");
+ assertNotNull(clazz);
+ assertEquals(clazz.getAttributes().size(), 3);
+ assertEquals(clazz.getOperations().size(), 2);
+ List<ObjectModelOperation> operations = (List<ObjectModelOperation>)clazz.getOperations();
+ ObjectModelOperation operation = operations.get(0);
+ log.debug("Body code [" + operation.getName() + "] : " + operation.getBodyCode());
+ assertFalse(operation.getBodyCode().isEmpty());
+ }
+
+}
\ No newline at end of file
Property changes on: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/java/org/nuiton/eugene/test/generator/TestBuilderTest.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/resources/log4j.properties
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/resources/log4j.properties (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/src/test/resources/log4j.properties 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,12 @@
+# Global logging configuration
+log4j.rootLogger=ERROR, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+# package level
+log4j.logger.org.nuiton.eugene=DEBUG
+log4j.logger.org.nuiton.eugene.test=DEBUG
+log4j.logger.org.nuiton.processor=DEBUG
Added: branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/verify.groovy
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/verify.groovy (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/it/generate/generators/verify.groovy 2009-12-14 01:57:24 UTC (rev 749)
@@ -0,0 +1,5 @@
+
+//TODO
+
+return true;
+
Modified: branches/eugene-2.0/pom.xml
===================================================================
--- branches/eugene-2.0/pom.xml 2009-12-13 22:07:38 UTC (rev 748)
+++ branches/eugene-2.0/pom.xml 2009-12-14 01:57:24 UTC (rev 749)
@@ -19,7 +19,6 @@
<modules>
<module>eugene</module>
<module>maven-eugene-plugin</module>
- <module>eugene-test</module>
</modules>
<dependencyManagement>
1
0
r748 - branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java
by tchemit@users.nuiton.org 13 Dec '09
by tchemit@users.nuiton.org 13 Dec '09
13 Dec '09
Author: tchemit
Date: 2009-12-13 23:07:38 +0100 (Sun, 13 Dec 2009)
New Revision: 748
Modified:
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
Log:
delegate addDocumentation to builder
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2009-12-13 22:06:22 UTC (rev 747)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2009-12-13 22:07:38 UTC (rev 748)
@@ -199,4 +199,8 @@
public ObjectModelClassifier addInnerClassifier(ObjectModelClass clazz, ObjectModelType type, String name) throws IllegalArgumentException {
return builder.addInnerClassifier(clazz, type, name);
}
+
+ public void setDocumentation(ObjectModelElement element, String documentation) {
+ builder.setDocumentation(element, documentation);
+ }
}
1
0
r747 - branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene
by tchemit@users.nuiton.org 13 Dec '09
by tchemit@users.nuiton.org 13 Dec '09
13 Dec '09
Author: tchemit
Date: 2009-12-13 23:06:22 +0100 (Sun, 13 Dec 2009)
New Revision: 747
Modified:
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelTransformer.java
Log:
add comment
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelTransformer.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelTransformer.java 2009-12-13 20:06:30 UTC (rev 746)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelTransformer.java 2009-12-13 22:06:22 UTC (rev 747)
@@ -60,6 +60,7 @@
@Override
public void transform() {
+ // transformFromModel
transformFromElement(getModel(), ObjectModelType.OBJECT_MODEL);
// transformFromClassifier
1
0
r746 - in branches/eugene-2.0: eugene/src/main/java/org/nuiton/eugene eugene/src/main/java/org/nuiton/eugene/java eugene/src/main/java/org/nuiton/eugene/models/object eugene/src/main/java/org/nuiton/eugene/models/object/xml eugene/src/test/java/org/nuiton/eugene/xmi/objectmodel maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin
by tchemit@users.nuiton.org 13 Dec '09
by tchemit@users.nuiton.org 13 Dec '09
13 Dec '09
Author: tchemit
Date: 2009-12-13 21:06:30 +0100 (Sun, 13 Dec 2009)
New Revision: 746
Modified:
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaGenerator.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelClass.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelClassifier.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelEnumeration.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/DigesterObjectModelRuleSet.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelAssociationClassImpl.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelBuilder.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassImpl.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassifierImpl.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelEnumerationImpl.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelInterfaceImpl.java
branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI12ToObjectModelTest.java
branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI21ToObjectModelTest.java
branches/eugene-2.0/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java
Log:
- add enum support as classifier
- reformat code
- add classifier generation code for java
- add convinient method in java transformer with class parameter
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelGenerator.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -253,8 +253,8 @@
/**
* Test if given element can be generated.
*
- * An element can be generated if his package is in the {@link generatedPackages} list
- * or if {@link generatedPackages} is null or empty.
+ * An element can be generated if his package is in the {@link #generatedPackages} list
+ * or if {@link #generatedPackages} is null or empty.
*
* @param element element to test
* @return generation allowed
@@ -304,7 +304,8 @@
* @return
*/
public String getFilenameForInterface(ObjectModelInterface interfacez) {
- return interfacez.getQualifiedName().replace('.', File.separatorChar);
+ return getFilenameForClassifier(interfacez);
+// return interfacez.getQualifiedName().replace('.', File.separatorChar);
}
/**
@@ -314,7 +315,8 @@
* @return
*/
public String getFilenameForClass(ObjectModelClass clazz) {
- return clazz.getQualifiedName().replace('.', File.separatorChar);
+ return getFilenameForClassifier(clazz);
+// return clazz.getQualifiedName().replace('.', File.separatorChar);
}
/**
@@ -328,26 +330,25 @@
}
public String getFilenameForEnumeration(ObjectModelEnumeration enumeration) {
- return enumeration.getQualifiedName().replace('.', File.separatorChar);
+ return getFilenameForClassifier(enumeration);
+// return enumeration.getQualifiedName().replace('.', File.separatorChar);
}
- public void generateFromModel(Writer output, ObjectModel model)
- throws IOException {
+ public void generateFromModel(Writer output, ObjectModel model) throws IOException {
}
- public void generateFromInterface(Writer output,
- ObjectModelInterface interfacez) throws IOException {
+ public void generateFromInterface(Writer output, ObjectModelInterface interfacez) throws IOException {
}
- public void generateFromClass(Writer output, ObjectModelClass clazz)
- throws IOException {
+ public void generateFromEnum(Writer output, ObjectModelEnumeration interfacez) throws IOException {
}
- public void generateFromClassifier(Writer output,
- ObjectModelClassifier clazz) throws IOException {
+ public void generateFromClass(Writer output, ObjectModelClass clazz) throws IOException {
}
- public void generateFromEnumeration(Writer output,
- ObjectModelEnumeration enumeration) throws IOException {
+ public void generateFromClassifier(Writer output, ObjectModelClassifier clazz) throws IOException {
}
+
+ public void generateFromEnumeration(Writer output, ObjectModelEnumeration enumeration) throws IOException {
+ }
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaBuilder.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -22,28 +22,30 @@
import java.util.HashSet;
import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.eugene.GeneratorUtil;
import org.nuiton.eugene.ImportsManager;
+import org.nuiton.eugene.ObjectModelType;
import org.nuiton.eugene.models.object.*;
import org.nuiton.eugene.models.object.ObjectModelModifier;
import org.nuiton.eugene.models.object.xml.*;
/**
- * JavaBuilder
- *
+ * JavaBuilder TODO heritates it from ModelBuilder
+ * <p/>
* Created: 29 oct. 2009
*
* @author fdesbois
* @version $Revision$
- *
- * Builder to fill an empty ObjectModel with java specificities (imports, only one inheritance, constructor, ...).
- * JavaBuilder uses ImportsManagerExtension to manage imports in the model.
- * JavaBuilder is also based on ObjectModelBuilder for the simple filling of the model.
- *
- * Mise a jour: $Date$
- * par : $Author$
+ * <p/>
+ * Builder to fill an empty ObjectModel with java specificities (imports, only one inheritance, constructor, ...).
+ * JavaBuilder uses ImportsManagerExtension to manage imports in the model.
+ * JavaBuilder is also based on ObjectModelBuilder for the simple filling of the model.
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author$
*/
public class JavaBuilder {
@@ -62,32 +64,38 @@
@SuppressWarnings("unchecked")
public JavaBuilder(String modelName) {
this.modelBuilder = new ObjectModelBuilder(modelName);
-
+
this.managers = getModel().getExtension(
- ImportsManagerExtension.OBJECTMODEL_EXTENSION, ImportsManagerExtension.class);
+ ImportsManagerExtension.OBJECTMODEL_EXTENSION, ImportsManagerExtension.class);
}
/**
* Get the model which is built
+ *
* @return an ObjectModel
*/
public ObjectModel getModel() {
return this.modelBuilder.getModel();
}
+ public void setDocumentation(ObjectModelElement element, String documentation) {
+ modelBuilder.setDocumentation(element, documentation);
+ }
+
/**
* Add an import to a classifier. Imports are automatic for lots of JavaBuilder's methods except body
* code of operations.
* <pre>
* You can have some complex imports like :
- * - new java.util.List<org.chorem.bonzoms.Role>()
+ * - new java.util.List<org.chorem.bonzoms.Role>()
* --> two imports 'java.util.List' and 'org.chorem.bonzoms.Role'
* - java.util.Collection<T extends org.nuiton.topia.TopiaEntity>
* --> two imports 'java.util.Collection' and 'org.nuiton.topia.TopiaEntity'
* </pre>
+ *
* @param classifier where the imports will be added.
- * @param imports to add
- * @see org.nuiton.eugene.GeneratorUtil#getTypesList(java.lang.String)
+ * @param imports to add
+ * @see org.nuiton.eugene.GeneratorUtil#getTypesList(java.lang.String)
*/
public void addImport(ObjectModelClassifier classifier, String imports) {
if (imports == null) {
@@ -104,11 +112,11 @@
/**
* Create a new class in the model.
+ *
* @param name
* @param packageName
* @return a new ObjectModelClass
- * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#createClass(java.lang.String, java.lang.String,
- * org.nuiton.eugene.models.object.ObjectModelModifier[]) )
+ * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#createClass(java.lang.String, java.lang.String,org.nuiton.eugene.models.object.ObjectModelModifier...)
*/
public ObjectModelClass createClass(String name, String packageName) {
return modelBuilder.createClass(name, packageName);
@@ -116,11 +124,11 @@
/**
* Create a new abstract class in the model.
+ *
* @param name
* @param packageName
* @return a new ObjectModelClass
- * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#createClass(java.lang.String,
- * java.lang.String, org.nuiton.eugene.models.object.ObjectModelModifier[])
+ * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#createClass(java.lang.String,java.lang.String, org.nuiton.eugene.models.object.ObjectModelModifier...)
*/
public ObjectModelClass createAbstractClass(String name, String packageName) {
return modelBuilder.createClass(name, packageName, ObjectModelModifier.ABSTRACT);
@@ -128,22 +136,35 @@
/**
* Create a new interface in the model
+ *
* @param name
* @param packageName
* @return a new ObjectModelInterface
- * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#createInterface(java.lang.String, java.lang.String)
+ * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#createInterface(java.lang.String, java.lang.String)
*/
public ObjectModelInterface createInterface(String name, String packageName) {
return modelBuilder.createInterface(name, packageName);
}
/**
+ * Create a new enumration in the model
+ *
+ * @param name
+ * @param packageName
+ * @return a new ObjectModelEnumeration
+ */
+ public ObjectModelEnumeration createEnumeration(String name, String packageName) {
+ return modelBuilder.createEnumeration(name, packageName);
+ }
+
+ /**
* Set the superclass of an other class. Only one superclass can be set to the class.
* IMPORTS superclassQualifiedName.
+ *
* @param classifier
* @param superclassQualifiedName
* @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#addInterface(
- * org.nuiton.eugene.models.object.ObjectModelClassifier, java.lang.String)
+ *org.nuiton.eugene.models.object.ObjectModelClassifier, java.lang.String)
*/
public void setSuperClass(ObjectModelClass classifier, String superclassQualifiedName) {
ObjectModelClassImpl impl = (ObjectModelClassImpl) classifier;
@@ -155,10 +176,11 @@
/**
* Add an interface to a classifier (interface, class, enum).
* IMPORTS interfaceQualifiedName.
+ *
* @param classifier
* @param interfaceQualifiedName
* @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#addInterface(
- * org.nuiton.eugene.models.object.ObjectModelClassifier, java.lang.String)
+ *org.nuiton.eugene.models.object.ObjectModelClassifier, java.lang.String)
*/
public void addInterface(ObjectModelClassifier classifier, String interfaceQualifiedName) {
modelBuilder.addInterface(classifier, interfaceQualifiedName);
@@ -168,18 +190,17 @@
/**
* Add a new attribute to a classifier.
* IMPORTS type, value.
+ *
* @param classifier
* @param name
* @param type
* @param value
* @param modifiers
* @return a new ObjectModelAttribute
- * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#addAttribute(
- * org.nuiton.eugene.models.object.ObjectModelClassifier, java.lang.String,
- * java.lang.String, java.lang.String, org.nuiton.eugene.models.object.ObjectModelModifier[])
+ * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#addAttribute(org.nuiton.eugene.models.object.ObjectModelClassifier, java.lang.String,java.lang.String, java.lang.String, org.nuiton.eugene.models.object.ObjectModelModifier...)
*/
public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, String type, String value,
- ObjectModelModifier... modifiers) {
+ ObjectModelModifier... modifiers) {
this.addImport(classifier, type);
this.addImport(classifier, value);
return modelBuilder.addAttribute(classifier, name, type, value, modifiers);
@@ -188,6 +209,7 @@
/**
* Add a new constant to a classifier. A constant is static and final and have a value.
* IMPORTS type, value.
+ *
* @param classifier
* @param name
* @param type
@@ -197,12 +219,12 @@
* @throws IllegalArgumentException if the modifier is not a visibility
*/
public ObjectModelAttribute addConstant(ObjectModelClassifier classifier, String name, String type, String value,
- ObjectModelModifier visibility) throws IllegalArgumentException {
+ ObjectModelModifier visibility) throws IllegalArgumentException {
if (!visibility.isVisibility()) {
throw new IllegalArgumentException("Illegal visibility type : " + visibility.name() +
" for " + classifier.getQualifiedName());
}
-
+
return addAttribute(classifier, name, type, value, visibility,
ObjectModelModifier.STATIC, ObjectModelModifier.FINAL);
}
@@ -210,6 +232,7 @@
/**
* Add a new attribute to a classifier with no default value. Default visibility is set to PROTECTED.
* IMPORTS type.
+ *
* @param classifier
* @param name
* @param type
@@ -222,6 +245,7 @@
/**
* Add a new attribute to a classifier from an existing attribute.
* IMPORTS attribute.getType() and attribute.getDefaultValue().
+ *
* @param classifier
* @param attribute
* @return a new ObjectModelAttribute
@@ -247,28 +271,28 @@
}
return addAttribute(classifier, attribute.getName(), attribute.getType(),
- attribute.getDefaultValue(), modifiers.toArray(new ObjectModelModifier[modifiers.size()]));
+ attribute.getDefaultValue(), modifiers.toArray(new ObjectModelModifier[modifiers.size()]));
}
/**
* Add a new operation to a classifier.
+ *
* @param classifier
* @param name
* @param type
* @param modifiers
* @return a new ObjectModelOperation
- * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#addOperation(
- * org.nuiton.eugene.models.object.ObjectModelClassifier, java.lang.String,
- * java.lang.String, org.nuiton.eugene.models.object.ObjectModelModifier[])
+ * @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#addOperation(org.nuiton.eugene.models.object.ObjectModelClassifier, java.lang.String,java.lang.String, org.nuiton.eugene.models.object.ObjectModelModifier...)
*/
public ObjectModelOperation addOperation(ObjectModelClassifier classifier, String name, String type,
- ObjectModelModifier... modifiers) {
+ ObjectModelModifier... modifiers) {
this.addImport(classifier, type);
return modelBuilder.addOperation(classifier, name, type, modifiers);
}
/**
* Add a constructor to a class.
+ *
* @param clazz
* @param visibility
* @return a new ObjectModelOperation
@@ -286,12 +310,13 @@
/**
* Add a new parameter to an existing operation.
+ *
* @param operation
* @param type
* @param name
* @return a new ObjectModelParameter
* @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#addParameter(
- * org.nuiton.eugene.models.object.ObjectModelOperation, java.lang.String, java.lang.String)
+ *org.nuiton.eugene.models.object.ObjectModelOperation, java.lang.String, java.lang.String)
*/
public ObjectModelParameter addParameter(ObjectModelOperation operation, String type, String name) {
this.addImport((ObjectModelClassifier) operation.getDeclaringElement(), type);
@@ -300,10 +325,11 @@
/**
* Add an exception to an operation.
+ *
* @param operation
* @param exception
* @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#addException(
- * org.nuiton.eugene.models.object.ObjectModelOperation, java.lang.String)
+ *org.nuiton.eugene.models.object.ObjectModelOperation, java.lang.String)
*/
public void addException(ObjectModelOperation operation, String exception) {
this.addImport((ObjectModelClassifier) operation.getDeclaringElement(), exception);
@@ -312,11 +338,12 @@
/**
* Set the operation body code.
+ *
* @param operation
* @param body
* @throws IllegalArgumentException if operation is abstract
* @see org.nuiton.eugene.models.object.xml.ObjectModelBuilder#setOperationBody(
- * org.nuiton.eugene.models.object.ObjectModelOperation, java.lang.String)
+ *org.nuiton.eugene.models.object.ObjectModelOperation, java.lang.String)
*/
public void setOperationBody(ObjectModelOperation operation, String body)
throws IllegalArgumentException {
@@ -326,5 +353,21 @@
modelBuilder.setOperationBody(operation, body);
}
+ public ObjectModelClassifier addInnerClassifier(ObjectModelClass clazz, ObjectModelType type, String name) throws IllegalArgumentException {
+ return modelBuilder.addInnerClassifier(clazz, type, name);
+ }
+ public ObjectModelOperation addConstructor(ObjectModelEnumeration enumeration, ObjectModelModifier visibility)
+ throws IllegalArgumentException {
+ if (!visibility.isVisibility()) {
+ throw new IllegalArgumentException("Illegal visibility type : " + visibility.name() +
+ " for " + enumeration.getQualifiedName());
+ }
+
+ return addOperation(enumeration, enumeration.getName(), null, visibility);
+ }
+
+ public void addLiteral(ObjectModelEnumeration classifier, String name) {
+ modelBuilder.addLiteral(classifier,name);
+ }
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaGenerator.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaGenerator.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/JavaGenerator.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -24,6 +24,7 @@
import java.io.File;
import java.io.IOException;
import java.io.Writer;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
@@ -31,12 +32,7 @@
import org.apache.commons.logging.LogFactory;
import org.nuiton.eugene.GeneratorUtil;
import org.nuiton.eugene.ObjectModelGenerator;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelClassifier;
-import org.nuiton.eugene.models.object.ObjectModelInterface;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-import org.nuiton.eugene.models.object.ObjectModelParameter;
+import org.nuiton.eugene.models.object.*;
/**
* JavaGenerator
@@ -59,16 +55,29 @@
private static final Log log = LogFactory.getLog(JavaGenerator.class);
+ protected int innerLevel;
+ protected String prefix;
+
@Override
public String getFilenameForClass(ObjectModelClass clazz) {
- return clazz.getQualifiedName().replace('.', File.separatorChar) + ".java";
+ return getFilenameForClassifier(clazz);
}
@Override
public String getFilenameForInterface(ObjectModelInterface interfacez) {
- return interfacez.getQualifiedName().replace('.', File.separatorChar) + ".java";
+ return getFilenameForClassifier(interfacez);
}
+ @Override
+ public String getFilenameForEnumeration(ObjectModelEnumeration enumeration) {
+ return getFilenameForClassifier(enumeration);
+ }
+
+ @Override
+ public String getFilenameForClassifier(ObjectModelClassifier clazz) {
+ return clazz.getQualifiedName().replace('.', File.separatorChar) + ".java";
+ }
+
/**
* Generate from all classes.
* @param output Writer for generating the java file
@@ -81,9 +90,11 @@
if (log.isInfoEnabled()) {
log.info("generate class : " + clazz.getName());
}
+ preparePrefix(clazz);
- this.generateHeader(output, clazz); // Imports, package et documentation
-
+ // Imports, package et documentation
+ this.generateHeader(output, clazz);
+
String abstractStr = clazz.isAbstract() ? " abstract " : " ";
String className = clazz.getName();
@@ -105,7 +116,7 @@
}
/*{
-public<%=abstractStr%>class <%=className%>}*/
+<%=prefix%>public<%=abstractStr%>class <%=className%>}*/
/*
* Définition de la super classe : il ne doit y avoir qu'une
@@ -124,10 +135,12 @@
}*/
}
+ this.generateInnerClassifiers(output, clazz.getInnerClassifiers());
this.generateAttributes(output, clazz.getAttributes());
this.generateOperations(output, clazz.getOperations());
+
/*{
-} //<%=className%>
+<%=prefix%>} //<%=className%>
}*/
}
@@ -136,9 +149,11 @@
if (log.isInfoEnabled()) {
log.info("generate interface : " + interfacez.getName());
}
-
- this.generateHeader(output, interfacez); // Imports, package et documentation
+ preparePrefix(interfacez);
+ // Imports, package et documentation
+ this.generateHeader(output, interfacez);
+
String interfaceName = interfacez.getName();
String extend = "";
@@ -148,7 +163,7 @@
extend += GeneratorUtil.getSimpleName(p.getQualifiedName());
}
/*{
-public interface <%=interfaceName%>}*/
+<%=prefix%>public interface <%=interfaceName%>}*/
/*
* Définition de la super interface : il ne doit y avoir qu'une
@@ -160,15 +175,100 @@
}*/
}
-
this.generateAttributes(output, interfacez.getAttributes());
this.generateOperations(output, interfacez.getOperations());
/*{
-} //<%=interfaceName%>
+<%=prefix%>} //<%=interfaceName%>
}*/
}
+ @Override
+ public void generateFromEnum(Writer output, ObjectModelEnumeration enumz) throws IOException {
+ if (log.isInfoEnabled()) {
+ log.info("generate enumeration : " + enumz.getName());
+ }
+ preparePrefix(enumz);
+ this.generateHeader(output, enumz); // Imports, package et documentation
+
+ String enumzName = enumz.getName();
+
+ String extend = "";
+ Iterator<ObjectModelInterface> j = enumz.getInterfaces().iterator();
+ if (j.hasNext()) {
+ ObjectModelClassifier p = j.next();
+ extend += GeneratorUtil.getSimpleName(p.getQualifiedName());
+ }
+/*{
+<%=prefix%>public enum <%=enumzName%>}*/
+
+ if (extend.length() > 0) {
+/*{ implements <%=extend%> {
+
+}*/
+ }
+ else {
+ /*{ {
+
+}*/
+ }
+ // generation of literal
+ if (enumz.getLiterals().isEmpty()) {
+ /*{ ; }*/
+ } else {
+ Iterator<String> i = enumz.getLiterals().iterator();
+ while (i.hasNext()) {
+ String literal = i.next();
+/*{<%=prefix%> <%=literal%><%=(i.hasNext() ? "," : ";")%>
+}*/
+ }
+ }
+ this.generateAttributes(output, enumz.getAttributes());
+ this.generateOperations(output, enumz.getOperations());
+/*{
+<%=prefix%>} //<%=enumzName%>
+}*/
+ }
+
+ public void generateInnerClassifiers(Writer output, Collection<ObjectModelClassifier> innerClassifiers) throws IOException {
+ if (innerClassifiers == null || innerClassifiers.isEmpty()) {
+ return;
+ }
+ for (ObjectModelClassifier innerClassifier : innerClassifiers) {
+ if (innerClassifier.isClass()) {
+ generateFromClass(output, (ObjectModelClass) innerClassifier);
+ innerLevel--;
+ continue;
+ }
+ if (innerClassifier.isInterface()) {
+ generateFromInterface(output, (ObjectModelInterface) innerClassifier);
+ innerLevel--;
+ continue;
+ }
+ if (innerClassifier.isEnum()) {
+ generateFromEnum(output, (ObjectModelEnumeration) innerClassifier);
+ innerLevel--;
+ continue;
+ }
+ }
+ }
+
+ protected void preparePrefix(ObjectModelClassifier clazz) {
+ if (!clazz.isInner()) {
+ innerLevel = 0;
+ prefix = "";
+ } else {
+ innerLevel++;
+ char[] tmp = new char[innerLevel * 4];
+ Arrays.fill(tmp, ' ');
+ prefix = new String(tmp);
+ }
+ if (log.isInfoEnabled()) {
+ log.info("prefix to use for classifier " + clazz.getName() + " : [" + prefix + "]");
+ }
+ }
+
+
/**
* Generate Header for a classifier : Package, Documentation, Imports and Classifier signature.
* @param output Writer for generating the java file
@@ -176,7 +276,9 @@
* @throws IOException
*/
protected void generateHeader(Writer output, ObjectModelClassifier classifier) throws IOException {
-
+ if (classifier.isInner()) {
+ return;
+ }
String packageName = classifier.getPackageName();
/*{package <%=packageName%>;
@@ -187,7 +289,7 @@
for (String imports : managers.getImports(classifier)) {
/*{import <%=imports%>;
- }*/
+}*/
}
}
@@ -203,9 +305,9 @@
for (ObjectModelAttribute attr : attributes) {
if (attr.getDocumentation() != null && !attr.getDocumentation().isEmpty()) {
-/*{ /**
- * <%=attr.getDocumentation()%>
- *)
+/*{<%=prefix%> /**
+<%=prefix%> * <%=attr.getDocumentation()%>
+<%=prefix%> *)
}*/
}
@@ -223,7 +325,7 @@
String attrValue = attr.getDefaultValue() != null && !attr.getDefaultValue().isEmpty() ?
" = " + GeneratorUtil.getSimpleName(attr.getDefaultValue()) : "";
-/*{ <%=attrVisibility%><%=attrStatic%><%=attrFinal%> <%=attrType%> <%=attrName%><%=attrValue%>;
+/*{<%=prefix%> <%=attrVisibility%><%=attrStatic%><%=attrFinal%> <%=attrType%> <%=attrName%><%=attrValue%>;
}*/
}
}
@@ -237,12 +339,12 @@
protected void generateOperations(Writer output, Collection<ObjectModelOperation> operations) throws IOException {
for (ObjectModelOperation op : operations) {
String opName = op.getName();
-/*{ /**
- * <%=opName%> :
-}*/
+/*{<%=prefix%> /**
+<%=prefix%> * <%=opName%> :
+<%=prefix%>}*/
if (op.getDocumentation() != null && !op.getDocumentation().isEmpty()) {
String opDocumentation = op.getDocumentation();
-/*{ * <%=opDocumentation%>
+/*{<%=prefix%> * <%=opDocumentation%>
}*/
}
Collection<ObjectModelParameter> params = op.getParameters();
@@ -252,7 +354,7 @@
if (paramDocumentation == null) {
paramDocumentation = "";
}
-/*{ * @param <%=paramName%> <%=paramDocumentation%>
+/*{<%=prefix%> * @param <%=paramName%> <%=paramDocumentation%>
}*/
}
String opVisibility = op.getVisibility();
@@ -268,19 +370,19 @@
if (paramDocumentation == null) {
paramDocumentation = opReturn;
}
-/*{ * @return <%=paramDocumentation%>
+/*{<%=prefix%> * @return <%=paramDocumentation%>
}*/
}
}
Set<String> exceptions = op.getExceptions();
for (String exception : exceptions) {
String exceptionName = GeneratorUtil.getSimpleName(exception);
-/*{ * @throws <%=exceptionName%>
+/*{<%=prefix%> * @throws <%=exceptionName%>
}*/
}
/*{ *)
- <%=opVisibility%> <%=opStatic%><%=opAbstract%><%=opReturn%><%=opName%>(}*/
+<%=prefix%> <%=opVisibility%> <%=opStatic%><%=opAbstract%><%=opReturn%><%=opName%>(}*/
String comma = "";
for (ObjectModelParameter param : params) {
String paramName = param.getName();
@@ -298,7 +400,7 @@
}
if (!op.getBodyCode().isEmpty()) {
-/*{ {<%=op.getBodyCode()%>}
+/*{<%=prefix%> {<%=op.getBodyCode()%>}
}*/
} else {
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -22,6 +22,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.ObjectModelType;
import org.nuiton.eugene.Template;
import org.nuiton.eugene.ImportsManager;
import org.nuiton.eugene.ObjectModelTransformer;
@@ -44,10 +45,6 @@
protected JavaBuilder builder;
- public ObjectModelTransformerToJava() {
- super();
- }
-
@Override
protected Template<ObjectModel> initOutputTemplate() {
return new JavaGenerator();
@@ -55,7 +52,7 @@
@Override
protected ObjectModel initOutputModel() {
- if (log.isInfoEnabled()) {
+ if (log.isDebugEnabled()) {
log.debug("inputModelName = " + getModel().getName());
}
this.builder = new JavaBuilder(getModel().getName());
@@ -86,6 +83,10 @@
return builder.createClass(name, packageName);
}
+ public ObjectModelEnumeration createEnumeration(String name, String packageName) {
+ return builder.createEnumeration(name, packageName);
+ }
+
protected ObjectModelClass createAbstractClass(String name, String packageName) {
return builder.createAbstractClass(name, packageName);
}
@@ -98,49 +99,104 @@
builder.setSuperClass(classifier, superclassQualifiedName);
}
+ protected void setSuperClass(ObjectModelClass classifier, Class<?> superclassQualifiedName) {
+ builder.setSuperClass(classifier, superclassQualifiedName.getName());
+ }
+
protected void addInterface(ObjectModelClassifier classifier, String interfaceQualifiedName) {
builder.addInterface(classifier, interfaceQualifiedName);
}
+ protected void addInterface(ObjectModelClassifier classifier, Class<?> interfaceQualifiedName) {
+ builder.addInterface(classifier, interfaceQualifiedName.getName());
+ }
+
protected void addImport(ObjectModelClassifier classifier, String imports) {
builder.addImport(classifier, imports);
}
+ protected void addImport(ObjectModelClassifier classifier, ObjectModelClass imports) {
+ builder.addImport(classifier, imports.getPackageName() + "." + imports.getName());
+ }
+
+ protected void addImport(ObjectModelClassifier classifier, Class<?> imports) {
+ builder.addImport(classifier, imports.getName());
+ }
+
protected ObjectModelAttribute addConstant(ObjectModelClassifier classifier, String name, String type, String value,
- ObjectModelModifier visibility) throws IllegalArgumentException {
+ ObjectModelModifier visibility) throws IllegalArgumentException {
return builder.addConstant(classifier, name, type, value, visibility);
}
+ protected ObjectModelAttribute addConstant(ObjectModelClassifier classifier, String name, Class<?> type, String value,
+ ObjectModelModifier visibility) throws IllegalArgumentException {
+ return builder.addConstant(classifier, name, type.getName(), value, visibility);
+ }
+
protected ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, String type, String value,
- ObjectModelModifier... modifiers) {
+ ObjectModelModifier... modifiers) {
return builder.addAttribute(classifier, name, type, value, modifiers);
}
+ protected ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, Class<?> type, String value,
+ ObjectModelModifier... modifiers) {
+ return builder.addAttribute(classifier, name, type.getName(), value, modifiers);
+ }
+
protected ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, ObjectModelAttribute attribute) {
return builder.addAttribute(classifier, attribute);
}
+ public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, String type) {
+ return builder.addAttribute(classifier, name, type);
+ }
+
protected ObjectModelOperation addConstructor(ObjectModelClass clazz, ObjectModelModifier visibility)
throws IllegalArgumentException {
return builder.addConstructor(clazz, visibility);
}
+ protected ObjectModelOperation addConstructor(ObjectModelEnumeration clazz, ObjectModelModifier visibility)
+ throws IllegalArgumentException {
+ return builder.addConstructor(clazz, visibility);
+ }
+
protected ObjectModelOperation addOperation(ObjectModelClassifier classifier, String name, String type,
- ObjectModelModifier... modifiers) {
+ ObjectModelModifier... modifiers) {
return builder.addOperation(classifier, name, type, modifiers);
}
+ protected ObjectModelOperation addOperation(ObjectModelClassifier classifier, String name, Class<?> type,
+ ObjectModelModifier... modifiers) {
+ return builder.addOperation(classifier, name, type == null ? null : type.getName(), modifiers);
+ }
+
+ protected void addLiteral(ObjectModelEnumeration classifier, String name) {
+ builder.addLiteral(classifier, name);
+ }
+
protected ObjectModelParameter addParameter(ObjectModelOperation operation, String type, String name) {
return builder.addParameter(operation, type, name);
}
+ protected ObjectModelParameter addParameter(ObjectModelOperation operation, Class<?> type, String name) {
+ return builder.addParameter(operation, type.getName(), name);
+ }
+
protected void addException(ObjectModelOperation operation, String exception) {
builder.addException(operation, exception);
}
+ protected void addException(ObjectModelOperation operation, Class<?> exception) {
+ builder.addException(operation, exception.getName());
+ }
+
protected void setOperationBody(ObjectModelOperation operation, String body)
throws IllegalArgumentException {
builder.setOperationBody(operation, body);
}
+ public ObjectModelClassifier addInnerClassifier(ObjectModelClass clazz, ObjectModelType type, String name) throws IllegalArgumentException {
+ return builder.addInnerClassifier(clazz, type, name);
+ }
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelClass.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelClass.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelClass.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -50,7 +50,7 @@
*
* @return a Collection containing all inner ObjectModelClass for this class.
*/
- Collection<ObjectModelClass> getInnerClasses();
+ Collection<ObjectModelClassifier> getInnerClassifiers();
/**
* Returns the discriminator for the given superclass.
@@ -84,12 +84,12 @@
*/
boolean isAbstract();
- /**
- * Returns whether this class is inner an other class or not.
- *
- * @return a boolean indicating whether this class is inner an other class or not.
- */
- boolean isInner();
+// /**
+// * Returns whether this class is inner an other class or not.
+// *
+// * @return a boolean indicating whether this class is inner an other class or not.
+// */
+// boolean isInner();
/**
* Returns all operations defined on all Super class extended by this
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelClassifier.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelClassifier.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelClassifier.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -157,4 +157,19 @@
*/
public boolean isInterface();
+ /**
+ * Returns whether this classifier is an enumeration or not
+ * @see ObjectModelEnumeration
+ *
+ * @return a boolean indicating whether this classifier is an enumeration or not.
+ */
+ public boolean isEnum();
+
+ /**
+ * Returns whether this class is inner an other class or not.
+ *
+ * @return a boolean indicating whether this class is inner an other class or not.
+ */
+ boolean isInner();
+
} //ObjectModelClassifier
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelEnumeration.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelEnumeration.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/ObjectModelEnumeration.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -25,39 +25,38 @@
* ObjectModelEnumeration.
*
* @author Florian Desbois <fdesbois(a)codelutin.com>
- * Copyright Code Lutin
+ * Copyright Code Lutin
* @version $Revision: 483 $
- *
*/
-public interface ObjectModelEnumeration extends ObjectModelElement {
+public interface ObjectModelEnumeration extends ObjectModelClassifier {
- /**
- * Returns the package name of this enumeration.
- *
- * @return the package name of this enumeration.
- */
- public String getPackageName();
+// /**
+// * Returns the package name of this enumeration.
+// *
+// * @return the package name of this enumeration.
+// */
+// public String getPackageName();
+//
+// /**
+// * Returns the qualified name of this enumeration.
+// * Class qualified name is composed of the package name and the enumeration name.
+// *
+// * @return the qualified name of this enumeration.
+// */
+// public String getQualifiedName();
/**
- * Returns the qualified name of this enumeration.
- * Class qualified name is composed of the package name and the enumeration name.
- *
- * @return the qualified name of this enumeration.
- */
- public String getQualifiedName();
-
- /**
* Returns literals of this enumeration.
*
* @return a Collection of String
*/
public Collection<String> getLiterals();
- /**
- * Returns all operations defined on this en enumeration.
- * @see ObjectModelOperation
- *
- * @return a Collection containing all ObjectModelOperation for this enumeration.
- */
- public Collection<ObjectModelOperation> getOperations();
+// /**
+// * Returns all operations defined on this en enumeration.
+// * @see ObjectModelOperation
+// *
+// * @return a Collection containing all ObjectModelOperation for this enumeration.
+// */
+// public Collection<ObjectModelOperation> getOperations();
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/DigesterObjectModelRuleSet.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/DigesterObjectModelRuleSet.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/DigesterObjectModelRuleSet.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -71,10 +71,14 @@
// root element must be present on stask
d.addSetProperties("objectModel");
- d.addObjectCreate("*/class", ObjectModelClassImpl.class);
- d.addSetProperties("*/class");
- d.addSetNext("*/class", "addClass");
+ d.addObjectCreate("objectModel/class", ObjectModelClassImpl.class);
+ d.addSetProperties("objectModel/class");
+ d.addSetNext("objectModel/class", "addClass");
+ d.addObjectCreate("objectModel/class/class", ObjectModelClassImpl.class);
+ d.addSetProperties("objectModel/class/class");
+ d.addSetNext("objectModel/class/class", "addInnerClassifier");
+
d.addObjectCreate("objectModel/interface",
ObjectModelInterfaceImpl.class);
d.addSetProperties("objectModel/interface");
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelAssociationClassImpl.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelAssociationClassImpl.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelAssociationClassImpl.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -101,9 +101,10 @@
.getClassifier(ref.getName());
participantsClassifiers.add(classifier);
ObjectModelAttribute attribute = null;
- if (classifier.isClass()) {
- attribute = ((ObjectModelClass) classifier).getAttribute(ref
- .getAttributeName());
+ //TODO this
+// if (classifier.isClass()) {
+ if (classifier instanceof ObjectModelClass) {
+ attribute = classifier.getAttribute(ref.getAttributeName());
if (attribute == null) {
log.warn("WARNING : Attribute " + ref.getAttributeName()
+ " not found on " + classifier.getQualifiedName());
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelBuilder.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelBuilder.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelBuilder.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -21,30 +21,22 @@
package org.nuiton.eugene.models.object.xml;
-import org.nuiton.eugene.models.object.ObjectModel;
-import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelClassifier;
-import org.nuiton.eugene.models.object.ObjectModelElement;
-import org.nuiton.eugene.models.object.ObjectModelInterface;
-import org.nuiton.eugene.models.object.ObjectModelModifier;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-import org.nuiton.eugene.models.object.ObjectModelParameter;
+import org.nuiton.eugene.ObjectModelType;
+import org.nuiton.eugene.models.object.*;
/**
* ObjectModelBuilder
- *
+ * <p/>
* Created: 3 nov. 2009
*
* @author fdesbois
* @version $Revision$
- *
- * Builder to fill an empty ObjectModel. The object model name is important if you want to use the model
- * in generators.
- *
- * Mise a jour: $Date$
- * par : $Author$
+ * <p/>
+ * Builder to fill an empty ObjectModel. The object model name is important if you want to use the model
+ * in generators.
+ * <p/>
+ * Mise a jour: $Date$
+ * par : $Author$
*/
public class ObjectModelBuilder {
@@ -52,6 +44,7 @@
/**
* Constructor. Must have a name for the new model created.
+ *
* @param name model name
*/
public ObjectModelBuilder(String name) {
@@ -61,6 +54,7 @@
/**
* Get the building model
+ *
* @return the ObjectModel which is currently built
*/
public ObjectModel getModel() {
@@ -69,7 +63,8 @@
/**
* Add a tagValue to the model.
- * @param name tagValue name
+ *
+ * @param name tagValue name
* @param value tagValue value
*/
public void addTagValue(String name, String value) {
@@ -81,12 +76,13 @@
/**
* Add a tagValue to an element
+ *
* @param element where the tag value will be added
- * @param name tagValue name
- * @param value tagValue value
+ * @param name tagValue name
+ * @param value tagValue value
*/
public void addTagValue(ObjectModelElement element, String name, String value) {
- ObjectModelElementImpl impl = (ObjectModelElementImpl)element;
+ ObjectModelElementImpl impl = (ObjectModelElementImpl) element;
ObjectModelImplTagValue tagValue = new ObjectModelImplTagValue();
tagValue.setName(name);
@@ -97,9 +93,10 @@
/**
* Create a new class in the model.
* Modifiers allowed : ABSTRACT, STATIC.
- * @param name class name
+ *
+ * @param name class name
* @param packageName class package
- * @param modifiers class modifiers
+ * @param modifiers class modifiers
* @return the new ObjectModelClass added to the model
*/
public ObjectModelClass createClass(String name, String packageName, ObjectModelModifier... modifiers) {
@@ -107,17 +104,18 @@
return createClass(result, name, packageName, modifiers);
}
- protected ObjectModelClass createClass(ObjectModelClassImpl clazz,
- String name, String packageName, ObjectModelModifier... modifiers)
+ protected ObjectModelClass createClass(ObjectModelClassImpl clazz, String name, String packageName, ObjectModelModifier... modifiers)
throws IllegalArgumentException {
clazz.setName(name);
clazz.setPackage(packageName);
for (ObjectModelModifier modifier : modifiers) {
switch (modifier) {
case ABSTRACT:
- clazz.setAbstract(true); break;
+ clazz.setAbstract(true);
+ break;
case STATIC:
- clazz.setStatic(true); break;
+ clazz.setStatic(true);
+ break;
default:
throw new IllegalArgumentException("Unsupported modifier type '" + modifier.name() + "'");
}
@@ -128,7 +126,8 @@
/**
* Create a new interface in the model.
- * @param name interface name
+ *
+ * @param name interface name
* @param packageName interface package
* @return the new ObjectModelInterface added to the model
*/
@@ -141,11 +140,28 @@
}
/**
+ * Create a new interface in the model.
+ *
+ * @param name interface name
+ * @param packageName interface package
+ * @return the new ObjectModelInterface added to the model
+ */
+ public ObjectModelEnumeration createEnumeration(String name, String packageName) {
+ ObjectModelEnumerationImpl result = new ObjectModelEnumerationImpl();
+ result.setName(name);
+ result.setPackage(packageName);
+ model.addEnumeration(result);
+ return result;
+ }
+
+
+ /**
* Add an attribute to a classifier (interface, class, enum) without default value.
* Default visibility is set to PUBLIC.
+ *
* @param classifier where the attribute will be added
- * @param name attribute name
- * @param type attribute type (full qualified name)
+ * @param name attribute name
+ * @param type attribute type (full qualified name)
* @return the new ObjectModelAttribute added
*/
public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, String type) {
@@ -156,17 +172,18 @@
* Add an attribute to a classifier (interface, class, enum).
* Modifiers allowed : STATIC, FINAL, PUBLIC, PRIVATE, PROTECTED, PACKAGE, ORDERED, UNIQUE.
* The last visibility set will be keeped.
+ *
* @param classifier where the attribute will be added
- * @param name attribute name
- * @param type attribute type (full qualified name)
- * @param value default value for the attribute
- * @param modifiers attribute modifiers
+ * @param name attribute name
+ * @param type attribute type (full qualified name)
+ * @param value default value for the attribute
+ * @param modifiers attribute modifiers
* @return the new ObjectModelAttribute added
* @throws IllegalArgumentException illegal Modifier
* @see org.nuiton.eugene.models.object.ObjectModelModifier#isVisibility()
*/
public ObjectModelAttribute addAttribute(ObjectModelClassifier classifier, String name, String type, String value,
- ObjectModelModifier... modifiers) throws IllegalArgumentException {
+ ObjectModelModifier... modifiers) throws IllegalArgumentException {
ObjectModelAttributeImpl attribute = new ObjectModelAttributeImpl();
attribute.setName(name);
attribute.setType(type);
@@ -178,20 +195,24 @@
} else {
switch (modifier) {
case STATIC:
- attribute.setStatic(true); break;
- case FINAL:
- attribute.setFinal(true); break;
+ attribute.setStatic(true);
+ break;
+ case FINAL:
+ attribute.setFinal(true);
+ break;
case ORDERED:
- attribute.setOrdering(modifier.toString()); break;
+ attribute.setOrdering(modifier.toString());
+ break;
case UNIQUE:
- attribute.setUnique(true); break;
+ attribute.setUnique(true);
+ break;
default:
throw new IllegalArgumentException("Unsupported modifier type '" + modifier.name() + "'");
}
}
}
- ObjectModelClassifierImpl classifierImpl = (ObjectModelClassifierImpl)classifier;
+ ObjectModelClassifierImpl classifierImpl = (ObjectModelClassifierImpl) classifier;
classifierImpl.addAttribute(attribute);
return attribute;
}
@@ -200,20 +221,20 @@
* Add an association A to B. Create only attribute association for classifierA.
* MODIFIERS allowed : PUBLIC, PRIVATE, PACKAGE, PROTECTED, AGGREGATE, COMPOSITE, ORDERED, UNIQUE
* STATIC, NAVIGABLE.
- * You have to use method {@link #addReverseAssociation(org.nuiton.eugene.models.object.ObjectModelAttribute,
- * java.lang.String, int, int, org.nuiton.eugene.models.object.ObjectModelModifier[])} to create
- * attribute association for classifierB.
- * @param classifierA classifier from
- * @param classifierB classifier to
- * @param roleName role of A in association
+ * You have to use method {@link #addReverseAssociation(org.nuiton.eugene.models.object.ObjectModelAttribute,java.lang.String, int, int, org.nuiton.eugene.models.object.ObjectModelModifier...)}
+ * to create attribute association for classifierB.
+ *
+ * @param classifierA classifier from
+ * @param classifierB classifier to
+ * @param roleName role of A in association
* @param minMultiplicity minimum multiplicity of A in association
* @param maxMultiplicity maximum multiplicity of A in association
- * @param modifiers for the association
+ * @param modifiers for the association
* @return the attribute corresponding to the association for classifierA
* @throws IllegalArgumentException illegal modifier
*/
public ObjectModelAttribute addAssociation(ObjectModelClassifier classifierA, ObjectModelClassifier classifierB, String roleName,
- int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers)
+ int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers)
throws IllegalArgumentException {
ObjectModelAttributeImpl attribute = new ObjectModelAttributeImpl();
@@ -232,19 +253,23 @@
} else {
switch (modifier) {
case ORDERED:
- attribute.setOrdering(modifier.toString()); break;
+ attribute.setOrdering(modifier.toString());
+ break;
case UNIQUE:
- attribute.setUnique(true); break;
+ attribute.setUnique(true);
+ break;
case STATIC:
- attribute.setStatic(true); break;
+ attribute.setStatic(true);
+ break;
case NAVIGABLE:
- attribute.setNavigable(true); break;
+ attribute.setNavigable(true);
+ break;
default:
throw new IllegalArgumentException("Unsupported modifier type '" + modifier.name() + "'");
}
}
}
- ObjectModelClassifierImpl impl = (ObjectModelClassifierImpl)classifierA;
+ ObjectModelClassifierImpl impl = (ObjectModelClassifierImpl) classifierA;
impl.addAttribute(attribute);
return attribute;
}
@@ -253,35 +278,34 @@
* Create reverse association from an other association.
* MODIFIERS allowed : PUBLIC, PRIVATE, PACKAGE, PROTECTED, AGGREGATE, COMPOSITE, ORDERED, UNIQUE
* STATIC, NAVIGABLE.
+ *
* @param attrAssociation other association A to B
- * @param roleName role of B in association
+ * @param roleName role of B in association
* @param minMultiplicity minimum multiplicity of B in association
* @param maxMultiplicity maximum multiplicity of B in association
- * @param modifiers for the association
+ * @param modifiers for the association
* @return the attribute corresponding to the association for classifierB
- * @see #addAssociation(org.nuiton.eugene.models.object.ObjectModelClassifier, org.nuiton.eugene.models.object.ObjectModelClassifier,
- * java.lang.String, int, int, org.nuiton.eugene.models.object.ObjectModelModifier[])
+ * @see #addAssociation(org.nuiton.eugene.models.object.ObjectModelClassifier, org.nuiton.eugene.models.object.ObjectModelClassifier,java.lang.String, int, int, org.nuiton.eugene.models.object.ObjectModelModifier...)
*/
public ObjectModelAttribute addReverseAssociation(ObjectModelAttribute attrAssociation, String roleName,
- int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers) {
+ int minMultiplicity, int maxMultiplicity, ObjectModelModifier... modifiers) {
- ObjectModelAttributeImpl associationA = (ObjectModelAttributeImpl)attrAssociation;
+ ObjectModelAttributeImpl associationA = (ObjectModelAttributeImpl) attrAssociation;
// Add reverse parameters
associationA.setReverseAttributeName(roleName);
associationA.setReverseMaxMultiplicity(maxMultiplicity);
-
- ObjectModelClassifierImpl classifierA =
- (ObjectModelClassifierImpl)associationA.getDeclaringElement();
-
+
+ ObjectModelClassifierImpl classifierA =
+ (ObjectModelClassifierImpl) associationA.getDeclaringElement();
+
String typeB = associationA.getType();
// Get classifierB from model
- ObjectModelClassifierImpl classifierB =
- (ObjectModelClassifierImpl)model.getClassifier(typeB);
+ ObjectModelClassifierImpl classifierB = (ObjectModelClassifierImpl) model.getClassifier(typeB);
// Create reverse association
ObjectModelAttributeImpl associationB =
- (ObjectModelAttributeImpl)addAssociation(classifierB, classifierA, roleName,
- minMultiplicity, maxMultiplicity, modifiers);
+ (ObjectModelAttributeImpl) addAssociation(classifierB, classifierA, roleName,
+ minMultiplicity, maxMultiplicity, modifiers);
associationB.setReverseAttributeName(associationA.getName());
associationB.setReverseMaxMultiplicity(associationA.getMaxMultiplicity());
@@ -293,25 +317,26 @@
* Create association class. The two extremities of the association must be existing before creating
* the association class.
* Modifiers allowed : ABSTRACT, STATIC.
- * @param name association class name
- * @param packageName association package name
+ *
+ * @param name association class name
+ * @param packageName association package name
* @param attrAssociationA attribute association for classifierA involved in association class
* @param attrAssociationB attribute association for classifierB involved in association class
- * @param modifiers for the association class
+ * @param modifiers for the association class
* @return the new association class created with participants A and B
*/
public ObjectModelAssociationClass createAssociationClass(String name, String packageName, ObjectModelAttribute attrAssociationA,
- ObjectModelAttribute attrAssociationB, ObjectModelModifier... modifiers) {
+ ObjectModelAttribute attrAssociationB, ObjectModelModifier... modifiers) {
ObjectModelAssociationClassImpl associationClass = new ObjectModelAssociationClassImpl();
createClass(associationClass, name, packageName, modifiers);
// Add associationClass in attrAssociationA
- ObjectModelAttributeImpl attrA = (ObjectModelAttributeImpl)attrAssociationA;
+ ObjectModelAttributeImpl attrA = (ObjectModelAttributeImpl) attrAssociationA;
attrA.setAssociationClassName(associationClass.getQualifiedName());
// Add associationClass in attrAssociationB
- ObjectModelAttributeImpl attrB = (ObjectModelAttributeImpl)attrAssociationB;
+ ObjectModelAttributeImpl attrB = (ObjectModelAttributeImpl) attrAssociationB;
attrB.setAssociationClassName(associationClass.getQualifiedName());
// Create participantA
@@ -319,7 +344,7 @@
new ObjectModeImplAssociationClassParticipant();
participantA.setAttribute(attrA.getName());
- ObjectModelClassifier classifierA = (ObjectModelClassifier)attrA.getDeclaringElement();
+ ObjectModelClassifier classifierA = (ObjectModelClassifier) attrA.getDeclaringElement();
participantA.setName(classifierA.getQualifiedName());
associationClass.addParticipant(participantA);
@@ -329,7 +354,7 @@
new ObjectModeImplAssociationClassParticipant();
participantB.setAttribute(attrB.getName());
- ObjectModelClassifier classifierB = (ObjectModelClassifier)attrB.getDeclaringElement();
+ ObjectModelClassifier classifierB = (ObjectModelClassifier) attrB.getDeclaringElement();
participantB.setName(classifierB.getQualifiedName());
associationClass.addParticipant(participantB);
@@ -341,16 +366,17 @@
* Add an operation to a classifier.
* Modifiers allowed : STATIC, ABSTRACT, PUBLIC, PRIVATE, PROTECTED, PACKAGE.
* The last visibility set will be keeped.
+ *
* @param classifier where the operation will be added
- * @param name operation name
+ * @param name operation name
* @param returnType operation type (full qualified name)
- * @param modifiers operation modifiers
+ * @param modifiers operation modifiers
* @return the new ObjectModelOperation added
* @throws IllegalArgumentException illegal Modifier
*/
public ObjectModelOperation addOperation(ObjectModelClassifier classifier,
- String name, String returnType, ObjectModelModifier... modifiers)
- throws IllegalArgumentException{
+ String name, String returnType, ObjectModelModifier... modifiers)
+ throws IllegalArgumentException {
ObjectModelOperationImpl result = new ObjectModelOperationImpl();
result.setName(name);
@@ -366,23 +392,26 @@
} else {
switch (modifier) {
case STATIC:
- result.setStatic(true); break;
- case ABSTRACT:
- result.setAbstract(true); break;
+ result.setStatic(true);
+ break;
+ case ABSTRACT:
+ result.setAbstract(true);
+ break;
default:
throw new IllegalArgumentException("Unsupported modifier type '" + modifier.name() + "'");
}
}
}
- ((ObjectModelClassifierImpl)classifier).addOperation(result);
+ ((ObjectModelClassifierImpl) classifier).addOperation(result);
return result;
}
/**
* Set the body code for an Operation.
+ *
* @param operation where the code will be added
- * @param body code to add to the operation
+ * @param body code to add to the operation
*/
public void setOperationBody(ObjectModelOperation operation, String body) {
ObjectModelOperationImpl operationImpl = (ObjectModelOperationImpl) operation;
@@ -391,7 +420,8 @@
/**
* Add an interface to a classifier. The interface may not exist in model.
- * @param classifier where the interface will be added
+ *
+ * @param classifier where the interface will be added
* @param interfaceQualifiedName interface qualified name
*/
public void addInterface(ObjectModelClassifier classifier, String interfaceQualifiedName) {
@@ -405,7 +435,8 @@
/**
* Add a superclass to an other class. The superclass may not exist in model.
- * @param clazz where the superclass will be added
+ *
+ * @param clazz where the superclass will be added
* @param superclassQualifiedName superclass qualified name
*/
public void addSuperclass(ObjectModelClass clazz, String superclassQualifiedName) {
@@ -418,10 +449,43 @@
}
/**
+ * Add a superclass to an other class. The superclass may not exist in model.
+ *
+ * @param clazz where the superclass will be added
+ * @param type type of inner classifier to create
+ * @param name superclass qualified name
+ * @return the new instanciated inner classifier
+ * @throws IllegalArgumentException if given {@code type} is not a concrete classifier type
+ */
+ public ObjectModelClassifier addInnerClassifier(ObjectModelClass clazz, ObjectModelType type, String name) throws IllegalArgumentException {
+ ObjectModelClassImpl impl = (ObjectModelClassImpl) clazz;
+ ObjectModelClassifierImpl inner;
+ switch (type) {
+
+ case OBJECT_MODEL_ENUMERATION:
+ inner = new ObjectModelEnumerationImpl();
+ break;
+ case OBJECT_MODEL_CLASS:
+ inner = new ObjectModelClassImpl();
+ break;
+ case OBJECT_MODEL_INTERFACE:
+ inner = new ObjectModelInterfaceImpl();
+ break;
+ default:
+ throw new IllegalArgumentException("can not add a none classifier type " + type);
+ }
+ inner.setName(name);
+ impl.addInnerClassifier(inner);
+ inner.setObjectModelImpl(impl.getModel());
+ return inner;
+ }
+
+ /**
* Add a parameter to an operation.
+ *
* @param operation where the parameter will be added
- * @param type paremeter type (full qualified name)
- * @param name parameter name
+ * @param type paremeter type (full qualified name)
+ * @param name parameter name
* @return the new ObjectModelParameter added
*/
public ObjectModelParameter addParameter(ObjectModelOperation operation, String type, String name) {
@@ -435,6 +499,7 @@
/**
* Add an exception to an operation.
+ *
* @param operation where the exception will be added
* @param exception name of the exception (full qualified name)
*/
@@ -447,24 +512,32 @@
/**
* Set the documentation of an element in the model.
- * @param element where the documentation will be setted
+ *
+ * @param element where the documentation will be setted
* @param documentation String documentation for the element
*/
public void setDocumentation(ObjectModelElement element, String documentation) {
- ObjectModelElementImpl impl = (ObjectModelElementImpl)element;
+ ObjectModelElementImpl impl = (ObjectModelElementImpl) element;
impl.setDocumentation(documentation);
}
/**
* Add a stereotype to an element.
- * @param element where the stereotype will be added
+ *
+ * @param element where the stereotype will be added
* @param stereotype name
*/
public void addStereotype(ObjectModelElement element, String stereotype) {
- ObjectModelElementImpl impl = (ObjectModelElementImpl)element;
+ ObjectModelElementImpl impl = (ObjectModelElementImpl) element;
ObjectModelImplRef ref = new ObjectModelImplRef();
ref.setName(stereotype);
impl.addStereotype(ref);
}
+ public void addLiteral(ObjectModelEnumeration enumz, String name) {
+ ObjectModelEnumerationImpl impl = (ObjectModelEnumerationImpl) enumz;
+ ObjectModelImplRef ref = new ObjectModelImplRef();
+ ref.setName(name);
+ impl.addLiteral(ref);
+ }
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassImpl.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassImpl.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassImpl.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -28,7 +28,6 @@
import java.util.List;
import java.util.Map;
-import org.nuiton.eugene.ObjectModelType;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
import org.nuiton.eugene.models.object.ObjectModelClass;
import org.nuiton.eugene.models.object.ObjectModelClassifier;
@@ -46,16 +45,14 @@
* Last update : $Date$
* by : $Author$
*/
-public class ObjectModelClassImpl extends ObjectModelClassifierImpl implements
- ObjectModelClass {
+public class ObjectModelClassImpl extends ObjectModelClassifierImpl implements ObjectModelClass {
protected List<ObjectModelClass> superclasses = null;
protected Map<ObjectModelClass, String> superclassesDiscriminators = new HashMap<ObjectModelClass, String>();
protected List<ObjectModelImplRef> superclassesRefs = new ArrayList<ObjectModelImplRef>();
protected List<ObjectModelClass> specialisations = null;
- protected List<ObjectModelClass> innerClasses = null;
+ protected List<ObjectModelClassifier> innerClasses = null;
protected boolean abstractz = false;
- protected boolean inner = false;
public ObjectModelClassImpl() {
super();
@@ -76,18 +73,16 @@
* Digester method to add innerClass to this ObjectModelClass.
* @param innerClass the ObjectModelClass to add
*/
- public void addClass(ObjectModelClassImpl innerClass) {
+ public void addInnerClassifier(ObjectModelClassifierImpl innerClass) {
innerClass.setDeclaringElement(this);
innerClass.setInner(true);
if (innerClasses == null) {
- innerClasses = new ArrayList<ObjectModelClass>();
+ innerClasses = new ArrayList<ObjectModelClassifier>();
}
innerClasses.add(innerClass);
}
- public void setInner(boolean inner) {
- this.inner = inner;
- }
+
public void setAbstract(boolean abstractz) {
this.abstractz = abstractz;
@@ -97,12 +92,9 @@
public Collection<ObjectModelClass> getSuperclasses() {
if (superclasses == null) {
superclasses = new ArrayList<ObjectModelClass>();
- Iterator<?> i = superclassesRefs.iterator();
- while (i.hasNext()) {
- ObjectModelImplSuperClassRef ref = (ObjectModelImplSuperClassRef) i
- .next();
- ObjectModelClass superclass = objectModelImpl.getClass(ref
- .getName());
+ for (ObjectModelImplRef superclassesRef : superclassesRefs) {
+ ObjectModelImplSuperClassRef ref = (ObjectModelImplSuperClassRef) superclassesRef;
+ ObjectModelClass superclass = objectModelImpl.getClass(ref.getName());
if (superclass == null) {
ExternalCacheExtension cache = objectModelImpl.getExtension(
@@ -119,7 +111,7 @@
}
@Override
- public Collection<ObjectModelClass> getInnerClasses() {
+ public Collection<ObjectModelClassifier> getInnerClassifiers() {
return this.innerClasses;
}
@@ -146,9 +138,8 @@
public Collection<ObjectModelClass> getSpecialisations() {
if (specialisations == null) {
specialisations = new ArrayList<ObjectModelClass>();
- for (Iterator<?> i = objectModelImpl.getClasses().iterator(); i
- .hasNext();) {
- ObjectModelClass candidateClass = (ObjectModelClass) i.next();
+ for (Object o : objectModelImpl.getClasses()) {
+ ObjectModelClass candidateClass = (ObjectModelClass) o;
if (candidateClass.getSuperclasses().contains(this)) {
specialisations.add(candidateClass);
}
@@ -169,9 +160,7 @@
@Override
public Collection<ObjectModelClass> getSpecialisations(String discriminator) {
List<ObjectModelClass> discriminatedSpecialisations = new ArrayList<ObjectModelClass>();
- for (Iterator<ObjectModelClass> i = getSpecialisations().iterator(); i
- .hasNext();) {
- ObjectModelClass candidateClass = i.next();
+ for (ObjectModelClass candidateClass : getSpecialisations()) {
if (discriminator.equals(candidateClass.getDiscriminator(this))) {
discriminatedSpecialisations.add(candidateClass);
}
@@ -189,10 +178,10 @@
return abstractz;
}
- @Override
- public boolean isInner() {
- return inner;
- }
+// @Override
+// public boolean isInner() {
+// return inner;
+// }
@Override
public Collection<ObjectModelOperation> getAllOtherOperations(
@@ -205,7 +194,7 @@
@Override
public Collection<ObjectModelOperation> getAllSuperclassOperations(
boolean distinct) {
- Collection<ObjectModelOperation> result = null;
+ Collection<ObjectModelOperation> result;
if (distinct) {
result = new HashSet<ObjectModelOperation>();
} else {
@@ -217,8 +206,8 @@
protected Collection<ObjectModelOperation> getAllSuperclassOperations(
Collection<ObjectModelOperation> result) {
- for (Iterator<?> i = getSuperclasses().iterator(); i.hasNext();) {
- ObjectModelClassImpl clazz = (ObjectModelClassImpl) i.next();
+ for (Object o : getSuperclasses()) {
+ ObjectModelClassImpl clazz = (ObjectModelClassImpl) o;
result.addAll(clazz.getOperations());
clazz.getAllSuperclassOperations(result);
clazz.getAllInterfaceOperations(result);
@@ -235,8 +224,8 @@
protected Collection<ObjectModelAttribute> getAllOtherAttributes(
Collection<ObjectModelAttribute> result) {
- for (Iterator<?> i = getSuperclasses().iterator(); i.hasNext();) {
- ObjectModelClassImpl clazz = (ObjectModelClassImpl) i.next();
+ for (Object o : getSuperclasses()) {
+ ObjectModelClassImpl clazz = (ObjectModelClassImpl) o;
result.addAll(clazz.getAttributes());
clazz.getAllOtherAttributes(result);
}
@@ -246,8 +235,7 @@
@Override
public String toString() {
StringBuffer result = new StringBuffer();
- result.append("class " + getQualifiedName() + "<<" + getStereotypes()
- + ">> tagvalue: " + getTagValues() + " ");
+ result.append("class ").append(getQualifiedName()).append("<<").append(getStereotypes()).append(">> tagvalue: ").append(getTagValues()).append(" ");
result.append("extends ");
for (Iterator<?> i = getSuperclasses().iterator(); i.hasNext();) {
result.append(((ObjectModelClassifier) i.next()).getName());
@@ -265,28 +253,28 @@
return result.toString();
}
- /**
- * Returns whether this classifier is a class or not
- *
- * @see ObjectModelClass
- *
- * @return a boolean indicating whether this classifier is a class or not.
- */
- @Override
- public boolean isClass() {
- return true;
- }
-
- /**
- * Returns whether this classifier is an interface or not
- *
- * @see ObjectModelInterface
- *
- * @return a boolean indicating whether this classifier is an interface or
- * not.
- */
- @Override
- public boolean isInterface() {
- return false;
- }
+// /**
+// * Returns whether this classifier is a class or not
+// *
+// * @see ObjectModelClass
+// *
+// * @return a boolean indicating whether this classifier is a class or not.
+// */
+// @Override
+// public boolean isClass() {
+// return true;
+// }
+//
+// /**
+// * Returns whether this classifier is an interface or not
+// *
+// * @see ObjectModelInterface
+// *
+// * @return a boolean indicating whether this classifier is an interface or
+// * not.
+// */
+// @Override
+// public boolean isInterface() {
+// return false;
+// }
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassifierImpl.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassifierImpl.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelClassifierImpl.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -19,22 +19,9 @@
package org.nuiton.eugene.models.object.xml;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
+import org.nuiton.eugene.models.object.*;
-import java.util.Map;
-import org.nuiton.eugene.GeneratorUtil;
-import org.nuiton.eugene.ObjectModelType;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClassifier;
-import org.nuiton.eugene.models.object.ObjectModelDependency;
-import org.nuiton.eugene.models.object.ObjectModelInterface;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
+import java.util.*;
/**
* ObjectModelClassifierImpl.
@@ -61,16 +48,13 @@
protected List<ObjectModelDependency> dependencies = new ArrayList<ObjectModelDependency>();
protected String type = null;
-
+ protected boolean inner = false;
+
@Override
public String toString() {
return "" + getQualifiedName() + " implements " + getInterfaces();
}
- public ObjectModelClassifierImpl() {
- super();
- }
-
@Override
public void postInit() {
super.postInit();
@@ -85,6 +69,15 @@
this.packageName = packageName;
}
+ public void setInner(boolean inner) {
+ this.inner = inner;
+ }
+
+ @Override
+ public boolean isInner() {
+ return inner;
+ }
+
public void addInterface(ObjectModelImplRef ref) {
//if (ref == null)
// return new ObjectModelImplRef();
@@ -158,9 +151,7 @@
@Override
public Collection<ObjectModelOperation> getOperations(String name) {
List<ObjectModelOperation> result = new ArrayList<ObjectModelOperation>();
- for (Iterator<ObjectModelOperation> i = getOperations().iterator(); i
- .hasNext();) {
- ObjectModelOperation op = i.next();
+ for (ObjectModelOperation op : getOperations()) {
if (name.equals(op.getName())) {
result.add(op);
}
@@ -233,8 +224,8 @@
protected Collection<ObjectModelAttribute> getAllInterfaceAttributes(
Collection<ObjectModelAttribute> result) {
- for (Iterator<?> i = getInterfaces().iterator(); i.hasNext();) {
- ObjectModelClassifierImpl clazz = (ObjectModelClassifierImpl) i.next();
+ for (Object o : getInterfaces()) {
+ ObjectModelClassifierImpl clazz = (ObjectModelClassifierImpl) o;
result.addAll(clazz.getAttributes());
clazz.getAllInterfaceAttributes(result);
}
@@ -258,4 +249,19 @@
}
return null;
}
+
+ @Override
+ public final boolean isClass() {
+ return this instanceof ObjectModelClass;
+ }
+
+ @Override
+ public final boolean isInterface() {
+ return this instanceof ObjectModelInterface;
+ }
+
+ @Override
+ public final boolean isEnum() {
+ return this instanceof ObjectModelEnumeration;
+ }
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelEnumerationImpl.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelEnumerationImpl.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelEnumerationImpl.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -35,7 +35,7 @@
* @version $Revision: 478 $
*
*/
-public class ObjectModelEnumerationImpl extends ObjectModelElementImpl
+public class ObjectModelEnumerationImpl extends ObjectModelClassifierImpl
implements ObjectModelEnumeration {
/**
@@ -43,23 +43,23 @@
*/
private Collection<ObjectModelImplRef> literalRefs = new ArrayList<ObjectModelImplRef>();
- /**
- * Collection of operations objectModel
- */
- private Collection<ObjectModelOperation> operations = new ArrayList<ObjectModelOperation>();
+// /**
+// * Collection of operations objectModel
+// */
+// private Collection<ObjectModelOperation> operations = new ArrayList<ObjectModelOperation>();
- /**
- * Package name from objectModel file, loaded with Digester
- */
- private String packageName;
+// /**
+// * Package name from objectModel file, loaded with Digester
+// */
+// private String packageName;
- public void setPackage(String packageName) {
- this.packageName = packageName;
- }
-
- public String getPackage() {
- return this.packageName;
- }
+// public void setPackage(String packageName) {
+// this.packageName = packageName;
+// }
+//
+// public String getPackage() {
+// return this.packageName;
+// }
/**
* Add a literal to the ObjectModelEnumeration from Digester
* @param ref corresponding to a Literal value
@@ -68,27 +68,27 @@
literalRefs.add(ref);
}
- /**
- * Add an operation to the ObjectModelEnumeration from Digester
- * @param operation
- */
- public void addOperation(ObjectModelOperationImpl operation) {
- operation.postInit();
- operation.setDeclaringElement(this);
- operations.add(operation);
- }
+// /**
+// * Add an operation to the ObjectModelEnumeration from Digester
+// * @param operation
+// */
+// public void addOperation(ObjectModelOperationImpl operation) {
+// operation.postInit();
+// operation.setDeclaringElement(this);
+// operations.add(operation);
+// }
+//
+// @Override
+// public String getPackageName() {
+// return this.packageName;
+// }
+//
+// @Override
+// public String getQualifiedName() {
+// return this.packageName+"."+this.getName();
+// }
@Override
- public String getPackageName() {
- return this.packageName;
- }
-
- @Override
- public String getQualifiedName() {
- return this.packageName+"."+this.getName();
- }
-
- @Override
public Collection<String> getLiterals() {
Collection<String> results = new ArrayList<String>();
for (ObjectModelImplRef ref : literalRefs) {
@@ -97,9 +97,9 @@
return results;
}
- @Override
- public Collection<ObjectModelOperation> getOperations() {
- return operations;
- }
+// @Override
+// public Collection<ObjectModelOperation> getOperations() {
+// return operations;
+// }
}
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelImpl.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -174,7 +174,7 @@
@Override
public ObjectModelClassifier getClassifier(String qualifiedClassifierName) {
return (qualifiedClassifierName == null ? null
- : (ObjectModelClassifier) classifiers.get(qualifiedClassifierName));
+ : classifiers.get(qualifiedClassifierName));
}
/**
@@ -256,8 +256,7 @@
*/
@Override
public ObjectModelInterface getInterface(String qualifiedInterfaceName) {
- ObjectModelInterface result = null;
- result = (ObjectModelInterface) interfaces.get(qualifiedInterfaceName);
+ ObjectModelInterface result = interfaces.get(qualifiedInterfaceName);
if (result == null && log.isWarnEnabled()) {
log.warn("Interface " + qualifiedInterfaceName + " not found in model");
}
@@ -279,6 +278,7 @@
public void addEnumeration(ObjectModelEnumerationImpl enumeration) {
enumeration.postInit();
enumeration.setObjectModelImpl(this);
+ classifiers.put(enumeration.getQualifiedName(), enumeration);
enumerations.put(enumeration.getQualifiedName(), enumeration);
}
@@ -481,7 +481,7 @@
*/
@Override
public String getTagValue(String tagValue) {
- return (tagValue == null ? null : (String) tagValues.get(tagValue));
+ return (tagValue == null ? null : tagValues.get(tagValue));
}
/**
@@ -495,8 +495,7 @@
*/
@Override
@SuppressWarnings("unchecked")
- public <O> O getExtension(String reference, Class<O> extensionClass)
- throws ClassCastException, RuntimeException {
+ public <O> O getExtension(String reference, Class<O> extensionClass) throws RuntimeException {
Object object = extensions.get(reference);
O result;
if (object != null && !extensionClass.isAssignableFrom(object.getClass())) {
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelInterfaceImpl.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelInterfaceImpl.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/models/object/xml/ObjectModelInterfaceImpl.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -37,16 +37,11 @@
* Last update : $Date$
* by : $Author$
*/
-public class ObjectModelInterfaceImpl extends ObjectModelClassifierImpl
- implements ObjectModelInterface {
+public class ObjectModelInterfaceImpl extends ObjectModelClassifierImpl implements ObjectModelInterface {
- public ObjectModelInterfaceImpl() {
- super();
- }
-
public String toString() {
StringBuffer result = new StringBuffer();
- result.append("interface " + getQualifiedName() + " ");
+ result.append("interface ").append(getQualifiedName()).append(" ");
result.append("extends ");
for (Iterator i = getInterfaces().iterator(); i.hasNext();) {
result.append(((ObjectModelClassifier) i.next()).getName());
@@ -57,26 +52,26 @@
return result.toString();
}
- /**
- * Returns whether this classifier is a class or not
- *
- * @see ObjectModelClass
- *
- * @return a boolean indicating whether this classifier is a class or not.
- */
- public boolean isClass() {
- return false;
- }
-
- /**
- * Returns whether this classifier is an interface or not
- *
- * @see ObjectModelInterface
- *
- * @return a boolean indicating whether this classifier is an interface or
- * not.
- */
- public boolean isInterface() {
- return true;
- }
+// /**
+// * Returns whether this classifier is a class or not
+// *
+// * @see ObjectModelClass
+// *
+// * @return a boolean indicating whether this classifier is a class or not.
+// */
+// public boolean isClass() {
+// return false;
+// }
+//
+// /**
+// * Returns whether this classifier is an interface or not
+// *
+// * @see ObjectModelInterface
+// *
+// * @return a boolean indicating whether this classifier is an interface or
+// * not.
+// */
+// public boolean isInterface() {
+// return true;
+// }
}
Modified: branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI12ToObjectModelTest.java
===================================================================
--- branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI12ToObjectModelTest.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI12ToObjectModelTest.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -167,10 +167,10 @@
// Test for inner class
ObjectModelClass storeClass = model.getClass("org.nuiton.topiatest.Store");
Assert.assertNotNull(storeClass);
- List<ObjectModelClass> inners = (List<ObjectModelClass>) storeClass.getInnerClasses();
+ List<ObjectModelClassifier> inners = (List<ObjectModelClassifier>) storeClass.getInnerClassifiers();
Assert.assertNotNull(inners);
Assert.assertEquals(inners.size(), 1);
- ObjectModelClass rowClass = inners.get(0);
+ ObjectModelClass rowClass = (ObjectModelClass) inners.get(0);
Assert.assertNotNull(rowClass);
Assert.assertEquals(rowClass.getDeclaringElement().getName(), "Store");
}
Modified: branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI21ToObjectModelTest.java
===================================================================
--- branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI21ToObjectModelTest.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/xmi/objectmodel/XMI21ToObjectModelTest.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -41,12 +41,7 @@
import org.junit.Before;
import org.junit.Test;
import org.nuiton.eugene.ObjectModelGenerator;
-import org.nuiton.eugene.models.object.ObjectModel;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelEnumeration;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-import org.nuiton.eugene.models.object.ObjectModelParameter;
+import org.nuiton.eugene.models.object.*;
import org.nuiton.util.Resource;
import org.nuiton.util.ResourceResolver;
@@ -148,8 +143,10 @@
assertNotNull(model);
assertEquals("XMITest21", model.getName());
- assertEquals(15, model.getClassifiers().size());
-
+ //FIXME check there is an xmi enumeration since we changed enumeration to classifier
+// assertEquals(15, model.getClassifiers().size());
+ assertEquals(16, model.getClassifiers().size());
+
// ClassB
ObjectModelClass clazzB = model.getClass("org.nuiton.eugene.test21.ClassB");
assertNotNull(clazzB);
@@ -214,8 +211,10 @@
assertNotNull(model);
assertEquals("org::sharengo::utils::container::link", model.getName());
- assertEquals(8, model.getClassifiers().size());
-
+ //FIXME check there is an xmi enumeration since we changed enumeration to classifier
+ assertEquals(9, model.getClassifiers().size());
+// assertEquals(8, model.getClassifiers().size());
+
// LinkEntity
ObjectModelClass clazzLinkEntity = model.getClass("org.sharengo.utils.container.link.entities.LinkEntity");
assertNotNull(clazzLinkEntity);
@@ -506,12 +505,12 @@
// OuterClass
ObjectModelClass outer = model.getClass("org.nuiton.eugene.test21.OuterClass");
- List<ObjectModelClass> inners = (List<ObjectModelClass>)outer.getInnerClasses();
+ List<ObjectModelClassifier> inners = (List<ObjectModelClassifier>)outer.getInnerClassifiers();
assertNotNull(inners);
assertEquals(inners.size(), 1);
-
+
// InnerClass
- ObjectModelClass inner = inners.get(0);
+ ObjectModelClass inner = (ObjectModelClass) inners.get(0);
assertNotNull(inner);
assertNotNull(inner.getDeclaringElement());
assertEquals(inner.getDeclaringElement().getName(), "OuterClass");
Modified: branches/eugene-2.0/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java 2009-12-13 20:02:52 UTC (rev 745)
+++ branches/eugene-2.0/maven-eugene-plugin/src/main/java/org/nuiton/eugene/plugin/EugenePlugin.java 2009-12-13 20:06:30 UTC (rev 746)
@@ -31,6 +31,7 @@
import java.util.Map.Entry;
import java.util.Set;
+
import org.apache.commons.lang.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Resource;
@@ -49,10 +50,9 @@
*
* @author ruchaud
* @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- *
+ * <p/>
+ * Last update: $Date$
+ * by : $Author$
* @goal generate
* @projectRequired true
*/
@@ -60,9 +60,9 @@
/**
* Les entrées sorties du plugin.
- *
* <p/>
- *
+ * <p/>
+ * <p/>
* En entrée on demande des répertoires où chercher les fichiers objectmodel a convertir.
* <p/>
* En sortie on demande le répertoire ou generer les classes java.
@@ -79,7 +79,7 @@
* </generateResources>
* </pre>
* </p>
- *
+ * <p/>
* Note: si {@link #testPhase} est activée, les valeurs par défaut sont :
* </p>
* <pre>
@@ -134,9 +134,9 @@
protected File extraClassPathDirectory;
/**
* List of packages to generate (comma separated).
- *
+ * <p/>
* If the parameter is not filled, will generate all packages.
- *
+ *
* @parameter expression="${eugene.generatedPackages}"
* @since 1.0.0-rc-8
*/
@@ -159,7 +159,7 @@
getLog().info(" includes : " + includes);
getLog().info(" using template : " + templates);
getLog().info(" using defaultPackage : " + defaultPackage);
-
+
File[] modelFiles = getModelFiles();
if (modelFiles.length == 0) {
// can skip
@@ -201,11 +201,11 @@
//TC-20090829 fix when loading more than one model together...
- try {
- template.applyTemplate(model, generateResources.getOutput());
- } catch (IOException eee) {
- throw new MojoExecutionException("Generation problem", eee);
- }
+ try {
+ template.applyTemplate(model, generateResources.getOutput());
+ } catch (IOException eee) {
+ throw new MojoExecutionException("Generation problem", eee);
+ }
// for (File modelFile : modelFiles) {
// getLog().debug(" on " + modelFile.getAbsolutePath());
//
@@ -236,7 +236,7 @@
/**
* Recuperation de la liste des fichiers de modele a traite.
- *
+ *
* @return la liste des modeles a utiliser
*/
protected File[] getModelFiles() {
@@ -287,8 +287,7 @@
ModelReader<?> modelReader = null;
try {
ClassLoader fixedClassLoader = fixClassLoader();
- modelReader = (ModelReader<?>) Class.forName(reader,
- true, fixedClassLoader).newInstance();
+ modelReader = (ModelReader<?>) Class.forName(reader, true, fixedClassLoader).newInstance();
} catch (InstantiationException eee) {
throw new MojoFailureException("Can't instantiate reader : " + reader, eee);
} catch (IllegalAccessException eee) {
@@ -300,8 +299,7 @@
}
@SuppressWarnings("unchecked")
- protected <M extends Model> List<Template<M>>
- getTemplates(ModelReader<M> modelReader)
+ protected <M extends Model> List<Template<M>> getTemplates(ModelReader<M> modelReader)
throws MojoFailureException, MojoExecutionException {
// init generators
Properties templateProperties = new Properties();
@@ -339,9 +337,9 @@
protected String getExcludeTemplatesAsString() {
String result = "";
- for (int i=0; i < excludeTemplates.length; i++) {
+ for (int i = 0; i < excludeTemplates.length; i++) {
result += excludeTemplates[i];
- if (i != excludeTemplates.length-1) {
+ if (i != excludeTemplates.length - 1) {
result += ",";
}
}
1
0
r745 - branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene
by tchemit@users.nuiton.org 13 Dec '09
by tchemit@users.nuiton.org 13 Dec '09
13 Dec '09
Author: tchemit
Date: 2009-12-13 21:02:52 +0100 (Sun, 13 Dec 2009)
New Revision: 745
Modified:
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelTransformer.java
Log:
remove unucessary default constructor
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelTransformer.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelTransformer.java 2009-12-13 20:02:13 UTC (rev 744)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelTransformer.java 2009-12-13 20:02:52 UTC (rev 745)
@@ -42,10 +42,6 @@
* @param <O>
*/
public abstract class ObjectModelTransformer<O extends Model> extends Transformer<ObjectModel, O> {
-
- public ObjectModelTransformer() {
- super();
- }
/**
* Le model associé au transformer est le model d'entree. Le modele de sortie
1
0
r744 - branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene
by tchemit@users.nuiton.org 13 Dec '09
by tchemit@users.nuiton.org 13 Dec '09
13 Dec '09
Author: tchemit
Date: 2009-12-13 21:02:13 +0100 (Sun, 13 Dec 2009)
New Revision: 744
Modified:
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelType.java
Log:
reformat + javadoc
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelType.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelType.java 2009-12-13 20:01:41 UTC (rev 743)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ObjectModelType.java 2009-12-13 20:02:13 UTC (rev 744)
@@ -24,14 +24,31 @@
* Contains all types available for generating specific ObjectModelElement file.
* Needed because of inheritance between class, interface and classifier.
* Method instanceof (previously used) is inadequat so expliciting the ObjectModel type is much better.
- *
+ * <p/>
* Created: may 4th 2009
*
* @author Florian DESBOIS <fdesbois(a)codelutin.com>
- *
* @version $Revision: 496 $
*/
public enum ObjectModelType {
- OBJECT_MODEL, OBJECT_MODEL_ENUMERATION, OBJECT_MODEL_CLASSIFIER,
- OBJECT_MODEL_CLASS, OBJECT_MODEL_INTERFACE
+ /**
+ * a model
+ */
+ OBJECT_MODEL,
+ /**
+ * an enumration
+ */
+ OBJECT_MODEL_ENUMERATION,
+ /**
+ * a generic classifier
+ */
+ OBJECT_MODEL_CLASSIFIER,
+ /**
+ * a class
+ */
+ OBJECT_MODEL_CLASS,
+ /**
+ * an interface
+ */
+ OBJECT_MODEL_INTERFACE
}
1
0
r743 - branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene
by tchemit@users.nuiton.org 13 Dec '09
by tchemit@users.nuiton.org 13 Dec '09
13 Dec '09
Author: tchemit
Date: 2009-12-13 21:01:41 +0100 (Sun, 13 Dec 2009)
New Revision: 743
Modified:
branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ModelFileWriterConfiguration.java
Log:
javadoc
Modified: branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ModelFileWriterConfiguration.java
===================================================================
--- branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ModelFileWriterConfiguration.java 2009-12-11 18:09:59 UTC (rev 742)
+++ branches/eugene-2.0/eugene/src/main/java/org/nuiton/eugene/ModelFileWriterConfiguration.java 2009-12-13 20:01:41 UTC (rev 743)
@@ -7,8 +7,8 @@
import java.util.Set;
/**
- * Shared configuration of a {@link ModelFileWriter}, should be the same for all writer
- * to use in a time.
+ * Shared configuration of a {@link ModelFileWriter}, should be the same for all writers
+ * to use at a time.
*
* @author tchemit
* @since 2.0.0
1
0
r742 - branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene
by fdesbois@users.nuiton.org 11 Dec '09
by fdesbois@users.nuiton.org 11 Dec '09
11 Dec '09
Author: fdesbois
Date: 2009-12-11 19:09:59 +0100 (Fri, 11 Dec 2009)
New Revision: 742
Modified:
branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java
Log:
Add test for getSimpleName method, broken for getTypesList --> it's necessary to do imports before using this type of expression
Modified: branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java
===================================================================
--- branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java 2009-12-11 10:56:36 UTC (rev 741)
+++ branches/eugene-2.0/eugene/src/test/java/org/nuiton/eugene/GeneratorUtilTest.java 2009-12-11 18:09:59 UTC (rev 742)
@@ -126,6 +126,12 @@
result = GeneratorUtil.getSimpleName(str);
log.info(str + " -> " + result);
assertEquals(expResult, result);
+
+ str = "<T extends org.nuiton.topia.TopiaEntity, D extends org.nuiton.topia.TopiaDAO<? super T>> D";
+ expResult = "<T extends TopiaEntity, D extends TopiaDAO<? super T>> D";
+ result = GeneratorUtil.getSimpleName(str);
+ log.info(str + " -> " + result);
+ assertEquals(expResult, result);
}
@Test
@@ -166,10 +172,15 @@
log.info(str + " -> " + results);
assertEquals(results.size(), 3);
- str = "java.util.Map<org.chorem.jtimer.Jtimer, java.util.Collection<java.lang.String>>";
+ str = "java.util.Map<org.chorem.jtimer.Jtimer, java.util.Collection<String>>";
results = GeneratorUtil.getTypesList(str);
log.info(str + " -> " + results);
assertEquals(results.size(), 4);
+
+// str = "<T extends org.nuiton.topia.TopiaEntity> T";
+// results = GeneratorUtil.getTypesList(str);
+// log.info(str + " -> " + results);
+// assertEquals(results.size(), 1);
}
}
\ No newline at end of file
1
0
r741 - in branches/eugene-2.0: . eugene/src/site eugene/src/site/resources eugene-test maven-eugene-plugin maven-eugene-plugin/src/site maven-eugene-plugin/src/site/fr maven-eugene-plugin/src/site/fr/rst maven-eugene-plugin/src/site/rst src/site
by tchemit@users.nuiton.org 11 Dec '09
by tchemit@users.nuiton.org 11 Dec '09
11 Dec '09
Author: tchemit
Date: 2009-12-11 11:56:36 +0100 (Fri, 11 Dec 2009)
New Revision: 741
Added:
branches/eugene-2.0/eugene/src/site/rst/
branches/eugene-2.0/maven-eugene-plugin/src/site/fr/
branches/eugene-2.0/maven-eugene-plugin/src/site/fr/rst/
branches/eugene-2.0/maven-eugene-plugin/src/site/fr/rst/index.rst
branches/eugene-2.0/maven-eugene-plugin/src/site/site_en.xml
branches/eugene-2.0/maven-eugene-plugin/src/site/site_fr.xml
branches/eugene-2.0/src/site/site_en.xml
branches/eugene-2.0/src/site/site_fr.xml
Removed:
branches/eugene-2.0/eugene-test/nbactions.xml
branches/eugene-2.0/eugene/src/site/en/
branches/eugene-2.0/eugene/src/site/resources/index.html
branches/eugene-2.0/maven-eugene-plugin/src/site/site.xml
branches/eugene-2.0/src/site/site.xml
Modified:
branches/eugene-2.0/eugene/src/site/site_en.xml
branches/eugene-2.0/eugene/src/site/site_fr.xml
branches/eugene-2.0/maven-eugene-plugin/pom.xml
branches/eugene-2.0/maven-eugene-plugin/src/site/rst/index.rst
branches/eugene-2.0/pom.xml
Log:
- use mavenpom 1.1.2
- use normal directory layout for site
- remove ide files
Deleted: branches/eugene-2.0/eugene/src/site/resources/index.html
===================================================================
--- branches/eugene-2.0/eugene/src/site/resources/index.html 2009-12-11 09:58:30 UTC (rev 740)
+++ branches/eugene-2.0/eugene/src/site/resources/index.html 2009-12-11 10:56:36 UTC (rev 741)
@@ -1,9 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- <title>EUGene</title>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <meta http-equiv="Refresh" content="0; url=fr/index.html">
- </head>
- <body />
-</html>
Modified: branches/eugene-2.0/eugene/src/site/site_en.xml
===================================================================
--- branches/eugene-2.0/eugene/src/site/site_en.xml 2009-12-11 09:58:30 UTC (rev 740)
+++ branches/eugene-2.0/eugene/src/site/site_en.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -8,7 +8,7 @@
<body>
<breadcrumbs>
- <item name="${project.name}" href="${project.url}" />
+ <item name="${project.name}" href="index.html" />
</breadcrumbs>
<links>
Modified: branches/eugene-2.0/eugene/src/site/site_fr.xml
===================================================================
--- branches/eugene-2.0/eugene/src/site/site_fr.xml 2009-12-11 09:58:30 UTC (rev 740)
+++ branches/eugene-2.0/eugene/src/site/site_fr.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -8,13 +8,13 @@
<body>
<breadcrumbs>
- <item name="${project.name}" href="${project.url}" />
+ <item name="${project.name}" href="index.html" />
</breadcrumbs>
<links>
<item name="Libre-Entreprise" href="http://www.libre-entreprise.org/" />
<item name="[fr" href="index.html" />
- <item name="en]" href="../en/index.html" />
+ <item name="en]" href="../index.html" />
</links>
<menu ref="parent"/>
Deleted: branches/eugene-2.0/eugene-test/nbactions.xml
===================================================================
--- branches/eugene-2.0/eugene-test/nbactions.xml 2009-12-11 09:58:30 UTC (rev 740)
+++ branches/eugene-2.0/eugene-test/nbactions.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<actions>
- <action>
- <actionName>CUSTOM-debug maven</actionName>
- <displayName>debug maven</displayName>
- <goals>
- <goal>clean</goal>
- <goal>install</goal>
- <goal>-e</goal>
- <goal>-Dlog4j.configuration=file:src/test/resources/log4j.properties</goal>
- </goals>
- </action>
- </actions>
Modified: branches/eugene-2.0/maven-eugene-plugin/pom.xml
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/pom.xml 2009-12-11 09:58:30 UTC (rev 740)
+++ branches/eugene-2.0/maven-eugene-plugin/pom.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -91,7 +91,6 @@
<execution>
<goals>
<goal>generate-metadata</goal>
- <!--<goal>merge-metadata</goal>-->
</goals>
</execution>
</executions>
Copied: branches/eugene-2.0/maven-eugene-plugin/src/site/fr/rst/index.rst (from rev 739, branches/eugene-2.0/maven-eugene-plugin/src/site/rst/index.rst)
===================================================================
(Binary files differ)
Modified: branches/eugene-2.0/maven-eugene-plugin/src/site/rst/index.rst
===================================================================
(Binary files differ)
Deleted: branches/eugene-2.0/maven-eugene-plugin/src/site/site.xml
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/site/site.xml 2009-12-11 09:58:30 UTC (rev 740)
+++ branches/eugene-2.0/maven-eugene-plugin/src/site/site.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="${project.name}">
-
- <bannerLeft>
- <name>${project.name}</name>
- </bannerLeft>
-
- <body>
- <links>
- <item name="Eugene" href="../eugene"/>
- </links>
-
- <breadcrumbs>
- <item name="${project.name}" href="${project.url}" />
- </breadcrumbs>
-
- <menu ref="parent"/>
-
- <menu name="Utilisateur">
- <item href="index.html" name="Accueil"/>
- <item name="Goals" href="plugin-info.html">
- <item name="zargo2xmi" href="zargo2xmi-mojo.html"/>
- <item name="xmi2statemodel" href="xmi2statemodel-mojo.html"/>
- <item name="xmi2objectmodel" href="xmi2objectmodel-mojo.html"/>
- <item name="generate" href="generate-mojo.html"/>
- <item name="copyVersionFiles" href="copyVersionFiles-mojo.html"/>
- <item name="help" href="help-mojo.html"/>
- </item>
- </menu>
-
- <menu name="Téléchargement">
- <item href="${repository.home.url}/org/nuiton/eugene/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
- name="Librairie (jar)"/>
- <item href="${repository.home.url}/org/nuiton/eugene/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
- name="Javadoc (jar)"/>
- <item href="${repository.home.url}/org/nuiton/eugene/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
- name="Sources (jar)"/>
- </menu>
-
- <menu ref="reports"/>
-
- </body>
-</project>
Added: branches/eugene-2.0/maven-eugene-plugin/src/site/site_en.xml
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/site/site_en.xml (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/site/site_en.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ </bannerLeft>
+
+ <body>
+ <links>
+ <item name="Libre-Entreprise" href="http://www.libre-entreprise.org/" />
+ <item name="[fr" href="../fr/index.html" />
+ <item name="en]" href="index.html" />
+ </links>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="User">
+ <item href="index.html" name="Index"/>
+ <item name="Goals" href="plugin-info.html">
+ <item name="zargo2xmi" href="zargo2xmi-mojo.html"/>
+ <item name="xmi2statemodel" href="xmi2statemodel-mojo.html"/>
+ <item name="xmi2objectmodel" href="xmi2objectmodel-mojo.html"/>
+ <item name="generate-model-files" href="generate-model-files-mojo.html"/>
+ <item name="generate" href="generate-mojo.html"/>
+ <item name="copyVersionFiles" href="copyVersionFiles-mojo.html"/>
+ <item name="help" href="help-mojo.html"/>
+ </item>
+ </menu>
+
+ <menu name="Download">
+ <item href="${repository.home.url}/org/nuiton/eugene/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
+ name="Library (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/eugene/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
+ name="Javadoc (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/eugene/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
+ name="Sources (jar)"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Copied: branches/eugene-2.0/maven-eugene-plugin/src/site/site_fr.xml (from rev 739, branches/eugene-2.0/maven-eugene-plugin/src/site/site.xml)
===================================================================
--- branches/eugene-2.0/maven-eugene-plugin/src/site/site_fr.xml (rev 0)
+++ branches/eugene-2.0/maven-eugene-plugin/src/site/site_fr.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ </bannerLeft>
+
+ <body>
+ <links>
+ <item name="Libre-Entreprise" href="http://www.libre-entreprise.org/"/>
+ <item name="[fr" href="index.html"/>
+ <item name="en]" href="../index.html"/>
+ </links>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html"/>
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur">
+ <item href="index.html" name="Accueil"/>
+ <item name="Goals" href="plugin-info.html">
+ <item name="zargo2xmi" href="zargo2xmi-mojo.html"/>
+ <item name="xmi2statemodel" href="xmi2statemodel-mojo.html"/>
+ <item name="xmi2objectmodel" href="xmi2objectmodel-mojo.html"/>
+ <item name="generate-model-files" href="generate-model-files-mojo.html"/>
+ <item name="generate" href="generate-mojo.html"/>
+ <item name="copyVersionFiles" href="copyVersionFiles-mojo.html"/>
+ <item name="help" href="help-mojo.html"/>
+ </item>
+ </menu>
+
+ <menu name="Téléchargement">
+ <item href="${repository.home.url}/org/nuiton/eugene/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
+ name="Librairie (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/eugene/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
+ name="Javadoc (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/eugene/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
+ name="Sources (jar)"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Property changes on: branches/eugene-2.0/maven-eugene-plugin/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: branches/eugene-2.0/pom.xml
===================================================================
--- branches/eugene-2.0/pom.xml 2009-12-11 09:58:30 UTC (rev 740)
+++ branches/eugene-2.0/pom.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.1.1</version>
+ <version>1.1.2</version>
</parent>
<artifactId>eugene</artifactId>
@@ -251,12 +251,11 @@
<!-- TODO TC-20090823 remove ant deps -->
<ant.version>1.7.1</ant.version>
- <processor.version>1.0.2</processor.version>
+ <processor.version>1.0.3-SNAPSHOT</processor.version>
<nuiton-utils.version>1.1.0</nuiton-utils.version>
<!--Multilanguage maven-site -->
<maven.site.locales>en,fr</maven.site.locales>
- <defaultLocale>en</defaultLocale>
</properties>
<build>
Deleted: branches/eugene-2.0/src/site/site.xml
===================================================================
--- branches/eugene-2.0/src/site/site.xml 2009-12-11 09:58:30 UTC (rev 740)
+++ branches/eugene-2.0/src/site/site.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="${project.name}">
-
- <bannerLeft>
- <name>${project.name}</name>
- <href>/</href>
- </bannerLeft>
-
- <poweredBy>
- <logo href="http://maven.apache.org" name="Maven" img="${project.url}/images/logos/maven-feather.png"/>
- <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="${project.url}/images/jrst-logo.png"/>
- <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="${project.url}/images/restructuredtext-logo.png"/>
- </poweredBy>
-
- <body>
-
- <breadcrumbs>
- <item name="${project.name}" href="${project.url}" />
- </breadcrumbs>
-
- <menu ref="modules"/>
-
- <menu ref="reports"/>
- </body>
-</project>
Added: branches/eugene-2.0/src/site/site_en.xml
===================================================================
--- branches/eugene-2.0/src/site/site_en.xml (rev 0)
+++ branches/eugene-2.0/src/site/site_en.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>/</href>
+ </bannerLeft>
+
+ <poweredBy>
+ <logo href="http://maven.apache.org" name="Maven" img="${project.url}/images/logos/maven-feather.png"/>
+ <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="${project.url}/images/jrst-logo.png"/>
+ <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="${project.url}/images/restructuredtext-logo.png"/>
+ </poweredBy>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html" />
+ </breadcrumbs>
+
+ <menu ref="modules"/>
+
+ <menu ref="reports"/>
+ </body>
+</project>
Copied: branches/eugene-2.0/src/site/site_fr.xml (from rev 739, branches/eugene-2.0/src/site/site.xml)
===================================================================
--- branches/eugene-2.0/src/site/site_fr.xml (rev 0)
+++ branches/eugene-2.0/src/site/site_fr.xml 2009-12-11 10:56:36 UTC (rev 741)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>/</href>
+ </bannerLeft>
+
+ <poweredBy>
+ <logo href="http://maven.apache.org" name="Maven" img="${project.url}/images/logos/maven-feather.png"/>
+ <logo href="http://jrst.labs.libre-entreprise.org" name="JRst" img="${project.url}/images/jrst-logo.png"/>
+ <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText" img="${project.url}/images/restructuredtext-logo.png"/>
+ </poweredBy>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="index.html" />
+ </breadcrumbs>
+
+ <menu ref="modules"/>
+
+ <menu ref="reports"/>
+ </body>
+</project>
1
0