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
December 2009
- 3 participants
- 67 discussions
r1741 - in trunk/topia-persistence/src/main/java/org/nuiton/topia: framework persistence
by fdesbois@users.nuiton.org 29 Dec '09
by fdesbois@users.nuiton.org 29 Dec '09
29 Dec '09
Author: fdesbois
Date: 2009-12-29 13:12:40 +0100 (Tue, 29 Dec 2009)
New Revision: 1741
Added:
trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java
Modified:
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java
Log:
Evol #178 : TopiaQuery + use it for count in TopiaDAO
Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java (rev 0)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java 2009-12-29 12:12:40 UTC (rev 1741)
@@ -0,0 +1,688 @@
+/*
+ * *##%
+ * ToPIA :: Persistence
+ * Copyright (C) 2004 - 2009 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>.
+ * ##%*
+ */
+
+package org.nuiton.topia.framework;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * Query HQL managment to simplify utilisation of {@link TopiaContext#find(java.lang.String, java.lang.Object[]) }.
+ *
+ * TODO-FD20091224 Complete documentation of this class + JUnit Tests
+ *
+ * Created: 21 déc. 2009
+ *
+ * @author fdesbois
+ * @version $Revision$
+ *
+ * Mise a jour: $Date$
+ * par : $Author$
+ */
+public class TopiaQuery {
+
+ private static final Log log = LogFactory.getLog(TopiaQuery.class);
+
+ /** Params for HQL query **/
+ protected List<Object> params;
+
+ /** Select part of the query **/
+ protected String select;
+
+ /** From part of the query **/
+ protected String from;
+
+ /** Where part of the query **/
+ protected String where;
+
+ /** Order By part of the query **/
+ protected String orderBy;
+
+ /** Group By part of the query **/
+ protected String groupBy;
+
+ protected Integer startIndex;
+
+ protected Integer endIndex;
+
+ /** Used to determine if parentheses are needed for Where input **/
+ protected boolean parentheses;
+
+ protected List<String> propertiesToLoad;
+
+ protected Class<? extends TopiaEntity> mainEntityClass;
+
+ /**
+ * Enum to simmplify using operation in query
+ */
+ public static enum Op {
+ /** EQUALS **/
+ EQ("="),
+ /** GREATER THAN **/
+ GT(">"),
+ /** GREATER OR EQUALS **/
+ GE(">="),
+ /** LIKE for String manipulation **/
+ LIKE("LIKE"),
+ /** LESS THAN **/
+ LT("<"),
+ /** LESS OR EQUALS **/
+ LE("<="),
+ /** IS NOT NULL **/
+ NOT_NULL("IS NOT NULL");
+
+ protected String value;
+
+ /**
+ * Constructor of the Op Enum.
+ *
+ * @param value corresponding to the String for the query
+ */
+ Op(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Constructor of TopiaQuery with entityClass initialization.
+ *
+ * @param entityClass Class for an entity Query
+ */
+ public TopiaQuery(Class<? extends TopiaEntity> entityClass) {
+ this(entityClass.getName());
+ this.mainEntityClass = entityClass;
+ }
+
+ /**
+ * Constructor of TopiaQuery with String form initialization.
+ *
+ * @param from From part for the Query
+ */
+ public TopiaQuery(String from) {
+ this.from = " FROM " + from;
+ parentheses = true;
+ }
+
+ @Override
+ public String toString() {
+ return fullQuery();
+ }
+
+ /**
+ * Get the full query.
+ *
+ * @return a String corresponding to the full query.
+ */
+ public String fullQuery() {
+ String result = "";
+ if (select != null) {
+ result = select;
+ }
+ result += from;
+ if (where != null) {
+ result += where;
+ }
+ if (groupBy != null) {
+ result += groupBy;
+ }
+ if (orderBy != null) {
+ result += orderBy;
+ }
+ return result.trim();
+ }
+
+ /**
+ * Add a HQL parameter to the Query.
+ *
+ * @param id identification of the param in the query
+ * @param e value of the param
+ * @return the TopiaQuery
+ */
+ public TopiaQuery addParam(String id, Object e) {
+ getParams().add(id);
+ getParams().add(e);
+ return this;
+ }
+
+ protected List<Object> getParams() {
+ if (params == null) {
+ params = new ArrayList<Object>();
+ }
+ return params;
+ }
+
+ /**
+ * Add a property to load when query is executed.
+ * Used to avoid LazyInitializationException for property needed after closing context.
+ * The property is a string like those in HQL query.
+ * <pre>
+ * Exemples :
+ * - "person.company" (Property TopiaEntity person linked to the result entity in query and company linked to person)
+ * --> calling myEntity.getPerson().getCompany();
+ * - "partyRoles" (Property Collection partyRoles linked to the result entity in query)
+ * --> calling myEntity.getPartyRoles().size();
+ * </pre>
+ *
+ * @param properties
+ * @return
+ */
+ public TopiaQuery addLoad(String... properties) {
+ getPropertiesToLoad().addAll(Arrays.asList(properties));
+ return this;
+ }
+
+ protected List<String> getPropertiesToLoad() {
+ if (propertiesToLoad == null) {
+ propertiesToLoad = new ArrayList<String>();
+ }
+ return propertiesToLoad;
+ }
+
+ /**
+ * Add a where element to the Query. Could be anything.
+ * Parentheses are added automatically (even if there are not needed).
+ *
+ * @param where element to add
+ * @return the TopiaQuery
+ */
+ public TopiaQuery add(String where) {
+ if (this.where == null) {
+ this.where = " WHERE ";
+ } else {
+ this.where += " AND ";
+ }
+ if (parentheses) {
+ this.where += "(";
+ }
+ this.where += where;
+ if (parentheses) {
+ this.where += ")";
+ }
+ parentheses = true;
+ return this;
+ }
+
+ /**
+ * Add an element to the query. The parameter will be automatically added.
+ * The constraint is needed to determine what type of operation it is.
+ *
+ * @param paramName the name of the parameter in the query (attribute of the entity)
+ * @param constraint the operation concerned
+ * @param paramValue the value of the parameter (an other entity, a String, ...)
+ * @return the TopiaQuery
+ */
+ public TopiaQuery add(String paramName, Op constraint, Object paramValue) {
+ int dot = paramName.lastIndexOf(".");
+ String valueName = paramName;
+ if (dot != -1) {
+ valueName = paramName.substring(dot+1);
+ }
+ parentheses = false;
+ return add(paramName + " " + constraint + " :" + valueName).addParam(valueName, paramValue);
+ }
+
+ /**
+ * Add an element to the query with the constraint Not null.
+ *
+ * @param paramName name of the parameter in the query
+ * @return the TopiaQuery
+ */
+ public TopiaQuery addNotNull(String paramName) {
+ return add(paramName + " " + Op.NOT_NULL);
+ }
+
+ /**
+ * Add an element to the query. The parameter will be automatically added.
+ * The default constrainst operation is Op.EQ for EQUALS.
+ * Ex : add("boat", boat) means -> boat = :boat.
+ *
+ * @param paramName name of the parameter in the query
+ * @param paramValue value of the parameter
+ * @return the TopiaQuery
+ * @see #add(java.lang.String, fr.ifremer.suiviobsmer.TopiaQuery.Op, java.lang.Object)
+ */
+ public TopiaQuery add(String paramName, Object paramValue) {
+ return add(paramName, Op.EQ, paramValue);
+ }
+
+ /**
+ * Add an element to the from in the query. Used to add some other data in the query or for join.
+ *
+ * @param str the element to add
+ * @return the TopiaQuery
+ */
+ public TopiaQuery addFrom(String str) {
+ from += ", " + str;
+ return this;
+ }
+
+ /**
+ * Add an element to the select in the query. Used to add some parameters for the return of query.
+ *
+ * @param select element to add
+ * @return the TopiaQuery
+ */
+ public TopiaQuery addSelect(String select) {
+ if (this.select == null) {
+ this.select = "SELECT ";
+ } else {
+ this.select += ", ";
+ }
+ this.select += select;
+ return this;
+ }
+
+ /**
+ * Add an element to the order in the query. Used to add some parameters to order by.
+ *
+ * @param order element to add
+ * @return the TopiaQuery
+ */
+ public TopiaQuery addOrder(String order) {
+ if (orderBy == null) {
+ orderBy = " ORDER BY ";
+ } else {
+ orderBy += ", ";
+ }
+ orderBy += order;
+ return this;
+ }
+
+ public TopiaQuery addOrderDesc(String order) {
+ return addOrder(order + " DESC");
+ }
+
+ /**
+ * Add an element to the group of the query. Used to add some paramters to group by.
+ *
+ * @param group element to add
+ * @return the TopiaQuery
+ */
+ public TopiaQuery addGroup(String group) {
+ if (groupBy == null) {
+ groupBy = " GROUP BY ";
+ } else {
+ groupBy += ", ";
+ }
+ groupBy += group;
+ return this;
+ }
+
+ /**
+ * Limit the result of the query with startIndex and endIndex.
+ *
+ * @param start first index to get from the results
+ * @param end last index to get from the results
+ * @return the TopiaQuery
+ */
+ public TopiaQuery setLimit(int start, int end) {
+ this.startIndex = start;
+ this.endIndex = end;
+ return this;
+ }
+
+ /**
+ * Set the max results wanted for the query.
+ *
+ * @param max the number of elements wanted
+ * @return the TopiaQuery
+ */
+ public TopiaQuery setMaxResults(int max) {
+ return setLimit(0,max-1);
+ }
+
+ /**
+ * Simple execution of the query. This method use directly the find method in TopiaContext interface.
+ *
+ * @param transaction the TopiaContext to use for execution
+ * @return a List of results
+ * @throws TopiaException
+ * @see org.nuiton.topia.TopiaContext#find(java.lang.String, java.lang.Object[])
+ */
+ public List execute(TopiaContext transaction) throws TopiaException {
+ if (log.isTraceEnabled()) {
+ log.trace("# QUERY : " + fullQuery());
+ log.trace("# PARAMS : " + Arrays.toString(params.toArray()));
+ }
+ if (startIndex != null && endIndex != null) {
+ return transaction.find(fullQuery(), startIndex, endIndex, getParams().toArray());
+ }
+ return transaction.find(fullQuery(), getParams().toArray());
+ }
+
+ /**
+ * Execute the query and get a List of entity. Some properties will be loaded if they are
+ * prealably set using ${@link #addLoad(java.lang.String[]) }.
+ *
+ * @param <T> the type of TopiaEntity to return
+ * @param transaction the TopiaContext to use for execution
+ * @param entityClass the class of the TopiaEntity used for return type
+ * @return a List of TopiaEntity corresponding to the entityClass in argument
+ * @throws TopiaException
+ * @throws ClassCastException
+ */
+ public <T extends TopiaEntity> List<T> executeToEntityList(TopiaContext transaction, Class<T> entityClass)
+ throws TopiaException, ClassCastException {
+ List res = execute(transaction);
+ if (log.isTraceEnabled()) {
+ log.trace("Properties to load : " + getPropertiesToLoad());
+ }
+ List<T> results = new ArrayList<T>();
+ for (Object o : res) {
+ if (o != null && !entityClass.isAssignableFrom(o.getClass())) {
+ throw new ClassCastException("Invalid cast for " + entityClass.getName());
+ }
+ T entity = (T)o;
+ if (!getPropertiesToLoad().isEmpty()) {
+ loadProperties(entity);
+ }
+ results.add(entity);
+ }
+ return results;
+ }
+
+ /**
+ * {@link #executeToEntity(org.nuiton.topia.TopiaContext, java.lang.Class) } with default entityClass set from constructor.
+ *
+ * @param <T>
+ * @param transaction
+ * @return the TopiaEntity from entityClass set from ${@link #TopiaQuery(java.lang.Class) } constructor
+ * @throws TopiaException
+ * @throws ClassCastException
+ */
+ public <T extends TopiaEntity> List<T> executeToEntityList(TopiaContext transaction) throws TopiaException, ClassCastException {
+ if (this.mainEntityClass == null) {
+ throw new NullPointerException("Main entity class from constructor can't be null to use executeToEntityList method without entityClass");
+ }
+ return (List<T>)executeToEntityList(transaction, mainEntityClass);
+ }
+
+ /**
+ * Load all properties for the entity.
+ *
+ * @param <T> type of the entity extends TopiaEntity
+ * @param entity used to load properties
+ * @throws TopiaException
+ */
+ protected <T extends TopiaEntity> void loadProperties(T entity) throws TopiaException {
+ for (String prop : getPropertiesToLoad()) {
+ if (log.isTraceEnabled()) {
+ log.trace("load property " + prop + " ...");
+ }
+ List<String> str = Arrays.asList(prop.split("\\."));
+ Iterator<String> it = str.iterator();
+ TopiaEntity currEntity = entity;
+ while (it.hasNext()) {
+ String s = it.next();
+ if (log.isTraceEnabled()) {
+ log.trace("Current entity : " + currEntity.getClass().getSimpleName());
+ log.trace("Current loading : " + s);
+ }
+ if (it.hasNext()) {
+ currEntity = loadEntityProperty(currEntity, s);
+ } else {
+ loadProperty(currEntity, s);
+ }
+ }
+ }
+ }
+
+ /**
+ * Load a property of type TopiaEntity from an other entity.
+ *
+ * @param <T> type of the entity extends TopiaEntity
+ * @param entity used to load the property
+ * @param property name of the property in the entity
+ * @return a TopiaEntity corresponding to the property loaded
+ * @throws TopiaException
+ */
+ protected <T extends TopiaEntity> TopiaEntity loadEntityProperty(T entity, String property) throws TopiaException {
+ return (TopiaEntity)loadProperty(entity, property);
+ }
+
+ /**
+ * Load a property from an entity.
+ *
+ * @param <T> type of the entity extends TopiaEntity
+ * @param entity used to load the property
+ * @param property name of the property in the entity
+ * @return an Object corresponding to the property loaded
+ * @throws TopiaException
+ */
+ protected <T extends TopiaEntity> Object loadProperty(T entity, String property) throws TopiaException {
+ try {
+ Object res = PropertyUtils.getProperty(entity, property);
+ if (log.isTraceEnabled()) {
+ log.trace("load property '" + property + "' for '" + entity.getClass().getSimpleName() + "'");
+ }
+ if (Collection.class.isAssignableFrom(res.getClass())) {
+ Collection list = (Collection) res;
+ list.size();
+ }
+ return res;
+ } catch (IllegalAccessException eee) {
+ throw new TopiaException("Illegal access on property " + property + " from entity " + entity.getClass().getName(), eee);
+ } catch (InvocationTargetException eee) {
+ throw new TopiaException("Invocation error on entity " + entity.getClass().getName() + " for property " + property, eee);
+ } catch (NoSuchMethodException eee) {
+ throw new TopiaException("Getter method does not exist for property " + property + " from entity " + entity.getClass().getName(), eee);
+ }
+ }
+
+ /**
+ * Execute the query and get a Map of entity with key type in argument. Some properties will be loaded if they are
+ * prealably set using ${@link #addLoad(java.lang.String[]) }.
+ *
+ * @param <K> the type of the map key
+ * @param <T> the type of entity, value of the map
+ * @param transaction the TopiaContext to use for execution
+ * @param entityClass the class of the TopiaEntity used for return
+ * @param keyName the property name of the key in the entity
+ * @param keyClass the key class for the result map
+ * @return a Map with the key type defined and the entity in value
+ * @throws TopiaException
+ * @throws ClassCastException
+ */
+ public <K, T extends TopiaEntity> Map<K, T> executeToEntityMap(TopiaContext transaction, Class<T> entityClass, String keyName, Class<K> keyClass)
+ throws TopiaException, ClassCastException {
+
+ Map<K, T> results = new HashMap<K, T>();
+ for (T elmt : executeToEntityList(transaction, entityClass)) {
+ Object value = loadProperty(elmt, keyName);
+ if (value != null && !keyClass.isAssignableFrom(value.getClass())) {
+ throw new ClassCastException("Invalid cast for " + keyClass.getName());
+ }
+ results.put((K)value, elmt);
+ }
+ return results;
+ }
+
+ /**
+ * {@link #executeToEntityMap(org.nuiton.topia.TopiaContext, java.lang.Class, java.lang.String, java.lang.Class) }
+ * with default entityClass set from constructor.
+ *
+ * @param <K>
+ * @param <T>
+ * @param transaction
+ * @param keyName
+ * @param keyClass
+ * @return the TopiaEntity from entityClass set from ${@link #TopiaQuery(java.lang.Class) } constructor
+ * @throws TopiaException
+ * @throws ClassCastException
+ */
+ public <K, T extends TopiaEntity> Map<K, T> executeToEntityMap(TopiaContext transaction, String keyName, Class<K> keyClass)
+ throws TopiaException, ClassCastException {
+ if (this.mainEntityClass == null) {
+ throw new NullPointerException("Main entity class from constructor can't be null to use executeToEntityMap method without entityClass");
+ }
+ return (Map<K, T>)executeToEntityMap(transaction, mainEntityClass, keyName, keyClass);
+ }
+
+ /**
+ * Execute the query and get a Map of entity with topiaId in key. Some properties will be loaded if they are
+ * prealably set using ${@link #addLoad(java.lang.String[]) }.
+ *
+ * @param <T> the type of entity, value of the map
+ * @param transaction the TopiaContext to use for execution
+ * @param entityClass the class of the TopiaEntity used for return
+ * @return a Map with the key type defined and the entity in value
+ * @throws TopiaException
+ * @throws ClassCastException
+ */
+ public <T extends TopiaEntity> Map<String, T> executeToEntityMap(TopiaContext transaction, Class<T> entityClass)
+ throws TopiaException, ClassCastException {
+ return executeToEntityMap(transaction, entityClass, TopiaEntity.TOPIA_ID, String.class);
+ }
+
+ /**
+ * {@link #executeToEntityMap(org.nuiton.topia.TopiaContext, java.lang.Class) } with default entityClass set from constructor.
+ *
+ * @param <T>
+ * @param transaction
+ * @return the TopiaEntity from entityClass set from ${@link #TopiaQuery(java.lang.Class) } constructor
+ * @throws TopiaException
+ * @throws ClassCastException
+ */
+ public <T extends TopiaEntity> Map<String, T> executeToEntityMap(TopiaContext transaction)
+ throws TopiaException, ClassCastException {
+ if (this.mainEntityClass == null) {
+ throw new NullPointerException("Main entity class from constructor can't be null to use executeToEntityMap method without entityClass");
+ }
+ return (Map<String, T>)executeToEntityMap(transaction, mainEntityClass);
+ }
+
+ /**
+ * Execute the query and get the first result entity. Some properties will be loaded if they are
+ * prealably set using ${@link #addLoad(java.lang.String[]) }.
+ *
+ * @param <T> the type of TopiaEntity to return
+ * @param transaction the TopiaContext to use for execution
+ * @param entityClass the class of the TopiaEntity used for return type
+ * @return a TopiaEntity corresponding to the entityClass in argument
+ * @throws TopiaException
+ * @throws ClassCastException
+ */
+ public <T extends TopiaEntity> T executeToEntity(TopiaContext transaction, Class<T> entityClass)
+ throws TopiaException, ClassCastException {
+ setMaxResults(1);
+ List<T> results = executeToEntityList(transaction, entityClass);
+ return !results.isEmpty() ? results.get(0) : null;
+ }
+
+ /**
+ * {@link #executeToEntity(org.nuiton.topia.TopiaContext, java.lang.Class) } with default entityClass set from constructor.
+ *
+ * @param <T>
+ * @param transaction
+ * @return the TopiaEntity from entityClass set from ${@link #TopiaQuery(java.lang.Class) } constructor
+ * @throws TopiaException
+ * @throws ClassCastException
+ */
+ public <T extends TopiaEntity> T executeToEntity(TopiaContext transaction)
+ throws TopiaException, ClassCastException {
+ if (this.mainEntityClass == null) {
+ throw new NullPointerException("Main entity class from constructor can't be null to use executeToEntity method without entityClass");
+ }
+ return (T)executeToEntity(transaction, mainEntityClass);
+ }
+
+ /**
+ * Execute the query and get an Integer for result. Used for query with COUNT or SUM, ...
+ * The select is overriden to get only the right value for return.
+ *
+ * @param transaction the TopiaContext to use for execution
+ * @param select the Select overriden (ex : SUM(myParam))
+ * @return an Integer
+ * @throws TopiaException
+ */
+ public int executeToInteger(TopiaContext transaction, String select) throws TopiaException {
+ Long res = (Long)executeToObject(transaction, select);
+ return res != null ? res.intValue() : 0;
+ }
+
+ /**
+ * Execute the query and get a String for result. Used for query with MAX, ...
+ * The select is overriden to get only the right value for return.
+ *
+ * @param transaction the TopiaContext to use for execution
+ * @param select the Select overriden (ex : MAX(myParam))
+ * @return a String
+ * @throws TopiaException
+ */
+ public String executeToString(TopiaContext transaction, String select) throws TopiaException {
+ Object res = executeToObject(transaction, select);
+ return res != null ? (String)res : "";
+ }
+
+ /**
+ * Execute the query and get an Object for result.
+ * The select is overriden to get only the right value for return.
+ *
+ * @param transaction the TopiaContext to use for execution
+ * @param select the Select overriden
+ * @return an Object
+ * @throws TopiaException
+ */
+ public Object executeToObject(TopiaContext transaction, String select) throws TopiaException {
+ String oldValue = this.select;
+ if (!StringUtils.isEmpty(select)) {
+ this.select = "SELECT " + select;
+ }
+ Object result = null;
+ setMaxResults(1);
+ List results = execute(transaction);
+ if (!results.isEmpty()) {
+ result = results.get(0);
+ }
+ this.select = oldValue;
+ return result;
+ }
+
+ /**
+ * Execute a simple count on the query, i.e. the number of results get from the query.
+ *
+ * @param transaction the TopiaContext to use for execution
+ * @return an int corresponding to the number of result in the query
+ * @throws TopiaException
+ */
+ public int executeCount(TopiaContext transaction) throws TopiaException {
+ return executeToInteger(transaction, "COUNT(*)");
+ }
+
+}
Property changes on: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
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 2009-12-29 12:11:40 UTC (rev 1740)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaDAOImpl.java 2009-12-29 12:12:40 UTC (rev 1741)
@@ -56,6 +56,7 @@
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.hibernate.metadata.ClassMetadata;
+import org.nuiton.topia.framework.TopiaQuery;
/**
* Cette classe permet d'avoir un ensemble de méthode implantée de façon
@@ -731,15 +732,17 @@
}
/**
- * Utilisation du count(*) en HQL pour recuperer le nombre d'entites du type lie au DAO
- * @return un long correspondant au nombre d'entités existantes en base
+ * Count number of existing entities using {@link org.nuiton.topia.framework.TopiaQuery#executeCount(org.nuiton.topia.TopiaContext) }
+ * FIXME-FD20091224 change type to int like in 2.2.2 version
+ *
+ * @return a long for the number of entities in database
*/
@Override
public long size() throws TopiaException {
//int result = findAll().size();
-
- List result = this.getContext().find("SELECT count(*) FROM " + getEntityClass().getName() + "Impl");
- return (Long)result.get(0);
+// List result = this.getContext().find("SELECT count(*) FROM " + getEntityClass().getName() + "Impl");
+// return (Long)result.get(0);
+ return new TopiaQuery(getEntityClass()).executeCount(context);
}
@Override
1
0
r1740 - in trunk/topia-persistence/src/main/java/org/nuiton/topia: generator persistence
by fdesbois@users.nuiton.org 29 Dec '09
by fdesbois@users.nuiton.org 29 Dec '09
29 Dec '09
Author: fdesbois
Date: 2009-12-29 13:11:40 +0100 (Tue, 29 Dec 2009)
New Revision: 1740
Modified:
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOTransformer.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaTransformer.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java
Log:
Add license header
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOTransformer.java 2009-12-24 15:35:49 UTC (rev 1739)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOTransformer.java 2009-12-29 12:11:40 UTC (rev 1740)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * ToPIA :: Persistence
+ * Copyright (C) 2004 - 2009 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>.
+ * ##%*
+ */
package org.nuiton.topia.generator;
import org.apache.commons.lang.StringUtils;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaTransformer.java 2009-12-24 15:35:49 UTC (rev 1739)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaTransformer.java 2009-12-29 12:11:40 UTC (rev 1740)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * ToPIA :: Persistence
+ * Copyright (C) 2004 - 2009 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>.
+ * ##%*
+ */
package org.nuiton.topia.generator;
import org.apache.commons.logging.Log;
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 2009-12-24 15:35:49 UTC (rev 1739)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java 2009-12-29 12:11:40 UTC (rev 1740)
@@ -1,5 +1,6 @@
-/* *##%
- * Copyright (C) 2009 Code Lutin, Chatellier Eric
+/* *##%
+ * ToPIA :: Persistence
+ * Copyright (C) 2004 - 2009 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
@@ -14,7 +15,7 @@
* 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>.
- *##%*/
+ * ##%*/
package org.nuiton.topia.persistence;
1
0
r1739 - trunk/topia-persistence/src/main/java/org/nuiton/topia/generator
by fdesbois@users.nuiton.org 24 Dec '09
by fdesbois@users.nuiton.org 24 Dec '09
24 Dec '09
Author: fdesbois
Date: 2009-12-24 16:35:49 +0100 (Thu, 24 Dec 2009)
New Revision: 1739
Modified:
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java
Log:
Evol #177 : change type date by timestamp for topiaCreateDate
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2009-12-24 15:34:54 UTC (rev 1738)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2009-12-24 15:35:49 UTC (rev 1739)
@@ -55,6 +55,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang.BooleanUtils;
/**
* FIXME mettre les attributs node="..." sur tous les attributs
@@ -95,7 +96,7 @@
String clazzDOType = TopiaGeneratorUtil.getDOType(clazz, model);
String tableName = TopiaGeneratorUtil.getDBName(clazz);
- String isAbstract = clazz.isAbstract()?"true":"false";
+ String isAbstract = BooleanUtils.toStringTrueFalse(clazz.isAbstract());
String clazzFQN = clazz.getQualifiedName();
String optionalAttributes = "";
@@ -151,7 +152,7 @@
}*/
}
/*{ <version name="topiaVersion" type="long" node="@topiaVersion"/>
- <property name="topiaCreateDate" type="date" node="@topiaCreateDate"/>
+ <property name="topiaCreateDate" type="timestamp" node="@topiaCreateDate"/>
}*/
}
1
0
r1738 - trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence
by fdesbois@users.nuiton.org 24 Dec '09
by fdesbois@users.nuiton.org 24 Dec '09
24 Dec '09
Author: fdesbois
Date: 2009-12-24 16:34:54 +0100 (Thu, 24 Dec 2009)
New Revision: 1738
Modified:
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntity.java
Log:
Add static String for main TopiaEntity properties
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntity.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntity.java 2009-12-21 11:39:53 UTC (rev 1737)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/TopiaEntity.java 2009-12-24 15:34:54 UTC (rev 1738)
@@ -50,6 +50,10 @@
@SearchFields
public interface TopiaEntity {
+ String TOPIA_ID = "topiaId";
+ String TOPIA_CREATE_DATE = "topiaCreateDate";
+ String TOPIA_VERSION = "topiaVersion";
+
public String getTopiaId();
public void setTopiaId(String v);
1
0
r1737 - trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence
by echatellier@users.nuiton.org 21 Dec '09
by echatellier@users.nuiton.org 21 Dec '09
21 Dec '09
Author: echatellier
Date: 2009-12-21 12:39:53 +0100 (Mon, 21 Dec 2009)
New Revision: 1737
Added:
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java
Modified:
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/DepthEntityVisitor.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java
Log:
Add horizontal entity visitor.
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 2009-12-20 19:08:53 UTC (rev 1736)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/DepthEntityVisitor.java 2009-12-21 11:39:53 UTC (rev 1737)
@@ -36,10 +36,14 @@
*/
public class DepthEntityVisitor implements EntityVisitor {
+ /** Class logger. */
private static Log log = LogFactory.getLog(DepthEntityVisitor.class);
+
+ /** Cache of already explored entities. */
protected Collection<TopiaEntity> alreadyExplored;
+
/**
- * Le visiteur metier (optionel)
+ * Le visiteur metier (optionel).
*/
protected EntityVisitor delegateVisitor;
@@ -65,7 +69,7 @@
}
@Override
- public void visit(TopiaEntity e, String name, Class<?> type, Object value) {
+ public void visit(TopiaEntity e, String propertyName, Class<?> type, Object value) {
// si c'est une entité
if (value instanceof TopiaEntity) {
TopiaEntity entity = (TopiaEntity) value;
@@ -80,26 +84,26 @@
}
} else {
if (delegateVisitor != null) {
- delegateVisitor.visit(e, name, type, value);
+ delegateVisitor.visit(e, propertyName, type, value);
}
}
}
@Override
- public void visit(TopiaEntity e, String name, Class<?> collectionType, Class<?> type,
+ public void visit(TopiaEntity e, String propertyName, Class<?> collectionType, Class<?> type,
Object value) {
Collection<?> cValue = (Collection<?>) value;
if (cValue != null && !cValue.isEmpty()) {
int i = 0;
for (Object currentValue : cValue) {
- visit(e, name, type, collectionType, i++, currentValue);
+ visit(e, propertyName, type, collectionType, i++, currentValue);
}
}
}
@Override
- public void visit(TopiaEntity e, String name, Class<?> collectionType, Class<?> type, int index, Object value) {
+ public void visit(TopiaEntity e, String propertyName, Class<?> collectionType, Class<?> type, int index, Object value) {
// si c'est une entité
if (value instanceof TopiaEntity) {
TopiaEntity entity = (TopiaEntity) value;
@@ -114,7 +118,7 @@
}
} else {
if (delegateVisitor != null) {
- delegateVisitor.visit(e, name, collectionType, type, index, value);
+ delegateVisitor.visit(e, propertyName, collectionType, type, index, value);
}
}
}
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 2009-12-20 19:08:53 UTC (rev 1736)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/EntityVisitor.java 2009-12-21 11:39:53 UTC (rev 1737)
@@ -20,7 +20,6 @@
package org.nuiton.topia.persistence;
/**
- *
* The contract of a visitor of any {@link TopiaEntity}.
*
* Created: 28 janv. 2009 18:10:34
@@ -36,58 +35,60 @@
/**
* Start the visit of the given entity.
*
- * @param e the visited entity
+ * @param entity the visited entity
*/
- void start(TopiaEntity e);
+ void start(TopiaEntity entity);
/**
* Ends the visit of the given entity.
*
- * @param e the visited entity
+ * @param entity the visited entity
*/
- void end(TopiaEntity e);
+ void end(TopiaEntity entity);
/**
* Visit a none indexed property for the given entity.
*
* The property visited is defined by the other parameters.
*
- * @param e the visited entity
- * @param name the name of the visited property
+ * @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 visitied property
+ * @param value the value of the visited property
*/
- void visit(TopiaEntity e, String name, Class<?> type, Object value);
+ void visit(TopiaEntity entity, String propertyName, Class<?> type, Object value);
/**
* Visit a collection property for the given entity.
*
* The property visited is defined by the other parameters.
*
- * @param e the visited entity
- * @param name 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 visited collection
* @param type the type of the visited property
- * @param value the value of the visitied property
+ * @param value the value of the visited property
*/
- void visit(TopiaEntity e, String name, Class<?> collectionType, Class<?> type, Object value);
+ void visit(TopiaEntity entity, String propertyName, Class<?> collectionType, Class<?> type, Object value);
/**
* Visit a indexed value from a collection property for the given entity.
*
* The property visited is defined by the other parameters.
*
- * @param e the visited entity
- * @param name 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 visitied property
+ * @param value the value of the visited property
*/
- void visit(TopiaEntity e, String name, Class<?> collectionType, Class<?> type, int index, Object value);
+ void visit(TopiaEntity entity, String propertyName, Class<?> collectionType, Class<?> type, int index, Object value);
/**
- * reset all states of the visitor.
+ * Reset all states of the visitor.
+ *
+ * TODO called by who ? what is it for ?
*/
void clear();
}
Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java (rev 0)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java 2009-12-21 11:39:53 UTC (rev 1737)
@@ -0,0 +1,154 @@
+/* *##%
+ * Copyright (C) 2009 Code Lutin, 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
+ * 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>.
+ *##%*/
+
+package org.nuiton.topia.persistence;
+
+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;
+import org.nuiton.topia.persistence.EntityVisitor;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+/**
+ * Parcourt en largeur du modele et délegation à un autre visiteur.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class HorizontalEntityVisitor implements EntityVisitor {
+
+ /** Class logger. */
+ private static Log log = LogFactory.getLog(HorizontalEntityVisitor.class);
+
+ /** Delegate visitor. */
+ protected EntityVisitor delegateVisitor;
+
+ /** Cache used to remember entity during exploration. */
+ protected List<TopiaEntity> alreadyExplored;
+
+ /** Entity to be visited later. */
+ protected List<TopiaEntity> toVisitEntities;
+
+ /**
+ * Constructor.
+ *
+ * @param delegateVisitor delegate visitor
+ */
+ public HorizontalEntityVisitor(EntityVisitor delegateVisitor) {
+ this.delegateVisitor = delegateVisitor;
+ this.alreadyExplored = new ArrayList<TopiaEntity>();
+ this.toVisitEntities = new ArrayList<TopiaEntity>();
+ }
+
+ /*
+ * @see org.nuiton.topia.persistence.EntityVisitor#start(org.nuiton.topia.persistence.TopiaEntity)
+ */
+ @Override
+ public void start(TopiaEntity entity) {
+ delegateVisitor.start(entity);
+ if (!alreadyExplored.contains(entity)) {
+ alreadyExplored.add(entity);
+ }
+ }
+
+ /*
+ * @see org.nuiton.topia.persistence.EntityVisitor#visit(org.nuiton.topia.persistence.TopiaEntity, java.lang.String, java.lang.Class, java.lang.Object)
+ */
+ @Override
+ public void visit(TopiaEntity entity, String propertyName, Class<?> type, Object value) {
+ // si c'est une entité
+ if (value instanceof TopiaEntity) {
+ TopiaEntity entityValue = (TopiaEntity) value;
+ toVisitEntities.add(entityValue);
+ } else {
+ delegateVisitor.visit(entity, propertyName, type, value);
+ }
+ }
+
+ /*
+ * @see org.nuiton.topia.persistence.EntityVisitor#visit(org.nuiton.topia.persistence.TopiaEntity, java.lang.String, java.lang.Class, java.lang.Class, java.lang.Object)
+ */
+ @Override
+ public void visit(TopiaEntity entity, String propertyName, Class<?> collectionType,
+ Class<?> type, Object value) {
+ Collection<?> values = (Collection<?>) value;
+ if (values != null && !values.isEmpty()) {
+ int i = 0;
+ for (Object currentValue : values) {
+ visit(entity, propertyName, type, collectionType, i++, currentValue);
+ }
+ }
+ }
+
+ /*
+ * @see org.nuiton.topia.persistence.EntityVisitor#visit(org.nuiton.topia.persistence.TopiaEntity, java.lang.String, java.lang.Class, java.lang.Class, int, java.lang.Object)
+ */
+ @Override
+ public void visit(TopiaEntity entity, String propertyName, Class<?> collectionType,
+ Class<?> type, int index, Object value) {
+ // si c'est une entité
+ if (value instanceof TopiaEntity) {
+ TopiaEntity entityValue = (TopiaEntity) value;
+ toVisitEntities.add(entityValue);
+ } else {
+ delegateVisitor.visit(entity, propertyName, collectionType, type, index, value);
+ }
+ }
+
+ /*
+ * @see org.nuiton.topia.persistence.EntityVisitor#end(org.nuiton.topia.persistence.TopiaEntity)
+ */
+ @Override
+ public void end(TopiaEntity entity) {
+ delegateVisitor.end(entity);
+
+ // here, must revisit all remembered entities
+ List<TopiaEntity> currentEntities = new ArrayList<TopiaEntity>(toVisitEntities);
+ // TODO verify if clearing here is enough
+ toVisitEntities.clear();
+ for (TopiaEntity currentEntity : currentEntities) {
+ try {
+ if (!alreadyExplored.contains(currentEntity)) {
+ currentEntity.accept(this);
+ log.debug("Post process " + currentEntity);
+ }
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Error on horizontal exploration", ex);
+ }
+ }
+ }
+ }
+
+ /*
+ * @see org.nuiton.topia.persistence.EntityVisitor#clear()
+ */
+ @Override
+ public void clear() {
+ alreadyExplored.clear();
+ toVisitEntities.clear();
+ delegateVisitor.clear();
+ }
+} // HorizontallyEntityVisitor
Property changes on: trunk/topia-persistence/src/main/java/org/nuiton/topia/persistence/HorizontalEntityVisitor.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL"
1
0
r1736 - in trunk: . topia-persistence topia-service-history topia-service-index topia-service-migration topia-service-replication topia-service-security topia-soa
by tchemit@users.nuiton.org 20 Dec '09
by tchemit@users.nuiton.org 20 Dec '09
20 Dec '09
Author: tchemit
Date: 2009-12-20 20:08:53 +0100 (Sun, 20 Dec 2009)
New Revision: 1736
Modified:
trunk/pom.xml
trunk/topia-persistence/pom.xml
trunk/topia-service-history/pom.xml
trunk/topia-service-index/pom.xml
trunk/topia-service-migration/pom.xml
trunk/topia-service-replication/pom.xml
trunk/topia-service-security/pom.xml
trunk/topia-soa/pom.xml
Log:
[maven-release-plugin] prepare for next development iteration
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-20 19:08:44 UTC (rev 1735)
+++ trunk/pom.xml 2009-12-20 19:08:53 UTC (rev 1736)
@@ -13,7 +13,7 @@
</parent>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2</version>
+ <version>2.3.0-beta-3-SNAPSHOT</version>
<modules>
<module>topia-persistence</module>
@@ -360,9 +360,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/topia/tags/topia-2.3.0-beta-2</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/topia/tags/topia-2.3.0-beta-2</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/topia/tags/topia-2.3.0-beta-2</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/topia/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/topia/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/topia/trunk</url>
</scm>
</project>
Modified: trunk/topia-persistence/pom.xml
===================================================================
--- trunk/topia-persistence/pom.xml 2009-12-20 19:08:44 UTC (rev 1735)
+++ trunk/topia-persistence/pom.xml 2009-12-20 19:08:53 UTC (rev 1736)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2</version>
+ <version>2.3.0-beta-3-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-history/pom.xml
===================================================================
--- trunk/topia-service-history/pom.xml 2009-12-20 19:08:44 UTC (rev 1735)
+++ trunk/topia-service-history/pom.xml 2009-12-20 19:08:53 UTC (rev 1736)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2</version>
+ <version>2.3.0-beta-3-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-index/pom.xml
===================================================================
--- trunk/topia-service-index/pom.xml 2009-12-20 19:08:44 UTC (rev 1735)
+++ trunk/topia-service-index/pom.xml 2009-12-20 19:08:53 UTC (rev 1736)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2</version>
+ <version>2.3.0-beta-3-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-migration/pom.xml
===================================================================
--- trunk/topia-service-migration/pom.xml 2009-12-20 19:08:44 UTC (rev 1735)
+++ trunk/topia-service-migration/pom.xml 2009-12-20 19:08:53 UTC (rev 1736)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2</version>
+ <version>2.3.0-beta-3-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-replication/pom.xml
===================================================================
--- trunk/topia-service-replication/pom.xml 2009-12-20 19:08:44 UTC (rev 1735)
+++ trunk/topia-service-replication/pom.xml 2009-12-20 19:08:53 UTC (rev 1736)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2</version>
+ <version>2.3.0-beta-3-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-security/pom.xml
===================================================================
--- trunk/topia-service-security/pom.xml 2009-12-20 19:08:44 UTC (rev 1735)
+++ trunk/topia-service-security/pom.xml 2009-12-20 19:08:53 UTC (rev 1736)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2</version>
+ <version>2.3.0-beta-3-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-soa/pom.xml
===================================================================
--- trunk/topia-soa/pom.xml 2009-12-20 19:08:44 UTC (rev 1735)
+++ trunk/topia-soa/pom.xml 2009-12-20 19:08:53 UTC (rev 1736)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2</version>
+ <version>2.3.0-beta-3-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.topia</groupId>
1
0
Author: tchemit
Date: 2009-12-20 20:08:44 +0100 (Sun, 20 Dec 2009)
New Revision: 1735
Added:
tags/topia-2.3.0-beta-2/
Log:
[maven-scm] copy for tag topia-2.3.0-beta-2
Property changes on: tags/topia-2.3.0-beta-2
___________________________________________________________________
Added: svn:ignore
+ *.ipr
*.iws
.classpath
*.iml
.project
target
.settings
Added: svn:mergeinfo
+ /branches/from2.2.2-eugene2-beta:1662-1714
1
0
r1734 - in trunk: . topia-persistence topia-service-history topia-service-index topia-service-migration topia-service-replication topia-service-security topia-soa
by tchemit@users.nuiton.org 20 Dec '09
by tchemit@users.nuiton.org 20 Dec '09
20 Dec '09
Author: tchemit
Date: 2009-12-20 20:08:40 +0100 (Sun, 20 Dec 2009)
New Revision: 1734
Modified:
trunk/pom.xml
trunk/topia-persistence/pom.xml
trunk/topia-service-history/pom.xml
trunk/topia-service-index/pom.xml
trunk/topia-service-migration/pom.xml
trunk/topia-service-replication/pom.xml
trunk/topia-service-security/pom.xml
trunk/topia-soa/pom.xml
Log:
[maven-release-plugin] prepare release topia-2.3.0-beta-2
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-20 18:41:57 UTC (rev 1733)
+++ trunk/pom.xml 2009-12-20 19:08:40 UTC (rev 1734)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -14,7 +13,7 @@
</parent>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2-SNAPSHOT</version>
+ <version>2.3.0-beta-2</version>
<modules>
<module>topia-persistence</module>
@@ -361,9 +360,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/topia/trunk</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/topia/trunk</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/topia/trunk</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/topia/tags/topia-2.3.0-beta-2</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/topia/tags/topia-2.3.0-beta-2</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/topia/tags/topia-2.3.0-beta-2</url>
</scm>
</project>
Modified: trunk/topia-persistence/pom.xml
===================================================================
--- trunk/topia-persistence/pom.xml 2009-12-20 18:41:57 UTC (rev 1733)
+++ trunk/topia-persistence/pom.xml 2009-12-20 19:08:40 UTC (rev 1734)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2-SNAPSHOT</version>
+ <version>2.3.0-beta-2</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-history/pom.xml
===================================================================
--- trunk/topia-service-history/pom.xml 2009-12-20 18:41:57 UTC (rev 1733)
+++ trunk/topia-service-history/pom.xml 2009-12-20 19:08:40 UTC (rev 1734)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2-SNAPSHOT</version>
+ <version>2.3.0-beta-2</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-index/pom.xml
===================================================================
--- trunk/topia-service-index/pom.xml 2009-12-20 18:41:57 UTC (rev 1733)
+++ trunk/topia-service-index/pom.xml 2009-12-20 19:08:40 UTC (rev 1734)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2-SNAPSHOT</version>
+ <version>2.3.0-beta-2</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-migration/pom.xml
===================================================================
--- trunk/topia-service-migration/pom.xml 2009-12-20 18:41:57 UTC (rev 1733)
+++ trunk/topia-service-migration/pom.xml 2009-12-20 19:08:40 UTC (rev 1734)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2-SNAPSHOT</version>
+ <version>2.3.0-beta-2</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-replication/pom.xml
===================================================================
--- trunk/topia-service-replication/pom.xml 2009-12-20 18:41:57 UTC (rev 1733)
+++ trunk/topia-service-replication/pom.xml 2009-12-20 19:08:40 UTC (rev 1734)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2-SNAPSHOT</version>
+ <version>2.3.0-beta-2</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-service-security/pom.xml
===================================================================
--- trunk/topia-service-security/pom.xml 2009-12-20 18:41:57 UTC (rev 1733)
+++ trunk/topia-service-security/pom.xml 2009-12-20 19:08:40 UTC (rev 1734)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2-SNAPSHOT</version>
+ <version>2.3.0-beta-2</version>
</parent>
<groupId>org.nuiton.topia</groupId>
Modified: trunk/topia-soa/pom.xml
===================================================================
--- trunk/topia-soa/pom.xml 2009-12-20 18:41:57 UTC (rev 1733)
+++ trunk/topia-soa/pom.xml 2009-12-20 19:08:40 UTC (rev 1734)
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>topia</artifactId>
- <version>2.3.0-beta-2-SNAPSHOT</version>
+ <version>2.3.0-beta-2</version>
</parent>
<groupId>org.nuiton.topia</groupId>
1
0
r1733 - in trunk: . topia-persistence/src/main/java/org/nuiton/topia/generator
by tchemit@users.nuiton.org 20 Dec '09
by tchemit@users.nuiton.org 20 Dec '09
20 Dec '09
Author: tchemit
Date: 2009-12-20 19:41:57 +0100 (Sun, 20 Dec 2009)
New Revision: 1733
Added:
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOTransformer.java
Modified:
trunk/pom.xml
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractTransformer.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOTransformer.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDTOTransformer.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/InterfaceTransformer.java
Log:
- use eugene last stable version
- migrate DTOGenerator to DTOTransformer
- improve some transformers (clean imports, add methods to make code more readable...)
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-20 16:29:38 UTC (rev 1732)
+++ trunk/pom.xml 2009-12-20 18:41:57 UTC (rev 1733)
@@ -189,7 +189,7 @@
<projectId>topia</projectId>
<!-- libs version -->
- <eugene.version>2.0.0-beta-2-SNAPSHOT</eugene.version>
+ <eugene.version>2.0.0-beta-2</eugene.version>
<lutinutil.version>1.1.1</lutinutil.version>
<processor.version>1.0.2</processor.version>
<i18n.version>1.0.1</i18n.version>
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 2009-12-20 16:29:38 UTC (rev 1732)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractTransformer.java 2009-12-20 18:41:57 UTC (rev 1733)
@@ -67,7 +67,6 @@
}
String clazzName = clazz.getName();
- String clazzFQN = clazz.getQualifiedName();
ObjectModelClass result = createAbstractClass(clazzName + "DAOAbstract<E extends " + clazzName + ">", clazz.getPackageName());
@@ -329,7 +328,7 @@
* Generation of DAO operations signatures from class.
* These operations are abstract and identified by <<dao>> stereotype in the model.
* The developper must defined these methods in the DAOImpl associated to this DAOAbstract.
- * @param result
+ * @param result clazz where to add operations
* @param operations operations to generate
*/
private void generateDAOOperations(ObjectModelClass result, Collection<ObjectModelOperation> operations) {
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOTransformer.java 2009-12-20 16:29:38 UTC (rev 1732)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOTransformer.java 2009-12-20 18:41:57 UTC (rev 1733)
@@ -22,8 +22,6 @@
import org.nuiton.eugene.java.ObjectModelTransformerToJava;
import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelElement;
-import org.nuiton.eugene.models.object.xml.ObjectModelElementImpl;
/*{generator option: parentheses = false}*/
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOGenerator.java 2009-12-20 18:41:57 UTC (rev 1733)
@@ -57,7 +57,10 @@
/**
* DTO generator
* @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.topia.generator.DTOGenerator"
+ * @deprecated since 2.3.0, prefer use the corresponding {@link org.nuiton.eugene.Transformer} :
+ * {@link DTOTransformer}.
*/
+@Deprecated
public class DTOGenerator extends ObjectModelGenerator {
/**
Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOTransformer.java (rev 0)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOTransformer.java 2009-12-20 18:41:57 UTC (rev 1733)
@@ -0,0 +1,440 @@
+package org.nuiton.topia.generator;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.GeneratorUtil;
+import org.nuiton.eugene.java.ObjectModelTransformerToJava;
+import org.nuiton.eugene.models.object.*;
+import static org.nuiton.topia.generator.TopiaGeneratorUtil.TAG_ANNOTATION;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+
+
+/*{generator option: parentheses = false}*/
+
+/*{generator option: writeString = +}*/
+
+/**
+ * Created: 20 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.topia.generator.DTOTransformer"
+ * @since 2.3.0
+ */
+public class DTOTransformer extends ObjectModelTransformerToJava {
+
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(DTOTransformer.class);
+
+ @Override
+ public void transformFromClass(ObjectModelClass clazz) {
+ if (!clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
+ return;
+ }
+ String clazzName = clazz.getName();
+ ObjectModelClass result;
+ result = createClass(clazzName + "DTO", clazz.getPackageName());
+ addImport(result, ToStringBuilder.class);
+ addImport(result, PropertyChangeListener.class);
+
+ setDocumentation(result, "Implantation DTO pour l'entité " + StringUtils.capitalize(clazzName) + ".");
+ String extendClass = "";
+ for (ObjectModelClass parent : clazz.getSuperclasses()) {
+ extendClass = parent.getQualifiedName() + "DTO";
+ // no multi-inheritance in java
+ break;
+ }
+ if (extendClass.length() > 0) {
+ setSuperClass(result, extendClass);
+ }
+
+ addInterface(result, Serializable.class);
+ for (ObjectModelInterface parentInterface : clazz.getInterfaces()) {
+ if (parentInterface.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO)) {
+ addInterface(result, parentInterface.getName() + "DTO");
+ } else {
+ addInterface(result, parentInterface.getName());
+ }
+ }
+
+ addAttributes(result, clazz);
+
+ addOperations(result, clazz);
+ }
+
+ protected void addAttributes(ObjectModelClass result, ObjectModelClass clazz) {
+
+ String svUID = TopiaGeneratorUtil.findTagValue("dto-serialVersionUID", clazz, model);
+ if (StringUtils.isNotEmpty(svUID)) {
+ addAttribute(result, "serialVersionUID", long.class, svUID, ObjectModelModifier.FINAL, ObjectModelModifier.PUBLIC, ObjectModelModifier.STATIC);
+ }
+
+ addAttribute(result, "p", PropertyChangeSupport.class, null, ObjectModelModifier.PROTECTED);
+
+/*
+* Définition des attributs
+*/
+ ObjectModelAttribute attr2;
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
+ ObjectModelAttribute reverse = attr.getReverseAttribute();
+
+ String attributeName;
+ String attributeType;
+ if (!(attr.isNavigable()
+ || attr.hasAssociationClass())) {
+ continue;
+ }
+
+ String attrName = attr.getName();
+ String attrVisibility = attr.getVisibility();
+ String attrType = attr.getType();
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+ if (!attr.hasAssociationClass()) {
+ if (isDTO(attrType)) {
+ attrType += "DTO";
+ }
+ attributeType = attrType;
+ attributeName = attrName;
+ } else {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ attributeType = attr.getAssociationClass().getQualifiedName();
+ attributeName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
+ }
+ } else {
+ if (!attr.hasAssociationClass()) {
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = List.class.getName() + "<";
+ } else {
+ nMultType = Collection.class.getName() + "<";
+ }
+ nMultType += attrType;
+ if (isDTO(attrType)) {
+ nMultType += "DTO";
+ }
+ nMultType += ">";
+
+ attributeType = nMultType;
+ attributeName = attrName;
+ } else {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = List.class.getName() + "<";
+ } else {
+ nMultType = Collection.class.getName() + "<";
+ }
+ nMultType += assocClassFQN;
+ if (isDTO(attrType)) {
+ nMultType += "DTO";
+ }
+ nMultType += ">";
+ attributeType = nMultType;
+ attributeName = GeneratorUtil.toLowerCaseFirstLetter(assocAttrName);
+ }
+ }
+
+ attr2 = addAttribute(result, attributeName, attributeType, null, ObjectModelModifier.PROTECTED);
+
+ if (attr2 != null) {
+ if (TopiaGeneratorUtil.hasDocumentation(attr)) {
+ setDocumentation(attr2, attr.getDocumentation());
+ }
+ String annotation = attr.getTagValue(TAG_ANNOTATION);
+ if (StringUtils.isNotEmpty(annotation)) {
+ addAnnotation(result, attr2, annotation);
+ }
+ }
+ } /* end for*/
+
+ //Déclaration des attributs d'une classe d'associations
+ if (clazz instanceof ObjectModelAssociationClass) {
+ ObjectModelAssociationClass assoc = (ObjectModelAssociationClass) clazz;
+ for (ObjectModelAttribute attr : assoc.getParticipantsAttributes()) {
+ if (attr != null) {
+ String attrName = attr.getName();
+ String attrVisibility = attr.getVisibility();
+ String attrType = attr.getType();
+ if (isDTO(attrType)) {
+ attrType += "DTO";
+ }
+ addAttribute(result, GeneratorUtil.toLowerCaseFirstLetter(attrName), attrType);
+ }
+ }
+ }
+
+ }
+
+ protected void addOperations(ObjectModelClass result, ObjectModelClass clazz) {
+ ObjectModelOperation op;
+ op = addOperation(result, "addPropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
+ addParameter(op, PropertyChangeListener.class, "listener");
+ setOperationBody(op, ""
+/*{
+ p.addPropertyChangeListener(listener);
+ }*/
+ );
+
+ op = addOperation(result, "addPropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
+ addParameter(op, String.class, "propertyName");
+ addParameter(op, PropertyChangeListener.class, "listener");
+ setOperationBody(op, ""
+/*{
+ p.addPropertyChangeListener(propertyName, listener);
+ }*/
+ );
+
+ op = addOperation(result, "removePropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
+ addParameter(op, PropertyChangeListener.class, "listener");
+ setOperationBody(op, ""
+/*{
+ p.removePropertyChangeListener(listener);
+ }*/
+ );
+
+ op = addOperation(result, "removePropertyChangeListener", "void", ObjectModelModifier.PUBLIC);
+ addParameter(op, String.class, "propertyName");
+ addParameter(op, PropertyChangeListener.class, "listener");
+ setOperationBody(op, ""
+/*{
+ p.removePropertyChangeListener(propertyName, listener);
+ }*/
+ );
+ /*
+ * Définition des getteurs et setteurs
+ */
+ for (ObjectModelAttribute attr : clazz.getAttributes()) {
+
+ ObjectModelAttribute reverse = attr.getReverseAttribute();
+
+// if (!(attr.isNavigable() || hasUnidirectionalRelationOnAbstractType(reverse, model))) {
+ if (!attr.isNavigable()) {
+ continue;
+ }
+
+ String attrName = attr.getName();
+ String attrType = attr.getType();
+ String attrTypeDTO = attr.getType();
+ if (isDTO(attrType)) {
+ attrTypeDTO += "DTO";
+ }
+
+ if (!GeneratorUtil.isNMultiplicity(attr)) {
+ if (!attr.hasAssociationClass()) {
+ op = addOperation(result, "set" + StringUtils.capitalize(attrName), "void", ObjectModelModifier.PUBLIC);
+ addParameter(op, attrTypeDTO, "value");
+ setOperationBody(op, ""
+/*{
+ <%=attrTypeDTO%> oldValue = this.<%=attrName%>;
+ this.<%=attrName%> = value;
+ p.firePropertyChange("<%=attrName%>", oldValue, value);
+ }*/
+ );
+
+ op = addOperation(result, "get" + StringUtils.capitalize(attrName), attrTypeDTO, ObjectModelModifier.PUBLIC);
+ setOperationBody(op, ""
+/*{
+ return <%=attrName%>;
+ }*/
+ );
+
+ } else {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ if (log.isTraceEnabled()) {
+ log.trace("assocAttrName: " + assocAttrName);
+ }
+ op = addOperation(result, "set" + StringUtils.capitalize(assocAttrName), "void", ObjectModelModifier.PUBLIC);
+ addParameter(op, assocClassFQN + "DTO", "association");
+ setOperationBody(op, ""
+/*{
+ <%=assocClassFQN%>DTO oldAssocation = this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = association;
+ p.firePropertyChange("<%=attrName%>", oldAssocation, assocation);
+ }*/
+ );
+
+ op = addOperation(result, "get" + StringUtils.capitalize(assocAttrName), assocClassFQN + "DTO", ObjectModelModifier.PUBLIC);
+ setOperationBody(op, ""
+/*{
+ return <%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ }*/
+ );
+ }
+ } else { //NMultiplicity
+ if (!attr.hasAssociationClass()) { //Méthodes remplacées par des accesseurs sur les classes d'assoc
+
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = List.class.getName() + "<" + attrTypeDTO + ">";
+ } else {
+ nMultType = Collection.class.getName() + "<" + attrTypeDTO + ">";
+ }
+ op = addOperation(result, "set" + StringUtils.capitalize(attrName), "void", ObjectModelModifier.PUBLIC);
+ addParameter(op, nMultType, "values");
+ setOperationBody(op, ""
+/*{
+ <%=nMultType%> oldValues = this.<%=attrName%>;
+ this.<%=attrName%> = values;
+ p.firePropertyChange("<%=attrName%>", oldValues, values);
+ }*/
+ );
+
+ op = addOperation(result, "addChild" + StringUtils.capitalize(attrName), attrTypeDTO, ObjectModelModifier.PUBLIC);
+ addParameter(op, attrTypeDTO, attrName);
+ StringBuilder buffercode = new StringBuilder();
+
+ buffercode.append(""
+/*{
+ this.<%=attrName%>.add(<%=attrName%>);
+ }*/
+ );
+
+ if (reverse != null && reverse.isNavigable()) {
+ String reverseAttrName = reverse.getName();
+ buffercode.append(""
+/*{ <%=attrName%>.set<%=StringUtils.capitalize(reverseAttrName)%>(this);
+ }*/
+ );
+ }
+ buffercode.append(""
+/*{ return <%=attrName%>;
+ }*/
+ );
+ setOperationBody(op, buffercode.toString());
+
+ op = addOperation(result, "removeChild", "void");
+ addParameter(op, attrTypeDTO, attrName);
+
+ buffercode = new StringBuilder();
+ buffercode.append(""
+/*{
+ this.<%=attrName%>.remove(<%=attrName%>);
+ }*/
+ );
+
+ if (reverse != null && reverse.isNavigable()) {
+ String reverseAttrName = reverse.getName();
+ buffercode.append(""
+/*{ <%=attrName%>.set<%=StringUtils.capitalize(reverseAttrName)%>(null);
+ }*/
+ );
+ }
+ setOperationBody(op, buffercode.toString());
+
+ } else {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = List.class.getName() + "<" + assocClassFQN + "DTO>";
+ } else {
+ nMultType = Collection.class.getName() + "<" + assocClassFQN + "DTO>";
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("assocAttrName: " + assocAttrName);
+ }
+ op = addOperation(result, "set" + StringUtils.capitalize(assocAttrName), "void");
+ addParameter(op, nMultType, "values");
+ setOperationBody(op, ""
+/*{
+ <%=nMultType%> oldValues = this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%> = values;
+ p.firePropertyChange("<%=attrName%>", oldValues, values);
+ }*/
+ );
+ }
+ if (!attr.hasAssociationClass()) {
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = List.class.getName() + "<" + attrTypeDTO + ">";
+ } else {
+ nMultType = Collection.class.getName() + "<" + attrTypeDTO + ">";
+ }
+ op = addOperation(result, "get" + StringUtils.capitalize(attrName), nMultType);
+ setOperationBody(op, ""
+/*{
+ return this.<%=attrName%>;
+ }*/
+ );
+ } else {
+ String assocAttrName = TopiaGeneratorUtil.getAssocAttrName(attr);
+ String assocClassFQN = attr.getAssociationClass().getQualifiedName();
+ String nMultType;
+ if (attr.isOrdered()) {
+ nMultType = List.class.getName() + "<" + assocClassFQN + "DTO>";
+ } else {
+ nMultType = Collection.class.getName() + "<" + assocClassFQN + "DTO>";
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("assocAttrName: " + assocAttrName);
+ }
+ op = addOperation(result, "get" + StringUtils.capitalize(assocAttrName), nMultType);
+ setOperationBody(op, ""
+/*{
+ return this.<%=GeneratorUtil.toLowerCaseFirstLetter(assocAttrName)%>;
+ }*/
+ );
+ }
+ }
+ }
+
+ op = addOperation(result, "toString", String.class, ObjectModelModifier.PUBLIC);
+ StringBuilder buffer = new StringBuilder();
+
+ buffer.append(""
+/*{
+ String result = new ToStringBuilder(this).
+}*/
+ );
+
+ for (Object o : clazz.getAttributes()) {
+ ObjectModelAttribute attr = (ObjectModelAttribute) o;
+ if (!(attr.isNavigable()
+ || attr.hasAssociationClass())) {
+ continue;
+ }
+ //FIXME possibilité de boucles (non directes)
+ ObjectModelClass attrEntity = null;
+ if (model.hasClass(attr.getType())) {
+ attrEntity = model.getClass(attr.getType());
+ }
+ boolean isDTO = (attrEntity != null && attrEntity.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_ENTITY)); //THIMEL : STEREOTYPE ENTITY ???
+ ObjectModelAttribute reverse = attr.getReverseAttribute();
+ if ((isDTO && (reverse == null || !reverse.isNavigable()) && !attr.hasAssociationClass()) || (!isDTO)) {
+ String attrName = attr.getName();
+ buffer.append(""
+/*{ append("<%=attrName%>", this.<%=attrName%>).
+}*/
+ );
+ }
+ }
+ buffer.append(""
+/*{ toString();
+ return result;
+ }*/
+ );
+ setOperationBody(op, buffer.toString());
+ }
+
+ public boolean isDTO(String type) {
+ ObjectModelClassifier clazz = model.getClassifier(type);
+ return clazz != null && clazz.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DTO);
+ }
+
+
+}
+
Property changes on: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOTransformer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDTOTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDTOTransformer.java 2009-12-20 16:29:38 UTC (rev 1732)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDTOTransformer.java 2009-12-20 18:41:57 UTC (rev 1733)
@@ -76,6 +76,15 @@
}
addInterface(result, Serializable.class);
+
+ addAttributes(result,clazz);
+
+ addOperations(result,clazz);
+
+ }
+
+ protected void addAttributes(ObjectModelClass result, ObjectModelClass clazz) {
+
String svUID = TopiaGeneratorUtil.findTagValue("dto-serialVersionUID", clazz, model);
if (svUID != null) {
addAttribute(result, "serialVersionUID", "long", svUID, ObjectModelModifier.FINAL, ObjectModelModifier.PUBLIC, ObjectModelModifier.STATIC);
@@ -94,13 +103,6 @@
continue;
}
-//FIXME : make annotation possible
-// if (attr.hasTagValue(TAG_ANNOTATION)) {
-// String annotation = attr.getTagValue(TAG_ANNOTATION);
-//{ <%=annotation%>
-//}*/
-// }
-
String attrVisibility = attr.getVisibility();
ObjectModelModifier modifier = ObjectModelModifier.toValue(attrVisibility);
if (!attr.hasAssociationClass()) {
@@ -127,6 +129,11 @@
if (TopiaGeneratorUtil.hasDocumentation(attr)) {
setDocumentation(attr2, attr.getDocumentation());
}
+
+ if (attr.hasTagValue(TopiaGeneratorUtil.TAG_ANNOTATION)) {
+ String annotation = attr.getTagValue(TopiaGeneratorUtil.TAG_ANNOTATION);
+ addAnnotation(result, attr2, annotation);
+ }
}
}
@@ -142,19 +149,22 @@
if (isEntity(attrType)) {
attrType += "DTO";
}
- attr2 = addAttribute(result, GeneratorUtil.toLowerCaseFirstLetter(attrName), attrType, null, modifier);
+ addAttribute(result, GeneratorUtil.toLowerCaseFirstLetter(attrName), attrType, null, modifier);
}
}
}
addAttribute(result,"p", PropertyChangeSupport.class,"new PropertyChangeSupport(this)",ObjectModelModifier.PROTECTED,ObjectModelModifier.FINAL);
+ }
+ protected void addOperations(ObjectModelClass result,ObjectModelClass clazz) {
+
ObjectModelOperation op;
op = addOperation(result, "addPropertyChangeListener", "void");
addParameter(op,PropertyChangeListener.class,"listener");
setOperationBody(op,""
/*{
- p.addPropertyChangeListener(listener);
+ p.addPropertyChangeListener(listener);
}*/
);
@@ -163,7 +173,7 @@
addParameter(op, PropertyChangeListener.class, "listener");
setOperationBody(op, ""
/*{
- p.addPropertyChangeListener(propertyName, listener);
+ p.addPropertyChangeListener(propertyName, listener);
}*/
);
@@ -191,7 +201,7 @@
if (!(attr.isNavigable() || hasUnidirectionalRelationOnAbstractType(reverse, model))) {
continue;
}
-
+
String attrName = attr.getName();
if (!attr.hasAssociationClass()) {
@@ -208,7 +218,7 @@
<%=attrType%> oldValue = this.<%=attrName%>;
this.<%=attrName%> = value;
p.firePropertyChange("<%=attrName%>", oldValue, value);
- }*/
+ }*/
);
op = addOperation(result, "get" + capitalizedAttrName, attrType, ObjectModelModifier.PUBLIC);
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/InterfaceTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/InterfaceTransformer.java 2009-12-20 16:29:38 UTC (rev 1732)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/InterfaceTransformer.java 2009-12-20 18:41:57 UTC (rev 1733)
@@ -57,6 +57,11 @@
ObjectModelInterface resultInterface = createInterface(interfacez.getName(), interfacez.getPackageName());
+ if (log.isDebugEnabled()) {
+ log.debug("will create model for "+resultInterface.getQualifiedName());
+ }
+
+
// extend interface
Iterator<ObjectModelInterface> it = interfacez.getInterfaces().iterator();
if (it.hasNext()) {
1
0
r1732 - in trunk: topia-persistence topia-persistence/src/main/java/org/nuiton/topia/generator topia-service-history topia-service-migration topia-service-security topia-soa/src/main/java/org/nuiton/topia/generator topia-soa/src/main/java/org/nuiton/topia/service/servers
by tchemit@users.nuiton.org 20 Dec '09
by tchemit@users.nuiton.org 20 Dec '09
20 Dec '09
Author: tchemit
Date: 2009-12-20 17:29:38 +0100 (Sun, 20 Dec 2009)
New Revision: 1732
Added:
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaTransformer.java
Modified:
trunk/topia-persistence/pom.xml
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/BeanGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOImplGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityAbstractGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDTOGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityImplGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityInterfaceGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/InterfaceGenerator.java
trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaGenerator.java
trunk/topia-service-history/pom.xml
trunk/topia-service-migration/pom.xml
trunk/topia-service-security/pom.xml
trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceAbstractGenerator.java
trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceImplGenerator.java
trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceInterfaceGenerator.java
trunk/topia-soa/src/main/java/org/nuiton/topia/generator/TopiaApplicationServiceMetaGenerator.java
trunk/topia-soa/src/main/java/org/nuiton/topia/service/servers/XMLRPCServer.java
Log:
- use cleaned eugene api : everything which is not neutral can not be on org.nuiton.eugene package (go to models.object or models.state)
- remove deprecated code, clean code in soa module
- introduce TopiaMetaTransformer using AbstractMetaTransformer api from eugene and use it
Modified: trunk/topia-persistence/pom.xml
===================================================================
--- trunk/topia-persistence/pom.xml 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/pom.xml 2009-12-20 16:29:38 UTC (rev 1732)
@@ -156,7 +156,7 @@
<phase>generate-test-sources</phase>
<configuration>
<testPhase>true</testPhase>
- <templates>org.nuiton.topia.generator.TopiaMetaGenerator,
+ <templates>org.nuiton.topia.generator.TopiaMetaTransformer,
org.nuiton.topia.generator.InterfaceTransformer,
org.nuiton.topia.generator.BeanTransformer,
org.nuiton.topia.generator.EntityDTOTransformer
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/BeanGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/BeanGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/BeanGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -50,7 +50,7 @@
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.GeneratorUtil;
import org.nuiton.eugene.ImportsManager;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOAbstractGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -46,7 +46,7 @@
import org.apache.commons.lang.StringUtils;
import org.nuiton.eugene.GeneratorUtil;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
import org.nuiton.eugene.models.object.ObjectModelClass;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -38,7 +38,7 @@
import java.io.IOException;
import java.io.Writer;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModelClass;
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -43,8 +43,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.GeneratorUtil;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModel;
import org.nuiton.eugene.models.object.ObjectModelClass;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOHelperTransformer.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -22,7 +22,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelType;
+import org.nuiton.eugene.models.object.ObjectModelType;
import org.nuiton.eugene.Template;
import org.nuiton.eugene.java.ObjectModelTransformerToJava;
import org.nuiton.eugene.models.object.*;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOImplGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOImplGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DAOImplGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -38,7 +38,7 @@
import java.io.IOException;
import java.io.Writer;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModelClass;
import org.nuiton.eugene.models.object.ObjectModelOperation;
/**
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/DTOGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -43,7 +43,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.GeneratorUtil;
import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityAbstractGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityAbstractGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityAbstractGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -37,7 +37,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.GeneratorUtil;
import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDTOGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDTOGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityDTOGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -34,6 +34,7 @@
package org.nuiton.topia.generator;
+import org.nuiton.eugene.models.object.*;
import static org.nuiton.topia.generator.TopiaGeneratorUtil.TAG_ANNOTATION;
import static org.nuiton.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
@@ -44,12 +45,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.GeneratorUtil;
-import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelClassifier;
// do not remove me
import org.apache.commons.lang.StringUtils;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityHibernateMappingGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -38,7 +38,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.GeneratorUtil;
import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityImplGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityImplGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityImplGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -39,7 +39,7 @@
import java.io.Writer;
import java.util.Collection;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModelClass;
import org.nuiton.eugene.models.object.ObjectModelOperation;
import org.apache.commons.logging.Log;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityInterfaceGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityInterfaceGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityInterfaceGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -36,7 +36,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.GeneratorUtil;
import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/InterfaceGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/InterfaceGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/InterfaceGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -37,12 +37,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelClassifier;
-import org.nuiton.eugene.models.object.ObjectModelInterface;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-import org.nuiton.eugene.models.object.ObjectModelParameter;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.*;
import java.io.File;
import java.io.IOException;
Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaGenerator.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -35,7 +35,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.eugene.AbstractGenerator;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.Template;
import org.nuiton.eugene.Transformer;
import org.nuiton.eugene.models.object.ObjectModel;
@@ -47,6 +47,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import org.nuiton.eugene.models.object.ObjectModelClass;
@@ -55,34 +56,26 @@
* Il repercute la generation de code sur chacun des generateurs de ToPIA en se
* positionnant en tant que parent de ces generateurs.
* @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.topia.generator.TopiaMetaGenerator"
+ * @deprecated since 2.3.0, prefer use the corresponding {@link Transformer} : {@link TopiaMetaTransformer}.
*/
+@Deprecated
public class TopiaMetaGenerator extends ObjectModelGenerator {
protected static Log log = LogFactory.getLog(TopiaMetaGenerator.class);
-
+
/**
* la liste des generateurs par defaut a utiliser
*/
- protected static final List<Class<? extends Template<ObjectModel>>> DEFAULT_GENERATORS = java.util.Collections
+ protected static final List<Class<? extends ObjectModelGenerator>> DEFAULT_GENERATORS = Collections
.unmodifiableList(Arrays.asList(
-
-// EntityInterfaceGenerator.class,
- EntityInterfaceTransformer.class,
-// EntityAbstractGenerator.class,
- EntityAbstractTransformer.class,
- EntityImplTransformer.class,
-// EntityImplGenerator.class,
+ EntityInterfaceGenerator.class,
+ EntityAbstractGenerator.class,
+ EntityImplGenerator.class,
EntityHibernateMappingGenerator.class,
-
- DAOTransformer.class,
- DAOImplTransformer.class,
- DAOAbstractTransformer.class,
- DAOHelperTransformer.class
-// DAOGenerator.class,
-// DAOImplGenerator.class,
-// DAOAbstractGenerator.class,
-
-// DAOHelperGenerator.class)
+ DAOGenerator.class,
+ DAOImplGenerator.class,
+ DAOAbstractGenerator.class,
+ DAOHelperGenerator.class
));
protected boolean validateModel(ObjectModel model) {
@@ -140,7 +133,7 @@
log.warn("no entity to generate, " + getClass().getName() + " is skipped");
return;
}
-
+
generatePersistence(model, destDir);
}
@@ -158,7 +151,7 @@
generator = generatorClass.newInstance();
// init generator
-
+
if (generator instanceof AbstractGenerator) {
((AbstractGenerator<ObjectModel>)generator).setParent(this);
}
@@ -172,7 +165,7 @@
}
throw new RuntimeException(e);
}
-
+
// log
if(log.isDebugEnabled()) {
log.debug("call template : " + generatorClass.getSimpleName());
Added: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaTransformer.java
===================================================================
--- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaTransformer.java (rev 0)
+++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaTransformer.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -0,0 +1,94 @@
+package org.nuiton.topia.generator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.eugene.AbstractMetaTransformer;
+import org.nuiton.eugene.models.object.ObjectModel;
+import org.nuiton.eugene.models.object.ObjectModelClass;
+import org.nuiton.eugene.models.object.validator.AttributeNamesValidator;
+import org.nuiton.eugene.models.object.validator.ClassNamesValidator;
+import org.nuiton.eugene.models.object.validator.ObjectModelValidator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created: 20 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ * @plexus.component role="org.nuiton.eugene.Template" role-hint="org.nuiton.topia.generator.TopiaMetaTransformer"
+ */
+public class TopiaMetaTransformer extends AbstractMetaTransformer<ObjectModel> {
+
+ /**
+ * Logger
+ */
+ private static final Log log = LogFactory.getLog(TopiaMetaTransformer.class);
+
+ public TopiaMetaTransformer() {
+ super(
+ EntityInterfaceTransformer.class,
+ EntityAbstractTransformer.class,
+ EntityImplTransformer.class,
+ DAOTransformer.class,
+ DAOImplTransformer.class,
+ DAOAbstractTransformer.class,
+ DAOHelperTransformer.class,
+ EntityHibernateMappingGenerator.class
+ );
+ }
+
+ protected boolean validateModel(ObjectModel model) {
+ List<ObjectModelValidator> validators = new ArrayList<ObjectModelValidator>();
+
+ AttributeNamesValidator attrValidator = new AttributeNamesValidator(
+ model);
+ attrValidator.addNameAndReason("next",
+ "Le nom d'attribut \"next\" est incompatible avec HSQL");
+ attrValidator.addNameAndReason("value",
+ "Le nom d'attribut \"value\" est incompatible avec certains SGBD");
+ attrValidator.addNameAndReason("values",
+ "Le nom d'attribut \"values\" est incompatible avec certains SGBD");
+ attrValidator.addNameAndReason("begin",
+ "Le nom d'attribut \"begin\" est incompatible avec certains SGBD");
+ attrValidator.addNameAndReason("end",
+ "Le nom d'attribut \"end\" est incompatible avec certains SGBD");
+ attrValidator.addNameAndReason("authorization",
+ "Le nom d'attribut \"authorization\" est incompatible avec certains SGBD");
+ attrValidator.addNameAndReason("order",
+ "Le nom d'attribut \"order\" est incompatible avec certains SGBD");
+ validators.add(attrValidator);
+
+ ClassNamesValidator classValidator = new ClassNamesValidator(model);
+ classValidator.addNameAndReason("constraint", "Nom de classe incompatible avec certains SGBD");
+ classValidator.addNameAndReason("user", "Nom de classe incompatible avec certains SGBD");
+ validators.add(classValidator);
+
+ validators.add(new TopiaJavaValidator(model));
+ validators.add(new TopiaRelationValidator(model));
+
+ for (ObjectModelValidator validator : validators) {
+ if (!validator.validate()) {
+ for (String error : validator.getErrors()) {
+ log.info("[VALIDATION] " + error);
+ }
+ }
+ }
+
+ // test before all if there is some entities to generate
+ List<ObjectModelClass> classes = TopiaGeneratorUtil.getEntityClasses(model, true);
+
+ if (classes.isEmpty()) {
+ // no entity to generate, can stop safely
+ log.warn("No entity to generate, " + getClass().getName() + " is skipped");
+ return false;
+ }
+ //FIXME-TC20091220 seems we still generate if there is some validation errors ? not very normal
+ return true;
+ }
+
+}
Property changes on: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/TopiaMetaTransformer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/topia-service-history/pom.xml
===================================================================
--- trunk/topia-service-history/pom.xml 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-service-history/pom.xml 2009-12-20 16:29:38 UTC (rev 1732)
@@ -98,12 +98,12 @@
<phase>generate-sources</phase>
<id>generate-sources</id>
<configuration>
- <templates>org.nuiton.topia.generator.TopiaMetaGenerator</templates>
+ <templates>org.nuiton.topia.generator.TopiaMetaTransformer</templates>
<defaultPackage>org.nuiton.topia</defaultPackage>
<fullPackagePath>org.nuiton.topia</fullPackagePath>
<includes>**/*.objectmodel</includes>
- <copyVersionDir>${maven.src.dir}/main/resources/oldmappings/%MODELNAME%</copyVersionDir>
+ <copyVersionDir>${project.basedir}/src/main/resources/oldmappings/%MODELNAME%</copyVersionDir>
<copyVersionFiles>**/*.hbm.xml</copyVersionFiles>
<overwrite>true</overwrite>
</configuration>
Modified: trunk/topia-service-migration/pom.xml
===================================================================
--- trunk/topia-service-migration/pom.xml 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-service-migration/pom.xml 2009-12-20 16:29:38 UTC (rev 1732)
@@ -104,7 +104,7 @@
<id>Migration service generator</id>
<phase>generate-sources</phase>
<configuration>
- <templates>org.nuiton.topia.generator.TopiaMetaGenerator</templates>
+ <templates>org.nuiton.topia.generator.TopiaMetaTransformer</templates>
<fullPackagePath>org.nuiton.topia.migration</fullPackagePath>
<defaultPackage>org.nuiton.topia.migration</defaultPackage>
</configuration>
Modified: trunk/topia-service-security/pom.xml
===================================================================
--- trunk/topia-service-security/pom.xml 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-service-security/pom.xml 2009-12-20 16:29:38 UTC (rev 1732)
@@ -94,7 +94,7 @@
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
- <templates>org.nuiton.topia.generator.TopiaMetaGenerator</templates>
+ <templates>org.nuiton.topia.generator.TopiaMetaTransformer</templates>
<defaultPackage>org.nuiton.topia</defaultPackage>
<fullPackagePath>org.nuiton.topia</fullPackagePath>
Modified: trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceAbstractGenerator.java
===================================================================
--- trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceAbstractGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceAbstractGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -18,6 +18,7 @@
* ##%*/
package org.nuiton.topia.generator;
+import org.nuiton.eugene.models.object.*;
import static org.nuiton.topia.generator.TopiaGeneratorUtil.hasUnidirectionalRelationOnAbstractType;
import java.io.File;
@@ -29,20 +30,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.GeneratorUtil;
-import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
-import org.nuiton.eugene.models.object.ObjectModelAttribute;
-import org.nuiton.eugene.models.object.ObjectModelClass;
-import org.nuiton.eugene.models.object.ObjectModelClassifier;
-import org.nuiton.eugene.models.object.ObjectModelInterface;
-import org.nuiton.eugene.models.object.ObjectModelOperation;
-import org.nuiton.eugene.models.object.ObjectModelParameter;
import org.nuiton.topia.service.TopiaApplicationServiceAbstract;
-
-// do not remove
import org.apache.commons.lang.StringUtils;
+
/**
* ServiceAbstractGenerator.java
*
@@ -182,7 +175,7 @@
comma = ", ";
}
/*{)}*/
- Set<String> exceptions = (Set<String>)op.getExceptions();
+ Set<String> exceptions = op.getExceptions();
comma = " throws ";
for (String exception : exceptions) {
/*{<%=comma%><%=exception%>}*/
@@ -307,7 +300,7 @@
* @param v la valeur que doit avoir <%=attr.getName()%>
* @return un element ou null
*)
- public <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
+ public <%=clazzFQN%> find<%=clazzName%>By<%=StringUtils.capitalize(attr.getName())%>(<%=attr.getType()%> v) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
<%=clazzName%> entity = dao.findBy<%=StringUtils.capitalize(attr.getName())%>(v);
@@ -397,7 +390,7 @@
if(parent.hasStereotype(TopiaGeneratorUtil.STEREOTYPE_DAO)){
// r�cup�rer la classe de l'object model correspondant � la DAO
- String entityClassName = null;
+ String entityClassName;
entityClassName = parent.getQualifiedName().replace("DAO", "");
if(getModel().hasClass(entityClassName)){
ObjectModelClass clazz = getModel().getClass(entityClassName);
@@ -417,6 +410,7 @@
for (ObjectModelAttribute attr : clazz.getAttributes()) {
ObjectModelAttribute reverse = attr.getReverseAttribute();
+ String capitalizedAttrName = StringUtils.capitalize(attr.getName());
if (!attr.isNavigable()
&& !hasUnidirectionalRelationOnAbstractType(reverse, model)) {
continue;
@@ -429,9 +423,9 @@
/*{ * <%=attr.getName()%> : <%=attr.getDocumentation()%>
}*/
}
-/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> � positionner.
+/*{ * @param <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%> La valeur de l'attribut <%=attr.getName()%> a positionner.
*)
- public void set<%=StringUtils.capitalize(attr.getName())%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
+ public void set<%=capitalizedAttrName%>Of<%=clazzName%>(String topiaId, <%=attr.getType()%> <%=GeneratorUtil.toLowerCaseFirstLetter(attr.getName())%>) throws TopiaException{
TopiaContextImplementor usedContextImpl = (TopiaContextImplementor) topiaContext;
<%=clazzName%>DAOAbstract dao = (<%=clazzName%>DAOAbstract)usedContextImpl.getDAO(<%=clazzName%>.class);
<%=clazzName%> entity = (<%=clazzName%>)dao.findByTopiaId(topiaId);
Modified: trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceImplGenerator.java
===================================================================
--- trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceImplGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceImplGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -26,7 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModelClass;
import org.nuiton.eugene.models.object.ObjectModelClassifier;
import org.nuiton.eugene.models.object.ObjectModelInterface;
Modified: trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceInterfaceGenerator.java
===================================================================
--- trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceInterfaceGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-soa/src/main/java/org/nuiton/topia/generator/ServiceInterfaceGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -34,7 +34,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.eugene.GeneratorUtil;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModelAssociationClass;
import org.nuiton.eugene.models.object.ObjectModelAttribute;
import org.nuiton.eugene.models.object.ObjectModelClass;
@@ -332,8 +332,8 @@
}
// ajouter les methodes à la liste
- methods.add(clazzName+" find"+clazzName+"By"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" v)");
- methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" v)");
+ methods.add(clazzName+" find"+clazzName+"By"+StringUtils.capitalize(attrName)+"("+attrType+" v)");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+StringUtils.capitalize(attrName)+"("+attrType+" v)");
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
@@ -341,20 +341,20 @@
* @param v la valeur que doit avoir <%=attrName%>
* @return un element ou null
*)
- public abstract <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>By<%=StringUtils.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException;
/**
* Retourne les éléments ayant comme valeur pour l'attribut
* <%=attrName%> le paramêtre
* @param v la valeur que doit avoir <%=attrName%>
* @return une liste
*)
- public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=StringUtils.capitalize(attrName)%>(<%=attrType%> v) throws TopiaException;
}*/
if (attr.hasAssociationClass()) {
String assocClassName = attr.getAssociationClass().getName();
String assocClassFQN = attr.getAssociationClass().getQualifiedName();
- methods.add(clazzName +" find"+clazzName+"By"+TopiaGeneratorUtil.capitalize(assocClassName)+"("+assocClassFQN+" value)");
- methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+TopiaGeneratorUtil.capitalize(assocClassName)+"("+assocClassFQN+" value)");
+ methods.add(clazzName +" find"+clazzName+"By"+StringUtils.capitalize(assocClassName)+"("+assocClassFQN+" value)");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"By"+StringUtils.capitalize(assocClassName)+"("+assocClassFQN+" value)");
/*{
/**
* Retourne le premier element trouve ayant comme valeur pour l'attribut
@@ -362,14 +362,14 @@
* @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>
* @return un element ou null
*)
- public abstract <%=clazzFQN%> find<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>By<%=StringUtils.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException;
/**
* Retourne les éléments ayant comme valeur pour l'attribut
* <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%> le paramêtre
* @param value la valeur que doit avoir <%=TopiaGeneratorUtil.toLowerCaseFirstLetter(assocClassName)%>
* @return une liste
*)
- public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=TopiaGeneratorUtil.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>By<%=StringUtils.capitalize(assocClassName)%>(<%=assocClassFQN%> value) throws TopiaException;
}*/
}
}
@@ -379,8 +379,8 @@
String attrType = attr.getType();
String clazzName = clazz.getName();
String clazzFQN = clazz.getQualifiedName();
- methods.add(clazzName + " find"+clazzName+"Contains"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" ... v)");
- methods.add("List<"+clazzName+"> findAll"+clazzName+"Contains"+TopiaGeneratorUtil.capitalize(attrName)+"("+attrType+" ... v)");
+ methods.add(clazzName + " find"+clazzName+"Contains"+StringUtils.capitalize(attrName)+"("+attrType+" ... v)");
+ methods.add("List<"+clazzName+"> findAll"+clazzName+"Contains"+StringUtils.capitalize(attrName)+"("+attrType+" ... v)");
/*{
/**
* Retourne le premier element trouve dont l'attribut
@@ -388,14 +388,14 @@
* @param v la valeur que doit contenir <%=attrName%>
* @return un element ou null
*)
- public abstract <%=clazzFQN%> find<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException;
+ public abstract <%=clazzFQN%> find<%=clazzName%>Contains<%=StringUtils.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException;
/**
* Retourne les elements trouve dont l'attribut
* <%=attrName%> contient le parametre
* @param v la valeur que doit contenir <%=attrName%>
* @return une liste
*)
- public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>Contains<%=TopiaGeneratorUtil.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException;
+ public abstract List<<%=clazzFQN%>> findAll<%=clazzName%>Contains<%=StringUtils.capitalize(attrName)%>(<%=attrType%> ... v) throws TopiaException;
}*/
}
Modified: trunk/topia-soa/src/main/java/org/nuiton/topia/generator/TopiaApplicationServiceMetaGenerator.java
===================================================================
--- trunk/topia-soa/src/main/java/org/nuiton/topia/generator/TopiaApplicationServiceMetaGenerator.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-soa/src/main/java/org/nuiton/topia/generator/TopiaApplicationServiceMetaGenerator.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -21,7 +21,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.nuiton.eugene.ObjectModelGenerator;
+import org.nuiton.eugene.models.object.ObjectModelGenerator;
import org.nuiton.eugene.models.object.ObjectModel;
import java.io.File;
Modified: trunk/topia-soa/src/main/java/org/nuiton/topia/service/servers/XMLRPCServer.java
===================================================================
--- trunk/topia-soa/src/main/java/org/nuiton/topia/service/servers/XMLRPCServer.java 2009-12-19 18:09:15 UTC (rev 1731)
+++ trunk/topia-soa/src/main/java/org/nuiton/topia/service/servers/XMLRPCServer.java 2009-12-20 16:29:38 UTC (rev 1732)
@@ -173,7 +173,7 @@
* Construit et retourne une map de "maps entité", clé : TopiaId de
* l'entité, valeur : Map de l'entité
*
- * @see #entityToMap(E entity)
+ * @see #entityToMap(org.nuiton.topia.persistence.TopiaEntity)
* @param <E>
* la classe étendant TopiaEntity
* @param list
@@ -183,7 +183,7 @@
*/
private <E extends TopiaEntity> Map listToMap(List<E> list) {
// construire la map contenant les entités
- // cl� TopiaId, valeur :Map des attributs de l'entité
+ // cle TopiaId, valeur :Map des attributs de l'entité
Map<String, Map<String, Object>> resultMap = new HashMap<String, Map<String, Object>>();
for (E entity : list) {
// ajouter la map de l'entité
@@ -206,20 +206,20 @@
*/
private <E extends TopiaEntity> Map entityToMap(E entity) {
Map<String, Object> entityMap = new HashMap<String, Object>();
- // invoquer tous les getters pour construire la map de l'entit�
+ // invoquer tous les getters pour construire la map de l'entite
for (Method m : entity.getClass().getMethods()) {
if (m.getName().startsWith("get")) {
logger.info("* method " + m);
String attributeName = m.getName().replace("get", "");
try {
- Object o = m.invoke(entity, null);
- if (o instanceof String && !((String) o).equals("")) {
+ Object o = m.invoke(entity);
+ if (o instanceof String && !o.equals("")) {
// nom de l'attribut : valeur
- entityMap.put(attributeName, (String) o);
+ entityMap.put(attributeName, o);
} else if (o instanceof Date && o != null) {
// nom de l'attribut : date
- entityMap.put(attributeName, ((Date) o).toString());
+ entityMap.put(attributeName, o.toString());
} else if (o instanceof TopiaEntity && o != null) {
// nom de l'attribut : TopiaId
1
0