r622 - in nuiton-jpa: . nuiton-jpa-api/src/main/java/org/nuiton/jpa/api nuiton-jpa-templates/src/main/java/org/nuiton/jpa nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates
Author: tchemit Date: 2013-05-24 18:42:23 +0200 (Fri, 24 May 2013) New Revision: 622 Url: http://nuiton.org/projects/sandbox/repository/revisions/622 Log: nuiton-api Added: nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/AbstractJpaEntity.java nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/ nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/AbstractJpaTransformer.java nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaDaoTransformer.java nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaEntityTransformer.java nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesGeneratorUtil.java nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesModelPropertiesProvider.java nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesStereoTypes.java nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesTagValues.java nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/package-info.java Removed: nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/JpaEntity.java Modified: nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/AbstractJpaDao.java nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/JpaDao.java nuiton-jpa/pom.xml Modified: nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/AbstractJpaDao.java =================================================================== --- nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/AbstractJpaDao.java 2013-05-24 15:48:17 UTC (rev 621) +++ nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/AbstractJpaDao.java 2013-05-24 16:42:23 UTC (rev 622) @@ -37,7 +37,7 @@ * @author bleny, tchemit * @since 0.1 */ -public abstract class AbstractJpaDao<E extends JpaEntity> implements JpaDao<E> { +public abstract class AbstractJpaDao<E extends AbstractJpaEntity> implements JpaDao<E> { protected EntityManager entityManager; Copied: nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/AbstractJpaEntity.java (from rev 621, nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/JpaEntity.java) =================================================================== --- nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/AbstractJpaEntity.java (rev 0) +++ nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/AbstractJpaEntity.java 2013-05-24 16:42:23 UTC (rev 622) @@ -0,0 +1,59 @@ +package org.nuiton.jpa.api; + +/* + * #%L + * MagaLiE :: Persistence + * $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 Affero 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 Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ + +/** + * A AbstractJpaEntity must have a technical id. + * + * Also equals() is defined for compliance with JPA expectations. + * + * @author bleny, tchemit + * @since 0.1 + */ +public abstract class AbstractJpaEntity { + + public abstract String getId(); + + @Override + public boolean equals(Object other) { + String id = getId(); + if (other instanceof AbstractJpaEntity) { + AbstractJpaEntity that = (AbstractJpaEntity) other; + return id != null && that.getId() != null && id.equals(that.getId()); + } + return false; + } + + @Override + public int hashCode() { + String id = getId(); + return id == null ? 0 : id.hashCode(); + } + + @Override + public String toString() { + return "AbstractJpaEntity{id=" + getId() + "}"; + } + +} Modified: nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/JpaDao.java =================================================================== --- nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/JpaDao.java 2013-05-24 15:48:17 UTC (rev 621) +++ nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/JpaDao.java 2013-05-24 16:42:23 UTC (rev 622) @@ -33,7 +33,7 @@ * @author bleny, tchemit * @since 0.1 */ -public interface JpaDao<E extends JpaEntity> { +public interface JpaDao<E extends AbstractJpaEntity> { E findById(String id); Deleted: nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/JpaEntity.java =================================================================== --- nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/JpaEntity.java 2013-05-24 15:48:17 UTC (rev 621) +++ nuiton-jpa/nuiton-jpa-api/src/main/java/org/nuiton/jpa/api/JpaEntity.java 2013-05-24 16:42:23 UTC (rev 622) @@ -1,59 +0,0 @@ -package org.nuiton.jpa.api; - -/* - * #%L - * MagaLiE :: Persistence - * $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 Affero 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 Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * #L% - */ - -/** - * A JpaEntity must have a technical id. - * - * Also equals() is defined for compliance with JPA expectations. - * - * @author bleny, tchemit - * @since 0.1 - */ -public abstract class JpaEntity { - - public abstract String getId(); - - @Override - public boolean equals(Object other) { - String id = getId(); - if (other instanceof JpaEntity) { - JpaEntity that = (JpaEntity) other; - return id != null && that.getId() != null && id.equals(that.getId()); - } - return false; - } - - @Override - public int hashCode() { - String id = getId(); - return id == null ? 0 : id.hashCode(); - } - - @Override - public String toString() { - return "JpaEntity{id=" + getId() + "}"; - } - -} Added: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/AbstractJpaTransformer.java =================================================================== --- nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/AbstractJpaTransformer.java (rev 0) +++ nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/AbstractJpaTransformer.java 2013-05-24 16:42:23 UTC (rev 622) @@ -0,0 +1,588 @@ +package org.nuiton.jpa.templates; + +/* + * #%L + * EUGene :: JPA templates + * $Id$ + * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-jpa-templates/src/main/java/or... $ + * %% + * 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.apache.commons.collections.CollectionUtils; +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@codelutin.com> + * @see JpaEntityTransformer + * @since 2.7 + */ +public abstract class AbstractJpaTransformer extends ObjectModelTransformerToJava { + + public static final String DEFAULT_CONSTANT_PREFIX = "PROPERTY_"; + + protected boolean isInClassPath(String packageName, String className) { + + return isInClassPath(packageName + "." + className); + } + + protected boolean isSuperClassEntity(ObjectModelClass input) { + // test if a super class is in same package (so is another entity) + boolean superClassIsBean = false; + Collection<ObjectModelClass> superclasses = input.getSuperclasses(); + if (CollectionUtils.isNotEmpty(superclasses)) { + for (ObjectModelClass superclass : superclasses) { + if (input.getPackageName().equals(superclass.getPackageName())) { + superClassIsBean = true; + break; + } + } + } + return superClassIsBean; + } + + 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 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: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/AbstractJpaTransformer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaDaoTransformer.java =================================================================== --- nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaDaoTransformer.java (rev 0) +++ nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaDaoTransformer.java 2013-05-24 16:42:23 UTC (rev 622) @@ -0,0 +1,166 @@ +package org.nuiton.jpa.templates; + +/* + * #%L + * EUGene :: JPA templates + * $Id$ + * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-jpa-templates/src/main/java/or... $ + * %% + * 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.models.object.ObjectModelClass; +import org.nuiton.eugene.models.object.ObjectModelJavaModifier; +import org.nuiton.eugene.models.object.ObjectModelOperation; +import org.nuiton.jpa.api.AbstractJpaDao; + +import javax.persistence.EntityManager; + +/** + * JpaDaoTransformer generates a dao for an entity. + * <p/> + * <ul> + * <li>{@code AbstractXXXJpaDao}: abstract jpa dao for entity named {@code XXX}, will find here the generated stuff (with jpa mapping, technical stuff)</li> + * <li>{@code XXXJpaDao}: concrete public jpa dao to use in your persistence layer</li> + * </ul> + * <p/> + * {@code Note:} All classes found in class-path are not generated. + * + * @author tchemit <chemit@codelutin.com> + * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.jpa.JpaDaoTransformer" + * @since 0.1 + */ +public class JpaDaoTransformer extends AbstractJpaTransformer { + + private static final Log log = LogFactory.getLog(JpaDaoTransformer.class); + + protected String getConcreteName(ObjectModelClass input) { + return input.getName() + "JpaDao"; + } + + @Override + public void transformFromClass(ObjectModelClass input) { + + String entityAbstractName = "Abstract" + input.getName() + "JpaDao"; + + String entityConcreteName = getConcreteName(input); + + boolean generateAbstract = !isInClassPath(input.getPackageName(), + entityAbstractName); + + boolean generateConcrete = !isInClassPath(input.getPackageName(), + entityConcreteName); + + if (generateAbstract) { + + generateAbstract(input, entityAbstractName); + } + + if (generateConcrete) { + + generateImpl(input, entityConcreteName); + } + } + + protected ObjectModelClass generateAbstract(ObjectModelClass input, + String entityAbstractName) { + + // test if a super class is in same package (so is yet another entity) + boolean superClassIsEntity = isSuperClassEntity(input); + + String superClass; + + if (superClassIsEntity) { + + // get first super-class + ObjectModelClass superClassModel = input.getSuperclasses().iterator().next(); + superClass = getConcreteName(superClassModel); + + } else { + + // try to find a super class by tag-value + superClass = JpaTemplatesGeneratorUtil.getDaoSuperClassTagValue( + model, input); + + if (superClass == null) { + + // no super-class, use default one + superClass = AbstractJpaDao.class.getName(); + } + } + + // detect if there is a contract to set on abstract + String packageName = input.getPackageName(); + + String daoContractName = input.getPackageName() + "." + input.getName() + "Dao"; + + boolean addUserDaoContract = isInClassPath(daoContractName); + + ObjectModelClass output = + createAbstractClass(entityAbstractName, packageName); + + setSuperClass(output, superClass); + + if (addUserDaoContract) { + addInterface(output, daoContractName); + } + + addConstructor(output); + + if (log.isDebugEnabled()) { + log.debug("will generate " + output.getQualifiedName()); + } + + return output; + } + + protected ObjectModelClass generateImpl(ObjectModelClass input, + String entityConcreteName) { + + ObjectModelClass output = createClass( + entityConcreteName, + input.getPackageName() + ); + + // set the abstract resulClass as the resultClassImpl super class + setSuperClass(output, input.getQualifiedName()); + + addConstructor(output); + + if (log.isDebugEnabled()) { + log.debug("will generate " + output.getQualifiedName()); + } + + return output; + } + + protected void addConstructor(ObjectModelClass output) { + + ObjectModelOperation constructor = addConstructor( + output, + ObjectModelJavaModifier.PUBLIC); + + addParameter(constructor, EntityManager.class, "entityManager"); + } +} \ No newline at end of file Property changes on: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaDaoTransformer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaEntityTransformer.java =================================================================== --- nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaEntityTransformer.java (rev 0) +++ nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaEntityTransformer.java 2013-05-24 16:42:23 UTC (rev 622) @@ -0,0 +1,346 @@ +package org.nuiton.jpa.templates; + +/* + * #%L + * EUGene :: JPA templates + * $Id$ + * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-jpa-templates/src/main/java/or... $ + * %% + * 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 com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +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 org.nuiton.jpa.api.AbstractJpaEntity; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + +/*{generator option: parentheses = false}*/ +/*{generator option: writeString = +}*/ + +/** + * JpaEntityTransformer generates two type of classes: + * <ul> + * <li>{@code AbstractJpaXXXEntity}: abstract jpa entity for entity named {@code XXX}, will find here the generated stuff (with jpa mapping, technical stuff) </li> + * <li>{@code JpaXXXEntity}: concrete public jpa entity to use in your persistence layer</li> + * </ul> + * <p/> + * {@code Note:} All classes found in class-path are not generated. + * + * @author tchemit <chemit@codelutin.com> + * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.eugene.jpa.JpaEntityTransformer" + * @since 0.1 + */ +public class JpaEntityTransformer extends AbstractJpaTransformer { + + private static final Log log = + LogFactory.getLog(JpaEntityTransformer.class); + + protected String getConcreteName(ObjectModelClass input) { + return input.getName(); + } + + @Override + public void transformFromClass(ObjectModelClass input) { + + String entityAbstractName = "Jpa" + input.getName(); + + String entityConcreteName = getConcreteName(input); + + boolean generateAbstract = !isInClassPath(input.getPackageName(), entityAbstractName); + + boolean generateConcrete = !isInClassPath(input.getPackageName(), entityConcreteName); + + if (generateAbstract) { + + generateAbstract(input, entityAbstractName); + } + + if (generateConcrete) { + + generateImpl(input, entityConcreteName); + } + } + + protected void createAbstractOperations(ObjectModelClass ouput, + Iterable<ObjectModelOperation> operations) { + JpaTemplatesGeneratorUtil.cloneOperations( + this, + operations, + ouput, + true, + ObjectModelJavaModifier.ABSTRACT + ); + } + + protected ObjectModelClass generateAbstract(ObjectModelClass input, + String entityAbstractName) { + + // test if a super class is in same package (so is yet another entity) + boolean superClassIsEntity = isSuperClassEntity(input); + + String superClass; + + if (superClassIsEntity) { + + // get first super-class + ObjectModelClass superClassModel = + input.getSuperclasses().iterator().next(); + superClass = getConcreteName(superClassModel); + + } else { + + // try to find a super class by tag-value + superClass = JpaTemplatesGeneratorUtil.getDaoSuperClassTagValue( + model, input); + + if (superClass == null) { + + // no super-class, use default one + superClass = AbstractJpaEntity.class.getName(); + + } else { + + // will act as if super class is a bean + superClassIsEntity = true; + } + } + + ObjectModelClass output = + createAbstractClass(entityAbstractName, input.getPackageName()); + + setSuperClass(output, superClass); + + if (log.isDebugEnabled()) { + log.debug("will generate " + output.getQualifiedName()); + } + + String prefix = getConstantPrefix(input, DEFAULT_CONSTANT_PREFIX); + + setConstantPrefix(prefix); + + boolean serializableFound = addInterfaces(input, output); + + if (superClassIsEntity) { + serializableFound = true; + } + + addSerializable(input, output, serializableFound); + + Set<String> constantNames = addConstantsFromDependency(input, output); + + // Get available properties + List<ObjectModelAttribute> properties = getProperties(input); + + //TODO Add attribute id (+ @Id) + //TODO Add @MappedSuperClass sur output) + //TODO 1 -> 1 @OnetoOne (uniquement navigeable sans bidi) si composition (Cascade = ALL) si aggregeation Cascade = (tout sauf ALL TODO A check) + orphanRemoval = true) + //TODO * -> 1 @ManyToOne (uniquement navigeable sans bidi) si composition (Cascade = ALL) si aggregeation Cascade = (tout sauf ALL TODO A check) + orphanRemoval = true) + //TODO 1 -> * @OneToMany (uniquement navigeable sans bidi) si composition (Cascade = ALL) si aggregeation Cascade = (tout sauf ALL TODO A check) + orphanRemoval = true) + //TODO * -> * @ManyToMany (uniquement navigeable sans bidi) si composition (Cascade = ALL) si aggregeation Cascade = (tout sauf ALL TODO A check) + orphanRemoval = true) + + //TODO Si ORDERED ou et UNIQUE choisir le bon type de collection (O+U = LHS (laisser ça comme definition), (U = HS + S), (O = ArrayList +L), ( = ArrayList + C) + //TODO Si ORDERED ajouter l'annotation @OrderColumn + //TODO Si enumeration @Enumeration(value = EnumType.STRING) (Voir pour mettre une tag-value pour mettre en ordinal) + voir comment ça marche pour les collections + + //TODO Generate Persistence annotations + Multimap<ObjectModelAttribute, String> annotationsForAttributes = + ArrayListMultimap.create(); + + + // Add properties constant + for (ObjectModelAttribute attr : properties) { + + createPropertyConstant(output, attr, prefix, constantNames); + } + + // Add properties field + javabean methods + for (ObjectModelAttribute attr : properties) { + + createProperty(output, attr, annotationsForAttributes.get(attr)); + } + + boolean hasAMultipleProperty = containsMutiple(properties); + + // Add helper operations + if (hasAMultipleProperty) { + + + // add getChild methods + createGetChildMethod(output); + + + } + return output; + } + + protected ObjectModelClass generateImpl(ObjectModelClass input, + String entityConcreteName) { + + ObjectModelClass resultClassImpl = createClass( + entityConcreteName, + 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 createProperty(ObjectModelClass output, + ObjectModelAttribute attr, + Collection<String> annotations) { + + boolean usePCS = false; + + 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) { + + createGetMethod(output, + attrName, + attrType, + JpaTemplatesGeneratorUtil.OPERATION_GETTER_DEFAULT_PREFIX + ); + + } + createSetMethod(output, + attrName, + attrType, + simpleType, + constantName, + usePCS + ); + + // Add attribute to the class + ObjectModelAttribute attribute = addAttribute(output, + attrName, + attrType, + "", + ObjectModelJavaModifier.PROTECTED + ); + + for (String annotation : annotations) { + addAnnotation(output, attribute, annotation); + } + + } + +} \ No newline at end of file Property changes on: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaEntityTransformer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesGeneratorUtil.java =================================================================== --- nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesGeneratorUtil.java (rev 0) +++ nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesGeneratorUtil.java 2013-05-24 16:42:23 UTC (rev 622) @@ -0,0 +1,72 @@ +package org.nuiton.jpa.templates; + +/* + * #%L + * EUGene :: JPA templates + * $Id$ + * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-jpa-templates/src/main/java/or... $ + * %% + * 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@codelutin.com> + * @since 2.7 + */ +public class JpaTemplatesGeneratorUtil extends JavaGeneratorUtil { + + /** + * 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; + } + + /** + * Obtain the value of the {@link JpaTemplatesTagValues#TAG_DAO_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_DAO_SUPER_CLASS + * @since 2.3 + */ + public static String getDaoSuperClassTagValue(ObjectModel model, ObjectModelClassifier classifier) { + String value = findTagValue(JpaTemplatesTagValues.TAG_ENTITY_SUPER_CLASS, classifier, model); + return value; + } +} Property changes on: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesGeneratorUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesModelPropertiesProvider.java =================================================================== --- nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesModelPropertiesProvider.java (rev 0) +++ nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesModelPropertiesProvider.java 2013-05-24 16:42:23 UTC (rev 622) @@ -0,0 +1,43 @@ +package org.nuiton.jpa.templates; + +/* + * #%L + * EUGene :: JPA templates + * $Id$ + * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-jpa-templates/src/main/java/or... $ + * %% + * 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@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: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesModelPropertiesProvider.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesStereoTypes.java =================================================================== --- nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesStereoTypes.java (rev 0) +++ nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesStereoTypes.java 2013-05-24 16:42:23 UTC (rev 622) @@ -0,0 +1,37 @@ +package org.nuiton.jpa.templates; + +/* + * #%L + * EUGene :: JPA templates + * $Id$ + * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-jpa-templates/src/main/java/or... $ + * %% + * 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; + +/** + * Defines all stereotypes managed by JPA templates. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.7 + */ +public interface JpaTemplatesStereoTypes extends EugeneStereoTypes { + +} Property changes on: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesStereoTypes.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesTagValues.java =================================================================== --- nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesTagValues.java (rev 0) +++ nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesTagValues.java 2013-05-24 16:42:23 UTC (rev 622) @@ -0,0 +1,65 @@ +package org.nuiton.jpa.templates; + +/* + * #%L + * EUGene :: JPA templates + * $Id$ + * $HeadURL: http://svn.nuiton.org/svn/eugene/trunk/eugene-jpa-templates/src/main/java/or... $ + * %% + * 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@codelutin.com> + * @since 2.7 + */ +public interface JpaTemplatesTagValues extends EugeneTagValues { + + /** + * Tag value to use a super class for generated bean. + * + * @see JpaTemplatesGeneratorUtil#getEntitySuperClassTagValue(ObjectModel, ObjectModelClassifier) + * @since 0.1 + */ + @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"; + + + /** + * Tag value to use a super class for generated bean. + * + * @see JpaTemplatesGeneratorUtil#getDaoSuperClassTagValue(ObjectModel, ObjectModelClassifier) + * @since 0.1 + */ + @ModelPropertiesUtil.TagValueDefinition( + target = {ObjectModel.class, ObjectModelClassifier.class}, + documentation = "To specify a super-class to used on generated dao " + + "for a class or any class of a model") + String TAG_DAO_SUPER_CLASS = "daoSuperClass"; + +} Property changes on: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/JpaTemplatesTagValues.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/package-info.java =================================================================== --- nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/package-info.java (rev 0) +++ nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/package-info.java 2013-05-24 16:42:23 UTC (rev 622) @@ -0,0 +1,10 @@ +/** + * Eugene jpa package : JPA generators. + * <pre> + * - Generator : {@link JpaEntityTransformer } to generate a jap entity. + * - Generator : {@link JpaDaoTransformer } to generate a dao. + * - Generator : {@link JpaPersistenceContextTransformer } to generate a dao. + * </pre> + */ +package org.nuiton.jpa.templates; + Property changes on: nuiton-jpa/nuiton-jpa-templates/src/main/java/org/nuiton/jpa/templates/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: nuiton-jpa/pom.xml =================================================================== --- nuiton-jpa/pom.xml 2013-05-24 15:48:17 UTC (rev 621) +++ nuiton-jpa/pom.xml 2013-05-24 16:42:23 UTC (rev 622) @@ -76,12 +76,6 @@ </dependency> <dependency> - <groupId>org.nuiton</groupId> - <artifactId>nuiton-utils</artifactId> - <version>${nuitonUtilsVersion}</version> - </dependency> - - <dependency> <groupId>org.hibernate.javax.persistence</groupId> <artifactId>hibernate-jpa-2.0-api</artifactId> <version>1.0.1.Final</version>
participants (1)
-
tchemit@users.nuiton.org