Index: topia/src/java/org/codelutin/topia/persistence/jdo/generators/EntityJDOGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/persistence/jdo/generators/EntityJDOGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/persistence/jdo/generators/EntityJDOGenerator.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,282 @@ +/* *##% + * 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. + *##%*/ + +/* * + * EntityJDOGenerator.java + * + * Created: 6 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.persistence.jdo.generators; + +import org.codelutin.topia.generators.EmptyGenerator; + +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 java.io.File; + +public class EntityJDOGenerator extends EmptyGenerator { // EntityJDOGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return (clazz.getPackageName()+".persistence.jdo.").replace('.', File.separatorChar)+clazz.getName()+"JDO.java"; + } + + public boolean accept(ObjectModelClassifier clazz){ + return Util.isEntity(clazz); + } + + ////////////////////////////////////////////////////////////////////// + // P A C K A G E + ////////////////////////////////////////////////////////////////////// + + public void generatePackageStatement(Writer output, ObjectModelClassifier clazz) + throws IOException { +/*{ +package <%=clazz.getPackageName()%>.persistence.jdo; + +}*/ + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateImportStatement(Writer output, ObjectModelClassifier clazz) throws IOException { + super.generateImportStatement(output, clazz); +/*{ +import org.codelutin.topia.persistence.jdo.AbstractJDOEntity; +import org.codelutin.topia.persistence.jdo.JDOEntity; +import <%=clazz.getPackageName()%>.*; +}*/ + } + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazzifier) throws IOException { +/*{ +/** +<%=clazzifier.getDocumentation()%> + *)}*/ + if(clazzifier instanceof ObjectModelClass){ + ObjectModelClass clazz = (ObjectModelClass)clazzifier; +/*{ +public class <%=clazz.getName() + "JDO"%> extends }*/ + Iterator i = clazz.getSuperclasses().iterator(); + if (i.hasNext()) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); + /*{<%=superclass.getName()%>JDO implements JDOEntity}*/ + } else { + /*{AbstractJDOEntity implements JDOEntity}*/ + } + }else{ +/*{ +public interface <%=clazzifier.getName() + "JDO"%> extends JDOEntity}*/ + } + + for (Iterator i = clazzifier.getInterfaces().iterator(); i.hasNext();) { + ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); + /*{, <%=interfacezz.getName()%>JDO }*/ + } + } + + ////////////////////////////////////////////////////////////////////// + // 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 { + if(attribute.getDeclaringElement() instanceof ObjectModelClass){ +/*{ + public <%=Util.getAttributeType(attribute)%> <%=attribute.getName()%> = <%=Util.getInitValue(attribute)%>; +}*/ + } + } + + public void generateEntityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) + throws IOException { + /*{ + public <%=Util.getJDOClassName(Util.getAttributeType(attribute))%> <%=attribute.getName()%> = <%=Util.getInitValue(attribute)%>; +}*/ + } + + ////////////////////////////////////////////////////////////////////// + // O T H E R + ////////////////////////////////////////////////////////////////////// + + public void generateOther(Writer output, ObjectModelClassifier clazzifier) throws IOException { + if(!(clazzifier instanceof ObjectModelClass)){ + return; + } + + ObjectModelClass clazz = (ObjectModelClass)clazzifier; +/*{ + + /** + * 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; + } + + /** + * Met a jour l'objet jdo a partir de l'entity. Et appelle l'operation + * d'update sur les Entities elle meme modifié. + * @param topiaEntity une vrai entity et pas un Lazy + *) + public void update(TopiaEntity topiaEntity, HashSet done) throws TopiaException { + super.update(topiaEntity, done); + <%=clazz.getQualifiedName()%>Impl entity = (<%=clazz.getQualifiedName()%>Impl)topiaEntity; + }*/ + + // Iterate on each attribute + for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { + ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); + if(! Util.isDerived(attribute)){ +/*{ + if(entity.is_<%=attribute.getName()%>Modified_()){ +}*/ + if (! attribute.referenceClassifier()) { +/*{ + this.<%=attribute.getName()%> = entity.get<%=Util.capitalize(attribute.getName())%>(); +}*/ + } else { + if (!Util.isNMultiplicity(attribute)) { +/*{ + TopiaEntity te = (TopiaEntity)entity.get<%=Util.capitalize(attribute.getName())%>(); + if (te != null){ + JDOEntity tejdo = getPersistenceHelper().update(te, done); + this.<%=attribute.getName()%> = (<%=Util.getJDOClassName(Util.getAttributeType(attribute))%>)tejdo; + }else{ + this.<%=attribute.getName()%> = null; + } +}*/ + } else { +/*{ + ArrayList tmpIds = new ArrayList(); + for (Iterator i=entity.get<%=Util.capitalize(attribute.getName())%>().iterator(); i.hasNext();) { + TopiaEntity te = (TopiaEntity)i.next(); + if (te != null){ + JDOEntity tejdo = getPersistenceHelper().update(te, done); + tmpIds.add(tejdo); + }else{ + tmpIds.add(null); + } + } + this.<%=attribute.getName()%> = tmpIds; +}*/ + } + } +/*{ + } +}*/ + } + } +/*{ + } + + public TopiaEntity convertToEntity() throws TopiaException { + return convertToEntity(new <%=clazz.getName()%>Impl()); + } + + /** + * Converti l'objet JDO en objet normal du framework, chaque attribut et + * element de collection referencant une entity est encapsulé dans un + * LazyEntity + * @param result l'objet resultat a utiliser s'il est different de null, + * sinon on en instancie un nouveau. + * @return l'objet resultat est lui meme dans un Lazy + *) + protected TopiaEntity convertToEntity(TopiaEntity result) throws TopiaException { + <%=clazz.getName()%>Impl entity = (<%=clazz.getName()%>Impl)result; + + super.convertToEntity(entity); +}*/ + // Iterate on each attribute + for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { + ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); + if(! Util.isDerived(attribute)){ + if (!Util.isNMultiplicity(attribute)) { + if (! attribute.referenceClassifier()) { +/*{ + entity.set<%=Util.capitalize(attribute.getName())%>(<%=attribute.getName()%>); +}*/ + }else{ +/*{ + if(<%=attribute.getName()%> == null){ + entity.set<%=Util.capitalize(attribute.getName())%>(null); + }else{ + entity.set<%=Util.capitalize(attribute.getName())%>(new <%=Util.getLazyClassName(attribute.getType())%>(getContext(), <%=attribute.getName()%>.get_topiaId_(), <%=attribute.getName()%>.get_version_())); + } +}*/ + } + }else{ + if (! attribute.referenceClassifier()) { +/*{ + for(Iterator i=<%=attribute.getName()%>.iterator(); i.hasNext();){ + entity.add<%=Util.capitalize(attribute.getName())%>((<%=attribute.getType()%>)i.next()); + } +}*/ + }else{ +/*{ + for(Iterator i=<%=attribute.getName()%>.iterator(); i.hasNext();){ + JDOEntity e = (JDOEntity)i.next(); + entity.add<%=Util.capitalize(attribute.getName())%>(new <%=Util.getLazyClassName(attribute.getType())%>(getContext(), e.get_topiaId_(), e.get_version_())); + } +}*/ + } + } + } + } +/*{ + // ajouter le code qui indique que l'entity n'a pas ete modifie + // c-a-d remettre tous les ismodified a false + + return new <%=clazz.getName()%>Lazy(getContext(), result); + } +}*/ + } + +} // EntityJDOGenerator + Index: topia/src/java/org/codelutin/topia/persistence/jdo/generators/EntityJDOMetaDataGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/persistence/jdo/generators/EntityJDOMetaDataGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/persistence/jdo/generators/EntityJDOMetaDataGenerator.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,139 @@ +/* *##% + * 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. + *##%*/ + +/* * + * EntityJDOMetaDataGenerator.java + * + * Created: 6 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.persistence.jdo.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.topia.generators.Util; + +public class EntityJDOMetaDataGenerator extends ObjectModelGenerator { // EntityJDOMetaDataGenerator + + public String getFilenameForClass(ObjectModelClass clazz) { + return (clazz.getPackageName()+".persistence.jdo.").replace('.', File.separatorChar)+clazz.getName()+"JDO.jdo"; + } + + public void generateFromClass(Writer output, ObjectModelClass clazz) + throws IOException { + + // Consider only entities, return immediately if not an entity + if (! Util.isEntity(clazz)) return; + +// ------------- XML header + /*{ + +}*/ + +// ------------- JDO start +/*{ + + + +}*/ + +// ------------- Fields declaration + // Iterate on each attribute to generate fields declarations + for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { + ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); + ObjectModelClassifier classifier = attribute.getClassifier(); +/*{ + +}*/ + if (Util.isNMultiplicity(attribute)) { +/*{ + JDO"> + + +}*/ + } else if ("java.lang.String".equals(attribute.getType())) { +/*{ + +}*/ + } +/*{ + +}*/ + } + +// ------------- JDO end +/*{ + + + +}*/ + + } + + public String getFilenameForInterface(ObjectModelInterface interfacez) { + return (interfacez.getPackageName()+".persistence.jdo.").replace('.', File.separatorChar)+interfacez.getName()+"JDO.jdo"; + } + + public void generateFromInterface( + Writer output, + ObjectModelInterface interfacez) + throws IOException { + +// ------------- XML header +/*{ + +}*/ + +// ------------- JDO start +/*{ + + + + + +}*/ + + } + +} // EntityJDOMetaDataGenerator + Index: topia/src/java/org/codelutin/topia/persistence/jdo/generators/JDOGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/persistence/jdo/generators/JDOGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/persistence/jdo/generators/JDOGenerator.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,76 @@ +/* *##% + * 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. + *##%*/ + +/* * + * JDOGenerator.java + * + * Created: 7 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.persistence.jdo.generators; + +import org.codelutin.topia.generators.TopiaGenerator; +import org.codelutin.generator.ObjectModelGenerator; +import org.codelutin.generator.models.object.ObjectModel; +import java.io.IOException; +import java.io.File; + +public class JDOGenerator extends ObjectModelGenerator { // JDOGenerator + + public JDOGenerator(){ + super(); + } + + public void generate(ObjectModel model, File destDir) throws IOException { + ObjectModelGenerator gen = null; + + System.out.println("Generation de TopiaGenerator"); + gen = new TopiaGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de EntityJDOGenerator"); + gen = new EntityJDOGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de EntityJDOMetaDataGenerator"); + gen = new EntityJDOMetaDataGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de LazyEntityGenerator"); + gen = new LazyEntityGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + + System.out.println("Generation de PersistenceHelperPropertiesGenerator"); + gen = new PersistenceHelperPropertiesGenerator(); + gen.setProperties(properties); + gen.generate(model, destDir); + } + +} // JDOGenerator + Index: topia/src/java/org/codelutin/topia/persistence/jdo/generators/LazyEntityGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/persistence/jdo/generators/LazyEntityGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/persistence/jdo/generators/LazyEntityGenerator.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,269 @@ +/* *##% + * 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. + *##%*/ + +/* * + * LazyEntityGenerator.java + * + * Created: 6 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.persistence.jdo.generators; + +import org.codelutin.topia.generators.EmptyGenerator; +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 LazyEntityGenerator extends EmptyGenerator { // LazyEntityGenerator + + public String getFilenameForClassifier(ObjectModelClassifier clazz) { + return (clazz.getPackageName()+".persistence.jdo.").replace('.', File.separatorChar)+clazz.getName()+"Lazy.java"; + } + + public boolean accept(ObjectModelClassifier clazz){ + return Util.isEntity(clazz) && clazz instanceof ObjectModelClass; + } + + ////////////////////////////////////////////////////////////////////// + // P A C K A G E + ////////////////////////////////////////////////////////////////////// + + public void generatePackageStatement(Writer output, ObjectModelClassifier clazz) + throws IOException { +/*{ +package <%=clazz.getPackageName()%>.persistence.jdo; + +}*/ + } + + ////////////////////////////////////////////////////////////////////// + // C L A S S D E C L A R A T I O N + ////////////////////////////////////////////////////////////////////// + + public void generateImportStatement(Writer output, ObjectModelClassifier clazz) throws IOException { + super.generateImportStatement(output, clazz); +/*{ +import org.codelutin.topia.persistence.jdo.AbstractLazyEntity; +import <%=clazz.getPackageName()%>.*; +}*/ + } + + public void generateClassDeclaration(Writer output, ObjectModelClassifier clazzifier) throws IOException { + ObjectModelClass clazz = (ObjectModelClass)clazzifier; +/*{ +/** +<%=clazz.getDocumentation()%> + *) +public class <%=clazz.getName()%>Lazy}*/ + Iterator i = clazz.getSuperclasses().iterator(); + if (i.hasNext()) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); +/*{ extends <%=superclass.getName()%>Lazy}*/ + } else { +/*{ extends AbstractLazyEntity}*/ + } + + /*{ implements <%=clazz.getQualifiedName()%>}*/ + } + + ////////////////////////////////////////////////////////////////////// + // 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 <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException{ + load(); + return getTypedEntity().get<%=Util.capitalize(attribute.getName())%>(); + } +}*/ + } + + public void generateGetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) throws IOException { +/*{ + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + load(); + return getTypedEntity().get<%=Util.capitalize(attribute.getName())%>(); + } +}*/ + } + + public void generateGetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + /** + * @return an unmodifiable collection + *) + public <%=Util.getAttributeType(attribute)%> get<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + load(); + return getTypedEntity().get<%=Util.capitalize(attribute.getName())%>(); + } +}*/ + } + + ////////////////////////////////////////////////////////////////////// + // 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{ + load(); + getTypedEntity().set<%=Util.capitalize(attribute.getName())%>(value); + } + +}*/ + } + + public void generateSetNormalAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public void set<%=Util.capitalize(attribute.getName())%>(<%=Util.getAttributeType(attribute)%> value) throws TopiaException { + getTypedEntity().set<%=Util.capitalize(attribute.getName())%>(value); + } +}*/ + } + + public void generateSetNormalNMultiplicityAttributeAccessor(Writer output, ObjectModelAttribute attribute) + throws IOException { +/*{ + public void add<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException { + getTypedEntity().add<%=Util.capitalize(attribute.getName())%>(value); + } + + public void remove<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException { + getTypedEntity().remove<%=Util.capitalize(attribute.getName())%>(value); + } + + public void clear<%=Util.capitalize(attribute.getName())%>() throws TopiaException { + getTypedEntity().clear<%=Util.capitalize(attribute.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 { + String args = Util.getMethodParameterListName(operation.getParameters()); +/*{ { + <%=("void".equals(operation.getReturnType())?"":"return ")%> getTypedEntity().<%=operation.getName()%>(<%=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 clazzifier) throws IOException { + ObjectModelClass clazz = (ObjectModelClass)clazzifier; +/*{ + public <%=clazz.getName()%>Lazy(TopiaContext context, String _topiaId_, String version)throws TopiaException { + super(context, _topiaId_, version); + } + + public <%=clazz.getName()%>Lazy(TopiaContext context, TopiaEntity entity) throws TopiaException { + super(context, entity); + } + + private <%=clazz.getName()%> getTypedEntity(){ + return (<%=clazz.getName()%>)getEntity(); + } + + /** + * 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; + } + + protected void setContextOnAllLazy(TopiaContext context) throws TopiaException { +}*/ + for (Iterator i = clazz.getAttributes().iterator(); i.hasNext();) { + ObjectModelAttribute attribute = (ObjectModelAttribute) i.next(); + if(! Util.isDerived(attribute) && attribute.referenceClassifier()){ + if (!Util.isNMultiplicity(attribute)) { +/*{ + get<%=Util.capitalize(attribute.getName())%>().setContext(context); +}*/ + }else{ +/*{ + for(Iterator i=get<%=Util.capitalize(attribute.getName())%>().iterator(); i.hasNext(); ){ + ((TopiaEntity)i.next()).setContext(context); + } +}*/ + } + } + } +/*{ + } +}*/ + } + +} // LazyEntityGenerator + Index: topia/src/java/org/codelutin/topia/persistence/jdo/generators/PersistenceHelperPropertiesGenerator.java diff -u /dev/null topia/src/java/org/codelutin/topia/persistence/jdo/generators/PersistenceHelperPropertiesGenerator.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/persistence/jdo/generators/PersistenceHelperPropertiesGenerator.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,71 @@ +/* *##% + * 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. + *##%*/ + +/* * + * PersistenceHelperPropertiesGenerator.java + * + * Created: 6 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.persistence.jdo.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.generator.models.object.ObjectModelClassifier; +import org.codelutin.topia.generators.Util; + +public class PersistenceHelperPropertiesGenerator extends ObjectModelGenerator { // PersistenceHelperPropertiesGenerator + + public String getFilenameForModel(ObjectModel model){ + return model.getName() + "JDOPersistenceHelper.properties"; + } + + public void generateFromModel(Writer output, ObjectModel model) throws IOException { +/*{ +javax.jdo.PersistenceManagerFactoryClass=com.triactive.jdo.PersistenceManagerFactoryImpl +javax.jdo.option.ConnectionDriverName=org.postgresql.Driver +javax.jdo.option.ConnectionURL=jdbc:postgresql://localhost/database +javax.jdo.option.ConnectionUserName=dbuser +javax.jdo.option.ConnectionPassword=dbuser +javax.jdo.option.NontransactionalRead=true +com.triactive.jdo.autoCreateTables=true + +}*/ + for(Iterator i=model.getClassifiers().iterator(); i.hasNext();){ + ObjectModelClassifier clazz = (ObjectModelClassifier)i.next(); + if(Util.isEntity(clazz)){ +/*{mapping.jdo.<%=clazz.getQualifiedName()%>=<%=clazz.getPackageName()%>.persistence.jdo.<%=clazz.getName()%>JDO +}*/ + } + } + } + +} // PersistenceHelperPropertiesGenerator + Index: topia/src/java/org/codelutin/topia/persistence/jdo/generators/Util.java diff -u /dev/null topia/src/java/org/codelutin/topia/persistence/jdo/generators/Util.java:1.1 --- /dev/null Thu Jul 15 13:13:18 2004 +++ topia/src/java/org/codelutin/topia/persistence/jdo/generators/Util.java Thu Jul 15 13:13:13 2004 @@ -0,0 +1,45 @@ +/* *##% + * 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. + *##%*/ + +/* * + * Util.java + * + * Created: 8 juil. 2004 + * + * @author Benjamin Poussin + * Copyright Code Lutin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/07/15 13:13:13 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.topia.persistence.jdo.generators; + +public class Util extends org.codelutin.topia.generators.Util { // Util + + public static String getLazyClassName(String clazz){ + return org.codelutin.topia.persistence.jdo.Util.getLazyClassName(clazz); + } + + public static String getJDOClassName(String clazz){ + return org.codelutin.topia.persistence.jdo.Util.getJDOClassName(clazz); + } + +} // Util +