Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java:1.12 topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java:1.13 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java:1.12 Thu Jul 21 17:10:38 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToContextPropertiesGenerator.java Fri Jul 22 16:57:57 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.12 $ + * @version $Revision: 1.13 $ * - * Mise a jour: $Date: 2005/07/21 17:10:38 $ + * Mise a jour: $Date: 2005/07/22 16:57:57 $ * par : $Author: thimel $ */ @@ -67,6 +67,8 @@ #context.helper.persistence.properties.file=<%=model.getName()%>JDOPersistenceHelper.properties context.helper.distribution=org.codelutin.topia.distribution.LocalDistributionHelper context.helper.hook=org.codelutin.topia.hook.DefaultHookHelper +context.helper.security=org.codelutin.topia.security.TopiaSecurityHelper +#context.helper.security.properties.file=<%=model.getName()%>Context.properties }*/ for(Iterator i=model.getClassifiers().iterator(); i.hasNext();){ Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToApplicationContextGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToApplicationContextGenerator.java:1.7 topia/src/java/org/codelutin/topia/generators/ObjectModelToApplicationContextGenerator.java:1.8 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToApplicationContextGenerator.java:1.7 Thu Jul 21 17:10:38 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToApplicationContextGenerator.java Fri Jul 22 16:57:57 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * - * Mise a jour: $Date: 2005/07/21 17:10:38 $ + * Mise a jour: $Date: 2005/07/22 16:57:57 $ * par : $Author: thimel $ */ @@ -33,20 +33,14 @@ import java.io.IOException; import java.io.Writer; -//import java.util.Hashtable; import java.util.Iterator; -import java.util.logging.Logger; import java.io.File; -import javax.security.auth.login.Configuration; - import org.codelutin.generator.Generator; 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; -import org.codelutin.topia.security.TopiaConfiguration; -import org.codelutin.topia.security.TopiaPolicy; public class ObjectModelToApplicationContextGenerator extends ObjectModelGenerator { // ObjectModelToApplicationContextGenerator @@ -71,6 +65,7 @@ import org.codelutin.topia.TopiaContextFactory; import org.codelutin.topia.TopiaException; import org.codelutin.topia.security.TopiaSecurityException; +import org.codelutin.topia.security.TopiaPrincipal; import java.util.Properties; import java.util.List; import java.util.logging.Logger; @@ -93,6 +88,10 @@ super(parentContext); } + public String getContextName() { + return "<%=model.getName()%>"; + } + /** * Donne le nom du fichier de propriété lu par defaut. *) @@ -174,7 +173,7 @@ /*{ // TODO Controls - protected List xmiAuthentication(String login, String password) throws TopiaSecurityException { + protected List xmiAuthentication(String login, String password) throws TopiaSecurityException { throw new TopiaSecurityException("xmiAuthentication not supported");}*/ //TODO Arno ;) /*{ } Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java:1.9 topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java:1.10 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java:1.9 Fri Jun 10 08:21:57 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceImplGenerator.java Fri Jul 22 16:57:57 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * - * Mise a jour: $Date: 2005/06/10 08:21:57 $ + * Mise a jour: $Date: 2005/07/22 16:57:57 $ * par : $Author: thimel $ */ @@ -80,15 +80,15 @@ *) public class <%=clazz.getName() + "PersistenceServiceImpl"%> extends }*/ if(clazz instanceof ObjectModelClass){ - Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); - if (i.hasNext()) { - ObjectModelClass superclass = (ObjectModelClass) i.next(); - /*{<%=superclass.getQualifiedName()%>PersistenceServiceImpl}*/ - }else{ - /*{AbstractTopiaPersistenceService}*/ - } +// Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); +// if (i.hasNext()) { +// ObjectModelClass superclass = (ObjectModelClass) i.next(); +// /*{<%=superclass.getQualifiedName()%>PersistenceServiceImpl}*/ +// }else{ + /*{AbstractTopiaPersistenceService<<%=clazz.getName()%>>}*/ +// } }else{ - /*{AbstractTopiaPersistenceService}*/ + /*{AbstractTopiaPersistenceService<<%=clazz.getName()%>>}*/ } /*{ implements <%=clazz.getName()%>PersistenceService}*/ @@ -125,6 +125,30 @@ generateNormalAttributeDeclaration(output, attribute); } + public void generateAllOtherAttributeDeclaration(Writer output, ObjectModelClass clazz) throws IOException { + for (Iterator it = clazz.getAllOtherAttributes().iterator(); it.hasNext(); ) { + ObjectModelAttribute attribute = (ObjectModelAttribute)it.next(); +/*{ + /** + * @return an entity + *) + public <%=clazz.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 (<%=clazz.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)); + } +}*/ + } + } ////////////////////////////////////////////////////////////////////// // O T H E R ////////////////////////////////////////////////////////////////////// @@ -132,46 +156,39 @@ public void generateOther(Writer output, ObjectModelClassifier clazzifier) throws IOException { if(clazzifier instanceof ObjectModelClass){ ObjectModelClass clazz = (ObjectModelClass)clazzifier; + generateAllOtherAttributeDeclaration(output, clazz); /*{ - /** - * Return the <%=clazz.getName()%> entity having the given topiaId - *) - public <%=clazz.getName()%> find<%=clazz.getName()%>By_TopiaId_(String topiaId) throws TopiaException { -}*/ // TODO Arno : Tester le topiaId avant de faire le find !!! -/*{ return (<%=clazz.getName()%>)getAppContext().getPersistenceHelper().findByTopiaId(topiaId); - } - - /** - * Return new entity - *) - public <%=clazz.getName()%> create<%=clazz.getName()%>() throws TopiaException { - <% if(((ObjectModelClass)clazz).isAbstract()){ %> - throw new TopiaException("Abstract entity can't be instanciate"); - <% } else { %> - return (<%=clazz.getName()%>)super.create(); - <% } %> - } - - public <%=clazz.getName()%> makePersistent(<%=clazz.getName()%> entity) throws TopiaException { - if (! (entity instanceof <%=clazz.getName()%>)) { - throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); - } - return (<%=clazz.getName()%>)super.makePersistent(entity); - } - - public <%=clazz.getName()%> update(<%=clazz.getName()%> entity) throws TopiaException { - if (! (entity instanceof <%=clazz.getName()%>)) { - throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); - } - return (<%=clazz.getName()%>)super.update(entity); - } - - public void delete(<%=clazz.getName()%> entity) throws TopiaException { - if (! (entity instanceof <%=clazz.getName()%>)) { - throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); - } - super.delete(entity); - } +// /** +// * Return new entity +// *) +// public <%=clazz.getName()%> create<%=clazz.getName()%>() throws TopiaException { +// <% if(((ObjectModelClass)clazz).isAbstract()){ %> +// throw new TopiaException("Abstract entity can't be instanciate"); +// <% } else { %> +// return (<%=clazz.getName()%>)super.create(); +// <% } %> +// } +// +// public <%=clazz.getName()%> makePersistent(<%=clazz.getName()%> entity) throws TopiaException { +// if (! (entity instanceof <%=clazz.getName()%>)) { +// throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); +// } +// return (<%=clazz.getName()%>)super.makePersistent(entity); +// } +// +// public <%=clazz.getName()%> update(<%=clazz.getName()%> entity) throws TopiaException { +// if (! (entity instanceof <%=clazz.getName()%>)) { +// throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); +// } +// return (<%=clazz.getName()%>)super.update(entity); +// } +// +// public void delete(<%=clazz.getName()%> entity) throws TopiaException { +// if (! (entity instanceof <%=clazz.getName()%>)) { +// throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); +// } +// super.delete(entity); +// } /** * Return entity Class managed by this service @@ -188,37 +205,21 @@ return context; } - protected String [] fielNames = new String[]{ - <% for(Iterator i=clazz.getAttributes().iterator(); i.hasNext();){ %> - "<%=((ObjectModelAttribute)i.next()).getName()%>", - <% } %> - <% for(Iterator i=clazz.getAllOtherAttributes().iterator(); i.hasNext();){ %> - "<%=((ObjectModelAttribute)i.next()).getName()%>", - <% } %> - }; + protected String [] fieldNames = new String[] { +}*/ + for (Iterator it = clazz.getAttributes().iterator(); it.hasNext(); ) { +/*{ "<%=((ObjectModelAttribute)it.next()).getName()%>", +}*/ + } + for (Iterator it = clazz.getAllOtherAttributes().iterator(); it.hasNext(); ) { +/*{ "<%=((ObjectModelAttribute)it.next()).getName()%>", +}*/ + } +/*{ }; public String [] getFieldNames(){ - return fielNames; + return fieldNames; } - - /** - * Return the <%=clazz.getName()%> corresponding to the given XML representation - *) -}*/ -// TODO Arno : A verif ac Cédric ! - Iterator it = ((ObjectModelClass)clazz).getSuperclasses().iterator(); - String out = clazz.getName(); - if (it.hasNext()) - out = ((ObjectModelClass)it.next()).getName(); -/*{ -/* public <%=clazz.getName()%> fromXML(String entityXML) throws TopiaException { - TopiaEntity entity =(<%=clazz.getName()%>) <%=getProperty("defaultPackage")%>.<%=model.getName()%>EntitiesHelper.fromXML(entityXML); - if (! (entity instanceof <%=clazz.getName()%>)) { - throw new TopiaException("Wrong persistence service. You should use the entity related persistence service"); - } - return (<%=clazz.getName()%>) entity; - } -*) }*/ } else { ObjectModelInterface interfacz = (ObjectModelInterface)clazzifier; Index: topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java diff -u topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java:1.10 topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java:1.11 --- topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java:1.10 Fri Jun 10 08:21:57 2005 +++ topia/src/java/org/codelutin/topia/generators/ObjectModelToEntityPersistenceServiceGenerator.java Fri Jul 22 16:57:57 2005 @@ -23,9 +23,9 @@ * * @author Benjamin Poussin * Copyright Code Lutin - * @version $Revision: 1.10 $ + * @version $Revision: 1.11 $ * - * Mise a jour: $Date: 2005/06/10 08:21:57 $ + * Mise a jour: $Date: 2005/07/22 16:57:57 $ * par : $Author: thimel $ */ @@ -72,19 +72,19 @@ /** <%=clazz.getDocumentation()%> *) -public interface <%=clazz.getName()%>PersistenceService extends TopiaPersistenceService}*/ - for (Iterator i = clazz.getInterfaces().iterator(); i.hasNext();) { - ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); - if (Util.isEntity(interfacezz)) { -/*{, <%=interfacezz.getQualifiedName()%>PersistenceService }*/ - } - } - if(clazz instanceof ObjectModelClass){ - for (Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); i.hasNext();) { - ObjectModelClass superclass = (ObjectModelClass) i.next(); -/*{, <%=superclass.getQualifiedName()%>PersistenceService}*/ - } - } +public interface <%=clazz.getName()%>PersistenceService extends TopiaPersistenceService<<%=clazz.getName()%>>}*/ +// for (Iterator i = clazz.getInterfaces().iterator(); i.hasNext();) { +// ObjectModelInterface interfacezz = (ObjectModelInterface) i.next(); +// if (Util.isEntity(interfacezz)) { +///*{, <%=interfacezz.getQualifiedName()%>PersistenceService }*/ +// } +// } +// if(clazz instanceof ObjectModelClass){ +// for (Iterator i=((ObjectModelClass)clazz).getSuperclasses().iterator(); i.hasNext();) { +// ObjectModelClass superclass = (ObjectModelClass) i.next(); +///*{, <%=superclass.getQualifiedName()%>PersistenceService}*/ +// } +// } } ////////////////////////////////////////////////////////////////////// @@ -125,27 +125,18 @@ public void generateOther(Writer output, ObjectModelClassifier clazz) throws IOException { if(clazz instanceof ObjectModelClass){ /*{ - public <%=clazz.getName()%> find<%=clazz.getName()%>By_TopiaId_(String topiaId) throws TopiaException; - /** * Return new entity *) - public <%=clazz.getName()%> create<%=clazz.getName()%>() throws TopiaException; +/* public <%=clazz.getName()%> create() throws TopiaException; public <%=clazz.getName()%> makePersistent(<%=clazz.getName()%> entity) throws TopiaException; - /** - * Return the <%=clazz.getName()%> corresponding to the given XML representation - *)}*/ -//TODO Arno : A verif ac Cédric ! - Iterator it = ((ObjectModelClass)clazz).getSuperclasses().iterator(); - String out = clazz.getName(); - if (it.hasNext()) - out = ((ObjectModelClass)it.next()).getName(); -/*{ -// public <%=clazz.getName()%> fromXML(String entityXML) throws TopiaException; -}*/ + public <%=clazz.getName()%> update(<%=clazz.getName()%> entity) throws TopiaException; + public void delete(<%=clazz.getName()%> entity) throws TopiaException; +*) +}*/ } }