Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java:1.19 topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java:1.20 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java:1.19 Fri Aug 19 17:05:38 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java Thu Sep 22 14:50:05 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.19 $ + * @version $Revision: 1.20 $ * - * Mise a jour: $Date: 2005/08/19 17:05:38 $ + * Mise a jour: $Date: 2005/09/22 14:50:05 $ * par : $Author: thimel $ */ @@ -74,7 +74,7 @@ #context.helper.persistence.properties.file=<%=model.getName()%>JDOPersistenceHelper.properties #context.helper.distribution=org.codelutin.topia.distribution.LocalDistributionHelper -//Secuity Variables +#Secuity Variables topia.auth.loginEntry=<%=model.getName()%> topia.auth.type=simple topia.auth.simple.file.login=passwords.file Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java:1.18 topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java:1.19 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java:1.18 Fri Sep 2 17:18:51 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java Thu Sep 22 14:50:05 2005 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.18 $ + * @version $Revision: 1.19 $ * - * Mise a jour: $Date: 2005/09/02 17:18:51 $ - * par : $Author: bpoussin $ + * Mise a jour: $Date: 2005/09/22 14:50:05 $ + * par : $Author: thimel $ */ package org.codelutin.topia.generators; @@ -105,15 +105,16 @@ public void generateNormalAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { super.generateNormalAttributeDeclaration(output, attribute); if(currentClazz instanceof ObjectModelAssociationClass && - Util.isFirstAttribute(attribute) && - attribute.getReverseAttribute() != null){ + Util.isFirstAttribute(attribute) && + ((Util.isGeneratedAssociationClass(currentClazz)) || (attribute.hasAssociationClass())) + ){ /*{ - public <%=currentClazz.getName()%> findByAttributes(<%=attribute.getType()%> <%=attribute.getName()%>, <%=attribute.getReverseAttribute().getType()%> <%=attribute.getReverseAttribute().getName()%>) throws TopiaException { - List result = find(newQuery().where("<%=attribute.getName()%> = ? AND <%=attribute.getReverseAttribute().getName()%> = ?").addArg(<%=attribute.getName()%>).addArg(<%=attribute.getReverseAttribute().getName()%>)); + public <%=currentClazz.getName()%> findByAttributes(<%=attribute.getType()%> <%=attribute.getName()%>, <%=((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attribute.getDeclaringElement().getName())%>) throws TopiaException { + List<<%=currentClazz.getName()%>> result = find(newQuery().where("<%=attribute.getName()%> = ? AND <%=Util.toLowerCaseFirstLetter(attribute.getDeclaringElement().getName())%> = ?").addArg(<%=attribute.getName()%>).addArg(<%=Util.toLowerCaseFirstLetter(attribute.getDeclaringElement().getName())%>)); if(result.size() == 0){ return null; } - return (<%=currentClazz.getName()%>)result.get(0); + return result.get(0); } }*/ @@ -121,36 +122,49 @@ if(attribute.hasAssociationClass() && attribute.getReverseAttribute() != null){ - String associationClassName = attribute.getAssociationClass().getName(); /*{ /** * @return an entity *) public <%=currentClazz.getName()%> findBy<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException{ - TopiaQuery query = new TopiaQuery(); - query.select(<%=attribute.getReverseAttribute().getName()%>) +}*/ + if (!(currentClazz instanceof ObjectModelAssociationClass)) { +/*{ TopiaQuery query = new TopiaQuery(); + query.select("<%=attribute.getReverseAttribute().getName()%>") .from(<%=attribute.getAssociationClass().getQualifiedName()%>.class) - .where("<%=attribute.getName()%> = ?") +}*/ + } else { +/*{ TopiaQuery query = newQuery() +}*/ + } +/*{ .where("<%=attribute.getName()%> = ?") .limit(0,1) - .addArg(value)); - List result = getContext().getPersistenceHelper().find(query); + .addArg(value); + List<<%=currentClazz.getName()%>> result = find(query); if(result.size() == 0){ return null;/*throw new TopiaNotFoundException("Can't find object with attribute <%=attribute.getName()%> == " + value);*) } - return (<%=currentClazz.getName()%>)result.get(0); + return result.get(0); } /** * @return an unmodifiable collection *) public List<<%=currentClazz.getName()%>> findAllBy<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException{ - TopiaQuery query = new TopiaQuery(); - query.select(<%=attribute.getReverseAttribute().getName()%>) +}*/ + if (!(currentClazz instanceof ObjectModelAssociationClass)) { +/*{ TopiaQuery query = new TopiaQuery(); + query.select("<%=attribute.getReverseAttribute().getName()%>") .from(<%=attribute.getAssociationClass().getQualifiedName()%>.class) - .where("<%=attribute.getName()%> = ?") - .addArg(value)); - List<<%=currentClazz.getName()%>> result = (List<<%=currentClazz.getName()%>>)getContext().getPersistenceHelper().find(query); +}*/ + } else { +/*{ TopiaQuery query = newQuery() +}*/ + } +/*{ .where("<%=attribute.getName()%> = ?") + .addArg(value); + List<<%=currentClazz.getName()%>> result = find(query); return result; } @@ -161,21 +175,57 @@ * @return an entity *) public <%=currentClazz.getName()%> findBy<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException{ - List result = find(newQuery().where("<%=attribute.getName()%> = ?").limit(0,1).addArg(value)); + List<<%=currentClazz.getName()%>> result = find(newQuery().where("<%=attribute.getName()%> = ?").limit(0,1).addArg(value)); if(result.size() == 0){ return null;/*throw new TopiaNotFoundException("Can't find object with attribute <%=attribute.getName()%> == " + value);*) } - return (<%=currentClazz.getName()%>)result.get(0); + return result.get(0); } /** * @return an unmodifiable collection *) public List<<%=currentClazz.getName()%>> findAllBy<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException{ - return (List<<%=currentClazz.getName()%>>)find(newQuery().where("<%=attribute.getName()%> = ?").addArg(value)); + return find(newQuery().where("<%=attribute.getName()%> = ?").addArg(value)); } }*/ } + if(currentClazz instanceof ObjectModelAssociationClass && + ((Util.isGeneratedAssociationClass(currentClazz)) || (attribute.hasAssociationClass())) && + attribute.getReverseAttribute() == null ){ + //Pas de navigabilité +/*{ + /** + * @return an entity + *) + public <%=currentClazz.getName()%> findBy<%=Util.capitalize(attribute.getDeclaringElement().getName())%>(<%=((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName()%> value) throws TopiaException { + TopiaQuery query = newQuery() + .where("<%=Util.toLowerCaseFirstLetter(attribute.getDeclaringElement().getName())%> = ?") + .limit(0,1) + .addArg(value); + List<<%=currentClazz.getName()%>> result = find(query); + + if(result.size() == 0){ + return null;/*throw new TopiaNotFoundException("Can't find object with attribute <%=attribute.getName()%> == " + value);*) + } + return result.get(0); + } + + /** + * @return an unmodifiable collection + *) + public List<<%=currentClazz.getName()%>> findAllBy<%=Util.capitalize(attribute.getDeclaringElement().getName())%>(<%=((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName()%> value) throws TopiaException { + TopiaQuery query = newQuery() + .where("<%=Util.toLowerCaseFirstLetter(attribute.getDeclaringElement().getName())%> = ?") + .addArg(value); + List<<%=currentClazz.getName()%>> result = find(query); + + return result; + } +}*/ + + } + } public void generateEntityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { @@ -190,18 +240,18 @@ * @return an entity *) public <%=clazz.getName()%> findBy<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException { - List result = find(newQuery().where("<%=attribute.getName()%> = ?").addArg(value)); + List<<%=clazz.getName()%>> result = find(newQuery().where("<%=attribute.getName()%> = ?").addArg(value)); if(result.size() == 0){ return null;/*throw new TopiaNotFoundException("Can't find object with attribute <%=attribute.getName()%> == " + value);*) } - return (<%=clazz.getName()%>)result.get(0); + return result.get(0); } /** * @return an unmodifiable collection *) public List<<%=currentClazz.getName()%>> findAllBy<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> value) throws TopiaException{ - return (List<<%=currentClazz.getName()%>>)find(newQuery().where("<%=attribute.getName()%> = ?").addArg(value)); + return find(newQuery().where("<%=attribute.getName()%> = ?").addArg(value)); } }*/ } Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java:1.15 topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java:1.16 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java:1.15 Tue Aug 16 22:19:33 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java Thu Sep 22 14:50:05 2005 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.15 $ + * @version $Revision: 1.16 $ * - * Mise a jour: $Date: 2005/08/16 22:19:33 $ - * par : $Author: bpoussin $ + * Mise a jour: $Date: 2005/09/22 14:50:05 $ + * par : $Author: thimel $ */ package org.codelutin.topia.generators; @@ -106,13 +106,14 @@ public void generateNormalAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { if(currentClazz instanceof ObjectModelAssociationClass && - Util.isFirstAttribute(attribute) && - attribute.getReverseAttribute() != null){ + Util.isFirstAttribute(attribute) && + ((Util.isGeneratedAssociationClass(currentClazz)) || (attribute.hasAssociationClass())) + ){ /*{ /** * @return the instance of the associationClass associated with both given arguments *) - public <%=currentClazz.getName()%> findByAttributes(<%=attribute.getType()%> <%=attribute.getName()%>, <%=attribute.getReverseAttribute().getType()%> <%=attribute.getReverseAttribute().getName()%>) throws TopiaException; + public <%=currentClazz.getName()%> findByAttributes(<%=attribute.getType()%> <%=attribute.getName()%>, <%=((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attribute.getDeclaringElement().getName())%>) throws TopiaException; }*/ } @@ -126,8 +127,26 @@ /** * @return an unmodifiable collection *) - public List findAllBy<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> <%=attribute.getName()%>) throws TopiaException; + public List<<%=currentClazz.getName()%>> findAllBy<%=Util.capitalize(attribute.getName())%>(<%=attribute.getType()%> <%=attribute.getName()%>) throws TopiaException; }*/ + + if(currentClazz instanceof ObjectModelAssociationClass && + ((Util.isGeneratedAssociationClass(currentClazz)) || (attribute.hasAssociationClass())) && + attribute.getReverseAttribute() == null ){ + //Pas de navigabilité +/*{ + /** + * @return an entity + *) + public <%=currentClazz.getName()%> findBy<%=Util.capitalize(attribute.getDeclaringElement().getName())%>(<%=((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attribute.getDeclaringElement().getName())%>) throws TopiaException; + + /** + * @return an unmodifiable collection + *) + public List<<%=currentClazz.getName()%>> findAllBy<%=Util.capitalize(attribute.getDeclaringElement().getName())%>(<%=((ObjectModelClass)attribute.getDeclaringElement()).getQualifiedName()%> <%=Util.toLowerCaseFirstLetter(attribute.getDeclaringElement().getName())%>) throws TopiaException; +}*/ + + } } public void generateEntityAttributeDeclaration(Writer output, ObjectModelAttribute attribute) throws IOException { Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java:1.20 topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java:1.21 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java:1.20 Fri Sep 16 14:12:06 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityGenerator.java Thu Sep 22 14:50:05 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.20 $ + * @version $Revision: 1.21 $ * - * Mise a jour: $Date: 2005/09/16 14:12:06 $ + * Mise a jour: $Date: 2005/09/22 14:50:05 $ * par : $Author: thimel $ */ @@ -230,6 +230,19 @@ public <%=attribute.getType()%> get<%=Util.capitalize(attribute.getName())%>(int index) throws TopiaException; }*/ + if (attribute.hasAssociationClass()) { +/*{ + + /** + * @return a collection of association classes + *) + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, true, false)%> + public <%=Util.getAttributeType(attribute)%><<%=attribute.getAssociationClass().getQualifiedName()%>> get<%=Util.capitalize(attribute.getAssociationClass().getName())%>() throws TopiaException; + + <%=generateMethodInfo(MethodType.FIELD_ACCESSOR, false, attribute, true, false)%> + public <%=attribute.getAssociationClass().getQualifiedName()%> get<%=Util.capitalize(attribute.getAssociationClass().getName())%>(<%=attribute.getType()%> value) throws TopiaException; +}*/ + } } public void generateGetAssociationAttributeAccessor(Writer output, ObjectModelAttribute attribute)