Index: topia/src/java/org/codelutin/topia/generators/Util.java diff -u topia/src/java/org/codelutin/topia/generators/Util.java:1.3 topia/src/java/org/codelutin/topia/generators/Util.java:1.4 --- topia/src/java/org/codelutin/topia/generators/Util.java:1.3 Wed Jun 30 12:31:53 2004 +++ topia/src/java/org/codelutin/topia/generators/Util.java Thu Jul 15 13:13:12 2004 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * - * Mise a jour: $Date: 2004/06/30 12:31:53 $ + * Mise a jour: $Date: 2004/07/15 13:13:12 $ * par : $Author: bpoussin $ */ @@ -42,6 +42,7 @@ import org.codelutin.generator.models.object.ObjectModelInterface; import org.codelutin.generator.models.object.ObjectModelOperation; import java.util.List; +import java.util.LinkedList; /** * Classe contenant des methodes utiles pour la generation @@ -147,155 +148,21 @@ } /** - * @return vrai si la classe on une super classe a des operations de - * defini. + * Retourne vrai si l'operation passé en parametre est aussi une operation + * genere par le framework */ - public static boolean hasOperation(ObjectModelClassifier clazz){ - boolean result = false; - if(clazz.getOperations().size() != 0){ - return true; + public static boolean isGeneratedOperation(ObjectModelClassifier clazzifier, ObjectModelOperation operation){ + if(!(clazzifier instanceof ObjectModelClass)){ + return false; } - if(clazz.getInterfaces().size() != 0){ - for(Iterator i=clazz.getInterfaces().iterator(); i.hasNext();){ - if(hasOperation((ObjectModelClassifier)i.next())){ - return true; - } - } - } - if(clazz instanceof ObjectModelClass && - ((ObjectModelClass)clazz).getSuperclasses().size() != 0){ - for(Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); i.hasNext();){ - if(hasOperation((ObjectModelClassifier)i.next())){ - return true; - } - } - } - return false; - } - -// /** -// * Une class est abtraite si elle a des operations abtraite ou qu'elle -// * implante des interfaces qui ont des operations ou qu'elle etend une -// * classe qui a des operations ou des interfaces qui ont des operations. -// * Mais sans implanter elle meme ces operations -// */ -// public static boolean hasAbstractOperation(ObjectModelClass clazz){ -// for(Iterator i=clazz.getOperations().iterator(); i.hasNext();){ -// ObjectModelOperation operation = (ObjectModelOperation)i.next(); -// if(operation.isAbstract()){ -// return true; -// } -// } -// for(Iterator i=clazz.getSuperclasses().iterator(); i.hasNext();){ -// ObjectModelClass parentClazz = (ObjectModelClass)i.next(); -// if(hasAbstractOperation(parentClazz)){ -// return true; -// } -// } -// for(Iterator i=clazz.getInterfaces().iterator(); i.hasNext();){ -// ObjectModelInterface interfacez = (ObjectModelInterface)i.next(); -// if(hasOperation(interfacez)){ -// return true; -// } -// } -// return false; -// } - - /** - * Donne la liste de toutes les operations abstraites definies sur la - * classe, ceci comprend les operations definie sur les interfaces ou - * superclass qu'elle etend. - */ - public static List getAbstractOperationList(ObjectModelClassifier clazz){ - List result = new ArrayList(); - getAbstractOperationList(clazz, result); - return result; - } - /** - * Donne la liste de toutes les operations abstraites definies sur la - * classe, ceci comprend les operations definie sur les interfaces ou - * superclass qu'elle etend. - * @param clazz la classe sur lequel il faut chercher les operations - * @param result un objet liste instancier qui sert a mettre les operations - * trouvées - */ - protected static void getAbstractOperationList(ObjectModelClassifier clazz, List result){ - for(Iterator i=clazz.getOperations().iterator(); i.hasNext();){ - ObjectModelOperation operation = (ObjectModelOperation)i.next(); - if(clazz instanceof ObjectModelInterface || operation.isAbstract()){ - result.add(operation); - } - } - if(clazz instanceof ObjectModelClass){ - for(Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); i.hasNext();){ - ObjectModelClass parentClazz = (ObjectModelClass)i.next(); - getAbstractOperationList(parentClazz, result); - } - } - for(Iterator i=clazz.getInterfaces().iterator(); i.hasNext();){ - ObjectModelInterface interfacez = (ObjectModelInterface)i.next(); - getAbstractOperationList(interfacez, result); - } - } - + ObjectModelClass clazz = (ObjectModelClass)clazzifier; - /** - *

Methode qui retourne vrai si la classe ou la super classe n'implantent - * pas toutes les methodes des interfaces ou bien si elle contient des - * operations abstraites.

- *

La classe peut implanter une operation soit parce qu'elle a aussi - * l'operation de defini et marquee non abstraite, soit parce que sa - * superclasse implante l'operation, soit parce qu'elle ou sa super classe - * implantent l'operation par la generation des methodes d'acces au - * attributs.

- *

ATTENTION: une methode non abstraite dans une superclasse ne peut pas - * devenir abstraite dans une classe enfant.

- */ - public static boolean hasAbstractOperation(ObjectModelClass clazz){ - // recherche de toutes les methodes abstraites de la classe est des - //super classes et des interfaces. - List operations = getAbstractOperationList(clazz); -//System.out.println("List op:" + operations); - // pour chaque operation abstraite, on regarde si la classe ou les - // superclasses les implantes ou les laisse abstraites. - for(Iterator i=operations.iterator(); i.hasNext();){ - ObjectModelOperation operation = (ObjectModelOperation)i.next(); -// System.out.println(operation+" implemented by :"+clazz+" == "+implementOperation(clazz, operation)); - if(! implementOperation(clazz, operation)){ - return true; - } - } - return false; - } - - /** - * Retourne vrai si la classe ou sa super classe implante l'operation passé - * en argument. Cela est vrai si la classe definie l'operation comme non - * abstraites ou qu'un attribut généré cette méthode. - * pour les attributs les methodes sont: get[attributeName]() - * et si l'attribut n'est pas readOnly on aura pour un attribut de - * cardinalite 1: set[attributeName]([attributeType]) - * cardinalite n: add[attributeName]([attributeType]), - * remove[attributeName]([attributeType]), clear[attributeName]() - */ - public static boolean implementOperation(ObjectModelClass clazz, ObjectModelOperation operation){ - for(Iterator i=clazz.getOperations().iterator(); i.hasNext();){ - if(operation.equals(i.next())){ - return true; - } - } - - // on a pas trouve sur la classe on recherche sur les super classes - for(Iterator i=clazz.getSuperclasses().iterator(); i.hasNext();){ - ObjectModelClass parentClazz = (ObjectModelClass)i.next(); - if(implementOperation(parentClazz, operation)){ - return true; - } - } - - // on a pas trouver sur les operations declarées // on recherche sur les opérations générer par les attributs - for(Iterator i=clazz.getAttributes().iterator(); i.hasNext();){ + Collection allAttributes = new LinkedList(); + allAttributes.addAll(clazz.getAttributes()); + allAttributes.addAll(clazz.getAllOtherAttributes()); + + for(Iterator i=allAttributes.iterator(); i.hasNext();){ ObjectModelAttribute att = (ObjectModelAttribute)i.next(); String name = null; String []argType = null; Index: topia/src/java/org/codelutin/topia/generators/ApplicationContextGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ApplicationContextGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/ApplicationContextGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,115 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ApplicationContextGenerator.java + * + * Created: 3 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; +import java.io.File; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModel; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.topia.generators.Util; + +public class ApplicationContextGenerator extends ObjectModelGenerator { // ApplicationContextGenerator + + public String getFilenameForModel(ObjectModel model){ + return (getProperty("defaultPackage")+".").replace('.', File.separatorChar) + + model.getName() + "Context.java"; + } + + public void generateFromModel(Writer output, ObjectModel model) throws IOException { + +/*{ +package <%=getProperty("defaultPackage")%>; + +import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaContextFactory; +import org.codelutin.topia.TopiaException; +import java.util.Properties; + +public class <%=model.getName()%>Context extends TopiaContext { + + /** + *) + protected <%=model.getName()%>Context(Properties properties) { + super(properties); + } + + /** + * Method qui permet de recuperer un context pour l'application. + * Cette methode est en fait un appel a la factory de context. + * L'avantage d'utiliser cette methode est qu'elle vous evite un cast + *) + public static <%=model.getName()%>Context getContext() throws TopiaException { + String propName = "<%=model.getName()%>Context.properties"; + return (<%=model.getName()%>Context)TopiaContextFactory.getContext(propName); + } + + /** + * Method qui permet de recuperer un context pour l'application. + * Cette methode est en fait un appel a la factory de context. + * L'avantage d'utiliser cette methode est qu'elle vous evite un cast + *) + public static <%=model.getName()%>Context getContext(Properties prop) throws TopiaException { + return (<%=model.getName()%>Context)TopiaContextFactory.getContext(prop); + } + +}*/ + for (Iterator i=model.getClassifiers().iterator(); i.hasNext();) { + ObjectModelClassifier classifier = (ObjectModelClassifier)i.next(); + if(Util.isEntity(classifier)){ +/*{ + public <%=classifier.getQualifiedName()%>PersistenceService get<%=classifier.getName()%>PersistenceService() throws TopiaException { + return (<%=classifier.getQualifiedName()%>PersistenceService) getPersistenceService(<%=classifier.getQualifiedName()%>.class); + } +}*/ + } + if(Util.isService(classifier)){ +/*{ + public <%=classifier.getQualifiedName()%> get<%=classifier.getName()%>() throws TopiaException { + return (<%=classifier.getQualifiedName()%>) getService(<%=classifier.getQualifiedName()%>.class); + } +}*/ + } + } + +/*{ + // TODO Controls + +} +}*/ + } + +} // ApplicationContextGenerator + Index: topia/src/java/org/codelutin/topia/generators/ContextPropertiesGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ContextPropertiesGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/ContextPropertiesGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,74 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ContextPropertiesGenerator.java + * + * Created: 3 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModel; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.topia.generators.Util; + +public class ContextPropertiesGenerator extends ObjectModelGenerator { // ContextPropertiesGenerator + + public String getFilenameForModel(ObjectModel model){ + return model.getName() + "Context.properties"; + } + + public void generateFromModel(Writer output, ObjectModel model) throws IOException { +/*{ +context.class=<%=getProperty("defaultPackage")%>.<%=model.getName()%>Context +context.helper.persistence=org.codelutin.topia.persistence.jdo.JDOPersistenceHelper +context.helper.persistence.properties.file=<%=model.getName()%>JDOPersistenceHelper.properties +context.helper.distribution=org.codelutin.topia.distribution.local.LocalDistributionHelper +context.helper.hook=org.codelutin.topia.hook.DefaultHookHelper + +}*/ + for(Iterator i=model.getClasses().iterator(); i.hasNext();){ + ObjectModelClass clazz = (ObjectModelClass)i.next(); + if(Util.isEntity(clazz)){ +/*{mapping.implentation.<%=clazz.getQualifiedName()%>Operation=<%=clazz.getQualifiedName()%>OperationImpl +mapping.distribution.<%=clazz.getQualifiedName()%>Operation=<%=clazz.getQualifiedName()%>OperationDist +}*/ + } + if(Util.isService(clazz)){ +/*{mapping.implementation.<%=clazz.getQualifiedName()%>=<%=clazz.getQualifiedName()%>Impl +mapping.distribution.<%=clazz.getQualifiedName()%>=<%=clazz.getQualifiedName()%>Dist +}*/ + } + } + } + +} // ContextPropertiesGenerator + Index: topia/src/java/org/codelutin/topia/generators/EmptyGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/EmptyGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/EmptyGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,462 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * EmptyGenerator.java + * + * Created: 4 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; + +public abstract class EmptyGenerator extends ObjectModelGenerator { // EmptyGenerator + + /** + * if this method return false, nothing is generate + */ + abstract public boolean accept(ObjectModelClassifier clazz); + + public String getFilenameForClassifier(ObjectModelClassifier clazz){ + return clazz.getQualifiedName().replace('.', File.separatorChar); + } + + public void generateFromClassifier(Writer output, ObjectModelClassifier clazz) throws IOException { + // Consider only entities, return immediately if not an entity + if (! accept(clazz)) + return; + + // ------------- File Header + generatePackageStatement(output, clazz); + + // ------------- Imports + generateImportStatement(output, clazz); + + // ------------- Class start + generateClassDeclaration(output, clazz); +/*{ { +}*/ + + if(clazz instanceof ObjectModelClass){ + // ------------- Attributes + for (Iterator i=((ObjectModelClass)clazz).getAttributes().iterator(); i.hasNext();) { + ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); + generateAttributeDeclaration(output, attribute); + generateGetAttributeAccessor(output, attribute); + generateSetAttributeAccessor(output, attribute); + } + + // parcours les operations des super classes + for(Iterator i=((ObjectModelClass)clazz).getAllSuperclassOperations(true).iterator(); i.hasNext();){ + ObjectModelOperation operation = (ObjectModelOperation) i.next(); + if(!Util.isGeneratedOperation(clazz, operation)){ + generateSuperclassOperationDeclaration(output, operation); + generateSuperclassOperationBody(output, operation); + } + } + } + + // ------------- Operations declarations + for(Iterator i=clazz.getOperations().iterator(); i.hasNext();){ + ObjectModelOperation operation = (ObjectModelOperation) i.next(); + if(!Util.isGeneratedOperation(clazz, operation)){ + generateOperationDeclaration(output, operation); + generateOperationBody(output, operation); + } + } + + // parcours les operations des interfaces + for(Iterator i=clazz.getAllInterfaceOperations(true).iterator(); i.hasNext();){ + ObjectModelOperation operation = (ObjectModelOperation) i.next(); + if(!Util.isGeneratedOperation(clazz, operation)){ + generateInterfaceOperationDeclaration(output, operation); + generateInterfaceOperationBody(output, operation); + } + } +// + // ---------------- All that framework used + generateOther(output, clazz); +/*{ +} +}*/ + } + + ////////////////////////////////////////////////////////////////////// + // P A C K A G E + ////////////////////////////////////////////////////////////////////// + + /** + * Il faut absolument que les classes soit dans un package, sinon + * il faut revoir la modelisation :) + */ + public void generatePackageStatement(Writer output, ObjectModelClassifier clazz) + throws IOException { +/*{ +package <%=clazz.getPackageName()%>; + +}*/ + } + + /** + * Appelle la methode {@link #generatePackageStatement(Writer, ObjectModelClassifier)} + */ + public void generatePackageStatement(Writer output, ObjectModelClass clazz) + throws IOException { + generatePackageStatement(output, (ObjectModelClassifier)clazz); + } + + /** + * Appelle la methode {@link #generatePackageStatement(Writer, ObjectModelClassifier)} + */ + public void generatePackageStatement(Writer output, ObjectModelInterface interfacez) + throws IOException { + generatePackageStatement(output, (ObjectModelClassifier)interfacez); + } + + + ////////////////////////////////////////////////////////////////////// + // I M P O R T + ////////////////////////////////////////////////////////////////////// + + /** + * Importe les classes utilises utilisees le plus souvent + */ + public void generateImportStatement(Writer output, ObjectModelClassifier clazz) + throws IOException { + /*{ +import <%=getProperty("defaultPackage")%>.<%=model.getName()%>Context; +import org.codelutin.topia.TopiaContext; +import org.codelutin.topia.TopiaEntity; +import org.codelutin.topia.TopiaEntityOperation; +import org.codelutin.topia.AbstractTopiaEntity; +import org.codelutin.topia.AbstractTopiaElement; +import org.codelutin.topia.AbstractTopiaPersistenceService; +import org.codelutin.topia.TopiaUser; +import org.codelutin.topia.TopiaException; +import org.codelutin.topia.TopiaNotFoundException; +import org.codelutin.topia.TopiaPersistenceService; +import org.codelutin.topia.TopiaQuery; +import org.codelutin.topia.TopiaArgument; +import java.util.List; +import java.util.Collection; +import java.util.Collections; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.HashSet; +import java.util.Date; +import java.util.logging.Level; +import java.util.logging.Logger; + +}*/ + } + + /** + * Appelle la methode {@link #generateImportStatement(Writer, ObjectModelClassifier)} + */ + public void generateImportStatement(Writer output, ObjectModelClass clazz) + throws IOException { + generateImportStatement(output, (ObjectModelClassifier)clazz); + } + + /** + * Appelle la methode {@link #generateImportStatement(Writer, ObjectModelClassifier)} + */ + public void generateImportStatement(Writer output, ObjectModelInterface interfacez) + throws IOException { + generateImportStatement(output, (ObjectModelClassifier)interfacez); + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + abstract public void generateClassDeclaration(Writer output, ObjectModelClassifier clazz) throws IOException; + + ////////////////////////////////////////////////////////////////////// + // A T T R I B U T S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + if(Util.isDerived(attribute)){ + generateDerivedAttributeDeclaration(output, attribute); + }else{ + if (!attribute.referenceClassifier()) { + if(!Util.isNMultiplicity(attribute)){ + generateNormalAttributeDeclaration(output, attribute); + }else{ + generateNormalNMultiplicityAttributeDeclaration(output, attribute); + } + }else{ + if(!Util.isNMultiplicity(attribute)){ + generateEntityAttributeDeclaration(output, attribute); + }else{ + generateEntityNMultiplicityAttributeDeclaration(output, attribute); + } + } + } + } + + /** + * For derived (calculated) attribute. Generate nothing + */ + public void generateDerivedAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + } + + /** + * For normal attribute, aka not entity or derived and with 0/1 cardinality. + */ + public void generateNormalAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + } + + /** + * For normal attribute, aka not entity or derived and with n cardinality. + * By default call {@link #generateNormalAttributeDeclaration} + */ + public void generateNormalNMultiplicityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateNormalAttributeDeclaration(output, attribute); + } + + /** + * For entity attribute with 0/1 cardinality. By default call + * {@link #generateNormalAttributeDeclaration} + */ + public void generateEntityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateNormalAttributeDeclaration(output, attribute); + } + + /** + * For entity attribute with n cardinality. By default call + * {@link #generateNormalAttributeDeclaration} + */ + public void generateEntityNMultiplicityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateNormalNMultiplicityAttributeDeclaration(output, attribute); + } + + ////////////////////////////////////////////////////////////////////// + // G E T A T T R I B U T E S A C C E S S O R S + ////////////////////////////////////////////////////////////////////// + + public void generateGetAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + if(Util.isDerived(attribute)){ + generateGetDerivedAttributeAccessor(output, attribute); + }else{ + if (!attribute.referenceClassifier()) { + if(!Util.isNMultiplicity(attribute)){ + generateGetNormalAttributeAccessor(output, attribute); + }else{ + generateGetNormalNMultiplicityAttributeAccessor(output, attribute); + } + }else{ + if(!Util.isNMultiplicity(attribute)){ + generateGetEntityAttributeAccessor(output, attribute); + }else{ + generateGetEntityNMultiplicityAttributeAccessor(output, attribute); + } + } + } + } + + /** + * For derived (calculated) attribute. + */ + public void generateGetDerivedAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + } + + /** + * For normal attribute, aka not entity or derived. + */ + public void generateGetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + } + + /** + * For normal attribute, aka not entity or derived and with n cardinality. + * By default call {@link #generateNormalAttributeDeclaration} + */ + public void generateGetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateGetNormalAttributeAccessor(output, attribute); + } + + /** + * For entity attribute with 0/1 cardinality. By default call + * {@link #generateNormalAttributeDeclaration} + */ + public void generateGetEntityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateGetNormalAttributeAccessor(output, attribute); + } + + /** + * For entity attribute with n cardinality. By default call + * {@link #generateNormalNMultiplicityAttributeDeclaration} + */ + public void generateGetEntityNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateGetNormalNMultiplicityAttributeAccessor(output, attribute); + } + + ////////////////////////////////////////////////////////////////////// + // S E T A T T R I B U T E S A C C E S S O R S + ////////////////////////////////////////////////////////////////////// + + public void generateSetAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + if (!Util.isReadOnly(attribute)){ + if(Util.isDerived(attribute)){ + generateSetDerivedAttributeAccessor(output, attribute); + }else{ + if (!attribute.referenceClassifier()) { + if(!Util.isNMultiplicity(attribute)){ + generateSetNormalAttributeAccessor(output, attribute); + }else{ + generateSetNormalNMultiplicityAttributeAccessor(output, attribute); + } + }else{ + if(!Util.isNMultiplicity(attribute)){ + generateSetEntityAttributeAccessor(output, attribute); + }else{ + generateSetEntityNMultiplicityAttributeAccessor(output, attribute); + } + } + } + } + } + + /** + * For derived (calculated) attribute. + */ + public void generateSetDerivedAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + } + + /** + * For normal attribute, aka not entity or derived. + */ + public void generateSetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + } + + /** + * For normal attribute, aka not entity or derived and with n cardinality. + * By default call {@link #generateNormalAttributeDeclaration} + */ + public void generateSetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + } + + /** + * For entity attribute with 0/1 cardinality. By default call + * {@link #generateNormalAttributeDeclaration} + */ + public void generateSetEntityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateSetNormalAttributeAccessor(output, attribute); + } + + /** + * For entity attribute with n cardinality. By default call + * {@link #generateNormalNMultiplicityAttributeDeclaration} + */ + public void generateSetEntityNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { + generateSetNormalNMultiplicityAttributeAccessor(output, attribute); + } + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateOperationDeclaration(Writer output, ObjectModelOperation operation) + throws IOException { + } + + /** + * Generate the body of operation. include {, }, or ; + */ + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + } + + public void generateInterfaceOperationDeclaration(Writer output, ObjectModelOperation operation) + throws IOException { + } + + /** + * Generate the body of operation. include {, }, or ; + */ + public void generateInterfaceOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + } + + public void generateSuperclassOperationDeclaration(Writer output, ObjectModelOperation operation) + throws IOException { + } + + /** + * Generate the body of operation. include {, }, or ; + */ + public void generateSuperclassOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + } + + + ////////////////////////////////////////////////////////////////////// + // O T H E R + ////////////////////////////////////////////////////////////////////// + + /** + * generate nothing by default + */ + public void generateOther(Writer output, ObjectModelClassifier clazz) + throws IOException { + } + public void generateOther(Writer output, ObjectModelClass clazz) + throws IOException { + generateOther(output, (ObjectModelClassifier)clazz); + } + public void generateOther(Writer output, ObjectModelInterface interfacez) + throws IOException { + generateOther(output, (ObjectModelClassifier)interfacez); + } + +} // EmptyGenerator + Index: topia/src/java/org/codelutin/topia/generators/EntityGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/EntityGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/EntityGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,142 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * EntityGenerator.java + * + * Created: 3 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.topia.generators.Util; + +public class EntityGenerator extends EmptyGenerator { // EntityGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return super.getFilenameForClassifier(clazz) + ".java"; + } + + public boolean accept(ObjectModelClassifier clazz){ + return true; + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazz) + throws IOException { +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public interface <%=clazz.getName()%> extends TopiaEntity}*/ + for (Iterator i = clazz.getInterfaces().iterator(); i.hasNext();) { + ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); +/*{, <%=interfacezz.getName()%> }*/ + } + if(clazz instanceof ObjectModelClass){ + for (Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); i.hasNext();) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); + /*{, <%=superclass.getName()%>}*/ + } + } + } + + + ////////////////////////////////////////////////////////////////////// + // G E T A T T R I B U T E S A C C E S S O R S + ////////////////////////////////////////////////////////////////////// + + public void generateGetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; +}*/ + } + + public void generateGetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + /** + * @return an unmodifiable collection + *) + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; +}*/ + + } + + ////////////////////////////////////////////////////////////////////// + // S E T A T T R I B U T E S A C C E S S O R S + ////////////////////////////////////////////////////////////////////// + + public void generateSetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> value) throws TopiaException; +}*/ + } + + public void generateSetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; + + public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException; + + public void clear<%=Util.capitalize(attribute.getName())%>() throws TopiaException; +}*/ + } + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateOperationDeclaration(Writer output, ObjectModelOperation operation) throws IOException { +/*{ + /** + <%=operation.getDocumentation()%> + *) + <%=operation.getVisibility()%> <%=operation.getReturnType()%> <%=operation.getName()%> (<%=Util.getMethodParameterDeclaration(operation.getParameters())%>) throws TopiaException}*/ + } + + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + String args = Util.getMethodParameterListName(operation.getParameters()); +/*{; +}*/ + } + +} // EntityGenerator + Index: topia/src/java/org/codelutin/topia/generators/EntityImplGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/EntityImplGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/EntityImplGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,275 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * EntityImplGenerator.java + * + * Created: 3 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.topia.generators.Util; + +public class EntityImplGenerator extends EmptyGenerator { // EntityImplGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return super.getFilenameForClassifier(clazz) + "Impl.java"; + } + + public boolean accept(ObjectModelClassifier clazz){ + return Util.isEntity(clazz) && clazz instanceof ObjectModelClass; + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazzifier) throws IOException { + ObjectModelClass clazz = (ObjectModelClass)clazzifier; +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public class <%=clazz.getName() + "Impl"%>}*/ + Iterator i = clazz.getSuperclasses().iterator(); + if (i.hasNext()) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); +/*{ extends <%=superclass.getName() + "Impl"%>}*/ + } else { +/*{ extends AbstractTopiaEntity}*/ + } + + /*{ implements <%=clazz.getName()%>}*/ + } + + ////////////////////////////////////////////////////////////////////// + // A T T R I B U T S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateNormalAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { +/*{ + protected <%=Util.getAttributeType(attribute)%> <%=attribute.getName()%> = <%=Util.getInitValue(attribute)%>; + protected boolean _<%=attribute.getName()%>Modified_ = false; +}*/ + } + + ////////////////////////////////////////////////////////////////////// + // G E T A T T R I B U T E S A C C E S S O R S + ////////////////////////////////////////////////////////////////////// + + public void generateGetDerivedAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public abstract <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException; +}*/ + } + + public void generateGetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) throws IOException { +/*{ + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + return <%=attribute.getName()%>; + } + public boolean is_<%=attribute.getName()%>Modified_(){ + return this._<%=attribute.getName()%>Modified_; + } +}*/ + } + + public void generateGetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + /** + * @return an unmodifiable collection + *) + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + return Collections.unmodifiableCollection(<%=attribute.getName()%>); + } + public boolean is_<%=attribute.getName()%>Modified_(){ + return this._<%=attribute.getName()%>Modified_; + } +}*/ + } + + ////////////////////////////////////////////////////////////////////// + // S E T A T T R I B U T E S A C C E S S O R S + ////////////////////////////////////////////////////////////////////// + + public void generateSetDerivedAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public abstract void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> value) throws TopiaException; + +}*/ + } + + public void generateSetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> value) throws TopiaException { + this._<%=attribute.getName()%>Modified_ = true; + this.<%=attribute.getName()%> = value; + } +}*/ + } + + public void generateSetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException { + this._<%=attribute.getName()%>Modified_ = true; + this.<%=attribute.getName()%>.add(value); + } + + public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException { + this._<%=attribute.getName()%>Modified_ = true; + this.<%=attribute.getName()%>.remove(value); + } + + public void clear<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + this._<%=attribute.getName()%>Modified_ = true; + this.<%=attribute.getName()%> = <%=Util.getInitValue(attribute)%>; + } +}*/ + } + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateOperationDeclaration(Writer output, ObjectModelOperation operation) throws IOException { +/*{ + /** + <%=operation.getDocumentation()%> + *) + <%=operation.getVisibility()%> <%=operation.getReturnType()%> <%=operation.getName()%> (<%=Util.getMethodParameterDeclaration(operation.getParameters())%>) throws TopiaException}*/ + } + + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + String args = Util.getMethodParameterListName(operation.getParameters()); +/*{ { + <%=("void".equals(operation.getReturnType())?"":"return ")%> getEntityOperation().<%=operation.getName()%>(this<%=(args.equals("")?"":", ")%> <%=args%>); + } +}*/ + } + + public void generateInterfaceOperationDeclaration(Writer output, ObjectModelOperation operation) throws IOException { + generateOperationDeclaration(output, operation); + } + public void generateInterfaceOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + generateOperationBody(output, operation); + } + + ////////////////////////////////////////////////////////////////////// + // O T H E R + ////////////////////////////////////////////////////////////////////// + + public void generateOther(Writer output, ObjectModelClassifier clazz) throws IOException { + generateSetAllFrameworkProperties(output, (ObjectModelClass)clazz); + +/*{ + + public <%=clazz.getName()%>Impl()throws TopiaException { + } + + /** + * Return entity Class managed by this service + *) + public Class getEntityClass(){ + return <%=clazz.getName()%>.class; + } + + /** + * Retourne le persistenceService associé à cette entite. + *) + private <%=clazz.getName()%>PersistenceService getPersistenceService()throws TopiaException { + <%=clazz.getName()%>PersistenceService persistenceService = getAppContext().get<%=clazz.getName()%>PersistenceService(); + return persistenceService; + } + + /** + * Retourne le context d'application associe a cette entite + *) + public <%=model.getName()%>Context getAppContext(){ + <%=model.getName()%>Context context = (<%=model.getName()%>Context)getContext(); + return context; + } + + private <%=clazz.getName()%>Operation getEntityOperation() throws TopiaException { + return (<%=clazz.getName()%>Operation)getContext().getEntityOperation(getEntityClass()); + } +}*/ + } + + protected void generateSetAllFrameworkProperties(Writer output, ObjectModelClass clazz) throws IOException { +/*{ + /** + * Prend toutes les valeurs de l'objet passé en paramètre et les utilises + * comme valeur pour l'objet courant, ceci inclue l'id de l'objet + * Les modifications s'effectue au travers des methodes set. + *) + public void set_allProperties_(TopiaEntity topiaEntity) throws TopiaException { + <%=clazz.getName()%> entity = (<%=clazz.getName()%>)topiaEntity; +}*/ + if(clazz.getSuperclasses().size() != 0){ +/*{ + super.set_allProperties_(entity); +}*/ + }else{ +/*{ + this._topiaId_ = entity.get_topiaId_(); + this._version_ = entity.get_version_(); + this._creationDate_ = entity.get_creationDate_(); + this._lastUpdateDate_ = entity.get_lastUpdateDate_(); + this._lastUpdateUser_ = entity.get_lastUpdateUser_(); +}*/ + } + + // Iterate on each attribute + for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { + ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); + if(! Util.isDerived(attribute)){ +/*{ + this.<%=attribute.getName()%> = entity.get<%=Util.capitalize(attribute.getName())%>(); +}*/ + } + } +/*{ + } +}*/ + } + +} // EntityImplGenerator + Index: topia/src/java/org/codelutin/topia/generators/EntityOperationDistGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/EntityOperationDistGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/EntityOperationDistGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,145 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * EntityOperationDistGenerator.java + * + * Created: 4 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelParameter; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.topia.generators.Util; + +public class EntityOperationDistGenerator extends EmptyGenerator { // EntityOperationDistGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return super.getFilenameForClassifier(clazz) + "OperationDist.java"; + } + + public boolean accept(ObjectModelClassifier clazz){ + return Util.isEntity(clazz); + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazz) throws IOException { +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public class <%=clazz.getName()%>OperationDist extends AbstractTopiaElement implements <%=clazz.getName()%>Operation}*/ + } + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateOperationDeclaration(Writer output, ObjectModelOperation operation) throws IOException { + String args = Util.getMethodParameterDeclaration(operation.getParameters()); +/*{ + /** + <%=operation.getDocumentation()%> + *) + <%=operation.getVisibility()%> <%=operation.getReturnType()%> <%=operation.getName()%> (<%=operation.getDeclaringElement().getName()%> _self_<%=(args.equals("")?"":", ")%><%=args%>) throws TopiaException}*/ + } + + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + // si la methode doit être appelé localement + if(!operation.isAbstract()){ + String args = Util.getMethodParameterListName(operation.getParameters()); +/*{ { + <%=("void".equals(operation.getReturnType())?"":"return ")%> getLocalEntityOperation().<%=operation.getName()%>(_self_<%=(args.equals("")?"":", ")%><%=args%>); + } +}*/ + // sinon + }else{ +/*{ { + TopiaArgument args = new TopiaArgument().addArg(_self_); +}*/ + for(Iterator i=operation.getParameters().iterator(); i.hasNext();){ + ObjectModelParameter param = (ObjectModelParameter)i.next(); +/*{ args.addArg(<%=param.getName()%>); +}*/ + } +/*{ + + Object result = getContext().getDistributionHelper().call( + getEntityOperationClass(), operation.getName(), args); + <%=("void".equals(operation.getReturnType())?"":"return ")%> <%=Util.getCastValue(operation.getReturnType(), "result")%>; + } +}*/ + } + } + + public void generateInterfaceOperationDeclaration(Writer output, ObjectModelOperation operation) throws IOException { + generateOperationDeclaration(output, operation); + } + public void generateInterfaceOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + generateOperationBody(output, operation); + } + + public void generateSuperclassOperationDeclaration(Writer output, ObjectModelOperation operation) throws IOException { + generateOperationDeclaration(output, operation); + } + public void generateSuperclassOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + generateOperationBody(output, operation); + } + + ////////////////////////////////////////////////////////////////////// + // O T H E R + ////////////////////////////////////////////////////////////////////// + + public void generateOther(Writer output, ObjectModelClassifier clazz) throws IOException { +/*{ + protected Class getEntityOperationClass(){ + return <%=clazz.getName()%>Operation.class; + } + + protected Class getEntityClass(){ + return <%=clazz.getName()%>.class; + } + + private <%=clazz.getName()%>Operation getLocalEntityOperation()throws TopiaException { + return (<%=clazz.getName()%>Operation)getContext().getEntityOperation(getEntityClass(), true); + } +}*/ + } + +} // EntityOperationDistGenerator + Index: topia/src/java/org/codelutin/topia/generators/EntityOperationGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/EntityOperationGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/EntityOperationGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,98 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * EntityOperationGenerator.java + * + * Created: 4 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelParameter; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.topia.generators.Util; + +public class EntityOperationGenerator extends EmptyGenerator { // EntityOperationGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return super.getFilenameForClassifier(clazz) + "Operation.java"; + } + + public boolean accept(ObjectModelClassifier clazz){ + return Util.isEntity(clazz); + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazz) throws IOException { +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public interface <%=clazz.getName() + "Operation"%> extends TopiaEntityOperation}*/ + for (Iterator i = clazz.getInterfaces().iterator(); i.hasNext();) { + ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); +/*{, <%=interfacezz.getName()%>Operation }*/ + } + if(clazz instanceof ObjectModelClass){ + for (Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); i.hasNext();) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); + /*{, <%=superclass.getName()%>Operation}*/ + } + } + } + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateOperationDeclaration(Writer output, ObjectModelOperation operation) throws IOException { + String args = Util.getMethodParameterDeclaration(operation.getParameters()); +/*{ + /** + <%=operation.getDocumentation()%> + *) + <%=operation.getVisibility()%> <%=operation.getReturnType()%> <%=operation.getName()%> (<%=operation.getDeclaringElement().getName()%> _self_<%=(args.equals("")?"":", ")%><%=args%>) throws TopiaException}*/ + } + + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { +/*{; +}*/ + } + +} // EntityOperationGenerator + Index: topia/src/java/org/codelutin/topia/generators/PersistenceServiceGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/PersistenceServiceGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/PersistenceServiceGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,128 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * PersistenceServiceGenerator.java + * + * Created: 3 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.topia.generators.Util; + +public class PersistenceServiceGenerator extends EmptyGenerator { // PersistenceServiceGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return super.getFilenameForClassifier(clazz) + "PersistenceService.java"; + } + + + public boolean accept(ObjectModelClassifier clazz){ + return Util.isEntity(clazz); + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazz) + throws IOException { +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public interface <%=clazz.getName()%>PersistenceService extends TopiaPersistenceService}*/ + for (Iterator i = clazz.getInterfaces().iterator(); i.hasNext();) { + ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); +/*{, <%=interfacezz.getName()%>PersistenceService }*/ + } + if(clazz instanceof ObjectModelClass){ + for (Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); i.hasNext();) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); + /*{, <%=superclass.getName()%>PersistenceService}*/ + } + } + } + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + // TODO dans le futur les operations de nom find seront a mettre ici + // et pas dans l'entite + public void generateOperationDeclaration(Writer output, ObjectModelOperation operation) throws IOException { + } + + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + } + + public void generateNormalAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + /** + * @return an entity + *) + public <%=attribute.getDeclaringElement().getName()%> findBy<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> <%=attribute.getName()%>) throws TopiaException; + + /** + * @return an unmodifiable collection + *) + public List findAllBy<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> <%=attribute.getName()%>) throws TopiaException; +}*/ + } + + public void generateEntityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { + generateNormalAttributeDeclaration(output, attribute); + } + + ////////////////////////////////////////////////////////////////////// + // O T H E R + ////////////////////////////////////////////////////////////////////// + + public void generateOther(Writer output, ObjectModelClassifier clazz) throws IOException { + if(clazz instanceof ObjectModelClass){ +/*{ + /** + * Return new entity + *) + public <%=clazz.getName()%> create<%=clazz.getName()%>() throws TopiaException; + + public <%=clazz.getName()%> makePersistent(<%=clazz.getName()%> entity) throws TopiaException; +}*/ + } + } + +} // PersistenceServiceGenerator + Index: topia/src/java/org/codelutin/topia/generators/PersistenceServiceImplGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/PersistenceServiceImplGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/PersistenceServiceImplGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,152 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * PersistenceServiceImplGenerator.java + * + * Created: 3 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; +import java.util.Collection; + +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.topia.generators.Util; +import java.util.LinkedList; + +public class PersistenceServiceImplGenerator extends EmptyGenerator { // PersistenceServiceImplGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return super.getFilenameForClassifier(clazz) + "PersistenceServiceImpl.java"; + } + + public boolean accept(ObjectModelClassifier clazz){ + return Util.isEntity(clazz) && clazz instanceof ObjectModelClass; + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazz) throws IOException { + Collection operations = new LinkedList(); + operations.addAll(clazz.getOperations()); + operations.addAll(clazz.getAllOtherOperations(false)); +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public <%=(operations.size()==0?"":"abstract ")%>class <%=clazz.getName() + "PersistenceServiceImpl"%> extends }*/ + if(clazz instanceof ObjectModelClass){ + Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); + if (i.hasNext()) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); + /*{<%=superclass.getName()%>PersistenceServiceImpl}*/ + }else{ + /*{AbstractTopiaPersistenceService}*/ + } + } + + /*{ implements <%=clazz.getName()%>PersistenceService}*/ + } + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateNormalAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { + super.generateNormalAttributeDeclaration(output, attribute); +/*{ + /** + * @return an entity + *) + public <%=attribute.getDeclaringElement().getName()%> findBy<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> value) throws TopiaException{ + List result = find(newQuery().where("<%=attribute.getName()%> = ?").addArg(value)); + if(result.size() == 0){ + throw new TopiaNotFoundException("Can't find object with attribute <%=attribute.getName()%> == " + value); + } + return (<%=attribute.getDeclaringElement().getName()%>)result.get(0); + } + + /** + * @return an unmodifiable collection + *) + public List findAllBy<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> value) throws TopiaException{ + return find(newQuery().where("<%=attribute.getName()%> = ?").addArg(value)); + } +}*/ + } + + public void generateEntityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { + generateNormalAttributeDeclaration(output, attribute); + } + + ////////////////////////////////////////////////////////////////////// + // O T H E R + ////////////////////////////////////////////////////////////////////// + + public void generateOther(Writer output, ObjectModelClassifier clazz) throws IOException { +/*{ + + /** + * Return new entity + *) + public <%=clazz.getName()%> create<%=clazz.getName()%>() throws TopiaException { + return (<%=clazz.getName()%>)super.create(); + } + + public <%=clazz.getName()%> makePersistent(<%=clazz.getName()%> entity) throws TopiaException{ + return (<%=clazz.getName()%>)super.makePersistent(entity); + } + + /** + * Return entity Class managed by this service + *) + public Class getEntityClass(){ + return <%=clazz.getName()%>.class; + } + + /** + * Retourne le context d'application associe a cette entite + *) + public <%=model.getName()%>Context getAppContext(){ + <%=model.getName()%>Context context = (<%=model.getName()%>Context)getContext(); + return context; + } + +}*/ + } + +} // PersistenceServiceImplGenerator + Index: topia/src/java/org/codelutin/topia/generators/ServiceDistGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ServiceDistGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:17 2004 +++ topia/src/java/org/codelutin/topia/generators/ServiceDistGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,127 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ServiceDistGenerator.java + * + * Created: 3 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelParameter; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.topia.generators.Util; + +public class ServiceDistGenerator extends EmptyGenerator { // ServiceDistGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return super.getFilenameForClassifier(clazz) + "Dist.java"; + } + + public boolean accept(ObjectModelClassifier clazz){ + return Util.isService(clazz); + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazzifier) throws IOException { + ObjectModelClass clazz = (ObjectModelClass)clazzifier; +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public class <%=clazz.getName()%>Dist implements <%=clazz.getName()%>}*/ + } + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateOperationDeclaration(Writer output, ObjectModelOperation operation) throws IOException { + String args = Util.getMethodParameterDeclaration(operation.getParameters()); +/*{ + /** + <%=operation.getDocumentation()%> + *) + <%=operation.getVisibility()%> <%=operation.getReturnType()%> <%=operation.getName()%> (<%=args%>) throws TopiaException}*/ + } + + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + // si la methode doit être appelé localement + if(!operation.isAbstract()){ + String args = Util.getMethodParameterListName(operation.getParameters()); +/*{ { + <%=("void".equals(operation.getReturnType())?"":"return ")%> getLocalPersistenceService().<%=operation.getName()%>(<%=args%>); + } +}*/ + // sinon + }else{ +/*{ { + TopiaArgument args = new TopiaArgument(); +}*/ + for(Iterator i=operation.getParameters().iterator(); i.hasNext();){ + ObjectModelParameter param = (ObjectModelParameter)i.next(); +/*{ args.addArg(<%=param.getName()%>); +}*/ + } +/*{ + + Object result = getContext().getDistributionHelper().call( + getPersistenceServiceClass(), operation.getName(), args); + <%=("void".equals(operation.getReturnType())?"":"return ")%> <%=Util.getCastValue(operation.getReturnType(), "result")%>; + } +}*/ + } + } + + ////////////////////////////////////////////////////////////////////// + // O T H E R + ////////////////////////////////////////////////////////////////////// + + public void generateOther(Writer output, ObjectModelClassifier clazz) throws IOException { +/*{ + protected Class getServiceClass(){ + return <%=clazz.getName()%>.class; + } + protected <%=clazz.getName()%> getLocalService(){ + return (<%=clazz.getName()%>)getContext().getService(getServiceClass(), true); + } +}*/ + } + +} // ServiceDistGenerator + Index: topia/src/java/org/codelutin/topia/generators/ServiceGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/ServiceGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/generators/ServiceGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,99 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ServiceGenerator.java + * + * Created: 3 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +import org.codelutin.generator.models.object.ObjectModelAttribute; +import org.codelutin.generator.models.object.ObjectModelParameter; +import org.codelutin.generator.models.object.ObjectModelClass; +import org.codelutin.generator.models.object.ObjectModelClassifier; +import org.codelutin.generator.models.object.ObjectModelInterface; +import org.codelutin.generator.models.object.ObjectModelOperation; +import org.codelutin.topia.generators.Util; + +public class ServiceGenerator extends EmptyGenerator { // ServiceGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return super.getFilenameForClassifier(clazz) + ".java"; + } + + public boolean accept(ObjectModelClassifier clazz){ + return Util.isService(clazz); + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazz) + throws IOException { +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public interface <%=clazz.getName()%> extends TopiaService}*/ + for (Iterator i = clazz.getInterfaces().iterator(); i.hasNext();) { + ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); +/*{, <%=interfacezz.getName()%> }*/ + } + if(clazz instanceof ObjectModelClass){ + for (Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); i.hasNext();) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); + /*{, <%=superclass.getName()%>}*/ + } + } + } + + + ////////////////////////////////////////////////////////////////////// + // O P E R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateOperationDeclaration(Writer output, ObjectModelOperation operation) + throws IOException { +/*{ + /** + <%=operation.getDocumentation()%> + *) + <%=operation.getVisibility()%> <%=operation.getReturnType()%> <%=operation.getName()%> (<%=Util.getMethodParameterDeclaration(operation.getParameters())%>) throws TopiaException}*/ + } + + public void generateOperationBody(Writer output, ObjectModelOperation operation) throws IOException { + /*{; + }*/ + } + +} // ServiceGenerator + Index: topia/src/java/org/codelutin/topia/generators/TopiaGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/generators/TopiaGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/generators/TopiaGenerator.java Thu Jul 15 13:13:12 2004 @@ -0,0 +1,105 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * TopiaGenerator.java + * + * Created: 4 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:12 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.generators; + +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModel; +import java.io.IOException; +import java.io.File; + +/** +* Meta generateur qui appelle tous les générateur de classe util pour le +* framework de base de ToPIA. C'est à dire les générateur qui ne sont +* pas spécifique à la persistence ou aux autre module. +*/ +public class TopiaGenerator extends ObjectModelGenerator { // TopiaGenerator + + public TopiaGenerator(){ + super(); + } + + public void generate(ObjectModel model, File destDir) throws IOException { + ObjectModelGenerator gen = null; + + System.out.println("Generation de ApplicationContextGenerator"); + gen = new ApplicationContextGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de ContextPropertiesGenerator"); + gen = new ContextPropertiesGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de EntityGenerator"); + gen = new EntityGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de EntityImplGenerator"); + gen = new EntityImplGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de EntityOperationGenerator"); + gen = new EntityOperationGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de EntityOperationDistGenerator"); + gen = new EntityOperationDistGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de PersistenceServiceGenerator"); + gen = new PersistenceServiceGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de PersistenceServiceImplGenerator"); + gen = new PersistenceServiceImplGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de ServiceDistGenerator"); + gen = new ServiceDistGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de ServiceGenerator"); + gen = new ServiceGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + } + +} // TopiaGenerator +