Author: tchemit Date: 2010-04-23 16:35:05 +0200 (Fri, 23 Apr 2010) New Revision: 1910 Log: - Evolution #552: Clean api - Deprecates some TopiaGeneratorUil methods (already present in GeneratorUtil) Modified: trunk/topia-persistence/pom.xml trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java Modified: trunk/topia-persistence/pom.xml =================================================================== --- trunk/topia-persistence/pom.xml 2010-04-23 14:32:23 UTC (rev 1909) +++ trunk/topia-persistence/pom.xml 2010-04-23 14:35:05 UTC (rev 1910) @@ -274,7 +274,7 @@ <!-- reporting at release time --> <profile> - <id>reporting-profile</id> + <id>reporting</id> <activation> <property> <name>performRelease</name> Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java 2010-04-23 14:32:23 UTC (rev 1909) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaGeneratorUtil.java 2010-04-23 14:35:05 UTC (rev 1910) @@ -38,11 +38,11 @@ import java.util.*; -import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.eugene.AbstractGenerator; import org.nuiton.eugene.GeneratorUtil; +import org.nuiton.eugene.java.JavaGeneratorUtil; import org.nuiton.eugene.models.Model; import org.nuiton.eugene.models.object.ObjectModel; import org.nuiton.eugene.models.object.ObjectModelAssociationClass; @@ -56,7 +56,7 @@ /** * Classe regroupant divers méthodes utiles pour la génération des entités */ -public class TopiaGeneratorUtil extends GeneratorUtil { +public class TopiaGeneratorUtil extends JavaGeneratorUtil { /** * Logger @@ -77,7 +77,10 @@ public static final String STEREOTYPE_DTO = "dto"; /** * Stéréotype pour les objets devant être générées sous forme de bean + * @deprecated since 2.4, prefer use the + * {@link JavaGeneratorUtil#STEREOTYPE_BEAN} method. */ + @Deprecated public static final String STEREOTYPE_BEAN = "bean"; /** * Stéréotype pour les interfaces devant être générées sous forme de @@ -594,15 +597,19 @@ * * @param attr l'attribut a traiter * @return le nom de l'attribut de classe d'association + * @deprecated since 2.4, prefer use the + * {@link GeneratorUtil#getAssocAttrName(ObjectModelAttribute)} */ + @Deprecated public static String getAssocAttrName(ObjectModelAttribute attr) { - String typeName = attr.getType().substring( - attr.getType().lastIndexOf(".") + 1); - String result = attr.getName(); - if (attr.getName().equalsIgnoreCase(typeName)) { - result += StringUtils.capitalize( - attr.getAssociationClass().getName()); - } + String result = GeneratorUtil.getAssocAttrName(attr); +// String typeName = attr.getType().substring( +// attr.getType().lastIndexOf(".") + 1); +// String result = attr.getName(); +// if (attr.getName().equalsIgnoreCase(typeName)) { +// result += StringUtils.capitalize( +// attr.getAssociationClass().getName()); +// } return result; } @@ -953,13 +960,21 @@ return result; } + /** + * + * @param fqn fqn to parse + * @return the simple name of fqn + * @deprecated since 2.0.2 : already in GeneratorUtil + */ + @Deprecated public static String getSimpleName(String fqn) { - int lasIndex = fqn.lastIndexOf("."); - if (lasIndex == 1) { - // primitive type - return fqn; - } - return fqn.substring(lasIndex + 1); + return GeneratorUtil.getSimpleName(fqn); +// int lasIndex = fqn.lastIndexOf("."); +// if (lasIndex == 1) { +// // primitive type +// return fqn; +// } +// return fqn.substring(lasIndex + 1); /*if (lasIndex == aClass.getPackageName().length()) { // same package return fqn.substring(lasIndex + 1); Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2010-04-23 14:32:23 UTC (rev 1909) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2010-04-23 14:35:05 UTC (rev 1910) @@ -36,7 +36,6 @@ */ package org.nuiton.topia.persistence; -import java.lang.Class; import java.security.Permission; import java.util.Collection; import java.util.List; @@ -72,7 +71,7 @@ * * @return new entity instance * @since 2.3.1 - * @throws TopiaException + * @throws TopiaException if any pb while creating the entitie */ Entity newInstance() throws TopiaException; @@ -134,17 +133,17 @@ * * @param e l'entité instanciée à sauver * @return l'entité avec son topiaID valorisé - * @throws TopiaException + * @throws TopiaException if any pb while creating datas * * @since 2.3.1 - * @throw TopiaException if any pb while creating datas */ Entity create(Entity e) throws TopiaException; /** * Permet d'ajouter ou de mettre a jour un objet. Cela permet d'ajouter * par exemple un objet provenant d'un autre context mais du meme type - * de DAO + * de DAO. + * * @param e l'entite a ajouter ou mettre a jour * @return l'entity passé en paramètre. * @throws TopiaException if any pb while updating datas @@ -152,9 +151,10 @@ Entity update(Entity e) throws TopiaException; /** - * Permet de supprimer - * @param e - * @throws TopiaException + * Permet de supprimer une entite. + * + * @param e l'entite a supprimer + * @throws TopiaException if any pb while deleting datas */ void delete(Entity e) throws TopiaException; @@ -258,7 +258,7 @@ * * @param keys la liste des champs de la cle naturelle avec leur valeur * @return l'entite trouvé - * @throws TopiaException + * @throws TopiaException if any pb while getting datas */ Entity findByPrimaryKey(Map<String, Object> keys) throws TopiaException; @@ -278,8 +278,8 @@ /** * - * @param propertyName - * @param value + * @param propertyName le nom de la propriété + * @param value la valeur à tester * @param others les autres proprietes doivent aller par 2 propertyName, * value * @return l'entité trouvé @@ -295,8 +295,8 @@ /** * - * @param propertyName - * @param value + * @param propertyName le nom de la propriété + * @param value la valeur à tester * @param others les autres proprietes doivent aller par 2 propertyName, * value * @return l'entité trouvé @@ -315,35 +315,35 @@ * Cherche et renvoie la première entité trouvée dont les propriétés en clé * de Map contiennent toutes les valeurs de la Collection. * - * @param properties + * @param properties les proprietes a utiliser * @return l'entité trouvé * @throws TopiaException if any pb while getting datas */ - Entity findContainsProperties(Map<String, Collection> properties) throws + Entity findContainsProperties(Map<String, Collection<?>> properties) throws TopiaException; /** * Cherche et renvoie la première entité trouvée dont la propriété * propertyName contient values, ainsi de suite avec others. * - * @param propertyName - * @param values - * @param others + * @param propertyName le nom de la propriété + * @param values les premières valeurs à tester + * @param others les secondes valeurs ) tester * @return l'entité trouvé * @throws TopiaException if any pb while getting datas */ - Entity findContainsProperties(String propertyName, Collection values, + Entity findContainsProperties(String propertyName, Collection<?> values, Object... others) throws TopiaException; /** * Cherche et renvoie la première entité trouvée dont les propriétés en clé * de Map contiennent toutes les valeurs de la Collection. * - * @param properties + * @param properties les propriétés à tester * @return l'entité trouvé * @throws TopiaException if any pb while getting datas */ - List<Entity> findAllContainsProperties(Map<String, Collection> properties) + List<Entity> findAllContainsProperties(Map<String, Collection<?>> properties) throws TopiaException; /** @@ -351,13 +351,13 @@ * propertyName contient values, ainsi de suite avec others. * * @param propertyName the name of the property - * @param values - * @param others + * @param values les premières valeurs à tester + * @param others les secondes valeurs à tester * @return l'entité trouvé * @throws TopiaException if any pb while getting datas */ List<Entity> findAllContainsProperties(String propertyName, - Collection values, Object... others) throws TopiaException; + Collection<?> values, Object... others) throws TopiaException; /** * Find usages of the given {@code entity} in the entities of the given @@ -393,7 +393,7 @@ * service Taas. * * @param topiaId topiaId d'une entite - * @param actions + * @param actions encoded actions * @return la liste des permissions * @throws TopiaException if any pb while getting datas */ Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2010-04-23 14:32:23 UTC (rev 1909) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2010-04-23 14:35:05 UTC (rev 1910) @@ -273,7 +273,7 @@ public E create(Object... properties) throws TopiaException { Map<String, Object> map = new HashMap<String, Object>(); Object propertyName = null; - Object value = null; + Object value; try { for (int i = 0; i < properties.length;) { propertyName = properties[i++]; @@ -413,7 +413,7 @@ } @Override - public E findContainsProperties(Map<String, Collection> properties) + public E findContainsProperties(Map<String, Collection<?>> properties) throws TopiaException { List<E> results = findAllContainsProperties(properties); E result = null; @@ -425,14 +425,14 @@ @Override public E findContainsProperties(String propertyName, - Collection values, Object... others) throws TopiaException { - Map<String, Collection> properties = new HashMap<String, Collection>(); + Collection<?> values, Object... others) throws TopiaException { + Map<String, Collection<?>> properties = new HashMap<String, Collection<?>>(); properties.put(propertyName, values); Object name = null; for (int i = 0; i < others.length;) { try { name = others[i++]; - values = (Collection) others[i++]; + values = (Collection<?>) others[i++]; properties.put((String) name, values); } catch (ClassCastException eee) { throw new IllegalArgumentException( @@ -467,16 +467,16 @@ */ @Override public List<E> findAllContainsProperties(Map<String, - Collection> properties) throws TopiaException { + Collection<?>> properties) throws TopiaException { List<E> all = findAll(); List<E> result = new ArrayList<E>(); for (E e : all) { boolean ok = true; try { - for (Entry<String, Collection> kv : properties.entrySet()) { - Collection entityValues = (Collection) PropertyUtils + for (Entry<String, Collection<?>> kv : properties.entrySet()) { + Collection<?> entityValues = (Collection<?>) PropertyUtils .getProperty(e, kv.getKey()); - Collection values = kv.getValue(); + Collection<?> values = kv.getValue(); if (!entityValues.containsAll(values)) { ok = false; break; @@ -521,14 +521,14 @@ @Override public List<E> findAllContainsProperties(String propertyName, - Collection values, Object... others) throws TopiaException { - Map<String, Collection> properties = new HashMap<String, Collection>(); + Collection<?> values, Object... others) throws TopiaException { + Map<String, Collection<?>> properties = new HashMap<String, Collection<?>>(); properties.put(propertyName, values); Object name = null; for (int i = 0; i < others.length;) { try { name = others[i++]; - values = (Collection) others[i++]; + values = (Collection<?>) others[i++]; properties.put((String) name, values); } catch (ClassCastException eee) { throw new IllegalArgumentException(