r1884 - in trunk: . topia-persistence/src/main/java/org/nuiton/topia/framework topia-persistence/src/main/java/org/nuiton/topia/generator
Author: fdesbois Date: 2010-04-08 11:30:09 +0200 (Thu, 08 Apr 2010) New Revision: 1884 Log: - Ano #470: [ServiceTransformer] problem with multiple methods with same name - Evo #473: [TopiaQuery] Add method to easily concat entity properties - Use nuiton-utils and eugene snapshots Modified: trunk/pom.xml trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-04-06 13:01:43 UTC (rev 1883) +++ trunk/pom.xml 2010-04-08 09:30:09 UTC (rev 1884) @@ -192,8 +192,8 @@ <projectId>topia</projectId> <!-- libs version --> - <eugene.version>2.0</eugene.version> - <lutinutil.version>1.2.1</lutinutil.version> + <eugene.version>2.0.1-SNAPSHOT</eugene.version> + <lutinutil.version>1.2.2-SNAPSHOT</lutinutil.version> <processor.version>1.0.3</processor.version> <i18n.version>1.2.1</i18n.version> <xmlrpc.version>3.1.2</xmlrpc.version> Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java 2010-04-06 13:01:43 UTC (rev 1883) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/framework/TopiaQuery.java 2010-04-08 09:30:09 UTC (rev 1884) @@ -38,6 +38,7 @@ import org.nuiton.topia.TopiaException; import org.nuiton.topia.persistence.TopiaDAO; import org.nuiton.topia.persistence.TopiaEntity; +import org.nuiton.util.StringUtil; /** * Query HQL managment to simplify usage of @@ -1361,4 +1362,25 @@ groupBy = null; } + /** + * This method is used to concat properties from entities. Ex in HQL you + * can have boat.shipOwner.name, these properties are defined as constants + * in each entity associated (SHIP_OWNER in Boat entity, NAME in ShipOwner + * entity) so you just have to call this method as : + * getProperty("boat", Boat.SHIP_OWNER, ShipOwner.NAME); to have the + * correct property to use : boat.shipOwner.name. It's better to use + * constants instead of directly the string chain to avoid problems on + * changing property name in model. Furthermore it's better to use this + * method instead of doing : + * "boat." + Boat.SHIP_OWNER + "." + ShipOwner.NAME + * + * @param entityProperty to concat + * @return the string chain with properties separated with a dot + */ + public static String getProperty(String... entityProperty) { + List<String> list = Arrays.asList(entityProperty); + String result = StringUtil.join(list, ".", false); + return result; + } + } Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2010-04-06 13:01:43 UTC (rev 1883) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2010-04-08 09:30:09 UTC (rev 1884) @@ -332,7 +332,7 @@ createOperationExecuteAbstract(serviceAbstract, op); // Keep abstract methods to use them in operationImplementation // generation - abstOps.put(op.getName(), abstOp); + abstOps.put(getAbstractOperationKeyMap(op), abstOp); } // Imports for implementations @@ -343,12 +343,28 @@ // Create abstract execute methods for (ObjectModelOperation op : source.getOperations()) { - createOperationImplementation(serviceAbstract, - abstOps.get(op.getName()), op, source.getName()); + createOperationImplementation( + serviceAbstract, + abstOps.get(getAbstractOperationKeyMap(op)), + op, + source.getName()); } } /** + * Create a key for the abstractOperations map from {@code op}. Concat + * opName + params as String. + * + * @param op used as reference to construct the keyMap + * @return the keyMap + */ + protected String getAbstractOperationKeyMap(ObjectModelOperation op) { + String key = op.getName() + + GeneratorUtil.getOperationParametersListName(op); + return key; + } + + /** * Create an operation abstract to execute in contract implementation. * You can use tagvalues "errorArgs" (default = false) and "transaction" * (default = true) to generate appropriate parameters. This abstract @@ -450,12 +466,13 @@ // Abstract operation parameters String abstName = abstOp.getName(); - String abstParams = ""; - String separator = ""; - for (ObjectModelParameter param : abstOp.getParameters()) { - abstParams += separator + param.getName(); - separator = ", "; - } + String abstParams = + GeneratorUtil.getOperationParametersListName(abstOp); +// String separator = ""; +// for (ObjectModelParameter param : abstOp.getParameters()) { +// abstParams += separator + param.getName(); +// separator = ", "; +// } // Abstract operation return managment String abstReturnType = "";
Le Thu, 8 Apr 2010 11:30:09 +0200 (CEST), fdesbois@users.nuiton.org a écrit :
String abstParams
t'aime vraiment bien les noms qui veulent rien dire :) De manière générale, en Java on essaye toujours de mettre des noms complets,pas d'acronymes, abréviations ou autre choses... Cela rends le code beaucoup plus lisible et ne force pas le lecteur du code à décrypter les noms de variables ou méthodes ou classes Donc j'aurais préféré abstractParameters :) -- Tony Chemit -------------------- tél: +33 (0) 2 40 50 29 28 email: chemit@codelutin.com http://www.codelutin.com
+1 Julien Le Thu, 8 Apr 2010 11:44:39 +0200, Tony Chemit <chemit@codelutin.com> a écrit :
Le Thu, 8 Apr 2010 11:30:09 +0200 (CEST), fdesbois@users.nuiton.org a écrit :
String abstParams
t'aime vraiment bien les noms qui veulent rien dire :)
De manière générale, en Java on essaye toujours de mettre des noms complets,pas d'acronymes, abréviations ou autre choses... Cela rends le code beaucoup plus lisible et ne force pas le lecteur du code à décrypter les noms de variables ou méthodes ou classes
Donc j'aurais préféré abstractParameters :)
participants (3)
-
fdesbois@users.nuiton.org -
Julien Ruchaud -
Tony Chemit