Index: topia/src/java/org/codelutin/topia/persistence/jdo/generators/LazyEntityGenerator.java diff -u topia/src/java/org/codelutin/topia/persistence/jdo/generators/LazyEntityGenerator.java:1.1 topia/src/java/org/codelutin/topia/persistence/jdo/generators/LazyEntityGenerator.java:1.2 --- topia/src/java/org/codelutin/topia/persistence/jdo/generators/LazyEntityGenerator.java:1.1 Thu Jul 15 13:13:13 2004 +++ topia/src/java/org/codelutin/topia/persistence/jdo/generators/LazyEntityGenerator.java Fri Jul 23 12:42:28 2004 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * - * Mise a jour: $Date: 2004/07/15 13:13:13 $ - * par : $Author: bpoussin $ + * Mise a jour: $Date: 2004/07/23 12:42:28 $ + * par : $Author: pineau $ */ package org.codelutin.topia.persistence.jdo.generators; @@ -51,7 +51,7 @@ } public boolean accept(ObjectModelClassifier clazz){ - return Util.isEntity(clazz) && clazz instanceof ObjectModelClass; + return Util.isEntity(clazz); } ////////////////////////////////////////////////////////////////////// @@ -79,21 +79,25 @@ } public void generateClassDeclaration(Writer output, ObjectModelClassifier clazzifier) throws IOException { - ObjectModelClass clazz = (ObjectModelClass)clazzifier; /*{ /** -<%=clazz.getDocumentation()%> +<%=clazzifier.getDocumentation()%> *) -public class <%=clazz.getName()%>Lazy}*/ - Iterator i = clazz.getSuperclasses().iterator(); - if (i.hasNext()) { - ObjectModelClass superclass = (ObjectModelClass) i.next(); +public class <%=clazzifier.getName()%>Lazy}*/ + if (clazzifier instanceof ObjectModelClass) { + ObjectModelClass clazz = (ObjectModelClass) clazzifier; + Iterator i = clazz.getSuperclasses().iterator(); + if (i.hasNext()) { + ObjectModelClass superclass = (ObjectModelClass) i.next(); /*{ extends <%=superclass.getName()%>Lazy}*/ + } else { +/*{ extends AbstractLazyEntity}*/ + } } else { /*{ extends AbstractLazyEntity}*/ } - /*{ implements <%=clazz.getQualifiedName()%>}*/ + /*{ implements <%=clazzifier.getQualifiedName()%>}*/ } ////////////////////////////////////////////////////////////////////// @@ -205,32 +209,31 @@ ////////////////////////////////////////////////////////////////////// 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 { + public <%=clazzifier.getName()%>Lazy(TopiaContext context, String _topiaId_, String version)throws TopiaException { super(context, _topiaId_, version); } - public <%=clazz.getName()%>Lazy(TopiaContext context, TopiaEntity entity) throws TopiaException { + public <%=clazzifier.getName()%>Lazy(TopiaContext context, TopiaEntity entity) throws TopiaException { super(context, entity); } - private <%=clazz.getName()%> getTypedEntity(){ - return (<%=clazz.getName()%>)getEntity(); + private <%=clazzifier.getName()%> getTypedEntity(){ + return (<%=clazzifier.getName()%>)getEntity(); } /** * Return entity Class managed by this service *) public Class getEntityClass(){ - return <%=clazz.getName()%>.class; + return <%=clazzifier.getName()%>.class; } /** * Retourne le persistenceService associé à cette entite. *) - private <%=clazz.getName()%>PersistenceService getPersistenceService()throws TopiaException { - <%=clazz.getName()%>PersistenceService persistenceService = getAppContext().get<%=clazz.getName()%>PersistenceService(); + private <%=clazzifier.getName()%>PersistenceService getPersistenceService()throws TopiaException { + <%=clazzifier.getName()%>PersistenceService persistenceService = getAppContext().get<%=clazzifier.getName()%>PersistenceService(); return persistenceService; } @@ -241,22 +244,24 @@ <%=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)) { + if (clazzifier instanceof ObjectModelClass) { + ObjectModelClass clazz = (ObjectModelClass)clazzifier; + 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{ + }else{ /*{ for(Iterator i=get<%=Util.capitalize(attribute.getName())%>().iterator(); i.hasNext(); ){ ((TopiaEntity)i.next()).setContext(context); } }*/ + } } } }