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
October 2012
- 2 participants
- 20 discussions
r1188 - in trunk: . eugene eugene-java-templates eugene-maven-plugin
by maven-release@users.nuiton.org 25 Oct '12
by maven-release@users.nuiton.org 25 Oct '12
25 Oct '12
Author: maven-release
Date: 2012-10-25 17:06:50 +0200 (Thu, 25 Oct 2012)
New Revision: 1188
Url: http://nuiton.org/repositories/revision/eugene/1188
Log:
[maven-release-plugin] prepare release eugene-2.5.5
Modified:
trunk/eugene-java-templates/pom.xml
trunk/eugene-maven-plugin/pom.xml
trunk/eugene/pom.xml
trunk/pom.xml
Modified: trunk/eugene/pom.xml
===================================================================
--- trunk/eugene/pom.xml 2012-10-25 15:03:45 UTC (rev 1187)
+++ trunk/eugene/pom.xml 2012-10-25 15:06:50 UTC (rev 1188)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.5.5-SNAPSHOT</version>
+ <version>2.5.5</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/eugene-java-templates/pom.xml
===================================================================
--- trunk/eugene-java-templates/pom.xml 2012-10-25 15:03:45 UTC (rev 1187)
+++ trunk/eugene-java-templates/pom.xml 2012-10-25 15:06:50 UTC (rev 1188)
@@ -29,7 +29,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.5.5-SNAPSHOT</version>
+ <version>2.5.5</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/eugene-maven-plugin/pom.xml
===================================================================
--- trunk/eugene-maven-plugin/pom.xml 2012-10-25 15:03:45 UTC (rev 1187)
+++ trunk/eugene-maven-plugin/pom.xml 2012-10-25 15:06:50 UTC (rev 1188)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.5.5-SNAPSHOT</version>
+ <version>2.5.5</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-10-25 15:03:45 UTC (rev 1187)
+++ trunk/pom.xml 2012-10-25 15:06:50 UTC (rev 1188)
@@ -36,7 +36,7 @@
</parent>
<artifactId>eugene</artifactId>
- <version>2.5.5-SNAPSHOT</version>
+ <version>2.5.5</version>
<modules>
<module>eugene</module>
@@ -462,11 +462,11 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/eugene/trunk</connection>
+ <connection>scm:svn:http://svn.nuiton.org/svn/eugene/tags/eugene-2.5.5</connection>
<developerConnection>
- scm:svn:http://svn.nuiton.org/svn/eugene/trunk
+ scm:svn:http://svn.nuiton.org/svn/eugene/tags/eugene-2.5.5
</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/eugene/trunk</url>
+ <url>http://www.nuiton.org/repositories/browse/eugene/tags/eugene-2.5.5</url>
</scm>
<distributionManagement>
@@ -529,12 +529,12 @@
<tasks>
<copy todir="target/site/xsd/v1" verbose="${maven.verbose}" failonerror="false" overwrite="true">
<fileset dir="${basedir}/eugene/src/main/resources/xsd">
- <include name="**/*.xsd"/>
+ <include name="**/*.xsd" />
</fileset>
</copy>
<copy todir="target/site/dtd/v1" verbose="${maven.verbose}" failonerror="false" overwrite="true">
<fileset dir="${basedir}/eugene/src/main/resources/dtd">
- <include name="**/*.dtd"/>
+ <include name="**/*.dtd" />
</fileset>
</copy>
</tasks>
1
0
Author: tchemit
Date: 2012-10-25 17:03:45 +0200 (Thu, 25 Oct 2012)
New Revision: 1187
Url: http://nuiton.org/repositories/revision/eugene/1187
Log:
optimize dependencies
Modified:
trunk/eugene-java-templates/pom.xml
Modified: trunk/eugene-java-templates/pom.xml
===================================================================
--- trunk/eugene-java-templates/pom.xml 2012-10-25 14:57:04 UTC (rev 1186)
+++ trunk/eugene-java-templates/pom.xml 2012-10-25 15:03:45 UTC (rev 1187)
@@ -44,6 +44,21 @@
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
1
0
r1186 - in trunk: . eugene eugene-java-templates eugene-java-templates/src/license eugene-maven-plugin
by tchemit@users.nuiton.org 25 Oct '12
by tchemit@users.nuiton.org 25 Oct '12
25 Oct '12
Author: tchemit
Date: 2012-10-25 16:57:04 +0200 (Thu, 25 Oct 2012)
New Revision: 1186
Url: http://nuiton.org/repositories/revision/eugene/1186
Log:
prepare release 2.5.5
Modified:
trunk/eugene-java-templates/LICENSE.txt
trunk/eugene-java-templates/README.txt
trunk/eugene-java-templates/changelog.txt
trunk/eugene-java-templates/pom.xml
trunk/eugene-java-templates/src/license/THIRD-PARTY.properties
trunk/eugene-maven-plugin/pom.xml
trunk/eugene/pom.xml
trunk/pom.xml
Modified: trunk/eugene/pom.xml
===================================================================
--- trunk/eugene/pom.xml 2012-10-24 19:38:01 UTC (rev 1185)
+++ trunk/eugene/pom.xml 2012-10-25 14:57:04 UTC (rev 1186)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.6-SNAPSHOT</version>
+ <version>2.5.5-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Property changes on: trunk/eugene-java-templates/LICENSE.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-java-templates/README.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-java-templates/changelog.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/eugene-java-templates/pom.xml
===================================================================
--- trunk/eugene-java-templates/pom.xml 2012-10-24 19:38:01 UTC (rev 1185)
+++ trunk/eugene-java-templates/pom.xml 2012-10-25 14:57:04 UTC (rev 1186)
@@ -29,7 +29,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.6-SNAPSHOT</version>
+ <version>2.5.5-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Property changes on: trunk/eugene-java-templates/src/license/THIRD-PARTY.properties
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Modified: trunk/eugene-maven-plugin/pom.xml
===================================================================
--- trunk/eugene-maven-plugin/pom.xml 2012-10-24 19:38:01 UTC (rev 1185)
+++ trunk/eugene-maven-plugin/pom.xml 2012-10-25 14:57:04 UTC (rev 1186)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.6-SNAPSHOT</version>
+ <version>2.5.5-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-10-24 19:38:01 UTC (rev 1185)
+++ trunk/pom.xml 2012-10-25 14:57:04 UTC (rev 1186)
@@ -36,7 +36,7 @@
</parent>
<artifactId>eugene</artifactId>
- <version>2.6-SNAPSHOT</version>
+ <version>2.5.5-SNAPSHOT</version>
<modules>
<module>eugene</module>
1
0
24 Oct '12
Author: tchemit
Date: 2012-10-24 21:38:01 +0200 (Wed, 24 Oct 2012)
New Revision: 1185
Url: http://nuiton.org/repositories/revision/eugene/1185
Log:
clean link to templates
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java
trunk/eugene/src/main/java/org/nuiton/eugene/EugeneTagValues.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java 2012-10-24 19:34:25 UTC (rev 1184)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/EugeneStereoTypes.java 2012-10-24 19:38:01 UTC (rev 1185)
@@ -24,8 +24,6 @@
*/
package org.nuiton.eugene;
-import org.nuiton.eugene.java.JavaBeanTransformer;
-import org.nuiton.eugene.java.JavaEnumerationTransformer;
import org.nuiton.eugene.java.JavaGeneratorUtil;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
import org.nuiton.eugene.models.object.ObjectModelClassifier;
@@ -46,7 +44,6 @@
/**
* Stereotype for JavaBean objects to place on a classifier.
*
- * @see JavaBeanTransformer
* @see JavaGeneratorUtil#hasBeanStereotype(ObjectModelClassifier)
*/
@StereotypeDefinition(target = ObjectModelClassifier.class,
@@ -75,11 +72,10 @@
/**
* Stereotype to skip generation for some transformer.
*
- * @see JavaEnumerationTransformer
* @see JavaGeneratorUtil#hasSkipStereotype(ObjectModelClassifier)
*/
@StereotypeDefinition(target = ObjectModelClassifier.class,
- documentation = "To specify that a classifier should not been generated.")
- String STEREOTYPE_SKIP= "skip";
+ documentation = "To specify that a classifier should not been generated.")
+ String STEREOTYPE_SKIP = "skip";
}
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/EugeneTagValues.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/EugeneTagValues.java 2012-10-24 19:34:25 UTC (rev 1184)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/EugeneTagValues.java 2012-10-24 19:38:01 UTC (rev 1185)
@@ -24,7 +24,6 @@
*/
package org.nuiton.eugene;
-import org.nuiton.eugene.java.JavaBeanTransformer;
import org.nuiton.eugene.java.JavaGeneratorUtil;
import org.nuiton.eugene.models.object.ObjectModel;
import org.nuiton.eugene.models.object.ObjectModelClassifier;
@@ -91,7 +90,6 @@
* <p/>
* You can globaly use it on the complete model or to a specific classifier.
*
- * @see JavaBeanTransformer
* @see JavaGeneratorUtil#getNoPCSTagValue(ObjectModel, ObjectModelClassifier)
* @since 2.3
*/
1
0
24 Oct '12
Author: tchemit
Date: 2012-10-24 21:34:25 +0200 (Wed, 24 Oct 2012)
New Revision: 1184
Url: http://nuiton.org/repositories/revision/eugene/1184
Log:
use ObjectModelJavaModifier instead of deprectaed ObjectModelModifier
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2012-10-24 19:32:21 UTC (rev 1183)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/java/ObjectModelTransformerToJava.java 2012-10-24 19:34:25 UTC (rev 1184)
@@ -487,7 +487,7 @@
public ObjectModelOperation cloneOperation(ObjectModelOperation source,
ObjectModelClassifier destination,
boolean cloneDocumentation,
- ObjectModelModifier... modifiers) {
+ ObjectModelJavaModifier... modifiers) {
ObjectModelOperation outputOperation = cloneOperationSignature(
source,
destination,
1
0
24 Oct '12
Author: tchemit
Date: 2012-10-24 21:32:21 +0200 (Wed, 24 Oct 2012)
New Revision: 1183
Url: http://nuiton.org/repositories/revision/eugene/1183
Log:
add license and third parties
Added:
trunk/eugene-java-templates/src/license/
trunk/eugene-java-templates/src/license/THIRD-PARTY.properties
Modified:
trunk/eugene-java-templates/LICENSE.txt
Modified: trunk/eugene-java-templates/LICENSE.txt
===================================================================
--- trunk/eugene-java-templates/LICENSE.txt 2012-10-24 19:31:48 UTC (rev 1182)
+++ trunk/eugene-java-templates/LICENSE.txt 2012-10-24 19:32:21 UTC (rev 1183)
@@ -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: trunk/eugene-java-templates/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/eugene-java-templates/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/eugene-java-templates/src/license/THIRD-PARTY.properties 2012-10-24 19:32:21 UTC (rev 1183)
@@ -0,0 +1,25 @@
+# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - BSD License
+# - BSD style
+# - COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
+# - Common Public License Version 1.0
+# - Indiana University Extreme! Lab Software License, vesion 1.1.1
+# - Lesser General Public License (LGPL) v 3.0
+# - Lesser General Public License (LPGL)
+# - Lesser General Public License (LPGL) v 2.1
+# - MIT License
+# - Mozilla Public License Version 1.0
+# - The Apache Software License, Version 2.0
+# - The SAX License
+# - The W3C License
+# - The Werken Company License
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Wed Oct 24 21:31:10 CEST 2012
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
+dom4j--dom4j--1.6.1=BSD
+jdom--jdom--1.0=The Apache Software License, Version 2.0
Property changes on: trunk/eugene-java-templates/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
1
0
r1182 - in trunk/eugene-maven-plugin/src/it: evol-308 evol-879/model evol-879/xmi evol-879/zargo generate generate/all generate/generators generate/only-zargo generate/only-zargo-xmi generate-model-files/testIncludeWithNoProtocol generate-model-files/testIncludeWithOnlyProtocol
by tchemit@users.nuiton.org 24 Oct '12
by tchemit@users.nuiton.org 24 Oct '12
24 Oct '12
Author: tchemit
Date: 2012-10-24 21:31:48 +0200 (Wed, 24 Oct 2012)
New Revision: 1182
Url: http://nuiton.org/repositories/revision/eugene/1182
Log:
add missing svn properties
Modified:
trunk/eugene-maven-plugin/src/it/evol-308/goals.txt
trunk/eugene-maven-plugin/src/it/evol-879/model/goals.txt
trunk/eugene-maven-plugin/src/it/evol-879/xmi/goals.txt
trunk/eugene-maven-plugin/src/it/evol-879/zargo/goals.txt
trunk/eugene-maven-plugin/src/it/generate-model-files/testIncludeWithNoProtocol/goals.txt
trunk/eugene-maven-plugin/src/it/generate-model-files/testIncludeWithOnlyProtocol/goals.txt
trunk/eugene-maven-plugin/src/it/generate/all/goals.txt
trunk/eugene-maven-plugin/src/it/generate/generators/goals.txt
trunk/eugene-maven-plugin/src/it/generate/goals.txt
trunk/eugene-maven-plugin/src/it/generate/only-zargo-xmi/goals.txt
trunk/eugene-maven-plugin/src/it/generate/only-zargo/goals.txt
Property changes on: trunk/eugene-maven-plugin/src/it/evol-308/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/evol-879/model/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/evol-879/xmi/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/evol-879/zargo/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/generate/all/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/generate/generators/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/generate/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/generate/only-zargo/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/generate/only-zargo-xmi/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/generate-model-files/testIncludeWithNoProtocol/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
Property changes on: trunk/eugene-maven-plugin/src/it/generate-model-files/testIncludeWithOnlyProtocol/goals.txt
___________________________________________________________________
Modified: svn:keywords
- Author Date Id Revision
+ Author Date Id Revision HeadURL
1
0
Author: tchemit
Date: 2012-10-24 21:30:08 +0200 (Wed, 24 Oct 2012)
New Revision: 1181
Url: http://nuiton.org/repositories/revision/eugene/1181
Log:
fixes #2282: Extract eugene generator into a new module (there have nothing to do inside eugene module)
Added:
trunk/eugene-java-templates/
trunk/eugene-java-templates/LICENSE.txt
trunk/eugene-java-templates/README.txt
trunk/eugene-java-templates/changelog.txt
trunk/eugene-java-templates/pom.xml
trunk/eugene-java-templates/src/
trunk/eugene-java-templates/src/main/
trunk/eugene-java-templates/src/main/java/
trunk/eugene-java-templates/src/main/java/org/
trunk/eugene-java-templates/src/main/java/org/nuiton/
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/package-info.java
trunk/eugene-java-templates/src/main/resources/
trunk/eugene-java-templates/src/test/
trunk/eugene-java-templates/src/test/java/
trunk/eugene-java-templates/src/test/java/org/
trunk/eugene-java-templates/src/test/java/org/nuiton/
trunk/eugene-java-templates/src/test/java/org/nuiton/eugene/
trunk/eugene-java-templates/src/test/java/org/nuiton/eugene/java/
trunk/eugene-java-templates/src/test/resources/
Removed:
trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java
trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java
trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java
Modified:
trunk/eugene-maven-plugin/pom.xml
trunk/pom.xml
Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java 2012-10-24 19:03:21 UTC (rev 1180)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java 2012-10-24 19:30:08 UTC (rev 1181)
@@ -1,877 +0,0 @@
-/*
- * #%L
- * ToPIA :: Persistence
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 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>.
- * #L%
- */
-package org.nuiton.eugene.java;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.EugeneTagValues;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelInterface;
-import org.nuiton.eugene.models.object.ObjectModelJavaModifier;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/*{generator option: parentheses = false}*/
-/*{generator option: writeString = +}*/
-
-/**
- * JavaBeanTransformer generates simple bean with pcs support
- * (and nothing else) according to the JavaBeans 1.1 norm.
- *
- * Since version 2.2.1, it is possible to
- * <ul>
- * <li>generate a simple POJO (says with no PCS support) by using the tag value {@link EugeneTagValues#TAG_NO_PCS}.</li>
- * <li>generate i18n keys using the tag value {@link EugeneTagValues#TAG_I18N_PREFIX}.</li>
- * </ul>
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.java.JavaBeanTransformer"
- * @since 2.0.2
- */
-public class JavaBeanTransformer extends ObjectModelTransformerToJava {
-
- private static final Log log = LogFactory.getLog(JavaBeanTransformer.class);
-
- public static final String DEFAULT_CONSTANT_PREFIX = "PROPERTY_";
-
- @Override
- public void transformFromClass(ObjectModelClass input) {
-
- if (!JavaGeneratorUtil.hasBeanStereotype(input)) {
-
- // not a bean
- return;
- }
-
- if (canGenerateImpl(input)) {
-
- generateImpl(input);
- }
-
- if (!canGenerateAbstract(input)) {
-
- // nothing more to do
- return;
- }
-
- // test if a super class has bean stereotype
- boolean superClassIsBean = false;
- Collection<ObjectModelClass> superclasses = input.getSuperclasses();
- if(CollectionUtils.isNotEmpty(superclasses)) {
- for (ObjectModelClass superclass : superclasses) {
- if (JavaGeneratorUtil.hasBeanStereotype(superclass)) {
- superClassIsBean = true;
- break;
- }
- }
- }
-
- ObjectModelClass output =
- createAbstractClass(input.getName(), input.getPackageName());
-
- if (log.isDebugEnabled()) {
- log.debug("will generate " + output.getQualifiedName());
- }
-
- String i18nPrefix = JavaGeneratorUtil.getI18nPrefixTagValue(input, model);
- if (!StringUtils.isEmpty(i18nPrefix)) {
- generateI18nBlock(input, output, i18nPrefix);
- }
-
- String noPCSTagValue = JavaGeneratorUtil.getNoPCSTagValue(model, input);
- boolean usePCS = StringUtils.isEmpty(noPCSTagValue) ||
- !"true".equals(noPCSTagValue.trim());
-
- String noGenerateBooleanGetMethods =
- JavaGeneratorUtil.getDoNotGenerateBooleanGetMethods(model, input);
- boolean generateBooleanGetMethods =
- StringUtils.isEmpty(noGenerateBooleanGetMethods) ||
- !"true".equals(noGenerateBooleanGetMethods.trim());
-
- String prefix = getConstantPrefix(input, DEFAULT_CONSTANT_PREFIX);
-
- setConstantPrefix(prefix);
-
- addSuperClass(input, output);
-
- boolean serializableFound = addInterfaces(input, output);
-
- if (superClassIsBean) {
- serializableFound = true;
- }
-
- addSerializable(input, output, serializableFound);
-
- Set<String> constantNames = addConstantsFromDependency(input, output);
-
- // Get available properties
- List<ObjectModelAttribute> properties = getProperties(input);
-
- // Add properties constant
- for (ObjectModelAttribute attr : properties) {
-
- createPropertyConstant(output, attr, prefix, constantNames);
- }
-
- // Add properties field + javabean methods
- for (ObjectModelAttribute attr : properties) {
-
- createProperty(output, attr, usePCS, generateBooleanGetMethods);
- }
-
- // Add operations
- createAbstractOperations(output, input.getOperations());
-
- if (!superClassIsBean) {
-
- if (usePCS) {
-
- // Add property change support
- createPropertyChangeSupport(output);
- }
-
- boolean hasAMultipleProperty = containsMutiple(properties);
-
- // Add helper operations
- if (hasAMultipleProperty) {
- createGetChildMethod(output);
- }
- }
- }
-
- protected boolean canGenerateAbstract(ObjectModelClass input) {
- boolean b = !isInClassPath(input);
- return b;
- }
-
- protected boolean canGenerateImpl(ObjectModelClass input) {
- String fqn = input.getQualifiedName() + "Impl";
-
- if (isInClassPath(fqn)) {
-
- // already in class-path
- return false;
- }
-
- boolean hasOperations = !input.getAllOtherOperations(true).isEmpty() ||
- !input.getOperations().isEmpty();
-
- // generate only if no user operations found
- return !hasOperations;
- }
-
- protected void createPropertyConstant(ObjectModelClass output,
- ObjectModelAttribute attr,
- String prefix,
- Set<String> constantNames) {
-
- String attrName = getAttributeName(attr);
-
- String constantName = prefix + builder.getConstantName(attrName);
-
- if (constantNames.contains(constantName)) {
-
- // already generated
- return;
- }
-
- addConstant(output,
- constantName,
- String.class,
- "\"" + attrName + "\"",
- ObjectModelJavaModifier.PUBLIC
- );
- }
-
- protected String getAttributeName(ObjectModelAttribute attr) {
- String attrName = attr.getName();
- if (attr.hasAssociationClass()) {
- String assocAttrName = JavaGeneratorUtil.getAssocAttrName(attr);
- attrName = JavaGeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
- }
- return attrName;
- }
-
- protected String getAttributeType(ObjectModelAttribute attr) {
- String attrType = attr.getType();
- if (attr.hasAssociationClass()) {
- attrType = attr.getAssociationClass().getName();
- }
- return attrType;
- }
-
- protected boolean containsMutiple(List<ObjectModelAttribute> attributes) {
-
- boolean result = false;
-
- for (ObjectModelAttribute attr : attributes) {
-
- if (JavaGeneratorUtil.isNMultiplicity(attr)) {
- result = true;
-
- break;
- }
-
- }
- return result;
- }
-
- protected void createProperty(ObjectModelClass output,
- ObjectModelAttribute attr,
- boolean usePCS,
- boolean generateBooleanGetMethods) {
-
- String attrName = getAttributeName(attr);
- String attrType = getAttributeType(attr);
-
- boolean multiple = JavaGeneratorUtil.isNMultiplicity(attr);
-
- String constantName = getConstantName(attrName);
- String simpleType = JavaGeneratorUtil.getSimpleName(attrType);
-
- if (multiple) {
-
- createGetChildMethod(output,
- attrName,
- attrType,
- simpleType
- );
-
- createIsEmptyMethod(output,
- attrName
- );
-
- createSizeMethod(output,
- attrName
- );
-
- createAddChildMethod(output,
- attrName,
- attrType,
- constantName,
- usePCS
- );
-
- createAddAllChildrenMethod(output,
- attrName,
- attrType,
- constantName,
- usePCS
- );
-
- createRemoveChildMethod(output,
- attrName,
- attrType,
- constantName,
- usePCS
- );
-
- createRemoveAllChildrenMethod(output,
- attrName,
- attrType,
- constantName,
- usePCS
- );
-
- createContainsChildMethod(output,
- attrName,
- attrType,
- constantName,
- usePCS
- );
-
- createContainsAllChildrenMethod(output,
- attrName,
- attrType,
- constantName,
- usePCS
- );
-
- // Change type for Multiple attribute
- if (attr.isOrdered()) {
- attrType = List.class.getName() + "<" + attrType + ">";
- } else {
- attrType = Collection.class.getName() + "<" + attrType + ">";
- }
-
- simpleType = JavaGeneratorUtil.getSimpleName(attrType);
- }
-
- boolean booleanProperty = JavaGeneratorUtil.isBooleanPrimitive(attr);
-
- if (booleanProperty && !multiple) {
-
- // creates a isXXX method
- createGetMethod(output,
- attrName,
- attrType,
- JavaGeneratorUtil.OPERATION_GETTER_BOOLEAN_PREFIX
- );
- }
-
- if (multiple || !booleanProperty || generateBooleanGetMethods) {
-
- createGetMethod(output,
- attrName,
- attrType,
- JavaGeneratorUtil.OPERATION_GETTER_DEFAULT_PREFIX
- );
-
- }
- createSetMethod(output,
- attrName,
- attrType,
- simpleType,
- constantName,
- usePCS
- );
-
- // Add attribute to the class
- addAttribute(output,
- attrName,
- attrType,
- "",
- ObjectModelJavaModifier.PROTECTED
- );
-
- }
-
- protected void createAbstractOperations(ObjectModelClass ouput,
- Iterable<ObjectModelOperation> operations) {
- JavaGeneratorUtil.cloneOperations(
- this,
- operations,
- ouput,
- true,
- ObjectModelJavaModifier.ABSTRACT
- );
- }
-
- protected List<ObjectModelAttribute> getProperties(ObjectModelClass input) {
- List<ObjectModelAttribute> attributes =
- (List<ObjectModelAttribute>) input.getAttributes();
-
- List<ObjectModelAttribute> attrs =
- new ArrayList<ObjectModelAttribute>();
- for (ObjectModelAttribute attr : attributes) {
- if (attr.isNavigable()) {
-
- // only keep navigable attributes
- attrs.add(attr);
- }
- }
- return attrs;
- }
-
- protected void createGetMethod(ObjectModelClass output,
- String attrName,
- String attrType,
- String methodPrefix) {
-
- ObjectModelOperation getter = addOperation(
- output,
- getJavaBeanMethodName(methodPrefix , attrName),
- attrType,
- ObjectModelJavaModifier.PUBLIC
- );
- setOperationBody(getter, ""
- /*{
- return <%=attrName%>;
- }*/
- );
- }
-
- protected void createGetChildMethod(ObjectModelClass output,
- String attrName,
- String attrType,
- String simpleType) {
- ObjectModelOperation getChild = addOperation(
- output,
- getJavaBeanMethodName("get", attrName),
- attrType,
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(getChild, "int", "index");
- setOperationBody(getChild, ""
- /*{
- <%=simpleType%> o = getChild(<%=attrName%>, index);
- return o;
- }*/
- );
- }
-
- protected void createIsEmptyMethod(ObjectModelClass output,
- String attrName) {
- ObjectModelOperation getChild = addOperation(
- output,
- getJavaBeanMethodName("is", attrName)+"Empty",
- boolean.class,
- ObjectModelJavaModifier.PUBLIC
- );
- setOperationBody(getChild, ""
- /*{
- return <%=attrName%> != null && !<%=attrName%>.isEmpty();
- }*/
- );
- }
-
- protected void createSizeMethod(ObjectModelClass output,
- String attrName) {
- ObjectModelOperation getChild = addOperation(
- output,
- getJavaBeanMethodName("size", attrName),
- int.class,
- ObjectModelJavaModifier.PUBLIC
- );
- setOperationBody(getChild, ""
- /*{
- return <%=attrName%> == null ? 0 : <%=attrName%>.size();
- }*/
- );
- }
- protected void createAddChildMethod(ObjectModelClass output,
- String attrName,
- String attrType,
- String constantName,
- boolean usePCS) {
- ObjectModelOperation addChild = addOperation(
- output,
- getJavaBeanMethodName("add", attrName),
- "void",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(addChild, attrType, attrName);
-
- String methodName = getJavaBeanMethodName("get", attrName);
- StringBuilder buffer = new StringBuilder(""
- /*{
- <%=methodName%>().add(<%=attrName%>);
- }*/
- );
- if (usePCS) {
- buffer.append(""
- /*{
- firePropertyChange(<%=constantName%>, null, <%=attrName%>);
- }*/
- );
- }
- setOperationBody(addChild, buffer.toString());
- }
-
- protected void createAddAllChildrenMethod(ObjectModelClass output,
- String attrName,
- String attrType,
- String constantName,
- boolean usePCS) {
- ObjectModelOperation addAllChild = addOperation(
- output,
- getJavaBeanMethodName("addAll", attrName),
- "void",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(addAllChild, "java.util.Collection<" + attrType + ">", attrName);
-
- String methodName = getJavaBeanMethodName("get", attrName);
- StringBuilder buffer = new StringBuilder(""
- /*{
- <%=methodName%>().addAll(<%=attrName%>);
- }*/
- );
- if (usePCS) {
- buffer.append(""
- /*{
- firePropertyChange(<%=constantName%>, null, <%=attrName%>);
- }*/
- );
- }
- setOperationBody(addAllChild, buffer.toString());
- }
-
- protected void createRemoveChildMethod(ObjectModelClass output,
- String attrName,
- String attrType,
- String constantName,
- boolean usePCS) {
- ObjectModelOperation operation = addOperation(
- output,
- getJavaBeanMethodName("remove", attrName),
- "boolean",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(operation, attrType, attrName);
- String methodName = getJavaBeanMethodName("get", attrName);
- StringBuilder buffer = new StringBuilder();
- buffer.append(""
- /*{
- boolean removed = <%=methodName%>().remove(<%=attrName%>);
- }*/
- );
-
- if (usePCS) {
- buffer.append(""
- /*{
- if (removed) {
- firePropertyChange(<%=constantName%>, <%=attrName%>, null);
- }
- }*/
- );
- }
- buffer.append(""
- /*{
- return removed;
- }*/
- );
- setOperationBody(operation, buffer.toString());
- }
-
- protected void createRemoveAllChildrenMethod(ObjectModelClass output,
- String attrName,
- String attrType,
- String constantName,
- boolean usePCS) {
-
- ObjectModelOperation operation = addOperation(
- output,
- getJavaBeanMethodName("removeAll", attrName),
- "boolean",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(operation, "java.util.Collection<" + attrType + ">", attrName);
- StringBuilder buffer = new StringBuilder();
- String methodName = getJavaBeanMethodName("get", attrName);
- buffer.append(""
- /*{
- boolean removed = <%=methodName%>().removeAll(<%=attrName%>);
- }*/
- );
-
- if (usePCS) {
- buffer.append(""
- /*{
- if (removed) {
- firePropertyChange(<%=constantName%>, <%=attrName%>, null);
- }
- }*/
- );
- }
- buffer.append(""
- /*{
- return removed;
- }*/
- );
- setOperationBody(operation, buffer.toString());
- }
-
- protected void createContainsChildMethod(ObjectModelClass output,
- String attrName,
- String attrType,
- String constantName,
- boolean usePCS) {
-
- ObjectModelOperation operation = addOperation(
- output,
- getJavaBeanMethodName("contains", attrName),
- "boolean",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(operation, attrType, attrName);
- StringBuilder buffer = new StringBuilder();
- String methodName = getJavaBeanMethodName("get", attrName);
- buffer.append(""
- /*{
- boolean contains = <%=methodName%>().contains(<%=attrName%>);
- }*/
- );
-
- buffer.append(""
- /*{
- return contains;
- }*/
- );
- setOperationBody(operation, buffer.toString());
- }
-
- protected void createContainsAllChildrenMethod(ObjectModelClass output,
- String attrName,
- String attrType,
- String constantName,
- boolean usePCS) {
-
- ObjectModelOperation operation = addOperation(
- output,
- getJavaBeanMethodName("containsAll", attrName),
- "boolean",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(operation, "java.util.Collection<" + attrType + ">", attrName);
- StringBuilder buffer = new StringBuilder();
- String methodName = getJavaBeanMethodName("get", attrName);
- buffer.append(""
- /*{
- boolean contains = <%=methodName%>().containsAll(<%=attrName%>);
- }*/
- );
-
- buffer.append(""
- /*{
- return contains;
- }*/
- );
- setOperationBody(operation, buffer.toString());
- }
-
- protected void createSetMethod(ObjectModelClass output,
- String attrName,
- String attrType,
- String simpleType,
- String constantName,
- boolean usePCS) {
- ObjectModelOperation operation = addOperation(
- output,
- getJavaBeanMethodName("set", attrName),
- "void",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(operation, attrType, attrName);
-
- if (usePCS) {
- String methodName = getJavaBeanMethodName("get", attrName);
- setOperationBody(operation, ""
- /*{
- <%=simpleType%> oldValue = <%=methodName%>();
- this.<%=attrName%> = <%=attrName%>;
- firePropertyChange(<%=constantName%>, oldValue, <%=attrName%>);
- }*/
- );
- } else {
- setOperationBody(operation, ""
- /*{
- this.<%=attrName%> = <%=attrName%>;
- }*/
- );
- }
- }
-
- protected void createGetChildMethod(ObjectModelClass output) {
- ObjectModelOperation getChild = addOperation(
- output,
- "getChild", "<T> T",
- ObjectModelJavaModifier.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;
- }*/
- );
- }
-
- protected void addSerializable(ObjectModelClass input,
- ObjectModelClass output,
- boolean interfaceFound) {
- if (!interfaceFound) {
- addInterface(output, Serializable.class);
- }
-
- // Generate the serialVersionUID
- long serialVersionUID = JavaGeneratorUtil.generateSerialVersionUID(input);
-
- addConstant(output,
- JavaGeneratorUtil.SERIAL_VERSION_UID,
- "long",
- serialVersionUID + "L",
- ObjectModelJavaModifier.PRIVATE
- );
- }
-
- /**
- * Add all interfaces defines in input class and returns if
- * {@link Serializable} interface was found.
- *
- * @param input the input model class to process
- * @param output the output generated class
- * @return {@code true} if {@link Serializable} was found from input,
- * {@code false} otherwise
- */
- protected boolean addInterfaces(ObjectModelClass input,
- ObjectModelClass output) {
- boolean foundSerializable = false;
- for (ObjectModelInterface parentInterface : input.getInterfaces()) {
- String fqn = parentInterface.getQualifiedName();
- addInterface(output, fqn);
- if (Serializable.class.getName().equals(fqn)) {
- foundSerializable = true;
- }
- }
- return foundSerializable;
- }
-
- protected void addSuperClass(ObjectModelClass input,
- ObjectModelClass output) {
- // Set superclass
- Iterator<ObjectModelClass> j = input.getSuperclasses().iterator();
- if (j.hasNext()) {
- ObjectModelClass p = j.next();
- // We want to set the inheritance to the implementation class of the father
- // Ex for model : A -> B (a inherits B) we want : A -> BImpl -> B
- String qualifiedName = p.getQualifiedName() + "Impl";
- setSuperClass(output, qualifiedName);
- }
- }
-
- protected ObjectModelClass generateImpl(ObjectModelClass input) {
-
- ObjectModelClass resultClassImpl = createClass(
- input.getName() + "Impl",
- input.getPackageName()
- );
-
- // set the abstract resulClass as the resultClassImpl super class
- setSuperClass(resultClassImpl, input.getQualifiedName());
-
- // add a fix serialVersionUID, since the class has no field nor method
- addConstant(resultClassImpl,
- JavaGeneratorUtil.SERIAL_VERSION_UID,
- "long",
- "1L",
- ObjectModelJavaModifier.PRIVATE
- );
- return resultClassImpl;
- }
-
- protected void createPropertyChangeSupport(ObjectModelClass output) {
-
- addAttribute(output,
- "pcs",
- PropertyChangeSupport.class,
- "new PropertyChangeSupport(this)",
- ObjectModelJavaModifier.PROTECTED,
- ObjectModelJavaModifier.FINAL
- );
-
- // Add PropertyListener
-
- ObjectModelOperation operation;
-
- operation = addOperation(output,
- "addPropertyChangeListener",
- "void",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(operation, PropertyChangeListener.class, "listener");
- setOperationBody(operation, ""
- /*{
- pcs.addPropertyChangeListener(listener);
- }*/
- );
-
- operation = addOperation(output,
- "addPropertyChangeListener",
- "void",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(operation, String.class, "propertyName");
- addParameter(operation, PropertyChangeListener.class, "listener");
- setOperationBody(operation, ""
- /*{
- pcs.addPropertyChangeListener(propertyName, listener);
- }*/
- );
-
- operation = addOperation(output,
- "removePropertyChangeListener",
- "void",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(operation, PropertyChangeListener.class, "listener");
- setOperationBody(operation, ""
- /*{
- pcs.removePropertyChangeListener(listener);
- }*/
- );
-
- operation = addOperation(output,
- "removePropertyChangeListener",
- "void",
- ObjectModelJavaModifier.PUBLIC
- );
- addParameter(operation, String.class, "propertyName");
- addParameter(operation, PropertyChangeListener.class, "listener");
- setOperationBody(operation, ""
- /*{
- pcs.removePropertyChangeListener(propertyName, listener);
- }*/
- );
-
- operation = addOperation(output,
- "firePropertyChange",
- "void",
- ObjectModelJavaModifier.PROTECTED
- );
- addParameter(operation, String.class, "propertyName");
- addParameter(operation, Object.class, "oldValue");
- addParameter(operation, Object.class, "newValue");
- setOperationBody(operation, ""
- /*{
- pcs.firePropertyChange(propertyName, oldValue, newValue);
- }*/
- );
-
- operation = addOperation(output,
- "firePropertyChange",
- "void",
- ObjectModelJavaModifier.PROTECTED
- );
- addParameter(operation, String.class, "propertyName");
- addParameter(operation, Object.class, "newValue");
- setOperationBody(operation, ""
- /*{
- firePropertyChange(propertyName, null, newValue);
- }*/
- );
- }
-
-}
\ No newline at end of file
Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java 2012-10-24 19:03:21 UTC (rev 1180)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java 2012-10-24 19:30:08 UTC (rev 1181)
@@ -1,83 +0,0 @@
-/*
- * #%L
- * EUGene :: EUGene
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2011 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>.
- * #L%
- */
-package org.nuiton.eugene.java;
-
-
-/*{generator option: parentheses = false}*/
-/*{generator option: writeString = +}*/
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.models.object.ObjectModelEnumeration;
-
-import java.util.Collection;
-
-/**
- * JavaEnumerationTransformer generates a enumeration for enuration with
- * stereotype enumeration.
- *
- * @author tchemit <chemit(a)codelutin.com>
- * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.java.JavaEnumerationTransformer"
- * @since 2.5
- */
-public class JavaEnumerationTransformer extends ObjectModelTransformerToJava {
-
- private static final Log log =
- LogFactory.getLog(JavaEnumerationTransformer.class);
-
- @Override
- public void transformFromEnumeration(ObjectModelEnumeration input) {
- if (!canGenerate(input)) {
-
- if (log.isDebugEnabled()) {
- log.debug("Skip generation for " + input.getQualifiedName());
- }
- return;
- }
-
- ObjectModelEnumeration output =
- createEnumeration(input.getName(), input.getPackageName());
-
- if (log.isDebugEnabled()) {
- log.debug("will generate " + output.getQualifiedName());
- }
-
- Collection<String> literals = input.getLiterals();
-
- for (String literal : literals) {
- addLiteral(output, literal);
- }
- }
-
- protected boolean canGenerate(ObjectModelEnumeration input) {
- boolean b = !JavaGeneratorUtil.hasSkipStereotype(input);
- if (b) {
-
- // check if not found in class-path
- b = !isInClassPath(input);
- }
- return b;
- }
-}
\ No newline at end of file
Deleted: trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java 2012-10-24 19:03:21 UTC (rev 1180)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java 2012-10-24 19:30:08 UTC (rev 1181)
@@ -1,139 +0,0 @@
-/*
- * #%L
- * EUGene :: EUGene
- * *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2004 - 2010 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>.
- * #L%
- */
-
-package org.nuiton.eugene.java;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelInterface;
-import org.nuiton.eugene.models.object.ObjectModelJavaModifier;
-
-import java.util.Set;
-
-/*{generator option: parentheses = false}*/
-/*{generator option: writeString = +}*/
-
-/**
- * JavaInterfaceTransformer generates simple interfaces for Java language.
- * <p/>
- * Created: 7 nov. 2009
- *
- * @author fdesbois <fdesbois(a)codelutin.com>
- * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.java.JavaInterfaceTransformer"
- * @since 2.0.2
- */
-public class JavaInterfaceTransformer extends ObjectModelTransformerToJava {
-
- private static final Log log =
- LogFactory.getLog(JavaInterfaceTransformer.class);
-
- @Override
- public void transformFromInterface(ObjectModelInterface input) {
-
- boolean canGenerate = canGenerate(input);
- if (!canGenerate) {
-
- return;
- }
-
- ObjectModelInterface output = createInterface(input.getName(),
- input.getPackageName());
-
- if (log.isDebugEnabled()) {
- log.debug("generate interface " +
- output.getQualifiedName());
- }
-
- // extend interface
-
- for (ObjectModelInterface extend : input.getInterfaces()) {
- addInterface(output, extend.getQualifiedName());
- }
-
- String prefix = getConstantPrefix(input, "");
-
- if (StringUtils.isEmpty(prefix)) {
-
- // no specific prefix, so no prefix
- if (log.isWarnEnabled()) {
- log.warn("[" + input.getName() + "] Will generate constants with NO prefix, not a good idea...");
- }
- }
- setConstantPrefix(prefix);
-
- Set<String> constants = addConstantsFromDependency(input, output);
-
- // constant attributes
- for (ObjectModelAttribute attr : input.getAttributes()) {
-
- if (attr.isStatic() ||
- !StringUtils.isNotEmpty(attr.getDefaultValue())) {
-
- // only static attribut with value
- continue;
- }
-
- String constantName = attr.getName();
-
- if (constants.contains(constantName)) {
-
- // already generated
- continue;
- }
-
- // add constant
- addConstant(output,
- constantName,
- attr.getType(),
- attr.getDefaultValue(),
- ObjectModelJavaModifier.PUBLIC
- );
- }
-
-
- // interface operations
- JavaGeneratorUtil.cloneOperations(this,
- input.getOperations(),
- output,
- false
- );
- }
-
- protected boolean canGenerate(ObjectModelInterface input) {
-
- // check if not found in class-path
- boolean b = !isInClassPath(input);
-
- if (b) {
-
- // only generate when no stereotype are on interface ? Strange !?
- b = input.getStereotypes().isEmpty();
- }
- return b;
- }
-
-}
Property changes on: trunk/eugene-java-templates
___________________________________________________________________
Added: svn:ignore
+ target
*.ipr
*.iws
*.iml
.idea
.project
.classpath
Property changes on: trunk/eugene-java-templates/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Property changes on: trunk/eugene-java-templates/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Property changes on: trunk/eugene-java-templates/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/eugene-java-templates/pom.xml
===================================================================
--- trunk/eugene-java-templates/pom.xml (rev 0)
+++ trunk/eugene-java-templates/pom.xml 2012-10-24 19:30:08 UTC (rev 1181)
@@ -0,0 +1,134 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ EUGene :: EUGene
+
+ $HeadURL$
+ %%
+ Copyright (C) 2004 - 2010 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>.
+ #L%
+ -->
+<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/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>eugene</artifactId>
+ <version>2.6-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>eugene-java-templates</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>eugene</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <name>EUGene :: Java templates</name>
+
+ <inceptionYear>2012</inceptionYear>
+
+ <properties>
+ <!-- extra files to include in release -->
+ <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
+ </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>
+
+ <!-- expose new plexus components -->
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+
+ </build>
+
+ <profiles>
+
+ <!-- perform only on a release stage when using the maven-release-plugin -->
+ <profile>
+ <id>reporting</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-maven-plugin</artifactId>
+ <version>1.3.8</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+ </profiles>
+
+</project>
+
+
+
Property changes on: trunk/eugene-java-templates/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java (from rev 1180, trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java)
===================================================================
--- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java (rev 0)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java 2012-10-24 19:30:08 UTC (rev 1181)
@@ -0,0 +1,877 @@
+/*
+ * #%L
+ * EUGene :: Java templates
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2012 CodeLutin, Tony Chemit
+ * %%
+ * 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>.
+ * #L%
+ */
+package org.nuiton.eugene.java;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.EugeneTagValues;
+import org.nuiton.eugene.models.object.ObjectModelAttribute;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelInterface;
+import org.nuiton.eugene.models.object.ObjectModelJavaModifier;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/*{generator option: parentheses = false}*/
+/*{generator option: writeString = +}*/
+
+/**
+ * JavaBeanTransformer generates simple bean with pcs support
+ * (and nothing else) according to the JavaBeans 1.1 norm.
+ *
+ * Since version 2.2.1, it is possible to
+ * <ul>
+ * <li>generate a simple POJO (says with no PCS support) by using the tag value {@link EugeneTagValues#TAG_NO_PCS}.</li>
+ * <li>generate i18n keys using the tag value {@link EugeneTagValues#TAG_I18N_PREFIX}.</li>
+ * </ul>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.java.JavaBeanTransformer"
+ * @since 2.0.2
+ */
+public class JavaBeanTransformer extends ObjectModelTransformerToJava {
+
+ private static final Log log = LogFactory.getLog(JavaBeanTransformer.class);
+
+ public static final String DEFAULT_CONSTANT_PREFIX = "PROPERTY_";
+
+ @Override
+ public void transformFromClass(ObjectModelClass input) {
+
+ if (!JavaGeneratorUtil.hasBeanStereotype(input)) {
+
+ // not a bean
+ return;
+ }
+
+ if (canGenerateImpl(input)) {
+
+ generateImpl(input);
+ }
+
+ if (!canGenerateAbstract(input)) {
+
+ // nothing more to do
+ return;
+ }
+
+ // test if a super class has bean stereotype
+ boolean superClassIsBean = false;
+ Collection<ObjectModelClass> superclasses = input.getSuperclasses();
+ if(CollectionUtils.isNotEmpty(superclasses)) {
+ for (ObjectModelClass superclass : superclasses) {
+ if (JavaGeneratorUtil.hasBeanStereotype(superclass)) {
+ superClassIsBean = true;
+ break;
+ }
+ }
+ }
+
+ ObjectModelClass output =
+ createAbstractClass(input.getName(), input.getPackageName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("will generate " + output.getQualifiedName());
+ }
+
+ String i18nPrefix = JavaGeneratorUtil.getI18nPrefixTagValue(input, model);
+ if (!StringUtils.isEmpty(i18nPrefix)) {
+ generateI18nBlock(input, output, i18nPrefix);
+ }
+
+ String noPCSTagValue = JavaGeneratorUtil.getNoPCSTagValue(model, input);
+ boolean usePCS = StringUtils.isEmpty(noPCSTagValue) ||
+ !"true".equals(noPCSTagValue.trim());
+
+ String noGenerateBooleanGetMethods =
+ JavaGeneratorUtil.getDoNotGenerateBooleanGetMethods(model, input);
+ boolean generateBooleanGetMethods =
+ StringUtils.isEmpty(noGenerateBooleanGetMethods) ||
+ !"true".equals(noGenerateBooleanGetMethods.trim());
+
+ String prefix = getConstantPrefix(input, DEFAULT_CONSTANT_PREFIX);
+
+ setConstantPrefix(prefix);
+
+ addSuperClass(input, output);
+
+ boolean serializableFound = addInterfaces(input, output);
+
+ if (superClassIsBean) {
+ serializableFound = true;
+ }
+
+ addSerializable(input, output, serializableFound);
+
+ Set<String> constantNames = addConstantsFromDependency(input, output);
+
+ // Get available properties
+ List<ObjectModelAttribute> properties = getProperties(input);
+
+ // Add properties constant
+ for (ObjectModelAttribute attr : properties) {
+
+ createPropertyConstant(output, attr, prefix, constantNames);
+ }
+
+ // Add properties field + javabean methods
+ for (ObjectModelAttribute attr : properties) {
+
+ createProperty(output, attr, usePCS, generateBooleanGetMethods);
+ }
+
+ // Add operations
+ createAbstractOperations(output, input.getOperations());
+
+ if (!superClassIsBean) {
+
+ if (usePCS) {
+
+ // Add property change support
+ createPropertyChangeSupport(output);
+ }
+
+ boolean hasAMultipleProperty = containsMutiple(properties);
+
+ // Add helper operations
+ if (hasAMultipleProperty) {
+ createGetChildMethod(output);
+ }
+ }
+ }
+
+ protected boolean canGenerateAbstract(ObjectModelClass input) {
+ boolean b = !isInClassPath(input);
+ return b;
+ }
+
+ protected boolean canGenerateImpl(ObjectModelClass input) {
+ String fqn = input.getQualifiedName() + "Impl";
+
+ if (isInClassPath(fqn)) {
+
+ // already in class-path
+ return false;
+ }
+
+ boolean hasOperations = !input.getAllOtherOperations(true).isEmpty() ||
+ !input.getOperations().isEmpty();
+
+ // generate only if no user operations found
+ return !hasOperations;
+ }
+
+ protected void createPropertyConstant(ObjectModelClass output,
+ ObjectModelAttribute attr,
+ String prefix,
+ Set<String> constantNames) {
+
+ String attrName = getAttributeName(attr);
+
+ String constantName = prefix + builder.getConstantName(attrName);
+
+ if (constantNames.contains(constantName)) {
+
+ // already generated
+ return;
+ }
+
+ addConstant(output,
+ constantName,
+ String.class,
+ "\"" + attrName + "\"",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ }
+
+ protected String getAttributeName(ObjectModelAttribute attr) {
+ String attrName = attr.getName();
+ if (attr.hasAssociationClass()) {
+ String assocAttrName = JavaGeneratorUtil.getAssocAttrName(attr);
+ attrName = JavaGeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
+ }
+ return attrName;
+ }
+
+ protected String getAttributeType(ObjectModelAttribute attr) {
+ String attrType = attr.getType();
+ if (attr.hasAssociationClass()) {
+ attrType = attr.getAssociationClass().getName();
+ }
+ return attrType;
+ }
+
+ protected boolean containsMutiple(List<ObjectModelAttribute> attributes) {
+
+ boolean result = false;
+
+ for (ObjectModelAttribute attr : attributes) {
+
+ if (JavaGeneratorUtil.isNMultiplicity(attr)) {
+ result = true;
+
+ break;
+ }
+
+ }
+ return result;
+ }
+
+ protected void createProperty(ObjectModelClass output,
+ ObjectModelAttribute attr,
+ boolean usePCS,
+ boolean generateBooleanGetMethods) {
+
+ String attrName = getAttributeName(attr);
+ String attrType = getAttributeType(attr);
+
+ boolean multiple = JavaGeneratorUtil.isNMultiplicity(attr);
+
+ String constantName = getConstantName(attrName);
+ String simpleType = JavaGeneratorUtil.getSimpleName(attrType);
+
+ if (multiple) {
+
+ createGetChildMethod(output,
+ attrName,
+ attrType,
+ simpleType
+ );
+
+ createIsEmptyMethod(output,
+ attrName
+ );
+
+ createSizeMethod(output,
+ attrName
+ );
+
+ createAddChildMethod(output,
+ attrName,
+ attrType,
+ constantName,
+ usePCS
+ );
+
+ createAddAllChildrenMethod(output,
+ attrName,
+ attrType,
+ constantName,
+ usePCS
+ );
+
+ createRemoveChildMethod(output,
+ attrName,
+ attrType,
+ constantName,
+ usePCS
+ );
+
+ createRemoveAllChildrenMethod(output,
+ attrName,
+ attrType,
+ constantName,
+ usePCS
+ );
+
+ createContainsChildMethod(output,
+ attrName,
+ attrType,
+ constantName,
+ usePCS
+ );
+
+ createContainsAllChildrenMethod(output,
+ attrName,
+ attrType,
+ constantName,
+ usePCS
+ );
+
+ // Change type for Multiple attribute
+ if (attr.isOrdered()) {
+ attrType = List.class.getName() + "<" + attrType + ">";
+ } else {
+ attrType = Collection.class.getName() + "<" + attrType + ">";
+ }
+
+ simpleType = JavaGeneratorUtil.getSimpleName(attrType);
+ }
+
+ boolean booleanProperty = JavaGeneratorUtil.isBooleanPrimitive(attr);
+
+ if (booleanProperty && !multiple) {
+
+ // creates a isXXX method
+ createGetMethod(output,
+ attrName,
+ attrType,
+ JavaGeneratorUtil.OPERATION_GETTER_BOOLEAN_PREFIX
+ );
+ }
+
+ if (multiple || !booleanProperty || generateBooleanGetMethods) {
+
+ createGetMethod(output,
+ attrName,
+ attrType,
+ JavaGeneratorUtil.OPERATION_GETTER_DEFAULT_PREFIX
+ );
+
+ }
+ createSetMethod(output,
+ attrName,
+ attrType,
+ simpleType,
+ constantName,
+ usePCS
+ );
+
+ // Add attribute to the class
+ addAttribute(output,
+ attrName,
+ attrType,
+ "",
+ ObjectModelJavaModifier.PROTECTED
+ );
+
+ }
+
+ protected void createAbstractOperations(ObjectModelClass ouput,
+ Iterable<ObjectModelOperation> operations) {
+ JavaGeneratorUtil.cloneOperations(
+ this,
+ operations,
+ ouput,
+ true,
+ ObjectModelJavaModifier.ABSTRACT
+ );
+ }
+
+ protected List<ObjectModelAttribute> getProperties(ObjectModelClass input) {
+ List<ObjectModelAttribute> attributes =
+ (List<ObjectModelAttribute>) input.getAttributes();
+
+ List<ObjectModelAttribute> attrs =
+ new ArrayList<ObjectModelAttribute>();
+ for (ObjectModelAttribute attr : attributes) {
+ if (attr.isNavigable()) {
+
+ // only keep navigable attributes
+ attrs.add(attr);
+ }
+ }
+ return attrs;
+ }
+
+ protected void createGetMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String methodPrefix) {
+
+ ObjectModelOperation getter = addOperation(
+ output,
+ getJavaBeanMethodName(methodPrefix , attrName),
+ attrType,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(getter, ""
+ /*{
+ return <%=attrName%>;
+ }*/
+ );
+ }
+
+ protected void createGetChildMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String simpleType) {
+ ObjectModelOperation getChild = addOperation(
+ output,
+ getJavaBeanMethodName("get", attrName),
+ attrType,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(getChild, "int", "index");
+ setOperationBody(getChild, ""
+ /*{
+ <%=simpleType%> o = getChild(<%=attrName%>, index);
+ return o;
+ }*/
+ );
+ }
+
+ protected void createIsEmptyMethod(ObjectModelClass output,
+ String attrName) {
+ ObjectModelOperation getChild = addOperation(
+ output,
+ getJavaBeanMethodName("is", attrName)+"Empty",
+ boolean.class,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(getChild, ""
+ /*{
+ return <%=attrName%> != null && !<%=attrName%>.isEmpty();
+ }*/
+ );
+ }
+
+ protected void createSizeMethod(ObjectModelClass output,
+ String attrName) {
+ ObjectModelOperation getChild = addOperation(
+ output,
+ getJavaBeanMethodName("size", attrName),
+ int.class,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(getChild, ""
+ /*{
+ return <%=attrName%> == null ? 0 : <%=attrName%>.size();
+ }*/
+ );
+ }
+ protected void createAddChildMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String constantName,
+ boolean usePCS) {
+ ObjectModelOperation addChild = addOperation(
+ output,
+ getJavaBeanMethodName("add", attrName),
+ "void",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(addChild, attrType, attrName);
+
+ String methodName = getJavaBeanMethodName("get", attrName);
+ StringBuilder buffer = new StringBuilder(""
+ /*{
+ <%=methodName%>().add(<%=attrName%>);
+ }*/
+ );
+ if (usePCS) {
+ buffer.append(""
+ /*{
+ firePropertyChange(<%=constantName%>, null, <%=attrName%>);
+ }*/
+ );
+ }
+ setOperationBody(addChild, buffer.toString());
+ }
+
+ protected void createAddAllChildrenMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String constantName,
+ boolean usePCS) {
+ ObjectModelOperation addAllChild = addOperation(
+ output,
+ getJavaBeanMethodName("addAll", attrName),
+ "void",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(addAllChild, "java.util.Collection<" + attrType + ">", attrName);
+
+ String methodName = getJavaBeanMethodName("get", attrName);
+ StringBuilder buffer = new StringBuilder(""
+ /*{
+ <%=methodName%>().addAll(<%=attrName%>);
+ }*/
+ );
+ if (usePCS) {
+ buffer.append(""
+ /*{
+ firePropertyChange(<%=constantName%>, null, <%=attrName%>);
+ }*/
+ );
+ }
+ setOperationBody(addAllChild, buffer.toString());
+ }
+
+ protected void createRemoveChildMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String constantName,
+ boolean usePCS) {
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("remove", attrName),
+ "boolean",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, attrType, attrName);
+ String methodName = getJavaBeanMethodName("get", attrName);
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(""
+ /*{
+ boolean removed = <%=methodName%>().remove(<%=attrName%>);
+ }*/
+ );
+
+ if (usePCS) {
+ buffer.append(""
+ /*{
+ if (removed) {
+ firePropertyChange(<%=constantName%>, <%=attrName%>, null);
+ }
+ }*/
+ );
+ }
+ buffer.append(""
+ /*{
+ return removed;
+ }*/
+ );
+ setOperationBody(operation, buffer.toString());
+ }
+
+ protected void createRemoveAllChildrenMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String constantName,
+ boolean usePCS) {
+
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("removeAll", attrName),
+ "boolean",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, "java.util.Collection<" + attrType + ">", attrName);
+ StringBuilder buffer = new StringBuilder();
+ String methodName = getJavaBeanMethodName("get", attrName);
+ buffer.append(""
+ /*{
+ boolean removed = <%=methodName%>().removeAll(<%=attrName%>);
+ }*/
+ );
+
+ if (usePCS) {
+ buffer.append(""
+ /*{
+ if (removed) {
+ firePropertyChange(<%=constantName%>, <%=attrName%>, null);
+ }
+ }*/
+ );
+ }
+ buffer.append(""
+ /*{
+ return removed;
+ }*/
+ );
+ setOperationBody(operation, buffer.toString());
+ }
+
+ protected void createContainsChildMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String constantName,
+ boolean usePCS) {
+
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("contains", attrName),
+ "boolean",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, attrType, attrName);
+ StringBuilder buffer = new StringBuilder();
+ String methodName = getJavaBeanMethodName("get", attrName);
+ buffer.append(""
+ /*{
+ boolean contains = <%=methodName%>().contains(<%=attrName%>);
+ }*/
+ );
+
+ buffer.append(""
+ /*{
+ return contains;
+ }*/
+ );
+ setOperationBody(operation, buffer.toString());
+ }
+
+ protected void createContainsAllChildrenMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String constantName,
+ boolean usePCS) {
+
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("containsAll", attrName),
+ "boolean",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, "java.util.Collection<" + attrType + ">", attrName);
+ StringBuilder buffer = new StringBuilder();
+ String methodName = getJavaBeanMethodName("get", attrName);
+ buffer.append(""
+ /*{
+ boolean contains = <%=methodName%>().containsAll(<%=attrName%>);
+ }*/
+ );
+
+ buffer.append(""
+ /*{
+ return contains;
+ }*/
+ );
+ setOperationBody(operation, buffer.toString());
+ }
+
+ protected void createSetMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String simpleType,
+ String constantName,
+ boolean usePCS) {
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("set", attrName),
+ "void",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, attrType, attrName);
+
+ if (usePCS) {
+ String methodName = getJavaBeanMethodName("get", attrName);
+ setOperationBody(operation, ""
+ /*{
+ <%=simpleType%> oldValue = <%=methodName%>();
+ this.<%=attrName%> = <%=attrName%>;
+ firePropertyChange(<%=constantName%>, oldValue, <%=attrName%>);
+ }*/
+ );
+ } else {
+ setOperationBody(operation, ""
+ /*{
+ this.<%=attrName%> = <%=attrName%>;
+ }*/
+ );
+ }
+ }
+
+ protected void createGetChildMethod(ObjectModelClass output) {
+ ObjectModelOperation getChild = addOperation(
+ output,
+ "getChild", "<T> T",
+ ObjectModelJavaModifier.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;
+ }*/
+ );
+ }
+
+ protected void addSerializable(ObjectModelClass input,
+ ObjectModelClass output,
+ boolean interfaceFound) {
+ if (!interfaceFound) {
+ addInterface(output, Serializable.class);
+ }
+
+ // Generate the serialVersionUID
+ long serialVersionUID = JavaGeneratorUtil.generateSerialVersionUID(input);
+
+ addConstant(output,
+ JavaGeneratorUtil.SERIAL_VERSION_UID,
+ "long",
+ serialVersionUID + "L",
+ ObjectModelJavaModifier.PRIVATE
+ );
+ }
+
+ /**
+ * Add all interfaces defines in input class and returns if
+ * {@link Serializable} interface was found.
+ *
+ * @param input the input model class to process
+ * @param output the output generated class
+ * @return {@code true} if {@link Serializable} was found from input,
+ * {@code false} otherwise
+ */
+ protected boolean addInterfaces(ObjectModelClass input,
+ ObjectModelClass output) {
+ boolean foundSerializable = false;
+ for (ObjectModelInterface parentInterface : input.getInterfaces()) {
+ String fqn = parentInterface.getQualifiedName();
+ addInterface(output, fqn);
+ if (Serializable.class.getName().equals(fqn)) {
+ foundSerializable = true;
+ }
+ }
+ return foundSerializable;
+ }
+
+ protected void addSuperClass(ObjectModelClass input,
+ ObjectModelClass output) {
+ // Set superclass
+ Iterator<ObjectModelClass> j = input.getSuperclasses().iterator();
+ if (j.hasNext()) {
+ ObjectModelClass p = j.next();
+ // We want to set the inheritance to the implementation class of the father
+ // Ex for model : A -> B (a inherits B) we want : A -> BImpl -> B
+ String qualifiedName = p.getQualifiedName() + "Impl";
+ setSuperClass(output, qualifiedName);
+ }
+ }
+
+ protected ObjectModelClass generateImpl(ObjectModelClass input) {
+
+ ObjectModelClass resultClassImpl = createClass(
+ input.getName() + "Impl",
+ input.getPackageName()
+ );
+
+ // set the abstract resulClass as the resultClassImpl super class
+ setSuperClass(resultClassImpl, input.getQualifiedName());
+
+ // add a fix serialVersionUID, since the class has no field nor method
+ addConstant(resultClassImpl,
+ JavaGeneratorUtil.SERIAL_VERSION_UID,
+ "long",
+ "1L",
+ ObjectModelJavaModifier.PRIVATE
+ );
+ return resultClassImpl;
+ }
+
+ protected void createPropertyChangeSupport(ObjectModelClass output) {
+
+ addAttribute(output,
+ "pcs",
+ PropertyChangeSupport.class,
+ "new PropertyChangeSupport(this)",
+ ObjectModelJavaModifier.PROTECTED,
+ ObjectModelJavaModifier.FINAL
+ );
+
+ // Add PropertyListener
+
+ ObjectModelOperation operation;
+
+ operation = addOperation(output,
+ "addPropertyChangeListener",
+ "void",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, PropertyChangeListener.class, "listener");
+ setOperationBody(operation, ""
+ /*{
+ pcs.addPropertyChangeListener(listener);
+ }*/
+ );
+
+ operation = addOperation(output,
+ "addPropertyChangeListener",
+ "void",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, String.class, "propertyName");
+ addParameter(operation, PropertyChangeListener.class, "listener");
+ setOperationBody(operation, ""
+ /*{
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }*/
+ );
+
+ operation = addOperation(output,
+ "removePropertyChangeListener",
+ "void",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, PropertyChangeListener.class, "listener");
+ setOperationBody(operation, ""
+ /*{
+ pcs.removePropertyChangeListener(listener);
+ }*/
+ );
+
+ operation = addOperation(output,
+ "removePropertyChangeListener",
+ "void",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, String.class, "propertyName");
+ addParameter(operation, PropertyChangeListener.class, "listener");
+ setOperationBody(operation, ""
+ /*{
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }*/
+ );
+
+ operation = addOperation(output,
+ "firePropertyChange",
+ "void",
+ ObjectModelJavaModifier.PROTECTED
+ );
+ addParameter(operation, String.class, "propertyName");
+ addParameter(operation, Object.class, "oldValue");
+ addParameter(operation, Object.class, "newValue");
+ setOperationBody(operation, ""
+ /*{
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }*/
+ );
+
+ operation = addOperation(output,
+ "firePropertyChange",
+ "void",
+ ObjectModelJavaModifier.PROTECTED
+ );
+ addParameter(operation, String.class, "propertyName");
+ addParameter(operation, Object.class, "newValue");
+ setOperationBody(operation, ""
+ /*{
+ firePropertyChange(propertyName, null, newValue);
+ }*/
+ );
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java (from rev 1179, trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java)
===================================================================
--- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java (rev 0)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java 2012-10-24 19:30:08 UTC (rev 1181)
@@ -0,0 +1,83 @@
+/*
+ * #%L
+ * EUGene :: Java templates
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2011 CodeLutin, Tony Chemit
+ * %%
+ * 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>.
+ * #L%
+ */
+package org.nuiton.eugene.java;
+
+
+/*{generator option: parentheses = false}*/
+/*{generator option: writeString = +}*/
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.models.object.ObjectModelEnumeration;
+
+import java.util.Collection;
+
+/**
+ * JavaEnumerationTransformer generates a enumeration for enuration with
+ * stereotype enumeration.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.java.JavaEnumerationTransformer"
+ * @since 2.5
+ */
+public class JavaEnumerationTransformer extends ObjectModelTransformerToJava {
+
+ private static final Log log =
+ LogFactory.getLog(JavaEnumerationTransformer.class);
+
+ @Override
+ public void transformFromEnumeration(ObjectModelEnumeration input) {
+ if (!canGenerate(input)) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Skip generation for " + input.getQualifiedName());
+ }
+ return;
+ }
+
+ ObjectModelEnumeration output =
+ createEnumeration(input.getName(), input.getPackageName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("will generate " + output.getQualifiedName());
+ }
+
+ Collection<String> literals = input.getLiterals();
+
+ for (String literal : literals) {
+ addLiteral(output, literal);
+ }
+ }
+
+ protected boolean canGenerate(ObjectModelEnumeration input) {
+ boolean b = !JavaGeneratorUtil.hasSkipStereotype(input);
+ if (b) {
+
+ // check if not found in class-path
+ b = !isInClassPath(input);
+ }
+ return b;
+ }
+}
\ No newline at end of file
Property changes on: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaEnumerationTransformer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java (from rev 1179, trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java)
===================================================================
--- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java (rev 0)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java 2012-10-24 19:30:08 UTC (rev 1181)
@@ -0,0 +1,139 @@
+/*
+ * #%L
+ * EUGene :: Java templates
+ * *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2004 - 2010 CodeLutin, Tony Chemit
+ * %%
+ * 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>.
+ * #L%
+ */
+
+package org.nuiton.eugene.java;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.models.object.ObjectModelAttribute;
+import org.nuiton.eugene.models.object.ObjectModelInterface;
+import org.nuiton.eugene.models.object.ObjectModelJavaModifier;
+
+import java.util.Set;
+
+/*{generator option: parentheses = false}*/
+/*{generator option: writeString = +}*/
+
+/**
+ * JavaInterfaceTransformer generates simple interfaces for Java language.
+ * <p/>
+ * Created: 7 nov. 2009
+ *
+ * @author fdesbois <fdesbois(a)codelutin.com>
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.java.JavaInterfaceTransformer"
+ * @since 2.0.2
+ */
+public class JavaInterfaceTransformer extends ObjectModelTransformerToJava {
+
+ private static final Log log =
+ LogFactory.getLog(JavaInterfaceTransformer.class);
+
+ @Override
+ public void transformFromInterface(ObjectModelInterface input) {
+
+ boolean canGenerate = canGenerate(input);
+ if (!canGenerate) {
+
+ return;
+ }
+
+ ObjectModelInterface output = createInterface(input.getName(),
+ input.getPackageName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("generate interface " +
+ output.getQualifiedName());
+ }
+
+ // extend interface
+
+ for (ObjectModelInterface extend : input.getInterfaces()) {
+ addInterface(output, extend.getQualifiedName());
+ }
+
+ String prefix = getConstantPrefix(input, "");
+
+ if (StringUtils.isEmpty(prefix)) {
+
+ // no specific prefix, so no prefix
+ if (log.isWarnEnabled()) {
+ log.warn("[" + input.getName() + "] Will generate constants with NO prefix, not a good idea...");
+ }
+ }
+ setConstantPrefix(prefix);
+
+ Set<String> constants = addConstantsFromDependency(input, output);
+
+ // constant attributes
+ for (ObjectModelAttribute attr : input.getAttributes()) {
+
+ if (attr.isStatic() ||
+ !StringUtils.isNotEmpty(attr.getDefaultValue())) {
+
+ // only static attribut with value
+ continue;
+ }
+
+ String constantName = attr.getName();
+
+ if (constants.contains(constantName)) {
+
+ // already generated
+ continue;
+ }
+
+ // add constant
+ addConstant(output,
+ constantName,
+ attr.getType(),
+ attr.getDefaultValue(),
+ ObjectModelJavaModifier.PUBLIC
+ );
+ }
+
+
+ // interface operations
+ JavaGeneratorUtil.cloneOperations(this,
+ input.getOperations(),
+ output,
+ false
+ );
+ }
+
+ protected boolean canGenerate(ObjectModelInterface input) {
+
+ // check if not found in class-path
+ boolean b = !isInClassPath(input);
+
+ if (b) {
+
+ // only generate when no stereotype are on interface ? Strange !?
+ b = input.getStereotypes().isEmpty();
+ }
+ return b;
+ }
+
+}
Property changes on: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaInterfaceTransformer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/package-info.java
===================================================================
--- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/package-info.java (rev 0)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/package-info.java 2012-10-24 19:30:08 UTC (rev 1181)
@@ -0,0 +1,33 @@
+/**
+ * Eugene java package : Java generators.
+ * <pre>
+ * - Generator : {@link JavaBeanTransformer } to generate a bean.
+ * - Generator : {@link JavaEnumerationTransformer } to generate a enumeration.
+ * - Generator : {@link JavaInterfaceTransformer } to generate a interface.
+ * </pre>
+ */
+package org.nuiton.eugene.java;
+
+/*
+ * #%L
+ * EUGene :: Java templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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>.
+ * #L%
+ */
Property changes on: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Modified: trunk/eugene-maven-plugin/pom.xml
===================================================================
--- trunk/eugene-maven-plugin/pom.xml 2012-10-24 19:03:21 UTC (rev 1180)
+++ trunk/eugene-maven-plugin/pom.xml 2012-10-24 19:30:08 UTC (rev 1181)
@@ -50,6 +50,13 @@
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>eugene-java-templates</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
</dependency>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-10-24 19:03:21 UTC (rev 1180)
+++ trunk/pom.xml 2012-10-24 19:30:08 UTC (rev 1181)
@@ -40,6 +40,7 @@
<modules>
<module>eugene</module>
+ <module>eugene-java-templates</module>
<module>eugene-maven-plugin</module>
<!--<module>ant-eugene-task</module>-->
</modules>
@@ -396,8 +397,8 @@
<projectId>eugene</projectId>
<processorPluginVersion>1.2.2</processorPluginVersion>
- <nuitonUtilsVersion>2.5.3</nuitonUtilsVersion>
- <nuitonI18nVersion>2.4.1</nuitonI18nVersion>
+ <nuitonUtilsVersion>2.6.3</nuitonUtilsVersion>
+ <nuitonI18nVersion>2.5</nuitonI18nVersion>
<!--Multilanguage maven-site -->
<locales>en,fr</locales>
1
0
24 Oct '12
Author: tchemit
Date: 2012-10-24 21:03:21 +0200 (Wed, 24 Oct 2012)
New Revision: 1180
Url: http://nuiton.org/repositories/revision/eugene/1180
Log:
fixes #2371: Improve java eugene generator when inheritance is used
fixes #2372: Add isXXXEmpty and sizeXXX method in bean for properties (with multiplicity>1)
Modified:
trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java
Modified: trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java
===================================================================
--- trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java 2012-10-11 02:47:54 UTC (rev 1179)
+++ trunk/eugene/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java 2012-10-24 19:03:21 UTC (rev 1180)
@@ -24,6 +24,7 @@
*/
package org.nuiton.eugene.java;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -86,6 +87,18 @@
return;
}
+ // test if a super class has bean stereotype
+ boolean superClassIsBean = false;
+ Collection<ObjectModelClass> superclasses = input.getSuperclasses();
+ if(CollectionUtils.isNotEmpty(superclasses)) {
+ for (ObjectModelClass superclass : superclasses) {
+ if (JavaGeneratorUtil.hasBeanStereotype(superclass)) {
+ superClassIsBean = true;
+ break;
+ }
+ }
+ }
+
ObjectModelClass output =
createAbstractClass(input.getName(), input.getPackageName());
@@ -116,6 +129,10 @@
boolean serializableFound = addInterfaces(input, output);
+ if (superClassIsBean) {
+ serializableFound = true;
+ }
+
addSerializable(input, output, serializableFound);
Set<String> constantNames = addConstantsFromDependency(input, output);
@@ -138,17 +155,20 @@
// Add operations
createAbstractOperations(output, input.getOperations());
- if (usePCS) {
-
- // Add property change support
- createPropertyChangeSupport(output);
- }
+ if (!superClassIsBean) {
- boolean hasAMultipleProperty = containsMutiple(properties);
+ if (usePCS) {
- // Add helper operations
- if (hasAMultipleProperty) {
- createGetChildMethod(output);
+ // Add property change support
+ createPropertyChangeSupport(output);
+ }
+
+ boolean hasAMultipleProperty = containsMutiple(properties);
+
+ // Add helper operations
+ if (hasAMultipleProperty) {
+ createGetChildMethod(output);
+ }
}
}
@@ -250,6 +270,14 @@
simpleType
);
+ createIsEmptyMethod(output,
+ attrName
+ );
+
+ createSizeMethod(output,
+ attrName
+ );
+
createAddChildMethod(output,
attrName,
attrType,
@@ -405,6 +433,35 @@
);
}
+ protected void createIsEmptyMethod(ObjectModelClass output,
+ String attrName) {
+ ObjectModelOperation getChild = addOperation(
+ output,
+ getJavaBeanMethodName("is", attrName)+"Empty",
+ boolean.class,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(getChild, ""
+ /*{
+ return <%=attrName%> != null && !<%=attrName%>.isEmpty();
+ }*/
+ );
+ }
+
+ protected void createSizeMethod(ObjectModelClass output,
+ String attrName) {
+ ObjectModelOperation getChild = addOperation(
+ output,
+ getJavaBeanMethodName("size", attrName),
+ int.class,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(getChild, ""
+ /*{
+ return <%=attrName%> == null ? 0 : <%=attrName%>.size();
+ }*/
+ );
+ }
protected void createAddChildMethod(ObjectModelClass output,
String attrName,
String attrType,
1
0
Author: tchemit
Date: 2012-10-11 04:47:54 +0200 (Thu, 11 Oct 2012)
New Revision: 1179
Url: http://nuiton.org/repositories/revision/eugene/1179
Log:
Update mavenpom4redmineAndCentral to 3.4.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-08-30 14:42:46 UTC (rev 1178)
+++ trunk/pom.xml 2012-10-11 02:47:54 UTC (rev 1179)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.3.7</version>
+ <version>3.4</version>
</parent>
<artifactId>eugene</artifactId>
1
0