Author: fdesbois Date: 2010-06-27 16:12:49 +0200 (Sun, 27 Jun 2010) New Revision: 2040 Url: http://nuiton.org/repositories/revision/topia/2040 Log: Evo #609 : Clean last refactors Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java 2010-06-27 14:01:18 UTC (rev 2039) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java 2010-06-27 14:12:49 UTC (rev 2040) @@ -133,7 +133,13 @@ // Create Entity Abstract class and its header createEntityAbstractClass(input); - // Create accept operation, will be updated during attribute route + // Generate i18n block + String i18nPrefix = TopiaGeneratorUtil.getI18nPrefix(input, model); + if (!StringUtils.isEmpty(i18nPrefix)) { + generateI18nBlock(input, i18nPrefix); + } + + // Create accept operation, will be updated during property generation createAcceptOperation(); // Add constant, attribute and operations for each property @@ -150,20 +156,23 @@ closeAcceptOperation(); - // Add util operations : accept, aggregate, composite, toString, i18n block - generateUtilOperations(input); - // Add extra constants (from uml dependency) generateExtraConstants(input); // Add extra operations (defined on the entity) generateExtraOperations(input); - boolean generateImpl = isGenerateImpl(input, input.getOperations()); + // Implement aggregate and composite operations + generateAggregateOperation(input); + generateCompositeOperation(input); - if (generateImpl) { + // Implement toString operation + if (TopiaGeneratorUtil.generateToString(input, model)) { + generateToStringOperation(input); + } - // generate impl + // Generate Entity Implementation class + if (isGenerateImpl(input, input.getOperations())) { generateImpl(input); } @@ -313,17 +322,6 @@ setSuperClass(outputImpl, input.getQualifiedName() + "Abstract"); } - protected void generateUtilOperations(ObjectModelClass input) { - - generateI18nBlock(input); - - generateAggregateMethod(input); - - generateCompositeMethod(input); - - generateToStringMethod(input); - } - /** * Generate extra constants if {@code input} has dependencies on * enum used as constant injector. @@ -1247,12 +1245,8 @@ setOperationBody(operation, body.length() == 0 ? " " : body.toString()); } - protected void generateToStringMethod(ObjectModelClass input) { + protected void generateToStringOperation(ObjectModelClass input) { - if (!TopiaGeneratorUtil.generateToString(input, model)) { - return; - } - if (log.isDebugEnabled()) { log.debug("generate toString method for entity " + outputInterface.getQualifiedName()); @@ -1301,7 +1295,7 @@ } - protected void generateCompositeMethod(ObjectModelClass input) { + protected void generateCompositeOperation(ObjectModelClass input) { ObjectModelOperation operation = addOperation(outputAbstract, "getComposite", @@ -1407,7 +1401,7 @@ setOperationBody(operation, body.length() == 0 ? " " : body.toString()); } - protected void generateAggregateMethod(ObjectModelClass input) { + protected void generateAggregateOperation(ObjectModelClass input) { ObjectModelOperation operation = addOperation(outputAbstract, "getAggregate", @@ -1465,13 +1459,8 @@ setOperationBody(operation, body.length() == 0 ? " " : body.toString()); } - protected void generateI18nBlock(ObjectModelClass input) { + protected void generateI18nBlock(ObjectModelClass input, String i18nPrefix) { - String i18nPrefix = TopiaGeneratorUtil.getI18nPrefix(input, model); - if (StringUtils.isEmpty(i18nPrefix)) { - return; - } - ObjectModelOperation block = addBlock(outputAbstract, ObjectModelModifier.STATIC);