Author: athimel Date: 2013-11-26 18:19:25 +0100 (Tue, 26 Nov 2013) New Revision: 2895 Url: http://nuiton.org/projects/topia/repository/revisions/2895 Log: refs #2923 TopiaContextFactory is adapted refs #299 Documentation on migration Modified: trunk/src/site/rst/migrate_to_3.0.rst trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContextFactory.java trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/AbstractTopiaDao.java Modified: trunk/src/site/rst/migrate_to_3.0.rst =================================================================== --- trunk/src/site/rst/migrate_to_3.0.rst 2013-11-26 15:51:34 UTC (rev 2894) +++ trunk/src/site/rst/migrate_to_3.0.rst 2013-11-26 17:19:25 UTC (rev 2895) @@ -40,10 +40,32 @@ * Hibernate >= 4.2.1.Final +Configuration du plugin Maven +============================= + +|MANDATORY| + +Les templates sont contenus dans un modules à part, il faut désormais utiliser +cette dépendance dans le plugin eugene. + +:: + + <dependency> + <groupId>org.nuiton.topia</groupId> + <artifactId>topia-templates</artifactId> + <version>3.0</version> + </dependency> + +De plus les templates ont changé de package, le nouveau package est le suivant : + +:: + + org.nuiton.topia.templates + + Code déprécié ============= - La migration vers ToPIA 3.0 voit un certain nombre de classes et attributs dépréciés. Gérer les impacts n'est pas *nécessaire* pour passer à ToPIA 3.0, mais c'est fortement recommandé. En effet, ce code @@ -144,7 +166,7 @@ |RECOMMENDED| Si vous utilisiez explicitement le Transformer de DAO dans la configuration de votre plugin Eugene, il faut maintenant -changer le nouveau Transformer : org.nuiton.topia.generator.EntityDaoTransformer +changer le nouveau Transformer : org.nuiton.topia.templates.EntityDaoTransformer Exemple de configuration : @@ -161,7 +183,7 @@ <inputs>classpath:model:/:myProject.objectmodel</inputs> <defaultPackage>org.project.entities</defaultPackage> <templates> - org.nuiton.topia.generator.EntityDaoTransformer + org.nuiton.topia.templates.EntityDaoTransformer </templates> </configuration> <goals> @@ -220,26 +242,6 @@ méthodes les remplacer. S'il n'y pas de documentation, il faut remplacer le code appellant par le corps de la méthode dépréciée (fonctionnalité « inline » dans l'IDE). -Utilisation des templates de générations ----------------------------------------- - -Les templates sont contenues dans un modules à part, il faut désormais utiliser -cette dépendance dans le plugin eugene. - -:: - - <dependency> - <groupId>org.nuiton.topia</groupId> - <artifactId>topia-templates</artifactId> - <version>3.0</version> - </dependency> - -De plus les templates ont changé de paquetage, le nouveau paquetage est le suivant : - -:: - - org.nuiton.topia.templates - Amélioration du code sql ------------------------ Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContextFactory.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContextFactory.java 2013-11-26 15:51:34 UTC (rev 2894) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/TopiaContextFactory.java 2013-11-26 17:19:25 UTC (rev 2895) @@ -182,8 +182,8 @@ * @return Un TopiaContext ouvert * @throws TopiaNotFoundException if any pb */ - public static AbstractTopiaApplicationContext getContext( - Properties config, Function<Properties, AbstractTopiaApplicationContext> createContextFunction) + public static <C extends AbstractTopiaApplicationContext> C getContext( + Properties config, Function<Properties, C> createContextFunction) throws TopiaNotFoundException { // Put all properties from a hierarchy in the current properties object. // Resolve problem with hibernate which used iterator to get properties @@ -193,7 +193,7 @@ for (String key : config.stringPropertyNames()) { cloned.setProperty(key, config.getProperty(key)); } - AbstractTopiaApplicationContext result = contextCache.get(cloned); + C result = (C)contextCache.get(cloned); if (result == null || result.isClosed()) { if (createContextFunction == null) { throw new TopiaException("Function<Properties, AbstractTopiaApplicationContext> is needed to create context"); Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/AbstractTopiaDao.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/AbstractTopiaDao.java 2013-11-26 15:51:34 UTC (rev 2894) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/AbstractTopiaDao.java 2013-11-26 17:19:25 UTC (rev 2895) @@ -475,7 +475,7 @@ } protected <R> R findUniqueOrNull(String hql, Map<String, Object> hqlParameters, Class<R> type) throws TopiaNonUniqueResultException { - List<R> results = findAll(hql, hqlParameters, type, 0, 1); + List<R> results = find(hql, hqlParameters, type, 0, 1); // If there is more than 1 result, throw an exception if (results.size() > 1) { throw new TopiaNonUniqueResultException(hql, hqlParameters); @@ -524,7 +524,7 @@ protected <R> R findAnyOrNull(String hql, Map<String, Object> hqlParameters, Class<R> type) { Preconditions.checkNotNull(hql); Preconditions.checkNotNull(hqlParameters); - List<R> results = findAll(hql, hqlParameters, type, 0, 0); + List<R> results = find(hql, hqlParameters, type, 0, 0); R result = Iterables.getOnlyElement(results, null); return result; } @@ -536,15 +536,15 @@ return result; } - protected List<E> findAll(String hql, Map<String, Object> hqlParameters, int startIndex, int endIndex) { + protected List<E> find(String hql, Map<String, Object> hqlParameters, int startIndex, int endIndex) { Preconditions.checkNotNull(hql); Preconditions.checkNotNull(hqlParameters); List<E> result = topiaJpaSupport.find(hql, startIndex, endIndex, hqlParameters); return result; } - protected List<E> findAll(String hql, Map<String, Object> hqlParameters, TopiaPagerBean pager) { - List<E> result = findAll(hql, hqlParameters, getEntityClass(), pager); + protected List<E> find(String hql, Map<String, Object> hqlParameters, TopiaPagerBean pager) { + List<E> result = find(hql, hqlParameters, getEntityClass(), pager); return result; } @@ -556,7 +556,7 @@ return result; } - protected <R> List<R> findAll(String hql, Map<String, Object> hqlParameters, Class<R> type, int startIndex, int endIndex) { + protected <R> List<R> find(String hql, Map<String, Object> hqlParameters, Class<R> type, int startIndex, int endIndex) { Preconditions.checkNotNull(hql); Preconditions.checkNotNull(hqlParameters); Preconditions.checkNotNull(type); @@ -564,7 +564,7 @@ return result; } - protected <R> List<R> findAll(String hql, Map<String, Object> hqlParameters, Class<R> type, TopiaPagerBean pager) { + protected <R> List<R> find(String hql, Map<String, Object> hqlParameters, Class<R> type, TopiaPagerBean pager) { Preconditions.checkNotNull(hql); Preconditions.checkNotNull(hqlParameters); Preconditions.checkNotNull(type); @@ -753,7 +753,7 @@ PagerBeanUtil.computeRecordIndexesAndPagesNumber(pager); // load new window of data - data = dao.findAll(hql, params, type, pager).iterator(); + data = dao.find(hql, params, type, pager).iterator(); } @@ -1027,7 +1027,7 @@ @Override public List<E> find(int startIndex, int endIndex) { - return topiaDAO.findAll(hql, hqlParameters, startIndex, endIndex); + return topiaDAO.find(hql, hqlParameters, startIndex, endIndex); } @Override @@ -1041,7 +1041,7 @@ public List<String> findIds(int startIndex, int endIndex) { // XXX brendan 30/09/13 does this truely work ? String hqlWithSelectClause = "select topiaId " + hql; - return topiaDAO.findAll(hqlWithSelectClause, hqlParameters, String.class, startIndex, endIndex); + return topiaDAO.find(hqlWithSelectClause, hqlParameters, String.class, startIndex, endIndex); } }