Topia-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
- July
- June
- May
May 2011
- 4 participants
- 25 discussions
Author: tchemit
Date: 2011-05-13 16:22:02 +0200 (Fri, 13 May 2011)
New Revision: 2275
Url: http://nuiton.org/repositories/revision/topia/2275
Log:
Evolution #1524: Updates to i18n 2.4 (using utf-8 i18n files)
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-05-12 18:12:59 UTC (rev 2274)
+++ trunk/pom.xml 2011-05-13 14:22:02 UTC (rev 2275)
@@ -259,7 +259,7 @@
<eugeneVersion>2.3.3</eugeneVersion>
<nuitonUtilsVersion>2.2-SNAPSHOT</nuitonUtilsVersion>
<processorPluginVersion>1.2.1</processorPluginVersion>
- <nuitonI18nVersion>2.4-SNAPSHOT</nuitonI18nVersion>
+ <nuitonI18nVersion>2.4</nuitonI18nVersion>
<xmlrpcVersion>3.1.2</xmlrpcVersion>
<hibernateVersion>3.3.2.GA</hibernateVersion>
1
0
r2274 - in trunk/topia-persistence/src/main/java/org/nuiton/topia: generator persistence
by tchemit@users.nuiton.org 12 May '11
by tchemit@users.nuiton.org 12 May '11
12 May '11
Author: tchemit
Date: 2011-05-12 20:12:59 +0200 (Thu, 12 May 2011)
New Revision: 2274
Url: http://nuiton.org/repositories/revision/topia/2274
Log:
clean code + fix some javadoc tags
Evolution #1523: Add a findAllContainsXXX and findContainsXXX method in generated dao for collection properties
Anomalie #1522: generated findUsages in DAO are not correct
Modified:
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractTransformer.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/DepthEntityVisitor.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.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
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractTransformer.java 2011-05-06 09:26:31 UTC (rev 2273)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractTransformer.java 2011-05-12 18:12:59 UTC (rev 2274)
@@ -62,7 +62,6 @@
/*{generator option: parentheses = false}*/
-
/*{generator option: writeString = +}*/
/**
@@ -593,7 +592,8 @@
builder.addImport(result, usageType);
String usageSimpleType =
TopiaGeneratorUtil.getClassNameFromQualifiedName(usageType);
-
+ String usageSimplePropertyMethod = "findAllBy" + usageSimpleType;
+ String usageCollectionPropertyMethod = "findAllContaining" + usageSimpleType;
for (ObjectModelAttribute attr : usageClass.getAttributes()) {
if (!attr.isNavigable()) {
// skip this case
@@ -616,13 +616,20 @@
continue;
}
ObjectModelClass targetEntity = allEntitiesByFQN.get(type);
- //if (!type.equals(clazz.getQualifiedName())) {
+// if (!type.equals(clazz.getQualifiedName())) {
if (!targetEntity.equals(clazz)) {
// not a good attribute reference
continue;
}
// found something to seek
+ String methodNameSuffix = StringUtils.capitalize(attrName);
+ String methodName;
+ if (TopiaGeneratorUtil.isNMultiplicity(attr)) {
+ methodName = "findAllContains" + methodNameSuffix;
+ } else {
+ methodName = "findAllBy" + methodNameSuffix;
+ }
String daoName = StringUtils.capitalize(usageSimpleType) + "DAO";
builder.addImport(result, usageClass.getPackageName() + '.' + daoName);
@@ -632,7 +639,7 @@
if (type == <%=usageSimpleType%>.class) {
<%=daoName%> dao = (<%=daoName%>)
getContext().getDAO(<%=usageSimpleType%>.class);
- tmp = dao.findAllByProperties(<%=usageSimpleType%>.<%=getConstantName(attrName)%>, entity);
+ tmp = dao.<%=methodName%>(entity);
result.addAll(tmp);
}
}*/
@@ -861,8 +868,45 @@
protected void generateNMultiplicity(String clazzName, ObjectModelClass result, ObjectModelAttribute attr) {
String attrName = attr.getName();
String attrType = attr.getType();
+ if (attr.hasAssociationClass()) {
+ // do nothing for association class, too complex...
+ return;
+ }
ObjectModelOperation op;
// Since 2.4 do nothing, findContains and findAllContains are not generated anymore
+ op = addOperation(result,
+ "findContains" + StringUtils.capitalize(attrName),
+ "E",
+ ObjectModelModifier.PUBLIC);
+ addException(op, TopiaException.class);
+ addParameter(op, attrType, "v");
+ setDocumentation(op, "Retourne le premier élément ayant comme valeur pour" +
+ " l'attribut " +
+ TopiaGeneratorUtil.toLowerCaseFirstLetter(attrName) +
+ " le paramètre.");
+ setOperationBody(op, ""
+/*{
+ E result = findContains(<%=clazzName + "." + getConstantName(attrName)%>, v);
+ return result;
+ }*/
+ );
+
+ op = addOperation(result,
+ "findAllContains" + StringUtils.capitalize(attrName),
+ "List<E>",
+ ObjectModelModifier.PUBLIC);
+ addException(op, TopiaException.class);
+ addParameter(op, attrType, "v");
+ setDocumentation(op, "Retourne les éléments ayant comme valeur pour" +
+ " l'attribut " +
+ TopiaGeneratorUtil.toLowerCaseFirstLetter(attrName) +
+ " le paramètre.");
+ setOperationBody(op, ""
+/*{
+ List<E> result = findAllContains(<%=clazzName + "." + getConstantName(attrName)%>, v);
+ return result;
+ }*/
+ );
}
private boolean isCollectionNeeded(
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/DepthEntityVisitor.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/DepthEntityVisitor.java 2011-05-06 09:26:31 UTC (rev 2273)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/DepthEntityVisitor.java 2011-05-12 18:12:59 UTC (rev 2274)
@@ -25,17 +25,17 @@
package org.nuiton.topia.persistence;
-import java.util.ArrayList;
-import java.util.Collection;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaException;
+import java.util.ArrayList;
+import java.util.Collection;
+
/**
* Parcourt du graphe d'entité en profondeur.
*
- * @author chatellier <chatellier(a)codelutin.com>
+ * @author echatellier <chatellier(a)codelutin.com>
* @author tchemit <tchemit(a)codelutin.com>
* @version $Id$
*/
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java 2011-05-06 09:26:31 UTC (rev 2273)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java 2011-05-12 18:12:59 UTC (rev 2274)
@@ -27,10 +27,11 @@
/**
* The contract of a visitor of any {@link TopiaEntity}.
- *
+ * <p/>
* Created: 28 janv. 2009 18:10:34
*
- * @author poussin <poussin(a)codelutin.com>
+ * @author bpoussin <poussin(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @version $Id$
*/
public interface EntityVisitor {
@@ -51,50 +52,53 @@
/**
* Visit a none indexed property for the given entity.
- *
+ * <p/>
* The property visited is defined by the other parameters.
*
- * @param entity the visited entity
+ * @param entity the visited entity
* @param propertyName the name of the visited property
- * @param type the type of the visited property
- * @param value the value of the visited property
+ * @param type the type of the visited property
+ * @param value the value of the visited property
*/
void visit(TopiaEntity entity, String propertyName, Class<?> type,
Object value);
/**
* Visit a collection property for the given entity.
- *
+ * <p/>
* The property visited is defined by the other parameters.
*
- * @param entity the visited entity
- * @param propertyName the name of the visited property
- * @param collectionType the type of the visited collection
- * @param type the type of the visited property
- * @param value the value of the visited property
+ * @param entity the visited entity
+ * @param propertyName the name of the visited property
+ * @param collectionType the type of the visited collection
+ * @param type the type of the visited property
+ * @param value the value of the visited property
*/
void visit(TopiaEntity entity, String propertyName,
Class<?> collectionType, Class<?> type, Object value);
/**
* Visit a indexed value from a collection property for the given entity.
- *
+ * <p/>
* The property visited is defined by the other parameters.
*
- * @param entity the visited entity
- * @param propertyName the name of the visited property
+ * @param entity the visited entity
+ * @param propertyName the name of the visited property
* @param collectionType the type of the container of the visited property
- * @param type the type of the visited property
- * @param index the index of the visited property in his container
- * @param value the value of the visited property
+ * @param type the type of the visited property
+ * @param index the index of the visited property in his container
+ * @param value the value of the visited property
*/
void visit(TopiaEntity entity, String propertyName,
Class<?> collectionType, Class<?> type, int index, Object value);
/**
* Reset all states of the visitor.
- *
- * TODO-chatellier-20091221 : need explanations : called by who ? what is it for ?
+ * <p/>
+ * If you use internal states inside the visitor, this method should clean
+ * all of them.
+ * <p/>
+ * This method should be invoked after usage of the visitor.
*/
void clear();
}
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java 2011-05-06 09:26:31 UTC (rev 2273)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java 2011-05-12 18:12:59 UTC (rev 2274)
@@ -25,18 +25,18 @@
package org.nuiton.topia.persistence;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaException;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.topia.TopiaException;
-
/**
* Parcourt en largeur du modele et délegation à un autre visiteur.
*
- * @author chatellier <chatellier(a)codelutin.com>
+ * @author echatellier <chatellier(a)codelutin.com>
* @author tchemit <tchemit(a)codelutin.com>
* @version $Id$
*/
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 2011-05-06 09:26:31 UTC (rev 2273)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAO.java 2011-05-12 18:12:59 UTC (rev 2274)
@@ -60,12 +60,12 @@
* DAOAbstractTransformer} for abstract implementation and {@link
* DAOImplTransformer} for final implementation class.
* <p/>
- * TODO-fdesbois-20100508 : Need translation of javadoc.
*
- * @author poussin <poussin(a)codelutin.com>
+ * @param <E> the entity type linked with the dao
+ * @author bpoussin <poussin(a)codelutin.com>
* @author fdesbois <fdesbois(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
* @version $Id$
- * @param <E> the entity type linked with the dao
*/
public interface TopiaDAO<E extends TopiaEntity> {
@@ -241,7 +241,7 @@
* Find an entity corresponding to the {@code id}. If the {@code id} is
* null, nothing will be search.
*
- * @param id topiaId of the entity to found
+ * @param id topiaId of the entity to found
* @return the entity found or null if not
* @throws TopiaException for Topia errors on query
*/
@@ -349,6 +349,34 @@
throws TopiaException;
/**
+ * Récupère toutes les entités (du type géré par ce dao) dont la
+ * collection nommée {@code propertyName} contient la {@code property}
+ * donnée.
+ *
+ * @param propertyName le nom de la propriété
+ * @param property la propriété recherchée
+ * @return toutes les entités recherchées
+ * @throws TopiaException pour tout erreur lors de la recherche
+ * @since 2.5.4
+ */
+ List<E> findAllContains(String propertyName,
+ Object property) throws TopiaException;
+
+ /**
+ * Récupère la première entité (du type géré par ce dao) dont la
+ * collection nommée {@code propertyName} contient la {@code property}
+ * donnée.
+ *
+ * @param propertyName le nom de la propriété
+ * @param property la propriété recherchée
+ * @return la première entité recherchée
+ * @throws TopiaException pour tout erreur lors de la recherche
+ * @since 2.5.4
+ */
+ E findContains(String propertyName,
+ Object property) throws TopiaException;
+
+ /**
* Check the existence of an entity with technical {@code id}.
*
* @param id unique id of the entity to test existence.
@@ -395,7 +423,7 @@
/**
* Count the number of entities based on {@code query}.
- *
+ *
* @param query query
* @return number of entities filtered by the query
* @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 2011-05-06 09:26:31 UTC (rev 2273)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2011-05-12 18:12:59 UTC (rev 2274)
@@ -57,8 +57,6 @@
import java.util.Map;
/**
- * TODO-fdesbois-20100508 : Need translation of javadoc.
- * <p/>
* Cette classe permet d'avoir un ensemble de méthode implantée de façon
* standard et plus spécifiquement pour Hibernate.
* <p/>
@@ -67,9 +65,9 @@
* possible d'accèder au meta information hibernate sur les classes lorque l'on
* en a besoin.
*
- * @author poussin <poussin(a)codelutin.com>
+ * @param <E> le type de l'entite
+ * @author bpoussin <poussin(a)codelutin.com>
* @version $Id$
- * @param <E> le type de l'entite
*/
public class TopiaDAOImpl<E extends TopiaEntity> implements
@@ -102,11 +100,11 @@
try {
Serializable result;
result = (Serializable) PropertyUtils.getSimpleProperty(e,
- idPropName);
+ idPropName);
return result;
} catch (Exception eee) {
throw new TopiaException("Impossible de récuperer l'identifiant "
- + idPropName + " de l'entite: " + e);
+ + idPropName + " de l'entite: " + e);
}
}
@@ -162,12 +160,12 @@
.newInstance();
if (log.isDebugEnabled()) {
log.debug("Utilisation de la classe " + classname + "Impl"
- + " pour " + classname);
+ + " pour " + classname);
}
} catch (ClassNotFoundException eee) {
if (log.isWarnEnabled()) {
log.warn("Impossible de trouver la classe " + classname
- + "Impl");
+ + "Impl");
}
if (log.isDebugEnabled()) {
log.debug("StackTrace", eee);
@@ -187,7 +185,7 @@
result = entityClass.getConstructor().newInstance();
if (log.isDebugEnabled()) {
log.debug("Utilisation de la classe " + classname
- + " pour " + classname);
+ + " pour " + classname);
}
} catch (Exception eee) {
if (log.isWarnEnabled()) {
@@ -202,7 +200,7 @@
if (result == null) {
throw new TopiaException(
"Impossible de trouver ou d'instancier la classe "
- + classname);
+ + classname);
}
return result;
@@ -308,13 +306,13 @@
}
} catch (ArrayIndexOutOfBoundsException eee) {
throw new IllegalArgumentException("Wrong number of argument "
- + properties.length
- + ", you must have even number. Last property name read: "
- + propertyName);
+ + properties.length
+ + ", you must have even number. Last property name read: "
+ + propertyName);
} catch (ClassCastException eee) {
throw new IllegalArgumentException(
"Wrong argument type, wait property name as String and " +
- "have " + propertyName.getClass().getName());
+ "have " + propertyName.getClass().getName());
}
E result = create(map);
@@ -510,6 +508,24 @@
}
@Override
+ public E findContains(String propertyName,
+ Object property) throws TopiaException {
+ TopiaQuery k = createQuery().
+ addInElements(":K", propertyName).
+ addParam("K", property);
+ return findByQuery(k);
+ }
+
+ @Override
+ public List<E> findAllContains(String propertyName,
+ Object property) throws TopiaException {
+ TopiaQuery k = createQuery().
+ addInElements(":K", propertyName).
+ addParam("K", property);
+ return findAllByQuery(k);
+ }
+
+ @Override
public boolean existByTopiaId(String id) throws TopiaException {
boolean result = existByProperties(TopiaEntity.TOPIA_ID, id);
return result;
@@ -571,13 +587,13 @@
} catch (ClassCastException eee) {
throw new IllegalArgumentException(
"Les noms des propriétés doivent être des chaines et " +
- "non pas " + propertyName.getClass().getName(),
+ "non pas " + propertyName.getClass().getName(),
eee);
} catch (ArrayIndexOutOfBoundsException eee) {
throw new IllegalArgumentException(
"Le nombre d'argument n'est pas un nombre pair: "
- + (others.length + 2)
- + " La dernière propriété était: " + name, eee);
+ + (others.length + 2)
+ + " La dernière propriété était: " + name, eee);
}
}
return properties;
@@ -598,7 +614,7 @@
throw new TopiaException(eee);
}
throw new TopiaException("La classe " + entityClass.getName()
- + " n'a pas de cle primaire naturelle");
+ + " n'a pas de cle primaire naturelle");
}
@@ -625,7 +641,7 @@
throw new TopiaException(eee);
}
throw new TopiaException("La classe " + entityClass.getName()
- + " n'a pas de cle primaire naturelle");
+ + " n'a pas de cle primaire naturelle");
}
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java 2011-05-06 09:26:31 UTC (rev 2273)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOLegacy.java 2011-05-12 18:12:59 UTC (rev 2274)
@@ -41,18 +41,6 @@
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* ##%*/
-/* *
- * TopiaDAOAbstract.java
- *
- * Created: 31 déc. 2005 13:10:34
- *
- * @author poussin
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-
package org.nuiton.topia.persistence;
import org.apache.commons.beanutils.PropertyUtils;
@@ -86,19 +74,22 @@
* choix de se baser entièrement sur hibernate pour la persistence, et il
* est ainsi possible d'accèder au meta information hibernate sur les classes
* lorque l'on en a besoin.
- *
- * @param <E> le type de l'entite
- * @author poussin
*
+ * Created: 31 déc. 2005 13:10:34
+ *
+ * @param <E> le type de l'entite
+ * @author bpoussin <poussin(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
*/
public class TopiaDAOLegacy<E extends TopiaEntity> extends TopiaDAOImpl<E> { // TopiaDAOImpl
- /** to use log facility, just put in your code: log.info(\"...\"); */
+
+ /** Logger. */
private static Log log = LogFactory.getLog(TopiaDAOImpl.class);
- protected Class<E> entityClass = null;
+ protected Class<E> entityClass;
- protected TopiaContextImplementor context = null;
+ protected TopiaContextImplementor context;
@Override
public Class<E> getEntityClass() {
@@ -120,15 +111,9 @@
try {
result = (Serializable) PropertyUtils.getSimpleProperty(e,
idPropName);
- } catch (IllegalAccessException eee) {
+ } catch (Exception eee) {
throw new TopiaException("Impossible de récuperer l'identifiant "
+ idPropName + " de l'entite: " + e);
- } catch (InvocationTargetException eee) {
- throw new TopiaException("Impossible de récuperer l'identifiant "
- + idPropName + " de l'entite: " + e);
- } catch (NoSuchMethodException eee) {
- throw new TopiaException("Impossible de récuperer l'identifiant "
- + idPropName + " de l'entite: " + e);
}
return result;
}
1
0
06 May '11
Author: echatellier
Date: 2011-05-06 11:26:31 +0200 (Fri, 06 May 2011)
New Revision: 2273
Url: http://nuiton.org/repositories/revision/topia/2273
Log:
Update topia migration doc
Modified:
trunk/topia-persistence/src/site/rst/devel/SchemaMigration.rst
Modified: trunk/topia-persistence/src/site/rst/devel/SchemaMigration.rst
===================================================================
--- trunk/topia-persistence/src/site/rst/devel/SchemaMigration.rst 2011-05-04 14:39:50 UTC (rev 2272)
+++ trunk/topia-persistence/src/site/rst/devel/SchemaMigration.rst 2011-05-06 09:26:31 UTC (rev 2273)
@@ -5,7 +5,7 @@
.. * $Id$
.. * $HeadURL$
.. * %%
-.. * Copyright (C) 2004 - 2010 CodeLutin
+.. * Copyright (C) 2004 - 2011 CodeLutin, Chatellier Eric
.. * %%
.. * This program is free software: you can redistribute it and/or modify
.. * it under the terms of the GNU Lesser General Public License as
@@ -22,113 +22,152 @@
.. * <http://www.gnu.org/licenses/lgpl-3.0.html>.
.. * #L%
.. -
-=====================================
-Comment migrer d'un schéma à un autre
-=====================================
+Comment migrer les version d'un schema de base de données
+=========================================================
+Lorsque des modifications sont effectuer dans une application qui impacte
+le schema de base de données, celui doit subir des migrations.
+ToPIA fournit une API visant a assister le developpeur pour migrer un schema
+de base de données.
-Une application modifie et ajoute des objets. La persistence doit donc être
-adaptée à ces changements. Le problème est la migration des données
-existantes dans le nouveau schéma.
+Approche
+--------
-Voici quelques idées d'implantations.
+TODO approche migration par copy
+TOOD approche migration par requette sql
-Hibernate et dynamic-map
-========================
+Configuration
+-------------
-Hibernate permet de mapper les objets de la base de données dans des
-dynamic-map. Nous n'avons donc pas besoin de pojo pour les représenter, il
-nous suffit d'avoir le mapping hibernate.
+Pour commencer, topia doit connaitre l'ensemble des versions de la base
+de données, et la version actuelle de l'application. Si la version de l'application
+diffère de celle de la base de données, une migration sera effectuée.
+Après la migration, la version de la base de données est égale à celle de
+l'application.
-L'idée est donc, lors de la modification de schéma, de regrouper tous les
-anciens mapping dans un seul fichier de mapping qui contiendra le numero de
-version du schema.
+Dépendances
+~~~~~~~~~~~
-On utilisera ces mappings pour charger l'ancienne configuration et ainsi les
-réenregistrer dans le nouveau schéma.
+La migration est effectuée par le service de migration de ToPIA. Il est
+necessaire de l'ajouter explicitement.
-Une classe java de migration devra être écrite pour transformer les données
-d'un schéma vers un autre schéma.
+::
-Avantage
---------
+ <dependency>
+ <groupId>org.nuiton.topia</groupId>
+ <artifactId>topia-service-migration</artifactId>
+ <version>2.5.3</version>
+ <scope>compile</scope>
+ </dependency>
-Le changement de schéma est fait en java
+Class de definition des migration
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Désavantage
------------
+Pour commencer, il faut créer la classe definissant les versions.
-Il faut dans la base une table qui indique dans quelle version de schéma
-actuelle est la base (Topia->schemaVersion).
-Une autre solution est de faire une base
-par version, le numero de version étant dans le nom de la base (inconveniant :
-le nom de la base change a chaque version).
-Une autre solution possible est de faire un
-changement de schéma dans une transaction, donc on peut lire les anciennes
-données dans une transaction et on écrit les nouvelles dans une autre
-transaction sur la même table mais qui aurait des schéma différents.
+::
-Il faut, dans les noms des tables, le numéro de version du schéma pour que les
-les anciennes tables ne servent pas comme nom pour les nouvelles.
+ public class DatabaseMigrationClass extends TopiaMigrationCallbackByClass {
+
+ protected static final Version VERSION_1 = new Version("1");
+ protected static final Version VERSION_2 = new Version("2");
+ protected static final Version VERSION_3 = new Version("3");
+
+ public DatabaseMigrationClass() {
+ super(new MigrationResolver());
+ }
-Il faut soit faire l'aggrégation des mapping dans un seul fichier, soit
-n'utiliser qu'un seul fichier pour les mappings, soit avoir un fichier par
-classe et par version, mais il est moins simple de retrouver tous les
-fichiers de mapping et surtout moins simple
+ protected static class MigrationResolver implements MigrationCallBackForVersionResolver {
+
+ @Override
+ public Class<? extends MigrationCallBackForVersion> getCallBack(Version version) {
+ Class<? extends MigrationCallBackForVersion> result = null;
+
+ if (version.equals(VERSION_1)) {
+ result = MigrationV0V1.class;
+ }
+ else if (version.equals(VERSION_2)) {
+ result = MigrationV1V2.class;
+ }
+ else if (version.equals(VERSION_3)) {
+ result = MigrationV2V3.class;
+ }
+ return result;
+ }
+
+ }
+
+ @Override
+ public Version[] getAvailableVersions() {
+ Version[] result = new Version[] { VERSION_1, VERSION_2, VERSION_3 };
+ return result;
+ }
+
+ @Override
+ public Version getApplicationVersion() {
+ Version appVersion = new Version(MyAppDAOHelper.getModelVersion());
+ return appVersion;
+ }
+
+ @Override
+ public boolean askUser(Version dbVersion, List<Version> versions) {
+ return true;
+ }
+
+ }
-En fait il n'y a pas vraiment de desavantage. La solution parrait simple et
-efficace.
-
-Exemple de classe de conversion
+Classes de migration de version
-------------------------------
+Ensuite, il faut créer une classe par migration.
+
+Par exemple, voici la classe migrant le shema de la version 0 à la version 1 :
+MigrationV0V1.
+
::
- class Convert {
- convert() {
- // recherche de la version actuelle de la base topia->schemaVersion
- // recherche de la version utilisé par l'application config->schemaVersion
- // si les versions divergent, appel de toutes les méthodes convert
- // pour arriver à la version de schema actuelle dans config
+ public class MigrationV0V1 extends MigrationCallBackForVersion {
+
+ public MigrationV0V1(Version version, TopiaMigrationCallbackByClass callBack) {
+ super(version, callBack);
}
- convert_2_0_1_to_2_0_2(){
- // chargement schema 2_0_1 en utilisant les dynamic-map
- // chargement schema 2_0_2 en utilisant les dynamic-map
- ...
- // code de migration d'un schema a un autre
- // si pas de modification pour une classe, il faut au moins faire une
- // copie pour remplir les nouvelles tables
- ...
- // modification de version dans topia->schemaVersion
- // commit nouvelle données
- // on peut supprimer les anciennes tables
+ @Override
+ protected void prepareMigrationScript(TopiaContextImplementor tx,
+ List<String> queries, boolean showSql, boolean showProgression)
+ throws TopiaException {
+ queries.add("alter table SETOFVESSELS add column TECHNICALEFFICIENCYEQUATION VARCHAR(255);");
+ queries.add("alter table STRATEGY add column INACTIVITYEQUATIONUSED BIT default false;");
+ queries.add("alter table STRATEGY add column INACTIVITYEQUATION VARCHAR(255);");
+ queries.add("alter table STRATEGYMONTHINFO alter NUMBEROFTRIPS double;");
+ queries.add("alter table STRATEGYMONTHINFO alter MININACTIVITYDAYS double;");
}
-
- convert_2_0_2_to_2_1_0(){
- // idem
- }
}
-Hibernate et XML
-================
+Configuration du topia context
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Il est aussi possible de lire une base en XML. On utiliserait donc la même
-technique que pour les dynamic-map, mais on utiliserait du XSL pour
-convertir le XML vers le schéma souhaité. De cette facon il n'y a pas besoin
-de table intermédiaire ni de numéro de version de schéma dans les tables.
+Pour finir, il faut ajouter l'utilisation de la migration par ces classe
+dans le topia context. En effet, la migration est effectuée automatiquement
+lors de l'ouverture d'un TopiaContext.
-- Export XML en utilisant le vieux mapping
-- converion en enchainant les transformations XSL
-- Import du nouveau fichier XML
+Configuration:
-Inconvéniant
-------------
+::
-si le volume est important il peut-etre long de tout transformer en XML.
-
+ config.put(TopiaMigrationService.TOPIA_SERVICE_NAME, TopiaMigrationEngine.class.getName());
+ config.put(TopiaMigrationService.MIGRATION_CALLBACK, DatabaseMigrationClass.getName());
+
+ou dans un fichier de properties :
+
+::
+
+ topia.service.migration=org.nuiton.topia.migration.TopiaMigrationEngine
+ topia.service.migration.callback=org.test.myapp.DatabaseMigrationClass
+
+
Kettle
-======
+------
Une autre idee est de ne pas utiliser hibernate mais kettle pour la
migration des données. Nous aurions de la même façon dans le nom des tables
1
0
r2272 - in trunk: . topia-persistence/src/main/resources/i18n topia-service-migration/src/main/resources/i18n topia-service-replication/src/main/resources/i18n
by fdesbois@users.nuiton.org 04 May '11
by fdesbois@users.nuiton.org 04 May '11
04 May '11
Author: fdesbois
Date: 2011-05-04 16:39:50 +0200 (Wed, 04 May 2011)
New Revision: 2272
Url: http://nuiton.org/repositories/revision/topia/2272
Log:
Use I18n 2.4 snapshot, resources file becomes UTF-8
Modified:
trunk/pom.xml
trunk/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties
trunk/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties
trunk/topia-service-migration/src/main/resources/i18n/topia-service-migration_es_ES.properties
trunk/topia-service-migration/src/main/resources/i18n/topia-service-migration_fr_FR.properties
trunk/topia-service-replication/src/main/resources/i18n/topia-service-replication_es_ES.properties
trunk/topia-service-replication/src/main/resources/i18n/topia-service-replication_fr_FR.properties
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-05-04 10:57:35 UTC (rev 2271)
+++ trunk/pom.xml 2011-05-04 14:39:50 UTC (rev 2272)
@@ -259,7 +259,7 @@
<eugeneVersion>2.3.3</eugeneVersion>
<nuitonUtilsVersion>2.2-SNAPSHOT</nuitonUtilsVersion>
<processorPluginVersion>1.2.1</processorPluginVersion>
- <nuitonI18nVersion>2.3.2</nuitonI18nVersion>
+ <nuitonI18nVersion>2.4-SNAPSHOT</nuitonI18nVersion>
<xmlrpcVersion>3.1.2</xmlrpcVersion>
<hibernateVersion>3.3.2.GA</hibernateVersion>
Modified: trunk/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties
===================================================================
--- trunk/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties 2011-05-04 10:57:35 UTC (rev 2271)
+++ trunk/topia-persistence/src/main/resources/i18n/topia-persistence_es_ES.properties 2011-05-04 14:39:50 UTC (rev 2272)
@@ -1,28 +1,28 @@
topia.persistence.error.class.not.found=No ha sido encontrada la clase persistente %1$s
topia.persistence.error.context.already.closed=El contexto ya ha sido cerrado
-topia.persistence.error.context.is.closed=Este contexto ya ha sido cerrado, no se puede comenzar una transacci\u00F3n
-topia.persistence.error.create.schema=No se puede crear el esquema debido a la raz\u00F3n siguiente \: %2$s
-topia.persistence.error.empty.doc=Documento vac\u00EDo
-topia.persistence.error.no.hibernate.session=No se encuentra ninguna sesi\u00F3n hibernada, debe iniciar una transacci\u00F3n con el m\u00E9todo 'BeginTransaction'
-topia.persistence.error.null.param=El m\u00E9todo '%1$s' requiere un par\u00E1metro '%2$s' no nulo.
+topia.persistence.error.context.is.closed=Este contexto ya ha sido cerrado, no se puede comenzar una transacción
+topia.persistence.error.create.schema=No se puede crear el esquema debido a la razón siguiente \: %2$s
+topia.persistence.error.empty.doc=Documento vacío
+topia.persistence.error.no.hibernate.session=No se encuentra ninguna sesión hibernada, debe iniciar una transacción con el método 'BeginTransaction'
+topia.persistence.error.null.param=El método '%1$s' requiere un parámetro '%2$s' no nulo.
topia.persistence.error.on.commit=Se produjo un error durante el guardado \: %1$s
-topia.persistence.error.on.export=Se produjo un error durante la exportaci\u00F3n \: %1$s
+topia.persistence.error.on.export=Se produjo un error durante la exportación \: %1$s
topia.persistence.error.on.loding.xml.doc=No se puede leer el documento debido a \: %1$s
topia.persistence.error.on.query=Se produjo un error duratne la busqueda (consulta %1$s) \: %2$s
-topia.persistence.error.on.rollback=Se produjo un error durante la vuelta a atr\u00E1s (rollback) \: %1$s
+topia.persistence.error.on.rollback=Se produjo un error durante la vuelta a atrás (rollback) \: %1$s
topia.persistence.error.open.transaction.failed=
-topia.persistence.error.replicate.entity=Error de repliaci\u00F3n de la entidad %1$s\ndebido a la siguiente raz\u00F3n \: %2$s
+topia.persistence.error.replicate.entity=Error de repliación de la entidad %1$s\ndebido a la siguiente razón \: %2$s
topia.persistence.error.replicate.on.same.context=No se puede duplicar en la misma base
-topia.persistence.error.rootContext.access=Est\u00E1 usted en la ra\u00EDz, debe abrir una transacci\u00F3n para acceder a los datos.
-topia.persistence.error.service.not.found=El servicio %1$s no est\u00E1 disponible
+topia.persistence.error.rootContext.access=Está usted en la raíz, debe abrir una transacción para acceder a los datos.
+topia.persistence.error.service.not.found=El servicio %1$s no está disponible
topia.persistence.error.service.not.retreaved=El servicio %1$s debido a \: %2$s
topia.persistence.error.service.unknown=El servicio '%1$s' de clase '%2$s' es desconocido
-topia.persistence.error.unsupported.class=La clase %1$n no est\u00E1 soportada por TopiaContext, puede que se halla olvidado de a\u00F1adir su mapa
-topia.persistence.error.unsupported.operation.on.closed.context=El contexto est\u00E1 cerrado, no se puede realizar la operaci\u00F3n %1$s
+topia.persistence.error.unsupported.class=La clase %1$n no está soportada por TopiaContext, puede que se halla olvidado de añadir su mapa
+topia.persistence.error.unsupported.operation.on.closed.context=El contexto está cerrado, no se puede realizar la operación %1$s
topia.persistence.error.update.schema=El esquema no se puede actualizar debido a \: %2$s
topia.persistence.service.loaded=Servicio '%1$s' cargado por '%2$s'
-topia.persistence.supported.classes.for.context=Classes support\u00E9es par ce TopiaContext \: %1$s
+topia.persistence.supported.classes.for.context=Classes supportées par ce TopiaContext \: %1$s
topia.persistence.warn.service.not.found=El nombre del servicio '%1$s' no ha sido encontrado debido a \: %2$s
-topia.persistence.warn.service.not.loaded=Le service de cl\u00E9 '%1$s' tiene un nombre de servicio '%2$s' diferente \! (servicio desactivado)
+topia.persistence.warn.service.not.loaded=Le service de clé '%1$s' tiene un nombre de servicio '%2$s' diferente \! (servicio desactivado)
topia.persistence.warn.service.not.postInit=El servicio '%1$s' no puede ser inicializado (servicio desactivado)
topia.persistence.warn.service.not.preInit=El servicio '%1$s' no puede ser inicializado (servicio desactivado)
Modified: trunk/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties
===================================================================
--- trunk/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties 2011-05-04 10:57:35 UTC (rev 2271)
+++ trunk/topia-persistence/src/main/resources/i18n/topia-persistence_fr_FR.properties 2011-05-04 14:39:50 UTC (rev 2272)
@@ -1,28 +1,28 @@
-topia.persistence.error.class.not.found=La classe persistante %1$s n'a pas \u00E9t\u00E9 trouv\u00E9e
+topia.persistence.error.class.not.found=La classe persistante %1$s n'a pas été trouvée
topia.persistence.error.context.already.closed=Ce contexte a deja ete ferme
topia.persistence.error.context.is.closed=Ce contexte a ete ferme, impossible de commencer une transaction
-topia.persistence.error.create.schema=Le sch\u00E9ma n'a pas pu \u00EAtre cr\u00E9e pour la raison suivante \: %2$s
+topia.persistence.error.create.schema=Le schéma n'a pas pu être crée pour la raison suivante \: %2$s
topia.persistence.error.empty.doc=Document vide
-topia.persistence.error.no.hibernate.session=Aucune session hibernate trouv\u00E9e, vous devez d\u00E9marr\u00E9 une transaction avec la m\u00E9thode 'beginTransaction'
-topia.persistence.error.null.param=La m\u00E9thode '%1$s' requi\u00E8re un param\u00E8tre '%2$s' non null.
+topia.persistence.error.no.hibernate.session=Aucune session hibernate trouvée, vous devez démarré une transaction avec la méthode 'beginTransaction'
+topia.persistence.error.null.param=La méthode '%1$s' requière un paramètre '%2$s' non null.
topia.persistence.error.on.commit=Une erreur est apparue pendant le commit \: %1$s
topia.persistence.error.on.export=Une erreur est apparue pendant l'export \: %1$s
topia.persistence.error.on.loding.xml.doc=Lecture du document impossible pour la raison suivante \: %1$s
-topia.persistence.error.on.query=Une erreur est apparue pendant le recherche (requ\u00EAte %1$s) \: %2$s
+topia.persistence.error.on.query=Une erreur est apparue pendant le recherche (requête %1$s) \: %2$s
topia.persistence.error.on.rollback=Une erreur est apparue pendant le rollback \: %1$s
topia.persistence.error.open.transaction.failed=Une erreur est apparue pendant la demande de transaction \: %1$s
topia.persistence.error.replicate.entity=Echec de replication de l'entite %1$s\npour la raison suivante \: %2$s
-topia.persistence.error.replicate.on.same.context=Impossible de dupliquer dans la m\u00EAme base
-topia.persistence.error.rootContext.access=Vous \u00EAtes sur le root context, vous devez ouvrir une transaction pour pouvoir acc\u00E9der aux donn\u00E9es.
+topia.persistence.error.replicate.on.same.context=Impossible de dupliquer dans la même base
+topia.persistence.error.rootContext.access=Vous êtes sur le root context, vous devez ouvrir une transaction pour pouvoir accéder aux données.
topia.persistence.error.service.not.found=Le service %1$s n'est pas disponible
-topia.persistence.error.service.not.retreaved=La service %1$s n'a pas pu \u00EAtre r\u00E9cup\u00E9r\u00E9 pour la raison suivante \: %2$s
+topia.persistence.error.service.not.retreaved=La service %1$s n'a pas pu être récupéré pour la raison suivante \: %2$s
topia.persistence.error.service.unknown=Le service '%1$s' ayant pour classe '%2$s' n'est pas connu
-topia.persistence.error.unsupported.class=La classe %1$s n'est pas support\u00E9e par ce TopiaContext, vous avez sans doute oubli\u00E9 d'ajouter son mapping
-topia.persistence.error.unsupported.operation.on.closed.context=Ce contexte a \u00E9t\u00E9 ferm\u00E9, impossible de r\u00E9aliser l'op\u00E9ration %1$s
-topia.persistence.error.update.schema=Le sch\u00E9ma n'a pas pu \u00EAtre mis \u00E0 jour pour la raison suivante \: %2$s
-topia.persistence.service.loaded=Service '%1$s' charg\u00E9 par '%2$s'
-topia.persistence.supported.classes.for.context=Classes support\u00E9es par ce TopiaContext \: %1$s
-topia.persistence.warn.service.not.found=Le nom du service '%1$s' n'a pas \u00E9t\u00E9 trouv\u00E9 pour la raison suivante \: %2$s
-topia.persistence.warn.service.not.loaded=Le service de cl\u00E9 '%1$s' a un nom de service '%2$s' diff\u00E9rent \! (service d\u00E9sactiv\u00E9)
-topia.persistence.warn.service.not.postInit=Le service '%1$s' n'a pas pu \u00EAtre initialis\u00E9 (service d\u00E9sactiv\u00E9)
-topia.persistence.warn.service.not.preInit=Le service '%1$s' n'a pas pu \u00EAtre finalis\u00E9 (service d\u00E9sactiv\u00E9)
+topia.persistence.error.unsupported.class=La classe %1$s n'est pas supportée par ce TopiaContext, vous avez sans doute oublié d'ajouter son mapping
+topia.persistence.error.unsupported.operation.on.closed.context=Ce contexte a été fermé, impossible de réaliser l'opération %1$s
+topia.persistence.error.update.schema=Le schéma n'a pas pu être mis à jour pour la raison suivante \: %2$s
+topia.persistence.service.loaded=Service '%1$s' chargé par '%2$s'
+topia.persistence.supported.classes.for.context=Classes supportées par ce TopiaContext \: %1$s
+topia.persistence.warn.service.not.found=Le nom du service '%1$s' n'a pas été trouvé pour la raison suivante \: %2$s
+topia.persistence.warn.service.not.loaded=Le service de clé '%1$s' a un nom de service '%2$s' différent \! (service désactivé)
+topia.persistence.warn.service.not.postInit=Le service '%1$s' n'a pas pu être initialisé (service désactivé)
+topia.persistence.warn.service.not.preInit=Le service '%1$s' n'a pas pu être finalisé (service désactivé)
Modified: trunk/topia-service-migration/src/main/resources/i18n/topia-service-migration_es_ES.properties
===================================================================
--- trunk/topia-service-migration/src/main/resources/i18n/topia-service-migration_es_ES.properties 2011-05-04 10:57:35 UTC (rev 2271)
+++ trunk/topia-service-migration/src/main/resources/i18n/topia-service-migration_es_ES.properties 2011-05-04 14:39:50 UTC (rev 2272)
@@ -1,14 +1,14 @@
topia.migration.available.versions=Versiones detectadas \: %1$s
-topia.migration.db.not.versionned=La base de datos no tiene versi\u00F3n, se considera como la versi\u00F3n 0.
-topia.migration.detected.db.version=Versi\u00F3n de la base \: %1$s
+topia.migration.db.not.versionned=La base de datos no tiene versión, se considera como la versión 0.
+topia.migration.detected.db.version=Versión de la base \: %1$s
topia.migration.end.sql=Consulta [%1$-4s/%2$-4s] ejecutada en %3$s.
-topia.migration.migrate.versions=Actualizaci\u00F3n para instalar \: %1$s
-topia.migration.migration.incomplete=\\u00a1La migraci\u00F3n de la base de datos ha fallado o se ha cancelado\!
-topia.migration.saving.db.version=Copia de seguridad de la nueva versi\u00F3n de la base \: %1$s
-topia.migration.skip.migration.db.is.empty=Base de datos vac\u00EDa, no es necesaria la migraci\u00F3n.
-topia.migration.skip.migration.db.is.up.to.date=La base est\u00E1 actualizada, no es necesaria ninguna migraci\u00F3n.
-topia.migration.skip.migration.no.version.to.apply=No hay versi\u00F3n a aplicar, no es necesaria ninguna migraci\u00F3n.
-topia.migration.start.migrate=Inicio de la actualizaci\u00F3n hacia la versi\u00F3n %1$s
-topia.migration.start.migration=Inicio del servicio de actualizaci\u00F3n - versi\u00F3n de la aplicaci\u00F3n \: %1$s, versi\u00F3n de la base \: %2$s
-topia.migration.start.sql=Ejecuci\u00F3n de la consulta [%1$-4s/%2$-4s]
+topia.migration.migrate.versions=Actualización para instalar \: %1$s
+topia.migration.migration.incomplete=\\u00a1La migración de la base de datos ha fallado o se ha cancelado\!
+topia.migration.saving.db.version=Copia de seguridad de la nueva versión de la base \: %1$s
+topia.migration.skip.migration.db.is.empty=Base de datos vacía, no es necesaria la migración.
+topia.migration.skip.migration.db.is.up.to.date=La base está actualizada, no es necesaria ninguna migración.
+topia.migration.skip.migration.no.version.to.apply=No hay versión a aplicar, no es necesaria ninguna migración.
+topia.migration.start.migrate=Inicio de la actualización hacia la versión %1$s
+topia.migration.start.migration=Inicio del servicio de actualización - versión de la aplicación \: %1$s, versión de la base \: %2$s
+topia.migration.start.sql=Ejecución de la consulta [%1$-4s/%2$-4s]
topia.migration.start.sqls=Se va a ejecutar %1$s consulta(s)...
Modified: trunk/topia-service-migration/src/main/resources/i18n/topia-service-migration_fr_FR.properties
===================================================================
--- trunk/topia-service-migration/src/main/resources/i18n/topia-service-migration_fr_FR.properties 2011-05-04 10:57:35 UTC (rev 2271)
+++ trunk/topia-service-migration/src/main/resources/i18n/topia-service-migration_fr_FR.properties 2011-05-04 14:39:50 UTC (rev 2272)
@@ -1,14 +1,14 @@
-topia.migration.available.versions=Versions d\u00E9tect\u00E9es \: %1$s
-topia.migration.db.not.versionned=La base de donn\u00E9es n'est pas versionn\u00E9e, elle sera consid\u00E9r\u00E9e en version 0.
-topia.migration.detected.db.version=Version de base d\u00E9tect\u00E9e \: %1$s
-topia.migration.end.sql=Requ\u00EAte [%1$-4s/%2$-4s] ex\u00E9cut\u00E9e en %3$s.
-topia.migration.migrate.versions=Mises \u00E0 jour \u00E0 installer \: %1$s
-topia.migration.migration.incomplete=La migration de la base s'est mal d\u00E9roul\u00E9e ou a \u00E9t\u00E9 annul\u00E9e\!
+topia.migration.available.versions=Versions détectées \: %1$s
+topia.migration.db.not.versionned=La base de données n'est pas versionnée, elle sera considérée en version 0.
+topia.migration.detected.db.version=Version de base détectée \: %1$s
+topia.migration.end.sql=Requête [%1$-4s/%2$-4s] exécutée en %3$s.
+topia.migration.migrate.versions=Mises à jour à installer \: %1$s
+topia.migration.migration.incomplete=La migration de la base s'est mal déroulée ou a été annulée\!
topia.migration.saving.db.version=Sauvegarde de la nouvelle version de la base \: %1$s
-topia.migration.skip.migration.db.is.empty=La base de donn\u00E9es est vierge, aucune migration n\u00E9cessaire.
-topia.migration.skip.migration.db.is.up.to.date=La base est \u00E0 jour, aucune migration n\u00E9cessaire.
-topia.migration.skip.migration.no.version.to.apply=Aucune version \u00E0 appliquer, aucune migration n\u00E9cessaire.
-topia.migration.start.migrate=D\u00E9marrage de la mise \u00E0 jour vers la version %1$s
-topia.migration.start.migration=D\u00E9marrage du service de mise \u00E0 jour - version de l'application \: %1$s, version de la base \: %2$s
-topia.migration.start.sql=Execution de la requ\u00EAte [%1$-4s/%2$-4s]
-topia.migration.start.sqls=Va executer %1$s requ\u00EAte(s)...
+topia.migration.skip.migration.db.is.empty=La base de données est vierge, aucune migration nécessaire.
+topia.migration.skip.migration.db.is.up.to.date=La base est à jour, aucune migration nécessaire.
+topia.migration.skip.migration.no.version.to.apply=Aucune version à appliquer, aucune migration nécessaire.
+topia.migration.start.migrate=Démarrage de la mise à jour vers la version %1$s
+topia.migration.start.migration=Démarrage du service de mise à jour - version de l'application \: %1$s, version de la base \: %2$s
+topia.migration.start.sql=Execution de la requête [%1$-4s/%2$-4s]
+topia.migration.start.sqls=Va executer %1$s requête(s)...
Modified: trunk/topia-service-replication/src/main/resources/i18n/topia-service-replication_es_ES.properties
===================================================================
--- trunk/topia-service-replication/src/main/resources/i18n/topia-service-replication_es_ES.properties 2011-05-04 10:57:35 UTC (rev 2271)
+++ trunk/topia-service-replication/src/main/resources/i18n/topia-service-replication_es_ES.properties 2011-05-04 14:39:50 UTC (rev 2272)
@@ -1,5 +1,5 @@
topia.replication.attachAssociation.nothing.to.do=Rien a attacher...
-topia.replication.error.operation.loadLink.illegalSource=Le noeud source de l'op\u00E9ration de chargement d'association attendait un noeud %1$s mais a trouv\u00E9 le noeud %2$s.
-topia.replication.error.operation.uncreatable=La operaci\u00F3n %1$s es interna y no puede ser creada por el API para a\u00F1adir la operaci\u00F3n.
-topia.replication.error.unkown.operation=La operaci\u00F3n %1$s es desconocida, operaciones conocidas \: %2$s
-topia.replication.error.unkown.owner.node=El nodo rattachement (de tipo %1$s) para la operaci\u00F3n %2$s no ha sido encontrado, nodos conocidos \: %3$s
+topia.replication.error.operation.loadLink.illegalSource=Le noeud source de l'opération de chargement d'association attendait un noeud %1$s mais a trouvé le noeud %2$s.
+topia.replication.error.operation.uncreatable=La operación %1$s es interna y no puede ser creada por el API para añadir la operación.
+topia.replication.error.unkown.operation=La operación %1$s es desconocida, operaciones conocidas \: %2$s
+topia.replication.error.unkown.owner.node=El nodo rattachement (de tipo %1$s) para la operación %2$s no ha sido encontrado, nodos conocidos \: %3$s
Modified: trunk/topia-service-replication/src/main/resources/i18n/topia-service-replication_fr_FR.properties
===================================================================
--- trunk/topia-service-replication/src/main/resources/i18n/topia-service-replication_fr_FR.properties 2011-05-04 10:57:35 UTC (rev 2271)
+++ trunk/topia-service-replication/src/main/resources/i18n/topia-service-replication_fr_FR.properties 2011-05-04 14:39:50 UTC (rev 2272)
@@ -1,5 +1,5 @@
-topia.replication.attachAssociation.nothing.to.do=Rien a attacher...
-topia.replication.error.operation.loadLink.illegalSource=Le noeud source de l'op\u00E9ration de chargement d'association attendait un noeud %1$s mais a trouv\u00E9 le noeud %2$s.
-topia.replication.error.operation.uncreatable=L'operation %1$s est interne et ne peut pas \u00EAtre cr\u00E9\u00E9e par l'api d'ajout d'op\u00E9ration.
-topia.replication.error.unkown.operation=L'op\u00E9ration %1$s est inconnue, op\u00E9rations connues \: %2$s
-topia.replication.error.unkown.owner.node=Le noeud de rattachement (de type %1$s) pour l'op\u00E9ration %2$s n'a pas \u00E9t\u00E9 trouv\u00E9, noeuds connus \: %3$s
+topia.replication.attachAssociation.nothing.to.do=Rien à attacher...
+topia.replication.error.operation.loadLink.illegalSource=Le noeud source de l'opération de chargement d'association attendait un noeud %1$s mais a trouvé le noeud %2$s.
+topia.replication.error.operation.uncreatable=L'operation %1$s est interne et ne peut pas être créée par l'api d'ajout d'opération.
+topia.replication.error.unkown.operation=L'opération %1$s est inconnue, opérations connues \: %2$s
+topia.replication.error.unkown.owner.node=Le noeud de rattachement (de type %1$s) pour l'opération %2$s n'a pas été trouvé, noeuds connus \: %3$s
1
0
r2271 - trunk/topia-persistence/src/main/java/org/nuiton/topia/generator
by fdesbois@users.nuiton.org 04 May '11
by fdesbois@users.nuiton.org 04 May '11
04 May '11
Author: fdesbois
Date: 2011-05-04 12:57:35 +0200 (Wed, 04 May 2011)
New Revision: 2271
Url: http://nuiton.org/repositories/revision/topia/2271
Log:
#1466 : remove noLog flag. Logs will no longer been generated.
Modified:
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2011-04-28 12:47:32 UTC (rev 2270)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2011-05-04 10:57:35 UTC (rev 2271)
@@ -195,14 +195,6 @@
protected String exceptionName;
- /**
- * flag to not use any logger code inside service method, globally set
- * for all the incoming model.
- *
- * @since 2.5
- */
- protected boolean noLog;
-
private static final String OP_NAME_BEGIN_TRANSACTION = "beginTransaction";
private static final String OP_NAME_COMMIT_TRANSACTION = "commitTransaction";
@@ -222,7 +214,6 @@
exceptionName =
TopiaGeneratorUtil.getExceptionClassTagValue(model);
modelName = model.getName();
- noLog = isNoLog(null, model);
}
@Override
@@ -233,14 +224,12 @@
// global transaction needed (if set to false then never use transaction)
boolean needTransaction = isTransactionNeeded(input);
- boolean noLog = this.noLog || isNoLog(input,null);
ObjectModelInterface serviceContract = createServiceContract(input);
createServiceAbstract(input,
serviceContract,
- needTransaction,
- noLog);
+ needTransaction);
}
/**
@@ -370,12 +359,10 @@
* @param source interface from model
* @param serviceContract to implement
* @param needTransaction flag to know if service globally use transaction
- * @param noLog a flag to not add any log code in body of methods
*/
protected void createServiceAbstract(ObjectModelInterface source,
ObjectModelInterface serviceContract,
- boolean needTransaction,
- boolean noLog) {
+ boolean needTransaction) {
ObjectModelClass serviceAbstract = createAbstractClass(
getServiceAbstractClassName(serviceContract.getName()),
@@ -386,23 +373,7 @@
addImport(serviceAbstract, TopiaContext.class);
}
addImport(serviceAbstract, I18n.class);
-// addImport(serviceAbstract, ArrayList.class);
-
- if (!noLog) {
- addImport(serviceAbstract, DurationFormatUtils.class);
- // Add Logger attribute
- addAttribute(serviceAbstract, "log",
- Log.class,
- "LogFactory.getLog(" + source.getName() + ".class)",
- ObjectModelModifier.PRIVATE,
- ObjectModelModifier.STATIC,
- ObjectModelModifier.FINAL);
-
- addImport(serviceAbstract, Log.class);
- addImport(serviceAbstract, LogFactory.class);
- }
-
// Implements contract interface
addInterface(serviceAbstract, serviceContract.getQualifiedName());
@@ -454,8 +425,7 @@
executeOperation,
operation,
source.getName(),
- needTransaction,
- noLog
+ needTransaction
);
}
}
@@ -522,7 +492,6 @@
* @param source ObjectModelOperation from model
* @param serviceContractName where the signature method is defined
* @param needTransaction flag to know if service globally use transaction
- * @param noLog a flag to not add any log inside method
* @see #isErrorArgsNeeded(ObjectModelOperation)
* @see #isTransactionNeeded(ObjectModelInterface)
*/
@@ -531,8 +500,7 @@
ObjectModelOperation abstOp,
ObjectModelOperation source,
String serviceContractName,
- boolean needTransaction,
- boolean noLog) {
+ boolean needTransaction) {
// boolean to specify if the method need a transaction or not
// Default set to true but can be override by a tagvalue on the
@@ -559,13 +527,6 @@
for (ObjectModelParameter param : source.getParameters()) {
String paramName = param.getName();
addParameter(implOp, param.getType(), paramName);
- if (!noLog) {
- // Prepare Log
- toStringAppend +=
- "\n\t\t\t.append(\"" + separatorLog + paramName + " = \")" +
- ".append(" + paramName + ")";
- separatorLog = " _ ";
- }
}
// Use buffer for operation body
@@ -629,43 +590,11 @@
}
String implName = StringUtils.capitalize(implOp.getName());
String first = modelName.substring(0, 1);
-
- if (!noLog) {
- buffer.append(""
- /*{
- long startTime = 0;
- if (log.isDebugEnabled()) {
- log.debug("<%=first%>:[ begin <%=implName%> ]");
- startTime = System.currentTimeMillis();
- }
- if (log.isTraceEnabled()) {
- String message = new StringBuilder("# ARGS >")<%=toStringAppend%>.
- toString();
- log.trace(message);
- }
- }*/);
- }
-
buffer.append(""
/*{
<%=abstReturnType%><%=abstName%>(<%=abstParams%>);}*/);
- if (!noLog) {
-
- buffer.append(""
- /*{
-
- if (log.isDebugEnabled()) {
- long stopTime = System.currentTimeMillis();
- Runtime runtime = Runtime.getRuntime();
- long mem = (runtime.totalMemory() - runtime.freeMemory()) / 1048576;
- log.debug("<%=first%>:[ end <%=implName%> ] Time = " +
- DurationFormatUtils.formatDurationHMS(
- stopTime - startTime) + " _ Memory = " + mem + " Mo");
- }}*/
- );
- }
if (needTransaction && isCommit(source, model)) {
// add the commit instruction
@@ -758,29 +687,6 @@
}
/**
- * boolean to specify if inside the method body we should add log informations.
- *
- * @param anInterface model element where the tagvalue is set
- * @param model model where to tagvalue can be also set
- * @return {@code true} if no log will be generated insde body's method
- * @see TopiaTagValues#TAG_NO_LOG_IN_SERVICE
- */
- protected boolean isNoLog(ObjectModelInterface anInterface,
- ObjectModel model) {
- boolean noLog = false;
-
- String tagValue = TopiaGeneratorUtil.getNoLogInServiceTagValue(
- anInterface,
- model
- );
-
- if (tagValue != null) {
- noLog = Boolean.parseBoolean(tagValue);
- }
- return noLog;
- }
-
- /**
* boolean to specify if method needs a commit after the executeXXX code invoked.
*
* @param op model element where the tagvalue is set
1
0