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
March 2013
- 1 participants
- 2 discussions
r1235 - in trunk: . eugene eugene-java-templates eugene-java-templates/src/main/java/org/nuiton/eugene/java eugene-jpa-templates eugene-maven-plugin
by tchemit@users.nuiton.org 29 Mar '13
by tchemit@users.nuiton.org 29 Mar '13
29 Mar '13
Author: tchemit
Date: 2013-03-30 00:36:59 +0100 (Sat, 30 Mar 2013)
New Revision: 1235
Url: http://nuiton.org/projects/eugene/repository/revisions/1235
Log:
- move to version 2.6.2-SNAPSHOT
- remove from build eugene-jpa-templates (don't want to expose it in this version)
fixes #2636: SimpleBean generator does not add abstract modifier if required
fixes #2637: Can suffix simple bean generated classes names
fixes #2638: Can generate beanFactory from simple bean
fixes #2639: Can generate interface from simple bean
fixes #2640: Can prefix simple bean generated classes names
fixes #2641: Can prefix simple bean generated interfaces names
fixes #2642: Can suffix simple bean generated interfaces names
fixes #2643: Can choose a default interface to place on generated interface of simple beans (when simple bean has not super bean)
fixes #2644: Can choose a default class to place on generated simple beans (when simple bean has not super bean)
Modified:
trunk/eugene-java-templates/pom.xml
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/AbstractJavaBeanTransformer.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/JavaTemplatesGeneratorUtil.java
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesTagValues.java
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/SimpleJavaBeanTransformer.java
trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/package-info.java
trunk/eugene-jpa-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 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene/pom.xml 2013-03-29 23:36:59 UTC (rev 1235)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.6.2-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/eugene-java-templates/pom.xml
===================================================================
--- trunk/eugene-java-templates/pom.xml 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene-java-templates/pom.xml 2013-03-29 23:36:59 UTC (rev 1235)
@@ -29,7 +29,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.6.2-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/AbstractJavaBeanTransformer.java
===================================================================
--- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/AbstractJavaBeanTransformer.java 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/AbstractJavaBeanTransformer.java 2013-03-29 23:36:59 UTC (rev 1235)
@@ -28,8 +28,10 @@
/*{generator option: parentheses = false}*/
/*{generator option: writeString = +}*/
+import org.apache.commons.lang3.StringUtils;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelClassifier;
import org.nuiton.eugene.models.object.ObjectModelInterface;
import org.nuiton.eugene.models.object.ObjectModelJavaModifier;
import org.nuiton.eugene.models.object.ObjectModelOperation;
@@ -39,6 +41,7 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -54,7 +57,7 @@
public static final String DEFAULT_CONSTANT_PREFIX = "PROPERTY_";
- protected void createPropertyConstant(ObjectModelClass output,
+ protected void createPropertyConstant(ObjectModelClassifier output,
ObjectModelAttribute attr,
String prefix,
Set<String> constantNames) {
@@ -538,21 +541,27 @@
* Add all interfaces defines in input class and returns if
* {@link Serializable} interface was found.
*
- * @param input the input model class to process
+ * @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) {
+ ObjectModelClassifier output,
+ String extraInterfaceName) {
boolean foundSerializable = false;
+ Set<String> added = new HashSet<String>();
for (ObjectModelInterface parentInterface : input.getInterfaces()) {
String fqn = parentInterface.getQualifiedName();
+ added.add(fqn);
addInterface(output, fqn);
- if (Serializable.class.getName().equals(fqn)) {
+ if (Serializable.class.getName().equals(fqn)) {
foundSerializable = true;
}
}
+ if (extraInterfaceName != null && !added.contains(extraInterfaceName)) {
+ addInterface(output, extraInterfaceName);
+ }
return foundSerializable;
}
@@ -682,4 +691,46 @@
}*/
);
}
+
+ protected void generateI18nBlockAndConstants(ObjectModelClass input,
+ ObjectModelClassifier output) {
+
+ String i18nPrefix = JavaGeneratorUtil.getI18nPrefixTagValue(input, model);
+ if (!StringUtils.isEmpty(i18nPrefix)) {
+ generateI18nBlock(input, output, i18nPrefix);
+ }
+
+ String prefix = getConstantPrefix(input, DEFAULT_CONSTANT_PREFIX);
+
+ setConstantPrefix(prefix);
+
+ Set<String> constantNames = addConstantsFromDependency(input, output);
+
+ // Add properties constant
+ for (ObjectModelAttribute attr : getProperties(input)) {
+
+ createPropertyConstant(output, attr, prefix, constantNames);
+ }
+ }
+
+ protected void addDefaultMethodForNoneBeanSuperClass(ObjectModelClass output,
+ boolean usePCS,
+ List<ObjectModelAttribute> properties) {
+
+
+ if (usePCS) {
+
+ // Add property change support
+ createPropertyChangeSupport(output);
+ }
+
+ boolean hasAMultipleProperty = containsMutiple(properties);
+
+ // Add helper operations
+ if (hasAMultipleProperty) {
+
+ // add getChild methods
+ createGetChildMethod(output);
+ }
+ }
}
Modified: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java
===================================================================
--- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaBeanTransformer.java 2013-03-29 23:36:59 UTC (rev 1235)
@@ -37,7 +37,6 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import java.util.Set;
/*{generator option: parentheses = false}*/
/*{generator option: writeString = +}*/
@@ -45,7 +44,7 @@
/**
* JavaBeanTransformer generates simple bean with pcs support
* (and nothing else) according to the JavaBeans 1.1 norm.
- *
+ * <p/>
* 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 JavaTemplatesTagValues#TAG_NO_PCS}.</li>
@@ -113,7 +112,7 @@
Collection<ObjectModelOperation> allExistingOperations =
new ArrayList<ObjectModelOperation>(input.getAllSuperclassOperations(true));
- if (abstractOutput!=null) {
+ if (abstractOutput != null) {
allExistingOperations.addAll(abstractOutput.getOperations());
}
@@ -126,20 +125,12 @@
}
}
return true;
-
-// boolean hasOperations = !allOtherOperations.isEmpty() ||
-// !operations.isEmpty();
-//
-// // generate only if no user operations found
-// return !hasOperations;
}
-
-
protected void createAbstractOperations(ObjectModelClass ouput,
Iterable<ObjectModelOperation> operations) {
- JavaGeneratorUtil.cloneOperations(
+ JavaTemplatesGeneratorUtil.cloneOperations(
this,
operations,
ouput,
@@ -152,7 +143,7 @@
// test if a super class has bean stereotype
boolean superClassIsBean = false;
Collection<ObjectModelClass> superclasses = input.getSuperclasses();
- if(CollectionUtils.isNotEmpty(superclasses)) {
+ if (CollectionUtils.isNotEmpty(superclasses)) {
for (ObjectModelClass superclass : superclasses) {
if (JavaTemplatesGeneratorUtil.hasBeanStereotype(superclass)) {
superClassIsBean = true;
@@ -186,46 +177,31 @@
log.debug("will generate " + output.getQualifiedName());
}
- String i18nPrefix = JavaGeneratorUtil.getI18nPrefixTagValue(input, model);
- if (!StringUtils.isEmpty(i18nPrefix)) {
- generateI18nBlock(input, output, i18nPrefix);
+ addSuperClass(input, output);
+
+ boolean serializableFound = addInterfaces(input, output, null);
+
+ if (superClassIsBean) {
+ serializableFound = true;
}
+ addSerializable(input, output, serializableFound);
+
+ generateI18nBlockAndConstants(input, output);
+
String noPCSTagValue = JavaTemplatesGeneratorUtil.getNoPCSTagValue(model, input);
boolean usePCS = StringUtils.isEmpty(noPCSTagValue) ||
!"true".equals(noPCSTagValue.trim());
String noGenerateBooleanGetMethods =
- JavaGeneratorUtil.getDoNotGenerateBooleanGetMethods(model, input);
+ JavaTemplatesGeneratorUtil.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) {
@@ -236,26 +212,9 @@
createAbstractOperations(output, input.getOperations());
if (!superClassIsBean) {
-
- if (usePCS) {
-
- // Add property change support
- createPropertyChangeSupport(output);
- }
+ addDefaultMethodForNoneBeanSuperClass(output, usePCS, properties);
}
- boolean hasAMultipleProperty = containsMutiple(properties);
-
- // Add helper operations
- if (hasAMultipleProperty) {
-
- if (!superClassIsBean) {
-
- // add getChild methods
- createGetChildMethod(output);
- }
-
- }
return output;
}
@@ -271,7 +230,7 @@
// add a fix serialVersionUID, since the class has no field nor method
addConstant(resultClassImpl,
- JavaGeneratorUtil.SERIAL_VERSION_UID,
+ JavaTemplatesGeneratorUtil.SERIAL_VERSION_UID,
"long",
"1L",
ObjectModelJavaModifier.PRIVATE
Modified: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesGeneratorUtil.java
===================================================================
--- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesGeneratorUtil.java 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesGeneratorUtil.java 2013-03-29 23:36:59 UTC (rev 1235)
@@ -80,4 +80,137 @@
String value = findTagValue(JavaTemplatesTagValues.TAG_BEAN_SUPER_CLASS, classifier, model);
return value;
}
+
+ /**
+ * Obtain the value of the {@link JavaTemplatesTagValues#TAG_SIMPLE_BEAN_SUPER_CLASS}
+ * tag value on the given model or classifier.
+ * <p/>
+ * It will first look on the model, and then in the given classifier.
+ *
+ * @param model model to seek
+ * @param classifier classifier to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JavaTemplatesTagValues#TAG_SIMPLE_BEAN_SUPER_CLASS
+ * @since 2.6.2
+ */
+ public static String getSimpleBeanSuperClassTagValue(ObjectModel model, ObjectModelClassifier classifier) {
+ String value = findTagValue(JavaTemplatesTagValues.TAG_SIMPLE_BEAN_SUPER_CLASS, classifier, model);
+ return value;
+ }
+
+ /**
+ * Obtain the value of the {@link JavaTemplatesTagValues#TAG_SIMPLE_BEAN_GENERATE_INTERFACE}
+ * tag value on the given model or classifier.
+ * <p/>
+ * It will first look on the model, and then in the given classifier.
+ *
+ * @param model model to seek
+ * @param classifier classifier to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JavaTemplatesTagValues#TAG_SIMPLE_BEAN_GENERATE_INTERFACE
+ * @since 2.3
+ */
+ public static String getSimpleBeanGenerateInterfaceTagValue(ObjectModel model, ObjectModelClassifier classifier) {
+ String value = findTagValue(JavaTemplatesTagValues.TAG_SIMPLE_BEAN_GENERATE_INTERFACE, classifier, model);
+ return value;
+ }
+
+ /**
+ * Obtain the value of the {@link JavaTemplatesTagValues#TAG_SIMPLE_BEAN_GENERATE_FACTORY}
+ * tag value on the given model or classifier.
+ *
+ * @param model model to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JavaTemplatesTagValues#TAG_SIMPLE_BEAN_GENERATE_FACTORY
+ * @since 2.3
+ */
+ public static String getSimpleBeanGenerateFactoryTagValue(ObjectModel model) {
+ String value = findTagValue(JavaTemplatesTagValues.TAG_SIMPLE_BEAN_GENERATE_FACTORY, null, model);
+ return value;
+ }
+
+ /**
+ * Obtain the value of the {@link JavaTemplatesTagValues#TAG_SIMPLE_BEAN_INTERFACE_SUPER_CLASS}
+ * tag value on the given model or classifier.
+ * <p/>
+ * It will first look on the model, and then in the given classifier.
+ *
+ * @param model model to seek
+ * @param classifier classifier to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JavaTemplatesTagValues#TAG_SIMPLE_BEAN_INTERFACE_SUPER_CLASS
+ * @since 2.6.2
+ */
+ public static String getSimpleBeanInterfaceSuperClassTagValue(ObjectModel model, ObjectModelClassifier classifier) {
+ String value = findTagValue(JavaTemplatesTagValues.TAG_SIMPLE_BEAN_INTERFACE_SUPER_CLASS, classifier, model);
+ return value;
+ }
+
+ /**
+ * Obtain the value of the {@link JavaTemplatesTagValues#TAG_SIMPLE_BEAN_CLASS_NAME_PREFIX}
+ * tag value on the given model or classifier.
+ * <p/>
+ * It will first look on the model, and then in the given classifier.
+ *
+ * @param model model to seek
+ * @param classifier classifier to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JavaTemplatesTagValues#TAG_SIMPLE_BEAN_CLASS_NAME_PREFIX
+ * @since 2.6.2
+ */
+ public static String getSimpleBeanClassNamePrefixTagValue(ObjectModel model, ObjectModelClassifier classifier) {
+ String value = findTagValue(JavaTemplatesTagValues.TAG_SIMPLE_BEAN_CLASS_NAME_PREFIX, classifier, model);
+ return value;
+ }
+
+ /**
+ * Obtain the value of the {@link JavaTemplatesTagValues#TAG_SIMPLE_BEAN_CLASS_NAME_SUFFIX}
+ * tag value on the given model or classifier.
+ * <p/>
+ * It will first look on the model, and then in the given classifier.
+ *
+ * @param model model to seek
+ * @param classifier classifier to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JavaTemplatesTagValues#TAG_SIMPLE_BEAN_CLASS_NAME_SUFFIX
+ * @since 2.6.2
+ */
+ public static String getSimpleBeanClassNameSuffixTagValue(ObjectModel model, ObjectModelClassifier classifier) {
+ String value = findTagValue(JavaTemplatesTagValues.TAG_SIMPLE_BEAN_CLASS_NAME_SUFFIX, classifier, model);
+ return value;
+ }
+
+ /**
+ * Obtain the value of the {@link JavaTemplatesTagValues#TAG_SIMPLE_BEAN_INTERFACE_NAME_PREFIX}
+ * tag value on the given model or classifier.
+ * <p/>
+ * It will first look on the model, and then in the given classifier.
+ *
+ * @param model model to seek
+ * @param classifier classifier to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JavaTemplatesTagValues#TAG_SIMPLE_BEAN_INTERFACE_NAME_PREFIX
+ * @since 2.6.2
+ */
+ public static String getSimpleBeanInterfaceNamePrefixTagValue(ObjectModel model, ObjectModelClassifier classifier) {
+ String value = findTagValue(JavaTemplatesTagValues.TAG_SIMPLE_BEAN_INTERFACE_NAME_PREFIX, classifier, model);
+ return value;
+ }
+
+ /**
+ * Obtain the value of the {@link JavaTemplatesTagValues#TAG_SIMPLE_BEAN_INTERFACE_NAME_SUFFIX}
+ * tag value on the given model or classifier.
+ * <p/>
+ * It will first look on the model, and then in the given classifier.
+ *
+ * @param model model to seek
+ * @param classifier classifier to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JavaTemplatesTagValues#TAG_SIMPLE_BEAN_INTERFACE_NAME_SUFFIX
+ * @since 2.6.2
+ */
+ public static String getSimpleBeanInterfaceNameSuffixTagValue(ObjectModel model, ObjectModelClassifier classifier) {
+ String value = findTagValue(JavaTemplatesTagValues.TAG_SIMPLE_BEAN_INTERFACE_NAME_SUFFIX, classifier, model);
+ return value;
+ }
}
Modified: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesTagValues.java
===================================================================
--- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesTagValues.java 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/JavaTemplatesTagValues.java 2013-03-29 23:36:59 UTC (rev 1235)
@@ -111,6 +111,175 @@
@ModelPropertiesUtil.TagValueDefinition(
target = {ObjectModel.class, ObjectModelClassifier.class},
documentation = "To specify a super-class to used on generated bean " +
- "for a class or any class of a model")
+ "for a class or any class of a model.\n" +
+ "(only effective with bean generator)")
String TAG_BEAN_SUPER_CLASS = "beanSuperClass";
+
+ /**
+ * Tag value to use a super class for generated bean.
+ * <p/>
+ * If the bean needs Property change support (says you do not add the {@link #TAG_NO_PCS} on classifier or model,
+ * then your class must provide evrything for it.
+ * <p/>
+ * More over, if you use some collections in your bean you must also define
+ * two method named {@code getChild(Collection list, int index)} and
+ * {@code getChild(List list, int index)}
+ * <p/>
+ * See new code to know minimum stuff to add in your class for this purpose.
+ * <pre>
+ * public abstract class AbstractBean implements Serializable {
+ *
+ * private static final long serialVersionUID = 1L;
+ *
+ * protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ *
+ * public void addPropertyChangeListener(PropertyChangeListener listener) {
+ * pcs.addPropertyChangeListener(listener);
+ * }
+ *
+ * public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ * pcs.addPropertyChangeListener(propertyName, listener);
+ * }
+ *
+ * public void removePropertyChangeListener(PropertyChangeListener listener) {
+ * pcs.removePropertyChangeListener(listener);
+ * }
+ *
+ * public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ * pcs.removePropertyChangeListener(propertyName, listener);
+ * }
+ *
+ * protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ * pcs.firePropertyChange(propertyName, oldValue, newValue);
+ * }
+ *
+ * protected void firePropertyChange(String propertyName, Object newValue) {
+ * firePropertyChange(propertyName, null, newValue);
+ * }
+ *
+ * protected <T> T getChild(Collection<T> list, int index) {
+ * return CollectionUtil.getOrNull(list, index);
+ * }
+ *
+ * protected <T> T getChild(List<T> list, int index) {
+ * return CollectionUtil.getOrNull(list, index);
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * You can globaly use it on the complete model or to a specific classifier.
+ *
+ * @see JavaTemplatesGeneratorUtil#getSimpleBeanSuperClassTagValue(ObjectModel, ObjectModelClassifier)
+ * @since 2.5.6
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class, ObjectModelClassifier.class},
+ documentation = "To specify a super-class to used on generated simple bean " +
+ "for a class or any class of a model.\n" +
+ "(only effective with simple bean generator)")
+ String TAG_SIMPLE_BEAN_SUPER_CLASS = "simpleBeanSuperClass";
+
+ /**
+ * To add a prefix on the name of each generated bean class.
+ * <p/>
+ * You can globaly use it on the complete model or to a specific classifier.
+ *
+ * @see JavaTemplatesGeneratorUtil#getSimpleBeanClassNamePrefixTagValue(ObjectModel, ObjectModelClassifier)
+ * @since 2.6.2
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class, ObjectModelClassifier.class},
+ documentation = "To add a prefix on class name of generated bean " +
+ "for a class or any class of a model.\n" +
+ "(only effective with simple bean generator)")
+ String TAG_SIMPLE_BEAN_CLASS_NAME_PREFIX = "simpleBeanClassNamePrefix";
+
+ /**
+ * To add a prefix on the name of each generated bean class.
+ * <p/>
+ * You can globaly use it on the complete model or to a specific classifier.
+ *
+ * @see JavaTemplatesGeneratorUtil#getSimpleBeanClassNameSuffixTagValue(ObjectModel, ObjectModelClassifier)
+ * @since 2.6.2
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class, ObjectModelClassifier.class},
+ documentation = "To add a suffix on class name of generated bean " +
+ "for a class or any class of a model.\n" +
+ "(only effective with simple bean generator)")
+ String TAG_SIMPLE_BEAN_CLASS_NAME_SUFFIX = "simpleBeanClassNameSuffix";
+
+ /**
+ * To generate an interface of each simple bean.
+ * <p/>
+ * You can globaly use it on the complete model or to a specific classifier.
+ *
+ * @see JavaTemplatesGeneratorUtil#getSimpleBeanGenerateInterfaceTagValue(ObjectModel, ObjectModelClassifier)
+ * @since 2.6.2
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class, ObjectModelClassifier.class},
+ documentation = "To generate an interface for each bean " +
+ "for a class or any class of a model.\n" +
+ "(only effective with simple bean generator)")
+ String TAG_SIMPLE_BEAN_GENERATE_INTERFACE = "simpleBeanGenerateInterface";
+
+ /**
+ * Tag value to use a super interface for generated interfaces on simple bean.
+ * <p/>
+ * You can globaly use it on the complete model or to a specific classifier.
+ *
+ * @see JavaTemplatesGeneratorUtil#getSimpleBeanInterfaceSuperClassTagValue(ObjectModel, ObjectModelClassifier)
+ * @since 2.6.2
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class, ObjectModelClassifier.class},
+ documentation = "To specify a super-class to used on generated interfaces " +
+ "for a class or any class of a model.\n" +
+ "(only effective with simple bean generator)")
+ String TAG_SIMPLE_BEAN_INTERFACE_SUPER_CLASS = "simpleBeanInterfaceSuperClass";
+
+ /**
+ * To add a prefix on the name of each generated interface of a simple bean.
+ * <p/>
+ * You can globaly use it on the complete model or to a specific classifier.
+ *
+ * @see JavaTemplatesGeneratorUtil#getSimpleBeanInterfaceNamePrefixTagValue(ObjectModel, ObjectModelClassifier)
+ * @since 2.6.2
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class, ObjectModelClassifier.class},
+ documentation = "To add a prefix on interface name of generated bean " +
+ "for a class or any class of a model.\n" +
+ "(only effective with simple bean generator)")
+ String TAG_SIMPLE_BEAN_INTERFACE_NAME_PREFIX = "simpleBeanInterfaceNamePrefix";
+
+ /**
+ * To add a prefix on the name of each generated interface of a simple bean.
+ * <p/>
+ * You can globaly use it on the complete model or to a specific classifier.
+ *
+ * @see JavaTemplatesGeneratorUtil#getSimpleBeanInterfaceNameSuffixTagValue(ObjectModel, ObjectModelClassifier)
+ * @since 2.6.2
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class, ObjectModelClassifier.class},
+ documentation = "To add a suffix on interface name of generated bean " +
+ "for a class or any class of a model.\n" +
+ "(only effective with simple bean generator)")
+ String TAG_SIMPLE_BEAN_INTERFACE_NAME_SUFFIX = "simpleBeanInterfaceNameSuffix";
+
+ /**
+ * To generate an factory of generated simple beans.
+ * <p/>
+ * You must use it on the complete model.
+ *
+ * @see JavaTemplatesGeneratorUtil#getSimpleBeanGenerateFactoryTagValue(ObjectModel)
+ * @since 2.6.2
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class},
+ documentation = "To generate a factory of simple bean.\n" +
+ "(only effective with simple bean generator)")
+ String TAG_SIMPLE_BEAN_GENERATE_FACTORY = "simpleBeanGenerateFactory";
}
Modified: trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/SimpleJavaBeanTransformer.java
===================================================================
--- trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/SimpleJavaBeanTransformer.java 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/SimpleJavaBeanTransformer.java 2013-03-29 23:36:59 UTC (rev 1235)
@@ -24,7 +24,6 @@
* #L%
*/
-
/*{generator option: parentheses = false}*/
/*{generator option: writeString = +}*/
@@ -33,13 +32,17 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.eugene.GeneratorException;
+import org.nuiton.eugene.models.object.ObjectModel;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelInterface;
+import org.nuiton.eugene.models.object.ObjectModelJavaModifier;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
-import java.util.Set;
/**
* SimpleJavaBeanTransformer generates simple bean with pcs support
@@ -59,6 +62,17 @@
LogFactory.getLog(SimpleJavaBeanTransformer.class);
@Override
+ public void transformFromModel(ObjectModel model) {
+
+ String className = model.getName() + "BeanFactory";
+
+ if (canGenerateFactory(model, className)) {
+
+ generateBeanFactory(model, className);
+ }
+ }
+
+ @Override
public void transformFromClass(ObjectModelClass input) {
if (!JavaTemplatesGeneratorUtil.hasBeanStereotype(input)) {
@@ -67,25 +81,102 @@
return;
}
+ String interfaceName = getBeanInterfaceName(input);
+ String className = getBeanClassName(input);
- if (canGenerate(input)) {
+ boolean generateInterface = canGenerateInterface(input, interfaceName);
- ObjectModelClass output = generateBean(input);
+ boolean generateClass = canGenerateBean(input, className);
+
+ if (generateClass || generateInterface) {
+
+ ObjectModelClass outputClass = generateBeanClass(input,
+ className,
+ interfaceName);
+ if (generateInterface) {
+
+ generateBeanInterface(input, interfaceName, outputClass);
+
+ if (generateClass) {
+
+ // add override annotation on all public operations
+
+ for (ObjectModelOperation operation : getPublicOperations(outputClass)) {
+ addAnnotation(outputClass,
+ operation,
+ Override.class.getSimpleName());
+ }
+
+ }
+ }
+
+ if (!generateClass) {
+
+ // remove bean class from builder (just used to build the interface)
+ builder.getModel().getClasses().remove(outputClass);
+ }
}
+
}
- protected boolean canGenerate(ObjectModelClass input) {
- boolean canGenerate = !isInClassPath(input);
+ protected boolean canGenerateFactory(ObjectModel model, String className) {
+ String generateTagValue =
+ JavaTemplatesGeneratorUtil.getSimpleBeanGenerateFactoryTagValue(model);
+ boolean generateFactory = generateTagValue != null &&
+ Boolean.valueOf(generateTagValue);
+
+ String defaultPackage =
+ getConfiguration().getProperty(PROP_DEFAULT_PACKAGE);
+
+ String fqn = defaultPackage + "." + className;
+ boolean canGenerate = generateFactory &&
+ !isInClassPath(fqn);
+
+ return canGenerate;
+ }
+
+ protected boolean canGenerateInterface(ObjectModelClass input,
+ String className) {
+
+ String generateTagValue =
+ JavaTemplatesGeneratorUtil.getSimpleBeanGenerateInterfaceTagValue(model, input);
+
+ boolean generateInterface = generateTagValue != null &&
+ Boolean.valueOf(generateTagValue);
+
+ String fqn = input.getPackageName() + "." + className;
+
+ boolean canGenerate = generateInterface && !isInClassPath(fqn);
+
if (canGenerate) {
// check there is no operation on input
if (!input.getOperations().isEmpty()) {
throw new GeneratorException(
+ "Can't generate a simple bean interface as class " +
+ fqn +
+ " contains so operations." +
+ "\nUse instead the JavaBeanTransformer.");
+ }
+ }
+ return canGenerate;
+ }
+
+ protected boolean canGenerateBean(ObjectModelClass input, String className) {
+ String fqn = input.getPackageName() + "." + className;
+ boolean canGenerate = !isInClassPath(fqn);
+
+ if (canGenerate) {
+
+ // check there is no operation on input
+ if (!input.getOperations().isEmpty()) {
+
+ throw new GeneratorException(
"Can't generate a simple bean as class " +
- input.getQualifiedName() +
+ fqn +
" contains so operations." +
"\nUse instead the JavaBeanTransformer.");
}
@@ -93,27 +184,129 @@
return canGenerate;
}
- protected ObjectModelClass generateBean(ObjectModelClass input) {
+ protected void generateBeanFactory(ObjectModel model, String className) {
+ String defaultPackage =
+ getConfiguration().getProperty(PROP_DEFAULT_PACKAGE);
+ ObjectModelClass output = createClass(className, defaultPackage);
+
+ for (ObjectModelClass aClass : model.getClasses()) {
+ if (!aClass.isAbstract() &&
+ JavaTemplatesGeneratorUtil.hasBeanStereotype(aClass)) {
+ String packageName = aClass.getPackageName();
+ String typeName = getBeanInterfaceName(aClass);
+ String typeBeanName = getBeanClassName(aClass);
+ addImport(output, packageName + "." + typeName);
+ addImport(output, packageName + "." + typeBeanName);
+ ObjectModelOperation operation = addOperation(
+ output,
+ "typeOf" + typeName,
+ "Class<? extends " + typeName + ">",
+ ObjectModelJavaModifier.STATIC,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(operation, ""
+ /*{
+ return <%=typeBeanName%>.class;
+ }*/
+ );
+ operation = addOperation(
+ output,
+ "new" + typeName,
+ typeName,
+ ObjectModelJavaModifier.STATIC,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(operation, ""
+ /*{
+ return new <%=typeBeanName%>();
+ }*/
+ );
+ }
+ }
+ }
+
+ protected ObjectModelInterface generateBeanInterface(ObjectModelClass input,
+ String className,
+ ObjectModelClass outputClass) {
+
+ ObjectModelInterface output =
+ createInterface(className, input.getPackageName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("will generate " + output.getQualifiedName());
+ }
+
+ boolean superClassIsBean = false;
+
+ String superClass = null;
+
// 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 (JavaTemplatesGeneratorUtil.hasBeanStereotype(superclass)) {
superClassIsBean = true;
+ superClass = superclass.getPackageName() + "." +
+ getBeanInterfaceName(superclass);
break;
}
+ superClass = superclass.getQualifiedName();
}
}
+ if (superClass == null) {
+
+ // try to find a super class by tag-value
+ superClass =
+ JavaTemplatesGeneratorUtil.getSimpleBeanInterfaceSuperClassTagValue(
+ model, input);
+ }
+
+ boolean serializableFound = addInterfaces(input, output, superClass);
+
+ if (serializableFound || superClassIsBean) {
+ addInterface(output, Serializable.class);
+ }
+
+ generateI18nBlockAndConstants(input, output);
+
+ for (ObjectModelOperation operation : getPublicOperations(outputClass)) {
+ cloneOperation(operation, output, true);
+ }
+
+ return output;
+ }
+
+ protected ObjectModelClass generateBeanClass(ObjectModelClass input,
+ String className,
+ String interfaceName) {
+
+ boolean generateInterface = interfaceName != null;
+
String superClass = null;
+ // 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 (JavaTemplatesGeneratorUtil.hasBeanStereotype(superclass)) {
+ superClassIsBean = true;
+ superClass = getBeanClassName(superclass);
+ break;
+ } else {
+ superClass = superclass.getQualifiedName();
+ }
+ }
+ }
+
if (!superClassIsBean) {
// try to find a super class by tag-value
superClass =
- JavaTemplatesGeneratorUtil.getBeanSuperClassTagValue(
+ JavaTemplatesGeneratorUtil.getSimpleBeanSuperClassTagValue(
model, input);
if (superClass != null) {
@@ -122,9 +315,14 @@
}
}
- ObjectModelClass output =
- createClass(input.getName(), input.getPackageName());
+ ObjectModelClass output;
+ if (input.isAbstract()) {
+ output = createAbstractClass(className, input.getPackageName());
+ } else {
+ output = createClass(className, input.getPackageName());
+ }
+
if (superClass != null) {
setSuperClass(output, superClass);
}
@@ -132,83 +330,99 @@
log.debug("will generate " + output.getQualifiedName());
}
- String i18nPrefix = JavaGeneratorUtil.getI18nPrefixTagValue(input, model);
- if (!StringUtils.isEmpty(i18nPrefix)) {
- generateI18nBlock(input, output, i18nPrefix);
- }
+ boolean serializableFound;
- String noPCSTagValue = JavaTemplatesGeneratorUtil.getNoPCSTagValue(model, input);
- boolean usePCS = StringUtils.isEmpty(noPCSTagValue) ||
- !"true".equals(noPCSTagValue.trim());
+ if (generateInterface) {
- String noGenerateBooleanGetMethods =
- JavaGeneratorUtil.getDoNotGenerateBooleanGetMethods(model, input);
- boolean generateBooleanGetMethods =
- StringUtils.isEmpty(noGenerateBooleanGetMethods) ||
- !"true".equals(noGenerateBooleanGetMethods.trim());
+ addInterface(output, interfaceName);
- String prefix = getConstantPrefix(input, DEFAULT_CONSTANT_PREFIX);
+ serializableFound = true;
+ } else {
- setConstantPrefix(prefix);
+ serializableFound = addInterfaces(input, output, null);
- addSuperClass(input, output);
-
- boolean serializableFound = addInterfaces(input, output);
-
- if (superClassIsBean) {
- serializableFound = true;
+ generateI18nBlockAndConstants(input, output);
}
- addSerializable(input, output, serializableFound);
+ addSerializable(input, output, serializableFound || superClassIsBean);
- Set<String> constantNames = addConstantsFromDependency(input, output);
-
// Get available properties
List<ObjectModelAttribute> properties = getProperties(input);
- // Add properties constant
- for (ObjectModelAttribute attr : properties) {
+ String noPCSTagValue = JavaTemplatesGeneratorUtil.getNoPCSTagValue(model, input);
+ boolean usePCS = StringUtils.isEmpty(noPCSTagValue) ||
+ !"true".equals(noPCSTagValue.trim());
- createPropertyConstant(output, attr, prefix, constantNames);
- }
+ String noGenerateBooleanGetMethods =
+ JavaGeneratorUtil.getDoNotGenerateBooleanGetMethods(model, input);
+ boolean generateBooleanGetMethods =
+ StringUtils.isEmpty(noGenerateBooleanGetMethods) ||
+ !"true".equals(noGenerateBooleanGetMethods.trim());
// Add properties field + javabean methods
for (ObjectModelAttribute attr : properties) {
- createProperty(output, attr, usePCS, generateBooleanGetMethods);
+ createProperty(output,
+ attr,
+ usePCS,
+ generateBooleanGetMethods);
}
if (!superClassIsBean) {
+ addDefaultMethodForNoneBeanSuperClass(output, usePCS, properties);
+ }
+ return output;
+ }
- if (usePCS) {
- // Add property change support
- createPropertyChangeSupport(output);
+ protected Collection<ObjectModelOperation> getPublicOperations(ObjectModelClass clazz) {
+
+ Collection<ObjectModelOperation> result = new ArrayList<ObjectModelOperation>();
+ for (ObjectModelOperation operation : clazz.getOperations()) {
+
+ ObjectModelJavaModifier visibility =
+ ObjectModelJavaModifier.fromVisibility(
+ operation.getVisibility());
+ if (ObjectModelJavaModifier.PUBLIC == visibility) {
+ result.add(operation);
}
}
+ return result;
+ }
- boolean hasAMultipleProperty = containsMutiple(properties);
+ protected String getBeanInterfaceName(ObjectModelClass input) {
+ String interfaceNamePrefix = JavaTemplatesGeneratorUtil.getSimpleBeanInterfaceNamePrefixTagValue(model, input);
+ String interfaceNameSuffix = JavaTemplatesGeneratorUtil.getSimpleBeanInterfaceNameSuffixTagValue(model, input);
- // Add helper operations
- if (hasAMultipleProperty) {
+ return generateName(
+ interfaceNamePrefix,
+ input.getName(),
+ interfaceNameSuffix
+ );
+ }
- if (!superClassIsBean) {
+ protected String getBeanClassName(ObjectModelClass input) {
+ String classNamePrefix = JavaTemplatesGeneratorUtil.getSimpleBeanClassNamePrefixTagValue(model, input);
+ String classNameSuffix = JavaTemplatesGeneratorUtil.getSimpleBeanClassNameSuffixTagValue(model, input);
- // add getChild methods
- createGetChildMethod(output);
- }
- }
- return output;
+ return generateName(
+ classNamePrefix,
+ input.getName(),
+ classNameSuffix
+ );
}
- protected void addSuperClass(ObjectModelClass input,
- ObjectModelClass output) {
- // Set superclass
- Iterator<ObjectModelClass> j = input.getSuperclasses().iterator();
- if (j.hasNext()) {
- ObjectModelClass p = j.next();
- String qualifiedName = p.getQualifiedName();
- setSuperClass(output, qualifiedName);
+ protected String generateName(String prefix,
+ String name,
+ String suffix) {
+ StringBuilder sb = new StringBuilder();
+ if (StringUtils.isNotEmpty(prefix)) {
+ sb.append(prefix);
}
+ sb.append(name);
+ if (StringUtils.isNotEmpty(suffix)) {
+ sb.append(suffix);
+ }
+ return sb.toString();
}
}
Modified: 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 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene-java-templates/src/main/java/org/nuiton/eugene/java/package-info.java 2013-03-29 23:36:59 UTC (rev 1235)
@@ -1,9 +1,10 @@
/**
* Eugene java package : Java generators.
* <pre>
- * - Generator : {@link JavaBeanTransformer } to generate a bean.
+ * - Generator : {@link JavaBeanTransformer } to generate a bean (with abstract and impl class).
* - Generator : {@link JavaEnumerationTransformer } to generate a enumeration.
* - Generator : {@link JavaInterfaceTransformer } to generate a interface.
+ * - Generator : {@link SimpleJavaBeanTransformer} to generate a bean (one class and interface if required).
* </pre>
*/
package org.nuiton.eugene.java;
Modified: trunk/eugene-jpa-templates/pom.xml
===================================================================
--- trunk/eugene-jpa-templates/pom.xml 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene-jpa-templates/pom.xml 2013-03-29 23:36:59 UTC (rev 1235)
@@ -29,7 +29,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.6.2-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/eugene-maven-plugin/pom.xml
===================================================================
--- trunk/eugene-maven-plugin/pom.xml 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/eugene-maven-plugin/pom.xml 2013-03-29 23:36:59 UTC (rev 1235)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.6.2-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-03-28 11:13:11 UTC (rev 1234)
+++ trunk/pom.xml 2013-03-29 23:36:59 UTC (rev 1235)
@@ -36,12 +36,12 @@
</parent>
<artifactId>eugene</artifactId>
- <version>2.7-SNAPSHOT</version>
+ <version>2.6.2-SNAPSHOT</version>
<modules>
<module>eugene</module>
<module>eugene-java-templates</module>
- <module>eugene-jpa-templates</module>
+ <!--module>eugene-jpa-templates</module-->
<module>eugene-maven-plugin</module>
</modules>
1
0
Author: tchemit
Date: 2013-03-28 12:13:11 +0100 (Thu, 28 Mar 2013)
New Revision: 1234
Url: http://nuiton.org/projects/eugene/repository/revisions/1234
Log:
fixes #2634: Updates mavenpom to 3.4.8
refs #2633: Add JPA templates (entity, dao)
Added:
trunk/eugene-jpa-templates/
trunk/eugene-jpa-templates/LICENSE.txt
trunk/eugene-jpa-templates/README.txt
trunk/eugene-jpa-templates/changelog.txt
trunk/eugene-jpa-templates/pom.xml
trunk/eugene-jpa-templates/src/
trunk/eugene-jpa-templates/src/license/
trunk/eugene-jpa-templates/src/license/THIRD-PARTY.properties
trunk/eugene-jpa-templates/src/main/
trunk/eugene-jpa-templates/src/main/java/
trunk/eugene-jpa-templates/src/main/java/org/
trunk/eugene-jpa-templates/src/main/java/org/nuiton/
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/AbstractJPATransformer.java
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPADaoTransformer.java
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPAEntityTransformer.java
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesGeneratorUtil.java
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProvider.java
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesStereoTypes.java
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesTagValues.java
trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/package-info.java
trunk/eugene-jpa-templates/src/main/resources/
trunk/eugene-jpa-templates/src/main/resources/META-INF/
trunk/eugene-jpa-templates/src/main/resources/META-INF/services/
trunk/eugene-jpa-templates/src/main/resources/META-INF/services/org.nuiton.eugene.ModelPropertiesUtil$ModelPropertiesProvider
trunk/eugene-jpa-templates/src/site/
trunk/eugene-jpa-templates/src/site/fr/
trunk/eugene-jpa-templates/src/site/fr/rst/
trunk/eugene-jpa-templates/src/site/fr/rst/index.rst
trunk/eugene-jpa-templates/src/site/rst/
trunk/eugene-jpa-templates/src/site/rst/index.rst
trunk/eugene-jpa-templates/src/site/site_en.xml
trunk/eugene-jpa-templates/src/site/site_fr.xml
trunk/eugene-jpa-templates/src/test/
trunk/eugene-jpa-templates/src/test/java/
trunk/eugene-jpa-templates/src/test/java/org/
trunk/eugene-jpa-templates/src/test/java/org/nuiton/
trunk/eugene-jpa-templates/src/test/java/org/nuiton/eugene/
trunk/eugene-jpa-templates/src/test/java/org/nuiton/eugene/jpa/
trunk/eugene-jpa-templates/src/test/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProviderTest.java
trunk/eugene-jpa-templates/src/test/resources/
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 2013-01-11 16:08:07 UTC (rev 1233)
+++ trunk/eugene/pom.xml 2013-03-28 11:13:11 UTC (rev 1234)
@@ -32,7 +32,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.6.2-SNAPSHOT</version>
+ <version>2.7-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
@@ -252,7 +252,7 @@
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-maven-plugin</artifactId>
- <version>1.3.8</version>
+ <version>${plexusPluginVersion}</version>
</plugin>
</plugins>
</reporting>
Modified: trunk/eugene-java-templates/pom.xml
===================================================================
--- trunk/eugene-java-templates/pom.xml 2013-01-11 16:08:07 UTC (rev 1233)
+++ trunk/eugene-java-templates/pom.xml 2013-03-28 11:13:11 UTC (rev 1234)
@@ -29,7 +29,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.6.2-SNAPSHOT</version>
+ <version>2.7-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
@@ -57,7 +57,7 @@
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
-
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -135,7 +135,7 @@
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-maven-plugin</artifactId>
- <version>1.3.8</version>
+ <version>${plexusPluginVersion}</version>
</plugin>
</plugins>
</reporting>
Property changes on: trunk/eugene-jpa-templates
___________________________________________________________________
Added: svn:ignore
+ target
.project
.classpath
.idea
*.ipr
*.iws
*.iml
Added: trunk/eugene-jpa-templates/LICENSE.txt
===================================================================
--- trunk/eugene-jpa-templates/LICENSE.txt (rev 0)
+++ trunk/eugene-jpa-templates/LICENSE.txt 2013-03-28 11:13:11 UTC (rev 1234)
@@ -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.
+
Property changes on: trunk/eugene-jpa-templates/LICENSE.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/eugene-jpa-templates/README.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/eugene-jpa-templates/changelog.txt
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/pom.xml
===================================================================
--- trunk/eugene-jpa-templates/pom.xml (rev 0)
+++ trunk/eugene-jpa-templates/pom.xml 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ EUGene :: JPA templates
+
+ $HeadURL$
+ %%
+ Copyright (C) 2013 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%
+ -->
+<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.7-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.nuiton.eugene</groupId>
+ <artifactId>eugene-jpa-templates</artifactId>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>eugene</artifactId>
+ <version>${project.version}</version>
+ </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>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <name>EUGene :: JPA templates</name>
+
+ <inceptionYear>2013</inceptionYear>
+
+ <properties>
+ <!-- extra files to include in release -->
+ <redmine.releaseFiles>${redmine.libReleaseFiles}</redmine.releaseFiles>
+ </properties>
+
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.nuiton.processor</groupId>
+ <artifactId>processor-maven-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>${plexusPluginVersion}</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ </profile>
+ </profiles>
+
+</project>
+
+
+
Property changes on: trunk/eugene-jpa-templates/pom.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/license/THIRD-PARTY.properties
===================================================================
--- trunk/eugene-jpa-templates/src/license/THIRD-PARTY.properties (rev 0)
+++ trunk/eugene-jpa-templates/src/license/THIRD-PARTY.properties 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,23 @@
+# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - BSD License
+# - 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
+# - New BSD License
+# - The Apache Software License, Version 2.0
+# - The SAX License
+# - The W3C License
+# - http://jaxen.codehaus.org/license.html
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Thu Mar 28 12:01:53 CET 2013
+commons-primitives--commons-primitives--1.0=The Apache Software License, Version 2.0
Property changes on: trunk/eugene-jpa-templates/src/license/THIRD-PARTY.properties
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/AbstractJPATransformer.java
===================================================================
--- trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/AbstractJPATransformer.java (rev 0)
+++ trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/AbstractJPATransformer.java 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,684 @@
+package org.nuiton.eugene.jpa;
+
+/*
+ * #%L
+ * EUGene :: JPA templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+/*{generator option: parentheses = false}*/
+/*{generator option: writeString = +}*/
+
+import org.nuiton.eugene.java.ObjectModelTransformerToJava;
+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.List;
+import java.util.Set;
+
+/**
+ * Common class form jpa like transformer.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @see JPAEntityTransformer
+ * @since 2.7
+ */
+public abstract class AbstractJPATransformer extends ObjectModelTransformerToJava {
+
+ public static final String DEFAULT_CONSTANT_PREFIX = "PROPERTY_";
+
+ 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)) {
+
+ addConstant(output,
+ constantName,
+ String.class,
+ "\"" + attrName + "\"",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ }
+ }
+
+ protected String getAttributeName(ObjectModelAttribute attr) {
+ String attrName = attr.getName();
+ if (attr.hasAssociationClass()) {
+ String assocAttrName = JPATemplatesGeneratorUtil.getAssocAttrName(attr);
+ attrName = JPATemplatesGeneratorUtil.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 (JPATemplatesGeneratorUtil.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 = JPATemplatesGeneratorUtil.isNMultiplicity(attr);
+
+ String constantName = getConstantName(attrName);
+ String simpleType = JPATemplatesGeneratorUtil.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 = JPATemplatesGeneratorUtil.getSimpleName(attrType);
+ }
+
+ boolean booleanProperty = JPATemplatesGeneratorUtil.isBooleanPrimitive(attr);
+
+ if (booleanProperty && !multiple) {
+
+ // creates a isXXX method
+ createGetMethod(output,
+ attrName,
+ attrType,
+ JPATemplatesGeneratorUtil.OPERATION_GETTER_BOOLEAN_PREFIX
+ );
+ }
+
+ if (multiple || !booleanProperty || generateBooleanGetMethods) {
+
+ createGetMethod(output,
+ attrName,
+ attrType,
+ JPATemplatesGeneratorUtil.OPERATION_GETTER_DEFAULT_PREFIX
+ );
+
+ }
+ createSetMethod(output,
+ attrName,
+ attrType,
+ simpleType,
+ constantName,
+ usePCS
+ );
+
+ // Add attribute to the class
+ addAttribute(output,
+ attrName,
+ attrType,
+ "",
+ ObjectModelJavaModifier.PROTECTED
+ );
+
+ }
+
+ 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 operation = addOperation(
+ output,
+ getJavaBeanMethodName(methodPrefix , attrName),
+ attrType,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(operation, ""
+ /*{
+ return <%=attrName%>;
+ }*/
+ );
+ }
+
+ protected void createGetChildMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String simpleType) {
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("get", attrName),
+ attrType,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, "int", "index");
+ setOperationBody(operation, ""
+ /*{
+ <%=simpleType%> o = getChild(<%=attrName%>, index);
+ return o;
+ }*/
+ );
+ }
+
+ protected void createIsEmptyMethod(ObjectModelClass output,
+ String attrName) {
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("is", attrName)+"Empty",
+ boolean.class,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(operation, ""
+ /*{
+ return <%=attrName%> == null || <%=attrName%>.isEmpty();
+ }*/
+ );
+ }
+
+ protected void createSizeMethod(ObjectModelClass output,
+ String attrName) {
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("size", attrName),
+ int.class,
+ ObjectModelJavaModifier.PUBLIC
+ );
+ setOperationBody(operation, ""
+ /*{
+ return <%=attrName%> == null ? 0 : <%=attrName%>.size();
+ }*/
+ );
+ }
+ protected void createAddChildMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String constantName,
+ boolean usePCS) {
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("add", attrName),
+ "void",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, attrType, attrName);
+
+ String methodName = getJavaBeanMethodName("get", attrName);
+ StringBuilder buffer = new StringBuilder(""
+ /*{
+ <%=methodName%>().add(<%=attrName%>);
+ }*/
+ );
+ if (usePCS) {
+ buffer.append(""
+ /*{ firePropertyChange(<%=constantName%>, null, <%=attrName%>);
+ }*/
+ );
+ }
+ setOperationBody(operation, buffer.toString());
+ }
+
+ protected void createAddAllChildrenMethod(ObjectModelClass output,
+ String attrName,
+ String attrType,
+ String constantName,
+ boolean usePCS) {
+ ObjectModelOperation operation = addOperation(
+ output,
+ getJavaBeanMethodName("addAll", attrName),
+ "void",
+ ObjectModelJavaModifier.PUBLIC
+ );
+ addParameter(operation, "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(operation, 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%>);
+ 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%>);
+ 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 addSerializable(ObjectModelClass input,
+ ObjectModelClass output,
+ boolean interfaceFound) {
+ if (!interfaceFound) {
+ addInterface(output, Serializable.class);
+ }
+
+ // Generate the serialVersionUID
+ long serialVersionUID = JPATemplatesGeneratorUtil.generateSerialVersionUID(input);
+
+ addConstant(output,
+ JPATemplatesGeneratorUtil.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 createPropertyChangeSupport(ObjectModelClass output) {
+
+ addAttribute(output,
+ "pcs",
+ PropertyChangeSupport.class,
+ "new PropertyChangeSupport(this)",
+ ObjectModelJavaModifier.PROTECTED,
+ ObjectModelJavaModifier.FINAL,
+ ObjectModelJavaModifier.TRANSIENT
+ );
+
+ // 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);
+ }*/
+ );
+ }
+
+ protected void createGetChildMethod(ObjectModelClass output) {
+ ObjectModelOperation getChild = addOperation(
+ output,
+ "getChild", "<T> T",
+ ObjectModelJavaModifier.PROTECTED
+ );
+ addImport(output, List.class);
+
+ addParameter(getChild, "java.util.Collection<T>", "childs");
+ addParameter(getChild, "int", "index");
+ setOperationBody(getChild, ""
+/*{
+ T result = null;
+ if (childs != null) {
+ if (childs instanceof List) {
+ if (index < childs.size()) {
+ result = ((List<T>) childs).get(index);
+ }
+ } else {
+ int i = 0;
+ for (T o : childs) {
+ if (index == i) {
+ result = o;
+ break;
+ }
+ i++;
+ }
+ }
+ }
+ return result;
+}*/
+ );
+ }
+}
Property changes on: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/AbstractJPATransformer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPADaoTransformer.java
===================================================================
--- trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPADaoTransformer.java (rev 0)
+++ trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPADaoTransformer.java 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,72 @@
+package org.nuiton.eugene.jpa;
+
+/*
+ * #%L
+ * EUGene :: JPA templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+
+/*{generator option: parentheses = false}*/
+/*{generator option: writeString = +}*/
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.java.ObjectModelTransformerToJava;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+
+import java.util.Collection;
+
+/**
+ * JPADaoTransformer generates a dao for an entity.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.jpa.JPADaoTransformer"
+ * @since 2.7
+ */
+public class JPADaoTransformer extends ObjectModelTransformerToJava {
+
+ private static final Log log = LogFactory.getLog(JPADaoTransformer.class);
+
+ @Override
+ public void transformFromClass(ObjectModelClass input) {
+
+ if (!canGenerate(input)) {
+
+ // not an entity, or skip, or already in classpath
+ return;
+ }
+
+ //TODO
+ ObjectModelClass output = null;
+ }
+
+ protected boolean canGenerate(ObjectModelClass input) {
+ boolean b = !JPATemplatesGeneratorUtil.hasSkipStereotype(input) &&
+ JPATemplatesGeneratorUtil.hasEntityStereotype(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-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPADaoTransformer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPAEntityTransformer.java
===================================================================
--- trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPAEntityTransformer.java (rev 0)
+++ trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPAEntityTransformer.java 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,303 @@
+package org.nuiton.eugene.jpa;
+
+/*
+ * #%L
+ * EUGene :: JPA templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+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.models.object.ObjectModelAttribute;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelJavaModifier;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+
+import javax.persistence.EntityManager;
+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 JPATemplatesTagValues#TAG_NO_PCS}.</li>
+ * <li>generate i18n keys using the tag value {@link JPATemplatesTagValues#TAG_I18N_PREFIX}.</li>
+ * </ul>
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.jpa.JPAEntityTransformer"
+ * @since 2.7
+ */
+public class JPAEntityTransformer extends AbstractJPATransformer{
+
+ private static final Log log = LogFactory.getLog(JPAEntityTransformer.class);
+
+ @Override
+ public void transformFromClass(ObjectModelClass input) {
+
+ if (!canGenerate(input)) {
+
+ // not an entity, or skip
+ return;
+ }
+
+ EntityManager m;
+
+ ObjectModelClass output = null;
+
+ if (canGenerateAbstract(input)) {
+
+ // nothing more to do
+ output = generateAbstract(input);
+ }
+
+ if (canGenerateImpl(input, output)) {
+
+ generateImpl(input);
+ }
+ }
+
+ protected boolean canGenerate(ObjectModelClass input) {
+ boolean b = !JPATemplatesGeneratorUtil.hasSkipStereotype(input) &&
+ JPATemplatesGeneratorUtil.hasEntityStereotype(input);
+ return b;
+ }
+
+ protected boolean canGenerateAbstract(ObjectModelClass input) {
+ boolean b = !isInClassPath(input);
+ return b;
+ }
+
+ protected boolean canGenerateImpl(ObjectModelClass input,
+ ObjectModelClass abstractOutput) {
+ String fqn = input.getQualifiedName() + "Impl";
+
+ if (isInClassPath(fqn)) {
+
+ // already in class-path
+ return false;
+ }
+
+ Collection<ObjectModelOperation> operations = input.getOperations();
+ if (!operations.isEmpty()) {
+
+ // this input have some specific operations (so Impl can not be generated)
+ return false;
+ }
+
+ Collection<ObjectModelOperation> allOtherOperations =
+ input.getAllOtherOperations(true);
+
+ if (!allOtherOperations.isEmpty()) {
+
+ Collection<ObjectModelOperation> allExistingOperations =
+ new ArrayList<ObjectModelOperation>(input.getAllSuperclassOperations(true));
+
+ if (abstractOutput!=null) {
+ allExistingOperations.addAll(abstractOutput.getOperations());
+ }
+
+ for (ObjectModelOperation operation : allOtherOperations) {
+ if (!allExistingOperations.contains(operation)) {
+
+ // found one method not on super classe, so can't generate Impl
+ return false;
+ }
+ }
+ }
+ return true;
+
+// boolean hasOperations = !allOtherOperations.isEmpty() ||
+// !operations.isEmpty();
+//
+// // generate only if no user operations found
+// return !hasOperations;
+ }
+
+
+
+
+ protected void createAbstractOperations(ObjectModelClass ouput,
+ Iterable<ObjectModelOperation> operations) {
+ JPATemplatesGeneratorUtil.cloneOperations(
+ this,
+ operations,
+ ouput,
+ true,
+ ObjectModelJavaModifier.ABSTRACT
+ );
+ }
+
+ protected ObjectModelClass generateAbstract(ObjectModelClass input) {
+ // 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 (JPATemplatesGeneratorUtil.hasEntityStereotype(superclass)) {
+ superClassIsBean = true;
+ break;
+ }
+ }
+ }
+
+ String superClass = null;
+
+ if (!superClassIsBean) {
+
+ // try to find a super class by tag-value
+ superClass =
+ JPATemplatesGeneratorUtil.getEntitySuperClassTagValue(
+ model, input);
+ if (superClass != null) {
+
+ // will act as if super class is a bean
+ superClassIsBean = true;
+ }
+ }
+
+ ObjectModelClass output =
+ createAbstractClass(input.getName(), input.getPackageName());
+
+ if (superClass != null) {
+ setSuperClass(output, superClass);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will generate " + output.getQualifiedName());
+ }
+
+ String i18nPrefix = JPATemplatesGeneratorUtil.getI18nPrefixTagValue(input, model);
+ if (!StringUtils.isEmpty(i18nPrefix)) {
+ generateI18nBlock(input, output, i18nPrefix);
+ }
+
+ String noPCSTagValue = JPATemplatesGeneratorUtil.getNoPCSTagValue(model, input);
+ boolean usePCS = StringUtils.isEmpty(noPCSTagValue) ||
+ !"true".equals(noPCSTagValue.trim());
+
+ String noGenerateBooleanGetMethods =
+ JPATemplatesGeneratorUtil.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) {
+
+ if (!superClassIsBean) {
+
+ // add getChild methods
+ createGetChildMethod(output);
+ }
+
+ }
+ return output;
+ }
+
+ 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,
+ JPATemplatesGeneratorUtil.SERIAL_VERSION_UID,
+ "long",
+ "1L",
+ ObjectModelJavaModifier.PRIVATE
+ );
+ return resultClassImpl;
+ }
+
+ 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);
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPAEntityTransformer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesGeneratorUtil.java
===================================================================
--- trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesGeneratorUtil.java (rev 0)
+++ trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesGeneratorUtil.java 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,84 @@
+package org.nuiton.eugene.jpa;
+
+/*
+ * #%L
+ * EUGene :: JPA templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+import org.nuiton.eugene.java.JavaGeneratorUtil;
+import org.nuiton.eugene.models.object.ObjectModel;
+import org.nuiton.eugene.models.object.ObjectModelClassifier;
+
+/**
+ * Utility class for pure jpa templates.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.7
+ */
+public class JPATemplatesGeneratorUtil extends JavaGeneratorUtil {
+
+ /**
+ * Check if the given classifier has the
+ * {@link JPATemplatesStereoTypes#STEREOTYPE_ENTITY} stereotype.
+ *
+ * @param classifier classifier to test
+ * @return {@code true} if stereotype was found, {@code false otherwise}
+ * @see JPATemplatesStereoTypes#STEREOTYPE_ENTITY
+ */
+ public static boolean hasEntityStereotype(ObjectModelClassifier classifier) {
+ return classifier.hasStereotype(JPATemplatesStereoTypes.STEREOTYPE_ENTITY);
+ }
+
+ /**
+ * Obtain the value of the {@link JPATemplatesTagValues#TAG_NO_PCS}
+ * tag value on the given model or classifier.
+ * <p/>
+ * It will first look on the model, and then in the given classifier.
+ *
+ * @param model model to seek
+ * @param classifier classifier to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JPATemplatesTagValues#TAG_NO_PCS
+ * @since 2.3
+ */
+ public static String getNoPCSTagValue(ObjectModel model, ObjectModelClassifier classifier) {
+ String value = findTagValue(JPATemplatesTagValues.TAG_NO_PCS, classifier, model);
+ return value;
+ }
+
+ /**
+ * Obtain the value of the {@link JPATemplatesTagValues#TAG_ENTITY_SUPER_CLASS}
+ * tag value on the given model or classifier.
+ * <p/>
+ * It will first look on the model, and then in the given classifier.
+ *
+ * @param model model to seek
+ * @param classifier classifier to seek
+ * @return the none empty value of the found tag value or {@code null} if not found nor empty.
+ * @see JPATemplatesTagValues#TAG_ENTITY_SUPER_CLASS
+ * @since 2.3
+ */
+ public static String getEntitySuperClassTagValue(ObjectModel model, ObjectModelClassifier classifier) {
+ String value = findTagValue(JPATemplatesTagValues.TAG_ENTITY_SUPER_CLASS, classifier, model);
+ return value;
+ }
+}
Property changes on: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesGeneratorUtil.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProvider.java
===================================================================
--- trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProvider.java (rev 0)
+++ trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProvider.java 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,43 @@
+package org.nuiton.eugene.jpa;
+
+/*
+ * #%L
+ * EUGene :: JPA templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+import org.nuiton.eugene.ModelPropertiesUtil;
+
+/**
+ * The JPA templates provider of tag values and stereotypes.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @plexus.component role="org.nuiton.eugene.ModelPropertiesUtil$ModelPropertiesProvider" role-hint="jpa"
+ * @since 2.7
+ */
+public class JPATemplatesModelPropertiesProvider extends ModelPropertiesUtil.ModelPropertiesProvider {
+
+ @Override
+ public void init() throws IllegalAccessException {
+ scanStereotypeClass(JPATemplatesStereoTypes.class);
+ scanTagValueClass(JPATemplatesTagValues.class);
+ }
+}
Property changes on: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProvider.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesStereoTypes.java
===================================================================
--- trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesStereoTypes.java (rev 0)
+++ trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesStereoTypes.java 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,49 @@
+package org.nuiton.eugene.jpa;
+
+/*
+ * #%L
+ * EUGene :: JPA templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+import org.nuiton.eugene.EugeneStereoTypes;
+import org.nuiton.eugene.ModelPropertiesUtil;
+import org.nuiton.eugene.models.object.ObjectModelClassifier;
+
+/**
+ * Defines all stereotypes managed by JPA templates.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.7
+ */
+public interface JPATemplatesStereoTypes extends EugeneStereoTypes {
+
+ /**
+ * Stereotype for JPA entities to place on a classifier.
+ *
+ * @see JPATemplatesGeneratorUtil#hasEntityStereotype(ObjectModelClassifier)
+ * @since 2.5.6
+ */
+ @ModelPropertiesUtil.StereotypeDefinition(
+ target = ObjectModelClassifier.class,
+ documentation = "To specify that a class is a JPA Entity")
+ String STEREOTYPE_ENTITY = "entity";
+}
Property changes on: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesStereoTypes.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesTagValues.java
===================================================================
--- trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesTagValues.java (rev 0)
+++ trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesTagValues.java 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,116 @@
+package org.nuiton.eugene.jpa;
+
+/*
+ * #%L
+ * EUGene :: JPA templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+import org.nuiton.eugene.EugeneTagValues;
+import org.nuiton.eugene.ModelPropertiesUtil;
+import org.nuiton.eugene.models.object.ObjectModel;
+import org.nuiton.eugene.models.object.ObjectModelClassifier;
+
+/**
+ * Defines all tag values managed by JPA templates.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.7
+ */
+public interface JPATemplatesTagValues extends EugeneTagValues {
+
+ /**
+ * Tag value to set if do not want any pcs (says PropertyChangeSupport in a generated bean).
+ * <p/>
+ * You can globaly use it on the complete model or to a specific classifier.
+ *
+ * @see JPATemplatesGeneratorUtil#getNoPCSTagValue(ObjectModel, ObjectModelClassifier)
+ * @since 2.7
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class, ObjectModelClassifier.class},
+ documentation = "To specify to not generate any propertyChange " +
+ "code for a class or any class of a model")
+ String TAG_NO_PCS = "noPCS";
+
+ /**
+ * Tag value to use a super class for generated bean.
+ * <p/>
+ * If the bean needs Property change support (says you do not add the {@link #TAG_NO_PCS} on classifier or model,
+ * then your class must provide evrything for it.
+ * <p/>
+ * More over, if you use some collections in your bean you must also define
+ * two method named {@code getChild(Collection list, int index)} and
+ * {@code getChild(List list, int index)}
+ * <p/>
+ * See new code to know minimum stuff to add in your class for this purpose.
+ * <pre>
+ * public abstract class AbstractEntity implements Serializable {
+ *
+ * private static final long serialVersionUID = 1L;
+ *
+ * protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ *
+ * public void addPropertyChangeListener(PropertyChangeListener listener) {
+ * pcs.addPropertyChangeListener(listener);
+ * }
+ *
+ * public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ * pcs.addPropertyChangeListener(propertyName, listener);
+ * }
+ *
+ * public void removePropertyChangeListener(PropertyChangeListener listener) {
+ * pcs.removePropertyChangeListener(listener);
+ * }
+ *
+ * public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ * pcs.removePropertyChangeListener(propertyName, listener);
+ * }
+ *
+ * protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ * pcs.firePropertyChange(propertyName, oldValue, newValue);
+ * }
+ *
+ * protected void firePropertyChange(String propertyName, Object newValue) {
+ * firePropertyChange(propertyName, null, newValue);
+ * }
+ *
+ * protected <T> T getChild(Collection<T> list, int index) {
+ * return CollectionUtil.getOrNull(list, index);
+ * }
+ *
+ * protected <T> T getChild(List<T> list, int index) {
+ * return CollectionUtil.getOrNull(list, index);
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * You can globaly use it on the complete model or to a specific classifier.
+ *
+ * @see JPATemplatesGeneratorUtil#getEntitySuperClassTagValue(ObjectModel, ObjectModelClassifier)
+ * @since 2.7
+ */
+ @ModelPropertiesUtil.TagValueDefinition(
+ target = {ObjectModel.class, ObjectModelClassifier.class},
+ documentation = "To specify a super-class to used on generated entities " +
+ "for a class or any class of a model")
+ String TAG_ENTITY_SUPER_CLASS = "entitySuperClass";
+}
Property changes on: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/JPATemplatesTagValues.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/package-info.java
===================================================================
--- trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/package-info.java (rev 0)
+++ trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/package-info.java 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,32 @@
+/**
+ * Eugene jpa package : JPA generators.
+ * <pre>
+ * - Generator : {@link JPAEntityTransformer } to generate a jap entity.
+ * - Generator : {@link JPADaoTransformer } to generate a dao.
+ * </pre>
+ */
+package org.nuiton.eugene.jpa;
+
+/*
+ * #%L
+ * EUGene :: JPA templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
Property changes on: trunk/eugene-jpa-templates/src/main/java/org/nuiton/eugene/jpa/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/main/resources/META-INF/services/org.nuiton.eugene.ModelPropertiesUtil$ModelPropertiesProvider
===================================================================
--- trunk/eugene-jpa-templates/src/main/resources/META-INF/services/org.nuiton.eugene.ModelPropertiesUtil$ModelPropertiesProvider (rev 0)
+++ trunk/eugene-jpa-templates/src/main/resources/META-INF/services/org.nuiton.eugene.ModelPropertiesUtil$ModelPropertiesProvider 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1 @@
+org.nuiton.eugene.jpa.JPATemplatesModelPropertiesProvider
\ No newline at end of file
Property changes on: trunk/eugene-jpa-templates/src/main/resources/META-INF/services/org.nuiton.eugene.ModelPropertiesUtil$ModelPropertiesProvider
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/site/fr/rst/index.rst
===================================================================
--- trunk/eugene-jpa-templates/src/site/fr/rst/index.rst (rev 0)
+++ trunk/eugene-jpa-templates/src/site/fr/rst/index.rst 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,44 @@
+.. -
+.. * #%L
+.. * EUGene :: JPA templates
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2013 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%
+.. -
+
+======
+Eugene
+======
+
+:Authors: tony CHEMIT
+:Contact: chemit(a)codelutin.com
+:Revision: $Revision$
+:Date: $Date$
+
+.. contents::
+
+Templates java
+==============
+
+Ce module offre des templates pour générer des objets jpa, à savoir :
+
+- des entités (*org.nuiton.eugene.jpa.JPAEntityTransformer*)
+- des dao (*org.nuiton.eugene.jpa.JPADaoTransformer*)
+
+*TODO Finir cette documentation avant la version 3.0 en donnant un exemple complet d'utilisation.*
\ No newline at end of file
Property changes on: trunk/eugene-jpa-templates/src/site/fr/rst/index.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/site/rst/index.rst
===================================================================
--- trunk/eugene-jpa-templates/src/site/rst/index.rst (rev 0)
+++ trunk/eugene-jpa-templates/src/site/rst/index.rst 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,44 @@
+.. -
+.. * #%L
+.. * EUGene :: JPA templates
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2013 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%
+.. -
+
+======
+Eugene
+======
+
+:Authors: tony CHEMIT
+:Contact: chemit(a)codelutin.com
+:Revision: $Revision$
+:Date: $Date$
+
+.. contents::
+
+JPA Templates
+=============
+
+This module offers you some templates to generate some JPA stuff:
+
+- entities (*org.nuiton.eugene.jpa.JPAEntityTransformer*)
+- dao (*org.nuiton.eugene.jpa.JPADaoTransformer*)
+
+* TODO Finish this documentation before version 3.0*.
Property changes on: trunk/eugene-jpa-templates/src/site/rst/index.rst
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/site/site_en.xml
===================================================================
--- trunk/eugene-jpa-templates/src/site/site_en.xml (rev 0)
+++ trunk/eugene-jpa-templates/src/site/site_en.xml 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ EUGene :: JPA templates
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2013 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%
+ -->
+
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ </bannerLeft>
+
+ <body>
+
+ <head>
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+ </head>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="./index.html"/>
+ </breadcrumbs>
+
+ <links>
+ <item name="[fr" href="fr/index.html"/>
+ <item name="en]" href="index.html"/>
+ </links>
+
+ <menu ref="parent"/>
+
+ <menu name="User">
+ <item href="index.html" name="Home"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ <footer>
+
+ <div id='projectMetas' locale='en'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.developerConnection}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
+
+ </body>
+</project>
Property changes on: trunk/eugene-jpa-templates/src/site/site_en.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/site/site_fr.xml
===================================================================
--- trunk/eugene-jpa-templates/src/site/site_fr.xml (rev 0)
+++ trunk/eugene-jpa-templates/src/site/site_fr.xml 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ EUGene :: JPA templates
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2013 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%
+ -->
+
+
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ </bannerLeft>
+
+ <body>
+
+ <head>
+ <script type="text/javascript"
+ src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js">
+ </script>
+ </head>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="./index.html"/>
+ </breadcrumbs>
+
+ <links>
+ <item name="[fr" href="index.html"/>
+ <item name="en]" href="../index.html"/>
+ </links>
+
+ <!-- TC-20100117 : ne fonctionne pas sur une langue non principale -->
+ <!--<menu ref="parent"/>-->
+ <menu name="Parent Projet">
+ <item name="Eugene" href="../../fr/index.html"/>
+ </menu>
+
+ <menu name="Utilisateur">
+ <item href="index.html" name="Accueil"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ <footer>
+
+ <div id='projectMetas' locale='fr'
+ projectversion='${project.version}'
+ platform='${project.platform}'
+ projectid='${project.projectId}'
+ scm='${project.scm.developerConnection}'
+ scmwebeditorenabled='${project.scmwebeditorEnabled}'
+ scmwebeditorurl='${project.scmwebeditorUrl}'
+ siteSourcesType='${project.siteSourcesType}'
+ piwikEnabled='${project.piwikEnabled}'
+ piwikId='${project.piwikId}'>
+ </div>
+ </footer>
+
+ </body>
+</project>
Property changes on: trunk/eugene-jpa-templates/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/eugene-jpa-templates/src/test/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProviderTest.java
===================================================================
--- trunk/eugene-jpa-templates/src/test/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProviderTest.java (rev 0)
+++ trunk/eugene-jpa-templates/src/test/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProviderTest.java 2013-03-28 11:13:11 UTC (rev 1234)
@@ -0,0 +1,146 @@
+package org.nuiton.eugene.jpa;
+
+/*
+ * #%L
+ * EUGene :: JPA templates
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 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%
+ */
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.nuiton.eugene.ModelPropertiesUtil;
+import org.nuiton.eugene.models.object.ObjectModel;
+import org.nuiton.eugene.models.object.ObjectModelAttribute;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.ObjectModelClassifier;
+import org.nuiton.eugene.models.object.ObjectModelEnumeration;
+import org.nuiton.eugene.models.object.ObjectModelInterface;
+import org.nuiton.eugene.models.object.ObjectModelOperation;
+
+/**
+ * To test stereotypes and tag values of this module.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.7
+ */
+public class JPATemplatesModelPropertiesProviderTest {
+
+ protected ModelPropertiesUtil.ModelPropertiesProvider provider;
+
+ @Before
+ public void setUp() throws Exception {
+ provider = new JPATemplatesModelPropertiesProvider();
+ provider.init();
+ }
+
+ @Test
+ public void getTagValueTarget() throws Exception {
+ getTagValueTarget(JPATemplatesTagValues.TAG_NO_PCS, ObjectModel.class, ObjectModelClassifier.class);
+ }
+
+ @Test
+ public void containsTagValue() throws Exception {
+ containsTagValue(JPATemplatesTagValues.TAG_NO_PCS, true);
+ containsTagValue(JPATemplatesTagValues.TAG_ENTITY_SUPER_CLASS, true);
+
+ long l = System.nanoTime();
+ containsTagValue(JPATemplatesTagValues.TAG_NO_PCS + l, false);
+ containsTagValue(JPATemplatesTagValues.TAG_ENTITY_SUPER_CLASS + l, false);
+ }
+
+ @Test
+ public void acceptTagValue() throws Exception {
+ acceptTagValue(JPATemplatesTagValues.TAG_NO_PCS, true, ObjectModel.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class);
+ acceptTagValue(JPATemplatesTagValues.TAG_ENTITY_SUPER_CLASS, true, ObjectModel.class, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class);
+
+ acceptTagValue(JPATemplatesTagValues.TAG_NO_PCS, false, ObjectModelOperation.class, ObjectModelAttribute.class);
+ acceptTagValue(JPATemplatesTagValues.TAG_ENTITY_SUPER_CLASS, false, ObjectModelOperation.class, ObjectModelAttribute.class);
+
+ long l = System.nanoTime();
+ acceptTagValue(JPATemplatesTagValues.TAG_NO_PCS + l, false, ObjectModelOperation.class, ObjectModelAttribute.class);
+ acceptTagValue(JPATemplatesTagValues.TAG_ENTITY_SUPER_CLASS + l, false, ObjectModelOperation.class, ObjectModelAttribute.class);
+ }
+
+ @Test
+ public void getStereotypeTarget() throws Exception {
+
+ getStereotypeTarget(JPATemplatesStereoTypes.STEREOTYPE_ENTITY, ObjectModelClassifier.class);
+ }
+
+ @Test
+ public void containsStereotype() throws Exception {
+ containsStereotype(JPATemplatesStereoTypes.STEREOTYPE_ENTITY, true);
+
+ long l = System.nanoTime();
+ containsStereotype(JPATemplatesStereoTypes.STEREOTYPE_ENTITY + l, false);
+ }
+
+ @Test
+ public void acceptStereotype() throws Exception {
+
+ acceptStereotype(JPATemplatesStereoTypes.STEREOTYPE_ENTITY, true, ObjectModelClassifier.class, ObjectModelClass.class, ObjectModelEnumeration.class, ObjectModelInterface.class);
+
+ acceptStereotype(JPATemplatesStereoTypes.STEREOTYPE_ENTITY, false, ObjectModel.class, ObjectModelOperation.class);
+
+ long l = System.nanoTime();
+ acceptStereotype(JPATemplatesStereoTypes.STEREOTYPE_ENTITY + l, false, ObjectModel.class, ObjectModelOperation.class);
+
+ }
+
+ protected void getTagValueTarget(String name, Class<?>... expected) {
+ Class<?>[] classes = provider.getTagValueTarget(name);
+ Assert.assertNotNull("Could not find target for " + name, classes);
+ Assert.assertEquals("Should have " + expected.length + " targets for " + name + " but had " + classes.length, classes.length, expected.length);
+ Assert.assertArrayEquals(expected, classes);
+ }
+
+ protected void containsTagValue(String name, boolean expected) {
+ boolean classes = provider.containsTagValue(name);
+ Assert.assertEquals(expected, classes);
+ }
+
+ protected void acceptTagValue(String name, boolean expected, Class<?>... types) {
+ for (Class<?> type : types) {
+ boolean actual = provider.acceptTagValue(name, type);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+
+ protected void getStereotypeTarget(String name, Class<?>... expected) {
+ Class<?>[] classes = provider.getStereotypeTarget(name);
+ Assert.assertNotNull("Could not find target for " + name, classes);
+ Assert.assertEquals("Should have " + expected.length + " targets for " + name + " but had " + classes.length, classes.length, expected.length);
+ Assert.assertArrayEquals(expected, classes);
+ }
+
+ protected void containsStereotype(String name, boolean expected) {
+ boolean classes = provider.containsStereotype(name);
+ Assert.assertEquals(expected, classes);
+ }
+
+ protected void acceptStereotype(String name, boolean expected, Class<?>... types) {
+ for (Class<?> type : types) {
+ boolean actual = provider.acceptStereotype(name, type);
+ Assert.assertEquals(expected, actual);
+ }
+ }
+}
Property changes on: trunk/eugene-jpa-templates/src/test/java/org/nuiton/eugene/jpa/JPATemplatesModelPropertiesProviderTest.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 2013-01-11 16:08:07 UTC (rev 1233)
+++ trunk/eugene-maven-plugin/pom.xml 2013-03-28 11:13:11 UTC (rev 1234)
@@ -33,7 +33,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>eugene</artifactId>
- <version>2.6.2-SNAPSHOT</version>
+ <version>2.7-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.eugene</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-01-11 16:08:07 UTC (rev 1233)
+++ trunk/pom.xml 2013-03-28 11:13:11 UTC (rev 1234)
@@ -32,15 +32,16 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.4.7</version>
+ <version>3.4.8</version>
</parent>
<artifactId>eugene</artifactId>
- <version>2.6.2-SNAPSHOT</version>
+ <version>2.7-SNAPSHOT</version>
<modules>
<module>eugene</module>
<module>eugene-java-templates</module>
+ <module>eugene-jpa-templates</module>
<module>eugene-maven-plugin</module>
</modules>
@@ -139,6 +140,12 @@
</dependency>
<dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <version>1.0.1.Final</version>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton</groupId>
<artifactId>helper-maven-plugin-api</artifactId>
<version>${helperPluginVersion}</version>
@@ -318,6 +325,7 @@
<!-- do not relativize links in generated site -->
<relativizeDecorationLinks>false</relativizeDecorationLinks>
+ <plexusPluginVersion>1.3.8</plexusPluginVersion>
</properties>
<build>
1
0